ana-balica avatar ana-balica committed 0547496

hashtags on settings page

Comments (0)

Files changed (1)

MoinMoin/templates/common.js

     // 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')),
             // 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');
         $('.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 () {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.