From ff29f3e4e8288393938c29cffcdb9d3254622f5a Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 5 Apr 2011 21:08:24 +1200 Subject: [PATCH] ENHANCEMENT Changed HtmlEditorField link/image/flash forms to use model jQuery.dialog instead of side panel - less side effects when switching focus between editor and side panels, and fits better in new design drafts --- forms/HtmlEditorField.php | 3 +++ javascript/HtmlEditorField.js | 4 +++ javascript/tiny_mce_improvements.js | 41 ++++++++--------------------- 3 files changed, 18 insertions(+), 30 deletions(-) diff --git a/forms/HtmlEditorField.php b/forms/HtmlEditorField.php index 74918bf09..63f2c310d 100755 --- a/forms/HtmlEditorField.php +++ b/forms/HtmlEditorField.php @@ -275,6 +275,7 @@ class HtmlEditorField_Toolbar extends RequestHandler { $form->unsetValidator(); $form->loadDataFrom($this); + $form->addExtraClass('htmleditorfield-form htmleditorfield-linkform'); $this->extend('updateLinkForm', $form); @@ -347,6 +348,7 @@ class HtmlEditorField_Toolbar extends RequestHandler { $form->unsetValidator(); $form->disableSecurityToken(); $form->loadDataFrom($this); + $form->addExtraClass('htmleditorfield-form htmleditorfield-imageform'); return $form; } @@ -385,6 +387,7 @@ class HtmlEditorField_Toolbar extends RequestHandler { $form->unsetValidator(); $form->loadDataFrom($this); $form->disableSecurityToken(); + $form->addExtraClass('htmleditorfield-form htmleditorfield-flashform'); return $form; } diff --git a/javascript/HtmlEditorField.js b/javascript/HtmlEditorField.js index 602846d6c..95d5f17e0 100644 --- a/javascript/HtmlEditorField.js +++ b/javascript/HtmlEditorField.js @@ -7,7 +7,11 @@ */ (function($) { + $(document).ready(function() { + + $('.htmleditorfield-form').dialog({autoOpen: false, bgiframe: true, modal: true, height: 500, width: 500, ghost: true}); + /** * On page refresh load the initial images (in root) */ diff --git a/javascript/tiny_mce_improvements.js b/javascript/tiny_mce_improvements.js index 47a9fd992..83b2cbd6d 100755 --- a/javascript/tiny_mce_improvements.js +++ b/javascript/tiny_mce_improvements.js @@ -5,14 +5,10 @@ ToolbarForm.prototype = { else this.open(ed); }, close: function(ed) { - if(this.style.display == 'block') { - this.style.display = 'none'; - } + jQuery(this).dialog('close'); }, open: function(ed) { - if(this.style.display != 'block') { - this.style.display = 'block'; - } + jQuery(this).dialog('open'); }, onsubmit: function() { return false; @@ -140,6 +136,7 @@ LinkForm.prototype = { }, updateSelection: function(ed) { + if(ed == null) ed = tinyMCE.activeEditor; if(ed.selection.getRng()) { this.originalSelection = ed.selection.getRng(); } @@ -164,14 +161,14 @@ LinkForm.prototype = { Form.Element.setValue(this.elements[i], selected); } } - - // If we haven't selected an existing link, then just make sure we default to "internal" for the link - // type. - } else { - if(!Form.Element.getValue(this.elements.LinkType)) Form.Element.setValue(this.elements.LinkType, 'internal'); } - this.linkTypeChanged(data ? false : true); + + // If we haven't selected an existing link, then just make sure we default to "internal" for the link + // type. + } else { + if(!Form.Element.getValue(this.elements.LinkType)) Form.Element.setValue(this.elements.LinkType, 'internal'); } + this.linkTypeChanged(data ? false : true); }, handleaction_insert: function() { @@ -437,6 +434,7 @@ SideFormAction.prototype = { } catch(er) { alert("An error occurred. Please try again, or reload the CMS if the problem persists.\n\nError details: " + er.message); } + jQuery(this).parents('form').dialog('close'); } else { alert("Couldn't find form method handle" + this.name); } @@ -622,13 +620,6 @@ ImageThumbnail.prototype = { if(el && el.nodeName == 'IMG') { ed.dom.setAttribs(el, attributes); } else { - // Focus gets saved in tinymce_ssbuttons when opening the sidebar. - // Unless the focus has changed in the meantime, reset it to the previous position. - // This is necessary because IE can lose its focus if any of the sidebar input fields are used. - if(ed.ss_focus_bookmark) { - ed.selection.moveToBookmark(ed.ss_focus_bookmark); - delete ed.ss_focus_bookmark; - } ed.execCommand('mceInsertContent', false, html, { skip_undo : 1 }); @@ -897,14 +888,4 @@ function sapphiremce_cleanup(type, value) { } return value; -} - -contentPanelCloseButton = Class.create(); -contentPanelCloseButton.prototype = { - onclick: function() { - tinyMCE.activeEditor.execCommand('ssclosesidepanel'); - } -} - -contentPanelCloseButton.applyTo('#contentPanel h2 img'); - +} \ No newline at end of file