]> git.mxchange.org Git - friendica.git/blobdiff - view/theme/frost/js/theme.js
Merge pull request #4892 from MrPetovan/bug/infinite-loop-in-dba-delete
[friendica.git] / view / theme / frost / js / theme.js
index ca0d143c2d8cf3716308a1dafabf22d6ca9d98ac..bf7bdd585c625c0ced878e51c6c9f1f6d26c59fb 100644 (file)
@@ -12,7 +12,7 @@ $(document).ready(function() {
                '#system-menu-list-closing': false
        };
 
-       /* enable tinymce on focus and click */
+       /* enable editor on focus and click */
        $("#profile-jot-text").focus(enableOnUser);
        $("#profile-jot-text").click(enableOnUser);
 
@@ -61,8 +61,7 @@ $(document).ready(function() {
 
                if ($('#id_share').is(':checked')) {
                        $('#acl-wrapper').show();
-               }
-               else {
+               } else {
                        $('#acl-wrapper').hide();
                }
        }).trigger('change');
@@ -357,8 +356,7 @@ function showNavMenu(menuID) {
        if (window.navMenuTimeout[menuID + '-closing']) {
                window.navMenuTimeout[menuID + '-closing'] = false;
                clearTimeout(window.navMenuTimeout[menuID + '-timeout']);
-       }
-       else {
+       } else {
                window.navMenuTimeout[menuID + '-opening'] = true;
 
                window.navMenuTimeout[menuID + '-timeout'] = setTimeout( function () {
@@ -373,8 +371,7 @@ function hideNavMenu(menuID) {
        if (window.navMenuTimeout[menuID + '-opening']) {
                window.navMenuTimeout[menuID + '-opening'] = false;
                clearTimeout(window.navMenuTimeout[menuID + '-timeout']);
-       }
-       else {
+       } else {
                window.navMenuTimeout[menuID + '-closing'] = true;
 
                window.navMenuTimeout[menuID + '-timeout'] = setTimeout( function () {
@@ -387,254 +384,52 @@ function hideNavMenu(menuID) {
 
 
 /*
- * TinyMCE/Editor
+ * Editor
  */
 
-function InitMCEEditor(editorData) {
-       var tinyMCEInitConfig = {
-               theme : "advanced",
-               //mode : // SPECIFIC
-               //editor_selector: // SPECIFIC
-               //elements: // SPECIFIC
-               plugins : "bbcode,paste,autoresize,inlinepopups",
-               theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
-               theme_advanced_buttons2 : "",
-               theme_advanced_buttons3 : "",
-               theme_advanced_toolbar_location : "top",
-               theme_advanced_toolbar_align : "center",
-               theme_advanced_blockformats : "blockquote,code",
-               gecko_spellcheck : true,
-               paste_text_sticky : true, // COUPLED WITH paste PLUGIN
-               entity_encoding : "raw",
-               add_unload_trigger : false,
-               remove_linebreaks : false,
-               //force_p_newlines : false,
-               //force_br_newlines : true,
-               forced_root_block : 'div',
-               //convert_urls: false, //SPECIFIC?
-               content_css: baseurl + "/view/custom_tinymce.css",
-               theme_advanced_path : false,
-               file_browser_callback : "fcFileBrowser",
-               //setup : // SPECIFIC
-       };
-
-       if (window.editSelect != 'none') {
-               $.extend(tinyMCEInitConfig, editorData);
-               tinyMCE.init(tinyMCEInitConfig);
-       }
-       else if (typeof editorData.plaintextFn == 'function') {
-               (editorData.plaintextFn)();
-       }
-}
-
 var editor = false;
 var textlen = 0;
 
-function initEditor(cb) {
-       if (editor==false) {
-               editor = true;
+function initEditor(callback) {
+       if(editor == false) {
                $("#profile-jot-text-loading").show();
 
-               var editorData = {
-                       mode : "specific_textareas",
-                       editor_selector : "profile-jot-text",
-                       auto_focus : "profile-jot-text",
-                       //plugins : "bbcode,paste,autoresize,inlinepopups",
-                       //paste_text_sticky : true,
-                       convert_urls : false,
-                       setup : function(ed) {
-                               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(window.isPublic);
-                                       }
-                                       else {
-                                               $('#profile-jot-desc').html(' ');
-                                       }
-
-                                       //Character count
-
-                                       if (textlen <= 140) {
-                                               $('#character-counter').removeClass('red');
-                                               $('#character-counter').removeClass('orange');
-                                               $('#character-counter').addClass('grey');
-                                       }
-                                       if ((textlen > 140) && (textlen <= 420)) {
-                                               $('#character-counter').removeClass('grey');
-                                               $('#character-counter').removeClass('red');
-                                               $('#character-counter').addClass('orange');
-                                       }
-                                       if (textlen > 420) {
-                                               $('#character-counter').removeClass('grey');
-                                               $('#character-counter').removeClass('orange');
-                                               $('#character-counter').addClass('red');
-                                       }
-                                       $('#character-counter').text(textlen);
-                               });
-
-                               ed.onInit.add(function(ed) {
-                                       ed.pasteAsPlainText = true;
-                                       $("#profile-jot-text-loading").hide();
-                                       $(".jothidden").show();
-                                       if (typeof cb!="undefined") cb();
-                               });
-
-                       },
-                       plaintextFn : function() {
-                               $("#profile-jot-text-loading").hide();
-                               $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
-                               $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
-                               $(".jothidden").show();
-                               if (typeof cb!="undefined") cb();
-                       }
-               };
-               InitMCEEditor(editorData);
-
+               $("#profile-jot-text-loading").hide();
+               $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
+               $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
+               $(".jothidden").show();
                // setup acl popup
                $("a#jot-perms-icon").colorbox({
                        'inline' : true,
                        'transition' : 'elastic'
                });
-       } else {
-               if (typeof cb!="undefined") cb();
+
+               editor = true;
+       }
+       if (typeof callback != "undefined") {
+               callback();
        }
 }
 
 function enableOnUser() {
-       if (editor) return;
+       if (editor) {
+               return;
+       }
        $(this).val("");
        initEditor();
 }
 
-
 function msgInitEditor() {
-       var editorData = {
-               mode : "specific_textareas",
-               editor_selector : "prvmail-text",
-               //plugins : "bbcode,paste",
-               //paste_text_sticky : true,
-               convert_urls : false,
-               //theme_advanced_path : false,
-               setup : function(ed) {
-                       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(window.isPublic);
-                               }
-                               else {
-                                       $('#profile-jot-desc').html('&nbsp;');
-                               }
-                       });
-
-                       ed.onInit.add(function(ed) {
-                               ed.pasteAsPlainText = true;
-                               var editorId = ed.editorId;
-                               var textarea = $('#'+editorId);
-                               if (typeof(textarea.attr('tabindex')) != "undefined") {
-                                       $('#'+editorId+'_ifr').attr('tabindex', textarea.attr('tabindex'));
-                                       textarea.attr('tabindex', null);
-                               }
-                       });
-               },
-               plaintextFn : function() {
-                       $("#prvmail-text").editor_autocomplete(baseurl+"/acl");
-               }
-       }
-       InitMCEEditor(editorData);
-}
-
-
-function contactInitEditor() {
-       var editorData = {
-               mode : "exact",
-               elements : "contact-edit-info",
-               //plugins : "bbcode"
-       }
-       InitMCEEditor(editorData);
-}
-
-
-function eventInitEditor() {
-       var editorData = {
-               mode : "textareas",
-               //plugins : "bbcode,paste",
-               //paste_text_sticky : true,
-               //theme_advanced_path : false,
-               setup : function(ed) {
-                       ed.onInit.add(function(ed) {
-                               ed.pasteAsPlainText = true;
-                       });
-               }
-       }
-       InitMCEEditor(editorData);
-}
-
-
-function profInitEditor() {
-       var editorData = {
-               mode : "textareas",
-               //plugins : "bbcode,paste",
-               //paste_text_sticky : true,
-               //theme_advanced_path : false,
-               setup : function(ed) {
-                       ed.onInit.add(function(ed) {
-                               ed.pasteAsPlainText = true;
-                       });
-               }
-       }
-       InitMCEEditor(editorData);
+       $("#prvmail-text").editor_autocomplete(baseurl+"/acl");
 }
 
-
 /*
  * Jot
  */
 
 function addeditortext(textElem, data) {
-       if (window.editSelect == 'none') {
-               var currentText = $(textElem).val();
-               $(textElem).val(currentText + data);
-       }
-       else
-               tinyMCE.execCommand('mceInsertRawHTML',false,data);
+       var currentText = $(textElem).val();
+       $(textElem).val(currentText + data);
 }
 
 function jotVideoURL() {
@@ -733,8 +528,7 @@ function deleteCheckedItems(delID) {
                        if ($(this).is(':checked')) {
                                if (checkedstr.length != 0) {
                                        checkedstr = checkedstr + ',' + $(this).val();
-                               }
-                               else {
+                               } else {
                                        checkedstr = $(this).val();
                                }
                        }
@@ -797,33 +591,25 @@ function itemFiler(id) {
  * Comments
  */
 
-function insertFormatting(comment,BBcode,id) {
-       
+function insertFormatting(BBcode, id) {
        var tmpStr = $("#comment-edit-text-" + id).val();
-       if(tmpStr == comment) {
-               tmpStr = "";
+       if (tmpStr == "") {
                $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
                $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
                openMenu("comment-edit-submit-wrapper-" + id);
-               $("#comment-edit-text-" + id).val(tmpStr);
        }
 
        textarea = document.getElementById("comment-edit-text-" +id);
        if (document.selection) {
                textarea.focus();
                selected = document.selection.createRange();
-               if (BBcode == "url"){
-                       selected.text = "["+BBcode+"=http://]" +  selected.text + "[/"+BBcode+"]";
-                       } else                  
                selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
        } else if (textarea.selectionStart || textarea.selectionStart == "0") {
                var start = textarea.selectionStart;
                var end = textarea.selectionEnd;
-               if (BBcode == "url"){
-                       textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
-                       } else
                textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
        }
+
        return true;
 }
 
@@ -835,8 +621,7 @@ function cmtBbClose(id) {
 }
 
 function commentOpen(obj,id) {
-       if(obj.value == window.commentEmptyText) {
-               obj.value = "";
+       if (obj.value == "") {
                $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
                $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
                $("#mod-cmnt-wrap-" + id).show();
@@ -844,8 +629,7 @@ function commentOpen(obj,id) {
        }
 }
 function commentClose(obj,id) {
-       if(obj.value == "") {
-               obj.value = window.commentEmptyText;
+       if (obj.value == "") {
                $("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
                $("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
                $("#mod-cmnt-wrap-" + id).hide();
@@ -856,8 +640,7 @@ function commentClose(obj,id) {
 
 function commentInsert(obj,id) {
        var tmpStr = $("#comment-edit-text-" + id).val();
-       if(tmpStr == window.commentEmptyText) {
-               tmpStr = "";
+       if (tmpStr == "") {
                $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
                $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
                openMenu("comment-edit-submit-wrapper-" + id);
@@ -872,8 +655,7 @@ function commentInsert(obj,id) {
 
 function qCommentInsert(obj,id) {
        var tmpStr = $("#comment-edit-text-" + id).val();
-       if(tmpStr == window.commentEmptyText) {
-               tmpStr = "";
+       if (tmpStr == "") {
                $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
                $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
                openMenu("comment-edit-submit-wrapper-" + id);