]> git.mxchange.org Git - friendica.git/blob - view/theme/frost-mobile/js/theme.js
Merge branch 'master' of github.com:CyberDomovoy/friendica into threaded_items
[friendica.git] / view / theme / frost-mobile / js / theme.js
1 $(document).ready(function() {
2
3 /*$('html').click(function() { $("#nav-notifications-menu" ).hide(); });*/
4
5         $('.group-edit-icon').hover(
6                 function() {
7                         $(this).addClass('icon'); $(this).removeClass('iconspacer');},
8                 function() {
9                         $(this).removeClass('icon'); $(this).addClass('iconspacer');}
10         );
11
12         $('.sidebar-group-element').hover(
13                 function() {
14                         id = $(this).attr('id');
15                         $('#edit-' + id).addClass('icon'); $('#edit-' + id).removeClass('iconspacer');},
16
17                 function() {
18                         id = $(this).attr('id');
19                         $('#edit-' + id).removeClass('icon');$('#edit-' + id).addClass('iconspacer');}
20         );
21
22
23         $('.savedsearchdrop').hover(
24                 function() {
25                         $(this).addClass('drop'); $(this).addClass('icon'); $(this).removeClass('iconspacer');},
26                 function() {
27                         $(this).removeClass('drop'); $(this).removeClass('icon'); $(this).addClass('iconspacer');}
28         );
29
30         $('.savedsearchterm').hover(
31                 function() {
32                         id = $(this).attr('id');
33                         $('#drop-' + id).addClass('icon');      $('#drop-' + id).addClass('drophide'); $('#drop-' + id).removeClass('iconspacer');},
34
35                 function() {
36                         id = $(this).attr('id');
37                         $('#drop-' + id).removeClass('icon');$('#drop-' + id).removeClass('drophide'); $('#drop-' + id).addClass('iconspacer');}
38         );
39
40         $(".popupbox").click(function () {
41                 var parent = $( $(this).attr('href') ).parent();
42                 if (parent.css('display') == 'none') {
43                         parent.show();
44                 } else {
45                         parent.hide();
46                 }
47                 return false;
48         });
49
50 });
51
52
53 function insertFormatting(comment,BBcode,id) {
54         
55                 var tmpStr = $("#comment-edit-text-" + id).val();
56                 if(tmpStr == comment) {
57                         tmpStr = "";
58                         $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
59                         $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
60                         openMenu("comment-edit-submit-wrapper-" + id);
61                         $("#comment-edit-text-" + id).val(tmpStr);
62                 }
63
64         textarea = document.getElementById("comment-edit-text-" +id);
65         if (document.selection) {
66                 textarea.focus();
67                 selected = document.selection.createRange();
68                 if (BBcode == "url"){
69                         selected.text = "["+BBcode+"]" + "http://" +  selected.text + "[/"+BBcode+"]";
70                         } else                  
71                 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
72         } else if (textarea.selectionStart || textarea.selectionStart == "0") {
73                 var start = textarea.selectionStart;
74                 var end = textarea.selectionEnd;
75                 if (BBcode == "url"){
76                         textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
77                         } else
78                 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
79         }
80         return true;
81 }
82
83 function cmtBbOpen(id) {
84         $(".comment-edit-bb-" + id).show();
85 }
86 function cmtBbClose(id) {
87         $(".comment-edit-bb-" + id).hide();
88 }
89
90
91
92
93 // TinyMCE stuff
94 // Needs to be in "jot-header.tpl" if the "$editselect" variable is used
95
96 var editor=false;
97 var textlen = 0;
98 var plaintext = 'none';//'$editselect';
99
100 function initEditor(cb){
101         if (editor==false){
102 //              $("#profile-jot-text-loading").show();
103                 if(plaintext == 'none') {
104 //                      $("#profile-jot-text-loading").hide();
105                         $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
106                         $("#profile-jot-text").contact_autocomplete(baseurl+"/acl");
107                         editor = true;
108 /*                      $("a#jot-perms-icon").fancybox({
109                                 'transitionIn' : 'none',
110                                 'transitionOut' : 'none'
111                         });*/
112                         $("a#jot-perms-icon, a#settings-default-perms-menu").click(function () {
113                                 var parent = $("#profile-jot-acl-wrapper").parent();
114                                 if (parent.css('display') == 'none') {
115                                         parent.show();
116                                 } else {
117                                         parent.hide();
118                                 }
119 //                              $("#profile-jot-acl-wrapper").parent().toggle();
120                                 return false;
121                         });
122                         $(".jothidden").show();
123                         if (typeof cb!="undefined") cb();
124                         return;
125                 }       
126 /*              tinyMCE.init({
127                         theme : "advanced",
128                         mode : "specific_textareas",
129                         editor_selector: $editselect,
130                         auto_focus: "profile-jot-text",
131                         plugins : "bbcode,paste,autoresize, inlinepopups",
132                         theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
133                         theme_advanced_buttons2 : "",
134                         theme_advanced_buttons3 : "",
135                         theme_advanced_toolbar_location : "top",
136                         theme_advanced_toolbar_align : "center",
137                         theme_advanced_blockformats : "blockquote,code",
138                         gecko_spellcheck : true,
139                         paste_text_sticky : true,
140                         entity_encoding : "raw",
141                         add_unload_trigger : false,
142                         remove_linebreaks : false,
143                         force_p_newlines : false,
144                         force_br_newlines : true,
145                         forced_root_block : '',
146                         convert_urls: false,
147                         content_css: "$baseurl/view/custom_tinymce.css",
148                         theme_advanced_path : false,
149                         file_browser_callback : "fcFileBrowser",
150                         setup : function(ed) {
151                                 cPopup = null;
152                                 ed.onKeyDown.add(function(ed,e) {
153                                         if(cPopup !== null)
154                                                 cPopup.onkey(e);
155                                 });
156
157                                 ed.onKeyUp.add(function(ed, e) {
158                                         var txt = tinyMCE.activeEditor.getContent();
159                                         match = txt.match(/@([^ \n]+)$/);
160                                         if(match!==null) {
161                                                 if(cPopup === null) {
162                                                         cPopup = new ACPopup(this,baseurl+"/acl");
163                                                 }
164                                                 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
165                                                 if(! cPopup.ready) cPopup = null;
166                                         }
167                                         else {
168                                                 if(cPopup !== null) { cPopup.close(); cPopup = null; }
169                                         }
170
171                                         textlen = txt.length;
172                                         if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
173                                                 $('#profile-jot-desc').html(ispublic);
174                                         }
175                                         else {
176                                                 $('#profile-jot-desc').html(' ');
177                                         }        
178
179                                  //Character count
180
181                                         if(textlen <= 140) {
182                                                 $('#character-counter').removeClass('red');
183                                                 $('#character-counter').removeClass('orange');
184                                                 $('#character-counter').addClass('grey');
185                                         }
186                                         if((textlen > 140) && (textlen <= 420)) {
187                                                 $('#character-counter').removeClass('grey');
188                                                 $('#character-counter').removeClass('red');
189                                                 $('#character-counter').addClass('orange');
190                                         }
191                                         if(textlen > 420) {
192                                                 $('#character-counter').removeClass('grey');
193                                                 $('#character-counter').removeClass('orange');
194                                                 $('#character-counter').addClass('red');
195                                         }
196                                         $('#character-counter').text(textlen);
197                                 });
198
199                                 ed.onInit.add(function(ed) {
200                                         ed.pasteAsPlainText = true;
201                                         $("#profile-jot-text-loading").hide();
202                                         $(".jothidden").show();
203                                         if (typeof cb!="undefined") cb();
204                                 });
205
206                         }
207                 });
208                 editor = true;
209                 // setup acl popup
210                 $("a#jot-perms-icon").fancybox({
211                         'transitionIn' : 'elastic',
212                         'transitionOut' : 'elastic'
213                 }); */
214         } else {
215                 if (typeof cb!="undefined") cb();
216         }
217 }
218
219 function enableOnUser(){
220         if (editor) return;
221         $(this).val("");
222         initEditor();
223 }
224