Ticket 868: tags in visual editor
authorroot <root@debian.localdomain>
Tue, 5 Oct 2010 12:51:38 +0000 (07:51 -0500)
committerroot <root@debian.localdomain>
Tue, 5 Oct 2010 12:54:04 +0000 (07:54 -0500)
redakcja/static/css/html.css
redakcja/static/js/wiki/view_editor_wysiwyg.js

index 820aed7..d156aab 100644 (file)
@@ -479,7 +479,7 @@ div[x-node] > .uwaga {
     visibility: hidden;
 }
 
     visibility: hidden;
 }
 
-.edit-button, .delete-button, .accept-button {
+.edit-button, .delete-button, .accept-button, .tytul-button, .wyroznienie-button, .slowo-button {
     position: absolute;
     top: -21px;
     left: -1px;
     position: absolute;
     top: -21px;
     left: -1px;
@@ -502,9 +502,26 @@ div[x-node] > .uwaga {
     left: 70px;
 }
 
     left: 70px;
 }
 
+.tytul-button {
+    left:200px;
+    width:100px;
+}
+
+.wyroznienie-button {
+    left:300px;
+    width:100px;
+}
+.slowo-button {
+    left: 400px;
+    width:100px;
+}
+
 .edit-button:hover, .edit-button:active,
 .delete-button:hover, .delete-button:active,
 .edit-button:hover, .edit-button:active,
 .delete-button:hover, .delete-button:active,
-.accept-button:hover, .accept-button:active {
+.accept-button:hover, .accept-button:active,
+.tytul-button:hover, .tytul-button:active,
+.wyroznienie-button:hover, .wyroznienie-button:active,
+.slowo-button:hover, .slowo-button:active {
     /*    color: #FFF;*/
     background-color: #999;
     color: #FFF;
     /*    color: #FFF;*/
     background-color: #999;
     color: #FFF;
index 2beb4d4..d5fa29d 100644 (file)
         }
 
         // start edition on this node
         }
 
         // start edition on this node
-        var $overlay = $('<div class="html-editarea"><button class="accept-button">Zapisz</button><button class="delete-button">Usuń</button><textarea></textarea></div>').css({
+        var $overlay = $('<div class="html-editarea"><button class="accept-button">Zapisz</button><button class="delete-button">Usuń</button><button class="tytul-button akap-edit-button">tytuł dzieła</button><button class="wyroznienie-button akap-edit-button">wyróżnienie</button><button class="slowo-button akap-edit-button">słowo obce</button><textarea></textarea></div>').css({
             position: 'absolute',
             height: h,
             left: x,
             position: 'absolute',
             height: h,
             left: x,
         
 
         if ($origin.is('.motyw')) {
         
 
         if ($origin.is('.motyw')) {
+           $('.akap-edit-button').remove();
             withThemes(function(canonThemes){
                 $('textarea', $overlay).autocomplete(canonThemes, {
                     autoFill: true,
             withThemes(function(canonThemes){
                 $('textarea', $overlay).autocomplete(canonThemes, {
                     autoFill: true,
                     });
                 }
 
                     });
                 }
 
+               $('.akap-edit-button', $overlay).click(function(){
+                       var textAreaOpened = $('textarea', $overlay)[0];
+                       var startTag = "";
+                       var endTag = "";
+                       var buttonName = this.innerHTML;
+
+                       if(buttonName == "słowo obce") {
+                               startTag = "<slowo_obce>";
+                               endTag = "</slowo_obce>";
+                       } else if (buttonName == "wyróżnienie") {
+                               startTag = "<wyroznienie>";
+                               endTag = "</wyroznienie>";
+                       } else if (buttonName == "tytuł dzieła") {
+                               startTag = "<tytul_dziela>";
+                               endTag = "</tytul_dziela>";
+                       }
+                       var myField = textAreaOpened;                   
+                        
+                       //IE support
+                       if (document.selection) {
+                           textAreaOpened.focus();
+                           sel = document.selection.createRange();
+                           sel.text = startTag + sel.text + endTag;
+                       }
+                       //MOZILLA/NETSCAPE support
+                       else if (textAreaOpened.selectionStart || textAreaOpened.selectionStart == '0') {
+                           var startPos = textAreaOpened.selectionStart;
+                           var endPos = textAreaOpened.selectionEnd;
+                           textAreaOpened.value = textAreaOpened.value.substring(0, startPos)
+                                 + startTag + textAreaOpened.value.substring(startPos, endPos) + endTag + textAreaOpened.value.substring(endPos, textAreaOpened.value.length);
+                       }
+               });
+
                 $('.accept-button', $overlay).click(function(){
                     save();
                 });
                 $('.accept-button', $overlay).click(function(){
                     save();
                 });