Selaa lähdekoodia

Added checks for file api support

A browser without file api support, like IE9, throws an error when anything but the constructor is called, this change will fix all of the scenarios.
dfisch 11 vuotta sitten
vanhempi
commit
9b6162c620
1 muutettua tiedostoa jossa 9 lisäystä ja 1 poistoa
  1. 9 1
      js/fileinput.js

+ 9 - 1
js/fileinput.js

@@ -675,6 +675,10 @@
     }
     }
 
 
     $.fn.fileinput = function (options) {
     $.fn.fileinput = function (options) {
+        if (!hasFileAPISupport()) {
+          return;
+        }
+        
         return this.each(function () {
         return this.each(function () {
             var $this = $(this), data = $this.data('fileinput')
             var $this = $(this), data = $this.data('fileinput')
             if (!data) {
             if (!data) {
@@ -688,6 +692,10 @@
 
 
     //FileInput plugin definition
     //FileInput plugin definition
     $.fn.fileinput = function (option) {
     $.fn.fileinput = function (option) {
+        if (!hasFileAPISupport()) {
+          return;
+        }
+        
         var args = Array.apply(null, arguments);
         var args = Array.apply(null, arguments);
         args.shift();
         args.shift();
         return this.each(function () {
         return this.each(function () {
@@ -771,4 +779,4 @@
         }
         }
     });
     });
 
 
-})(window.jQuery);
+})(window.jQuery);