src/hg/js/hui.js 1.21
1.21 2009/03/09 18:37:42 tdreszer
Stdize view vis select name. Support for disabling view cfgs on hide NOT TURNED ON. Converted more code to jQuery.
Index: src/hg/js/hui.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/hui.js,v
retrieving revision 1.20
retrieving revision 1.21
diff -b -B -U 4 -r1.20 -r1.21
--- src/hg/js/hui.js 26 Feb 2009 03:56:15 -0000 1.20
+++ src/hg/js/hui.js 9 Mar 2009 18:37:42 -0000 1.21
@@ -30,23 +30,27 @@
//if(viewDDtoMatCB)
// $("input.matrixCB").filter(":checked").each( function (i) { matChkBoxNormalize(this); } );
}
matEnableSubtrackCheckBoxes(false,view);
+ hideConfigControls(view);
+ //enableViewCfgLink(false,view); // Could "disable" view cfg when hidden!
} else {
+ //enableViewCfgLink(true,view); // Would need to reeanble view cfg when visible
+
// Make main display dropdown show full if currently hide
- var trackName = obj.name.substring(0,obj.name.indexOf("_dd_"))
- var displayDD = document.getElementsByName(trackName);
- if(displayDD.length >= 1 && displayDD[0].selectedIndex < (displayDD[0].options.length - 1)) { // Composite vis display not already full
- var list = inputArrayThatMatches('select','name',trackName+"_dd_",'');
+ var trackName = obj.name.substring(0,obj.name.indexOf(".")); // {trackName}.{view}.vis
+ var compositeDD = $("select[name='"+trackName+"']");
+ if($(compositeDD).attr('selectedIndex') < ($(compositeDD).children('option').length - 1)) { // Composite vis display not already full
+ var list = $(".viewDd");
var maxVis = obj.selectedIndex;
- for (var ix=0;ix<list.length;ix++) {
- if(maxVis < list[ix].selectedIndex)
- maxVis = list[ix].selectedIndex;
- }
- if(displayDD[0].options.length - 1 < maxVis)
- displayDD[0].selectedIndex = displayDD[0].options.length - 1;
- else if(displayDD[0].selectedIndex < maxVis)
- displayDD[0].selectedIndex = maxVis;
+ $(list).each(function (i) {
+ if( maxVis < this.selectedIndex)
+ maxVis = this.selectedIndex;
+ });
+ if($(compositeDD).children('option').length - 1 < maxVis)
+ $(compositeDD).attr('selectedIndex') = $(compositeDD).options.length - 1;
+ else if($(compositeDD).attr('selectedIndex') < maxVis)
+ $(compositeDD).attr('selectedIndex',maxVis);
}
// if matrix used then: essentially reclick all 'checked' matrix checkboxes
if(viewDDtoSubCB) {
var CBs = $("input.matrixCB").filter(":checked");
@@ -81,8 +85,26 @@
matEnableSubtrackCheckBoxes(true,view);
}
}
+// Obsolete because matCBwithViewDD is not true
+//function getViewNamesSelected(on)
+//{
+//// Returns an array of all views that are on or off (hide)
+//// views are "select" drop downs containing 'hide','dense',...
+//// To be clear, an array of strings with the view name is returned.
+// var views = new Array();
+// var list = $(".viewDd");
+// if(on)
+// list = $(list).filter("[selectedIndex!=0]")
+// else
+// list = $(list).filter("[selectedIndex=0]")
+// $(list).each( function (i) {
+// views.push(this.name.substring(this.name.indexOf('.') + 1, this.name.lastIndexOf('.')));
+// });
+// return( views );
+//}
+
function matSetMatrixCheckBoxes(state)
{
// Set all Matrix checkboxes to state. If additional arguments are passed in, the list of CBs will be narrowed by the classes
var CBs;
@@ -104,9 +126,9 @@
CBs = CBs.filter("."+arguments[vIx]); // Successively limit list by additional classes.
}
//if(matCBwithViewDD) {
// if(state) { // further filter by view
- // views = getViewsSelected("_dd_",false); // get views (strings) that are off
+ // views = getViewNamesSelected(false); // get views (strings) that are off
// for(var vIx=0;vIx<views.length;vIx++) {
// CBs = CBs.not("."+views[vIx]); // Successively limit list by additional classes.
// }
// }
@@ -124,9 +146,9 @@
CBs = CBs.filter("."+arguments[vIx]); // Successively limit list by additional classes.
}
//if(matCBwithViewDD) {
// if(state) { // further filter by view
- // views = getViewsSelected("_dd_",false); // get views (strings) that are off
+ // views = getViewNamesSelected(false); // get views (strings) that are off
// for(var vIx=0;vIx<views.length;vIx++) {
// CBs = CBs.filter(":not(."+views[vIx]+")"); // Successively limit list by additional classes.
// }
// }
@@ -144,9 +166,9 @@
CBs = CBs.filter("."+arguments[vIx]); // Successively limit list by additional classes.
}
//if(matCBwithViewDD) {
// if(state) { // further filter by view
- // views = getViewsSelected("_dd_",false); // get views (strings) that are off
+ // views = getViewNamesSelected(false); // get views (strings) that are off
// for(var vIx=0;vIx<views.length;vIx++) {
// CBs = CBs.filter(":not(."+views[vIx]+")"); // Successively limit list by additional classes.
// }
// }
@@ -192,20 +214,19 @@
{
// After composite level cfg settings written to HTML it is necessary to go back and
// make sure that each time they change, any matching subtrack level cfg setting are changed.
var count=0;
- var list = inputArrayThatMatches("","name",prefix,"");
+ var list = $("input[name^='"+prefix+"']").not("[name$='.vis']");
+
for (var ix=0;ix<list.length;ix++) {
list[ix].onchange = function(){compositeCfgUpdateSubtrackCfgs(this);};
count++;
}
- var list = document.getElementsByTagName('select');
+ var list = $("select[name^='"+prefix+"']").not("[name$='.vis']");
for (var ix=0;ix<list.length;ix++) {
- if(list[ix].name.indexOf(prefix) == 0) {
list[ix].onchange = function(){compositeCfgUpdateSubtrackCfgs(this);};
count++;
}
- }
}
function subtrackCfgHideAll(table)
@@ -237,12 +258,42 @@
}
return true;
}
+function enableViewCfgLink(enable,view)
+{
+// Enables or disables a single configuration link.
+ var link = $('#a_cfg_'+view);
+ if(enable)
+ $(link).attr('href','#'+$(link).attr('id'));
+ else
+ $(link).removeAttr('href');
+}
+
+function enableAllViewCfgLinks()
+{
+ $( ".viewDd").each( function (i) {
+ var view = this.name.substring(this.name.indexOf(".") + 1,lastIndexOf(".vis"));
+ enableViewCfgLink((this.selectedIndex > 0),view);
+ });
+}
+
+function hideConfigControls(view)
+{
+// Will hide the configuration controls associated with one name
+ $("input[name$='"+view+".showCfg']").val("off"); // Set cart variable
+ $("tr[id^='tr_cfg_"+view+"']").css('display','none'); // Hide controls
+}
+
function showConfigControls(name)
{
-// Will show configuration controls
+// Will show configuration controls for name= {tableName}.{view}
// Config controls not matching name will be hidden
+ //if($( ".viewDd[name$='" + name + ".vis']").attr("selectedIndex") == 0) {
+ // $("input[name$='.showCfg']").val("off");
+ // $("tr[id^='tr_cfg_']").css('display','none'); // hide cfg controls when view is hide
+ // return true;
+ //}
var trs = $("tr[id^='tr_cfg_']")
$("input[name$='.showCfg']").val("off"); // Turn all off
$( trs ).each( function (i) {
if( this.id == 'tr_cfg_'+name && this.style.display == 'none') {
@@ -670,11 +721,12 @@
// check/unchecks matrix checkboxes based upon subtrack checkboxes
$("input.matrixCB").each( function (i) { matChkBoxNormalize(this); } );
// For each viewDD not selected, disable associated subtracks
- $('select.viewDd').not('[@selectedIndex]').each( function (i) {
- var viewClass = this.name.substring(this.name.lastIndexOf("_") + 1);
- matEnableSubtrackCheckBoxes(false,viewClass); } );
+ $('select.viewDd').not("[selectedIndex]").each( function (i) {
+ var viewClass = this.name.substring(this.name.indexOf(".") + 1,this.name.lastIndexOf("."));
+ matEnableSubtrackCheckBoxes(false,viewClass);
+ });
}
function showOrHideSelectedSubtracks(inp)
{
@@ -711,8 +763,9 @@
// Called at Onload to coordinate all subtracks with the matrix of check boxes
if (document.getElementsByTagName) {
matChkBoxesNormalized(); // Note that this needs to be done when the page is first displayed. But ideally only on clean cart!
showOrHideSelectedSubtracks();
+ //enableAllViewCfgLinks();
}
else if(debugLevel>2) {
alert("matInitializeMatrix is unimplemented for this browser)");
}