* Poprawki w redmine.
[redakcja.git] / project / static / js / editor.ui.js
index 59c3f75..4d2a5d3 100755 (executable)
@@ -15,6 +15,11 @@ Editor.prototype.setupUI = function() {
     var resize_changed =  function(event) {\r
         var old_width = parseInt(event.data.overlay.css('width'));\r
         var delta = event.pageX + event.data.hotspot_x - old_width;\r
+\r
+        if(old_width + delta < 12) delta = 12 - old_width;\r
+        if(old_width + delta > $(window).width()) \r
+            delta = $(window).width() - old_width;\r
+        \r
         event.data.overlay.css({\r
             'width': old_width + delta\r
         });\r
@@ -104,7 +109,7 @@ Editor.prototype.setupUI = function() {
 \r
     panel_root.bind('hpanel:panel-resize-start', resize_start);\r
     self.rootDiv.bind('stopResize', function() {\r
-        self.savePanelOptions()\r
+        self.savePanelOptions();      \r
     });\r
     \r
     /*\r
@@ -127,11 +132,15 @@ Editor.prototype.setupUI = function() {
             function() {\r
                 panel.refresh();\r
             } );\r
+\r
+        self.rootDiv.bind('stopResize', function() {\r
+            panel.callHook('toolbarResized');\r
+        });\r
     });\r
 \r
     $(document).bind('panel:contentChanged', function() {\r
         self.onContentChanged.apply(self, arguments)\r
-    });\r
+    });  \r
 \r
     /*\r
      * Connect various buttons\r
@@ -154,15 +163,17 @@ Editor.prototype.setupUI = function() {
     $('#commit-dialog').\r
     jqm({\r
         modal: true,\r
+        onShow: $.fbind(self, self.loadRelatedIssues),\r
         trigger: '#toolbar-button-commit'\r
     });\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
+    $('#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
@@ -171,10 +182,11 @@ Editor.prototype.setupUI = function() {
             $('#commit-dialog-error-empty-message').hide();\r
             $('#commit-dialog').jqmHide();\r
             self.sendMergeRequest($('#commit-dialog-message').val() );\r
-        }       \r
-     \r
+        }\r
+\r
         return false;\r
-    });    \r
+    });\r
+    \r
 \r
     /* SPLIT DIALOG */\r
     $('#split-dialog').jqm({\r
@@ -186,6 +198,31 @@ Editor.prototype.setupUI = function() {
 // $('#split-dialog').   \r
 }\r
 \r
+Editor.prototype.loadRelatedIssues = function(hash)\r
+{\r
+    var self = this;\r
+    var c = $('#commit-dialog-related-issues');\r
+\r
+    $("div.loading-box", c).show();\r
+    $("div.fatal-error-box", c).hide();\r
+    $("div.container-box", c).hide();\r
+    \r
+    $.getJSON( c.attr('ui:ajax-src') + '?callback=?',\r
+    function(data, status)\r
+    {\r
+        var fmt = '';\r
+        $(data).each( function() {\r
+            fmt += '<label><input type="checkbox" checked="checked"'\r
+            fmt += ' value="' + this.id + '" />' + this.subject +'</label>\n'\r
+        });\r
+        $("div.container-box", c).html(fmt);\r
+        $("div.loading-box", c).hide();\r
+        $("div.container-box", c).show();        \r
+    });   \r
+    \r
+    hash.w.show();\r
+}\r
+\r
 Editor.prototype.loadSplitDialog = function(hash)\r
 {\r
     var self = this;    \r
@@ -206,8 +243,8 @@ Editor.prototype.loadSplitDialog = function(hash)
         // put the form into the window\r
         $('div.container-box', hash.w).html(data);\r
         $("div.loading-box", hash.w).hide();\r
-        $('form input[name=splittext]', hash.w).val(hash.t.selection);\r
-        $('form input[name=fulltext]', hash.w).val(hash.t.fulltext);\r
+        $('form input[name=splitform-splittext]', hash.w).val(hash.t.selection);\r
+        $('form input[name=splitform-fulltext]', hash.w).val(hash.t.fulltext);\r
         $('div.container-box', hash.w).show();\r
 \r
         // connect buttons\r
@@ -225,6 +262,19 @@ Editor.prototype.loadSplitDialog = function(hash)
         $('#split-dialog-button-dismiss').click(function() {\r
             hash.w.jqmHide();\r
             $('div.container-box', hash.w).html('');\r
+            hash.t.success();\r
+        });\r
+\r
+        if($('#id_splitform-autoxml').is(':checked'))\r
+            $('#split-form-dc-subform').show();\r
+        else\r
+            $('#split-form-dc-subform').hide();\r
+\r
+        $('#id_splitform-autoxml').change(function() {            \r
+            if( $(this).is(':checked') )\r
+                $('#split-form-dc-subform').show();\r
+            else\r
+                $('#split-form-dc-subform').hide();\r
         });\r
     };   \r
 \r
@@ -250,8 +300,11 @@ Editor.prototype.refreshPanels = function() {
         else\r
             panel.refresh();\r
     });\r
-};\r
 \r
+    $('#toolbar-button-save').attr('disabled', 'disabled');\r
+    $('#toolbar-button-commit').removeAttr('disabled');\r
+    $('#toolbar-button-update').removeAttr('disabled');\r
+};\r
 \r
 /*\r
  * Pop-up messages\r