File size: 2,751 Bytes
cbc76af | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | /*!
* @version $Id: Popover.js 11781 2013-06-26 21:40:26Z djamil $
* @author RocketTheme http://www.rockettheme.com
* @copyright Copyright (C) 2007 - 2015 RocketTheme, LLC
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
*/
((function(){
if (typeof this.RokSprocket == 'undefined') this.RokSprocket = {};
this.Popover = new Class({
Implements: [Options, Events],
options: {
/* */
},
initialize: function(options){
this.built = false;
this.build();
},
build: function(){
if (this.built) return this.wrapper;
if (document.getElement('.popover-wrapper')){
['wrapper', 'arrow', 'inner', 'content'].each(function(type, i){
this[type.camelCase()] = document.getElement('.popover-' + type);
}, this);
} else {
this.wrapper = new Element('div.popover-wrapper', {styles: {display: 'none'}}).inject(document.body);
this.wrapper.addEvent('click:relay([data-dismiss])', this.hide.bind(this));
['arrow', 'inner', 'content'].each(function(type, i){
this[type] = new Element('div.popover-' + type).inject(type == 'content' ? this.inner : this.wrapper);
}, this);
//this.close = new Element('a.close[data-dismiss=true]', {html: '×'}).inject(this.header);
//this.title = new Element('h3').inject(this.header);
}
this.wrapper.styles({opacity: 0});
this.built = true;
},
inject: function(element, where){
this.wrapper.inject(element, where || 'inside');
return this;
},
set: function(object){
Object.each(object, function(args, action){
var method = 'set' + action.capitalize();
if (this[method]) this[method](args);
}, this);
return this;
},
setTitle: function(title){
if (!this.title) this.title = new Element('h1.popover-title').inject(this.content, 'top');
this.title.set('html', title);
return this;
},
setBody: function(body){
this.content.set('html', body);
return this;
},
setKind: function(kind){
this.kind = kind;
this.wrapper.addClass(this.kind);
return this;
},
show: function(){
if (this.isShown) return;
this.wrapper.setStyle('display', 'block');
this.wrapper.fx({opacity: 1}, {
duration: '300ms',
equation: 'ease-out',
callback: function(){
this.isShown = true;
}.bind(this)
});
return this;
},
hide: function(){
if (!this.isShown) return;
this.wrapper.fx({opacity: 0}, {
duration: '300ms',
equation: 'ease-out',
callback: function(){
if (this.kind) this.wrapper.removeClass(this.kind);
this.wrapper.setStyle('display', 'none');
this.isShown = false;
}.bind(this)
});
return this;
},
toElement: function(){
return this.wrapper;
}
});
})());
|