/* jQuery Custom Input File Plugin - version 1.0 Copyright 2014, Ángel Espro, www.aesolucionesweb.com.ar, Licence : GNU General Public License Site: www.aesolucionesweb.com.ar/plugins/custom-input-file You must not remove these lines. Read gpl.txt for further legal information. */ (function($){ /* * CUSTOMFILE */ // Constructor (CustomFile) CustomFile = function(elem, options){ this.elem = $(elem); this.itemFileList = []; this.defaults = { type : 'all', allowed : 'all', //or array of allowed extensions. E.g. ["exe", "jpeg", "jpg"] notAllowed : [],//E.g. ["exe", "jpeg", "jpg"] addContainerAfter : $(elem), //jQuery Object. E.g $('#my-element') multiple : true, maxFiles : 5, //0 = no limits maxMB : 0, //0 = no limits maxKBperFile: 2048, fileWrapper : '
', //markup or jQuery object. E.g $('#my-element') filePicker : 'or click to select them
',//markup or jQuery object. E.g $('#my-element') image : { crop : false, preview : { display: true, maxWidth: 300 //if cropSize were wider than maxWidth, only preview would be redimensioned (real crop area would not) }, cropSize: [320,225], //[width, height] minSize : [0,0], //[width, height] 0 = no limits maxSize : [0,0] //[width, height] 0 = no limits }, messages : { errorType : "File type not allowed", errorMaxMB : "Total weight exceeded", errorFileKB : "File too heavy", errorMaxFiles : "Maximum number of files reached", errorBigImage : "Image too big", errorSmallImage : "Image too small", errorOnReading : "App busy. Please, try again later.", errorMultipleDisable : "Drag & drop one file at a time." }, popup : { active : true, autoclose : true, delay : 10000 //10sec }, callbacks : { onComplete : function(app){ //function fires when all files have already read; }, beforeRead : function(file){ //function fires every time a file is just to be read; //Return false if you want to stop app reading this file }, onSuccess : function(item, callback){ //function called every time a file has been successfuly read; //retur false for stop app reading next file. Then, you can execute callback for reading next file. //E.g. //item.serialize(); FunctionToSend(callback); return false; }, onError : function(file, msg){ //function called every time a file has been not successfuly read; }, beforeRemove : function(item){ //function called every time an item file is been removed; //Here you can handle file (item.file) before removing item }, } } this.settings = $.extend(true, {}, this.defaults, options); this.status = 'stop'; this.init(); } //Methods (CustomFile) CustomFile.prototype = { init : function(){ var attnm = this.elem.attr("name"); if(attnm == '') var attnm = "inputfile"; //properties: this.name = (attnm.indexOf("[]", attnm - 2) === -1)? attnm+"[]" : attnm; this.form = this.elem.parents('form'); this.container = $('