o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1356306315.480031:@value"h!{I" class:EFI"BundledAsset; FI"logical_path; FI"cytoplasm/cytoUpload.js; FI" pathname; FI"g/Applications/XAMPP/xamppfiles/htdocs/cytoplasm/app/assets/javascripts/cytoplasm/cytoUpload.js.erb; FI"content_type; FI"application/javascript; FI" mtime; FI"2012-12-23T18:45:01-05:00; FI"length; FiyI"digest; F"%9defe07828e7eebd9e26a890acc11994I"source; FI"y// 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:'12px Verdana', 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 = $('').addClass('cytoButton cytoUpload-button').css(settings.widget.button.css).appendTo(settings.widget.wrapper.element) settings.widget.button.nameReadout.element = $('').addClass('cytoUpload-nameReadout').css(settings.widget.button.nameReadout.css).html(settings.widget.button.placeholder).appendTo(settings.widget.button.element); settings.widget.button.sizeReadout.element = $('').addClass('cytoUpload-sizeReadout').css(settings.widget.button.sizeReadout.css).appendTo(settings.widget.button.element); // Bindings settings.widget.button.element.bind('click.cytoUpload',function(e){ e.preventDefault(); $this.click(); }); $this.bind('change.cytoUpload',function(){ var file = this.files[0]; methods.activate.apply($this,[file]); var size = file.size; for (u=0;size>=1024;u++) size/=1024; settings.widget.button.element.html(file.name).append($('').css(settings.widget.button.sizeReadout.css).html(size.toFixed(2)+" "+settings.widget.button.sizeReadout.units[u])).addClass('active'); settings.events.change.apply($this,[file]); }); // Store data in data-cytoUpload $this.data('cytoUpload',settings); // Attempt to activate via JSON from data-file attribute if ($this.data('file')!=null) try { var file = $.parseJSON($this.data('file')); methods.activate.apply($this,[file]); } catch (e) {console.warn("The file parameter you passed did not contain valid JSON and therefore it has been ignored.");} settings.events.create.apply($this); }); }, activate:function(file){ if (file==null || typeof file!="object" || typeof file.name!="string" || typeof file.size!="number" || typeof file.type!="string") return $.error("$.cytoUpload('activate') requires one parameter of type File Object ({name:(string containing filename),size:(integer containing filesize in bytes),type:(string containing a MIME type)}."); return this.each(function(){ var $this = $(this); var settings = $this.data('cytoUpload'); if (!$this.hasClass('cytoUpload') || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the activate method!"); // Run filters over the received data var error; if (typeof settings.filters.name == "string" && file.name != settings.filters.name) error = settings.errors.name; if ((typeof settings.filters.type == "string" && file.type != settings.filters.type) || (typeof settings.filters.type=="object" && $.inArray(file.type,settings.filters.type)==-1)) error = settings.errors.type; if (settings.filters.size && size > settings.filters.size) error = settings.errors.size; if (error!=null) { $.cytoAjaxResponse(error,"error"); return; } // Calculate size var size = file.size; for (u=0;size>=1024;u++) size/=1024; size = size.toFixed(settings.widget.button.sizeReadout.precision)+" "+settings.widget.button.sizeReadout.units[u]; // Apply cosmetic changes settings.widget.button.element.addClass('active'); settings.widget.button.nameReadout.element.html(file.name); settings.widget.button.sizeReadout.element.html(size); }); }, destroy:function(){ return this.each(function(){ var $this = $(this); var settings = $this.data('cytoUpload'); if (!$this.hasClass('cytoUpload') || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the destroy method!"); $this.removeClass('cytoUpload').unbind('.cytoUpload').data('cytoUpload',null).siblings('*').remove().end().unwrap().show(); }); }, refresh:function(){ return this.each(function(){ var $this = $(this); var settings = $this.data('cytoUpload'); if (!$this.hasClass('cytoUpload') || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the refresh method!"); methods.destroy.apply($this); methods.init.apply($this,[settings,true]); $this.trigger('change.cytoUpload'); }); }, error:function(message){ return this.each(function(){ var $this = $(this); var settings = $this.data('cytoUpload'); if (!$this.hasClass('cytoUpload') || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the error method!"); settings.widget.errorMessage.element.html(((typeof message == "string")?message:"An error occurred, please try again.")).show(settings.widget.errorMessage.animationTime); settings.widget.button.element.removeClass('active'); methods.refresh.apply($this); }); }, resize:function(){ return this.each(function(){ var $this = $(this); var settings = $this.data('cytoUpload'); if (!$this.hasClass('cytoUpload') || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the resize method!"); var w = settings.widget.wrapper.element.width(0); setTimeout(function(){ w.width("100%").width(w.width()-2); },1); }); }, options:function(newOptions){ if (newOptions!=null) { return this.each(function(){ var $this = $(this); var settings = $this.data('cytoUpload'); if (!$this.hasClass("cytoUpload") || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the options method!"); $this.data('cytoUpload',$.extend(true,{},settings,newOptions)); methods.refresh.apply($this); }); } else { var returnVal; this.each(function(){ var $this = $(this); var settings = $this.data('cytoUpload'); if (!$this.hasClass("cytoUpload") || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the options method!"); returnVal = settings; }); return returnVal; } } }; $.fn.cytoUpload = function(method){ if (methods[method]) return methods[method].apply(this,Array.prototype.slice.call(arguments,1)); else if (typeof method == 'object' || !method) return methods.init.apply(this,arguments); else $.error('Method '+method+' does not exist on jQuery.cytoUpload!'); }; $(window).resize(function(){$('.cytoUpload').cytoUpload('resize');}); $.Cytoplasm("ready",function(){$('.cytoUpload').cytoUpload();}); })(jQuery); ; TI"required_assets_digest; F"%053ccd65dac36a5640d65914a6488856I" _version; F"%6776f581a4329e299531e1d52aa59832