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