* Dodanie przycisku "commit". Zmiana nazwy z "save" na "quick save". Closes #96.
authorŁukasz Rekucki <lrekucki@gmail.com>
Tue, 15 Sep 2009 15:46:17 +0000 (17:46 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Tue, 15 Sep 2009 15:46:17 +0000 (17:46 +0200)
project/static/js/editor.js
project/static/js/editor.ui.js
project/templates/explorer/editor.html

index e37228c..4150043 100644 (file)
@@ -347,7 +347,7 @@ Editor.prototype.saveToBranch = function(msg)
     var self = this;
     $.log('Saving to local branch - panel:', changed_panel);
 
-    if(!msg) msg = "Zapis z edytora platformy.";
+    if(!msg) msg = "Szybki zapis z edytora platformy.";
 
     if( changed_panel.length == 0) {
         $.log('Nothing to save.');
@@ -417,9 +417,8 @@ Editor.prototype.autoSave = function()
 Editor.prototype.onContentChanged = function(event, data) {
     var self = this;
 
-    $('#toolbar-button-save').removeAttr('disabled');
-    $('#toolbar-button-commit').attr('disabled', 'disabled');
-    $('#toolbar-button-update').attr('disabled', 'disabled');
+    $('button.provides-save').removeAttr('disabled');
+    $('button.requires-save').attr('disabled', 'disabled');
     
     if(this.autosaveTimer) return;
     this.autosaveTimer = setTimeout( function() {
@@ -461,10 +460,7 @@ Editor.prototype.sendMergeRequest = function (message) {
         alert("There are unsaved changes - can't commit.");
 
     var self =  this;    
-
-    $('#commit-dialog-related-issues input:checked').
-        each(function() { message += ' refs #' + $(this).val(); });  
-    
+        
     $.ajax({        
         url: $('#commit-dialog form').attr('action'),
         dataType: 'json',
index 4d2a5d3..8932b4e 100755 (executable)
@@ -146,10 +146,14 @@ Editor.prototype.setupUI = function() {
      * Connect various buttons\r
      */\r
 \r
-    $('#toolbar-button-save').click( function (event, data) {\r
+    $('#toolbar-button-quick-save').click( function (event, data) {\r
         self.saveToBranch();\r
     } );\r
 \r
+    $('#toolbar-button-save').click( function (event, data) {\r
+        $('#commit-dialog').jqmShow( {callback: $.fbind(self, self.saveToBranch)} );\r
+    } );\r
+\r
     $('#toolbar-button-update').click( function (event, data) {\r
         if (self.updateUserBranch()) {\r
             // commit/update can be called only after proper, save\r
@@ -163,29 +167,18 @@ Editor.prototype.setupUI = function() {
     $('#commit-dialog').\r
     jqm({\r
         modal: true,\r
-        onShow: $.fbind(self, self.loadRelatedIssues),\r
-        trigger: '#toolbar-button-commit'\r
+        onShow: $.fbind(self, self.loadRelatedIssues)        \r
     });\r
+\r
+    $('#toolbar-button-commit').click( function (event, data) {\r
+        $('#commit-dialog').jqmShow( {callback: $.fbind(self, self.sendMergeRequest)} );\r
+    } );\r
     \r
     /* STATIC BINDS */\r
     $('#commit-dialog-cancel-button').click(function() {\r
         $('#commit-dialog-error-empty-message').hide();\r
         $('#commit-dialog').jqmHide();\r
-    });\r
-\r
-    $('#commit-dialog-save-button').click( function (event, data)\r
-    {\r
-        if( $('#commit-dialog-message').val().match(/^\s*$/)) {\r
-            $('#commit-dialog-error-empty-message').fadeIn();\r
-        }\r
-        else {\r
-            $('#commit-dialog-error-empty-message').hide();\r
-            $('#commit-dialog').jqmHide();\r
-            self.sendMergeRequest($('#commit-dialog-message').val() );\r
-        }\r
-\r
-        return false;\r
-    });\r
+    });   \r
     \r
 \r
     /* SPLIT DIALOG */\r
@@ -203,6 +196,25 @@ Editor.prototype.loadRelatedIssues = function(hash)
     var self = this;\r
     var c = $('#commit-dialog-related-issues');\r
 \r
+    $('#commit-dialog-save-button').click( function (event, data)\r
+    {\r
+        if( $('#commit-dialog-message').val().match(/^\s*$/)) {\r
+            $('#commit-dialog-error-empty-message').fadeIn();\r
+        }\r
+        else {\r
+            $('#commit-dialog-error-empty-message').hide();\r
+            $('#commit-dialog').jqmHide();\r
+\r
+            var message = $('#commit-dialog-message').val();\r
+            $('#commit-dialog-related-issues input:checked').\r
+                each(function() { message += ' refs #' + $(this).val(); });\r
+            $.log("COMMIT APROVED", hash.t);\r
+            hash.t.callback(message);\r
+        }\r
+\r
+        return false;\r
+    });\r
+\r
     $("div.loading-box", c).show();\r
     $("div.fatal-error-box", c).hide();\r
     $("div.container-box", c).hide();\r
@@ -301,9 +313,8 @@ Editor.prototype.refreshPanels = function() {
             panel.refresh();\r
     });\r
 \r
-    $('#toolbar-button-save').attr('disabled', 'disabled');\r
-    $('#toolbar-button-commit').removeAttr('disabled');\r
-    $('#toolbar-button-update').removeAttr('disabled');\r
+    $('button.provides-save').attr('disabled', 'disabled');\r
+    $('button.requires-save').removeAttr('disabled');\r
 };\r
 \r
 /*\r
index 02a1c75..c82b75f 100644 (file)
     </script>
 {% endblock extrabody %}
 
- {% load explorer_tags %}
+{% load explorer_tags %}
 
 {% block breadcrumbs %}<a href="{% url file_list %}">Platforma Redakcyjna</a> &gt; {{ fileid|bookname }}{% endblock breadcrumbs %}
 
 {% block header-toolbar %}
-
-
-<button type="button" class="toolbar-button" id="toolbar-button-commit">Merge</button>
-<button type="button" class="toolbar-button" id="toolbar-button-update"
+<button type="button" class="requires-save toolbar-button" id="toolbar-button-commit">Merge</button>
+<button type="button" class="requires-save toolbar-button" id="toolbar-button-update"
         ui:ajax-action="{% url file_update fileid %}">Update</button>
-<button type="button" class="toolbar-button" id="toolbar-button-save" disabled="disabled">Save</button>
+<button type="button" class="provides-save toolbar-button" id="toolbar-button-save" disabled="disabled">Commit</button>
+<button type="button" class="provides-save toolbar-button" id="toolbar-button-quick-save" disabled="disabled">Quick Save</button>
 {% endblock %}
 
 {% block message-box %}
@@ -96,7 +95,7 @@
                     <div class="container-box">No related issues.</div>
                 </fieldset>
                 <p>
-                   <input type="submit" value="Save" id="commit-dialog-save-button" />
+                   <input type="button" value="Save" id="commit-dialog-save-button" />
                    <input type="reset" value="Cancel" id="commit-dialog-cancel-button" />
                 </p>
             </form>