]> git.mxchange.org Git - friendica.git/blob - view/theme/dispy/theme.php
Implement Smarty3
[friendica.git] / view / theme / dispy / theme.php
1 <?php
2
3 /*
4  * Name: Dispy
5  * Description: Dispy family (light, dark): Sleek and Functional Themes 
6  * Version: 1.2.1
7  * Author: Simon <http://simon.kisikew.org/>
8  * Maintainer: Simon <http://simon.kisikew.org/>
9  * Screenshot: <a href="screenshot.jpg">Screenshot</a>
10  */
11
12 /* If you borrow any of these functions, make sure to
13  * RENAME your functions, otherwise both themes get conflicts,
14  * and the friendica instance will get HTTP 500 errors.
15  * To paraphrase Mike: "Might wish to wrap
16  * function_name with "if(! function_exists('function_name')) ... "
17  * or rename to prefix1_function_name (prefix2_function_name), etc.
18  */
19
20 $a = get_app();
21 $a->theme_info = array(
22     'family' => 'dispy',
23         'version' => '1.2.2'
24 );
25 $a->theme['template_engine'] = 'smarty3';
26
27 function dispy_init(&$a) {
28
29     /** @purpose set some theme defaults
30     */
31     $cssFile = null;
32     $colour = get_pconfig(local_user(), "dispy", "colour");
33         $baseurl = $a->get_baseurl($ssl_state);
34
35     if ($colour === false) { $colour = "light"; }
36     if ($colour == "light") {
37                 $colour_path = "/light/";
38                 require_once ('light/theme.php');
39         }
40     if ($colour == "dark") {
41                 $colour_path = "/dark/";
42                 require_once ('dark/theme.php');
43         }
44
45     /** @purpose aside on profile page
46     */
47         if (($a->argv[0] . $a->argv[1]) === ("profile" . $a->user['nickname'])) {
48                 dispy_community_info();
49         }
50
51         $a->page['htmlhead'] .= <<<EOT
52         <script type="text/javascript" src="$baseurl/view/theme/dispy/js/modernizr.custom.2.5.3.min.js"></script>
53         <script type="text/javascript">
54         $(document).ready(function() {
55                 // Select all links with lightbox class
56                 $("a.lightbox").fancybox();
57
58         $('.group-edit-icon').hover(
59                         function() {
60                                 $(this).addClass('icon');
61                                 $(this).removeClass('iconspacer'); },
62
63                         function() {
64                                 $(this).removeClass('icon');
65                                 $(this).addClass('iconspacer'); }
66                 );
67
68                 $('.sidebar-group-element').hover(
69                         function() {
70                                 id = $(this).attr('id');
71                                 $('#edit-' + id).addClass('icon');
72                                 $('#edit-' + id).removeClass('iconspacer'); },
73
74                         function() {
75                                 id = $(this).attr('id');
76                                 $('#edit-' + id).removeClass('icon');
77                                 $('#edit-' + id).addClass('iconspacer'); }
78                 );
79
80                 $('.savedsearchdrop').hover(
81                         function() {
82                                 $(this).addClass('drop');
83                                 $(this).addClass('icon');
84                                 $(this).removeClass('iconspacer'); },
85
86                         function() {
87                                 $(this).removeClass('drop');
88                                 $(this).removeClass('icon');
89                                 $(this).addClass('iconspacer'); }
90                 );
91
92                 $('.savedsearchterm').hover(
93                         function() {
94                                 id = $(this).attr('id');
95                                 $('#drop-' + id).addClass('icon');
96                                 $('#drop-' + id).addClass('drophide');
97                                 $('#drop-' + id).removeClass('iconspacer'); },
98
99                         function() {
100                                 id = $(this).attr('id');
101                                 $('#drop-' + id).removeClass('icon');
102                                 $('#drop-' + id).removeClass('drophide');
103                                 $('#drop-' + id).addClass('iconspacer'); }
104                         );
105
106                 // click outside notifications menu closes it
107                 $('html').click(function() {
108                         $('#nav-notifications-linkmenu').removeClass('selected');
109                         $('#nav-notifications-menu').css({display: 'none'});
110                 });
111
112                 $('#nav-notifications-linkmenu').click(function(event) {
113                         event.stopPropagation();
114                 });
115                 // click outside profiles menu closes it
116                 $('html').click(function() {
117                         $('#profiles-menu-trigger').removeClass('selected');
118                         $('#profiles-menu').css({display: 'none'});
119                 });
120
121                 $('#profiles-menu').click(function(event) {
122                         event.stopPropagation();
123                 });
124
125                 // main function in toolbar functioning
126                 function toggleToolbar() {
127                         if ( $('#nav-floater').is(':visible') ) {
128                                 $('#nav-floater').slideUp('fast');
129                                 $('.floaterflip').css({
130                                         backgroundPosition: '-210px -60px' 
131                                 });
132                                 $('.search-box').slideUp('fast');
133                         } else {
134                                 $('#nav-floater').slideDown('fast');
135                                 $('.floaterflip').css({
136                                         backgroundPosition: '-190px -60px'
137                                 });
138                                 $('.search-box').slideDown('fast');
139                         }
140                 };
141                 // our trigger for the toolbar button
142                 $('.floaterflip').click(function() {
143                         toggleToolbar();
144                         return false;
145                 });
146
147                 // (attempt to) change the text colour in a top post
148                 $('#profile-jot-text').focusin(function() {
149                         $(this).css({color: '#eec'});
150                 });
151
152                 $('a[href=#top]').click(function() {
153                         $('html, body').animate({scrollTop:0}, 'slow');
154                         return false;
155                 });
156
157         });
158         // shadowing effect for floating toolbars
159         $(document).scroll(function(e) {
160                 var pageTop = $('html').scrollTop();
161                 if (pageTop) {
162                         $('#nav-floater').css({boxShadow: '3px 3px 10px rgba(0, 0, 0, 0.7)'});
163                         $('.search-box').css({boxShadow: '3px 3px 10px rgba(0, 0, 0, 0.7)'});
164                 } else {
165                         $('#nav-floater').css({boxShadow: '0 0 0 0'});
166                         $('.search-box').css({boxShadow: '0 0 0 0'});
167                 }
168         });
169         </script>
170 EOT;
171
172     // custom css
173     if (!is_null($cssFile)) {
174         $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
175     }
176
177         _js_in_foot();
178 }
179
180 function dispy_community_info() {
181     /** @purpose some sidebar stuff for new users
182     */
183         $a = get_app();
184         $url = $a->get_baseurl($ssl_state);
185         $aside['$url'] = $url;
186
187         $tpl = file_get_contents(dirname(__file__) . '/communityhome.tpl');
188         return $a->page['aside_bottom'] = replace_macros($tpl, $aside);
189 }
190
191 if(! function_exists('_js_in_foot')) {
192         function _js_in_foot() {
193                 /** @purpose insert stuff in bottom of page
194                 */
195                 $a = get_app();
196                 $baseurl = $a->get_baseurl($ssl_state);
197                 $bottom['$baseurl'] = $baseurl;
198                 $tpl = file_get_contents(dirname(__file__) . '/bottom.tpl');
199
200                 return $a->page['bottom'] = replace_macros($tpl, $bottom);
201         }
202 }