'); }); node.set('innerHTML', newNode); node.setStyle('display','block'); node.all('a.close').setStyle('display','block'); node.all('.ysf-'+type).setStyle('display','block').setStyle('opacity','1').setStyle('filter','alpha(opacity=100)').setStyle('height','auto'); }; var Alerts = Y.Base.create('FantasyAlerts', Y.Base, [], { _handles : {}, initializer: function() { var oAlerts = this, warningNode = Y.one('#ysf-warning-block'), confirmNode = Y.one('#ysf-confirmation-block'), criticalNode = Y.one('#ysf-critical-block'), infoNode = Y.one('#ysf-info-block'), containerNode = Y.one('#ysf-alerts'); // If we have alerts elsewhere on the page, don't use the header alerts, use these instead if(Y.one('#ysf-alerts-other')) { warningNode = Y.one('#ysf-warning-block-other'), confirmNode = Y.one('#ysf-confirm-block-other'); criticalNode = Y.one('#ysf-critical-block-other'); infoNode = Y.one('#ysf-info-block-other'); containerNode = Y.one('#ysf-alerts-other'); } if(containerNode) { containerNode.delegate('click', oAlerts.closeAlert, 'a.close'); containerNode.all('a.close').setStyle('display','block'); } oAlerts.set('warningNode', warningNode); oAlerts.set('confirmationNode', confirmNode); oAlerts.set('criticalNode', criticalNode); oAlerts.set('infoNode', infoNode); }, closeAlert: function(e) { e.preventDefault(); var node = e.currentTarget, parentNode = node.get('parentNode'), anim = new Y.Anim({ node: parentNode, to: { opacity: 0 }, duration: 0.3, easing: Y.Easing.easeOut }), heightAnim = new Y.Anim({ node: parentNode, to: {height: 0}, duration: 0.2 }); anim.on('end', function() { heightAnim.run(); }, this); heightAnim.on('end', function() { parentNode.setStyles({ 'display' : 'none', 'opacity' : '' }); }, this); anim.run(); }, show : function(types) { this.fire('beforeShow'); var oAlerts = this, types = (!Y.Lang.isArray(types)) ? false : types; Y.each(types, function(k,i,a) { oAlerts.get(k+'Node').setStyle('display', 'block'); }); this.fire('afterShow'); }, destructor : function() { } }, { ATTRS : { warnings : { value : [], setter : function(v) { var oAlerts = this; return Y.bind(setMessages, oAlerts, 'warning', v)(); }, validator : Y.Lang.isArray }, confirmations : { value : [], setter : function(v) { var oAlerts = this; return Y.bind(setMessages, oAlerts, 'confirmation', v)(); }, validator : Y.Lang.isArray }, criticals : { value : [], setter : function(v) { var oAlerts = this; return Y.bind(setMessages, oAlerts, 'critical', v)(); }, validator : Y.Lang.isArray }, infos : { value : [], setter : function(v) { var oAlerts = this; return Y.bind(setMessages, oAlerts, 'info', v)(); }, validator : Y.Lang.isArray }, warningNode : { value : null }, confirmationNode : { value : null }, criticalNode : { value : null }, infoNode : { value : null } } }); YUI.Fantasy.Alerts = new Alerts(); }, '', { requires : ['base-build', 'node-event-delegate', 'anim-base', 'anim-easing'] }); YSF.use('event', function(Y) { Y.on('contentready', function() { Y.use('ysf-alerts', function(){}); }, '#ysf-alerts.visible'); }); // -->