X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/213b1af47b5f2c279db50304d318eb972289e3aa..97e1a72c211205e4596accbfc86cf5eeaec487ee:/project/static/js/models.js?ds=sidebyside diff --git a/project/static/js/models.js b/project/static/js/models.js index 9a42bca1..ab021f51 100644 --- a/project/static/js/models.js +++ b/project/static/js/models.js @@ -23,7 +23,15 @@ Editor.ToolbarButtonsModel = Editor.Model.extend({ } }, - loadSucceeded: function(data) { + loadSucceeded: function(data) + { + // do some escaping + $.each(data, function() { + $.each(this.buttons, function() { + //do some lame escapes + this.tooltip = this.tooltip.replace(/"/g, """); + }); + }); this.set('buttons', data); } }); @@ -176,7 +184,7 @@ Editor.HTMLModel = Editor.Model.extend({ this.set('state', 'loading'); // load the transformed data - messageCenter.addMessage('info', 'WczytujÄ HTML...'); + // messageCenter.addMessage('info', 'WczytujÄ HTML...'); $.ajax({ url: this.htmlURL, @@ -196,16 +204,42 @@ Editor.HTMLModel = Editor.Model.extend({ } this.set('data', data); this.set('state', 'synced'); - messageCenter.addMessage('success', 'WczytaÅem HTML :-)'); + // messageCenter.addMessage('success', 'WczytaÅem HTML :-)'); }, - loadingFailed: function() { + loadingFailed: function(response) { if (this.get('state') != 'loading') { alert('erroneous state:', this.get('state')); } - this.set('error', 'Nie udaÅo siÄ zaÅadowaÄ panelu'); + + var json_response = null; + var message = ""; + + try { + json_response = $.evalJSON(response.responseText); + + if(json_response.reason == 'xml-parse-error') { + + message = json_response.message.replace(/(line\s+)(\d+)(\s+)/i, + "$1$2$3"); + + message = message.replace(/(line\s+)(\d+)(\,\s*column\s+)(\d+)/i, + "$1$2$3$4"); + + + } + else { + message = json_response.message || json_response.reason || "nieznany bÅÄ d."; + } + } + catch (e) { + message = response.statusText; + } + + this.set('error', '
Nie udaÅo siÄ wczytaÄ widoku HTML:
' + message); + this.set('state', 'error'); - messageCenter.addMessage('error', 'Nie udaÅo mi siÄ wczytaÄ HTML. Spróbuj ponownie :-('); + // messageCenter.addMessage('error', 'Nie udaÅo mi siÄ wczytaÄ HTML. Spróbuj ponownie :-('); }, getXMLPart: function(elem, callback) @@ -548,12 +582,12 @@ $(function() toolbarUrl = $('#api-toolbar-url').text(); doc = new Editor.DocumentModel(); - var editor = new EditorView('#body-wrap', doc); - editor.freeze(); - var flashView = new FlashView('#flashview', messageCenter); - var splitView = new SplitView('#splitview', doc); + EditorView = new EditorView('#body-wrap', doc); + EditorView.freeze(); leftPanelView = new PanelContainerView('#left-panel-container', doc); rightPanelContainer = new PanelContainerView('#right-panel-container', doc); + + var flashView = new FlashView('#flashview', messageCenter); });