mirror of
https://github.com/YunoHost-Apps/agendav_ynh.git
synced 2024-09-03 20:36:12 +02:00
16 lines
No EOL
2.2 KiB
JavaScript
16 lines
No EOL
2.2 KiB
JavaScript
/**
|
|
* Freeow!
|
|
* Stylish, Growl-like message boxes
|
|
*
|
|
* Copyright (c) 2011 PJ Dietz
|
|
* Version: 1.00
|
|
* Licensed under the MIT license:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
*
|
|
* http://pjdietz.com/jquery-plugins/freeow/
|
|
*/
|
|
(function($){"use strict";var Freeow;Freeow=function(title,message,options){var startStyle,i,u;this.options=$.extend({},$.fn.freeow.defaults,options);this.element=$(this.options.template(title,message));if(this.options.startStyle){startStyle=this.options.startStyle;}
|
|
else{startStyle=this.options.hideStyle;}
|
|
this.element.css(startStyle);this.element.data("freeow",this);for(i=0,u=this.options.classes.length;i<u;i+=1){this.element.addClass(this.options.classes[i]);}
|
|
this.element.click(this.options.onClick);this.element.hover(this.options.onHover);this.autoHide=false;};Freeow.prototype={attach:function(container){$(container).prepend(this.element);this.show();},show:function(){var opts,self,fn,delay;opts={duration:this.showDuration};if(this.options.autoHide&&this.options.autoHideDelay>0){this.autoHide=true;self=this;delay=this.options.autoHideDelay;fn=function(){if(self.autoHide){self.hide();}};opts.complete=function(){setTimeout(fn,delay);};}
|
|
this.element.animate(this.options.showStyle,opts);},hide:function(){var self=this;this.element.animate(this.options.hideStyle,{duration:this.options.hideDuration,complete:function(){self.destroy();}});},destroy:function(){this.element.data("freeow",undefined);this.element.remove();}};if(typeof $.fn.freeow==="undefined"){$.fn.extend({freeow:function(title,message,options){return this.each(function(){var f;f=new Freeow(title,message,options);f.attach(this);});}});$.fn.freeow.defaults={autoHide:true,autoHideDelay:3000,classes:[],startStyle:null,showStyle:{opacity:1.0},showDuration:250,hideStyle:{opacity:0.0},hideDuration:500,onClick:function(event){$(this).data("freeow").hide();},onHover:function(event){$(this).data("freeow").autoHide=false;},template:function(title,message){var e;e=['<div>','<div class="background">','<div class="content">','<h2>'+title+'</h2>','<p>'+message+'</p>','</div>','</div>','<span class="icon"></span>','<span class="close"></span>','</div>'].join("");return e;}};}}(jQuery)); |