-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe_header.php
More file actions
366 lines (344 loc) · 12.8 KB
/
e_header.php
File metadata and controls
366 lines (344 loc) · 12.8 KB
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<?php
/**
* G4HDU Goto Top plugin
*
* Copyright (C) 2008-2016 Barry Keal G4HDU http://e107.keal.me.uk
* blankd under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* @author Barry Keal e107@keal.me.uk>
* @copyright Copyright (C) 2008-2016 Barry Keal G4HDU
* @license GPL
* @version 1.0.0
*
*
*/
if (!defined('e107_INIT')) {
exit;
}
// error_reporting(E_ALL);
gotop::gotop();
/**
* gotop
*
* @package gotop
* @author Barry G4HDU
* @copyright Copyright (c) 2016
* @version $Id$
* @access public
*/
class gotop
{
private static $gotopPrefs; // all the preferences for the plugin
private static $size; // size of the goto top in px
private static $Active; // activate the plugin
private static $Admin; // show on admin pages
private static $HOffset; // horizontal offset in px
private static $VOffset; // vertical offset in px
private static $Position; // Which corner of the screen TL TR BL or BR(default)
private static $width; // width of gotop
private static $height; // height of gotop
private static $padding; // padding around the
private static $showText; // show or hide the word Top in the icon
private static $topFontSize; //
private static $background; // background colour
private static $backgroundColour; // background colour
private static $backgroundHover; // background colour when hovering
private static $borderWidth; // width of border in px
private static $borderColour; // border colour
private static $borderHover; // border colour when hovering
private static $borderShown; // show or hide the border
private static $borderRadius; // border radius (if any)
private static $borderCorner; // size of radius
private static $iconSize; // size of the arrow
private static $iconColour; // colour of the arrow
private static $iconHover; // colour of the arrow when hovering
private static $icon; // colour of the arrow when hovering
private static $paddingPref; // colour of the arrow when hovering
private static $gotoIcon; // colour of the arrow when hovering
/**
* gotop::__construct()
*/
function __construct()
{
}
/**
* gotop::gotop()
*
* @param void
* @return void
* @version 1.0.0
* @since 1.0.0
* @author Barry Keal G4HDU
*
*/
public static function gotop()
{
// self::$gotopPrefs = e107::getPlugConfig('gotop', true);
self::$gotopPrefs = e107::getPlugConfig('gotop', true);
self::$Active = self::$gotopPrefs->getPref('gotop_Active', 1);
self::$Admin = self::$gotopPrefs->getPref('gotop_Admin', 0);
self::$gotoIcon = self::$gotopPrefs->getPref('gotop_icon', 'arrow-up');
self::$paddingPref = self::$gotopPrefs->getPref('gotop_padding', 2);
if (self::$Active) {
if (self::$Admin || USER_AREA) {
self::$size = self::$gotopPrefs->getPref('gotop_size', 1);
self::$HOffset = self::$gotopPrefs->getPref('gotop_HOffset', 30);
self::$VOffset = self::$gotopPrefs->getPref('gotop_VOffset', 30);
self::$showText = self::$gotopPrefs->getPref('gotop_Text', 1);
self::$iconColour = self::resolveColour('gotop_iconColour');
self::$iconHover = self::resolveColour('gotop_iconHover');
self::$backgroundColour = self::resolveColour('gotop_backgroundColour');
self::$backgroundHover = self::resolveColour('gotop_backgroundHover');
self::$borderShown = self::$gotopPrefs->getPref('gotop_borderShown', 0);
self::$borderWidth = self::$gotopPrefs->getPref('gotop_borderWidth', 1);
self::$borderCorner = self::$gotopPrefs->getPref('gotop_corners', 0);
self::$borderColour = self::resolveColour('gotop_borderColour');
self::$borderHover = self::resolveColour('gotop_borderHover');
$Location = self::$gotopPrefs->getPref('gotop_location', 'br');
switch ($Location) {
case 'tl':
self::$Position = "
top:" . self::$VOffset . "px;
left:" . self::$HOffset . "px;";
break;
case 'tr':
self::$Position = "
top:" . self::$VOffset . "px;
right:" . self::$HOffset . "px;";
break;
case 'bl':
self::$Position = "
bottom:" . self::$VOffset . "px;
left:" . self::$HOffset . "px;";
break;
case 'br':
default:
self::$Position = "
bottom:" . self::$VOffset . "px;
right:" . self::$HOffset . "px;";
} // switch
self::$padding = self::$paddingPref;
if (self::$showText) {
switch (self::$size) {
case 24:
self::$background = 24;
self::$width = 24;
self::$height = 24;
self::$iconSize = 10;
self::$topFontSize = 8;
break;
case 36:
self::$background = 36;
self::$width = 36;
self::$height = 36;
self::$iconSize = 15;
self::$topFontSize = 11;
break;
case 48:
default:
self::$background = 48;
self::$width = 48;
self::$height = 48;
self::$iconSize = 26;
self::$topFontSize = 13;
break;
case 60:
self::$background = 60;
self::$width = 60;
self::$height = 60;
self::$iconSize = 33;
self::$topFontSize = 16;
break;
case 72:
self::$background = 72;
self::$width = 72;
self::$height = 72;
self::$iconSize = 38;
self::$topFontSize = 19;
break;
case 84:
self::$background = 84;
self::$width = 84;
self::$height = 84;
self::$iconSize = 46;
self::$topFontSize = 22;
break;
case 96:
self::$background = 96;
self::$width = 96;
self::$height = 96;
self::$iconSize = 52;
self::$topFontSize = 26;
break;
} // switch
} else {
switch (self::$size) {
case 24:
self::$background = 24;
self::$width = 24;
self::$height = 24;
self::$iconSize = 12;
break;
case 36:
self::$background = 36;
self::$width = 36;
self::$height = 36;
self::$iconSize = 18;
break;
case 48:
default:
self::$background = 48;
self::$width = 48;
self::$height = 48;
self::$iconSize = 24;
break;
case 60:
self::$background = 60;
self::$width = 60;
self::$height = 60;
self::$iconSize = 31;
break;
case 72:
self::$background = 72;
self::$width = 72;
self::$height = 72;
self::$iconSize = 37;
break;
case 84:
self::$background = 84;
self::$width = 84;
self::$height = 84;
self::$iconSize = 42;
self::$topFontSize = 18;
break;
case 96:
self::$background = 96;
self::$width = 96;
self::$height = 96;
self::$iconSize = 66;
self::$topFontSize = 18;
break;
} // switch
}
switch (self::$borderCorner) {
case 2:
self::$borderRadius = self::$height / 2;
break;
case 1:
self::$borderRadius = self::$height * .3;
break;
case 0:
default:
self::$borderRadius = 0;
break;
}
self::outputJS(); // output the javascript
self::outputCSS(); // output the css
}
}
}
/**
* gotop::resolveColour()
*
* @param void
* @return void
* @version 1.0.0
* @since 1.0.0
* @author Barry Keal G4HDU
*
*/
protected static function resolveColour($thePref)
{
$tempColour = self::$gotopPrefs->getPref($thePref, 'trans');
return ($tempColour == 'trans' ? 'transparent' : '#' . $tempColour);
}
/**
* gotop::resolveColour()
*
* @param void
* @return void
* @version 1.0.0
* @since 1.0.0
* @author Barry Keal G4HDU
*
*/
function outputJS()
{
// print (self::$showText);
e107::js('inline', 'var gotopText=' . self::$showText . ';', 'jquery'); // loads e107_plugins/gotop/js/gotop.js
e107::js('inline', 'var gotoIcon="' . self::$gotoIcon . '";', 'jquery'); // loads e107_plugins/gotop/js/gotop.js
e107::js('gotop', 'js/gotop.js', 'jquery'); // loads e107_plugins/gotop/js/gotop.js
}
/**
* gotop::resolveColour()
*
* @param void
* @return void
* @version 1.0.0
* @since 1.0.0
* @author Barry Keal G4HDU
*
*/
function outputCSS()
{
$width=self::$width+ self::$padding;
$height=self::$height+ self::$padding;
e107::css('inline', '
/* Goto Top */
#gotopContainer{
width:' . $width. 'px;
height:' . $height . 'px;
padding-left:' . self::$padding . 'px;
padding-right:' . self::$padding . 'px;
padding-top:' . self::$padding . 'px;
padding-bottom:' . self::$padding . 'px;
border:' . self::$borderWidth . 'px solid;
border-color: ' . self::$borderColour . ';
color: ' . self::$iconColour . ';
text-decoration: none;
position:fixed;
border:' . self::$borderWidth . 'px solid;
'. self::$Position.'
display:none;
background-color:' . self::$backgroundColour . ';
border-radius:' . self::$borderRadius . 'px;
z-index: 99;
-webkit-transition: background-color 1s, color 1s, border-color 1s ;
-moz-transition: background-color 1s, color 1s, border-color 1s ;
-o-transition: background-color 1s, color 1s, border-color 1s ;
transition: background-color 1s, color 1s, border-color 1s ;
}
#gotopContainer:hover {
cursor: pointer;
background-color:' . self::$backgroundHover . ' !important;
color: ' . self::$iconHover . ';
border-color: ' . self::$borderHover . ' !important;
}
#gotopInner{
display:flex;
flex-direction: column;
height:100%;
width:100%;
}
#gotopIcon{
text-align:center;
font-weight: bold;
font-size:' . self::$iconSize . 'px;
line-height:0.9em;
}
#gotopWord{
font-size:' . self::$topFontSize . 'px;
font-weight:normal;
line-height:0.99em;
}
.scrollToTopx:hover{
text-decoration:none;
background-color:' . self::$backgroundHover . ' !important;
color: ' . self::$iconHover . ';
border-color: ' . self::$borderHover . ' !important;
border:' . self::$borderWidth . 'px solid;
}
'); // end of e107::css
} // end outputCSS
} // end class