From: Lukasz Rekucki Date: Tue, 3 Nov 2009 18:46:11 +0000 (+0100) Subject: Przeksztalcenie odwrotne. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/c988cd5d12cb6203ca8216e05bcbc202e14a04f8?ds=sidebyside;hp=-c Przeksztalcenie odwrotne. --- c988cd5d12cb6203ca8216e05bcbc202e14a04f8 diff --git a/platforma/static/css/html.css b/platforma/static/css/html.css index 88560687..5d4e08c2 100755 --- a/platforma/static/css/html.css +++ b/platforma/static/css/html.css @@ -349,7 +349,7 @@ visibility: hidden; } -.htmlview *[x-editable] > .context-menu { +.context-menu { position: absolute; top: 0px; left: -50px; @@ -384,7 +384,7 @@ z-index: 3000; } -.htmlview *[x-editable] > .context-menu * { +.context-menu * { margin: 0px; display: block; @@ -396,45 +396,54 @@ border-bottom: 1px solid black; } -.htmlview *[x-editable] > .context-menu *:last-child { +.context-menu *:last-child { cursor: pointer; border-bottom: none; } -.htmlview *[x-editable] > .context-menu *:hover { +.context-menu *:hover { background-color: orange; } /* * VISIBILITY RULES */ -.htmlview *[x-editable] > .default-menu { +.default-menu { visibility: inherit; - opacity: 0.4; + opacity: 0.2; } -.htmlview *[x-editable] > .default-menu:hover { +.default-menu:hover { opacity: 1; } -.htmlview *[x-annotation-box][x-editable] > .default-menu { +.htmlview *[x-annotation-box] > .default-menu { opacity: 1; } .htmlview *[x-editable][x-open] > .default-menu { visibility: hidden; } +.htmlview *[x-editable][x-open] *[x-annotation-box] > .default-menu { + visibility: hidden; +} .htmlview *[x-editable] > .edit-menu { visibility: hidden; } +.htmlview *[x-editable] *[x-annotation-box] > .edit-menu { + visibility: hidden; +} .htmlview *[x-editable][x-open] > .edit-menu { visibility: visible; } +.htmlview *[x-editable][x-open] *[x-annotation-box] > .edit-menu { + visibility: visible; +} .html-editarea { - border: 2px solid black; + border: 0px; background-color: gray; padding: 1px; @@ -443,7 +452,8 @@ .html-editarea textarea { - border: 0px; + border: 2px solid black; + margin: 0px; padding: 0px; @@ -453,24 +463,4 @@ z-index: 0; font-size: 10pt; background-color: ivory; -} - -.html-editarea p.html-editarea-toolbar { - position: absolute; - background: gray; - - bottom: -26px; - height: 24px; - - left: 0px; - right: 0px; - - border: 2px solid black; - - margin: 0px; - padding: 0px; - - z-index: 100; -} - - +} \ No newline at end of file diff --git a/platforma/static/js/models.js b/platforma/static/js/models.js index 40525946..d2869ede 100755 --- a/platforma/static/js/models.js +++ b/platforma/static/js/models.js @@ -36,76 +36,174 @@ Editor.ToolbarButtonsModel = Editor.Model.extend({ }); -// Stany modelu: // -// -> error -> loading -// / -// empty -> loading -> synced -> unsynced -> loading -// \ -// -> dirty -> updating -> updated -> synced +// HTML Document Model // -Editor.XMLModel = Editor.Model.extend({ - _className: 'Editor.XMLModel', - serverURL: null, - data: '', +Editor.HTMLModel = Editor.Model.extend({ + _className: 'Editor.HTMLModel', + textURL: null, state: 'empty', - - init: function(document, serverURL) { + + init: function(document, textURL) { this._super(); this.set('state', 'empty'); this.set('revision', document.get('revision')); this.document = document; - this.serverURL = serverURL; - this.toolbarButtonsModel = new Editor.ToolbarButtonsModel(); + + this.textURL = textURL; + + this.htmlXSL = null; + this.wlmlXSL = null; + this.rawText = null; + + // create a parser and a serializer + this.parser = new DOMParser(); + this.serializer = new XMLSerializer(); + this.addObserver(this, 'data', this.dataChanged.bind(this)); }, - + load: function(force) { if (force || this.get('state') == 'empty') { this.set('state', 'loading'); - messageCenter.addMessage('info', 'xmlload', 'Wczytuję XML...'); + messageCenter.addMessage('info', 'xmlload', 'Wczytuję HTML...'); + + // request all stylesheets $.ajax({ - url: this.serverURL, + url: documentInfo.staticURL + 'xsl/wl2html_client.xsl', + dataType: 'xml', + success: this.htmlXSLLoadSuccess.bind(this), + error: this.loadingFailed.bind(this) + }); + + $.ajax({ + url: documentInfo.staticURL + 'xsl/html2wl_client.xsl', + dataType: 'xml', + success: this.wlmlXSLLoadSuccess.bind(this), + error: this.loadingFailed.bind(this) + }); + + $.ajax({ + url: this.textURL, dataType: 'text', data: { revision: this.get('revision'), user: this.document.get('user') }, - success: this.loadingSucceeded.bind(this), + success: this.textLoadSuccess.bind(this), error: this.loadingFailed.bind(this) }); return true; } return false; }, - - loadingSucceeded: function(data) { + + asWLML: function(element) + { + var result = this.wlmlXSL.transformToFragment(element, document); + + if(!result) { + console.log(this.wlmlXSL.transformToDocument(element)); + throw "Failed to transform fragment"; + } + + console.log("Transform result:", result); + return this.serializer.serializeToString(result); + }, + + updateWithWLML: function($element, text) + { + // filter the string + text = text.replace(/\/\s+/g, '
'); + var chunk = this.parser.parseFromString(""+text+"", "text/xml"); + + var errors = $('parsererror', chunk); + + // check if chunk is parsable + if(errors.length > 0) + throw {text: errors.text(), html: errors.html()}; + + var result = this.htmlXSL.transformToFragment(chunk, document); + + console.log("RESULT", this.serializer.serializeToString(result)); + + if(!result) + throw "WLML->HTML transformation failed."; + + $element.replaceWith(result); + }, + + createXSLT: function(xslt_doc) { + var p = new XSLTProcessor(); + p.importStylesheet(xslt_doc); + return p; + }, + + htmlXSLLoadSuccess: function(data) + { + try { + this.htmlXSL = this.createXSLT(data); + + if(this.wlmlXSL && this.htmlXSL && this.rawText) + this.loadSuccess(); + } catch(e) { + this.loadingFailed(); + } + }, + + wlmlXSLLoadSuccess: function(data) + { + try { + this.wlmlXSL = this.createXSLT(data); + + if(this.wlmlXSL && this.htmlXSL && this.rawText) + this.loadSuccess(); + } catch(e) { + this.loadingFailed(); + } + }, + + textLoadSuccess: function(data) { + this.rawText = data; + + if(this.wlmlXSL && this.htmlXSL && this.rawText) + this.loadSuccess(); + }, + + loadSuccess: function() { if (this.get('state') != 'loading') { alert('erroneous state:', this.get('state')); } - this.set('data', data); + + // prepare text + var doc = null; + doc = this.rawText.replace(/\/\s+/g, '
'); + doc = this.parser.parseFromString(doc, 'text/xml'); + doc = this.htmlXSL.transformToFragment(doc, document).firstChild; + + this.set('data', doc); this.set('state', 'synced'); - messageCenter.addMessage('success', 'xmlload', 'Wczytałem XML :-)'); + messageCenter.addMessage('success', 'xmlload', 'Wczytałem HTML :-)'); }, - + loadingFailed: function(response) { if (this.get('state') != 'loading') { alert('erroneous state:', this.get('state')); } - + var message = parseXHRError(response); - + this.set('error', '

Błąd przy ładowaniu XML

'+message+'

'); this.set('state', 'error'); - messageCenter.addMessage('error', 'xmlload', 'Nie udało mi się wczytać XML. Spróbuj ponownie :-('); + messageCenter.addMessage('error', 'xmlload', 'Nie udało mi się wczytać HTML. Spróbuj ponownie :-('); }, - + save: function(message) { if (this.get('state') == 'dirty') { this.set('state', 'updating'); messageCenter.addMessage('info', 'xmlsave', 'Zapisuję XML...'); - + var payload = { contents: this.get('data'), revision: this.get('revision'), @@ -114,7 +212,7 @@ Editor.XMLModel = Editor.Model.extend({ if (message) { payload.message = message; } - + $.ajax({ url: this.serverURL, type: 'post', @@ -127,7 +225,7 @@ Editor.XMLModel = Editor.Model.extend({ } return false; }, - + saveSucceeded: function(data) { if (this.get('state') != 'updating') { alert('erroneous state:', this.get('state')); @@ -136,7 +234,7 @@ Editor.XMLModel = Editor.Model.extend({ this.set('state', 'updated'); messageCenter.addMessage('success', 'xmlsave', 'Zapisałem XML :-)'); }, - + saveFailed: function() { if (this.get('state') != 'updating') { alert('erroneous state:', this.get('state')); @@ -144,7 +242,7 @@ Editor.XMLModel = Editor.Model.extend({ messageCenter.addMessage('error', 'xmlsave', 'Nie udało mi się zapisać XML. Spróbuj ponownie :-('); this.set('state', 'dirty'); }, - + // For debbuging set: function(property, value) { if (property == 'state') { @@ -152,13 +250,13 @@ Editor.XMLModel = Editor.Model.extend({ } return this._super(property, value); }, - + dataChanged: function(property, value) { if (this.get('state') == 'synced') { this.set('state', 'dirty'); } }, - + dispose: function() { this.removeObserver(this); this._super(); @@ -166,36 +264,36 @@ Editor.XMLModel = Editor.Model.extend({ }); -Editor.HTMLModel = Editor.Model.extend({ - _className: 'Editor.HTMLModel', - dataURL: null, - htmlURL: null, - renderURL: null, - displaData: '', - xmlParts: {}, +// Stany modelu: +// +// -> error -> loading +// / +// empty -> loading -> synced -> unsynced -> loading +// \ +// -> dirty -> updating -> updated -> synced +// +Editor.XMLModel = Editor.Model.extend({ + _className: 'Editor.XMLModel', + serverURL: null, + data: '', state: 'empty', - init: function(document, dataURL, htmlURL) { + init: function(document, serverURL) { this._super(); this.set('state', 'empty'); - this.set('revision', document.get('revision')); - + this.set('revision', document.get('revision')); this.document = document; - this.htmlURL = htmlURL; - this.dataURL = dataURL; - this.renderURL = documentInfo.renderURL; - this.xmlParts = {}; + this.serverURL = serverURL; + this.toolbarButtonsModel = new Editor.ToolbarButtonsModel(); + this.addObserver(this, 'data', this.dataChanged.bind(this)); }, load: function(force) { if (force || this.get('state') == 'empty') { this.set('state', 'loading'); - - // load the transformed data - // messageCenter.addMessage('info', 'Wczytuję HTML...'); - + messageCenter.addMessage('info', 'xmlload', 'Wczytuję XML...'); $.ajax({ - url: this.htmlURL, + url: this.serverURL, dataType: 'text', data: { revision: this.get('revision'), @@ -204,8 +302,10 @@ Editor.HTMLModel = Editor.Model.extend({ success: this.loadingSucceeded.bind(this), error: this.loadingFailed.bind(this) }); + return true; } - }, + return false; + }, loadingSucceeded: function(data) { if (this.get('state') != 'loading') { @@ -213,98 +313,38 @@ Editor.HTMLModel = Editor.Model.extend({ } this.set('data', data); this.set('state', 'synced'); + messageCenter.addMessage('success', 'xmlload', 'Wczytałem XML :-)'); }, - loadingFailed: function(response) { + loadingFailed: function(response) + { if (this.get('state') != 'loading') { alert('erroneous state:', this.get('state')); } - var err = parseXHRError(response); + var message = parseXHRError(response); - this.set('error', '

Nie udało się wczytać widoku HTML:

' + err.error_message); - this.set('state', 'error'); - }, - - getXMLPart: function(elem, callback) - { - var path = elem.attr('x-pointer'); - if(!this.xmlParts[path]) - this.loadXMLPart(elem, callback); - else - callback(path, this.xmlParts[path]); - }, - - loadXMLPart: function(elem, callback) - { - var path = elem.attr('x-pointer'); - var self = this; - - $.ajax({ - url: this.dataURL, - dataType: 'text', - data: { - revision: this.get('revision'), - user: this.document.get('user'), - chunk: path - // format: 'nl' - }, - success: function(data) { - self.xmlParts[path] = data; - console.log(data); - callback(path, data); - }, - // TODO: error handling - error: function(data) { - console.log('Failed to load fragment'); - callback(undefined, undefined); - } - }); - }, - - putXMLPart: function(elem, data, callback) { - var self = this; - - var path = elem.attr('x-pointer'); - this.xmlParts[path] = data; - - this.set('state', 'dirty'); - - /* re-render the changed fragment */ - $.ajax({ - url: this.renderURL, - type: "POST", - dataType: 'text; charset=utf-8', - data: { - fragment: data, - chunk: path - // format: 'nl' - }, - success: function(htmldata) { - callback(elem, htmldata); - self.set('state', 'dirty'); - } - }); + this.set('error', '

Błąd przy ładowaniu XML

'+message+'

'); + this.set('state', 'error'); + messageCenter.addMessage('error', 'xmlload', 'Nie udało mi się wczytać XML. Spróbuj ponownie :-('); }, - + save: function(message) { if (this.get('state') == 'dirty') { this.set('state', 'updating'); - + messageCenter.addMessage('info', 'xmlsave', 'Zapisuję XML...'); + var payload = { - chunks: $.toJSON(this.xmlParts), + contents: this.get('data'), revision: this.get('revision'), user: this.document.get('user') }; - if (message) { payload.message = message; } - - console.log(payload) - + $.ajax({ - url: this.dataURL, + url: this.serverURL, type: 'post', dataType: 'json', data: payload, @@ -314,38 +354,45 @@ Editor.HTMLModel = Editor.Model.extend({ return true; } return false; - }, - + saveSucceeded: function(data) { if (this.get('state') != 'updating') { alert('erroneous state:', this.get('state')); } - - // flush the cache - this.xmlParts = {}; - this.set('revision', data.revision); this.set('state', 'updated'); + messageCenter.addMessage('success', 'xmlsave', 'Zapisałem XML :-)'); }, - + saveFailed: function() { if (this.get('state') != 'updating') { alert('erroneous state:', this.get('state')); - } + } + messageCenter.addMessage('error', 'xmlsave', 'Nie udało mi się zapisać XML. Spróbuj ponownie :-('); this.set('state', 'dirty'); }, - + // For debbuging set: function(property, value) { if (property == 'state') { console.log(this.description(), ':', property, '=', value); } return this._super(property, value); + }, + + dataChanged: function(property, value) { + if (this.get('state') == 'synced') { + this.set('state', 'dirty'); + } + }, + + dispose: function() { + this.removeObserver(this); + this._super(); } }); - Editor.ImageGalleryModel = Editor.Model.extend({ _className: 'Editor.ImageGalleryModel', serverURL: null, @@ -449,7 +496,7 @@ Editor.DocumentModel = Editor.Model.extend({ this.contentModels = { 'xml': new Editor.XMLModel(this, data.text_url), - 'html': new Editor.HTMLModel(this, data.text_url, data.html_url), + 'html': new Editor.HTMLModel(this, data.text_url), 'gallery': new Editor.ImageGalleryModel(this, data.gallery_url) }; diff --git a/platforma/static/js/views/gallery.js b/platforma/static/js/views/gallery.js old mode 100644 new mode 100755 index 176b0abb..31b47cec --- a/platforma/static/js/views/gallery.js +++ b/platforma/static/js/views/gallery.js @@ -10,7 +10,8 @@ var ImageGalleryView = View.extend({ init: function(element, model, parent, template) { console.log("init for gallery"); - this._super(element, model, template); + var submodel = model.contentModels['gallery']; + this._super(element, submodel, template); this.parent = parent; console.log("gallery model", this.model); diff --git a/platforma/static/js/views/html.js b/platforma/static/js/views/html.js index cefd0d2b..8aff5f06 100755 --- a/platforma/static/js/views/html.js +++ b/platforma/static/js/views/html.js @@ -6,14 +6,14 @@ var HTMLView = View.extend({ template: 'html-view-template', init: function(element, model, parent, template) { - this._super(element, model, template); - this.parent = parent; + var submodel = model.contentModels['html']; + this._super(element, submodel, template); + this.parent = parent; this.model - .addObserver(this, 'data', this.modelDataChanged.bind(this)) + .addObserver(this, 'data', this.modelDataChanged.bind(this)) .addObserver(this, 'state', this.modelStateChanged.bind(this)); - - this.$menuTemplate = $(render_template('html-view-frag-menu-template', this)); + this.modelStateChanged('state', this.model.get('state')); this.modelDataChanged('data', this.model.get('data')); @@ -24,18 +24,19 @@ var HTMLView = View.extend({ this.themeBoxes = []; }, - modelDataChanged: function(property, value) { - $('.htmlview', this.element).html(value); + modelDataChanged: function(property, value) + { + if(!value) return; + + // the xml model changed + var container = $('.htmlview', this.element); + container.empty(); + container.append(value); + this.updatePrintLink(); - var self = this; - - /* upgrade editable elements */ - $("*[x-editable]", this.$docbase).each(function() { - $(this).append( self.$menuTemplate.clone() ); - }); - /* mark themes */ - /* $(".theme-ref", this.$docbase).each(function() { + /* mark themes */ + /* $(".theme-ref", this.$docbase).each(function() { var id = $(this).attr('x-theme-class'); var end = $("span.theme-end[x-theme-class = " + id+"]"); @@ -69,20 +70,23 @@ var HTMLView = View.extend({ } else if (value == 'error') { this.freeze(this.model.get('error')); $('.xml-editor-ref', this.overlay).click( - function(event) { - console.log("Sending scroll rq.", this); - try { - var href = $(this).attr('href').split('-'); - var line = parseInt(href[1]); - var column = parseInt(href[2]); + function(event) { + console.log("Sending scroll rq.", this); + try { + var href = $(this).attr('href').split('-'); + var line = parseInt(href[1]); + var column = parseInt(href[2]); - $(document).trigger('xml-scroll-request', {line:line, column:column}); - } catch(e) { - console.log(e); - } + $(document).trigger('xml-scroll-request', { + line:line, + column:column + }); + } catch(e) { + console.log(e); + } - return false; - }); + return false; + }); } }, @@ -119,7 +123,9 @@ var HTMLView = View.extend({ if(this.currentFocused && $p[0] == this.currentFocused[0]) { this.currentFocused = $p; - $box.css({'display': 'block'}); + $box.css({ + 'display': 'block' + }); } return; @@ -176,17 +182,24 @@ var HTMLView = View.extend({ { console.log($e); this.selectTheme($e.attr('x-theme-class')); + return false; } /* other buttons */ - if($e.hasClass('edit-button')) - this.openForEdit( this.editableFor($e) ); + try { + if($e.hasClass('edit-button')) + this.openForEdit( this.editableFor($e) ); - if($e.hasClass('accept-button')) - this.closeWithSave( this.editableFor($e) ); + if($e.hasClass('accept-button')) + this.closeWithSave( this.editableFor($e) ); - if($e.hasClass('reject-button')) - this.closeWithoutSave( this.editableFor($e) ); + if($e.hasClass('reject-button')) + this.closeWithoutSave( this.editableFor($e) ); + } catch(e) { + messageCenter.addMessage('error', "wlsave", 'Błąd:' + e.text); + } + + return false; }, unfocusAnnotation: function() @@ -198,15 +211,17 @@ var HTMLView = View.extend({ } if(this.currentOpen - && this.currentOpen.is("*[x-annotation-box]") - && this.currentOpen.parent()[0] == this.currentFocused[0]) - { + && this.currentOpen.is("*[x-annotation-box]") + && this.currentOpen.parent()[0] == this.currentFocused[0]) + { console.log("Can't unfocus open box"); return false; } var $box = $("*[x-annotation-box]", this.currentFocused); - $box.css({'display': 'none'}); + $box.css({ + 'display': 'none' + }); // this.currentFocused.removeAttr('x-focused'); // this.currentFocused.hide(); this.currentFocused = null; @@ -215,21 +230,20 @@ var HTMLView = View.extend({ focusAnnotation: function($e) { this.currentFocused = $e; var $box = $("*[x-annotation-box]", $e); - $box.css({'display': 'block'}); + $box.css({ + 'display': 'block' + }); - // $e.attr('x-focused', 'focused'); + // $e.attr('x-focused', 'focused'); }, closeWithSave: function($e) { var $edit = $e.data('edit-overlay'); var newText = $('textarea', $edit).val(); - this.model.putXMLPart($e, newText, function($e, html) { - this.renderPart($e, html); - $edit.remove(); - $e.removeAttr('x-open'); - }.bind(this) ); - this.currentOpen = null; + this.model.updateWithWLML($e, newText); + $edit.remove(); + this.currentOpen = null; }, closeWithoutSave: function($e) { @@ -264,54 +278,74 @@ var HTMLView = View.extend({ this.closeWithSave(this.currentOpen); } - var x = $origin[0].offsetLeft; - var y = $origin[0].offsetTop; - var w = $origin.outerWidth(); - var h = $origin.innerHeight(); + var $box = null + + // annotations overlay their sub box - not their own box // + if($origin.is(".annotation-inline-box")) + $box = $("*[x-annotation-box]", $origin); + else + $box = $origin; + + var x = $box[0].offsetLeft; + var y = $box[0].offsetTop; + var w = $box.outerWidth(); + var h = $box.innerHeight(); - console.log("Editable:", $origin, " offsetParent:", $origin[0].offsetParent); + console.log("Edit origin:", $origin, " box:", $box); + console.log("offsetParent:", $box[0].offsetParent); console.log("Dimensions: ", x, y, w , h); // start edition on this node var $overlay = $('
'); - $overlay.css({position: 'absolute', height: h, left: x, top: y, width: '95%'}); - $($origin[0].offsetParent).append($overlay); - $origin.data('edit-overlay', $overlay); - - this.model.getXMLPart($origin, function(path, data) { - $('textarea', $overlay).val(data); - }); - - if($origin.is("*[x-annotation-box]")) - { - var $b = $origin.parent(); - if(this.currentFocused) { - // if some other is focused - if($b[0] != this.currentFocused[0]) { - this.unfocusAnnotation(); - this.focusAnnotation($b); - } + $overlay.css({ + position: 'absolute', + height: h, + left: x, + top: y, + width: '95%' + }); + + try { + $('textarea', $overlay).val( this.model.asWLML($origin[0]) ); + + if($origin.is(".annotation-inline-box")) + { + if(this.currentFocused) { + // if some other is focused + if($origin[0] != this.currentFocused[0]) { + this.unfocusAnnotation(); + this.focusAnnotation($origin); + } // already focues + } + else { // nothing was focused + this.focusAnnotation($origin); + } } - else { // nothing was focused - this.focusAnnotation($b); + else { // this item is not focusable + if(this.currentFocused) this.unfocusAnnotation(); } + + $($box[0].offsetParent).append($overlay); + $origin.data('edit-overlay', $overlay); + + this.currentOpen = $origin; + $origin.attr('x-open', 'open'); } - else { // this item is not focusable - if(this.currentFocused) this.unfocusAnnotation(); + catch(e) { + console.log("Can't open", e); } - - this.currentOpen = $origin; - $origin.attr('x-open', 'open'); return false; }, addTheme: function() { - var selection = document.getSelection(); + var selection = window.getSelection(); var n = selection.rangeCount; + + console.log("Range count:", n); if(n == 0) window.alert("Nie zaznaczono żadnego obszaru"); @@ -320,34 +354,39 @@ var HTMLView = View.extend({ if(n > 1) window.alert("Zaznacz jeden obszar"); + // from this point, we will assume that the ranges are disjoint - for(var i=0; i < n; i++) { + for(var i=0; i < n; i++) + { var range = selection.getRangeAt(i); console.log(i, range.startContainer, range.endContainer); var date = Date.now(); var random = Math.floor(4000000000*Math.random()); var id = (''+date) + '-' + (''+random); - var ipoint = document.createRange(); - - // Firefox alters the later node when inserting, so - // insert from end - ipoint.setStart(range.endContainer, range.endOffset); - elem = $('')[0]; - ipoint.insertNode(elem); + var spoint = document.createRange(); + var epoint = document.createRange(); + + spoint.setStart(range.startContainer, range.startOffset); + epoint.setStart(range.endContainer, range.endOffset); // insert theme-ref - ipoint.setStart(range.startContainer, range.startOffset); - var elem = $('Nowy motyw')[0]; - ipoint.insertNode(elem); - ipoint.setStartBefore(elem); + + var elem = $('Nowy motyw'); + elem.attr('x-attrib-id', 'm'+id); + spoint.insertNode(elem[0]); // insert theme-begin - elem = $('')[0]; - ipoint.insertNode(elem); + elem = $(''); + elem.attr('x-attrib-id', 'b'+id); + spoint.insertNode(elem[0]); + + elem = $(''); + elem.attr('x-attrib-id', 'e'+id); + epoint.insertNode(elem[0]); } - selection.removeAllRanges(); + //selection.removeAllRanges(); }, selectTheme: function(themeId) diff --git a/platforma/static/js/views/panel_container.js b/platforma/static/js/views/panel_container.js old mode 100644 new mode 100755 index 6dbddd98..f4bdc89f --- a/platforma/static/js/views/panel_container.js +++ b/platforma/static/js/views/panel_container.js @@ -26,9 +26,8 @@ var PanelContainerView = View.extend({ } if( value != 'empty') { - this.contentView = new klass($('.content-view', - this.element.get(0)), this.model.contentModels[value], this); - $('.panel-main-toolbar .refresh', this.element.get(0)).attr('disabled', null); + this.contentView = new klass($('.content-view', this.element.get(0)), this.model, this); + $('.panel-main-toolbar .refresh', this.element.get(0)).attr('disabled', null); } }, diff --git a/platforma/static/js/views/xml.js b/platforma/static/js/views/xml.js old mode 100644 new mode 100755 index 6f0b6fa6..0dd5453f --- a/platforma/static/js/views/xml.js +++ b/platforma/static/js/views/xml.js @@ -8,8 +8,11 @@ var XMLView = View.extend({ buttonToolbar: null, init: function(element, model, parent, template) { - this._super(element, model, template); + var submodel = model.contentModels['xml']; + this._super(element, submodel, template); + this.parent = parent; + this.buttonToolbar = new ButtonToolbarView( $('.xmlview-toolbar', this.element), this.model.toolbarButtonsModel, parent); diff --git a/platforma/static/xsl/html2wl_client.xsl b/platforma/static/xsl/html2wl_client.xsl new file mode 100755 index 00000000..d92a4d3e --- /dev/null +++ b/platforma/static/xsl/html2wl_client.xsl @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + / + + + + + + + / + + + + + + + / + + + + + + + + + + + \ No newline at end of file diff --git a/platforma/static/xsl/wl2html_client.xsl b/platforma/static/xsl/wl2html_client.xsl index 85ff4a38..7a7da8c4 100755 --- a/platforma/static/xsl/wl2html_client.xsl +++ b/platforma/static/xsl/wl2html_client.xsl @@ -24,9 +24,11 @@ Base tag for rendering the whole text --> - - - + + + + + - + + +
+ + + +
+
+ + + +
+ + + +
+
+ + + +
+ + + +
+
+ +
@@ -64,6 +93,7 @@

+ @@ -81,6 +111,7 @@

+ @@ -103,6 +134,7 @@

+ @@ -126,6 +158,7 @@

+ @@ -176,6 +209,7 @@

+ @@ -190,7 +224,7 @@ --> -

+
@@ -199,7 +233,8 @@ -

+

+ @@ -209,6 +244,7 @@

+ @@ -229,6 +265,7 @@

+ @@ -242,6 +279,7 @@

+ @@ -255,6 +293,7 @@

+ @@ -272,6 +311,7 @@

+ @@ -281,6 +321,7 @@

+ @@ -295,6 +336,7 @@

+ @@ -304,6 +346,7 @@

+ @@ -379,6 +422,7 @@

+ @@ -388,6 +432,7 @@

+ @@ -397,6 +442,7 @@

+ @@ -410,27 +456,26 @@ -->

+ + - - + - + + - - + - - + @@ -438,31 +483,42 @@ + - + + + - -

+ +

- + - + -

+

+ -

+

- + - + -

-
-
- - +

+ + + +
+ + + + + + + @@ -480,11 +536,11 @@ --> - + - + @@ -506,7 +562,7 @@
- +
@@ -531,35 +587,36 @@ Przypisy i motywy --> - + + - - - - - + + + + - + + - - + + @@ -587,5 +644,21 @@
+ + + + Edit + + + OK + Cancel + + + + + + + + \ No newline at end of file diff --git a/platforma/templates/explorer/editor.html b/platforma/templates/explorer/editor.html index 7db4f44a..247f59ca 100755 --- a/platforma/templates/explorer/editor.html +++ b/platforma/templates/explorer/editor.html @@ -12,9 +12,8 @@ docID: '{{ fileid }}', userID: '{{ euser }}', docURL: '{% url document_view fileid %}{% if euser %}?user={{ euser|urlencode }}{% endif %}', - toolbarURL: '{% url toolbar_buttons %}', - renderURL: '{% url api.views.render %}', - staticURL: '{{ STATIC_URL }}' + toolbarURL: '{% url toolbar_buttons %}', + staticURL: '{{ STATIC_URL }}' } @@ -71,18 +70,6 @@
- - - -