+
+ postData += '&' + $.param({
+ 'commit_message': msg
+ });
+
+ self.showPopup('save-waiting', '', -1);
+
+ $.ajax({
+ url: saveInfo.url,
+ dataType: 'json',
+ success: function(data, textStatus) {
+ if (data.result != 'ok') {
+ self.showPopup('save-error', (data.errors && data.errors[0]) || 'Nieznany błąd X_X.');
+ }
+ else {
+ self.refreshPanels();
+
+
+ if(self.autosaveTimer) {
+ clearTimeout(self.autosaveTimer);
+ }
+ if (data.warnings === null || data.warning === undefined) {
+ self.showPopup('save-successful');
+ } else {
+ self.showPopup('save-warn', data.warnings[0]);
+ }
+ }
+
+ self.advancePopupQueue();
+ },
+ error: function(rq, tstat, err) {
+ self.showPopup('save-error', '- bład wewnętrzny serwera.');
+ self.advancePopupQueue();
+ },
+ type: 'POST',
+ data: postData
+ });
+
+ return true;
+};
+
+Editor.prototype.autoSave = function()
+{
+ this.autosaveTimer = null;
+ // first check if there is anything to save
+ $.log('Autosave');
+ this.saveToBranch("Automatyczny zapis z edytora platformy.");
+};
+
+Editor.prototype.onContentChanged = function(event, data) {
+ var self = this;
+
+ $('button.provides-save').removeAttr('disabled');
+ $('button.requires-save').attr('disabled', 'disabled');
+
+ if(this.autosaveTimer) return;
+ this.autosaveTimer = setTimeout( function() {
+ self.autoSave();
+ }, 300000 );
+};
+
+Editor.prototype.updateUserBranch = function() {
+ if($('.panel-wrap.changed').length !== 0) {
+ alert("There are unsaved changes - can't update.");
+ }
+
+ var self = this;
+ $.ajax({
+ url: $('#toolbar-button-update').attr('ui:ajax-action'),
+ dataType: 'json',
+ success: function(data, textStatus) {
+ switch(data.result) {
+ case 'done':
+ self.showPopup('generic-yes', 'Plik uaktualniony.');
+ self.refreshPanels();
+ break;
+ case 'nothing-to-do':
+ self.showPopup('generic-info', 'Brak zmian do uaktualnienia.');
+ break;
+ default:
+ self.showPopup('generic-error', data.errors && data.errors[0]);
+ }
+ },
+ error: function(rq, tstat, err) {
+ self.showPopup('generic-error', 'Błąd serwera: ' + err);
+ },
+ type: 'POST',
+ data: {}
+ });
+};
+
+Editor.prototype.sendMergeRequest = function (message) {
+ if( $('.panel-wrap.changed').length !== 0) {
+ alert("There are unsaved changes - can't commit.");
+ }
+
+ var self = this;
+
+ $.ajax({
+ url: $('#commit-dialog form').attr('action'),
+ dataType: 'json',
+ success: function(data, textStatus) {
+ switch(data.result) {
+ case 'done':
+ self.showPopup('generic-yes', 'Łączenie zmian powiodło się.');
+
+ if(data.localmodified) {
+ self.refreshPanels();
+ }
+
+ break;
+ case 'nothing-to-do':
+ self.showPopup('generic-info', 'Brak zmian do połaczenia.');
+ break;
+ default:
+ self.showPopup('generic-error', data.errors && data.errors[0]);
+ }
+ },
+ error: function(rq, tstat, err) {
+ self.showPopup('generic-error', 'Błąd serwera: ' + err);
+ },
+ type: 'POST',
+ data: {
+ 'message': message
+ }
+ });
+};
+
+Editor.prototype.postSplitRequest = function(s, f)
+{
+ $.ajax({
+ url: $('#split-dialog form').attr('action'),
+ dataType: 'html',
+ success: s,
+ error: f,
+ type: 'POST',
+ data: $('#split-dialog form').serialize()
+ });
+};
+