Added "delete" button to annotations. Fixes #554.
authorŁukasz Rekucki <lrekucki@gmail.com>
Tue, 25 May 2010 13:20:46 +0000 (15:20 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Tue, 25 May 2010 13:20:46 +0000 (15:20 +0200)
redakcja/static/js/wiki/view_editor_wysiwyg.js

index 2ae1a8d..ef087a3 100644 (file)
@@ -44,7 +44,7 @@
     }
 
     /* Convert HTML frament to plaintext */
     }
 
     /* Convert HTML frament to plaintext */
-    var ANNOT_ALLOWED = ['wyroznienie', 'slowo_obce', 'osoba'];
+    var ANNOT_FORBIDDEN = ['pt', 'pa', 'pr', 'pe', 'begin', 'end', 'theme'];
 
     function html2plainText(fragment){
         var text = "";
 
     function html2plainText(fragment){
         var text = "";
         $(fragment.childNodes).each(function(){
             if (this.nodeType == 3) // textNode
                 text += this.nodeValue;
         $(fragment.childNodes).each(function(){
             if (this.nodeType == 3) // textNode
                 text += this.nodeValue;
-            else
+            else {
                 if (this.nodeType == 1 &&
                 if (this.nodeType == 1 &&
-                $.inArray($(this).attr('x-node'), ANNOT_ALLOWED) != -1) {
+                        $.inArray($(this).attr('x-node'), ANNOT_FORBIDDEN) == -1) {
                     text += html2plainText(this);
                 }
                     text += html2plainText(this);
                 }
+            };
         });
 
         return text;
         });
 
         return text;
@@ -87,7 +88,7 @@
             return false;
         }
 
             return false;
         }
 
-        // BUG #273 - selected text can contain themes, which should be omited from
+        // BUG #273 - selected text can contain themes, which should be omitted from
         // defining term
         var text = html2plainText(range.cloneContents());
 
         // defining term
         var text = html2plainText(range.cloneContents());
 
             });
         }
 
             });
         }
 
-        if ($origin.is('.motyw')) {
+        if ($origin.is('.motyw')){
             $('.delete-button', $overlay).click(function(){
                 if (window.confirm("Czy jesteś pewien, że chcesz usunąć ten motyw ?")) {
                     $('[theme-class=' + $origin.attr('theme-class') + ']').remove();
             $('.delete-button', $overlay).click(function(){
                 if (window.confirm("Czy jesteś pewien, że chcesz usunąć ten motyw ?")) {
                     $('[theme-class=' + $origin.attr('theme-class') + ']').remove();
                     $(document).unbind('click.blur-overlay');
                     return false;
                 };
                     $(document).unbind('click.blur-overlay');
                     return false;
                 };
-                            });
+            });
+        }
+        else if($box.is('*[x-annotation-box]')) {
+            $('.delete-button', $overlay).click(function(){
+                if (window.confirm("Czy jesteś pewien, że chcesz usunąć ten przypis?")) {
+                    $origin.remove();
+                    $overlay.remove();
+                    $(document).unbind('click.blur-overlay');
+                    return false;
+                };
+            });
         }
         else {
             $('.delete-button', $overlay).hide();
         }
         else {
             $('.delete-button', $overlay).hide();