7f39a66dca865c28f279e2b43211772e53bfa722 tdreszer Fri Sep 23 23:23:32 2011 -0700 Tightened a few more screws on subCfg diff --git src/hg/js/subCfg.js src/hg/js/subCfg.js index 4a619e6..e071ea7 100644 --- src/hg/js/subCfg.js +++ src/hg/js/subCfg.js @@ -20,69 +20,67 @@ // unnamed: control that has not been updated by the user. Will not be sent to cart. // TODO: // 1) SOLVED: Radio buttons work BUT they require name to keep unified set, so rely upon 'changed' class to detect changes. // 2) SOLVED: checkboxes: working with name = boolshad.{name} FIXME: multishad? // 3) SOLVED: filterBy,filterComp working: they rely upon id, and id with '.' screwed it all up. So replaced '.' with '_-' // 4) SOLVED: subCfg not matching parent: solved. // 5) SOLVED: OpenChromSynth: subtrack filterby needs to be updated by composite filterBy. // 6) SOLVED: check subtrack to enable/disable fauxVis and wrench // 7) SOLVED: matCB should effect subCb including enable/disable fauxVis and wrench // 8) SOLVED: composite/view vis should effect subVis and enable/disable fauxVis and wrench // 9) SOLVED: inside out: changing subtrack vis should affect subCB and matCB // 10) SOLVED: Loosing checked tracks!!! Setting vis clears checkboxes? // 11) TESTED: hui.c #ifdef SUBTRACK_CFG should switch full functionality on/off // 12) SOLVED: Make "disabled" subCB clickable! +// 13) SOLVED: PROBLEM is fauxDisabled. SOLUTION is convert fauxDisabled to true disabled on form.submit() // -) When parent vis makes subs hidden, should they go to unchecked? No, disabled! // -) Should user be able to click on disabled vis to check the CB? No, not important. // -) Make vis changes "reshape" composite! NOTE: Do we want to do this??? I am against this as too disruptive. We may want to end reshaping in CGIs as well! // -) Non-configurable will need to show/change vis independently! (separate vis control but no wrench) // - Verify all composites work (conservation and SNPs are likely failures) // - Decide on a name (scm, subCfg, ? ) and then make a module file like ddcl.js. // - Remove debug code when ready // NOTE: // Current implementation relies upon '.' delimiter in name and no '_-' in name. Nothing breaks rule yet... var scm = { // subtrack config module. //mySelf: null, // There is no need for a "mySelf" unless this object is being instantiated. // There is one instance and these vars are page wide compositeId: undefined, visIndependent: false, viewIds: [], markChange: function (obj) { // Marks a control as having been changed by the user. Naming will send value to cart. + $(obj).addClass('changed'); if(obj.type.indexOf("radio") == 0) // radios must keep their names! return; var oldName = obj.id.replace(/\_\-/g,'.'); // sanitized id replaces '.' with '_-' $(obj).attr('name',oldName); // checkboxes have hidden boolshads which should be marked when unchecked if(obj.type.indexOf("checkbox") == 0) { var boolshad = normed($('input#boolshad_-' + obj.id)); if (boolshad != undefined) { - //if(obj.checked == false) { var oldName = boolshad.id.replace(/\_\-/g,'.'); // sanitized id replaces '.' with '_-' $(obj).addClass('changed'); $(boolshad).attr('name',oldName); - //} - //else - // scm.clearChange(boolshad); } } }, clearChange: function (obj) { // Mark as unchanged $(obj).removeClass('changed'); if(obj.type.indexOf("radio") == 0) // radios must keep their names! return; $(obj).removeAttr('name'); // checkboxes have hidden boolshads which should be cleared in tandem if(obj.type.indexOf("checkbox") == 0) { @@ -405,31 +403,34 @@ } else { var classList = $( parentObj ).attr("class").split(" "); classList = aryRemove(classList,["viewDD","normalText","changed"]); if (classList.length != 1) { warn("Unexpected view vis class list:"+classList); return []; } return $(subVis).filter('.' + classList[0]); } }, checkOneSubtrack: function (subCb,check,enable) { // Handle a single check of a single subCb // called by changing subVis to/from 'hide' subCb.checked = check; - subCb.dsabled = enable; + if (enable) + fauxDisable(subCb,false,""); + else + fauxDisable(subCb,true, "View is hidden"); scm.markChange(subCb); matSubCBsetShadow(subCb); hideOrShowSubtrack(subCb); scm.enableCfg(subCb,undefined,check); }, propagateSetting: function (parentObj) { // propagate composite/view level setting to subtrack children var children = scm.childrenFind(parentObj); if(parentObj.type.indexOf("checkbox") == 0) { var parentChecked = parentObj.checked; $(children).each(function (i) { // Note checkbox and boolshad are children. if (this.type != 'hidden') this.checked = parentObj.checked; @@ -936,18 +937,23 @@ // DEBUG ------------- if (this.id != undefined && this.id.length > 0 && $(this).hasClass('filterBy') == false && $(this).hasClass('filterComp') == false) warn('DEBUG: Not expected control with name ['+this.name + '], and id #'+this.id); // DEBUG ------------- scm.unnameIt(this,true); $(this).bind('change',function (e) { scm.markChange(this); scm.propagateSetting(this); }); }); } + + // Because of fauxDisabled subCBs, it is necessary to truly disable them before submitting. + $("FORM").submit(function (i) { + $('input.subCB.changed.disabled').attr('disabled',true); + }); } };