]> git.mxchange.org Git - friendica.git/blob - view/theme/quattro/js/quattro.js
Merge branch 'develop' into issue/#3062
[friendica.git] / view / theme / quattro / js / quattro.js
1 $(document).ready(function(){
2         $('nav').bind('nav-update', function(e,data){
3                 var notifCount = $(data).find('notif').attr('count');
4                 var intro = $(data).find('intro').text();
5                 var mail = $(data).find('mail').text();
6
7                 $(".tool .notify").removeClass("on");
8                 $(data).find("group").each(function() {
9                         var gid = this.id;
10                         var gcount = this.innerHTML;
11                         $(".group-"+gid+" .notify").addClass("on").text(gcount);
12                 });
13
14                 $(".forum-widget-entry .notify").removeClass("on");
15                 $(data).find("forum").each(function() {
16                         var fid = this.id;
17                         var fcount = this.innerHTML;
18                         $(".forum-"+fid+" .notify").addClass("on").text(fcount);
19                 });
20
21                 console.log(intro,mail);
22
23                 if (notifCount > 0 ) {
24                         Tinycon.setBubble(notifCount);
25                 } else {
26                         Tinycon.setBubble('');
27                 }
28
29                 if (intro>0){
30                         $("#nav-introductions-link").addClass("on");
31                 } else {
32                         $("#nav-introductions-link").removeClass("on");
33                 }
34
35                 if (mail>0){
36                         $("#nav-messages-link").addClass("on");
37                 } else {
38                         $("#nav-messages-link").removeClass("on");
39                 }
40
41         });
42
43         /*
44          * show and hide contact action buttons in
45          * contacts page on contacts' checkbox selection
46          */
47         $('.contact-select').bind('click', function(e) {
48                 var y = e.clientY;
49                 var elm = $("#contacts-actions");
50                 y=y-40;
51                 if (y<0) y=0;
52                 if (y+elm.height() > $("html").height()) y=$("html").height()-elm.height();
53                 elm.css('top', y+"px");
54                 if ($(".contact-select:checked").length > 0) {
55                         elm.show();
56                 } else {
57                         elm.hide();
58                 }
59         });
60 });
61
62 function insertFormatting(BBcode, id) {
63         var tmpStr = $("#comment-edit-text-" + id).val();
64         if (tmpStr == "") {
65                 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
66                 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
67                 openMenu("comment-edit-submit-wrapper-" + id);
68                 $("#comment-edit-text-" + id).val(tmpStr);
69         }
70
71         textarea = document.getElementById("comment-edit-text-" +id);
72         if (document.selection) {
73                 textarea.focus();
74                 selected = document.selection.createRange();
75                 if (BBcode == "url") {
76                         selected.text = "["+BBcode+"]" + "http://" +  selected.text + "[/"+BBcode+"]";
77                 } else {
78                         selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
79                 }
80         } else if (textarea.selectionStart || textarea.selectionStart == "0") {
81                 var start = textarea.selectionStart;
82                 var end = textarea.selectionEnd;
83                 if (BBcode == "url") {
84                         textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
85                 } else {
86                         textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
87                 }
88         }
89
90         return true;
91 }
92
93 function showThread(id) {
94         $("#collapsed-comments-" + id).show()
95         $("#collapsed-comments-" + id + " .collapsed-comments").show()
96 }
97 function hideThread(id) {
98         $("#collapsed-comments-" + id).hide()
99         $("#collapsed-comments-" + id + " .collapsed-comments").hide()
100 }
101
102
103 function cmtBbOpen(id) {
104         $("#comment-edit-bb-" + id).show();
105 }
106 function cmtBbClose(id) {
107         $("#comment-edit-bb-" + id).hide();
108 }
109
110 $(document).ready(function() {
111
112         $('html').click(function() { $("#nav-notifications-menu" ).hide(); });
113
114         $('.group-edit-icon').hover(
115                 function() {
116                         $(this).addClass('icon'); $(this).removeClass('iconspacer');},
117                 function() {
118                         $(this).removeClass('icon'); $(this).addClass('iconspacer');}
119                 );
120
121         $('.sidebar-group-element').hover(
122                 function() {
123                         id = $(this).attr('id');
124                         $('#edit-' + id).addClass('icon'); $('#edit-' + id).removeClass('iconspacer');},
125
126                 function() {
127                         id = $(this).attr('id');
128                         $('#edit-' + id).removeClass('icon');$('#edit-' + id).addClass('iconspacer');}
129                 );
130
131
132         $('.savedsearchdrop').hover(
133                 function() {
134                         $(this).addClass('drop'); $(this).addClass('icon'); $(this).removeClass('iconspacer');},
135                 function() {
136                         $(this).removeClass('drop'); $(this).removeClass('icon'); $(this).addClass('iconspacer');}
137                 );
138
139         $('.savedsearchterm').hover(
140                 function() {
141                         id = $(this).attr('id');
142                         $('#drop-' + id).addClass('icon');      $('#drop-' + id).addClass('drophide'); $('#drop-' + id).removeClass('iconspacer');},
143
144                 function() {
145                         id = $(this).attr('id');
146                         $('#drop-' + id).removeClass('icon');$('#drop-' + id).removeClass('drophide'); $('#drop-' + id).addClass('iconspacer');}
147         );
148
149 });
150
151