Math.randomString=function(n){for(var text="",possible="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=0;n>i;i++)text+=possible.charAt(Math.floor(Math.random()*possible.length));return text};var Lobibox=Lobibox||{};!function(){var LobiboxNotify=function(type,options){this.$type,this.$options,this.$el,this.$sound;var me=this,_processInput=function(options){return("mini"===options.size||"large"===options.size)&&(options.width=options.width||Lobibox.notify.OPTIONS[options.size].width),options=$.extend({},Lobibox.notify.OPTIONS[me.$type],Lobibox.notify.DEFAULTS,options),"mini"!==options.size&&options.title===!0?options.title=Lobibox.notify.OPTIONS[me.$type].title:"mini"===options.size&&options.title===!0&&(options.title=!1),options.icon===!0&&(options.icon=Lobibox.notify.OPTIONS[me.$type].icon),options.sound===!0&&(options.sound=Lobibox.notify.OPTIONS[me.$type].sound),options.sound&&(options.sound=options.soundPath+options.sound+options.soundExt),options},_init=function(){var notify=_createNotify(),wrapper=_createNotifyWrapper();if(_appendInWrapper(notify,wrapper),me.$el=notify,me.$options.sound){var snd=new Audio(me.$options.sound);snd.play()}me.$el.data("lobibox",me)},_appendInWrapper=function($el,$wrapper){if("normal"===me.$options.size)$wrapper.append($el);else if("mini"===me.$options.size)$el.addClass("notify-mini"),$wrapper.append($el);else if("large"===me.$options.size){var tabPane=_createTabPane();tabPane.append($el);var tabControl=_createTabControl(tabPane.attr("id"));$wrapper.find(".tab-content").append(tabPane),$wrapper.find(".nav-tabs").append(tabControl),tabControl.find(">a").tab("show")}},_createTabControl=function(tabPaneId){var $li=$("
  • ");return $('').attr("data-toggle","tab").attr("role","tab").append('').appendTo($li),$li.addClass(Lobibox.notify.OPTIONS[me.$type]["class"]),$li},_createTabPane=function(){var $pane=$("
    ").addClass("tab-pane").attr("id",Math.randomString(10));return $pane},_createNotifyWrapper=function(){var selector;selector="large"===me.$options.size?".lobibox-notify-wrapper-large":".lobibox-notify-wrapper";var classes=me.$options.position.split(" ");selector+="."+classes.join(".");var wrapper=$(selector);return 0===wrapper.length&&(wrapper=$("
    ").addClass(selector.replace(/\./g," ").trim()).appendTo($("body")),"large"===me.$options.size&&wrapper.append($('')).append($('
    '))),wrapper},_createNotify=function(){var notify=$('
    ').addClass(Lobibox.notify.OPTIONS[me.$type]["class"]).addClass(Lobibox.notify.OPTIONS["class"]).addClass(me.$options.showClass),iconWrapper=$('
    ').appendTo(notify);if(me.$options.img){var img=iconWrapper.append('');iconWrapper.append(img)}else if(me.$options.icon){var icon=iconWrapper.append('');iconWrapper.append(icon)}else notify.addClass("without-icon");var $body=$("
    ").addClass("lobibox-notify-body").append('
    '+me.$options.msg+"
    ").appendTo(notify);return me.$options.title&&$body.prepend('
    '+me.$options.title+"
    "),_addCloseButton(notify),("normal"===me.$options.size||"mini"===me.$options.size)&&(_addCloseOnClick(notify),_addDelay(notify)),me.$options.width&¬ify.css("width",_calculateWidth(me.$options.width)),notify},_addCloseButton=function($el){if(me.$options.closable){var close=$('×');$el.append(close),close.click(function(){me.remove()})}},_addCloseOnClick=function($el){me.$options.closeOnClick&&$el.click(function(){me.remove()})},_addDelay=function($el){if(me.$options.delay){if(me.$options.delayIndicator){var delay=$('
    ');$el.append(delay)}var time=0,interval=1e3/30,timer=setInterval(function(){time+=interval;var width=100*time/me.$options.delay;width>=100&&(width=100,me.remove(),timer=clearInterval(timer)),me.$options.delayIndicator&&delay.find("div").css("width",width+"%")},interval)}},_findTabToActivate=function($li){var $itemToActivate=$li.prev();return 0===$itemToActivate.length&&($itemToActivate=$li.next()),0===$itemToActivate.length?null:$itemToActivate.find(">a")},_calculateWidth=function(width){return width=Math.min($(window).outerWidth(),width)};this.remove=function(){me.$el.removeClass(me.$options.showClass).addClass(me.$options.hideClass);var parent=me.$el.parent(),wrapper=parent.closest(".lobibox-notify-wrapper-large"),href="#"+parent.attr("id"),$li=wrapper.find('>.nav-tabs>li:has(a[href="'+href+'"])');return $li.addClass(Lobibox.notify.OPTIONS["class"]).addClass(me.$options.hideClass),setTimeout(function(){if("normal"===me.$options.size||"mini"===me.$options.size)me.$el.remove();else if("large"===me.$options.size){var $itemToActivate=_findTabToActivate($li);$itemToActivate&&$itemToActivate.tab("show"),$li.remove(),parent.remove()}},500),me},this.$type=type,this.$options=_processInput(options),_init()};Lobibox.notify=function(type,options){return["info","warning","error","success"].indexOf(type)>-1?new LobiboxNotify(type,options):void 0},Lobibox.notify.DEFAULTS={title:!0,size:"normal",soundPath:"sounds/",soundExt:".ogg",showClass:"zoomIn",hideClass:"zoomOut",icon:!0,msg:"",img:null,closable:!0,delay:5e3,delayIndicator:!0,closeOnClick:!0,width:400,sound:!0,position:"bottom right"},Lobibox.notify.OPTIONS={"class":"animated-fast",large:{width:500},mini:{"class":"notify-mini"},success:{"class":"lobibox-notify-success",title:"Success",icon:"glyphicon glyphicon-ok-sign",sound:"sound2"},error:{"class":"lobibox-notify-error",title:"Error",icon:"glyphicon glyphicon-remove-sign",sound:"sound4"},warning:{"class":"lobibox-notify-warning",title:"Warning",icon:"glyphicon glyphicon-exclamation-sign",sound:"sound5"},info:{"class":"lobibox-notify-info",title:"Information",icon:"glyphicon glyphicon-info-sign",sound:"sound6"}}}();