display: none;\r
}\r
\r
+#rng-skelton {\r
+ position: relative;\r
+}\r
+\r
#rng-skelton-menu {\r
float: right;\r
}\r
\r
+#rng-skelton-messages {\r
+ position: absolute;\r
+ top: -22px;\r
+ width:100%;\r
+ text-align:center;\r
+}\r
+\r
+#rng-skelton-messages span {\r
+ font-weight: bold;\r
+ background: #f9edbe;\r
+ padding: 2px 5px;\r
+ border: solid 1px #f6e39c;\r
+}\r
+\r
#rng-skelton-menu ul {\r
list-style-type: none;\r
}\r
sandbox.publish('documentChanged', doc, reason);\r
},\r
saveDocument: function() {\r
+ sandbox.publish('savingStarted');\r
$.ajax({\r
method: 'post',\r
url: '/' + gettext('editor') + '/' + document_id,\r
- data: JSON.stringify({document:doc})\r
+ data: JSON.stringify({document:doc}),\r
+ success: function() {sandbox.publish('savingEnded', 'success');},\r
+ error: function() {sandbox.publish('savingEnded', 'error');}\r
});\r
}\r
\r
documentChanged: function(document, reason) {\r
var slug = (reason === 'visual_edit' ? 'source' : 'visual');\r
sandbox.getModule(slug+'Editor').setDocument(document);\r
+ },\r
+ savingStarted: function() {\r
+ sandbox.getModule('skelton').deactivateCommand('save');\r
+ sandbox.getModule('skelton').showMessage(gettext('Saving...'));\r
+ },\r
+ savingEnded: function(status) {\r
+ sandbox.getModule('skelton').activateCommand('save');\r
+ sandbox.getModule('skelton').clearMessage();\r
}\r
}\r
\r
\r
var view = $(sandbox.getTemplate('main')());\r
\r
- view.find('#rng-skelton-menu a').click(function(e) {\r
+ view.find('#rng-skelton-menu button').click(function(e) {\r
e.preventDefault();\r
sandbox.publish('cmd.' + $(e.target).attr('data-cmd'));\r
});\r
},\r
setMainView: function(mainView) {\r
view.find('#rng-skelton-mainView').html(mainView);\r
+ },\r
+ showMessage: function(message) {\r
+ view.find('#rng-skelton-messages').html('<span>'+message+'</span>').show();\r
+ },\r
+ clearMessage: function() {\r
+ view.find('#rng-skelton-messages').empty().hide();\r
+ },\r
+ deactivateCommand: function(cmd) {\r
+ view.find('[data-cmd='+cmd+']').addClass('disabled');\r
+ },\r
+ activateCommand: function(cmd) {\r
+ view.find('[data-cmd='+cmd+']').removeClass('disabled');\r
}\r
}\r
};
\ No newline at end of file