diff js-lib/buy3.js @ 87:81deee1fc85b laserkard

got pure raphael color selector working
author Robert McIntyre <rlm@mit.edu>
date Mon, 26 Jul 2010 02:20:29 -0400
parents e48424b01e5f
children 08f93d043ed2
line wrap: on
line diff
     1.1 --- a/js-lib/buy3.js	Mon Jul 26 01:24:29 2010 -0400
     1.2 +++ b/js-lib/buy3.js	Mon Jul 26 02:20:29 2010 -0400
     1.3 @@ -16,17 +16,17 @@
     1.4      //var select_black;
     1.5      
     1.6      var select_map = 
     1.7 -	{"green" : 0,
     1.8 -	 "red"   : 0,
     1.9 -	 "blue"  : 0,
    1.10 -	 "green" : 0};
    1.11 +	{green : {offAttr : 0, onAttr : 0, ref : 0},
    1.12 +	 red   : {offAttr : 0, onAttr : 0, ref : 0},
    1.13 +	 blue  : {offAttr : 0, onAttr : 0, ref : 0},
    1.14 +	 green : {offAttr : 0, onAttr : 0, ref : 0}};
    1.15      
    1.16      var toggle_on = (function (button){
    1.17 -	button.scale(0.5, 0.75);
    1.18 +	button.ref.animate(button.onAttr, 500);
    1.19      });
    1.20      
    1.21      var toggle_off = (function (button){
    1.22 -	    button.attr("fill", "black");
    1.23 +	button.ref.animate(button.offAttr, 500);
    1.24      });
    1.25      
    1.26      var color_update = (function (){
    1.27 @@ -44,20 +44,27 @@
    1.28      
    1.29      var drawInit = (function (){
    1.30  	//color-select init
    1.31 -	select_map["red"] = color.rect(1, 1, 70, 50, 10).attr("fill","red");
    1.32 -	select_map["red"].node.onclick = (function (){
    1.33 -	    order.color= "red"; update();});
    1.34 -	//toggle_on(select_red);
    1.35 -	
    1.36 -	
    1.37 -	select_map["green"] = 
    1.38 -	    color.rect(80, 1, 70, 50,10).attr("fill", "green");
    1.39 -	select_map["green"].node.onclick = 
    1.40 -	    (function (){order.color = "green"; update();});
    1.41 -	select_map["blue"] = 
    1.42 -	    color.rect(160, 1, 70, 50, 10).attr("fill", "blue");
    1.43 -	select_map["blue"].node.onclick = 
    1.44 -	    (function (){order.color = "blue"; update();});
    1.45 +	select_map["red"].onAttr =  {"fill" : "#F00"};
    1.46 +	select_map["red"].offAttr = {"fill" : "#300"};
    1.47 +	select_map["red"].ref = 
    1.48 +	    color.rect(1, 1, 70, 50, 10).attr(select_map["red"].offAttr);
    1.49 +	select_map["red"].ref.node.onclick = 
    1.50 +	    (function (){order.color= "red"; update();});
    1.51 +
    1.52 +	select_map["green"].onAttr =  {"fill" : "#0F0"};
    1.53 +	select_map["green"].offAttr = {"fill" : "#030"};
    1.54 +	select_map["green"].ref = 
    1.55 +	    color.rect(80, 1, 70, 50, 10).attr(select_map["green"].offAttr);
    1.56 +	select_map["green"].ref.node.onclick = 
    1.57 +	    (function (){order.color= "green"; update();});
    1.58 +
    1.59 +	select_map["blue"].onAttr =  {"fill" : "#00F"};
    1.60 +	select_map["blue"].offAttr = {"fill" : "#003"};
    1.61 +	select_map["blue"].ref = 
    1.62 +	    color.rect(160, 1, 70, 50, 10).attr(select_map["blue"].offAttr);
    1.63 +	select_map["blue"].ref.node.onclick = 
    1.64 +	    (function (){order.color= "blue"; update();});
    1.65 +
    1.66  	
    1.67  	toggle_on(select_map[order.color]);
    1.68