+
+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.sendPullRequest = function () {
+ if( $('.panel-wrap.changed').length != 0)
+ alert("There are unsaved changes - can't commit.");
+
+ var self = this;
+
+ /* this.showPopup('not-implemented'); */
+
+ $.log('URL !: ', $('#toolbar-commit-form').attr('action'));
+
+ $.ajax({
+ url: $('#toolbar-commit-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': $('#toolbar-commit-message').val() }
+ });
+}
+
+Editor.prototype.showPopup = function(name, text, timeout)
+{
+ timeout = timeout || 4000;
+ var self = this;
+ self.popupQueue.push( [name, text, timeout] )
+
+ if( self.popupQueue.length > 1)
+ return;
+
+ var box = $('#message-box > #' + name);
+ $('*.data', box).html(text || '');
+ box.fadeIn();
+
+ if(timeout > 0)
+ setTimeout( $.fbind(self, self.advancePopupQueue), timeout);
+};
+
+Editor.prototype.advancePopupQueue = function() {
+ var self = this;
+ var elem = this.popupQueue.shift();
+ if(elem) {
+ var box = $('#message-box > #' + elem[0]);
+
+ box.fadeOut(200, function()
+ {
+ $('*.data', box).html();
+
+ if( self.popupQueue.length > 0) {
+ var ibox = $('#message-box > #' + self.popupQueue[0][0]);
+ $('*.data', ibox).html(self.popupQueue[0][1]);
+ ibox.fadeIn();
+ if(self.popupQueue[0][2] > 0)
+ setTimeout( $.fbind(self, self.advancePopupQueue), self.popupQueue[0][2]);
+ }
+ });
+ }
+};
+
+Editor.prototype.allPanels = function() {
+ return $('#' + this.rootDiv.attr('id') +' > *.panel-wrap', this.rootDiv.parent());
+}
+
+
+Editor.prototype.registerScriptlet = function(scriptlet_id, scriptlet_func)
+{
+ // I briefly assume, that it's verified not to break the world on SS
+ if (!this[scriptlet_id])
+ this[scriptlet_id] = scriptlet_func;
+}
+
+Editor.prototype.callScriptlet = function(scriptlet_id, panel, params) {
+ var func = this[scriptlet_id]
+ if(!func)
+ throw 'No scriptlet named "' + scriptlet_id + '" found.';
+
+ return func(this, panel, params);
+}
+