-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswipe_gestures.php
executable file
·133 lines (127 loc) · 3.99 KB
/
swipe_gestures.php
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
<?php
/**
* A simple plugin that enabled touch screen left and right swiping for various previous and next pages.
* Based on the jQuery plugin touchSwipe http://labs.rampinteractive.co.uk/touchSwipe
*
* @author Malte Müller (acrylian) <[email protected]>
* @copyright 2015 Malte Müller
* @license GPL v3 or later
* @package plugins
* @subpackage misc
*/
$plugin_is_filter = 9|THEME_PLUGIN;
$plugin_description = gettext('A simple plugin that enabled touch screen left and right swiping on the single image page. Based on the jQuery plugin touchSwipe.');
$plugin_author = 'Malte Müller (acrylian)';
$plugin_version = '1.0.6';
$option_interface = 'swipeGestures';
zp_register_filter('theme_head','swipeGestures::swipejs');
/**
* Plugin option handling class
*
*/
class swipeGestures {
function __construct() {
}
function getOptionsSupported() {
$options = array(
gettext('Single image page') => array(
'order' => 0,
'key' => 'swipe_gestures_image',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext('Enables left/right swipe gestures for the previous/next image navigation.')),
gettext('Album pages') => array(
'order' => 1,
'key' => 'swipe_gestures_album',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext('Enables left/right swipe gestures for the previous/next album/search page navigation.')),
gettext('News loop pages') => array(
'order' => 2,
'key' => 'swipe_gestures_news',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext('Enables left/right swipe gestures for the previous/next news loop page navigation (<em>news on index</em> option not supported).')),
gettext('Single News pages') => array(
'order' => 3,
'key' => 'swipe_gestures_news_single',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext('Enables left/right swipe gestures for the previous/next single news page navigation.'))
);
return $options;
}
static function swipejs() {
global $_zp_gallery, $_zp_current_image, $_zp_gallery_page;
$prevurl = '';
$nexturl = '';
switch($_zp_gallery_page) {
case 'index.php':
case 'gallery.php':
case 'album.php':
case 'search.php':
if(getOption('swipe_gestures_album')) {
if(hasPrevPage()) {
$prevurl = getPrevPageURL();
}
if(hasNextPage()) {
$nexturl = getNextPageURL();
}
}
break;
case 'image.php':
if(getOption('swipe_gestures_image')) {
if(hasPrevImage()) {
$prevurl = getPrevImageURL();
}
if(hasNextImage()) {
$nexturl = getNextImageURL();
}
}
break;
case 'news.php':
if (getOption('zp_plugin_zenpage')) {
if (getOption('swipe_gestures_news') && !is_NewsArticle()) {
if(getPrevNewsPageURL()) {
$prevurl = getPrevNewsPageURL();
}
if(getNextNewsPageURL()) {
$nexturl = getNextNewsPageURL();
}
}
if (getOption('swipe_gestures_news_single') && is_NewsArticle()) {
if(getPrevNewsURL()) {
$prevurl = getPrevNewsURL();
$prevurl = $prevurl['link'];
}
if(getNextNewsURL()) {
$nexturl = getNextNewsURL();
$nexturl = $nexturl['link'];
}
}
}
break;
}
if(!empty($prevurl) || !empty($nexturl)) {
?>
<script type="text/javascript" src="<?php echo FULLWEBPATH.'/'.USER_PLUGIN_FOLDER; ?>/swipe_gestures/jquery.touchSwipe.min.js"></script>
<script type="text/javascript">
$('html').swipe({
//Generic swipe handler for all directions
<?php if(!empty($prevurl)) { ?>
swipeRight:function(event, direction, distance, duration, fingerCount) {
this.fadeOut();
document.location.href = '<?php echo $prevurl; ?>';
},
<?php } ?>
<?php if(!empty($nexturl)) { ?>
swipeLeft:function(event, direction, distance, duration, fingerCount) {
this.fadeOut();
document.location.href = '<?php echo $nexturl; ?>';
},
<?php } ?>
//Default is 75px, set to 0 for demo so any distance triggers swipe
threshold: 100
});
</script>
<?php
}
}
}
?>