mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Make bold etc. work in demo without requiring text selection.
This commit is contained in:
parent
9e3fa11d4c
commit
2a3dbe1b1c
4 changed files with 27 additions and 24 deletions
|
@ -36,7 +36,7 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
iframe {
|
iframe {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: 1px #919191 solid;
|
border: 1px #919191 solid;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
-webkit-border-radius: 4px;
|
-webkit-border-radius: 4px;
|
||||||
|
@ -50,13 +50,14 @@ iframe {
|
||||||
outline: none;
|
outline: none;
|
||||||
box-shadow: inset 0 1px 2px rgba(0,0,0,0.075);
|
box-shadow: inset 0 1px 2px rgba(0,0,0,0.075);
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu .item {
|
.menu .item {
|
||||||
color:#000;
|
color:#000;
|
||||||
float:left;
|
float:left;
|
||||||
background:#FFF;
|
background:#FFF;
|
||||||
padding:10px;
|
padding:10px;
|
||||||
border-left:1px #EEE solid;
|
border-left:1px #EEE solid;
|
||||||
|
border-bottom: 3px transparent solid;
|
||||||
-webkit-font-smoothing:subpixel-antialiased
|
-webkit-font-smoothing:subpixel-antialiased
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ input[type=text] {
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu .group .item:hover, .menu .item:first-child:hover {
|
.menu .group .item:hover, .menu .item:first-child:hover {
|
||||||
border-left: 3px #55ACEE solid;
|
border-bottom: 3px #55ACEE solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu .item:first-child {
|
.menu .item:first-child {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -36,7 +36,7 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
iframe {
|
iframe {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: 1px #919191 solid;
|
border: 1px #919191 solid;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
-webkit-border-radius: 4px;
|
-webkit-border-radius: 4px;
|
||||||
|
@ -50,13 +50,14 @@ iframe {
|
||||||
outline: none;
|
outline: none;
|
||||||
box-shadow: inset 0 1px 2px rgba(0,0,0,0.075);
|
box-shadow: inset 0 1px 2px rgba(0,0,0,0.075);
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu .item {
|
.menu .item {
|
||||||
color:#000;
|
color:#000;
|
||||||
float:left;
|
float:left;
|
||||||
background:#FFF;
|
background:#FFF;
|
||||||
padding:10px;
|
padding:10px;
|
||||||
border-left:1px #EEE solid;
|
border-left:1px #EEE solid;
|
||||||
|
border-bottom: 3px transparent solid;
|
||||||
-webkit-font-smoothing:subpixel-antialiased
|
-webkit-font-smoothing:subpixel-antialiased
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ input[type=text] {
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu .group .item:hover, .menu .item:first-child:hover {
|
.menu .group .item:hover, .menu .item:first-child:hover {
|
||||||
border-left: 3px #55ACEE solid;
|
border-bottom: 3px #55ACEE solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu .item:first-child {
|
.menu .item:first-child {
|
||||||
|
|
|
@ -61,7 +61,7 @@ $(document).ready(function() {
|
||||||
$('.quit').unbind().click(function () {
|
$('.quit').unbind().click(function () {
|
||||||
$(this).parent().parent().removeClass('drop-open');
|
$(this).parent().parent().removeClass('drop-open');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.sumbitImageURL').unbind().click(function () {
|
$('.sumbitImageURL').unbind().click(function () {
|
||||||
console.log("Passed through .sumbitImageURL");
|
console.log("Passed through .sumbitImageURL");
|
||||||
var editor = iframe.contentWindow.editor;
|
var editor = iframe.contentWindow.editor;
|
||||||
|
@ -90,7 +90,7 @@ $(document).ready(function() {
|
||||||
var selectedFonts = $('select#fontSelect option:selected').last().data('fonts');
|
var selectedFonts = $('select#fontSelect option:selected').last().data('fonts');
|
||||||
var fontSize = $('select#textSelector option:selected').last().data('size') + 'px';
|
var fontSize = $('select#textSelector option:selected').last().data('size') + 'px';
|
||||||
editor.setFontSize(fontSize);
|
editor.setFontSize(fontSize);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
editor.setFontFace(selectedFonts);
|
editor.setFontFace(selectedFonts);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -98,17 +98,17 @@ $(document).ready(function() {
|
||||||
} finally {
|
} finally {
|
||||||
$(this).parent().parent().removeClass('drop-open');
|
$(this).parent().parent().removeClass('drop-open');
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.item').click(function() {
|
$('.item').click(function() {
|
||||||
var iframe = $(this).parents('.Squire-UI').next('iframe').first()[0];
|
var iframe = $(this).parents('.Squire-UI').next('iframe').first()[0];
|
||||||
var editor = iframe.contentWindow.editor;
|
var editor = iframe.contentWindow.editor;
|
||||||
var action = $(this).data('action');
|
var action = $(this).data('action');
|
||||||
|
|
||||||
test = {
|
test = {
|
||||||
value: $(this).data('action'),
|
value: $(this).data('action'),
|
||||||
testBold: editor.testPresenceinSelection('bold',
|
testBold: editor.testPresenceinSelection('bold',
|
||||||
|
@ -143,18 +143,18 @@ $(document).ready(function() {
|
||||||
} else if (test.isNotValue('makeLink') | test.isNotValue('insertImage') | test.isNotValue('selectFont')) {
|
} else if (test.isNotValue('makeLink') | test.isNotValue('insertImage') | test.isNotValue('selectFont')) {
|
||||||
// do nothing these are dropdowns.
|
// do nothing these are dropdowns.
|
||||||
} else {
|
} else {
|
||||||
if (editor.getSelectedText() === '' && !(action == 'insertImage' || action == 'makeOrderedList' || action == 'increaseQuoteLevel' || action == 'redo' || action == 'undo')) return;
|
|
||||||
editor[action]();
|
editor[action]();
|
||||||
|
editor.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(container).append(div);
|
$(container).append(div);
|
||||||
$(container).append(iframe);
|
$(container).append(iframe);
|
||||||
|
|
||||||
var style = document.createElement('style');
|
var style = document.createElement('style');
|
||||||
style.innerHTML = 'blockquote { border-left: 3px green solid; padding-left: 5px; }';
|
style.innerHTML = 'blockquote { border-left: 3px green solid; padding-left: 5px; }';
|
||||||
|
|
||||||
|
|
||||||
iframe.contentWindow.editor = new Squire(iframe.contentWindow.document);
|
iframe.contentWindow.editor = new Squire(iframe.contentWindow.document);
|
||||||
iframe.addEventListener('load', function() {
|
iframe.addEventListener('load', function() {
|
||||||
|
@ -164,4 +164,4 @@ $(document).ready(function() {
|
||||||
iframe.contentWindow.document.head.appendChild(style);
|
iframe.contentWindow.document.head.appendChild(style);
|
||||||
return iframe.contentWindow.editor;
|
return iframe.contentWindow.editor;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue