+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');
+/*
+ $.ajax({
+ url: '/pull-request',
+ dataType: 'json',
+ success: function(data, textStatus) {
+ $.log('data: ' + data);
+ },
+ error: function(rq, tstat, err) {
+ $.log('commit error', rq, tstat, err);
+ },
+ type: 'POST',
+ data: {}
+ }); */
+}
+
+Editor.prototype.showPopup = function(name)
+{
+ var self = this;
+ self.popupQueue.push(name)
+
+ if( self.popupQueue.length > 1)
+ return;
+
+ $('#message-box > #' + name).fadeIn();
+
+ self._nextPopup = function() {
+ var elem = self.popupQueue.pop()
+ if(elem) {
+ elem = $('#message-box > #' + elem);
+ elem.fadeOut(300, function() {
+ if( self.popupQueue.length > 0)
+ $('#message-box > #' + self.popupQueue[0]).fadeIn();
+ setTimeout(self._nextPopup, 1700);
+ });
+
+ }
+ }
+
+ setTimeout(self._nextPopup, 2000);
+}
+
+