/
jquerybar.min.js
25 lines (21 loc) · 13.7 KB
/
jquerybar.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*Copyright 2012 Jaspreet Chahal
http://jaspreetchahal.org/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Donations are welcome! or a purchase is appreciated if you are using it commercially
*/
jQuery.fn.jquerybar=function(e){var e,t,i,s,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C;function n(e){var r,i,t="_0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".split("");e||(e=Math.floor(Math.random()*t.length));r="";for(i=0;i<e;i++)r+=t[Math.floor(Math.random()*t.length)];return jQuery("#"+r).length==0?r:n(20)}function r(e){var t,n,r,i=document.cookie.split(";");for(t=0;t<i.length;t++){n=i[t].substr(0,i[t].indexOf("=")),r=i[t].substr(i[t].indexOf("=")+1),n=n.replace(/^\s+|\s+$/g,"");if(n==e)return unescape(r)}}function o(){if(jQuery("div.jcnotify-flipper").length<=1)return;jQuery("div.jcnotify-flipper").length==s&&(s=0),s==0&&jQuery("div.jcnotify-flipper").slideDown(),i=jQuery("div.jcnotify-flipper").eq(s),setTimeout(function(){i.slideUp(),s++,o()},e.notificationSlideInterval)}function k(t,n){(e.notificationAreaBorderAnimationWhenShown||n!=undefined)&&t.animate({borderTopColor:e.attentionSeekerColor,borderLeftColor:e.attentionSeekerColor,borderRightColor:e.attentionSeekerColor,borderBottomColor:e.attentionSeekerColor},1e3).animate({borderTopColor:e.notificationAreaBorderColor,borderLeftColor:e.notificationAreaBorderColor,borderRightColor:e.notificationAreaBorderColor,borderBottomColor:e.notificationAreaBorderColor},1e3)}function L(){e.hideAction=="hide"?($root.children(".jcnotify-hchild").hide(),$root.slideUp(500,function(){e.notificationAreaAdjustBodyMargins&&jQuery("body").css($bodyadjust_margins,parseInt(jQuery("body").css($bodyadjust_margins))-$containerOuterHeight+"px")})):(e.notificationAreaPosition=="fixed-bottom"?($bar.css("border-bottom","none"),$bar.css("border-radius","8px 8px 0px 0px "),$bar.find("img").attr("src","./imgs/up.png")):($bar.css("border-top","none"),$bar.css("border-radius","0px 0px 8px 8px"),$bar.find("img").attr("src","./imgs/down.png")),$root.animate({height:C},500,function(){}).animate({height:e.notificationAreaCollapsedHeight},500,function(){$root.children(".jcnotify-hchild").hide(),y=!0,$bar.slideDown(),e.notificationAreaAdjustBodyMargins&&jQuery("body").css($bodyadjust_margins,parseInt(jQuery("body").css($bodyadjust_margins))-$containerOuterHeight+"px")})),e.keepHiddenOnRefreshIfUserHides&&(document.cookie="jcnotify=no_load")}function A(){$root.animate({height:C},500,function(){y=!1,$bar.slideUp(),$root.children(".jcnotify-hchild").show(),O()}),e.notificationAreaAdjustBodyMargins&&jQuery("body").css($bodyadjust_margins,parseInt(jQuery("body").css($bodyadjust_margins))+$containerOuterHeight+"px")}function O(){e.hideSocialYoutubeLowResolutions&&(jQuery(".jcnotify-social").show(),$jcnotify_area1.show(),$jcnotify_area2.children().css("width","100%"),jQuery(window).width()<1e3&&jQuery(".jcnotify-social").hide(),jQuery(window).width()<800&&$jcnotify_area1.hide(),jQuery(window).width()<800&&jQuery(document).width()>400&&($jcnotify_area2.children().css("width","80%"),$jcnotify_area2.css("overflow","hidden")))}e=jQuery.extend({notificationAreaHeight:55,notificationAreaCollapsedHeight:10,notificationAreaCollapsedBarBackground:"#f1f1f1",notificationAreaPadding:10,notificationAreaBackground:"#6174c3",notificationAreaBorderSize:4,notificationAreaBorderColor:"#6174c3",notificationAreaBorderRadius:8,notificationAreaPosition:"fixed-top",notificationAreaShadow:!0,notificationAreaShadowColor:"#000",notificationAreaInitialDisplay:"delayed",notificationAreaDelay:2e3,notificationAreaBorderAnimationWhenShown:!0,notificationAreaEasing:"easeOutQuad",notificationAreaAutoHide:!1,notificationAreaAutoHideDelay:15e3,notificationAreaZIndex:999,hideAction:"collapse",keepHiddenOnRefreshIfUserHides:!1,attentionSeeker:!1,attentionSeekerColor:"#6174c3",notifications:[],links:[],linkTexts:[],linkOnNewLine:!0,notificationSlideInterval:5e3,notificationAreaAdjustBodyMargins:!0,textFontFamily:"Georgia,Times New Roman,Times,serif",textFontSize:14,textColor:"#FFF",textShadow:"none",textShadowColor:"#f1f1f1",linkFontFamily:"Georgia,Times New Roman,Times,serif",linkFontSize:11,linkPadding:5,linkBackground:"#c00",linkColor:"#ffffff",linkShadow:"none",linkShadowColor:"#f1f1f1",linkTextDecoration:"none",youtubeVideoCode:"",youtubeVideoWidth:180,youtubeVideoHeight:136,youtubeAutoPlay:!1,youtubeAllowFullScreen:!1,youtubePlayerControls:!0,includeSocial:!0,socialFollowFacebook:"",socialFollowTwitter:"",socialFollowLinkedin:"",socialFollowGoogleplus:"",socialFollowRss:"",hideSocialYoutubeLowResolutions:!0,showPoweredBy:!0},e);parseInt(e.notificationAreaHeight)<40&&(e.notificationAreaHeight=40);t=e.notificationAreaHeight,i=null,s=0;$bodyadjust_margins="margin-top";u=e.notificationAreaShadow?"box-shadow: 0px 0px 10px 1px"+e.notificationAreaShadowColor+";":"";e.notificationAreaShadow||(u="");a="position: fixed;top:0;left:0;right:0;border-top:none !important;",f="border-radius:0px 0px "+e.notificationAreaBorderRadius+"px "+e.notificationAreaBorderRadius+"px;";if(e.notificationAreaPosition=="fixed-bottom"||e.notificationAreaPosition=="document-bottom")f="border-radius:"+e.notificationAreaBorderRadius+"px "+e.notificationAreaBorderRadius+"px 0px 0px; ";parseInt(e.notificationAreaBorderRadius)==0&&(f=""),e.notificationAreaPosition=="fixed-bottom"?(a="position: fixed;bottom:0;left:0;right:0;border-bottom:none !important",$bodyadjust_margins="margin-bottom"):e.notificationAreaPosition=="document-bottom"?a="position: relative;bottom:0;left:0;right:0;border-bottom:none !important":e.notificationAreaPosition=="document-top"&&(a="position: absolute;top:0;left:0;right:0;border-top:none !important");l="",c=e.youtubeVideoCode,h=e.youtubeAllowFullScreen?"allowfullscreen":"",p=e.youtubeAutoPlay?"autoplay=1&":"",d=e.youtubePlayerControls?"controls=2&":"controls=0";c&&(l='<iframe style="margin:0 auto" width="'+e.youtubeVideoWidth+'" height="'+e.youtubeVideoHeight+'" src="http://www.youtube.com/embed/'+c+"?"+p+d+'" frameborder="0" '+h+" ></iframe>");v=n(),m="#"+v,g=jQuery('<div id="'+v+'" style="display:none;border-top:'+e.notificationAreaBorderSize+"px "+e.notificationAreaBorderColor+" solid;border-bottom:"+e.notificationAreaBorderSize+"px "+e.notificationAreaBorderColor+" solid;"+a+" z-index:"+e.notificationAreaZIndex+";height:"+e.notificationAreaHeight+"px;background-color: "+e.notificationAreaBackground+"; "+u+"width:100%;box-sizing: padding:0;margin:0;"+f+' ">'+'<div class="jcnotify-hchild jcnotify_area1" id="jcnotify_area1-'+v+'" style="width:20%;min-width:240px;float:left;box-sizing: border-box;text-align:center;position: relative;"><div style="padding:'+e.notificationAreaPadding+'px">'+l+"</div></div>"+'<div class="jcnotify-hchild jcnotify_area2" id="jcnotify_area2-'+v+'" style="width:60%;min-width:520px;float:left;box-sizing: border-box;position: relative;height:'+e.notificationAreaHeight+'px;overflow:hidden;text-align:center"></div>'+'<div class="jcnotify-hchild jcnotify_area3" id="jcnotify_area3-'+v+'" style="width:20%;max-width:250px;;max-height:'+(e.notificationAreaHeight-e.notificationAreaBorderSize)+'px;box-sizing: border-box;position: absolute;margin-bottom:3px;text-align:right"></div>'+'<div class="jcnotify-hchild" style="clear: both; "></div>'+'<div id="areajcnotify-bar-hidden" style="display: none;box-shadow:0px 1px 8px 1px #666;background: '+e.notificationAreaCollapsedBarBackground+";"+a+'border:1px solid; width:250px;margin:0 auto;cursor:pointer;height:18px; text-align:center;"><img src="./imgs/down.png"></div>'+"</div>").appendTo("body"),y=!1,b="";$root=jQuery(m),$jcnotify_area1=jQuery("#jcnotify_area1-"+v),$jcnotify_area2=jQuery("#jcnotify_area2-"+v),$jcnotify_area3=jQuery("#jcnotify_area3-"+v),$bar=jQuery("#areajcnotify-bar-hidden"),l.length>0?$root.css("height",e.youtubeVideoHeight+20+"px"):$jcnotify_area1.height(1),$containerOuterHeight=$root.outerHeight(!0)+20,e.notificationAreaAdjustBodyMargins&&jQuery("body").css($bodyadjust_margins,parseInt(jQuery("body").css($bodyadjust_margins))+$containerOuterHeight+parseInt($bar.height())+"px"),e.showPoweredBy&&$root.append('<div style="font-family: arial;font-size: 9px;color:#eee;text-align: right;height:9px;position:absolute;right:15px;bottom:-'+(parseInt(e.notificationAreaBorderSize)+9)+'px;">Powered by <a href="http://jaspreetchahal.org" style="color:#eee">jcnotify</a></div>');w="margin:0;padding:0;margin-top:3px;margin-right:5px; display:inline-block;height:21px;width:21px;background:#34b7eb;border:#1babe4 2px solid;border-radius:21px;text-align:center",E='<span id="areabtn-'+v+'" style="'+w+';width:21px;height:21px;float:right;background:#666;border:#666 2px solid;background-image: url(./imgs/buttons.png);background-position:0px 0px;cursor: pointer"> </span>';e.socialFollowTwitter.length>0&&(b+="<a href='"+e.socialFollowTwitter+"' target='_blank' style='"+w+"'><img style='border:none;width:20px;height:20px' src='./imgs/twitter_16.png'></a>"),e.socialFollowFacebook.length>0&&(b+="<a href='"+e.socialFollowFacebook+"' target='_blank' style='"+w+"'><img style='border:none;width:20px;height:20px' src='./imgs/facebook_16.png'></a>"),e.socialFollowGoogleplus.length>0&&(b+="<a href='"+e.socialFollowGoogleplus+"' target='_blank' style='"+w+"'><img style='border:none;width:20px;height:20px' src='./imgs/googleplus.png'></a>"),e.socialFollowLinkedin.length>0&&(b+="<a href='"+e.socialFollowLinkedin+"' target='_blank' style='"+w+"'><img style='border:none;width:20px;height:20px' src='./imgs/linkedin.png'></a>"),e.socialFollowRss.length>0&&(b+="<a href='"+e.socialFollowRss+"' target='_blank' style='"+w+"'><img style='border:none;width:20px;height:20px' src='./imgs/rss_16.png'></a>"),b.length>0&&(b="<span class='jcnotify-social' style='display:inline-block;float:left;margin-top:0px;'>"+b+"</span>"),e.includeSocial&&$root.find(".jcnotify_area3").prepend(b),$jcnotify_area3.append(E),$jcnotify_area3.css("margin-top",Math.floor(e.notificationAreaHeight/2)-25),$updownbutton=jQuery("#areabtn-"+v);S="",x="text-shadow:none",T="text-shadow:none";e.textShadow=="normal"?T="text-shadow: -1px -1px white, 1px 1px "+e.textShadowColor+";":e.textShadow=="indent"&&(T="text-shadow: 1px 1px white, -1px -1px "+e.textShadowColor+";"),e.linkShadow=="normal"?x="text-shadow: -1px -1px white, 1px 1px "+e.linkShadowColor+";":e.linkShadow=="indent"&&(x="text-shadow: 1px 1px white, -1px -1px "+e.linkShadowColor+";");N=e.linkOnNewLine?"<br>":"";jQuery.each(e.notifications,function(t,n){link=e.links[t],linktext=e.linkTexts[t],linktext||(linktext=link),link&&(link=N+'<a href="'+link+'" target="_blank" style="margin:3px 3px 3px 0px;display:inline-block;background:'+e.linkBackground+";border-radius:5px;padding:"+e.linkPadding+"px;position:relative;top:-1px;text-decoration:"+e.linkTextDecoration+";font-family: "+e.linkFontFamily+";font-size:"+e.linkFontSize+"px;color:"+e.linkColor+";"+x+'">'+linktext+"</a>"),S+="<div style='width:100%;text-align:center !important;height:"+e.notificationAreaHeight+"px;box-sizing: border-box;font-family: "+e.textFontFamily+";font-size:"+e.textFontSize+"px;color:"+e.textColor+";"+T+"' class='jcnotify-flipper'><table style='width:100%'><tr><td style='width:100%;text-align:center;height:"+e.notificationAreaHeight+"px;vertical-align:middle;'>"+n+" "+link+"</td></tr></table></div>"}),$jcnotify_area2.append(S),$updownbutton.mouseenter(function(){e.notificationAreaPosition=="fixed-bottom"?jQuery(this).css("background-position"," 0px -22px"):jQuery(this).css("background-position"," 0px -1px")}).mouseleave(function(){e.notificationAreaPosition=="fixed-bottom"?jQuery(this).css("background-position"," 0px -21px"):jQuery(this).css("background-position"," 0px 0px")}).click(function(){L()}),e.notificationAreaPosition=="fixed-bottom"&&$updownbutton.css("background-position"," 0px -21px");C=$root.outerHeight(!0);$root.css("box-sizing","border-box"),e.notificationAreaInitialDisplay=="delayed"?setTimeout(function(){$root.slideDown({easing:e.notificationAreaEasing,duration:700,complete:function(){k($root)}})},e.notificationAreaDelay):e.notificationAreaInitialDisplay=="expanded"?$root.show(0,function(){k($root)}):e.notificationAreaInitialDisplay=="collapsed"&&$root.show(0,function(){L()}),$bar.mouseenter(function(){y&&e.notificationAreaPosition!="document-top"&&$root.stop(!1,!1).animate({height:$root.outerHeight(!0)+12},150)}).mouseleave(function(){y&&e.notificationAreaPosition!="document-top"&&$root.stop(!1,!1).animate({height:e.notificationAreaCollapsedHeight},150)}).click(function(){A()}),e.notificationAreaAutoHide&&setTimeout(function(){L()},e.notificationAreaAutoHideDelay),e.attentionSeeker&&setInterval(function(){k($root,"seekattention")},15e3),$jcnotify_area3.css("top",Math.round(($root.outerHeight(!0)-$jcnotify_area3.outerHeight(!0))/2.5)+"px"),$jcnotify_area3.css("right","5px"),$jcnotify_area2.css("margin-top",Math.round(($root.outerHeight(!0)-$jcnotify_area2.outerHeight(!0))/2.5)),r("jcnotify")&&$root.hide(),o(),jQuery(window).resize(function(){setTimeout(O,150)}),O()}