Mercurial > moin-2.0-moinboot
changeset 2110:054749699f8a
hashtags on settings page
| author | Ana Balica <ana.balica@gmail.com> |
|---|---|
| date | Thu, 02 May 2013 23:25:02 +0300 |
| parents | 0e122fcb96ca |
| children | 60e75cabd0d6 |
| files | MoinMoin/templates/common.js |
| diffstat | 1 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/templates/common.js Thu Apr 25 22:44:32 2013 +0300 +++ b/MoinMoin/templates/common.js Thu May 02 23:25:02 2013 +0300 @@ -253,7 +253,8 @@ // create a UL that will be displayed as row of tabs or column of buttons $(function () { var tabs = $('#moin-usersettings'), - titles = $('<ul class="moin-tab-titles">'); + titles = $('<ul class="moin-tab-titles">'), + hashTag = window.location.hash; // for each form on page, create a corresponding LI $('.moin-tab-body').each(function () { var li = $(document.createElement('li')), @@ -264,6 +265,7 @@ // add click handler to show this form and hide all others aTagClone.click(function (ev) { var tab = this.hash; + window.location.hash = tab; $('.moin-current-tab').removeClass('moin-current-tab'); $(ev.target).addClass('moin-current-tab'); tabs.children('.moin-tab-body').hide().removeClass('moin-current-form'); @@ -275,8 +277,17 @@ $('.moin-tabs ul').remove(); // add tabs/buttons with click handlers to top/side per theme template $('.moin-tabs').prepend(titles); - // click a tab to show first form and hide all other forms - $(titles.children('li').children('a')[0]).click(); + + // check for the hashtag and switch tab + if (hashTag !== '') { + var tab = $('.moin-tab-titles li a[href="'+ hashTag +'"]'); + if (tab.length !== 0) { + $(tab)[0].click(); + } + } else { + // click a tab to show first form and hide all other forms + $(titles.children('li').children('a')[0]).click(); + } // save initial values of each form; used in changeHandler to detect changes to a form $('#moin-usersettings form').each(function () {
