PHP Classes

File: bootstrap/js/animo.min.js

Recommend this page to a friend!
  Classes of Minh Tien   Noblesse CMS   bootstrap/js/animo.min.js   Download  
File: bootstrap/js/animo.min.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Noblesse CMS
Content management system with custom plugins
Author: By
Last change:
Date: 8 years ago
Size: 4,647 bytes
 

Contents

Class file image Download
(function($,window,document,undefined){function animo(element,options,callback,other_cb){var defaults={duration:1,animation:null,iterate:1,delay:0,timing:"linear",keep:false};this.prefixes=["","-moz-","-o-animation-","-webkit-"];this.element=$(element);this.bare=element;this.queue=[];this.listening=false;var cb=(typeof callback=="function"?callback:other_cb);switch(options){case"blur":defaults={amount:3,duration:0.5,focusAfter:null};this.options=$.extend(defaults,callback);this._blur(cb);break;case"focus":this._focus();break;case"rotate":defaults={degrees:15,duration:0.5};this.options=$.extend(defaults,callback);this._rotate(cb);break;case"cleanse":this.cleanse();break;default:this.options=$.extend(defaults,options);this.init(cb);break}}animo.prototype={init:function(callback){var $me=this;if(Object.prototype.toString.call($me.options.animation)==="[object Array]"){$.merge($me.queue,$me.options.animation)}else{$me.queue.push($me.options.animation)}$me.cleanse();$me.animate(callback)},animate:function(callback){this.element.addClass("animated");this.element.addClass(this.queue[0]);this.element.data("animo",this.queue[0]);var ai=this.prefixes.length;while(ai--){this.element.css(this.prefixes[ai]+"animation-duration",this.options.duration+"s");this.element.css(this.prefixes[ai]+"animation-delay",this.options.delay+"s");this.element.css(this.prefixes[ai]+"animation-iteration-count",this.options.iterate);this.element.css(this.prefixes[ai]+"animation-timing-function",this.options.timing)}var $me=this,_cb=callback;if($me.queue.length>1){_cb=null}this._end("AnimationEnd",function(){if($me.element.hasClass($me.queue[0])){if(!$me.options.keep){$me.cleanse()}$me.queue.shift();if($me.queue.length){$me.animate(callback)}}},_cb)},cleanse:function(){this.element.removeClass("animated");this.element.removeClass(this.queue[0]);this.element.removeClass(this.element.data("animo"));var ai=this.prefixes.length;while(ai--){this.element.css(this.prefixes[ai]+"animation-duration","");this.element.css(this.prefixes[ai]+"animation-delay","");this.element.css(this.prefixes[ai]+"animation-iteration-count","");this.element.css(this.prefixes[ai]+"animation-timing-function","");this.element.css(this.prefixes[ai]+"transition","");this.element.css(this.prefixes[ai]+"transform","");this.element.css(this.prefixes[ai]+"filter","")}},_blur:function(callback){if(this.element.is("img")){var svg_id="svg_"+(((1+Math.random())*16777216)|0).toString(16).substring(1);var filter_id="filter_"+(((1+Math.random())*16777216)|0).toString(16).substring(1);$("body").append('<svg version="1.1" xmlns="http://www.w3.org/2000/svg" id="'+svg_id+'" style="height:0;position:absolute;top:-1000px;"><filter id="'+filter_id+'"><feGaussianBlur stdDeviation="'+this.options.amount+'" /></filter></svg>');var ai=this.prefixes.length;while(ai--){this.element.css(this.prefixes[ai]+"filter","blur("+this.options.amount+"px)");this.element.css(this.prefixes[ai]+"transition",this.options.duration+"s all linear")}this.element.css("filter","url(#"+filter_id+")");this.element.data("svgid",svg_id)}else{var color=this.element.css("color");var ai=this.prefixes.length;while(ai--){this.element.css(this.prefixes[ai]+"transition","all "+this.options.duration+"s linear")}this.element.css("text-shadow","0 0 "+this.options.amount+"px "+color);this.element.css("color","transparent")}this._end("TransitionEnd",null,callback);var $me=this;if(this.options.focusAfter){var focus_wait=window.setTimeout(function(){$me._focus();focus_wait=window.clearTimeout(focus_wait)},(this.options.focusAfter*1000))}},_focus:function(){var ai=this.prefixes.length;if(this.element.is("img")){while(ai--){this.element.css(this.prefixes[ai]+"filter","");this.element.css(this.prefixes[ai]+"transition","")}var $svg=$("#"+this.element.data("svgid"));$svg.remove()}else{while(ai--){this.element.css(this.prefixes[ai]+"transition","")}this.element.css("text-shadow","");this.element.css("color","")}},_rotate:function(callback){var ai=this.prefixes.length;while(ai--){this.element.css(this.prefixes[ai]+"transition","all "+this.options.duration+"s linear");this.element.css(this.prefixes[ai]+"transform","rotate("+this.options.degrees+"deg)")}this._end("TransitionEnd",null,callback)},_end:function(type,todo,callback){var $me=this;var binding=type.toLowerCase()+" webkit"+type+" o"+type+" MS"+type;this.element.bind(binding,function(){$me.element.unbind(binding);if(typeof todo=="function"){todo()}if(typeof callback=="function"){callback($me)}})}};$.fn.animo=function(options,callback,other_cb){return this.each(function(){new animo(this,options,callback,other_cb)})}})(jQuery,window,document);