seminar/app/assets/stylesheets/seminar/background_style/6/js/layout.js

43 lines
1.4 KiB
JavaScript

;(function($, win, undefined) {
// ECMAScript 5 嚴格模式
'use strict';
$(document).ready(function() {
var timeout_id;
if (window.innerWidth < 768) {
if($('.mobile-menu .modules-menu').length == 0){
$(".modules-menu").appendTo('.mobile-menu');
}
}else{
var body_image_pos_y = $('header').offset().top + $('header').height() - $('.modules-menu').height();
$("body").css("background-position-y",Math.ceil(body_image_pos_y)+"px");
}
$(window).resize(function() {
window.clearTimeout(timeout_id)
if (window.innerWidth < 768) {
if($('.mobile-menu').length != 0){
timeout_id = setTimeout(function(){
if($('.mobile-menu .modules-menu').length == 0){
$(".modules-menu").appendTo('.mobile-menu');
}
}, 500);
}
} else {
var body_image_pos_y = $('header').offset().top + $('header').height() - $('.modules-menu').height();
$("body").css("background-position-y",Math.ceil(body_image_pos_y)+"px");
if($("div.aside").length == 0){
timeout_id = setTimeout(function(){
if($('.mobile-menu .modules-menu').length > 0){
$("header .container").append($('.mobile-menu .modules-menu'))
}
}, 500);
}else{
timeout_id = setTimeout(function(){
if($('.modules-menu').length > 0){
$("div.aside").eq(0).append($('.modules-menu'))
}
}, 500);
}
}
})
})
}(jQuery, window));