X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/b9166b62220208f49bfd3521e547d60d377ab7c1..6c81c82481a5407bc6e4f3c5cdd16baedbc2a523:/src/redakcja/static/js/wiki/view_editor_wysiwyg.js
diff --git a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js
index 4554bbe7..f3d18fd7 100644
--- a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js
+++ b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js
@@ -6,8 +6,8 @@
selection.removeAllRanges();
var range = document.createRange();
- var s = $(".motyw[theme-class='" + themeId + "']")[0];
- var e = $(".end[theme-class='" + themeId + "']")[0];
+ var s = $("[x-node='motyw'][theme-class='" + themeId + "']")[0];
+ var e = $("[x-node='end'][theme-class='" + themeId + "']")[0];
if (s && e) {
range.setStartAfter(s);
@@ -237,7 +237,7 @@
spoint.insertNode(btag[0])
btag.replaceWith(text);
selection.removeAllRanges();
- openForEdit($('.motyw[theme-class="' + id + '"]'));
+ openForEdit($('[x-node="motyw"][theme-class="' + id + '"]'));
}
});
}
@@ -465,11 +465,11 @@
$('.akap-edit-button').remove();
}
- if ($origin.is('.motyw')) {
+ if ($origin.is('[x-node="motyw"]')) {
$.themes.autocomplete($('textarea', $overlay));
}
- if ($origin.is('.motyw')){
+ if ($origin.is('[x-node="motyw"]')){
$('.delete-button', $overlay).click(function(){
if (window.confirm("Czy jesteÅ pewien, że chcesz usunÄ
Ä ten motyw?")) {
$('[theme-class="' + $origin.attr('theme-class') + '"]').remove();
@@ -479,9 +479,20 @@
};
});
}
- else if($box.is('*[x-annotation-box]') || $origin.is('*[x-edit-attribute]')) {
+ else if($box.is('*[x-annotation-box]') || $origin.is('*[x-edit-attribute]') || $origin.is('*[x-node="uwaga"]')) {
+ let q;
+ switch ($origin.attr('x-node')) {
+ case 'uwaga':
+ q = 'tÄ uwagÄ';
+ break;
+ case 'ref':
+ q = 'tÄ referencjÄ';
+ break
+ default:
+ q = 'ten przypis';
+ }
$('.delete-button', $overlay).click(function(){
- if (window.confirm("Czy jesteÅ pewien, że chcesz usunÄ
Ä ten przypis?")) {
+ if (window.confirm("Czy jesteÅ pewien, że chcesz usunÄ
Ä " + q + "?")) {
$origin.remove();
$overlay.remove();
$(document).unbind('click.blur-overlay');
@@ -505,7 +516,7 @@
if($box.attr("x-edit-attribute")) {
source = $('');
- source.text($box.attr("data-wlf-" + $box.attr("x-edit-attribute")));
+ source.text($box.attr("x-a-wl-" + $box.attr("x-edit-attribute")));
source = source[0];
} else {
source = $box[0];
@@ -525,7 +536,7 @@
var nodeName = $box.attr('x-node') || 'pe';
var insertedText = $('textarea', $overlay).val();
- if ($origin.is('.motyw')) {
+ if ($origin.is('[x-node="motyw"]')) {
insertedText = insertedText.replace(/,\s*$/, '');
}
@@ -621,6 +632,16 @@
});
}
+ function createUwagaBefore(before) {
+ xml2html({
+ xml: '',
+ success: function(element){
+ let $element = $(element);
+ $element.insertBefore(before);
+ openForEdit($element);
+ }
+ });
+ }
function VisualPerspective(options){
perspective = this;
@@ -629,26 +650,28 @@
options.callback = function(){
var element = $("#html-view");
- var button = $('');
+ var button = $('');
+ var uwagaButton = $('');
if (!CurrentDocument.readonly) {
$('#html-view').bind('mousemove', function(event){
var editable = $(event.target).closest('*[x-editable]');
- $('.active', element).not(editable).removeClass('active').children('.edit-button').remove();
+ $('.active', element).not(editable).removeClass('active').children('.active-block-button').remove();
if (!editable.hasClass('active')) {
editable.addClass('active').append(button);
+ if (!editable.is('[x-edit-attribute]') &&
+ !editable.is('.annotation-inline-box') &&
+ !editable.is('[x-edit-no-format]')
+ ) {
+ editable.append(uwagaButton);
+ }
}
if (editable.is('.annotation-inline-box')) {
$('*[x-annotation-box]', editable).css({
-// left: event.clientX - editable.offset().left + 5,
-// top: event.clientY - editable.offset().top + 5
}).show();
}
- else {
-// $('*[x-annotation-box]').hide();
- }
});
perspective.caret = new Caret(element);
@@ -685,9 +708,13 @@
openForEdit($(this).parent());
});
+ $(document).on('click', '.uwaga-button', function(event){
+ event.preventDefault();
+ createUwagaBefore($(this).parent());
+ });
}
- $(document).on('click', '.motyw', function(){
+ $(document).on('click', '[x-node="motyw"]', function(){
selectTheme($(this).attr('theme-class'));
});
@@ -727,14 +754,6 @@
var htmlView = $('#html-view');
htmlView.html(element);
- htmlView.find('*[x-node]').dblclick(function(e) {
- if($(e.target).is('textarea'))
- return;
- var selection = window.getSelection();
- selection.collapseToStart();
- selection.modify('extend', 'forward', 'word');
- e.stopPropagation();
- });
_finalize(success);
},
error: function(text, source){
@@ -751,6 +770,8 @@
var self = this;
self.caret.detach();
+
+ $.wiki.exitTab('#PropertiesPerspective');
$.blockUI({
message: 'Zapisywanie widoku...'
@@ -784,7 +805,7 @@
let selection = window.getSelection();
var n = selection.rangeCount;
- if (n != 1) {
+ if (n != 1 || selection.isCollapsed) {
window.alert("Nie zaznaczono obszaru");
return false
}