Permalink
Browse files

BUGFIX Partially reverting 28e43bd which broke media insertion

  • Loading branch information...
1 parent 23a3872 commit 0235a8c0c76468d21196ab64b8a39b77c7265be8 @halkyon halkyon committed May 28, 2012
Showing with 10 additions and 17 deletions.
  1. +4 −5 forms/HtmlEditorField.php
  2. +6 −7 javascript/HtmlEditorField.js
  3. +0 −5 templates/Includes/HtmlEditorField_viewfile.ss
@@ -159,8 +159,7 @@ public function saveInto(DataObjectInterface $record) {
if($width && $height && ($width != $image->getWidth() || $height != $image->getHeight())) {
//Make sure that the resized image actually returns an image:
$resized=$image->ResizedImage($width, $height);
- if($resized)
- $img->setAttribute('src', $resized->getRelativePath());
+ if($resized) $img->setAttribute('src', $resized->getRelativePath());
}
}
@@ -429,17 +428,17 @@ function MediaForm() {
$editComposite = new CompositeField(
new LiteralField('contentEdit', '<div class="content-edit ss-uploadfield-files files"></div>')
- )
+ )
);
- $allFields -> addExtraClass('ss-insert-media');
+ $allFields->addExtraClass('ss-insert-media');
$headings = new CompositeField(
new LiteralField(
'Heading',
sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.INSERTMEDIA', 'Insert Media')).
sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>', _t('HtmlEditorField.UpdateMEDIA', 'Update Media'))
- )
+ )
);
$headings->addExtraClass('cms-content-header');
@@ -676,7 +676,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
var updateExisting = Boolean(this.find('.ss-htmleditorfield-file').length);
this.find('.overview .action-delete')[updateExisting ? 'hide' : 'show']();
},
- onsubmit: function() {
+ onsubmit: function() {
var self = this, ed = this.getEditor();
// HACK: See ondialogopen()
@@ -690,7 +690,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
return false;
},
- updateFromEditor: function() {
+ updateFromEditor: function() {
var self = this, ed = this.getEditor(), node = $(ed.getSelectedNode());
// TODO Depends on managed mime type
if(node.is('img')) {
@@ -714,7 +714,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
if(header) header[(hasItems) ? 'show' : 'hide']();
// Disable "insert" button if no files are selected
- this.find('.Actions :submit')
+ this.find('.Actions :submit')
.button(hasItems ? 'enable' : 'disable')
.toggleClass('ui-state-disabled', !hasItems);
@@ -728,7 +728,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
this.find('.htmleditorfield-mediaform-heading.update')[updateExisting ? 'show' : 'hide']();
this.find('.Actions .media-update')[updateExisting ? 'show' : 'hide']();
},
- resetFields: function() {
+ resetFields: function() {
var ed = this.getEditor(), node = $(ed.getSelectedNode());
// HACK: See ondialogopen()
@@ -849,8 +849,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
* Insert updated HTML content into the rich text editor
*/
insertHTML: function() {
-
- var ed = this.getEditor();
+ var form = this.closest('form'), ed = form.getEditor();
// Workaround for browsers losing focus, similar to tinyMCEPopup.restoreSelection
ed.moveToBookmark(window._ss_htmleditorfield_bookmark);
@@ -940,7 +939,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
* Logic similar to TinyMCE 'advimage' plugin, insertAndClose() method.
*/
insertHTML: function() {
- var form = this.closest('.cms').find('.cms-container textarea.htmleditor'), ed = form.getEditor(),
+ var form = this.closest('form'), ed = form.getEditor(),
node = $(ed.getSelectedNode()), captionNode = node.closest('.captionImage');
// Workaround for browsers losing focus, similar to tinyMCEPopup.restoreSelection.
@@ -1,5 +1,3 @@
-
-
<div class="ss-uploadfield-item $appCategory ss-htmleditorfield-file template-upload" data-id="$File.ID" data-url="$URL">
<div class="ss-uploadfield-item-preview">
<span>$Preview.SetRatioSize(30, 40)</span>
@@ -37,6 +35,3 @@
</div>
</div>
-
-
-

0 comments on commit 0235a8c

Please sign in to comment.