github.com/apremalal/vamps-core@v1.0.1-0.20161221121535-d430b56ec174/server/webapps/app/base/plugins/jquery-file-upload/js/jquery.fileupload-jquery-ui.js (about) 1 /* 2 * jQuery File Upload jQuery UI Plugin 8.7.1 3 * https://github.com/blueimp/jQuery-File-Upload 4 * 5 * Copyright 2013, Sebastian Tschan 6 * https://blueimp.net 7 * 8 * Licensed under the MIT license: 9 * http://www.opensource.org/licenses/MIT 10 */ 11 12 /* jshint nomen:false */ 13 /* global define, window */ 14 15 (function (factory) { 16 'use strict'; 17 if (typeof define === 'function' && define.amd) { 18 // Register as an anonymous AMD module: 19 define(['jquery', './jquery.fileupload-ui.js'], factory); 20 } else { 21 // Browser globals: 22 factory(window.jQuery); 23 } 24 }(function ($) { 25 'use strict'; 26 27 $.widget('blueimp.fileupload', $.blueimp.fileupload, { 28 29 options: { 30 processdone: function (e, data) { 31 data.context.find('.start').button('enable'); 32 }, 33 progress: function (e, data) { 34 if (data.context) { 35 data.context.find('.progress').progressbar( 36 'option', 37 'value', 38 parseInt(data.loaded / data.total * 100, 10) 39 ); 40 } 41 }, 42 progressall: function (e, data) { 43 var $this = $(this); 44 $this.find('.fileupload-progress') 45 .find('.progress').progressbar( 46 'option', 47 'value', 48 parseInt(data.loaded / data.total * 100, 10) 49 ).end() 50 .find('.progress-extended').each(function () { 51 $(this).html( 52 ($this.data('blueimp-fileupload') || 53 $this.data('fileupload')) 54 ._renderExtendedProgress(data) 55 ); 56 }); 57 } 58 }, 59 60 _renderUpload: function (func, files) { 61 var node = this._super(func, files), 62 showIconText = $(window).width() > 480; 63 node.find('.progress').empty().progressbar(); 64 node.find('.start').button({ 65 icons: {primary: 'ui-icon-circle-arrow-e'}, 66 text: showIconText 67 }); 68 node.find('.cancel').button({ 69 icons: {primary: 'ui-icon-cancel'}, 70 text: showIconText 71 }); 72 if (node.hasClass('fade')) { 73 node.hide(); 74 } 75 return node; 76 }, 77 78 _renderDownload: function (func, files) { 79 var node = this._super(func, files), 80 showIconText = $(window).width() > 480; 81 node.find('.delete').button({ 82 icons: {primary: 'ui-icon-trash'}, 83 text: showIconText 84 }); 85 if (node.hasClass('fade')) { 86 node.hide(); 87 } 88 return node; 89 }, 90 91 _startHandler: function (e) { 92 $(e.currentTarget).button('disable'); 93 this._super(e); 94 }, 95 96 _transition: function (node) { 97 var deferred = $.Deferred(); 98 if (node.hasClass('fade')) { 99 node.fadeToggle( 100 this.options.transitionDuration, 101 this.options.transitionEasing, 102 function () { 103 deferred.resolveWith(node); 104 } 105 ); 106 } else { 107 deferred.resolveWith(node); 108 } 109 return deferred; 110 }, 111 112 _create: function () { 113 this._super(); 114 this.element 115 .find('.fileupload-buttonbar') 116 .find('.fileinput-button').each(function () { 117 var input = $(this).find('input:file').detach(); 118 $(this) 119 .button({icons: {primary: 'ui-icon-plusthick'}}) 120 .append(input); 121 }) 122 .end().find('.start') 123 .button({icons: {primary: 'ui-icon-circle-arrow-e'}}) 124 .end().find('.cancel') 125 .button({icons: {primary: 'ui-icon-cancel'}}) 126 .end().find('.delete') 127 .button({icons: {primary: 'ui-icon-trash'}}) 128 .end().find('.progress').progressbar(); 129 }, 130 131 _destroy: function () { 132 this.element 133 .find('.fileupload-buttonbar') 134 .find('.fileinput-button').each(function () { 135 var input = $(this).find('input:file').detach(); 136 $(this) 137 .button('destroy') 138 .append(input); 139 }) 140 .end().find('.start') 141 .button('destroy') 142 .end().find('.cancel') 143 .button('destroy') 144 .end().find('.delete') 145 .button('destroy') 146 .end().find('.progress').progressbar('destroy'); 147 this._super(); 148 } 149 150 }); 151 152 }));