]> git.mxchange.org Git - friendica.git/blob - view/theme/dispy/theme.php
Merge https://github.com/friendica/friendica into pull
[friendica.git] / view / theme / dispy / theme.php
1 <?php
2
3 /*
4  * Name: Dispy
5  * Description: Dispy, Friendica theme
6  * Version: 1.1
7  * Author: unknown
8  * Maintainer: Simon <http://simon.kisikew.org/>
9  * Screenshot: <a href="screenshot.jpg">Screenshot</a>
10  */
11
12 $a = get_app();
13 $a->theme_info = array(
14         'name' => 'dispy',
15         'version' => '1.1'
16 );
17
18 function dispy_init(&$a) {
19
20         // aside on profile page
21         if (($a->argv[0] . $a->argv[1]) === ("profile" . $a->user['nickname'])) {
22                 dispy_community_info();
23         }
24
25         $a->page['htmlhead'] .= <<<EOT
26         <script type="text/javascript">
27         $(document).ready(function() {
28                 $('.group-edit-icon').hover(
29                         function() {
30                                 $(this).addClass('icon');
31                                 $(this).removeClass('iconspacer'); },
32
33                         function() {
34                                 $(this).removeClass('icon');
35                                 $(this).addClass('iconspacer'); }
36                 );
37
38                 $('.sidebar-group-element').hover(
39                         function() {
40                                 id = $(this).attr('id');
41                                 $('#edit-' + id).addClass('icon');
42                                 $('#edit-' + id).removeClass('iconspacer'); },
43
44                         function() {
45                                 id = $(this).attr('id');
46                                 $('#edit-' + id).removeClass('icon');
47                                 $('#edit-' + id).addClass('iconspacer'); }
48                 );
49
50                 $('.savedsearchdrop').hover(
51                         function() {
52                                 $(this).addClass('drop');
53                                 $(this).addClass('icon');
54                                 $(this).removeClass('iconspacer'); },
55
56                         function() {
57                                 $(this).removeClass('drop');
58                                 $(this).removeClass('icon');
59                                 $(this).addClass('iconspacer'); }
60                 );
61
62                 $('.savedsearchterm').hover(
63                         function() {
64                                 id = $(this).attr('id');
65                                 $('#drop-' + id).addClass('icon');
66                                 $('#drop-' + id).addClass('drophide');
67                                 $('#drop-' + id).removeClass('iconspacer'); },
68
69                         function() {
70                                 id = $(this).attr('id');
71                                 $('#drop-' + id).removeClass('icon');
72                                 $('#drop-' + id).removeClass('drophide');
73                                 $('#drop-' + id).addClass('iconspacer'); }
74                         );
75
76                 // click outside notifications menu closes it
77                 $('html').click(function() {
78                         $('#nav-notifications-linkmenu').removeClass('selected');
79                         $('#nav-notifications-menu').css({display: 'none'});
80                 });
81
82                 $('#nav-notifications-linkmenu').click(function(event) {
83                         event.stopPropagation();
84                 });
85                 // click outside profiles menu closes it
86                 $('html').click(function() {
87                         $('#profiles-menu-trigger').removeClass('selected');
88                         $('#profiles-menu').css({display: 'none'});
89                 });
90
91                 $('#profiles-menu').click(function(event) {
92                         event.stopPropagation();
93                 });
94
95                 // main function in toolbar functioning
96                 function toggleToolbar() {
97                         if ( $('#nav-floater').is(':visible') ) {
98                                 $('#nav-floater').slideUp('fast');
99                                 $('.floaterflip').css({
100                                         backgroundPosition: '-210px -60px' 
101                                 });
102                                 $('.search-box').slideUp('fast');
103                         } else {
104                                 $('#nav-floater').slideDown('fast');
105                                 $('.floaterflip').css({
106                                         backgroundPosition: '-190px -60px'
107                                 });
108                                 $('.search-box').slideDown('fast');
109                         }
110                 };
111                 // our trigger for the toolbar button
112                 $('.floaterflip').click(function() {
113                         toggleToolbar();
114                         return false;
115                 });
116
117                 // (attempt to) change the text colour in a top post
118                 $('#profile-jot-text').focusin(function() {
119                         $(this).css({color: '#eec'});
120                 });
121
122                 $('a[href=#top]').click(function() {
123                         $('html, body').animate({scrollTop:0}, 'slow');
124                         return false;
125                 });
126
127         });
128         // shadowing effect for floating toolbars
129         $(document).scroll(function(e) {
130                 var pageTop = $('html').scrollTop();
131                 if (pageTop) {
132                         $('#nav-floater').css({boxShadow: '3px 3px 10px rgba(0, 0, 0, 0.7)'});
133                         $('.search-box').css({boxShadow: '3px 3px 10px rgba(0, 0, 0, 0.7)'});
134                 } else {
135                         $('#nav-floater').css({boxShadow: '0 0 0 0'});
136                         $('.search-box').css({boxShadow: '0 0 0 0'});
137                 }
138         });
139         </script>
140 EOT;
141
142         js_in_foot();
143 }
144
145 function dispy_community_info() {
146         $a = get_app();
147         $url = $a->get_baseurl($ssl_state);
148         $aside['$url'] = $url;
149
150         $fpostitJS = "javascript:(function() {"
151                 . "the_url = '" . $url . "/view/theme/".$a->theme_info['name']."/fpostit/fpostit.php?url=' + encodeURIComponent(window.location.href) + '&title=' + encodeURIComponent(document.title) + '&text=' + encodeURIComponent(''+(window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text));
152                                                 a_funct = function() {
153                                                         if (!window.open(the_url, 'fpostit', 'location=yes,links=no,scrollbars=no,toolbar=no,width=600,height=300')) location.href = the_url;};
154                                                         if (/Firefox/.test(navigator.userAgent)) {setTimeout(a_funct, 0);} 
155                                                         else {a_funct();}})()";
156
157         $aside['$fpostitJS'] = $fpostitJS;
158         $tpl = file_get_contents(dirname(__file__) . '/communityhome.tpl');
159         return $a->page['aside_bottom'] = replace_macros($tpl, $aside);
160 }
161
162 function js_in_foot() {
163         /** @purpose insert stuff in bottom of page
164          */
165         $a = get_app();
166         $baseurl = $a->get_baseurl($ssl_state);
167         $bottom['$baseurl'] = $baseurl;
168         $tpl = file_get_contents(dirname(__file__) . '/bottom.tpl');
169
170         return $a->page['bottom'] = replace_macros($tpl, $bottom);
171 }