From 7bbc64b88fc7a72d834a8c070346db661b51af72 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Tue, 15 Apr 2014 15:47:52 +0800 Subject: [PATCH] MDL-44826 Atto: Set default image alignment to 'bottom' --- .../moodle-atto_image-button-debug.js | 10 +++++++++- .../moodle-atto_image-button-min.js | 4 ++-- .../moodle-atto_image-button.js | 10 +++++++++- .../atto/plugins/image/yui/src/button/js/button.js | 13 +++++++++++-- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-debug.js b/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-debug.js index 1c1b18171d4..487b4cd8ac5 100644 --- a/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-debug.js +++ b/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-debug.js @@ -64,7 +64,8 @@ var CSS = { name: 'text-bottom', str: 'alignment_bottom', value: 'vertical-align', - margin: '0 .5em' + margin: '0 .5em', + isDefault: true }, // Floats. @@ -426,6 +427,13 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi if (properties === false) { img.setStyle('display', 'none'); + // Set the default alignment. + for (i in ALIGNMENTS) { + if (ALIGNMENTS[i].isDefault === true) { + css = ALIGNMENTS[i].value + ':' + ALIGNMENTS[i].name + ';'; + form.one('.' + CSS.INPUTALIGNMENT).set('value', css); + } + } // Remove the custom style option if this is a new image. form.one('.' + CSS.INPUTALIGNMENT).getDOMNode().options.remove(ALIGNMENTS.length - 1); return; diff --git a/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-min.js b/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-min.js index 6a463c4fbc8..c70702be458 100644 --- a/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-min.js +++ b/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-min.js @@ -1,2 +1,2 @@ -YUI.add("moodle-atto_image-button",function(e,t){var n={INPUTALIGNMENT:"atto_image_alignment",INPUTALT:"atto_image_altentry",INPUTHEIGHT:"atto_image_heightentry",INPUTSUBMIT:"atto_image_urlentrysubmit",INPUTURL:"atto_image_urlentry",INPUTSIZE:"atto_image_size",INPUTWIDTH:"atto_image_widthentry",IMAGEALTWARNING:"atto_image_altwarning",IMAGEBROWSER:"openimagebrowser",IMAGEPRESENTATION:"atto_image_presentation",INPUTCONSTRAIN:"atto_image_constrain",INPUTCUSTOMSTYLE:"atto_image_customstyle",IMAGEPREVIEW:"atto_image_preview"},r=[{name:"text-top",str:"alignment_top",value:"vertical-align",margin:"0 .5em"},{name:"middle",str:"alignment_middle",value:"vertical-align",margin:"0 .5em"},{name:"text-bottom",str:"alignment_bottom",value:"vertical-align",margin:"0 .5em"},{name:"left",str:"alignment_left",value:"float",margin:"0 .5em 0 0"},{name:"right",str:"alignment_right",value:"float",margin:"0 0 .5em 0"},{name:"customstyle",str:"customstyle",value:"style"}],i="atto_image",s='

{{#if showFilepicker}}{{/if}}

x


',o='{{alt}}';e.namespace("M.atto_image").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,_selectedImage:null,_form:null,_imageRawWidth:0,_imageRawHeight:0,initializer:function(){this.addButton({icon:"e/insert_edit_image",callback:this._displayDialogue,tags:"img",tagMatchRequiresAll:!1}),this.editor.delegate("dblclick",this._handleDoubleClick,"img",this)},_handleDoubleClick:function(e){var t=e.target,n=this.get("host").getSelectionFromNode(t);this.get("host").setSelection(n),this._displayDialogue()},_displayDialogue:function(){this._currentSelection=this.get("host").getSelection();if(this._currentSelection===!1)return;var e=this.getDialogue({headerContent:M.util.get_string("createimage",i),width:"480px",focusAfterHide:!0});e.set("bodyContent",this._getDialogueContent()).show()},_loadPreviewImage:function(e){var t=new Image,r=this;t.onload=function(){var e,t,i,s,o;r._imageRawWidth=this.width,r._imageRawHeight=this.height,e=r._form.one("."+n.INPUTWIDTH),t=e.get("value"),t===""&&(e.set("value",this.width),t=this.width),e=r._form.one("."+n.INPUTHEIGHT),i=e.get("value"),i===""&&(e.set("value",this.height),i=this.height),e=r._form.one("."+n.IMAGEPREVIEW),e.set("src",this.src),e.setStyle("display","inline"),this.width===0&&(this.width=1),this.height===0&&(this.height=1),e=r._form.one("."+n.INPUTCONSTRAIN),s=Math.round(parseInt(t,10)/this.width),o=Math.round(parseInt(i,10)/this.height),e.set("checked",s===o),r.getDialogue().centerDialogue()},t.src=e},_getDialogueContent:function(){var t=e.Handlebars.compile(s),o=this.get("host").canShowFilepicker("image"),u=e.Node.create(t({elementid:this.get("host").get("elementid"),CSS:n,component:i,showFilepicker:o,alignments:r}));return this._form=u,this._applyImageProperties(this._form),this._form.one("."+n.INPUTURL).on("blur",this._urlChanged,this),this._form.one("."+n.IMAGEPRESENTATION).on("change",this._updateWarning,this),this._form.one("."+n.INPUTALT).on("change",this._updateWarning,this),this._form.one("."+n.INPUTWIDTH).on("blur",this._autoAdjustHeight,this),this._form.one("."+n.INPUTHEIGHT).on("blur",this._autoAdjustWidth,this),this._form.one("."+n.INPUTURL).on("blur",this._urlChanged,this),this._form.one("."+n.INPUTSUBMIT).on("click",this._setImage,this),o&&this._form.one("."+n.IMAGEBROWSER).on("click",function(){this.get("host").showFilepicker("image",this._filepickerCallback,this)},this),u},_autoAdjustHeight:function(){var e,t,r;if(!this._form.one("."+n.INPUTCONSTRAIN).get("checked")){e=parseInt -(this._form.one("."+n.INPUTWIDTH).get("value"),10),r=parseInt(this._form.one("."+n.INPUTHEIGHT).get("value"),10),this._form.one("."+n.IMAGEPREVIEW).setAttribute("height",r),this._form.one("."+n.IMAGEPREVIEW).setAttribute("width",e);return}e=parseInt(this._form.one("."+n.INPUTWIDTH).get("value"),10),t=Math.round(e/this._imageRawWidth*this._imageRawHeight),this._form.one("."+n.INPUTHEIGHT).set("value",t),this._form.one("."+n.IMAGEPREVIEW).setAttribute("height",t),this._form.one("."+n.IMAGEPREVIEW).setAttribute("width",e)},_autoAdjustWidth:function(){var e,t;if(!this._form.one("."+n.INPUTCONSTRAIN).get("checked")){currentWidth=parseInt(this._form.one("."+n.INPUTWIDTH).get("value"),10),e=parseInt(this._form.one("."+n.INPUTHEIGHT).get("value"),10),this._form.one("."+n.IMAGEPREVIEW).setAttribute("height",e),this._form.one("."+n.IMAGEPREVIEW).setAttribute("width",currentWidth);return}e=parseInt(this._form.one("."+n.INPUTHEIGHT).get("value"),10),t=Math.round(e/this._imageRawHeight*this._imageRawWidth),this._form.one("."+n.INPUTWIDTH).set("value",t),this._form.one("."+n.IMAGEPREVIEW).setAttribute("width",t),this._form.one("."+n.IMAGEPREVIEW).setAttribute("height",e)},_filepickerCallback:function(e){if(e.url!==""){var t=this._form.one("."+n.INPUTURL);t.set("value",e.url),this._form.one("."+n.INPUTWIDTH).set("value",""),this._form.one("."+n.INPUTHEIGHT).set("value",""),this._loadPreviewImage(e.url)}},_applyImageProperties:function(e){var t=this._getSelectedImageProperties(),i=e.one("."+n.IMAGEPREVIEW);if(t===!1){i.setStyle("display","none"),e.one("."+n.INPUTALIGNMENT).getDOMNode().options.remove(r.length-1);return}t.align?(e.one("."+n.INPUTALIGNMENT).set("value",t.align),e.one("."+n.INPUTALIGNMENT).getDOMNode().options.remove(r.length-1)):e.one("."+n.INPUTALIGNMENT).set("value","style:customstyle;"),t.customstyle&&e.one("."+n.INPUTCUSTOMSTYLE).set("value",t.customstyle),t.display&&i.setStyle("display",t.display),t.width&&e.one("."+n.INPUTWIDTH).set("value",t.width),t.height&&e.one("."+n.INPUTHEIGHT).set("value",t.height),t.alt&&e.one("."+n.INPUTALT).set("value",t.alt),t.src&&(e.one("."+n.INPUTURL).set("value",t.src),this._loadPreviewImage(t.src)),t.presentation&&e.one("."+n.IMAGEPRESENTATION).set("checked","checked")},_getSelectedImageProperties:function(){var e={src:null,alt:null,width:null,height:null,align:"",display:"inline",presentation:!1},t=this.get("host").getSelectedNodes(),n,i,s,o,u;t&&(t=t.filter("img"));if(t&&t.size()){image=t.item(0),this._selectedImage=image,o=image.getAttribute("style"),e.customstyle=o,o=o.replace(/ /g,""),i=parseInt(image.getAttribute("width"),10),s=parseInt(image.getAttribute("height"),10),i>0&&(e.width=i),s>0&&(e.height=s);for(n in r){u=r[n].value+":"+r[n].name+";";if(o.indexOf(u)!==-1){margin="margin:"+r[n].margin+";",margin=margin.replace(/ /g,"");if(o.indexOf(margin)!==-1){e.align=u;break}}}return e.src=image.getAttribute("src"),e.alt=image.getAttribute("alt")||"",e.presentation=image.get("role")==="presentation",e}return this._selectedImage=null,!1},_urlChanged:function(){var e=this._form.one("."+n.INPUTURL);e.get("value")!==""&&this._loadPreviewImage(e.get("value"))},_setImage:function(t){var i=this._form,s=i.one("."+n.INPUTURL).get("value"),u=i.one("."+n.INPUTALT).get("value"),a=i.one("."+n.INPUTWIDTH).get("value"),f=i.one("."+n.INPUTHEIGHT).get("value"),l=i.one("."+n.INPUTALIGNMENT).get("value"),c="",h=i.one("."+n.IMAGEPRESENTATION).get("checked"),p,d="",v,m=this.get("host");t.preventDefault();if(this._updateWarning())return;this.getDialogue({focusAfterHide:null}).hide(),m.focus();if(s!==""){this._selectedImage?m.setSelection(m.getSelectionFromNode(this._selectedImage)):m.setSelection(this._currentSelection);if(l==="style:customstyle;")l="",d=i.one("."+n.INPUTCUSTOMSTYLE).get("value");else for(v in r)css=r[v].value+":"+r[v].name+";",l===css&&(c=" margin: "+r[v].margin+";");template=e.Handlebars.compile(o),p=template({url:s,alt:u,width:a,height:f,presentation:h,alignment:l,margin:c,customstyle:d}),this.get("host").insertContentAtFocusPoint(p),this.markUpdated()}},_updateWarning:function(){var e=this._form,t=!0,r=e.one("."+n.INPUTALT).get("value"),i=e.one("."+n.IMAGEPRESENTATION).get("checked");return r===""&&!i?(e.one("."+n.IMAGEALTWARNING).setStyle("display","block"),e.one("."+n.INPUTALT).setAttribute("aria-invalid",!0),e.one("."+n.IMAGEPRESENTATION).setAttribute("aria-invalid",!0),t=!0):(e.one("."+n.IMAGEALTWARNING).setStyle("display","none"),e.one("."+n.INPUTALT).setAttribute("aria-invalid",!1),e.one("."+n.IMAGEPRESENTATION).setAttribute("aria-invalid",!1),t=!1),this.getDialogue().centerDialogue(),t}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); +YUI.add("moodle-atto_image-button",function(e,t){var n={INPUTALIGNMENT:"atto_image_alignment",INPUTALT:"atto_image_altentry",INPUTHEIGHT:"atto_image_heightentry",INPUTSUBMIT:"atto_image_urlentrysubmit",INPUTURL:"atto_image_urlentry",INPUTSIZE:"atto_image_size",INPUTWIDTH:"atto_image_widthentry",IMAGEALTWARNING:"atto_image_altwarning",IMAGEBROWSER:"openimagebrowser",IMAGEPRESENTATION:"atto_image_presentation",INPUTCONSTRAIN:"atto_image_constrain",INPUTCUSTOMSTYLE:"atto_image_customstyle",IMAGEPREVIEW:"atto_image_preview"},r=[{name:"text-top",str:"alignment_top",value:"vertical-align",margin:"0 .5em"},{name:"middle",str:"alignment_middle",value:"vertical-align",margin:"0 .5em"},{name:"text-bottom",str:"alignment_bottom",value:"vertical-align",margin:"0 .5em",isDefault:!0},{name:"left",str:"alignment_left",value:"float",margin:"0 .5em 0 0"},{name:"right",str:"alignment_right",value:"float",margin:"0 0 .5em 0"},{name:"customstyle",str:"customstyle",value:"style"}],s="atto_image",o='

{{#if showFilepicker}}{{/if}}

x


',u='{{alt}}';e.namespace("M.atto_image").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,_selectedImage:null,_form:null,_imageRawWidth:0,_imageRawHeight:0,initializer:function(){this.addButton({icon:"e/insert_edit_image",callback:this._displayDialogue,tags:"img",tagMatchRequiresAll:!1}),this.editor.delegate("dblclick",this._handleDoubleClick,"img",this)},_handleDoubleClick:function(e){var t=e.target,n=this.get("host").getSelectionFromNode(t);this.get("host").setSelection(n),this._displayDialogue()},_displayDialogue:function(){this._currentSelection=this.get("host").getSelection();if(this._currentSelection===!1)return;var e=this.getDialogue({headerContent:M.util.get_string("createimage",s),width:"480px",focusAfterHide:!0});e.set("bodyContent",this._getDialogueContent()).show()},_loadPreviewImage:function(e){var t=new Image,r=this;t.onload=function(){var e,t,i,s,o;r._imageRawWidth=this.width,r._imageRawHeight=this.height,e=r._form.one("."+n.INPUTWIDTH),t=e.get("value"),t===""&&(e.set("value",this.width),t=this.width),e=r._form.one("."+n.INPUTHEIGHT),i=e.get("value"),i===""&&(e.set("value",this.height),i=this.height),e=r._form.one("."+n.IMAGEPREVIEW),e.set("src",this.src),e.setStyle("display","inline"),this.width===0&&(this.width=1),this.height===0&&(this.height=1),e=r._form.one("."+n.INPUTCONSTRAIN),s=Math.round(parseInt(t,10)/this.width),o=Math.round(parseInt(i,10)/this.height),e.set("checked",s===o),r.getDialogue().centerDialogue()},t.src=e},_getDialogueContent:function(){var t=e.Handlebars.compile(o),i=this.get("host").canShowFilepicker("image"),u=e.Node.create(t({elementid:this.get("host").get("elementid"),CSS:n,component:s,showFilepicker:i,alignments:r}));return this._form=u,this._applyImageProperties(this._form),this._form.one("."+n.INPUTURL).on("blur",this._urlChanged,this),this._form.one("."+n.IMAGEPRESENTATION).on("change",this._updateWarning,this),this._form.one("."+n.INPUTALT).on("change",this._updateWarning,this),this._form.one("."+n.INPUTWIDTH).on("blur",this._autoAdjustHeight,this),this._form.one("."+n.INPUTHEIGHT).on("blur",this._autoAdjustWidth,this),this._form.one("."+n.INPUTURL).on("blur",this._urlChanged,this),this._form.one("."+n.INPUTSUBMIT).on("click",this._setImage,this),i&&this._form.one("."+n.IMAGEBROWSER).on("click",function(){this.get("host").showFilepicker("image",this._filepickerCallback,this)},this),u},_autoAdjustHeight:function(){var e,t,r;if(!this._form.one("."+n.INPUTCONSTRAIN).get("checked" +)){e=parseInt(this._form.one("."+n.INPUTWIDTH).get("value"),10),r=parseInt(this._form.one("."+n.INPUTHEIGHT).get("value"),10),this._form.one("."+n.IMAGEPREVIEW).setAttribute("height",r),this._form.one("."+n.IMAGEPREVIEW).setAttribute("width",e);return}e=parseInt(this._form.one("."+n.INPUTWIDTH).get("value"),10),t=Math.round(e/this._imageRawWidth*this._imageRawHeight),this._form.one("."+n.INPUTHEIGHT).set("value",t),this._form.one("."+n.IMAGEPREVIEW).setAttribute("height",t),this._form.one("."+n.IMAGEPREVIEW).setAttribute("width",e)},_autoAdjustWidth:function(){var e,t;if(!this._form.one("."+n.INPUTCONSTRAIN).get("checked")){currentWidth=parseInt(this._form.one("."+n.INPUTWIDTH).get("value"),10),e=parseInt(this._form.one("."+n.INPUTHEIGHT).get("value"),10),this._form.one("."+n.IMAGEPREVIEW).setAttribute("height",e),this._form.one("."+n.IMAGEPREVIEW).setAttribute("width",currentWidth);return}e=parseInt(this._form.one("."+n.INPUTHEIGHT).get("value"),10),t=Math.round(e/this._imageRawHeight*this._imageRawWidth),this._form.one("."+n.INPUTWIDTH).set("value",t),this._form.one("."+n.IMAGEPREVIEW).setAttribute("width",t),this._form.one("."+n.IMAGEPREVIEW).setAttribute("height",e)},_filepickerCallback:function(e){if(e.url!==""){var t=this._form.one("."+n.INPUTURL);t.set("value",e.url),this._form.one("."+n.INPUTWIDTH).set("value",""),this._form.one("."+n.INPUTHEIGHT).set("value",""),this._loadPreviewImage(e.url)}},_applyImageProperties:function(e){var t=this._getSelectedImageProperties(),s=e.one("."+n.IMAGEPREVIEW);if(t===!1){s.setStyle("display","none");for(i in r)r[i].isDefault===!0&&(css=r[i].value+":"+r[i].name+";",e.one("."+n.INPUTALIGNMENT).set("value",css));e.one("."+n.INPUTALIGNMENT).getDOMNode().options.remove(r.length-1);return}t.align?(e.one("."+n.INPUTALIGNMENT).set("value",t.align),e.one("."+n.INPUTALIGNMENT).getDOMNode().options.remove(r.length-1)):e.one("."+n.INPUTALIGNMENT).set("value","style:customstyle;"),t.customstyle&&e.one("."+n.INPUTCUSTOMSTYLE).set("value",t.customstyle),t.display&&s.setStyle("display",t.display),t.width&&e.one("."+n.INPUTWIDTH).set("value",t.width),t.height&&e.one("."+n.INPUTHEIGHT).set("value",t.height),t.alt&&e.one("."+n.INPUTALT).set("value",t.alt),t.src&&(e.one("."+n.INPUTURL).set("value",t.src),this._loadPreviewImage(t.src)),t.presentation&&e.one("."+n.IMAGEPRESENTATION).set("checked","checked")},_getSelectedImageProperties:function(){var e={src:null,alt:null,width:null,height:null,align:"",display:"inline",presentation:!1},t=this.get("host").getSelectedNodes(),n,i,s,o,u;t&&(t=t.filter("img"));if(t&&t.size()){image=t.item(0),this._selectedImage=image,o=image.getAttribute("style"),e.customstyle=o,o=o.replace(/ /g,""),i=parseInt(image.getAttribute("width"),10),s=parseInt(image.getAttribute("height"),10),i>0&&(e.width=i),s>0&&(e.height=s);for(n in r){u=r[n].value+":"+r[n].name+";";if(o.indexOf(u)!==-1){margin="margin:"+r[n].margin+";",margin=margin.replace(/ /g,"");if(o.indexOf(margin)!==-1){e.align=u;break}}}return e.src=image.getAttribute("src"),e.alt=image.getAttribute("alt")||"",e.presentation=image.get("role")==="presentation",e}return this._selectedImage=null,!1},_urlChanged:function(){var e=this._form.one("."+n.INPUTURL);e.get("value")!==""&&this._loadPreviewImage(e.get("value"))},_setImage:function(t){var i=this._form,s=i.one("."+n.INPUTURL).get("value"),o=i.one("."+n.INPUTALT).get("value"),a=i.one("."+n.INPUTWIDTH).get("value"),f=i.one("."+n.INPUTHEIGHT).get("value"),l=i.one("."+n.INPUTALIGNMENT).get("value"),c="",h=i.one("."+n.IMAGEPRESENTATION).get("checked"),p,d="",v,m=this.get("host");t.preventDefault();if(this._updateWarning())return;this.getDialogue({focusAfterHide:null}).hide(),m.focus();if(s!==""){this._selectedImage?m.setSelection(m.getSelectionFromNode(this._selectedImage)):m.setSelection(this._currentSelection);if(l==="style:customstyle;")l="",d=i.one("."+n.INPUTCUSTOMSTYLE).get("value");else for(v in r)css=r[v].value+":"+r[v].name+";",l===css&&(c=" margin: "+r[v].margin+";");template=e.Handlebars.compile(u),p=template({url:s,alt:o,width:a,height:f,presentation:h,alignment:l,margin:c,customstyle:d}),this.get("host").insertContentAtFocusPoint(p),this.markUpdated()}},_updateWarning:function(){var e=this._form,t=!0,r=e.one("."+n.INPUTALT).get("value"),i=e.one("."+n.IMAGEPRESENTATION).get("checked");return r===""&&!i?(e.one("."+n.IMAGEALTWARNING).setStyle("display","block"),e.one("."+n.INPUTALT).setAttribute("aria-invalid",!0),e.one("."+n.IMAGEPRESENTATION).setAttribute("aria-invalid",!0),t=!0):(e.one("."+n.IMAGEALTWARNING).setStyle("display","none"),e.one("."+n.INPUTALT).setAttribute("aria-invalid",!1),e.one("."+n.IMAGEPRESENTATION).setAttribute("aria-invalid",!1),t=!1),this.getDialogue().centerDialogue(),t}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); diff --git a/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button.js b/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button.js index 1c1b18171d4..487b4cd8ac5 100644 --- a/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button.js +++ b/lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button.js @@ -64,7 +64,8 @@ var CSS = { name: 'text-bottom', str: 'alignment_bottom', value: 'vertical-align', - margin: '0 .5em' + margin: '0 .5em', + isDefault: true }, // Floats. @@ -426,6 +427,13 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi if (properties === false) { img.setStyle('display', 'none'); + // Set the default alignment. + for (i in ALIGNMENTS) { + if (ALIGNMENTS[i].isDefault === true) { + css = ALIGNMENTS[i].value + ':' + ALIGNMENTS[i].name + ';'; + form.one('.' + CSS.INPUTALIGNMENT).set('value', css); + } + } // Remove the custom style option if this is a new image. form.one('.' + CSS.INPUTALIGNMENT).getDOMNode().options.remove(ALIGNMENTS.length - 1); return; diff --git a/lib/editor/atto/plugins/image/yui/src/button/js/button.js b/lib/editor/atto/plugins/image/yui/src/button/js/button.js index a0af106c2df..bec3b9d3c15 100644 --- a/lib/editor/atto/plugins/image/yui/src/button/js/button.js +++ b/lib/editor/atto/plugins/image/yui/src/button/js/button.js @@ -62,7 +62,8 @@ var CSS = { name: 'text-bottom', str: 'alignment_bottom', value: 'vertical-align', - margin: '0 .5em' + margin: '0 .5em', + isDefault: true }, // Floats. @@ -420,10 +421,18 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi */ _applyImageProperties: function(form) { var properties = this._getSelectedImageProperties(), - img = form.one('.' + CSS.IMAGEPREVIEW); + img = form.one('.' + CSS.IMAGEPREVIEW), + i; if (properties === false) { img.setStyle('display', 'none'); + // Set the default alignment. + for (i in ALIGNMENTS) { + if (ALIGNMENTS[i].isDefault === true) { + css = ALIGNMENTS[i].value + ':' + ALIGNMENTS[i].name + ';'; + form.one('.' + CSS.INPUTALIGNMENT).set('value', css); + } + } // Remove the custom style option if this is a new image. form.one('.' + CSS.INPUTALIGNMENT).getDOMNode().options.remove(ALIGNMENTS.length - 1); return;