pos-gis/public/js/plugins.linkscroll.js

165 lines
11 KiB
JavaScript
Raw Normal View History

2024-10-07 06:13:42 +00:00
window.scwLinkScrollPlugin = window.scwLinkScrollPlugin || {};
/*!
* jQuery Color Animations v@VERSION
* https://github.com/jquery/jquery-color
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* Date: @DATE
*/
!function(r,n){function t(r,n,t){var e=f[n.type]||{};return null==r?t||!n.def?null:n.def:(r=e.floor?~~r:parseFloat(r),isNaN(r)?n.def:e.mod?(r+e.mod)%e.mod:0>r?0:e.max<r?e.max:r)}function e(n){var t=l(),e=t._rgba=[];return n=n.toLowerCase(),h(u,function(r,o){var a,s=o.re.exec(n),i=s&&o.parse(s),u=o.space||"rgba";return i?(a=t[u](i),t[c[u].cache]=a[c[u].cache],e=t._rgba=a._rgba,!1):void 0}),e.length?("0,0,0,0"===e.join()&&r.extend(e,a.transparent),t):a[n]}function o(r,n,t){return t=(t+1)%1,1>6*t?r+(n-r)*t*6:1>2*t?n:2>3*t?r+(n-r)*(2/3-t)*6:r}var a,s="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",i=/^([\-+])=\s*(\d+\.?\d*)/,u=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(r){return[r[1],r[2],r[3],r[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(r){return[2.55*r[1],2.55*r[2],2.55*r[3],r[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(r){return[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(r){return[parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(r){return[r[1],r[2]/100,r[3]/100,r[4]]}}],l=r.Color=function(n,t,e,o){return new r.Color.fn.parse(n,t,e,o)},c={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},f={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},p=l.support={},d=r("<p>")[0],h=r.each;d.style.cssText="background-color:rgba(1,1,1,.5)",p.rgba=d.style.backgroundColor.indexOf("rgba")>-1,h(c,function(r,n){n.cache="_"+r,n.props.alpha={idx:3,type:"percent",def:1}}),l.fn=r.extend(l.prototype,{parse:function(o,s,i,u){if(o===n)return this._rgba=[null,null,null,null],this;(o.jquery||o.nodeType)&&(o=r(o).css(s),s=n);var f=this,p=r.type(o),d=this._rgba=[];return s!==n&&(o=[o,s,i,u],p="array"),"string"===p?this.parse(e(o)||a._default):"array"===p?(h(c.rgba.props,function(r,n){d[n.idx]=t(o[n.idx],n)}),this):"object"===p?(o instanceof l?h(c,function(r,n){o[n.cache]&&(f[n.cache]=o[n.cache].slice())}):h(c,function(n,e){var a=e.cache;h(e.props,function(r,n){if(!f[a]&&e.to){if("alpha"===r||null==o[r])return;f[a]=e.to(f._rgba)}f[a][n.idx]=t(o[r],n,!0)}),f[a]&&r.inArray(null,f[a].slice(0,3))<0&&(f[a][3]=1,e.from&&(f._rgba=e.from(f[a])))}),this):void 0},is:function(r){var n=l(r),t=!0,e=this;return h(c,function(r,o){var a,s=n[o.cache];return s&&(a=e[o.cache]||o.to&&o.to(e._rgba)||[],h(o.props,function(r,n){return null!=s[n.idx]?t=s[n.idx]===a[n.idx]:void 0})),t}),t},_space:function(){var r=[],n=this;return h(c,function(t,e){n[e.cache]&&r.push(t)}),r.pop()},transition:function(r,n){var e=l(r),o=e._space(),a=c[o],s=0===this.alpha()?l("transparent"):this,i=s[a.cache]||a.to(s._rgba),u=i.slice();return e=e[a.cache],h(a.props,function(r,o){var a=o.idx,s=i[a],l=e[a],c=f[o.type]||{};null!==l&&(null===s?u[a]=l:(c.mod&&(l-s>c.mod/2?s+=c.mod:s-l>c.mod/2&&(s-=c.mod)),u[a]=t((l-s)*n+s,o)))}),this[o](u)},blend:function(n){if(1===this._rgba[3])return this;var t=this._rgba.slice(),e=t.pop(),o=l(n)._rgba;return l(r.map(t,function(r,n){return(1-e)*o[n]+e*r}))},toRgbaString:function(){var n="rgba(",t=r.map(this._rgba,function(r,n){return null==r?n>2?1:0:r});return 1===t[3]&&(t.pop(),n="rgb("),n+t.join()+")"},toHslaString:function(){var n="hsla(",t=r.map(this.hsla(),function(r,n){return null==r&&(r=n>2?1:0),n&&3>n&&(r=Math.round(100*r)+"%"),r});return 1===t[3]&&(t.pop(),n="hsl("),n+t.join()+")"},toHexString:function(n){var t=this._rgba.slice(),e=t.pop();return n&&t.push(~~(255*e)),"#"+r.map(t,function(r){return r=(r||0).toString(16),1===r.length?"0"+r:r}).join("")},toString:function(){return 0===th
let windowElLs = jQuery(window),
$bodyLs = jQuery('body'),
$pageSectionElLs,
locationHashLs = location.hash;
window.SEMICOLON_linkScrollInit = function( $linkScrollEl ){
$linkScrollEl = $linkScrollEl.filter(':not(.customjs)');
if( $linkScrollEl.length < 1 ){
return true;
}
if( $('[data-scrollto="'+ locationHashLs +'"]').length > 0 ) {
windowElLs.on('beforeunload', function() {
windowElLs.scrollTop(0);
});
windowElLs.scrollTop(0);
let linkElement = $( locationHashLs );
if( linkElement.length > 0 ) {
setTimeout( function(){
let linkElementOff = linkElement.offset().top,
linkElSettings = JSON.parse( linkElement.attr('data-scrollto-settings') );
$('html,body').stop(true, true).animate({
'scrollTop': linkElementOff - Number( linkElSettings.offset )
}, linkElSettings.speed, linkElSettings.easing, function(){
if( linkElSettings.highlight ) {
if( linkElement.find('.highlight-me').length > 0 ) {
linkElement.find('.highlight-me').animate({'backgroundColor': linkElSettings.highlight}, 300);
setTimeout( function(){
linkElement.find('.highlight-me').animate({'backgroundColor': 'transparent'}, 300);
}, 500 );
} else {
linkElement.animate({'backgroundColor': linkElSettings.highlight}, 300);
setTimeout( function(){
linkElement.animate({'backgroundColor': 'transparent'}, 300);
}, 500 );
}
}
});
}, 1200);
}
}
$linkScrollEl.each( function(){
let linkEl = $(this),
linkElAnchor = linkEl.attr('data-scrollto'),
linkElement = $( linkElAnchor ),
linkElSettings = SEMICOLON_linkScrollSettings( linkElAnchor, $('[data-scrollto="'+ linkElAnchor +'"]') );
if( linkElement.length > 0 ) {
setTimeout( function(){
linkElement.attr( 'data-scrollto-settings', JSON.stringify( linkElSettings ) );
$pageSectionElLs = $('[data-scrollto-settings]');
}, 1000);
}
});
$linkScrollEl.off( 'click' ).on( 'click', function(){
let linkEl = $(this),
linkElAnchor = linkEl.attr('data-scrollto'),
linkElement = $( linkElAnchor );
if( linkEl.parents('.primary-menu').hasClass('on-click') ) { return true; }
if( linkElement.length > 0 ) {
let linkElSettings = JSON.parse( linkElement.attr('data-scrollto-settings') );
$('html,body').stop(true).animate({
'scrollTop': linkElement.offset().top - Number( linkElSettings.offset )
}, Number( linkElSettings.speed ), linkElSettings.easing, function(){
if( linkElSettings.highlight ) {
if( linkElement.find('.highlight-me').length > 0 ) {
linkElement.find('.highlight-me').animate({'backgroundColor': linkElSettings.highlight}, 300);
setTimeout( function(){
linkElement.find('.highlight-me').animate({'backgroundColor': 'transparent'}, 300);
}, 500 );
} else {
linkElement.animate({'backgroundColor': linkElSettings.highlight}, 300);
setTimeout( function(){
linkElement.animate({'backgroundColor': 'transparent'}, 300);
}, 500 );
}
}
});
return false;
}
});
};
window.SEMICOLON_linkScrollSettings = function( hash, element ) {
if( typeof hash === 'undefined' && element.length < 1 ) {
return true;
}
let settings = {},
offsetTop = $( hash ).offset().top,
elSpeed = element.attr( 'data-speed' ) || 1250,
elOffset = element.attr( 'data-offset' ) || SEMICOLON.initialize.topScrollOffset(),
elEasing = element.attr( 'data-easing' ) || 'easeOutQuad',
elHighlight = element.attr( 'data-highlight' );
let elOffsetXXL = element.attr( 'data-offset-xxl' ),
elOffsetXL = element.attr( 'data-offset-xl' ),
elOffsetLG = element.attr( 'data-offset-lg' ),
elOffsetMD = element.attr( 'data-offset-md' ),
elOffsetSM = element.attr( 'data-offset-sm' ),
elOffsetXS = element.attr( 'data-offset-xs' );
if( !elOffsetXS ) { elOffsetXS = elOffset; }
if( !elOffsetSM ) { elOffsetSM = elOffsetXS; }
if( !elOffsetMD ) { elOffsetMD = elOffsetSM; }
if( !elOffsetLG ) { elOffsetLG = elOffsetMD; }
if( !elOffsetXL ) { elOffsetXL = elOffsetLG; }
if( !elOffsetXXL ) { elOffsetXXL = elOffsetXL; }
if( $bodyLs.hasClass('device-xxl') ) {
elOffset = elOffsetXXL;
} else if( $bodyLs.hasClass('device-xl') ) {
elOffset = elOffsetXL;
} else if( $bodyLs.hasClass('device-lg') ) {
elOffset = elOffsetLG;
} else if( $bodyLs.hasClass('device-md') ) {
elOffset = elOffsetMD;
} else if( $bodyLs.hasClass('device-sm') ) {
elOffset = elOffsetSM;
} else if( $bodyLs.hasClass('device-xs') ) {
elOffset = elOffsetXS;
}
settings.offset = Number(elOffset);
settings.speed = elSpeed;
settings.easing = elEasing;
settings.highlight = elHighlight;
return settings;
};