[Movecommons-commits] r569 - trunk/src

Mario Gallegos mgallegos at ourproject.org
Sun Nov 4 18:55:34 CET 2012


Author: mgallegos
Date: 2012-11-04 18:55:33 +0100 (Sun, 04 Nov 2012)
New Revision: 569

Modified:
   trunk/src/mc-dia-form2.js
Log:


Modified: trunk/src/mc-dia-form2.js
===================================================================
--- trunk/src/mc-dia-form2.js	2012-11-04 17:40:51 UTC (rev 568)
+++ trunk/src/mc-dia-form2.js	2012-11-04 17:55:33 UTC (rev 569)
@@ -1,561 +1,5 @@
 var $j = jQuery.noConflict();
 
-// categories selection
-
-function clickCheckBox(id,answer){
-	if(answer=='yes'){
-		if ($j("#mc-form-" + id).is('.mc-form-descbox-selected')) return;
-		$j('#'+id+'-checkbox').val('S'); 
-		$j("#mc-form-" + id).addClass("mc-form-descbox-selected");
-		$j("#mc-cat-selected-"+ id).slideDown();		
-		if(id=='np'){
-			$("#registered-non-profit").removeAttr("disabled");
-			$("#open-accounting").removeAttr("disabled");
-			$("#accept-donations").removeAttr("disabled");
-			$j("#mc-form-optional-non-profit").effect("shake", { times:1 }, 200);
-		}
-		if(id=='rp'){
-			$("#terms-of-use").removeAttr("disabled");
-			$("#creative-commons").removeAttr("disabled");
-			$("#other-license").removeAttr("disabled");						
-			$("#organization-structure").removeAttr("disabled");
-			$("#projects-and-results").removeAttr("disabled");
-			$("#methods-procedures").removeAttr("disabled");
-			$("#documentation").removeAttr("disabled");
-			$j("#mc-form-optional-reproducible").effect("shake", { times:1 }, 200);
-		}
-		if(id=='gr'){
-			$("#decisions-general-assemblies").removeAttr("disabled");
-			$("#decisions-consensus").removeAttr("disabled");
-			$("#representatives-democratically").removeAttr("disabled");						
-			$("#meetings-transparent").removeAttr("disabled");
-			$("#decisions-voting").removeAttr("disabled");
-			$j("#mc-form-optional-grassroots").effect("shake", { times:1 }, 200);
-		}
-		if(id=='rc')
-			$j("#mc-form-optional-reinforcing").effect("shake", { times:1 }, 200);
-	} 		 
-	else{		
-		$j('#'+id+'-checkbox').val('N');
-		$j("#mc-form-" + id).removeClass("mc-form-descbox-selected");
-		$j("#mc-cat-selected-"+ id).slideUp();
-		if(id=='np'){
-			$("#registered-non-profit").attr("disabled", "disabled");
-			$('#registered-non-profit').attr('checked', false);
-			$("#open-accounting").attr("disabled", "disabled");
-			$('#open-accounting').attr('checked', false);
-			$("#accept-donations").attr("disabled", "disabled");
-			$('#accept-donations').attr('checked', false);			
-			$j('#non-profit-website').hide();
-			$j('#infield-non-profit-website').hide();
-			$j('#open-accounting-website').hide();
-			$j('#infield-open-accounting-website').hide();
-			$j('#donation-website').hide();
-			$j('#infield-donation-website').hide();
-			$j('#submit_second').click();
-		}
-		if(id=='rp'){
-			$("#terms-of-use").attr("disabled", "disabled");
-			$('#terms-of-use').attr('checked', false);
-			$("#creative-commons").attr("disabled", "disabled");
-			$('#creative-commons').attr('checked', false);
-			$("#other-license").attr("disabled", "disabled");
-			$('#other-license').attr('checked', false);			
-			$("#organization-structure").attr("disabled", "disabled");
-			$('#organization-structure').attr('checked', false);
-			$("#projects-and-results").attr("disabled", "disabled");
-			$('#projects-and-results').attr('checked', false);
-			$("#methods-procedures").attr("disabled", "disabled");
-			$('#methods-procedures').attr('checked', false);
-			$("#documentation").attr("disabled", "disabled");
-			$('#documentation').attr('checked', false);
-			$j('#terms-of-use-website').hide();
-			$j('#infield-terms-of-use-website').hide();
-			$j('#creative-commons-website').hide();
-			$j('#infield-creative-commons-website').hide();
-			$j('#other-license-website').hide();
-			$j('#infield-other-license-website').hide();
-			$j('#submit_third').click();
-		}
-		if(id=='rc'){
-			reset_areas();
-			$j('#submit_fourth').click();
-		}
-		if(id=='gr'){
-			$("#decisions-general-assemblies").attr("disabled", "disabled");
-			$('#decisions-general-assemblies').attr('checked', false);
-			$("#decisions-consensus").attr("disabled", "disabled");
-			$('#decisions-consensus').attr('checked', false);
-			$("#representatives-democratically").attr("disabled", "disabled");
-			$('#representatives-democratically').attr('checked', false);			
-			$("#meetings-transparent").attr("disabled", "disabled");
-			$('#meetings-transparent').attr('checked', false);
-			$("#decisions-voting").attr("disabled", "disabled");
-			$('#decisions-voting').attr('checked', false);
-			$j('#submit_fifth').click();						     
-		}
-			
-	}
-}
-
-function imageMapInit(){
-	$j( ".map").mapster({
-        fillColor: 'EA8F5F',
-        fillOpacity: 0.8,
-        isSelectable: false,
-        mapKey: 'step',
-        onClick: function (e) {
-        	onClickImageMap(e);
-        }        
-    });	
-}
-
-function onClickImageMap(e){		                        
-	if (e.key=='#first_step'){        		
-	 	$j('#progress_text').html('0% Complete');
-	 	$j('#progress').css('width','0');
-	}             
-	else if (e.key=='#second_step'){
-		$j('#progress_text').html('20% Complete');
-        $j('#progress').css('width','68px');
-        if($j('#np-checkbox').val()=='S')
-        	$j('label[for*="step2-yes"]').addClass('ui-state-active');
-        else if ($j('#np-checkbox').val()=='N')
-        	$j('label[for*="step2-no"]').addClass('ui-state-active');
-	}
-	else if (e.key=='#third_step'){
-		$j('#progress_text').html('40% Complete');
-        $j('#progress').css('width','136px');
-        if($j('#rp-checkbox').val()=='S')
-        	$j('label[for*="step3-yes"]').addClass('ui-state-active');
-        else if ($j('#rp-checkbox').val()=='N')
-        	$j('label[for*="step3-no"]').addClass('ui-state-active');        
-	}         	
-	else if (e.key=='#fourth_step'){
-		$j('#progress_text').html('60% Complete');
-        $j('#progress').css('width','204px');
-        if($j('#rc-checkbox').val()=='S')
-        	$j('label[for*="step4-yes"]').addClass('ui-state-active');
-        else if ($j('#rc-checkbox').val()=='N')
-        	$j('label[for*="step4-no"]').addClass('ui-state-active');
-	}
-	else if (e.key=='#fifth_step'){
-		$j('#progress_text').html('60% Complete');
-        $j('#progress').css('width','204px');
-        if($j('#gr-checkbox').val()=='S')
-        	$j('label[for*="step5-yes"]').addClass('ui-state-active');
-        else if ($j('#gr-checkbox').val()=='N')
-        	$j('label[for*="step5-no"]').addClass('ui-state-active');
-	}
-	else if (e.key=='#sixth_step'){
-		$j('#progress_text').html('100% Complete');
-        $j('#progress').css('width','339px');
-	}	
-	$j(current_step).slideUp();
-    $j(e.key).slideDown();
-}
-
-function select_cat($id, $id2) {
-  var cat_id = "#mc-form-" + $id;
-  $j(cat_id + ",#mc-form-icon-" + $id).click(
-    function ()
-    {/*
-    //  if ($id != "rc") {
-	$j(cat_id).addClass("mc-form-descbox-selected");
-	$j("#mc-cat-selected-"+ $id).slideDown();
-      //}
-      $j("#mc-form-" + $id2).removeClass("mc-form-descbox-selected");
-      $j("#mc-cat-selected-"+ $id2).slideUp();
-      // $j("#mc-form-more-link-" + $id2).show('slow');
-      $j("#mc-form-less-link-" + $id2).hide();
-      //      $j("#mc-form-" + $id).removeAttr("title");
-      //      $j("#mc-form-" + $id2).attr("title", click_to_select);
-      $j("#mc-form-more-text-" + $id2).slideUp(function() {adjustHeights();});*/
-      if (cat_id == "#mc-form-rc") {
-    	  //$j("#mc-cat-rc-options").slideDown(function() {adjustHeights();});
-    	  mc_rc="0";
-    	  update_logo($id);
-    	  //$j('div.blockMe3').unblock();
-    	  //$('#mc-form-optional-reinforcing').show();
-      } else if (cat_id == "#mc-form-nrc") {
-    	  //$j("#mc-cat-rc-options").slideUp(function() {adjustHeights();});
-    	  reset_areas();
-    	  update_logo($id);
-      } else if (cat_id == "#mc-form-np") {
-    	  //$j('div.blockMe1').unblock();
-    	  //$('#mc-form-optional-non-profit').show();
-      } else if (cat_id == "#mc-form-rp") {
-    	  //$j('div.blockMe2').unblock();    	  
-    	  //$('#mc-form-optional-reproducible').show();
-      } else if (cat_id == "#mc-form-gr") {
-    	  //$j('div.blockMe4').unblock();	  
-    	  //$('#mc-form-optional-grassroots').show();
-      } else {
-    	  update_logo($id);
-    	  //$j("#mc-cat-rc-options").slideUp(function() {adjustHeights();});
-      }
-    });
-};
-
-function hover_cat($id) {
-  var cat_id = "#mc-form-" + $id;
-  $j(cat_id + ",#mc-form-icon-" + $id).hover(
-    function ()
-    {
-      $j(cat_id).addClass("mc-form-descbox-high");
-      //if ($j('#mc-form-less-link-'+$id).is(':hidden'))
-    	//  $j("#mc-form-more-link-"+$id).show();
-    }, function () {
-      $j(cat_id).removeClass("mc-form-descbox-high");
-      //if ($j('#mc-form-less-link-'+$id).is(':hidden'))
-    	 // $j("#mc-form-more-link-"+$id).hide();
-    });
-};
-
-// More links
-
-function click_more_link($id) {
-  $j("#mc-form-more-link-" + $id).click(
-    function (event) {
-      event.stopPropagation();
-      $j(this).hide();
-      /*if ($id == "rc") {
-    	  $j("#mc-cat-rc-options").slideDown();
-      }*/
-      $j("#mc-form-less-link-" + $id).show('slow');
-      $j("#mc-form-more-text-" + $id).show('slow',function() {adjustHeights();});
-
-    });
-};
-
-function click_less_link($id) {
-  $j("#mc-form-less-link-" + $id).click(
-    function (event) {
-      event.stopPropagation();
-      $j(this).hide();
-      /*if ($id == "rc") {
-    	  $j("#mc-cat-rc-options").slideUp();
-      }*/
-      $j("#mc-form-more-link-" + $id).show('slow');
-      $j("#mc-form-more-text-" + $id).slideUp(function() {adjustHeights();});
-      //if ($id == "rc") { $j("#mc-cat-rc-options").slideUp(function() {adjustHeights();});}
-    });
-};
-
-function hover_more_link($id) {
-  $j("#mc-form-more-link-" + $id).hover(
-    function () {
-      $j(this).addClass("mc-form-link-high");
-    }, function () {
-      $j(this).removeClass("mc-form-link-high");
-    });
-};
-
-function hover_less_link($id) {
-  $j("#mc-form-less-link-" + $id).hover(
-    function () {
-      $j(this).addClass("mc-form-link-high");
-    }, function () {
-      $j(this).removeClass("mc-form-link-high");
-    });
-};
-
-function hide_initial($id) {
-  $j("#mc-form-more-link-" + $id).hide();
-  //$j("#mc-form-more-text-" + $id).hide();
-  $j("#mc-form-less-link-" + $id).hide();
-};
-
-function dclick_toggle($id) {
-  $j("#mc-form-" + $id).dblclick(
-    function () {
-      var id_text = "#mc-form-more-text-" + $id;
-      var id_link = "#mc-form-more-link-" + $id;
-      if ($j(id_text).is(':visible')) { $j(id_text).slideUp(); $j(id_link).slideDown(); }
-      else { $j(id_text).slideDown(); $j(id_link).slideUp(); };
-    });};
-
-function reset_areas() {
-  mc_rc="0";
-  $j("#mc-cat-rc-option-box-ec").removeClass("mc-cat-rc-option-box-selected");
-  $j("#mc-cat-rc-option-box-bo").removeClass("mc-cat-rc-option-box-selected");
-  $j("#mc-cat-rc-option-box-to").removeClass("mc-cat-rc-option-box-selected");
-  $j("#mc-cat-rc-option-box-di").removeClass("mc-cat-rc-option-box-selected");
-  $j("#mc-form-icon-rc").attr({src : "/mc/0.1/images/rc60.png"});
-  $j("#mc-cat-selected-rc").slideUp();
-}
-
-function select_area($id) {
-  var cat_id = "#mc-cat-rc-option-box-" + $id;
-  $j(cat_id + ",#mc-cat-rc-option-icon-" + $id).click(
-    function (event) {
-      if($j('#rc-checkbox').val()=='N')
-    	  return;
-      event.stopPropagation();
-      reset_areas();
-      $j("#mc-form-rc").addClass("mc-form-descbox-selected");
-      $j("#mc-cat-selected-rc").slideDown();
-      $j(cat_id).addClass("mc-cat-rc-option-box-selected");
-      $j("#mc-form-icon-rc").attr({src : "/mc/0.1/images/rc" + $id + "60.png"});
-      update_logo($id);
-    });
-};
-
-// Inspired in:
-// http://stackoverflow.com/questions/803688/how-do-i-keep-multiple-divs-the-same-height-using-jquery
-
-function adjustPairHeights($id1, $id2) {
-  var maxHeight = 0;
-  var idcat1 = "#mc-form-category-group-" + $id1;
-  var idcat2 = "#mc-form-category-group-" + $id2;
-  var ids = idcat1 + "," + idcat2;
-  $j(ids).each(function(){
-		 $j(this).height('auto');
-		 if (maxHeight < $j(this).height()) {maxHeight = $j(this).height();}
-               });
-  if($j(idcat1).height() < maxHeight) { $j(idcat1).height(maxHeight); };
-  if($j(idcat2).height() < maxHeight) { $j(idcat2).height(maxHeight); };
-}
-
-function adjustHeights() {
-  adjustPairHeights("aa", "ab");
-  adjustPairHeights("bb", "ba");
-}
-
-function update_logo($cat) {
-  if ($cat == "np" ) mc_np="np-";
-  if ($cat == "nnp") mc_np="fp-";
-  if ($cat == "rp" ) mc_rp="rp-";
-  if ($cat == "nrp") mc_rp="ex-";
-  if ($cat == "gr" ) mc_gr="gr-";
-  if ($cat == "ngr") mc_gr="rs-";
-  if ($cat == "ec" || $cat == "bo" ||
-      $cat == "to" || $cat == "di") mc_rc="rc." + $cat + "-";
-  if ($cat == "nrc") mc_rc="ro-";
-
-  mc_category = "";
-  var icon_url = "";
-
-  if (mc_np != "0" && mc_rp != "0" && mc_rc != "0" && mc_gr != "0") {
-    if (mc_np!="") { mc_category += mc_np; }
-    if (mc_rp!="") { mc_category += mc_rp; }
-    if (mc_rc!="") { mc_category += mc_rc; }
-    if (mc_gr!="") { mc_category += mc_gr; }
-    //  /lang/mc-0-1-np-rp-sc-dc/
-    mc_category = mc_category.replace(/-$/, "");
-    icon_url = "/mc/0.1/images/" + mc_category + "-120x90-0.1.png";
-  }
-  if (icon_url != "") {
-    $j("#mc-form-icon-result").attr({src : icon_url});
-    $j("#mc-form-icon-result").show('fast');
-  } else {
-    $j("#mc-form-icon-result").hide();
-  }
-  checkIfFormReady();
-}
-
-function checkIfFormReady()  {
-  urlIni = $j('#url').val();
-  nameIni = $j('#ininame').val();
-  keywordsIni = $j('#keywords').val();
-  if (mc_category != "" && nameIni.length > 0 && urlIni.length > 0) {
-    $j("#mc-dia-continue-btn").addClass("mc-dia-continue-btn-enabled");
-    $j("#mc-dia-continue-btn").removeClass("mc-dia-continue-btn-disabled");
-    $j("#mc-dia-continue-btn").effect("highlight", {}, 2000);
-  } else {
-    $j("#mc-dia-continue-btn").addClass("mc-dia-continue-btn-disabled");
-    $j("#mc-dia-continue-btn").removeClass("mc-dia-continue-btn-enabled");
-  }
-}
-
-function confInputValidation($id) {
-  $j($id).bind("change keyup", function(event) {
-    checkIfFormReady();
-  });
-}
-
-// adapted from:
-// http://stackoverflow.com/questions/1277070/is-there-an-equivalent-javascript-or-jquery-sleep-function
-function doadjustwithsleep( part ) {
-    if( part == 0 ) {
-        setTimeout( function() { doadjustwithsleep( 1 ); }, 1000 );
-    } else if( part == 1 ) {
-      adjustHeights();
-    }
-}
-
-function conf_link($id) {
-  var nid = "n" + $id;
-  //hover_more_link($id);
-  //hover_more_link(nid);
-  //hover_less_link(nid);
-  //hover_less_link(nid);
-  //hide_initial($id);
-  //hide_initial(nid);
-  //click_more_link($id);
-  //click_more_link(nid);
-  //click_less_link($id);
-  //click_less_link(nid);
-  select_cat($id, nid);
-  select_cat(nid, $id);
-  //hover_cat($id);
-  //hover_cat(nid);
-  // dclick_toggle($id);
-  // dclick_toggle(nid);
-};
-
-function conf_click_continue() {
-  $j("#mc-dia-continue-btn").click(
-    function (event) {
-      event.stopPropagation();
-      if (mc_category != "" && urlIni.length > 0 && nameIni.length > 0) {
-        var currentUrl = window.location.pathname.split('/');
-	var langCode = "";
-	if (currentUrl[1] == 'preview') { langCode = 'en'; }
-	else { langCode = currentUrl[1]; };
-        window.location.href="/" + langCode + "/" + mc_category + "-html/0.1/?ini_name=" + nameIni +
-          "&ini_url=" + urlIni + "&ini_keywords=" + keywordsIni;
-      }
-    });
-};
-
-
-// http://www.richreuter.com/2008/08/01/UsingJQueryToResizeTextBoxesToMaxLength.aspx
-function max_textsize() {
-  $j('input[type=text]').each(function() {
-    var max_length = $j(this).attr('maxlength');
-    var multiplier = (max_length > 10) ? 7.3 : 8;
-    var w = (max_length * multiplier) + "px";
-    $j(this).width(w);
-});
-
-}
-
-// http://remysharp.com/2007/03/19/a-few-more-jquery-plugins-crop-labelover-and-pluck/#labelOver
-$.fn.labelOver = function(overClass) {
-  return this.each(function()
-    {
-      var label = $j(this);
-      var f = label.attr('for');
-      if (f) {
-	var input = $j('#' + f);
-
-	this.hide = function() {
-	  label.css({ textIndent: -10000 });
-	};
-
-	this.show = function() {
-	  if (input.val() == '') label.css({ textIndent: 0 });
-	};
-
-	// handlers
-	input.focus(this.hide);
-	input.blur(this.show);
-	label.addClass(overClass).click(function(){ input.focus(); });
-
-	if (input.val() != '') this.hide();
-      }
-    });
-};
-
-var mc_np = "0";
-var mc_rp = "0";
-var mc_rc = "0";
-var mc_gr = "0";
-var mc_category = "";
-var nameIni = "";
-var urlIni = "";
-var keywordsIni = "";
-// var click_to_select = $j("#mc-form-gr").attr("title"); // store of title value
-
-/*conf_link("np");
-conf_link("rp");
-conf_link("rc");*/
-//conf_link("gr");
-select_area("ec");
-select_area("bo");
-select_area("to");
-select_area("di");
-//confInputValidation("#url");
-//confInputValidation("#ininame");
-
-$j("#mc-dia-continue-btn").addClass("mc-dia-continue-btn-disabled");
-//$j("#mc-cat-rc-options").hide(function() {adjustHeights();});
-$j("#mc-form-icon-result").hide();
-conf_click_continue();
-//$j('#label1').labelOver('over-apply');
-// max_textsize();
-$j(window).load(function () { doadjustwithsleep(0); });
-
-$j("#registered-non-profit").click(function(){		
-  if($j("#registered-non-profit").attr("checked")){
-    $j('#non-profit-website').show();
-    $j('#infield-non-profit-website').show();
-  }  	
-  else{
-    $j('#non-profit-website').hide();
-    $j('#infield-non-profit-website').hide();
-  }  
-});
-
-
-$j("#open-accounting").click(function(){		
-  if($j("#open-accounting").attr("checked")){
-    $j('#open-accounting-website').show();
-    $j('#infield-open-accounting-website').show();
-  }  	
-  else{
-    $j('#open-accounting-website').hide();
-    $j('#infield-open-accounting-website').hide();
-  }  
-});
-
-$j("#accept-donations").click(function(){		
-  if($j("#accept-donations").attr("checked")){
-    $j('#donation-website').show();
-    $j('#infield-donation-website').show();
-  }  	
-  else{
-    $j('#donation-website').hide();
-    $j('#infield-donation-website').hide();
-  }  
-});
-
-$j("#terms-of-use").click(function(){		
-  if($j("#terms-of-use").attr("checked")){
-    $j('#terms-of-use-website').show();
-    $j('#infield-terms-of-use-website').show();    
-  }  	
-  else{
-    $j('#terms-of-use-website').hide();
-    $j('#infield-terms-of-use-website').hide();
-  }  
-});
-
-
-$j("#creative-commons").click(function(){		
-  if($j("#creative-commons").attr("checked")){
-    $j('#creative-commons-website').show();
-    $j('#infield-creative-commons-website').show();
-  }  	
-  else{
-    $j('#creative-commons-website').hide();
-    $j('#infield-creative-commons-website').hide();
-  }  
-});
-
-$j("#other-license").click(function(){		
-  if($j("#other-license").attr("checked")){
-    $j('#other-license-website').show();
-    $j('#infield-other-license-website').show();
-  }  	
-  else{
-    $j('#other-license-website').hide();
-    $j('#infield-other-license-website').hide();
-  }  
-});
-
-
 $j(function(){
 	
 	var current_step='#first_step';
@@ -965,6 +409,559 @@
         	$j(this).trigger('keydown');
         }    	
     });
+    
+    function clickCheckBox(id,answer){
+    	if(answer=='yes'){
+    		if ($j("#mc-form-" + id).is('.mc-form-descbox-selected')) return;
+    		$j('#'+id+'-checkbox').val('S'); 
+    		$j("#mc-form-" + id).addClass("mc-form-descbox-selected");
+    		$j("#mc-cat-selected-"+ id).slideDown();		
+    		if(id=='np'){
+    			$("#registered-non-profit").removeAttr("disabled");
+    			$("#open-accounting").removeAttr("disabled");
+    			$("#accept-donations").removeAttr("disabled");
+    			$j("#mc-form-optional-non-profit").effect("shake", { times:1 }, 200);
+    		}
+    		if(id=='rp'){
+    			$("#terms-of-use").removeAttr("disabled");
+    			$("#creative-commons").removeAttr("disabled");
+    			$("#other-license").removeAttr("disabled");						
+    			$("#organization-structure").removeAttr("disabled");
+    			$("#projects-and-results").removeAttr("disabled");
+    			$("#methods-procedures").removeAttr("disabled");
+    			$("#documentation").removeAttr("disabled");
+    			$j("#mc-form-optional-reproducible").effect("shake", { times:1 }, 200);
+    		}
+    		if(id=='gr'){
+    			$("#decisions-general-assemblies").removeAttr("disabled");
+    			$("#decisions-consensus").removeAttr("disabled");
+    			$("#representatives-democratically").removeAttr("disabled");						
+    			$("#meetings-transparent").removeAttr("disabled");
+    			$("#decisions-voting").removeAttr("disabled");
+    			$j("#mc-form-optional-grassroots").effect("shake", { times:1 }, 200);
+    		}
+    		if(id=='rc')
+    			$j("#mc-form-optional-reinforcing").effect("shake", { times:1 }, 200);
+    	} 		 
+    	else{		
+    		$j('#'+id+'-checkbox').val('N');
+    		$j("#mc-form-" + id).removeClass("mc-form-descbox-selected");
+    		$j("#mc-cat-selected-"+ id).slideUp();
+    		if(id=='np'){
+    			$("#registered-non-profit").attr("disabled", "disabled");
+    			$('#registered-non-profit').attr('checked', false);
+    			$("#open-accounting").attr("disabled", "disabled");
+    			$('#open-accounting').attr('checked', false);
+    			$("#accept-donations").attr("disabled", "disabled");
+    			$('#accept-donations').attr('checked', false);			
+    			$j('#non-profit-website').hide();
+    			$j('#infield-non-profit-website').hide();
+    			$j('#open-accounting-website').hide();
+    			$j('#infield-open-accounting-website').hide();
+    			$j('#donation-website').hide();
+    			$j('#infield-donation-website').hide();
+    			$j('#submit_second').click();
+    		}
+    		if(id=='rp'){
+    			$("#terms-of-use").attr("disabled", "disabled");
+    			$('#terms-of-use').attr('checked', false);
+    			$("#creative-commons").attr("disabled", "disabled");
+    			$('#creative-commons').attr('checked', false);
+    			$("#other-license").attr("disabled", "disabled");
+    			$('#other-license').attr('checked', false);			
+    			$("#organization-structure").attr("disabled", "disabled");
+    			$('#organization-structure').attr('checked', false);
+    			$("#projects-and-results").attr("disabled", "disabled");
+    			$('#projects-and-results').attr('checked', false);
+    			$("#methods-procedures").attr("disabled", "disabled");
+    			$('#methods-procedures').attr('checked', false);
+    			$("#documentation").attr("disabled", "disabled");
+    			$('#documentation').attr('checked', false);
+    			$j('#terms-of-use-website').hide();
+    			$j('#infield-terms-of-use-website').hide();
+    			$j('#creative-commons-website').hide();
+    			$j('#infield-creative-commons-website').hide();
+    			$j('#other-license-website').hide();
+    			$j('#infield-other-license-website').hide();
+    			$j('#submit_third').click();
+    		}
+    		if(id=='rc'){
+    			reset_areas();
+    			$j('#submit_fourth').click();
+    		}
+    		if(id=='gr'){
+    			$("#decisions-general-assemblies").attr("disabled", "disabled");
+    			$('#decisions-general-assemblies').attr('checked', false);
+    			$("#decisions-consensus").attr("disabled", "disabled");
+    			$('#decisions-consensus').attr('checked', false);
+    			$("#representatives-democratically").attr("disabled", "disabled");
+    			$('#representatives-democratically').attr('checked', false);			
+    			$("#meetings-transparent").attr("disabled", "disabled");
+    			$('#meetings-transparent').attr('checked', false);
+    			$("#decisions-voting").attr("disabled", "disabled");
+    			$('#decisions-voting').attr('checked', false);
+    			$j('#submit_fifth').click();						     
+    		}
+    			
+    	}
+    }
+
+    function imageMapInit(){
+    	$j( ".map").mapster({
+            fillColor: 'EA8F5F',
+            fillOpacity: 0.8,
+            isSelectable: false,
+            mapKey: 'step',
+            onClick: function (e) {
+            	onClickImageMap(e);
+            }        
+        });	
+    }
+
+    function onClickImageMap(e){		                        
+    	if (e.key=='#first_step'){        		
+    	 	$j('#progress_text').html('0% Complete');
+    	 	$j('#progress').css('width','0');
+    	}             
+    	else if (e.key=='#second_step'){
+    		$j('#progress_text').html('20% Complete');
+            $j('#progress').css('width','68px');
+            if($j('#np-checkbox').val()=='S')
+            	$j('label[for*="step2-yes"]').addClass('ui-state-active');
+            else if ($j('#np-checkbox').val()=='N')
+            	$j('label[for*="step2-no"]').addClass('ui-state-active');
+    	}
+    	else if (e.key=='#third_step'){
+    		$j('#progress_text').html('40% Complete');
+            $j('#progress').css('width','136px');
+            if($j('#rp-checkbox').val()=='S')
+            	$j('label[for*="step3-yes"]').addClass('ui-state-active');
+            else if ($j('#rp-checkbox').val()=='N')
+            	$j('label[for*="step3-no"]').addClass('ui-state-active');        
+    	}         	
+    	else if (e.key=='#fourth_step'){
+    		$j('#progress_text').html('60% Complete');
+            $j('#progress').css('width','204px');
+            if($j('#rc-checkbox').val()=='S')
+            	$j('label[for*="step4-yes"]').addClass('ui-state-active');
+            else if ($j('#rc-checkbox').val()=='N')
+            	$j('label[for*="step4-no"]').addClass('ui-state-active');
+    	}
+    	else if (e.key=='#fifth_step'){
+    		$j('#progress_text').html('60% Complete');
+            $j('#progress').css('width','204px');
+            if($j('#gr-checkbox').val()=='S')
+            	$j('label[for*="step5-yes"]').addClass('ui-state-active');
+            else if ($j('#gr-checkbox').val()=='N')
+            	$j('label[for*="step5-no"]').addClass('ui-state-active');
+    	}
+    	else if (e.key=='#sixth_step'){
+    		$j('#progress_text').html('100% Complete');
+            $j('#progress').css('width','339px');
+    	}	
+    	$j(current_step).slideUp();
+        $j(e.key).slideDown();
+    }
+
+    function select_cat($id, $id2) {
+      var cat_id = "#mc-form-" + $id;
+      $j(cat_id + ",#mc-form-icon-" + $id).click(
+        function ()
+        {/*
+        //  if ($id != "rc") {
+    	$j(cat_id).addClass("mc-form-descbox-selected");
+    	$j("#mc-cat-selected-"+ $id).slideDown();
+          //}
+          $j("#mc-form-" + $id2).removeClass("mc-form-descbox-selected");
+          $j("#mc-cat-selected-"+ $id2).slideUp();
+          // $j("#mc-form-more-link-" + $id2).show('slow');
+          $j("#mc-form-less-link-" + $id2).hide();
+          //      $j("#mc-form-" + $id).removeAttr("title");
+          //      $j("#mc-form-" + $id2).attr("title", click_to_select);
+          $j("#mc-form-more-text-" + $id2).slideUp(function() {adjustHeights();});*/
+          if (cat_id == "#mc-form-rc") {
+        	  //$j("#mc-cat-rc-options").slideDown(function() {adjustHeights();});
+        	  mc_rc="0";
+        	  update_logo($id);
+        	  //$j('div.blockMe3').unblock();
+        	  //$('#mc-form-optional-reinforcing').show();
+          } else if (cat_id == "#mc-form-nrc") {
+        	  //$j("#mc-cat-rc-options").slideUp(function() {adjustHeights();});
+        	  reset_areas();
+        	  update_logo($id);
+          } else if (cat_id == "#mc-form-np") {
+        	  //$j('div.blockMe1').unblock();
+        	  //$('#mc-form-optional-non-profit').show();
+          } else if (cat_id == "#mc-form-rp") {
+        	  //$j('div.blockMe2').unblock();    	  
+        	  //$('#mc-form-optional-reproducible').show();
+          } else if (cat_id == "#mc-form-gr") {
+        	  //$j('div.blockMe4').unblock();	  
+        	  //$('#mc-form-optional-grassroots').show();
+          } else {
+        	  update_logo($id);
+        	  //$j("#mc-cat-rc-options").slideUp(function() {adjustHeights();});
+          }
+        });
+    };
+
+    function hover_cat($id) {
+      var cat_id = "#mc-form-" + $id;
+      $j(cat_id + ",#mc-form-icon-" + $id).hover(
+        function ()
+        {
+          $j(cat_id).addClass("mc-form-descbox-high");
+          //if ($j('#mc-form-less-link-'+$id).is(':hidden'))
+        	//  $j("#mc-form-more-link-"+$id).show();
+        }, function () {
+          $j(cat_id).removeClass("mc-form-descbox-high");
+          //if ($j('#mc-form-less-link-'+$id).is(':hidden'))
+        	 // $j("#mc-form-more-link-"+$id).hide();
+        });
+    };
+
+    // More links
+
+    function click_more_link($id) {
+      $j("#mc-form-more-link-" + $id).click(
+        function (event) {
+          event.stopPropagation();
+          $j(this).hide();
+          /*if ($id == "rc") {
+        	  $j("#mc-cat-rc-options").slideDown();
+          }*/
+          $j("#mc-form-less-link-" + $id).show('slow');
+          $j("#mc-form-more-text-" + $id).show('slow',function() {adjustHeights();});
+
+        });
+    };
+
+    function click_less_link($id) {
+      $j("#mc-form-less-link-" + $id).click(
+        function (event) {
+          event.stopPropagation();
+          $j(this).hide();
+          /*if ($id == "rc") {
+        	  $j("#mc-cat-rc-options").slideUp();
+          }*/
+          $j("#mc-form-more-link-" + $id).show('slow');
+          $j("#mc-form-more-text-" + $id).slideUp(function() {adjustHeights();});
+          //if ($id == "rc") { $j("#mc-cat-rc-options").slideUp(function() {adjustHeights();});}
+        });
+    };
+
+    function hover_more_link($id) {
+      $j("#mc-form-more-link-" + $id).hover(
+        function () {
+          $j(this).addClass("mc-form-link-high");
+        }, function () {
+          $j(this).removeClass("mc-form-link-high");
+        });
+    };
+
+    function hover_less_link($id) {
+      $j("#mc-form-less-link-" + $id).hover(
+        function () {
+          $j(this).addClass("mc-form-link-high");
+        }, function () {
+          $j(this).removeClass("mc-form-link-high");
+        });
+    };
+
+    function hide_initial($id) {
+      $j("#mc-form-more-link-" + $id).hide();
+      //$j("#mc-form-more-text-" + $id).hide();
+      $j("#mc-form-less-link-" + $id).hide();
+    };
+
+    function dclick_toggle($id) {
+      $j("#mc-form-" + $id).dblclick(
+        function () {
+          var id_text = "#mc-form-more-text-" + $id;
+          var id_link = "#mc-form-more-link-" + $id;
+          if ($j(id_text).is(':visible')) { $j(id_text).slideUp(); $j(id_link).slideDown(); }
+          else { $j(id_text).slideDown(); $j(id_link).slideUp(); };
+        });};
+
+    function reset_areas() {
+      mc_rc="0";
+      $j("#mc-cat-rc-option-box-ec").removeClass("mc-cat-rc-option-box-selected");
+      $j("#mc-cat-rc-option-box-bo").removeClass("mc-cat-rc-option-box-selected");
+      $j("#mc-cat-rc-option-box-to").removeClass("mc-cat-rc-option-box-selected");
+      $j("#mc-cat-rc-option-box-di").removeClass("mc-cat-rc-option-box-selected");
+      $j("#mc-form-icon-rc").attr({src : "/mc/0.1/images/rc60.png"});
+      $j("#mc-cat-selected-rc").slideUp();
+    }
+
+    function select_area($id) {
+      var cat_id = "#mc-cat-rc-option-box-" + $id;
+      $j(cat_id + ",#mc-cat-rc-option-icon-" + $id).click(
+        function (event) {
+          if($j('#rc-checkbox').val()=='N')
+        	  return;
+          event.stopPropagation();
+          reset_areas();
+          $j("#mc-form-rc").addClass("mc-form-descbox-selected");
+          $j("#mc-cat-selected-rc").slideDown();
+          $j(cat_id).addClass("mc-cat-rc-option-box-selected");
+          $j("#mc-form-icon-rc").attr({src : "/mc/0.1/images/rc" + $id + "60.png"});
+          update_logo($id);
+        });
+    };
+
+    // Inspired in:
+    // http://stackoverflow.com/questions/803688/how-do-i-keep-multiple-divs-the-same-height-using-jquery
+
+    function adjustPairHeights($id1, $id2) {
+      var maxHeight = 0;
+      var idcat1 = "#mc-form-category-group-" + $id1;
+      var idcat2 = "#mc-form-category-group-" + $id2;
+      var ids = idcat1 + "," + idcat2;
+      $j(ids).each(function(){
+    		 $j(this).height('auto');
+    		 if (maxHeight < $j(this).height()) {maxHeight = $j(this).height();}
+                   });
+      if($j(idcat1).height() < maxHeight) { $j(idcat1).height(maxHeight); };
+      if($j(idcat2).height() < maxHeight) { $j(idcat2).height(maxHeight); };
+    }
+
+    function adjustHeights() {
+      adjustPairHeights("aa", "ab");
+      adjustPairHeights("bb", "ba");
+    }
+
+    function update_logo($cat) {
+      if ($cat == "np" ) mc_np="np-";
+      if ($cat == "nnp") mc_np="fp-";
+      if ($cat == "rp" ) mc_rp="rp-";
+      if ($cat == "nrp") mc_rp="ex-";
+      if ($cat == "gr" ) mc_gr="gr-";
+      if ($cat == "ngr") mc_gr="rs-";
+      if ($cat == "ec" || $cat == "bo" ||
+          $cat == "to" || $cat == "di") mc_rc="rc." + $cat + "-";
+      if ($cat == "nrc") mc_rc="ro-";
+
+      mc_category = "";
+      var icon_url = "";
+
+      if (mc_np != "0" && mc_rp != "0" && mc_rc != "0" && mc_gr != "0") {
+        if (mc_np!="") { mc_category += mc_np; }
+        if (mc_rp!="") { mc_category += mc_rp; }
+        if (mc_rc!="") { mc_category += mc_rc; }
+        if (mc_gr!="") { mc_category += mc_gr; }
+        //  /lang/mc-0-1-np-rp-sc-dc/
+        mc_category = mc_category.replace(/-$/, "");
+        icon_url = "/mc/0.1/images/" + mc_category + "-120x90-0.1.png";
+      }
+      if (icon_url != "") {
+        $j("#mc-form-icon-result").attr({src : icon_url});
+        $j("#mc-form-icon-result").show('fast');
+      } else {
+        $j("#mc-form-icon-result").hide();
+      }
+      checkIfFormReady();
+    }
+
+    function checkIfFormReady()  {
+      urlIni = $j('#url').val();
+      nameIni = $j('#ininame').val();
+      keywordsIni = $j('#keywords').val();
+      if (mc_category != "" && nameIni.length > 0 && urlIni.length > 0) {
+        $j("#mc-dia-continue-btn").addClass("mc-dia-continue-btn-enabled");
+        $j("#mc-dia-continue-btn").removeClass("mc-dia-continue-btn-disabled");
+        $j("#mc-dia-continue-btn").effect("highlight", {}, 2000);
+      } else {
+        $j("#mc-dia-continue-btn").addClass("mc-dia-continue-btn-disabled");
+        $j("#mc-dia-continue-btn").removeClass("mc-dia-continue-btn-enabled");
+      }
+    }
+
+    function confInputValidation($id) {
+      $j($id).bind("change keyup", function(event) {
+        checkIfFormReady();
+      });
+    }
+
+    // adapted from:
+    // http://stackoverflow.com/questions/1277070/is-there-an-equivalent-javascript-or-jquery-sleep-function
+    function doadjustwithsleep( part ) {
+        if( part == 0 ) {
+            setTimeout( function() { doadjustwithsleep( 1 ); }, 1000 );
+        } else if( part == 1 ) {
+          adjustHeights();
+        }
+    }
+
+    function conf_link($id) {
+      var nid = "n" + $id;
+      //hover_more_link($id);
+      //hover_more_link(nid);
+      //hover_less_link(nid);
+      //hover_less_link(nid);
+      //hide_initial($id);
+      //hide_initial(nid);
+      //click_more_link($id);
+      //click_more_link(nid);
+      //click_less_link($id);
+      //click_less_link(nid);
+      select_cat($id, nid);
+      select_cat(nid, $id);
+      //hover_cat($id);
+      //hover_cat(nid);
+      // dclick_toggle($id);
+      // dclick_toggle(nid);
+    };
+
+    function conf_click_continue() {
+      $j("#mc-dia-continue-btn").click(
+        function (event) {
+          event.stopPropagation();
+          if (mc_category != "" && urlIni.length > 0 && nameIni.length > 0) {
+            var currentUrl = window.location.pathname.split('/');
+    	var langCode = "";
+    	if (currentUrl[1] == 'preview') { langCode = 'en'; }
+    	else { langCode = currentUrl[1]; };
+            window.location.href="/" + langCode + "/" + mc_category + "-html/0.1/?ini_name=" + nameIni +
+              "&ini_url=" + urlIni + "&ini_keywords=" + keywordsIni;
+          }
+        });
+    };
+
+
+    // http://www.richreuter.com/2008/08/01/UsingJQueryToResizeTextBoxesToMaxLength.aspx
+    function max_textsize() {
+      $j('input[type=text]').each(function() {
+        var max_length = $j(this).attr('maxlength');
+        var multiplier = (max_length > 10) ? 7.3 : 8;
+        var w = (max_length * multiplier) + "px";
+        $j(this).width(w);
+    });
+
+    }
+
+    // http://remysharp.com/2007/03/19/a-few-more-jquery-plugins-crop-labelover-and-pluck/#labelOver
+    $.fn.labelOver = function(overClass) {
+      return this.each(function()
+        {
+          var label = $j(this);
+          var f = label.attr('for');
+          if (f) {
+    	var input = $j('#' + f);
+
+    	this.hide = function() {
+    	  label.css({ textIndent: -10000 });
+    	};
+
+    	this.show = function() {
+    	  if (input.val() == '') label.css({ textIndent: 0 });
+    	};
+
+    	// handlers
+    	input.focus(this.hide);
+    	input.blur(this.show);
+    	label.addClass(overClass).click(function(){ input.focus(); });
+
+    	if (input.val() != '') this.hide();
+          }
+        });
+    };
+
+    var mc_np = "0";
+    var mc_rp = "0";
+    var mc_rc = "0";
+    var mc_gr = "0";
+    var mc_category = "";
+    var nameIni = "";
+    var urlIni = "";
+    var keywordsIni = "";
+    // var click_to_select = $j("#mc-form-gr").attr("title"); // store of title value
+
+    /*conf_link("np");
+    conf_link("rp");
+    conf_link("rc");*/
+    //conf_link("gr");
+    select_area("ec");
+    select_area("bo");
+    select_area("to");
+    select_area("di");
+    //confInputValidation("#url");
+    //confInputValidation("#ininame");
+
+    $j("#mc-dia-continue-btn").addClass("mc-dia-continue-btn-disabled");
+    //$j("#mc-cat-rc-options").hide(function() {adjustHeights();});
+    $j("#mc-form-icon-result").hide();
+    conf_click_continue();
+    //$j('#label1').labelOver('over-apply');
+    // max_textsize();
+    $j(window).load(function () { doadjustwithsleep(0); });
+
+    $j("#registered-non-profit").click(function(){		
+      if($j("#registered-non-profit").attr("checked")){
+        $j('#non-profit-website').show();
+        $j('#infield-non-profit-website').show();
+      }  	
+      else{
+        $j('#non-profit-website').hide();
+        $j('#infield-non-profit-website').hide();
+      }  
+    });
+
+
+    $j("#open-accounting").click(function(){		
+      if($j("#open-accounting").attr("checked")){
+        $j('#open-accounting-website').show();
+        $j('#infield-open-accounting-website').show();
+      }  	
+      else{
+        $j('#open-accounting-website').hide();
+        $j('#infield-open-accounting-website').hide();
+      }  
+    });
+
+    $j("#accept-donations").click(function(){		
+      if($j("#accept-donations").attr("checked")){
+        $j('#donation-website').show();
+        $j('#infield-donation-website').show();
+      }  	
+      else{
+        $j('#donation-website').hide();
+        $j('#infield-donation-website').hide();
+      }  
+    });
+
+    $j("#terms-of-use").click(function(){		
+      if($j("#terms-of-use").attr("checked")){
+        $j('#terms-of-use-website').show();
+        $j('#infield-terms-of-use-website').show();    
+      }  	
+      else{
+        $j('#terms-of-use-website').hide();
+        $j('#infield-terms-of-use-website').hide();
+      }  
+    });
+
+
+    $j("#creative-commons").click(function(){		
+      if($j("#creative-commons").attr("checked")){
+        $j('#creative-commons-website').show();
+        $j('#infield-creative-commons-website').show();
+      }  	
+      else{
+        $j('#creative-commons-website').hide();
+        $j('#infield-creative-commons-website').hide();
+      }  
+    });
+
+    $j("#other-license").click(function(){		
+      if($j("#other-license").attr("checked")){
+        $j('#other-license-website').show();
+        $j('#infield-other-license-website').show();
+      }  	
+      else{
+        $j('#other-license-website').hide();
+        $j('#infield-other-license-website').hide();
+      }  
+    });
         
 });
 




More information about the Movecommons-commits mailing list