/* * Kendo UI Web v2013.1.319 (http://kendoui.com) * Copyright 2013 Telerik AD. All rights reserved. * * Kendo UI Web commercial licenses may be obtained at * https://www.kendoui.com/purchase/license-agreement/kendo-ui-web-commercial.aspx * If you do not own a commercial license, this file shall be governed by the * GNU General Public License (GPL) version 3. * For GPL requirements, please review: http://www.gnu.org/copyleft/gpl.html */ ("function"==typeof define&&define.amd?define:function(e,t){return t()})(["./kendo.listview.min","./kendo.upload.min"],function(){(function(e,t){function a(e,t,a){var i,n;e.on("dragenter"+F,function(){t(),n=new Date,i||(i=setInterval(function(){var e=new Date-n;e>100&&(a(),clearInterval(i),i=null)},100))}).on("dragover"+F,function(){n=new Date})}function i(e,t){var a=e[t];return p(a)?a.field||t:a}function n(e,a){return e!==t&&e.match(/\/$/)||(e=(e||"")+"/"),e+a}function o(e){if(!e)return"";var t=" bytes";return e>=1073741824?(t=" GB",e/=1073741824):e>=1048576?(t=" MB",e/=1048576):e>=1024&&(t=" KB",e/=1024),Math.round(100*e)/100+t}var r,s,l,d,u=window.kendo,c=u.ui.Widget,p=e.isPlainObject,f=e.proxy,h=e.extend,m=u.support.placeholder,g=u.support.browser,v=e.isFunction,_=/(^\/|\/$)/g,k="change",b="apply",w="error",y="click",F=".kendoImageBrowser",S=".kendoBreadcrumbs",x=".kendoSearchBox",N="name",B="size",T="type",C={field:T,dir:"asc"},D=u.template('
  • ${text}
  • '),z=u.template('
  • ${text}
  • '),U='
    #if(showUpload) { #
    #=messages.uploadFile#
    #}##if(showCreate) {##}##if(showDelete) {# #}#
    #=messages.orderBy#: #=messages.orderByName#
    ';h(!0,u.data,{schemas:{imagebrowser:{data:function(e){return e.items||e||[]},model:{id:"name",fields:{name:"name",size:"size",type:"type"}}}}}),h(!0,u.data,{transports:{imagebrowser:u.data.RemoteTransport.extend({init:function(t){u.data.RemoteTransport.fn.init.call(this,e.extend(!0,{},this.options,t))},_call:function(t,a){a.data=e.extend({},a.data,{path:this.options.path()}),v(this.options[t])?this.options[t].call(this,a):u.data.RemoteTransport.fn[t].call(this,a)},read:function(e){this._call("read",e)},create:function(e){this._call("create",e)},destroy:function(e){this._call("destroy",e)},update:function(){},options:{read:{type:"POST"},update:{type:"POST"},create:{type:"POST"},destroy:{type:"POST"}}})}}),r=g.msie&&8>g.version?function(e){return e.offsetTop}:function(t){return t.offsetTop-e(t).height()},s=c.extend({init:function(e,t){var a=this;t=t||{},c.fn.init.call(a,e,t),a.element.addClass("k-imagebrowser"),a.element.on(y+F,".k-toolbar button:not(.k-state-disabled):has(.k-delete)",f(a._deleteClick,a)).on(y+F,".k-toolbar button:not(.k-state-disabled):has(.k-addfolder)",f(a._addClick,a)).on("keydown"+F,"li.k-state-selected input",f(a._directoryKeyDown,a)).on("blur"+F,"li.k-state-selected input",f(a._directoryBlur,a)),a._dataSource(),a.refresh(),a.path(a.options.path)},options:{name:"ImageBrowser",messages:{uploadFile:"Upload",orderBy:"Arrange by",orderByName:"Name",orderBySize:"Size",directoryNotFound:"A directory with this name was not found.",emptyFolder:"Empty Folder",deleteFile:'Are you sure you want to delete "{0}"?',invalidFileType:'The selected file "{0}" is not valid. Supported file types are {1}.',overwriteFile:'A file with name "{0}" already exists in the current directory. Do you want to overwrite it?',dropFilesHere:"drop files here to upload",search:"Search"},transport:{},path:"/",fileTypes:"*.png,*.gif,*.jpg,*.jpeg"},events:[w,k,b],destroy:function(){var e=this;c.fn.destroy.call(e),e.dataSource.unbind(w,e._errorHandler),e.element.add(e.list).add(e.toolbar).off(F),e.arrangeByPopup&&e.arrangeByPopup.destroy(),u.destroy(e.element)},value:function(){var e,a=this,i=a._selectedItem(),o=a.options.transport.imageUrl;return i&&"f"===i.get(a._getFieldName(T))?(e=n(a.path(),i.get(a._getFieldName(N))).replace(_,""),o&&(e=v(o)?o(e):u.format(o,e)),e):t},_selectedItem:function(){var e=this.listView,a=e.select();return a.length?this.dataSource.getByUid(a.attr(u.attr("uid"))):t},_toolbar:function(){var t,a,i=this,n=u.template(U),o=i.options.messages,r=[{text:o.orderByName,value:"name",ns:u.ns},{text:o.orderBySize,value:"size",ns:u.ns}];i.toolbar=e(n({messages:o,showUpload:i.options.transport.uploadUrl,showCreate:i.options.transport.create,showDelete:i.options.transport.destroy})).appendTo(i.element).find(".k-upload input").kendoUpload({multiple:!1,localization:{dropFilesHere:o.dropFilesHere},async:{saveUrl:i.options.transport.uploadUrl,autoUpload:!0},upload:f(i._fileUpload,i)}).end(),i.upload=i.toolbar.find(".k-upload input").data("kendoUpload"),t=i.toolbar.find(".k-tiles-arrange a"),i.arrangeByPopup=a=e("").kendoPopup({anchor:t}).on(y+F,"li",function(){var t=e(this),n=t.attr(u.attr("value"));i.toolbar.find(".k-tiles-arrange a span:first").html(t.text()),a.close(),i.orderBy(n)}).data("kendoPopup"),t.on(y+F,function(e){e.preventDefault(),a.toggle()}),i._attachDropzoneEvents()},_attachDropzoneEvents:function(){var t=this;t.options.transport.uploadUrl&&(a(e(document.documentElement),e.proxy(t._dropEnter,t),e.proxy(t._dropLeave,t)),t._scrollHandler=f(t._positionDropzone,t))},_dropEnter:function(){this._positionDropzone(),e(document).on("scroll"+F,this._scrollHandler)},_dropLeave:function(){this._removeDropzone(),e(document).off("scroll"+F,this._scrollHandler)},_positionDropzone:function(){var e=this,t=e.element,a=t.offset();e.toolbar.find(".k-dropzone").addClass("k-imagebrowser-dropzone").offset(a).css({width:t[0].clientWidth,height:t[0].clientHeight,lineHeight:t[0].clientHeight+"px"})},_removeDropzone:function(){this.toolbar.find(".k-dropzone").removeClass("k-imagebrowser-dropzone").css({width:"",height:"",lineHeight:"",top:"",left:""})},_deleteClick:function(){var e=this,t=e.listView.select(),a=u.format(e.options.messages.deleteFile,t.find("strong").text());t.length&&e._showMessage(a,"confirm")&&e.listView.remove(t)},_addClick:function(){this.createDirectory()},_fileUpload:function(e){var t,a=this,i=a.options,n=i.fileTypes,o=RegExp(("("+n.split(",").join(")|(")+")").replace(/\*\./g,".*."),"i"),r=e.files[0].name,s=a._getFieldName(N),l=a._getFieldName(B);o.test(r)?(e.data={path:a.path()},t=a._createFile(r),t?a.upload.one("success",function(e){t.set(s,e.response[s]),t.set(l,e.response[l]),a._tiles=a.listView.items().filter("["+u.attr("type")+"=f]"),a._scroll()}):e.preventDefault()):(e.preventDefault(),a._showMessage(u.format(i.messages.invalidFileType,r,n)))},_findFile:function(e){var t,a,i,n=this.dataSource.data(),o=this._getFieldName(T),r=this._getFieldName(N);for(e=e.toLowerCase(),t=0,i=n.length;i>t;t++)if("f"===n[t].get(o)&&n[t].get(r).toLowerCase()===e){a=n[t];break}return a},_createFile:function(e){var t,a,i=this,n=0,o={},r=i._getFieldName(T),s=i.dataSource.view(),l=i._findFile(e);if(l&&!i._showMessage(u.format(i.options.messages.overwriteFile,e),"confirm"))return null;if(l)return l;for(t=0,a=s.length;a>t;t++)if("f"===s[t].get(r)){n=t;break}return o[r]="f",o[i._getFieldName(N)]=e,o[i._getFieldName(B)]=0,i.dataSource.insert(++n,o)},createDirectory:function(){var e,t,a=this,i=0,n=a._getFieldName(T),o=a._getFieldName(N),r=a.dataSource.data(),s=a._nameDirectory(),l=new a.dataSource.reader.model;for(e=0,t=r.length;t>e;e++)"d"===r[e].get(n)&&(i=e);l.set(n,"d"),l.set(o,s),a.listView.one("dataBound",function(){var e=a.listView.items().filter("["+u.attr("uid")+"="+l.uid+"]"),t=e.find("input");e.length&&this.edit(e),this.element.scrollTop(e.attr("offsetTop")-this.element[0].offsetHeight),setTimeout(function(){t.select()})}).one("save",function(e){var t=e.model.get(o);t?e.model.set(o,a._nameExists(t,l.uid)?a._nameDirectory():t):e.model.set(o,s)}),a.dataSource.insert(++i,l)},_directoryKeyDown:function(e){13==e.keyCode&&e.currentTarget.blur()},_directoryBlur:function(){this.listView.save()},_nameExists:function(e,t){var a,i,n=this.dataSource.data(),o=this._getFieldName(T),r=this._getFieldName(N);for(a=0,i=n.length;i>a;a++)if("d"===n[a].get(o)&&n[a].get(r).toLowerCase()===e.toLowerCase()&&n[a].uid!==t)return!0;return!1},_nameDirectory:function(){var t,a,i,n="New folder",o=this.dataSource.data(),r=[],s=this._getFieldName(T),l=this._getFieldName(N);for(a=0,i=o.length;i>a;a++)"d"===o[a].get(s)&&o[a].get(l).toLowerCase().indexOf(n.toLowerCase())>-1&&r.push(o[a].get(l));if(e.inArray(n,r)>-1){a=2;do t=n+" ("+a+")",a++;while(e.inArray(t,r)>-1);n=t}return n},orderBy:function(e){this.dataSource.sort([{field:this._getFieldName(T),dir:"asc"},{field:this._getFieldName(e),dir:"asc"}])},search:function(e){this.dataSource.filter({field:this._getFieldName(N),operator:"contains",value:e})},_content:function(){var t=this;t.list=e('