mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 23:40:35 -05:00
Working: Non solution to fuproblem
This commit is contained in:
parent
f706dd6763
commit
af9c68a2c3
1 changed files with 18 additions and 12 deletions
|
@ -30,9 +30,15 @@ $(document).ready(function () {
|
||||||
$(div).load(buildPath + 'Squire-UI.html', function() {
|
$(div).load(buildPath + 'Squire-UI.html', function() {
|
||||||
$('.item').click(function() {
|
$('.item').click(function() {
|
||||||
var me = $(this);
|
var me = $(this);
|
||||||
|
var s = SquireUI;
|
||||||
var iFrame = me.parents('.Squire-UI').next('iframe').first()[0];
|
var iFrame = me.parents('.Squire-UI').next('iframe').first()[0];
|
||||||
var editor = iFrame.contentWindow.editor;
|
var editor = iFrame.contentWindow.editor;
|
||||||
console.log(SquireUI.isBold(editor));
|
var test = (me.data('action') == ('bold' | 'italic' | 'underline' | 'link'));
|
||||||
|
|
||||||
|
if (test && s.isBold(editor)) { editor.removeBold() };
|
||||||
|
me.data('action') == 'italic' && s.isItalic(editor)) editor.removeItalic();
|
||||||
|
me.data('action') == 'underline' && s.isUnderlined(editor)) editor.removeUnderline();
|
||||||
|
me.data('action') == 'link' && s.isLink(editor)) editor.removeLink();
|
||||||
|
|
||||||
editor[me.data('action')](me.data('value'));
|
editor[me.data('action')](me.data('value'));
|
||||||
});
|
});
|
||||||
|
@ -45,13 +51,13 @@ $(document).ready(function () {
|
||||||
return iframe.contentWindow.editor;
|
return iframe.contentWindow.editor;
|
||||||
};
|
};
|
||||||
|
|
||||||
SquireUI.isBold = function (editor) { return this.isPresent( 'B', ( />B\b/ ), editor ); };
|
SquireUI.isBold = function (editor) { return (this.isPresent( 'B', ( />B\b/ ), editor )); };
|
||||||
SquireUI.isItalic = function (editor) { return isPresent( 'I', ( />I\b/ ), editor ); };
|
SquireUI.isItalic = function (editor) { return (isPresent( 'I', ( />I\b/ ), editor )); };
|
||||||
SquireUI.isUnderlined = function (editor) { return isPresent( 'U', ( />U\b/ ), editor); };
|
SquireUI.isUnderlined = function (editor) { return (isPresent( 'U', ( />U\b/ ), editor)); };
|
||||||
SquireUI.isStriked = function (editor) { return isPresent( 'S', ( />S\b/ ), editor ); };
|
SquireUI.isStriked = function (editor) { return (isPresent( 'S', ( />S\b/ ), editor )); };
|
||||||
SquireUI.isLink = function (editor) { return isPresent( 'A', ( />A\b/ ), editor ); };
|
SquireUI.isLink = function (editor) { return (isPresent( 'A', ( />A\b/ ), editor )); };
|
||||||
SquireUI.isPresent = function (format, validation, editor) {
|
SquireUI.isPresent = function (format, validation, editor) {
|
||||||
var path = editor.getPath();
|
var path = editor.getPath();
|
||||||
return validation.test(path);
|
return validation.test(path) | editor.hasFormat(format);
|
||||||
};
|
};
|
||||||
});
|
});
|
Loading…
Reference in a new issue