Permalink
Browse files

MINOR Moved redundant toggleLooks() logic in HtmlEditorField.js to ex…

…isting redraw() logic
  • Loading branch information...
1 parent 0250524 commit 7ab47b649388fdd6043e5141dc93142c7e181d44 @chillu chillu committed May 20, 2012
Showing with 9 additions and 14 deletions.
  1. +9 −14 javascript/HtmlEditorField.js
@@ -655,17 +655,6 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
* of remove files as well.
*/
$('form.htmleditorfield-mediaform').entwine({
- onmatch: function() {
- this.toggleLooks();
- this._super();
- },
- toggleLooks: function(){
- var updateExisting = Boolean(this.find('.ss-htmleditorfield-file').length);
- this.find('.htmleditorfield-mediaform-heading.insert')[updateExisting ? 'hide' : 'show']();
- this.find('.Actions .image-insert')[updateExisting ? 'hide' : 'show']();
- this.find('.htmleditorfield-mediaform-heading.update')[updateExisting ? 'show' : 'hide']();
- this.find('.Actions .image-update')[updateExisting ? 'show' : 'hide']();
- },
toggleCloseButton: function(){
var updateExisting = Boolean(this.find('.ss-htmleditorfield-file').length);
this.find('.overview .action-delete')[updateExisting ? 'hide' : 'show']();
@@ -695,17 +684,17 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
self.redraw();
});
}
- this.toggleLooks();
this.redraw();
},
redraw: function() {
this._super();
var ed = this.getEditor(), node = $(ed.getSelectedNode()),
hasItems = Boolean(this.find('.ss-htmleditorfield-file').length),
- editingSelected = node.is('img');
+ editingSelected = node.is('img'),
+ header = this.find('.header-edit');
// Only show second step if files are selected
- this.find('.header-edit')[(hasItems) ? 'show' : 'hide']();
+ if(header) header[(hasItems) ? 'show' : 'hide']();
// Disable "insert" button if no files are selected
this.find('.Actions :submit')
@@ -714,6 +703,12 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
// Hide file selection and step labels when editing an existing file
this.find('#MediaFormInsertImageTabs,.header-edit')[editingSelected ? 'hide' : 'show']();
+
+ var updateExisting = Boolean(this.find('.ss-htmleditorfield-file').length);
+ this.find('.htmleditorfield-mediaform-heading.insert')[updateExisting ? 'hide' : 'show']();
+ this.find('.Actions .image-insert')[updateExisting ? 'hide' : 'show']();
+ this.find('.htmleditorfield-mediaform-heading.update')[updateExisting ? 'show' : 'hide']();
+ this.find('.Actions .image-update')[updateExisting ? 'show' : 'hide']();
},
resetFields: function() {
var ed = this.getEditor(), node = $(ed.getSelectedNode());

0 comments on commit 7ab47b6

Please sign in to comment.