// CytoUpload v2.0 // By MacKinley Smith (function($){ var defaults = { widget:{ button:{ placeholder:"Click to select a file for upload…", css:{ "text-align":"left", width:"100%", height:30 }, element:null, nameReadout:{ css:{}, element:null }, sizeReadout:{ css:{ font:$.Cytoplasm("vars","fonts.sizes.small")+" "+$.Cytoplasm("vars","fonts.faces.medium"), float:'right' }, element:null, precision:2, units:['b','Kb','Mb','Gb','Tb'] }, active:false }, input:{ css:{display:'none'}, element:null }, wrapper:{ css:{}, element:null } }, events:{ create:function(){}, change:function(file){}, destroy:function(){} }, filters:{ name:false, type:false, size:false }, errors:{ name:"The file you have chosen is not named correctly.", size:"The file you have chosen is larger that the allowed size.", type:"The file you have chosen is not the correct type." } }; var methods = { init:function(options,reinit){ if (reinit==null) reinit = false; return this.each(function(){ var $this = $(this); if ($this.data("cytoUpload")!=null && $this.hasClass("cytoUpload")) return console.warn("You cannot reinstatiate cytoUpload before calling the destroy method.\nProtip: Use the refresh method to reinstantiate in one move."); // Instantiate settings var settings = $.extend(true,{},defaults,options); $this.data('cytoUpload',settings); // Generate widget settings.widget.wrapper.element = $this.wrap("
").parent().addClass('cytoUpload-wrapper').css(settings.widget.wrapper.css); settings.widget.input.element = $this.addClass('cytoUpload').css(settings.widget.input.css); settings.widget.button.element = $('