aboutsummaryrefslogtreecommitdiffstats
path: root/view/theme/dispy/theme.php
blob: 2d423a9280ec5e28547270375d4eb45841da4867 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php

/*
 * Name: Dispy
 * Description: Dispy family (light, dark): Sleek and Functional Themes 
 * Version: 1.2.1
 * Author: Simon <http://simon.kisikew.org/>
 * Maintainer: Simon <http://simon.kisikew.org/>
 * Screenshot: <a href="screenshot.jpg">Screenshot</a>
 */

/* If you borrow any of these functions, make sure to
 * RENAME your functions, otherwise both themes get conflicts,
 * and the friendica instance will get HTTP 500 errors.
 * To paraphrase Mike: "Might wish to wrap
 * function_name with "if(! function_exists('function_name')) ... "
 * or rename to prefix1_function_name (prefix2_function_name), etc.
 */

$a = get_app();
$a->theme_info = array(
    'family' => 'dispy',
	'version' => '1.2.2'
);

function dispy_init(&$a) {

    /** @purpose set some theme defaults
    */
    $cssFile = null;
    $colour = get_pconfig(local_user(), "dispy", "colour");
	$baseurl = $a->get_baseurl($ssl_state);

    if ($colour === false) { $colour = "light"; }
    if ($colour == "light") {
		$colour_path = "/light/";
		require_once ('light/theme.php');
	}
    if ($colour == "dark") {
		$colour_path = "/dark/";
		require_once ('dark/theme.php');
	}

    /** @purpose aside on profile page
    */
	if (($a->argv[0] . $a->argv[1]) === ("profile" . $a->user['nickname'])) {
		dispy_community_info();
	}

	$a->page['htmlhead'] .= <<<EOT
	<script type="text/javascript" src="$baseurl/view/theme/dispy/js/modernizr.custom.2.5.3.min.js"></script>
	<script type="text/javascript">
	$(document).ready(function() {
		// Select all links with lightbox class
		$("a.lightbox").fancybox();

    	$('.group-edit-icon').hover(
			function() {
				$(this).addClass('icon');
				$(this).removeClass('iconspacer'); },

			function() {
				$(this).removeClass('icon');
				$(this).addClass('iconspacer'); }
		);

		$('.sidebar-group-element').hover(
			function() {
				id = $(this).attr('id');
				$('#edit-' + id).addClass('icon');
				$('#edit-' + id).removeClass('iconspacer'); },

			function() {
				id = $(this).attr('id');
				$('#edit-' + id).removeClass('icon');
				$('#edit-' + id).addClass('iconspacer'); }
		);

		$('.savedsearchdrop').hover(
			function() {
				$(this).addClass('drop');
				$(this).addClass('icon');
				$(this).removeClass('iconspacer'); },

			function() {
				$(this).removeClass('drop');
				$(this).removeClass('icon');
				$(this).addClass('iconspacer'); }
		);

		$('.savedsearchterm').hover(
			function() {
				id = $(this).attr('id');
				$('#drop-' + id).addClass('icon');
				$('#drop-' + id).addClass('drophide');
				$('#drop-' + id).removeClass('iconspacer'); },

			function() {
				id = $(this).attr('id');
				$('#drop-' + id).removeClass('icon');
				$('#drop-' + id).removeClass('drophide');
				$('#drop-' + id).addClass('iconspacer'); }
			);

		// click outside notifications menu closes it
		$('html').click(function() {
			$('#nav-notifications-linkmenu').removeClass('selected');
			$('#nav-notifications-menu').css({display: 'none'});
		});

		$('#nav-notifications-linkmenu').click(function(event) {
			event.stopPropagation();
		});
		// click outside profiles menu closes it
		$('html').click(function() {
			$('#profiles-menu-trigger').removeClass('selected');
			$('#profiles-menu').css({display: 'none'});
		});

		$('#profiles-menu').click(function(event) {
			event.stopPropagation();
		});

		// main function in toolbar functioning
		function toggleToolbar() {
			if ( $('#nav-floater').is(':visible') ) {
				$('#nav-floater').slideUp('fast');
				$('.floaterflip').css({
					backgroundPosition: '-210px -60px' 
				});
				$('.search-box').slideUp('fast');
			} else {
				$('#nav-floater').slideDown('fast');
				$('.floaterflip').css({
					backgroundPosition: '-190px -60px'
				});
				$('.search-box').slideDown('fast');
			}
		};
		// our trigger for the toolbar button
		$('.floaterflip').click(function() {
			toggleToolbar();
			return false;
		});

		// (attempt to) change the text colour in a top post
		$('#profile-jot-text').focusin(function() {
			$(this).css({color: '#eec'});
		});

		$('a[href=#top]').click(function() {
			$('html, body').animate({scrollTop:0}, 'slow');
			return false;
		});

	});
	// shadowing effect for floating toolbars
	$(document).scroll(function(e) {
		var pageTop = $('html').scrollTop();
		if (pageTop) {
			$('#nav-floater').css({boxShadow: '3px 3px 10px rgba(0, 0, 0, 0.7)'});
			$('.search-box').css({boxShadow: '3px 3px 10px rgba(0, 0, 0, 0.7)'});
		} else {
			$('#nav-floater').css({boxShadow: '0 0 0 0'});
			$('.search-box').css({boxShadow: '0 0 0 0'});
		}
	});
	</script>
EOT;

    // custom css
    if (!is_null($cssFile)) {
        $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
    }

	_js_in_foot();
}

function dispy_community_info() {
    /** @purpose some sidebar stuff for new users
    */
	$a = get_app();
	$url = $a->get_baseurl($ssl_state);
	$aside['$url'] = $url;

	$tpl = file_get_contents(dirname(__file__) . '/communityhome.tpl');
	return $a->page['aside_bottom'] = replace_macros($tpl, $aside);
}

if(! function_exists('_js_in_foot')) {
	function _js_in_foot() {
		/** @purpose insert stuff in bottom of page
		*/
		$a = get_app();
		$baseurl = $a->get_baseurl($ssl_state);
		$bottom['$baseurl'] = $baseurl;
		$tpl = file_get_contents(dirname(__file__) . '/bottom.tpl');

		return $a->page['bottom'] = replace_macros($tpl, $bottom);
	}
}