Commits

Thomas Waldmann  committed 39151f3 Merge

merged default into namespaces branch

  • Participants
  • Parent commits 63f5fc2, 269cd70
  • Branches namespaces

Comments (0)

Files changed (9)

File MoinMoin/templates/common.js

 }
 
 
+// User Settings page enhancements - make long multi-form page appear as a shorter page
+// with a row of tabs at the top or side that may be clicked to select a form.
+$(function () {
+    "use strict";
+    // do nothing if this is not a User Settings page
+    if ($('#moin-usersettings').length === 0) { return; }
 
-// Executed on page load.  If this is the user "Settings" page, make the long 6-form page
-// appear as a shorter page with a row of tabs near the top.  User clicks a tab to select target form.
-function initMoinTabs() {
-    "use strict";
-    // find all .moin-tabs elements and initialize them
-    $('.moin-tabs').each(function () {
-        var tabs = $(this),
-            titles = $(document.createElement('ul')),
-            lastLocationHash;
-        titles.addClass('moin-tab-titles');
-
-        // switching between tabs based on the current location hash
-        function updateFromLocationHash() {
-            if (location.hash !== undefined && location.hash !== '' && tabs.children(location.hash).length) {
-                if (location.hash !== lastLocationHash) {
-                    lastLocationHash = location.hash;
-                    tabs.children('.moin-tab-body').hide();
-                    tabs.children(location.hash).show();
-                    titles.children('li').children('a').removeClass('current');
-                    titles.children('li').children('a[href="' + location.hash + '"]').addClass('current');
-                }
-            } else {
-                $(titles.children('li').children('a')[0]).click();
-            }
-        }
-
-        // move all tab titles to an <ul> at the beginning of .moin-tabs
-        tabs.children('.moin-tab-title').each(function () {
+    // 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">');
+        // for each form on page, create a corresponding LI
+        $('.moin-tab-body').each(function () {
             var li = $(document.createElement('li')),
-                a = $(this).children('a');
-            a.click(function () {
-                location.hash = this.hash;
-                updateFromLocationHash();
+                // copy a-tag defined in heading
+                aTagClone = $(this).find('a').clone();
+            li.append(aTagClone);
+            titles.append(li);
+            // add click handler to show this form and hide all others
+            aTagClone.click(function (ev) {
+                var tab = this.hash;
+                $('.moin-current-tab').removeClass('moin-current-tab');
+                $(ev.target).addClass('moin-current-tab');
+                tabs.children('.moin-tab-body').hide().removeClass('moin-current-form');
+                tabs.children(tab).show().addClass('moin-current-form');
                 return false;
             });
-            li.append(a);
-            titles.append(li);
-            $(this).remove();
         });
-        tabs.prepend(titles);
+        // if this is foobar (or similar sidebar theme) remove buttons that work when javascript is disabled
+        $('.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();
 
-        updateFromLocationHash();
-        setInterval(updateFromLocationHash, 40); // there is no event for that
-    });
-}
-$(document).ready(initMoinTabs);
-
-
-
-// Executed on page load.  Useful only if this is the user "Settings" page.
-// Saves initial values of user "Settings" forms on client side.
-// Detects unsaved changes and sets visual indicator.
-// Processes form Submit and displays status messages and updated data.
-function initMoinUsersettings() {
-    "use strict";
-    // save initial values of each form
-    $('#moin-usersettings form').each(function () {
-        $(this).data('initialForm', $(this).serialize());
+        // save initial values of each form; used in changeHandler to detect changes to a form
+        $('#moin-usersettings form').each(function () {
+            $(this).data('initialForm', $(this).serialize());
+        });
     });
 
-    // check if any changes were made, add indicator if user changes tabs without saving form
+    // add/remove "*" indicator if user changes/saves form
     function changeHandler(ev) {
         var form = $(ev.currentTarget),
-            title = $('.moin-tab-titles a.current', form.parentsUntil('.moin-tabs').parent()),
-            e;
+            title = $('.moin-tab-titles a.moin-current-tab', form.parentsUntil('.moin-tabs').parent());
         if (form.data('initialForm') === form.serialize()) {
             // current values are identicaly to initial ones, remove all change indicators (if any)
-            $('.change-indicator', title).remove();
+            $('.moin-change-indicator', title).remove();
         } else {
             // the values differ
-            if (!$('.change-indicator', title).length) {
+            if (!$('.moin-change-indicator', title).length) {
                 // only add a change indicator if there none
-                e = $(document.createElement('span'));
-                e.addClass('change-indicator');
-                e.text('*');
-                title.append(e);
+                title.append($('<span class="moin-change-indicator">*</span>'));
             }
         }
     }
-    // attach above function to all forms on page
+    // attach above function to all forms as a change handler
     $('#moin-usersettings form').change(changeHandler);
 
-    // executed when user clicks submit button on one of the tabbed forms
+    // executed when user clicks submit button on a user settings form
     function submitHandler(ev) {
         var form = $(ev.target),
             button = $('button', form),
         button.attr('disabled', true);
 
         // remove change indicators from the current tab as we are now saving it
-        $('.moin-tab-titles a.current .change-indicator',
+        $('.moin-tab-titles a.moin-current-tab .moin-change-indicator',
                 form.parentsUntil('.moin-tabs').parent()).remove();
 
         // animate the submit button to indicating a running request
         }, 'json');
         return false;
     }
-    // attach above function to all form submit buttons
+    // attach above function as a submit handler to each user setting form
     $('#moin-usersettings form').submit(submitHandler);
-}
-$(document).ready(initMoinUsersettings);
+
+    // warn user if he tries to leave page when there are unsaved changes (Opera 12.10 does not support onbeforeunload)
+    window.onbeforeunload = function () {
+        var discardMessage = ' {{ _("Your changes will be discarded if you leave this page without saving.") }} ';
+        if ($('.moin-change-indicator').length > 0) {
+            return discardMessage;
+        }
+    };
+});  // end of User Settings page enhancements
 
 
 // This anonymous function supports doubleclick to edit, auto-scroll the edit textarea and page after edit

File MoinMoin/templates/usersettings.html

 
 {% block content %}
 <h1>{{ _("User Settings") }}</h1>
-
-<div id="moin-usersettings" class="moin-tabs">
-    <h2 class="moin-tab-title"><a href="#personal">{{ _("Personal Settings") }}</a></h2>
-    <div id="personal" class="moin-tab-body moin-form">
-        {{ user_forms.personal(form_objs.personal) }}
-    </div>
-
-    <h2 class="moin-tab-title"><a href="#password">{{ _("Change Password") }}</a></h2>
-    <div id="password" class="moin-tab-body moin-form">
-        {{ user_forms.password(form_objs.password) }}
-    </div>
-
-    <h2 class="moin-tab-title"><a href="#notification">{{ _("Notification Settings") }}</a></h2>
-    <div id="notification" class="moin-tab-body moin-form">
-        {{ user_forms.notification(form_objs.notification) }}
-    </div>
-
-    <h2 class="moin-tab-title"><a href="#ui">{{ _("Wiki Appearance Settings") }}</a></h2>
-    <div id="ui" class="moin-tab-body moin-form">
-        {{ user_forms.ui(form_objs.ui) }}
-    </div>
-
-    <h2 class="moin-tab-title"><a href="#navigation">{{ _("Navigation Settings") }}</a></h2>
-    <div id="navigation" class="moin-tab-body moin-form">
-        {{ user_forms.navigation(form_objs.navigation) }}
-    </div>
-
-    <h2 class="moin-tab-title"><a href="#options">{{ _("Options") }}</a></h2>
-    <div id="options" class="moin-tab-body moin-form">
-        {{ user_forms.options(form_objs.options) }}
-    </div>
-</div>
-
+<div class="moin-tabs"></div> {# placeholder - javascript will append UL with clickable tabs here #}
+{{ user_forms.all_usersettings_forms(form_objs) }}
 {% endblock %}

File MoinMoin/templates/usersettings_forms.html

 {{ forms.render_button(_("Save")) }}
 {{ gen.form.close() }}
 {% endmacro %}
+
+{# javascript functions within common.js are dependent upon the structure, classes and ids defined here #}
+{% macro all_usersettings_forms(form_objs) %}
+<div id="moin-usersettings">
+    <div id="personal" class="moin-tab-body moin-form">
+        <h2 class="moin-settings-head"><a href="#personal">{{ _("Personal Settings") }}</a></h2>
+        {{ personal(form_objs.personal) }}
+    </div>
+    <div id="password" class="moin-tab-body moin-form">
+        <h2 class="moin-settings-head"><a href="#password">{{ _("Change Password") }}</a></h2>
+        {{ password(form_objs.password) }}
+    </div>
+    <div id="notification" class="moin-tab-body moin-form">
+        <h2 class="moin-settings-head"><a href="#notification">{{ _("Notification Settings") }}</a></h2>
+        {{ notification(form_objs.notification) }}
+    </div>
+    <div id="ui" class="moin-tab-body moin-form">
+        <h2 class="moin-settings-head"><a href="#ui">{{ _("Wiki Appearance Settings") }}</a></h2>
+        {{ ui(form_objs.ui) }}
+    </div>
+    <div id="navigation" class="moin-tab-body moin-form">
+        <h2 class="moin-settings-head"><a href="#navigation">{{ _("Navigation Settings") }}</a></h2>
+        {{ navigation(form_objs.navigation) }}
+    </div>
+    <div id="options" class="moin-tab-body moin-form">
+        <h2 class="moin-settings-head"><a href="#options">{{ _("Options") }}</a></h2>
+        {{ options(form_objs.options) }}
+    </div>
+</div>
+{% endmacro %}

File MoinMoin/themes/foobar/static/css/common.css

 .moin-form dd input{width:70%}
 .moin-form dt{clear:both;float:left;width:30%;text-align:right;margin-top:.3em;padding-right:1%;}
 .moin-form dt label.required:after{content:'*';color:#000}
-.moin-form button,.moin-form input[type="submit"]{margin-left:48%}
+.moin-form button,.moin-form input[type="submit"]{clear:both;display:table;margin:auto}
 #moin-modify dd,form[name="delete_item"] dd,form[name="rename_item"] dd,form[name="destroy_item"] dd{margin-left:.9em;width:100%;float:none;}
 #moin-modify dd input,form[name="delete_item"] dd input,form[name="rename_item"] dd input,form[name="destroy_item"] dd input{width:96%}
 #moin-modify dt,form[name="delete_item"] dt,form[name="rename_item"] dt,form[name="destroy_item"] dt{float:none;text-align:left;width:auto}
 a.moin-conflict:before{content:url("../img/moin-conflict.png");margin:0 .2em}
 .moin-tab-titles{margin:-.5em;list-style:none;}
 .moin-tab-titles span{display:none}
+.moin-tab-titles a.moin-current-tab{color:#1e90ff}
 #moin-usersetting-title li a{font-size:.84em;color:#696969}
 #moin-global-history,#moin-page-history{font-size:.75em}
 #moin-page-history table{border:1px solid #ccc;border-radius:5px;}

File MoinMoin/themes/foobar/static/css/stylus/main.styl

                 color font_color
     button,
     input[type="submit"]
-        margin-left 48%
+        clear both
+        display table
+        margin auto
 
 #moin-modify, form[name="delete_item"], form[name="rename_item"], form[name="destroy_item"]
     dd
     span
         display none
 
+.moin-tab-titles a.moin-current-tab
+    color link_color
+
 #moin-usersetting-title
     li a
         font-size .84em

File MoinMoin/themes/foobar/templates/usersettings.html

 {% import "usersettings_forms.html" as user_forms %}
 
 {% block local_panel %}
-<ul id="moin-usersetting-title">
-<li class="moin-tab-title"><a href="#moin-personal">{{ _("Personal Settings") }}</a></li>
-<li class="moin-tab-title"><a href="#moin-password">{{ _("Change Password") }}</a></li>
-<li class="moin-tab-title"><a href="#moin-notification">{{ _("Notification Settings") }}</a></li>
-<li class="moin-tab-title"><a href="#moin-ui">{{ _("Wiki Appearance Settings") }}</a></li>
-<li class="moin-tab-title"><a href="#moin-navigation">{{ _("Navigation Settings") }}</a></li>
-<li class="moin-tab-title"><a href="#moin-options">{{ _("Options") }}</a></li>
-</ul>
+<div class="moin-tabs">
+    <ul id="moin-usersetting-title">
+        <li class="moin-tab-title"><a href="#moin-personal">{{ _("Personal Settings") }}</a></li>
+        <li class="moin-tab-title"><a href="#moin-password">{{ _("Change Password") }}</a></li>
+        <li class="moin-tab-title"><a href="#moin-notification">{{ _("Notification Settings") }}</a></li>
+        <li class="moin-tab-title"><a href="#moin-ui">{{ _("Wiki Appearance Settings") }}</a></li>
+        <li class="moin-tab-title"><a href="#moin-navigation">{{ _("Navigation Settings") }}</a></li>
+        <li class="moin-tab-title"><a href="#moin-options">{{ _("Options") }}</a></li>
+    </ul>
+</div>
 {% endblock %}
 
 {% block content %}
-<div id="moin-usersettings" class="moin-tabs">
-    <div class="moin-tab-title"><a href="#moin-personal"></a></div>
-    <div id="moin-personal" class="moin-tab-body moin-form">
-        <h2>{{ _("Personal Settings") }}</h2>
-        {{ user_forms.personal(form_objs.personal) }}
-    </div>
-
-
-    <div id="moin-password" class="moin-tab-body moin-form">
-        <h2>{{ _("Change Password") }}</h2>
-        {{ user_forms.password(form_objs.password) }}
-    </div>
-
-
-    <div id="moin-notification" class="moin-tab-body moin-form">
-        <h2>{{ _("Notification Settings") }}</h2>
-        {{ user_forms.notification(form_objs.notification) }}
-    </div>
-
-
-    <div id="moin-ui" class="moin-tab-body moin-form">
-        <h2>{{ _("Wiki Appearance Settings") }}</h2>
-        {{ user_forms.ui(form_objs.ui) }}
-    </div>
-
-
-    <div id="moin-navigation" class="moin-tab-body moin-form">
-        <h2>{{ _("Navigation Settings") }}</h2>
-        {{ user_forms.navigation(form_objs.navigation) }}
-    </div>
-
-
-    <div id="moin-options" class="moin-tab-body moin-form">
-        <h2>{{ _("Options") }}</h2>
-        {{ user_forms.options(form_objs.options) }}
-    </div>
-</div>
-
+{{ user_forms.all_usersettings_forms(form_objs) }}
 {% endblock %}

File MoinMoin/themes/modernized/static/css/common.css

 .moin-form dd input{width:75%}
 .moin-form dt{clear:both;float:left;width:25%;text-align:right;margin-top:.3em;padding-right:1%;}
 .moin-form dt label.required:after{content:'*';color:#000}
-.moin-form button,.moin-form input[type="submit"]{margin-left:48%}
+.moin-form button,.moin-form input[type="submit"]{clear:both;display:table;margin:auto}
 form[name="delete_item"] dd input,form[name="rename_item"] dd input,form[name="destroy_item"] dd input{width:100%}
 form[name="delete_item"] dt,form[name="rename_item"] dt,form[name="destroy_item"] dt{width:20%}
 #moin-modify dd{width:100%;}
 .moin-textcha{padding-top:.2em}
 #options dd{float:none;width:38%;display:table-cell;padding:1.2em}
 #options dt{margin-left:10%;text-align:left;width:61%;margin-top:1.3em}
-#moin-usersettings a{color:#00008b}
+.moin-tabs .moin-tab-titles a{color:#00008b}
 .moin-tab-titles{margin:0;padding:-10px 0 0;list-style:none;border-bottom:3px solid #4e7da9}
 .moin-tab-titles li{display:inline-block;*display:inline;zoom:1;margin:10px 0 -3px;padding:0 5px;border-bottom:3px solid #4e7da9}
 .moin-tab-titles a{display:inline-block;padding:4px;background-color:#eef1f6;border-width:1px 1px 0;border-style:solid;border-color:#4e7da9;color:#00008b;border-top-left-radius:7px;border-top-right-radius:7px}
 .moin-tab-titles a:hover{background-color:#d8dfe9;text-decoration:none}
-.moin-tab-titles a.current{background:#d8dfe9;padding-top:8px;margin-top:-4px}
-.moin-tab-titles .change-indicator{font-weight:bold;color:#1f9ae0}
-.moin-tab-title a{color:#000;text-decoration:none}
+.moin-tab-titles a.moin-current-tab{background:#d8dfe9;padding-top:8px;margin-top:-4px}
+.moin-tab-titles .moin-change-indicator{font-weight:bold;color:#1f9ae0}
+.moin-current-form h2{display:none}
+.moin-settings-head a{color:#000;text-decoration:none}
 .searchresults dt{margin-top:1em;font-weight:normal}
 .searchresults dd,.searchresults p{font-size:.85em}
 .searchresults td{border-width:0}

File MoinMoin/themes/modernized/static/css/stylus/main.styl

                 color font_color
     button,
     input[type="submit"]
-        margin-left 48%
+        clear both
+        display table
+        margin auto
 
 form[name="delete_item"], form[name="rename_item"], form[name="destroy_item"]
     dd
         width 61%
         margin-top 1.3em
 
-#moin-usersettings
+.moin-tabs .moin-tab-titles
     a
         color link_color
 
     background-color table_row_color
     text-decoration none
 
-.moin-tab-titles a.current
+.moin-tab-titles a.moin-current-tab
     background table_row_color
     padding-top 8px
     margin-top -4px
 
-.moin-tab-titles .change-indicator
+.moin-tab-titles .moin-change-indicator
     font-weight bold
     color hover_color
 
-.moin-tab-title a
+.moin-current-form h2
+    display none // bold tab at top of user setting page makes h2 redundant
+
+.moin-settings-head a
     color font_color
     text-decoration none
 
         'pytest>=2.1, <2.3', # pytest is needed by unit tests
                              # note: currently 2.3.x is not compatible with our test code,
                              # likely due to the fixtures changes.
-        'pytest-pep8', # coding style checker
+        'pytest-pep8<1.0.3', # coding style checker
+                             # note: pytest-pep8 1.0.3 needs pytest 2.3
         'whoosh>=2.4.0', # needed for indexed search
         'sphinx>=1.1', # needed to build the docs
         'pdfminer', # pdf -> text/plain conversion
         'XStatic-svgweb>=2011.2.3.2',
         'XStatic-TWikiDraw-moin>=2004.10.23.2',
         'XStatic-AnyWikiDraw>=0.14.2',
-        'XStatic-svg-edit-moin>=2011.07.07.2',
+        'XStatic-svg-edit-moin>=2012.11.15.1',
     ],
     # optional features and their list of requirements
     extras_require={