diff --git a/CHANGE.md b/CHANGE.md index 8cf7be21..d0899862 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,3 +1,11 @@ +version 1.6.0 +============= +Date: 03-Jun-2014 + +### Additions +1. The plugin now offers an additional `refresh` method. This enables you to dynamically change element attributes or plugin options + at runtime and refresh the widget. + version 1.5.0 ============= Date: 23-May-2014 diff --git a/README.md b/README.md index 01421db4..09998e02 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ An enhanced HTML 5 file input for Bootstrap 3.x with file preview for images and ![File Input Screenshot](https://lh6.googleusercontent.com/-2niyujIaat0/UyqzA_78OQI/AAAAAAAAADE/f6IJkr11uA8/w666-h418-no/fileinput-screenshot.jpg) -> NOTE: The latest version of the plugin v1.5.0 has been released. Refer the [CHANGE LOG](https://github.com/kartik-v/bootstrap-fileinput/blob/master/CHANGE.md) for details. +> NOTE: The latest version of the plugin v1.6.0 has been released. Refer the [CHANGE LOG](https://github.com/kartik-v/bootstrap-fileinput/blob/master/CHANGE.md) for details. ## Features @@ -32,7 +32,7 @@ An enhanced HTML 5 file input for Bootstrap 3.x with file preview for images and 11. Upload action defaults to form submit. Supports an upload route/server action parameter for custom ajax based upload. 12. Triggers JQuery events for advanced development. Events currently available are `filereset` and `fileclear`. 13. Disabled and readonly file input support. -14. Size of the entire plugin is less than 11KB (about 9KB for the minified JS and 2KB for the minified CSS). +14. Size of the entire plugin is about 5KB if gzipped. The minified assets are less than 12KB (about 10KB for the minified JS and 2KB for the minified CSS). ## Demo diff --git a/bower.json b/bower.json index 3a16ca04..68ab4c9b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "bootstrap-fileinput", - "version": "1.0.0", + "version": "1.6.0", "homepage": "https://github.com/kartik-v/bootstrap-fileinput", "authors": [ "Kartik Visweswaran " diff --git a/css/fileinput.css b/css/fileinput.css index 243ea572..d56e74b1 100644 --- a/css/fileinput.css +++ b/css/fileinput.css @@ -1,7 +1,7 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2013 * @package yii2-widgets - * @version 1.0.0 + * @version 1.6.0 * * File input styling for Bootstrap 3.0 * Built for Yii Framework 2.0 diff --git a/css/fileinput.min.css b/css/fileinput.min.css index 0809f372..1bf911e1 100644 --- a/css/fileinput.min.css +++ b/css/fileinput.min.css @@ -1,7 +1,7 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2013 * @package yii2-widgets - * @version 1.0.0 + * @version 1.6.0 * * File input styling for Twitter Bootstrap 3.0 * Built for Yii Framework 2.0 diff --git a/examples/index.html b/examples/index.html index fcf5430f..523fe2c6 100644 --- a/examples/index.html +++ b/examples/index.html @@ -22,6 +22,10 @@

Bootstrap File Input Example

+ +
+
+
@@ -37,5 +41,9 @@

Bootstrap File Input Example

browseClass: "btn btn-primary btn-lg", fileType: "any" }); + $(".btn-warning").on('click', function() { + $("#file-4").attr('disabled', 'disabled'); + $('#file-4').fileinput('refresh', {browseLabel: 'Kartik'}); + }); \ No newline at end of file diff --git a/js/fileinput.js b/js/fileinput.js index 7d969057..47798693 100644 --- a/js/fileinput.js +++ b/js/fileinput.js @@ -1,6 +1,6 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2013 - * @version 1.5.0 + * @version 1.6.0 * * File input styled for Bootstrap 3.0 that utilizes HTML5 File Input's advanced * features including the FileReader API. This plugin is inspired by the blog article at @@ -77,77 +77,91 @@ }; var FileInput = function (element, options) { this.$element = $(element); - this.showCaption = options.showCaption; - this.showPreview = options.showPreview; - this.initialPreview = options.initialPreview; - this.initialCaption = options.initialCaption; - this.showRemove = options.showRemove; - this.showUpload = options.showUpload; - this.captionClass = options.captionClass; - this.previewClass = options.previewClass; - this.mainClass = options.mainClass; - if (isEmpty(options.mainTemplate)) { - this.mainTemplate = this.showCaption ? MAIN_TEMPLATE_1 : MAIN_TEMPLATE_2; - } - else { - this.mainTemplate = options.mainTemplate; - } - this.previewTemplate = (this.showPreview) ? options.previewTemplate : ''; - this.captionTemplate = options.captionTemplate; - this.browseLabel = options.browseLabel; - this.browseIcon = options.browseIcon; - this.browseClass = options.browseClass; - this.removeLabel = options.removeLabel; - this.removeIcon = options.removeIcon; - this.removeClass = options.removeClass; - this.uploadLabel = options.uploadLabel; - this.uploadIcon = options.uploadIcon; - this.uploadClass = options.uploadClass; - this.uploadUrl = options.uploadUrl; - this.msgLoading = options.msgLoading; - this.msgProgress = options.msgProgress; - this.msgSelected = options.msgSelected; - this.previewFileType = options.previewFileType; - this.wrapTextLength = options.wrapTextLength; - this.wrapIndicator = options.wrapIndicator; - this.isDisabled = this.$element.attr('disabled') || this.$element.attr('readonly'); - if (isEmpty(this.$element.attr('id'))) { - this.$element.attr('id', uniqId()); - } - this.$container = this.createContainer(); - /* Initialize plugin option parameters */ - this.$captionContainer = getElement(options, 'elCaptionContainer', this.$container.find('.file-caption')); - this.$caption = getElement(options, 'elCaptionText', this.$container.find('.file-caption-name')); - this.$previewContainer = getElement(options, 'elPreviewContainer', this.$container.find('.file-preview')); - this.$preview = getElement(options, 'elPreviewImage', this.$container.find('.file-preview-thumbnails')); - this.$previewStatus = getElement(options, 'elPreviewStatus', this.$container.find('.file-preview-status')); - this.initPreview(); - this.$name = this.$element.attr('name') || options.name; - this.$hidden = this.$container.find('input[type=hidden][name="' + this.$name + '"]'); - if (this.$hidden.length === 0) { - this.$hidden = $(''); - this.$container.prepend(this.$hidden); - } - this.original = { - preview: this.$preview.html(), - caption: this.$caption.html(), - hiddenVal: this.$hidden.val() - }; - this.listen() + this.options = options; + this.init(options); + this.listen(); }; FileInput.prototype = { constructor: FileInput, + init: function (options) { + var self = this; + self.showCaption = options.showCaption; + self.showPreview = options.showPreview; + self.initialPreview = options.initialPreview; + self.initialCaption = options.initialCaption; + self.showRemove = options.showRemove; + self.showUpload = options.showUpload; + self.captionClass = options.captionClass; + self.previewClass = options.previewClass; + self.mainClass = options.mainClass; + if (isEmpty(options.mainTemplate)) { + self.mainTemplate = self.showCaption ? MAIN_TEMPLATE_1 : MAIN_TEMPLATE_2; + } + else { + self.mainTemplate = options.mainTemplate; + } + self.previewTemplate = (self.showPreview) ? options.previewTemplate : ''; + self.captionTemplate = options.captionTemplate; + self.browseLabel = options.browseLabel; + self.browseIcon = options.browseIcon; + self.browseClass = options.browseClass; + self.removeLabel = options.removeLabel; + self.removeIcon = options.removeIcon; + self.removeClass = options.removeClass; + self.uploadLabel = options.uploadLabel; + self.uploadIcon = options.uploadIcon; + self.uploadClass = options.uploadClass; + self.uploadUrl = options.uploadUrl; + self.msgLoading = options.msgLoading; + self.msgProgress = options.msgProgress; + self.msgSelected = options.msgSelected; + self.previewFileType = options.previewFileType; + self.wrapTextLength = options.wrapTextLength; + self.wrapIndicator = options.wrapIndicator; + self.isDisabled = self.$element.attr('disabled') || self.$element.attr('readonly'); + if (isEmpty(self.$element.attr('id'))) { + self.$element.attr('id', uniqId()); + } + if (typeof self.$container == 'undefined') { + self.$container = self.createContainer(); + } + else { + self.$container.html(self.renderMain()); + } + /* Initialize plugin option parameters */ + self.$captionContainer = getElement(options, 'elCaptionContainer', self.$container.find('.file-caption')); + self.$caption = getElement(options, 'elCaptionText', self.$container.find('.file-caption-name')); + self.$previewContainer = getElement(options, 'elPreviewContainer', self.$container.find('.file-preview')); + self.$preview = getElement(options, 'elPreviewImage', self.$container.find('.file-preview-thumbnails')); + self.$previewStatus = getElement(options, 'elPreviewStatus', self.$container.find('.file-preview-status')); + self.initPreview(); + self.$name = self.$element.attr('name') || options.name; + self.$hidden = self.$container.find('input[type=hidden][name="' + self.$name + '"]'); + if (self.$hidden.length === 0) { + self.$hidden = $(''); + self.$container.prepend(self.$hidden); + } + self.original = { + preview: self.$preview.html(), + caption: self.$caption.html(), + hiddenVal: self.$hidden.val() + }; + }, listen: function () { var self = this; self.$element.on('change', $.proxy(self.change, self)); $(self.$element[0].form).on('reset', $.proxy(self.reset, self)); self.$container.find('.fileinput-remove').on('click', $.proxy(self.clear, self)); }, - trigger: function (e) { + refresh: function (options) { var self = this; - self.$element.trigger('click'); - e.preventDefault(); + if (arguments.length) { + self.init($.extend(self.options, options)); + } + else { + self.init(self.options); + } }, initPreview: function () { var self = this, html = '', diff --git a/js/fileinput.min.js b/js/fileinput.min.js index 1ed8d16d..af7538b5 100644 --- a/js/fileinput.min.js +++ b/js/fileinput.min.js @@ -1,5 +1,6 @@ /*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 + * @version 1.6.0 * bootstrap-fileinput * For more JQuery Plugins visit http://plugins.krajee.com - */(function(e){var t="{preview}\n"+'
\n'+" {caption}\n"+'
\n'+" {remove}\n"+" {upload}\n"+" {browse}\n"+"
\n"+"
";var n="{preview}\n{remove}\n{upload}\n{browse}\n";var r='
\n'+'
\n'+'
×
\n'+'
\n'+'
'+"
";var i='
\n'+' \n'+"
";var s='\n";var o=function(t,n){return t===null||t===undefined||t==[]||t===""||n&&e.trim(t)===""};var u=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};var a=function(e,t,n){return o(e)||o(e[t])?n:e[t]};var f=function(t,n,r){return o(t)||o(t[n])?r:e(t[n])};var l=function(e,t){return typeof e!=="undefined"?e.match("image.*"):t.match(/\.(gif|png|jpe?g)$/i)};var c=function(e,t){return typeof e!=="undefined"?e.match("text.*"):t.match(/\.(txt|md|csv|htm|html|php|ini)$/i)};var h=function(){return Math.round((new Date).getTime()+Math.random()*100)};var p=function(r,i){this.$element=e(r);this.showCaption=i.showCaption;this.showPreview=i.showPreview;this.initialPreview=i.initialPreview;this.initialCaption=i.initialCaption;this.showRemove=i.showRemove;this.showUpload=i.showUpload;this.captionClass=i.captionClass;this.previewClass=i.previewClass;this.mainClass=i.mainClass;if(o(i.mainTemplate)){this.mainTemplate=this.showCaption?t:n}else{this.mainTemplate=i.mainTemplate}this.previewTemplate=this.showPreview?i.previewTemplate:"";this.captionTemplate=i.captionTemplate;this.browseLabel=i.browseLabel;this.browseIcon=i.browseIcon;this.browseClass=i.browseClass;this.removeLabel=i.removeLabel;this.removeIcon=i.removeIcon;this.removeClass=i.removeClass;this.uploadLabel=i.uploadLabel;this.uploadIcon=i.uploadIcon;this.uploadClass=i.uploadClass;this.uploadUrl=i.uploadUrl;this.msgLoading=i.msgLoading;this.msgProgress=i.msgProgress;this.msgSelected=i.msgSelected;this.previewFileType=i.previewFileType;this.wrapTextLength=i.wrapTextLength;this.wrapIndicator=i.wrapIndicator;this.isDisabled=this.$element.attr("disabled")||this.$element.attr("readonly");if(o(this.$element.attr("id"))){this.$element.attr("id",h())}this.$container=this.createContainer();this.$captionContainer=f(i,"elCaptionContainer",this.$container.find(".file-caption"));this.$caption=f(i,"elCaptionText",this.$container.find(".file-caption-name"));this.$previewContainer=f(i,"elPreviewContainer",this.$container.find(".file-preview"));this.$preview=f(i,"elPreviewImage",this.$container.find(".file-preview-thumbnails"));this.$previewStatus=f(i,"elPreviewStatus",this.$container.find(".file-preview-status"));this.initPreview();this.$name=this.$element.attr("name")||i.name;this.$hidden=this.$container.find('input[type=hidden][name="'+this.$name+'"]');if(this.$hidden.length===0){this.$hidden=e('');this.$container.prepend(this.$hidden)}this.original={preview:this.$preview.html(),caption:this.$caption.html(),hiddenVal:this.$hidden.val()};this.listen()};p.prototype={constructor:p,listen:function(){var t=this;t.$element.on("change",e.proxy(t.change,t));e(t.$element[0].form).on("reset",e.proxy(t.reset,t));t.$container.find(".fileinput-remove").on("click",e.proxy(t.clear,t))},trigger:function(e){var t=this;t.$element.trigger("click");e.preventDefault()},initPreview:function(){var e=this,t="",n=e.initialPreview,r=e.initialPreview.length,i=e.initialCaption.length,s=i>0?e.initialCaption:r+" file selected";if(u(n)&&r>0){for(var o=0;o'+n[o]+"\n"}e.$preview.html(t);if(r>1&&i==0){s=r+" files selected"}}else if(r>0){t='
'+n+"
"}else{return}e.$preview.html(t);e.$caption.html(s);e.$container.removeClass("file-input-new")},clear:function(e){var t=this;if(e){e.preventDefault()}t.$hidden.val("");t.$hidden.attr("name",t.name);t.$element.attr("name","");t.$element.val("");if(e!==false){t.$element.trigger("change");t.$element.trigger("fileclear")}t.$preview.html("");t.$caption.html("");t.$container.removeClass("file-input-new").addClass("file-input-new")},reset:function(e){var t=this;t.clear(false);t.$hidden.val(t.original.hiddenVal);t.$preview.html(t.original.preview);t.$caption.html(t.original.caption);t.$container.find(".fileinput-filename").text("");t.$element.trigger("filereset");if(t.initialPreview.length>0){t.$container.removeClass("file-input-new")}},change:function(e){var t=this;var n=t.$element,r=n.get(0).files,i=r?r.length:1,o=n.val().replace(/\\/g,"/").replace(/.*\//,""),u=t.$preview,a=t.$previewContainer,f=t.$previewStatus,p=t.msgLoading,d=t.msgProgress,v=t.msgSelected,m,g=t.previewFileType,y=parseInt(t.wrapTextLength),b=t.wrapIndicator;if(e.target.files===undefined){m=e.target&&e.target.value?[{name:e.target.value.replace(/^.+\\/,"")}]:[]}else{m=e.target.files}if(m.length===0){return}u.html("");var w=m.length,t=t;for(var E=0;E0&&(g=="any"?n||r:g=="text"?r:n)&&typeof FileReader!=="undefined"){var i=new FileReader;f.html(p);a.addClass("loading");i.onload=function(e){var n="",i="";if(r){var o=e.target.result;if(o.length>y){var l=h(),c=window.innerHeight*.75,i=s.replace("{id}",l).replace("{title}",t).replace("{body}",o).replace("{height}",c);b=b.replace("{title}",t).replace("{dialog}","$('#"+l+"').modal('show')");o=o.substring(0,y-1)+b}n='
'+o+"
"+i}else{n='
'+t+'
'}u.append("\n"+n);if(E>=w-1){a.removeClass("loading");f.html("")}};i.onprogress=function(t){if(t.lengthComputable){var n=parseInt(t.loaded/t.total*100,10);var r=d.replace("{percent}",n).replace("{file}",e.name);f.html(r)}};if(r){i.readAsText(e)}else{i.readAsDataURL(e)}}else{u.append("\n"+'

'+t+"
")}})(m[E])}var S=i>1?v.replace("{n}",i):o;t.$caption.html(S);t.$container.removeClass("file-input-new");n.trigger("fileselect",[i,o])},createContainer:function(){var t=this;var n=e(document.createElement("div")).attr({"class":"file-input file-input-new"}).html(t.renderMain());t.$element.before(n);n.find(".btn-file").append(t.$element);return n},renderMain:function(){var e=this;var t=e.previewTemplate.replace("{class}",e.previewClass);var n=e.isDisabled?e.captionClass+" file-caption-disabled":e.captionClass;var r=e.captionTemplate.replace("{class}",n);return e.mainTemplate.replace("{class}",e.mainClass).replace("{preview}",t).replace("{caption}",r).replace("{upload}",e.renderUpload()).replace("{remove}",e.renderRemove()).replace("{browse}",e.renderBrowse())},renderBrowse:function(){var e=this,t=e.browseClass+" btn-file",n="";if(e.isDisabled){n=" disabled "}return'
"+e.browseIcon+e.browseLabel+"
"},renderRemove:function(){var e=this,t=e.removeClass+" fileinput-remove fileinput-remove-button",n="";if(!e.showRemove){return""}if(e.isDisabled){n=" disabled "}return'"},renderUpload:function(){var e=this,t="",n="";if(!e.showUpload){return""}if(e.isDisabled){n=" disabled "}if(o(e.uploadUrl)){t='"}else{t='"+e.uploadIcon+e.uploadLabel+""}return t}};e.fn.fileinput=function(t){return this.each(function(){var n=e(this),r=n.data("fileinput");if(!r){n.data("fileinput",r=new p(this,t))}if(typeof t=="string"){r[t]()}})};e.fn.fileinput=function(t){var n=Array.apply(null,arguments);n.shift();return this.each(function(){var r=e(this),i=r.data("fileinput"),s=typeof t==="object"&&t;if(!i){r.data("fileinput",i=new p(this,e.extend({},e.fn.fileinput.defaults,s,e(this).data())))}if(typeof t==="string"){i[t].apply(i,n)}})};e.fn.fileinput.defaults={showCaption:true,showPreview:true,showRemove:true,showUpload:true,captionClass:"",previewClass:"",mainClass:"",mainTemplate:null,initialPreview:"",initialCaption:"",previewTemplate:r,captionTemplate:i,browseLabel:"Browse …",browseIcon:'  ',browseClass:"btn btn-primary",removeLabel:"Remove",removeIcon:' ',removeClass:"btn btn-default",uploadLabel:"Upload",uploadIcon:' ',uploadClass:"btn btn-default",uploadUrl:null,msgLoading:"Loading …",msgProgress:"Loaded {percent}% of {file}",msgSelected:"{n} files selected",previewFileType:"image",wrapTextLength:250,wrapIndicator:' […]',elCaptionContainer:null,elCaptionText:null,elPreviewContainer:null,elPreviewImage:null,elPreviewStatus:null};e(function(){var t=e("input.file[type=file]");if(t.length>0){t.fileinput()}})})(window.jQuery) \ No newline at end of file + */!function(e){var i='{preview}\n
\n {caption}\n
\n {remove}\n {upload}\n {browse}\n
\n
',n="{preview}\n{remove}\n{upload}\n{browse}\n",a='
\n
\n
×
\n
\n
',t='
\n \n
',l='\n',r=function(i,n){return null===i||void 0===i||i==[]||""===i||n&&""===e.trim(i)},o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},s=function(i,n,a){return r(i)||r(i[n])?a:e(i[n])},p=function(e,i){return"undefined"!=typeof e?e.match("image.*"):i.match(/\.(gif|png|jpe?g)$/i)},d=function(e,i){return"undefined"!=typeof e?e.match("text.*"):i.match(/\.(txt|md|csv|htm|html|php|ini)$/i)},c=function(){return Math.round((new Date).getTime()+100*Math.random())},v=function(i,n){this.$element=e(i),this.options=n,this.init(n),this.listen()};v.prototype={constructor:v,init:function(a){var t=this;t.showCaption=a.showCaption,t.showPreview=a.showPreview,t.initialPreview=a.initialPreview,t.initialCaption=a.initialCaption,t.showRemove=a.showRemove,t.showUpload=a.showUpload,t.captionClass=a.captionClass,t.previewClass=a.previewClass,t.mainClass=a.mainClass,t.mainTemplate=r(a.mainTemplate)?t.showCaption?i:n:a.mainTemplate,t.previewTemplate=t.showPreview?a.previewTemplate:"",t.captionTemplate=a.captionTemplate,t.browseLabel=a.browseLabel,t.browseIcon=a.browseIcon,t.browseClass=a.browseClass,t.removeLabel=a.removeLabel,t.removeIcon=a.removeIcon,t.removeClass=a.removeClass,t.uploadLabel=a.uploadLabel,t.uploadIcon=a.uploadIcon,t.uploadClass=a.uploadClass,t.uploadUrl=a.uploadUrl,t.msgLoading=a.msgLoading,t.msgProgress=a.msgProgress,t.msgSelected=a.msgSelected,t.previewFileType=a.previewFileType,t.wrapTextLength=a.wrapTextLength,t.wrapIndicator=a.wrapIndicator,t.isDisabled=t.$element.attr("disabled")||t.$element.attr("readonly"),r(t.$element.attr("id"))&&t.$element.attr("id",c()),"undefined"==typeof t.$container?t.$container=t.createContainer():t.$container.html(t.renderMain()),t.$captionContainer=s(a,"elCaptionContainer",t.$container.find(".file-caption")),t.$caption=s(a,"elCaptionText",t.$container.find(".file-caption-name")),t.$previewContainer=s(a,"elPreviewContainer",t.$container.find(".file-preview")),t.$preview=s(a,"elPreviewImage",t.$container.find(".file-preview-thumbnails")),t.$previewStatus=s(a,"elPreviewStatus",t.$container.find(".file-preview-status")),t.initPreview(),t.$name=t.$element.attr("name")||a.name,t.$hidden=t.$container.find('input[type=hidden][name="'+t.$name+'"]'),0===t.$hidden.length&&(t.$hidden=e(''),t.$container.prepend(t.$hidden)),t.original={preview:t.$preview.html(),caption:t.$caption.html(),hiddenVal:t.$hidden.val()}},listen:function(){var i=this;i.$element.on("change",e.proxy(i.change,i)),e(i.$element[0].form).on("reset",e.proxy(i.reset,i)),i.$container.find(".fileinput-remove").on("click",e.proxy(i.clear,i))},refresh:function(i){var n=this;n.init(arguments.length?e.extend(n.options,i):n.options)},initPreview:function(){var e=this,i="",n=e.initialPreview,a=e.initialPreview.length,t=e.initialCaption.length,l=t>0?e.initialCaption:a+" file selected";if(o(n)&&a>0){for(var r=0;a>r;r++)i+='
'+n[r]+"
\n";e.$preview.html(i),a>1&&0==t&&(l=a+" files selected")}else{if(!(a>0))return;i='
'+n+"
"}e.$preview.html(i),e.$caption.html(l),e.$container.removeClass("file-input-new")},clear:function(e){var i=this;e&&e.preventDefault(),i.$hidden.val(""),i.$hidden.attr("name",i.name),i.$element.attr("name",""),i.$element.val(""),e!==!1&&(i.$element.trigger("change"),i.$element.trigger("fileclear")),i.$preview.html(""),i.$caption.html(""),i.$container.removeClass("file-input-new").addClass("file-input-new")},reset:function(){var e=this;e.clear(!1),e.$hidden.val(e.original.hiddenVal),e.$preview.html(e.original.preview),e.$caption.html(e.original.caption),e.$container.find(".fileinput-filename").text(""),e.$element.trigger("filereset"),e.initialPreview.length>0&&e.$container.removeClass("file-input-new")},change:function(e){var i,n=this,a=n.$element,t=a.get(0).files,r=t?t.length:1,o=a.val().replace(/\\/g,"/").replace(/.*\//,""),s=n.$preview,v=n.$previewContainer,m=n.$previewStatus,u=n.msgLoading,f=n.msgProgress,h=n.msgSelected,w=n.previewFileType,g=parseInt(n.wrapTextLength),b=n.wrapIndicator;if(i=void 0===e.target.files?e.target&&e.target.value?[{name:e.target.value.replace(/^.+\\/,"")}]:[]:e.target.files,0!==i.length){s.html("");for(var $=i.length,n=n,C=0;$>C;C++)!function(e){var i=e.name,n=p(e.type,e.name),a=d(e.type,e.name);if(s.length>0&&("any"==w?n||a:"text"==w?a:n)&&"undefined"!=typeof FileReader){var t=new FileReader;m.html(u),v.addClass("loading"),t.onload=function(e){var n="",t="";if(a){var r=e.target.result;if(r.length>g){var o=c(),p=.75*window.innerHeight,t=l.replace("{id}",o).replace("{title}",i).replace("{body}",r).replace("{height}",p);b=b.replace("{title}",i).replace("{dialog}","$('#"+o+"').modal('show')"),r=r.substring(0,g-1)+b}n='
'+r+"
"+t}else n='
'+i+'
';s.append("\n"+n),C>=$-1&&(v.removeClass("loading"),m.html(""))},t.onprogress=function(i){if(i.lengthComputable){var n=parseInt(i.loaded/i.total*100,10),a=f.replace("{percent}",n).replace("{file}",e.name);m.html(a)}},a?t.readAsText(e):t.readAsDataURL(e)}else s.append('\n

'+i+"
")}(i[C]);var y=r>1?h.replace("{n}",r):o;n.$caption.html(y),n.$container.removeClass("file-input-new"),a.trigger("fileselect",[r,o])}},createContainer:function(){var i=this,n=e(document.createElement("div")).attr({"class":"file-input file-input-new"}).html(i.renderMain());return i.$element.before(n),n.find(".btn-file").append(i.$element),n},renderMain:function(){var e=this,i=e.previewTemplate.replace("{class}",e.previewClass),n=e.isDisabled?e.captionClass+" file-caption-disabled":e.captionClass,a=e.captionTemplate.replace("{class}",n);return e.mainTemplate.replace("{class}",e.mainClass).replace("{preview}",i).replace("{caption}",a).replace("{upload}",e.renderUpload()).replace("{remove}",e.renderRemove()).replace("{browse}",e.renderBrowse())},renderBrowse:function(){var e=this,i=e.browseClass+" btn-file",n="";return e.isDisabled&&(n=" disabled "),'
"+e.browseIcon+e.browseLabel+"
"},renderRemove:function(){var e=this,i=e.removeClass+" fileinput-remove fileinput-remove-button",n="";return e.showRemove?(e.isDisabled&&(n=" disabled "),'"):""},renderUpload:function(){var e=this,i="",n="";return e.showUpload?(e.isDisabled&&(n=" disabled "),i=r(e.uploadUrl)?'":'"+e.uploadIcon+e.uploadLabel+""):""}},e.fn.fileinput=function(i){return this.each(function(){var n=e(this),a=n.data("fileinput");a||n.data("fileinput",a=new v(this,i)),"string"==typeof i&&a[i]()})},e.fn.fileinput=function(i){var n=Array.apply(null,arguments);return n.shift(),this.each(function(){var a=e(this),t=a.data("fileinput"),l="object"==typeof i&&i;t||a.data("fileinput",t=new v(this,e.extend({},e.fn.fileinput.defaults,l,e(this).data()))),"string"==typeof i&&t[i].apply(t,n)})},e.fn.fileinput.defaults={showCaption:!0,showPreview:!0,showRemove:!0,showUpload:!0,captionClass:"",previewClass:"",mainClass:"",mainTemplate:null,initialPreview:"",initialCaption:"",previewTemplate:a,captionTemplate:t,browseLabel:"Browse …",browseIcon:'  ',browseClass:"btn btn-primary",removeLabel:"Remove",removeIcon:' ',removeClass:"btn btn-default",uploadLabel:"Upload",uploadIcon:' ',uploadClass:"btn btn-default",uploadUrl:null,msgLoading:"Loading …",msgProgress:"Loaded {percent}% of {file}",msgSelected:"{n} files selected",previewFileType:"image",wrapTextLength:250,wrapIndicator:' […]',elCaptionContainer:null,elCaptionText:null,elPreviewContainer:null,elPreviewImage:null,elPreviewStatus:null},e(function(){var i=e("input.file[type=file]");i.length>0&&i.fileinput()})}(window.jQuery); \ No newline at end of file