test/dummy/tmp/cache/assets/D14/170/sprockets%2F40a7b83bb067eea7ce2c8394e1529287 in cytoplasm-0.1.3 vs test/dummy/tmp/cache/assets/D14/170/sprockets%2F40a7b83bb067eea7ce2c8394e1529287 in cytoplasm-0.1.4
- old
+ new
@@ -1,25 +1,20 @@
-o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1356891866.506549:@value" {I"
+o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1357586231.770189:@value"U,{I"
class:EFI"BundledAsset; FI"logical_path; FI"cytoplasm/cytoplasm.js; FI"
pathname; FI"f/Applications/XAMPP/xamppfiles/htdocs/cytoplasm/app/assets/javascripts/cytoplasm/cytoplasm.js.erb; FI"content_type; FI"application/javascript; FI"
-mtime; FI"2012-12-29T18:46:25-05:00; FI"length; FiI"digest; F"%b6d8088049384655f785843a5eca253dI"source; FI"// CytoPlasm jQuery Setup v0.1
+mtime; FI"2013-01-07T14:17:11-05:00; FI"length; Fih*I"digest; F"%a0f854e68a8e1ad4ad6653196cf12deeI"source; FI"h*// CytoPlasm jQuery Setup v0.1
// By MacKinley Smith
// Initialize global JS variables
var Cytoplasm;
(function($){
// Ensure that jQuery and jQuery UI get loaded
$.each(["/assets/jquery.js","/assets/jquery-ui.js"],function(i,script){if (!$('script[src="'+script+'"], script[src="'+script+'?body=1"]').is('*')) $('head').append("<script type='text/javascript' src='"+script+"'></script>");});
- var fixInputs = function(){$('.cytoField').width("100%").each(function(){$(this).width($(this).width()-16);});};
- $(window).resize(fixInputs);
- $(document).ready(fixInputs);
-
$(document).ready(function(){
// Setup header
- var header = $("header");
- header.find('h1').click(function(){window.location = "/";});
+ var header = $("header").find('h1').click(function(){window.location = "/";}).end();
// Setup callback messages
$.each(["success","sending","error"],function(i,v){
var $this = $('#'+v+'_message');
if (!$this.is('*')) {
@@ -40,28 +35,99 @@
};
var conf = {};
var vars = {};
var ready = false;
+ var parseGradient = function(grad,reverse){
+ // Return untouched if not gradient
+ if (grad.indexOf("gradient")==-1) return grad;
+ if (reverse!=true) reverse = false;
+ var o = {};
+
+ var halves = grad.split("(");
+ o.type = halves[0];
+ o.params = halves[1].split(")")[0].split(",");
+ if (o.type.indexOf("linear")>-1) {
+ if (isColorStop(o.params[0])) o.params.unshift("to bottom");
+ o.params[0] = normalizeDirection(o.params[0]);
+ if (reverse) o.params[0] = invertDirection(o.params[0]);
+ o.dir = o.params[0];
+ o.colors = o.params.slice(1);
+ } else if (o.type.indexOf("radial")>-1) {
+ var firstcolor;
+ if (isColorStop(o.params[0])) o.params.unshift("center");
+ $.each(o.params,function(i,p){if (isColorStop(p)) {firstcolor = i;return false;}});
+ o.dir = o.params[0];
+ o.colors = o.params.slice(firstcolor);
+ } else return false;
+
+ var params = o.params.join(",");
+
+ // String types
+ o.shortened = o.type+"("+denormalizeDirection(o.dir)+","+o.colors.join(",")+");";
+
+ o.expanded = "background-color:"+((o.colors[0].indexOf("%")>-1) ? o.colors[0].split(" ").slice(0,-1).join(" ") : o.colors[0]) + ";";
+ o.expanded += "background-image:-webkit-"+o.type+"("+params+");";
+ o.expanded += "background-image:-moz-"+o.type+"("+params+");";
+ o.expanded += "background-image:-o-"+o.type+"("+params+");";
+ o.expanded += "background-image:-ms-"+o.type+"("+params+");";
+ o.expanded += "background-image:"+o.shortened;
+
+ return o;
+ };
+ var expandGradient = function(orig){
+ if (typeof orig != "string") return console.warn("Cytoplasm.expandGradient only accepts string arguments!");
+ // Return untouched if not gradient
+ if (orig.indexOf("gradient")==-1) return orig;
+
+ var g = parseGradient(orig);
+ return g.expanded;
+ };
var reverseGradient = function(orig){
if (typeof orig != "string") return console.warn("Cytoplasm.reverseGradient only accepts string arguments!");
// Return untouched if not gradient
if (orig.indexOf("gradient")==-1) return orig;
- // Get direction
- var dir = orig.split("(")[1].split(",")[0];
- // Reverse direction
+
+ var g = parseGradient(orig,true);
+ return g.shortened;
+ };
+ var normalizeDirection = function(dir){
var newdir = dir;
+ if (newdir.slice(0,3)!="to ") return newdir;
+ return invertDirection(newdir).slice(3);
+ };
+ var denormalizeDirection = function(dir){
+ var newdir = dir;
+ if (newdir.slice(0,3)=="to ") return newdir;
+ return "to "+invertDirection(newdir);
+ };
+ var invertDirection = function(dir){
+ var newdir = " "+dir+" ";
if (dir.indexOf("top")>-1) newdir = newdir.replace("top","bottom");
else if (dir.indexOf("bottom")>-1) newdir = newdir.replace("bottom","top");
if (dir.indexOf("left")>-1) newdir = newdir.replace("left","right");
else if (dir.indexOf("right")>-1) newdir = newdir.replace("right","left");
- return orig.replace(dir,newdir)
+ newdir = newdir.slice(2,-2);
+ return newdir;
};
+ var isColorStop = function(str){
+ var cache, p=parseInt, nstr = str;
+ if (nstr.slice(-1) == "%") nstr = nstr.split(" ").slice(0,-1).join(" ");
+ nstr = nstr.replace(/\s\s*/g,'') // Remove all spaces
+ if ($.inArray(nstr,['aqua','black','blue','fuchsia','gray','grey','green','lime','maroon','navy','olive','purple','red','silver','teal','white','yellow'])>-1) return true;
+ return (nstr.match(/^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})/) || nstr.match(/^#([\da-fA-F])([\da-fA-F])([\da-fA-F])/) || nstr.match(/^rgba\(([\d]+),([\d]+),([\d]+),([\d]+|[\d]*.[\d]+)\)/) || nstr.match(/^rgb\(([\d]+),([\d]+),([\d]+)\)/));
+ };
var compileStyles = function(element,styles){
output = "";
output += element+" { ";
- $.each(styles,function(prop,value){output += (typeof value == "object") ? compileStyles(prop,value) : prop+" : "+value+"; ";});
+ $.each(styles,function(prop,value){
+ if (typeof value == "object") output += compileStyles(prop,value);
+ else {
+ if (prop == "background" && value.indexOf("gradient")>-1) output += expandGradient(value);
+ else output += prop+" : "+value+"; ";
+ }
+ });
output += " } ";
return output;
};
var methods = {
@@ -128,21 +194,36 @@
td:{
border:vars.colors.plugins.cytoTable.border,
"&.labelcell":{"font-size":vars.fonts.sizes.small}
}
},
- 'input.cytoField':{"font-family":vars.fonts.faces.regular},
+ '.cytoField':{"font-family":vars.fonts.faces.regular},
'.cytoButton':{
border:vars.colors.plugins.cytoButton.border,
color:vars.colors.plugins.cytoButton.text,
"&:not(.active),&:not(:active)":{background:vars.colors.plugins.cytoButton.background},
- "&.active,&:active":{background:reverseGradient(vars.colors.plugins.cytoButton.background)}
+ "&.active,&:active":{
+ background:reverseGradient(vars.colors.plugins.cytoButton.background),
+ "box-shadow":vars.layout.plugins.cytoButton.shadow
+ }
}
};
// Heading sizes
- $.each([1,2,3,4,5,6],function(i,num){$('h'+num.toString()).css("font-size",parseInt(vars.fonts.sizes.huge) - (parseInt(vars.fonts.sizes.heading_factor)*i));});
+ (function(){
+ var verbose = false;
+ var huge = parseInt(vars.fonts.sizes.huge), normal = parseInt(vars.fonts.sizes.normal);
+ var hRange = huge - normal;
+ $.each([1,2,3,4,5,6],function(i,num){
+ if (verbose) console.log("----- H"+num+" -----");
+ var factor = Math.pow(vars.fonts.sizes.heading_factor,i);
+ if (verbose) console.log("Factor: "+factor);
+ var size = parseInt(vars.fonts.sizes.normal) + (hRange/factor);
+ if (verbose) console.log("Size: "+size);
+ $('h'+num.toString()).css("font-size",size);
+ });
+ })();
// Logo positioning
if (vars.layout.header.logo.align == "center") styles.header["#logo"].left = (($(window).width()-$('header #logo').width())/2) + vars.layout.header.logo.x;
else styles.header["#logo"][vars.layout.header.logo.align] = vars.layout.header.logo.x+10;
// Compile the styles for HTML and add to <head>
@@ -221,6 +302,6 @@
};
$(document).ready(function(){$.Cytoplasm()});
})(jQuery);
-; FI"required_assets_digest; F"%89b0e8947e25a9d42cca66fa75c67fc9I"
_version; F"%6776f581a4329e299531e1d52aa59832
+; FI"required_assets_digest; F"%281c12e34ee0ef90e05fe232f4edcb0fI"
_version; F"%6776f581a4329e299531e1d52aa59832
\ No newline at end of file