-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.splash.min.js
1 lines (1 loc) · 4.04 KB
/
jquery.splash.min.js
1
var windowWidth,windowHeight,heightBreakpoint=0,widthBreakpoint=767,pullHeight,pageElementCheck,onResize=!1,dynamicElements,staticElements,stickyElements,splashElements={},Splash=function(){var a=this,b=!1;this.init=function(c,d){var e,f,g;c&&"object"===$.type(c)?(void 0!==c.dynamicObject&&(e=c.dynamicObject),void 0!==c.stickyObject&&(f=c.stickyObject),void 0!==c.staticObject&&(g=c.staticObject)):(a.log("No Elements have been set."),c={}),d&&"object"===$.type(d)?(void 0!==d.pageObjectCheck&&"string"===$.type(d.pageObjectCheck)&&a.setPageElementCheck(d.pageObjectCheck),void 0!==d.onResizeBoolean&&"boolean"===$.type(d.onResizeBoolean)&&(onResize=d.onResizeBoolean,a.log(onResize?"Reponsive on-resize: Enabled":"Reponsive on-resize: Disabled")),void 0!==d.debugBoolean&&"boolean"===$.type(d.debugBoolean)&&(b=d.debugBoolean)):(a.log("No Options have been set."),d={}),a.checkForPageElement()&&(e?a.setSplashElements(e,f,g):a.log("You must set your Splash Elements or Height Breakpoint Manually and run."),a.setDynamicElementsHeight(),onResize&&$(window).resize(function(){a.setDynamicElementsHeight()}))},this.setSplashElements=function(b,c,d){b&&b instanceof jQuery?(dynamicElements=b,splashElements.dynamicElements=b,a.log("Dynamic Elements: "),a.log(dynamicElements),c instanceof jQuery&&(stickyElements=c,splashElements.stickyElements=c,a.log("Sticky Elements: "),a.log(stickyElements)),d instanceof jQuery&&(staticElements=d,splashElements.staticElements=d,a.log("Static Elements: "),a.log(staticElements)),a.log("Splash Elements: "),a.log(splashElements),a.setHeightBreakpoint()):a.log("First Parameter (Dynamic Elements) must be a jQuery object.")},this.getWindowWidth=function(){return windowWidth=$(window).width(),a.log("Browser Window's Width: "+windowWidth),windowWidth},this.getWindowHeight=function(){return windowHeight=$(window).height(),a.log("Browser Window's Height: "+windowHeight),windowHeight},this.calculatePullHeight=function(){var b,c;return stickyElements&&stickyElements instanceof jQuery?(b=stickyElements.outerHeight(),a.log("Sticky Element Height: "+b)):b=0,staticElements&&staticElements instanceof jQuery?(c=staticElements.outerHeight(),a.log("Static Element Height: "+c)):c=0,pullHeight=b+c,a.log("Pull Height: "+pullHeight),pullHeight},this.setDynamicElementsHeight=function(b){a.calculatePullHeight(),b&&"number"===$.type(b)&&b>0?(dynamicElements.css({height:b+"px"}),a.log("Manually Set Dynamic Elements' Height to: "+b)):pullHeight>=0&&heightBreakpoint>0?(a.getWindowWidth(),a.getWindowHeight(),windowHeight>heightBreakpoint&&windowWidth>widthBreakpoint&&windowHeight-pullHeight>0?(dynamicElements.css({height:windowHeight-pullHeight+"px"}),a.log("Dynamic Elements' Height: "+(windowHeight-pullHeight))):dynamicElements.attr("style")&&(dynamicElements.removeAttr("style"),a.log("Dynamic Elements' Height has been reset."))):a.log("Unable to Set Dynamic Elements' height. Pull Height and Height Breakpoint aren't set properly.")},this.setHeightBreakpoint=function(b){b&&"number"===$.type(b)&&b>0?(heightBreakpoint=b,a.log("Manually Set Height Breakpoint to: "+b)):splashElements?(heightBreakpoint=0,$.each(splashElements,function(a,b){heightBreakpoint+=b.outerHeight()}),a.log("Breakpoint Height: "+heightBreakpoint)):a.log("Unable to set Height Breakpoint. No Splash Elements have been set")},this.setWidthBreakpoint=function(b){b&&"number"===$.type(b)&&b>0?(widthBreakpoint=b,a.log("Manually Set Height Breakpoint to: "+b)):a.log("Unable to set Width Breakpoint")},this.setPageElementCheck=function(b){b&&"string"===$.type(b)?(pageElementCheck=b,a.log("Element to Check for before running: "+pageElementCheck)):a.log("Page Element Check must be a jQuery selector (string).")},this.checkForPageElement=function(b){return b&&"string"===$.type(b)?(pageElementCheck=b,void a.log("Manually Checking for: "+pageElementCheck)):pageElementCheck?$(pageElementCheck).length?(a.log("Page Element Exists. Success! Continuing..."),!0):(a.log("Page Element does not exist. Stopping..."),!1):(a.log("No Page Element to check for. Passing..."),!0)},this.log=function(a){window.console&&b&&console.log(a)}};