mirror of
https://github.com/hanzoai/jube-fork.git
synced 2026-11-02 14:29:36 +00:00
27 lines
27 KiB
JavaScript
Executable File
27 lines
27 KiB
JavaScript
Executable File
/**
|
|
* Kendo UI v2021.1.224 (http://www.telerik.com/kendo-ui)
|
|
* Copyright 2021 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
|
|
*
|
|
* Kendo UI commercial licenses may be obtained at
|
|
* http://www.telerik.com/purchase/license-agreement/kendo-ui-complete
|
|
* If you do not own a commercial license, this file shall be governed by the trial license terms.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
!function(e,define){define("imageeditor/toolbar.min",["kendo.toolbar.min","kendo.dropdownlist.min"],e)}(function(){return function(e,t){var o=window.kendo,i=o.ui,n=e.extend,a=e.proxy,r=o.ui.ToolBar,d=o.toolbar.Item,s="click",m="dropDownChange",c="action",l=r.extend({init:function(e,t){var o=this;o._extendOptions(t),r.fn.init.call(o,e,t),o._attachEvents(),o.toggleTools()},events:r.fn.events.concat([m,c]),defaultTools:{open:{type:"button",icon:"upload",name:"open",command:"OpenImageEditorCommand",showText:"overflow"},save:{type:"button",icon:"download",name:"save",command:"SaveImageEditorCommand",showText:"overflow",toggleCondition:"canExport"},separator:{type:"separator"},undo:{type:"button",icon:"undo",name:"undo",command:"UndoImageEditorCommand",showText:"overflow",toggleCondition:"undo"},redo:{type:"button",icon:"redo",name:"redo",command:"RedoImageEditorCommand",showText:"overflow",toggleCondition:"redo"},separator1:{type:"separator"},crop:{type:"button",icon:"crop",name:"crop",command:"OpenPaneImageEditorCommand",options:"crop",showText:"overflow",toggleCondition:"canExport"},resize:{type:"button",icon:"image-resize",name:"resize",command:"OpenPaneImageEditorCommand",options:"resize",showText:"overflow",toggleCondition:"canExport"},zoomIn:{type:"button",icon:"zoom-in",name:"zoomIn",command:"ZoomImageEditorCommand",showText:"overflow",options:"zoomIn",toggleCondition:"enable"},zoomOut:{type:"button",icon:"zoom-out",name:"zoomOut",command:"ZoomImageEditorCommand",showText:"overflow",options:"zoomOut",toggleCondition:"enable"},zoomDropdown:{type:"imageEditorZoomDropDown",name:"zoomDropdown",command:"ZoomImageEditorCommand",text:"Zoom options",toggleCondition:"enable",items:[{name:"zoomActualSize",icon:"zoom-actual-size",text:"Show actual size",options:"actualSize"},{name:"zoomFitToScreen",icon:"zoom-best-fit",text:"Fit to screen",options:"fitToScreen"}]}},_attachEvents:function(){var e=this;e.bind(m,a(e._dropDownChange,e)),e.bind(s,a(e._click,e))},_extendOptions:function(e){var t=this,o=e.items?e.items:Object.keys(t.defaultTools);t.options=e,t.options.items=t._extendToolsOptions(o)},_extendToolsOptions:function(t){var i=this,a=i.options.messages;if(t.length)return t.map(function(t){var r,d,s=e.isPlainObject(t)&&1===Object.keys(t).length&&t.name;return t=s?t.name:t,r=e.isPlainObject(t)?t:n({},i.defaultTools[t]),d=a[r.name]||r.text,o.deepExtend(r,{id:r.name+"-"+o.guid(),name:r.name,text:d,attributes:{"aria-label":d,title:d,"data-command":r.command,"data-options":r.options,"data-toggle":r.toggleCondition},overflow:r.overflow}),"imageEditorZoomDropDown"===r.type&&(r.items=i._extendToolsOptions(r.items)),r},i)},_click:function(t){var o=e(t.target).data("command"),i=e(t.target).data("options");o&&this.action({command:o,options:i})},_dropDownChange:function(e){e.command&&this.action({command:e.command,options:e.options})},action:function(e){this.trigger(c,e)},toggleTools:function(t){var i=this,n=i.element.find("[data-toggle]");n.each(function(n,a){var r=e(a),d=null,s=r.data("toggle"),m=t&&t[s];r.is("[data-role]")&&(d=o.widgetInstance(r)),d&&d.enable?d.enable(m||!1):i.enable(r,m)})},destroy:function(){var e=this;e.zoomDropdown&&e.zoomDropdown.destroy(),r.fn.destroy.call(this)}}),p=d.extend({init:function(t,o){var n=this,r=e("<div></div>"),d=e("<input />").attr(t.attributes),s='<span class="k-icon k-i-#:icon#"></span> #:text#';n.element=r,n.input=d,n.toolbar=o,n.dropDown=new i.DropDownList(n.input,{optionLabel:{text:t.text,icon:""},dataTextField:"text",dataSource:t.items,template:s,change:a(n._change,n)}),n.element.append(n.dropDown.wrapper),n.dropDown.list.find(".k-list-optionlabel").hide(),n.toolbar.zoomDropdown=n},_change:function(e){var t=this;t.toolbar.trigger(m,{command:e.sender.element.data("command"),options:e.sender.dataItem().options})},destroy:function(){this.dropDown.destroy()}});o.toolbar.registerComponent("imageEditorZoomDropDown",p),n(o.ui,{imageeditor:{ToolBar:l,ZoomDropDown:p}})}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t,o){(o||t)()}),function(e,define){define("imageeditor/pane.min",["kendo.core.min","kendo.form.min","kendo.buttongroup.min","kendo.draganddrop.min"],e)}(function(){return function(e,t){var o=window.kendo,i=e.extend,n=e.proxy,a=o.Class,r=".k-imageeditor-pane",d="click",s={form:"k-imageeditor-pane-form",button:"k-imageeditor-pane-button",confirmButton:"k-imageeditor-pane-confirm-button",cropOverlay:"k-imageeditor-crop-overlay",crop:"k-imageeditor-crop",resizeHandle:"k-resize-handle",resizeHandlePrefix:"k-resize-"},m=function(e){return Math.round(1e3*e)/1e3},c=a.extend({init:function(t){var o=this;o.imageeditor=t,o.imageeditor.currentPaneTool&&o.imageeditor.currentPaneTool.destroy(),o.element=e("<div></div>").addClass(s.form)},open:function(){var e=this,t=e.imageeditor,n=t.options.messages.common;t.paneWrapper.append(e.element),e.formWidget=new o.ui.Form(e.element,i(e.formSettings(),{buttonsTemplate:o.format("<button class='{0} k-button' data-action='cancel'>{2}</button><button class='{0} {1} k-button k-primary' data-action='confirm'>{3}</button>",s.button,s.confirmButton,n.cancel,n.confirm)})),e.bindButtonEvents(),t.paneWrapper.show(),t.currentPaneTool=e},bindButtonEvents:function(){var e=this,t=e.formWidget,o=t.element.find("."+s.button);e._clickHandler=n(e._click,e),o.on(d+r,e._clickHandler)},_click:function(t){var o=this,i=e(t.target),n=i.data("action");o[n]&&o[n]()},cancel:function(){this.destroy()},confirm:function(){window.console.error("Pane's confirm method is not implemented!"),this.destroy()},refresh:function(){},destroy:function(){var e=this,t=e.imageeditor;e.formWidget.element.find("."+s.button).off(r),e.formWidget.destroy(),t.paneWrapper.html(""),t.paneWrapper.hide(),delete t.currentPaneTool}}),l=c.extend({init:function(e){var t=this;c.fn.init.call(t,e),t.buildCropModel(),t.canvasUI()},confirm:function(){var e=this,t=e.formWidget._model.toJSON();e.destroy(),e.imageeditor.executeCommand({command:"CropImageEditorCommand",options:t})},formSettings:function(){var t,o=this,i=o.imageeditor.options.messages.panes.crop,a=o.imageeditor.options.messages.common,r=i.aspectRatioItems,d=[];if(r)for(t in r)d.push({value:t,text:r[t]});else d=[{value:"originalRatio",text:"Original ratio"},{value:"1:1",text:"1:1 (Square)"},{value:"4:5",text:"4:5 (8:10)"},{value:"5:7",text:"5:7"},{value:"2:3",text:"2:3 (4:6)"},{value:"16:9",text:"16:9"}];return{formData:o._model,change:n(o.onChange,o),items:[{type:"group",label:i.title||"Crop Image",layout:"grid",grid:{cols:2,gutter:"0 8px"},items:[{label:i.aspectRatio||"Aspect ratio:",field:"aspectRatio",editor:"DropDownList",editorOptions:{dataValueField:"value",dataTextField:"text",dataSource:d},colSpan:2},{label:i.orientation,field:"orientation",editor:e.proxy(o._orientationEditor,o),colSpan:2},{label:a.width||"Width:",field:"width",attributes:{style:"max-width: 100px;"},editor:"NumericTextBox",editorOptions:{format:"n0",max:o._model.width,min:0},colSpan:1},{label:a.height||"Height:",field:"height",attributes:{style:"max-width: 100px;"},editor:"NumericTextBox",editorOptions:{format:"n0",max:o._model.height,min:0},colSpan:1},{label:a.lockAspectRatio||"Lock aspect ratio",field:"lockAspectRatio",colSpan:2}]}]}},_orientationEditor:function(t,o){var i=this,n=i.imageeditor.options.messages.panes.crop,a=o.model[o.field];e("<div name='"+o.field+"'></div>").appendTo(t).kendoButtonGroup({items:[{text:n.portrait||"Portrait",attributes:{"data-value":"portrait"},selected:"portrait"===a},{text:n.landscape||"Landscape",attributes:{"data-value":"landscape"},selected:"landscape"===a}],select:function(e){var t=e.sender.wrapper.find(".k-state-active").data("value");o.model.set(o.field,t)}})},buildCropModel:function(){var e=this,t=e.imageeditor,o=t.getCanvasElement(),i=o.width,n=o.height;e._model={top:0,left:0,aspectRatio:"originalRatio",width:i,height:n,orientation:i-n<0?"portrait":"landscape",lockAspectRatio:!0}},canvasUI:function(){var t,i,n,a,r,d=this,m=d.imageeditor,c=d.imageeditor.canvasContainer,l=e("<div></div>").addClass(s.cropOverlay),p=e("<div></div>").addClass(s.crop),h="<span class='"+s.resizeHandle+"'></span>",g=["nw","n","ne","w","e","sw","s","se"],u=m.getZoomLevel();for(t=0;t<g.length;t++)i=e(h).addClass(s.resizeHandlePrefix+g[t]).attr("data-orientation",g[t]),d._initResizeHandle(i),p.append(i);d.cropElement=p,d._canvasUI=l.append(p).appendTo(c),n=Math.round(d._model.width*u),a=Math.round(d._model.height*u),r=parseInt(d.cropElement.css("border-top-width"),10),d.cropElement.css({width:n,height:a,backgroundImage:"url('"+m._image.src+"')",backgroundSize:o.format("{0}px {1}px",n,a),backgroundClip:"content-box",backgroundPosition:o.format("-{0}px -{0}px",r)}),d.cropElement.kendoDraggable({ignore:"."+s.resizeHandle,drag:function(e){d._adjustTopLeft(e.target.offsetTop+e.y.delta,e.target.offsetLeft+e.x.delta)}})},refresh:function(){var e=this,t=e.formWidget._model,i=e.imageeditor.getZoomLevel(),n=Math.round(t.width*i),a=Math.round(t.height*i),r=Math.round(t.top*i),d=Math.round(t.left*i),s=parseInt(e.cropElement.css("border-top-width"),10);e.cropElement.css({top:r,left:d,width:n,height:a,backgroundSize:o.format("{0}px {1}px",e._model.width*i,e._model.height*i),backgroundPosition:o.format("-{0}px -{1}px",d+s,r+s)})},_initResizeHandle:function(t){var o=this;t.kendoDraggable({drag:function(t){var i=e(t.sender.element),n=o.formWidget._model,a=o._model,r=i.data("orientation"),d={},s=o.imageeditor.getZoomLevel(),m=n.left*s,c=n.top*s;r.indexOf("w")>=0?(d.left=o.cropElement[0].offsetLeft+t.x.delta,d.width=o.cropElement[0].offsetWidth-t.x.delta):r.indexOf("e")>=0&&(d.width=o.cropElement[0].offsetWidth+t.x.delta),r.indexOf("n")>=0?(d.top=o.cropElement[0].offsetTop+t.y.delta,d.height=o.cropElement[0].offsetHeight-t.y.delta):r.indexOf("s")>=0&&(d.height=o.cropElement[0].offsetHeight+t.y.delta),d.width&&(d.left||m)+d.width<=a.width*s&&n.set("width",Math.round(d.width/s)),d.height&&(d.top||c)+d.height<=a.height*s&&n.set("height",Math.round(d.height/s)),(d.top||d.left)&&o._adjustTopLeft(d.top,d.left)}})},_adjustTopLeft:function(e,t,o){var i=this,n=o||i.formWidget._model,a=i.formWidget._model,r=i._model,d=i.imageeditor.getZoomLevel();e>=0&&e/d+n.height<=r.height&&a.set("top",Math.round(e/d)),t>=0&&t/d+n.width<=r.width&&a.set("left",Math.round(t/d))},onChange:function(e){var t,n,a,r,d,s,m,c,l,p=this,h=p.imageeditor.getZoomLevel(),g=e.sender._model,u=p._model,f=u.width,v=u.height,w=u.width+":"+u.height,x=p._gcd(u.width,u.height);w=u.width/x+":"+u.height/x,"aspectRatio"===e.field&&"originalRatio"===e.value?(g.set("top",0),g.set("left",0),g.set("width",u.width),g.set("height",u.height),g.set("orientation",u.orientation)):"orientation"===e.field?(t=i({},g,{width:g.height,height:g.width}),n=p._calcSize(t,w,f,v),g.set("width",n.width),g.set("height",n.height)):g.lockAspectRatio&&(a=e.field,r=p._calcSize(g,w,f,v,a),g.set("width",r.width),g.set("height",r.height)),d=Math.round(g.width*h),s=Math.round(g.height*h),m=Math.round(g.top*h),c=Math.round(g.left*h),l=parseInt(p.cropElement.css("border-top-width"),10),p.cropElement.css({top:m,left:c,width:d,height:s,backgroundPosition:o.format("-{0}px -{1}px",c+l,m+l)})},_calcSize:function(e,t,o,i,n){var a,r,d,s,c,l=Math.min(e.width,o),p=Math.min(e.height,i),h="portrait"===e.orientation,g=e.aspectRatio;return g.indexOf(":")<0&&(g=t),g=g.split(":").map(function(e){return parseInt(e,10)}),a=h?Math.min(g[0],g[1]):Math.max(g[0],g[1]),r=h?Math.max(g[0],g[1]):Math.min(g[0],g[1]),d=m(a/r),s=m(l/p),c={width:Math.round(p*d),height:Math.round(l/d)},"width"===n?{width:l,height:c.height}:"height"===n?{width:c.width,height:p}:(s>d?l=c.width:s<d&&(p=c.height),{width:l,height:p})},_gcd:function(e,t){return 0===t?e:this._gcd(t,e%t)},destroy:function(){o.destroy(this._canvasUI),this._canvasUI.remove(),c.fn.destroy.call(this)}}),p=c.extend({init:function(e){c.fn.init.call(this,e),this.buildResizeModel()},confirm:function(){var e=this,t=e._model.width,o=e._model.height,i=e.formWidget._model.toJSON();"percents"===i.measure&&(i.width=t*(i.width/100),i.height=o*(i.height/100)),e.imageeditor.executeCommand({command:"ResizeImageEditorCommand",options:i}),e.destroy()},formSettings:function(){var e=this,t=e.imageeditor.options.messages.panes.resize,o=e.imageeditor.options.messages.common;return{formData:e._model,change:n(e.onChange,e),items:[{type:"group",label:t.title||"Resize image",layout:"grid",grid:{cols:2,gutter:"0 8px"},items:[{label:o.width||"Width:",field:"width",attributes:{style:"max-width: 100px;"},editor:"NumericTextBox",editorOptions:{format:"n0",min:0},colSpan:1},{field:"measureW",editor:"DropDownList",attributes:{style:"max-width: 100px;"},label:{text:" ",encoded:!1},editorOptions:{dataTextField:"text",dataValueField:"value",dataSource:[{text:t.pixels||"Pixels",value:"pixels"},{text:t.percents||"Percents",value:"percents"}]},colSpan:1},{label:o.height||"Height:",field:"height",attributes:{style:"max-width: 100px;"},editor:"NumericTextBox",editorOptions:{format:"n0",min:0},colSpan:1},{field:"measureH",label:{text:" ",encoded:!1},attributes:{style:"max-width: 100px;"},editor:"DropDownList",editorOptions:{dataTextField:"text",dataValueField:"value",dataSource:[{text:t.pixels||"Pixels",value:"pixels"},{text:t.percents||"Percents",value:"percents"}]},colSpan:1},{label:o.lockAspectRatio||"Lock aspect ratio",field:"lockAspectRatio",colSpan:2}]}]}},buildResizeModel:function(){var e=this,t=e.imageeditor,o=t.getCanvasElement(),i=o.width,n=o.height;e._model={width:i,height:n,measure:"pixels",measureW:"pixels",measureH:"pixels",lockAspectRatio:!0,ratio:m(i/n)}},onChange:function(e){var t=this,o=e.sender._model,i=o.lockAspectRatio;"measureW"===e.field||"measureH"===e.field?(o.set("measureW",e.value),o.set("measureH",e.value),o.set("measure",e.value)):"measure"===e.field?t.resetNumericsTo(e.value):"width"===e.field&&i&&!t._preventChange?o.set("height",o.width/o.ratio):"height"===e.field&&i&&!t._preventChange&&o.set("width",o.height*o.ratio),o.set("ratio",m(o.width/o.height))},resetNumericsTo:function(e){var t=this,o=t._model.width,i=t._model.height,n=t.formWidget,a=n._model,r=n.element.find("[name=width]").data("kendoNumericTextBox"),d=n.element.find("[name=height]").data("kendoNumericTextBox"),s="percents"===e,m={percents:{format:"#\\%"},pixels:{format:"n0"}};r.setOptions(m[e]),d.setOptions(m[e]),t._preventChange=!0,a.set("width",s?o/r.value()*100:o*(r.value()/100)),a.set("height",s?i/d.value()*100:i*(d.value()/100)),t._preventChange=!1}});i(o.ui.imageeditor,{ImageEditorPane:c,panes:{crop:l,resize:p}})}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t,o){(o||t)()}),function(e,define){define("imageeditor/commands.min",["imageeditor/pane.min","kendo.upload.min"],e)}(function(){return function(e,t){var o=window.kendo,i=o.ui.imageeditor,n=e.extend,a=e.proxy,r=o.Class,d=r.extend({init:function(e){this.options=n({},e,this.options),this.imageeditor=e.imageeditor}}),s=d.extend({init:function(e){d.fn.init.call(this,e)},exec:function(){var e=this,t=e.imageeditor,o=new i.panes[e.options.value](t);o.open()}}),m=d.extend({options:{zoomStep:.05,spacing:20},init:function(e){d.fn.init.call(this,e)},exec:function(){var t=this,o=t.options,i=o.value,n=t.imageeditor,a=n._image.height,r=n.getZoomLevel(),d=a;isNaN(i)?"string"==typeof i&&(i=t._processStringValue(i,r)):i=parseFloat(i),d=Math.round(a*i),d>0&&(e(n._canvas).css("height",d),n._zoomLevel=i),n.currentPaneTool&&n.currentPaneTool.refresh()},_processStringValue:function(e,t){var o=this,i=o.options,n=o.imageeditor,a=n._image.height,r=n.canvasWrapper.height()-i.spacing,d=i.zoomStep;switch(e){case"zoomIn":return t+d;case"zoomOut":return t-d;case"fitToScreen":return Math.round(r/a*100)/100;default:return 1}}}),c=d.extend({init:function(e){d.fn.init.call(this,e)},exec:function(){var e=this,t=e.options,o=e.imageeditor,i=o.getCanvasElement(),n=o.getCurrent2dContext(),a=n.getImageData(t.left,t.top,t.width,t.height);n.clearRect(0,0,i.width,i.height),i.width=t.width,i.height=t.height,n.putImageData(a,0,0),o.drawImage(i.toDataURL()).done(function(e){o.drawCanvas(e)}).fail(function(e){o.trigger("error",e)})}}),l=d.extend({init:function(e){d.fn.init.call(this,e)},exec:function(){var e=this,t=e.options,o=e.imageeditor,i=o.getCanvasElement(),n=o.getCurrent2dContext(),a=o.getCurrentImage();n.clearRect(0,0,i.width,i.height),i.width=t.width,i.height=t.height,n.drawImage(a,0,0,t.width,t.height),o.drawImage(i.toDataURL()).done(function(e){o.drawCanvas(e)}).fail(function(e){o.trigger("error",e)})}}),p=d.extend({exec:function(){var e=this,t=e.imageeditor,o=t.getCanvasElement(),i=t.getCurrent2dContext(),n=t.undoStack.pop();n&&(t.redoStack.push(t.getCurrentImage()),delete t._image,i.clearRect(0,0,o.width,o.height),o.width=n.width,o.height=n.height,i.drawImage(n,0,0,n.width,n.height),t.drawImage(o.toDataURL()).done(function(e){t.drawCanvas(e)}).fail(function(e){t.trigger("error",e)}))}}),h=d.extend({exec:function(){var e=this,t=e.imageeditor,o=t.getCanvasElement(),i=t.getCurrent2dContext(),n=t.redoStack.pop();n&&(t.undoStack.push(t.getCurrentImage()),delete t._image,i.clearRect(0,0,o.width,o.height),o.width=n.width,o.height=n.height,i.drawImage(n,0,0,n.width,n.height),t.drawImage(o.toDataURL()).done(function(e){t.drawCanvas(e)}).fail(function(e){t.trigger("error",e)}))}}),g=d.extend({exec:function(){var e=this,t=e.imageeditor,i=t.getCanvasElement();o.saveAs(n({},t.options.saveAs,{dataURI:i.toDataURL()}))}}),u=d.extend({exec:function(){var t,o=this,i=o.imageeditor,n=i._upload;n||(t=e("<input type='file' />"),t.kendoUpload({select:a(o.onSelect,o),error:a(o.onError,o),multiple:!1,validation:{allowedExtensions:[".jpg",".jpeg",".gif",".png",".bmp",".tiff",".webp"]}}),i._upload=n=t.getKendoUpload()),n.element.click()},onSelect:function(e){var t=this,o=t.imageeditor,i=e.files[0].rawFile,n=new FileReader;n.addEventListener("load",function(){o.drawImage(n.result).done(function(e){o.trigger("imageLoaded",{image:e})||(o.drawCanvas(e),o._initUndoRedoStack(),o._toggleTools())}).fail(function(e){o.trigger("error",e)})},!1),i&&n.readAsDataURL(i)},onError:function(e){var t=this,o=t.imageeditor;o.trigger("error",e)}});n(o.ui.imageeditor,{ImageEditorCommand:d,commands:{OpenPaneImageEditorCommand:s,ZoomImageEditorCommand:m,CropImageEditorCommand:c,ResizeImageEditorCommand:l,UndoImageEditorCommand:p,RedoImageEditorCommand:h,SaveImageEditorCommand:g,OpenImageEditorCommand:u}})}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t,o){(o||t)()}),function(e,define){define("kendo.imageeditor.min",["imageeditor/toolbar.min","imageeditor/commands.min"],e)}(function(){return function(e,t){var o=window.kendo,i=e.extend,n=e.isPlainObject,a=o.ui.Widget,r=o.ui,d=".kendoImageEditor",s=o._outerHeight,m="error",c="imageLoaded",l="imageRendered",p="execute",h={wrapper:"k-widget k-imageeditor",header:"k-imageeditor-header",toolbar:"k-imageeditor-toolbar",paneWrapper:"k-imageeditor-action-pane",contentWrapper:"k-imageeditor-content",canvasWrapper:"k-imageeditor-canvas-container",canvasContainer:"k-imageeditor-canvas"},g=a.extend({init:function(t,i){var n=this;a.fn.init.call(n,t,i),i=e.extend(!0,{},i),n._wrapper(),n._renderHeader(),n._contentWrapper(),n._keyHandler(),i.imageUrl&&n._drawCanvas(),n._initUndoRedoStack(),n._toggleTools(),o.notify(n)},options:{name:"ImageEditor",width:"100%",height:570,imageUrl:"",toolbar:{},saveAs:{fileName:"image.png"},messages:{toolbar:{open:"Open Image",save:"Save Image",undo:"Undo",redo:"Redo",crop:"Crop",resize:"Resize",zoomIn:"Zoom In",zoomOut:"Zoom Out",zoomDropdown:"Zoom options",zoomActualSize:"Show actual size",zoomFitToScreen:"Fit to screen"},panes:{crop:{title:"Crop Image",aspectRatio:"Aspect Ratio:",aspectRatioItems:{originalRatio:"Original ratio","1:1":"1:1 (Square)","4:5":"4:5 (8:10)","5:7":"5:7","2:3":"2:3 (4:6)","16:9":"16:9"},orientation:"Orientation:",portrait:"Portrait",landscape:"Landscape"},resize:{title:"Resize image",pixels:"Pixels",percents:"Percents"}},common:{width:"Width:",height:"Height:",cancel:"Cancel",confirm:"Confirm",lockAspectRatio:"Lock aspect ratio"}}},events:[m,c,l,p],_wrapper:function(){var e=this,t=e.options,i=t.width,n=t.height;e.wrapper=e.element.addClass(h.wrapper),i&&e.wrapper.width(i),n&&e.wrapper.height(n),e._resizeHandler=o.onResize(function(){e.resize(!0)})},_renderHeader:function(){var t=this,o=t.options;t.header=e("<div />").addClass(h.header),o.toolbar&&t.header.append(t._initToolbar().element),t.wrapper.append(t.header)},_initToolbar:function(){var t=this,o=t.options,n=e("<div></div>").addClass(h.toolbar),a=i({},o.toolbar,{messages:o.messages.toolbar,action:t.executeCommand.bind(t)});return t.toolbar=new r.imageeditor.ToolBar(n,a)},_contentWrapper:function(){var t=this,o=e("<div></div>").addClass(h.contentWrapper),i=e("<div></div>").addClass(h.canvasWrapper),n=e("<div></div>").addClass(h.canvasContainer),a=e("<div></div>").addClass(h.paneWrapper).hide(),r=s(t.header);t.canvasWrapper=i,t.canvasContainer=n,t.paneWrapper=a,i.append(n),o.height(s(t.wrapper)-r),o.append(i).append(a),t.wrapper.append(o)},_keyHandler:function(){var e=this,t=!1;e.wrapper.on("keydown"+d,function(o){if(o.ctrlKey){switch(o.keyCode){case 48:e.executeCommand({command:"ZoomImageEditorCommand",options:"fitToScreen"}),t=!0;break;case 189:e.executeCommand({command:"ZoomImageEditorCommand",options:"zoomOut"}),t=!0;break;case 187:e.executeCommand({command:"ZoomImageEditorCommand",options:"zoomIn"}),t=!0;break;case 90:e.executeCommand({command:"UndoImageEditorCommand"}),t=!0;break;case 89:e.executeCommand({command:"RedoImageEditorCommand"}),t=!0}t&&o.preventDefault()}})},_drawCanvas:function(){var e=this,t=e.options.imageUrl;e.drawImage(t).done(function(t){e.trigger(c,{image:t})||e.drawCanvas(t)}).fail(function(t){e.trigger(m,t)})},_initUndoRedoStack:function(){var e=this;e.undoStack=[],e.redoStack=[]},_toggleTools:function(){var e=this,t=e.redoStack.length>0,o=e.undoStack.length>0,i=!!e._image,n=!0;try{e._canvas.toDataURL()}catch(a){n=!1}e.toolbar.toggleTools({redo:t,undo:o,enable:i,canExport:n})},drawImage:function(t){var i=this,n=new e.Deferred,a=new Image;return a.onload=function(){o.ui.progress(i.canvasContainer,!1),n.resolve(a)},a.onerror=function(){o.ui.progress(i.canvasContainer,!1),n.reject(arguments)},o.ui.progress(i.canvasContainer,!0),a.src=t,n.promise()},drawCanvas:function(t){var o=this,i=e("<canvas>Canvas element</canvas>")[0],n=i.getContext("2d");o._canvas&&e(o._canvas).remove(),o._image&&o.undoStack.push(o._image),o._canvas=i,o._ctx=n,o._image=t,i.width=t.width,i.height=t.height,n.drawImage(t,0,0),o.canvasContainer.append(i),o.executeCommand(t.height>o.canvasWrapper.height()?{command:"ZoomImageEditorCommand",options:"fitToScreen"}:{command:"ZoomImageEditorCommand",options:o.getZoomLevel()}),o.trigger(l,{canvas:i,ctx:n,image:t}),o._toggleTools()},getCanvasElement:function(){return this._canvas},getCurrent2dContext:function(){return this._ctx},getCurrentImage:function(){return this._image},executeCommand:function(e){var t=e.command,o=i({imageeditor:this},n(e.options)?e.options:{value:e.options}),a=new r.imageeditor.commands[t](o);if(!this.trigger(p,e))return this._toggleTools(),a.exec()},getZoomLevel:function(){return this._zoomLevel||1},destroy:function(){var e=this;e.element.off(d),e.currentPaneTool&&e.currentPaneTool.destroy(),e.toolbar&&e.toolbar.destroy(),e._upload&&e._upload.destroy(),a.fn.destroy.call(e)}});r.plugin(g)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t,o){(o||t)()});
|
|
//# sourceMappingURL=kendo.imageeditor.min.js.map
|