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