Easy Smooth Scroll Links - Version 1.0

Version Description

*First Version

=

Download this release

Release Info

Developer Jeriff Cheng
Plugin Icon 128x128 Easy Smooth Scroll Links
Version 1.0
Comparing to
See all releases

Version 1.0

easy_smooth_scroll_links.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ /*Easy Smooth Scroll Links,Plugin URI: http://www.92app.com/wordpress-plugins/easy-smooth-scroll-links*/
2
+ var ss={fixAllLinks:function(){var allLinks=document.getElementsByTagName('a');for(var i=0;i<allLinks.length;i++){var lnk=allLinks[i];if((lnk.href&&lnk.href.indexOf('#')!=-1)&&((lnk.pathname==location.pathname)||('/'+lnk.pathname==location.pathname))&&(lnk.search==location.search)){ss.addEvent(lnk,'click',ss.smoothScroll);}}},smoothScroll:function(e){if(window.event){target=window.event.srcElement;}else if(e){target=e.target;}else return;if(target.nodeName.toLowerCase()!='a'){target=target.parentNode;}
3
+ if(target.nodeName.toLowerCase()!='a')return;anchor=target.hash.substr(1);var allLinks=document.getElementsByTagName('a');var destinationLink=null;for(var i=0;i<allLinks.length;i++){var lnk=allLinks[i];if(lnk.name&&(lnk.name==anchor)){destinationLink=lnk;break;}}
4
+ if(!destinationLink)destinationLink=document.getElementById(anchor);if(!destinationLink)return true;var destx=destinationLink.offsetLeft;var desty=destinationLink.offsetTop;var thisNode=destinationLink;while(thisNode.offsetParent&&(thisNode.offsetParent!=document.body)){thisNode=thisNode.offsetParent;destx+=thisNode.offsetLeft;desty+=thisNode.offsetTop;}
5
+ clearInterval(ss.INTERVAL);cypos=ss.getCurrentYPos();ss_stepsize=parseInt((desty-cypos)/ss.STEPS);ss.INTERVAL=setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);if(window.event){window.event.cancelBubble=true;window.event.returnValue=false;}
6
+ if(e&&e.preventDefault&&e.stopPropagation){e.preventDefault();e.stopPropagation();}},scrollWindow:function(scramount,dest,anchor){wascypos=ss.getCurrentYPos();isAbove=(wascypos<dest);window.scrollTo(0,wascypos+scramount);iscypos=ss.getCurrentYPos();isAboveNow=(iscypos<dest);if((isAbove!=isAboveNow)||(wascypos==iscypos)){window.scrollTo(0,dest);clearInterval(ss.INTERVAL);location.hash=anchor;}},getCurrentYPos:function(){if(document.body&&document.body.scrollTop)
7
+ return document.body.scrollTop;if(document.documentElement&&document.documentElement.scrollTop)
8
+ return document.documentElement.scrollTop;if(window.pageYOffset)
9
+ return window.pageYOffset;return 0;},addEvent:function(elm,evType,fn,useCapture){if(elm.addEventListener){elm.addEventListener(evType,fn,useCapture);return true;}else if(elm.attachEvent){var r=elm.attachEvent("on"+evType,fn);return r;}else{alert("Handler could not be removed");}}}
10
+ ss.STEPS=25;ss.addEvent(window,"load",ss.fixAllLinks);
easy_smooth_scroll_links.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Easy Smooth Scroll Links
4
+ Plugin URI: http://www.92app.com/wordpress-plugins/easy-smooth-scroll-links
5
+ Description:Adds smoth scrolling effect to links that link to other parts of the page,which are called "Page Anchors".Extremely useful for setting up a menu which can send you to different section of a post.
6
+ Version: 1.0
7
+ Author: Jeriff Cheng
8
+ Author URI: http://www.92app.com/
9
+ */
10
+
11
+ /*
12
+ Copyright 2011 Jeriff Cheng(Email:hschengyongtao@gmail.com)
13
+
14
+ This program is free software: you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation, either version 3 of the License, or
17
+ (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
26
+
27
+ */
28
+
29
+ //add anchor button to visual editor
30
+ if ( ! function_exists('enable_anchor_button') ) {
31
+ function enable_anchor_button($buttons) {
32
+ $buttons[] = 'anchor';
33
+ return $buttons;
34
+ }
35
+ add_filter("mce_buttons_2", "enable_anchor_button");
36
+ }
37
+
38
+ //add required js
39
+ if ( ! function_exists('add_smooth_scroll_links_js') ) {
40
+ function add_smooth_scroll_links_js() {
41
+ ?>
42
+ <script type="text/javascript" src="<?php echo get_option('siteurl') . '/' . PLUGINDIR . '/' . dirname(plugin_basename (__FILE__))?>/easy_smooth_scroll_links.js"></script>
43
+ <?php
44
+ }
45
+ add_action(wp_footer,add_smooth_scroll_links_js,20);
46
+ }
readme.txt ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Easy Smooth Scroll Links ===
2
+ Contributors: Jeriff Cheng
3
+ Donate link: http://www.92app.com
4
+ Tags:anchor,anchor text,links,link,smooth scroll links,scroll,smooth scroll
5
+ Requires at least: 2.6.5
6
+ Tested up to: 3.2.1
7
+
8
+ == Description ==
9
+ Easy Smooth Scroll Links adds smooth scrolling effect to links that link to other parts of the page,which are called "Page Anchors". This plugin will enable you to easily create Page Anchors and add smooth scrolling effect to links that point to Page Anchors,instead of "jumping" to them. Easy Smooth Scroll Links WordPress Plugin is extremely useful for setting up a menu which can send you to different sections of a post.
10
+
11
+ For more information,refer to <a title="Easy Smooth Scroll Links WordPress Plugin" href="http://www.92app.com/wordpress-plugins/easy-smooth-scroll-links" target="_blank">Easy Smooth Scroll Links WordPress Plugin</a>
12
+
13
+ My personal blog:<a href="http://www.92app.com" target="_blank">www.92app.com</a>
14
+
15
+ == Installation ==
16
+ 1. Upload the full directory into your wp-content/plugins directory
17
+ 2. Activate the plugin at the plugin administration page
18
+ 3. That's it!
19
+
20
+ == Frequently Asked Questions ==
21
+ For FAQs and bug report,refer to <a title="Easy Smooth Scroll Links WordPress Plugin" href="http://www.92app.com/wordpress-plugins/easy-smooth-scroll-links" target="_blank">Easy Smooth Scroll Links WordPress Plugin</a>
22
+
23
+ == Screenshots ==
24
+
25
+ 1. Set up an anchor
26
+ 2. Link to an anchor
27
+
28
+ == Changelog ==
29
+
30
+ = 1.0 =
31
+ *First Version
32
+
33
+ == Upgrade Notice ==
34
+ soon...
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file