var QuickSidebar=function(){var handleQuickSidebarToggler=function(){$('.dropdown-quick-sidebar-toggler a, .page-quick-sidebar-toggler, .quick-sidebar-toggler').click(function(e){$('body').toggleClass('page-quick-sidebar-open');});};var handleQuickSidebarChat=function(){var wrapper=$('.page-quick-sidebar-wrapper');var wrapperChat=wrapper.find('.page-quick-sidebar-chat');var initChatSlimScroll=function(){var chatUsers=wrapper.find('.page-quick-sidebar-chat-users');var chatUsersHeight;chatUsersHeight=wrapper.height()-wrapper.find('.nav-tabs').outerHeight(true);App.destroySlimScroll(chatUsers);chatUsers.attr("data-height",chatUsersHeight);App.initSlimScroll(chatUsers);var chatMessages=wrapperChat.find('.page-quick-sidebar-chat-user-messages');var chatMessagesHeight=chatUsersHeight-wrapperChat.find('.page-quick-sidebar-chat-user-form').outerHeight(true);chatMessagesHeight=chatMessagesHeight-wrapperChat.find('.page-quick-sidebar-nav').outerHeight(true);App.destroySlimScroll(chatMessages);chatMessages.attr("data-height",chatMessagesHeight);App.initSlimScroll(chatMessages);};initChatSlimScroll();App.addResizeHandler(initChatSlimScroll);wrapper.find('.page-quick-sidebar-chat-users .media-list > .media').click(function(){wrapperChat.addClass("page-quick-sidebar-content-item-shown");});wrapper.find('.page-quick-sidebar-chat-user .page-quick-sidebar-back-to-list').click(function(){wrapperChat.removeClass("page-quick-sidebar-content-item-shown");});var handleChatMessagePost=function(e){e.preventDefault();var chatContainer=wrapperChat.find(".page-quick-sidebar-chat-user-messages");var input=wrapperChat.find('.page-quick-sidebar-chat-user-form .form-control');var text=input.val();if(text.length===0){return;}
var preparePost=function(dir,time,name,avatar,message){var tpl='';tpl+='
';tpl+='
![]('+Layout.getLayoutImgPath()+avatar+'.jpg)
';tpl+='
';tpl+='
';tpl+='
Bob Nilson ';tpl+='
'+time+'';tpl+='
';tpl+=message;tpl+='';tpl+='
';tpl+='
';return tpl;};var time=new Date();var message=preparePost('out',(time.getHours()+':'+time.getMinutes()),"Bob Nilson",'avatar3',text);message=$(message);chatContainer.append(message);chatContainer.slimScroll({scrollTo:'1000000px'});input.val("");setTimeout(function(){var time=new Date();var message=preparePost('in',(time.getHours()+':'+time.getMinutes()),"Ella Wong",'avatar2','Lorem ipsum doloriam nibh...');message=$(message);chatContainer.append(message);chatContainer.slimScroll({scrollTo:'1000000px'});},3000);};wrapperChat.find('.page-quick-sidebar-chat-user-form .btn').click(handleChatMessagePost);wrapperChat.find('.page-quick-sidebar-chat-user-form .form-control').keypress(function(e){if(e.which==13){handleChatMessagePost(e);return false;}});};var handleQuickSidebarAlerts=function(){var wrapper=$('.page-quick-sidebar-wrapper');var initAlertsSlimScroll=function(){var alertList=wrapper.find('.page-quick-sidebar-alerts-list');var alertListHeight;alertListHeight=wrapper.height()-wrapper.find('.nav-justified > .nav-tabs').outerHeight();App.destroySlimScroll(alertList);alertList.attr("data-height",alertListHeight);App.initSlimScroll(alertList);};initAlertsSlimScroll();App.addResizeHandler(initAlertsSlimScroll);};var handleQuickSidebarSettings=function(){var wrapper=$('.page-quick-sidebar-wrapper');var initSettingsSlimScroll=function(){var settingsList=wrapper.find('.page-quick-sidebar-settings-list');var settingsListHeight;settingsListHeight=wrapper.height()-80-wrapper.find('.nav-justified > .nav-tabs').outerHeight();App.destroySlimScroll(settingsList);settingsList.attr("data-height",settingsListHeight);App.initSlimScroll(settingsList);};initSettingsSlimScroll();App.addResizeHandler(initSettingsSlimScroll);};return{init:function(){handleQuickSidebarToggler();handleQuickSidebarChat();handleQuickSidebarAlerts();handleQuickSidebarSettings();}};}();if(App.isAngularJsApp()===false){jQuery(document).ready(function(){QuickSidebar.init();});}