forked from fatrex/jquery-goup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.goup.min.js
10 lines (10 loc) · 3.22 KB
/
jquery.goup.min.js
1
2
3
4
5
6
7
8
9
10
/*
*
* Copyright (c) 2014-2016 Daniele Lenares (https://github.com/Ryuk87)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* Version 1.1.0
*
*/
!function(t){"use strict";function e(t,e,i){if("show"==e)switch(i){case"fade":t.fadeIn();break;case"slide":t.slideDown();break;default:t.fadeIn()}else switch(i){case"fade":t.fadeOut();break;case"slide":t.slideUp();break;default:t.fadeOut()}}function i(e,i){var o=!0;e.on("click",function(){1==o&&(o=!1,t("html, body").animate({scrollTop:0},i,function(){o=!0}))})}t.goup=function(o){var n=t.extend({location:"right",locationOffset:20,bottomOffset:10,containerSize:40,containerRadius:10,containerClass:"goup-container",arrowClass:"goup-arrow",alwaysVisible:!1,trigger:500,entryAnimation:"fade",goupSpeed:"slow",hideUnderWidth:500,containerColor:"#000",arrowColor:"#fff",title:"",titleAsText:!1,titleAsTextClass:"goup-text",zIndex:1},o);"right"!=n.location&&"left"!=n.location&&(n.location="right"),n.locationOffset<0&&(n.locationOffset=0),n.bottomOffset<0&&(n.bottomOffset=0),n.containerSize<20&&(n.containerSize=20),n.containerRadius<0&&(n.containerRadius=0),n.trigger<0&&(n.trigger=0),n.hideUnderWidth<0&&(n.hideUnderWidth=0);var r=/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i;r.test(n.containerColor)||(n.containerColor="#000"),r.test(n.arrowColor)||(n.arrowColor="#fff"),""===n.title&&(n.titleAsText=!1),isNaN(n.zIndex)&&(n.zIndex=1);var a=t("body"),s=t(window),d=t("<div>");d.addClass(n.containerClass);var l=t("<div>");l.addClass(n.arrowClass),d.html(l),a.append(d);var c={position:"fixed",width:n.containerSize,height:n.containerSize,background:n.containerColor,cursor:"pointer",display:"none","z-index":n.zIndex};if(c.bottom=n.bottomOffset,c[n.location]=n.locationOffset,c["border-radius"]=n.containerRadius,d.css(c),n.titleAsText){var f=t("<div>");a.append(f),f.addClass(n.titleAsTextClass).text(n.title),f.attr("style",d.attr("style")),f.css("background","transparent").css("width",n.containerSize+40).css("height","auto").css("text-align","center").css(n.location,n.locationOffset-20);var h=parseInt(f.height())+10,p=parseInt(d.css("bottom")),u=h+p;d.css("bottom",u)}else d.attr("title",n.title);var g=.25*n.containerSize,y={width:0,height:0,margin:"0 auto","padding-top":Math.ceil(.325*n.containerSize),"border-style":"solid","border-width":"0 "+g+"px "+g+"px "+g+"px","border-color":"transparent transparent "+n.arrowColor+" transparent"};l.css(y);var w=!1;s.resize(function(){s.outerWidth()<=n.hideUnderWidth?(w=!0,e(d,"hide",n.entryAnimation),"undefined"!=typeof f&&e(f,"hide",n.entryAnimation)):(w=!1,s.trigger("scroll"))}),s.outerWidth()<=n.hideUnderWidth&&(w=!0,d.hide(),"undefined"!=typeof f&&f.hide()),n.alwaysVisible?(e(d,"show",n.entryAnimation),"undefined"!=typeof f&&e(f,"show",n.entryAnimation)):s.scroll(function(){s.scrollTop()>=n.trigger&&!w&&(e(d,"show",n.entryAnimation),"undefined"!=typeof f&&e(f,"show",n.entryAnimation)),s.scrollTop()<n.trigger&&!w&&(e(d,"hide",n.entryAnimation),"undefined"!=typeof f&&e(f,"hide",n.entryAnimation))}),s.scrollTop()>=n.trigger&&!w&&(e(d,"show",n.entryAnimation),"undefined"!=typeof f&&e(f,"show",n.entryAnimation)),i(d,n.goupSpeed),"undefined"!=typeof f&&i(f,n.goupSpeed)}}(jQuery);