Version Description
- Dropped jQuery UI dependency (jQuery UI is no longer required for the plugin to work).
- Fixed the bug of non-working links to other pages. The script now checks if href values refer to the parent document, before preventing the default behavior.
- Fixed the bug regarding selectors referencing body class not working.
- Any link handled by the plugin with href value
#top
will now scroll the page to top, if no element with idtop
exists.
- Added links highlighting feature. The script adds a class (default:
mPS2id-highlight
) automatically on links whose target elements are considered to be within the viewport. - Plugin adds a class (default:
mPS2id-target
) automatically on targets that are considered to be within the viewport. - Plugin adds a class (default:
mPS2id-clicked
) automatically on the link that has been clicked. - Added
offset
option: Offsets scroll-to position by x amount of pixels (positive or negative). - The plugin script now fully validates href values and ids before scrolling the page.
- Fixed varius minor bugs.
- Code rewritten and optimized for better performance and maintenance.
- For more see Plugin changelog.
Download this release
Release Info
Developer | malihu |
Plugin | Page scroll to id |
Version | 1.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.2 to 1.5.0
- css/admin.css +120 -0
- includes/admin.php +89 -0
- includes/help/get-started.inc +31 -0
- includes/help/overview.inc +18 -0
- includes/help/plugin-settings.inc +58 -0
- includes/help/sidebar.inc +12 -0
- jquery.malihu.PageScroll2id-init.js +0 -12
- jquery.malihu.PageScroll2id.js +0 -197
- js/admin.js +197 -0
- js/jquery.malihu.PageScroll2id-init.js +22 -0
- js/jquery.malihu.PageScroll2id.js +568 -0
- malihu-pagescroll2id.php +702 -238
- readme.txt +121 -25
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- uninstall.php +26 -0
css/admin.css
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* admin styling */
|
2 |
+
|
3 |
+
.plugin-info, .plugin-version, .repeatable-info, .donate{
|
4 |
+
color: #777;
|
5 |
+
}
|
6 |
+
|
7 |
+
.plugin-header{
|
8 |
+
overflow: hidden;
|
9 |
+
border-bottom: 1px solid #dfdfdf;
|
10 |
+
margin-bottom: 1.4em;
|
11 |
+
}
|
12 |
+
|
13 |
+
.plugin-info{
|
14 |
+
float: left;
|
15 |
+
width: 75%;
|
16 |
+
margin-right: 5%;
|
17 |
+
font-style: italic;
|
18 |
+
}
|
19 |
+
|
20 |
+
.plugin-version{
|
21 |
+
float: right;
|
22 |
+
text-align: right;
|
23 |
+
width: 20%;
|
24 |
+
}
|
25 |
+
|
26 |
+
.repeatable-group{
|
27 |
+
overflow: hidden;
|
28 |
+
}
|
29 |
+
|
30 |
+
.js .wrap .metabox-holder form{
|
31 |
+
opacity: 0;
|
32 |
+
}
|
33 |
+
|
34 |
+
.repeatable,.sortable-placeholder{
|
35 |
+
float: left;
|
36 |
+
margin-right: 1.4em;
|
37 |
+
margin-bottom: 1.4em;
|
38 |
+
}
|
39 |
+
|
40 |
+
.repeatable-info{
|
41 |
+
font-size: 0.9em;
|
42 |
+
}
|
43 |
+
|
44 |
+
.repeatable-info .shortcode-info .code code{
|
45 |
+
background: none;
|
46 |
+
}
|
47 |
+
|
48 |
+
.repeatable-info .shortcode-info:hover .code code{
|
49 |
+
background-color: rgba(0,0,0,0.07);
|
50 |
+
}
|
51 |
+
|
52 |
+
.repeatable .form-table{
|
53 |
+
max-width: 492px;
|
54 |
+
}
|
55 |
+
|
56 |
+
.repeatable.closed{
|
57 |
+
width: 492px;
|
58 |
+
max-width: 100%;
|
59 |
+
}
|
60 |
+
|
61 |
+
.repeatable .form-table th{
|
62 |
+
padding-left: 5px;
|
63 |
+
}
|
64 |
+
|
65 |
+
.repeatable .form-table td{
|
66 |
+
padding-right: 5px;
|
67 |
+
}
|
68 |
+
|
69 |
+
.repeatable .form-table tr:hover th, .repeatable .form-table tr:hover td{
|
70 |
+
background-color: rgba(0,0,0,0.07);
|
71 |
+
}
|
72 |
+
|
73 |
+
.repeatable-info{
|
74 |
+
padding: 0 10px 1em 10px;
|
75 |
+
border-bottom: 1px solid #dfdfdf;
|
76 |
+
}
|
77 |
+
|
78 |
+
.repeatable-tools{
|
79 |
+
padding: 1em 10px 0 10px;
|
80 |
+
border-top: 1px solid #dfdfdf;
|
81 |
+
}
|
82 |
+
|
83 |
+
.remove-disabled{
|
84 |
+
opacity: 0.5;
|
85 |
+
}
|
86 |
+
|
87 |
+
.other-buttons .button{
|
88 |
+
margin-right: 0.5em;
|
89 |
+
}
|
90 |
+
|
91 |
+
.submit{
|
92 |
+
display: inline-block;
|
93 |
+
margin-right: 0.25em;
|
94 |
+
}
|
95 |
+
|
96 |
+
.plugin-footer{
|
97 |
+
overflow: hidden;
|
98 |
+
border-top: 1px solid #dfdfdf;
|
99 |
+
margin-top: 1.4em;
|
100 |
+
}
|
101 |
+
|
102 |
+
.donate{
|
103 |
+
margin-top: 1.4em;
|
104 |
+
}
|
105 |
+
|
106 |
+
.donate span + input{
|
107 |
+
vertical-align: middle;
|
108 |
+
}
|
109 |
+
|
110 |
+
.description code{
|
111 |
+
font-style: normal;
|
112 |
+
}
|
113 |
+
|
114 |
+
.oldwp-plugin-help-section{
|
115 |
+
display: none;
|
116 |
+
}
|
117 |
+
|
118 |
+
.oldwp-plugin-help-section.oldwp-plugin-help-section-active{
|
119 |
+
display: block;
|
120 |
+
}
|
includes/admin.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// --edit--
|
3 |
+
$repeatables=false;
|
4 |
+
$shortcodes=false;
|
5 |
+
$plugin_info=__('<a href="#" class="mPS2id-open-help mPS2id-open-help-overview">Overview</a> <a href="#" class="mPS2id-open-help mPS2id-open-help-get-started">Get started</a> <a href="#" class="mPS2id-open-help mPS2id-open-help-plugin-settings">Plugin settings</a>', $this->plugin_slug);
|
6 |
+
$btn_add=__('Add instance', $this->plugin_slug);
|
7 |
+
$btn_more_actions=__('More actions', $this->plugin_slug);
|
8 |
+
$btn_reset=($repeatables) ? __('Delete all and reset to default', $this->plugin_slug) : __('Reset to default', $this->plugin_slug);
|
9 |
+
$toggle_instance_title=__('Click to toggle', $this->plugin_slug);
|
10 |
+
?>
|
11 |
+
|
12 |
+
<div class="wrap">
|
13 |
+
|
14 |
+
<?php screen_icon(); ?>
|
15 |
+
<h2><?php echo esc_html(get_admin_page_title()); ?></h2>
|
16 |
+
|
17 |
+
<div class="plugin-header">
|
18 |
+
<p class="plugin-info"><?php echo $plugin_info; ?></p>
|
19 |
+
<p class="plugin-version">Version <?php echo $this->version; ?></p>
|
20 |
+
|
21 |
+
<?php if(get_bloginfo('version') < '3.6') : ?>
|
22 |
+
<div class="oldwp-plugin-help">
|
23 |
+
<!-- --edit-- -->
|
24 |
+
<div class="oldwp-plugin-help-section oldwp-plugin-help-section-overview">
|
25 |
+
<?php include_once(plugin_dir_path( __FILE__ ).'help/overview.inc'); ?>
|
26 |
+
<p>
|
27 |
+
<strong>For more information</strong> <br />
|
28 |
+
<a href="http://manos.malihu.gr" target="_blank">Plugin homepage</a> <a href="http://manos.malihu.gr" target="_blank">Plugin documentation</a>
|
29 |
+
</p>
|
30 |
+
</div>
|
31 |
+
<div class="oldwp-plugin-help-section oldwp-plugin-help-section-get-started">
|
32 |
+
<?php include_once(plugin_dir_path( __FILE__ ).'help/get-started.inc'); ?>
|
33 |
+
</div>
|
34 |
+
<div class="oldwp-plugin-help-section oldwp-plugin-help-section-plugin-settings">
|
35 |
+
<?php include_once(plugin_dir_path( __FILE__ ).'help/plugin-settings.inc'); ?>
|
36 |
+
</div>
|
37 |
+
</div>
|
38 |
+
<?php endif; ?>
|
39 |
+
|
40 |
+
</div>
|
41 |
+
|
42 |
+
<?php if($repeatables) : ?>
|
43 |
+
<div class="metabox-holder">
|
44 |
+
<?php endif; ?>
|
45 |
+
|
46 |
+
<form id="<?php echo $this->pl_pfx; ?>form" method="post" action="options.php">
|
47 |
+
|
48 |
+
<?php settings_fields($this->plugin_slug); ?>
|
49 |
+
|
50 |
+
<?php echo '<input type="hidden" id="'.$this->db_prefix.'total_instances'.'" name="'.$this->db_prefix.'total_instances'.'" value="'.$this->index.'" /> '; ?>
|
51 |
+
<?php echo '<input type="hidden" id="'.$this->db_prefix.'instances'.'" name="'.$this->db_prefix.'instances'.'" value="" /> '; ?>
|
52 |
+
<?php echo '<input type="hidden" id="'.$this->db_prefix.'reset'.'" name="'.$this->db_prefix.'reset'.'" value="false" /> '; ?>
|
53 |
+
|
54 |
+
<?php do_settings_sections($this->plugin_slug); ?>
|
55 |
+
|
56 |
+
<div class="other-buttons">
|
57 |
+
<?php if($repeatables) : ?>
|
58 |
+
<a class="button button-small repeatable-add" href="#"><?php echo $btn_add; ?></a>
|
59 |
+
<?php endif; ?>
|
60 |
+
<a class="button button-small reset-to-default" href="#"><?php echo $btn_reset; ?></a>
|
61 |
+
</div>
|
62 |
+
|
63 |
+
<?php submit_button(); ?>
|
64 |
+
|
65 |
+
</form>
|
66 |
+
|
67 |
+
<?php if($repeatables) : ?>
|
68 |
+
</div>
|
69 |
+
<?php endif; ?>
|
70 |
+
|
71 |
+
<div class="plugin-footer">
|
72 |
+
<div class="donate">
|
73 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
74 |
+
<input type="hidden" name="cmd" value="_s-xclick">
|
75 |
+
<input type="hidden" name="hosted_button_id" value="UYJ5G65M6ZA28">
|
76 |
+
<span>If you like this plugin and find it useful, consider making a donation :)</span> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
77 |
+
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
78 |
+
</form>
|
79 |
+
</div>
|
80 |
+
</div>
|
81 |
+
|
82 |
+
</div>
|
83 |
+
|
84 |
+
<script>
|
85 |
+
var wpVersion="<?php echo get_bloginfo('version'); ?>",
|
86 |
+
repeatables="<?php echo $repeatables; ?>",
|
87 |
+
shortcodes="<?php echo $shortcodes; ?>",
|
88 |
+
toggle_instance_title="<?php echo $toggle_instance_title; ?>";
|
89 |
+
</script>
|
includes/help/get-started.inc
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$help_get_started_text=<<<EOD
|
3 |
+
|
4 |
+
<p>
|
5 |
+
The plugin works simply by connecting links in the form of <code><a href="#id">link</a></code>, to sections within the document, in the form of <code><div id="id">target</div></code>. Clicking the links will smoothly animate the page to the connected sections, provided the links are included in the Selector(s) field. <br />
|
6 |
+
The default value of Selector(s) is <code>a[rel='m_PageScroll2id']</code>, meaning the plugin will apply on links with <code>m_PageScroll2id</code> rel attribute value (e.g. <code><a href="#id" rel="m_PageScroll2id">link</a></code>).
|
7 |
+
</p>
|
8 |
+
|
9 |
+
<p>
|
10 |
+
<strong>Get started</strong> by adding <code>rel="m_PageScroll2id"</code> to your links that point to existing sections within your page, making sure each link's href value contains a hash (<code>#</code>) with the id of the section you want to scroll-to.
|
11 |
+
</p>
|
12 |
+
|
13 |
+
<p>
|
14 |
+
To add <code>rel="m_PageScroll2id"</code> to links in custom menus (menus created in Appearance › Menus), do the following: <br />
|
15 |
+
While on the Menus admin page, click "Screen Options" and check "Link Relationship (XFN)". To enable the plugin on a menu item, click the arrow on the right of the item and insert <code>m_PageScroll2id</code> in the "Link Relationship (XFN)" field (assuming your menu contains links with "URL" value in the form of <code>#id</code>).
|
16 |
+
</p>
|
17 |
+
|
18 |
+
<p>
|
19 |
+
If you cannot edit your html markup or don't want to alter your links rel attributes, you can change the Selector(s) field value to existing matching sets of elements in your theme, e.g. <code>a.class-name</code>, <code>#id a</code>, <code>a[href*='#']</code> etc. For multiple selectors, use comma separated values: e.g. <code>a[rel='m_PageScroll2id'], a.class-name</code>.
|
20 |
+
</p>
|
21 |
+
|
22 |
+
<p>
|
23 |
+
To highlight your links and/or targets, use the class(es) provided by the plugin in your theme's stylesheet. The default highlight class is <code>mPS2id-highlight</code> but you can set your own in the Classes fields below. <br />
|
24 |
+
For example, to style the highlighted link (the link whose target element is considered to be within the viewport), you could add in your CSS: <br />
|
25 |
+
<code>a.mPS2id-highlight{ background: #ff0; }</code> or <code>.menu-item a.mPS2id-highlight{ background: #ff0; }</code> for highlighting custom menus links only.
|
26 |
+
</p>
|
27 |
+
|
28 |
+
EOD;
|
29 |
+
?>
|
30 |
+
|
31 |
+
<?php _e($help_get_started_text, $this->plugin_slug); ?>
|
includes/help/overview.inc
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$help_overview_text=<<<EOD
|
3 |
+
|
4 |
+
<p>
|
5 |
+
<strong>Page scroll to id</strong> is an easy-to-use jQuery plugin that enables animated page scrolling to specific id within the document.
|
6 |
+
</p>
|
7 |
+
|
8 |
+
<p>
|
9 |
+
The plugin replaces the default browser behaviour of "jumping" to page sections when links with href value containing <code>#</code> are clicked, by smoothly animating the page to those sections. <br />
|
10 |
+
You can use it for simple back-to-top links or complex, single-page website navigation and features include: adjustable animation speed, advanced animation easings, vertical and/or horizontal scrolling, links highlighting etc.
|
11 |
+
</p>
|
12 |
+
|
13 |
+
<p>If you like this plugin and find it useful, consider making a <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UYJ5G65M6ZA28" target="_blank">donation</a> :)</p>
|
14 |
+
|
15 |
+
EOD;
|
16 |
+
?>
|
17 |
+
|
18 |
+
<?php _e($help_overview_text, $this->plugin_slug); ?>
|
includes/help/plugin-settings.inc
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$help_plugin_settings_text=<<<EOD
|
3 |
+
|
4 |
+
<p>
|
5 |
+
<strong>Selector(s)</strong> -
|
6 |
+
The matching set of elements handled by the plugin (<a href="http://www.w3.org/TR/css3-selectors/" target="_blank">strings that represent ways of choosing elements in the DOM</a>). These should be anchor tags (links) with an href value in the form of <code>#id</code>. <br />
|
7 |
+
Each selector is separated by comma, so multiple matching sets of elements can be defined as: <code>selector1, selector2, selector3</code> etc. <br />
|
8 |
+
The default selector value is <code>a[rel='m_PageScroll2id']</code>, meaning the plugin is applied to all anchor elements with <code>m_PageScroll2id</code> rel attribute value. <br />
|
9 |
+
Other examples: <code>a[href*='#']</code> (anchors that contain <code>#</code> in their href attribute), <code>a[href='#top']</code> (anchors with href attribute value: <code>#top</code>), <code>a.className</code> (anchors with class: <code>className</code>).
|
10 |
+
</p>
|
11 |
+
|
12 |
+
<p>
|
13 |
+
<strong>Scroll animation speed</strong> -
|
14 |
+
Sets the duration of scrolling animation in milliseconds. By checking "Auto-adjust animation speed", the duration is adjusted automatically according to target element position and window scroll. This normalizes animation speed in order to avoid short-distance animations that take too long (e.g. a page scrolling of just 100 pixels will last shorter than the value specified above).
|
15 |
+
</p>
|
16 |
+
|
17 |
+
<p>
|
18 |
+
<strong>Scroll animation easing</strong> -
|
19 |
+
Sets the easing type of scrolling animation (the speed at which an animation progresses at different points within the animation). <br />
|
20 |
+
You can set different easing types: one for when page is idle (no animation currently running) and another that applies while page is animating. <br />
|
21 |
+
<a href="http://api.jqueryui.com/easings/" target="_blank">Visual representation of all easings</a>
|
22 |
+
</p>
|
23 |
+
|
24 |
+
<p>
|
25 |
+
<strong>Scroll-to position</strong> -
|
26 |
+
Adjusts automatically the scroll-to position so it does not exceed document length. For example, when scrolling to a target element that sits at the bottom of the document, the animation stops smoothly at bottom of the page, instead of breaking at an earlier point.
|
27 |
+
</p>
|
28 |
+
|
29 |
+
<p>
|
30 |
+
<strong>Page layout</strong> -
|
31 |
+
Defines the page scrolling axis. Selecting <code>vertical</code> will scroll the page in the y axis (top-bottom only), while <code>horizontal</code> will scroll the page in the x axis (left-right only). To scroll both axis simultaneously select <code>auto</code>.
|
32 |
+
</p>
|
33 |
+
|
34 |
+
<p>
|
35 |
+
<strong>Offset</strong> -
|
36 |
+
Defines the amount of pixels to offset the scroll-to position. The value can a be a positive or negative number. For example, setting offset to 50 will stop page scrolling 50 pixels before reaching the target.
|
37 |
+
</p>
|
38 |
+
|
39 |
+
<p>
|
40 |
+
<strong>Highlight selector(s)</strong> -
|
41 |
+
The matching set of elements already handled by the plugin (defined in Selector(s) field) that will be highlighted. <br />
|
42 |
+
The plugin adds a class (specified in Classes fields) on the links whose target elements are considered to be within the viewport. Highlight selector(s) specifies those links. <br />
|
43 |
+
Leaving the field empty (also the default setting), all selectors specified in Selector(s) field are eligible for highlighting. In case you need to highlight only a specific selector (e.g. your navigation menu links but not back-to-top links etc.), you should enter those selector(s) (e.g. <code>.menu-item a[rel='m_PageScroll2id']</code>).
|
44 |
+
</p>
|
45 |
+
|
46 |
+
<p>
|
47 |
+
<strong>Classes</strong> -
|
48 |
+
Set the classes added to links by the plugin: <br />
|
49 |
+
1. The class name for the link that's been clicked <br />
|
50 |
+
2. The class name for the (current) target element<br />
|
51 |
+
3. The class name for the (current) highlighted link <br />
|
52 |
+
By checking "Force single highlight", only one highlighted element is allowed at a time.
|
53 |
+
</p>
|
54 |
+
|
55 |
+
EOD;
|
56 |
+
?>
|
57 |
+
|
58 |
+
<?php _e($help_plugin_settings_text, $this->plugin_slug); ?>
|
includes/help/sidebar.inc
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$help_sidebar_text=<<<EOD
|
3 |
+
|
4 |
+
<p><strong>For more information</strong></p>
|
5 |
+
|
6 |
+
<p><a href="http://manos.malihu.gr/page-scroll-to-id" target="_blank">Plugin homepage</a> <br />
|
7 |
+
<a href="http://manos.malihu.gr/page-scroll-to-id/2/" target="_blank">Code examples & short tutorials</a></p>
|
8 |
+
|
9 |
+
EOD;
|
10 |
+
?>
|
11 |
+
|
12 |
+
<?php _e($help_sidebar_text, $this->plugin_slug); ?>
|
jquery.malihu.PageScroll2id-init.js
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
(function($){
|
2 |
-
$(window).load(function(){
|
3 |
-
$(malihuPageScroll2idInitParams.sel).mPageScroll2id({
|
4 |
-
scrollSpeed:parseInt(malihuPageScroll2idInitParams.scrollSpeed),
|
5 |
-
autoScrollSpeed:malihuPageScroll2idInitParams.autoScrollSpeed == "true" ? true : false,
|
6 |
-
scrollEasing:malihuPageScroll2idInitParams.scrollEasing,
|
7 |
-
scrollingEasing:malihuPageScroll2idInitParams.scrollingEasing,
|
8 |
-
pageEndSmoothScroll:malihuPageScroll2idInitParams.pageEndSmoothScroll == "true" ? true : false,
|
9 |
-
layout:malihuPageScroll2idInitParams.layout
|
10 |
-
});
|
11 |
-
});
|
12 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jquery.malihu.PageScroll2id.js
DELETED
@@ -1,197 +0,0 @@
|
|
1 |
-
//Page scroll to id by malihu (http://manos.malihu.gr)
|
2 |
-
//plugin home http://manos.malihu.gr/animate-page-to-id-with-jquery
|
3 |
-
(function($){
|
4 |
-
var methods={
|
5 |
-
init:function(options){
|
6 |
-
var defaults={
|
7 |
-
scrollSpeed:1300, //scroll animation speed in milliseconds
|
8 |
-
autoScrollSpeed:true, //auto-adjust animation speed (according to element position)
|
9 |
-
scrollEasing:"easeInOutExpo", //scroll animation easing when page is idle
|
10 |
-
scrollingEasing:"easeInOutCirc", //scroll animation easing while page is animated
|
11 |
-
callback:function(){}, //user custom callback function
|
12 |
-
pageEndSmoothScroll:true, //end of page smooth scrolling (if bottom elements are too short)
|
13 |
-
layout:"vertical" //page layout defines scrolling direction (vertical, horizontal, auto)
|
14 |
-
};
|
15 |
-
var options=$.extend(defaults,options);
|
16 |
-
$().mPageScroll2id("checkTouchDevice");
|
17 |
-
var ua=navigator.userAgent,
|
18 |
-
scrollElem="html";
|
19 |
-
if(ua.indexOf(' AppleWebKit/')!==-1){ //animate body for webkit browsers that don't support html animation
|
20 |
-
scrollElem="body";
|
21 |
-
}
|
22 |
-
//store options, global animation state
|
23 |
-
$(document).data("mPageScroll2id-scrollElem",scrollElem).data("mPageScroll2id-layout",options.layout).data("mPageScroll2id-pageEndSmoothScroll",options.pageEndSmoothScroll).data("mPageScroll2id-speed",options.scrollSpeed).data("mPageScroll2id-easing",options.scrollEasing).data("mPageScroll2id-animation","idle");
|
24 |
-
return $("body")["delegate"](this.selector,"click",function(e){
|
25 |
-
e.preventDefault();
|
26 |
-
var $this=$(this);
|
27 |
-
var scrollTarget=$this.attr("href").split("#");
|
28 |
-
var scrollToPos=$("#"+scrollTarget[1]).offset().top;
|
29 |
-
var docHeight=$(document).height();
|
30 |
-
if(options.layout==="horizontal"){ //x-axis
|
31 |
-
scrollToPos=$("#"+scrollTarget[1]).offset().left;
|
32 |
-
var docWidth=$(document).width();
|
33 |
-
}else if(options.layout==="auto"){ //xy-axis
|
34 |
-
var scrollToPosX=$("#"+scrollTarget[1]).offset().left;
|
35 |
-
var docWidth=$(document).width();
|
36 |
-
var scrollToX=scrollToPosX;
|
37 |
-
}
|
38 |
-
var scrollTo=scrollToPos;
|
39 |
-
if(options.pageEndSmoothScroll){
|
40 |
-
scrollTo=$().mPageScroll2id("pageEndSmoothScroll",{
|
41 |
-
scrollTo:scrollToPos,
|
42 |
-
scrollToX:scrollToPosX
|
43 |
-
});
|
44 |
-
if(options.layout==="auto"){ //xy-axis
|
45 |
-
var getScrollTo=scrollTo[0];
|
46 |
-
var getScrollToX=scrollTo[1];
|
47 |
-
scrollTo=getScrollTo;
|
48 |
-
scrollToX=getScrollToX;
|
49 |
-
}
|
50 |
-
}
|
51 |
-
var easing=options.scrollEasing;
|
52 |
-
$(document).data("mPageScroll2id-easing",easing); //store easing for history
|
53 |
-
if($(scrollElem).is(":animated")){ //if page is animated change easing type
|
54 |
-
easing=options.scrollingEasing;
|
55 |
-
}
|
56 |
-
var speed=options.scrollSpeed;
|
57 |
-
$(document).data("mPageScroll2id-speed",speed); //store speed for history
|
58 |
-
if(options.autoScrollSpeed){ //auto-adjust scroll speed
|
59 |
-
var autoSpeedPercentage=Math.floor((Math.abs(scrollTo-$(window).scrollTop())/docHeight)*100);
|
60 |
-
if(options.layout==="horizontal"){ //x-axis
|
61 |
-
autoSpeedPercentage=Math.floor((Math.abs(scrollTo-$(window).scrollLeft())/docWidth)*100);
|
62 |
-
}else if(options.layout==="auto"){ //xy-axis
|
63 |
-
var autoSpeedPercentageX=Math.floor((Math.abs(scrollToX-$(window).scrollLeft())/docWidth)*100);
|
64 |
-
if(autoSpeedPercentageX>autoSpeedPercentage){
|
65 |
-
autoSpeedPercentage=autoSpeedPercentageX;
|
66 |
-
}
|
67 |
-
}
|
68 |
-
var autoSpeed=speed+((speed*autoSpeedPercentage)/100);
|
69 |
-
speed=autoSpeed;
|
70 |
-
}
|
71 |
-
$(scrollElem).mPageScroll2id("animate",{
|
72 |
-
scrollTo:scrollTo,
|
73 |
-
speed:speed,
|
74 |
-
easing:easing,
|
75 |
-
callback:options.callback,
|
76 |
-
layout:options.layout,
|
77 |
-
scrollToX:scrollToX //xy-axis
|
78 |
-
});
|
79 |
-
});
|
80 |
-
},
|
81 |
-
pageEndSmoothScroll:function(options){
|
82 |
-
var scrollTo;
|
83 |
-
var scrollToX; //xy-axis
|
84 |
-
var docLength=$(document).height();
|
85 |
-
var winLength=$(window).height();
|
86 |
-
if($(document).data("mPageScroll2id-layout")==="horizontal"){ //x-axis
|
87 |
-
docLength=$(document).width();
|
88 |
-
winLength=$(window).width();
|
89 |
-
}else if($(document).data("mPageScroll2id-layout")==="auto"){ //xy-axis
|
90 |
-
var docLengthX=$(document).width();
|
91 |
-
var winLengthX=$(window).width();
|
92 |
-
scrollToX=options.scrollToX;
|
93 |
-
if((docLengthX-options.scrollToX)<winLengthX){ //page end smooth scrolling
|
94 |
-
scrollToX=docLengthX-winLengthX;
|
95 |
-
}
|
96 |
-
}
|
97 |
-
scrollTo=options.scrollTo;
|
98 |
-
if((docLength-options.scrollTo)<winLength){ //page end smooth scrolling
|
99 |
-
scrollTo=docLength-winLength;
|
100 |
-
}
|
101 |
-
if($(document).data("mPageScroll2id-layout")==="auto"){
|
102 |
-
return [scrollTo,scrollToX];
|
103 |
-
}else{
|
104 |
-
return scrollTo;
|
105 |
-
}
|
106 |
-
},
|
107 |
-
animate:function(options){
|
108 |
-
var $this=$(this);
|
109 |
-
$(document).data("mPageScroll2id-animation","underway"); //global animation state
|
110 |
-
if(options.layout==="horizontal"){ //x-axis
|
111 |
-
$this.stop().animate({scrollLeft:options.scrollTo},options.speed,options.easing,function(){
|
112 |
-
$(document).data("mPageScroll2id-animation","idle"); //global animation state
|
113 |
-
options.callback.call(); //user custom callback function
|
114 |
-
});
|
115 |
-
}else if(options.layout==="auto"){ //xy-axis
|
116 |
-
if($(document).data("mPageScroll2id-is_touch_device")==="iOS"){ //iOS fix
|
117 |
-
$(window).scrollTop(options.scrollTo).scrollLeft(options.scrollToX);
|
118 |
-
$(document).data("mPageScroll2id-animation","idle"); //global animation state
|
119 |
-
options.callback.call(); //user custom callback function
|
120 |
-
}else{
|
121 |
-
$this.stop().animate({scrollTop:options.scrollTo,scrollLeft:options.scrollToX},options.speed,options.easing,function(){
|
122 |
-
$(document).data("mPageScroll2id-animation","idle"); //global animation state
|
123 |
-
options.callback.call(); //user custom callback function
|
124 |
-
});
|
125 |
-
}
|
126 |
-
}else{
|
127 |
-
$this.stop().animate({scrollTop:options.scrollTo},options.speed,options.easing,function(){
|
128 |
-
$(document).data("mPageScroll2id-animation","idle"); //global animation state
|
129 |
-
options.callback.call(); //user custom callback function
|
130 |
-
});
|
131 |
-
}
|
132 |
-
},
|
133 |
-
history:function(options){ //history
|
134 |
-
var hScrollTo=$("#"+options.scrollTo).offset().top;
|
135 |
-
if($(document).data("mPageScroll2id-layout")==="horizontal"){ //x-axis
|
136 |
-
hScrollTo=$("#"+options.scrollTo).offset().left;
|
137 |
-
}else if($(document).data("mPageScroll2id-layout")==="auto"){ //xy-axis
|
138 |
-
var hScrollToX=$("#"+options.scrollTo).offset().left;
|
139 |
-
}
|
140 |
-
if($(document).data("mPageScroll2id-pageEndSmoothScroll")===true){
|
141 |
-
hScrollTo=$().mPageScroll2id("pageEndSmoothScroll",{
|
142 |
-
scrollTo:hScrollTo,
|
143 |
-
scrollToX:hScrollToX
|
144 |
-
});
|
145 |
-
if($(document).data("mPageScroll2id-layout")==="auto"){ //xy-axis
|
146 |
-
var gethScrollTo=hScrollTo[0];
|
147 |
-
var gethScrollToX=hScrollTo[1];
|
148 |
-
hScrollTo=gethScrollTo;
|
149 |
-
hScrollToX=gethScrollToX;
|
150 |
-
}
|
151 |
-
}
|
152 |
-
$(document).data("mPageScroll2id-animation","underway"); //global animation state
|
153 |
-
if($(document).data("mPageScroll2id-layout")==="horizontal"){ //x-axis
|
154 |
-
$($(document).data("mPageScroll2id-scrollElem")).stop().animate({scrollLeft:hScrollTo},$(document).data("mPageScroll2id-speed"),$(document).data("mPageScroll2id-easing"),function(){
|
155 |
-
$(document).data("mPageScroll2id-animation","idle"); //global animation state
|
156 |
-
});
|
157 |
-
}else if($(document).data("mPageScroll2id-layout")==="auto"){ //xy-axis
|
158 |
-
if($(document).data("mPageScroll2id-is_touch_device")==="iOS"){ //iOS fix
|
159 |
-
$(window).scrollTop(hScrollTo).scrollLeft(hScrollToX);
|
160 |
-
$(document).data("mPageScroll2id-animation","idle"); //global animation state
|
161 |
-
}else{
|
162 |
-
$($(document).data("mPageScroll2id-scrollElem")).stop().animate({scrollTop:hScrollTo,scrollLeft:hScrollToX},$(document).data("mPageScroll2id-speed"),$(document).data("mPageScroll2id-easing"),function(){
|
163 |
-
$(document).data("mPageScroll2id-animation","idle"); //global animation state
|
164 |
-
});
|
165 |
-
}
|
166 |
-
}else{
|
167 |
-
$($(document).data("mPageScroll2id-scrollElem")).stop().animate({scrollTop:hScrollTo},$(document).data("mPageScroll2id-speed"),$(document).data("mPageScroll2id-easing"),function(){
|
168 |
-
$(document).data("mPageScroll2id-animation","idle"); //global animation state
|
169 |
-
});
|
170 |
-
}
|
171 |
-
},
|
172 |
-
checkTouchDevice:function(){
|
173 |
-
if(is_touch_device()){
|
174 |
-
$("html").addClass("is-touch-device");
|
175 |
-
$(document).data("mPageScroll2id-is_touch_device","true");
|
176 |
-
//check iOS
|
177 |
-
var deviceAgent=navigator.userAgent.toLowerCase();
|
178 |
-
var $iOS=deviceAgent.match(/(iphone|ipod|ipad)/);
|
179 |
-
if($iOS){
|
180 |
-
$(document).data("mPageScroll2id-is_touch_device","iOS");
|
181 |
-
}
|
182 |
-
}
|
183 |
-
function is_touch_device(){
|
184 |
-
return !!("ontouchstart" in window) ? 1 : 0;
|
185 |
-
}
|
186 |
-
}
|
187 |
-
}
|
188 |
-
$.fn.mPageScroll2id=function(method){
|
189 |
-
if(methods[method]){
|
190 |
-
return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
|
191 |
-
}else if(typeof method==="object" || !method){
|
192 |
-
return methods.init.apply(this,arguments);
|
193 |
-
}else{
|
194 |
-
$.error("Method "+method+" does not exist");
|
195 |
-
}
|
196 |
-
};
|
197 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/admin.js
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
$(document).ready(function(){
|
3 |
+
|
4 |
+
/*
|
5 |
+
--------------------
|
6 |
+
General js
|
7 |
+
--------------------
|
8 |
+
*/
|
9 |
+
|
10 |
+
var adminID="#"+_adminParams.id,
|
11 |
+
totalInstances=$("#"+_adminParams.db_prefix+"total_instances"),
|
12 |
+
resetField=$("#"+_adminParams.db_prefix+"reset"),
|
13 |
+
shortcodePrefix=_adminParams.sc_prefix,
|
14 |
+
instanceTitle="Instance title";
|
15 |
+
|
16 |
+
if(repeatables){
|
17 |
+
$(".form-table").wrapAll("<div class='repeatable-group meta-box-sortables' />").each(function(index){
|
18 |
+
$(this).wrap("<div class='repeatable postbox' />").wrap("<div class='inside' />").parent().parent().prepend("<div class='handlediv' title='"+toggle_instance_title+"'><br /></div><h3 class='handle'><span>"+instanceTitle+"</span></h3>").children(".inside").prepend("<p class='repeatable-info'></p>").append("<p class='repeatable-tools'><a class='button button-small repeatable-remove' href='#'>Remove</a></p>");
|
19 |
+
});
|
20 |
+
|
21 |
+
setRemovable();
|
22 |
+
setTitle();
|
23 |
+
|
24 |
+
if(shortcodes){
|
25 |
+
$(".repeatable-info").append("<span class='shortcode-info' />");
|
26 |
+
|
27 |
+
setShortcode();
|
28 |
+
}
|
29 |
+
|
30 |
+
$(".js .wrap form").css({"opacity":1});
|
31 |
+
|
32 |
+
$(".repeatable-add").click(function(e){
|
33 |
+
e.preventDefault();
|
34 |
+
var repeatable=loc=$(adminID+" .repeatable:last"),cloned;
|
35 |
+
if(repeatable.length>0){
|
36 |
+
cloned=repeatable.clone(true);
|
37 |
+
var clonedRadio=cloned.find("input:radio"),
|
38 |
+
clonedRadioName=clonedRadio.attr("name");
|
39 |
+
clonedRadio.attr("name",clonedRadioName+"-cloned");
|
40 |
+
cloned.insertAfter(loc);
|
41 |
+
totalInstances.val(parseInt(totalInstances.val())+1);
|
42 |
+
setRepeatable();
|
43 |
+
}else{
|
44 |
+
cloned="WTF!? All is empty...";
|
45 |
+
loc=$(".repeatable-group");
|
46 |
+
loc.append(cloned);
|
47 |
+
}
|
48 |
+
});
|
49 |
+
|
50 |
+
$(".repeatable-group").sortable({
|
51 |
+
opacity:0.6,
|
52 |
+
revert:true,
|
53 |
+
cursor:"move",
|
54 |
+
handle:".handle",
|
55 |
+
placeholder:"sortable-placeholder",
|
56 |
+
forcePlaceholderSize:true,
|
57 |
+
update: function(event,ui){
|
58 |
+
setRepeatable();
|
59 |
+
}
|
60 |
+
});
|
61 |
+
|
62 |
+
$("body").delegate(".repeatable-group","click",function(){
|
63 |
+
$(this).sortable("refresh");
|
64 |
+
}).delegate(".repeatable-remove","click",function(e){
|
65 |
+
e.preventDefault();
|
66 |
+
if(!$(this).hasClass("remove-disabled")){
|
67 |
+
$(this).parent().parent().parent(".repeatable").remove();
|
68 |
+
totalInstances.val(parseInt(totalInstances.val())-1);
|
69 |
+
setRepeatable();
|
70 |
+
}
|
71 |
+
}).delegate(".handlediv","click",function(e){
|
72 |
+
e.preventDefault();
|
73 |
+
var $this=$(this);
|
74 |
+
$this.parent().toggleClass("closed");
|
75 |
+
});
|
76 |
+
}else{
|
77 |
+
if(shortcodes){
|
78 |
+
$(".plugin-footer").prepend("<p><span class='shortcode-info' /></p>");
|
79 |
+
|
80 |
+
setShortcode();
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
$(".reset-to-default").click(function(e){
|
85 |
+
e.preventDefault();
|
86 |
+
resetField.val("true");
|
87 |
+
$("#submit").attr({"id":"none","name":"none"});
|
88 |
+
$(adminID).submit();
|
89 |
+
});
|
90 |
+
|
91 |
+
function setRepeatable(){
|
92 |
+
$(".repeatable").each(function(){
|
93 |
+
var $this=$(this),
|
94 |
+
i=$this.index();
|
95 |
+
$this.find("label,input,select,textarea").each(function(){
|
96 |
+
var field=$(this);
|
97 |
+
if(field[0].nodeName.toLowerCase()==="label"){
|
98 |
+
if(!!field.attr("for")){
|
99 |
+
var upd=changeAttr(field.attr("for"),i);
|
100 |
+
field.attr({"for":upd});
|
101 |
+
}
|
102 |
+
}else{
|
103 |
+
var upd=changeAttr(field.attr("name"),i).replace("-cloned","");
|
104 |
+
field.attr({"name":upd});
|
105 |
+
if(!!field.attr("id")){
|
106 |
+
field.attr({"id":upd});
|
107 |
+
}
|
108 |
+
}
|
109 |
+
});
|
110 |
+
});
|
111 |
+
setRemovable();
|
112 |
+
setTitle();
|
113 |
+
setShortcode();
|
114 |
+
}
|
115 |
+
|
116 |
+
function changeAttr(attr,i){
|
117 |
+
var n=attr.match(/\d+\.?\d*/g),
|
118 |
+
o=attr.replace("_"+n[0]+"_","_"+i+"_");
|
119 |
+
return o;
|
120 |
+
}
|
121 |
+
|
122 |
+
function setRemovable(){
|
123 |
+
$(".repeatable").find(".repeatable-remove").removeClass("remove-disabled");
|
124 |
+
if(totalInstances.val()<2){
|
125 |
+
$(".repeatable").find(".repeatable-remove").addClass("remove-disabled");
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
function setTitle(){
|
130 |
+
$(".repeatable").each(function(){
|
131 |
+
var $this=$(this),
|
132 |
+
i=$this.index();
|
133 |
+
$this.find("h3 span").each(function(){
|
134 |
+
$(this).text(instanceTitle+" "+(i+1));
|
135 |
+
});
|
136 |
+
});
|
137 |
+
}
|
138 |
+
|
139 |
+
function setShortcode(){
|
140 |
+
if(repeatables){
|
141 |
+
$(".repeatable").each(function(){
|
142 |
+
var $this=$(this),
|
143 |
+
i=$this.index();
|
144 |
+
$this.find(".repeatable-info .shortcode-info").each(function(){
|
145 |
+
$(this).html("Shortcode: <span class='code'><code>["+shortcodePrefix+(i+1)+"] your content here [/"+shortcodePrefix+(i+1)+"]</code></span>");
|
146 |
+
});
|
147 |
+
});
|
148 |
+
}else{
|
149 |
+
$(".shortcode-info").html("Shortcode: <span class='code'><code>["+shortcodePrefix+"] your content here [/"+shortcodePrefix+"]</code></span>");
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
/*
|
154 |
+
--------------------
|
155 |
+
Plugin specific js --edit--
|
156 |
+
--------------------
|
157 |
+
*/
|
158 |
+
|
159 |
+
$(".mPS2id-open-help").click(function(e){
|
160 |
+
e.preventDefault();
|
161 |
+
openHelp();
|
162 |
+
});
|
163 |
+
|
164 |
+
$(".mPS2id-open-help-overview").click(function(e){
|
165 |
+
e.preventDefault();
|
166 |
+
openHelp("overview");
|
167 |
+
});
|
168 |
+
|
169 |
+
$(".mPS2id-open-help-get-started").click(function(e){
|
170 |
+
e.preventDefault();
|
171 |
+
openHelp("get-started");
|
172 |
+
});
|
173 |
+
|
174 |
+
$(".mPS2id-open-help-plugin-settings").click(function(e){
|
175 |
+
e.preventDefault();
|
176 |
+
openHelp("plugin-settings");
|
177 |
+
});
|
178 |
+
|
179 |
+
function openHelp(tab){
|
180 |
+
if(wpVersion>=3.6){ //WP Contextual Help
|
181 |
+
if(tab){
|
182 |
+
$("a[href='#tab-panel-page-scroll-to-id"+tab+"']").trigger("click");
|
183 |
+
}else{
|
184 |
+
if(!$("#contextual-help-wrap").is(":visible")){
|
185 |
+
$("a#contextual-help-link").trigger("click");
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}else{
|
189 |
+
if(tab){
|
190 |
+
$(".oldwp-plugin-help-section-active:not(.oldwp-plugin-help-section-"+tab+")").removeClass("oldwp-plugin-help-section-active");
|
191 |
+
$(".oldwp-plugin-help-section-"+tab).toggleClass("oldwp-plugin-help-section-active");
|
192 |
+
}
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
});
|
197 |
+
})(jQuery);
|
js/jquery.malihu.PageScroll2id-init.js
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
$(window).load(function(){
|
3 |
+
var _p="mPS2id",
|
4 |
+
_o=mPS2id_params;
|
5 |
+
for(i=0; i<_o.total_instances; i++){
|
6 |
+
$(_o.instances[_p+"_instance_"+i]["selector"]["value"]).mPageScroll2id({
|
7 |
+
scrollSpeed:_o.instances[_p+"_instance_"+i]["scrollSpeed"]["value"],
|
8 |
+
autoScrollSpeed:(_o.instances[_p+"_instance_"+i]["autoScrollSpeed"]["value"] === "true") ? true : false,
|
9 |
+
scrollEasing:_o.instances[_p+"_instance_"+i]["scrollEasing"]["value"],
|
10 |
+
scrollingEasing:_o.instances[_p+"_instance_"+i]["scrollingEasing"]["value"],
|
11 |
+
pageEndSmoothScroll:(_o.instances[_p+"_instance_"+i]["pageEndSmoothScroll"]["value"] === "true") ? true : false,
|
12 |
+
layout:_o.instances[_p+"_instance_"+i]["layout"]["value"],
|
13 |
+
offset:_o.instances[_p+"_instance_"+i]["offset"]["value"],
|
14 |
+
highlightSelector:_o.instances[_p+"_instance_"+i]["highlightSelector"]["value"],
|
15 |
+
clickedClass:_o.instances[_p+"_instance_"+i]["clickedClass"]["value"],
|
16 |
+
targetClass:_o.instances[_p+"_instance_"+i]["targetClass"]["value"],
|
17 |
+
highlightClass:_o.instances[_p+"_instance_"+i]["highlightClass"]["value"],
|
18 |
+
forceSingleHighlight:(_o.instances[_p+"_instance_"+i]["forceSingleHighlight"]["value"] === "true") ? true : false
|
19 |
+
});
|
20 |
+
}
|
21 |
+
});
|
22 |
+
})(jQuery);
|
js/jquery.malihu.PageScroll2id.js
ADDED
@@ -0,0 +1,568 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
== Page scroll to id ==
|
3 |
+
Version: 1.5.0
|
4 |
+
Plugin URI: http://manos.malihu.gr/animate-page-to-id-with-jquery/
|
5 |
+
Author: malihu
|
6 |
+
Author URI: http://manos.malihu.gr
|
7 |
+
*/
|
8 |
+
|
9 |
+
/*
|
10 |
+
This program is free software: you can redistribute it and/or modify
|
11 |
+
it under the terms of the GNU Lesser General Public License as published by
|
12 |
+
the Free Software Foundation, either version 3 of the License, or
|
13 |
+
any later version.
|
14 |
+
|
15 |
+
This program is distributed in the hope that it will be useful,
|
16 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
GNU Lesser General Public License for more details.
|
19 |
+
|
20 |
+
You should have received a copy of the GNU Lesser General Public License
|
21 |
+
along with this program. If not, see http://www.gnu.org/licenses/lgpl.html.
|
22 |
+
*/
|
23 |
+
|
24 |
+
;(function($,window,document,undefined){
|
25 |
+
|
26 |
+
/* plugin namespace, prefix, default selector(s) */
|
27 |
+
|
28 |
+
var pluginNS="mPageScroll2id",
|
29 |
+
pluginPfx="mPS2id",
|
30 |
+
defaultSelector=".m_PageScroll2id,a[rel~='m_PageScroll2id'],.page-scroll-to-id,a[rel~='page-scroll-to-id']",
|
31 |
+
|
32 |
+
/* default options */
|
33 |
+
|
34 |
+
defaults={
|
35 |
+
/* scroll animation speed in milliseconds: Integer */
|
36 |
+
scrollSpeed:1300,
|
37 |
+
/* auto-adjust animation speed (according to target element position and window scroll): Boolean */
|
38 |
+
autoScrollSpeed:true,
|
39 |
+
/* scroll animation easing when page is idle: String */
|
40 |
+
scrollEasing:"easeInOutExpo",
|
41 |
+
/* scroll animation easing while page is scrolling: String */
|
42 |
+
scrollingEasing:"easeInOutCirc",
|
43 |
+
/* end of page "smooth scrolling" (auto-adjust the scroll-to position when bottom elements are too short): Boolean */
|
44 |
+
pageEndSmoothScroll:true,
|
45 |
+
/*
|
46 |
+
page layout defines scrolling direction: String
|
47 |
+
values: "vertical", "horizontal", "auto"
|
48 |
+
*/
|
49 |
+
layout:"vertical",
|
50 |
+
/* extra space in pixels for the target element position: Integer */
|
51 |
+
offset:0,
|
52 |
+
/* highlight the main/default selectors or insert a different set: Boolean, String */
|
53 |
+
highlightSelector:false,
|
54 |
+
/* class of the clicked element: String */
|
55 |
+
clickedClass:pluginPfx+"-clicked",
|
56 |
+
/* class of the current target element: String */
|
57 |
+
targetClass:pluginPfx+"-target",
|
58 |
+
/* class of the highlighted element: String */
|
59 |
+
highlightClass:pluginPfx+"-highlight",
|
60 |
+
/* force a single highlighted element each time: Boolean */
|
61 |
+
forceSingleHighlight:false,
|
62 |
+
/* enable/disable click events for all selectors */
|
63 |
+
clickEvents:true,
|
64 |
+
/* user callback functions: fn */
|
65 |
+
onStart:function(){},
|
66 |
+
onComplete:function(){},
|
67 |
+
/* enable/disable the default selector: Boolean */
|
68 |
+
defaultSelector:false
|
69 |
+
},
|
70 |
+
|
71 |
+
/* vars, constants */
|
72 |
+
|
73 |
+
selector,opt,_init,_trigger,_clicked,_target,_to,_axis,_offset,
|
74 |
+
|
75 |
+
/*
|
76 |
+
---------------
|
77 |
+
methods
|
78 |
+
---------------
|
79 |
+
*/
|
80 |
+
|
81 |
+
methods={
|
82 |
+
|
83 |
+
/* plugin initialization method */
|
84 |
+
|
85 |
+
init:function(options){
|
86 |
+
|
87 |
+
/* extend options, store each option in jquery data */
|
88 |
+
|
89 |
+
var options=$.extend(true,{},defaults,options);
|
90 |
+
|
91 |
+
$(document).data(pluginPfx,options);
|
92 |
+
opt=$(document).data(pluginPfx);
|
93 |
+
|
94 |
+
/* set default selector */
|
95 |
+
|
96 |
+
selector=(!selector) ? this.selector : selector+","+this.selector;
|
97 |
+
|
98 |
+
if(opt.defaultSelector){
|
99 |
+
if(typeof $(selector)!=="object" || $(selector).length===0){
|
100 |
+
selector=defaultSelector;
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
/* plugin events */
|
105 |
+
|
106 |
+
if(opt.clickEvents){
|
107 |
+
$(document)
|
108 |
+
|
109 |
+
.undelegate("."+pluginPfx)
|
110 |
+
|
111 |
+
.delegate(selector,"click."+pluginPfx,function(e){
|
112 |
+
var $this=$(this),
|
113 |
+
href=$this.attr("href"),
|
114 |
+
hrefProp=$this.prop("href");
|
115 |
+
if(href && href.indexOf("#/")!==-1){
|
116 |
+
return;
|
117 |
+
}
|
118 |
+
functions._reset.call(null);
|
119 |
+
if(functions._isValid.call(null,href,hrefProp) && functions._findTarget.call(null,href)){
|
120 |
+
e.preventDefault();
|
121 |
+
_trigger="selector";
|
122 |
+
_clicked=$this;
|
123 |
+
functions._setClasses.call(null,true);
|
124 |
+
functions._scrollTo.call(null);
|
125 |
+
}
|
126 |
+
});
|
127 |
+
}
|
128 |
+
|
129 |
+
$(window)
|
130 |
+
|
131 |
+
.unbind("."+pluginPfx)
|
132 |
+
|
133 |
+
.bind("scroll."+pluginPfx+" resize."+pluginPfx,function(){
|
134 |
+
var targets=$("._"+pluginPfx+"-t");
|
135 |
+
targets.each(function(){
|
136 |
+
var t=$(this),id=t.attr("id"),
|
137 |
+
h=functions._findHighlight.call(null,id);
|
138 |
+
functions._setClasses.call(null,false,t,h);
|
139 |
+
});
|
140 |
+
});
|
141 |
+
|
142 |
+
/* plugin has initialized */
|
143 |
+
|
144 |
+
_init=true;
|
145 |
+
|
146 |
+
/* setup selectors, target elements, basic plugin classes etc. */
|
147 |
+
|
148 |
+
functions._setup.call(null);
|
149 |
+
},
|
150 |
+
|
151 |
+
/* scrollTo method */
|
152 |
+
|
153 |
+
scrollTo:function(id,options){
|
154 |
+
if(id && typeof id!=="undefined"){
|
155 |
+
functions._isInit.call(null);
|
156 |
+
var defaults={
|
157 |
+
layout:opt.layout,
|
158 |
+
offset:opt.offset,
|
159 |
+
clicked:false
|
160 |
+
},
|
161 |
+
options=$.extend(true,{},defaults,options);
|
162 |
+
functions._reset.call(null);
|
163 |
+
_axis=options.layout;
|
164 |
+
_offset=options.offset;
|
165 |
+
id=(id.indexOf("#")!==-1) ? id : "#"+id;
|
166 |
+
if(functions._isValid.call(null,id) && functions._findTarget.call(null,id)){
|
167 |
+
_trigger="scrollTo";
|
168 |
+
_clicked=options.clicked;
|
169 |
+
if(_clicked){
|
170 |
+
functions._setClasses.call(null,true);
|
171 |
+
}
|
172 |
+
functions._scrollTo.call(null);
|
173 |
+
}
|
174 |
+
}
|
175 |
+
},
|
176 |
+
|
177 |
+
/* destroy method */
|
178 |
+
|
179 |
+
destroy:function(){
|
180 |
+
$(window).unbind("."+pluginPfx);
|
181 |
+
$(document).undelegate("."+pluginPfx).removeData(pluginPfx);
|
182 |
+
$("."+opt.clickedClass).removeClass(opt.clickedClass);
|
183 |
+
$("."+opt.targetClass).removeClass(opt.targetClass);
|
184 |
+
$("."+opt.highlightClass).removeClass(opt.highlightClass);
|
185 |
+
$("._"+pluginPfx+"-t").removeData(pluginPfx).removeClass("_"+pluginPfx+"-t");
|
186 |
+
$("._"+pluginPfx+"-h").removeClass("_"+pluginPfx+"-h");
|
187 |
+
}
|
188 |
+
},
|
189 |
+
|
190 |
+
/*
|
191 |
+
---------------
|
192 |
+
functions
|
193 |
+
---------------
|
194 |
+
*/
|
195 |
+
|
196 |
+
functions={
|
197 |
+
|
198 |
+
/* checks if href attribute is valid */
|
199 |
+
|
200 |
+
_isValid:function(href,hrefProp){
|
201 |
+
if(!href){
|
202 |
+
return;
|
203 |
+
}
|
204 |
+
hrefProp=(!hrefProp) ? href : hrefProp;
|
205 |
+
var str=(hrefProp.indexOf("#/")!==-1) ? hrefProp.split("#/")[0] : hrefProp.split("#")[0],
|
206 |
+
loc=window.location.toString().split("#")[0];
|
207 |
+
return href!=="#" && href.indexOf("#")!==-1 && (str==="" || str===loc);
|
208 |
+
},
|
209 |
+
|
210 |
+
/* setup selectors, target elements, basic plugin classes etc. */
|
211 |
+
|
212 |
+
_setup:function(){
|
213 |
+
var el=(opt.highlightSelector && opt.highlightSelector!=="") ? opt.highlightSelector : selector,i=1;
|
214 |
+
return $(el).each(function(){
|
215 |
+
var $this=$(this),href=$this.attr("href"),hrefProp=$this.prop("href");
|
216 |
+
if(functions._isValid.call(null,href,hrefProp)){
|
217 |
+
var id=(href.indexOf("#/")!==-1) ? href.split("#/")[1] : href.split("#")[1],t=$("#"+id);
|
218 |
+
if(t.length>0){
|
219 |
+
if(!t.hasClass("_"+pluginPfx+"-t")){
|
220 |
+
t.addClass("_"+pluginPfx+"-t").data(pluginPfx,{i:i});
|
221 |
+
}
|
222 |
+
if(!$this.hasClass("_"+pluginPfx+"-h")){
|
223 |
+
$this.addClass("_"+pluginPfx+"-h");
|
224 |
+
}
|
225 |
+
var h=functions._findHighlight.call(null,id);
|
226 |
+
functions._setClasses.call(null,false,t,h);
|
227 |
+
i++
|
228 |
+
}
|
229 |
+
}
|
230 |
+
});
|
231 |
+
},
|
232 |
+
|
233 |
+
/* finds the target element */
|
234 |
+
|
235 |
+
_findTarget:function(str){
|
236 |
+
var val=(str.indexOf("#/")!==-1) ? str.split("#/")[1] : str.split("#")[1],
|
237 |
+
el=$("#"+val);
|
238 |
+
if(el.length<1 || el.css("position")==="fixed"){
|
239 |
+
if(val==="top"){
|
240 |
+
el=$("body");
|
241 |
+
}else{
|
242 |
+
return;
|
243 |
+
}
|
244 |
+
}
|
245 |
+
_target=el;
|
246 |
+
if(!_axis){
|
247 |
+
_axis=opt.layout;
|
248 |
+
}
|
249 |
+
if(!_offset){
|
250 |
+
_offset=(opt.offset) ? opt.offset : 0;
|
251 |
+
}
|
252 |
+
_to=[(el.offset().top-parseInt(_offset)).toString(),(el.offset().left-parseInt(_offset)).toString()];
|
253 |
+
_to[0]=(_to[0]<0) ? 0 : _to[0];
|
254 |
+
_to[1]=(_to[1]<0) ? 0 : _to[1];
|
255 |
+
return _to;
|
256 |
+
},
|
257 |
+
|
258 |
+
/* finds the element that should be highlighted */
|
259 |
+
|
260 |
+
_findHighlight:function(id){
|
261 |
+
var loc=window.location.toString().split("#")[0],
|
262 |
+
hHash=$("._"+pluginPfx+"-h[href='#"+id+"']"),
|
263 |
+
lhHash=$("._"+pluginPfx+"-h[href='"+loc+"#"+id+"']"),
|
264 |
+
hHashSlash=$("._"+pluginPfx+"-h[href='#/"+id+"']"),
|
265 |
+
lhHashSlash=$("._"+pluginPfx+"-h[href='"+loc+"#/"+id+"']");
|
266 |
+
hHash=(hHash.length>0) ? hHash : lhHash;
|
267 |
+
hHashSlash=(hHashSlash.length>0) ? hHashSlash : lhHashSlash;
|
268 |
+
return (hHashSlash.length>0) ? hHashSlash : hHash;
|
269 |
+
},
|
270 |
+
|
271 |
+
/* sets plugin classes */
|
272 |
+
|
273 |
+
_setClasses:function(c,t,h){
|
274 |
+
var cc=opt.clickedClass,tc=opt.targetClass,hc=opt.highlightClass;
|
275 |
+
if(c && cc && cc!==""){
|
276 |
+
$("."+cc).removeClass(cc);
|
277 |
+
_clicked.addClass(cc);
|
278 |
+
}else if(t && tc && tc!=="" && h && hc && hc!==""){
|
279 |
+
if(functions._currentTarget.call(null,t)){
|
280 |
+
if(opt.forceSingleHighlight){
|
281 |
+
$("."+hc).removeClass(hc);
|
282 |
+
}
|
283 |
+
t.addClass(tc);
|
284 |
+
h.addClass(hc);
|
285 |
+
}else{
|
286 |
+
t.removeClass(tc);
|
287 |
+
h.removeClass(hc);
|
288 |
+
}
|
289 |
+
}
|
290 |
+
},
|
291 |
+
|
292 |
+
/* checks if target element is in viewport */
|
293 |
+
|
294 |
+
_currentTarget:function(t){
|
295 |
+
var o=opt["target_"+t.data(pluginPfx).i],
|
296 |
+
rect=t[0].getBoundingClientRect();
|
297 |
+
if(typeof o!=="undefined"){
|
298 |
+
var y=t.offset().top,x=t.offset().left,
|
299 |
+
from=(o.from) ? o.from+y : y,to=(o.to) ? o.to+y : y,
|
300 |
+
fromX=(o.fromX) ? o.fromX+x : x,toX=(o.toX) ? o.toX+x : x;
|
301 |
+
return(
|
302 |
+
rect.top >= to && rect.top <= from &&
|
303 |
+
rect.left >= toX && rect.left <= fromX
|
304 |
+
);
|
305 |
+
}else{
|
306 |
+
var wh=$(window).height(),ww=$(window).width(),
|
307 |
+
base=1+(rect.height/wh),
|
308 |
+
top=base,bottom=(rect.height<wh) ? base*(wh/rect.height) : base,
|
309 |
+
baseX=1+(rect.width/ww),
|
310 |
+
left=baseX,right=(rect.width<ww) ? baseX*(ww/rect.width) : baseX;
|
311 |
+
return(
|
312 |
+
rect.top <= wh/top && rect.bottom >= wh/bottom &&
|
313 |
+
rect.left <= ww/left && rect.right >= ww/right
|
314 |
+
);
|
315 |
+
}
|
316 |
+
},
|
317 |
+
|
318 |
+
/* scrolls the page */
|
319 |
+
|
320 |
+
_scrollTo:function(){
|
321 |
+
opt.scrollSpeed=parseInt(opt.scrollSpeed);
|
322 |
+
_to=(opt.pageEndSmoothScroll) ? functions._pageEndSmoothScroll.call(null) : _to;
|
323 |
+
var el=$("html,body"),
|
324 |
+
speed=(opt.autoScrollSpeed) ? functions._autoScrollSpeed.call(null) : opt.scrollSpeed,
|
325 |
+
easing=(el.is(":animated")) ? opt.scrollingEasing : opt.scrollEasing,
|
326 |
+
_t=$(window).scrollTop(),_l=$(window).scrollLeft();
|
327 |
+
switch(_axis){
|
328 |
+
case "horizontal":
|
329 |
+
if(_l!=_to[1]){
|
330 |
+
functions._callbacks.call(null,"onStart");
|
331 |
+
el.stop().animate({scrollLeft:_to[1]},speed,easing).promise().then(function(){
|
332 |
+
functions._callbacks.call(null,"onComplete");
|
333 |
+
});
|
334 |
+
}
|
335 |
+
break;
|
336 |
+
case "auto":
|
337 |
+
if(_t!=_to[0] || _l!=_to[1]){
|
338 |
+
functions._callbacks.call(null,"onStart");
|
339 |
+
el.stop().animate({scrollTop:_to[0],scrollLeft:_to[1]},speed,easing).promise().then(function(){
|
340 |
+
functions._callbacks.call(null,"onComplete");
|
341 |
+
});
|
342 |
+
}
|
343 |
+
break;
|
344 |
+
default:
|
345 |
+
if(_t!=_to[0]){
|
346 |
+
functions._callbacks.call(null,"onStart");
|
347 |
+
el.stop().animate({scrollTop:_to[0]},speed,easing).promise().then(function(){
|
348 |
+
functions._callbacks.call(null,"onComplete");
|
349 |
+
});
|
350 |
+
}
|
351 |
+
}
|
352 |
+
},
|
353 |
+
|
354 |
+
/* sets end of page "smooth scrolling" position */
|
355 |
+
|
356 |
+
_pageEndSmoothScroll:function(){
|
357 |
+
var _dh=$(document).height(),_dw=$(document).width(),
|
358 |
+
_wh=$(window).height(),_ww=$(window).width();
|
359 |
+
return [((_dh-_to[0])<_wh) ? _dh-_wh : _to[0],((_dw-_to[1])<_ww) ? _dw-_ww : _to[1]];
|
360 |
+
},
|
361 |
+
|
362 |
+
/* sets the auto-adjusted animation speed */
|
363 |
+
|
364 |
+
_autoScrollSpeed:function(){
|
365 |
+
var _t=$(window).scrollTop(),_l=$(window).scrollLeft(),
|
366 |
+
_h=$(document).height(),_w=$(document).width(),
|
367 |
+
val=[
|
368 |
+
opt.scrollSpeed+((opt.scrollSpeed*(Math.floor((Math.abs(_to[0]-_t)/_h)*100)))/100),
|
369 |
+
opt.scrollSpeed+((opt.scrollSpeed*(Math.floor((Math.abs(_to[1]-_l)/_w)*100)))/100)
|
370 |
+
];
|
371 |
+
return Math.max.apply(Math,val);
|
372 |
+
},
|
373 |
+
|
374 |
+
/* user callback functions */
|
375 |
+
|
376 |
+
_callbacks:function(c){
|
377 |
+
if(!opt){
|
378 |
+
return;
|
379 |
+
}
|
380 |
+
this[pluginPfx]={
|
381 |
+
trigger:_trigger,clicked:_clicked,target:_target,scrollTo:{y:_to[0],x:_to[1]}
|
382 |
+
};
|
383 |
+
switch(c){
|
384 |
+
case "onStart":
|
385 |
+
opt.onStart.call(null,this[pluginPfx]);
|
386 |
+
break;
|
387 |
+
case "onComplete":
|
388 |
+
opt.onComplete.call(null,this[pluginPfx]);
|
389 |
+
break;
|
390 |
+
}
|
391 |
+
},
|
392 |
+
|
393 |
+
/* resets/clears vars and constants */
|
394 |
+
|
395 |
+
_reset:function(){
|
396 |
+
_axis=_offset=false;
|
397 |
+
},
|
398 |
+
|
399 |
+
/* checks if plugin has initialized */
|
400 |
+
|
401 |
+
_isInit:function(){
|
402 |
+
if(!_init){
|
403 |
+
methods.init.apply(this);
|
404 |
+
}
|
405 |
+
},
|
406 |
+
|
407 |
+
/* extends jquery with custom easings (as jquery ui) */
|
408 |
+
|
409 |
+
_easing:function(){
|
410 |
+
$.easing.easeInQuad=$.easing.easeInQuad ||
|
411 |
+
function(x,t,b,c,d){return c*(t/=d)*t + b;};
|
412 |
+
$.easing.easeOutQuad=$.easing.easeOutQuad ||
|
413 |
+
function(x,t,b,c,d){return -c *(t/=d)*(t-2) + b;};
|
414 |
+
$.easing.easeInOutQuad=$.easing.easeInOutQuad ||
|
415 |
+
function(x,t,b,c,d){
|
416 |
+
if ((t/=d/2) < 1) return c/2*t*t + b;
|
417 |
+
return -c/2 * ((--t)*(t-2) - 1) + b;
|
418 |
+
};
|
419 |
+
$.easing.easeInCubic=$.easing.easeInCubic ||
|
420 |
+
function(x,t,b,c,d){return c*(t/=d)*t*t + b;};
|
421 |
+
$.easing.easeOutCubic=$.easing.easeOutCubic ||
|
422 |
+
function(x,t,b,c,d){return c*((t=t/d-1)*t*t + 1) + b;};
|
423 |
+
$.easing.easeInOutCubic=$.easing.easeInOutCubic ||
|
424 |
+
function(x,t,b,c,d){
|
425 |
+
if ((t/=d/2) < 1) return c/2*t*t*t + b;
|
426 |
+
return c/2*((t-=2)*t*t + 2) + b;
|
427 |
+
};
|
428 |
+
$.easing.easeInQuart=$.easing.easeInQuart ||
|
429 |
+
function(x,t,b,c,d){return c*(t/=d)*t*t*t + b;};
|
430 |
+
$.easing.easeOutQuart=$.easing.easeOutQuart ||
|
431 |
+
function(x,t,b,c,d){return -c * ((t=t/d-1)*t*t*t - 1) + b;};
|
432 |
+
$.easing.easeInOutQuart=$.easing.easeInOutQuart ||
|
433 |
+
function(x,t,b,c,d){
|
434 |
+
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
|
435 |
+
return -c/2 * ((t-=2)*t*t*t - 2) + b;
|
436 |
+
};
|
437 |
+
$.easing.easeInQuint=$.easing.easeInQuint ||
|
438 |
+
function(x,t,b,c,d){return c*(t/=d)*t*t*t*t + b;};
|
439 |
+
$.easing.easeOutQuint=$.easing.easeOutQuint ||
|
440 |
+
function(x,t,b,c,d){return c*((t=t/d-1)*t*t*t*t + 1) + b;};
|
441 |
+
$.easing.easeInOutQuint=$.easing.easeInOutQuint ||
|
442 |
+
function(x,t,b,c,d){
|
443 |
+
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
|
444 |
+
return c/2*((t-=2)*t*t*t*t + 2) + b;
|
445 |
+
};
|
446 |
+
$.easing.easeInExpo=$.easing.easeInExpo ||
|
447 |
+
function(x,t,b,c,d){return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;};
|
448 |
+
$.easing.easeOutExpo=$.easing.easeOutExpo ||
|
449 |
+
function(x,t,b,c,d){return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;};
|
450 |
+
$.easing.easeInOutExpo=$.easing.easeInOutExpo ||
|
451 |
+
function(x,t,b,c,d){
|
452 |
+
if (t==0) return b;
|
453 |
+
if (t==d) return b+c;
|
454 |
+
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
|
455 |
+
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
456 |
+
};
|
457 |
+
$.easing.easeInSine=$.easing.easeInSine ||
|
458 |
+
function(x,t,b,c,d){return -c * Math.cos(t/d * (Math.PI/2)) + c + b;};
|
459 |
+
$.easing.easeOutSine=$.easing.easeOutSine ||
|
460 |
+
function(x,t,b,c,d){return c * Math.sin(t/d * (Math.PI/2)) + b;};
|
461 |
+
$.easing.easeInOutSine=$.easing.easeInOutSine ||
|
462 |
+
function(x,t,b,c,d){return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;};
|
463 |
+
$.easing.easeInCirc=$.easing.easeInCirc ||
|
464 |
+
function(x,t,b,c,d){return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;};
|
465 |
+
$.easing.easeOutCirc=$.easing.easeOutCirc ||
|
466 |
+
function(x,t,b,c,d){return c * Math.sqrt(1 - (t=t/d-1)*t) + b;};
|
467 |
+
$.easing.easeInOutCirc=$.easing.easeInOutCirc ||
|
468 |
+
function(x,t,b,c,d){
|
469 |
+
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
|
470 |
+
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
|
471 |
+
};
|
472 |
+
$.easing.easeInElastic=$.easing.easeInElastic ||
|
473 |
+
function(x,t,b,c,d){
|
474 |
+
var s=1.70158;var p=0;var a=c;
|
475 |
+
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
476 |
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
477 |
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
478 |
+
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
479 |
+
};
|
480 |
+
$.easing.easeOutElastic=$.easing.easeOutElastic ||
|
481 |
+
function(x,t,b,c,d){
|
482 |
+
var s=1.70158;var p=0;var a=c;
|
483 |
+
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
484 |
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
485 |
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
486 |
+
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
|
487 |
+
};
|
488 |
+
$.easing.easeInOutElastic=$.easing.easeInOutElastic ||
|
489 |
+
function(x,t,b,c,d){
|
490 |
+
var s=1.70158;var p=0;var a=c;
|
491 |
+
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
|
492 |
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
493 |
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
494 |
+
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
495 |
+
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
|
496 |
+
};
|
497 |
+
$.easing.easeInBack=$.easing.easeInBack ||
|
498 |
+
function(x,t,b,c,d,s){
|
499 |
+
if (s == undefined) s = 1.70158;
|
500 |
+
return c*(t/=d)*t*((s+1)*t - s) + b;
|
501 |
+
};
|
502 |
+
$.easing.easeOutBack=$.easing.easeOutBack ||
|
503 |
+
function(x,t,b,c,d,s){
|
504 |
+
if (s == undefined) s = 1.70158;
|
505 |
+
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
|
506 |
+
};
|
507 |
+
$.easing.easeInOutBack=$.easing.easeInOutBack ||
|
508 |
+
function(x,t,b,c,d,s){
|
509 |
+
if (s == undefined) s = 1.70158;
|
510 |
+
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
|
511 |
+
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
|
512 |
+
};
|
513 |
+
$.easing.easeInBounce=$.easing.easeInBounce ||
|
514 |
+
function(x,t,b,c,d){return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;};
|
515 |
+
$.easing.easeOutBounce=$.easing.easeOutBounce ||
|
516 |
+
function(x,t,b,c,d){
|
517 |
+
if ((t/=d) < (1/2.75)) {return c*(7.5625*t*t) + b;}
|
518 |
+
else if (t < (2/2.75)) {return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;}
|
519 |
+
else if (t < (2.5/2.75)) {return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;}
|
520 |
+
else {return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;}
|
521 |
+
};
|
522 |
+
$.easing.easeInOutBounce=$.easing.easeInOutBounce ||
|
523 |
+
function(x,t,b,c,d){
|
524 |
+
if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
|
525 |
+
return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
|
526 |
+
};
|
527 |
+
}
|
528 |
+
}
|
529 |
+
|
530 |
+
/*
|
531 |
+
---------------
|
532 |
+
plugin setup
|
533 |
+
---------------
|
534 |
+
*/
|
535 |
+
|
536 |
+
/* extend jquery with custom easings */
|
537 |
+
|
538 |
+
functions._easing.call();
|
539 |
+
|
540 |
+
/* plugin constructor functions */
|
541 |
+
|
542 |
+
$.fn[pluginNS]=function(method){
|
543 |
+
if(methods[method]){
|
544 |
+
return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
|
545 |
+
}else if(typeof method==="object" || !method){
|
546 |
+
return methods.init.apply(this,arguments);
|
547 |
+
}else{
|
548 |
+
$.error("Method "+method+" does not exist");
|
549 |
+
}
|
550 |
+
};
|
551 |
+
$[pluginNS]=function(method){
|
552 |
+
if(methods[method]){
|
553 |
+
return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
|
554 |
+
}else if(typeof method==="object" || !method){
|
555 |
+
return methods.init.apply(this,arguments);
|
556 |
+
}else{
|
557 |
+
$.error("Method "+method+" does not exist");
|
558 |
+
}
|
559 |
+
};
|
560 |
+
|
561 |
+
/*
|
562 |
+
allow setting plugin default options.
|
563 |
+
example: $.plugin_name.defaults.option_name="option_value";
|
564 |
+
*/
|
565 |
+
|
566 |
+
$[pluginNS].defaults=defaults;
|
567 |
+
|
568 |
+
})(jQuery,window,document);
|
malihu-pagescroll2id.php
CHANGED
@@ -1,256 +1,720 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
Plugin Name: Page
|
4 |
-
Plugin URI: http://manos.malihu.gr/
|
5 |
-
Description:
|
6 |
-
Version: 1.
|
7 |
Author: malihu
|
8 |
Author URI: http://manos.malihu.gr
|
9 |
License: GNU GENERAL PUBLIC LICENSE Version 3
|
10 |
*/
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
-
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
wp_enqueue_script("jquery-malihu-PageScroll2id");
|
21 |
-
wp_register_script("jquery-malihu-PageScroll2id-init", malihuPageScroll2id_url."jquery.malihu.PageScroll2id-init.js",array("jquery","jquery-effects-core","jquery-malihu-PageScroll2id"), "1.2",1);
|
22 |
-
wp_enqueue_script("jquery-malihu-PageScroll2id-init");
|
23 |
-
}
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
define('malihuPageScroll2id_scrollEasing_default', 'easeInOutExpo');
|
30 |
-
define('malihuPageScroll2id_scrollingEasing_default', 'easeInOutCirc');
|
31 |
-
define('malihuPageScroll2id_pageEndSmoothScroll_default', 'true');
|
32 |
-
define('malihuPageScroll2id_layout_default', 'vertical');
|
33 |
-
|
34 |
-
function malihuPageScroll2id_call(){
|
35 |
-
$sel_opt=get_option('malihu_pagescroll2id_sel');
|
36 |
-
if($sel_opt==''){
|
37 |
-
$sel_opt=malihuPageScroll2id_sel_default;
|
38 |
-
}
|
39 |
-
$scrollSpeed_opt=get_option('malihu_pagescroll2id_scrollSpeed');
|
40 |
-
if($scrollSpeed_opt==''){
|
41 |
-
$scrollSpeed_opt=malihuPageScroll2id_scrollSpeed_default;
|
42 |
-
}
|
43 |
-
$autoScrollSpeed_opt=get_option('malihu_pagescroll2id_autoScrollSpeed');
|
44 |
-
if($autoScrollSpeed_opt==''){
|
45 |
-
$autoScrollSpeed_opt=malihuPageScroll2id_autoScrollSpeed_default;
|
46 |
-
}
|
47 |
-
$scrollEasing_opt=get_option('malihu_pagescroll2id_scrollEasing');
|
48 |
-
if($scrollEasing_opt==''){
|
49 |
-
$scrollEasing_opt=malihuPageScroll2id_scrollEasing_default;
|
50 |
-
}
|
51 |
-
$scrollingEasing_opt=get_option('malihu_pagescroll2id_scrollingEasing');
|
52 |
-
if($scrollingEasing_opt==''){
|
53 |
-
$scrollingEasing_opt=malihuPageScroll2id_scrollingEasing_default;
|
54 |
-
}
|
55 |
-
$pageEndSmoothScroll_opt=get_option('malihu_pagescroll2id_pageEndSmoothScroll');
|
56 |
-
if($pageEndSmoothScroll_opt==''){
|
57 |
-
$pageEndSmoothScroll_opt=malihuPageScroll2id_pageEndSmoothScroll_default;
|
58 |
-
}
|
59 |
-
$layout_opt=get_option('malihu_pagescroll2id_layout');
|
60 |
-
if($layout_opt==''){
|
61 |
-
$layout_opt=malihuPageScroll2id_layout_default;
|
62 |
-
}
|
63 |
-
$params = array(
|
64 |
-
"sel" => $sel_opt, //selector
|
65 |
-
"scrollSpeed" => $scrollSpeed_opt, //scrollSpeed
|
66 |
-
"autoScrollSpeed" => $autoScrollSpeed_opt, //auto-adjust scrollSpeed
|
67 |
-
"scrollEasing" => $scrollEasing_opt, //scrollEasing idle
|
68 |
-
"scrollingEasing" => $scrollingEasing_opt, //scrollEasing scrolling
|
69 |
-
"pageEndSmoothScroll" => $pageEndSmoothScroll_opt, //end of page smooth scrolling
|
70 |
-
"layout" => $layout_opt, //page layout - scrolling direction
|
71 |
-
);
|
72 |
-
wp_localize_script( 'jquery-malihu-PageScroll2id-init', 'malihuPageScroll2idInitParams', $params );
|
73 |
-
}
|
74 |
|
75 |
-
|
76 |
-
add_action('wp_footer', 'malihuPageScroll2id_call');
|
77 |
|
78 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
-
|
81 |
-
add_option(malihu_pagescroll2id_sel, malihuPageScroll2id_sel_default);
|
82 |
-
add_option(malihu_pagescroll2id_scrollSpeed, malihuPageScroll2id_scrollSpeed_default);
|
83 |
-
add_option(malihu_pagescroll2id_scrollSpeed, malihuPageScroll2id_autoScrollSpeed_default);
|
84 |
-
add_option(malihu_pagescroll2id_scrollEasing, malihuPageScroll2id_scrollEasing_default);
|
85 |
-
add_option(malihu_pagescroll2id_scrollingEasing, malihuPageScroll2id_scrollingEasing_default);
|
86 |
-
add_option(malihu_pagescroll2id_pageEndSmoothScroll, malihuPageScroll2id_pageEndSmoothScroll_default);
|
87 |
-
add_option(malihu_pagescroll2id_layout, malihuPageScroll2id_layout_default);
|
88 |
|
89 |
-
//
|
90 |
-
|
|
|
|
|
91 |
|
92 |
-
|
93 |
-
//create new sub-level menu
|
94 |
-
add_submenu_page('options-general.php','Page Scroll to id Plugin Settings','Page Scroll to id','administrator', __FILE__,'malihuPageScroll2id_settings_page');
|
95 |
-
//call register settings function
|
96 |
-
add_action('admin_init','malihuPageScroll2id_register_settings');
|
97 |
-
}
|
98 |
|
99 |
-
function malihuPageScroll2id_register_settings(){
|
100 |
-
//register settings
|
101 |
-
register_setting('malihuPageScroll2id-settings-group','malihu_pagescroll2id_sel');
|
102 |
-
register_setting('malihuPageScroll2id-settings-group','malihu_pagescroll2id_scrollSpeed');
|
103 |
-
register_setting('malihuPageScroll2id-settings-group','malihu_pagescroll2id_autoScrollSpeed');
|
104 |
-
register_setting('malihuPageScroll2id-settings-group','malihu_pagescroll2id_scrollEasing');
|
105 |
-
register_setting('malihuPageScroll2id-settings-group','malihu_pagescroll2id_scrollingEasing');
|
106 |
-
register_setting('malihuPageScroll2id-settings-group','malihu_pagescroll2id_pageEndSmoothScroll');
|
107 |
-
register_setting('malihuPageScroll2id-settings-group','malihu_pagescroll2id_layout');
|
108 |
}
|
109 |
-
|
110 |
-
function malihuPageScroll2id_settings_page(){
|
111 |
-
?>
|
112 |
-
<div class="wrap">
|
113 |
-
<div id="icon-options-general" class="icon32">
|
114 |
-
<br/>
|
115 |
-
</div>
|
116 |
-
<h2>Page Scroll to id Plugin Settings</h2>
|
117 |
-
<h3>Default Settings</h3>
|
118 |
-
<form method="post" action="options.php">
|
119 |
-
<?php settings_fields('malihuPageScroll2id-settings-group'); ?>
|
120 |
-
<table class="form-table">
|
121 |
-
<tr valign="top">
|
122 |
-
<th scope="row">Selector(s)</th>
|
123 |
-
<td>
|
124 |
-
<?php if(get_option('malihu_pagescroll2id_sel')!=''){ ?>
|
125 |
-
<input type="text" name="malihu_pagescroll2id_sel" value="<?php echo get_option('malihu_pagescroll2id_sel'); ?>" class="regular-text" />
|
126 |
-
<?php }else{ ?>
|
127 |
-
<input type="text" name="malihu_pagescroll2id_sel" value="<?php echo malihuPageScroll2id_sel_default; ?>" class="regular-text" />
|
128 |
-
<?php } ?>
|
129 |
-
<span class="description">The link(s) that will scroll the page when clicked. You can use any <a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/" target="_blank">css selector</a>. <br />By default, the plugin is applied to all anchor elements with "m_PageScroll2id" rel attribute value. You can have multiple selectors by separating them with comma (e.g. a[rel='m_PageScroll2id'], a[href='#top']). <br />
|
130 |
-
<b>Some selector examples</b> <br />
|
131 |
-
<code style="font-style:normal;">a[href*='#']</code> - All anchors that contain a hash (#) in their href attribute <br />
|
132 |
-
<code style="font-style:normal;">a[href='#top']</code> - All anchors with "#top" href attribute value <br />
|
133 |
-
<code style="font-style:normal;">a.className</code> - All anchors with a class of "className"</span>
|
134 |
-
</td>
|
135 |
-
</tr>
|
136 |
-
<tr valign="top">
|
137 |
-
<th scope="row">Scroll animation speed</th>
|
138 |
-
<td>
|
139 |
-
<?php if(get_option('malihu_pagescroll2id_scrollSpeed')!=''){ ?>
|
140 |
-
<input type="text" name="malihu_pagescroll2id_scrollSpeed" value="<?php echo get_option('malihu_pagescroll2id_scrollSpeed'); ?>" class="regular-text" />
|
141 |
-
<?php }else{ ?>
|
142 |
-
<input type="text" name="malihu_pagescroll2id_scrollSpeed" value="<?php echo malihuPageScroll2id_scrollSpeed_default; ?>" class="regular-text" />
|
143 |
-
<?php } ?>
|
144 |
-
<span class="description">Value in milliseconds (1000 milliseconds = 1 second)</span>
|
145 |
-
</td>
|
146 |
-
</tr>
|
147 |
-
<tr valign="top">
|
148 |
-
<th scope="row"> </th>
|
149 |
-
<td>
|
150 |
-
<input type="hidden" name="malihu_pagescroll2id_autoScrollSpeed" value="false" />
|
151 |
-
<?php if(get_option('malihu_pagescroll2id_autoScrollSpeed')!=''){ ?>
|
152 |
-
<?php if(get_option('malihu_pagescroll2id_autoScrollSpeed')==malihuPageScroll2id_autoScrollSpeed_default){ ?>
|
153 |
-
<input type="checkbox" name="malihu_pagescroll2id_autoScrollSpeed" value="<?php echo malihuPageScroll2id_autoScrollSpeed_default; ?>" style="vertical-align:middle;" id="malihu_pagescroll2id_autoScrollSpeed_1" checked="yes" />
|
154 |
-
<?php }else{ ?>
|
155 |
-
<input type="checkbox" name="malihu_pagescroll2id_autoScrollSpeed" value="<?php echo malihuPageScroll2id_autoScrollSpeed_default; ?>" style="vertical-align:middle;" id="malihu_pagescroll2id_autoScrollSpeed_1" />
|
156 |
-
<?php } ?>
|
157 |
-
<?php }else{ ?>
|
158 |
-
<input type="checkbox" name="malihu_pagescroll2id_autoScrollSpeed" value="<?php echo malihuPageScroll2id_autoScrollSpeed_default; ?>" style="vertical-align:middle;" id="malihu_pagescroll2id_autoScrollSpeed_1" checked="yes" />
|
159 |
-
<?php } ?>
|
160 |
-
<label for="malihu_pagescroll2id_autoScrollSpeed_1">Auto-adjust animation speed</label> <br />
|
161 |
-
<span class="description">Adjusts scroll animation speed according to element position within page. <br />Enabled by default</span>
|
162 |
-
</td>
|
163 |
-
</tr>
|
164 |
-
<tr valign="top">
|
165 |
-
<th scope="row">Scroll animation easing</th>
|
166 |
-
<td>
|
167 |
-
<?php if(get_option('malihu_pagescroll2id_scrollEasing')!=''){ ?>
|
168 |
-
<input type="text" name="malihu_pagescroll2id_scrollEasing" value="<?php echo get_option('malihu_pagescroll2id_scrollEasing'); ?>" class="regular-text" />
|
169 |
-
<?php }else{ ?>
|
170 |
-
<input type="text" name="malihu_pagescroll2id_scrollEasing" value="<?php echo malihuPageScroll2id_scrollEasing_default; ?>" class="regular-text" />
|
171 |
-
<?php } ?>
|
172 |
-
<span class="description">Standard animation easing when page is idle <br />
|
173 |
-
<a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/" target="_blank">Available values via jQuery UI</a></span>
|
174 |
-
</td>
|
175 |
-
</tr>
|
176 |
-
<tr valign="top">
|
177 |
-
<th scope="row">Scrolling animation easing</th>
|
178 |
-
<td>
|
179 |
-
<?php if(get_option('malihu_pagescroll2id_scrollingEasing')!=''){ ?>
|
180 |
-
<input type="text" name="malihu_pagescroll2id_scrollingEasing" value="<?php echo get_option('malihu_pagescroll2id_scrollingEasing'); ?>" class="regular-text" />
|
181 |
-
<?php }else{ ?>
|
182 |
-
<input type="text" name="malihu_pagescroll2id_scrollingEasing" value="<?php echo malihuPageScroll2id_scrollingEasing_default; ?>" class="regular-text" />
|
183 |
-
<?php } ?>
|
184 |
-
<span class="description">Alternative animation easing while page is animated</span>
|
185 |
-
</td>
|
186 |
-
</tr>
|
187 |
-
<tr valign="top">
|
188 |
-
<th scope="row"> </th>
|
189 |
-
<td>
|
190 |
-
<input type="hidden" name="malihu_pagescroll2id_pageEndSmoothScroll" value="false" />
|
191 |
-
<?php if(get_option('malihu_pagescroll2id_pageEndSmoothScroll')!=''){ ?>
|
192 |
-
<?php if(get_option('malihu_pagescroll2id_pageEndSmoothScroll')==malihuPageScroll2id_pageEndSmoothScroll_default){ ?>
|
193 |
-
<input type="checkbox" name="malihu_pagescroll2id_pageEndSmoothScroll" value="<?php echo malihuPageScroll2id_pageEndSmoothScroll_default; ?>" style="vertical-align:middle;" id="malihu_pagescroll2id_pageEndSmoothScroll_1" checked="yes" />
|
194 |
-
<?php }else{ ?>
|
195 |
-
<input type="checkbox" name="malihu_pagescroll2id_pageEndSmoothScroll" value="<?php echo malihuPageScroll2id_pageEndSmoothScroll_default; ?>" style="vertical-align:middle;" id="malihu_pagescroll2id_pageEndSmoothScroll_1" />
|
196 |
-
<?php } ?>
|
197 |
-
<?php }else{ ?>
|
198 |
-
<input type="checkbox" name="malihu_pagescroll2id_pageEndSmoothScroll" value="<?php echo malihuPageScroll2id_pageEndSmoothScroll_default; ?>" style="vertical-align:middle;" id="malihu_pagescroll2id_pageEndSmoothScroll_1" checked="yes" />
|
199 |
-
<?php } ?>
|
200 |
-
<label for="malihu_pagescroll2id_pageEndSmoothScroll_1">End of page smooth scrolling</label> <br />
|
201 |
-
<span class="description">If page-bottom elements are shorter than the viewport, the page will scroll at the bottom of the document to avoid breaking scroll animation. <br />Enabled by default</span>
|
202 |
-
</td>
|
203 |
-
</tr>
|
204 |
-
<tr valign="top">
|
205 |
-
<th scope="row">Layout</th>
|
206 |
-
<td>
|
207 |
-
<select name="malihu_pagescroll2id_layout" id="malihu_pagescroll2id_layout_1">
|
208 |
-
<?php if(get_option('malihu_pagescroll2id_layout')!=''){ ?>
|
209 |
-
<?php if(get_option('malihu_pagescroll2id_layout')==malihuPageScroll2id_layout_default){ ?>
|
210 |
-
<option value="<?php echo malihuPageScroll2id_layout_default; ?>" selected="selected">Vertical</option>
|
211 |
-
<?php }else{ ?>
|
212 |
-
<option value="<?php echo malihuPageScroll2id_layout_default; ?>">Vertical</option>
|
213 |
-
<?php } ?>
|
214 |
-
<?php if(get_option('malihu_pagescroll2id_layout')=='horizontal'){ ?>
|
215 |
-
<option value="horizontal" selected="selected">Horizontal</option>
|
216 |
-
<?php }else{ ?>
|
217 |
-
<option value="horizontal">Horizontal</option>
|
218 |
-
<?php } ?>
|
219 |
-
<?php if(get_option('malihu_pagescroll2id_layout')=='auto'){ ?>
|
220 |
-
<option value="auto" selected="selected">Auto</option>
|
221 |
-
<?php }else{ ?>
|
222 |
-
<option value="auto">Auto</option>
|
223 |
-
<?php } ?>
|
224 |
-
<?php }else{ ?>
|
225 |
-
<option value="<?php echo malihuPageScroll2id_layout_default; ?>" selected="selected">Vertical</option>
|
226 |
-
<option value="horizontal">Horizontal</option>
|
227 |
-
<option value="auto">Auto</option>
|
228 |
-
<?php } ?>
|
229 |
-
</select>
|
230 |
-
<span class="description">Page layout defines scrolling direction. <br />
|
231 |
-
"Vertical" and "Horizontal" values restrict page scrolling to vertical (top-bottom) or horizontal (left-right) axis accordingly. To unrestrict page scrolling and enable the plugin to animate page both vertically and horizontally, select "Auto". <br />
|
232 |
-
By default, scrolling is restricted to vertical, as it is the standard and most common layout.</span>
|
233 |
-
</td>
|
234 |
-
</tr>
|
235 |
-
</table>
|
236 |
-
<p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
|
237 |
-
</form>
|
238 |
-
<h3>Usage</h3>
|
239 |
-
<p>Out-of-the-box, the plugin is applied to every link with <em>m_PageScroll2id</em> rel attribute value: <code><a href="#targetID" rel="m_PageScroll2id">link</a></code>. Clicking the link, the page will scroll to the element with <code>id="targetID"</code> within the document.</p>
|
240 |
-
<p>To start using the plugin in your theme, simply add <code>rel="m_PageScroll2id"</code> to any anchor element (<a />) in your markup and give it an href value of the id you wanna scroll to within the page (e.g. <code>href="#targetID"</code>), assuming of course that an element with such id does exist in your document.</p>
|
241 |
-
<p>By changing the <em>selector</em> value in settings, you can apply the script to any other type of anchor you want (useful if you don't wanna edit your theme's markup). You can also have multiple selectors by inserting comma separated values (e.g. <code>a[rel='m_PageScroll2id'], a[href='#top']</code>).</p>
|
242 |
-
<h3>Info</h3>
|
243 |
-
<p>Plugin author: <a href="http://manos.malihu.gr" target="_blank">malihu</a> <br />
|
244 |
-
Plugin home: <a href="http://manos.malihu.gr/animate-page-to-id-with-jquery" target="_blank">http://manos.malihu.gr/animate-page-to-id-with-jquery</a></p>
|
245 |
-
<p>This plugin, as with everything I publish on my <a href="http://manos.malihu.gr" target="_blank">blog</a>, is completely free for personal and commercial use. <br />
|
246 |
-
If you feel like it, you can make a donation by clicking the button below. I greatly appreciate your support to continue updating, developing and sharing cool stuff.</p>
|
247 |
-
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
248 |
-
<input type="hidden" name="cmd" value="_s-xclick">
|
249 |
-
<input type="hidden" name="hosted_button_id" value="UYJ5G65M6ZA28">
|
250 |
-
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
251 |
-
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
252 |
-
</form>
|
253 |
-
</div>
|
254 |
-
<?php
|
255 |
-
}
|
256 |
?>
|
1 |
<?php
|
2 |
/*
|
3 |
+
Plugin Name: Page scroll to id
|
4 |
+
Plugin URI: http://manos.malihu.gr/page-scroll-to-id
|
5 |
+
Description: Page scroll to id is an easy-to-use jQuery plugin that enables animated page scrolling to specific id within the document.
|
6 |
+
Version: 1.5.0
|
7 |
Author: malihu
|
8 |
Author URI: http://manos.malihu.gr
|
9 |
License: GNU GENERAL PUBLIC LICENSE Version 3
|
10 |
*/
|
11 |
|
12 |
+
/*
|
13 |
+
Copyright 2013 malihu (email: manos@malihu.gr)
|
14 |
|
15 |
+
This program is free software; you can redistribute it and/or modify
|
16 |
+
it under the terms of the GNU General Public License, version 3, as
|
17 |
+
published by the Free Software Foundation.
|
18 |
|
19 |
+
This program is distributed in the hope that it will be useful,
|
20 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
+
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
You should have received a copy of the GNU General Public License
|
25 |
+
along with this program; if not, write to the Free Software
|
26 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
if(basename($_SERVER['SCRIPT_NAME'])==basename(__FILE__))exit(':)');
|
|
|
30 |
|
31 |
+
if(!class_exists('malihuPageScroll2id')){ // --edit--
|
32 |
+
|
33 |
+
/*
|
34 |
+
Plugin uses the following db options:
|
35 |
+
db_prefix_version (holds plugin version)
|
36 |
+
db_prefix_instances (holds all plugin instances and their settings in a single array)
|
37 |
+
*/
|
38 |
+
|
39 |
+
/* to setup, search for: --edit-- */
|
40 |
+
|
41 |
+
class malihuPageScroll2id{ // --edit--
|
42 |
+
|
43 |
+
protected $version='1.5.0'; // Plugin version --edit--
|
44 |
+
protected $update_option=null;
|
45 |
+
|
46 |
+
protected $plugin_name='Page scroll to id'; // Plugin name --edit--
|
47 |
+
protected $plugin_slug='page-scroll-to-id'; // Plugin slug --edit--
|
48 |
+
protected $db_prefix='page_scroll_to_id_'; // Database field plugin prefix --edit--
|
49 |
+
protected $pl_pfx='mPS2id_'; // Plugin prefix --edit--
|
50 |
+
protected $sc_pfx='ps2id'; // Shortcode prefix (remove trailing "-" for single shortcode) --edit--
|
51 |
+
|
52 |
+
protected static $instance=null;
|
53 |
+
protected $plugin_screen_hook_suffix=null;
|
54 |
+
|
55 |
+
protected $index=0;
|
56 |
+
protected $default;
|
57 |
+
|
58 |
+
protected $plugin_script='jquery.malihu.PageScroll2id.js'; // Plugin public script (main js plugin file) --edit--
|
59 |
+
protected $plugin_init_script='jquery.malihu.PageScroll2id-init.js'; // Plugin public initialization script --edit--
|
60 |
+
|
61 |
+
private function __construct(){
|
62 |
+
// Plugin requires WP version 3.1 or higher
|
63 |
+
if(get_bloginfo('version') < '3.1'){
|
64 |
+
add_action('admin_notices', array($this, 'admin_notice_wp_version'));
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
// Plugin default params
|
68 |
+
$this->default=array(
|
69 |
+
$this->pl_pfx.'instance_'.$this->index => $this->plugin_options_array('defaults',$this->index,null,null)
|
70 |
+
);
|
71 |
+
// Add textdomain
|
72 |
+
add_action('plugins_loaded', array($this, 'init_localization'));
|
73 |
+
// Add the options page and menu item.
|
74 |
+
add_action('admin_menu', array($this, 'add_plugin_admin_menu'));
|
75 |
+
// Upgrade plugin
|
76 |
+
add_action('admin_init', array($this, 'upgrade_plugin'));
|
77 |
+
// Add/save plugin settings.
|
78 |
+
add_action('admin_init', array($this, 'add_plugin_settings'));
|
79 |
+
// Load admin stylesheet and javaScript.
|
80 |
+
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles'));
|
81 |
+
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
|
82 |
+
// load public stylesheet and javaScript.
|
83 |
+
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
|
84 |
+
// Add plugin settings link
|
85 |
+
add_filter('plugin_action_links_'.plugin_basename(__FILE__), array($this, 'add_plugin_action_links'));
|
86 |
+
// Add contextual help for the plugin
|
87 |
+
add_action('contextual_help', array($this, 'plugin_contextual_help'), 10, 3);
|
88 |
+
}
|
89 |
+
|
90 |
+
public static function get_instance(){
|
91 |
+
if(null==self::$instance){
|
92 |
+
self::$instance=new self;
|
93 |
+
}
|
94 |
+
return self::$instance;
|
95 |
+
}
|
96 |
+
|
97 |
+
public static function activate(){
|
98 |
+
// TODO: Define activation functionality here
|
99 |
+
}
|
100 |
+
|
101 |
+
public static function deactivate(){
|
102 |
+
// TODO: Define deactivation functionality here
|
103 |
+
}
|
104 |
+
|
105 |
+
// WP version notice
|
106 |
+
public function admin_notice_wp_version(){
|
107 |
+
_e('<div class="error"><p>'.$this->plugin_name.' requires WordPress version 3.1 or higher. Deactivate the plugin and reactivate when WordPress is updated.</p></div>', $this->plugin_slug);
|
108 |
+
}
|
109 |
+
|
110 |
+
// Plugin localization (load plugin textdomain)
|
111 |
+
public function init_localization(){
|
112 |
+
if(!load_plugin_textdomain($this->plugin_slug, false, WP_LANG_DIR)){
|
113 |
+
load_plugin_textdomain($this->plugin_slug, false, dirname(plugin_basename(__FILE__)).'/languages/');
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
// Admin styles
|
118 |
+
public function enqueue_admin_styles(){
|
119 |
+
if(!isset($this->plugin_screen_hook_suffix)){
|
120 |
+
return;
|
121 |
+
}
|
122 |
+
$screen=get_current_screen();
|
123 |
+
// If this is the plugin's settings page, load admin styles
|
124 |
+
if($screen->id==$this->plugin_screen_hook_suffix){
|
125 |
+
wp_enqueue_style($this->plugin_slug.'-admin-styles', plugins_url('css/admin.css', __FILE__), $this->version);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
// Admin scripts
|
130 |
+
public function enqueue_admin_scripts(){
|
131 |
+
if(!isset($this->plugin_screen_hook_suffix)){
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
$screen=get_current_screen();
|
135 |
+
// If this is the plugin's settings page, load admin scripts
|
136 |
+
if($screen->id==$this->plugin_screen_hook_suffix){
|
137 |
+
wp_enqueue_script('jquery-ui-sortable');
|
138 |
+
wp_enqueue_script($this->plugin_slug.'-admin-script', plugins_url('js/admin.js', __FILE__), array('jquery', 'jquery-ui-sortable'), $this->version, 1);
|
139 |
+
$params=array(
|
140 |
+
'id' => $this->pl_pfx.'form',
|
141 |
+
'db_prefix' => $this->db_prefix,
|
142 |
+
'sc_prefix' => $this->sc_pfx
|
143 |
+
);
|
144 |
+
wp_localize_script($this->plugin_slug.'-admin-script', '_adminParams', $params);
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
// front-end plugin scripts
|
149 |
+
public function enqueue_scripts(){
|
150 |
+
wp_enqueue_script('jquery');
|
151 |
+
wp_register_script($this->plugin_slug.'-plugin-script', plugins_url('js/'.$this->plugin_script, __FILE__), array('jquery'), $this->version, 1);
|
152 |
+
wp_enqueue_script($this->plugin_slug.'-plugin-script');
|
153 |
+
wp_register_script($this->plugin_slug.'-plugin-init-script', plugins_url('js/'.$this->plugin_init_script, __FILE__), array('jquery', $this->plugin_slug.'-plugin-script'), $this->version, 1);
|
154 |
+
wp_enqueue_script($this->plugin_slug.'-plugin-init-script');
|
155 |
+
$this->plugin_fn_call();
|
156 |
+
//$this->add_plugin_shortcode(); // Remove/comment for plugin without any shortcodes --edit--
|
157 |
+
}
|
158 |
+
|
159 |
+
public function add_plugin_admin_menu(){
|
160 |
+
$this->plugin_screen_hook_suffix=add_options_page(
|
161 |
+
__($this->plugin_name, $this->plugin_slug),
|
162 |
+
__($this->plugin_name, $this->plugin_slug),
|
163 |
+
'manage_options',
|
164 |
+
$this->plugin_slug,
|
165 |
+
array($this, 'display_plugin_admin_page')
|
166 |
+
);
|
167 |
+
}
|
168 |
+
|
169 |
+
public function add_plugin_settings(){
|
170 |
+
// All plugin settings are saved as array in a single option
|
171 |
+
register_setting($this->plugin_slug, $this->db_prefix.'instances', $this->validate_plugin_settings());
|
172 |
+
// Get plugin options array
|
173 |
+
$pl_instances=get_option($this->db_prefix.'instances', $this->default);
|
174 |
+
// Loop the array to generate instances, fields etc.
|
175 |
+
// Add settings section for each plugin instance
|
176 |
+
while(list($var, $val)=each($pl_instances)){
|
177 |
+
add_settings_section(
|
178 |
+
$this->db_prefix.'settings_section'.$this->index,
|
179 |
+
null,
|
180 |
+
null,
|
181 |
+
$this->plugin_slug
|
182 |
+
);
|
183 |
+
// Add settings fields for each section
|
184 |
+
while(list($var2, $val2)=each($val)){
|
185 |
+
while(list($var3, $val3)=each($val2)){
|
186 |
+
switch($var3){
|
187 |
+
case 'value':
|
188 |
+
$i_val=$val3;
|
189 |
+
break;
|
190 |
+
case 'values':
|
191 |
+
$i_vals=$val3;
|
192 |
+
break;
|
193 |
+
case 'id':
|
194 |
+
$i_id=$val3;
|
195 |
+
break;
|
196 |
+
case 'field_type':
|
197 |
+
$i_field_type=$val3;
|
198 |
+
break;
|
199 |
+
case 'label':
|
200 |
+
$i_label=$val3;
|
201 |
+
break;
|
202 |
+
case 'checkbox_label':
|
203 |
+
$i_checkbox_label=$val3;
|
204 |
+
break;
|
205 |
+
case 'radio_labels':
|
206 |
+
$i_radio_labels=$val3;
|
207 |
+
break;
|
208 |
+
case 'field_info':
|
209 |
+
$i_field_info=$val3;
|
210 |
+
break;
|
211 |
+
case 'description':
|
212 |
+
$i_description=$val3;
|
213 |
+
break;
|
214 |
+
case 'wrapper':
|
215 |
+
$i_wrapper=$val3;
|
216 |
+
break;
|
217 |
+
}
|
218 |
+
}
|
219 |
+
add_settings_field(
|
220 |
+
$i_id,
|
221 |
+
$i_label,
|
222 |
+
array($this, 'instance_field_callback'),
|
223 |
+
$this->plugin_slug,
|
224 |
+
$this->db_prefix.'settings_section'.$this->index,
|
225 |
+
array(
|
226 |
+
'value' => $i_val,
|
227 |
+
'values' => $i_vals,
|
228 |
+
'id' => $i_id,
|
229 |
+
'field_type' => $i_field_type,
|
230 |
+
'label_for' => ($i_field_type!=='checkbox' && $i_field_type!=='radio') ? $i_id : null,
|
231 |
+
'checkbox_label' => $i_checkbox_label,
|
232 |
+
'radio_labels' => $i_radio_labels,
|
233 |
+
'field_info' => $i_field_info,
|
234 |
+
'description' => $i_description,
|
235 |
+
'wrapper' => $i_wrapper
|
236 |
+
)
|
237 |
+
);
|
238 |
+
}
|
239 |
+
$this->index++;
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
public function instance_field_callback($args){
|
244 |
+
$html=(!empty($args['wrapper'])) ? '<'.$args['wrapper'].'>' : '';
|
245 |
+
if($args['field_type']=='text'){ // Text field
|
246 |
+
$html.='<input type="text" id="'.$args['id'].'" name="'.$args['id'].'" value="'.$args['value'].'" class="regular-text code" /> ';
|
247 |
+
}else if($args['field_type']=='text-integer'){ // Text field - integer
|
248 |
+
$html.='<input type="text" id="'.$args['id'].'" name="'.$args['id'].'" value="'.$args['value'].'" class="small-text" /> ';
|
249 |
+
}else if($args['field_type']=='checkbox'){ // Checkbox
|
250 |
+
(!empty($args['checkbox_label'])) ? $html.='<label for="'.$args['id'].'">' : $html.='';
|
251 |
+
$html.='<input type="checkbox" id="'.$args['id'].'" name="'.$args['id'].'" value="true" '.checked('true', $args['value'], false).' /> ';
|
252 |
+
(!empty($args['checkbox_label'])) ? $html.=$args['checkbox_label'].'</label> ' : $html.='';
|
253 |
+
}else if($args['field_type']=='select'){ // Select/dropdown
|
254 |
+
$html.='<select id="'.$args['id'].'" name="'.$args['id'].'">';
|
255 |
+
$select_options=explode(',', $args['values']);
|
256 |
+
foreach($select_options as $select_option){
|
257 |
+
$html.='<option value="'.$select_option.'" '.selected($select_option, $args['value'], false).'>'.$select_option.'</option>';
|
258 |
+
}
|
259 |
+
$html.= '</select> ';
|
260 |
+
}else if($args['field_type']=='radio'){ // Radio buttons
|
261 |
+
$radio_buttons=explode(',', $args['values']);
|
262 |
+
$radio_labels=explode('|', $args['radio_labels']);
|
263 |
+
$i=0;
|
264 |
+
foreach($radio_buttons as $radio_button){
|
265 |
+
$html.='<label title="'.$radio_button.'"><input type="radio" name="'.$args['id'].'" value="'.$radio_button.'" '.checked($radio_button, $args['value'], false).' /> <span>'.$radio_labels[$i].'</span> </label> ';
|
266 |
+
$html.=($radio_button===end($radio_buttons)) ? '' : '<br />';
|
267 |
+
$i++;
|
268 |
+
}
|
269 |
+
}else if($args['field_type']=='textarea'){ // Textarea
|
270 |
+
$html.='<textarea id="'.$args['id'].'" name="'.$args['id'].'" rows="10" cols="50" class="large-text code">'.$args['value'].'</textarea> ';
|
271 |
+
}else if($args['field_type']=='hidden'){ // Hidden field
|
272 |
+
$html.='<input type="hidden" id="'.$args['id'].'" name="'.$args['id'].'" value="'.$args['value'].'" /> ';
|
273 |
+
}
|
274 |
+
$html.=(!empty($args['wrapper'])) ? '</'.$args['wrapper'].'>' : '';
|
275 |
+
(!empty($args['field_info'])) ? $html.='<span>'.$args['field_info'].'</span> ' : $html.='';
|
276 |
+
(!empty($args['description'])) ? $html.='<p class="description">'.$args['description'].'</p>' : $html.='';
|
277 |
+
echo $html;
|
278 |
+
}
|
279 |
+
|
280 |
+
public function display_plugin_admin_page(){
|
281 |
+
include_once(plugin_dir_path( __FILE__ ).'includes/admin.php');
|
282 |
+
}
|
283 |
+
|
284 |
+
public function add_plugin_action_links($links){
|
285 |
+
$settings_link='<a href="options-general.php?page='.$this->plugin_slug.'">Settings</a>';
|
286 |
+
array_unshift($links, $settings_link);
|
287 |
+
return $links;
|
288 |
+
}
|
289 |
+
|
290 |
+
public function plugin_fn_call(){
|
291 |
+
$instances=get_option($this->db_prefix.'instances');
|
292 |
+
$params=array(
|
293 |
+
'instances' => $instances,
|
294 |
+
'total_instances' => count($instances),
|
295 |
+
'shortcode_class' => $this->sc_pfx
|
296 |
+
);
|
297 |
+
wp_localize_script($this->plugin_slug.'-plugin-init-script', $this->pl_pfx.'params', $params);
|
298 |
+
}
|
299 |
+
|
300 |
+
public function add_plugin_shortcode(){
|
301 |
+
$pl_shortcodes=array();
|
302 |
+
$instances=get_option($this->db_prefix.'instances');
|
303 |
+
for($i=1; $i<=count($instances); $i++){
|
304 |
+
$pl_shortcodes[]='pl_shortcode_fn_'.$i;
|
305 |
+
$shortcode_class=$this->sc_pfx;
|
306 |
+
// --edit--
|
307 |
+
$pl_shortcodes[$i]=function($atts, $content=null) use ($i,$shortcode_class){
|
308 |
+
extract(shortcode_atts(array(
|
309 |
+
'att' => '',
|
310 |
+
), $atts));
|
311 |
+
return '';
|
312 |
+
};
|
313 |
+
add_shortcode($this->sc_pfx.$i, $pl_shortcodes[$i]);
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
public function validate_plugin_settings(){
|
318 |
+
if(!empty($_POST)){
|
319 |
+
if($_POST[$this->db_prefix.'reset']==='true' ){
|
320 |
+
// Reset all to default
|
321 |
+
$_POST[$this->db_prefix.'instances']=$this->default;
|
322 |
+
}else{
|
323 |
+
// Update settings array
|
324 |
+
$instances=$_POST[$this->db_prefix.'total_instances'];
|
325 |
+
for($i=0; $i<$instances; $i++){
|
326 |
+
$instance=$this->plugin_options_array('validate',$i,null,null);
|
327 |
+
$update[$this->pl_pfx.'instance_'.$i]=$instance;
|
328 |
+
}
|
329 |
+
$_POST[$this->db_prefix.'instances']=$update; // Save array to plugin option
|
330 |
+
}
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
public function sanitize_input($type, $val, $def){
|
335 |
+
switch($type){
|
336 |
+
case 'text':
|
337 |
+
$val=(empty($val)) ? $def : sanitize_text_field($val);
|
338 |
+
break;
|
339 |
+
case 'number':
|
340 |
+
$val=(int) preg_replace('/\D/', '', $val);
|
341 |
+
break;
|
342 |
+
case 'integer':
|
343 |
+
$s=strpos($val, '-');
|
344 |
+
$n=(int) preg_replace('/\D/', '', $val);
|
345 |
+
$val=($s===false) ? $n : '-'.$n;
|
346 |
+
break;
|
347 |
+
case 'class':
|
348 |
+
$val=sanitize_html_class($val, $def);
|
349 |
+
break;
|
350 |
+
}
|
351 |
+
return $val;
|
352 |
+
}
|
353 |
+
|
354 |
+
public function upgrade_plugin(){
|
355 |
+
// Get/set plugin version
|
356 |
+
$current_version=get_option($this->db_prefix.'version');
|
357 |
+
if(!$current_version){
|
358 |
+
add_option($this->db_prefix.'version', $this->version);
|
359 |
+
$old_db_options=$this->get_plugin_old_db_options(); // Get old/deprecated plugin db options --edit--
|
360 |
+
$this->delete_plugin_old_db_options(); // Delete old/deprecated plugin db options --edit--
|
361 |
+
}else{
|
362 |
+
$old_db_options=null; // Old/deprecated plugin db options --edit--
|
363 |
+
}
|
364 |
+
if($this->version!==$current_version){
|
365 |
+
// Update plugin options to new version ones
|
366 |
+
$pl_instances=get_option($this->db_prefix.'instances');
|
367 |
+
for($i=0; $i<count($pl_instances); $i++){
|
368 |
+
$j=$pl_instances[$this->pl_pfx.'instance_'.$i];
|
369 |
+
$instance=$this->plugin_options_array('upgrade',$i,$j,$old_db_options); // --edit--
|
370 |
+
$update[$this->pl_pfx.'instance_'.$i]=$instance;
|
371 |
+
}
|
372 |
+
$this->update_option=update_option($this->db_prefix.'instances', $update); // Update options
|
373 |
+
update_option($this->db_prefix.'version', $this->version); // Update version
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
+
// --edit--
|
378 |
+
public function get_plugin_old_db_options(){
|
379 |
+
$old_db_opt1=get_option('malihu_pagescroll2id_sel');
|
380 |
+
$old_db_opt2=get_option('malihu_pagescroll2id_scrollSpeed');
|
381 |
+
$old_db_opt3=get_option('malihu_pagescroll2id_autoScrollSpeed');
|
382 |
+
$old_db_opt4=get_option('malihu_pagescroll2id_scrollEasing');
|
383 |
+
$old_db_opt5=get_option('malihu_pagescroll2id_scrollingEasing');
|
384 |
+
$old_db_opt6=get_option('malihu_pagescroll2id_pageEndSmoothScroll');
|
385 |
+
$old_db_opt7=get_option('malihu_pagescroll2id_layout');
|
386 |
+
return array(
|
387 |
+
($old_db_opt1) ? $old_db_opt1 : 'a[rel=\'m_PageScroll2id\']',
|
388 |
+
($old_db_opt2) ? $old_db_opt2 : 1300,
|
389 |
+
($old_db_opt3) ? $old_db_opt3 : 'true',
|
390 |
+
($old_db_opt4) ? $old_db_opt4 : 'easeInOutExpo',
|
391 |
+
($old_db_opt5) ? $old_db_opt5 : 'easeInOutCirc',
|
392 |
+
($old_db_opt6) ? $old_db_opt6 : 'true',
|
393 |
+
($old_db_opt7) ? $old_db_opt7 : 'vertical'
|
394 |
+
);
|
395 |
+
}
|
396 |
+
|
397 |
+
// --edit--
|
398 |
+
public function delete_plugin_old_db_options(){
|
399 |
+
delete_option('malihu_pagescroll2id_sel');
|
400 |
+
delete_option('malihu_pagescroll2id_scrollSpeed');
|
401 |
+
delete_option('malihu_pagescroll2id_autoScrollSpeed');
|
402 |
+
delete_option('malihu_pagescroll2id_scrollEasing');
|
403 |
+
delete_option('malihu_pagescroll2id_scrollingEasing');
|
404 |
+
delete_option('malihu_pagescroll2id_pageEndSmoothScroll');
|
405 |
+
delete_option('malihu_pagescroll2id_layout');
|
406 |
+
}
|
407 |
+
|
408 |
+
public function debug_to_console($data){
|
409 |
+
/*
|
410 |
+
This is just a helper function that sends debug code to the Javascript console
|
411 |
+
Usage: $this->debug_to_console('hello world');
|
412 |
+
*/
|
413 |
+
echo('<script>var _debugData_='.json_encode($data).'; console.log("PHP: "+_debugData_);</script>');
|
414 |
+
}
|
415 |
+
|
416 |
+
public function plugin_contextual_help($contextual_help, $screen_id, $screen){
|
417 |
+
if(strcmp($screen->id, $this->plugin_screen_hook_suffix)==0){
|
418 |
+
if(get_bloginfo('version') >= '3.6'){
|
419 |
+
// --edit--
|
420 |
+
// Multiple contextual help files/tabs
|
421 |
+
ob_start();
|
422 |
+
include_once(plugin_dir_path( __FILE__ ).'includes/help/overview.inc');
|
423 |
+
$help_overview=ob_get_contents();
|
424 |
+
ob_end_clean();
|
425 |
+
ob_start();
|
426 |
+
include_once(plugin_dir_path( __FILE__ ).'includes/help/get-started.inc');
|
427 |
+
$help_get_started=ob_get_contents();
|
428 |
+
ob_end_clean();
|
429 |
+
ob_start();
|
430 |
+
include_once(plugin_dir_path( __FILE__ ).'includes/help/plugin-settings.inc');
|
431 |
+
$help_plugin_settings=ob_get_contents();
|
432 |
+
ob_end_clean();
|
433 |
+
ob_start();
|
434 |
+
include_once(plugin_dir_path( __FILE__ ).'includes/help/sidebar.inc');
|
435 |
+
$help_sidebar=ob_get_contents();
|
436 |
+
ob_end_clean();
|
437 |
+
if(method_exists($screen, 'add_help_tab')){
|
438 |
+
$screen->add_help_tab(array(
|
439 |
+
'id' => $this->plugin_slug.'overview',
|
440 |
+
'title' => 'Overview',
|
441 |
+
'content' => $help_overview,
|
442 |
+
));
|
443 |
+
$screen->add_help_tab(array(
|
444 |
+
'id' => $this->plugin_slug.'get-started',
|
445 |
+
'title' => 'Get started',
|
446 |
+
'content' => $help_get_started,
|
447 |
+
));
|
448 |
+
$screen->add_help_tab(array(
|
449 |
+
'id' => $this->plugin_slug.'plugin-settings',
|
450 |
+
'title' => 'Plugin settings',
|
451 |
+
'content' => $help_plugin_settings,
|
452 |
+
));
|
453 |
+
$screen->set_help_sidebar($help_sidebar);
|
454 |
+
}
|
455 |
+
return $contextual_help;
|
456 |
+
}
|
457 |
+
}
|
458 |
+
return $contextual_help;
|
459 |
+
}
|
460 |
+
|
461 |
+
public function plugin_options_array($action, $i, $j, $old){
|
462 |
+
// --edit--
|
463 |
+
// Defaults
|
464 |
+
$d0='a[rel=\'m_PageScroll2id\']';
|
465 |
+
$d1=1300;
|
466 |
+
$d2='true';
|
467 |
+
$d3='easeInOutExpo';
|
468 |
+
$d4='easeInOutCirc';
|
469 |
+
$d5='true';
|
470 |
+
$d6='vertical';
|
471 |
+
$d7=0;
|
472 |
+
$d8='';
|
473 |
+
$d9='mPS2id-clicked';
|
474 |
+
$d10='mPS2id-target';
|
475 |
+
$d11='mPS2id-highlight';
|
476 |
+
$d12='false';
|
477 |
+
// Values
|
478 |
+
switch($action){
|
479 |
+
case 'validate':
|
480 |
+
$v0=$this->sanitize_input('text', $_POST[$this->db_prefix.$i.'_selector'], $d0);
|
481 |
+
$v1=$this->sanitize_input('number', $_POST[$this->db_prefix.$i.'_scrollSpeed'], $d1);
|
482 |
+
$v2=(isset($_POST[$this->db_prefix.$i.'_autoScrollSpeed'])) ? 'true' : 'false';
|
483 |
+
$v3=$_POST[$this->db_prefix.$i.'_scrollEasing'];
|
484 |
+
$v4=$_POST[$this->db_prefix.$i.'_scrollingEasing'];
|
485 |
+
$v5=(isset($_POST[$this->db_prefix.$i.'_pageEndSmoothScroll'])) ? 'true' : 'false';
|
486 |
+
$v6=$_POST[$this->db_prefix.$i.'_layout'];
|
487 |
+
$v7=$this->sanitize_input('integer', $_POST[$this->db_prefix.$i.'_offset'], $d7);
|
488 |
+
$v8=(empty($_POST[$this->db_prefix.$i.'_highlightSelector'])) ? $d8 : $this->sanitize_input('text', $_POST[$this->db_prefix.$i.'_highlightSelector'], $d8);
|
489 |
+
$v9=$this->sanitize_input('class', $_POST[$this->db_prefix.$i.'_clickedClass'], $d9);
|
490 |
+
$v10=$this->sanitize_input('class', $_POST[$this->db_prefix.$i.'_targetClass'], $d10);
|
491 |
+
$v11=$this->sanitize_input('class', $_POST[$this->db_prefix.$i.'_highlightClass'], $d11);
|
492 |
+
$v12=(isset($_POST[$this->db_prefix.$i.'_forceSingleHighlight'])) ? 'true' : 'false';
|
493 |
+
break;
|
494 |
+
case 'upgrade':
|
495 |
+
if(isset($old)){
|
496 |
+
$v0=$old[0];
|
497 |
+
$v1=$old[1];
|
498 |
+
$v2=$old[2];
|
499 |
+
$v3=$old[3];
|
500 |
+
$v4=$old[4];
|
501 |
+
$v5=$old[5];
|
502 |
+
$v6=$old[6];
|
503 |
+
}else{
|
504 |
+
$v0=(isset($j['selector'])) ? $j['selector']['value'] : $d0;
|
505 |
+
$v1=(isset($j['scrollSpeed'])) ? $j['scrollSpeed']['value'] : $d1;
|
506 |
+
$v2=(isset($j['autoScrollSpeed'])) ? $j['autoScrollSpeed']['value'] : $d2;
|
507 |
+
$v3=(isset($j['scrollEasing'])) ? $j['scrollEasing']['value'] : $d3;
|
508 |
+
$v4=(isset($j['scrollingEasing'])) ? $j['scrollingEasing']['value'] : $d4;
|
509 |
+
$v5=(isset($j['pageEndSmoothScroll'])) ? $j['pageEndSmoothScroll']['value'] : $d5;
|
510 |
+
$v6=(isset($j['layout'])) ? $j['layout']['value'] : $d6;
|
511 |
+
}
|
512 |
+
$v7=(isset($j['offset'])) ? $j['offset']['value'] : $d7;
|
513 |
+
$v8=(isset($j['highlightSelector'])) ? $j['highlightSelector']['value'] : $d8;
|
514 |
+
$v9=(isset($j['clickedClass'])) ? $j['clickedClass']['value'] : $d9;
|
515 |
+
$v10=(isset($j['targetClass'])) ? $j['targetClass']['value'] : $d10;
|
516 |
+
$v11=(isset($j['highlightClass'])) ? $j['highlightClass']['value'] : $d11;
|
517 |
+
$v12=(isset($j['forceSingleHighlight'])) ? $j['forceSingleHighlight']['value'] : $d12;
|
518 |
+
break;
|
519 |
+
default:
|
520 |
+
$v0=$d0;
|
521 |
+
$v1=$d1;
|
522 |
+
$v2=$d2;
|
523 |
+
$v3=$d3;
|
524 |
+
$v4=$d4;
|
525 |
+
$v5=$d5;
|
526 |
+
$v6=$d6;
|
527 |
+
$v7=$d7;
|
528 |
+
$v8=$d8;
|
529 |
+
$v9=$d9;
|
530 |
+
$v10=$d10;
|
531 |
+
$v11=$d11;
|
532 |
+
$v12=$d12;
|
533 |
+
}
|
534 |
+
// Options array
|
535 |
+
/*
|
536 |
+
option name
|
537 |
+
option value
|
538 |
+
option values (for dropdowns, radio buttons)
|
539 |
+
field id
|
540 |
+
field type (e.g. text, checkbox etc.)
|
541 |
+
option setting title (also label for non checkboxes and radio buttons)
|
542 |
+
label for checkbox
|
543 |
+
labels for radio buttons
|
544 |
+
small information text (as span next to field/fieldset)
|
545 |
+
option setting description (as paragraph below the field/fieldset)
|
546 |
+
fields wrapper element (e.g. fieldset)
|
547 |
+
*/
|
548 |
+
return array(
|
549 |
+
'selector' => array(
|
550 |
+
'value' => $v0,
|
551 |
+
'values' => null,
|
552 |
+
'id' => $this->db_prefix.$i.'_selector',
|
553 |
+
'field_type' => 'text',
|
554 |
+
'label' => 'Selector(s)',
|
555 |
+
'checkbox_label' => null,
|
556 |
+
'radio_labels' => null,
|
557 |
+
'field_info' => null,
|
558 |
+
'description' => 'The link(s) that will scroll the page when clicked. Defaults to all links with <code>m_PageScroll2id</code> rel attribute value',
|
559 |
+
'wrapper' => null
|
560 |
+
),
|
561 |
+
'scrollSpeed' => array(
|
562 |
+
'value' => $v1,
|
563 |
+
'values' => null,
|
564 |
+
'id' => $this->db_prefix.$i.'_scrollSpeed',
|
565 |
+
'field_type' => 'text-integer',
|
566 |
+
'label' => 'Scroll animation speed',
|
567 |
+
'checkbox_label' => null,
|
568 |
+
'radio_labels' => null,
|
569 |
+
'field_info' => 'milliseconds',
|
570 |
+
'description' => 'Scroll animation speed in milliseconds (1000 milliseconds equals 1 second)',
|
571 |
+
'wrapper' => null
|
572 |
+
),
|
573 |
+
'autoScrollSpeed' => array(
|
574 |
+
'value' => $v2,
|
575 |
+
'values' => null,
|
576 |
+
'id' => $this->db_prefix.$i.'_autoScrollSpeed',
|
577 |
+
'field_type' => 'checkbox',
|
578 |
+
'label' => '',
|
579 |
+
'checkbox_label' => 'Auto-adjust animation speed',
|
580 |
+
'radio_labels' => null,
|
581 |
+
'field_info' => null,
|
582 |
+
'description' => 'Auto-adjust animation speed according to target element position and window scroll',
|
583 |
+
'wrapper' => 'fieldset'
|
584 |
+
),
|
585 |
+
'scrollEasing' => array(
|
586 |
+
'value' => $v3,
|
587 |
+
'values' => 'linear,swing,easeInQuad,easeOutQuad,easeInOutQuad,easeInCubic,easeOutCubic,easeInOutCubic,easeInQuart,easeOutQuart,easeInOutQuart,easeInQuint,easeOutQuint,easeInOutQuint,easeInExpo,easeOutExpo,easeInOutExpo,easeInSine,easeOutSine,easeInOutSine,easeInCirc,easeOutCirc,easeInOutCirc,easeInElastic,easeOutElastic,easeInOutElastic,easeInBack,easeOutBack,easeInOutBack,easeInBounce,easeOutBounce,easeInOutBounce',
|
588 |
+
'id' => $this->db_prefix.$i.'_scrollEasing',
|
589 |
+
'field_type' => 'select',
|
590 |
+
'label' => 'Scroll animation easing',
|
591 |
+
'checkbox_label' => null,
|
592 |
+
'radio_labels' => null,
|
593 |
+
'field_info' => null,
|
594 |
+
'description' => 'Animation easing when page is idle',
|
595 |
+
'wrapper' => null
|
596 |
+
),
|
597 |
+
'scrollingEasing' => array(
|
598 |
+
'value' => $v4,
|
599 |
+
'values' => 'linear,swing,easeInQuad,easeOutQuad,easeInOutQuad,easeInCubic,easeOutCubic,easeInOutCubic,easeInQuart,easeOutQuart,easeInOutQuart,easeInQuint,easeOutQuint,easeInOutQuint,easeInExpo,easeOutExpo,easeInOutExpo,easeInSine,easeOutSine,easeInOutSine,easeInCirc,easeOutCirc,easeInOutCirc,easeInElastic,easeOutElastic,easeInOutElastic,easeInBack,easeOutBack,easeInOutBack,easeInBounce,easeOutBounce,easeInOutBounce',
|
600 |
+
'id' => $this->db_prefix.$i.'_scrollingEasing',
|
601 |
+
'field_type' => 'select',
|
602 |
+
'label' => '',
|
603 |
+
'checkbox_label' => null,
|
604 |
+
'radio_labels' => null,
|
605 |
+
'field_info' => null,
|
606 |
+
'description' => 'Animation easing while page is animating',
|
607 |
+
'wrapper' => null
|
608 |
+
),
|
609 |
+
'pageEndSmoothScroll' => array(
|
610 |
+
'value' => $v5,
|
611 |
+
'values' => null,
|
612 |
+
'id' => $this->db_prefix.$i.'_pageEndSmoothScroll',
|
613 |
+
'field_type' => 'checkbox',
|
614 |
+
'label' => 'Scroll-to position',
|
615 |
+
'checkbox_label' => 'Auto-adjust',
|
616 |
+
'radio_labels' => null,
|
617 |
+
'field_info' => null,
|
618 |
+
'description' => 'Auto-adjust the scroll-to position so it does not exceed document length',
|
619 |
+
'wrapper' => 'fieldset'
|
620 |
+
),
|
621 |
+
'layout' => array(
|
622 |
+
'value' => $v6,
|
623 |
+
'values' => 'vertical,horizontal,auto',
|
624 |
+
'id' => $this->db_prefix.$i.'_layout',
|
625 |
+
'field_type' => 'radio',
|
626 |
+
'label' => 'Page layout',
|
627 |
+
'checkbox_label' => null,
|
628 |
+
'radio_labels' => 'vertical|horizontal|auto',
|
629 |
+
'field_info' => null,
|
630 |
+
'description' => 'Restrict page scrolling to top-bottom (vertical) or left-right (horizontal) accordingly. For both vertical and horizontal scrolling select <code>auto</code>',
|
631 |
+
'wrapper' => 'fieldset'
|
632 |
+
),
|
633 |
+
'offset' => array(
|
634 |
+
'value' => $v7,
|
635 |
+
'values' => null,
|
636 |
+
'id' => $this->db_prefix.$i.'_offset',
|
637 |
+
'field_type' => 'text-integer',
|
638 |
+
'label' => 'Offset',
|
639 |
+
'checkbox_label' => null,
|
640 |
+
'radio_labels' => null,
|
641 |
+
'field_info' => 'pixels',
|
642 |
+
'description' => 'Offset scroll-to position by x amount of pixels (positive or negative)',
|
643 |
+
'wrapper' => null
|
644 |
+
),
|
645 |
+
'highlightSelector' => array(
|
646 |
+
'value' => $v8,
|
647 |
+
'values' => null,
|
648 |
+
'id' => $this->db_prefix.$i.'_highlightSelector',
|
649 |
+
'field_type' => 'text',
|
650 |
+
'label' => 'Highlight selector(s)',
|
651 |
+
'checkbox_label' => null,
|
652 |
+
'radio_labels' => null,
|
653 |
+
'field_info' => null,
|
654 |
+
'description' => 'The link(s) that are highlighted. Leave empty to highlight all or enter your specific selector(s)',
|
655 |
+
'wrapper' => null
|
656 |
+
),
|
657 |
+
'clickedClass' => array(
|
658 |
+
'value' => $v9,
|
659 |
+
'values' => null,
|
660 |
+
'id' => $this->db_prefix.$i.'_clickedClass',
|
661 |
+
'field_type' => 'text',
|
662 |
+
'label' => 'Classes',
|
663 |
+
'checkbox_label' => null,
|
664 |
+
'radio_labels' => null,
|
665 |
+
'field_info' => 'class name',
|
666 |
+
'description' => 'Class of the clicked link',
|
667 |
+
'wrapper' => null
|
668 |
+
),
|
669 |
+
'targetClass' => array(
|
670 |
+
'value' => $v10,
|
671 |
+
'values' => null,
|
672 |
+
'id' => $this->db_prefix.$i.'_targetClass',
|
673 |
+
'field_type' => 'text',
|
674 |
+
'label' => '',
|
675 |
+
'checkbox_label' => null,
|
676 |
+
'radio_labels' => null,
|
677 |
+
'field_info' => 'class name',
|
678 |
+
'description' => 'Class of the (current) target element',
|
679 |
+
'wrapper' => null
|
680 |
+
),
|
681 |
+
'highlightClass' => array(
|
682 |
+
'value' => $v11,
|
683 |
+
'values' => null,
|
684 |
+
'id' => $this->db_prefix.$i.'_highlightClass',
|
685 |
+
'field_type' => 'text',
|
686 |
+
'label' => '',
|
687 |
+
'checkbox_label' => null,
|
688 |
+
'radio_labels' => null,
|
689 |
+
'field_info' => 'class name',
|
690 |
+
'description' => 'Class of the (current) highlighted element',
|
691 |
+
'wrapper' => null
|
692 |
+
),
|
693 |
+
'forceSingleHighlight' => array(
|
694 |
+
'value' => $v12,
|
695 |
+
'values' => null,
|
696 |
+
'id' => $this->db_prefix.$i.'_forceSingleHighlight',
|
697 |
+
'field_type' => 'checkbox',
|
698 |
+
'label' => '',
|
699 |
+
'checkbox_label' => 'Force single highlight',
|
700 |
+
'radio_labels' => null,
|
701 |
+
'field_info' => null,
|
702 |
+
'description' => 'Allow only one highlighted element at a time',
|
703 |
+
'wrapper' => 'fieldset'
|
704 |
+
)
|
705 |
+
);
|
706 |
+
}
|
707 |
+
|
708 |
+
}
|
709 |
|
710 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
711 |
|
712 |
+
if(class_exists('malihuPageScroll2id')){ // --edit--
|
713 |
+
|
714 |
+
register_activation_hook(__FILE__, array('malihu-plugin', 'activate')); // --edit--
|
715 |
+
register_deactivation_hook(__FILE__, array('malihu-plugin', 'deactivate')); // --edit--
|
716 |
|
717 |
+
malihuPageScroll2id::get_instance(); // --edit--
|
|
|
|
|
|
|
|
|
|
|
718 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
719 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
720 |
?>
|
readme.txt
CHANGED
@@ -1,49 +1,145 @@
|
|
1 |
=== Page scroll to id ===
|
2 |
-
Donate link:
|
3 |
Tags: page scrolling, page animation, navigation, single-page navigation
|
4 |
-
|
5 |
-
|
|
|
6 |
License: GPLv2 or later
|
7 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
8 |
|
9 |
-
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
18 |
-
Plugin home: http://manos.malihu.gr/animate-page-to-id-with-jquery
|
19 |
|
20 |
-
|
|
|
|
|
21 |
|
22 |
-
=
|
23 |
-
* Added support for jQuery 1.9+.
|
24 |
|
25 |
-
|
26 |
-
* Removed the hard-coded plugin directory URL in order to fix errors of .js files pointing to a wrong location.
|
27 |
|
28 |
-
=
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
== Installation ==
|
32 |
|
33 |
-
|
34 |
-
2. Put folder 'page-scroll-to-id'
|
35 |
-
3. Activate 'Page Scroll to id' Plugin through the 'Plugins' menu in WordPress
|
36 |
-
4. Go to 'WP-Admin -> settings -> 'Page Scroll to id' to configure plugin options.
|
37 |
|
38 |
-
|
|
|
|
|
39 |
|
40 |
-
|
41 |
|
42 |
-
|
|
|
|
|
43 |
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
GPLv3
|
49 |
|
@@ -54,4 +150,4 @@ If not, see <http://www.gnu.org/licenses/>.
|
|
54 |
|
55 |
== Donate ==
|
56 |
|
57 |
-
If you
|
1 |
=== Page scroll to id ===
|
2 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UYJ5G65M6ZA28
|
3 |
Tags: page scrolling, page animation, navigation, single-page navigation
|
4 |
+
Requires at least: 3.1
|
5 |
+
Tested up to: 3.8
|
6 |
+
Stable tag: 1.5.0
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
+
Page scroll to id is an easy-to-use jQuery plugin that enables animated page scrolling to specific id within the document.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
The plugin replaces the default browser behaviour of "jumping" to page sections when links with href value containing `#` are clicked, by smoothly animating the page to those sections. You can use it for simple back-to-top links or complex, single-page website navigation and features include:
|
15 |
|
16 |
+
* Auto-adjustable animation speed
|
17 |
+
* Advanced animation easings
|
18 |
+
* Vertical and/or horizontal scrolling
|
19 |
+
* Links and targets highlighting via ready-to-use classes
|
20 |
+
* Auto-adjustable Scroll-to position and user defined offset
|
21 |
|
22 |
+
= Demo =
|
|
|
23 |
|
24 |
+
* [Plugin demo: vertical layout](http://manos.malihu.gr/repository/page-scroll-to-id/demo/demo.html)
|
25 |
+
* [Plugin demo: horizontal layout](http://manos.malihu.gr/repository/page-scroll-to-id/demo/demo-horizontal-layout.html)
|
26 |
+
* [Plugin demo: auto layout](http://manos.malihu.gr/repository/page-scroll-to-id/demo/demo-auto-layout.html)
|
27 |
|
28 |
+
= Requirements =
|
|
|
29 |
|
30 |
+
Page scroll to id requires WordPress version **3.1** or higher and jQuery version **1.6.0** or higher (jQuery 1.6.1 was included in WordPress 3.2). For older installations use plugin version 1.2.0 or implement it in your theme manually.
|
|
|
31 |
|
32 |
+
= Quick usage =
|
33 |
+
|
34 |
+
1. [Install the plugin](http://wordpress.org/plugins/page-scroll-to-id/installation/).
|
35 |
+
2. Add `rel="m_PageScroll2id"` to your links that point to existing sections within your page, making sure each link's href value contains a hash (`#`) with the id of the section you want to scroll-to.
|
36 |
+
|
37 |
+
For more information see plugin resources below.
|
38 |
+
|
39 |
+
= Plugin Resources =
|
40 |
+
|
41 |
+
* [Plugin homepage](http://manos.malihu.gr/page-scroll-to-id/)
|
42 |
+
* [FAQ](http://wordpress.org/plugins/page-scroll-to-id/faq/)
|
43 |
+
* [Support](http://wordpress.org/support/plugin/page-scroll-to-id)
|
44 |
|
45 |
== Installation ==
|
46 |
|
47 |
+
= Automatic =
|
|
|
|
|
|
|
48 |
|
49 |
+
1. Click 'Add New' under 'Plugins' menu in WordPress.
|
50 |
+
2. Perform a search for the term 'Page scroll to id' and in search results, click 'Install/Install Now' under plugin name.
|
51 |
+
3. When installation is finished, click 'Activate Plugin'.
|
52 |
|
53 |
+
= Manual =
|
54 |
|
55 |
+
1. Download and extract the plugin.
|
56 |
+
2. Upload the entire `page-scroll-to-id` folder to `/wp-content/plugins/` directory.
|
57 |
+
3. Activate the plugin through the 'Plugins' menu in WordPress.
|
58 |
|
59 |
+
= Configuration =
|
60 |
+
|
61 |
+
Configure plugin options by clicking 'Settings' or through the 'Settings > Page Scroll to id' menu in WordPress.
|
62 |
+
|
63 |
+
== Frequently Asked Questions ==
|
64 |
+
|
65 |
+
= How to use the plugin with WP custom/native menus? =
|
66 |
+
|
67 |
+
While on the 'Menus' admin page, click 'Screen Options' and check 'Link Relationship (XFN)'. To enable the plugin on a menu item, click the arrow on the right of the item and insert `m_PageScroll2id` in the 'Link Relationship (XFN)' field (assuming your menu contains links with `URL` value in the form of `#id`).
|
68 |
+
|
69 |
+
= How to use the plugin without editing my theme's markup? =
|
70 |
+
|
71 |
+
In plugin's configuration page ('Settings > Page Scroll to id' menu in WordPress), you can change the `Selector(s)` field value to existing matching sets of elements in your theme. For example: `a.class-name`, `#id a`, `a[href*='#']` etc. For multiple selectors, use comma separated values: e.g. `a[rel='m_PageScroll2id'], a.class-name`.
|
72 |
+
|
73 |
+
= What if my links have rel values already set by the theme or other plugins? =
|
74 |
+
|
75 |
+
You can add the `m_PageScroll2id` in your link's rel attribute (along with the other values) and change the `Selector(s)` field value to `a[rel~='m_PageScroll2id']` in plugin settings.
|
76 |
+
|
77 |
+
= How do I highlight current menu items? =
|
78 |
+
|
79 |
+
The plugin provides a ready-to-use class for styling highlighted links (the links whose target element is considered to be within the viewport). The default highlight class is `mPS2id-highlight`, so you can use it in your theme's CSS to style current menu items, e.g. `.menu-item a.mPS2id-highlight{ background: #ff0; }`
|
80 |
+
|
81 |
+
= When I click the link, nothing happens... =
|
82 |
+
|
83 |
+
Make sure your link has href value `#` with the id of the section you want to scroll-to (e.g. `<a href="#id" rel="m_PageScroll2id">link</a>`) and a section with such an id exists in your page (e.g. `<div id="id">target</div>`).
|
84 |
+
|
85 |
+
= The page doesn't scroll exactly where I want =
|
86 |
|
87 |
+
The scroll-to position is the top position of your target element. Your target's top position does not include its margins, so make sure to check your element's actual position via your browser's developer tools and change your CSS if needed. You can also offset the scroll-to position by setting an `offset` value (in pixels) in plugin's settings.
|
88 |
+
|
89 |
+
= The page doesn't scroll to the very top =
|
90 |
+
|
91 |
+
Your target element is probably not at the very top (check its position via your browser's developer tools). If your link has href value `#top` and no target with id `top` exists in your page, the plugin will automatically scroll the page to the very top (the position of the `body` tag).
|
92 |
+
|
93 |
+
= Can I use the plugin to scroll an overflowed div? =
|
94 |
+
|
95 |
+
No. The plugin scrolls the entire page (the document's root element) so it works correctly highlighting links, alongside deep linking plugins etc. with mouse and touch events.
|
96 |
+
|
97 |
+
= Do you support Internet Explorer 7? =
|
98 |
+
|
99 |
+
No. IE7 usage is non-existent.
|
100 |
+
|
101 |
+
= Does the plugin offer user defined callbacks, scroll-to method or some other advanced feature? =
|
102 |
+
|
103 |
+
Yes but you probably need to implement the plugin in your theme **manually**. See [Plugin homepage](http://manos.malihu.gr/page-scroll-to-id/) for more info.
|
104 |
+
|
105 |
+
== Screenshots ==
|
106 |
+
|
107 |
+
1. Page scoll to id settings
|
108 |
+
|
109 |
+
2. Page scoll to id settings help
|
110 |
+
|
111 |
+
== Changelog ==
|
112 |
+
|
113 |
+
= 1.5.0 =
|
114 |
+
* Dropped jQuery UI dependency (jQuery UI is no longer required for the plugin to work).
|
115 |
+
* Fixed the bug of non-working links to other pages. The script now checks if href values refer to the parent document, before preventing the default behavior.
|
116 |
+
* Fixed the bug regarding selectors referencing body class not working.
|
117 |
+
* Any link handled by the plugin with href value `#top` will now scroll the page to top, if no element with id `top` exists.
|
118 |
+
* Added links highlighting feature. The script adds a class (default: `mPS2id-highlight`) automatically on links whose target elements are considered to be within the viewport.
|
119 |
+
* Plugin adds a class (default: `mPS2id-target`) automatically on targets that are considered to be within the viewport.
|
120 |
+
* Plugin adds a class (default: `mPS2id-clicked`) automatically on the link that has been clicked.
|
121 |
+
* Added `offset` option: Offsets scroll-to position by x amount of pixels (positive or negative).
|
122 |
+
* The plugin script now fully validates href values and ids before scrolling the page.
|
123 |
+
* Fixed varius minor bugs.
|
124 |
+
* Code rewritten and optimized for better performance and maintenance.
|
125 |
+
* For more see [Plugin changelog](http://manos.malihu.gr/page-scroll-to-id/4/).
|
126 |
+
|
127 |
+
= 1.2.0 =
|
128 |
+
* Added support for jQuery version 1.9.
|
129 |
+
|
130 |
+
= 1.1.0 =
|
131 |
+
* Removed the hard-coded plugin directory URL in order to fix errors of pointing .js files to a wrong location.
|
132 |
+
|
133 |
+
= 1.0.0 =
|
134 |
+
* Launch!
|
135 |
+
|
136 |
+
== Upgrade Notice ==
|
137 |
+
|
138 |
+
= 1.5.0 =
|
139 |
+
|
140 |
+
Dropped jQuery UI dependency, fixed bugs, added links highlighting, optimized scripts and extended documentation.
|
141 |
+
|
142 |
+
== License ==
|
143 |
|
144 |
GPLv3
|
145 |
|
150 |
|
151 |
== Donate ==
|
152 |
|
153 |
+
If you like this plugin and find it useful, consider making a [donation](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UYJ5G65M6ZA28) :).
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
uninstall.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if(!defined('WP_UNINSTALL_PLUGIN'))
|
3 |
+
exit();
|
4 |
+
|
5 |
+
// --edit--
|
6 |
+
$opt1='page_scroll_to_id_instances';
|
7 |
+
$opt2='page_scroll_to_id_version';
|
8 |
+
|
9 |
+
if(!is_multisite()){
|
10 |
+
// Single site --edit--
|
11 |
+
delete_option($opt1);
|
12 |
+
delete_option($opt2);
|
13 |
+
}else{
|
14 |
+
// Multisite
|
15 |
+
global $wpdb;
|
16 |
+
$blog_ids=$wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
|
17 |
+
$original_blog_id=get_current_blog_id();
|
18 |
+
foreach($blog_ids as $blog_id){
|
19 |
+
switch_to_blog($blog_id);
|
20 |
+
// --edit--
|
21 |
+
delete_site_option($opt1);
|
22 |
+
delete_site_option($opt2);
|
23 |
+
}
|
24 |
+
switch_to_blog($original_blog_id);
|
25 |
+
}
|
26 |
+
?>
|