args = $.makeArray(arguments)
var hookName = args.splice(0,1)[0]
var noHookAction = args.splice(0,1)[0]
+ var result = false;
$.log('calling hook: ', hookName, 'with args: ', args);
if(this.hooks && this.hooks[hookName])
- {
- return this.hooks[hookName].apply(this, args);
- }
- else if (noHookAction instanceof Function)
- return noHookAction(args);
- else return false;
+ result = this.hooks[hookName].apply(this, args);
+ else if (noHookAction instanceof Function)
+ result = noHookAction(args);
+ return result;
}
Panel.prototype.load = function (url) {
}
Panel.prototype.refresh = function(event, data) {
+ var self = this;
reload = function() {
- $.log('hard reload for panel ', this.current_url);
- this.load(this.current_url);
+ $.log('hard reload for panel ', self.current_url);
+ self.load(self.current_url);
return true;
}
}
Panel.prototype.markChanged = function () {
- if(!this.wrap.hasClass('changed') ) // TODO: is this needed ?
- this.wrap.addClass('changed');
+ this.wrap.addClass('changed');
}
Panel.prototype.changed = function () {
});
});
- $(document).bind('panel:contentChanged', function(event, data) {
- $('#toolbar-button-save').removeAttr('disabled');
- });
+ $(document).bind('panel:contentChanged', function() { self.onContentChanged.apply(self, arguments) });
$('#toolbar-button-save').click( function (event, data) { self.saveToBranch(); } );
+ $('#toolbar-button-commit').click( function (event, data) { self.sendPullRequest(); } );
self.rootDiv.bind('stopResize', function() { self.savePanelOptions() });
}
success: function(data, textStatus) {
if (data.result != 'ok')
$.log('save errors: ', data.errors)
- else
+ else {
self.refreshPanels(changed_panel);
- $('#toolbar-button-save').attr('disabled', 'disabled');
+ $('#toolbar-button-save').attr('disabled', 'disabled');
+ $('#toolbar-button-commit').removeAttr('disabled');
+ }
},
error: function(rq, tstat, err) {
$.log('save error', rq, tstat, err);
});
};
+Editor.prototype.onContentChanged = function(event, data) {
+ $('#toolbar-button-save').removeAttr('disabled');
+ $('#toolbar-button-commit').attr('disabled', 'disabled');
+};
+
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(this, panel);
+ $.log('Refreshing: ', this, panel);
if ( panel.changed() )
panel.unmarkChanged();
else
});
};
+
+Editor.prototype.sendPullRequest = function () {
+ if( $('.panel-wrap.changed').length != 0)
+ alert("There are unsaved changes - can't make a pull request.");
+
+ $.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: {}
+ });
+}
+
$(function() {
editor = new Editor();
{% load toolbar_tags %}
{% toolbar %}
+ <div class="change-font-size" style="">
+ <div class="decrease-font-size">A<sup>-</sup></div>
+ <div class="increase-font-size">A<sup>+</sup></div>
+ </div>
<div class="iframe-container" style="position: absolute; top: 48px; left:0px; right:0px; bottom: 0px;">
<textarea name="text">{{ text }}</textarea>
</div>
}
});
+ $('.decrease-font-size', panel).click(function() {
+ var frameBody = $('body', $(texteditor.frame).contents());
+ console.log(frameBody.css('font-size'));
+ frameBody.css('font-size', parseInt(frameBody.css('font-size')) - 2);
+ });
+
+ $('.increase-font-size', panel).click(function() {
+ var frameBody = $('body', $(texteditor.frame).contents());
+ console.log(frameBody.css('font-size'));
+ frameBody.css('font-size', parseInt(frameBody.css('font-size')) + 2);
+ });
+
this.texteditor = texteditor;
},
},
- refresh: function() {
- return false;
- },
+ //refresh: function() { }, // no support for refresh
saveInfo: function(saveInfo) {
var myInfo = {