a21b8d5bb7d8ffa63069c412ad71fbaeeb9f4e55 angie Wed Jun 25 11:00:52 2014 -0700 Fixing bug found by Jonathan: with clean cart, when showing contents offilter section for Regulatory Elements, the multiselects didn't appear. Turns out that the 'force' argument of ddcl.reinit actually makes it do nothing! To avoid disrupting anything else, for now I'll just forgo force. refs #11461 diff --git src/hg/js/ddcl.js src/hg/js/ddcl.js index 5d93020..2e57ebb 100644 --- src/hg/js/ddcl.js +++ src/hg/js/ddcl.js @@ -1,554 +1,555 @@ // The "ddcl" object that contains all the DDCL extension/support code. // DDCL: drop-down checkbox-list wrapper code to ui.dropdownchecklist.js jQuery widget. // The reason for extension/support code beyond the jquery widget is that // We have changed some widget functionality: // - Closed control show all currently selected options in multiple lines with CSS // - Open control can gray out invalid choices // NOTE: // Currently tied to ui.dropdownchecklist.js v1.3, with 2 "UCSC" changes: // - Chrome multi-select required changing ddcl code as per issue 176. // - IE needed special code to block window.resize event in DDCL. // *** v1.4 has been released which works with jquery 1.6.1 *** // Some useful names defined: // ddcl: This object just contains these supporting functions in one package. // multiSelect: original // // // Multiple filterTable controls can be defined, but only one table can be the target of filtering. variable: function (filter) { // returns the variable associated with a filter if ($(filter).hasClass('filterBy') === false) return undefined; if ($(filter).hasClass('filterTable') === false) return undefined; // Find the var for this filter var classes = $(filter).attr("class").split(' '); classes = aryRemove(classes,["filterBy","filterTable","noneIsAll"]); if (classes.length > 1 ) { warn('Too many classes for filterBy: ' + classes); return undefined; } return classes.pop(); }, applyOneFilter: function (filter,remainingTrs) { // Applies a single filter to a filterTables TRs var classes = $(filter).val(); if (!classes || classes.length === 0) return null; // Nothing selected so exclude all rows if (classes[0] === 'All') return remainingTrs; // nothing excluded by this filter // Get the filter variable var filterVar = filterTable.variable(filter); if (!filterVar || filterVar.length === 0) return null; var varTds = $(remainingTrs).children('td.' + filterVar); var filteredTrs = null; var ix =0; for (;ix 0) { var trs = $(tds).parent(); if (!filteredTrs) filteredTrs = trs; else filteredTrs = jQuery.merge( filteredTrs, trs ); // takes too long in IE! } } return filteredTrs; }, trsSurviving: function (filterClass) // returns a list of trs that satisfy all filters // If defined, will exclude filter identified by filterClass { // find all filterable table rows var showTrs = $('tr.filterable'); // Default all if (showTrs.length === 0) return undefined; // Find all filters var filters = $("select.filterBy"); if (filters.length === 0) return undefined; // Exclude one if requested. if (filterClass && filterClass.length > 0) filters = $(filters).not('.' + filterClass); for (var ix=0;showTrs && ix < filters.length;ix++) { showTrs = filterTable.applyOneFilter(filters[ix],showTrs); } return showTrs; }, _filter: function () { // Called by filter onchange event. Will show/hide trs based upon all filters var showTrs = filterTable.trsSurviving(); //$('tr.filterable').hide(); // <========= This is what is taking so long! $('tr.filterable').css('display', 'none'); var counter = $('.filesCount'); if (showTrs && showTrs.length > 0) { //$(showTrs).show(); $(showTrs).css('display', ''); // Update count if (counter) $(counter).text($(showTrs).length + " / "); } else { if (counter) $(counter).text(0 + " / "); } var tbody = $( $('tr.filterable')[0] ).parent('tbody.sorting'); if (tbody) $(tbody).removeClass('sorting'); }, trigger: function () { // Called by filter onchange event. Will show/hide trs based upon all filters var tbody = $( $('tr.filterable')[0] ).parent('tbody'); if (tbody) $(tbody).addClass('sorting'); waitOnFunction(filterTable._filter); }, done: function (event) { // Called by custom 'done' event event.stopImmediatePropagation(); $(this).unbind( event ); filterTable.trigger(); }, filter: function (multiSelect) { // Called by filter onchange event. Will show/hide trs based upon all filters // IE takes tooo long, so this should be called only when leaving the filterBy box if ( $('tr.filterable').length > 300) { $(multiSelect).one('done',filterTable.done); return; } else filterTable.trigger(); }, excludeOptions: function (filter) { // bound to 'click' event inside ddcl.js. // Will mark all options in one filterBy box that are inconsistent with the current // selections in other filterBy boxes. Mark with class ".excluded" // Compare to the list of all trs var allTrs = $('tr.filterable'); // Default all if (allTrs.length === 0) return false; // IE takes tooo long, so this should be called only when leaving the filterBy box if ($.browser.msie && $(allTrs).length > 300) return false; // Find the var for this filter var filterVar = filterTable.variable(filter); if (!filterVar) return false; // Look at list of visible trs. var visibleTrs = filterTable.trsSurviving(filterVar); if (!visibleTrs) return false; if (allTrs.length === visibleTrs.length) { $(filter).children('option.excluded').removeClass('excluded'); return true; // Nothing more to do. All are already excluded } // Find the tds that belong to this var var tds = $(visibleTrs).find('td.'+filterVar); if (tds.length === 0) { $(filter).children('option').addClass('excluded'); // add .excluded" to all return true; } // Find the val classes var classes = []; // i.e. new Array(); $(tds).each(function (i) { var someClass = $(this).attr("class").split(' '); someClass = aryRemove(someClass,[filterVar]); var val = someClass.pop(); if (aryFind(classes,val) === -1) classes.push(val); }); if (classes.length === 0) { $(filter).children('option').addClass('excluded'); // add .excluded" to all return true; } // Find all options with those classes $(filter).children('option').each(function (i) { if (aryFind(classes,$(this).val()) !== -1) $(this).removeClass('excluded'); // remove .excluded from matching else $(this).addClass('excluded'); // add .excluded" to non-matching }); // If all options except "all" are included then all should nt be excluded var excluded = $(filter).children('option.excluded'); if (excluded.length === 1) { var text = $(excluded[0]).text(); if (text === 'All' || text === 'Any') $(excluded[0]).removeClass('excluded'); } return true; } }; $(document).ready(function() { setTimeout(ddcl.start,2); // necessary to delay startup till all selects get ids. });