Browse files

ENHANCEMENT Changed HtmlEditorField link/image/flash forms to use mod…

…el jQuery.dialog instead of side panel - less side effects when switching focus between editor and side panels, and fits better in new design drafts
  • Loading branch information...
1 parent f6edcd1 commit ff29f3e4e8288393938c29cffcdb9d3254622f5a @chillu chillu committed Apr 5, 2011
Showing with 18 additions and 30 deletions.
  1. +3 −0 forms/HtmlEditorField.php
  2. +4 −0 javascript/HtmlEditorField.js
  3. +11 −30 javascript/tiny_mce_improvements.js
View
3 forms/HtmlEditorField.php
@@ -275,6 +275,7 @@ function LinkForm() {
$form->unsetValidator();
$form->loadDataFrom($this);
+ $form->addExtraClass('htmleditorfield-form htmleditorfield-linkform');
$this->extend('updateLinkForm', $form);
@@ -347,6 +348,7 @@ function ImageForm() {
$form->unsetValidator();
$form->disableSecurityToken();
$form->loadDataFrom($this);
+ $form->addExtraClass('htmleditorfield-form htmleditorfield-imageform');
return $form;
}
@@ -385,6 +387,7 @@ function FlashForm() {
$form->unsetValidator();
$form->loadDataFrom($this);
$form->disableSecurityToken();
+ $form->addExtraClass('htmleditorfield-form htmleditorfield-flashform');
return $form;
}
View
4 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)
*/
View
41 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');
-
+}

0 comments on commit ff29f3e

Please sign in to comment.