(function(f){var a={};var i=function(j){this.name="AlphaError";this.message=j};i.prototype=new Error();var h={renameFunction:function(k,j){return Function("fn","return (function "+j+"(){ return fn.apply(this, arguments) });")(k)},hydrate:function(j){if(j==null){return}for(var k in j){this[k]=j[k]}},setter:function(k,j){if(k==null){return}for(var l in k){if(j&&!this.hasOwnProperty(l)){throw new i("[setter] "+l+" is not a property of current object")}this[l]=k[l]}},splitAttributesMethods:function(j){if(j==null){throw new i("[splitAttributesMethods] properties must be an object")}var m={attributes:{},methods:{}};for(var l in j){var k=j[l];if(k instanceof Function){m.methods[l]=k}else{m.attributes[l]=k}}return m},extend:function(m,l){if(!(m instanceof Array)){throw new i("[extend] Parents must be an array")}var j;if(m.length>0){for(var k=0;k')}});return this};a.ui.loadCSS=function(){return a.ui.loadStylesheet(c)};a.ui.effects.js=function(k,l,j){if(a.ui.effects.js.all.indexOf(k)!=-1){jQuery.fn[k].call(l,j)}else{throw new i('[Alpha.ui.effects.js] "'+k+'" is not a jQuery effect')}return this};a.ui.effects.js.all=["fadeIn","fadeOut","slideUp","slideDown","slideToggle","toggle"];a.ui.effects.css=function(k,l,j){if(a.ui.effects.css.all.indexOf(k)!=-1){l.addClass(k+" animated").one(a.ui.effects.css.event,j)}else{throw new i('[Alpha.ui.effects.css] "'+k+'" is not a CSS effect registered')}return this};a.ui.effects.css.event="webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend";a.ui.effects.css.all=["bounce","flash","pulse","rubberBand","shake","swing","tada","wobble","jello","bounceIn","bounceInDown","bounceInLeft","bounceInRight","bounceInUp","bounceOut","bounceOutDown","bounceOutLeft","bounceOutRight","bounceOutUp","fadeIn","fadeInDown","fadeInDownBig","fadeInLeft","fadeInLeftBig","fadeInRight","fadeInRightBig","fadeInUp","fadeInUpBig","fadeOut","fadeOutDown","fadeOutDownBig","fadeOutLeft","fadeOutLeftBig","fadeOutRight","fadeOutRightBig","fadeOutUp","fadeOutUpBig","flip","flipInX","flipInY","flipOutX","flipOutY","lightSpeedIn","lightSpeedOut","rotateIn","rotateInDownLeft","rotateInDownRight","rotateInUpLeft","rotateInUpRight","rotateOut","rotateOutDownLeft","rotateOutDownRight","rotateOutUpLeft","rotateOutUpRight","slideInUp","slideInDown","slideInLeft","slideInRight","slideOutUp","slideOutDown","slideOutLeft","slideOutRight","zoomIn","zoomInDown","zoomInLeft","zoomInRight","zoomInUp","zoomOut","zoomOutDown","zoomOutLeft","zoomOutRight","zoomOutUp","hinge","rollIn","rollOut"];a.ui.Element=a.createClass({name:"UIElement",properties:{$container:null,$el:null,render:new Function(),onShow_effect:new Function(),onHide_effect:new Function(),set:function(){e.prototype.set.apply(this,arguments);if(arguments.length==2&&this.$el!=null){try{var k=arguments[0],j=this.$el.find("."+k);if(j.length!=0){j.html(this[k])}}catch(l){console.warn(l)}}return this}}});a.ui.Button=a.createClass({name:"AlphaButton",parents:[a.ui.Element],properties:{id:null,"class":null,content:"",type:null,href:null,belongsTo:null,onClick:null,render:function(){var k=null;if(this.type==null){throw new i("[Alpha.ui.Button.render] Type must be either 'link' or 'button'.")}var j="alphajs button";if(this["class"]!=null){this["class"]=j+" "+this["class"]}else{this["class"]=j}this.id="alphajs_button_"+(++a.ui.Button.instanceNumber);var l='id = "'+this.id+'" class = "'+this["class"]+'"';if(this.type=="link"){if(this.href==null){throw new i("[Alpha.ui.Button.render] Link must no be null to create a Alpha.ui.Button link")}k="'+(this.content||"")+""}else{if(this.type=="button"){k="'}else{throw new i("[Alpha.ui.Button.render] Type '"+this.type+"' doesn't apply for Alpha.ui.Button type")}}return k},show:function(){h.applyDOMElement.call(this,"$container",this.$container,function(){this.$container.append(this.render());this.$el=this.$container.find("#"+this.id);if(this.onClick!=null){if(!(this.onClick instanceof Function)){throw new i("[Alpha.ui.Button.show] Attribute onClick must be a function")}h.onclick.call(this,"#"+this.id,this.onClick)}});return this},bind:function(j){if(j==null){throw new i("[Alpha.ui.Button.bind] UIElement must be an instance of Alpha.ui.Element")}this.belongsTo=j;this.$container=this.belongsTo.$el;this.$el=this.$container.find("#"+this.id);if(this.onClick!=null){if(!(this.onClick instanceof Function)){throw new i("[Alpha.ui.Button.bind] Attribute onClick must be a function")}h.onclick.call(this,"#"+this.id,this.onClick)}return this},set:function(){a.ui.Element.prototype.set.apply(this,arguments);if(arguments.length==2&&this.$el!=null){var k=arguments[0];switch(k){case"content":if(this.type=="link"){this.$el.html(this.content)}else{if(this.type=="button"){this.$el.attr("value",this.content)}}break;case"href":if(this.type=="link"){this.$el.attr("href",this.href)}break;case"class":var j="alphajs button";this.$el.attr("class",j).addClass(this["class"]);break}}return this}}});a.ui.Button.instanceNumber=0;a.ui.ModalBox=a.createClass({name:"AlphaModalBox",parents:[a.ui.Element],properties:{id:null,title:"Title",content:"Put your content here.",$overlay:null,is_shown:false,buttonsAlignment:"right",buttons:[new a.ui.Button({"class":"blue",content:"OK",type:"button",onClick:function(){this.belongsTo.close()}}),new a.ui.Button({"class":"red",content:"Cancel",type:"button",onClick:function(){this.belongsTo.close()}})],triggeredBy:null,onShow_effect:function(){this.$overlay.hide().fadeIn();if(this.$container==a.ui.singletons.$body){this.$overlay.css("position","fixed");this.$el.css("top",b.scrollTop()+20)}this.$container.css("overflow","hidden").bind("mousewheel",function(j){j.preventDefault()});a.ui.effects.css("bounceInDown",this.$el);return this},onHide_effect:function(){var j=this;a.ui.effects.css("bounceOutUp",this.$el,function(){j.$overlay.fadeOut(function(){j.$overlay.remove();j.$el.remove()});j.$container.css("overflow","initial").unbind("mousewheel")});return this},render:function(){this.id="alphajs_modalbox_"+(++a.ui.ModalBox.instanceNumber);var l='";return j},show:function(j){if(this.is_shown){return}var l=this;this.$container.append(this.render());this.$el=this.$container.find("#"+this.id);this.$el.find(".close").on("click",function(){l.close()});this.is_shown=true;this.$el.css("top",j+"px").css(this.direction,"0");if(this.onShow_effect!=null&&this.onShow_effect instanceof Function){this.onShow_effect()}else{var k="";if(this.direction=="left"){k="rotateInDownLeft"}else{k="rotateInDownRight"}a.ui.effects.css(k,this.$el)}return this},close:function(){var k=this;if(this.onHide_effect!=null&&this.onHide_effect instanceof Function){this.onHide_effect()}else{var j="";if(this.direction=="left"){j="rotateOutUpLeft"}else{j="rotateOutUpRight"}a.ui.effects.css(j,this.$el,function(){k.$el.remove()})}return this}},init:function(){h.applyDOMElement.call(this,"$container",this.$container);a.ui.SideBox.instances.push(this);this.id="alphajs_sidebox_"+a.ui.SideBox.instances.length;if(this.direction!="left"&&this.direction!="right"){throw new i("[Alpha.ui.SideBox] direction must be either left or right")}h.applyDOMElement.call(this,"$appearOn",this.$appearOn,function(){if(this.$appearOn.length==0){throw new i("[Alpha.ui.SideBox] $appearOn must be a valid selector")}})}});a.ui.SideBox.instances=[];a.ui.SideBox.showAll=function(){f(function(){b.on("scroll",function(){var p=b.scrollTop(),k=p+b.height();for(var l=0;l=p){o.show(j+m)}}})})};a.ui.SearchWidget=a.createClass({name:"AlphaSearchWidget",parents:[a.ui.Element],properties:{id:null,guests:null,notFoundMessage:"No results found",getOptions:new Function(),getResults:new Function(),render:function(){this.id="alpha_js_searchwidget_"+(++a.ui.SearchWidget.instanceNumber);var j='
';return j},compareResults:function(k,j){return k.id==j.id},renderResult:new Function(),renderResults:function(l){if(this.renderResult==null){throw new i("[Alpha.ui.SearchWidget.renderResults] renderResult must be a function")}var m="";if(l==null||l.length==0){m='
'+this.notFoundMessage+"
"}else{for(var k=0;k"+this.renderResult(j)+""}}return m},renderGuest:function(j){return'
'+this.renderResult(j)+"
"},addGuest:function(l){if(h.containsElement.call(this.guests,l,this.compareResults)){return}var m=this;this.guests.push(l);var j=false;this.$el.find(".results").find(".result").each(function(){var n=f(this).data();if(m.compareResults(n,l)){if(!f(this).find("input[type=checkbox]").is(":checked")){f(this).find("input[type=checkbox]").prop("checked",true)}return}});this.$el.find(".guests-list").find(".guest").each(function(){var n=f(this).data();if(m.compareResults(n,l)){j=f(this);return}});if(j){j.find("input[type=checkbox]").prop("checked",true)}else{this.$el.find(".guests-list").append(this.renderGuest(l));var k=this.$el.find(".guests-list").find(".guest").last();k.data(l);a.ui.effects.css("bounceIn",k);k.find("input[type=checkbox]").change(function(){if(f(this).is(":checked")){m.addGuest(l)}else{m.removeGuest(l)}})}return this},addGuests:function(j){j.forEach(function(k){this.addGuest(k)}.bind(this));return this},removeGuest:function(j){if(!h.containsElement.call(this.guests,j,this.compareResults)){return}var l=this;h.removeElement.call(this.guests,j);var k=function(){var m=f(this).data();if(l.compareResults(m,j)){f(this).find("input[type=checkbox]").prop("checked",false);return}};this.$el.find(".results").find(".result").each(k);this.$el.find(".guests-list").find(".guest").each(k);return this},show:function(){var j=this;this.$container.append(this.render());this.$el=this.$container.find("#"+this.id);if(this.getOptions==null||!(this.getOptions instanceof Function)){throw new i("[Alpha.ui.SearchWidget.show] getOptions must be a function")}if(this.getResults==null||!(this.getResults instanceof Function)){throw new i("[Alpha.ui.SearchWidget.show] getResults must be a function")}this.getOptions(function(k){for(var l=0;l'+k[l]+"");j.$el.find("select.dropdown").change(function(m){j.$el.find(".search").find("input[type=search]").keyup()})}});this.$el.find(".search").find("input[type=search]").keyup(function(m){f(this).parent().find(".results").empty();var l=f(this).val().trim(),k=j.$el.find("select.dropdown").val();if(l==""){return}j.getResults(function(o){j.$el.find(".results").append(j.renderResults(o));var n=0;j.$el.find(".results").find(".result").each(function(){f(this).data(o[n]);f(this).find("input[type=checkbox]").change(function(){var p=f(this).parent().data();if(f(this).is(":checked")){j.addGuest(p)}else{j.removeGuest(p)}});n++})},l,k)});this.$el.find(".search").find("input[type=search]").on("search",function(){j.$el.find(".search").find(".results").empty()});return this}},init:function(){this.guests=[];h.applyDOMElement.call(this,"$container",this.$container,this.show)}});a.ui.SearchWidget.instanceNumber=0;window.Alpha=a})(jQuery);