init
This commit is contained in:
399
assets/js/custom/dense.js
Normal file
399
assets/js/custom/dense.js
Normal file
@@ -0,0 +1,399 @@
|
||||
/**
|
||||
* Dense - Device pixel ratio aware images
|
||||
*
|
||||
* @link http://dense.rah.pw
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Jukka Svahn
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name jQuery
|
||||
* @class
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name fn
|
||||
* @class
|
||||
* @memberOf jQuery
|
||||
*/
|
||||
|
||||
(function (factory)
|
||||
{
|
||||
'use strict';
|
||||
|
||||
if (typeof define === 'function' && define.amd)
|
||||
{
|
||||
define(['jquery'], factory);
|
||||
}
|
||||
else
|
||||
{
|
||||
factory(window.jQuery || window.Zepto);
|
||||
}
|
||||
}(function ($)
|
||||
{
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* An array of checked image URLs.
|
||||
*/
|
||||
|
||||
var pathStack = [],
|
||||
|
||||
/**
|
||||
* Methods.
|
||||
*/
|
||||
|
||||
methods = {},
|
||||
|
||||
/**
|
||||
* Regular expression to check whether the URL has a protocol.
|
||||
*
|
||||
* Is used to check whether the image URL is external.
|
||||
*/
|
||||
|
||||
regexHasProtocol = /^([a-z]:)?\/\//i,
|
||||
|
||||
/**
|
||||
* Regular expression that split extensions from the file.
|
||||
*
|
||||
* Is used to inject the DPR suffix to the name.
|
||||
*/
|
||||
|
||||
regexSuffix = /\.\w+$/,
|
||||
|
||||
/**
|
||||
* Device pixel ratio.
|
||||
*/
|
||||
|
||||
devicePixelRatio;
|
||||
|
||||
/**
|
||||
* Init is the default method responsible for rendering
|
||||
* a pixel-ratio-aware images.
|
||||
*
|
||||
* This method is used to select the images that
|
||||
* should display retina-size images on high pixel ratio
|
||||
* devices. Dense defaults to the init method if no
|
||||
* method is specified.
|
||||
*
|
||||
* When attached to an image, the correct image variation is
|
||||
* selected based on the device's pixel ratio. If the image element
|
||||
* defines <code>data-{ratio}x</code> attributes (e.g. data-1x, data-2x, data-3x),
|
||||
* the most appropriate of those is selected.
|
||||
*
|
||||
* If no data-ratio attributes are defined, the retina image is
|
||||
* constructed from the <code>src</code> attribute.
|
||||
* The searched high pixel ratio images follows
|
||||
* a <code>{imageName}_{ratio}x.{ext}</code> naming convention.
|
||||
* For an image found in /path/to/images/image.jpg, the 2x retina
|
||||
* image would be looked from /path/to/images/image_2x.jpg.
|
||||
*
|
||||
* When image is constructed from the src, the image existance is
|
||||
* verified using HTTP HEAD request, if <code>ping</code> option is
|
||||
* <code>true</code>. The check makes sure no HTTP error code is returned,
|
||||
* and that the received content-type is of an image. Vector image formats,
|
||||
* like svg, are skipped based on the file extension.
|
||||
*
|
||||
* This method can also be used to load image in semi-lazy fashion,
|
||||
* and avoid larger extra HTTP requests due to retina replacements.
|
||||
* The data-1x attribute can be used to supstitute the src, making
|
||||
* sure the browser doesn't try to download the normal image variation
|
||||
* before the JavaScript driven behaviour kicks in.
|
||||
*
|
||||
* Some classes are added to the selected elements while Dense is processing
|
||||
* the document. These classes include <code>dense-image</code>, <code>dense-loading</code>
|
||||
* and <code>dense-ready</code>. These classes can be used to style the images,
|
||||
* or hide them while they are being loaded.
|
||||
*
|
||||
* @param {Object} [options={}] Options
|
||||
* @param {Boolean} [options.ping=null] Check image existence. If the default <code>NULL</code> checks local images, <code>FALSE</code> disables checking and <code>TRUE</code> checks even external images cross-domain
|
||||
* @param {String} [options.dimensions=preserve] What to do with the image's <code>width</code> and <code>height</code> attributes. Either <code>update</code>, <code>remove</code> or <code>preserve</code>
|
||||
* @param {String} [options.glue=_] String that glues the retina "nx" suffix to the image. This option can be used to change the naming convention between the two commonly used practices, <code>image@2x.jpg</code> and <code>image_2x.jpg</code>
|
||||
* @param {Array} [options.skipExtensions=['svg']] Skipped image file extensions. There might be situations where you might want to exclude vector image formats
|
||||
* @return {Object} this
|
||||
* @method init
|
||||
* @memberof jQuery.fn.dense
|
||||
* @fires jQuery.fn.dense#denseRetinaReady.dense
|
||||
* @example
|
||||
* $('img').dense({
|
||||
* ping: false,
|
||||
* dimension: 'update'
|
||||
* });
|
||||
*/
|
||||
|
||||
methods.init = function (options)
|
||||
{
|
||||
options = $.extend({
|
||||
ping: null,
|
||||
dimensions: 'preserve',
|
||||
glue: '_',
|
||||
skipExtensions: ['svg']
|
||||
}, options);
|
||||
|
||||
this.each(function ()
|
||||
{
|
||||
var $this = $(this);
|
||||
|
||||
if (!$this.is('img') || $this.hasClass('dense-image'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this.addClass('dense-image dense-loading');
|
||||
|
||||
var image = methods.getImageAttribute.call(this),
|
||||
originalImage = $this.attr('src'),
|
||||
ping = false,
|
||||
updateImage;
|
||||
|
||||
if (!image)
|
||||
{
|
||||
if (!originalImage || devicePixelRatio === 1 || $.inArray(originalImage.split('.').pop().split(/[\?\#]/).shift(), options.skipExtensions) !== -1)
|
||||
{
|
||||
$this.removeClass('dense-image dense-loading');
|
||||
return;
|
||||
}
|
||||
|
||||
image = originalImage.replace(regexSuffix, function (extension)
|
||||
{
|
||||
var pixelRatio = $this.attr('data-dense-cap') ? $this.attr('data-dense-cap') : devicePixelRatio;
|
||||
return options.glue + pixelRatio + 'x' + extension;
|
||||
});
|
||||
|
||||
ping = options.ping !== false && $.inArray(image, pathStack) === -1 && (options.ping === true || !regexHasProtocol.test(image) || image.indexOf('//'+document.domain) === 0 || image.indexOf(document.location.protocol+'//'+document.domain) === 0);
|
||||
}
|
||||
|
||||
updateImage = function ()
|
||||
{
|
||||
var readyImage = function ()
|
||||
{
|
||||
$this.removeClass('dense-loading').addClass('dense-ready').trigger('denseRetinaReady.dense');
|
||||
};
|
||||
|
||||
$this.attr('src', image);
|
||||
|
||||
if (options.dimensions === 'update')
|
||||
{
|
||||
$this.dense('updateDimensions').one('denseDimensionChanged', readyImage);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (options.dimensions === 'remove')
|
||||
{
|
||||
$this.removeAttr('width height');
|
||||
}
|
||||
|
||||
readyImage();
|
||||
}
|
||||
};
|
||||
|
||||
if (ping)
|
||||
{
|
||||
$.ajax({
|
||||
url : image,
|
||||
type : 'HEAD'
|
||||
})
|
||||
.done(function (data, textStatus, jqXHR)
|
||||
{
|
||||
var type = jqXHR.getResponseHeader('Content-type');
|
||||
|
||||
if (!type || type.indexOf('image/') === 0)
|
||||
{
|
||||
pathStack.push(image);
|
||||
updateImage();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
updateImage();
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets an image's width and height attributes to its native values.
|
||||
*
|
||||
* Updates an img element's dimensions to the source image's
|
||||
* real values. This method is asynchronous, so you can not directly
|
||||
* return its values. Instead, use the 'dense-dimensions-updated'
|
||||
* event to detect when the action is done.
|
||||
*
|
||||
* @return {Object} this
|
||||
* @method updateDimensions
|
||||
* @memberof jQuery.fn.dense
|
||||
* @fires jQuery.fn.dense#denseDimensionChanged.dense
|
||||
* @example
|
||||
* var image = $('img').dense('updateDimensions');
|
||||
*/
|
||||
|
||||
methods.updateDimensions = function ()
|
||||
{
|
||||
return this.each(function ()
|
||||
{
|
||||
var img, $this = $(this), src = $this.attr('src');
|
||||
|
||||
if (src)
|
||||
{
|
||||
img = new Image();
|
||||
img.src = src;
|
||||
|
||||
$(img).on('load.dense', function ()
|
||||
{
|
||||
$this.attr({
|
||||
width: img.width,
|
||||
height: img.height
|
||||
}).trigger('denseDimensionChanged.dense');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets device pixel ratio rounded up to the closest integer.
|
||||
*
|
||||
* @return {Integer} The pixel ratio
|
||||
* @method devicePixelRatio
|
||||
* @memberof jQuery.fn.dense
|
||||
* @example
|
||||
* var ratio = $(window).dense('devicePixelRatio');
|
||||
* alert(ratio);
|
||||
*/
|
||||
|
||||
methods.devicePixelRatio = function ()
|
||||
{
|
||||
var pixelRatio = 1;
|
||||
|
||||
if ($.type(window.devicePixelRatio) !== 'undefined')
|
||||
{
|
||||
pixelRatio = window.devicePixelRatio;
|
||||
}
|
||||
else if ($.type(window.matchMedia) !== 'undefined')
|
||||
{
|
||||
$.each([1.3, 2, 3, 4, 5, 6], function (key, ratio)
|
||||
{
|
||||
var mediaQuery = [
|
||||
'(-webkit-min-device-pixel-ratio: '+ratio+')',
|
||||
'(min-resolution: '+Math.floor(ratio*96)+'dpi)',
|
||||
'(min-resolution: '+ratio+'dppx)'
|
||||
].join(',');
|
||||
|
||||
if (!window.matchMedia(mediaQuery).matches)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
pixelRatio = ratio;
|
||||
});
|
||||
}
|
||||
|
||||
return Math.ceil(pixelRatio);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets an appropriate URL for the pixel ratio from the data attribute list.
|
||||
*
|
||||
* Selects the most appropriate <code>data-{ratio}x</code> attribute from
|
||||
* the given element's attributes. If the devices pixel ratio is greater
|
||||
* than the largest specified image, the largest one of the available is used.
|
||||
*
|
||||
* @return {String|Boolean} The attribute value
|
||||
* @method getImageAttribute
|
||||
* @memberof jQuery.fn.dense
|
||||
* @example
|
||||
* var image = $('<div data-1x="image.jpg" data-2x="image_2x.jpg" />').dense('getImageAttribute');
|
||||
* $('body').css('background-image', 'url(' + image + ')');
|
||||
*/
|
||||
|
||||
methods.getImageAttribute = function ()
|
||||
{
|
||||
var $this = $(this).eq(0), image = false, url;
|
||||
|
||||
for (var i = 1; i <= devicePixelRatio; i++)
|
||||
{
|
||||
url = $this.attr('data-' + i + 'x');
|
||||
|
||||
if (url)
|
||||
{
|
||||
image = url;
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
};
|
||||
|
||||
devicePixelRatio = methods.devicePixelRatio();
|
||||
|
||||
/**
|
||||
* Dense offers few methods and options that can be used to both customize the
|
||||
* plugin's functionality and return resulting values. All interaction is done through
|
||||
* the <code>$.fn.dense()</code> method, that accepts a called method and its options
|
||||
* object as its arguments. Both arguments are optional, and either one can be omitted.
|
||||
*
|
||||
* @param {String} [method=init] The called method
|
||||
* @param {Object} [options={}] Options passed to the method
|
||||
* @class dense
|
||||
* @memberof jQuery.fn
|
||||
*/
|
||||
|
||||
$.fn.dense = function (method, options)
|
||||
{
|
||||
if ($.type(method) !== 'string' || $.type(methods[method]) !== 'function')
|
||||
{
|
||||
options = method;
|
||||
method = 'init';
|
||||
}
|
||||
|
||||
return methods[method].call(this, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize automatically when document is ready.
|
||||
*
|
||||
* Dense is initialized automatically if the body element
|
||||
* has a <code>dense-retina</code> class.
|
||||
*/
|
||||
|
||||
$(function ()
|
||||
{
|
||||
$('body.dense-retina img').dense();
|
||||
});
|
||||
|
||||
/**
|
||||
* This event is invoked when a retina image has finished loading.
|
||||
*
|
||||
* @event jQuery.fn.dense#denseRetinaReady.dense
|
||||
* @type {Object}
|
||||
*/
|
||||
|
||||
/**
|
||||
* This event is invoked when an image's dimension values
|
||||
* have been updated by the <code>updateDimensions</code>
|
||||
* method.
|
||||
*
|
||||
* @event jQuery.fn.dense#denseDimensionChanged.dense
|
||||
* @type {Object}
|
||||
*/
|
||||
}));
|
1
assets/js/custom/dense.min.js
vendored
Normal file
1
assets/js/custom/dense.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e(window.jQuery||window.Zepto)}(function(e){"use strict";var n,i=[],t={},a=/^([a-z]:)?\/\//i;t.init=function(d){return d=e.extend({ping:null,dimensions:"preserve",glue:"_",skipExtensions:["svg"]},d),this.each(function(){var s=e(this);if(s.is("img")&&!s.hasClass("dense-image")){s.addClass("dense-image dense-loading");var o,r=t.getImageAttribute.call(this),u=s.attr("src"),c=!1;if(!r){if(!u||1===n||-1!==e.inArray(u.split(".").pop().split(/[\?\#]/).shift(),d.skipExtensions))return void s.removeClass("dense-image dense-loading");r=u.replace(/\.\w+$/,function(e){var i=s.attr("data-dense-cap")?s.attr("data-dense-cap"):n;return d.glue+i+"x"+e}),c=!1!==d.ping&&-1===e.inArray(r,i)&&(!0===d.ping||!a.test(r)||0===r.indexOf("//"+document.domain)||0===r.indexOf(document.location.protocol+"//"+document.domain))}o=function(){var e=function(){s.removeClass("dense-loading").addClass("dense-ready").trigger("denseRetinaReady.dense")};s.attr("src",r),"update"===d.dimensions?s.dense("updateDimensions").one("denseDimensionChanged",e):("remove"===d.dimensions&&s.removeAttr("width height"),e())},c?e.ajax({url:r,type:"HEAD"}).done(function(e,n,t){var a=t.getResponseHeader("Content-type");a&&0!==a.indexOf("image/")||(i.push(r),o())}):o()}}),this},t.updateDimensions=function(){return this.each(function(){var n,i=e(this),t=i.attr("src");t&&(n=new Image,n.src=t,e(n).on("load.dense",function(){i.attr({width:n.width,height:n.height}).trigger("denseDimensionChanged.dense")}))})},t.devicePixelRatio=function(){var n=1;return"undefined"!==e.type(window.devicePixelRatio)?n=window.devicePixelRatio:"undefined"!==e.type(window.matchMedia)&&e.each([1.3,2,3,4,5,6],function(e,i){var t=["(-webkit-min-device-pixel-ratio: "+i+")","(min-resolution: "+Math.floor(96*i)+"dpi)","(min-resolution: "+i+"dppx)"].join(",");if(!window.matchMedia(t).matches)return!1;n=i}),Math.ceil(n)},t.getImageAttribute=function(){for(var i,t=e(this).eq(0),a=!1,d=1;d<=n;d++)(i=t.attr("data-"+d+"x"))&&(a=i);return a},n=t.devicePixelRatio(),e.fn.dense=function(n,i){return"string"===e.type(n)&&"function"===e.type(t[n])||(i=n,n="init"),t[n].call(this,i)},e(function(){e("body.dense-retina img").dense()})});
|
258
assets/js/custom/jquery.nav.js
Normal file
258
assets/js/custom/jquery.nav.js
Normal file
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
* jQuery One Page Nav Plugin
|
||||
* http://github.com/davist11/jQuery-One-Page-Nav
|
||||
*
|
||||
* Copyright (c) 2010 Trevor Davis (http://trevordavis.net)
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* Uses the same license as jQuery, see:
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* @version 3.0.0
|
||||
*
|
||||
* Example usage:
|
||||
* $('#nav').onePageNav({
|
||||
* currentClass: 'current',
|
||||
* changeHash: false,
|
||||
* scrollSpeed: 750
|
||||
* });
|
||||
*/
|
||||
|
||||
;(function($, window, document, undefined){
|
||||
|
||||
// our plugin constructor
|
||||
var OnePageNav = function(elem, options){
|
||||
this.elem = elem;
|
||||
this.$elem = $(elem);
|
||||
this.options = options;
|
||||
this.metadata = this.$elem.data('plugin-options');
|
||||
this.$win = $(window);
|
||||
this.sections = {};
|
||||
this.didScroll = false;
|
||||
this.$doc = $(document);
|
||||
this.docHeight = this.$doc.height();
|
||||
};
|
||||
|
||||
// the plugin prototype
|
||||
OnePageNav.prototype = {
|
||||
defaults: {
|
||||
navItems: 'a',
|
||||
currentClass: 'current',
|
||||
changeHash: false,
|
||||
easing: 'swing',
|
||||
filter: '',
|
||||
scrollOffset: 0,
|
||||
scrollSpeed: 750,
|
||||
scrollThreshold: 0.5,
|
||||
begin: false,
|
||||
end: false,
|
||||
scrollChange: false
|
||||
},
|
||||
|
||||
init: function() {
|
||||
// Introduce defaults that can be extended either
|
||||
// globally or using an object literal.
|
||||
this.config = $.extend({}, this.defaults, this.options, this.metadata);
|
||||
|
||||
this.$nav = this.$elem.find(this.config.navItems);
|
||||
|
||||
//Filter any links out of the nav
|
||||
if(this.config.filter !== '') {
|
||||
this.$nav = this.$nav.filter(this.config.filter);
|
||||
}
|
||||
|
||||
//Handle clicks on the nav
|
||||
this.$nav.on('click.onePageNav', $.proxy(this.handleClick, this));
|
||||
|
||||
//Get the section positions
|
||||
this.getPositions();
|
||||
|
||||
//Handle scroll changes
|
||||
this.bindInterval();
|
||||
|
||||
//Update the positions on resize too
|
||||
this.$win.on('resize.onePageNav', $.proxy(this.getPositions, this));
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
adjustNav: function(self, $parent) {
|
||||
self.$elem.find('.' + self.config.currentClass).removeClass(self.config.currentClass);
|
||||
$parent.addClass(self.config.currentClass);
|
||||
},
|
||||
|
||||
bindInterval: function() {
|
||||
var self = this;
|
||||
var docHeight;
|
||||
|
||||
self.$win.on('scroll.onePageNav', function() {
|
||||
self.didScroll = true;
|
||||
});
|
||||
|
||||
self.t = setInterval(function() {
|
||||
docHeight = self.$doc.height();
|
||||
|
||||
//If it was scrolled
|
||||
if(self.didScroll) {
|
||||
self.didScroll = false;
|
||||
self.scrollChange();
|
||||
}
|
||||
|
||||
//If the document height changes
|
||||
if(docHeight !== self.docHeight) {
|
||||
self.docHeight = docHeight;
|
||||
self.getPositions();
|
||||
}
|
||||
}, 250);
|
||||
},
|
||||
|
||||
getHash: function($link) {
|
||||
return $link.attr('href').split('#')[1];
|
||||
},
|
||||
|
||||
getPositions: function() {
|
||||
var self = this;
|
||||
var linkHref;
|
||||
var topPos;
|
||||
var $target;
|
||||
|
||||
self.$nav.each(function() {
|
||||
linkHref = self.getHash($(this));
|
||||
$target = $('#' + linkHref);
|
||||
|
||||
if($target.length) {
|
||||
topPos = $target.offset().top;
|
||||
self.sections[linkHref] = Math.round(topPos);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getSection: function(windowPos) {
|
||||
var returnValue = null;
|
||||
var windowHeight = Math.round(this.$win.height() * this.config.scrollThreshold);
|
||||
|
||||
// Sort Sections by Position
|
||||
this.sections = this.sortSectionsByPosition(this.sections);
|
||||
|
||||
for(var section in this.sections) {
|
||||
if((this.sections[section] - windowHeight) < windowPos) {
|
||||
returnValue = section;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sort Sections by its position value
|
||||
* based on http://am.aurlien.net/post/1221493460/sorting-javascript-objects
|
||||
* @param {Object} obj Object to sort
|
||||
* @return {Object} sorted Object
|
||||
*/
|
||||
sortSectionsByPosition: function (obj) {
|
||||
var tempArray = [];
|
||||
var tempObj = {};
|
||||
|
||||
// Transform Object in Array
|
||||
for (var key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
tempArray.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
tempArray.sort(function(a,b) {
|
||||
var x = obj[a];
|
||||
var y = obj[b];
|
||||
|
||||
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
||||
});
|
||||
|
||||
// Transform sorted tempArray back into Object
|
||||
for (var i=0; i<tempArray.length; i++) {
|
||||
tempObj[tempArray[i]] = obj[tempArray[i]];
|
||||
}
|
||||
|
||||
return tempObj;
|
||||
},
|
||||
|
||||
handleClick: function(e) {
|
||||
var self = this;
|
||||
var $link = $(e.currentTarget);
|
||||
var $parent = $link.parent();
|
||||
var newLoc = '#' + self.getHash($link);
|
||||
|
||||
if(!$parent.hasClass(self.config.currentClass)) {
|
||||
//Start callback
|
||||
if(self.config.begin) {
|
||||
self.config.begin();
|
||||
}
|
||||
|
||||
//Change the highlighted nav item
|
||||
self.adjustNav(self, $parent);
|
||||
|
||||
//Removing the auto-adjust on scroll
|
||||
self.unbindInterval();
|
||||
|
||||
//Scroll to the correct position
|
||||
self.scrollTo(newLoc, function() {
|
||||
//Do we need to change the hash?
|
||||
if(self.config.changeHash) {
|
||||
window.location.hash = newLoc;
|
||||
}
|
||||
|
||||
//Add the auto-adjust on scroll back in
|
||||
self.bindInterval();
|
||||
|
||||
//End callback
|
||||
if(self.config.end) {
|
||||
self.config.end();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
scrollChange: function() {
|
||||
var windowTop = this.$win.scrollTop();
|
||||
var position = this.getSection(windowTop);
|
||||
var $parent;
|
||||
|
||||
//If the position is set
|
||||
if(position !== null) {
|
||||
$parent = this.$elem.find('a[href$="#' + position + '"]').parent();
|
||||
|
||||
//If it's not already the current section
|
||||
if(!$parent.hasClass(this.config.currentClass)) {
|
||||
//Change the highlighted nav item
|
||||
this.adjustNav(this, $parent);
|
||||
|
||||
//If there is a scrollChange callback
|
||||
if(this.config.scrollChange) {
|
||||
this.config.scrollChange($parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
scrollTo: function(target, callback) {
|
||||
var offset = $(target).offset().top;
|
||||
$('html, body').animate({
|
||||
scrollTop: offset + this.config.scrollOffset
|
||||
}, this.config.scrollSpeed, this.config.easing, callback);
|
||||
},
|
||||
|
||||
unbindInterval: function() {
|
||||
clearInterval(this.t);
|
||||
this.$win.unbind('scroll.onePageNav');
|
||||
}
|
||||
};
|
||||
|
||||
OnePageNav.defaults = OnePageNav.prototype.defaults;
|
||||
|
||||
$.fn.onePageNav = function(options) {
|
||||
return this.each(function() {
|
||||
new OnePageNav(this, options).init();
|
||||
});
|
||||
};
|
||||
|
||||
})( jQuery, window , document );
|
1
assets/js/custom/jquery.nav.min.js
vendored
Normal file
1
assets/js/custom/jquery.nav.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(t,n,i,s){var e=function(s,e){this.elem=s,this.$elem=t(s),this.options=e,this.metadata=this.$elem.data("plugin-options"),this.$win=t(n),this.sections={},this.didScroll=!1,this.$doc=t(i),this.docHeight=this.$doc.height()};e.prototype={defaults:{navItems:"a",currentClass:"current",changeHash:!1,easing:"swing",filter:"",scrollOffset:0,scrollSpeed:750,scrollThreshold:.5,begin:!1,end:!1,scrollChange:!1},init:function(){return this.config=t.extend({},this.defaults,this.options,this.metadata),this.$nav=this.$elem.find(this.config.navItems),""!==this.config.filter&&(this.$nav=this.$nav.filter(this.config.filter)),this.$nav.on("click.onePageNav",t.proxy(this.handleClick,this)),this.getPositions(),this.bindInterval(),this.$win.on("resize.onePageNav",t.proxy(this.getPositions,this)),this},adjustNav:function(t,n){t.$elem.find("."+t.config.currentClass).removeClass(t.config.currentClass),n.addClass(t.config.currentClass)},bindInterval:function(){var t,n=this;n.$win.on("scroll.onePageNav",function(){n.didScroll=!0}),n.t=setInterval(function(){t=n.$doc.height(),n.didScroll&&(n.didScroll=!1,n.scrollChange()),t!==n.docHeight&&(n.docHeight=t,n.getPositions())},250)},getHash:function(t){return t.attr("href").split("#")[1]},getPositions:function(){var n,i,s,e=this;e.$nav.each(function(){n=e.getHash(t(this)),s=t("#"+n),s.length&&(i=s.offset().top,e.sections[n]=Math.round(i))})},getSection:function(t){var n=null,i=Math.round(this.$win.height()*this.config.scrollThreshold);this.sections=this.sortSectionsByPosition(this.sections);for(var s in this.sections)this.sections[s]-i<t&&(n=s);return n},sortSectionsByPosition:function(t){var n=[],i={};for(var s in t)t.hasOwnProperty(s)&&n.push(s);n.sort(function(n,i){var s=t[n],e=t[i];return e>s?-1:s>e?1:0});for(var e=0;e<n.length;e++)i[n[e]]=t[n[e]];return i},handleClick:function(i){var s=this,e=t(i.currentTarget),o=e.parent(),a="#"+s.getHash(e);o.hasClass(s.config.currentClass)||(s.config.begin&&s.config.begin(),s.adjustNav(s,o),s.unbindInterval(),s.scrollTo(a,function(){s.config.changeHash&&(n.location.hash=a),s.bindInterval(),s.config.end&&s.config.end()})),i.preventDefault()},scrollChange:function(){var t,n=this.$win.scrollTop(),i=this.getSection(n);null!==i&&(t=this.$elem.find('a[href$="#'+i+'"]').parent(),t.hasClass(this.config.currentClass)||(this.adjustNav(this,t),this.config.scrollChange&&this.config.scrollChange(t)))},scrollTo:function(n,i){var s=t(n).offset().top;t("html, body").animate({scrollTop:s+this.config.scrollOffset},this.config.scrollSpeed,this.config.easing,i)},unbindInterval:function(){clearInterval(this.t),this.$win.unbind("scroll.onePageNav")}},e.defaults=e.prototype.defaults,t.fn.onePageNav=function(t){return this.each(function(){new e(this,t).init()})}}(jQuery,window,document);
|
101
assets/js/custom/uikit_beforeready.js
Normal file
101
assets/js/custom/uikit_beforeready.js
Normal file
@@ -0,0 +1,101 @@
|
||||
// http://getuikit.com/docs/documentation_javascript.html#js-override
|
||||
|
||||
if (typeof UIkit !== 'undefined') {
|
||||
UIkit.on('beforeready.uk.dom', function () {
|
||||
|
||||
// accrodion
|
||||
if (typeof UIkit.components.accordion !== "undefined") { // check if accordion component is defined
|
||||
$.extend(UIkit.components.accordion.prototype.defaults, {
|
||||
easing: $.bez(easing_swiftOut),
|
||||
duration: 200
|
||||
});
|
||||
}
|
||||
|
||||
// dropdown
|
||||
if (typeof UIkit.components.dropdown.prototype !== "undefined") { // check if dropdown component is defined
|
||||
|
||||
$.extend(UIkit.components.dropdown.prototype.defaults, {
|
||||
remaintime: 150,
|
||||
delay: 50
|
||||
});
|
||||
|
||||
(function() {
|
||||
var old_show_function = UIkit.components.dropdown.prototype.show;
|
||||
|
||||
UIkit.components.dropdown.prototype.show = function() {
|
||||
|
||||
this.dropdown
|
||||
.css({
|
||||
'min-width': this.dropdown.outerWidth()
|
||||
})
|
||||
.addClass('uk-dropdown-active uk-dropdown-shown');
|
||||
|
||||
return old_show_function.apply(this, arguments);
|
||||
}
|
||||
})();
|
||||
|
||||
(function() {
|
||||
var old_hide_function = UIkit.components.dropdown.prototype.hide;
|
||||
|
||||
UIkit.components.dropdown.prototype.hide = function() {
|
||||
|
||||
var this_dropdown = this.dropdown;
|
||||
|
||||
this_dropdown.removeClass('uk-dropdown-shown');
|
||||
|
||||
var dropdown_timeout = setTimeout(function() {
|
||||
this_dropdown.removeClass('uk-dropdown-active')
|
||||
},280);
|
||||
|
||||
return old_hide_function.apply(this, arguments);
|
||||
}
|
||||
})();
|
||||
|
||||
}
|
||||
|
||||
// modal
|
||||
if (typeof UIkit.components.modal !== "undefined") { // check if modal component is defined
|
||||
$.extend(UIkit.components.modal.prototype.defaults, {
|
||||
center: true
|
||||
});
|
||||
|
||||
UIkit.modal.dialog.template = '<div class="uk-modal uk-modal-dialog-replace"><div class="uk-modal-dialog" style="min-height:0;"></div></div>';
|
||||
$body
|
||||
.on('show.uk.modal', '.uk-modal-dialog-replace', function () {
|
||||
// customize uikit dialog
|
||||
setTimeout(function () {
|
||||
var dialogReplace = $('.uk-modal-dialog-replace');
|
||||
if (dialogReplace.find('.uk-button-primary').length) {
|
||||
var actionBtn = dialogReplace.find('.uk-button-primary').toggleClass('uk-button-primary md-btn-flat-primary');
|
||||
if (actionBtn.next('button')) {
|
||||
actionBtn.next('button').after(actionBtn);
|
||||
}
|
||||
}
|
||||
if (dialogReplace.find('.uk-button').length) {
|
||||
dialogReplace.find('.uk-button').toggleClass('uk-button md-btn md-btn-flat');
|
||||
}
|
||||
if (dialogReplace.find('.uk-margin-small-top').length) {
|
||||
dialogReplace.find('.uk-margin-small-top').toggleClass('uk-margin-small-top uk-margin-top');
|
||||
}
|
||||
if (dialogReplace.find('input.uk-width-1-1').length) {
|
||||
dialogReplace.find('input.uk-width-1-1').toggleClass('uk-width-1-1 md-input');
|
||||
// reinitialize md inputs
|
||||
altair_md.inputs();
|
||||
}
|
||||
if (dialogReplace.find('.uk-form').length) {
|
||||
dialogReplace.find('.uk-form').removeClass('uk-form');
|
||||
}
|
||||
}, 50)
|
||||
});
|
||||
}
|
||||
|
||||
// tooltip
|
||||
if (typeof UIkit.components.tooltip !== "undefined") { // check if tooltip component is defined
|
||||
$.extend(UIkit.components.tooltip.prototype.defaults, {
|
||||
animation: 280,
|
||||
offset: 8
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}
|
1
assets/js/custom/uikit_beforeready.min.js
vendored
Normal file
1
assets/js/custom/uikit_beforeready.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"undefined"!=typeof UIkit&&UIkit.on("beforeready.uk.dom",function(){"undefined"!=typeof UIkit.components.accordion&&$.extend(UIkit.components.accordion.prototype.defaults,{easing:$.bez(easing_swiftOut),duration:200}),"undefined"!=typeof UIkit.components.dropdown.prototype&&($.extend(UIkit.components.dropdown.prototype.defaults,{remaintime:150,delay:50}),function(){var t=UIkit.components.dropdown.prototype.show;UIkit.components.dropdown.prototype.show=function(){return this.dropdown.css({"min-width":this.dropdown.outerWidth()}).addClass("uk-dropdown-active uk-dropdown-shown"),t.apply(this,arguments)}}(),function(){var t=UIkit.components.dropdown.prototype.hide;UIkit.components.dropdown.prototype.hide=function(){var o=this.dropdown;o.removeClass("uk-dropdown-shown");setTimeout(function(){o.removeClass("uk-dropdown-active")},280);return t.apply(this,arguments)}}()),"undefined"!=typeof UIkit.components.modal&&($.extend(UIkit.components.modal.prototype.defaults,{center:!0}),UIkit.modal.dialog.template='<div class="uk-modal uk-modal-dialog-replace"><div class="uk-modal-dialog" style="min-height:0;"></div></div>',$body.on("show.uk.modal",".uk-modal-dialog-replace",function(){setTimeout(function(){var t=$(".uk-modal-dialog-replace");if(t.find(".uk-button-primary").length){var o=t.find(".uk-button-primary").toggleClass("uk-button-primary md-btn-flat-primary");o.next("button")&&o.next("button").after(o)}t.find(".uk-button").length&&t.find(".uk-button").toggleClass("uk-button md-btn md-btn-flat"),t.find(".uk-margin-small-top").length&&t.find(".uk-margin-small-top").toggleClass("uk-margin-small-top uk-margin-top"),t.find("input.uk-width-1-1").length&&(t.find("input.uk-width-1-1").toggleClass("uk-width-1-1 md-input"),altair_md.inputs()),t.find(".uk-form").length&&t.find(".uk-form").removeClass("uk-form")},50)})),"undefined"!=typeof UIkit.components.tooltip&&$.extend(UIkit.components.tooltip.prototype.defaults,{animation:280,offset:8})});
|
Reference in New Issue
Block a user