X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/006c13d480258ab24c03abc8fef60aad8aa66e71..38747104cc8581d642f3c5a0d78c17565cc9988c:/project/static/js/models.js diff --git a/project/static/js/models.js b/project/static/js/models.js index 5c5e6fb1..96cab868 100644 --- a/project/static/js/models.js +++ b/project/static/js/models.js @@ -8,6 +8,31 @@ Editor.Model = Editor.Object.extend({ }); +Editor.ToolbarButtonsModel = Editor.Model.extend({ + _className: 'Editor.ToolbarButtonsModel', + serverURL: '/api/toolbar/buttons', + buttons: {}, + + init: function() { + this._super(); + }, + + load: function() { + if (!this.get('buttons').length) { + $.ajax({ + url: this.serverURL, + dataType: 'json', + success: this.loadSucceeded.bind(this) + }); + } + }, + + loadSucceeded: function(data) { + this.set('buttons', data); + } +}); + + Editor.XMLModel = Editor.Model.extend({ _className: 'Editor.XMLModel', serverURL: null, @@ -16,6 +41,7 @@ Editor.XMLModel = Editor.Model.extend({ init: function(serverURL) { this._super(); this.serverURL = serverURL; + this.toolbarButtonsModel = new Editor.ToolbarButtonsModel(); }, getData: function() {