Commits

Anonymous committed 054d088

1.1.2dev: Merged [12458] from 1.0-stable (fix for #10138).

Comments (0)

Files changed (20)

trac/admin/templates/admin_perms.html

             </label>
           </div>
           <div class="buttons">
-            <input type="submit" name="add" value="${_('Add')}" />
+            <input type="submit" name="add" class="trac-disable-on-submit" value="${_('Add')}" />
           </div>
           <p class="help">
             Grant permission for an action to a subject, which can be either a user
             <label>Group: <input id="sg_group" type="text" name="group" /></label>
           </div>
           <div class="buttons">
-            <input type="submit" name="add" value="${_('Add')}"/>
+            <input type="submit" name="add" class="trac-disable-on-submit" value="${_('Add')}"/>
           </div>
           <p class="help">
             Add a user or group to an existing permission group.

trac/admin/templates/admin_plugins.html

           </label>
         </div>
         <div class="buttons">
-          <input type="submit" name="install" class="trac-disable"
+          <input type="submit" name="install" class="trac-disable trac-disable-on-submit"
                  value="${_('Install')}" disabled="${readonly or None}" />
         </div>
         <p class="help" py:choose="readonly">

trac/htdocs/js/trac.js

     });
   }
 
+  // Disable the form's submit action after the submit button is pressed by
+  // replacing it with a handler that cancels the action. The handler is
+  // removed when navigating away from the page so that the action will
+  // be enabled when using the back button to return to the page.
+  $.fn.disableOnSubmit = function() {
+    this.click(function() {
+      var form = $(this).closest("form");
+      if (form.hasClass("trac-submit-is-disabled")) {
+        form.bind("submit.prevent-submit", function() {
+          return false;
+        });
+        $(window).on("unload", function() {
+          form.unbind("submit.prevent-submit");
+        });
+      } else {
+        form.addClass("trac-submit-is-disabled");
+        $(window).on("unload", function() {
+          form.removeClass("trac-submit-is-disabled");
+        })
+      }
+    });
+  }
+
   $.loadStyleSheet = function(href, type) {
     type = type || "text/css";
     $(document).ready(function() {

trac/templates/attachment.html

             <input type="hidden" name="action" value="new" />
             <input type="hidden" name="realm" value="$parent.realm" />
             <input type="hidden" name="id" value="$parent.id" />
-            <input type="submit" class="trac-disable" value="${_('Add attachment')}" />
+            <input type="submit" class="trac-disable trac-disable-on-submit" value="${_('Add attachment')}" />
             <input type="submit" name="cancel" value="${_('Cancel')}" />
           </div>
         </form>
           <form method="post" action="">
             <div id="delete">
               <input type="hidden" name="action" value="delete" />
-              <input type="submit" value="${_('Delete attachment')}" />
+              <input type="submit" class="trac-disable-on-submit" value="${_('Delete attachment')}" />
               <input type="submit" name="cancel" value="${_('Cancel')}" />
             </div>
           </form>

trac/templates/layout.html

         }
         $(".trac-disable").disableSubmit(".trac-disable-determinant");
         setTimeout(function() { $(".trac-scroll").scrollToTop() }, 1);
+        $(".trac-disable-on-submit").disableOnSubmit();
       });
     </script>
     ${select("*[local-name() != 'title']|text()|comment()")}

trac/ticket/templates/admin_components.html

             </fieldset>
           </div>
           <div class="buttons">
-            <input type="submit" name="save" value="${_('Save')}" />
+            <input type="submit" name="save" class="trac-disable-on-submit" value="${_('Save')}"/>
             <input type="submit" name="cancel" value="${_('Cancel')}" />
           </div>
         </fieldset>
             </div>
             ${owner_field()}
             <div class="buttons">
-              <input type="submit" name="add" value="${_('Add')}"/>
+              <input type="submit" name="add" class="trac-disable-on-submit" value="${_('Add')}"/>
             </div>
           </fieldset>
         </form>
             </table>
             <div class="buttons">
               <input type="submit" name="apply" value="${_('Apply changes')}" />
-              <input type="submit" name="remove" class="trac-disable" value="${_('Remove selected items')}" />
+              <input type="submit" name="remove" class="trac-disable trac-disable-on-submit" value="${_('Remove selected items')}" />
               <input type="submit" name="clear" value="${_('Clear default')}" />
             </div>
             <p class="help">

trac/ticket/templates/admin_enums.html

             <label>Name: <input type="text" name="name" class="trac-autofocus" value="${enum.name}" /></label>
           </div>
           <div class="buttons">
-            <input type="submit" name="save" value="${_('Save')}"/>
+            <input type="submit" name="save" class="trac-disable-on-submit" value="${_('Save')}"/>
             <input type="submit" name="cancel" value="${_('Cancel')}"/>
           </div>
         </fieldset>
               <label>Name: <input type="text" name="name" id="name"/></label>
             </div>
             <div class="buttons">
-              <input type="submit" name="add" value="${_('Add')}"/>
+              <input type="submit" name="add" class="trac-disable-on-submit" value="${_('Add')}"/>
             </div>
           </fieldset>
         </form>
             </table>
             <div class="buttons">
               <input type="submit" name="apply" value="${_('Apply changes')}" />
-              <input type="submit" name="remove" class="trac-disable" value="${_('Remove selected items')}" />
+              <input type="submit" name="remove" class="trac-disable trac-disable-on-submit" value="${_('Remove selected items')}" />
               <input type="submit" name="clear" value="${_('Clear default')}" />
             </div>
             <p class="help">

trac/ticket/templates/admin_milestones.html

             </fieldset>
           </div>
           <div class="buttons">
-            <input type="submit" name="save" value="${_('Save')}" disabled="${disabled}"/>
+            <input type="submit" name="save" value="${_('Save')}" class="trac-disable-on-submit" disabled="${disabled}"/>
             <input type="submit" name="cancel" value="${_('Cancel')}"/>
           </div>
         </fieldset>
               </label>
             </div>
             <div class="buttons">
-              <input type="submit" name="add" value="${_('Add')}" />
+              <input type="submit" name="add" class="trac-disable-on-submit" value="${_('Add')}"/>
             </div>
           </fieldset>
         </form>
             </table>
             <div class="buttons">
               <input type="submit" name="apply" value="${_('Apply changes')}" />
-              <input type="submit" name="remove" class="trac-disable" value="${_('Remove selected items')}" py:if="can_remove" />
+              <input type="submit" name="remove" class="trac-disable trac-disable-on-submit" value="${_('Remove selected items')}" py:if="can_remove" />
               <input type="submit" title="Clear default ticket milestone and default retargeting milestone"
                      name="clear" value="${_('Clear defaults')}" />
             </div>

trac/ticket/templates/admin_versions.html

             </fieldset>
           </div>
           <div class="buttons">
-            <input type="submit" name="save" value="${_('Save')}"/>
+            <input type="submit" name="save" class="trac-disable-on-submit" value="${_('Save')}"/>
             <input type="submit" name="cancel" value="${_('Cancel')}"/>
           </div>
         </fieldset>
               </label>
             </div>
             <div class="buttons">
-              <input type="submit" name="add" value="${_('Add')}" />
+              <input type="submit" name="add" class="trac-disable-on-submit" value="${_('Add')}" />
             </div>
           </fieldset>
         </form>
             </table>
             <div class="buttons">
               <input type="submit" name="apply" value="${_('Apply changes')}" />
-              <input type="submit" name="remove" class="trac-disable" value="${_('Remove selected items')}" />
+              <input type="submit" name="remove" class="trac-disable trac-disable-on-submit" value="${_('Remove selected items')}" />
               <input type="submit" name="clear" value="${_('Clear default')}" />
             </div>
             <p class="help">

trac/ticket/templates/batch_modify.html

   <div>
     <input type="hidden" name="selected_tickets" value=""/>
     <input type="hidden" name="query_href" value="${query_href}"/>
-    <input type="submit" id="batchmod_submit" name="batchmod_submit" value="${_('Change tickets')}" />
+    <input type="submit" id="batchmod_submit" name="batchmod_submit" class="trac-disable-on-submit" value="${_('Change tickets')}" />
   </div>
 
 </fieldset>

trac/ticket/templates/milestone_delete.html

         </span>
       </div>
       <div class="buttons">
-        <input type="submit" id="delete" value="${_('Delete milestone')}" />
+        <input type="submit" id="delete" class="trac-disable-on-submit" value="${_('Delete milestone')}" />
         <input type="submit" name="cancel" value="${_('Cancel')}" />
       </div>
     </form>

trac/ticket/templates/milestone_edit.html

         </div>
         <div class="buttons" py:choose="milestone.exists">
           <input py:when="True" type="submit" name="save"
-                 value="${_('Submit changes')}" />
+                 value="${_('Submit changes')}" class="trac-disable-on-submit" />
           <input py:otherwise="" type="submit" name="add"
                  value="${_('Add milestone')}" />
           <input type="submit" name="cancel" value="${_('Cancel')}" />

trac/ticket/templates/report_delete.html

         <div class="buttons">
           <input type="hidden" name="id" value="$report.id"/>
           <input type="hidden" name="action" value="delete" />
-          <input type="submit" value="${_('Delete report')}"/>
+          <input type="submit" class="trac-disable-on-submit" value="${_('Delete report')}"/>
           <input type="submit" name="cancel" value="${_('Cancel')}"/>
         </div>
       </form>

trac/ticket/templates/report_edit.html

 $report.sql</textarea>
           </div>
           <div class="buttons">
-            <input type="submit" value="${_('Save report')}"/>
+            <input type="submit" class="trac-disable-on-submit" value="${_('Save report')}"/>
             <input type="submit" name="cancel" value="${_('Cancel')}"/>
           </div>
         </div>

trac/ticket/templates/ticket.html

             <input type="hidden" name="replyto" value="${replyto}" />
           </py:if>
           <input type="submit" name="preview" value="${_('Preview')}" accesskey="r" />&nbsp;
-          <input type="submit" name="submit" value="${_('Submit changes') if ticket.exists else _('Create ticket')}" />
+          <input type="submit" name="submit" value="${_('Submit changes') if ticket.exists else _('Create ticket')}" class="trac-disable-on-submit" />
         </div>
 
       </form>

trac/versioncontrol/templates/admin_repositories.html

             </fieldset>
           </div>
           <div class="buttons">
-            <input py:if="info.editable" type="submit" name="save" value="${_('Save')}"/>
+            <input py:if="info.editable" type="submit" name="save" class="trac-disable-on-submit" value="${_('Save')}"/>
             <input type="submit" name="cancel" value="${_('Cancel')}"/>
           </div>
         </fieldset>
               <label>Directory: <input type="text" name="dir"/></label>
             </div>
             <div class="buttons">
-              <input type="submit" name="add_repos" value="${_('Add')}"/>
+              <input type="submit" name="add_repos" class="trac-disable-on-submit" value="${_('Add')}"/>
             </div>
           </fieldset>
         </form>
             </div>
             ${alias_field(True)}
             <div class="buttons">
-              <input type="submit" name="add_alias" value="${_('Add')}"/>
+              <input type="submit" name="add_alias" class="trac-disable-on-submit" value="${_('Add')}"/>
             </div>
           </fieldset>
         </form>
           </table>
           <div class="buttons">
             <input type="submit" name="refresh" value="${_('Refresh')}"/>
-            <input type="submit" name="remove" class="trac-disable" value="${_('Remove selected items')}"/>
+            <input type="submit" name="remove" class="trac-disable trac-disable-on-submit" value="${_('Remove selected items')}"/>
           </div>
         </form>
       </py:otherwise>

trac/wiki/templates/wiki_delete.html

           <strong>This is an irreversible operation.</strong>
         </p>
         <div class="buttons">
-          <input type="submit" value="${what == 'multiple' and _('Delete those versions')
-                                        or what == 'single' and _('Delete this version')
-                                        or _('Delete page')}" />
+          <input type="submit" class="trac-disable-on-submit"
+                 value="${what == 'multiple' and _('Delete those versions')
+                                   or what == 'single' and _('Delete this version')
+                                   or _('Delete page')}" />
           <input type="submit" name="cancel" value="${_('Cancel')}" />
         </div>
       </form>

trac/wiki/templates/wiki_edit_form.html

       <py:otherwise>
         <input type="submit" name="preview" value="${_('Preview Page')}" accesskey="p" />&nbsp;
         <input type="submit" name="diff" value="${_('Review Changes')}" accesskey="r" />&nbsp;
-        <input type="submit" id="save" name="save" value="${_('Submit changes')}" />&nbsp;
+        <input type="submit" id="save" name="save" class="trac-disable-on-submit" value="${_('Submit changes')}" />&nbsp;
       </py:otherwise>
       <input type="submit" name="cancel" value="${_('Cancel')}" />
     </div>

trac/wiki/templates/wiki_rename.html

           </label>
         </div>
         <div class="buttons">
-          <input type="submit" name="submit" value="${_('Rename page')}"/>
+          <input type="submit" name="submit" class="trac-disable-on-submit" value="${_('Rename page')}"/>
           <input type="submit" name="cancel" value="${_('Cancel')}"/>
         </div>
       </form>

tracopt/ticket/templates/ticket_delete.html

             </p>
           </div>
           <div class="buttons">
-            <input type="submit" value="${_('Delete ticket')}"/>
+            <input type="submit" class="trac-disable-on-submit" value="${_('Delete ticket')}"/>
             <input type="submit" name="cancel" value="${_('Cancel')}"/>
           </div>
         </form>
                This is an irreversible operation.</p>
           </div>
           <div class="buttons">
-            <input type="submit" value="${_('Delete comment')}"/>
+            <input type="submit" class="trac-disable-on-submit" value="${_('Delete comment')}"/>
             <input type="submit" name="cancel" value="${_('Cancel')}"/>
           </div>
         </form>