diff --git a/Gulpfile.js b/Gulpfile.js index 8cae1b5..539986a 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -64,11 +64,10 @@ gulp.task('concatAppJs', function() { // plugins压缩 gulp.task('plugins', function() { - gulp.src(base + '/js/plugins/libs/*.js') - .pipe(uglify()) // 压缩 - // .pipe(concat('main.min.js')) - .pipe(gulp.dest(base + '/js/plugins/libs-min')); - + // gulp.src(base + '/js/plugins/libs/*.js') + // .pipe(uglify()) // 压缩 + // // .pipe(concat('main.min.js')) + // .pipe(gulp.dest(base + '/js/plugins/libs-min')); // 所有js合并成一个 var jss = [ @@ -83,8 +82,9 @@ gulp.task('plugins', function() { for(var i in jss) { jss[i] = base + '/js/plugins/' + jss[i] + '.js'; } + jss.push(base + '/js/plugins/libs-min/fileupload.js'); - gulp.src(jss) + return gulp.src(jss) .pipe(uglify()) // 压缩 .pipe(concat('main.min.js')) .pipe(gulp.dest(base + '/js/plugins')); @@ -138,10 +138,15 @@ gulp.task('devToProHtml', function() { .pipe(replace(//, '')) // 替换 .pipe(replace(//, "var tinyMCEPreInit = {base: '/public/tinymce', suffix: '.min'};")) // 替换 .pipe(replace(/plugins\/main.js/, "plugins/main.min.js")) // 替换 - // 连续两个空行换成一个空行, 没用 - .pipe(replace(/\n\n/g, '\n')) - .pipe(replace(/\n\n/g, '\n')) + // 连续两个空行换成一个空行 + .pipe(replace(/\r\n\r\n/g, '\r\n')) + .pipe(replace(/\r\n\r\n/g, '\r\n')) + .pipe(replace(/\r\n\r\n/g, '\r\n')) + .pipe(replace(/\r\n\r\n/g, '\r\n')) + .pipe(replace(/\r\n\r\n/g, '\r\n')) + .pipe(replace(/\r\n\r\n/g, '\r\n')) .pipe(replace('console.log(o);', '')) + .pipe(replace('console.trace(o);', '')) // .pipe(minifyHtml()) // 不行, 压缩后golang报错 .pipe(rename('note.html')) .pipe(gulp.dest(noteProBase)); @@ -290,35 +295,6 @@ gulp.task('concatAlbumJs', function() { .pipe(gulp.dest(base + '/album/js')); }); -// plugins压缩 -gulp.task('plugins', function() { - gulp.src(base + '/js/plugins/libs/*.js') - .pipe(uglify()) // 压缩 - // .pipe(concat('main.min.js')) - .pipe(gulp.dest(base + '/js/plugins/libs-min')); - - - // 所有js合并成一个 - var jss = [ - 'note_info', - 'tips', - 'history', - 'attachment_upload', - 'editor_drop_paste', - 'main' - ]; - - for(var i in jss) { - jss[i] = base + '/js/plugins/' + jss[i] + '.js'; - } - - gulp.src(jss) - .pipe(uglify()) // 压缩 - .pipe(concat('main.min.js')) - .pipe(gulp.dest(base + '/js/plugins')); -}); - - // tinymce // please set the right path on your own env var tinymceBase = '/Users/life/leanote/leanote-tools/tinymce_4.1.9_leanote_public'; diff --git a/public/js/plugins/attachment_upload.js b/public/js/plugins/attachment_upload.js index ec8efaf..105e349 100644 --- a/public/js/plugins/attachment_upload.js +++ b/public/js/plugins/attachment_upload.js @@ -1,7 +1,7 @@ // upload attachment // 依赖note var urlPrefix = UrlPrefix; -define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){ +define('attachment_upload', ['fileupload'], function(){ // Helper function that formats the file sizes function formatFileSize(bytes) { if (typeof bytes !== 'number') { diff --git a/public/js/plugins/editor_drop_paste.js b/public/js/plugins/editor_drop_paste.js index aa7e5c5..f89b4bb 100644 --- a/public/js/plugins/editor_drop_paste.js +++ b/public/js/plugins/editor_drop_paste.js @@ -1,7 +1,7 @@ // for editor. // drag image to editor var urlPrefix = UrlPrefix; // window.location.protocol + "//" + window.location.host; -define('editor_drop_paste', ['jquery.ui.widget', 'fileupload'], function() { +define('editor_drop_paste', ['fileupload'], function() { // 在toggle成pre或ace时 // 最后没有元素, 或者元素不是p, 则在最后插入之 diff --git a/public/js/plugins/libs-min/fileupload.js b/public/js/plugins/libs-min/fileupload.js index 467a341..9a0d916 100644 --- a/public/js/plugins/libs-min/fileupload.js +++ b/public/js/plugins/libs-min/fileupload.js @@ -1,3 +1,6 @@ -!function(t){"use strict";t(window.jQuery)}(function(t){"use strict";var e=0;t.ajaxTransport("iframe",function(r){if(r.async){var a,n,p;return{send:function(o,i){a=t('
'),a.attr("accept-charset",r.formAcceptCharset),p=/\?/.test(r.url)?"&":"?","DELETE"===r.type?(r.url=r.url+p+"_method=DELETE",r.type="POST"):"PUT"===r.type?(r.url=r.url+p+"_method=PUT",r.type="POST"):"PATCH"===r.type&&(r.url=r.url+p+"_method=PATCH",r.type="POST"),n=t('').bind("load",function(){var e,p=t.isArray(r.paramName)?r.paramName:[r.paramName];n.unbind("load").bind("load",function(){var e;try{if(e=n.contents(),!e.length||!e[0].firstChild)throw new Error}catch(r){e=void 0}i(200,"success",{iframe:e}),t('').appendTo(a),a.remove()}),a.prop("target",n.prop("name")).prop("action",r.url).prop("method",r.type),r.formData&&t.each(r.formData,function(e,r){t('').prop("name",r.name).val(r.value).appendTo(a)}),r.fileInput&&r.fileInput.length&&"POST"===r.type&&(e=r.fileInput.clone(),r.fileInput.after(function(t){return e[t]}),r.paramName&&r.fileInput.each(function(e){t(this).prop("name",p[e]||r.paramName)}),a.append(r.fileInput).prop("enctype","multipart/form-data").prop("encoding","multipart/form-data")),a.submit(),e&&e.length&&r.fileInput.each(function(r,a){var n=t(e[r]);t(a).prop("name",n.prop("name")),n.replaceWith(a)})}),a.append(n).appendTo(document.body)},abort:function(){n&&n.unbind("load").prop("src","javascript".concat(":false;")),a&&a.remove()}}}}),t.ajaxSetup({converters:{"iframe text":function(e){return e&&t(e[0].body).text()},"iframe json":function(e){return e&&t.parseJSON(t(e[0].body).text())},"iframe html":function(e){return e&&t(e[0].body).html()},"iframe script":function(e){return e&&t.globalEval(t(e[0].body).text())}}})}); -!function(t){t(jQuery)}(function(t,e){var i=0,n=Array.prototype.slice,s=t.cleanData;t.cleanData=function(e){for(var i,n=0;null!=(i=e[n]);n++)try{t(i).triggerHandler("remove")}catch(o){}s(e)},t.widget=function(e,i,n){var s,o,a,r,u={},d=e.split(".")[0];e=e.split(".")[1],s=d+"-"+e,n||(n=i,i=t.Widget),t.expr[":"][s.toLowerCase()]=function(e){return!!t.data(e,s)},t[d]=t[d]||{},o=t[d][e],a=t[d][e]=function(t,e){return this._createWidget?void(arguments.length&&this._createWidget(t,e)):new a(t,e)},t.extend(a,o,{version:n.version,_proto:t.extend({},n),_childConstructors:[]}),r=new i,r.options=t.widget.extend({},r.options),t.each(n,function(e,n){return t.isFunction(n)?void(u[e]=function(){var t=function(){return i.prototype[e].apply(this,arguments)},s=function(t){return i.prototype[e].apply(this,t)};return function(){var e,i=this._super,o=this._superApply;return this._super=t,this._superApply=s,e=n.apply(this,arguments),this._super=i,this._superApply=o,e}}()):void(u[e]=n)}),a.prototype=t.widget.extend(r,{widgetEventPrefix:o?r.widgetEventPrefix:e},u,{constructor:a,namespace:d,widgetName:e,widgetFullName:s}),o?(t.each(o._childConstructors,function(e,i){var n=i.prototype;t.widget(n.namespace+"."+n.widgetName,a,i._proto)}),delete o._childConstructors):i._childConstructors.push(a),t.widget.bridge(e,a)},t.widget.extend=function(i){for(var s,o,a=n.call(arguments,1),r=0,u=a.length;u>r;r++)for(s in a[r])o=a[r][s],a[r].hasOwnProperty(s)&&o!==e&&(t.isPlainObject(o)?i[s]=t.isPlainObject(i[s])?t.widget.extend({},i[s],o):t.widget.extend({},o):i[s]=o);return i},t.widget.bridge=function(i,s){var o=s.prototype.widgetFullName||i;t.fn[i]=function(a){var r="string"==typeof a,u=n.call(arguments,1),d=this;return a=!r&&u.length?t.widget.extend.apply(null,[a].concat(u)):a,r?this.each(function(){var n,s=t.data(this,o);return s?t.isFunction(s[a])&&"_"!==a.charAt(0)?(n=s[a].apply(s,u),n!==s&&n!==e?(d=n&&n.jquery?d.pushStack(n.get()):n,!1):void 0):t.error("no such method '"+a+"' for "+i+" widget instance"):t.error("cannot call methods on "+i+" prior to initialization; attempted to call method '"+a+"'")}):this.each(function(){var e=t.data(this,o);e?e.option(a||{})._init():t.data(this,o,new s(a,this))}),d}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{disabled:!1,create:null},_createWidget:function(e,n){n=t(n||this.defaultElement||this)[0],this.element=t(n),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this.bindings=t(),this.hoverable=t(),this.focusable=t(),n!==this&&(t.data(n,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===n&&this.destroy()}}),this.document=t(n.style?n.ownerDocument:n.document||n),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:t.noop,widget:function(){return this.element},option:function(i,n){var s,o,a,r=i;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof i)if(r={},s=i.split("."),i=s.shift(),s.length){for(o=r[i]=t.widget.extend({},this.options[i]),a=0;ai)&&(this.bitrate=(t-this.loaded)*(1e3/r)*8,this.loaded=t,this.timestamp=e),this.bitrate}},_isXHRUpload:function(t){return!t.forceIframeTransport&&(!t.multipart&&e.support.xhrFileUpload||e.support.xhrFormDataFileUpload)},_getFormData:function(t){var i;return"function"==typeof t.formData?t.formData(t.form):e.isArray(t.formData)?t.formData:t.formData?(i=[],e.each(t.formData,function(e,t){i.push({name:e,value:t})}),i):[]},_getTotal:function(t){var i=0;return e.each(t,function(e,t){i+=t.size||1}),i},_initProgressObject:function(e){e._progress={loaded:0,total:0,bitrate:0}},_onProgress:function(e,t){if(e.lengthComputable){var i,r=+new Date;if(t._time&&t.progressInterval&&r-t._time").prop("href",t.url).prop("host")!==location.host&&t.formData.push({name:t.redirectParamName||"redirect",value:t.redirect})},_initDataSettings:function(e){this._isXHRUpload(e)?(this._chunkedUpload(e,!0)||(e.data||this._initXHRData(e),this._initProgressListener(e)),e.postMessage&&(e.dataType="postmessage "+(e.dataType||""))):this._initIframeSettings(e,"iframe")},_getParamName:function(t){var i=e(t.fileInput),r=t.paramName;return r?e.isArray(r)||(r=[r]):(r=[],i.each(function(){for(var t=e(this),i=t.prop("name")||"files[]",n=(t.prop("files")||[1]).length;n;)r.push(i),n-=1}),r.length||(r=[i.prop("name")||"files[]"])),r},_initFormSettings:function(t){t.form&&t.form.length||(t.form=e(t.fileInput.prop("form")),t.form.length||(t.form=e(this.options.fileInput.prop("form")))),t.paramName=this._getParamName(t),t.urlFunc&&(t.url=t.urlFunc()),t.url||(t.url=t.form.prop("action")||location.href),t.type=(t.type||t.form.prop("method")||"").toUpperCase(),"POST"!==t.type&&"PUT"!==t.type&&"PATCH"!==t.type&&(t.type="POST"),t.formAcceptCharset||(t.formAcceptCharset=t.form.attr("accept-charset"))},_getAJAXSettings:function(t){var i=e.extend({},this.options,t);return this._initFormSettings(i),this._initDataSettings(i),i},_getDeferredState:function(e){return e.state?e.state():e.isResolved()?"resolved":e.isRejected()?"rejected":"pending"},_enhancePromise:function(e){return e.success=e.done,e.error=e.fail,e.complete=e.always,e},_getXHRPromise:function(t,i,r){var n=e.Deferred(),o=n.promise();return i=i||this.options.context||o,t===!0?n.resolveWith(i,r):t===!1&&n.rejectWith(i,r),o.abort=n.promise,this._enhancePromise(o)},_addConvenienceMethods:function(e,t){var i=this;t.submit=function(){return"pending"!==this.state()&&(t.jqXHR=this.jqXHR=i._trigger("submit",e,this)!==!1&&i._onSend(e,this)),this.jqXHR||i._getXHRPromise()},t.abort=function(){return this.jqXHR?this.jqXHR.abort():this._getXHRPromise()},t.state=function(){return this.jqXHR?i._getDeferredState(this.jqXHR):void 0},t.progress=function(){return this._progress}},_getUploadedBytes:function(e){var t=e.getResponseHeader("Range"),i=t&&t.split("-"),r=i&&i.length>1&&parseInt(i[1],10);return r&&r+1},_chunkedUpload:function(t,i){var r,n,o=this,s=t.files[0],a=s.size,l=t.uploadedBytes=t.uploadedBytes||0,p=t.maxChunkSize||a,u=s.slice||s.webkitSlice||s.mozSlice,d=e.Deferred(),h=d.promise();return this._isXHRUpload(t)&&u&&(l||a>p)&&!t.data?i?!0:l>=a?(s.error="Uploaded bytes exceed file size",this._getXHRPromise(!1,t.context,[null,"error",s.error])):(n=function(){var i=e.extend({},t),h=i._progress.loaded;i.blob=u.call(s,l,l+p,s.type),i.chunkSize=i.blob.size,i.contentRange="bytes "+l+"-"+(l+i.chunkSize-1)+"/"+a,o._initXHRData(i),o._initProgressListener(i),r=(o._trigger("chunksend",null,i)!==!1&&e.ajax(i)||o._getXHRPromise(!1,i.context)).done(function(r,s,p){l=o._getUploadedBytes(p)||l+i.chunkSize,i._progress.loaded===h&&o._onProgress(e.Event("progress",{lengthComputable:!0,loaded:l-i.uploadedBytes,total:l-i.uploadedBytes}),i),t.uploadedBytes=i.uploadedBytes=l,i.result=r,i.textStatus=s,i.jqXHR=p,o._trigger("chunkdone",null,i),o._trigger("chunkalways",null,i),a>l?n():d.resolveWith(i.context,[r,s,p])}).fail(function(e,t,r){i.jqXHR=e,i.textStatus=t,i.errorThrown=r,o._trigger("chunkfail",null,i),o._trigger("chunkalways",null,i),d.rejectWith(i.context,[e,t,r])})},this._enhancePromise(h),h.abort=function(){return r.abort()},n(),h):!1},_beforeSend:function(e,t){0===this._active&&(this._trigger("start"),this._bitrateTimer=new this._BitrateTimer,this._progress.loaded=this._progress.total=0,this._progress.bitrate=0),t._progress||(t._progress={}),t._progress.loaded=t.loaded=t.uploadedBytes||0,t._progress.total=t.total=this._getTotal(t.files)||1,t._progress.bitrate=t.bitrate=0,this._active+=1,this._progress.loaded+=t.loaded,this._progress.total+=t.total},_onDone:function(t,i,r,n){var o=n._progress.total;n._progress.loadeda._sending)for(var r=a._slots.shift();r;){if("pending"===a._getDeferredState(r)){r.resolve();break}r=a._slots.shift()}})};return this._beforeSend(t,l),this.options.sequentialUploads||this.options.limitConcurrentUploads&&this.options.limitConcurrentUploads<=this._sending?(this.options.limitConcurrentUploads>1?(o=e.Deferred(),this._slots.push(o),s=o.pipe(p)):s=this._sequence=this._sequence.pipe(p,p),s.abort=function(){return n=[void 0,"abort","abort"],r?r.abort():(o&&o.rejectWith(l.context,n),p())},this._enhancePromise(s)):p()},_onAdd:function(t,i){var r,n,o,s,a=this,l=!0,p=e.extend({},this.options,i),u=p.limitMultiFileUploads,d=this._getParamName(p);if((p.singleFileUploads||u)&&this._isXHRUpload(p))if(!p.singleFileUploads&&u)for(o=[],r=[],s=0;s").append(i)[0].reset(),t.after(i).detach(),e.cleanData(t.unbind("remove")),this.options.fileInput=this.options.fileInput.map(function(e,r){return r===t[0]?i[0]:r}),t[0]===this.element[0]&&(this.element=i)},_handleFileTreeEntry:function(t,i){var r,n=this,o=e.Deferred(),s=function(e){e&&!e.entry&&(e.entry=t),o.resolve([e])};return i=i||"",t.isFile?t._file?(t._file.relativePath=i,o.resolve(t._file)):t.file(function(e){e.relativePath=i,o.resolve(e)},s):t.isDirectory?(r=t.createReader(),r.readEntries(function(e){n._handleFileTreeEntries(e,i+t.name+"/").done(function(e){o.resolve(e)}).fail(s)},s)):o.resolve([]),o.promise()},_handleFileTreeEntries:function(t,i){var r=this;return e.when.apply(e,e.map(t,function(e){return r._handleFileTreeEntry(e,i)})).pipe(function(){return Array.prototype.concat.apply([],arguments)})},_getDroppedFiles:function(t){t=t||{};var i=t.items;return i&&i.length&&(i[0].webkitGetAsEntry||i[0].getAsEntry)?this._handleFileTreeEntries(e.map(i,function(e){var t;return e.webkitGetAsEntry?(t=e.webkitGetAsEntry(),t&&(t._file=e.getAsFile()),t):e.getAsEntry()})):e.Deferred().resolve(e.makeArray(t.files)).promise()},_getSingleFileInputFiles:function(t){t=e(t);var i,r,n=t.prop("webkitEntries")||t.prop("entries");if(n&&n.length)return this._handleFileTreeEntries(n);if(i=e.makeArray(t.prop("files")),i.length)void 0===i[0].name&&i[0].fileName&&e.each(i,function(e,t){t.name=t.fileName,t.size=t.fileSize});else{if(r=t.prop("value"),!r)return e.Deferred().resolve([]).promise();i=[{name:r.replace(/^.*\\/,"")}]}return e.Deferred().resolve(i).promise()},_getFileInputFiles:function(t){return t instanceof e&&1!==t.length?e.when.apply(e,e.map(t,this._getSingleFileInputFiles)).pipe(function(){return Array.prototype.concat.apply([],arguments)}):this._getSingleFileInputFiles(t)},_onChange:function(t){var i=this,r={fileInput:e(t.target),form:e(t.target.form)};this._getFileInputFiles(r.fileInput).always(function(e){r.files=e,i.options.replaceFileInput&&i._replaceFileInput(r.fileInput),i._trigger("change",t,r)!==!1&&i._onAdd(t,r)})},_onPaste:function(t){var i=t.originalEvent.clipboardData,r=i&&i.items||[],n={files:[]};return e.each(r,function(e,t){var i=t.getAsFile&&t.getAsFile();i&&n.files.push(i)}),this._trigger("paste",t,n)===!1||this._onAdd(t,n)===!1?!1:void 0},_onDrop:function(e){var t=this,i=e.dataTransfer=e.originalEvent.dataTransfer,r={};i&&i.files&&i.files.length&&e.preventDefault(),this._getDroppedFiles(i).always(function(i){r.files=i,t._trigger("drop",e,r)!==!1&&t._onAdd(e,r)})},_onDragOver:function(t){var i=t.dataTransfer=t.originalEvent.dataTransfer;return this._trigger("dragover",t)===!1?!1:void(i&&-1!==e.inArray("Files",i.types)&&(i.dropEffect="copy",t.preventDefault()))},_initEventHandlers:function(){this._isXHRUpload(this.options)&&(this._on(this.options.dropZone,{dragover:this._onDragOver,drop:this._onDrop}),this._on(this.options.pasteZone,{paste:this._onPaste})),this._on(this.options.fileInput,{change:this._onChange})},_destroyEventHandlers:function(){this._off(this.options.dropZone,"dragover drop"),this._off(this.options.pasteZone,"paste"),this._off(this.options.fileInput,"change")},_setOption:function(t,i){var r=-1!==e.inArray(t,this._refreshOptionsList);r&&this._destroyEventHandlers(),this._super(t,i),r&&(this._initSpecialOptions(),this._initEventHandlers())},_initSpecialOptions:function(){var t=this.options;void 0===t.fileInput?t.fileInput=this.element.is('input[type="file"]')?this.element:this.element.find('input[type="file"]'):t.fileInput instanceof e||(t.fileInput=e(t.fileInput)),t.dropZone instanceof e||(t.dropZone=e(t.dropZone)),t.pasteZone instanceof e||(t.pasteZone=e(t.pasteZone))},_create:function(){var t=this.options;e.extend(t,e(this.element[0].cloneNode(!1)).data()),this._initSpecialOptions(),this._slots=[],this._sequence=this._getXHRPromise(!0),this._sending=this._active=0,this._initProgressObject(this),this._initEventHandlers()},progress:function(){return this._progress},add:function(t){var i=this;t&&!this.options.disabled&&(t.fileInput&&!t.files?this._getFileInputFiles(t.fileInput).always(function(e){t.files=e,i._onAdd(null,t)}):(t.files=e.makeArray(t.files),this._onAdd(null,t)))},send:function(t){if(t&&!this.options.disabled){if(t.fileInput&&!t.files){var i,r,n=this,o=e.Deferred(),s=o.promise();return s.abort=function(){return r=!0,i?i.abort():(o.reject(null,"abort","abort"),s)},this._getFileInputFiles(t.fileInput).always(function(e){r||(t.files=e,i=n._onSend(null,t).then(function(e,t,i){o.resolve(e,t,i)},function(e,t,i){o.reject(e,t,i)}))}),this._enhancePromise(s)}if(t.files=e.makeArray(t.files),t.files.length)return this._onSend(null,t)}return this._getXHRPromise(!1,t&&t.context)}})}); \ No newline at end of file +// 包含3个js: jquery.fileupload.js, jquery.iframe-transport.js, jquery.ui.widget.js +define('fileupload', [], function() { + !function(t){"use strict";t(window.jQuery)}(function(t){"use strict";var e=0;t.ajaxTransport("iframe",function(r){if(r.async){var a,n,p;return{send:function(o,i){a=t('
'),a.attr("accept-charset",r.formAcceptCharset),p=/\?/.test(r.url)?"&":"?","DELETE"===r.type?(r.url=r.url+p+"_method=DELETE",r.type="POST"):"PUT"===r.type?(r.url=r.url+p+"_method=PUT",r.type="POST"):"PATCH"===r.type&&(r.url=r.url+p+"_method=PATCH",r.type="POST"),n=t('').bind("load",function(){var e,p=t.isArray(r.paramName)?r.paramName:[r.paramName];n.unbind("load").bind("load",function(){var e;try{if(e=n.contents(),!e.length||!e[0].firstChild)throw new Error}catch(r){e=void 0}i(200,"success",{iframe:e}),t('').appendTo(a),a.remove()}),a.prop("target",n.prop("name")).prop("action",r.url).prop("method",r.type),r.formData&&t.each(r.formData,function(e,r){t('').prop("name",r.name).val(r.value).appendTo(a)}),r.fileInput&&r.fileInput.length&&"POST"===r.type&&(e=r.fileInput.clone(),r.fileInput.after(function(t){return e[t]}),r.paramName&&r.fileInput.each(function(e){t(this).prop("name",p[e]||r.paramName)}),a.append(r.fileInput).prop("enctype","multipart/form-data").prop("encoding","multipart/form-data")),a.submit(),e&&e.length&&r.fileInput.each(function(r,a){var n=t(e[r]);t(a).prop("name",n.prop("name")),n.replaceWith(a)})}),a.append(n).appendTo(document.body)},abort:function(){n&&n.unbind("load").prop("src","javascript".concat(":false;")),a&&a.remove()}}}}),t.ajaxSetup({converters:{"iframe text":function(e){return e&&t(e[0].body).text()},"iframe json":function(e){return e&&t.parseJSON(t(e[0].body).text())},"iframe html":function(e){return e&&t(e[0].body).html()},"iframe script":function(e){return e&&t.globalEval(t(e[0].body).text())}}})}); + !function(t){t(jQuery)}(function(t,e){var i=0,n=Array.prototype.slice,s=t.cleanData;t.cleanData=function(e){for(var i,n=0;null!=(i=e[n]);n++)try{t(i).triggerHandler("remove")}catch(o){}s(e)},t.widget=function(e,i,n){var s,o,a,r,u={},d=e.split(".")[0];e=e.split(".")[1],s=d+"-"+e,n||(n=i,i=t.Widget),t.expr[":"][s.toLowerCase()]=function(e){return!!t.data(e,s)},t[d]=t[d]||{},o=t[d][e],a=t[d][e]=function(t,e){return this._createWidget?void(arguments.length&&this._createWidget(t,e)):new a(t,e)},t.extend(a,o,{version:n.version,_proto:t.extend({},n),_childConstructors:[]}),r=new i,r.options=t.widget.extend({},r.options),t.each(n,function(e,n){return t.isFunction(n)?void(u[e]=function(){var t=function(){return i.prototype[e].apply(this,arguments)},s=function(t){return i.prototype[e].apply(this,t)};return function(){var e,i=this._super,o=this._superApply;return this._super=t,this._superApply=s,e=n.apply(this,arguments),this._super=i,this._superApply=o,e}}()):void(u[e]=n)}),a.prototype=t.widget.extend(r,{widgetEventPrefix:o?r.widgetEventPrefix:e},u,{constructor:a,namespace:d,widgetName:e,widgetFullName:s}),o?(t.each(o._childConstructors,function(e,i){var n=i.prototype;t.widget(n.namespace+"."+n.widgetName,a,i._proto)}),delete o._childConstructors):i._childConstructors.push(a),t.widget.bridge(e,a)},t.widget.extend=function(i){for(var s,o,a=n.call(arguments,1),r=0,u=a.length;u>r;r++)for(s in a[r])o=a[r][s],a[r].hasOwnProperty(s)&&o!==e&&(t.isPlainObject(o)?i[s]=t.isPlainObject(i[s])?t.widget.extend({},i[s],o):t.widget.extend({},o):i[s]=o);return i},t.widget.bridge=function(i,s){var o=s.prototype.widgetFullName||i;t.fn[i]=function(a){var r="string"==typeof a,u=n.call(arguments,1),d=this;return a=!r&&u.length?t.widget.extend.apply(null,[a].concat(u)):a,r?this.each(function(){var n,s=t.data(this,o);return s?t.isFunction(s[a])&&"_"!==a.charAt(0)?(n=s[a].apply(s,u),n!==s&&n!==e?(d=n&&n.jquery?d.pushStack(n.get()):n,!1):void 0):t.error("no such method '"+a+"' for "+i+" widget instance"):t.error("cannot call methods on "+i+" prior to initialization; attempted to call method '"+a+"'")}):this.each(function(){var e=t.data(this,o);e?e.option(a||{})._init():t.data(this,o,new s(a,this))}),d}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{disabled:!1,create:null},_createWidget:function(e,n){n=t(n||this.defaultElement||this)[0],this.element=t(n),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this.bindings=t(),this.hoverable=t(),this.focusable=t(),n!==this&&(t.data(n,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===n&&this.destroy()}}),this.document=t(n.style?n.ownerDocument:n.document||n),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:t.noop,widget:function(){return this.element},option:function(i,n){var s,o,a,r=i;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof i)if(r={},s=i.split("."),i=s.shift(),s.length){for(o=r[i]=t.widget.extend({},this.options[i]),a=0;ai)&&(this.bitrate=(t-this.loaded)*(1e3/r)*8,this.loaded=t,this.timestamp=e),this.bitrate}},_isXHRUpload:function(t){return!t.forceIframeTransport&&(!t.multipart&&e.support.xhrFileUpload||e.support.xhrFormDataFileUpload)},_getFormData:function(t){var i;return"function"==typeof t.formData?t.formData(t.form):e.isArray(t.formData)?t.formData:t.formData?(i=[],e.each(t.formData,function(e,t){i.push({name:e,value:t})}),i):[]},_getTotal:function(t){var i=0;return e.each(t,function(e,t){i+=t.size||1}),i},_initProgressObject:function(e){e._progress={loaded:0,total:0,bitrate:0}},_onProgress:function(e,t){if(e.lengthComputable){var i,r=+new Date;if(t._time&&t.progressInterval&&r-t._time").prop("href",t.url).prop("host")!==location.host&&t.formData.push({name:t.redirectParamName||"redirect",value:t.redirect})},_initDataSettings:function(e){this._isXHRUpload(e)?(this._chunkedUpload(e,!0)||(e.data||this._initXHRData(e),this._initProgressListener(e)),e.postMessage&&(e.dataType="postmessage "+(e.dataType||""))):this._initIframeSettings(e,"iframe")},_getParamName:function(t){var i=e(t.fileInput),r=t.paramName;return r?e.isArray(r)||(r=[r]):(r=[],i.each(function(){for(var t=e(this),i=t.prop("name")||"files[]",n=(t.prop("files")||[1]).length;n;)r.push(i),n-=1}),r.length||(r=[i.prop("name")||"files[]"])),r},_initFormSettings:function(t){t.form&&t.form.length||(t.form=e(t.fileInput.prop("form")),t.form.length||(t.form=e(this.options.fileInput.prop("form")))),t.paramName=this._getParamName(t),t.urlFunc&&(t.url=t.urlFunc()),t.url||(t.url=t.form.prop("action")||location.href),t.type=(t.type||t.form.prop("method")||"").toUpperCase(),"POST"!==t.type&&"PUT"!==t.type&&"PATCH"!==t.type&&(t.type="POST"),t.formAcceptCharset||(t.formAcceptCharset=t.form.attr("accept-charset"))},_getAJAXSettings:function(t){var i=e.extend({},this.options,t);return this._initFormSettings(i),this._initDataSettings(i),i},_getDeferredState:function(e){return e.state?e.state():e.isResolved()?"resolved":e.isRejected()?"rejected":"pending"},_enhancePromise:function(e){return e.success=e.done,e.error=e.fail,e.complete=e.always,e},_getXHRPromise:function(t,i,r){var n=e.Deferred(),o=n.promise();return i=i||this.options.context||o,t===!0?n.resolveWith(i,r):t===!1&&n.rejectWith(i,r),o.abort=n.promise,this._enhancePromise(o)},_addConvenienceMethods:function(e,t){var i=this;t.submit=function(){return"pending"!==this.state()&&(t.jqXHR=this.jqXHR=i._trigger("submit",e,this)!==!1&&i._onSend(e,this)),this.jqXHR||i._getXHRPromise()},t.abort=function(){return this.jqXHR?this.jqXHR.abort():this._getXHRPromise()},t.state=function(){return this.jqXHR?i._getDeferredState(this.jqXHR):void 0},t.progress=function(){return this._progress}},_getUploadedBytes:function(e){var t=e.getResponseHeader("Range"),i=t&&t.split("-"),r=i&&i.length>1&&parseInt(i[1],10);return r&&r+1},_chunkedUpload:function(t,i){var r,n,o=this,s=t.files[0],a=s.size,l=t.uploadedBytes=t.uploadedBytes||0,p=t.maxChunkSize||a,u=s.slice||s.webkitSlice||s.mozSlice,d=e.Deferred(),h=d.promise();return this._isXHRUpload(t)&&u&&(l||a>p)&&!t.data?i?!0:l>=a?(s.error="Uploaded bytes exceed file size",this._getXHRPromise(!1,t.context,[null,"error",s.error])):(n=function(){var i=e.extend({},t),h=i._progress.loaded;i.blob=u.call(s,l,l+p,s.type),i.chunkSize=i.blob.size,i.contentRange="bytes "+l+"-"+(l+i.chunkSize-1)+"/"+a,o._initXHRData(i),o._initProgressListener(i),r=(o._trigger("chunksend",null,i)!==!1&&e.ajax(i)||o._getXHRPromise(!1,i.context)).done(function(r,s,p){l=o._getUploadedBytes(p)||l+i.chunkSize,i._progress.loaded===h&&o._onProgress(e.Event("progress",{lengthComputable:!0,loaded:l-i.uploadedBytes,total:l-i.uploadedBytes}),i),t.uploadedBytes=i.uploadedBytes=l,i.result=r,i.textStatus=s,i.jqXHR=p,o._trigger("chunkdone",null,i),o._trigger("chunkalways",null,i),a>l?n():d.resolveWith(i.context,[r,s,p])}).fail(function(e,t,r){i.jqXHR=e,i.textStatus=t,i.errorThrown=r,o._trigger("chunkfail",null,i),o._trigger("chunkalways",null,i),d.rejectWith(i.context,[e,t,r])})},this._enhancePromise(h),h.abort=function(){return r.abort()},n(),h):!1},_beforeSend:function(e,t){0===this._active&&(this._trigger("start"),this._bitrateTimer=new this._BitrateTimer,this._progress.loaded=this._progress.total=0,this._progress.bitrate=0),t._progress||(t._progress={}),t._progress.loaded=t.loaded=t.uploadedBytes||0,t._progress.total=t.total=this._getTotal(t.files)||1,t._progress.bitrate=t.bitrate=0,this._active+=1,this._progress.loaded+=t.loaded,this._progress.total+=t.total},_onDone:function(t,i,r,n){var o=n._progress.total;n._progress.loadeda._sending)for(var r=a._slots.shift();r;){if("pending"===a._getDeferredState(r)){r.resolve();break}r=a._slots.shift()}})};return this._beforeSend(t,l),this.options.sequentialUploads||this.options.limitConcurrentUploads&&this.options.limitConcurrentUploads<=this._sending?(this.options.limitConcurrentUploads>1?(o=e.Deferred(),this._slots.push(o),s=o.pipe(p)):s=this._sequence=this._sequence.pipe(p,p),s.abort=function(){return n=[void 0,"abort","abort"],r?r.abort():(o&&o.rejectWith(l.context,n),p())},this._enhancePromise(s)):p()},_onAdd:function(t,i){var r,n,o,s,a=this,l=!0,p=e.extend({},this.options,i),u=p.limitMultiFileUploads,d=this._getParamName(p);if((p.singleFileUploads||u)&&this._isXHRUpload(p))if(!p.singleFileUploads&&u)for(o=[],r=[],s=0;s").append(i)[0].reset(),t.after(i).detach(),e.cleanData(t.unbind("remove")),this.options.fileInput=this.options.fileInput.map(function(e,r){return r===t[0]?i[0]:r}),t[0]===this.element[0]&&(this.element=i)},_handleFileTreeEntry:function(t,i){var r,n=this,o=e.Deferred(),s=function(e){e&&!e.entry&&(e.entry=t),o.resolve([e])};return i=i||"",t.isFile?t._file?(t._file.relativePath=i,o.resolve(t._file)):t.file(function(e){e.relativePath=i,o.resolve(e)},s):t.isDirectory?(r=t.createReader(),r.readEntries(function(e){n._handleFileTreeEntries(e,i+t.name+"/").done(function(e){o.resolve(e)}).fail(s)},s)):o.resolve([]),o.promise()},_handleFileTreeEntries:function(t,i){var r=this;return e.when.apply(e,e.map(t,function(e){return r._handleFileTreeEntry(e,i)})).pipe(function(){return Array.prototype.concat.apply([],arguments)})},_getDroppedFiles:function(t){t=t||{};var i=t.items;return i&&i.length&&(i[0].webkitGetAsEntry||i[0].getAsEntry)?this._handleFileTreeEntries(e.map(i,function(e){var t;return e.webkitGetAsEntry?(t=e.webkitGetAsEntry(),t&&(t._file=e.getAsFile()),t):e.getAsEntry()})):e.Deferred().resolve(e.makeArray(t.files)).promise()},_getSingleFileInputFiles:function(t){t=e(t);var i,r,n=t.prop("webkitEntries")||t.prop("entries");if(n&&n.length)return this._handleFileTreeEntries(n);if(i=e.makeArray(t.prop("files")),i.length)void 0===i[0].name&&i[0].fileName&&e.each(i,function(e,t){t.name=t.fileName,t.size=t.fileSize});else{if(r=t.prop("value"),!r)return e.Deferred().resolve([]).promise();i=[{name:r.replace(/^.*\\/,"")}]}return e.Deferred().resolve(i).promise()},_getFileInputFiles:function(t){return t instanceof e&&1!==t.length?e.when.apply(e,e.map(t,this._getSingleFileInputFiles)).pipe(function(){return Array.prototype.concat.apply([],arguments)}):this._getSingleFileInputFiles(t)},_onChange:function(t){var i=this,r={fileInput:e(t.target),form:e(t.target.form)};this._getFileInputFiles(r.fileInput).always(function(e){r.files=e,i.options.replaceFileInput&&i._replaceFileInput(r.fileInput),i._trigger("change",t,r)!==!1&&i._onAdd(t,r)})},_onPaste:function(t){var i=t.originalEvent.clipboardData,r=i&&i.items||[],n={files:[]};return e.each(r,function(e,t){var i=t.getAsFile&&t.getAsFile();i&&n.files.push(i)}),this._trigger("paste",t,n)===!1||this._onAdd(t,n)===!1?!1:void 0},_onDrop:function(e){var t=this,i=e.dataTransfer=e.originalEvent.dataTransfer,r={};i&&i.files&&i.files.length&&e.preventDefault(),this._getDroppedFiles(i).always(function(i){r.files=i,t._trigger("drop",e,r)!==!1&&t._onAdd(e,r)})},_onDragOver:function(t){var i=t.dataTransfer=t.originalEvent.dataTransfer;return this._trigger("dragover",t)===!1?!1:void(i&&-1!==e.inArray("Files",i.types)&&(i.dropEffect="copy",t.preventDefault()))},_initEventHandlers:function(){this._isXHRUpload(this.options)&&(this._on(this.options.dropZone,{dragover:this._onDragOver,drop:this._onDrop}),this._on(this.options.pasteZone,{paste:this._onPaste})),this._on(this.options.fileInput,{change:this._onChange})},_destroyEventHandlers:function(){this._off(this.options.dropZone,"dragover drop"),this._off(this.options.pasteZone,"paste"),this._off(this.options.fileInput,"change")},_setOption:function(t,i){var r=-1!==e.inArray(t,this._refreshOptionsList);r&&this._destroyEventHandlers(),this._super(t,i),r&&(this._initSpecialOptions(),this._initEventHandlers())},_initSpecialOptions:function(){var t=this.options;void 0===t.fileInput?t.fileInput=this.element.is('input[type="file"]')?this.element:this.element.find('input[type="file"]'):t.fileInput instanceof e||(t.fileInput=e(t.fileInput)),t.dropZone instanceof e||(t.dropZone=e(t.dropZone)),t.pasteZone instanceof e||(t.pasteZone=e(t.pasteZone))},_create:function(){var t=this.options;e.extend(t,e(this.element[0].cloneNode(!1)).data()),this._initSpecialOptions(),this._slots=[],this._sequence=this._getXHRPromise(!0),this._sending=this._active=0,this._initProgressObject(this),this._initEventHandlers()},progress:function(){return this._progress},add:function(t){var i=this;t&&!this.options.disabled&&(t.fileInput&&!t.files?this._getFileInputFiles(t.fileInput).always(function(e){t.files=e,i._onAdd(null,t)}):(t.files=e.makeArray(t.files),this._onAdd(null,t)))},send:function(t){if(t&&!this.options.disabled){if(t.fileInput&&!t.files){var i,r,n=this,o=e.Deferred(),s=o.promise();return s.abort=function(){return r=!0,i?i.abort():(o.reject(null,"abort","abort"),s)},this._getFileInputFiles(t.fileInput).always(function(e){r||(t.files=e,i=n._onSend(null,t).then(function(e,t,i){o.resolve(e,t,i)},function(e,t,i){o.reject(e,t,i)}))}),this._enhancePromise(s)}if(t.files=e.makeArray(t.files),t.files.length)return this._onSend(null,t)}return this._getXHRPromise(!1,t&&t.context)}})}); +}); \ No newline at end of file diff --git a/public/js/plugins/main.js b/public/js/plugins/main.js index e800afa..814c02f 100644 --- a/public/js/plugins/main.js +++ b/public/js/plugins/main.js @@ -9,9 +9,9 @@ requirejs.config({ 'editor_drop_paste': 'js/plugins/editor_drop_paste', 'attachment_upload': 'js/plugins/attachment_upload', - 'jquery.ui.widget': 'js/plugins/libs-min/jquery.ui.widget', - 'fileupload': 'js/plugins/libs-min/jquery.fileupload', - 'iframe-transport': 'js/plugins/libs-min/jquery.iframe-transport', + // 'jquery.ui.widget': 'js/plugins/libs-min/jquery.ui.widget', + 'fileupload': 'js/plugins/libs-min/fileupload', + // 'iframe-transport': 'js/plugins/libs-min/jquery.iframe-transport', 'note_info': 'js/plugins/note_info', 'tips': 'js/plugins/tips', @@ -19,7 +19,7 @@ requirejs.config({ }, shim: { // life - 'fileupload': {deps: ['jquery.ui.widget', 'iframe-transport']}, + // 'fileupload': {deps: ['jquery.ui.widget', 'iframe-transport']}, } }); diff --git a/public/js/plugins/main.min.js b/public/js/plugins/main.min.js index 697002d..edb1430 100644 --- a/public/js/plugins/main.min.js +++ b/public/js/plugins/main.min.js @@ -1,6 +1,7 @@ define("note_info",[],function(){var t=["","',"','',"","","","
"+getMsg("Create Time")+'
"+getMsg("Update Time")+'
"+getMsg("Post Url")+"",'
','http://blog.leanote.com/life/post/life-life-life-a-leanote','',"",' ',"
","
"].join(""),e=$(t),n=e.find("#noteInfoCreatedTime"),o=e.find("#noteInfoUpdatedTime"),i=(e.find("#noteInfoPostUrl"),e.find(".post-url-tr")),r=e.find(".post-url-wrap"),l=e.find("input"),d=e.find(".post-url-base"),s=e.find(".post-url-text"),a={$noteInfo:$("#noteInfo"),note:null,bind:function(){var t=this;$("#noteInfoDropdown").click(function(){t.render()}),e.find(".post-url-pencil").click(function(){r.addClass("post-url-edit"),l.val(decodeURI(t.note.UrlTitle)),l.focus()}),l.keydown(function(t){13===t.keyCode&&l.blur()}),l.blur(function(){r.removeClass("post-url-edit");var e=l.val();e&&ajaxPost("/member/blog/updateBlogUrlTitle",{noteId:t.note.NoteId,urlTitle:e},function(e){if(reIsOk(e)){var n=encodeURI(e.Item);t.note.UrlTitle=n,s.text(decodeURI(t.note.UrlTitle))}else alert(e.Msg||"error")})}),LEA.on("noteChanged",function(e){t.render(e)})},getPostUrl:function(t){return""},rendered:!1,render:function(t){var r=this;t||(t=Note.getCurNote()),t&&(r.note=t,n.html(goNowToDatetime(t.CreatedTime)),o.html(goNowToDatetime(t.UpdatedTime)),t.IsBlog?(i.removeClass("hide"),d.text(UserInfo.PostUrl+"/"),s.text(decodeURI(t.UrlTitle))):i.addClass("hide"),r.rendered||(r.$noteInfo.html(e),r.rendered=!0))},init:function(){this.bind()}};a.init()}); define("tips",[],function(){var d=['"].join(""),a=$(d),i={init:function(){$("#tipsBtn").click(function(){a.modal({show:!0})})}};i.init()}); define("history",[],function(){var t=['"].join(""),i=$(t),s=i.find(".history-content"),e=i.find(".history-list"),o=i.find(".history-num"),n={note:null,list:[],curIndex:0,renderContent:function(t){var i=this.list[t].Content;this.curIndex=t;var o="
",n="
";this.note.IsMarkdown&&(o="
",n="
"),s.html(o+i+n);var a=e.find("a");a.removeClass("active"),a.eq(t).addClass("active")},render:function(t){var s="";if(this.list=t,t)for(var n=0;n#'+(n+1)+""+goNowToDatetime(a.UpdatedTime)+""}e.html(s),this.renderContent(0),o.html(t.length),i.modal({show:!0})},bind:function(){var t=this;$("#contentHistory").click(function(){t.getHistories()}),e.on("click","a",function(){var i=$(this).data("index");t.renderContent(i)}),i.find(".back").click(function(){confirm(getMsg("confirmBackup"))&&(Note.curChangedSaveIt(!0),note=Note.cache[Note.curNoteId],setEditorContent(t.list[t.curIndex].Content,note.IsMarkdown),i.modal("hide"),Note.curChangedSaveIt(!0))})},getHistories:function(){var t=this,i=Note.getCurNote();t.note=i,ajaxGet("/noteContentHistory/listHistories",{noteId:Note.curNoteId},function(i){return isArray(i)?void t.render(i):void alert(getMsg("noHistories"))})},init:function(){this.bind()}};n.init()}); -var urlPrefix=UrlPrefix;define("attachment_upload",["jquery.ui.widget","fileupload"],function(){function e(e){return"number"!=typeof e?"":e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(2)+" MB":(e/1e3).toFixed(2)+" KB"}function t(e,t){var a=$(e);$(t).bind("dragover",function(e){e.preventDefault();var t=window.dropZoneTimeoutAttach;t&&clearTimeout(t);var o=!1,i=e.target;do{if(i===a[0]){o=!0;break}i=i.parentNode}while(null!=i);o?a.addClass("hover"):a.removeClass("hover"),window.dropZoneTimeoutAttach=setTimeout(function(){window.dropZoneTimeoutAttach=null,a.removeClass("in hover")},100)})}t("#dropAttach","#uploadAttach");var a=function(){$(".dropzone .btn-choose-file").click(function(){$(this).parent().find("input").click()});var t=$("#attachUploadMsg");$("#uploadAttach").fileupload({dataType:"json",pasteZone:"",dropZone:$("#dropAttach"),formData:function(e){return[{name:"noteId",value:Note.curNoteId}]},add:function(a,o){var i=Note.getCurNote();if(!i||i.IsNew)return void alert("This note hasn't saved, please save it firstly!");var r=$('');r.append(o.files[0].name+" ["+e(o.files[0].size)+"]"),t.html(r),o.context=t;var n=o.files[0].size,l=+GlobalConfigs.uploadAttachSize||100;if("number"==typeof n&&n>1048576*l)return r.find("img").remove(),r.removeClass("alert-info").addClass("alert-danger"),r.append(" Warning: File size is bigger than "+l+"M"),void setTimeout(function(e){return function(){e.remove()}}(r),3e3);var s;setTimeout(function(){s=o.submit()},10)},done:function(t,a){if(1==a.result.Ok)a.context.html(""),Attach.addAttach(a.result.Item);else{a.result;a.context.html("");var o=$('');o.append("Error: "+a.files[0].name+" ["+e(a.files[0].size)+"] "+a.result.Msg),a.context.html(o),setTimeout(function(e){return function(){e.remove()}}(o),3e3)}$("#uploadAttachMsg").scrollTop(1e3)},fail:function(t,a){a.context.html("");var o=$('');o.append("Error: "+a.files[0].name+" ["+e(a.files[0].size)+"] "+a.errorThrown),a.context.html(o),setTimeout(function(e){return function(){e.remove()}}(o),3e3),$("#uploadAttachMsg").scrollTop(1e3)}})};a()}); -var urlPrefix=UrlPrefix;define("editor_drop_paste",["jquery.ui.widget","fileupload"],function(){function e(){var e=$("#editorContent").children(),t=e&&e.length>0?e[e.length-1]:null;t&&"P"==t.tagName||$("#editorContent").append('


')}function t(t){var i="__mcenew"+(new Date).getTime(),o='
0%
';this.containerStr=o,t.insertContent(o),e();var a=$("#"+i);this.container=a,this.id=i,this.processBar=a.find(".progress-bar")}function i(e,t){function i(e,i){o.parentNode.removeChild(o),t({width:e,height:i})}var o=document.createElement("img");o.onload=function(){i(o.clientWidth,o.clientHeight)},o.onerror=function(){i()},o.src=e;var a=o.style;a.visibility="hidden",a.position="fixed",a.bottom=a.left=0,a.width=a.height="auto",document.body.appendChild(o)}function o(e){var t=tinymce.activeEditor,o=t.dom,r=function(t){function r(e){o.setAttrib(n,"src",t.src),t.title&&o.setAttrib(n,"title",t.title),o.setAttrib(n,"id",null)}var n,s={};s.id="__mcenew"+a++,s.src="/images/loading-24.gif",n=o.createHTML("img",s),tinymce.activeEditor.insertContent(n),n=o.get(s.id),i(e.src,r)},n="";if(fileIds=e.src.split("fileId="),2==fileIds.length&&fileIds[1].length=="53aecf8a8a039a43c8036282".length&&(n=fileIds[1]),n){var s=Note.getCurNote();s&&s.UserId!=UserInfo.UserId?!function(e){ajaxPost("/file/copyImage",{userId:UserInfo.UserId,fileId:n,toUserId:s.UserId},function(t){if(reIsOk(t)&&t.Id){var i=window.location.protocol+"//"+window.location.host;e.src=i+"/api/file/getImage?fileId="+t.Id}r(e)})}(e):r(e)}else r(e)}t.prototype.update=function(e){var t=this;e=Math.ceil(100*e),e>=100&&(e=99),e+="%",$("#"+t.id+" .progress-bar").html(e).css("width",e)},t.prototype.replace=function(e){var t=this;i(e,function(){$("#"+t.id).replaceWith('')})},t.prototype.remove=function(){var e=this;$("#"+e.id).remove()};var a=1,r=function(){function e(e){return"number"!=typeof e?"":e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(2)+" MB":(e/1e3).toFixed(2)+" KB"}function t(){$("#upload").css("z-index",12);var e=+$("#mceToolbar").css("height").slice(0,-2);$("#upload").css("top",e-8),$("#upload").show()}function i(){$("#upload").css("z-index",0).css("top","auto").hide()}var a=$("#upload ul");$("#drop a").click(function(){$(this).parent().find("input").click()}),$("#upload").fileupload({dataType:"json",pasteZone:"",acceptFileTypes:/(\.|\/)(gif|jpg|jpeg|png|jpe)$/i,maxFileSize:21e4,dropZone:$("#drop"),formData:function(e){return[{name:"albumId",value:""}]},add:function(t,i){var o=$('
  • ');o.find("div").append(i.files[0].name+" ["+e(i.files[0].size)+"]"),i.context=o.appendTo(a);i.submit()},done:function(t,i){if(1==i.result.Ok){i.context.remove();var a={src:urlPrefix+"/api/file/getImage?fileId="+i.result.Id};o(a)}else{i.context.empty();var r=$('
  • ');r.find("div").append(""+getMsg("Error")+": "+i.files[0].name+" ["+e(i.files[0].size)+"] "+i.result.Msg),i.context.append(r),setTimeout(function(e){return function(){e.remove()}}(r),2e3)}$("#uploadMsg").scrollTop(1e3)},fail:function(t,i){i.context.empty();var o=$('
  • ');o.find("div").append(""+getMsg("Error")+": "+i.files[0].name+" ["+e(i.files[0].size)+"] "+i.errorThrown),i.context.append(o),setTimeout(function(e){return function(){e.remove()}}(o),2e3),$("#uploadMsg").scrollTop(1e3)}}),$(document).on("drop dragover",function(e){e.preventDefault()}),$(document).bind("dragover",function(e){var o=$("#drop"),a=window.dropZoneTimeout;a?clearTimeout(a):(o.addClass("in"),t());var r=!1,n=e.target;do{if(n===o[0]){r=!0;break}n=n.parentNode}while(null!=n);r?(o.addClass("hover"),LEA.readOnly&&LEA.toggleWriteable()):o.removeClass("hover"),window.dropZoneTimeout=setTimeout(function(){window.dropZoneTimeout=null,o.removeClass("in hover"),i()},500)})},n=0,s=function(){var e,i;$("#editorContent, #wmd-input .editor-content").fileupload({dataType:"json",pasteZone:$("#editorContent, #wmd-input"),dropZone:"",maxFileSize:21e4,url:"/file/pasteImage",paramName:"file",formData:function(e){return[{name:"from",value:"pasteImage"},{name:"noteId",value:Note.curNoteId}]},progress:function(t,i){e&&!e.IsMarkdown&&i.process.update(i.loaded/i.total)},add:function(o,a){var r=(new Date).getTime();if(!(500>r-n)){n=r;var s=Note.getCurNote();if(e=s,!s||s.IsNew)return void alert("This note hasn't saved, please save it firstly!");if(i=tinymce.EditorManager.activeEditor,!s.IsMarkdown)var l=new t(i);a.process=l;a.submit()}},done:function(t,i){if(1==i.result.Ok){var o=i.result,a=UrlPrefix,r=a+"/api/file/getImage?fileId="+o.Id;e&&!e.IsMarkdown?i.process.replace(r):MD&&MD.insertLink(r,"title",!0)}else i.process.remove()},fail:function(t,i){e&&!e.IsMarkdown&&i.process.remove()}})};r(),s()}); -requirejs.config({paths:{editor_drop_paste:"js/plugins/editor_drop_paste",attachment_upload:"js/plugins/attachment_upload","jquery.ui.widget":"js/plugins/libs-min/jquery.ui.widget",fileupload:"js/plugins/libs-min/jquery.fileupload","iframe-transport":"js/plugins/libs-min/jquery.iframe-transport",note_info:"js/plugins/note_info",tips:"js/plugins/tips",history:"js/plugins/history"},shim:{fileupload:{deps:["jquery.ui.widget","iframe-transport"]}}}),setTimeout(function(){require(["editor_drop_paste","attachment_upload"]),require(["note_info"]),setTimeout(function(){require(["tips"]),require(["history"])},10)}); \ No newline at end of file +var urlPrefix=UrlPrefix;define("attachment_upload",["fileupload"],function(){function e(e){return"number"!=typeof e?"":e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(2)+" MB":(e/1e3).toFixed(2)+" KB"}function t(e,t){var a=$(e);$(t).bind("dragover",function(e){e.preventDefault();var t=window.dropZoneTimeoutAttach;t&&clearTimeout(t);var o=!1,i=e.target;do{if(i===a[0]){o=!0;break}i=i.parentNode}while(null!=i);o?a.addClass("hover"):a.removeClass("hover"),window.dropZoneTimeoutAttach=setTimeout(function(){window.dropZoneTimeoutAttach=null,a.removeClass("in hover")},100)})}t("#dropAttach","#uploadAttach");var a=function(){$(".dropzone .btn-choose-file").click(function(){$(this).parent().find("input").click()});var t=$("#attachUploadMsg");$("#uploadAttach").fileupload({dataType:"json",pasteZone:"",dropZone:$("#dropAttach"),formData:function(e){return[{name:"noteId",value:Note.curNoteId}]},add:function(a,o){var i=Note.getCurNote();if(!i||i.IsNew)return void alert("This note hasn't saved, please save it firstly!");var r=$('');r.append(o.files[0].name+" ["+e(o.files[0].size)+"]"),t.html(r),o.context=t;var n=o.files[0].size,l=+GlobalConfigs.uploadAttachSize||100;if("number"==typeof n&&n>1048576*l)return r.find("img").remove(),r.removeClass("alert-info").addClass("alert-danger"),r.append(" Warning: File size is bigger than "+l+"M"),void setTimeout(function(e){return function(){e.remove()}}(r),3e3);var s;setTimeout(function(){s=o.submit()},10)},done:function(t,a){if(1==a.result.Ok)a.context.html(""),Attach.addAttach(a.result.Item);else{a.result;a.context.html("");var o=$('');o.append("Error: "+a.files[0].name+" ["+e(a.files[0].size)+"] "+a.result.Msg),a.context.html(o),setTimeout(function(e){return function(){e.remove()}}(o),3e3)}$("#uploadAttachMsg").scrollTop(1e3)},fail:function(t,a){a.context.html("");var o=$('');o.append("Error: "+a.files[0].name+" ["+e(a.files[0].size)+"] "+a.errorThrown),a.context.html(o),setTimeout(function(e){return function(){e.remove()}}(o),3e3),$("#uploadAttachMsg").scrollTop(1e3)}})};a()}); +var urlPrefix=UrlPrefix;define("editor_drop_paste",["fileupload"],function(){function e(){var e=$("#editorContent").children(),t=e&&e.length>0?e[e.length-1]:null;t&&"P"==t.tagName||$("#editorContent").append('


    ')}function t(t){var i="__mcenew"+(new Date).getTime(),o='
    0%
    ';this.containerStr=o,t.insertContent(o),e();var a=$("#"+i);this.container=a,this.id=i,this.processBar=a.find(".progress-bar")}function i(e,t){function i(e,i){o.parentNode.removeChild(o),t({width:e,height:i})}var o=document.createElement("img");o.onload=function(){i(o.clientWidth,o.clientHeight)},o.onerror=function(){i()},o.src=e;var a=o.style;a.visibility="hidden",a.position="fixed",a.bottom=a.left=0,a.width=a.height="auto",document.body.appendChild(o)}function o(e){var t=tinymce.activeEditor,o=t.dom,r=function(t){function r(e){o.setAttrib(n,"src",t.src),t.title&&o.setAttrib(n,"title",t.title),o.setAttrib(n,"id",null)}var n,s={};s.id="__mcenew"+a++,s.src="/images/loading-24.gif",n=o.createHTML("img",s),tinymce.activeEditor.insertContent(n),n=o.get(s.id),i(e.src,r)},n="";if(fileIds=e.src.split("fileId="),2==fileIds.length&&fileIds[1].length=="53aecf8a8a039a43c8036282".length&&(n=fileIds[1]),n){var s=Note.getCurNote();s&&s.UserId!=UserInfo.UserId?!function(e){ajaxPost("/file/copyImage",{userId:UserInfo.UserId,fileId:n,toUserId:s.UserId},function(t){if(reIsOk(t)&&t.Id){var i=window.location.protocol+"//"+window.location.host;e.src=i+"/api/file/getImage?fileId="+t.Id}r(e)})}(e):r(e)}else r(e)}t.prototype.update=function(e){var t=this;e=Math.ceil(100*e),e>=100&&(e=99),e+="%",$("#"+t.id+" .progress-bar").html(e).css("width",e)},t.prototype.replace=function(e){var t=this;i(e,function(){$("#"+t.id).replaceWith('')})},t.prototype.remove=function(){var e=this;$("#"+e.id).remove()};var a=1,r=function(){function e(e){return"number"!=typeof e?"":e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(2)+" MB":(e/1e3).toFixed(2)+" KB"}function t(){$("#upload").css("z-index",12);var e=+$("#mceToolbar").css("height").slice(0,-2);$("#upload").css("top",e-8),$("#upload").show()}function i(){$("#upload").css("z-index",0).css("top","auto").hide()}var a=$("#upload ul");$("#drop a").click(function(){$(this).parent().find("input").click()}),$("#upload").fileupload({dataType:"json",pasteZone:"",acceptFileTypes:/(\.|\/)(gif|jpg|jpeg|png|jpe)$/i,maxFileSize:21e4,dropZone:$("#drop"),formData:function(e){return[{name:"albumId",value:""}]},add:function(t,i){var o=$('
  • ');o.find("div").append(i.files[0].name+" ["+e(i.files[0].size)+"]"),i.context=o.appendTo(a);i.submit()},done:function(t,i){if(1==i.result.Ok){i.context.remove();var a={src:urlPrefix+"/api/file/getImage?fileId="+i.result.Id};o(a)}else{i.context.empty();var r=$('
  • ');r.find("div").append(""+getMsg("Error")+": "+i.files[0].name+" ["+e(i.files[0].size)+"] "+i.result.Msg),i.context.append(r),setTimeout(function(e){return function(){e.remove()}}(r),2e3)}$("#uploadMsg").scrollTop(1e3)},fail:function(t,i){i.context.empty();var o=$('
  • ');o.find("div").append(""+getMsg("Error")+": "+i.files[0].name+" ["+e(i.files[0].size)+"] "+i.errorThrown),i.context.append(o),setTimeout(function(e){return function(){e.remove()}}(o),2e3),$("#uploadMsg").scrollTop(1e3)}}),$(document).on("drop dragover",function(e){e.preventDefault()}),$(document).bind("dragover",function(e){var o=$("#drop"),a=window.dropZoneTimeout;a?clearTimeout(a):(o.addClass("in"),t());var r=!1,n=e.target;do{if(n===o[0]){r=!0;break}n=n.parentNode}while(null!=n);r?(o.addClass("hover"),LEA.readOnly&&LEA.toggleWriteable()):o.removeClass("hover"),window.dropZoneTimeout=setTimeout(function(){window.dropZoneTimeout=null,o.removeClass("in hover"),i()},500)})},n=0,s=function(){var e,i;$("#editorContent, #wmd-input .editor-content").fileupload({dataType:"json",pasteZone:$("#editorContent, #wmd-input"),dropZone:"",maxFileSize:21e4,url:"/file/pasteImage",paramName:"file",formData:function(e){return[{name:"from",value:"pasteImage"},{name:"noteId",value:Note.curNoteId}]},progress:function(t,i){e&&!e.IsMarkdown&&i.process.update(i.loaded/i.total)},add:function(o,a){var r=(new Date).getTime();if(!(500>r-n)){n=r;var s=Note.getCurNote();if(e=s,!s||s.IsNew)return void alert("This note hasn't saved, please save it firstly!");if(i=tinymce.EditorManager.activeEditor,!s.IsMarkdown)var l=new t(i);a.process=l;a.submit()}},done:function(t,i){if(1==i.result.Ok){var o=i.result,a=UrlPrefix,r=a+"/api/file/getImage?fileId="+o.Id;e&&!e.IsMarkdown?i.process.replace(r):MD&&MD.insertLink(r,"title",!0)}else i.process.remove()},fail:function(t,i){e&&!e.IsMarkdown&&i.process.remove()}})};r(),s()}); +requirejs.config({paths:{editor_drop_paste:"js/plugins/editor_drop_paste",attachment_upload:"js/plugins/attachment_upload",fileupload:"js/plugins/libs-min/fileupload",note_info:"js/plugins/note_info",tips:"js/plugins/tips",history:"js/plugins/history"},shim:{}}),setTimeout(function(){require(["editor_drop_paste","attachment_upload"]),require(["note_info"]),setTimeout(function(){require(["tips"]),require(["history"])},10)}); +define("fileupload",[],function(){!function(e){"use strict";e(window.jQuery)}(function(e){"use strict";var t=0;e.ajaxTransport("iframe",function(i){if(i.async){var n,r,o;return{send:function(s,a){n=e('
    '),n.attr("accept-charset",i.formAcceptCharset),o=/\?/.test(i.url)?"&":"?","DELETE"===i.type?(i.url=i.url+o+"_method=DELETE",i.type="POST"):"PUT"===i.type?(i.url=i.url+o+"_method=PUT",i.type="POST"):"PATCH"===i.type&&(i.url=i.url+o+"_method=PATCH",i.type="POST"),r=e('').bind("load",function(){var t,o=e.isArray(i.paramName)?i.paramName:[i.paramName];r.unbind("load").bind("load",function(){var t;try{if(t=r.contents(),!t.length||!t[0].firstChild)throw new Error}catch(i){t=void 0}a(200,"success",{iframe:t}),e('').appendTo(n),n.remove()}),n.prop("target",r.prop("name")).prop("action",i.url).prop("method",i.type),i.formData&&e.each(i.formData,function(t,i){e('').prop("name",i.name).val(i.value).appendTo(n)}),i.fileInput&&i.fileInput.length&&"POST"===i.type&&(t=i.fileInput.clone(),i.fileInput.after(function(e){return t[e]}),i.paramName&&i.fileInput.each(function(t){e(this).prop("name",o[t]||i.paramName)}),n.append(i.fileInput).prop("enctype","multipart/form-data").prop("encoding","multipart/form-data")),n.submit(),t&&t.length&&i.fileInput.each(function(i,n){var r=e(t[i]);e(n).prop("name",r.prop("name")),r.replaceWith(n)})}),n.append(r).appendTo(document.body)},abort:function(){r&&r.unbind("load").prop("src","javascript".concat(":false;")),n&&n.remove()}}}}),e.ajaxSetup({converters:{"iframe text":function(t){return t&&e(t[0].body).text()},"iframe json":function(t){return t&&e.parseJSON(e(t[0].body).text())},"iframe html":function(t){return t&&e(t[0].body).html()},"iframe script":function(t){return t&&e.globalEval(e(t[0].body).text())}}})}),!function(e){e(jQuery)}(function(e,t){var i=0,n=Array.prototype.slice,r=e.cleanData;e.cleanData=function(t){for(var i,n=0;null!=(i=t[n]);n++)try{e(i).triggerHandler("remove")}catch(o){}r(t)},e.widget=function(t,i,n){var r,o,s,a,l={},p=t.split(".")[0];t=t.split(".")[1],r=p+"-"+t,n||(n=i,i=e.Widget),e.expr[":"][r.toLowerCase()]=function(t){return!!e.data(t,r)},e[p]=e[p]||{},o=e[p][t],s=e[p][t]=function(e,t){return this._createWidget?void(arguments.length&&this._createWidget(e,t)):new s(e,t)},e.extend(s,o,{version:n.version,_proto:e.extend({},n),_childConstructors:[]}),a=new i,a.options=e.widget.extend({},a.options),e.each(n,function(t,n){return e.isFunction(n)?void(l[t]=function(){var e=function(){return i.prototype[t].apply(this,arguments)},r=function(e){return i.prototype[t].apply(this,e)};return function(){var t,i=this._super,o=this._superApply;return this._super=e,this._superApply=r,t=n.apply(this,arguments),this._super=i,this._superApply=o,t}}()):void(l[t]=n)}),s.prototype=e.widget.extend(a,{widgetEventPrefix:o?a.widgetEventPrefix:t},l,{constructor:s,namespace:p,widgetName:t,widgetFullName:r}),o?(e.each(o._childConstructors,function(t,i){var n=i.prototype;e.widget(n.namespace+"."+n.widgetName,s,i._proto)}),delete o._childConstructors):i._childConstructors.push(s),e.widget.bridge(t,s)},e.widget.extend=function(i){for(var r,o,s=n.call(arguments,1),a=0,l=s.length;l>a;a++)for(r in s[a])o=s[a][r],s[a].hasOwnProperty(r)&&o!==t&&(e.isPlainObject(o)?i[r]=e.isPlainObject(i[r])?e.widget.extend({},i[r],o):e.widget.extend({},o):i[r]=o);return i},e.widget.bridge=function(i,r){var o=r.prototype.widgetFullName||i;e.fn[i]=function(s){var a="string"==typeof s,l=n.call(arguments,1),p=this;return s=!a&&l.length?e.widget.extend.apply(null,[s].concat(l)):s,a?this.each(function(){var n,r=e.data(this,o);return r?e.isFunction(r[s])&&"_"!==s.charAt(0)?(n=r[s].apply(r,l),n!==r&&n!==t?(p=n&&n.jquery?p.pushStack(n.get()):n,!1):void 0):e.error("no such method '"+s+"' for "+i+" widget instance"):e.error("cannot call methods on "+i+" prior to initialization; attempted to call method '"+s+"'")}):this.each(function(){var t=e.data(this,o);t?t.option(s||{})._init():e.data(this,o,new r(s,this))}),p}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
    ",options:{disabled:!1,create:null},_createWidget:function(t,n){n=e(n||this.defaultElement||this)[0],this.element=e(n),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),n!==this&&(e.data(n,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===n&&this.destroy()}}),this.document=e(n.style?n.ownerDocument:n.document||n),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(i,n){var r,o,s,a=i;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof i)if(a={},r=i.split("."),i=r.shift(),r.length){for(o=a[i]=e.widget.extend({},this.options[i]),s=0;si)&&(this.bitrate=(t-this.loaded)*(1e3/n)*8,this.loaded=t,this.timestamp=e),this.bitrate}},_isXHRUpload:function(t){return!t.forceIframeTransport&&(!t.multipart&&e.support.xhrFileUpload||e.support.xhrFormDataFileUpload)},_getFormData:function(t){var i;return"function"==typeof t.formData?t.formData(t.form):e.isArray(t.formData)?t.formData:t.formData?(i=[],e.each(t.formData,function(e,t){i.push({name:e,value:t})}),i):[]},_getTotal:function(t){var i=0;return e.each(t,function(e,t){i+=t.size||1}),i},_initProgressObject:function(e){e._progress={loaded:0,total:0,bitrate:0}},_onProgress:function(e,t){if(e.lengthComputable){var i,n=+new Date;if(t._time&&t.progressInterval&&n-t._time").prop("href",t.url).prop("host")!==location.host&&t.formData.push({name:t.redirectParamName||"redirect",value:t.redirect})},_initDataSettings:function(e){this._isXHRUpload(e)?(this._chunkedUpload(e,!0)||(e.data||this._initXHRData(e),this._initProgressListener(e)),e.postMessage&&(e.dataType="postmessage "+(e.dataType||""))):this._initIframeSettings(e,"iframe")},_getParamName:function(t){var i=e(t.fileInput),n=t.paramName;return n?e.isArray(n)||(n=[n]):(n=[],i.each(function(){for(var t=e(this),i=t.prop("name")||"files[]",r=(t.prop("files")||[1]).length;r;)n.push(i),r-=1}),n.length||(n=[i.prop("name")||"files[]"])),n},_initFormSettings:function(t){t.form&&t.form.length||(t.form=e(t.fileInput.prop("form")),t.form.length||(t.form=e(this.options.fileInput.prop("form")))),t.paramName=this._getParamName(t),t.urlFunc&&(t.url=t.urlFunc()),t.url||(t.url=t.form.prop("action")||location.href),t.type=(t.type||t.form.prop("method")||"").toUpperCase(),"POST"!==t.type&&"PUT"!==t.type&&"PATCH"!==t.type&&(t.type="POST"),t.formAcceptCharset||(t.formAcceptCharset=t.form.attr("accept-charset"))},_getAJAXSettings:function(t){var i=e.extend({},this.options,t);return this._initFormSettings(i),this._initDataSettings(i),i},_getDeferredState:function(e){return e.state?e.state():e.isResolved()?"resolved":e.isRejected()?"rejected":"pending"},_enhancePromise:function(e){return e.success=e.done,e.error=e.fail,e.complete=e.always,e},_getXHRPromise:function(t,i,n){var r=e.Deferred(),o=r.promise();return i=i||this.options.context||o,t===!0?r.resolveWith(i,n):t===!1&&r.rejectWith(i,n),o.abort=r.promise,this._enhancePromise(o)},_addConvenienceMethods:function(e,t){var i=this;t.submit=function(){return"pending"!==this.state()&&(t.jqXHR=this.jqXHR=i._trigger("submit",e,this)!==!1&&i._onSend(e,this)),this.jqXHR||i._getXHRPromise()},t.abort=function(){return this.jqXHR?this.jqXHR.abort():this._getXHRPromise()},t.state=function(){return this.jqXHR?i._getDeferredState(this.jqXHR):void 0},t.progress=function(){return this._progress}},_getUploadedBytes:function(e){var t=e.getResponseHeader("Range"),i=t&&t.split("-"),n=i&&i.length>1&&parseInt(i[1],10);return n&&n+1},_chunkedUpload:function(t,i){var n,r,o=this,s=t.files[0],a=s.size,l=t.uploadedBytes=t.uploadedBytes||0,p=t.maxChunkSize||a,u=s.slice||s.webkitSlice||s.mozSlice,d=e.Deferred(),h=d.promise();return this._isXHRUpload(t)&&u&&(l||a>p)&&!t.data?i?!0:l>=a?(s.error="Uploaded bytes exceed file size",this._getXHRPromise(!1,t.context,[null,"error",s.error])):(r=function(){var i=e.extend({},t),h=i._progress.loaded;i.blob=u.call(s,l,l+p,s.type),i.chunkSize=i.blob.size,i.contentRange="bytes "+l+"-"+(l+i.chunkSize-1)+"/"+a,o._initXHRData(i),o._initProgressListener(i),n=(o._trigger("chunksend",null,i)!==!1&&e.ajax(i)||o._getXHRPromise(!1,i.context)).done(function(n,s,p){l=o._getUploadedBytes(p)||l+i.chunkSize,i._progress.loaded===h&&o._onProgress(e.Event("progress",{lengthComputable:!0,loaded:l-i.uploadedBytes,total:l-i.uploadedBytes}),i),t.uploadedBytes=i.uploadedBytes=l,i.result=n,i.textStatus=s,i.jqXHR=p,o._trigger("chunkdone",null,i),o._trigger("chunkalways",null,i),a>l?r():d.resolveWith(i.context,[n,s,p])}).fail(function(e,t,n){i.jqXHR=e,i.textStatus=t,i.errorThrown=n,o._trigger("chunkfail",null,i),o._trigger("chunkalways",null,i),d.rejectWith(i.context,[e,t,n])})},this._enhancePromise(h),h.abort=function(){return n.abort()},r(),h):!1},_beforeSend:function(e,t){0===this._active&&(this._trigger("start"),this._bitrateTimer=new this._BitrateTimer,this._progress.loaded=this._progress.total=0,this._progress.bitrate=0),t._progress||(t._progress={}),t._progress.loaded=t.loaded=t.uploadedBytes||0,t._progress.total=t.total=this._getTotal(t.files)||1,t._progress.bitrate=t.bitrate=0,this._active+=1,this._progress.loaded+=t.loaded,this._progress.total+=t.total},_onDone:function(t,i,n,r){var o=r._progress.total;r._progress.loadeda._sending)for(var n=a._slots.shift();n;){if("pending"===a._getDeferredState(n)){n.resolve();break}n=a._slots.shift()}})};return this._beforeSend(t,l),this.options.sequentialUploads||this.options.limitConcurrentUploads&&this.options.limitConcurrentUploads<=this._sending?(this.options.limitConcurrentUploads>1?(o=e.Deferred(),this._slots.push(o),s=o.pipe(p)):s=this._sequence=this._sequence.pipe(p,p),s.abort=function(){return r=[void 0,"abort","abort"],n?n.abort():(o&&o.rejectWith(l.context,r),p())},this._enhancePromise(s)):p()},_onAdd:function(t,i){var n,r,o,s,a=this,l=!0,p=e.extend({},this.options,i),u=p.limitMultiFileUploads,d=this._getParamName(p);if((p.singleFileUploads||u)&&this._isXHRUpload(p))if(!p.singleFileUploads&&u)for(o=[],n=[],s=0;s").append(i)[0].reset(),t.after(i).detach(),e.cleanData(t.unbind("remove")),this.options.fileInput=this.options.fileInput.map(function(e,n){return n===t[0]?i[0]:n}),t[0]===this.element[0]&&(this.element=i)},_handleFileTreeEntry:function(t,i){var n,r=this,o=e.Deferred(),s=function(e){e&&!e.entry&&(e.entry=t),o.resolve([e])};return i=i||"",t.isFile?t._file?(t._file.relativePath=i,o.resolve(t._file)):t.file(function(e){e.relativePath=i,o.resolve(e)},s):t.isDirectory?(n=t.createReader(),n.readEntries(function(e){r._handleFileTreeEntries(e,i+t.name+"/").done(function(e){o.resolve(e)}).fail(s)},s)):o.resolve([]),o.promise()},_handleFileTreeEntries:function(t,i){var n=this;return e.when.apply(e,e.map(t,function(e){return n._handleFileTreeEntry(e,i)})).pipe(function(){return Array.prototype.concat.apply([],arguments)})},_getDroppedFiles:function(t){t=t||{};var i=t.items;return i&&i.length&&(i[0].webkitGetAsEntry||i[0].getAsEntry)?this._handleFileTreeEntries(e.map(i,function(e){var t;return e.webkitGetAsEntry?(t=e.webkitGetAsEntry(),t&&(t._file=e.getAsFile()),t):e.getAsEntry()})):e.Deferred().resolve(e.makeArray(t.files)).promise()},_getSingleFileInputFiles:function(t){t=e(t);var i,n,r=t.prop("webkitEntries")||t.prop("entries");if(r&&r.length)return this._handleFileTreeEntries(r);if(i=e.makeArray(t.prop("files")),i.length)void 0===i[0].name&&i[0].fileName&&e.each(i,function(e,t){t.name=t.fileName,t.size=t.fileSize});else{if(n=t.prop("value"),!n)return e.Deferred().resolve([]).promise();i=[{name:n.replace(/^.*\\/,"")}]}return e.Deferred().resolve(i).promise()},_getFileInputFiles:function(t){return t instanceof e&&1!==t.length?e.when.apply(e,e.map(t,this._getSingleFileInputFiles)).pipe(function(){return Array.prototype.concat.apply([],arguments)}):this._getSingleFileInputFiles(t)},_onChange:function(t){var i=this,n={fileInput:e(t.target),form:e(t.target.form)};this._getFileInputFiles(n.fileInput).always(function(e){n.files=e,i.options.replaceFileInput&&i._replaceFileInput(n.fileInput),i._trigger("change",t,n)!==!1&&i._onAdd(t,n)})},_onPaste:function(t){var i=t.originalEvent.clipboardData,n=i&&i.items||[],r={files:[]};return e.each(n,function(e,t){var i=t.getAsFile&&t.getAsFile();i&&r.files.push(i)}),this._trigger("paste",t,r)===!1||this._onAdd(t,r)===!1?!1:void 0},_onDrop:function(e){var t=this,i=e.dataTransfer=e.originalEvent.dataTransfer,n={};i&&i.files&&i.files.length&&e.preventDefault(),this._getDroppedFiles(i).always(function(i){n.files=i,t._trigger("drop",e,n)!==!1&&t._onAdd(e,n)})},_onDragOver:function(t){var i=t.dataTransfer=t.originalEvent.dataTransfer;return this._trigger("dragover",t)===!1?!1:void(i&&-1!==e.inArray("Files",i.types)&&(i.dropEffect="copy",t.preventDefault()))},_initEventHandlers:function(){this._isXHRUpload(this.options)&&(this._on(this.options.dropZone,{dragover:this._onDragOver,drop:this._onDrop}),this._on(this.options.pasteZone,{paste:this._onPaste})),this._on(this.options.fileInput,{change:this._onChange})},_destroyEventHandlers:function(){this._off(this.options.dropZone,"dragover drop"),this._off(this.options.pasteZone,"paste"),this._off(this.options.fileInput,"change")},_setOption:function(t,i){var n=-1!==e.inArray(t,this._refreshOptionsList);n&&this._destroyEventHandlers(),this._super(t,i),n&&(this._initSpecialOptions(),this._initEventHandlers())},_initSpecialOptions:function(){var t=this.options;void 0===t.fileInput?t.fileInput=this.element.is('input[type="file"]')?this.element:this.element.find('input[type="file"]'):t.fileInput instanceof e||(t.fileInput=e(t.fileInput)),t.dropZone instanceof e||(t.dropZone=e(t.dropZone)),t.pasteZone instanceof e||(t.pasteZone=e(t.pasteZone))},_create:function(){var t=this.options;e.extend(t,e(this.element[0].cloneNode(!1)).data()),this._initSpecialOptions(),this._slots=[],this._sequence=this._getXHRPromise(!0),this._sending=this._active=0,this._initProgressObject(this),this._initEventHandlers()},progress:function(){return this._progress},add:function(t){var i=this;t&&!this.options.disabled&&(t.fileInput&&!t.files?this._getFileInputFiles(t.fileInput).always(function(e){t.files=e,i._onAdd(null,t)}):(t.files=e.makeArray(t.files),this._onAdd(null,t)))},send:function(t){if(t&&!this.options.disabled){if(t.fileInput&&!t.files){var i,n,r=this,o=e.Deferred(),s=o.promise();return s.abort=function(){return n=!0,i?i.abort():(o.reject(null,"abort","abort"),s)},this._getFileInputFiles(t.fileInput).always(function(e){n||(t.files=e,i=r._onSend(null,t).then(function(e,t,i){o.resolve(e,t,i)},function(e,t,i){o.reject(e,t,i)}))}),this._enhancePromise(s)}if(t.files=e.makeArray(t.files),t.files.length)return this._onSend(null,t)}return this._getXHRPromise(!1,t&&t.context)}})})}); \ No newline at end of file