+ if( changed_panel.length > 1) {
+ alert('Błąd: więcej niż jeden panel został zmodyfikowany. Nie można zapisać.');
+ return false;
+ }
+
+ saveInfo = changed_panel.data('ctrl').saveInfo();
+ var postData = ''
+
+ if(saveInfo.postData instanceof Object)
+ postData = $.param(saveInfo.postData);
+ else
+ postData = saveInfo.postData;
+
+ postData += '&' + $.param({
+ 'commit_message': msg
+ })
+
+ $.ajax({
+ url: saveInfo.url,
+ dataType: 'json',
+ success: function(data, textStatus) {
+ if (data.result != 'ok')
+ self.showPopup('save-error', data.errors[0]);
+ else {
+ self.refreshPanels(changed_panel);
+ $('#toolbar-button-save').attr('disabled', 'disabled');
+ $('#toolbar-button-commit').removeAttr('disabled');
+ if(self.autosaveTimer)
+ clearTimeout(self.autosaveTimer);
+
+ self.showPopup('save-successful');
+ }
+ },
+ error: function(rq, tstat, err) {
+ self.showPopup('save-error');
+ },
+ 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;
+
+ $('#toolbar-button-save').removeAttr('disabled');
+ $('#toolbar-button-commit').attr('disabled', 'disabled');
+
+ if(this.autosaveTimer) return;
+ this.autosaveTimer = setTimeout( function() {
+ self.autoSave();
+ }, 300000 );
+};
+
+Editor.prototype.refreshPanels = function(goodPanel) {
+ var self = this;
+ var panels = $('#' + self.rootDiv.attr('id') +' > *.panel-wrap', self.rootDiv.parent());
+
+ panels.each(function() {
+ var panel = $(this).data('ctrl');
+ $.log('Refreshing: ', this, panel);
+ if ( panel.changed() )
+ panel.unmarkChanged();
+ else
+ panel.refresh();
+ });
+};
+
+
+Editor.prototype.sendPullRequest = function () {
+ if( $('.panel-wrap.changed').length != 0)
+ alert("There are unsaved changes - can't make a pull request.");
+
+ this.showPopup('not-implemented');
+/*