Dodanie PanelContainerView oraz postawy HTMLView i XMLView.
[redakcja.git] / project / static / js / editor.js
index fa796db..d9166cf 100644 (file)
@@ -253,7 +253,9 @@ Panel.prototype.isHotkey = function(event) {
     if(event.ctrlKey) code = code | 0x200;
     if(event.shiftKey) code = code | 0x400;
 
     if(event.ctrlKey) code = code | 0x200;
     if(event.shiftKey) code = code | 0x400;
 
-    if(this.hotkeys[code] !== null) {
+    $.log(event.character, this.hotkeys[code]);
+
+    if(this.hotkeys[code]) {
         return true;
     }
     return false;
         return true;
     }
     return false;
@@ -301,6 +303,10 @@ Editor.prototype.loadConfig = function() {
     
     this.fileOptions = this.options;
     var self = this;
     
     this.fileOptions = this.options;
     var self = this;
+
+    if(!this.options.recentFiles)
+        this.options.recentFiles = [];
+
     $.each(this.options.recentFiles, function(index) {
         if (fileId == self.options.recentFiles[index].fileId) {
             $.log('Found options for', fileId);
     $.each(this.options.recentFiles, function(index) {
         if (fileId == self.options.recentFiles[index].fileId) {
             $.log('Found options for', fileId);
@@ -316,30 +322,30 @@ Editor.prototype.loadConfig = function() {
 };
 
 Editor.prototype.loadPanelOptions = function() {
 };
 
 Editor.prototype.loadPanelOptions = function() {
-    var self = this;
-    var totalWidth = 0;
-    
-    $('.panel-wrap', self.rootDiv).each(function(index) {
-        var panelWidth = self.fileOptions.panels[index].ratio * self.rootDiv.width();
-        if ($(this).hasClass('last-panel')) {
-            $(this).css({
-                left: totalWidth,
-                right: 0
-            });
-        } else {
-            $(this).css({
-                left: totalWidth,
-                width: panelWidth
-            });
-            totalWidth += panelWidth;               
-        }
-        $.log('panel:', this, $(this).css('left'));
-        $('.panel-toolbar option', this).each(function() {
-            if ($(this).attr('p:panel-name') == self.fileOptions.panels[index].name) {
-                $(this).parent('select').val($(this).attr('value'));
-            }
-        });
-    });   
+    // var self = this;
+    // var totalWidth = 0;
+    // 
+    // $('.panel-wrap', self.rootDiv).each(function(index) {
+    //     var panelWidth = self.fileOptions.panels[index].ratio * self.rootDiv.width();
+    //     if ($(this).hasClass('last-panel')) {
+    //         $(this).css({
+    //             left: totalWidth,
+    //             right: 0
+    //         });
+    //     } else {
+    //         $(this).css({
+    //             left: totalWidth,
+    //             width: panelWidth
+    //         });
+    //         totalWidth += panelWidth;               
+    //     }
+    //     $.log('panel:', this, $(this).css('left'));
+    //     $('.panel-toolbar option', this).each(function() {
+    //         if ($(this).attr('p:panel-name') == self.fileOptions.panels[index].name) {
+    //             $(this).parent('select').val($(this).attr('value'));
+    //         }
+    //     });
+    // });   
 };
 
 Editor.prototype.savePanelOptions = function() {
 };
 
 Editor.prototype.savePanelOptions = function() {
@@ -378,7 +384,7 @@ Editor.prototype.saveToBranch = function(msg)
     var self = this;
     $.log('Saving to local branch - panel:', changed_panel);
 
     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.');
 
     if( changed_panel.length === 0) {
         $.log('Nothing to save.');
@@ -419,7 +425,7 @@ Editor.prototype.saveToBranch = function(msg)
                 if(self.autosaveTimer) {
                     clearTimeout(self.autosaveTimer);
                 }
                 if(self.autosaveTimer) {
                     clearTimeout(self.autosaveTimer);
                 }
-                if (data.warnings === null) {
+                if (data.warnings === null || data.warning === undefined) {
                     self.showPopup('save-successful');
                 } else {
                     self.showPopup('save-warn', data.warnings[0]);
                     self.showPopup('save-successful');
                 } else {
                     self.showPopup('save-warn', data.warnings[0]);
@@ -450,9 +456,8 @@ Editor.prototype.autoSave = function()
 Editor.prototype.onContentChanged = function(event, data) {
     var self = this;
 
 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() {
     
     if(this.autosaveTimer) return;
     this.autosaveTimer = setTimeout( function() {
@@ -495,9 +500,8 @@ Editor.prototype.sendMergeRequest = function (message) {
         alert("There are unsaved changes - can't commit.");
     }
 
         alert("There are unsaved changes - can't commit.");
     }
 
-    var self =  this;
-    $.log('URL !: ', $('#commit-dialog form').attr('action'));
-    
+    var self =  this;    
+        
     $.ajax({        
         url: $('#commit-dialog form').attr('action'),
         dataType: 'json',
     $.ajax({        
         url: $('#commit-dialog form').attr('action'),
         dataType: 'json',