]> git.mxchange.org Git - friendica.git/blob - view/theme/quattro/js/quattro.js
Merge pull request #2095 from rabuzarus/unread_forums
[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(comment,BBcode,id) {
63
64                 var tmpStr = $("#comment-edit-text-" + id).val();
65                 if(tmpStr == comment) {
66                         tmpStr = "";
67                         $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
68                         $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
69                         openMenu("comment-edit-submit-wrapper-" + id);
70                         $("#comment-edit-text-" + id).val(tmpStr);
71                 }
72
73         textarea = document.getElementById("comment-edit-text-" +id);
74         if (document.selection) {
75                 textarea.focus();
76                 selected = document.selection.createRange();
77                 if (BBcode == "url"){
78                         selected.text = "["+BBcode+"]" + "http://" +  selected.text + "[/"+BBcode+"]";
79                         } else
80                 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
81         } else if (textarea.selectionStart || textarea.selectionStart == "0") {
82                 var start = textarea.selectionStart;
83                 var end = textarea.selectionEnd;
84                 if (BBcode == "url"){
85                         textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
86                         } else
87                 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
88         }
89         return true;
90 }
91
92 function showThread(id) {
93         $("#collapsed-comments-" + id).show()
94         $("#collapsed-comments-" + id + " .collapsed-comments").show()
95 }
96 function hideThread(id) {
97         $("#collapsed-comments-" + id).hide()
98         $("#collapsed-comments-" + id + " .collapsed-comments").hide()
99 }
100
101
102 function cmtBbOpen(id) {
103         $("#comment-edit-bb-" + id).show();
104 }
105 function cmtBbClose(id) {
106         $("#comment-edit-bb-" + id).hide();
107 }
108
109 $(document).ready(function() {
110
111         $('html').click(function() { $("#nav-notifications-menu" ).hide(); });
112
113         $('.group-edit-icon').hover(
114                 function() {
115                         $(this).addClass('icon'); $(this).removeClass('iconspacer');},
116                 function() {
117                         $(this).removeClass('icon'); $(this).addClass('iconspacer');}
118                 );
119
120         $('.sidebar-group-element').hover(
121                 function() {
122                         id = $(this).attr('id');
123                         $('#edit-' + id).addClass('icon'); $('#edit-' + id).removeClass('iconspacer');},
124
125                 function() {
126                         id = $(this).attr('id');
127                         $('#edit-' + id).removeClass('icon');$('#edit-' + id).addClass('iconspacer');}
128                 );
129
130
131         $('.savedsearchdrop').hover(
132                 function() {
133                         $(this).addClass('drop'); $(this).addClass('icon'); $(this).removeClass('iconspacer');},
134                 function() {
135                         $(this).removeClass('drop'); $(this).removeClass('icon'); $(this).addClass('iconspacer');}
136                 );
137
138         $('.savedsearchterm').hover(
139                 function() {
140                         id = $(this).attr('id');
141                         $('#drop-' + id).addClass('icon');      $('#drop-' + id).addClass('drophide'); $('#drop-' + id).removeClass('iconspacer');},
142
143                 function() {
144                         id = $(this).attr('id');
145                         $('#drop-' + id).removeClass('icon');$('#drop-' + id).removeClass('drophide'); $('#drop-' + id).addClass('iconspacer');}
146         );
147
148 });
149
150