init_todo_slidedown = function(){ todo_buttons = $("#smart-toolbox .js-slidedown-button"); todo_content = $("#smart-toolbox .js-slidedown-content"); todo_content.each(function(){ $(this).hide(); }); todo_buttons.each(function(id){ $(this).click(function(){ $(todo_content[id]).slideToggle(200); }); }); } init_slidedown = function(){ boxes = $(".js-slide-down-box.plain"); boxes.each(function(id){ ident = randomString(); $(this).removeClass("plain"); $(this).addClass(ident); btn = $($(this).children(".js-slidedown-button")[0]); cont = $($(this).children(".js-slidedown-content")[0]); btn.addClass(ident); cont.addClass(ident); btn = $(".js-slidedown-button."+ident); btn.click(function(){ x = $(this).attr('class').split(' '); ident = x[x.length-1]; cont = $(".js-slidedown-content."+ident); box = $(".js-slide-down-box."+ident) session_id = box.attr("data-session-id") //cont.slideToggle(200); $(box).toggleClass("open"); //$.ajax({url: "/ajax/save_slidedown_box/"+session_id, data:'authenticity_token=' + AUTH_TOKEN, type:'get'}); }); }); } init_tab_slidedown = function(){ tab_boxes = $(".tabbed-box"); tab_buttons = $(".tabbed-box .tab-header"); tab_slidedown_content = $(".tabbed-box .tab-content"); tab_buttons.each(function(id){ // if(getCookieValue($(tab_boxes[id]).attr("id")) == "0"){ // $(tab_slidedown_content[id]).hide(); // } $(this).click(function(){ if($(tab_slidedown_content[id]).attr("style") == "display: none;"){ setCookieValue($(tab_boxes[id]).attr("id"), 1); } else{ setCookieValue($(tab_boxes[id]).attr("id"), 0); } $(tab_slidedown_content[id]).slideToggle(200); }); }); } init_hide_rows = function(){ hide_rows = $("tr.hiding-row"); hide_rows.each(function(id){ $(this).click(function(){ $(this).children(".hide-me").slideDown(200); }); $(this).mouseout(function(){ $(this).children(".hide-me").slideUp(200); }); }); } init_slide_table = function(){ tables = $(".js-slide-down-table") tables.each(function(i){ $(tables[i]).children("thead").click(function(){ $(tables[i]).children("tbody").slideToggle(200); }); }) } initPopOutBox = function(){ PopOutClassName = "popped-out" $(".js-pop-out-box.pop-disabled").each(function(){ $(this).mouseenter(function(){ original_width = $(this).width() if($(this).hasClass(PopOutClassName)){ button = $(this) button.children(".js-pop-out-content").fadeOut(0,function(){ button.removeClass(PopOutClassName) }); }else{ // Alles Zu! $(".js-pop-out-content:visible").hide(); $(".js-pop-out-box").removeAttr("style"); $(".js-pop-out-box").removeClass(PopOutClassName); // Checken ob Box nach Links aufgehen muss window_width = $(document).width() if($(this).offset()['left'] > (window_width/2)){ lefty = true }else{ lefty = false } if(lefty == true){ $(this).addClass("pop-out-left") }else{ $(this).addClass("pop-out-right") } $(this).children(".js-pop-out-content").fadeIn(0) $(this).addClass(PopOutClassName) } }); $(this).mouseleave(function(){ button = $(this) button.children(".js-pop-out-content").fadeOut(0,function(){ button.removeClass(PopOutClassName) }); }); $(this).removeClass("pop-disabled"); }); } $(document).ready(function(){ init_slidedown(); init_tab_slidedown(); init_hide_rows(); init_slide_table(); initPopOutBox(); // Pop-Out Box });