]> git.mxchange.org Git - friendica.git/blob - view/theme/frost/js/theme.js
0d96cfa924ec5726e8cb30bf0f8c7dfd70efff37
[friendica.git] / view / theme / frost / js / theme.js
1 $(document).ready(function() {
2
3         window.navMenuTimeout = {
4                 '#network-menu-list-timeout': null,
5                 '#contacts-menu-list-timeout': null,
6                 '#system-menu-list-timeout': null,
7                 '#network-menu-list-opening': false,
8                 '#contacts-menu-list-opening': false,
9                 '#system-menu-list-opening': false,
10                 '#network-menu-list-closing': false,
11                 '#contacts-menu-list-closing': false,
12                 '#system-menu-list-closing': false
13         };
14
15     $.ajaxSetup({ 
16         cache: false 
17     });
18
19
20         $('.nav-menu-link').hover(function() {
21                 showNavMenu($(this).attr('rel'));
22         }, function() {
23                 hideNavMenu($(this).attr('rel'));
24         });
25
26 /*      $('html').click(function() { $("#nav-notifications-menu" ).hide(); });*/
27
28         $('.group-edit-icon').hover(
29                 function() {
30                         $(this).addClass('icon'); $(this).removeClass('iconspacer');},
31                 function() {
32                         $(this).removeClass('icon'); $(this).addClass('iconspacer');}
33                 );
34
35         $('.sidebar-group-element').hover(
36                 function() {
37                         id = $(this).attr('id');
38                         $('#edit-' + id).addClass('icon'); $('#edit-' + id).removeClass('iconspacer');},
39
40                 function() {
41                         id = $(this).attr('id');
42                         $('#edit-' + id).removeClass('icon');$('#edit-' + id).addClass('iconspacer');}
43                 );
44
45
46         $('.savedsearchdrop').hover(
47                 function() {
48                         $(this).addClass('drop'); $(this).addClass('icon'); $(this).removeClass('iconspacer');},
49                 function() {
50                         $(this).removeClass('drop'); $(this).removeClass('icon'); $(this).addClass('iconspacer');}
51         );
52
53         $('.savedsearchterm').hover(
54                 function() {
55                         id = $(this).attr('id');
56                         $('#drop-' + id).addClass('icon');      $('#drop-' + id).addClass('drophide'); $('#drop-' + id).removeClass('iconspacer');},
57
58                 function() {
59                         id = $(this).attr('id');
60                         $('#drop-' + id).removeClass('icon');$('#drop-' + id).removeClass('drophide'); $('#drop-' + id).addClass('iconspacer');}
61         );
62
63 /*      $('.nav-load-page-link').click(function() {
64                 getPageContent( $(this).attr('href') );
65                 hideNavMenu( '#' + $(this).closest('ul').attr('id') );
66                 return false;
67         });*/
68
69 });
70
71
72 function insertFormatting(comment,BBcode,id) {
73         
74                 var tmpStr = $("#comment-edit-text-" + id).val();
75                 if(tmpStr == comment) {
76                         tmpStr = "";
77                         $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
78                         $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
79                         openMenu("comment-edit-submit-wrapper-" + id);
80                         $("#comment-edit-text-" + id).val(tmpStr);
81                 }
82
83         textarea = document.getElementById("comment-edit-text-" +id);
84         if (document.selection) {
85                 textarea.focus();
86                 selected = document.selection.createRange();
87                 if (BBcode == "url"){
88                         selected.text = "["+BBcode+"]" + "http://" +  selected.text + "[/"+BBcode+"]";
89                         } else                  
90                 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
91         } else if (textarea.selectionStart || textarea.selectionStart == "0") {
92                 var start = textarea.selectionStart;
93                 var end = textarea.selectionEnd;
94                 if (BBcode == "url"){
95                         textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
96                         } else
97                 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
98         }
99         return true;
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 /*
110 $(document).mouseup(function (clickPos) {
111
112         var sysMenu = $("#system-menu-list");
113         var sysMenuLink = $(".system-menu-link");
114         var contactsMenu = $("#contacts-menu-list");
115         var contactsMenuLink = $(".contacts-menu-link");
116         var networkMenu = $("#network-menu-list");
117         var networkMenuLink = $(".network-menu-link");
118
119         if( !sysMenu.is(clickPos.target) && !sysMenuLink.is(clickPos.target) && sysMenu.has(clickPos.target).length === 0) {
120                 hideNavMenu("#system-menu-list");
121         }
122         if( !contactsMenu.is(clickPos.target) && !contactsMenuLink.is(clickPos.target) && contactsMenu.has(clickPos.target).length === 0) {
123                 hideNavMenu("#contacts-menu-list");
124         }
125         if( !networkMenu.is(clickPos.target) && !networkMenuLink.is(clickPos.target) && networkMenu.has(clickPos.target).length === 0) {
126                 hideNavMenu("#network-menu-list");
127         }
128 });
129
130
131 function getPageContent(url) {
132
133         var pos = $('.main-container').position();
134
135         $('.main-container').css('margin-left', pos.left);      
136         $('.main-content-container').hide(0, function () {
137                 $('.main-content-loading').show(0);
138         });
139
140         $.get(url, function(html) {
141                 console.log($('.main-content-container').html());
142                 $('.main-content-container').html( $('.main-content-container', html).html() );
143                 console.log($('.main-content-container').html());
144                 $('.main-content-loading').hide(function() {
145                         $('.main-content-container').fadeIn(800,function() {
146                                 $('.main-container').css('margin-left', 'auto'); // This sucks -- if the CSS specification changes, this will be wrong
147                         });
148                 });
149         });
150 }
151 */
152
153 function showNavMenu(menuID) {
154
155         if(window.navMenuTimeout[menuID + '-closing']) {
156                 window.navMenuTimeout[menuID + '-closing'] = false;
157                 clearTimeout(window.navMenuTimeout[menuID + '-timeout']);
158         }
159         else {
160                 window.navMenuTimeout[menuID + '-opening'] = true;
161                 
162                 window.navMenuTimeout[menuID + '-timeout'] = setTimeout( function () {
163                         $(menuID).slideDown('fast').show();
164                         window.navMenuTimeout[menuID + '-opening'] = false;
165                 }, 200);
166         }
167 }
168
169 function hideNavMenu(menuID) {
170
171         if(window.navMenuTimeout[menuID + '-opening']) {
172                 window.navMenuTimeout[menuID + '-opening'] = false;
173                 clearTimeout(window.navMenuTimeout[menuID + '-timeout']);
174         }
175         else {
176                 window.navMenuTimeout[menuID + '-closing'] = true;
177                 
178                 window.navMenuTimeout[menuID + '-timeout'] = setTimeout( function () {
179                         $(menuID).slideUp('fast');
180                         window.navMenuTimeout[menuID + '-closing'] = false;
181                 }, 500);
182         }
183 }
184