moksha/api/widgets/containers/templates/tabbedcontainer_panes.mak | 2 moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak | 11 +++ moksha/lib/helpers.py | 4 + moksha/public/javascript/ui/moksha.ui.tabs.js | 32 ++++++++-- 4 files changed, 42 insertions(+), 7 deletions(-)
New commits: commit 9377c4b46782b02589a7b247d9fb2d7ea55f2d79 Merge: 121e792... 797632f... Author: John (J5) Palmieri johnp@redhat.com Date: Thu Apr 23 16:20:53 2009 -0400
Merge branch 'master' of git+ssh://johnp@git.fedorahosted.org/git/moksha
commit 121e792a79da9ab63bfb02948167637de38fece0 Author: John (J5) Palmieri johnp@redhat.com Date: Thu Apr 23 16:20:10 2009 -0400
add static links to the grid
diff --git a/moksha/api/widgets/containers/templates/tabbedcontainer_panes.mak b/moksha/api/widgets/containers/templates/tabbedcontainer_panes.mak index 5b3abd1..d3aa02a 100644 --- a/moksha/api/widgets/containers/templates/tabbedcontainer_panes.mak +++ b/moksha/api/widgets/containers/templates/tabbedcontainer_panes.mak @@ -2,6 +2,8 @@ % for t in tabgroup: % if t['type'] == 'Category': ${add_panel(t['apps'])} + % elif t['type'] == 'StaticLink': + <% pass %> % else: <div id="${t['content_id']}"> % if t.has_key('widget'): diff --git a/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak b/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak index 9e194d0..62874d8 100644 --- a/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak +++ b/moksha/api/widgets/containers/templates/tabbedcontainer_tabs.mak @@ -16,8 +16,17 @@ <%def name="display_tab(tab)"> % if tab['type'] == 'Category': ${display_category(tab)} + % elif tab['type'] == 'StaticLink': + <a href="${tab['url']}${tab['query_string']}" + title="${tab['label']}" + class="static_link" + > + ${tab['label']} + </a> % else: - <a href="${tab['url']}${tab['query_string']}" title="${tab['label']}" panel="${tab['content_id']}"> + <a href="${tab['url']}${tab['query_string']}" + title="${tab['label']}" + panel="${tab['content_id']}"> ${tab['label']} </a> % endif diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py index 2abe9ca..75f2b0f 100644 --- a/moksha/lib/helpers.py +++ b/moksha/lib/helpers.py @@ -315,6 +315,10 @@ class App(ConfigWrapper):
return results
+class StaticLink(App): + """A configuration wrapper class that shows up as a static link in nav + elements""" + class MokshaApp(App): """A configuration wrapper class that displays a Moksa application selected by name. This differes from App in that you don't have to diff --git a/moksha/public/javascript/ui/moksha.ui.tabs.js b/moksha/public/javascript/ui/moksha.ui.tabs.js index afa27df..c18824c 100644 --- a/moksha/public/javascript/ui/moksha.ui.tabs.js +++ b/moksha/public/javascript/ui/moksha.ui.tabs.js @@ -63,8 +63,12 @@ $.widget("ui.mokshatabs", {
var tab_id = this.element.attr('id') + '_tabs'; this.$lis = $('#' + tab_id + ' ul li:has(>a[href])', this.element); - console.log(this.$lis) - console.log(this.element); + // filter out static links + this.$lis = this.$lis.map(function() { + if (!$('a', this).hasClass('static_link')) + return this; + } + ); this.$tabs = this.$lis.map(function() { return $('a', this)[0]; }); this.$panels = $([]);
@@ -73,12 +77,22 @@ $.widget("ui.mokshatabs", {
self.path_remainder = '';
+ var first_non_static_tab = -1; this.$tabs.each(function(i, a) { // inline tab - if (a.hash && a.hash.replace('#', '')) // Safari 2 reports '#' for an empty hash + if (a.hash && a.hash.replace('#', '')) { // Safari 2 reports '#' for an empty hash self.$panels = self.$panels.add(a.hash); + if (first_non_static_tab == -1) + first_non_static_tab = i; + // static link + } else if ($(a).hasClass('static_link')) { + $.data(a, 'href.tabs', href); + $.data(a, 'load.tabs', href); // remote tab - else if ($(a).attr('href') != '#') { // prevent loading the page itself if href is just "#" + } else if ($(a).attr('href') != '#') { // prevent loading the page itself if href is just "#" + if (first_non_static_tab == -1) + first_non_static_tab = i; + var href = $(a).attr('href') $.data(a, 'href.tabs', href); // required for restore on destroy $.data(a, 'load.tabs', href); // mutable @@ -168,7 +182,7 @@ $.widget("ui.mokshatabs", { else if (self.$lis.filter('.' + o.selectedClass).length) o.selected = self.$lis.index( self.$lis.filter('.' + o.selectedClass)[0] ); } - o.selected = o.selected === null || o.selected !== undefined ? o.selected : 0; // first tab selected by default + o.selected = o.selected === null || o.selected !== undefined ? o.selected : first_non_static_tab; // first non-static tab selected by default
// Take disabling tabs via class attribute from HTML // into account and update option properly. @@ -278,7 +292,8 @@ $.widget("ui.mokshatabs", { //var trueClick = e.clientX; // add to history only if true click occured, not a triggered click var $li = $(this).parents('li:eq(0)'), $hide = self.$panels.filter(':visible'), - $show = $(this.hash + ':first', self.element); + $show = $(this.hash + ':first', self.element), + isStaticLink = $(this).hasClass('static_link');
// If tab disabled or // or is already loading or click callback returns false stop here. @@ -298,6 +313,11 @@ $.widget("ui.mokshatabs", { var href = $el.attr('href'); href = href.split("-uuid")[0];
+ if (isStaticLink) { + moksha.goto(href); + return false; + } + //only update the hash level we care about if (o.container_level != 0) { var hash = location.hash.substr(1);
moksha-commits@lists.fedorahosted.org