HierarchyRequestError: Errors using toolbar commands for styling of Wysihtml5x editor - wysihtml5

I'm using the wysihtml5x editor (v0.4.12) and I have found an issue when double-clicking on the toolbar link to change the font colour of the text.
I have prepared a jsFiddle with a very minimalistic code that reproduces the problem.
var editor = new wysihtml5.Editor("wysihtml5-editor", {
toolbar: "wysihtml5-toolbar",
parserRules: wysihtml5ParserRules,
contentEditableMode: false
});
var editor2 = new wysihtml5.Editor("wysihtml5-editor2", {
toolbar: "wysihtml5-toolbar2",
parserRules: wysihtml5ParserRules,
contentEditableMode: false
});
div[contenteditable="true"] {
border: solid grey 1px;
height: 150px;
}
.wysiwyg-color-red {
color: red;
}
.wysiwyg-color-black {
color: black;
}
a[data-wysihtml5-command-value="red"] {
color: red;
text-decoration: none;
}
a[data-wysihtml5-command-value="black"] {
color: black;
text-decoration: none;
}
<script src="https://rawgit.com/Voog/wysihtml5/textcolor/parser_rules/advanced_unwrap.js"></script>
<script src="https://rawgit.com/Voog/wysihtml/0.4.12/dist/wysihtml5x-toolbar.js"></script>
<link href="https://github.com/Voog/wysihtml/blob/0.4.12/examples/css/stylesheet.css" rel="stylesheet" />
<div id="wysihtml5-editor" contenteditable="true"><span class="wysiwyg-color-red">Please follow these steps to reproduce the problem:</span>
<br>1.Click on the editor below just to give focus to it.
<br>2.Select all the text on the first editor (CTRL+A or using the mouse).
<br>3.Double click on <span class="wysiwyg-color-red">red</span> link toolbar of the first editor.
<br>4.Open the console to see the error (F12).
<br>5.You should be able to see the <span class="wysiwyg-color-red">Uncaught HierarchyRequestError:</span>
<br>6.Ignore the 'Discontiguous selection is not supported.' error.</div>
<div id="wysihtml5-toolbar" style="display: none;"> <a data-wysihtml5-command="foreColor" data-wysihtml5-command-value="black">black</a>
<a data-wysihtml5-command="foreColor" data-wysihtml5-command-value="red">red</a>
</div>
<div id="wysihtml5-editor2" contenteditable="true"><span class="wysiwyg-color-red">The</span> quick brown fox jumps over the lazy dog</div>
<div id="wysihtml5-toolbar2" style="display: none;"> <a data-wysihtml5-command="foreColor" data-wysihtml5-command-value="black">black</a>
<a data-wysihtml5-command="foreColor" data-wysihtml5-command-value="red">red</a>
</div>
The error that can be seen on console when following the steps provided on jsFiddle:
Uncaught HierarchyRequestError: Failed to execute 'appendChild' on 'Node': Only one element on document allowed.
I have tested with the latest version of the Wysihtml5x editor and the same problem happens. Please ignore the Discontiguous selection is not supported. error as this is an issue that have been addressed already on latest version of the editor.
I am not sure if this error happens only with multiple editors, but I added two as it is what I used when I found the problem.
I have opened the issue on the Git Issue Tracker of the project.
It may be related to the issue opened on Xing base repository of this editor.
I could not reproduce the error on Firefox 37.0.2 which makes me think that it does not happen on Firefox.
Your help is much appreciated, thanks.

This problem has been resolved on version 0.5.2. All of them, including the 'Discontiguous selection is not supported.'
Thank you very much #oliver-pulges for pointing out the solution replying to the GitHub issue.

Related

Text Popups OnMouseOvers, No WeaselOvers Allowed

Jeopardy: "a gimmick to separate it from other quiz and game shows. Because the prompt is the answer!"
This weaselly question appears to be OK, .. But what a terrible coding (Hole) I've dug for myself in the process.
I have a problem, in that I want to create several sets of:-
-- [ div text popup rollovers ]
-- [ that appear and disappear again ], but only when a mouse goes into, and then out of an <a href link, as in:-
<a href="#"
onmouseover=show('popup1')
onmouseout=hide('popup1')>Help Text One</a>
<br /><br /><br />
<a href="#"
onmouseover=show('popup2')
onmouseout=hide('popup2')>Help Text Two</a>
This weasel is an insidious creature to track down, being as all the other weasels are far too clever by half, and for the life of me I couldn't see what was really happening as the other weasels were running: nor even where the Ron Weaselly code went in my Harried Pottering Code.
This website has helped me so many times in the past, that I wanted to give a [ pop-goes-the-weasel ] back to future generations.
The answer to my rollover weasels is found here, that also has a rider attached:-
"It’s also perfectly fine to ask and answer your own question, as long as you pretend you’re on Jeopardy! — phrase it in the form of a question."
Here's the [ text rollover popup solution ] that I end up with, and this was after a day and a half of mumbling to myself and re-editing on codepen.io, then mumbling some more to get the simple coded weasel to popup on command.
Note: the resulting rollover code doesn't look that impressive, but it works. My issue now is whether it could made to work even better, and be made even simpler without me getting lost in the Triwizard Maze, populated by popping weasels of course.
Not sure if codebase.io examples are allowed here, being as all of the demonstrations I've seen thus far are in (fiddle.)
So I've created a fiddle account for you knowledgeable folks to give it the once over.
** Note: I've also magicked up a rather helpful line of helpful text: that actually gets changed by JS, to then reflect the state of the variables going (on) in the JavaScript section, the (alert) popup kept stopping the code from working.
The weaselly fiddly link is as follows:-
https://jsfiddle.net/terrymcb/4gL0ntvs/
Here's the HTML code, three blind rollover links that correspond to three divs, that are individually nested.
<p>DIV BOX ROLLOVERS</p>
<a href="#"
onmouseover=javascript:show('gcinfo')
onmouseout=javascript:hide('gcinfo')>TEXT-1</a> JS-1
<br /><br /><br />
<a href="#"
onmouseover=javascript:show('ucinfo')
onmouseout=javascript:hide('ucinfo')>TEXT-2</a> JS-2
<br /><br /><br />
<a href="#"
onmouseover=javascript:show('uainfo')
onmouseout=javascript:hide('uainfo')>TEXT-3</a> JS-3
<br /><br />
<p id="tValue"> Show in-out OBJ value. </p>
Here's the DIVS laid out.
<div id="ucinfo"><!-- which is hidden -->
<div class="dialog"><!-- is the common style -->
<p>This is the ucinfo included text.</p>
</div>
</div>
<div id="uainfo"><!-- which is hidden -->
<div class="dialog"><!-- is the common style -->
<p>This is the uainfo included text.</p>
</div>
</div>
<div id="gcinfo"><!-- which is hidden -->
<div class="dialog"><!-- is the common style -->
<p>This is gcinfo included text.</p>
</div>
</div>
The CSS, dialog box followed by three outer classes: (visible & display?) Over kill perhaps.
.dialog {
position: fixed;
top: 50px;
right: 50px;
bottom: 50px;
left: 150px;
z-index: 10;
display: flex;
padding: 1em;
background-color: rgba(0,0,0,.100);
/* opacity: 1; */
pointer-events: pointer;
transition: .25s ease-out;
}
#uainfo {
visibility: hidden;
display: none;
}
#ucinfo {
visibility: hidden;
display: none;
}
#gcinfo {
visibility: hidden;
display: none;
}
The all important JavaScript, note: I've cleaned the variables on every call, it seems to keep the function functioning, but I might well be paranoid at this point where JS is concerned. What I do know for a fact, is that calling the document.getElementById( direct keeps failing with the second call to JS, and I've no idea why! - Which is why the variables disp and vist have been used.
function hide(obj) {
disp0 = '0';
visp0 = '0';
disp0 = document.getElementById(obj);
visp0 = document.getElementById(obj);
disp0.style.display="none";
visp0.style.visibility="hidden";
document.getElementById("tValue").innerText='hide ' + obj;
}
function show(obj) {
disp1 = '0';
visp1 = '0';
disp1 = document.getElementById(obj);
visp1 = document.getElementById(obj);
disp1.style.display="block";
visp1.style.visibility="visible";
document.getElementById("tValue").innerText='show ' + obj;
}
That's all folks ..

helpful focus overlay in bootstrap

we use Material Showcase in iOS and FancyShowCaseView in Android to provide tutorial-esque
Reveal animations
Focus user on a specific view or position
Is there anything we can use for bootstrap that would do the same? We had (in desperation) looked at modal popovers but they didn't really work well.
If it's jquery compatible it is still fine.
We'd like to simply pass a div and give it "focus" and have access to some sort of dismiss callback.
Does anyone have any experience of this sort of product?
I'n not super familiar with the two showcases you mentioned, but animations are possible with bootstrap and JQuery, with a wide variety of possibilities. I'll list a few I know of below.
Pure CSS
Pure CSS Animations the most basic, but not always very elegant.
More complex CSS
This example shows how to get a simple attention getting blink animation. It may be enlightening on how to make more complex CSS animations:
The HTML:
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row">
<div class="container">
<div class="row">
<a href="#" class="intro-banner-vdo-play-btn pinkBg" target="_blank">
<i class="glyphicon glyphicon-play whiteText" aria-hidden="true"></i>
<span class="ripple pinkBg"></span>
<span class="ripple pinkBg"></span>
<span class="ripple pinkBg"></span>
</a>
</div>
</div>
</div>
The CSS:
.pinkBg {
background-color: #ed184f!important;
background-image: linear-gradient(90deg, #fd5581, #fd8b55);
}
.intro-banner-vdo-play-btn{
height:60px;
width:60px;
position:absolute;
top:50%;
left:50%;
text-align:center;
margin:-30px 0 0 -30px;
border-radius:100px;
z-index:1
}
.intro-banner-vdo-play-btn i{
line-height:56px;
font-size:30px
}
.intro-banner-vdo-play-btn .ripple{
position:absolute;
width:160px;
height:160px;
z-index:-1;
left:50%;
top:50%;
opacity:0;
margin:-80px 0 0 -80px;
border-radius:100px;
-webkit-animation:ripple 1.8s infinite;
animation:ripple 1.8s infinite
}
#-webkit-keyframes ripple{
0%{
opacity:1;
-webkit-transform:scale(0);
transform:scale(0)
}
100%{
opacity:0;
-webkit-transform:scale(1);
transform:scale(1)
}
}
#keyframes ripple{
0%{
opacity:1;
-webkit-transform:scale(0);
transform:scale(0)
}
100%{
opacity:0;
-webkit-transform:scale(1);
transform:scale(1)
}
}
.intro-banner-vdo-play-btn .ripple:nth-child(2){
animation-delay:.3s;
-webkit-animation-delay:.3s
}
.intro-banner-vdo-play-btn .ripple:nth-child(3){
animation-delay:.6s;
-webkit-animation-delay:.6s
}
MD Bootstrap Library
The MD Bootstrap Library has more complex animations that are easy to use and require less code to get functional than pure CSS animations. The Attention Seeker animations seem most similar to some of what I saw on a quick search for Material Showcase. The link above has lots of examples on one page so you can see what kind of behaviors are supported.
UI Cookies
This site also has many free and licensed examples of bootstrap animations that are even more complex.

What does VS Code's setting html.format.unformatted do?

I'm trying to figure out what the VS Code html.format.unformatted setting does, but I can't.
I've found this issue and this issue in GitHub, but it explains nothing.
Can someone please explain to me what the html.format.unformatted setting does and how it differs from the html.format.contentUnformatted setting?
After much trial and error i found out this:
TLDR:
html.format.unformatted: does not format the tag itself nor the content
html.format.contentUnformatted: will format the tag but not the content
source (not very clear, imho): https://code.visualstudio.com/Docs/languages/html
Sample html code (not valid, i know, but irrelevant here):
<body>
<style class="foo" class="foo" class="foo" >
.foo {
background-image: 'bar.jpeg';
background-size: cover;
background-position-x: 50%;
background-position-y: 50%;
}
</style>
<div class="foo">
<div>
<div></div>
whatever
<div></div>
</div>
</div>
</body>
With this config:
{
"html.format.wrapAttributes": "force-expand-multiline",
//"html.format.contentUnformatted" : "style",
"html.format.unformatted": "style"
}
When we trigger an auto format on the sample html above, the STYLE TAG IS NOT formatted and the style tag content IS NOT changed.
With this config:
{
"html.format.wrapAttributes": "force-expand-multiline",
"html.format.contentUnformatted" : "style",
//"html.format.unformatted": "style"
}
When we trigger an auto format on the sample html above, the STYLE TAG IS formatted (spaces, ident, etc), the style tag content IS NOT changed.

Change border color of required Chosen jQuery select boxes

Simply put, how can you change the border color of a Chosen jQuery select box? I am assuming you can do it with CSS but I can't quite figure out how.
$(".pnChosen").chosen({
search_contains: true
});
<select required class="pnChosen"></select>
I can use this to change the border color of all of them, but I only want to change ones that I mark as required.
.chosen-container{
border: 1px solid red;
}
And I also want to change the background color when they are disabled if that is possible.
You can use chosen's option inherit_select_classes.
Give required class on select element, and set css for this selector .required>chosen-single
$(".pnChosen").chosen({
search_contains: true,
inherit_select_classes: true
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.jquery.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.css" rel="stylesheet" />
<style>
.required>.chosen-single {
border: 1px solid #EE0000;
}
</style>
<select required class="pnChosen required">
<option>Option 1</option>
<option>Option 2</option>
</select>
Another option is to use the adjacent sibling combinator (+) selector in CSS to achieve the desired styling.
For example:
HTML
<select id="myselect" required="required">
...
</select>
<div id="myselect_chosen" class="chosen-container chosen-container-single">
<a class="chosen-single">
...
</a>
</div>
CSS
select:required + div.chosen-container a { ... }
This would apply the desired style(s) to your div.chosen-container a DOM element immediately following select:required. Just be aware that you may still have to establish CSS priority if you're attempting to override an existing Chosen style so your definitions can supersede any existing chosen styles.
Reference: Adjacent Sibling Combinator

jQuery Click on next element

I have a problem with programming jQuery and I hope that you can help me even if a speak english like an alien %).
I'm doing a site with horizontal scrolling, you can see it here http://www.kinetics.ru/index_kin.html
I have a menu at the left and two buttons PREV and NEXT at the bottom.
Menu is working correctly, but I need to let the bottom buttons work.
By clicking for example on NEXT I need that code made a click on next menu btn after the one that have style 'on'.
The code is:
<div class="menu">
<ul class="nav">
<li id="main"><img src="img/menu/about.png" /></li>
<li><img src="img/menu/uslugi.png"/></li>
<li><img src="img/menu/portfolio.png"/></li>
<li><img src="img/menu/clients.png"/></li>
<li><img src="img/menu/contacts.png"/></li>
</ul>
</div>
...
<div class="bottomNav" style="position: absolute; z-index: 11">
<div style="height: 26px; width:98px; margin:-75px 0 0 500px; position: fixed" class="back"><img src="img/back.png"</div>
<div style="height: 26px; width:114px; margin:-25px 0 0 600px; position: fixed" id="next"><img src="img/forward.png"</div>
And my not working jQuery code for next btn:
$('bottomNav, #next img').click(function(){
if ($('ul.nav').find('img').hasClass('on')){
$('ul.nav').next().click();
}
});
Also I've tried to do like this:
$('bottomNav, #next img').click(function(){
$('ul.nav img').click(function(){
if ($(this).hasClass('on')){
$(this).next().click();}
});
});
P.S. Sorry for my noobish question. I just got a task at work to make a site and nobody cares that a designer is NOT the same as web-designer. I have no possibility to learn first, I have to learn and do at same time.
You have to review jQuery selectors and as well your HTML code, it's terribly wrong. Firebug says:
I modified your code in proper way:
<div class="bottomNav" style="position: absolute; z-index: 11">
<div id="prev" style="height: 26px; width:98px; margin:-75px 0 0 500px; position: fixed">
<img src="img/back.png" />
</div>
<div id="next" style="height: 26px; width:114px; margin:-25px 0 0 600px; position: fixed" >
<img src="img/forward.png" />
</div>
</div>
JavaScript (It's pretty simple and I didn't test it, but it should give you an idea).
$('#prev').click(function () {
var $activeLi = getActiveLi();
var $prevLi = $parentLi.prev();
if ($prevLi.length > 0) {
$prevLi.find('a').click();
}
});
$('#next').click(function () {
var $activeLi = getActiveLi();
var $nextLi = $parentLi.next();
if ($nextLi.length > 0) {
$nextLi.find('a').click();
}
});
function getActiveLi() {
var $activeImg = $('.menu .nav img.on');
var $activeLi = $activeImg.closest('li');
return $activeLi;
};
But beeing seriously: before continuing developing your web site you seriously should put some effort in learnin hot to use jQuery and how to structure HTML...
Solved!
Thank you again!
Your code was really helpfull.
I have modified it a little bit for my needs and also changed in line
var $activeLi = $activeImg.closest('li');
closest('li') to parents('li'), cause it wasn't working like that.
So now code looks like this:
$('#prev').click(function () {
var $prevLi = getActiveLi().prev();
if ($prevLi.length > 0){$prevLi.find('img').click();}
});
$('#next').click(function () {
var $nextLi = getActiveLi().next();
if ($nextLi.length > 0){$nextLi.find('img').click();}
});
function getActiveLi() {
var $activeImg = $('.menu .nav img.on');
var $activeLi = $activeImg.parents('li');
return $activeLi;
};
Also i guess, that i have understood why firebug was showing so big disaster in code... i have forgot to close the tag :)))
Anyway...MANY THANKS TO YOU!
P.S. third day reading a giant book about jQuery :)