# } ## if (showCreate) { ## } ## if (showDelete) { # # } #
';f(!0,d.data,{schemas:{imagebrowser:{data:function(e){return e.items||e||[]},model:{id:"name",fields:{name:"name",size:"size",type:"type"}}}}}),f(!0,d.data,{transports:{imagebrowser:d.data.RemoteTransport.extend({init:function(t){d.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):d.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=m.msie&&m.version<8?function(e){return e.offsetTop}:function(t){return t.offsetTop-e(t).height()},i=c.extend({init:function(e,t){var a=this;t=t||{},c.fn.init.call(a,e,t),a.element.addClass("k-imagebrowser k-secondary"),a.element.on(y+b,".k-toolbar button:not(.k-state-disabled):has(.k-delete)",p(a._deleteClick,a)).on(y+b,".k-toolbar button:not(.k-state-disabled):has(.k-addfolder)",p(a._addClick,a)).on("keydown"+b,"li.k-state-selected input",p(a._directoryKeyDown,a)).on("blur"+b,"li.k-state-selected input",p(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 file here to upload",search:"Search"},transport:{},path:"/",fileTypes:"*.png,*.gif,*.jpg,*.jpeg"},events:[w,k,_],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(b),e.arrangeBy&&e.arrangeBy.destroy(),d.destroy(e.element)},value:function(){var e,a=this,o=a._selectedItem(),r=a.options.transport.imageUrl;return o&&"f"===o.get(C)?(e=n(a.path(),o.get(T)).replace(g,""),r&&(e=v(r)?r(e):d.format(r,encodeURIComponent(e))),e):t},_selectedItem:function(){var e=this.listView,a=e.select();return a.length?this.dataSource.getByUid(a.attr(d.attr("uid"))):t},_toolbar:function(){var t=this,a=d.template(z),n=t.options.messages,o=[{text:n.orderByName,value:"name"},{text:n.orderBySize,value:"size"}];t.toolbar=e(a({messages:n,showUpload:t.options.transport.uploadUrl,showCreate:t.options.transport.create,showDelete:t.options.transport.destroy})).appendTo(t.element).find(".k-upload input").kendoUpload({multiple:!1,localization:{dropFilesHere:n.dropFilesHere},async:{saveUrl:t.options.transport.uploadUrl,autoUpload:!0},upload:p(t._fileUpload,t),error:function(e){t._error({xhr:e.XMLHttpRequest,status:"error"})}}).end(),t.upload=t.toolbar.find(".k-upload input").data("kendoUpload"),t.arrangeBy=t.toolbar.find(".k-tiles-arrange select").kendoDropDownList({dataSource:o,dataTextField:"text",dataValueField:"value",change:function(){t.orderBy(this.value())}}).data("kendoDropDownList"),t._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=p(t._positionDropzone,t))},_dropEnter:function(){this._positionDropzone(),e(document).on("scroll"+b,this._scrollHandler)},_dropLeave:function(){this._removeDropzone(),e(document).off("scroll"+b,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=d.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,n=a.options,o=n.fileTypes,r=RegExp(("("+o.split(",").join(")|(")+")").replace(/\*\./g,".*."),"i"),i=e.files[0].name,s=T,l=B;r.test(i)?(e.data={path:a.path()},t=a._createFile(i),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("["+d.attr("type")+"=f]"),a._scroll()}):e.preventDefault()):(e.preventDefault(),a._showMessage(d.format(n.messages.invalidFileType,i,o)))},_findFile:function(e){var t,a,n,o=this.dataSource.data(),r=C,i=T;for(e=e.toLowerCase(),t=0,n=o.length;n>t;t++)if("f"===o[t].get(r)&&o[t].get(i).toLowerCase()===e){a=o[t];break}return a},_createFile:function(e){var t,a,n=this,o=0,r={},i=C,s=n.dataSource.view(),l=n._findFile(e);if(l&&!n._showMessage(d.format(n.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(i)){o=t;break}return r[i]="f",r[T]=e,r[B]=0,n.dataSource.insert(++o,r)},createDirectory:function(){var e,t,a=this,n=0,o=C,r=T,i=a.dataSource.data(),s=a._nameDirectory(),l=new a.dataSource.reader.model;for(e=0,t=i.length;t>e;e++)"d"===i[e].get(o)&&(n=e);l.set(o,"d"),l.set(r,s),a.listView.one("dataBound",function(){var e=a.listView.items().filter("["+d.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(r);t?e.model.set(r,a._nameExists(t,l.uid)?a._nameDirectory():t):e.model.set(r,s)}),a.dataSource.insert(++n,l)},_directoryKeyDown:function(e){13==e.keyCode&&e.currentTarget.blur()},_directoryBlur:function(){this.listView.save()},_nameExists:function(e,t){var a,n,o=this.dataSource.data(),r=C,i=T;for(a=0,n=o.length;n>a;a++)if("d"===o[a].get(r)&&o[a].get(i).toLowerCase()===e.toLowerCase()&&o[a].uid!==t)return!0;return!1},_nameDirectory:function(){var t,a,n,o="New folder",r=this.dataSource.data(),i=[],s=C,l=T;for(a=0,n=r.length;n>a;a++)"d"===r[a].get(s)&&r[a].get(l).toLowerCase().indexOf(o.toLowerCase())>-1&&i.push(r[a].get(l));if(e.inArray(o,i)>-1){a=2;do t=o+" ("+a+")",a++;while(e.inArray(t,i)>-1);o=t}return o},orderBy:function(e){this.dataSource.sort([{field:C,dir:"asc"},{field:e,dir:"asc"}])},search:function(e){this.dataSource.filter({field:T,operator:"contains",value:e})},_content:function(){var t=this;t.list=e('
').appendTo(t.element).on("scroll"+b,p(t._scroll,t)).on("dblclick"+b,"li",p(t._dblClick,t)),t.listView=new d.ui.ListView(t.list,{dataSource:t.dataSource,template:t._itemTmpl(),editTemplate:t._editTmpl(),selectable:!0,autoBind:!1,dataBinding:function(e){t.toolbar.find(".k-delete").parent().addClass("k-state-disabled"),("remove"===e.action||"sync"===e.action)&&e.preventDefault()},dataBound:function(){t.dataSource.view().length?(t._tiles=this.items().filter("["+d.attr("type")+"=f]"),t._scroll()):this.wrapper.append(F({text:t.options.messages.emptyFolder}))},change:p(t._listViewChange,t)})},_dblClick:function(t){var a,o=this,r=e(t.currentTarget);r.filter("["+d.attr("type")+"=d]").length?(a=o.dataSource.getByUid(r.attr(d.attr("uid"))),a&&(o.path(n(o.path(),a.get(T))),o.breadcrumbs.value(o.path()))):r.filter("["+d.attr("type")+"=f]").length&&o.trigger(_)},_listViewChange:function(){var e=this._selectedItem();e&&(this.toolbar.find(".k-delete").parent().removeClass("k-state-disabled"),"f"===e.get(C)&&this.trigger(k))},_dataSource:function(){var e,t=this,a=t.options,n=a.transport,o=f({},D),r={field:T,dir:"asc"},i={type:n.type||"imagebrowser",sort:[o,r]};u(n)&&(n.path=p(t.path,t),i.transport=n),u(a.schema)?i.schema=a.schema:n.type&&u(d.data.schemas[n.type])&&(e=d.data.schemas[n.type]),t.dataSource&&t._errorHandler?t.dataSource.unbind(w,t._errorHandler):t._errorHandler=p(t._error,t),t.dataSource=d.data.DataSource.create(i).bind(w,t._errorHandler)},_navigation:function(){var t=this,a=e('').appendTo(this.element);t.breadcrumbs=a.find("input:first").kendoBreadcrumbs({value:t.options.path,change:function(){t.path(this.value())}}).data("kendoBreadcrumbs"),t.searchBox=a.parent().find("input:last").kendoSearchBox({label:t.options.messages.search,change:function(){t.search(this.value())}}).data("kendoSearchBox")},_error:function(e){var t,a=this;a.trigger(w,e)||(t=e.xhr.status,"error"==e.status?"404"==t?a._showMessage(a.options.messages.directoryNotFound):"0"!=t&&a._showMessage("Error! The requested URL returned "+t+" - "+e.xhr.statusText):"timeout"==t&&a._showMessage("Error! Server timeout."))},_showMessage:function(e,t){return window[t||"alert"](e)},refresh:function(){var e=this;e._navigation(),e._toolbar(),e._content()},_loadImage:function(t){var a=this,n=e(t),o=a.dataSource.getByUid(n.attr(d.attr("uid"))),r=o.get(T),i=a.options.transport.thumbnailUrl,s=e("",{alt:r}),l="?";s.hide().on("load"+b,function(){e(this).prev().remove().end().addClass("k-image").fadeIn()}),n.find(".k-loading").after(s),v(i)?i=i(a.path(),encodeURIComponent(r)):(i.indexOf("?")>=0&&(l="&"),i=i+l+"path="+a.path()+encodeURIComponent(r)),s.attr("src",i),t.loaded=!0},_scroll:function(){var e=this;e.options.transport&&e.options.transport.thumbnailUrl&&(clearTimeout(e._timeout),e._timeout=setTimeout(function(){var a=e.list.outerHeight(),n=e.list.scrollTop(),o=n+a;e._tiles.each(function(){var a=r(this),i=a+this.offsetHeight;return(a>=n&&o>a||i>=n&&o>i)&&e._loadImage(this),a>o?!1:t}),e._tiles=e._tiles.filter(function(){return!this.loaded})},250))},_editTmpl:function(){var e='