Merge branch 'MDL-66601-master' of git://github.com/mihailges/moodle
[moodle.git] / lib / editor / atto / plugins / image / yui / build / button / js / button.min.js.map
CommitLineData
ae671213 1{"version":3,"sources":["../../../src/button/js/button.js"],"names":["CSS","RESPONSIVE","INPUTALIGNMENT","INPUTALT","INPUTHEIGHT","INPUTSUBMIT","INPUTURL","INPUTSIZE","INPUTWIDTH","IMAGEALTWARNING","IMAGEBROWSER","IMAGEPRESENTATION","INPUTCONSTRAIN","INPUTCUSTOMSTYLE","IMAGEPREVIEW","IMAGEPREVIEWBOX","ALIGNSETTINGS","SELECTORS","ALIGNMENTS","name","str","value","margin","isDefault","REGEX","ISPERCENT","COMPONENTNAME","TEMPLATE","IMAGETEMPLATE","Y","namespace","Button","Base","create","M","editor_atto","EditorPlugin","_currentSelection","_selectedImage","_form","_rawImageDimensions","initializer","addButton","icon","callback","_displayDialogue","tags","tagMatchRequiresAll","editor","delegate","_handleClick","on","_handlePaste","_handleDragDrop","e","preventDefault","_event","dataTransfer","_handlePasteOrDropHelper","clipboardData","items","didUpload","i","item","length","kind","_isImage","type","_uploadImage","getAsFile","stopPropagation","mimeType","indexOf","fileToSave","self","host","get","template","Handlebars","compile","saveSelection","options","image","savepath","formData","FormData","timestamp","uploadid","xhr","XMLHttpRequest","imagehtml","keys","Object","repositories","append","itemid","id","env","cfg","sesskey","client_id","context","Date","getTime","Math","round","random","focus","restoreSelection","url","util","image_url","alt","get_string","insertContentAtFocusPoint","markUpdated","onreadystatechange","placeholder","one","result","file","newhtml","newimage","readyState","status","JSON","parse","responseText","error","remove","core","ajaxException","event","newfile","presentation","Node","replace","appendChild","use","alert","message","open","wwwroot","send","target","selection","getSelectionFromNode","getSelection","setSelection","dialogue","getDialogue","headerContent","width","focusAfterHide","focusOnShowSelector","setStyle","set","_getDialogueContent","show","_loadPreviewImage","Image","onerror","preview","setStyles","centerDialogue","onload","input","currentwidth","currentheight","widthRatio","heightRatio","height","setAttribute","src","match","parseInt","_autoAdjustSize","canShowFilepicker","content","elementid","component","showFilepicker","alignments","_applyImageProperties","_urlChanged","_updateWarning","_setImage","_filepickerCallback","_handleKeyup","forceHeight","keyField","keyFieldType","subField","subFieldType","constrainField","keyFieldValue","subFieldValue","imagePreview","rawPercentage","rawSize","_temporaryValue","params","form","properties","_getSelectedImageProperties","img","some","alignment","align","customstyle","images","getSelectedNodes","style","filter","size","_removeLegacyAlignment","getAttribute","_getAlignmentPropeties","complete","defaultAlignment","classname","_getAlignmentClass","hasClass","log","constrain","classlist","push","isNaN","join","hide","imageNode","getStyle","normalisedNode","addClass","state","characterCount","current","setHTML"],"mappings":"AAiCA,GAAIA,CAAAA,GAAG,CAAG,CACFC,UAAU,CAAE,gBADV,CAEFC,cAAc,CAAE,sBAFd,CAGFC,QAAQ,CAAE,qBAHR,CAIFC,WAAW,CAAE,wBAJX,CAKFC,WAAW,CAAE,2BALX,CAMFC,QAAQ,CAAE,qBANR,CAOFC,SAAS,CAAE,iBAPT,CAQFC,UAAU,CAAE,uBARV,CASFC,eAAe,CAAE,uBATf,CAUFC,YAAY,CAAE,kBAVZ,CAWFC,iBAAiB,CAAE,yBAXjB,CAYFC,cAAc,CAAE,sBAZd,CAaFC,gBAAgB,CAAE,wBAbhB,CAcFC,YAAY,CAAE,oBAdZ,CAeFC,eAAe,CAAE,wBAff,CAgBFC,aAAa,CAAE,mBAhBb,CAAV,CAkBIC,SAAS,CAAG,CACRX,QAAQ,CAAE,IAAMN,GAAG,CAACM,QADZ,CAlBhB,CAqBIY,UAAU,CAAG,CAET,CACIC,IAAI,CAAE,eADV,CAEIC,GAAG,CAAE,eAFT,CAGIC,KAAK,CAAE,UAHX,CAIIC,MAAM,CAAE,SAJZ,CAFS,CAON,CACCH,IAAI,CAAE,eADP,CAECC,GAAG,CAAE,kBAFN,CAGCC,KAAK,CAAE,QAHR,CAICC,MAAM,CAAE,SAJT,CAPM,CAYN,CACCH,IAAI,CAAE,eADP,CAECC,GAAG,CAAE,kBAFN,CAGCC,KAAK,CAAE,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YAAtC,CAAmD,cAAnD,KACA8D,CAAK,GACR,CACD,KAAKpF,WAAL,GAAmBc,cAAnB,GACA,MAAOsE,CAAAA,CACV,CAv1B0F,CA41B3F9C,YAAY,CAAE,uBAAW,CACrB,GAAIc,CAAAA,CAAI,CAAG,KAAKnK,KAAhB,CACIyE,CAAG,CAAG0F,CAAI,CAACpF,GAAL,CAAS,IAAMtH,GAAG,CAACG,QAAnB,EAA6ByE,GAA7B,CAAiC,OAAjC,CADV,CAEI+J,CAAc,CAAG3H,CAAG,CAAChD,MAFzB,CAGI4K,CAAO,CAAGlC,CAAI,CAACpF,GAAL,CAAS,eAAT,CAHd,CAIAsH,CAAO,CAACC,OAAR,CAAgBF,CAAhB,CACH,CAl2B0F,CAA1D,CAArC","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/*\n * @package atto_image\n * @copyright 2013 Damyon Wiese <damyon@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * @module moodle-atto_image_alignment-button\n */\n\n/**\n * Atto image selection tool.\n *\n * @namespace M.atto_image\n * @class Button\n * @extends M.editor_atto.EditorPlugin\n */\n\nvar CSS = {\n RESPONSIVE: 'img-responsive',\n INPUTALIGNMENT: 'atto_image_alignment',\n INPUTALT: 'atto_image_altentry',\n INPUTHEIGHT: 'atto_image_heightentry',\n INPUTSUBMIT: 'atto_image_urlentrysubmit',\n INPUTURL: 'atto_image_urlentry',\n INPUTSIZE: 'atto_image_size',\n INPUTWIDTH: 'atto_image_widthentry',\n IMAGEALTWARNING: 'atto_image_altwarning',\n IMAGEBROWSER: 'openimagebrowser',\n IMAGEPRESENTATION: 'atto_image_presentation',\n INPUTCONSTRAIN: 'atto_image_constrain',\n INPUTCUSTOMSTYLE: 'atto_image_customstyle',\n IMAGEPREVIEW: 'atto_image_preview',\n IMAGEPREVIEWBOX: 'atto_image_preview_box',\n ALIGNSETTINGS: 'atto_image_button'\n },\n SELECTORS = {\n INPUTURL: '.' + CSS.INPUTURL\n },\n ALIGNMENTS = [\n // Vertical alignment.\n {\n name: 'verticalAlign',\n str: 'alignment_top',\n value: 'text-top',\n margin: '0 0.5em'\n }, {\n name: 'verticalAlign',\n str: 'alignment_middle',\n value: 'middle',\n margin: '0 0.5em'\n }, {\n name: 'verticalAlign',\n str: 'alignment_bottom',\n value: 'text-bottom',\n margin: '0 0.5em',\n isDefault: true\n },\n\n // Floats.\n {\n name: 'float',\n str: 'alignment_left',\n value: 'left',\n margin: '0 0.5em 0 0'\n }, {\n name: 'float',\n str: 'alignment_right',\n value: 'right',\n margin: '0 0 0 0.5em'\n }\n ],\n\n REGEX = {\n ISPERCENT: /\\d+%/\n },\n\n COMPONENTNAME = 'atto_image',\n\n TEMPLATE = '' +\n '<form class=\"atto_form\">' +\n\n // Add the repository browser button.\n '{{#if showFilepicker}}' +\n '<div class=\"mb-1\">' +\n '<label for=\"{{elementid}}_{{CSS.INPUTURL}}\">{{get_string \"enterurl\" component}}</label>' +\n '<div class=\"input-group input-append w-100\">' +\n '<input class=\"form-control {{CSS.INPUTURL}}\" type=\"url\" ' +\n 'id=\"{{elementid}}_{{CSS.INPUTURL}}\" size=\"32\"/>' +\n '<span class=\"input-group-append\">' +\n '<button class=\"btn btn-secondary {{CSS.IMAGEBROWSER}}\" type=\"button\">' +\n '{{get_string \"browserepositories\" component}}</button>' +\n '</span>' +\n '</div>' +\n '</div>' +\n '{{else}}' +\n '<div class=\"mb-1\">' +\n '<label for=\"{{elementid}}_{{CSS.INPUTURL}}\">{{get_string \"enterurl\" component}}</label>' +\n '<input class=\"form-control fullwidth {{CSS.INPUTURL}}\" type=\"url\" ' +\n 'id=\"{{elementid}}_{{CSS.INPUTURL}}\" size=\"32\"/>' +\n '</div>' +\n '{{/if}}' +\n\n // Add the Alt box.\n '<div style=\"display:none\" role=\"alert\" class=\"alert alert-warning mb-1 {{CSS.IMAGEALTWARNING}}\">' +\n '{{get_string \"presentationoraltrequired\" component}}' +\n '</div>' +\n '<div class=\"mb-1\">' +\n '<label for=\"{{elementid}}_{{CSS.INPUTALT}}\">{{get_string \"enteralt\" component}}</label>' +\n '<textarea class=\"form-control fullwidth {{CSS.INPUTALT}}\" ' +\n 'id=\"{{elementid}}_{{CSS.INPUTALT}}\" maxlength=\"125\"></textarea>' +\n\n // Add the character count.\n '<div id=\"the-count\" class=\"d-flex justify-content-end small\">' +\n '<span id=\"currentcount\">0</span>' +\n '<span id=\"maximumcount\"> / 125</span>' +\n '</div>' +\n\n // Add the presentation select box.\n '<div class=\"form-check\">' +\n '<input type=\"checkbox\" class=\"form-check-input {{CSS.IMAGEPRESENTATION}}\" ' +\n 'id=\"{{elementid}}_{{CSS.IMAGEPRESENTATION}}\"/>' +\n '<label class=\"form-check-label\" for=\"{{elementid}}_{{CSS.IMAGEPRESENTATION}}\">' +\n '{{get_string \"presentation\" component}}' +\n '</label>' +\n '</div>' +\n '</div>' +\n\n // Add the size entry boxes.\n '<div class=\"mb-1\">' +\n '<label class=\"\" for=\"{{elementid}}_{{CSS.INPUTSIZE}}\">{{get_string \"size\" component}}</label>' +\n '<div id=\"{{elementid}}_{{CSS.INPUTSIZE}}\" class=\"form-inline {{CSS.INPUTSIZE}}\">' +\n '<label class=\"accesshide\" for=\"{{elementid}}_{{CSS.INPUTWIDTH}}\">{{get_string \"width\" component}}</label>' +\n '<input type=\"text\" class=\"form-control mr-1 input-mini {{CSS.INPUTWIDTH}}\" ' +\n 'id=\"{{elementid}}_{{CSS.INPUTWIDTH}}\" size=\"4\"/> x' +\n\n // Add the height entry box.\n '<label class=\"accesshide\" for=\"{{elementid}}_{{CSS.INPUTHEIGHT}}\">{{get_string \"height\" component}}</label>' +\n '<input type=\"text\" class=\"form-control ml-1 input-mini {{CSS.INPUTHEIGHT}}\" ' +\n 'id=\"{{elementid}}_{{CSS.INPUTHEIGHT}}\" size=\"4\"/>' +\n\n // Add the constrain checkbox.\n '<div class=\"form-check ml-2\">' +\n '<input type=\"checkbox\" class=\"form-check-input {{CSS.INPUTCONSTRAIN}}\" ' +\n 'id=\"{{elementid}}_{{CSS.INPUTCONSTRAIN}}\"/>' +\n '<label class=\"form-check-label\" for=\"{{elementid}}_{{CSS.INPUTCONSTRAIN}}\">' +\n '{{get_string \"constrain\" component}}</label>' +\n '</div>' +\n '</div>' +\n '</div>' +\n\n // Add the alignment selector.\n '<div class=\"form-inline mb-1\">' +\n '<label class=\"for=\"{{elementid}}_{{CSS.INPUTALIGNMENT}}\">{{get_string \"alignment\" component}}</label>' +\n '<select class=\"custom-select {{CSS.INPUTALIGNMENT}}\" id=\"{{elementid}}_{{CSS.INPUTALIGNMENT}}\">' +\n '{{#each alignments}}' +\n '<option value=\"{{value}}\">{{get_string str ../component}}</option>' +\n '{{/each}}' +\n '</select>' +\n '</div>' +\n // Hidden input to store custom styles.\n '<input type=\"hidden\" class=\"{{CSS.INPUTCUSTOMSTYLE}}\"/>' +\n '<br/>' +\n\n // Add the image preview.\n '<div class=\"mdl-align\">' +\n '<div class=\"{{CSS.IMAGEPREVIEWBOX}}\">' +\n '<img src=\"#\" class=\"{{CSS.IMAGEPREVIEW}}\" alt=\"\" style=\"display: none;\"/>' +\n '</div>' +\n\n // Add the submit button and close the form.\n '<button class=\"btn btn-secondary {{CSS.INPUTSUBMIT}}\" type=\"submit\">' + '' +\n '{{get_string \"saveimage\" component}}</button>' +\n '</div>' +\n '</form>',\n\n IMAGETEMPLATE = '' +\n '<img src=\"{{url}}\" alt=\"{{alt}}\" ' +\n '{{#if width}}width=\"{{width}}\" {{/if}}' +\n '{{#if height}}height=\"{{height}}\" {{/if}}' +\n '{{#if presentation}}role=\"presentation\" {{/if}}' +\n '{{#if customstyle}}style=\"{{customstyle}}\" {{/if}}' +\n '{{#if classlist}}class=\"{{classlist}}\" {{/if}}' +\n '{{#if id}}id=\"{{id}}\" {{/if}}' +\n '/>';\n\nY.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {\n /**\n * A reference to the current selection at the time that the dialogue\n * was opened.\n *\n * @property _currentSelection\n * @type Range\n * @private\n */\n _currentSelection: null,\n\n /**\n * The most recently selected image.\n *\n * @param _selectedImage\n * @type Node\n * @private\n */\n _selectedImage: null,\n\n /**\n * A reference to the currently open form.\n *\n * @param _form\n * @type Node\n * @private\n */\n _form: null,\n\n /**\n * The dimensions of the raw image before we manipulate it.\n *\n * @param _rawImageDimensions\n * @type Object\n * @private\n */\n _rawImageDimensions: null,\n\n initializer: function() {\n\n this.addButton({\n icon: 'e/insert_edit_image',\n callback: this._displayDialogue,\n tags: 'img',\n tagMatchRequiresAll: false\n });\n this.editor.delegate('dblclick', this._displayDialogue, 'img', this);\n this.editor.delegate('click', this._handleClick, 'img', this);\n this.editor.on('paste', this._handlePaste, this);\n this.editor.on('drop', this._handleDragDrop, this);\n\n // e.preventDefault needed to stop the default event from clobbering the desired behaviour in some browsers.\n this.editor.on('dragover', function(e) {\n e.preventDefault();\n }, this);\n this.editor.on('dragenter', function(e) {\n e.preventDefault();\n }, this);\n },\n\n /**\n * Handle a drag and drop event with an image.\n *\n * @method _handleDragDrop\n * @param {EventFacade} e\n * @return {boolean} false if we handled the event, else true.\n * @private\n */\n _handleDragDrop: function(e) {\n if (!e._event || !e._event.dataTransfer) {\n // Drop not fully supported in this browser.\n return true;\n }\n\n return this._handlePasteOrDropHelper(e, e._event.dataTransfer);\n },\n\n /**\n * Handles paste events where - if the thing being pasted is an image.\n *\n * @method _handlePaste\n * @param {EventFacade} e\n * @return {boolean} false if we handled the event, else true.\n * @private\n */\n _handlePaste: function(e) {\n if (!e._event || !e._event.clipboardData) {\n // Paste not fully supported in this browser.\n return true;\n }\n\n return this._handlePasteOrDropHelper(e, e._event.clipboardData);\n },\n\n /**\n * Handle a drag and drop event with an image.\n *\n * @method _handleDragDrop\n * @param {EventFacade} e\n * @param {DataTransfer} dataTransfer\n * @return {boolean} false if we handled the event, else true.\n * @private\n */\n _handlePasteOrDropHelper: function(e, dataTransfer) {\n\n var items = dataTransfer.items,\n didUpload = false;\n for (var i = 0; i < items.length; i++) {\n var item = items[i];\n if (item.kind !== 'file') {\n continue;\n }\n if (!this._isImage(item.type)) {\n continue;\n }\n this._uploadImage(item.getAsFile());\n didUpload = true;\n }\n\n if (didUpload) {\n // We handled this.\n e.preventDefault();\n e.stopPropagation();\n return false;\n } else {\n // Let someone else try to handle it.\n return true;\n }\n },\n\n /**\n * Is this file an image?\n *\n * @method _isImage\n * @param {string} mimeType the file's mime type.\n * @return {boolean} true if the file has an image mimeType.\n * @private\n */\n _isImage: function(mimeType) {\n return mimeType.indexOf('image/') === 0;\n },\n\n /**\n * Used by _handleDragDrop and _handlePaste to upload an image and insert it.\n *\n * @method _uploadImage\n * @param {File} fileToSave\n * @private\n */\n _uploadImage: function(fileToSave) {\n\n var self = this,\n host = this.get('host'),\n template = Y.Handlebars.compile(IMAGETEMPLATE);\n\n host.saveSelection();\n\n var options = host.get('filepickeroptions').image,\n savepath = (options.savepath === undefined) ? '/' : options.savepath,\n formData = new FormData(),\n timestamp = 0,\n uploadid = \"\",\n xhr = new XMLHttpRequest(),\n imagehtml = \"\",\n keys = Object.keys(options.repositories);\n\n formData.append('repo_upload_file', fileToSave);\n formData.append('itemid', options.itemid);\n\n // List of repositories is an object rather than an array. This makes iteration more awkward.\n for (var i = 0; i < keys.length; i++) {\n if (options.repositories[keys[i]].type === 'upload') {\n formData.append('repo_id', options.repositories[keys[i]].id);\n break;\n }\n }\n formData.append('env', options.env);\n formData.append('sesskey', M.cfg.sesskey);\n formData.append('client_id', options.client_id);\n formData.append('savepath', savepath);\n formData.append('ctx_id', options.context.id);\n\n // Insert spinner as a placeholder.\n timestamp = new Date().getTime();\n uploadid = 'moodleimage_' + Math.round(Math.random() * 100000) + '-' + timestamp;\n host.focus();\n host.restoreSelection();\n imagehtml = template({\n url: M.util.image_url(\"i/loading_small\", 'moodle'),\n alt: M.util.get_string('uploading', COMPONENTNAME),\n id: uploadid\n });\n host.insertContentAtFocusPoint(imagehtml);\n self.markUpdated();\n\n // Kick off a XMLHttpRequest.\n xhr.onreadystatechange = function() {\n var placeholder = self.editor.one('#' + uploadid),\n result,\n file,\n newhtml,\n newimage;\n\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n result = JSON.parse(xhr.responseText);\n if (result) {\n if (result.error) {\n if (placeholder) {\n placeholder.remove(true);\n }\n throw new M.core.ajaxException(result);\n }\n\n file = result;\n if (result.event && result.event === 'fileexists') {\n // A file with this name is already in use here - rename to avoid conflict.\n // Chances are, it's a different image (stored in a different folder on the user's computer).\n // If the user wants to reuse an existing image, they can copy/paste it within the editor.\n file = result.newfile;\n }\n\n // Replace placeholder with actual image.\n newhtml = template({\n url: file.url,\n presentation: true\n });\n newimage = Y.Node.create(newhtml);\n if (placeholder) {\n placeholder.replace(newimage);\n } else {\n self.editor.appendChild(newimage);\n }\n self.markUpdated();\n }\n } else {\n Y.use('moodle-core-notification-alert', function() {\n new M.core.alert({message: M.util.get_string('servererror', 'moodle')});\n });\n if (placeholder) {\n placeholder.remove(true);\n }\n }\n }\n };\n xhr.open(\"POST\", M.cfg.wwwroot + '/repository/repository_ajax.php?action=upload', true);\n xhr.send(formData);\n },\n\n /**\n * Handle a click on an image.\n *\n * @method _handleClick\n * @param {EventFacade} e\n * @private\n */\n _handleClick: function(e) {\n var image = e.target;\n\n var selection = this.get('host').getSelectionFromNode(image);\n if (this.get('host').getSelection() !== selection) {\n this.get('host').setSelection(selection);\n }\n },\n\n /**\n * Display the image editing tool.\n *\n * @method _displayDialogue\n * @private\n */\n _displayDialogue: function() {\n // Store the current selection.\n this._currentSelection = this.get('host').getSelection();\n if (this._currentSelection === false) {\n return;\n }\n\n // Reset the image dimensions.\n this._rawImageDimensions = null;\n\n var dialogue = this.getDialogue({\n headerContent: M.util.get_string('imageproperties', COMPONENTNAME),\n width: 'auto',\n focusAfterHide: true,\n focusOnShowSelector: SELECTORS.INPUTURL\n });\n // Set a maximum width for the dialog. This will prevent the dialog width to extend beyond the screen width\n // in cases when the uploaded image has larger width.\n dialogue.get('boundingBox').setStyle('maxWidth', '90%');\n // Set the dialogue content, and then show the dialogue.\n dialogue.set('bodyContent', this._getDialogueContent())\n .show();\n },\n\n /**\n * Set the inputs for width and height if they are not set, and calculate\n * if the constrain checkbox should be checked or not.\n *\n * @method _loadPreviewImage\n * @param {String} url\n * @private\n */\n _loadPreviewImage: function(url) {\n var image = new Image();\n var self = this;\n\n image.onerror = function() {\n var preview = self._form.one('.' + CSS.IMAGEPREVIEW);\n preview.setStyles({\n 'display': 'none'\n });\n\n // Centre the dialogue when clearing the image preview.\n self.getDialogue().centerDialogue();\n };\n\n image.onload = function() {\n var input, currentwidth, currentheight, widthRatio, heightRatio;\n\n self._rawImageDimensions = {\n width: this.width,\n height: this.height\n };\n\n input = self._form.one('.' + CSS.INPUTWIDTH);\n currentwidth = input.get('value');\n if (currentwidth === '') {\n input.set('value', this.width);\n currentwidth = \"\" + this.width;\n }\n input = self._form.one('.' + CSS.INPUTHEIGHT);\n currentheight = input.get('value');\n if (currentheight === '') {\n input.set('value', this.height);\n currentheight = \"\" + this.height;\n }\n input = self._form.one('.' + CSS.IMAGEPREVIEW);\n input.setAttribute('src', this.src);\n input.setStyles({\n 'display': 'inline'\n });\n\n input = self._form.one('.' + CSS.INPUTCONSTRAIN);\n if (currentwidth.match(REGEX.ISPERCENT) && currentheight.match(REGEX.ISPERCENT)) {\n input.set('checked', currentwidth === currentheight);\n } else {\n if (this.width === 0) {\n this.width = 1;\n }\n if (this.height === 0) {\n this.height = 1;\n }\n // This is the same as comparing to 3 decimal places.\n widthRatio = Math.round(1000 * parseInt(currentwidth, 10) / this.width);\n heightRatio = Math.round(1000 * parseInt(currentheight, 10) / this.height);\n input.set('checked', widthRatio === heightRatio);\n }\n\n // Apply the image sizing.\n self._autoAdjustSize(self);\n\n // Centre the dialogue once the preview image has loaded.\n self.getDialogue().centerDialogue();\n };\n\n image.src = url;\n },\n\n /**\n * Return the dialogue content for the tool, attaching any required\n * events.\n *\n * @method _getDialogueContent\n * @return {Node} The content to place in the dialogue.\n * @private\n */\n _getDialogueContent: function() {\n var template = Y.Handlebars.compile(TEMPLATE),\n canShowFilepicker = this.get('host').canShowFilepicker('image'),\n content = Y.Node.create(template({\n elementid: this.get('host').get('elementid'),\n CSS: CSS,\n component: COMPONENTNAME,\n showFilepicker: canShowFilepicker,\n alignments: ALIGNMENTS\n }));\n\n this._form = content;\n\n // Configure the view of the current image.\n this._applyImageProperties(this._form);\n\n this._form.one('.' + CSS.INPUTURL).on('blur', this._urlChanged, this);\n this._form.one('.' + CSS.IMAGEPRESENTATION).on('change', this._updateWarning, this);\n this._form.one('.' + CSS.INPUTALT).on('change', this._updateWarning, this);\n this._form.one('.' + CSS.INPUTWIDTH).on('blur', this._autoAdjustSize, this);\n this._form.one('.' + CSS.INPUTHEIGHT).on('blur', this._autoAdjustSize, this, true);\n this._form.one('.' + CSS.INPUTCONSTRAIN).on('change', function(event) {\n if (event.target.get('checked')) {\n this._autoAdjustSize(event);\n }\n }, this);\n this._form.one('.' + CSS.INPUTURL).on('blur', this._urlChanged, this);\n this._form.one('.' + CSS.INPUTSUBMIT).on('click', this._setImage, this);\n\n if (canShowFilepicker) {\n this._form.one('.' + CSS.IMAGEBROWSER).on('click', function() {\n this.get('host').showFilepicker('image', this._filepickerCallback, this);\n }, this);\n }\n\n // Character count.\n this._form.one('.' + CSS.INPUTALT).on('keyup', this._handleKeyup, this);\n\n return content;\n },\n\n _autoAdjustSize: function(e, forceHeight) {\n forceHeight = forceHeight || false;\n\n var keyField = this._form.one('.' + CSS.INPUTWIDTH),\n keyFieldType = 'width',\n subField = this._form.one('.' + CSS.INPUTHEIGHT),\n subFieldType = 'height',\n constrainField = this._form.one('.' + CSS.INPUTCONSTRAIN),\n keyFieldValue = keyField.get('value'),\n subFieldValue = subField.get('value'),\n imagePreview = this._form.one('.' + CSS.IMAGEPREVIEW),\n rawPercentage,\n rawSize;\n\n // If we do not know the image size, do not do anything.\n if (!this._rawImageDimensions) {\n return;\n }\n\n // Set the width back to default if it is empty.\n if (keyFieldValue === '') {\n keyFieldValue = this._rawImageDimensions[keyFieldType];\n keyField.set('value', keyFieldValue);\n keyFieldValue = keyField.get('value');\n }\n\n // Clear the existing preview sizes.\n imagePreview.setStyles({\n width: null,\n height: null\n });\n\n // Now update with the new values.\n if (!constrainField.get('checked')) {\n // We are not keeping the image proportion - update the preview accordingly.\n\n // Width.\n if (keyFieldValue.match(REGEX.ISPERCENT)) {\n rawPercentage = parseInt(keyFieldValue, 10);\n rawSize = this._rawImageDimensions.width / 100 * rawPercentage;\n imagePreview.setStyle('width', rawSize + 'px');\n } else {\n imagePreview.setStyle('width', keyFieldValue + 'px');\n }\n\n // Height.\n if (subFieldValue.match(REGEX.ISPERCENT)) {\n rawPercentage = parseInt(subFieldValue, 10);\n rawSize = this._rawImageDimensions.height / 100 * rawPercentage;\n imagePreview.setStyle('height', rawSize + 'px');\n } else {\n imagePreview.setStyle('height', subFieldValue + 'px');\n }\n } else {\n // We are keeping the image in proportion.\n if (forceHeight) {\n // By default we update based on width. Swap the key and sub fields around to achieve a height-based scale.\n var _temporaryValue;\n _temporaryValue = keyField;\n keyField = subField;\n subField = _temporaryValue;\n\n _temporaryValue = keyFieldType;\n keyFieldType = subFieldType;\n subFieldType = _temporaryValue;\n\n _temporaryValue = keyFieldValue;\n keyFieldValue = subFieldValue;\n subFieldValue = _temporaryValue;\n }\n\n if (keyFieldValue.match(REGEX.ISPERCENT)) {\n // This is a percentage based change. Copy it verbatim.\n subFieldValue = keyFieldValue;\n\n // Set the width to the calculated pixel width.\n rawPercentage = parseInt(keyFieldValue, 10);\n rawSize = this._rawImageDimensions.width / 100 * rawPercentage;\n\n // And apply the width/height to the container.\n imagePreview.setStyle('width', rawSize);\n rawSize = this._rawImageDimensions.height / 100 * rawPercentage;\n imagePreview.setStyle('height', rawSize);\n } else {\n // Calculate the scaled subFieldValue from the keyFieldValue.\n subFieldValue = Math.round((keyFieldValue / this._rawImageDimensions[keyFieldType]) *\n this._rawImageDimensions[subFieldType]);\n\n if (forceHeight) {\n imagePreview.setStyles({\n 'width': subFieldValue,\n 'height': keyFieldValue\n });\n } else {\n imagePreview.setStyles({\n 'width': keyFieldValue,\n 'height': subFieldValue\n });\n }\n }\n\n // Update the subField's value within the form to reflect the changes.\n subField.set('value', subFieldValue);\n }\n },\n\n /**\n * Update the dialogue after an image was selected in the File Picker.\n *\n * @method _filepickerCallback\n * @param {object} params The parameters provided by the filepicker\n * containing information about the image.\n * @private\n */\n _filepickerCallback: function(params) {\n if (params.url !== '') {\n var input = this._form.one('.' + CSS.INPUTURL);\n input.set('value', params.url);\n\n // Auto set the width and height.\n this._form.one('.' + CSS.INPUTWIDTH).set('value', '');\n this._form.one('.' + CSS.INPUTHEIGHT).set('value', '');\n\n // Load the preview image.\n this._loadPreviewImage(params.url);\n }\n },\n\n /**\n * Applies properties of an existing image to the image dialogue for editing.\n *\n * @method _applyImageProperties\n * @param {Node} form\n * @private\n */\n _applyImageProperties: function(form) {\n var properties = this._getSelectedImageProperties(),\n img = form.one('.' + CSS.IMAGEPREVIEW);\n\n if (properties === false) {\n img.setStyle('display', 'none');\n // Set the default alignment.\n ALIGNMENTS.some(function(alignment) {\n if (alignment.isDefault) {\n form.one('.' + CSS.INPUTALIGNMENT).set('value', alignment.value);\n return true;\n }\n\n return false;\n }, this);\n\n return;\n }\n\n if (properties.align) {\n form.one('.' + CSS.INPUTALIGNMENT).set('value', properties.align);\n }\n if (properties.customstyle) {\n form.one('.' + CSS.INPUTCUSTOMSTYLE).set('value', properties.customstyle);\n }\n if (properties.width) {\n form.one('.' + CSS.INPUTWIDTH).set('value', properties.width);\n }\n if (properties.height) {\n form.one('.' + CSS.INPUTHEIGHT).set('value', properties.height);\n }\n if (properties.alt) {\n form.one('.' + CSS.INPUTALT).set('value', properties.alt);\n }\n if (properties.src) {\n form.one('.' + CSS.INPUTURL).set('value', properties.src);\n this._loadPreviewImage(properties.src);\n }\n if (properties.presentation) {\n form.one('.' + CSS.IMAGEPRESENTATION).set('checked', 'checked');\n }\n\n // Update the image preview based on the form properties.\n this._autoAdjustSize();\n },\n\n /**\n * Gets the properties of the currently selected image.\n *\n * The first image only if multiple images are selected.\n *\n * @method _getSelectedImageProperties\n * @return {object}\n * @private\n */\n _getSelectedImageProperties: function() {\n var properties = {\n src: null,\n alt: null,\n width: null,\n height: null,\n align: '',\n presentation: false\n },\n\n // Get the current selection.\n images = this.get('host').getSelectedNodes(),\n width,\n height,\n style,\n image;\n\n if (images) {\n images = images.filter('img');\n }\n\n if (images && images.size()) {\n image = this._removeLegacyAlignment(images.item(0));\n this._selectedImage = image;\n\n style = image.getAttribute('style');\n properties.customstyle = style;\n\n width = image.getAttribute('width');\n if (!width.match(REGEX.ISPERCENT)) {\n width = parseInt(width, 10);\n }\n height = image.getAttribute('height');\n if (!height.match(REGEX.ISPERCENT)) {\n height = parseInt(height, 10);\n }\n\n if (width !== 0) {\n properties.width = width;\n }\n if (height !== 0) {\n properties.height = height;\n }\n this._getAlignmentPropeties(image, properties);\n properties.src = image.getAttribute('src');\n properties.alt = image.getAttribute('alt') || '';\n properties.presentation = (image.get('role') === 'presentation');\n return properties;\n }\n\n // No image selected - clean up.\n this._selectedImage = null;\n return false;\n },\n\n /**\n * Sets the alignment of a properties object.\n *\n * @method _getAlignmentPropeties\n * @param {Node} image The image that the alignment properties should be found for\n * @param {Object} properties The properties object that is created in _getSelectedImageProperties()\n * @private\n */\n _getAlignmentPropeties: function(image, properties) {\n var complete = false,\n defaultAlignment;\n\n // Check for an alignment value.\n complete = ALIGNMENTS.some(function(alignment) {\n var classname = this._getAlignmentClass(alignment.value);\n if (image.hasClass(classname)) {\n properties.align = alignment.value;\n Y.log('Found alignment ' + alignment.value, 'debug', 'atto_image-button');\n\n return true;\n }\n\n if (alignment.isDefault) {\n defaultAlignment = alignment.value;\n }\n\n return false;\n }, this);\n\n if (!complete && defaultAlignment) {\n properties.align = defaultAlignment;\n }\n },\n\n /**\n * Update the form when the URL was changed. This includes updating the\n * height, width, and image preview.\n *\n * @method _urlChanged\n * @private\n */\n _urlChanged: function() {\n var input = this._form.one('.' + CSS.INPUTURL);\n\n if (input.get('value') !== '') {\n // Load the preview image.\n this._loadPreviewImage(input.get('value'));\n }\n },\n\n /**\n * Update the image in the contenteditable.\n *\n * @method _setImage\n * @param {EventFacade} e\n * @private\n */\n _setImage: function(e) {\n var form = this._form,\n url = form.one('.' + CSS.INPUTURL).get('value'),\n alt = form.one('.' + CSS.INPUTALT).get('value'),\n width = form.one('.' + CSS.INPUTWIDTH).get('value'),\n height = form.one('.' + CSS.INPUTHEIGHT).get('value'),\n alignment = this._getAlignmentClass(form.one('.' + CSS.INPUTALIGNMENT).get('value')),\n presentation = form.one('.' + CSS.IMAGEPRESENTATION).get('checked'),\n constrain = form.one('.' + CSS.INPUTCONSTRAIN).get('checked'),\n imagehtml,\n customstyle = form.one('.' + CSS.INPUTCUSTOMSTYLE).get('value'),\n classlist = [],\n host = this.get('host');\n\n e.preventDefault();\n\n // Check if there are any accessibility issues.\n if (this._updateWarning()) {\n return;\n }\n\n // Focus on the editor in preparation for inserting the image.\n host.focus();\n if (url !== '') {\n if (this._selectedImage) {\n host.setSelection(host.getSelectionFromNode(this._selectedImage));\n } else {\n host.setSelection(this._currentSelection);\n }\n\n if (constrain) {\n classlist.push(CSS.RESPONSIVE);\n }\n\n // Add the alignment class for the image.\n classlist.push(alignment);\n\n if (!width.match(REGEX.ISPERCENT) && isNaN(parseInt(width, 10))) {\n form.one('.' + CSS.INPUTWIDTH).focus();\n return;\n }\n if (!height.match(REGEX.ISPERCENT) && isNaN(parseInt(height, 10))) {\n form.one('.' + CSS.INPUTHEIGHT).focus();\n return;\n }\n\n var template = Y.Handlebars.compile(IMAGETEMPLATE);\n imagehtml = template({\n url: url,\n alt: alt,\n width: width,\n height: height,\n presentation: presentation,\n customstyle: customstyle,\n classlist: classlist.join(' ')\n });\n\n this.get('host').insertContentAtFocusPoint(imagehtml);\n\n this.markUpdated();\n }\n\n this.getDialogue({\n focusAfterHide: null\n }).hide();\n\n },\n\n /**\n * Removes any legacy styles added by previous versions of the atto image button.\n *\n * @method _removeLegacyAlignment\n * @param {Y.Node} imageNode\n * @return {Y.Node}\n * @private\n */\n _removeLegacyAlignment: function(imageNode) {\n if (!imageNode.getStyle('margin')) {\n // There is no margin therefore this cannot match any known alignments.\n return imageNode;\n }\n\n ALIGNMENTS.some(function(alignment) {\n if (imageNode.getStyle(alignment.name) !== alignment.value) {\n // The name/value do not match. Skip.\n return false;\n }\n\n var normalisedNode = Y.Node.create('<div>');\n normalisedNode.setStyle('margin', alignment.margin);\n if (imageNode.getStyle('margin') !== normalisedNode.getStyle('margin')) {\n // The margin does not match.\n return false;\n }\n\n Y.log('Legacy alignment found and removed.', 'info', 'atto_image-button');\n imageNode.addClass(this._getAlignmentClass(alignment.value));\n imageNode.setStyle(alignment.name, null);\n imageNode.setStyle('margin', null);\n\n return true;\n }, this);\n\n return imageNode;\n },\n\n _getAlignmentClass: function(alignment) {\n return CSS.ALIGNSETTINGS + '_' + alignment;\n },\n\n /**\n * Update the alt text warning live.\n *\n * @method _updateWarning\n * @return {boolean} whether a warning should be displayed.\n * @private\n */\n _updateWarning: function() {\n var form = this._form,\n state = true,\n alt = form.one('.' + CSS.INPUTALT).get('value'),\n presentation = form.one('.' + CSS.IMAGEPRESENTATION).get('checked');\n if (alt === '' && !presentation) {\n form.one('.' + CSS.IMAGEALTWARNING).setStyle('display', 'block');\n form.one('.' + CSS.INPUTALT).setAttribute('aria-invalid', true);\n form.one('.' + CSS.IMAGEPRESENTATION).setAttribute('aria-invalid', true);\n state = true;\n } else {\n form.one('.' + CSS.IMAGEALTWARNING).setStyle('display', 'none');\n form.one('.' + CSS.INPUTALT).setAttribute('aria-invalid', false);\n form.one('.' + CSS.IMAGEPRESENTATION).setAttribute('aria-invalid', false);\n state = false;\n }\n this.getDialogue().centerDialogue();\n return state;\n },\n\n /**\n * Handle the keyup to update the character count.\n */\n _handleKeyup: function() {\n var form = this._form,\n alt = form.one('.' + CSS.INPUTALT).get('value'),\n characterCount = alt.length,\n current = form.one('#currentcount');\n current.setHTML(characterCount);\n }\n});\n"],"file":"button.min.js"}