/* * Kendo UI Beta v2013.2.716 (http://kendoui.com) * Copyright 2013 Telerik AD. All rights reserved. * * Kendo UI Beta license terms available at * http://www.kendoui.com/purchase/license-agreement/kendo-ui-beta.aspx */ ("function"==typeof define&&define.amd?define:function(e,t){return t()})(["./kendo.core.min"],function(){!function(e,t){function a(t){return e.map(o(t),function(e){return e.name}).join(", ")}function o(e){var t=e[0];return t.files?n(t.files):[{name:i(t.value),extension:s(t.value),size:null}]}function n(t){return e.map(t,function(e){return r(e)})}function r(e){var t=e.name||e.fileName;return{name:k.htmlEncode(t),extension:s(t),size:e.size||e.fileSize,rawFile:e}}function s(e){var t=e.match(y);return t?t[0]:""}function i(e){var t=e.lastIndexOf("\\");return-1!=t?e.substr(t+1):e}function l(t,a,o){var n,r;a._supportsRemove()&&(n=t.data("fileNames"),r=e.map(n,function(e){return e.name}),a._submitRemove(r,o,function(e,o,r){a._removeFileEntry(t),a.trigger(C,{operation:"remove",files:n,response:e,XMLHttpRequest:r})},function(e){a.trigger(S,{operation:"remove",files:n,XMLHttpRequest:e}),w("Server response: "+e.responseText)}))}function p(t,a,o){var n=!1,r="";try{r=e.parseJSON(u(t)),n=!0}catch(s){o()}n&&a(r)}function u(e){return(t===e||""===e)&&(e="{}"),e}function d(e){e.stopPropagation(),e.preventDefault()}function c(e,t,a,o){var n,r;e.on("dragenter"+t,function(){a(),r=new Date,n||(n=setInterval(function(){var e=new Date-r;e>100&&(o(),clearInterval(n),n=null)},100))}).on("dragover"+t,function(){r=new Date})}function f(e){return e.is(".k-file-progress, .k-file-success, .k-file-error")}function m(t){return e(t.target).closest(".k-file")}function h(){var a={},o=e("meta[name=csrf-token]").attr("content"),n=e("meta[name=csrf-param]").attr("content");return e("input[name^='__RequestVerificationToken']").each(function(){a[this.name]=this.value}),n!==t&&o!==t&&(a[n]=o),a}var v,g,k=window.kendo,_=k.ui.Widget,w=k.logToConsole,y=/\.([^\.]+)$/,F=".kendoUpload",U="select",b="upload",C="success",S="error",x="complete",R="cancel",A="progress",E="remove",z=_.extend({init:function(t,a){var o,n,r,s=this;_.fn.init.call(s,t,a),s.name=t.name,s.multiple=s.options.multiple,s.localization=s.options.localization,o=s.element,s.wrapper=o.closest(".k-upload"),0===s.wrapper.length&&(s.wrapper=s._wrapInput(o)),s._activeInput(o),s.toggle(s.options.enabled),n=s._ns=F+"-"+k.guid(),o.closest("form").on("submit"+n,e.proxy(s._onParentFormSubmit,s)).on("reset"+n,e.proxy(s._onParentFormReset,s)),s.options.async.saveUrl?(s._module=s._supportsFormData()?new g(s):new v(s),s._async=!0,r=s.options.files,r.length>0&&s._renderInitialFiles(r)):s._module=new D(s),s._supportsDrop()&&s._setupDropZone(),s.wrapper.on("click",".k-upload-action",e.proxy(s._onFileAction,s)).on("click",".k-upload-selected",e.proxy(s._onUploadSelected,s))},events:[U,b,C,S,x,R,A,E],options:{name:"Upload",enabled:!0,multiple:!0,showFileList:!0,template:"",files:[],async:{removeVerb:"POST",autoUpload:!0},localization:{select:"Select files...",cancel:"Cancel",retry:"Retry",remove:"Remove",uploadSelectedFiles:"Upload files",dropFilesHere:"drop files here to upload",statusUploading:"uploading",statusUploaded:"uploaded",statusFailed:"failed",headerStatusUploading:"Uploading...",headerStatusUploaded:"Done"}},setOptions:function(e){var t=this,a=t.element;_.fn.setOptions.call(t,e),t.multiple=t.options.multiple,a.attr("multiple",t._supportsMultiple()?t.multiple:!1),t.toggle(t.options.enabled)},enable:function(e){e=t===e?!0:e,this.toggle(e)},disable:function(){this.toggle(!1)},toggle:function(e){e=t===e?e:!e,this.wrapper.toggleClass("k-state-disabled",e),this.element.prop("disabled",e)},destroy:function(){var t=this;e(document).add(e(".k-dropzone",t.wrapper)).add(t.wrapper.closest("form")).off(t._ns),e(t.element).off(F),_.fn.destroy.call(t)},_addInput:function(t){if(t[0].nodeType){var a=this,o=t.clone().val("");o.insertAfter(a.element).data("kendoUpload",a),e(a.element).hide().removeAttr("id").off(F),a._activeInput(o)}},_activeInput:function(t){var a=this,o=a.wrapper;a.element=t,t.attr("multiple",a._supportsMultiple()?a.multiple:!1).attr("autocomplete","off").on("click"+F,function(e){o.hasClass("k-state-disabled")&&e.preventDefault()}).on("focus"+F,function(){e(this).parent().addClass("k-state-focused")}).on("blur"+F,function(){e(this).parent().removeClass("k-state-focused")}).on("change"+F,e.proxy(a._onInputChange,a))},_onInputChange:function(t){var a=this,n=e(t.target),r=a.trigger(U,{files:o(n)});r?(a._addInput(n),n.remove()):a._module.onSelect(t)},_onDrop:function(t){var a,o=t.originalEvent.dataTransfer,r=this,s=o.files;d(t),s.length>0&&(a=r.trigger(U,{files:n(s)}),a||r._module.onSelect({target:e(".k-dropzone",r.wrapper)},s))},_renderInitialFiles:function(t){var a,o,n=this,r=0;for(r=0;r100%"),n._fileAction(o,E)},_prepareTemplateData:function(e,t){var a=t.fileNames,o={},n=0,r=0;for(r=0;r"+t+""+""+"");return 1==a.fileNames.length&&a.fileNames[0].extension&&(o=a.fileNames[0].extension.substring(1),e(".k-icon",n).addClass("k-i-"+o)),n},_enqueueFile:function(t,a){var o,n,r,s=this,i=e(".k-upload-files",s.wrapper),l=s.options,p=l.template;return 0===i.length&&(i=e("").appendTo(s.wrapper),s.options.showFileList||i.hide(),s.wrapper.removeClass("k-upload-empty")),o=e(".k-file",i),p?(r=s._prepareTemplateData(t,a),p=k.template(p),n=e("
  • "+p(r)+"
  • "),n.find(".k-upload-action").addClass("k-button k-button-bare")):n=s._prepareDefaultFileEntryTemplate(t,a),n.appendTo(i).data(a),s._async||e(".k-progress",n).width("100%"),!s.multiple&&o.length>0&&s._module.onRemove({target:e(o,s.wrapper)}),n},_removeFileEntry:function(t){var a,o,n=this,r=t.closest(".k-upload-files");t.remove(),a=e(".k-file",r),o=e(".k-file-success, .k-file-error",r),o.length===a.length&&this._hideUploadButton(),0===a.length&&(r.remove(),n.wrapper.addClass("k-upload-empty"),n._hideHeaderUploadstatus())},_fileAction:function(e,t){var a={remove:"k-delete",cancel:"k-cancel",retry:"k-retry"},o={remove:"k-i-close",cancel:"k-i-close",retry:"k-i-refresh"};a.hasOwnProperty(t)&&(this._clearFileAction(e),this.options.template?e.find(".k-upload-action").addClass("k-button k-button-bare").append("").show():(e.find(".k-upload-status .k-upload-action").remove(),e.find(".k-upload-status").append(this._renderAction(a[t],this.localization[t],o[t]))))},_fileState:function(t,a){var o=this.localization,n={uploading:{text:o.statusUploading},uploaded:{text:o.statusUploaded},failed:{text:o.statusFailed}},r=n[a];r&&e(".k-icon:not(.k-delete, .k-cancel, .k-retry)",t).text(r.text)},_renderAction:function(t,a,o){return""!==t?e(""):e("")},_clearFileAction:function(t){e(".k-upload-action",t).empty().hide()},_onFileAction:function(t){var a,o,n,r,s=this;return s.wrapper.hasClass("k-state-disabled")||(a=e(t.target).closest(".k-upload-action"),o=a.find(".k-icon"),n=a.closest(".k-file"),r={files:n.data("fileNames")},o.hasClass("k-delete")?s.trigger(E,r)||s._module.onRemove({target:e(n,s.wrapper)},r.data):o.hasClass("k-cancel")?(s.trigger(R,r),s._module.onCancel({target:e(n,s.wrapper)}),this._checkAllComplete(),s._updateHeaderUploadStatus()):o.hasClass("k-retry")&&(e(".k-warning",n).remove(),s._module.onRetry({target:e(n,s.wrapper)}))),!1},_onUploadSelected:function(){return this._module.onSaveSelected(),!1},_onFileProgress:function(t,a){var o;this.options.template?e(".k-progress",t.target).width(a+"%"):(o=e(".k-upload-pct",t.target),0===o.length&&e(".k-upload-status",t.target).prepend(""),e(".k-upload-pct",t.target).text(a+"%"),e(".k-progress",t.target).width(a+"%")),this.trigger(A,{files:m(t).data("fileNames"),percentComplete:a})},_onUploadSuccess:function(e,t,a){var o=m(e);this._fileState(o,"uploaded"),o.removeClass("k-file-progress").addClass("k-file-success"),this._updateHeaderUploadStatus(),this.trigger(C,{files:o.data("fileNames"),response:t,operation:"upload",XMLHttpRequest:a}),this._supportsRemove()?this._fileAction(o,E):this._clearFileAction(o),this._checkAllComplete()},_onUploadError:function(t,a){var o=m(t),n=e(".k-upload-pct",o);this._fileState(o,"failed"),o.removeClass("k-file-progress").addClass("k-file-error"),e(".k-progress",o).width("100%"),n.length>0?n.empty().removeClass("k-upload-pct").addClass("k-icon k-warning"):e(".k-upload-status",o).prepend(""),this._updateHeaderUploadStatus(),this._fileAction(o,"retry"),this.trigger(S,{operation:"upload",files:o.data("fileNames"),XMLHttpRequest:a}),w("Server response: "+a.responseText),this._checkAllComplete()},_showUploadButton:function(){var t=e(".k-upload-selected",this.wrapper);0===t.length&&(t=this._renderAction("",this.localization.uploadSelectedFiles).addClass("k-upload-selected")),this.wrapper.append(t)},_hideUploadButton:function(){e(".k-upload-selected",this.wrapper).remove()},_showHeaderUploadStatus:function(){var t=this.localization,a=e(".k-dropzone",this.wrapper),o=e(".k-upload-status-total",this.wrapper);0!==o.length&&o.remove(),o=''+t.headerStatusUploading+''+t.statusUploading+""+"",a.length>0?a.append(o):e(".k-upload-button",this.wrapper).after(o)},_updateHeaderUploadStatus:function(){var t,a,o=e(".k-file",this.wrapper).not(".k-file-success, .k-file-error");0===o.length&&(t=e(".k-upload-status-total",this.wrapper),a=e(".k-icon",t).removeClass("k-loading").addClass("k-warning").text(this.localization.statusUploaded),t.text(this.localization.headerStatusUploaded).append(a))},_hideHeaderUploadstatus:function(){e(".k-upload-status-total",this.wrapper).remove()},_onParentFormSubmit:function(){var a,o=this,n=o.element;t!==this._module.onAbort&&this._module.onAbort(),n.value||(a=e(n),a.attr("disabled","disabled"),window.setTimeout(function(){a.removeAttr("disabled")},0))},_onParentFormReset:function(){e(".k-upload-files",this.wrapper).remove()},_supportsFormData:function(){return"undefined"!=typeof FormData},_supportsMultiple:function(){var e=this._userAgent().indexOf("Windows")>-1;return!(k.support.browser.opera||k.support.browser.safari&&e)},_supportsDrop:function(){var e=this._userAgent().toLowerCase(),t=/chrome/.test(e),a=!t&&/safari/.test(e),o=a&&/windows/.test(e);return!o&&this._supportsFormData()&&this.options.async.saveUrl},_userAgent:function(){return navigator.userAgent},_setupDropZone:function(){var t,a,o=this;e(".k-upload-button",this.wrapper).wrap("
    "),t=o._ns,a=e(".k-dropzone",o.wrapper).append(e(""+o.localization.dropFilesHere+"")).on("dragenter"+t,d).on("dragover"+t,function(e){e.preventDefault()}).on("drop"+t,e.proxy(this._onDrop,this)),c(a,t,function(){a.addClass("k-dropzone-hovered")},function(){a.removeClass("k-dropzone-hovered")}),c(e(document),t,function(){a.addClass("k-dropzone-active"),a.closest(".k-upload").removeClass("k-upload-empty")},function(){a.removeClass("k-dropzone-active"),0===e("li.k-file",a.closest(".k-upload")).length&&a.closest(".k-upload").addClass("k-upload-empty")})},_supportsRemove:function(){return!!this.options.async.removeUrl},_submitRemove:function(t,a,o,n){var r=this,s=r.options.async.removeField||"fileNames",i=e.extend(a,h());i[s]=t,jQuery.ajax({type:this.options.async.removeVerb,dataType:"json",dataFilter:u,url:this.options.async.removeUrl,traditional:!0,data:i,success:o,error:n})},_wrapInput:function(e){var t=this,a=t.options;return e.wrap("
    "),a.async.saveUrl||e.closest(".k-upload").addClass("k-upload-sync"),e.closest(".k-upload").addClass("k-upload-empty"),e.closest(".k-button").append(""+this.localization.select+""),e.closest(".k-upload")},_checkAllComplete:function(){0===e(".k-file.k-file-progress",this.wrapper).length&&this.trigger(x)}}),D=function(e){this.name="syncUploadModule",this.element=e.wrapper,this.upload=e,this.element.closest("form").attr("enctype","multipart/form-data").attr("encoding","multipart/form-data")};D.prototype={onSelect:function(t){var n,r=this.upload,s=e(t.target);r._addInput(s),n=r._enqueueFile(a(s),{relatedInput:s,fileNames:o(s)}),r._fileAction(n,E)},onRemove:function(e){var t=m(e);t.data("relatedInput").remove(),this.upload._removeFileEntry(t)}},v=function(e){this.name="iframeUploadModule",this.element=e.wrapper,this.upload=e,this.iframes=[]},z._frameId=0,v.prototype={onSelect:function(t){var a=this.upload,o=e(t.target),n=this.prepareUpload(o);a.options.async.autoUpload?this.performUpload(n):(a._supportsRemove()&&this.upload._fileAction(n,E),a._showUploadButton())},prepareUpload:function(t){var n,r,s,i=this.upload,l=e(i.element),p=i.options.async.saveField||t.attr("name");return i._addInput(t),t.attr("name",p),n=this.createFrame(i.name+"_"+z._frameId++),this.registerFrame(n),r=this.createForm(i.options.async.saveUrl,n.attr("name")).append(l),s=i._enqueueFile(a(t),{frame:n,relatedInput:l,fileNames:o(t)}),n.data({form:r,file:s}),s},performUpload:function(t){var a,o,n,r={files:t.data("fileNames")},s=t.data("frame"),i=this.upload;if(i.trigger(b,r))i._removeFileEntry(s.data("file")),this.cleanupFrame(s),this.unregisterFrame(s);else{i._hideUploadButton(),i._showHeaderUploadStatus(),s.appendTo(document.body),a=s.data("form").appendTo(document.body),r.data=e.extend({},r.data,h());for(o in r.data)n=a.find("input[name='"+o+"']"),0===n.length&&(n=e("",{type:"hidden",name:o}).appendTo(a)),n.val(r.data[o]);i._fileAction(t,R),i._fileState(t,"uploading"),e(t).addClass("k-file-progress"),s.one("load",e.proxy(this.onIframeLoad,this)),a[0].submit()}},onSaveSelected:function(){var t=this;e(".k-file",this.element).each(function(){var a=e(this),o=f(a);o||t.performUpload(a)})},onIframeLoad:function(t){var a,o=e(t.target);try{a=o.contents().text()}catch(n){a="Error trying to get server response: "+n}this.processResponse(o,a)},processResponse:function(t,a){var o=t.data("file"),n=this,r={responseText:a};p(a,function(a){e.extend(r,{statusText:"OK",status:"200"}),n.upload._onFileProgress({target:e(o,n.upload.wrapper)},100),n.upload._onUploadSuccess({target:e(o,n.upload.wrapper)},a,r),n.cleanupFrame(t),n.unregisterFrame(t)},function(){e.extend(r,{statusText:"error",status:"500"}),n.upload._onUploadError({target:e(o,n.upload.wrapper)},r)})},onCancel:function(t){var a=e(t.target).data("frame");this.stopFrameSubmit(a),this.cleanupFrame(a),this.unregisterFrame(a),this.upload._removeFileEntry(a.data("file"))},onRetry:function(e){var t=m(e);this.performUpload(t)},onRemove:function(e,t){var a=m(e),o=a.data("frame");o?(this.unregisterFrame(o),this.upload._removeFileEntry(a),this.cleanupFrame(o)):l(a,this.upload,t)},onAbort:function(){var t=this.element,a=this;e.each(this.iframes,function(){e("input",this.data("form")).appendTo(t),a.stopFrameSubmit(this[0]),this.data("form").remove(),this.remove()}),this.iframes=[]},createFrame:function(t){return e("