Merge pull request #359 from silverstripe-big-o/sapphire

---

When open an image form loaded from TinyMCE Content, change the looks of the popup, such as popup heading (change from "Insert Image" to "Update Image"), action button label (change from "Insert" to "Update"), hiding the cancelling button on the top right corner which still needs to show when in inserting mode

Conflicts:
	lang/en.yml
This commit is contained in:
Ingo Schommer 2012-04-27 10:15:16 +02:00
commit 8489ff37db
2 changed files with 24 additions and 4 deletions

View File

@ -422,14 +422,19 @@ class HtmlEditorField_Toolbar extends RequestHandler {
$fields = new FieldList(
new LiteralField(
'Heading',
sprintf('<h3>%s</h3>', _t('HtmlEditorField.IMAGE', 'Insert Image'))
sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.INSERTIMAGE', 'Insert Image')).
sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>', _t('HtmlEditorField.UpdateIMAGE', 'Update Image'))
),
$allFields
);
$actions = new FieldList(
FormAction::create('insertimage', _t('HtmlEditorField.BUTTONINSERT', 'Insert'))
->addExtraClass('ss-ui-action-constructive')
->addExtraClass('ss-ui-action-constructive image-insert')
->setAttribute('data-icon', 'accept')
->setUseButtonTag(true),
FormAction::create('insertimage', _t('HtmlEditorField.BUTTONUpdate', 'Update'))
->addExtraClass('ss-ui-action-constructive image-update')
->setAttribute('data-icon', 'accept')
->setUseButtonTag(true)
);

View File

@ -653,6 +653,21 @@ 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']();
},
onsubmit: function() {
var self = this, ed = this.getEditor();
@ -674,15 +689,15 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
if(node.is('img')) {
this.showFileView(node.attr('src'), function() {
$(this).updateFromNode(node);
self.toggleCloseButton();
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');