Edgewall Software

Ticket #2839: confirm-wiki.patch

File confirm-wiki.patch, 1.4 kB (added by eblot, 3 years ago)

Javascript to prompt the user about comment-less wiki page update

  • htdocs/js/trac.js

    old new  
    126126    addLinks(container.getElementsByTagName('h' + lvl)); 
    127127  } 
    128128} 
     129 
     130function confirmWiki() { 
     131  var comment = document.getElementById("comment"); 
     132 
     133  if ( comment.value == '' ) { 
     134    var force; 
     135 
     136    force = confirm('Comment field is empty.\n' + 
     137                   'Are you sure to leave the modifications with no comments ?\n' + 
     138                   '(Comments are useful to get a quick overview of the changes)'); 
     139 
     140    if ( force ) { 
     141      return true; 
     142    }  
     143    else { 
     144      comment.focus(); 
     145 
     146      return false; 
     147    } 
     148 
     149  } 
     150 
     151  return true; 
     152} 
     153 
  • templates/wiki.cs

    old new  
    264264      <input type="submit" name="save" value="Submit changes" disabled="disabled" />&nbsp; 
    265265     <?cs else ?> 
    266266      <input type="submit" name="preview" value="Preview" accesskey="r" />&nbsp; 
    267       <input type="submit" name="save" value="Submit changes" />&nbsp; 
     267      <?cs if wiki.action == "preview" ?>  
     268       <input type="submit" name="save" value="Submit changes" onclick="return confirmWiki()"/>&nbsp; 
     269      <?cs /if ?> 
    268270     <?cs /if ?> 
    269271     <input type="submit" name="cancel" value="Cancel" /> 
    270272    </div>