X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/f938afb8ab4cb091d12e0ef0311eaea14b774798..cbae1e671056708da934db5f07f8a5e9d9afc95c:/redakcja/static/js/wiki/xslt.js?ds=sidebyside
diff --git a/redakcja/static/js/wiki/xslt.js b/redakcja/static/js/wiki/xslt.js
index dda12a16..2bab378d 100644
--- a/redakcja/static/js/wiki/xslt.js
+++ b/redakcja/static/js/wiki/xslt.js
@@ -33,32 +33,71 @@ function withStylesheets(code_block, onError)
}
}
+var canonThemes = null;
-function xml2html(options) {
- withStylesheets(function() {
- var xml = options.xml.replace(/\/\s+/g, '
');
- var parser = new DOMParser();
- var serializer = new XMLSerializer();
- var doc = parser.parseFromString(xml, 'text/xml');
- var error = $('parsererror', doc);
-
- if (error.length == 0) {
- doc = xml2htmlStylesheet.transformToFragment(doc, document);
- console.log(doc.firstChild);
-
- if(doc.firstChild === null) {
- options.error("BÅÄ
d w przetwarzaniu XML.");
- return;
- }
+// Wykonuje block z zaÅadowanymi kanonicznymi motywami
+function withThemes(code_block, onError)
+{
+ if (!canonThemes) {
+ $.blockUI({message: 'Åadowanie motywów...'});
+ $.ajax({
+ url: '/themes',
+ dataType: 'text',
+ success: function(data) {
+ canonThemes = {};
+ themes = data.split('\n');
+ for (i in themes) {
+ canonThemes[themes[i]] = 1;
+ }
+ $.unblockUI();
+ code_block();
+ },
+ error: onError
+ })
+ }
+ else {
+ code_block();
+ }
+}
- error = $('parsererror', doc);
- }
- if (error.length > 0 && options.error) {
- options.error(error.text());
- } else {
- options.success(doc.firstChild);
- }
+
+function xml2html(options) {
+ withStylesheets(function() {
+ withThemes(function() {
+ var xml = options.xml.replace(/\/\s+/g, '
');
+ var parser = new DOMParser();
+ var serializer = new XMLSerializer();
+ var doc = parser.parseFromString(xml, 'text/xml');
+ var error = $('parsererror', doc);
+
+ if (error.length == 0) {
+ doc = xml2htmlStylesheet.transformToFragment(doc, document);
+ console.log(doc.firstChild);
+
+ if(doc.firstChild === null) {
+ options.error("BÅÄ
d w przetwarzaniu XML.");
+ return;
+ }
+
+ error = $('parsererror', doc);
+ }
+
+ if (error.length > 0 && options.error) {
+ options.error(error.text());
+ } else {
+ $('.theme-text-list', doc.firstChild).each(function(){
+ var themes = $(this).html().split(',');
+ for (i in themes) {
+ themes[i] = $.trim(themes[i]);
+ if (!(themes[i] in canonThemes))
+ themes[i] = '' + themes[i] + ""
+ }
+ $(this).html(themes.join(', '));
+ });
+ options.success(doc.firstChild);
+ }
+ }, function() { options.error && options.error('Nie udaÅo siÄ zaÅadowaÄ motywów'); });
}, function() { options.error && options.error('Nie udaÅo siÄ zaÅadowaÄ XSLT'); });
}
@@ -218,7 +257,8 @@ HTMLSerializer.prototype.serialize = function(rootElement, stripOuter)
switch(token.node.nodeType) {
case ELEMENT_NODE:
- if(token.node.hasAttribute('x-pass-thru')) {
+ if(token.node.hasAttribute('x-pass-thru')
+ || token.node.hasAttribute('data-pass-thru')) {
self._pushChildren(token.node);
break;
}