0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 15:23:29 -05:00

Working: Non solution to fuproblem

This commit is contained in:
Matthew Borden 2014-07-08 23:43:58 +10:00
parent f706dd6763
commit af9c68a2c3

View file

@ -29,11 +29,17 @@ $(document).ready(function () {
$(div).load(buildPath + 'Squire-UI.html', function() {
$('.item').click(function() {
var me = $(this);
var iFrame = me.parents('.Squire-UI').next('iframe').first()[0];
var editor = iFrame.contentWindow.editor;
console.log(SquireUI.isBold(editor));
var me = $(this);
var s = SquireUI;
var iFrame = me.parents('.Squire-UI').next('iframe').first()[0];
var editor = iFrame.contentWindow.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'));
});
});
@ -45,13 +51,13 @@ $(document).ready(function () {
return iframe.contentWindow.editor;
};
SquireUI.isBold = function (editor) { return this.isPresent( 'B', ( />B\b/ ), editor ); };
SquireUI.isItalic = function (editor) { return isPresent( 'I', ( />I\b/ ), editor ); };
SquireUI.isUnderlined = function (editor) { return isPresent( 'U', ( />U\b/ ), editor); };
SquireUI.isStriked = function (editor) { return isPresent( 'S', ( />S\b/ ), editor ); };
SquireUI.isLink = function (editor) { return isPresent( 'A', ( />A\b/ ), editor ); };
SquireUI.isPresent = function (format, validation, editor) {
SquireUI.isBold = function (editor) { return (this.isPresent( 'B', ( />B\b/ ), editor )); };
SquireUI.isItalic = function (editor) { return (isPresent( 'I', ( />I\b/ ), editor )); };
SquireUI.isUnderlined = function (editor) { return (isPresent( 'U', ( />U\b/ ), editor)); };
SquireUI.isStriked = function (editor) { return (isPresent( 'S', ( />S\b/ ), editor )); };
SquireUI.isLink = function (editor) { return (isPresent( 'A', ( />A\b/ ), editor )); };
SquireUI.isPresent = function (format, validation, editor) {
var path = editor.getPath();
return validation.test(path);
return validation.test(path) | editor.hasFormat(format);
};
});