moksha/public/javascript/moksha.js | 31 ++++++++++++++++++++++++++ moksha/public/javascript/ui/moksha.ui.tabs.js | 10 ++++++++ 2 files changed, 41 insertions(+)
New commits: commit efaf162c605308d52a12abd34ed0902c6a19b268 Author: John (J5) Palmieri johnp@redhat.com Date: Mon May 18 18:26:37 2009 -0400
add the ability to set the title from the tabs
diff --git a/moksha/public/javascript/moksha.js b/moksha/public/javascript/moksha.js index cc4fa96..ff2fda6 100644 --- a/moksha/public/javascript/moksha.js +++ b/moksha/public/javascript/moksha.js @@ -721,6 +721,37 @@ moksha = {
if (_moksha_deferred.length == 1) setTimeout(timeout, defer_time); + }, + + /************************************************************* + * Updates a component of the title + * + * label - the text to add into the title + * level - which component to update (e.g. if you have a two + * component title "Moksha" and "Updates" it will be + * displayed as "Updates - Moksha" if you then call + * moksha.update_title("Builds", 1) it will be rendered + * as "Builds - Moksha". level is a 0 based index so + * level 0 == "Moksha" + **************************************************************/ + + title: [], + update_title: function(label, level) { + var title = moksha.title; + var i; + + title.length = level + 1; + title[level] = label; + + var title_str = ''; + for(i=title.length - 1; i > 0; i--) { + title_str += title[i] + ' - '; + } + + title_str += title[0]; + document.title = title_str; + + moksha.title = title; } }
diff --git a/moksha/public/javascript/ui/moksha.ui.tabs.js b/moksha/public/javascript/ui/moksha.ui.tabs.js index 10ad65a..7bbaa24 100644 --- a/moksha/public/javascript/ui/moksha.ui.tabs.js +++ b/moksha/public/javascript/ui/moksha.ui.tabs.js @@ -250,7 +250,12 @@ $.widget("ui.mokshatabs", { if (o.selected !== null) {
var l = this.$lis.eq(o.selected).addClass(o.selectedClass); + var a = $('a', l)[0]; + var title = $(a).attr('title'); + if (title) + moksha.update_title(title, 1); + var $show = $($(a).data('dynamic_href.tabs') + ':first', self.element) $show.show().removeClass(o.hideClass); // use show and remove class to show in any case no matter how it has been hidden before
@@ -312,6 +317,11 @@ $.widget("ui.mokshatabs", { // Show a tab, animation prevents browser scrolling to fragment, // $hide is optional. function showTab(clicked, $show, $hide) { + // last tab gets to set the second title component + var title = $(clicked).attr('title'); + if (title) + moksha.update_title(title, 1); + if (showFx === baseFx) $show.css('display', 'block'); // prevent occasionally occuring flicker in Firefox cause by gap between showing and hiding the tab panels $show.animate(showFx, showFx.duration || baseDuration, function() {
moksha-commits@lists.fedorahosted.org