Skip to content

Commit 9e14751

Browse files
committed
Upgrade to release v2.4.0 - Fix template fetch bug
1 parent ed8c6ec commit 9e14751

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

js/fileinput.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
' <param name="autoPlay" value="false" />\n' +
2424
' <param name="autoStart" value="false" />\n'+
2525
' <param name="quality" value="high" />\n';
26+
2627
var DEFAULT_PREVIEW = '<div class="file-preview-other" ' + STYLE_SETTING + '>\n' +
2728
' <h2><i class="glyphicon glyphicon-file"></i></h2>\n' +
2829
' </div>';
@@ -149,7 +150,7 @@
149150
return Array.isArray(a) || Object.prototype.toString.call(a) === '[object Array]';
150151
},
151152
isSet = function (needle, haystack) {
152-
return (typeof haystack == 'object' && typeof haystack[needle] !== 'undefined');
153+
return (typeof haystack == 'object' && needle in haystack);
153154
},
154155
getValue = function (options, param, value) {
155156
return (isEmpty(options) || isEmpty(options[param])) ? value : options[param];
@@ -254,9 +255,11 @@
254255
self.$element.removeClass('file-loading');
255256
},
256257
getLayoutTemplate: function(t) {
258+
var self = this;
257259
return isSet(t, self.layoutTemplates) ? self.layoutTemplates[t] : defaultLayoutTemplates[t];
258260
},
259261
getPreviewTemplate: function(t) {
262+
var self = this;
260263
return isSet(t, self.previewTemplates) ? self.previewTemplates[t] : defaultPreviewTemplates[t];
261264
},
262265
listen: function () {
@@ -672,6 +675,22 @@
672675
}
673676
}
674677

678+
$.fn.fileinput = function (options) {
679+
if (!hasFileAPISupport()) {
680+
return;
681+
}
682+
683+
return this.each(function () {
684+
var $this = $(this), data = $this.data('fileinput')
685+
if (!data) {
686+
$this.data('fileinput', (data = new FileInput(this, options)))
687+
}
688+
if (typeof options == 'string') {
689+
data[options]()
690+
}
691+
})
692+
};
693+
675694
//FileInput plugin definition
676695
$.fn.fileinput = function (option) {
677696
if (!hasFileAPISupport()) {
@@ -761,4 +780,4 @@
761780
}
762781
});
763782

764-
})(window.jQuery);
783+
})(window.jQuery);

0 commit comments

Comments
 (0)