From eb8b2425a6a1e970c561238d707be77398573d4a Mon Sep 17 00:00:00 2001 From: Daniel Thies Date: Wed, 12 Nov 2014 20:41:28 -0600 Subject: [PATCH] MDL-48062 atto_image: Add image select on single click --- .../moodle-atto_image-button-debug.js | 16 +++++++++------- .../moodle-atto_image-button-min.js | 6 +++--- .../moodle-atto_image-button.js | 16 +++++++++------- .../plugins/image/yui/src/button/js/button.js | 16 +++++++++------- 4 files changed, 30 insertions(+), 24 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 511c6a8b7b7..dc3a0256bb5 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 @@ -214,7 +214,8 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi tags: 'img', tagMatchRequiresAll: false }); - this.editor.delegate('dblclick', this._handleDoubleClick, 'img', this); + this.editor.delegate('dblclick', this._displayDialogue, 'img', this); + this.editor.delegate('click', this._handleClick, 'img', this); this.editor.on('drop', this._handleDragDrop, this); }, @@ -330,21 +331,22 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi } return false; - }, +}, /** - * Handle a double click on an image. + * Handle a click on an image. * - * @method _handleDoubleClick + * @method _handleClick * @param {EventFacade} e * @private */ - _handleDoubleClick: function(e) { + _handleClick: function(e) { var image = e.target; var selection = this.get('host').getSelectionFromNode(image); - this.get('host').setSelection(selection); - this._displayDialogue(); + if (this.get('host').getSelection() !== selection) { + this.get('host').setSelection(selection); + } }, /** 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 8cf00acb8de..0c40a566538 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,3 +1,3 @@ -YUI.add("moodle-atto_image-button",function(e,t){var n={RESPONSIVE:"img-responsive",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",IMAGEPREVIEWBOX:"atto_image_preview_box"},r={INPUTURL:"."+n.INPUTURL},i=[{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 0 .5em"},{name:"customstyle",str:"customstyle",value:"style"}],s={ISPERCENT:/\d+%/},o="atto_image",u='

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

x

',a='{{alt}}';e.namespace("M.atto_image").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,_selectedImage:null,_form:null,_rawImageDimensions:null,initializer:function(){this.addButton({icon:"e/insert_edit_image",callback:this._displayDialogue,tags:"img",tagMatchRequiresAll:!1}),this.editor.delegate("dblclick",this._handleDoubleClick,"img",this),this.editor.on("drop",this._handleDragDrop,this)},_handleDragDrop:function(t){var n=this,r=this.get("host"),i=e.Handlebars.compile(a);r.saveSelection(),t=t._event;if(t.dataTransfer&&t.dataTransfer.files&&t.dataTransfer.files.length&&/^image\//.test(t.dataTransfer.files[0].type)){var s=r.get("filepickeroptions").image,u=s.savepath===undefined?"/":s.savepath,f=new FormData,l=0,c="",h=new XMLHttpRequest,p="",d=Object.keys(s.repositories);t.preventDefault(),t.stopPropagation(),f.append("repo_upload_file",t.dataTransfer.files[0]),f.append("itemid",s.itemid);for(var v=0;v
{{#if showFilepicker}}{{/if}}

x

',a='{{alt}}';e.namespace("M.atto_image").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,_selectedImage:null,_form:null,_rawImageDimensions:null,initializer:function(){this.addButton({icon:"e/insert_edit_image",callback:this._displayDialogue,tags:"img",tagMatchRequiresAll:!1}),this.editor.delegate("dblclick",this._displayDialogue,"img",this),this.editor.delegate("click",this._handleClick,"img",this),this.editor.on("drop",this._handleDragDrop,this)},_handleDragDrop:function(t){var n=this,r=this.get("host"),i=e.Handlebars.compile(a);r.saveSelection(),t=t._event;if(t.dataTransfer&&t.dataTransfer.files&&t.dataTransfer.files.length&&/^image\//.test(t.dataTransfer.files[0].type)){var s=r.get("filepickeroptions").image,u=s.savepath===undefined?"/":s.savepath,f=new FormData,l=0,c="",h=new XMLHttpRequest,p="",d=Object.keys(s.repositories);t.preventDefault(),t.stopPropagation(),f.append("repo_upload_file",t.dataTransfer.files[0]),f.append("itemid",s.itemid);for(var v=0;v