/**
* Kendo UI v2016.1.112 (http://www.telerik.com/kendo-ui)
* Copyright 2016 Telerik AD. 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("kendo.filebrowser.min",["kendo.listview.min","kendo.dropdownlist.min","kendo.upload.min"],e)}(function(){return function(e,t){function a(e,t,a){var r,o;e.on("dragenter"+S,function(){t(),o=new Date,r||(r=setInterval(function(){var e=new Date-o;e>100&&(a(),clearInterval(r),r=null)},100))}).on("dragover"+S,function(){o=new Date})}function r(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}function i(e,t){var a=e[t];return p(a)?a.from||a.field||t:a}var n,s,l,d,u=window.kendo,c=u.ui.Widget,p=e.isPlainObject,f=e.proxy,h=e.extend,v=u.support.placeholder,m=u.support.browser,k=u.isFunction,_=/(^\/|\/$)/g,g="change",w="apply",b="error",y="click",S=".kendoFileBrowser",x=".kendoBreadcrumbs",B=".kendoSearchBox",T="name",D="size",F="type",C={field:F,dir:"asc"},z=u.template('
${text}
'),H='
# if (showUpload) { #
#=messages.uploadFile#
# } ## if (showCreate) { ## } ## if (showDelete) { # # } #
';h(!0,u.data,{schemas:{filebrowser:{data:function(e){return e.items||e||[]},model:{id:"name",fields:{name:"name",size:"size",type:"type"}}}}}),h(!0,u.data,{transports:{filebrowser: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()}),k(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"}}})}}),n=m.msie&&8>m.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-filebrowser"),a.element.on(y+S,".k-filebrowser-toolbar button:not(.k-state-disabled):has(.k-delete)",f(a._deleteClick,a)).on(y+S,".k-filebrowser-toolbar button:not(.k-state-disabled):has(.k-addfolder)",f(a._addClick,a)).on("keydown"+S,"li.k-state-selected input",f(a._directoryKeyDown,a)).on("blur"+S,"li.k-state-selected input",f(a._directoryBlur,a)),a._dataSource(),a.refresh(),a.path(a.options.path)},options:{name:"FileBrowser",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:"*.*"},events:[b,g,w],destroy:function(){var e=this;c.fn.destroy.call(e),e.dataSource.unbind(b,e._errorHandler),e.element.add(e.list).add(e.toolbar).off(S),u.destroy(e.element)},value:function(){var e,a=this,o=a._selectedItem(),i=a.options.transport.fileUrl;return o&&"f"===o.get(F)?(e=r(a.path(),o.get(T)).replace(_,""),i&&(e=k(i)?i(e):u.format(i,encodeURIComponent(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=this,a=u.template(H),r=t.options.messages,o=[{text:r.orderByName,value:"name"},{text:r.orderBySize,value:"size"}];t.toolbar=e(a({messages:r,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:r.dropFilesHere},async:{saveUrl:t.options.transport.uploadUrl,autoUpload:!0},upload:f(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=f(t._positionDropzone,t))},_dropEnter:function(){this._positionDropzone(),e(document).on("scroll"+S,this._scrollHandler)},_dropLeave:function(){this._removeDropzone(),e(document).off("scroll"+S,this._scrollHandler)},_positionDropzone:function(){var e=this,t=e.element,a=t.offset();e.toolbar.find(".k-dropzone").addClass("k-filebrowser-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-filebrowser-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()},_getFieldName:function(e){return i(this.dataSource.reader.model.fields,e)},_fileUpload:function(e){var t,a=this,r=a.options,o=r.fileTypes,i=RegExp(("("+o.split(",").join(")|(")+")").replace(/\*\./g,".*."),"i"),n=e.files[0].name,s=T,l=D;i.test(n)?(e.data={path:a.path()},t=a._createFile(n),t?a.upload.one("success",function(e){t.set(s,e.response[a._getFieldName(s)]),t.set(l,e.response[a._getFieldName(l)]),a._tiles=a.listView.items().filter("["+u.attr("type")+"=f]")}):e.preventDefault()):(e.preventDefault(),a._showMessage(u.format(r.messages.invalidFileType,n,o)))},_findFile:function(e){var t,a,r,o=this.dataSource.data(),i=F,n=T;for(e=e.toLowerCase(),t=0,r=o.length;r>t;t++)if("f"===o[t].get(i)&&o[t].get(n).toLowerCase()===e){a=o[t];break}return a},_createFile:function(e){var t,a,r=this,o=0,i={},n=F,s=r.dataSource.view(),l=r._findFile(e);if(l)return r._showMessage(u.format(r.options.messages.overwriteFile,e),"confirm")?(l._forceReload=!0,l):null;for(t=0,a=s.length;a>t;t++)if("f"===s[t].get(n)){o=t;break}return i[n]="f",i[T]=e,i[D]=0,r.dataSource.insert(++o,i)},createDirectory:function(){var e,t,a=this,r=0,o=F,i=T,n=a.dataSource.data(),s=a._nameDirectory(),l=new a.dataSource.reader.model;for(e=0,t=n.length;t>e;e++)"d"===n[e].get(o)&&(r=e);l.set(o,"d"),l.set(i,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(i);t?e.model.set(i,a._nameExists(t,l.uid)?a._nameDirectory():t):e.model.set(i,s)}),a.dataSource.insert(++r,l)},_directoryKeyDown:function(e){13==e.keyCode&&e.currentTarget.blur()},_directoryBlur:function(){this.listView.save()},_nameExists:function(e,t){var a,r,o=this.dataSource.data(),i=F,n=T;for(a=0,r=o.length;r>a;a++)if("d"===o[a].get(i)&&o[a].get(n).toLowerCase()===e.toLowerCase()&&o[a].uid!==t)return!0;return!1},_nameDirectory:function(){var t,a,r,o="New folder",i=this.dataSource.data(),n=[],s=F,l=T;for(a=0,r=i.length;r>a;a++)"d"===i[a].get(s)&&i[a].get(l).toLowerCase().indexOf(o.toLowerCase())>-1&&n.push(i[a].get(l));if(e.inArray(o,n)>-1){a=2;do t=o+" ("+a+")",a++;while(e.inArray(t,n)>-1);o=t}return o},orderBy:function(e){this.dataSource.sort([{field:F,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("dblclick"+S,"li",f(t._dblClick,t)),t.listView=new u.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("["+u.attr("type")+"=f]"):this.wrapper.append(z({text:t.options.messages.emptyFolder}))},change:f(t._listViewChange,t)})},_dblClick:function(t){var a,o=this,i=e(t.currentTarget);i.hasClass("k-edit-item")&&o._directoryBlur(),i.filter("["+u.attr("type")+"=d]").length?(a=o.dataSource.getByUid(i.attr(u.attr("uid"))),a&&(o.path(r(o.path(),a.get(T))),o.breadcrumbs.value(o.path()))):i.filter("["+u.attr("type")+"=f]").length&&o.trigger(w)},_listViewChange:function(){var e=this._selectedItem();e&&(this.toolbar.find(".k-delete").parent().removeClass("k-state-disabled"),"f"===e.get(F)&&this.trigger(g))},_dataSource:function(){var e,t=this,a=t.options,r=a.transport,o=h({},C),i={field:T,dir:"asc"},n={type:r.type||"filebrowser",sort:[o,i]};p(r)&&(r.path=f(t.path,t),n.transport=r),p(a.schema)?n.schema=a.schema:r.type&&p(u.data.schemas[r.type])&&(e=u.data.schemas[r.type]),t.dataSource&&t._errorHandler?t.dataSource.unbind(b,t._errorHandler):t._errorHandler=f(t._error,t),t.dataSource=u.data.DataSource.create(n).bind(b,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(b,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()},_editTmpl:function(){var e='