1 line
3.5 KiB
JavaScript
1 line
3.5 KiB
JavaScript
!function(a){"use strict";var e,B;function s(e){return""!=e&&((e=e.replace(/\}\}/g,"}")).split("{").length==e.split("}").length&&(e=e.toString().replace(/\}\,/g,"}"),t=e.replace(/\{(.*?)\}/g,"|BREAK|").split("|BREAK|"),n=[],a.each(t,function(e,t){-1===a.inArray(t,n)&&n.push(t)}),n));var t,n}function u(e,t){return 0==e||1==e?"":(e=(e=(e=(e=e.replace(/(\r\n|\n|\r)/g,"").replace(/\t/g,"")).replace(/\/\*(.*?)\*\//g,"")).replace(/\}\s+\}/g,"}}").replace(/\s+\{/g,"{")).replace(/\s+\}/g,"}").replace(/\{\s+/g,"{"),e=e.replace(/[\u2018\u2019\u201A\u201B\u2032\u2035\u201C\u201D]/g,""),!0===t&&(e=e.replace(/@media(.*?)\}\}/g,"").replace(/@?([a-zA-Z0-9_-]+)?keyframes(.*?)\}\}/g,"").replace(/@font-face(.*?)\}\}/g,"").replace(/@import(.*?)\;/g,"").replace(/@charset(.*?)\;/g,"")),e)}function f(){if(0===a("style#yellow-pencil,style#yp-live-preview,link#yp-custom-css").length)return!1;var e="";return 0==a("link#yp-custom-css").length?0<a("style#yellow-pencil").length&&(e+=a("style#yellow-pencil").html()):e=function(){var e,t,n,i="";for(t=0;t<document.styleSheets.length;t++)if(null!=(e=document.styleSheets[t]).href&&-1!=e.ownerNode.outerHTML.indexOf("yp-custom-css"))for(n=0;n<e.cssRules.length;n++)i+=e.cssRules[n].cssText;return i}(),0<a("style#yp-live-preview").length&&(e+=a("style#yp-live-preview").html()),e}function t(n){var e=f(),t=s(u(e,!0)),i=[];a.each(t,function(e,t){if(t.match(/\:|\}|\{|\;/))return!0;0<=t.indexOf(n)&&""!=t&&i.push(t.replace(n,""))});var c=u(e,!1).match(/@media(.*?){(.*?)}}/g),r="",o="",l="";return a.each(c,function(e,t){o=t.match(/@media(.*?){/g).toString().replace(/\{/g,"").replace(/@media /g,"").replace(/@media/g,""),r=t.toString().replace(/@media(.*?){/g,""),l=s(r),a.each(l,function(e,t){if(t.match(/\:|\}|\{|\;/))return!0;window.matchMedia(o).matches&&0<=t.indexOf(n)&&""!=t&&i.push(t.replace(n,""))})}),i.toString()}function n(){a(t(".yp_onscreen")).each(function(){a(this).visible(!0)&&a(this).addClass("yp_onscreen")})}e=jQuery,B=e(window),e.fn.visible=function(e,t,n){if(!(this.length<1)){var i=1<this.length?this.eq(0):this,c=i.get(0),r=B.width(),o=B.height(),l=(n=n||"both",!0!==t||c.offsetWidth*c.offsetHeight);if("function"==typeof c.getBoundingClientRect){var a=c.getBoundingClientRect(),s=0<=a.top&&a.top<o,u=0<a.bottom&&a.bottom<=o,f=0<=a.left&&a.left<r,h=0<a.right&&a.right<=r,p=e?s||u:s&&u,d=e?f||h:f&&h;if("both"===n)return l&&p&&d;if("vertical"===n)return l&&p;if("horizontal"===n)return l&&d}else{var g=B.scrollTop(),m=g+o,y=B.scrollLeft(),v=y+r,w=i.offset(),b=w.top,k=b+i.height(),_=w.left,C=_+i.width(),A=!0===e?k:b,E=!0===e?b:k,R=!0===e?C:_,S=!0===e?_:C;if("both"===n)return!!l&&E<=m&&g<=A&&S<=v&&y<=R;if("vertical"===n)return!!l&&E<=m&&g<=A;if("horizontal"===n)return!!l&&S<=v&&y<=R}}},a(window).resize(function(){n()}),a(document).ready(function(){n(),a(t(".yp_click")).each(function(){a(this).click(function(){var e=a(this);e.addClass("yp_click"),"backwards"==e.css("animation-fill-mode")&&e.one("webkitAnimationEnd oanimationend msAnimationEnd animationend",function(){e.removeClass("yp_click")})})}),a(t(".yp_hover")).each(function(){a(this).mouseenter(function(){var e=a(this);e.addClass("yp_hover"),"backwards"==e.css("animation-fill-mode")&&e.one("webkitAnimationEnd oanimationend msAnimationEnd animationend",function(){e.removeClass("yp_hover")})})}),a(t(".yp_focus")).each(function(){a(this).focus(function(){a(this).addClass("yp_focus")}).blur(function(){"backwards"==el.css("animation-fill-mode")&&a(this).removeClass("yp_focus")})})}),a(document).scroll(function(){n()})}(jQuery); |