X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/bfdfacaea46413e3e32e4bdb3760fbe6f1ade25b..916dc16ab669079790e11beba72cb14c9b951389:/platforma/static/js/main.js?ds=sidebyside diff --git a/platforma/static/js/main.js b/platforma/static/js/main.js index c7e0af86..0f227b4a 100644 --- a/platforma/static/js/main.js +++ b/platforma/static/js/main.js @@ -473,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) @@ -515,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); @@ -599,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(); @@ -645,6 +659,13 @@ function html(element) { if (!editable.hasClass('active')) { editable.addClass('active').append(button); } + if (editable.is('.annotation-inline-box')) { + $('*[x-annotation-box]', editable) + .css({width: 300, position: 'absolute', left: event.clientX - editable.offset().left + 5, top: event.clientY - editable.offset().top + 5}) + .show(); + } else { + $('*[x-annotation-box]').hide(); + } }); $('.motyw').live('click', function() { @@ -676,6 +697,7 @@ $(function() { }, iframeClass: 'xml-iframe', textWrapping: true, + lineNumbers: true, tabMode: 'spaces', indentUnit: 0, initCallback: function(editor) { @@ -760,7 +782,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();