X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/b363e4352ce32f4518b5e5bb794635074d5f6ba6..b348abeb083671e831f711d3d41949a9b3f3a7b4:/project/static/js/models.js?ds=sidebyside diff --git a/project/static/js/models.js b/project/static/js/models.js index 5c5e6fb1..b2c7440c 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() { @@ -117,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);