|
@@ -328,3 +328,2031 @@ if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires j
|
|
})
|
|
})
|
|
|
|
|
|
}(window.jQuery);
|
|
}(window.jQuery);
|
|
|
|
+;/**
|
|
|
|
+ * jQuery Validation Plugin 1.9.0
|
|
|
|
+ *
|
|
|
|
+ * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
|
|
|
|
+ * http://docs.jquery.com/Plugins/Validation
|
|
|
|
+ *
|
|
|
|
+ * Copyright (c) 2006 - 2011 Jörn Zaefferer
|
|
|
|
+ *
|
|
|
|
+ * Dual licensed under the MIT and GPL licenses:
|
|
|
|
+ * http://www.opensource.org/licenses/mit-license.php
|
|
|
|
+ * http://www.gnu.org/licenses/gpl.html
|
|
|
|
+ */
|
|
|
|
+(function(c){c.extend(c.fn,{validate:function(a){if(this.length){var b=c.data(this[0],"validator");if(b)return b;this.attr("novalidate","novalidate");b=new c.validator(a,this[0]);c.data(this[0],"validator",b);if(b.settings.onsubmit){a=this.find("input, button");a.filter(".cancel").click(function(){b.cancelSubmit=true});b.settings.submitHandler&&a.filter(":submit").click(function(){b.submitButton=this});this.submit(function(d){function e(){if(b.settings.submitHandler){if(b.submitButton)var f=c("<input type='hidden'/>").attr("name",
|
|
|
|
+b.submitButton.name).val(b.submitButton.value).appendTo(b.currentForm);b.settings.submitHandler.call(b,b.currentForm);b.submitButton&&f.remove();return false}return true}b.settings.debug&&d.preventDefault();if(b.cancelSubmit){b.cancelSubmit=false;return e()}if(b.form()){if(b.pendingRequest){b.formSubmitted=true;return false}return e()}else{b.focusInvalid();return false}})}return b}else a&&a.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing")},valid:function(){if(c(this[0]).is("form"))return this.validate().form();
|
|
|
|
+else{var a=true,b=c(this[0].form).validate();this.each(function(){a&=b.element(this)});return a}},removeAttrs:function(a){var b={},d=this;c.each(a.split(/\s/),function(e,f){b[f]=d.attr(f);d.removeAttr(f)});return b},rules:function(a,b){var d=this[0];if(a){var e=c.data(d.form,"validator").settings,f=e.rules,g=c.validator.staticRules(d);switch(a){case "add":c.extend(g,c.validator.normalizeRule(b));f[d.name]=g;if(b.messages)e.messages[d.name]=c.extend(e.messages[d.name],b.messages);break;case "remove":if(!b){delete f[d.name];
|
|
|
|
+return g}var h={};c.each(b.split(/\s/),function(j,i){h[i]=g[i];delete g[i]});return h}}d=c.validator.normalizeRules(c.extend({},c.validator.metadataRules(d),c.validator.classRules(d),c.validator.attributeRules(d),c.validator.staticRules(d)),d);if(d.required){e=d.required;delete d.required;d=c.extend({required:e},d)}return d}});c.extend(c.expr[":"],{blank:function(a){return!c.trim(""+a.value)},filled:function(a){return!!c.trim(""+a.value)},unchecked:function(a){return!a.checked}});c.validator=function(a,
|
|
|
|
+b){this.settings=c.extend(true,{},c.validator.defaults,a);this.currentForm=b;this.init()};c.validator.format=function(a,b){if(arguments.length==1)return function(){var d=c.makeArray(arguments);d.unshift(a);return c.validator.format.apply(this,d)};if(arguments.length>2&&b.constructor!=Array)b=c.makeArray(arguments).slice(1);if(b.constructor!=Array)b=[b];c.each(b,function(d,e){a=a.replace(RegExp("\\{"+d+"\\}","g"),e)});return a};c.extend(c.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",
|
|
|
|
+validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:c([]),errorLabelContainer:c([]),onsubmit:true,ignore:":hidden",ignoreTitle:false,onfocusin:function(a){this.lastActive=a;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass);this.addWrapper(this.errorsFor(a)).hide()}},onfocusout:function(a){if(!this.checkable(a)&&(a.name in this.submitted||!this.optional(a)))this.element(a)},
|
|
|
|
+onkeyup:function(a){if(a.name in this.submitted||a==this.lastElement)this.element(a)},onclick:function(a){if(a.name in this.submitted)this.element(a);else a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).addClass(b).removeClass(d):c(a).addClass(b).removeClass(d)},unhighlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).removeClass(b).addClass(d):c(a).removeClass(b).addClass(d)}},setDefaults:function(a){c.extend(c.validator.defaults,
|
|
|
|
+a)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:c.validator.format("Please enter no more than {0} characters."),
|
|
|
|
+minlength:c.validator.format("Please enter at least {0} characters."),rangelength:c.validator.format("Please enter a value between {0} and {1} characters long."),range:c.validator.format("Please enter a value between {0} and {1}."),max:c.validator.format("Please enter a value less than or equal to {0}."),min:c.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){function a(e){var f=c.data(this[0].form,"validator"),g="on"+e.type.replace(/^validate/,
|
|
|
|
+"");f.settings[g]&&f.settings[g].call(f,this[0],e)}this.labelContainer=c(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||c(this.currentForm);this.containers=c(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var b=this.groups={};c.each(this.settings.groups,function(e,f){c.each(f.split(/\s/),function(g,h){b[h]=e})});var d=
|
|
|
|
+this.settings.rules;c.each(d,function(e,f){d[e]=c.validator.normalizeRule(f)});c(this.currentForm).validateDelegate("[type='text'], [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",a).validateDelegate("[type='radio'], [type='checkbox'], select, option","click",
|
|
|
|
+a);this.settings.invalidHandler&&c(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){this.checkForm();c.extend(this.submitted,this.errorMap);this.invalid=c.extend({},this.errorMap);this.valid()||c(this.currentForm).triggerHandler("invalid-form",[this]);this.showErrors();return this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(a){this.lastElement=
|
|
|
|
+a=this.validationTargetFor(this.clean(a));this.prepareElement(a);this.currentElements=c(a);var b=this.check(a);if(b)delete this.invalid[a.name];else this.invalid[a.name]=true;if(!this.numberOfInvalids())this.toHide=this.toHide.add(this.containers);this.showErrors();return b},showErrors:function(a){if(a){c.extend(this.errorMap,a);this.errorList=[];for(var b in a)this.errorList.push({message:a[b],element:this.findByName(b)[0]});this.successList=c.grep(this.successList,function(d){return!(d.name in a)})}this.settings.showErrors?
|
|
|
|
+this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){c.fn.resetForm&&c(this.currentForm).resetForm();this.submitted={};this.lastElement=null;this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b=0,d;for(d in a)b++;return b},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return this.size()==
|
|
|
|
+0},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{c(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(a){}},findLastActive:function(){var a=this.lastActive;return a&&c.grep(this.errorList,function(b){return b.element.name==a.name}).length==1&&a},elements:function(){var a=this,b={};return c(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&&
|
|
|
|
+a.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in b||!a.objectLength(c(this).rules()))return false;return b[this.name]=true})},clean:function(a){return c(a)[0]},errors:function(){return c(this.settings.errorElement+"."+this.settings.errorClass,this.errorContext)},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=c([]);this.toHide=c([]);this.currentElements=c([])},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers)},
|
|
|
|
+prepareElement:function(a){this.reset();this.toHide=this.errorsFor(a)},check:function(a){a=this.validationTargetFor(this.clean(a));var b=c(a).rules(),d=false,e;for(e in b){var f={method:e,parameters:b[e]};try{var g=c.validator.methods[e].call(this,a.value.replace(/\r/g,""),a,f.parameters);if(g=="dependency-mismatch")d=true;else{d=false;if(g=="pending"){this.toHide=this.toHide.not(this.errorsFor(a));return}if(!g){this.formatAndAdd(a,f);return false}}}catch(h){this.settings.debug&&window.console&&console.log("exception occured when checking element "+
|
|
|
|
+a.id+", check the '"+f.method+"' method",h);throw h;}}if(!d){this.objectLength(b)&&this.successList.push(a);return true}},customMetaMessage:function(a,b){if(c.metadata){var d=this.settings.meta?c(a).metadata()[this.settings.meta]:c(a).metadata();return d&&d.messages&&d.messages[b]}},customMessage:function(a,b){var d=this.settings.messages[a];return d&&(d.constructor==String?d:d[b])},findDefined:function(){for(var a=0;a<arguments.length;a++)if(arguments[a]!==undefined)return arguments[a]},defaultMessage:function(a,
|
|
|
|
+b){return this.findDefined(this.customMessage(a.name,b),this.customMetaMessage(a,b),!this.settings.ignoreTitle&&a.title||undefined,c.validator.messages[b],"<strong>Warning: No message defined for "+a.name+"</strong>")},formatAndAdd:function(a,b){var d=this.defaultMessage(a,b.method),e=/\$?\{(\d+)\}/g;if(typeof d=="function")d=d.call(this,b.parameters,a);else if(e.test(d))d=jQuery.format(d.replace(e,"{$1}"),b.parameters);this.errorList.push({message:d,element:a});this.errorMap[a.name]=d;this.submitted[a.name]=
|
|
|
|
+d},addWrapper:function(a){if(this.settings.wrapper)a=a.add(a.parent(this.settings.wrapper));return a},defaultShowErrors:function(){for(var a=0;this.errorList[a];a++){var b=this.errorList[a];this.settings.highlight&&this.settings.highlight.call(this,b.element,this.settings.errorClass,this.settings.validClass);this.showLabel(b.element,b.message)}if(this.errorList.length)this.toShow=this.toShow.add(this.containers);if(this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);
|
|
|
|
+if(this.settings.unhighlight){a=0;for(b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass)}this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return c(this.errorList).map(function(){return this.element})},showLabel:function(a,b){var d=this.errorsFor(a);if(d.length){d.removeClass(this.settings.validClass).addClass(this.settings.errorClass);
|
|
|
|
+d.attr("generated")&&d.html(b)}else{d=c("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(a),generated:true}).addClass(this.settings.errorClass).html(b||"");if(this.settings.wrapper)d=d.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();this.labelContainer.append(d).length||(this.settings.errorPlacement?this.settings.errorPlacement(d,c(a)):d.insertAfter(a))}if(!b&&this.settings.success){d.text("");typeof this.settings.success=="string"?d.addClass(this.settings.success):this.settings.success(d)}this.toShow=
|
|
|
|
+this.toShow.add(d)},errorsFor:function(a){var b=this.idOrName(a);return this.errors().filter(function(){return c(this).attr("for")==b})},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},validationTargetFor:function(a){if(this.checkable(a))a=this.findByName(a.name).not(this.settings.ignore)[0];return a},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(a){var b=this.currentForm;return c(document.getElementsByName(a)).map(function(d,
|
|
|
|
+e){return e.form==b&&e.name==a&&e||null})},getLength:function(a,b){switch(b.nodeName.toLowerCase()){case "select":return c("option:selected",b).length;case "input":if(this.checkable(b))return this.findByName(b.name).filter(":checked").length}return a.length},depend:function(a,b){return this.dependTypes[typeof a]?this.dependTypes[typeof a](a,b):true},dependTypes:{"boolean":function(a){return a},string:function(a,b){return!!c(a,b.form).length},"function":function(a,b){return a(b)}},optional:function(a){return!c.validator.methods.required.call(this,
|
|
|
|
+c.trim(a.value),a)&&"dependency-mismatch"},startRequest:function(a){if(!this.pending[a.name]){this.pendingRequest++;this.pending[a.name]=true}},stopRequest:function(a,b){this.pendingRequest--;if(this.pendingRequest<0)this.pendingRequest=0;delete this.pending[a.name];if(b&&this.pendingRequest==0&&this.formSubmitted&&this.form()){c(this.currentForm).submit();this.formSubmitted=false}else if(!b&&this.pendingRequest==0&&this.formSubmitted){c(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=
|
|
|
|
+false}},previousValue:function(a){return c.data(a,"previousValue")||c.data(a,"previousValue",{old:null,valid:true,message:this.defaultMessage(a,"remote")})}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(a,b){a.constructor==String?this.classRuleSettings[a]=b:c.extend(this.classRuleSettings,
|
|
|
|
+a)},classRules:function(a){var b={};(a=c(a).attr("class"))&&c.each(a.split(" "),function(){this in c.validator.classRuleSettings&&c.extend(b,c.validator.classRuleSettings[this])});return b},attributeRules:function(a){var b={};a=c(a);for(var d in c.validator.methods){var e;if(e=d==="required"&&typeof c.fn.prop==="function"?a.prop(d):a.attr(d))b[d]=e;else if(a[0].getAttribute("type")===d)b[d]=true}b.maxlength&&/-1|2147483647|524288/.test(b.maxlength)&&delete b.maxlength;return b},metadataRules:function(a){if(!c.metadata)return{};
|
|
|
|
+var b=c.data(a.form,"validator").settings.meta;return b?c(a).metadata()[b]:c(a).metadata()},staticRules:function(a){var b={},d=c.data(a.form,"validator");if(d.settings.rules)b=c.validator.normalizeRule(d.settings.rules[a.name])||{};return b},normalizeRules:function(a,b){c.each(a,function(d,e){if(e===false)delete a[d];else if(e.param||e.depends){var f=true;switch(typeof e.depends){case "string":f=!!c(e.depends,b.form).length;break;case "function":f=e.depends.call(b,b)}if(f)a[d]=e.param!==undefined?
|
|
|
|
+e.param:true;else delete a[d]}});c.each(a,function(d,e){a[d]=c.isFunction(e)?e(b):e});c.each(["minlength","maxlength","min","max"],function(){if(a[this])a[this]=Number(a[this])});c.each(["rangelength","range"],function(){if(a[this])a[this]=[Number(a[this][0]),Number(a[this][1])]});if(c.validator.autoCreateRanges){if(a.min&&a.max){a.range=[a.min,a.max];delete a.min;delete a.max}if(a.minlength&&a.maxlength){a.rangelength=[a.minlength,a.maxlength];delete a.minlength;delete a.maxlength}}a.messages&&delete a.messages;
|
|
|
|
+return a},normalizeRule:function(a){if(typeof a=="string"){var b={};c.each(a.split(/\s/),function(){b[this]=true});a=b}return a},addMethod:function(a,b,d){c.validator.methods[a]=b;c.validator.messages[a]=d!=undefined?d:c.validator.messages[a];b.length<3&&c.validator.addClassRules(a,c.validator.normalizeRule(a))},methods:{required:function(a,b,d){if(!this.depend(d,b))return"dependency-mismatch";switch(b.nodeName.toLowerCase()){case "select":return(a=c(b).val())&&a.length>0;case "input":if(this.checkable(b))return this.getLength(a,
|
|
|
|
+b)>0;default:return c.trim(a).length>0}},remote:function(a,b,d){if(this.optional(b))return"dependency-mismatch";var e=this.previousValue(b);this.settings.messages[b.name]||(this.settings.messages[b.name]={});e.originalMessage=this.settings.messages[b.name].remote;this.settings.messages[b.name].remote=e.message;d=typeof d=="string"&&{url:d}||d;if(this.pending[b.name])return"pending";if(e.old===a)return e.valid;e.old=a;var f=this;this.startRequest(b);var g={};g[b.name]=a;c.ajax(c.extend(true,{url:d,
|
|
|
|
+mode:"abort",port:"validate"+b.name,dataType:"json",data:g,success:function(h){f.settings.messages[b.name].remote=e.originalMessage;var j=h===true;if(j){var i=f.formSubmitted;f.prepareElement(b);f.formSubmitted=i;f.successList.push(b);f.showErrors()}else{i={};h=h||f.defaultMessage(b,"remote");i[b.name]=e.message=c.isFunction(h)?h(a):h;f.showErrors(i)}e.valid=j;f.stopRequest(b,j)}},d));return"pending"},minlength:function(a,b,d){return this.optional(b)||this.getLength(c.trim(a),b)>=d},maxlength:function(a,
|
|
|
|
+b,d){return this.optional(b)||this.getLength(c.trim(a),b)<=d},rangelength:function(a,b,d){a=this.getLength(c.trim(a),b);return this.optional(b)||a>=d[0]&&a<=d[1]},min:function(a,b,d){return this.optional(b)||a>=d},max:function(a,b,d){return this.optional(b)||a<=d},range:function(a,b,d){return this.optional(b)||a>=d[0]&&a<=d[1]},email:function(a,b){return this.optional(b)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(a)},
|
|
|
|
+url:function(a,b){return this.optional(b)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)},
|
|
|
|
+date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a))},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(a)},number:function(a,b){return this.optional(b)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},creditcard:function(a,b){if(this.optional(b))return"dependency-mismatch";if(/[^0-9 -]+/.test(a))return false;var d=0,e=0,f=false;a=a.replace(/\D/g,"");for(var g=a.length-1;g>=
|
|
|
|
+0;g--){e=a.charAt(g);e=parseInt(e,10);if(f)if((e*=2)>9)e-=9;d+=e;f=!f}return d%10==0},accept:function(a,b,d){d=typeof d=="string"?d.replace(/,/g,"|"):"png|jpe?g|gif";return this.optional(b)||a.match(RegExp(".("+d+")$","i"))},equalTo:function(a,b,d){d=c(d).unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){c(b).valid()});return a==d.val()}}});c.format=c.validator.format})(jQuery);
|
|
|
|
+(function(c){var a={};if(c.ajaxPrefilter)c.ajaxPrefilter(function(d,e,f){e=d.port;if(d.mode=="abort"){a[e]&&a[e].abort();a[e]=f}});else{var b=c.ajax;c.ajax=function(d){var e=("port"in d?d:c.ajaxSettings).port;if(("mode"in d?d:c.ajaxSettings).mode=="abort"){a[e]&&a[e].abort();return a[e]=b.apply(this,arguments)}return b.apply(this,arguments)}}})(jQuery);
|
|
|
|
+(function(c){!jQuery.event.special.focusin&&!jQuery.event.special.focusout&&document.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.handle.call(this,e)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)},handler:function(e){arguments[0]=c.event.fix(e);arguments[0].type=b;return c.event.handle.apply(this,arguments)}}});c.extend(c.fn,{validateDelegate:function(a,
|
|
|
|
+b,d){return this.bind(b,function(e){var f=c(e.target);if(f.is(a))return d.apply(f,arguments)})}})})(jQuery);
|
|
|
|
+;// ------------- JQUERY APPEAR ---------------------------------------------- //
|
|
|
|
+// ============ https://github.com/morr/jquery.appear ====================== //
|
|
|
|
+// -------------------------------------------------------------------------- //
|
|
|
|
+
|
|
|
|
+(function($) {
|
|
|
|
+ var selectors = [];
|
|
|
|
+
|
|
|
|
+ var check_binded = false;
|
|
|
|
+ var check_lock = false;
|
|
|
|
+ var defaults = {
|
|
|
|
+ interval: 250,
|
|
|
|
+ force_process: false
|
|
|
|
+ }
|
|
|
|
+ var $window = $(window);
|
|
|
|
+
|
|
|
|
+ var $prior_appeared;
|
|
|
|
+
|
|
|
|
+ function process() {
|
|
|
|
+ check_lock = false;
|
|
|
|
+ for (var index = 0, selectorsLength = selectors.length; index < selectorsLength; index++) {
|
|
|
|
+ var $appeared = $(selectors[index]).filter(function() {
|
|
|
|
+ return $(this).is(':appeared');
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ $appeared.trigger('appear', [$appeared]);
|
|
|
|
+
|
|
|
|
+ if ($prior_appeared) {
|
|
|
|
+ var $disappeared = $prior_appeared.not($appeared);
|
|
|
|
+ $disappeared.trigger('disappear', [$disappeared]);
|
|
|
|
+ }
|
|
|
|
+ $prior_appeared = $appeared;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // "appeared" custom filter
|
|
|
|
+ $.expr[':']['appeared'] = function(element) {
|
|
|
|
+ var $element = $(element);
|
|
|
|
+ if (!$element.is(':visible')) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var window_left = $window.scrollLeft();
|
|
|
|
+ var window_top = $window.scrollTop();
|
|
|
|
+ var offset = $element.offset();
|
|
|
|
+ var left = offset.left;
|
|
|
|
+ var top = offset.top;
|
|
|
|
+
|
|
|
|
+ if (top + $element.height() >= window_top &&
|
|
|
|
+ top - ($element.data('appear-top-offset') || 0) <= window_top + $window.height() &&
|
|
|
|
+ left + $element.width() >= window_left &&
|
|
|
|
+ left - ($element.data('appear-left-offset') || 0) <= window_left + $window.width()) {
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $.fn.extend({
|
|
|
|
+ // watching for element's appearance in browser viewport
|
|
|
|
+ appear: function(options) {
|
|
|
|
+ var opts = $.extend({}, defaults, options || {});
|
|
|
|
+ var selector = this.selector || this;
|
|
|
|
+ if (!check_binded) {
|
|
|
|
+ var on_check = function() {
|
|
|
|
+ if (check_lock) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ check_lock = true;
|
|
|
|
+
|
|
|
|
+ setTimeout(process, opts.interval);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ $(window).scroll(on_check).resize(on_check);
|
|
|
|
+ check_binded = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (opts.force_process) {
|
|
|
|
+ setTimeout(process, opts.interval);
|
|
|
|
+ }
|
|
|
|
+ selectors.push(selector);
|
|
|
|
+ return $(selector);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ $.extend({
|
|
|
|
+ // force elements's appearance check
|
|
|
|
+ force_appear: function() {
|
|
|
|
+ if (check_binded) {
|
|
|
|
+ process();
|
|
|
|
+ return true;
|
|
|
|
+ };
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+})(jQuery);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// ------------- DRAW FILL SVG ---------------------------------------------- //
|
|
|
|
+// ============ https://github.com/callmenick/Draw-Fill-SVG ================= //
|
|
|
|
+// -------------------------------------------------------------------------- //
|
|
|
|
+
|
|
|
|
+(function( window ){
|
|
|
|
+
|
|
|
|
+ 'use strict';
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Cross browser transition end events
|
|
|
|
+ *
|
|
|
|
+ * Use modernizr to detect cross browser transition end events. Make sure
|
|
|
|
+ * to include Modernizr in your doc and have "Modernizr.prefixed()" checked
|
|
|
|
+ * off in the extensibility section.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ var transEndEventNames = {
|
|
|
|
+ "WebkitTransition" : "webkitTransitionEnd",
|
|
|
|
+ "MozTransition" : "transitionend",
|
|
|
|
+ "OTransition" : "oTransitionEnd",
|
|
|
|
+ "msTransition" : "MSTransitionEnd",
|
|
|
|
+ "transition" : "transitionend"
|
|
|
|
+ },
|
|
|
|
+ transEndEventName = transEndEventNames[ Modernizr.prefixed('transition') ];
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Extend obj function
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ function extend( a, b ) {
|
|
|
|
+ for( var key in b ) {
|
|
|
|
+ if( b.hasOwnProperty( key ) ) {
|
|
|
|
+ a[key] = b[key];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return a;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * DrawFillSVG constructor
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ function DrawFillSVG( options ) {
|
|
|
|
+ this.options = extend( {}, this.options );
|
|
|
|
+ extend( this.options, options );
|
|
|
|
+ this._init();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * DrawFillSVG options
|
|
|
|
+ *
|
|
|
|
+ * Available options:
|
|
|
|
+ * elementId - the ID of the element to draw
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ DrawFillSVG.prototype.options = {
|
|
|
|
+ elementId : "svg"
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * DrawFillSVG _init
|
|
|
|
+ *
|
|
|
|
+ * Initialise DrawFillSVG
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ DrawFillSVG.prototype._init = function() {
|
|
|
|
+ this.svg = document.getElementById(this.options.elementId);
|
|
|
|
+ this.paths = this.svg.querySelectorAll("path");
|
|
|
|
+ this._initAnimation();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * DrawFillSVG _initAnimation()
|
|
|
|
+ *
|
|
|
|
+ * Reset some style properties on our paths, add some transitions, set the
|
|
|
|
+ * stroke-dasharray to the length of the path, and the stroke-dashoffset to
|
|
|
|
+ * the length of the path pushing it out of view initially. Then, set the
|
|
|
|
+ * stroke-dashoffset to 0, animating the strokes in a drawing manner. Then,
|
|
|
|
+ * run the path filler sequence.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ DrawFillSVG.prototype._initAnimation = function() {
|
|
|
|
+ for ( var i = 0; i < this.paths.length; i++ ) {
|
|
|
|
+ var path = this.paths[i];
|
|
|
|
+ var length = path.getTotalLength();
|
|
|
|
+
|
|
|
|
+ // reset opacities
|
|
|
|
+ path.style.fillOpacity = 0;
|
|
|
|
+ path.style.strokeOpacity = 1;
|
|
|
|
+
|
|
|
|
+ // reset transitions
|
|
|
|
+ path.style.transition = path.style.WebkitTransition = "none";
|
|
|
|
+
|
|
|
|
+ // reset stroke dash array and stroke dash offset
|
|
|
|
+ path.style.strokeDasharray = length + " " + length;
|
|
|
|
+ path.style.strokeDashoffset = length;
|
|
|
|
+ path.getBoundingClientRect();
|
|
|
|
+
|
|
|
|
+ // apply new transitions
|
|
|
|
+ path.style.transition = path.style.WebkitTransition = "stroke-dashoffset 2s ease-in-out";
|
|
|
|
+
|
|
|
|
+ // go baby go
|
|
|
|
+ path.style.strokeDashoffset = 0;
|
|
|
|
+
|
|
|
|
+ // fill the path
|
|
|
|
+ this._fillPath( path );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * DrawFillSVG _fillPath()
|
|
|
|
+ *
|
|
|
|
+ * Resets the transition props, then fills the path and fades out the stroke
|
|
|
|
+ * by updating the styles.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ DrawFillSVG.prototype._fillPath = function( path ) {
|
|
|
|
+ path.addEventListener( transEndEventName, function() {
|
|
|
|
+ // reset transitions
|
|
|
|
+ path.style.transition = path.style.WebkitTransition = "none";
|
|
|
|
+ path.style.transition = path.style.WebkitTransition = "fill-opacity 1s ease-in-out, stroke-opacity 1s ease-in-out";
|
|
|
|
+
|
|
|
|
+ // edit props
|
|
|
|
+ path.style.fillOpacity = 1;
|
|
|
|
+ path.style.strokeOpacity = 0;
|
|
|
|
+ } );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * DrawFillSVG replay
|
|
|
|
+ *
|
|
|
|
+ * A public function that allows you to replay the animation if you want. For
|
|
|
|
+ * example, click a button, and replay the animation.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ DrawFillSVG.prototype.replay = function() {
|
|
|
|
+ this._initAnimation();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Add to global namespace
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ window.DrawFillSVG = DrawFillSVG;
|
|
|
|
+
|
|
|
|
+})( window );
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// ------------- JQUERY TYPED.JS -------------------------------------------- //
|
|
|
|
+// ============ https://github.com/mattboldt/typed.js/ ====================== //
|
|
|
|
+// -------------------------------------------------------------------------- //
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+!function($){
|
|
|
|
+
|
|
|
|
+ "use strict";
|
|
|
|
+
|
|
|
|
+ var Typed = function(el, options){
|
|
|
|
+
|
|
|
|
+ // chosen element to manipulate text
|
|
|
|
+ this.el = $(el);
|
|
|
|
+
|
|
|
|
+ // options
|
|
|
|
+ this.options = $.extend({}, $.fn.typed.defaults, options);
|
|
|
|
+
|
|
|
|
+ // text content of element
|
|
|
|
+ this.baseText = this.el.text() || this.el.attr('placeholder') || '';
|
|
|
|
+
|
|
|
|
+ // typing speed
|
|
|
|
+ this.typeSpeed = this.options.typeSpeed;
|
|
|
|
+
|
|
|
|
+ // add a delay before typing starts
|
|
|
|
+ this.startDelay = this.options.startDelay;
|
|
|
|
+
|
|
|
|
+ // backspacing speed
|
|
|
|
+ this.backSpeed = this.options.backSpeed;
|
|
|
|
+
|
|
|
|
+ // amount of time to wait before backspacing
|
|
|
|
+ this.backDelay = this.options.backDelay;
|
|
|
|
+
|
|
|
|
+ // input strings of text
|
|
|
|
+ this.strings = this.options.strings;
|
|
|
|
+
|
|
|
|
+ // character number position of current string
|
|
|
|
+ this.strPos = 0;
|
|
|
|
+
|
|
|
|
+ // current array position
|
|
|
|
+ this.arrayPos = 0;
|
|
|
|
+
|
|
|
|
+ // number to stop backspacing on.
|
|
|
|
+ // default 0, can change depending on how many chars
|
|
|
|
+ // you want to remove at the time
|
|
|
|
+ this.stopNum = 0;
|
|
|
|
+
|
|
|
|
+ // Looping logic
|
|
|
|
+ this.loop = this.options.loop;
|
|
|
|
+ this.loopCount = this.options.loopCount;
|
|
|
|
+ this.curLoop = 0;
|
|
|
|
+
|
|
|
|
+ // for stopping
|
|
|
|
+ this.stop = false;
|
|
|
|
+
|
|
|
|
+ // show cursor
|
|
|
|
+ this.showCursor = this.isInput ? false : this.options.showCursor;
|
|
|
|
+
|
|
|
|
+ // custom cursor
|
|
|
|
+ this.cursorChar = this.options.cursorChar;
|
|
|
|
+
|
|
|
|
+ // attribute to type
|
|
|
|
+ this.isInput = this.el.is('input');
|
|
|
|
+ this.attr = this.options.attr || (this.isInput ? 'placeholder' : null);
|
|
|
|
+
|
|
|
|
+ // All systems go!
|
|
|
|
+ this.build();
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Typed.prototype = {
|
|
|
|
+
|
|
|
|
+ constructor: Typed
|
|
|
|
+
|
|
|
|
+ , init: function(){
|
|
|
|
+ // begin the loop w/ first current string (global self.string)
|
|
|
|
+ // current string will be passed as an argument each time after this
|
|
|
|
+ var self = this;
|
|
|
|
+ self.timeout = setTimeout(function() {
|
|
|
|
+ // Start typing
|
|
|
|
+ self.typewrite(self.strings[self.arrayPos], self.strPos);
|
|
|
|
+ }, self.startDelay);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ , build: function(){
|
|
|
|
+ // Insert cursor
|
|
|
|
+ if (this.showCursor === true){
|
|
|
|
+ this.cursor = $("<span class=\"typed-cursor\">" + this.cursorChar + "</span>");
|
|
|
|
+ this.el.after(this.cursor);
|
|
|
|
+ }
|
|
|
|
+ this.init();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // pass current string state to each function, types 1 char per call
|
|
|
|
+ , typewrite: function(curString, curStrPos){
|
|
|
|
+ // exit when stopped
|
|
|
|
+ if(this.stop === true)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ // varying values for setTimeout during typing
|
|
|
|
+ // can't be global since number changes each time loop is executed
|
|
|
|
+ var humanize = Math.round(Math.random() * (100 - 30)) + this.typeSpeed;
|
|
|
|
+ var self = this;
|
|
|
|
+
|
|
|
|
+ // ------------- optional ------------- //
|
|
|
|
+ // backpaces a certain string faster
|
|
|
|
+ // ------------------------------------ //
|
|
|
|
+ // if (self.arrayPos == 1){
|
|
|
|
+ // self.backDelay = 50;
|
|
|
|
+ // }
|
|
|
|
+ // else{ self.backDelay = 500; }
|
|
|
|
+
|
|
|
|
+ // contain typing function in a timeout humanize'd delay
|
|
|
|
+ self.timeout = setTimeout(function() {
|
|
|
|
+ // check for an escape character before a pause value
|
|
|
|
+ // format: \^\d+ .. eg: ^1000 .. should be able to print the ^ too using ^^
|
|
|
|
+ // single ^ are removed from string
|
|
|
|
+ var charPause = 0;
|
|
|
|
+ var substr = curString.substr(curStrPos);
|
|
|
|
+ if (substr.charAt(0) === '^') {
|
|
|
|
+ var skip = 1; // skip atleast 1
|
|
|
|
+ if(/^\^\d+/.test(substr)) {
|
|
|
|
+ substr = /\d+/.exec(substr)[0];
|
|
|
|
+ skip += substr.length;
|
|
|
|
+ charPause = parseInt(substr);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // strip out the escape character and pause value so they're not printed
|
|
|
|
+ curString = curString.substring(0,curStrPos)+curString.substring(curStrPos+skip);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // timeout for any pause after a character
|
|
|
|
+ self.timeout = setTimeout(function() {
|
|
|
|
+ if(curStrPos === curString.length) {
|
|
|
|
+ // fires callback function
|
|
|
|
+ self.options.onStringTyped(self.arrayPos);
|
|
|
|
+
|
|
|
|
+ // is this the final string
|
|
|
|
+ if(self.arrayPos === self.strings.length-1) {
|
|
|
|
+ // animation that occurs on the last typed string
|
|
|
|
+ self.options.callback();
|
|
|
|
+
|
|
|
|
+ self.curLoop++;
|
|
|
|
+
|
|
|
|
+ // quit if we wont loop back
|
|
|
|
+ if(self.loop === false || self.curLoop === self.loopCount)
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ self.timeout = setTimeout(function(){
|
|
|
|
+ self.backspace(curString, curStrPos);
|
|
|
|
+ }, self.backDelay);
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ /* call before functions if applicable */
|
|
|
|
+ if(curStrPos === 0)
|
|
|
|
+ self.options.preStringTyped(self.arrayPos);
|
|
|
|
+
|
|
|
|
+ // start typing each new char into existing string
|
|
|
|
+ // curString: arg, self.baseText: original text inside element
|
|
|
|
+ var nextString = self.baseText + curString.substr(0, curStrPos+1);
|
|
|
|
+ if (self.attr) {
|
|
|
|
+ self.el.attr(self.attr, nextString);
|
|
|
|
+ } else {
|
|
|
|
+ self.el.text(nextString);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // add characters one by one
|
|
|
|
+ curStrPos++;
|
|
|
|
+ // loop the function
|
|
|
|
+ self.typewrite(curString, curStrPos);
|
|
|
|
+ }
|
|
|
|
+ // end of character pause
|
|
|
|
+ }, charPause);
|
|
|
|
+
|
|
|
|
+ // humanized value for typing
|
|
|
|
+ }, humanize);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ , backspace: function(curString, curStrPos){
|
|
|
|
+ // exit when stopped
|
|
|
|
+ if (this.stop === true) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // varying values for setTimeout during typing
|
|
|
|
+ // can't be global since number changes each time loop is executed
|
|
|
|
+ var humanize = Math.round(Math.random() * (100 - 30)) + this.backSpeed;
|
|
|
|
+ var self = this;
|
|
|
|
+
|
|
|
|
+ self.timeout = setTimeout(function() {
|
|
|
|
+
|
|
|
|
+ // ----- this part is optional ----- //
|
|
|
|
+ // check string array position
|
|
|
|
+ // on the first string, only delete one word
|
|
|
|
+ // the stopNum actually represents the amount of chars to
|
|
|
|
+
|
|
|
|
+// ------------- CUSTOM OPTIONS --------------------------------------------- //
|
|
|
|
+// ========================================================================== //
|
|
|
|
+// -------------------------------------------------------------------------- //
|
|
|
|
+ if (self.arrayPos == 1) {
|
|
|
|
+ self.stopNum = 17;
|
|
|
|
+ self.backDelay = 500;
|
|
|
|
+ }
|
|
|
|
+ else if (self.arrayPos == 2) {
|
|
|
|
+ self.stopNum = 54;
|
|
|
|
+ }
|
|
|
|
+ else{self.stopNum = 0;}
|
|
|
|
+
|
|
|
|
+ // ----- continue important stuff ----- //
|
|
|
|
+ // replace text with base text + typed characters
|
|
|
|
+ var nextString = self.baseText + curString.substr(0, curStrPos);
|
|
|
|
+ if (self.attr) {
|
|
|
|
+ self.el.attr(self.attr, nextString);
|
|
|
|
+ } else {
|
|
|
|
+ self.el.text(nextString);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // if the number (id of character in current string) is
|
|
|
|
+ // less than the stop number, keep going
|
|
|
|
+ if (curStrPos > self.stopNum){
|
|
|
|
+ // subtract characters one by one
|
|
|
|
+ curStrPos--;
|
|
|
|
+ // loop the function
|
|
|
|
+ self.backspace(curString, curStrPos);
|
|
|
|
+ }
|
|
|
|
+ // if the stop number has been reached, increase
|
|
|
|
+ // array position to next string
|
|
|
|
+ else if (curStrPos <= self.stopNum) {
|
|
|
|
+ self.arrayPos++;
|
|
|
|
+
|
|
|
|
+ if(self.arrayPos === self.strings.length) {
|
|
|
|
+ self.arrayPos = 0;
|
|
|
|
+ self.init();
|
|
|
|
+ } else
|
|
|
|
+ self.typewrite(self.strings[self.arrayPos], curStrPos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // humanized value for typing
|
|
|
|
+ }, humanize);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Start & Stop currently not working
|
|
|
|
+
|
|
|
|
+ // , stop: function() {
|
|
|
|
+ // var self = this;
|
|
|
|
+
|
|
|
|
+ // self.stop = true;
|
|
|
|
+ // clearInterval(self.timeout);
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // , start: function() {
|
|
|
|
+ // var self = this;
|
|
|
|
+ // if(self.stop === false)
|
|
|
|
+ // return;
|
|
|
|
+
|
|
|
|
+ // this.stop = false;
|
|
|
|
+ // this.init();
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // Reset and rebuild the element
|
|
|
|
+ , reset: function(){
|
|
|
|
+ var self = this;
|
|
|
|
+ clearInterval(self.timeout);
|
|
|
|
+ var id = this.el.attr('id');
|
|
|
|
+ this.el.after('<span id="' + id + '"/>')
|
|
|
|
+ this.el.remove();
|
|
|
|
+ this.cursor.remove();
|
|
|
|
+ // Send the callback
|
|
|
|
+ self.options.resetCallback();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ $.fn.typed = function (option) {
|
|
|
|
+ return this.each(function () {
|
|
|
|
+ var $this = $(this)
|
|
|
|
+ , data = $this.data('typed')
|
|
|
|
+ , options = typeof option == 'object' && option;
|
|
|
|
+ if (!data) $this.data('typed', (data = new Typed(this, options)));
|
|
|
|
+ if (typeof option == 'string') data[option]();
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ $.fn.typed.defaults = {
|
|
|
|
+ strings: ["These are the default values...", "You know what you should do?", "Use your own!", "Have a great day!"],
|
|
|
|
+ // typing speed
|
|
|
|
+ typeSpeed: 0,
|
|
|
|
+ // time before typing starts
|
|
|
|
+ startDelay: 0,
|
|
|
|
+ // backspacing speed
|
|
|
|
+ backSpeed: 0,
|
|
|
|
+ // time before backspacing
|
|
|
|
+ backDelay: 500,
|
|
|
|
+ // loop
|
|
|
|
+ loop: false,
|
|
|
|
+ // false = infinite
|
|
|
|
+ loopCount: false,
|
|
|
|
+ // show cursor
|
|
|
|
+ showCursor: true,
|
|
|
|
+ // character for cursor
|
|
|
|
+ cursorChar: "|",
|
|
|
|
+ // attribute to type (null == text)
|
|
|
|
+ attr: null,
|
|
|
|
+ // call when done callback function
|
|
|
|
+ callback: function() {},
|
|
|
|
+ // starting callback function before each string
|
|
|
|
+ preStringTyped: function() {},
|
|
|
|
+ //callback for every typed string
|
|
|
|
+ onStringTyped: function() {},
|
|
|
|
+ // callback for reset
|
|
|
|
+ resetCallback: function() {}
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}(window.jQuery);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// ------------- JQUERY SCROLLTO--------------------------------------------- //
|
|
|
|
+// ============ https://github.com/balupton/jquery-scrollto ================= //
|
|
|
|
+// -------------------------------------------------------------------------- //
|
|
|
|
+
|
|
|
|
+/*global define:false require:false */
|
|
|
|
+(function (name, context, definition) {
|
|
|
|
+ if (typeof module != 'undefined' && module.exports) module.exports = definition();
|
|
|
|
+ else if (typeof define == 'function' && define.amd) define(definition);
|
|
|
|
+ else context[name] = definition();
|
|
|
|
+})('jquery-scrollto', this, function(){
|
|
|
|
+ // Prepare
|
|
|
|
+ var jQuery, $, ScrollTo;
|
|
|
|
+ jQuery = $ = window.jQuery || require('jquery');
|
|
|
|
+
|
|
|
|
+ // Fix scrolling animations on html/body on safari
|
|
|
|
+ $.propHooks.scrollTop = $.propHooks.scrollLeft = {
|
|
|
|
+ get: function(elem,prop) {
|
|
|
|
+ var result = null;
|
|
|
|
+ if ( elem.tagName === 'HTML' || elem.tagName === 'BODY' ) {
|
|
|
|
+ if ( prop === 'scrollLeft' ) {
|
|
|
|
+ result = window.scrollX;
|
|
|
|
+ } else if ( prop === 'scrollTop' ) {
|
|
|
|
+ result = window.scrollY;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ( result == null ) {
|
|
|
|
+ result = elem[prop];
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ $.Tween.propHooks.scrollTop = $.Tween.propHooks.scrollLeft = {
|
|
|
|
+ get: function(tween) {
|
|
|
|
+ return $.propHooks.scrollTop.get(tween.elem, tween.prop);
|
|
|
|
+ },
|
|
|
|
+ set: function(tween) {
|
|
|
|
+ // Our safari fix
|
|
|
|
+ if ( tween.elem.tagName === 'HTML' || tween.elem.tagName === 'BODY' ) {
|
|
|
|
+ // Defaults
|
|
|
|
+ tween.options.bodyScrollLeft = (tween.options.bodyScrollLeft || window.scrollX);
|
|
|
|
+ tween.options.bodyScrollTop = (tween.options.bodyScrollTop || window.scrollY);
|
|
|
|
+
|
|
|
|
+ // Apply
|
|
|
|
+ if ( tween.prop === 'scrollLeft' ) {
|
|
|
|
+ tween.options.bodyScrollLeft = Math.round(tween.now);
|
|
|
|
+ }
|
|
|
|
+ else if ( tween.prop === 'scrollTop' ) {
|
|
|
|
+ tween.options.bodyScrollTop = Math.round(tween.now);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Apply
|
|
|
|
+ window.scrollTo(tween.options.bodyScrollLeft, tween.options.bodyScrollTop);
|
|
|
|
+ }
|
|
|
|
+ // jQuery's IE8 Fix
|
|
|
|
+ else if ( tween.elem.nodeType && tween.elem.parentNode ) {
|
|
|
|
+ tween.elem[ tween.prop ] = tween.now;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // jQuery ScrollTo
|
|
|
|
+ ScrollTo = {
|
|
|
|
+ // Configuration
|
|
|
|
+ config: {
|
|
|
|
+ duration: 400,
|
|
|
|
+ easing: 'swing',
|
|
|
|
+ callback: undefined,
|
|
|
|
+ durationMode: 'each',
|
|
|
|
+ offsetTop: 0,
|
|
|
|
+ offsetLeft: 0
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // Set Configuration
|
|
|
|
+ configure: function(options){
|
|
|
|
+ // Apply Options to Config
|
|
|
|
+ $.extend(ScrollTo.config, options||{});
|
|
|
|
+
|
|
|
|
+ // Chain
|
|
|
|
+ return this;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // Perform the Scroll Animation for the Collections
|
|
|
|
+ // We use $inline here, so we can determine the actual offset start for each overflow:scroll item
|
|
|
|
+ // Each collection is for each overflow:scroll item
|
|
|
|
+ scroll: function(collections, config){
|
|
|
|
+ // Prepare
|
|
|
|
+ var collection, $container, container, $target, $inline, position, containerTagName,
|
|
|
|
+ containerScrollTop, containerScrollLeft,
|
|
|
|
+ containerScrollTopEnd, containerScrollLeftEnd,
|
|
|
|
+ startOffsetTop, targetOffsetTop, targetOffsetTopAdjusted,
|
|
|
|
+ startOffsetLeft, targetOffsetLeft, targetOffsetLeftAdjusted,
|
|
|
|
+ scrollOptions,
|
|
|
|
+ callback;
|
|
|
|
+
|
|
|
|
+ // Determine the Scroll
|
|
|
|
+ collection = collections.pop();
|
|
|
|
+ $container = collection.$container;
|
|
|
|
+ $target = collection.$target;
|
|
|
|
+ containerTagName = $container.prop('tagName');
|
|
|
|
+
|
|
|
|
+ // Prepare the Inline Element of the Container
|
|
|
|
+ $inline = $('<span/>').css({
|
|
|
|
+ 'position': 'absolute',
|
|
|
|
+ 'top': '0px',
|
|
|
|
+ 'left': '0px'
|
|
|
|
+ });
|
|
|
|
+ position = $container.css('position');
|
|
|
|
+
|
|
|
|
+ // Insert the Inline Element of the Container
|
|
|
|
+ $container.css({position:'relative'});
|
|
|
|
+ $inline.appendTo($container);
|
|
|
|
+
|
|
|
|
+ // Determine the top offset
|
|
|
|
+ startOffsetTop = $inline.offset().top;
|
|
|
|
+ targetOffsetTop = $target.offset().top;
|
|
|
|
+ targetOffsetTopAdjusted = targetOffsetTop - startOffsetTop - parseInt(config.offsetTop,10);
|
|
|
|
+
|
|
|
|
+ // Determine the left offset
|
|
|
|
+ startOffsetLeft = $inline.offset().left;
|
|
|
|
+ targetOffsetLeft = $target.offset().left;
|
|
|
|
+ targetOffsetLeftAdjusted = targetOffsetLeft - startOffsetLeft - parseInt(config.offsetLeft,10);
|
|
|
|
+
|
|
|
|
+ // Determine current scroll positions
|
|
|
|
+ containerScrollTop = $container.prop('scrollTop');
|
|
|
|
+ containerScrollLeft = $container.prop('scrollLeft');
|
|
|
|
+
|
|
|
|
+ // Reset the Inline Element of the Container
|
|
|
|
+ $inline.remove();
|
|
|
|
+ $container.css({position:position});
|
|
|
|
+
|
|
|
|
+ // Prepare the scroll options
|
|
|
|
+ scrollOptions = {};
|
|
|
|
+
|
|
|
|
+ // Prepare the callback
|
|
|
|
+ callback = function(event){
|
|
|
|
+ // Check
|
|
|
|
+ if ( collections.length === 0 ) {
|
|
|
|
+ // Callback
|
|
|
|
+ if ( typeof config.callback === 'function' ) {
|
|
|
|
+ config.callback();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ // Recurse
|
|
|
|
+ ScrollTo.scroll(collections,config);
|
|
|
|
+ }
|
|
|
|
+ // Return true
|
|
|
|
+ return true;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // Handle if we only want to scroll if we are outside the viewport
|
|
|
|
+ if ( config.onlyIfOutside ) {
|
|
|
|
+ // Determine current scroll positions
|
|
|
|
+ containerScrollTopEnd = containerScrollTop + $container.height();
|
|
|
|
+ containerScrollLeftEnd = containerScrollLeft + $container.width();
|
|
|
|
+
|
|
|
|
+ // Check if we are in the range of the visible area of the container
|
|
|
|
+ if ( containerScrollTop < targetOffsetTopAdjusted && targetOffsetTopAdjusted < containerScrollTopEnd ) {
|
|
|
|
+ targetOffsetTopAdjusted = containerScrollTop;
|
|
|
|
+ }
|
|
|
|
+ if ( containerScrollLeft < targetOffsetLeftAdjusted && targetOffsetLeftAdjusted < containerScrollLeftEnd ) {
|
|
|
|
+ targetOffsetLeftAdjusted = containerScrollLeft;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Determine the scroll options
|
|
|
|
+ if ( targetOffsetTopAdjusted !== containerScrollTop ) {
|
|
|
|
+ scrollOptions.scrollTop = targetOffsetTopAdjusted;
|
|
|
|
+ }
|
|
|
|
+ if ( targetOffsetLeftAdjusted !== containerScrollLeft ) {
|
|
|
|
+ scrollOptions.scrollLeft = targetOffsetLeftAdjusted;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Check to see if the scroll is necessary
|
|
|
|
+ if ( $container.prop('scrollHeight') === $container.width() ) {
|
|
|
|
+ delete scrollOptions.scrollTop;
|
|
|
|
+ }
|
|
|
|
+ if ( $container.prop('scrollWidth') === $container.width() ) {
|
|
|
|
+ delete scrollOptions.scrollLeft;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Perform the scroll
|
|
|
|
+ if ( scrollOptions.scrollTop != null || scrollOptions.scrollLeft != null ) {
|
|
|
|
+ $container.animate(scrollOptions, {
|
|
|
|
+ duration: config.duration,
|
|
|
|
+ easing: config.easing,
|
|
|
|
+ complete: callback
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Return true
|
|
|
|
+ return true;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // ScrollTo the Element using the Options
|
|
|
|
+ fn: function(options){
|
|
|
|
+ // Prepare
|
|
|
|
+ var collections, config, $container, container;
|
|
|
|
+ collections = [];
|
|
|
|
+
|
|
|
|
+ // Prepare
|
|
|
|
+ var $target = $(this);
|
|
|
|
+ if ( $target.length === 0 ) {
|
|
|
|
+ // Chain
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Handle Options
|
|
|
|
+ config = $.extend({},ScrollTo.config,options);
|
|
|
|
+
|
|
|
|
+ // Fetch
|
|
|
|
+ $container = $target.parent();
|
|
|
|
+ container = $container.get(0);
|
|
|
|
+
|
|
|
|
+ // Cycle through the containers
|
|
|
|
+ while ( ($container.length === 1) && (container !== document.body) && (container !== document) ) {
|
|
|
|
+ // Check Container for scroll differences
|
|
|
|
+ var containerScrollTop, containerScrollLeft;
|
|
|
|
+ containerScrollTop = $container.css('overflow-y') !== 'visible' && container.scrollHeight !== container.clientHeight;
|
|
|
|
+ containerScrollLeft = $container.css('overflow-x') !== 'visible' && container.scrollWidth !== container.clientWidth;
|
|
|
|
+ if ( containerScrollTop || containerScrollLeft ) {
|
|
|
|
+ // Push the Collection
|
|
|
|
+ collections.push({
|
|
|
|
+ '$container': $container,
|
|
|
|
+ '$target': $target
|
|
|
|
+ });
|
|
|
|
+ // Update the Target
|
|
|
|
+ $target = $container;
|
|
|
|
+ }
|
|
|
|
+ // Update the Container
|
|
|
|
+ $container = $container.parent();
|
|
|
|
+ container = $container.get(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Add the final collection
|
|
|
|
+ collections.push({
|
|
|
|
+ '$container': $('html'),
|
|
|
|
+ // document.body doesn't work in firefox, html works for all
|
|
|
|
+ // internet explorer starts at the beggining
|
|
|
|
+ '$target': $target
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // Adjust the Config
|
|
|
|
+ if ( config.durationMode === 'all' ) {
|
|
|
|
+ config.duration /= collections.length;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Handle
|
|
|
|
+ ScrollTo.scroll(collections,config);
|
|
|
|
+
|
|
|
|
+ // Chain
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // Apply our extensions to jQuery
|
|
|
|
+ $.ScrollTo = $.ScrollTo || ScrollTo;
|
|
|
|
+ $.fn.ScrollTo = $.fn.ScrollTo || ScrollTo.fn;
|
|
|
|
+
|
|
|
|
+ // Export
|
|
|
|
+ return ScrollTo;
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// ------------- WOW ANIMATE ------------------------------------------------ //
|
|
|
|
+// ==============https://github.com/matthieua/WOW =========================== //
|
|
|
|
+// -------------------------------------------------------------------------- //
|
|
|
|
+
|
|
|
|
+(function() {
|
|
|
|
+ var MutationObserver, Util, WeakMap, getComputedStyle, getComputedStyleRX,
|
|
|
|
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
|
|
|
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
|
|
|
+
|
|
|
|
+ Util = (function() {
|
|
|
|
+ function Util() {}
|
|
|
|
+
|
|
|
|
+ Util.prototype.extend = function(custom, defaults) {
|
|
|
|
+ var key, value;
|
|
|
|
+ for (key in defaults) {
|
|
|
|
+ value = defaults[key];
|
|
|
|
+ if (custom[key] == null) {
|
|
|
|
+ custom[key] = value;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return custom;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Util.prototype.isMobile = function(agent) {
|
|
|
|
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(agent);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Util.prototype.addEvent = function(elem, event, fn) {
|
|
|
|
+ if (elem.addEventListener != null) {
|
|
|
|
+ return elem.addEventListener(event, fn, false);
|
|
|
|
+ } else if (elem.attachEvent != null) {
|
|
|
|
+ return elem.attachEvent("on" + event, fn);
|
|
|
|
+ } else {
|
|
|
|
+ return elem[event] = fn;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Util.prototype.removeEvent = function(elem, event, fn) {
|
|
|
|
+ if (elem.removeEventListener != null) {
|
|
|
|
+ return elem.removeEventListener(event, fn, false);
|
|
|
|
+ } else if (elem.detachEvent != null) {
|
|
|
|
+ return elem.detachEvent("on" + event, fn);
|
|
|
|
+ } else {
|
|
|
|
+ return delete elem[event];
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Util.prototype.innerHeight = function() {
|
|
|
|
+ if ('innerHeight' in window) {
|
|
|
|
+ return window.innerHeight;
|
|
|
|
+ } else {
|
|
|
|
+ return document.documentElement.clientHeight;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ return Util;
|
|
|
|
+
|
|
|
|
+ })();
|
|
|
|
+
|
|
|
|
+ WeakMap = this.WeakMap || this.MozWeakMap || (WeakMap = (function() {
|
|
|
|
+ function WeakMap() {
|
|
|
|
+ this.keys = [];
|
|
|
|
+ this.values = [];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WeakMap.prototype.get = function(key) {
|
|
|
|
+ var i, item, _i, _len, _ref;
|
|
|
|
+ _ref = this.keys;
|
|
|
|
+ for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
|
|
|
+ item = _ref[i];
|
|
|
|
+ if (item === key) {
|
|
|
|
+ return this.values[i];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WeakMap.prototype.set = function(key, value) {
|
|
|
|
+ var i, item, _i, _len, _ref;
|
|
|
|
+ _ref = this.keys;
|
|
|
|
+ for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
|
|
|
+ item = _ref[i];
|
|
|
|
+ if (item === key) {
|
|
|
|
+ this.values[i] = value;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.keys.push(key);
|
|
|
|
+ return this.values.push(value);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ return WeakMap;
|
|
|
|
+
|
|
|
|
+ })());
|
|
|
|
+
|
|
|
|
+ MutationObserver = this.MutationObserver || this.WebkitMutationObserver || this.MozMutationObserver || (MutationObserver = (function() {
|
|
|
|
+ function MutationObserver() {
|
|
|
|
+ if (typeof console !== "undefined" && console !== null) {
|
|
|
|
+ console.warn('MutationObserver is not supported by your browser.');
|
|
|
|
+ }
|
|
|
|
+ if (typeof console !== "undefined" && console !== null) {
|
|
|
|
+ console.warn('WOW.js cannot detect dom mutations, please call .sync() after loading new content.');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ MutationObserver.notSupported = true;
|
|
|
|
+
|
|
|
|
+ MutationObserver.prototype.observe = function() {};
|
|
|
|
+
|
|
|
|
+ return MutationObserver;
|
|
|
|
+
|
|
|
|
+ })());
|
|
|
|
+
|
|
|
|
+ getComputedStyle = this.getComputedStyle || function(el, pseudo) {
|
|
|
|
+ this.getPropertyValue = function(prop) {
|
|
|
|
+ var _ref;
|
|
|
|
+ if (prop === 'float') {
|
|
|
|
+ prop = 'styleFloat';
|
|
|
|
+ }
|
|
|
|
+ if (getComputedStyleRX.test(prop)) {
|
|
|
|
+ prop.replace(getComputedStyleRX, function(_, char) {
|
|
|
|
+ return char.toUpperCase();
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ return ((_ref = el.currentStyle) != null ? _ref[prop] : void 0) || null;
|
|
|
|
+ };
|
|
|
|
+ return this;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ getComputedStyleRX = /(\-([a-z]){1})/g;
|
|
|
|
+
|
|
|
|
+ this.WOW = (function() {
|
|
|
|
+ WOW.prototype.defaults = {
|
|
|
|
+ boxClass: 'wow',
|
|
|
|
+ animateClass: 'animated',
|
|
|
|
+ offset: 0,
|
|
|
|
+ mobile: true,
|
|
|
|
+ live: true
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ function WOW(options) {
|
|
|
|
+ if (options == null) {
|
|
|
|
+ options = {};
|
|
|
|
+ }
|
|
|
|
+ this.scrollCallback = __bind(this.scrollCallback, this);
|
|
|
|
+ this.scrollHandler = __bind(this.scrollHandler, this);
|
|
|
|
+ this.start = __bind(this.start, this);
|
|
|
|
+ this.scrolled = true;
|
|
|
|
+ this.config = this.util().extend(options, this.defaults);
|
|
|
|
+ this.animationNameCache = new WeakMap();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WOW.prototype.init = function() {
|
|
|
|
+ var _ref;
|
|
|
|
+ this.element = window.document.documentElement;
|
|
|
|
+ if ((_ref = document.readyState) === "interactive" || _ref === "complete") {
|
|
|
|
+ this.start();
|
|
|
|
+ } else {
|
|
|
|
+ this.util().addEvent(document, 'DOMContentLoaded', this.start);
|
|
|
|
+ }
|
|
|
|
+ return this.finished = [];
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.start = function() {
|
|
|
|
+ var box, _i, _len, _ref;
|
|
|
|
+ this.stopped = false;
|
|
|
|
+ this.boxes = (function() {
|
|
|
|
+ var _i, _len, _ref, _results;
|
|
|
|
+ _ref = this.element.querySelectorAll("." + this.config.boxClass);
|
|
|
|
+ _results = [];
|
|
|
|
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
|
|
+ box = _ref[_i];
|
|
|
|
+ _results.push(box);
|
|
|
|
+ }
|
|
|
|
+ return _results;
|
|
|
|
+ }).call(this);
|
|
|
|
+ this.all = (function() {
|
|
|
|
+ var _i, _len, _ref, _results;
|
|
|
|
+ _ref = this.boxes;
|
|
|
|
+ _results = [];
|
|
|
|
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
|
|
+ box = _ref[_i];
|
|
|
|
+ _results.push(box);
|
|
|
|
+ }
|
|
|
|
+ return _results;
|
|
|
|
+ }).call(this);
|
|
|
|
+ if (this.boxes.length) {
|
|
|
|
+ if (this.disabled()) {
|
|
|
|
+ this.resetStyle();
|
|
|
|
+ } else {
|
|
|
|
+ _ref = this.boxes;
|
|
|
|
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
|
|
+ box = _ref[_i];
|
|
|
|
+ this.applyStyle(box, true);
|
|
|
|
+ }
|
|
|
|
+ this.util().addEvent(window, 'scroll', this.scrollHandler);
|
|
|
|
+ this.util().addEvent(window, 'resize', this.scrollHandler);
|
|
|
|
+ this.interval = setInterval(this.scrollCallback, 50);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (this.config.live) {
|
|
|
|
+ return new MutationObserver((function(_this) {
|
|
|
|
+ return function(records) {
|
|
|
|
+ var node, record, _j, _len1, _results;
|
|
|
|
+ _results = [];
|
|
|
|
+ for (_j = 0, _len1 = records.length; _j < _len1; _j++) {
|
|
|
|
+ record = records[_j];
|
|
|
|
+ _results.push((function() {
|
|
|
|
+ var _k, _len2, _ref1, _results1;
|
|
|
|
+ _ref1 = record.addedNodes || [];
|
|
|
|
+ _results1 = [];
|
|
|
|
+ for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
|
|
|
|
+ node = _ref1[_k];
|
|
|
|
+ _results1.push(this.doSync(node));
|
|
|
|
+ }
|
|
|
|
+ return _results1;
|
|
|
|
+ }).call(_this));
|
|
|
|
+ }
|
|
|
|
+ return _results;
|
|
|
|
+ };
|
|
|
|
+ })(this)).observe(document.body, {
|
|
|
|
+ childList: true,
|
|
|
|
+ subtree: true
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.stop = function() {
|
|
|
|
+ this.stopped = true;
|
|
|
|
+ this.util().removeEvent(window, 'scroll', this.scrollHandler);
|
|
|
|
+ this.util().removeEvent(window, 'resize', this.scrollHandler);
|
|
|
|
+ if (this.interval != null) {
|
|
|
|
+ return clearInterval(this.interval);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.sync = function(element) {
|
|
|
|
+ if (MutationObserver.notSupported) {
|
|
|
|
+ return this.doSync(this.element);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.doSync = function(element) {
|
|
|
|
+ var box, _i, _len, _ref, _results;
|
|
|
|
+ if (element == null) {
|
|
|
|
+ element = this.element;
|
|
|
|
+ }
|
|
|
|
+ if (element.nodeType !== 1) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ element = element.parentNode || element;
|
|
|
|
+ _ref = element.querySelectorAll("." + this.config.boxClass);
|
|
|
|
+ _results = [];
|
|
|
|
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
|
|
+ box = _ref[_i];
|
|
|
|
+ if (__indexOf.call(this.all, box) < 0) {
|
|
|
|
+ this.boxes.push(box);
|
|
|
|
+ this.all.push(box);
|
|
|
|
+ if (this.stopped || this.disabled()) {
|
|
|
|
+ this.resetStyle();
|
|
|
|
+ } else {
|
|
|
|
+ this.applyStyle(box, true);
|
|
|
|
+ }
|
|
|
|
+ _results.push(this.scrolled = true);
|
|
|
|
+ } else {
|
|
|
|
+ _results.push(void 0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return _results;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.show = function(box) {
|
|
|
|
+ this.applyStyle(box);
|
|
|
|
+ return box.className = "" + box.className + " " + this.config.animateClass;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.applyStyle = function(box, hidden) {
|
|
|
|
+ var delay, duration, iteration;
|
|
|
|
+ duration = box.getAttribute('data-wow-duration');
|
|
|
|
+ delay = box.getAttribute('data-wow-delay');
|
|
|
|
+ iteration = box.getAttribute('data-wow-iteration');
|
|
|
|
+ return this.animate((function(_this) {
|
|
|
|
+ return function() {
|
|
|
|
+ return _this.customStyle(box, hidden, duration, delay, iteration);
|
|
|
|
+ };
|
|
|
|
+ })(this));
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.animate = (function() {
|
|
|
|
+ if ('requestAnimationFrame' in window) {
|
|
|
|
+ return function(callback) {
|
|
|
|
+ return window.requestAnimationFrame(callback);
|
|
|
|
+ };
|
|
|
|
+ } else {
|
|
|
|
+ return function(callback) {
|
|
|
|
+ return callback();
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ })();
|
|
|
|
+
|
|
|
|
+ WOW.prototype.resetStyle = function() {
|
|
|
|
+ var box, _i, _len, _ref, _results;
|
|
|
|
+ _ref = this.boxes;
|
|
|
|
+ _results = [];
|
|
|
|
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
|
|
+ box = _ref[_i];
|
|
|
|
+ _results.push(box.style.visibility = 'visible');
|
|
|
|
+ }
|
|
|
|
+ return _results;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.customStyle = function(box, hidden, duration, delay, iteration) {
|
|
|
|
+ if (hidden) {
|
|
|
|
+ this.cacheAnimationName(box);
|
|
|
|
+ }
|
|
|
|
+ box.style.visibility = hidden ? 'hidden' : 'visible';
|
|
|
|
+ if (duration) {
|
|
|
|
+ this.vendorSet(box.style, {
|
|
|
|
+ animationDuration: duration
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (delay) {
|
|
|
|
+ this.vendorSet(box.style, {
|
|
|
|
+ animationDelay: delay
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (iteration) {
|
|
|
|
+ this.vendorSet(box.style, {
|
|
|
|
+ animationIterationCount: iteration
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ this.vendorSet(box.style, {
|
|
|
|
+ animationName: hidden ? 'none' : this.cachedAnimationName(box)
|
|
|
|
+ });
|
|
|
|
+ return box;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.vendors = ["moz", "webkit"];
|
|
|
|
+
|
|
|
|
+ WOW.prototype.vendorSet = function(elem, properties) {
|
|
|
|
+ var name, value, vendor, _results;
|
|
|
|
+ _results = [];
|
|
|
|
+ for (name in properties) {
|
|
|
|
+ value = properties[name];
|
|
|
|
+ elem["" + name] = value;
|
|
|
|
+ _results.push((function() {
|
|
|
|
+ var _i, _len, _ref, _results1;
|
|
|
|
+ _ref = this.vendors;
|
|
|
|
+ _results1 = [];
|
|
|
|
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
|
|
+ vendor = _ref[_i];
|
|
|
|
+ _results1.push(elem["" + vendor + (name.charAt(0).toUpperCase()) + (name.substr(1))] = value);
|
|
|
|
+ }
|
|
|
|
+ return _results1;
|
|
|
|
+ }).call(this));
|
|
|
|
+ }
|
|
|
|
+ return _results;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.vendorCSS = function(elem, property) {
|
|
|
|
+ var result, style, vendor, _i, _len, _ref;
|
|
|
|
+ style = getComputedStyle(elem);
|
|
|
|
+ result = style.getPropertyCSSValue(property);
|
|
|
|
+ _ref = this.vendors;
|
|
|
|
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
|
|
+ vendor = _ref[_i];
|
|
|
|
+ result = result || style.getPropertyCSSValue("-" + vendor + "-" + property);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.animationName = function(box) {
|
|
|
|
+ var animationName;
|
|
|
|
+ try {
|
|
|
|
+ animationName = this.vendorCSS(box, 'animation-name').cssText;
|
|
|
|
+ } catch (_error) {
|
|
|
|
+ animationName = getComputedStyle(box).getPropertyValue('animation-name');
|
|
|
|
+ }
|
|
|
|
+ if (animationName === 'none') {
|
|
|
|
+ return '';
|
|
|
|
+ } else {
|
|
|
|
+ return animationName;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.cacheAnimationName = function(box) {
|
|
|
|
+ return this.animationNameCache.set(box, this.animationName(box));
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.cachedAnimationName = function(box) {
|
|
|
|
+ return this.animationNameCache.get(box);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.scrollHandler = function() {
|
|
|
|
+ return this.scrolled = true;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.scrollCallback = function() {
|
|
|
|
+ var box;
|
|
|
|
+ if (this.scrolled) {
|
|
|
|
+ this.scrolled = false;
|
|
|
|
+ this.boxes = (function() {
|
|
|
|
+ var _i, _len, _ref, _results;
|
|
|
|
+ _ref = this.boxes;
|
|
|
|
+ _results = [];
|
|
|
|
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
|
|
+ box = _ref[_i];
|
|
|
|
+ if (!(box)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (this.isVisible(box)) {
|
|
|
|
+ this.show(box);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ _results.push(box);
|
|
|
|
+ }
|
|
|
|
+ return _results;
|
|
|
|
+ }).call(this);
|
|
|
|
+ if (!(this.boxes.length || this.config.live)) {
|
|
|
|
+ return this.stop();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.offsetTop = function(element) {
|
|
|
|
+ var top;
|
|
|
|
+ while (element.offsetTop === void 0) {
|
|
|
|
+ element = element.parentNode;
|
|
|
|
+ }
|
|
|
|
+ top = element.offsetTop;
|
|
|
|
+ while (element = element.offsetParent) {
|
|
|
|
+ top += element.offsetTop;
|
|
|
|
+ }
|
|
|
|
+ return top;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.isVisible = function(box) {
|
|
|
|
+ var bottom, offset, top, viewBottom, viewTop;
|
|
|
|
+ offset = box.getAttribute('data-wow-offset') || this.config.offset;
|
|
|
|
+ viewTop = window.pageYOffset;
|
|
|
|
+ viewBottom = viewTop + Math.min(this.element.clientHeight, this.util().innerHeight()) - offset;
|
|
|
|
+ top = this.offsetTop(box);
|
|
|
|
+ bottom = top + box.clientHeight;
|
|
|
|
+ return top <= viewBottom && bottom >= viewTop;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.util = function() {
|
|
|
|
+ return this._util != null ? this._util : this._util = new Util();
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ WOW.prototype.disabled = function() {
|
|
|
|
+ return !this.config.mobile && this.util().isMobile(navigator.userAgent);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ return WOW;
|
|
|
|
+
|
|
|
|
+ })();
|
|
|
|
+
|
|
|
|
+}).call(this);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// ------------- JQUERY SMOOTHSTATE ----------------------------------------- //
|
|
|
|
+// ============ https://github.com/miguel-perez/jquery.smoothState.js ======= //
|
|
|
|
+// -------------------------------------------------------------------------- //
|
|
|
|
+
|
|
|
|
+;(function ( $, window, document, undefined ) {
|
|
|
|
+ "use strict";
|
|
|
|
+
|
|
|
|
+ var
|
|
|
|
+ /** Used later to scroll page to the top */
|
|
|
|
+ $body = $("html, body"),
|
|
|
|
+
|
|
|
|
+ /** Used in development mode to console out useful warnings */
|
|
|
|
+ consl = (window.console || false),
|
|
|
|
+
|
|
|
|
+ /** Plugin default options */
|
|
|
|
+ defaults = {
|
|
|
|
+
|
|
|
|
+ /** jquery element string to specify which anchors smoothstate should bind to */
|
|
|
|
+ anchors : "a",
|
|
|
|
+
|
|
|
|
+ /** If set to true, smoothState will prefetch a link's contents on hover */
|
|
|
|
+ prefetch : false,
|
|
|
|
+
|
|
|
|
+ /** A selecor that deinfes with links should be ignored by smoothState */
|
|
|
|
+ blacklist : ".no-smoothstate, [target]",
|
|
|
|
+
|
|
|
|
+ /** If set to true, smoothState will log useful debug information instead of aborting */
|
|
|
|
+ development : false,
|
|
|
|
+
|
|
|
|
+ /** The number of pages smoothState will try to store in memory and not request again */
|
|
|
|
+ pageCacheSize : 0,
|
|
|
|
+
|
|
|
|
+ /** A function that can be used to alter urls before they are used to request content */
|
|
|
|
+ alterRequestUrl : function (url) {
|
|
|
|
+ return url;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** Run when a link has been activated */
|
|
|
|
+ onStart : {
|
|
|
|
+ duration: 0,
|
|
|
|
+ render: function (url, $container) {
|
|
|
|
+ $body.scrollTop(0);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** Run if the page request is still pending and onStart has finished animating */
|
|
|
|
+ onProgress : {
|
|
|
|
+ duration: 0,
|
|
|
|
+ render: function (url, $container) {
|
|
|
|
+ $body.css("cursor", "wait");
|
|
|
|
+ $body.find("a").css("cursor", "wait");
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** Run when requested content is ready to be injected into the page */
|
|
|
|
+ onEnd : {
|
|
|
|
+ duration: 0,
|
|
|
|
+ render: function (url, $container, $content) {
|
|
|
|
+ $body.css("cursor", "auto");
|
|
|
|
+ $body.find("a").css("cursor", "auto");
|
|
|
|
+ $container.html($content);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** Run when content has been injected and all animations are complete */
|
|
|
|
+ callback : function(url, $container, $content) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** Utility functions that are decoupled from SmoothState */
|
|
|
|
+ utility = {
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Checks to see if the url is external
|
|
|
|
+ * @param {string} url - url being evaluated
|
|
|
|
+ * @see http://stackoverflow.com/questions/6238351/fastest-way-to-detect-external-urls
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ isExternal: function (url) {
|
|
|
|
+ var match = url.match(/^([^:\/?#]+:)?(?:\/\/([^\/?#]*))?([^?#]+)?(\?[^#]*)?(#.*)?/);
|
|
|
|
+ if (typeof match[1] === "string" && match[1].length > 0 && match[1].toLowerCase() !== window.location.protocol) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ if (typeof match[2] === "string" && match[2].length > 0 && match[2].replace(new RegExp(":(" + {"http:": 80, "https:": 443}[window.location.protocol] + ")?$"), "") !== window.location.host) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Checks to see if the url is an internal hash
|
|
|
|
+ * @param {string} url - url being evaluated
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ isHash: function (url) {
|
|
|
|
+ var hasPathname = (url.indexOf(window.location.pathname) > 0) ? true : false,
|
|
|
|
+ hasHash = (url.indexOf("#") > 0) ? true : false;
|
|
|
|
+ return (hasPathname && hasHash) ? true : false;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Checks to see if we should be loading this URL
|
|
|
|
+ * @param {string} url - url being evaluated
|
|
|
|
+ * @param {string} blacklist - jquery selector
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ shouldLoad: function ($anchor, blacklist) {
|
|
|
|
+ var url = $anchor.prop("href");
|
|
|
|
+ // URL will only be loaded if it"s not an external link, hash, or blacklisted
|
|
|
|
+ return (!utility.isExternal(url) && !utility.isHash(url) && !$anchor.is(blacklist));
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Prevents jQuery from stripping elements from $(html)
|
|
|
|
+ * @param {string} url - url being evaluated
|
|
|
|
+ * @author Ben Alman http://benalman.com/
|
|
|
|
+ * @see https://gist.github.com/cowboy/742952
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ htmlDoc: function (html) {
|
|
|
|
+ var parent,
|
|
|
|
+ elems = $(),
|
|
|
|
+ matchTag = /<(\/?)(html|head|body|title|base|meta)(\s+[^>]*)?>/ig,
|
|
|
|
+ prefix = "ss" + Math.round(Math.random() * 100000),
|
|
|
|
+ htmlParsed = html.replace(matchTag, function(tag, slash, name, attrs) {
|
|
|
|
+ var obj = {};
|
|
|
|
+ if (!slash) {
|
|
|
|
+ elems = elems.add("<" + name + "/>");
|
|
|
|
+ if (attrs) {
|
|
|
|
+ $.each($("<div" + attrs + "/>")[0].attributes, function(i, attr) {
|
|
|
|
+ obj[attr.name] = attr.value;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ elems.eq(-1).attr(obj);
|
|
|
|
+ }
|
|
|
|
+ return "<" + slash + "div" + (slash ? "" : " id='" + prefix + (elems.length - 1) + "'") + ">";
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // If no placeholder elements were necessary, just return normal
|
|
|
|
+ // jQuery-parsed HTML.
|
|
|
|
+ if (!elems.length) {
|
|
|
|
+ return $(html);
|
|
|
|
+ }
|
|
|
|
+ // Create parent node if it hasn"t been created yet.
|
|
|
|
+ if (!parent) {
|
|
|
|
+ parent = $("<div/>");
|
|
|
|
+ }
|
|
|
|
+ // Create the parent node and append the parsed, place-held HTML.
|
|
|
|
+ parent.html(htmlParsed);
|
|
|
|
+
|
|
|
|
+ // Replace each placeholder element with its intended element.
|
|
|
|
+ $.each(elems, function(i) {
|
|
|
|
+ var elem = parent.find("#" + prefix + i).before(elems[i]);
|
|
|
|
+ elems.eq(i).html(elem.contents());
|
|
|
|
+ elem.remove();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return parent.children().unwrap();
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Resets an object if it has too many properties
|
|
|
|
+ *
|
|
|
|
+ * This is used to clear the "cache" object that stores
|
|
|
|
+ * all of the html. This would prevent the client from
|
|
|
|
+ * running out of memory and allow the user to hit the
|
|
|
|
+ * server for a fresh copy of the content.
|
|
|
|
+ *
|
|
|
|
+ * @param {object} obj
|
|
|
|
+ * @param {number} cap
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ clearIfOverCapacity: function (obj, cap) {
|
|
|
|
+ // Polyfill Object.keys if it doesn"t exist
|
|
|
|
+ if (!Object.keys) {
|
|
|
|
+ Object.keys = function (obj) {
|
|
|
|
+ var keys = [],
|
|
|
|
+ k;
|
|
|
|
+ for (k in obj) {
|
|
|
|
+ if (Object.prototype.hasOwnProperty.call(obj, k)) {
|
|
|
|
+ keys.push(k);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return keys;
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (Object.keys(obj).length > cap) {
|
|
|
|
+ obj = {};
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return obj;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Finds the inner content of an element, by an ID, from a jQuery object
|
|
|
|
+ * @param {string} id
|
|
|
|
+ * @param {object} $html
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ getContentById: function (id, $html) {
|
|
|
|
+ $html = ($html instanceof jQuery) ? $html : utility.htmlDoc($html);
|
|
|
|
+ var $insideElem = $html.find(id),
|
|
|
|
+ updatedContainer = ($insideElem.length) ? $.trim($insideElem.html()) : $html.filter(id).html(),
|
|
|
|
+ newContent = (updatedContainer.length) ? $(updatedContainer) : null;
|
|
|
|
+ return newContent;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Stores html content as jquery object in given object
|
|
|
|
+ * @param {object} object - object contents will be stored into
|
|
|
|
+ * @param {string} url - url to be used as the prop
|
|
|
|
+ * @param {jquery} html - contents to store
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ storePageIn: function (object, url, $html) {
|
|
|
|
+ $html = ($html instanceof jQuery) ? $html : utility.htmlDoc($html);
|
|
|
|
+ object[url] = { // Content is indexed by the url
|
|
|
|
+ status: "loaded",
|
|
|
|
+ title: $html.find("title").text(), // Stores the title of the page
|
|
|
|
+ html: $html // Stores the contents of the page
|
|
|
|
+ };
|
|
|
|
+ return object;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Triggers an "allanimationend" event when all animations are complete
|
|
|
|
+ * @param {object} $element - jQuery object that should trigger event
|
|
|
|
+ * @param {string} resetOn - which other events to trigger allanimationend on
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ triggerAllAnimationEndEvent: function ($element, resetOn) {
|
|
|
|
+
|
|
|
|
+ resetOn = " " + resetOn || "";
|
|
|
|
+
|
|
|
|
+ var animationCount = 0,
|
|
|
|
+ animationstart = "animationstart webkitAnimationStart oanimationstart MSAnimationStart",
|
|
|
|
+ animationend = "animationend webkitAnimationEnd oanimationend MSAnimationEnd",
|
|
|
|
+ eventname = "allanimationend",
|
|
|
|
+ onAnimationStart = function (e) {
|
|
|
|
+ if ($(e.delegateTarget).is($element)) {
|
|
|
|
+ e.stopPropagation();
|
|
|
|
+ animationCount ++;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ onAnimationEnd = function (e) {
|
|
|
|
+ if ($(e.delegateTarget).is($element)) {
|
|
|
|
+ e.stopPropagation();
|
|
|
|
+ animationCount --;
|
|
|
|
+ if(animationCount === 0) {
|
|
|
|
+ $element.trigger(eventname);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ $element.on(animationstart, onAnimationStart);
|
|
|
|
+ $element.on(animationend, onAnimationEnd);
|
|
|
|
+
|
|
|
|
+ $element.on("allanimationend" + resetOn, function(){
|
|
|
|
+ animationCount = 0;
|
|
|
|
+ utility.redraw($element);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** Forces browser to redraw elements */
|
|
|
|
+ redraw: function ($element) {
|
|
|
|
+ $element.height(0);
|
|
|
|
+ setTimeout(function(){$element.height("auto");}, 0);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** Handles the popstate event, like when the user hits "back" */
|
|
|
|
+ onPopState = function ( e ) {
|
|
|
|
+ if(e.state !== null) {
|
|
|
|
+ var url = window.location.href,
|
|
|
|
+ $page = $("#" + e.state.id),
|
|
|
|
+ page = $page.data("smoothState");
|
|
|
|
+
|
|
|
|
+ if(page.href !== url && !utility.isHash(url)) {
|
|
|
|
+ page.load(url, true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** Constructor function */
|
|
|
|
+ SmoothState = function ( element, options ) {
|
|
|
|
+ var
|
|
|
|
+ /** Container element smoothState is run on */
|
|
|
|
+ $container = $(element),
|
|
|
|
+
|
|
|
|
+ /** Variable that stores pages after they are requested */
|
|
|
|
+ cache = {},
|
|
|
|
+
|
|
|
|
+ /** Url of the content that is currently displayed */
|
|
|
|
+ currentHref = window.location.href,
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Loads the contents of a url into our container
|
|
|
|
+ *
|
|
|
|
+ * @param {string} url
|
|
|
|
+ * @param {bool} isPopped - used to determine if whe should
|
|
|
|
+ * add a new item into the history object
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ load = function (url, isPopped) {
|
|
|
|
+
|
|
|
|
+ /** Makes this an optional variable by setting a default */
|
|
|
|
+ isPopped = isPopped || false;
|
|
|
|
+
|
|
|
|
+ var
|
|
|
|
+ /** Used to check if the onProgress function has been run */
|
|
|
|
+ hasRunCallback = false,
|
|
|
|
+
|
|
|
|
+ callbBackEnded = false,
|
|
|
|
+
|
|
|
|
+ /** List of responses for the states of the page request */
|
|
|
|
+ responses = {
|
|
|
|
+
|
|
|
|
+ /** Page is ready, update the content */
|
|
|
|
+ loaded: function() {
|
|
|
|
+ var eventName = hasRunCallback ? "ss.onProgressEnd" : "ss.onStartEnd";
|
|
|
|
+
|
|
|
|
+ if(!callbBackEnded || !hasRunCallback) {
|
|
|
|
+ $container.one(eventName, function(){
|
|
|
|
+ updateContent(url);
|
|
|
|
+ });
|
|
|
|
+ } else if(callbBackEnded) {
|
|
|
|
+ updateContent(url);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!isPopped) {
|
|
|
|
+ window.history.pushState({ id: $container.prop("id") }, cache[url].title, url);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** Loading, wait 10 ms and check again */
|
|
|
|
+ fetching: function() {
|
|
|
|
+
|
|
|
|
+ if(!hasRunCallback) {
|
|
|
|
+
|
|
|
|
+ hasRunCallback = true;
|
|
|
|
+
|
|
|
|
+ // Run the onProgress callback and set trigger
|
|
|
|
+ $container.one("ss.onStartEnd", function(){
|
|
|
|
+ options.onProgress.render(url, $container, null);
|
|
|
|
+
|
|
|
|
+ setTimeout(function(){
|
|
|
|
+ $container.trigger("ss.onProgressEnd");
|
|
|
|
+ callbBackEnded = true;
|
|
|
|
+ }, options.onStart.duration);
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ // Might of been canceled, better check!
|
|
|
|
+ if(cache.hasOwnProperty(url)){
|
|
|
|
+ responses[cache[url].status]();
|
|
|
|
+ }
|
|
|
|
+ }, 10);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** Error, abort and redirect */
|
|
|
|
+ error: function(){
|
|
|
|
+ window.location = url;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ if (!cache.hasOwnProperty(url)) {
|
|
|
|
+ fetch(url);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Run the onStart callback and set trigger
|
|
|
|
+ options.onStart.render(url, $container, null);
|
|
|
|
+ setTimeout(function(){
|
|
|
|
+ $container.trigger("ss.onStartEnd");
|
|
|
|
+ }, options.onStart.duration);
|
|
|
|
+
|
|
|
|
+ // Start checking for the status of content
|
|
|
|
+ responses[cache[url].status]();
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** Updates the contents from cache[url] */
|
|
|
|
+ updateContent = function (url) {
|
|
|
|
+ // If the content has been requested and is done:
|
|
|
|
+ var containerId = "#" + $container.prop("id"),
|
|
|
|
+ $content = cache[url] ? utility.getContentById(containerId, cache[url].html) : null;
|
|
|
|
+
|
|
|
|
+ if($content) {
|
|
|
|
+ document.title = cache[url].title;
|
|
|
|
+ $container.data("smoothState").href = url;
|
|
|
|
+
|
|
|
|
+ // Call the onEnd callback and set trigger
|
|
|
|
+ options.onEnd.render(url, $container, $content);
|
|
|
|
+
|
|
|
|
+ $container.one("ss.onEndEnd", function(){
|
|
|
|
+ options.callback(url, $container, $content);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ setTimeout(function(){
|
|
|
|
+ $container.trigger("ss.onEndEnd");
|
|
|
|
+ }, options.onEnd.duration);
|
|
|
|
+
|
|
|
|
+ } else if (!$content && options.development && consl) {
|
|
|
|
+ // Throw warning to help debug in development mode
|
|
|
|
+ consl.warn("No element with an id of " + containerId + " in response from " + url + " in " + cache);
|
|
|
|
+ } else {
|
|
|
|
+ // No content availble to update with, aborting...
|
|
|
|
+ window.location = url;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Fetches the contents of a url and stores it in the "cache" varible
|
|
|
|
+ * @param {string} url
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ fetch = function (url) {
|
|
|
|
+
|
|
|
|
+ // Don"t fetch we have the content already
|
|
|
|
+ if(cache.hasOwnProperty(url)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cache = utility.clearIfOverCapacity(cache, options.pageCacheSize);
|
|
|
|
+
|
|
|
|
+ cache[url] = { status: "fetching" };
|
|
|
|
+
|
|
|
|
+ var requestUrl = options.alterRequestUrl(url) || url,
|
|
|
|
+ request = $.ajax(requestUrl);
|
|
|
|
+
|
|
|
|
+ // Store contents in cache variable if successful
|
|
|
|
+ request.success(function (html) {
|
|
|
|
+ // Clear cache varible if it"s getting too big
|
|
|
|
+ utility.storePageIn(cache, url, html);
|
|
|
|
+ $container.data("smoothState").cache = cache;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // Mark as error
|
|
|
|
+ request.error(function () {
|
|
|
|
+ cache[url].status = "error";
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ * Binds to the hover event of a link, used for prefetching content
|
|
|
|
+ *
|
|
|
|
+ * @param {object} event
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ hoverAnchor = function (event) {
|
|
|
|
+ var $anchor = $(event.currentTarget),
|
|
|
|
+ url = $anchor.prop("href");
|
|
|
|
+ if (utility.shouldLoad($anchor, options.blacklist)) {
|
|
|
|
+ event.stopPropagation();
|
|
|
|
+ fetch(url);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Binds to the click event of a link, used to show the content
|
|
|
|
+ *
|
|
|
|
+ * @param {object} event
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ clickAnchor = function (event) {
|
|
|
|
+ var $anchor = $(event.currentTarget),
|
|
|
|
+ url = $anchor.prop("href");
|
|
|
|
+
|
|
|
|
+ // Ctrl (or Cmd) + click must open a new tab
|
|
|
|
+ if (!event.metaKey && !event.ctrlKey && utility.shouldLoad($anchor, options.blacklist)) {
|
|
|
|
+ // stopPropagation so that event doesn"t fire on parent containers.
|
|
|
|
+ event.stopPropagation();
|
|
|
|
+ event.preventDefault();
|
|
|
|
+ load(url);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Binds all events and inits functionality
|
|
|
|
+ *
|
|
|
|
+ * @param {object} event
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ bindEventHandlers = function ($element) {
|
|
|
|
+ //@todo: Handle form submissions
|
|
|
|
+ $element.on("click", options.anchors, clickAnchor);
|
|
|
|
+
|
|
|
|
+ if (options.prefetch) {
|
|
|
|
+ $element.on("mouseover touchstart", options.anchors, hoverAnchor);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** Used to restart css animations with a class */
|
|
|
|
+ toggleAnimationClass = function (classname) {
|
|
|
|
+ var classes = $container.addClass(classname).prop("class");
|
|
|
|
+
|
|
|
|
+ $container.removeClass(classes);
|
|
|
|
+
|
|
|
|
+ setTimeout(function(){
|
|
|
|
+ $container.addClass(classes);
|
|
|
|
+ },0);
|
|
|
|
+
|
|
|
|
+ $container.one("ss.onStartEnd ss.onProgressEnd ss.onEndEnd", function(){
|
|
|
|
+ $container.removeClass(classname);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ /** Override defaults with options passed in */
|
|
|
|
+ options = $.extend(defaults, options);
|
|
|
|
+
|
|
|
|
+ /** Sets a default state */
|
|
|
|
+ if(window.history.state === null) {
|
|
|
|
+ window.history.replaceState({ id: $container.prop("id") }, document.title, currentHref);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /** Stores the current page in cache variable */
|
|
|
|
+ utility.storePageIn(cache, currentHref, document.documentElement.outerHTML);
|
|
|
|
+
|
|
|
|
+ /** Bind all of the event handlers on the container, not anchors */
|
|
|
|
+ utility.triggerAllAnimationEndEvent($container, "ss.onStartEnd ss.onProgressEnd ss.onEndEnd");
|
|
|
|
+
|
|
|
|
+ /** Bind all of the event handlers on the container, not anchors */
|
|
|
|
+ bindEventHandlers($container);
|
|
|
|
+
|
|
|
|
+ /** Public methods */
|
|
|
|
+ return {
|
|
|
|
+ href: currentHref,
|
|
|
|
+ cache: cache,
|
|
|
|
+ load: load,
|
|
|
|
+ fetch: fetch,
|
|
|
|
+ toggleAnimationClass: toggleAnimationClass
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** Returns elements with SmoothState attached to it */
|
|
|
|
+ declareSmoothState = function ( options ) {
|
|
|
|
+ return this.each(function () {
|
|
|
|
+ // Checks to make sure the smoothState element has an id and isn"t already bound
|
|
|
|
+ if(this.id && !$.data(this, "smoothState")) {
|
|
|
|
+ // Makes public methods available via $("element").data("smoothState");
|
|
|
|
+ $.data(this, "smoothState", new SmoothState(this, options));
|
|
|
|
+ } else if (!this.id && consl) {
|
|
|
|
+ // Throw warning if in development mode
|
|
|
|
+ consl.warn("Every smoothState container needs an id but the following one does not have one:", this);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ /** Sets the popstate function */
|
|
|
|
+ window.onpopstate = onPopState;
|
|
|
|
+
|
|
|
|
+ /** Makes utility functions public for unit tests */
|
|
|
|
+ $.smoothStateUtility = utility;
|
|
|
|
+
|
|
|
|
+ /** Defines the smoothState plugin */
|
|
|
|
+ $.fn.smoothState = declareSmoothState;
|
|
|
|
+
|
|
|
|
+})(jQuery, window, document);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// ------------- jQuery Cookie Plugin v1.4.1 -------------------------------- //
|
|
|
|
+// ============ https://github.com/carhartl/jquery-cookie =================== //
|
|
|
|
+// -------------------------------------------------------------------------- //
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+(function (factory) {
|
|
|
|
+ if (typeof define === 'function' && define.amd) {
|
|
|
|
+ // AMD
|
|
|
|
+ define(['jquery'], factory);
|
|
|
|
+ } else if (typeof exports === 'object') {
|
|
|
|
+ // CommonJS
|
|
|
|
+ factory(require('jquery'));
|
|
|
|
+ } else {
|
|
|
|
+ // Browser globals
|
|
|
|
+ factory(jQuery);
|
|
|
|
+ }
|
|
|
|
+}(function ($) {
|
|
|
|
+
|
|
|
|
+ var pluses = /\+/g;
|
|
|
|
+
|
|
|
|
+ function encode(s) {
|
|
|
|
+ return config.raw ? s : encodeURIComponent(s);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function decode(s) {
|
|
|
|
+ return config.raw ? s : decodeURIComponent(s);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function stringifyCookieValue(value) {
|
|
|
|
+ return encode(config.json ? JSON.stringify(value) : String(value));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function parseCookieValue(s) {
|
|
|
|
+ if (s.indexOf('"') === 0) {
|
|
|
|
+ // This is a quoted cookie as according to RFC2068, unescape...
|
|
|
|
+ s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ // Replace server-side written pluses with spaces.
|
|
|
|
+ // If we can't decode the cookie, ignore it, it's unusable.
|
|
|
|
+ // If we can't parse the cookie, ignore it, it's unusable.
|
|
|
|
+ s = decodeURIComponent(s.replace(pluses, ' '));
|
|
|
|
+ return config.json ? JSON.parse(s) : s;
|
|
|
|
+ } catch(e) {}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function read(s, converter) {
|
|
|
|
+ var value = config.raw ? s : parseCookieValue(s);
|
|
|
|
+ return $.isFunction(converter) ? converter(value) : value;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var config = $.cookie = function (key, value, options) {
|
|
|
|
+
|
|
|
|
+ // Write
|
|
|
|
+
|
|
|
|
+ if (arguments.length > 1 && !$.isFunction(value)) {
|
|
|
|
+ options = $.extend({}, config.defaults, options);
|
|
|
|
+
|
|
|
|
+ if (typeof options.expires === 'number') {
|
|
|
|
+ var days = options.expires, t = options.expires = new Date();
|
|
|
|
+ t.setTime(+t + days * 864e+5);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return (document.cookie = [
|
|
|
|
+ encode(key), '=', stringifyCookieValue(value),
|
|
|
|
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
|
|
|
+ options.path ? '; path=' + options.path : '',
|
|
|
|
+ options.domain ? '; domain=' + options.domain : '',
|
|
|
|
+ options.secure ? '; secure' : ''
|
|
|
|
+ ].join(''));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Read
|
|
|
|
+
|
|
|
|
+ var result = key ? undefined : {};
|
|
|
|
+
|
|
|
|
+ // To prevent the for loop in the first place assign an empty array
|
|
|
|
+ // in case there are no cookies at all. Also prevents odd result when
|
|
|
|
+ // calling $.cookie().
|
|
|
|
+ var cookies = document.cookie ? document.cookie.split('; ') : [];
|
|
|
|
+
|
|
|
|
+ for (var i = 0, l = cookies.length; i < l; i++) {
|
|
|
|
+ var parts = cookies[i].split('=');
|
|
|
|
+ var name = decode(parts.shift());
|
|
|
|
+ var cookie = parts.join('=');
|
|
|
|
+
|
|
|
|
+ if (key && key === name) {
|
|
|
|
+ // If second argument (value) is a function it's a converter...
|
|
|
|
+ result = read(cookie, value);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Prevent storing a cookie that we couldn't decode.
|
|
|
|
+ if (!key && (cookie = read(cookie)) !== undefined) {
|
|
|
|
+ result[name] = cookie;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ config.defaults = {};
|
|
|
|
+
|
|
|
|
+ $.removeCookie = function (key, options) {
|
|
|
|
+ if ($.cookie(key) === undefined) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Must not alter options, thus extending a fresh object...
|
|
|
|
+ $.cookie(key, '', $.extend({}, options, { expires: -1 }));
|
|
|
|
+ return !$.cookie(key);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+}));
|