소스 검색

Fix #96, Fix #97: Reset events correctly with plugin refresh method

Kartik Visweswaran 10 년 전
부모
커밋
8a6853b736
3개의 변경된 파일9개의 추가작업 그리고 7개의 파일을 삭제
  1. 1 0
      CHANGE.md
  2. 8 7
      js/fileinput.js
  3. 0 0
      js/fileinput.min.js

+ 1 - 0
CHANGE.md

@@ -10,6 +10,7 @@ version 4.1.4
 6. (enh #93): Better styling of file upload icon indicators in thumbnails.
 7. Code cleanup with reusable methods for event raising and outData generation.
 8. (bug #95): Correct event off for drag & drop in plugin refresh method.
+8. (bug #97): Reset events correctly with plugin refresh method.
 
 version 4.1.3
 =============

+ 8 - 7
js/fileinput.js

@@ -344,28 +344,29 @@
         listen: function () {
             var self = this, $el = self.$element, $cap = self.$captionContainer, $btnFile = self.$btnFile;
             $el.on('change', $.proxy(self.change, self));
-            $(window).on('resize', function() {
+            $(window).off('resize').on('resize', function() {
                 setTimeout(function() {
                     self.autoSizeCaption();
                 }, 50);  
             });
-            $btnFile.on('click', function (ev) {
+            $btnFile.off('click').on('click', function (ev) {
                 self.raise('filebrowse');
                 if (self.isError && !self.isUploadable) {
                     self.clear(false);
                 }
                 $cap.focus();
             });
-            $el.closest('form').on('reset', $.proxy(self.reset, self));
-            self.$container.on('click', '.fileinput-remove:not([disabled])', $.proxy(self.clear, self));
-            self.$container.on('click', '.fileinput-cancel', $.proxy(self.cancel, self));
+            $el.closest('form').off('reset').on('reset', $.proxy(self.reset, self));
+            self.$container.off('click')
+                .on('click', '.fileinput-remove:not([disabled])', $.proxy(self.clear, self))
+                .on('click', '.fileinput-cancel', $.proxy(self.cancel, self));
             if (self.isUploadable && self.dropZoneEnabled && self.showPreview) {
                 self.initDragDrop();
             }
             if (!self.isUploadable) {
                 return;
             }
-            self.$container.find('.kv-fileinput-upload').on('click', function(e) {
+            self.$container.find('.kv-fileinput-upload').off('click').on('click', function(e) {
                 if (!self.isUploadable) {
                     return;
                 }
@@ -436,9 +437,9 @@
             $el.off();
             self.init(params);
             var $zone = self.$container.find('.file-drop-zone');
-            $el.on('change', $.proxy(self.change, self));
             $zone.off('dragenter dragover drop');
             $(document).off('dragenter dragover drop');
+            self.listen();
             self.setFileDropZoneTitle();
         },
         initDragDrop: function() {

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
js/fileinput.min.js


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.