Version Description
Download this release
Release Info
Developer | sksmatt |
Plugin | Dynamic "To Top" Plugin |
Version | 2.0 |
Comparing to | |
See all releases |
Version 2.0
- css/img/ui.totop.png +0 -0
- css/ui.totop.css +30 -0
- dynamic-to-top.php +164 -0
- js/jquery.ui.totop.js +62 -0
- readme.txt +30 -0
- screenshot-1.jpg +0 -0
css/img/ui.totop.png
ADDED
Binary file
|
css/ui.totop.css
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#toTop {
|
2 |
+
display:none;
|
3 |
+
text-decoration:none;
|
4 |
+
position:fixed;
|
5 |
+
bottom:10px;
|
6 |
+
right:10px;
|
7 |
+
overflow:hidden;
|
8 |
+
width:51px;
|
9 |
+
height:51px;
|
10 |
+
border:none;
|
11 |
+
text-indent:-999px;
|
12 |
+
background:url(img/ui.totop.png) no-repeat left top;
|
13 |
+
}
|
14 |
+
|
15 |
+
#toTopHover {
|
16 |
+
background:url(img/ui.totop.png) no-repeat left -51px;
|
17 |
+
width:51px;
|
18 |
+
height:51px;
|
19 |
+
display:block;
|
20 |
+
overflow:hidden;
|
21 |
+
float:left;
|
22 |
+
opacity: 0;
|
23 |
+
-moz-opacity: 0;
|
24 |
+
filter:alpha(opacity=0);
|
25 |
+
}
|
26 |
+
|
27 |
+
#toTop:active, #toTop:focus
|
28 |
+
{
|
29 |
+
outline:none;
|
30 |
+
}
|
dynamic-to-top.php
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Dynamic To Top
|
4 |
+
Plugin URI: http://www.mattvarone.com
|
5 |
+
Description: Adds an automatic and dynamic "To Top" button to scroll long pages back to the top.
|
6 |
+
Author: Matt Varone
|
7 |
+
Version: 2.0
|
8 |
+
Author URI: http://www.mattvarone.com
|
9 |
+
*/
|
10 |
+
|
11 |
+
if (!class_exists("DynamicToTop")) {
|
12 |
+
class DynamicToTop {
|
13 |
+
public $options;
|
14 |
+
|
15 |
+
function DynamicToTop()
|
16 |
+
{
|
17 |
+
if ( !defined( 'WP_CONTENT_URL' ) )
|
18 |
+
define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
|
19 |
+
if ( !defined( 'WP_CONTENT_DIR' ) )
|
20 |
+
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
|
21 |
+
if ( !defined( 'WP_PLUGIN_URL' ) )
|
22 |
+
define('WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
|
23 |
+
if ( !defined( 'WP_PLUGIN_DIR' ) )
|
24 |
+
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
|
25 |
+
|
26 |
+
define( DYNAMIC_TO_TOP, WP_PLUGIN_DIR . '/dynamic-to-top' );
|
27 |
+
define( DYNAMIC_TO_TOP_URL, WP_PLUGIN_URL . '/dynamic-to-top' );
|
28 |
+
|
29 |
+
$this->options = array( 'speed' => 1000, 'distance' => 200, 'easing' => 'easeInOutExpo', 'text_version' => 'no', 'text' => 'To Top');
|
30 |
+
|
31 |
+
$options_db = get_option('dynamic_to_top');
|
32 |
+
if (empty($options_db))
|
33 |
+
update_option('dynamic_to_top', $this->options);
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
function create_menu()
|
38 |
+
{
|
39 |
+
add_options_page('Dynamic To Top', 'Dynamic To Top', 10, 'dynamic_to_top', array($this,'options_page'));
|
40 |
+
}
|
41 |
+
|
42 |
+
function options_page()
|
43 |
+
{
|
44 |
+
$option = get_option('dynamic_to_top');
|
45 |
+
?>
|
46 |
+
<div class="wrap">
|
47 |
+
<div id="icon-options-general" class="icon32"><br /></div>
|
48 |
+
<h2>Dynamic To Top Settings</h2>
|
49 |
+
|
50 |
+
<p>Welcome to the Dynamic To Top plugin settings. Click <a href="http://www.mattvarone.com/wordpress/dynamic-to-top-wordpress-plugin/" target="_blank">here</a> to learn more about this plugin. <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5061646" title="Donations are welcome" target="_blank">Donations are welcome</a>.</p>
|
51 |
+
|
52 |
+
<form method="post" action="options-general.php?page=dynamic_to_top">
|
53 |
+
|
54 |
+
<table class="form-table">
|
55 |
+
<tr valign="top">
|
56 |
+
<th scope="row"><label><strong>Scroll Time</strong> <small>( miliseconds )</small></label></th>
|
57 |
+
<td><input type="text" value="<?php echo $option['speed']; ?>" name="dynamic_to_top[speed]" class="regular-text" /></td>
|
58 |
+
</tr>
|
59 |
+
<tr valign="top">
|
60 |
+
<th scope="row"><label><strong>Fade-in distance</strong> <small>( pixels )</small></label></th>
|
61 |
+
<td><input type="text" value="<?php echo $option['distance']; ?>" name="dynamic_to_top[distance]" class="regular-text" /></td>
|
62 |
+
</tr>
|
63 |
+
<tr valign="top">
|
64 |
+
<th scope="row"><label><strong>Easing</strong></label></th>
|
65 |
+
<td><select name="dynamic_to_top[easing]">
|
66 |
+
<?php
|
67 |
+
|
68 |
+
$easing_types = array( 'linear', 'easeInQuad', 'easeOutQuad', 'easeInOutQuad', 'easeInExpo', 'easeOutExpo', 'easeInOutExpo', 'easeInBack', 'easeOutBack', 'easeInOutBack' );
|
69 |
+
foreach ( $easing_types as $type )
|
70 |
+
{
|
71 |
+
$selected = "";
|
72 |
+
if ( $option['easing'] == $type) $selected = 'selected="selected"';
|
73 |
+
|
74 |
+
echo '<option value="'.$type.'" '.$selected.' >'.$type.'</option>';
|
75 |
+
|
76 |
+
}
|
77 |
+
?>
|
78 |
+
</select></td>
|
79 |
+
</tr>
|
80 |
+
<tr valign="top">
|
81 |
+
<th scope="row"><label><strong>Text version</strong></label></th>
|
82 |
+
<td><input type="checkbox" value="yes" name="dynamic_to_top[text_version]" <?php if ( $option['text_version'] == 'yes' ) echo 'checked="checked"'; ?> />
|
83 |
+
</td>
|
84 |
+
</tr>
|
85 |
+
<tr valign="top">
|
86 |
+
<th scope="row"><label><strong>Button Text</strong></label></th>
|
87 |
+
<td><input type="text" value="<?php echo $option['text']; ?>" name="dynamic_to_top[text]" class="regular-text" /></td>
|
88 |
+
</tr>
|
89 |
+
</table>
|
90 |
+
|
91 |
+
<p class="submit">
|
92 |
+
<input type="submit" name="Submit" class="button-primary" value="Save Changes" />
|
93 |
+
</p>
|
94 |
+
</form>
|
95 |
+
|
96 |
+
<p><small><strong>Dynamic To Top plugin</strong> brought to you by <a href="http://www.mattvarone.com" title="Matt Varone" target="_blank"><strong>Matt Varone</strong></a>.</small>
|
97 |
+
</p>
|
98 |
+
</div>
|
99 |
+
<?php
|
100 |
+
}
|
101 |
+
|
102 |
+
function print_js()
|
103 |
+
{
|
104 |
+
$option = get_option("dynamic_to_top");
|
105 |
+
$out = "<script type=\"text/javascript\">jQuery().ready(function() { jQuery('body').UItoTop({ text: '".$option['text']."', min: ".$option['distance'].", scrollSpeed: ".$option['speed'].", easingType: '".$option['easing']."'}); });</script>\n";
|
106 |
+
echo $out;
|
107 |
+
}
|
108 |
+
|
109 |
+
function save_settings($data)
|
110 |
+
{
|
111 |
+
|
112 |
+
$option_values = array();
|
113 |
+
|
114 |
+
foreach ( $this->options as $option_name => $option_value )
|
115 |
+
{
|
116 |
+
|
117 |
+
if ($data[$option_name] == '')
|
118 |
+
{
|
119 |
+
if ( $option_name == 'text_version' )
|
120 |
+
$option_values['text_version'] = "no";
|
121 |
+
continue;
|
122 |
+
}
|
123 |
+
else { $option_values[$option_name] = $data[$option_name]; }
|
124 |
+
}
|
125 |
+
|
126 |
+
update_option('dynamic_to_top', $option_values);
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
+
}
|
131 |
+
|
132 |
+
}
|
133 |
+
|
134 |
+
$dynamic_to_top = new DynamicToTop();
|
135 |
+
|
136 |
+
if (isset($dynamic_to_top)) {
|
137 |
+
|
138 |
+
if ( !is_admin() )
|
139 |
+
{
|
140 |
+
|
141 |
+
$option = get_option("dynamic_to_top");
|
142 |
+
|
143 |
+
if ( trim($option['text_version']) == "yes")
|
144 |
+
wp_enqueue_style( 'dynamic-to-top', DYNAMIC_TO_TOP_URL . '/css/ui.totop.text.css', false, 1.0, 'all' );
|
145 |
+
else
|
146 |
+
wp_enqueue_style( 'dynamic-to-top', DYNAMIC_TO_TOP_URL . '/css/ui.totop.css', false, 1.0, 'all' );
|
147 |
+
|
148 |
+
wp_enqueue_script( 'dynamic-to-top', DYNAMIC_TO_TOP_URL . '/js/jquery.ui.totop.js', array('jquery'), 1.1, true );
|
149 |
+
|
150 |
+
if ( $option['easing'] != "linear")
|
151 |
+
wp_enqueue_script( 'jquery-easing', DYNAMIC_TO_TOP_URL . '/js/jquery.easing.1.3.js', array('jquery'), 1.3, true );
|
152 |
+
|
153 |
+
add_action('wp_footer', array($dynamic_to_top,'print_js'));
|
154 |
+
|
155 |
+
}
|
156 |
+
|
157 |
+
add_action('admin_menu', array($dynamic_to_top,'create_menu'));
|
158 |
+
|
159 |
+
if (isset($_POST['dynamic_to_top'])) {
|
160 |
+
$dynamic_to_top->save_settings($_POST['dynamic_to_top']);
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
|
js/jquery.ui.totop.js
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
|--------------------------------------------------------------------------
|
3 |
+
| UItoTop jQuery Plugin ver 1.1
|
4 |
+
| http://www.mattvarone.com/web-design/uitotop-jquery-plugin/
|
5 |
+
| By Matt Varone.
|
6 |
+
| Thanks to Remy Tourbiez
|
7 |
+
|--------------------------------------------------------------------------
|
8 |
+
*/
|
9 |
+
|
10 |
+
(function(jQuery){
|
11 |
+
jQuery.fn.UItoTop = function(options) {
|
12 |
+
|
13 |
+
var defaults = {
|
14 |
+
text: 'To Top',
|
15 |
+
min: 200,
|
16 |
+
inDelay:600,
|
17 |
+
outDelay:400,
|
18 |
+
containerID: 'toTop',
|
19 |
+
containerHoverID: 'toTopHover',
|
20 |
+
scrollSpeed: 1200,
|
21 |
+
easingType: 'linear'
|
22 |
+
};
|
23 |
+
|
24 |
+
var settings = jQuery.extend(defaults, options);
|
25 |
+
var containerIDhash = '#'+settings.containerID;
|
26 |
+
var containerHoverIDHash = '#'+settings.containerHoverID;
|
27 |
+
|
28 |
+
jQuery('body').append('<a href="#" id="'+settings.containerID+'">'+settings.text+'</a>');
|
29 |
+
jQuery(containerIDhash).hide().click(function(){
|
30 |
+
jQuery('html, body').animate({scrollTop:0}, settings.scrollSpeed, settings.easingType);
|
31 |
+
jQuery('#'+settings.containerHoverID, this).stop().animate({'opacity': 0 }, settings.Outdelay, settings.easingType);
|
32 |
+
return false;
|
33 |
+
})
|
34 |
+
.prepend('<span id="'+settings.containerHoverID+'"></span>')
|
35 |
+
.hover(function() {
|
36 |
+
jQuery(containerHoverIDHash, this).stop().animate({
|
37 |
+
'opacity': 1
|
38 |
+
}, 600, 'linear');
|
39 |
+
}, function() {
|
40 |
+
jQuery(containerHoverIDHash, this).stop().animate({
|
41 |
+
'opacity': 0
|
42 |
+
}, 700, 'linear');
|
43 |
+
});
|
44 |
+
|
45 |
+
jQuery(window).scroll(function() {
|
46 |
+
var sd = jQuery(window).scrollTop();
|
47 |
+
if(typeof document.body.style.maxHeight === "undefined") {
|
48 |
+
jQuery(containerIDhash).css({
|
49 |
+
'position': 'absolute',
|
50 |
+
'top': jQuery(window).scrollTop() + jQuery(window).height() - 50
|
51 |
+
});
|
52 |
+
}
|
53 |
+
if ( sd > settings.min )
|
54 |
+
jQuery(containerIDhash).fadeIn(settings.inDelay);
|
55 |
+
else
|
56 |
+
jQuery(containerIDhash).fadeOut(settings.Outdelay);
|
57 |
+
});
|
58 |
+
|
59 |
+
};
|
60 |
+
})(jQuery);
|
61 |
+
|
62 |
+
jQuery().ready(function() { jQuery().UItoTop(); });
|
readme.txt
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Dynamic "To Top" Plugin ===
|
2 |
+
Contributors: sksmatt
|
3 |
+
Donate link: http://www.mattvarone.com
|
4 |
+
Tags: Dynamic, UI, Scroll, To top
|
5 |
+
Requires at least: 2.5
|
6 |
+
Tested up to: 2.9.2
|
7 |
+
Stable tag: 2.0
|
8 |
+
|
9 |
+
Adds an automatic and dynamic "To Top" button to easily scroll long pages back to the top.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
This plugin for WordPress adds an automatic and dynamic "To Top" button to easily scroll long pages back to the top.
|
14 |
+
|
15 |
+
Based on [UiTotop jQuery Plugin](http://www.mattvarone.com/web-design/uitotop-jquery-plugin/ "UiTotop jQuery Plugin").
|
16 |
+
|
17 |
+
\* Thanks to Remy Tourbiez for his contributions.
|
18 |
+
|
19 |
+
== Installation ==
|
20 |
+
|
21 |
+
1. Unzip files
|
22 |
+
2. Upload "dynamic-to-top" folder into your plugins directory.
|
23 |
+
3. Activate the plugin.
|
24 |
+
4. Configure settings to your needs.
|
25 |
+
5. Have fun!
|
26 |
+
|
27 |
+
== Screenshots ==
|
28 |
+
|
29 |
+
1. Dynamic To Top plugin in action.
|
30 |
+
2. Dynamic To Top settings page.
|
screenshot-1.jpg
ADDED
Binary file
|