X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/213b1af47b5f2c279db50304d318eb972289e3aa..36387dac2e103ca656be9dc65fabb936f80191d1:/project/static/js/models.js 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); });