X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/f46d9319a26b5cf74fcf5aa24a5a8df18f1bda74..3dd811118b8168c78704c7271ca4e9c3e3be5079:/project/static/js/models.js diff --git a/project/static/js/models.js b/project/static/js/models.js index 97682d02..b2c7440c 100644 --- a/project/static/js/models.js +++ b/project/static/js/models.js @@ -8,13 +8,40 @@ 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, + data: '', init: function(serverURL) { this._super(); this.serverURL = serverURL; + this.toolbarButtonsModel = new Editor.ToolbarButtonsModel(); }, getData: function() { @@ -116,6 +143,7 @@ var leftPanelView, rightPanelContainer, doc; $(function() { doc = new Editor.DocumentModel(); + var editor = new EditorView('body', doc); var splitView = new SplitView('#splitview', doc); leftPanelView = new PanelContainerView('#left-panel-container', doc); rightPanelContainer = new PanelContainerView('#right-panel-container', doc);