commit/galaxy-central: guerler: Ui: Drilldown set initial expand states
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/1fbbe30e7b31/ Changeset: 1fbbe30e7b31 User: guerler Date: 2015-02-12 02:58:08+00:00 Summary: Ui: Drilldown set initial expand states Affected #: 3 files diff -r f9f99b2a25285ec0e09cfbc494ba8a1fe997ceb5 -r 1fbbe30e7b311b27b351f0964517bfeeb7500290 client/galaxy/scripts/mvc/ui/ui-drilldown.js --- a/client/galaxy/scripts/mvc/ui/ui-drilldown.js +++ b/client/galaxy/scripts/mvc/ui/ui-drilldown.js @@ -10,6 +10,30 @@ options.type = options.display || 'checkbox'; options.multiple = (options.display == 'checkbox'); Options.BaseIcons.prototype.initialize.call(this, options); + this.initial = true; + }, + + // set expand states for initial value + value: function (new_val) { + var val = Options.BaseIcons.prototype.value.call(this, new_val); + if (this.initial && val !== null && this.header_index) { + this.initial = false; + var values = val; + if (!$.isArray(values)) { + values = [values]; + } + var headers_merged = []; + for (var i in values) { + var list = this.header_index[values[i]] + if (list) { + headers_merged = _.uniq(headers_merged.concat(list)); + } + } + for (var i in headers_merged) { + this._setState(headers_merged[i], true); + } + } + return val; }, /** Expand/collapse a sub group @@ -81,6 +105,9 @@ $group.append($buttongroup); iterate($subgroup, level.options, new_header); $group.append($subgroup); + + // keep track of header list + self.header_index[level.value] = new_header; } else { // append child options $group.append(self._templateOption({ diff -r f9f99b2a25285ec0e09cfbc494ba8a1fe997ceb5 -r 1fbbe30e7b311b27b351f0964517bfeeb7500290 static/scripts/mvc/ui/ui-drilldown.js --- a/static/scripts/mvc/ui/ui-drilldown.js +++ b/static/scripts/mvc/ui/ui-drilldown.js @@ -10,6 +10,30 @@ options.type = options.display || 'checkbox'; options.multiple = (options.display == 'checkbox'); Options.BaseIcons.prototype.initialize.call(this, options); + this.initial = true; + }, + + // set expand states for initial value + value: function (new_val) { + var val = Options.BaseIcons.prototype.value.call(this, new_val); + if (this.initial && val !== null && this.header_index) { + this.initial = false; + var values = val; + if (!$.isArray(values)) { + values = [values]; + } + var headers_merged = []; + for (var i in values) { + var list = this.header_index[values[i]] + if (list) { + headers_merged = _.uniq(headers_merged.concat(list)); + } + } + for (var i in headers_merged) { + this._setState(headers_merged[i], true); + } + } + return val; }, /** Expand/collapse a sub group @@ -81,6 +105,9 @@ $group.append($buttongroup); iterate($subgroup, level.options, new_header); $group.append($subgroup); + + // keep track of header list + self.header_index[level.value] = new_header; } else { // append child options $group.append(self._templateOption({ diff -r f9f99b2a25285ec0e09cfbc494ba8a1fe997ceb5 -r 1fbbe30e7b311b27b351f0964517bfeeb7500290 static/scripts/packed/mvc/ui/ui-drilldown.js --- a/static/scripts/packed/mvc/ui/ui-drilldown.js +++ b/static/scripts/packed/mvc/ui/ui-drilldown.js @@ -1,1 +1,1 @@ -define(["utils/utils","mvc/ui/ui-options"],function(b,a){var c=a.BaseIcons.extend({initialize:function(d){d.type=d.display||"checkbox";d.multiple=(d.display=="checkbox");a.BaseIcons.prototype.initialize.call(this,d)},_setState:function(d,e){var f=this.$("#button-"+d);var g=this.$("#subgroup-"+d);f.data("is_expanded",e);if(e){g.fadeIn("fast");f.removeClass("toggle-expand");f.addClass("toggle")}else{g.hide();f.removeClass("toggle");f.addClass("toggle-expand")}},_templateOptions:function(g){var f=this;this.header_index={};this.header_list=[];function e(k,i){var l=k.find("#button-"+i);l.on("click",function(){f._setState(i,!l.data("is_expanded"))})}function d(r,t,o){o=o||[];for(h in t){var k=t[h];var l=k.options.length>0;var q=o.slice(0);var s=$("<div/>");if(l){var n=b.uuid();var i=$('<span id="button-'+n+'" class="ui-drilldown-button form-toggle icon-button toggle-expand"/>');var m=$('<div id="subgroup-'+n+'" style="display: none; margin-left: 25px;"/>');q.push(n);var p=$("<div/>");p.append(i);p.append(f._templateOption({label:k.name,value:k.value}));s.append(p);d(m,k.options,q);s.append(m)}else{s.append(f._templateOption({label:k.name,value:k.value}));f.header_index[k.value]=q}r.append(s)}}var j=$("<div/>");d(j,g);for(var h in this.header_index){this.header_list=_.uniq(this.header_list.concat(this.header_index[h]))}for(var h in this.header_list){e(j,this.header_list[h])}return j},_template:function(d){return'<div class="ui-options-list drilldown-container" id="'+d.id+'"/>'}});return{View:c}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-options"],function(b,a){var c=a.BaseIcons.extend({initialize:function(d){d.type=d.display||"checkbox";d.multiple=(d.display=="checkbox");a.BaseIcons.prototype.initialize.call(this,d);this.initial=true},value:function(d){var j=a.BaseIcons.prototype.value.call(this,d);if(this.initial&&j!==null&&this.header_index){this.initial=false;var e=j;if(!$.isArray(e)){e=[e]}var h=[];for(var f in e){var g=this.header_index[e[f]];if(g){h=_.uniq(h.concat(g))}}for(var f in h){this._setState(h[f],true)}}return j},_setState:function(d,e){var f=this.$("#button-"+d);var g=this.$("#subgroup-"+d);f.data("is_expanded",e);if(e){g.fadeIn("fast");f.removeClass("toggle-expand");f.addClass("toggle")}else{g.hide();f.removeClass("toggle");f.addClass("toggle-expand")}},_templateOptions:function(g){var f=this;this.header_index={};this.header_list=[];function e(k,i){var l=k.find("#button-"+i);l.on("click",function(){f._setState(i,!l.data("is_expanded"))})}function d(r,t,o){o=o||[];for(h in t){var k=t[h];var l=k.options.length>0;var q=o.slice(0);var s=$("<div/>");if(l){var n=b.uuid();var i=$('<span id="button-'+n+'" class="ui-drilldown-button form-toggle icon-button toggle-expand"/>');var m=$('<div id="subgroup-'+n+'" style="display: none; margin-left: 25px;"/>');q.push(n);var p=$("<div/>");p.append(i);p.append(f._templateOption({label:k.name,value:k.value}));s.append(p);d(m,k.options,q);s.append(m);f.header_index[k.value]=q}else{s.append(f._templateOption({label:k.name,value:k.value}));f.header_index[k.value]=q}r.append(s)}}var j=$("<div/>");d(j,g);for(var h in this.header_index){this.header_list=_.uniq(this.header_list.concat(this.header_index[h]))}for(var h in this.header_list){e(j,this.header_list[h])}return j},_template:function(d){return'<div class="ui-options-list drilldown-container" id="'+d.id+'"/>'}});return{View:c}}); \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org