Le repo des sources pour le site web des JM2L
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

153 行
4.9 KiB

  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. /* jshint nomen:false */
  12. /* global define, window */
  13. (function (factory) {
  14. 'use strict';
  15. if (typeof define === 'function' && define.amd) {
  16. // Register as an anonymous AMD module:
  17. define(['jquery', './jquery.fileupload-ui'], factory);
  18. } else {
  19. // Browser globals:
  20. factory(window.jQuery);
  21. }
  22. }(function ($) {
  23. 'use strict';
  24. $.widget('blueimp.fileupload', $.blueimp.fileupload, {
  25. options: {
  26. processdone: function (e, data) {
  27. data.context.find('.start').button('enable');
  28. },
  29. progress: function (e, data) {
  30. if (data.context) {
  31. data.context.find('.progress').progressbar(
  32. 'option',
  33. 'value',
  34. parseInt(data.loaded / data.total * 100, 10)
  35. );
  36. }
  37. },
  38. progressall: function (e, data) {
  39. var $this = $(this);
  40. $this.find('.fileupload-progress')
  41. .find('.progress').progressbar(
  42. 'option',
  43. 'value',
  44. parseInt(data.loaded / data.total * 100, 10)
  45. ).end()
  46. .find('.progress-extended').each(function () {
  47. $(this).html(
  48. ($this.data('blueimp-fileupload') ||
  49. $this.data('fileupload'))
  50. ._renderExtendedProgress(data)
  51. );
  52. });
  53. }
  54. },
  55. _renderUpload: function (func, files) {
  56. var node = this._super(func, files),
  57. showIconText = $(window).width() > 480;
  58. node.find('.progress').empty().progressbar();
  59. node.find('.start').button({
  60. icons: {primary: 'ui-icon-circle-arrow-e'},
  61. text: showIconText
  62. });
  63. node.find('.cancel').button({
  64. icons: {primary: 'ui-icon-cancel'},
  65. text: showIconText
  66. });
  67. if (node.hasClass('fade')) {
  68. node.hide();
  69. }
  70. return node;
  71. },
  72. _renderDownload: function (func, files) {
  73. var node = this._super(func, files),
  74. showIconText = $(window).width() > 480;
  75. node.find('.delete').button({
  76. icons: {primary: 'ui-icon-trash'},
  77. text: showIconText
  78. });
  79. if (node.hasClass('fade')) {
  80. node.hide();
  81. }
  82. return node;
  83. },
  84. _startHandler: function (e) {
  85. $(e.currentTarget).button('disable');
  86. this._super(e);
  87. },
  88. _transition: function (node) {
  89. var deferred = $.Deferred();
  90. if (node.hasClass('fade')) {
  91. node.fadeToggle(
  92. this.options.transitionDuration,
  93. this.options.transitionEasing,
  94. function () {
  95. deferred.resolveWith(node);
  96. }
  97. );
  98. } else {
  99. deferred.resolveWith(node);
  100. }
  101. return deferred;
  102. },
  103. _create: function () {
  104. this._super();
  105. this.element
  106. .find('.fileupload-buttonbar')
  107. .find('.fileinput-button').each(function () {
  108. var input = $(this).find('input:file').detach();
  109. $(this)
  110. .button({icons: {primary: 'ui-icon-plusthick'}})
  111. .append(input);
  112. })
  113. .end().find('.start')
  114. .button({icons: {primary: 'ui-icon-circle-arrow-e'}})
  115. .end().find('.cancel')
  116. .button({icons: {primary: 'ui-icon-cancel'}})
  117. .end().find('.delete')
  118. .button({icons: {primary: 'ui-icon-trash'}})
  119. .end().find('.progress').progressbar();
  120. },
  121. _destroy: function () {
  122. this.element
  123. .find('.fileupload-buttonbar')
  124. .find('.fileinput-button').each(function () {
  125. var input = $(this).find('input:file').detach();
  126. $(this)
  127. .button('destroy')
  128. .append(input);
  129. })
  130. .end().find('.start')
  131. .button('destroy')
  132. .end().find('.cancel')
  133. .button('destroy')
  134. .end().find('.delete')
  135. .button('destroy')
  136. .end().find('.progress').progressbar('destroy');
  137. this._super();
  138. }
  139. });
  140. }));