]> git.mxchange.org Git - friendica.git/blobdiff - view/jot-header.tpl
preliminary qcomment support, [nosmile] tag to disable smiley processing
[friendica.git] / view / jot-header.tpl
old mode 100644 (file)
new mode 100755 (executable)
index b067124..02662d2
@@ -3,14 +3,27 @@
 
 var editor=false;
 var textlen = 0;
+var plaintext = '$editselect';
 
 function initEditor(cb){
        if (editor==false){
-               $("#profile-jot-text-loading").show();  
+               $("#profile-jot-text-loading").show();
+               if(plaintext == 'none') {
+                       $("#profile-jot-text-loading").hide();
+                       $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
+                       $(".jothidden").show();
+                       editor = true;
+                       $("a#jot-perms-icon").fancybox({
+                               'transitionIn' : 'elastic',
+                               'transitionOut' : 'elastic'
+                       }); 
+                       if (typeof cb!="undefined") cb();
+                       return;
+               }       
                tinyMCE.init({
                        theme : "advanced",
                        mode : "specific_textareas",
-                       editor_selector: /(profile-jot-text|prvmail-text)/,
+                       editor_selector: $editselect,
                        auto_focus: "profile-jot-text",
                        plugins : "bbcode,paste,autoresize",
                        theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
@@ -30,9 +43,26 @@ function initEditor(cb){
                        content_css: "$baseurl/view/custom_tinymce.css",
                        theme_advanced_path : false,
                        setup : function(ed) {
-                                //Character count
+                               cPopup = null;
+                               ed.onKeyDown.add(function(ed,e) {
+                                       if(cPopup !== null)
+                                               cPopup.onkey(e);
+                               });
+
                                ed.onKeyUp.add(function(ed, e) {
                                        var txt = tinyMCE.activeEditor.getContent();
+                                       match = txt.match(/@([^ \n]+)$/);
+                                       if(match!==null) {
+                                               if(cPopup === null) {
+                                                       cPopup = new ACPopup(this,baseurl+"/acl");
+                                               }
+                                               if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
+                                               if(! cPopup.ready) cPopup = null;
+                                       }
+                                       else {
+                                               if(cPopup !== null) { cPopup.close(); cPopup = null; }
+                                       }
+
                                        textlen = txt.length;
                                        if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
                                                $('#profile-jot-desc').html(ispublic);
@@ -41,6 +71,8 @@ function initEditor(cb){
                                                $('#profile-jot-desc').html(' ');
                                        }        
 
+                                //Character count
+
                                        if(textlen <= 140) {
                                                $('#character-counter').removeClass('red');
                                                $('#character-counter').removeClass('orange');
@@ -62,7 +94,7 @@ function initEditor(cb){
                                ed.onInit.add(function(ed) {
                                        ed.pasteAsPlainText = true;
                                        $("#profile-jot-text-loading").hide();
-                                       $("#profile-jot-submit-wrapper").show();
+                                       $(".jothidden").show();
                                        if (typeof cb!="undefined") cb();
                                });
 
@@ -71,27 +103,32 @@ function initEditor(cb){
                editor = true;
                // setup acl popup
                $("a#jot-perms-icon").fancybox({
-                       'transitionIn' : 'none',
-                       'transitionOut' : 'none'
+                       'transitionIn' : 'elastic',
+                       'transitionOut' : 'elastic'
                }); 
        } else {
                if (typeof cb!="undefined") cb();
        }
 }
 
+function enableOnUser(){
+       if (editor) return;
+       $(this).val("");
+       initEditor();
+}
+
 </script>
-<script type="text/javascript" src="js/ajaxupload.js" ></script>
+<script type="text/javascript" src="$baseurl/js/ajaxupload.js" ></script>
 <script>
        var ispublic = '$ispublic';
+       var addtitle = '$addtitle';
+
        $(document).ready(function() {
                
-               /* enable tinymce on focus */
-               $("#profile-jot-text").focus(function(){
-                       if (editor) return;
-                       $(this).val("");
-                       initEditor();
-               });
-               
+               /* enable tinymce on focus and click */
+               $("#profile-jot-text").focus(enableOnUser);
+               $("#profile-jot-text").click(enableOnUser);
+
        
                var uploader = new window.AjaxUpload(
                        'wall-image-upload',
@@ -99,7 +136,7 @@ function initEditor(cb){
                                name: 'userfile',
                                onSubmit: function(file,ext) { $('#profile-rotator').show(); },
                                onComplete: function(file,response) {
-                                       tinyMCE.execCommand('mceInsertRawHTML',false,response);
+                                       addeditortext(response);
                                        $('#profile-rotator').hide();
                                }                                
                        }
@@ -110,7 +147,7 @@ function initEditor(cb){
                                name: 'userfile',
                                onSubmit: function(file,ext) { $('#profile-rotator').show(); },
                                onComplete: function(file,response) {
-                                       tinyMCE.execCommand('mceInsertRawHTML',false,response);
+                                       addeditortext(response);
                                        $('#profile-rotator').hide();
                                }                                
                        }
@@ -143,7 +180,7 @@ function initEditor(cb){
                        reply = bin2hex(reply);
                        $('#profile-rotator').show();
                        $.get('parse_url?binurl=' + reply, function(data) {
-                               tinyMCE.execCommand('mceInsertRawHTML',false,data);
+                               addeditortext(data);
                                $('#profile-rotator').hide();
                        });
                }
@@ -152,14 +189,14 @@ function initEditor(cb){
        function jotVideoURL() {
                reply = prompt("$vidurl");
                if(reply && reply.length) {
-                       tinyMCE.execCommand('mceInsertRawHTML',false,'[video]' + reply + '[/video]');
+                       addeditortext('[video]' + reply + '[/video]');
                }
        }
 
        function jotAudioURL() {
                reply = prompt("$audurl");
                if(reply && reply.length) {
-                       tinyMCE.execCommand('mceInsertRawHTML',false,'[audio]' + reply + '[/audio]');
+                       addeditortext('[audio]' + reply + '[/audio]');
                }
        }
 
@@ -171,20 +208,14 @@ function initEditor(cb){
                }
        }
 
-       function jotTitle() {
-               reply = prompt("$title", $('#jot-title').val());
-               if(reply && reply.length) {
-                       $('#jot-title').val(reply);
-               }
-       }
-
-
        function jotShare(id) {
+               if ($('#jot-popup').length != 0) $('#jot-popup').show();
+
                $('#like-rotator-' + id).show();
                $.get('share/' + id, function(data) {
                        if (!editor) $("#profile-jot-text").val("");
                        initEditor(function(){
-                               tinyMCE.execCommand('mceInsertRawHTML',false,data);
+                               addeditortext(data);
                                $('#like-rotator-' + id).hide();
                                $(window).scrollTop(0);
                        });
@@ -203,11 +234,12 @@ function initEditor(cb){
                event.target.textContent = reply;
                event.preventDefault();
                if(reply && reply.length) {
+                       reply = bin2hex(reply);
                        $('#profile-rotator').show();
-                       $.get('parse_url?url=' + reply, function(data) {
+                       $.get('parse_url?binurl=' + reply, function(data) {
                                if (!editor) $("#profile-jot-text").val("");
                                initEditor(function(){
-                                       tinyMCE.execCommand('mceInsertRawHTML',false,data);
+                                       addeditortext(data);
                                        $('#profile-rotator').hide();
                                });
                        });
@@ -215,14 +247,18 @@ function initEditor(cb){
        }
 
        function itemTag(id) {
-               $('#like-rotator-' + id).show();
                reply = prompt("$term");
                if(reply && reply.length) {
-                       reply.replace('#','');
+                       reply = reply.replace('#','');
                        if(reply.length) {
-                               $.get('tagger/' + id + '?term=' + reply, function(data) {
-                                       $('#like-rotator-' + id).hide();
-                               });
+
+                               commentBusy = true;
+                               $('body').css('cursor', 'wait');
+
+                               $.get('tagger/' + id + '?term=' + reply);
+                               if(timer) clearTimeout(timer);
+                               timer = setTimeout(NavUpdate,3000);
+                               liking = 1;
                        }
                }
        }
@@ -232,6 +268,15 @@ function initEditor(cb){
                $('#profile-nolocation-wrapper').hide();
        }
 
+       function addeditortext(data) {
+               if(plaintext == 'none') {
+                       var currentText = $("#profile-jot-text").val();
+                       $("#profile-jot-text").val(currentText + data);
+               }
+               else
+                       tinyMCE.execCommand('mceInsertRawHTML',false,data);
+       }       
+
        $geotag
 
 </script>