7f39a66dca865c28f279e2b43211772e53bfa722 tdreszer Fri Sep 23 23:23:32 2011 -0700 Tightened a few more screws on subCfg diff --git src/hg/js/hui.js src/hg/js/hui.js index edaca7f..26347e9 100644 --- src/hg/js/hui.js +++ src/hg/js/hui.js @@ -318,31 +318,31 @@ if(subCB.checked) shadowState = 1; //if(subCB.disabled) if (isFauxDisabled(subCB,true)) shadowState -= 2; var fourWay = normed($("input.fourWay#boolshad_-"+subCB.id)); if (fourWay == undefined && subCB.name != undefined) { fourWay = normed($("input.fourWay[name='boolshad\\."+subCB.name+"']")); if (fourWay == undefined) fourWay = normed($("#"+subCB.name+"_4way")); // FIXME: obsolete as soon as subCfg is working } if (fourWay == undefined) { warn("DEBUG: Failed to find fourWay shadow for '#"+subCB.id+"' ["+subCB.name+"]"); return; } - if ($(fourWay).val() != shadowState) { + if ($(fourWay).val() != shadowState.toString()) { $(fourWay).val(shadowState); if (typeof(scm) !== "undefined") { scm.enableCfg(subCB,null,(shadowState == 1)); $(subCB).change(); // 'change' event will update "scm" } } } function matChkBoxNormalize(matCB) { // Makes sure matCBs are in one of 3 states (checked,unchecked,indeterminate) based on matching set of subCBs var classList = $( matCB ).attr("class").split(" "); var isABC = (aryFind(classList,"abc") != -1); if(isABC) alert("ASSERT: matChkBoxNormalize() called for dim ABC!"); @@ -655,62 +655,103 @@ $( trs ).each( function (i) { if( this.id == 'tr_cfg_'+name && this.style.display == 'none') { $( this ).css('display',''); $("input[name$='."+name+".showCfg']").val("on"); } else if( this.style.display == '') { $( this ).css('display','none'); } }); // Close the cfg controls in the subtracks $("table.subtracks").each( function (i) { subtrackCfgHideAll(this);} ); return true; } +function hideOrShowSubtrack(obj) +{ +// This can show/hide a tablerow that contains a specific object +// Containing <tr>'s must be id'd with 'tr_' + obj.id +// Also, this relies upon the "displaySubtracks" radio button control + var tr = normed($(obj).parents('tr#tr_'+obj.id)); + if (tr != undefined) { + if(!obj.checked || isFauxDisabled(obj,true)) { + var radio = $('input.allOrOnly'); + for (var ix=0;ix<radio.length;ix++) { + if(radio[ix].checked && radio[ix].value == "selected") { + $(tr).hide(); + return; + } + } + } + $(tr).show(); + } +} + +function showSubTrackCheckBoxes(onlySelected) +{ +// If a Subtrack configuration page has show "only selected subtracks" option, +// This can show/hide tablerows that contain the checkboxes +// Containing <tr>'s must be id'd with 'tr_' + the checkbox id, +// while checkbox id must have 'cb_' prefix (ie: 'tr_cb_checkThis' & 'cb_checkThis') + var trs = $('table.subtracks').children('tbody').children('tr'); + if(!onlySelected) + $(trs).show(); + else { + $(trs).each(function (ix) { + var subCB = normed($(this).find('input.subCB')); + if (subCB != undefined) { + if (subCB.checked && isFauxDisabled(subCB,true) == false) + $(this).show(); + else + $(this).hide(); + } + //else + // warn('DEBUG: subtrack table row '+ix+' without subCB?'); + }); + } +} function showOrHideSelectedSubtracks(inp) { // Show or Hide subtracks based upon radio toggle var showHide; if(arguments.length > 0) showHide=inp; else { var onlySelected = $("input.allOrOnly'"); if(onlySelected.length > 0) showHide = onlySelected[0].checked; else return; } showSubTrackCheckBoxes(showHide); var tbody = $("tbody.sortable") $(tbody).each(function (i) { sortedTableAlternateColors(this); }); } ///// Following functions called on page load function matInitializeMatrix() { // Called at Onload to coordinate all subtracks with the matrix of check boxes //var start = startTiming(); -jQuery('body').css('cursor', 'wait'); - if (document.getElementsByTagName) { - matSubCBsSelected(); - showOrHideSelectedSubtracks(); - } -jQuery('body').css('cursor', ''); + + matSubCBsSelected(); // counts + //showOrHideSelectedSubtracks(); // Don't need this because hui.c is doing it + //showTiming(start,"matInitializeMatrix()"); } function multiSelectLoad(div,sizeWhenOpen) { //var div = $(obj);//.parent("div.multiSelectContainer"); var sel = $(div).children("select:first"); if(div != undefined && sel != undefined && sizeWhenOpen <= $(sel).length) { $(div).css('width', ( $(sel).clientWidth ) +"px"); $(div).css('overflow',"hidden"); $(div).css('borderRight',"2px inset"); } $(sel).show(); } @@ -1063,69 +1104,67 @@ }); } } function tableSortAtButtonPress(anchor,tagId) { // Special ONLY for hgTrackUi sorting. Others use utils.js::tableSortOnButtonPress() var table = $( anchor ).parents("table.sortable"); if (table) { subtrackCfgHideAll(table); waitOnFunction( _tableSortOnButtonPressEncapsulated, anchor, tagId); } return false; // called by link so return false means don't try to go anywhere } function fauxDisable(obj,disable,title) -{ -// Makes an obj appear diabled, but it isn't +{// Makes an obj appear disabled, but it isn't // span.disabled & input.disabled is opacity 0.5 // div.disabled is border-color: gray; color: gray; if ($(obj).hasClass('subCB') == false || typeof(scm) !== "undefined") { if(disable) { if ($.browser.msie) $(obj).css('opacity', '0.5'); $(obj).addClass('disabled'); } else { if ($.browser.msie) $(obj).css('opacity', '1'); // For some reason IE<9 accepts direct change but isn't happy with simply adding class! $(obj).removeClass('disabled'); } } else { obj.disabled = disable; } if (arguments.length > 2) $(obj).attr("title",title); } function isFauxDisabled(obj,orReallyDisabled) -{ -// Is object [faux] disabled? +{// Is object [faux] disabled? if (orReallyDisabled && obj.disabled) return true; return ($(obj).hasClass('disabled')); } - // The following js depends upon the jQuery library $(document).ready(function() { + if (normed($('table.subtracks')) != undefined) { + matInitializeMatrix(); + // If divs with class 'subCfg' then initialize the subtrack cfg code // NOTE: must be before any ddcl setup - if (typeof(scm) !== "undefined") { - var divs = $("div.subCfg"); - if (divs != undefined && divs.length > 0) { + if (typeof(scm) !== "undefined" && normed($("div.subCfg")) != undefined) { scm.initialize(); } } // Initialize sortable tables $('table.sortable').each(function (ix) { sortTableInitialize(this,true,true); }); // Register tables with drag and drop $("table.tableWithDragAndDrop").each(function (ix) { tableDragAndDropRegister(this); }); // Put navigation links in top corner