diff options
author | thingsym <thingsym@gmail.com> | 2019-10-06 09:32:04 +0300 |
---|---|---|
committer | thingsym <thingsym@gmail.com> | 2019-10-06 09:32:04 +0300 |
commit | 4d55f8b8441460977f92f1a4c2b05a4130d40868 (patch) | |
tree | 21696feddd8728d2727bbc29fcc038bd60ff1f21 /src | |
parent | 2bfc1bf3d05d78f9578d97288b77c9d6d2034bfb (diff) |
fix: move javascript files to src
Diffstat (limited to 'src')
-rw-r--r-- | src/js/functions.js | 22 | ||||
-rwxr-xr-x | src/js/jquery.backtothetop/jquery.backtothetop.js | 117 | ||||
-rwxr-xr-x | src/js/jquery.backtothetop/jquery.backtothetop.min.js | 12 |
3 files changed, 151 insertions, 0 deletions
diff --git a/src/js/functions.js b/src/js/functions.js new file mode 100644 index 0000000..4332b2c --- /dev/null +++ b/src/js/functions.js @@ -0,0 +1,22 @@ +jQuery(document).ready(function() { + jQuery(function() { + jQuery('.nav-prev').click(function(){ + location.href = jQuery(this).attr('href'); + }); + jQuery('.nav-next').click(function() { + location.href = jQuery(this).attr('href'); + }); + }); + + jQuery(document).keydown(function(e) { + // prev links - left arrow key + if(e.which == '37') { + jQuery('.nav.nav-prev').click(); + } + + // next links - right arrow key + if(e.which == '39') { + jQuery('.nav.nav-next').click(); + } + }); +}); diff --git a/src/js/jquery.backtothetop/jquery.backtothetop.js b/src/js/jquery.backtothetop/jquery.backtothetop.js new file mode 100755 index 0000000..77af2d2 --- /dev/null +++ b/src/js/jquery.backtothetop/jquery.backtothetop.js @@ -0,0 +1,117 @@ +(function($) { + $(window).on('load.BackToTheTop', function() { + $('a[href^="#"]').BackToTheTop(); + }); + + $.fn.BackToTheTop = function( options ) { + + var defaults = { + duration: 300, + easing: 'swing', + offset: 0, + hash: true, + scrolloffset: 0, + fadein: 'slow', + fadeout: 'slow', + display: 'bottom-right', + top: 0, + bottom: 0, + left: 0, + right: 0, + zIndex: 999, + position : 'fixed' + }; + + $.extend( defaults, options ); + + var init = function() { + $('a[href^="#"]').on('click.BackToTheTop', function() { + var scrollTop = + $(this).data('backtothetop-scrolltop') !== undefined ? $(this).data('backtothetop-scrolltop') + : $(this.hash).offset() ? $(this.hash).offset().top + : $(this).attr('id') == 'backtothetop-fixed' && $(this).attr('href') == '#' ? 0 + : null ; + + if (scrollTop === null) + return; + + var duration = typeof $(this).data('backtothetop-duration') === "undefined" ? defaults.duration : $(this).data('backtothetop-duration'); + var easing = typeof $(this).data('backtothetop-easing') === "undefined" ? defaults.easing : $(this).data('backtothetop-easing'); + var offset = typeof $(this).data('backtothetop-offset') === "undefined" ? defaults.offset : $(this).data('backtothetop-offset'); + var hash = typeof $(this).data('backtothetop-hash') === "undefined" ? defaults.hash : $(this).data('backtothetop-hash'); + var href = $(this).attr('href'); + + $('html,body').animate( + { 'scrollTop' : scrollTop + offset }, duration, easing, + function() { + if (hash === true) { + window.history.pushState('', '', href); + } + } + ); + + return false; + }); + }; + + var fixed = function() { + var elem = $('a#backtothetop-fixed'); + if ( !elem ) + return; + var scrollOffset = typeof elem.data('backtothetop-fixed-scroll-offset') === "undefined" ? defaults.scrolloffset : elem.data('backtothetop-fixed-scroll-offset'); + var fadeIn = typeof elem.data('backtothetop-fixed-fadein') === "undefined" ? defaults.fadein : elem.data('backtothetop-fixed-fadein'); + var fadeOut = typeof elem.data('backtothetop-fixed-fadeout') === "undefined" ? defaults.fadeout : elem.data('backtothetop-fixed-fadeout'); + var display = typeof elem.data('backtothetop-fixed-display') === "undefined" ? defaults.display : elem.data('backtothetop-fixed-display'); + var top = typeof elem.data('backtothetop-fixed-top') === "undefined" ? defaults.top : elem.data('backtothetop-fixed-top'); + var bottom = typeof elem.data('backtothetop-fixed-bottom') === "undefined" ? defaults.bottom : elem.data('backtothetop-fixed-bottom'); + var left = typeof elem.data('backtothetop-fixed-left') === "undefined" ? defaults.left : elem.data('backtothetop-fixed-left'); + var right = typeof elem.data('backtothetop-fixed-right') === "undefined" ? defaults.right : elem.data('backtothetop-fixed-right'); + var zindex = typeof elem.data('backtothetop-fixed-zindex') === "undefined" ? defaults.zIndex : elem.data('backtothetop-fixed-zindex'); + + if (display == 'top-left') { + bottom = 'none'; + right = 'none'; + } + else if (display == 'top-right') { + bottom = 'none'; + left = 'none'; + } + else if (display == 'bottom-left') { + top = 'none'; + right = 'none'; + } + else if (display == 'bottom-right') { + top = 'none'; + left = 'none'; + } + + elem.css({ 'display' : 'none' }); + + $(window).on('scroll.BackToTheTop', function () { + if ($(this).scrollTop() > scrollOffset) { + elem.css({ + 'top' : top, + 'bottom' : bottom, + 'left' : left, + 'right' : right, + 'zIndex' : zindex, + 'position' : defaults.position + }); + + if (elem.css('display') == 'none' ) { + elem.fadeIn(fadeIn); + } + + } + else if ($(this).scrollTop() <= 0 + scrollOffset) { + if (elem.css('display') != 'none' ) { + elem.fadeOut(fadeOut); + } + } + }); + }; + + init(); + fixed(); + }; +})(jQuery); diff --git a/src/js/jquery.backtothetop/jquery.backtothetop.min.js b/src/js/jquery.backtothetop/jquery.backtothetop.min.js new file mode 100755 index 0000000..4f3249f --- /dev/null +++ b/src/js/jquery.backtothetop/jquery.backtothetop.min.js @@ -0,0 +1,12 @@ +/*! + * jQuery Plugin Back to the Top + * Version 1.1.7 + * Update: 2017-05-06 11:14:36 + * Copyright 2017 thingsym + * URI: + * Repository: https://github.com/thingsym/jquery.backtothetop + * License: Dual licensed under the MIT and GPLv2 licenses. + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl-2.0.html +*/ +!function(t){t(window).on("load.BackToTheTop",function(){t('a[href^="#"]').BackToTheTop()}),t.fn.BackToTheTop=function(o){var a={duration:300,easing:"swing",offset:0,hash:!0,scrolloffset:0,fadein:"slow",fadeout:"slow",display:"bottom-right",top:0,bottom:0,left:0,right:0,zIndex:999,position:"fixed"};t.extend(a,o);!function(){t('a[href^="#"]').on("click.BackToTheTop",function(){var o=void 0!==t(this).data("backtothetop-scrolltop")?t(this).data("backtothetop-scrolltop"):t(this.hash).offset()?t(this.hash).offset().top:"backtothetop-fixed"==t(this).attr("id")&&"#"==t(this).attr("href")?0:null;if(null!==o){var e=void 0===t(this).data("backtothetop-duration")?a.duration:t(this).data("backtothetop-duration"),i=void 0===t(this).data("backtothetop-easing")?a.easing:t(this).data("backtothetop-easing"),d=void 0===t(this).data("backtothetop-offset")?a.offset:t(this).data("backtothetop-offset"),h=void 0===t(this).data("backtothetop-hash")?a.hash:t(this).data("backtothetop-hash"),f=t(this).attr("href");return t("html,body").animate({scrollTop:o+d},e,i,function(){!0===h&&window.history.pushState("","",f)}),!1}})}(),function(){var o=t("a#backtothetop-fixed");if(o){var e=void 0===o.data("backtothetop-fixed-scroll-offset")?a.scrolloffset:o.data("backtothetop-fixed-scroll-offset"),i=void 0===o.data("backtothetop-fixed-fadein")?a.fadein:o.data("backtothetop-fixed-fadein"),d=void 0===o.data("backtothetop-fixed-fadeout")?a.fadeout:o.data("backtothetop-fixed-fadeout"),h=void 0===o.data("backtothetop-fixed-display")?a.display:o.data("backtothetop-fixed-display"),f=void 0===o.data("backtothetop-fixed-top")?a.top:o.data("backtothetop-fixed-top"),n=void 0===o.data("backtothetop-fixed-bottom")?a.bottom:o.data("backtothetop-fixed-bottom"),s=void 0===o.data("backtothetop-fixed-left")?a.left:o.data("backtothetop-fixed-left"),c=void 0===o.data("backtothetop-fixed-right")?a.right:o.data("backtothetop-fixed-right"),p=void 0===o.data("backtothetop-fixed-zindex")?a.zIndex:o.data("backtothetop-fixed-zindex");"top-left"==h?(n="none",c="none"):"top-right"==h?(n="none",s="none"):"bottom-left"==h?(f="none",c="none"):"bottom-right"==h&&(f="none",s="none"),o.css({display:"none"}),t(window).on("scroll.BackToTheTop",function(){t(this).scrollTop()>e?(o.css({top:f,bottom:n,left:s,right:c,zIndex:p,position:a.position}),"none"==o.css("display")&&o.fadeIn(i)):t(this).scrollTop()<=0+e&&"none"!=o.css("display")&&o.fadeOut(d)})}}()}}(jQuery);
\ No newline at end of file |