X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/b0d77fd4dd2b177e77e2bb038a5864567adfd9df..514e98aeae05045d0086aae39960124a572e646f:/platforma/static/js/main.js diff --git a/platforma/static/js/main.js b/platforma/static/js/main.js index 00bc9c66..3c1a3c00 100644 --- a/platforma/static/js/main.js +++ b/platforma/static/js/main.js @@ -145,7 +145,7 @@ function gallery(element, url) { }); $('.change-gallery', element).click(function() { $('.chosen-gallery').val($('#document-meta .gallery').html() || '/platforma/gallery/'); - $('.gallery-image').animate({top: 53}, 200); + $('.gallery-image').animate({top: 60}, 200); $('.chosen-gallery').focus(); }); $('.change-gallery-ok', element).click(function() { @@ -154,10 +154,10 @@ function gallery(element, url) { } $('#document-meta .gallery').html($('.chosen-gallery').val()); updateGallery($('.chosen-gallery').val()); - $('.gallery-image').animate({top: 27}, 200); + $('.gallery-image').animate({top: 30}, 200); }); $('.change-gallery-cancel', element).click(function() { - $('.gallery-image').animate({top: 27}, 200); + $('.gallery-image').animate({top: 30}, 200); }); $('.gallery-image img', element).load(function() { @@ -269,14 +269,14 @@ function gallery(element, url) { element.data('images', data); pn.val(1); pn.change(); - $('img', element).show(); + $('.gallery-image img', element).show(); }, error: function(data) { element.data('images', []); pn.val(1); pn.change(); - $('img', element).hide(); + $('.gallery-image img', element).hide(); } }); } @@ -301,7 +301,11 @@ function transform(editor, callback) { callback(); } }, error: function(text) { - $('#html-view').html('

Wystąpił błąd:

' + text + '
'); + var message = $('
');
+				message.text(text);
+                $('#html-view').html('

Wystąpił błąd:

' + 
+				    message.html() + '
'); + $.unblockUI(); if (callback) { callback(); @@ -393,6 +397,23 @@ function html(element) { return true; } + + var ANNOT_ALLOWED = ['wyroznienie']; + + function html2plainText(fragment) { + var text = ""; + + $(fragment.childNodes).each(function() { + if(this.nodeType == 3) // textNode + text += this.nodeValue; + else if (this.nodeType == 1 + && $.inArray($(this).attr('x-node'), ANNOT_ALLOWED) != -1 ){ + text += html2plainText(this); + } + }); + + return text; + } function addAnnotation() { @@ -418,7 +439,10 @@ function html(element) { return false; } - var text = range.toString(); + // BUG #273 - selected text can contain themes, which should be omited from + // defining term + var text = html2plainText( range.cloneContents() ); + var tag = $(''); range.collapse(false); range.insertNode(tag[0]); @@ -449,12 +473,20 @@ function html(element) { // for now allow only 1 range if(n > 1) { - window.alert("Zaznacz jeden obszar"); + window.alert("Zaznacz jeden obszar."); return false; } + // remember the selected range var range = selection.getRangeAt(0); + + + if( $(range.startContainer).is('.html-editarea') + || $(range.endContainer).is('.html-editarea') ) { + window.alert("Motywy można oznaczać tylko na tekście nie otwartym do edycji. \n Zamknij edytowany fragment i spróbuj ponownie."); + return false; + } // verify if the start/end points make even sense - // they must be inside a x-node (otherwise they will be discarded) @@ -491,7 +523,7 @@ function html(element) { etag.replaceWith(text); xml2html({ xml: '', - success: function(text) { + success: function(text) { mtag = $(''); spoint.insertNode(mtag[0]); mtag.replaceWith(text); @@ -575,8 +607,14 @@ function html(element) { function save(argument) { var nodeName = $box.attr('x-node') || 'pe'; + var insertedText = $('textarea', $overlay).val(); + + if ($origin.is('.motyw')) { + insertedText = insertedText.replace(/,\s*$/, ''); + } + xml2html({ - xml: '<' + nodeName + '>' + $('textarea', $overlay).val() + '', + xml: '<' + nodeName + '>' + insertedText + '', success: function(element) { $box.html($(element).html()); $overlay.remove(); @@ -652,6 +690,7 @@ $(function() { }, iframeClass: 'xml-iframe', textWrapping: true, + lineNumbers: true, tabMode: 'spaces', indentUnit: 0, initCallback: function(editor) { @@ -736,7 +775,7 @@ $(function() { event.preventDefault(); var params = eval("(" + $(this).attr('ui:action-params') + ")"); scriptletCenter.scriptlets[$(this).attr('ui:action')](editor, params); - }); + }); $('.toolbar select').change(function() { var slug = $(this).val();