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