From 8479a7e1c784dfd89da8c9d58dc3beda8f680bde Mon Sep 17 00:00:00 2001 From: Matthew Borden Date: Tue, 8 Jul 2014 20:42:00 +1000 Subject: [PATCH] Working: on getting text selection to work --- ui/Squire-UI.html | 65 +++++++++++++++++++++++++++++++---------------- ui/Squire-UI.js | 47 +++++++++++++++++++++------------- 2 files changed, 72 insertions(+), 40 deletions(-) diff --git a/ui/Squire-UI.html b/ui/Squire-UI.html index 6ff2124..6e7f86e 100644 --- a/ui/Squire-UI.html +++ b/ui/Squire-UI.html @@ -1,30 +1,51 @@ - + + \ No newline at end of file diff --git a/ui/Squire-UI.js b/ui/Squire-UI.js index 9908769..7aef820 100644 --- a/ui/Squire-UI.js +++ b/ui/Squire-UI.js @@ -26,29 +26,40 @@ $(document).ready(function () { var div = document.createElement('div'); div.className = 'Squire-UI'; - $(div).load(buildPath + 'Squire-UI.html', function () { - $('.item').click(function () { - var me = $(this); - - var iFrame = me.parents('.Squire-UI').next('iframe').first()[0]; - editor = iFrame.contentWindow.document; - console.log(me.data('action'), me.data('value')); - try { - editor[me.data('action')](me.data('value')); - } catch (error) { - console.log(error); - } - - }); - }); + $(div).load(buildPath + 'Squire-UI.html', this.menuAction); $(container).append(div); $(container).append(iframe); - editor = new Squire(iframe.contentWindow.document); - return editor; + iframe.contentWindow.editor = new Squire(iframe.contentWindow.document); + return iframe.contentWindow.editor; }; - + SquireUI.menuAction = function() { + $('.item').click(function() { + var me = $(this); + var iFrame = me.parents('.Squire-UI').next('iframe').first()[0]; + var editor = iFrame.contentWindow.editor; + try { + editor[me.data('action')](me.data('value')); + } catch (error) { + console.log(error); + } + }); + }; + + SquireUI.isBold = isPresent( 'B', ( />B\b/ ) ); + SquireUI.isItalic = isPresent( 'I', ( />I\b/ ) ); + SquireUI.isUnderlined = isPresent( 'U', ( />U\b/ ) ); + SquireUI.isStriked = isPresent( 'S', ( />S\b/ ) ); + SquireUI.isLink = isPresent( 'A', ( />A\b/ ) ); + SquireUI.isPresent = function () { + editor.getPath() + }; + + SquireUI.whenTextSelected = function () { + + } + }); \ No newline at end of file