') ); // } $(function() { /** * -------------------------------------------------- * 計算線上人數 * -------------------------------------------------- */ $.post( "cache.php", function( data ) { $('.sc-online-number').html( data ); }); /** * -------------------------------------------------- * Header 滑動陰影 * -------------------------------------------------- */ $(window).scroll(function() { if ($(this).scrollTop() > 0) { $('.header').addClass('card'); } else { $('.header').removeClass('card'); } }); /** * -------------------------------------------------- * 側欄選單 * -------------------------------------------------- */ $('#menu').mmenu(); $('#menu > ul').toggle(); /** * -------------------------------------------------- * Freewall 格狀排版 * -------------------------------------------------- */ var $wall = new freewall('.freewall'); $wall.reset({ selector: '.brick', animate: true, gutterX: 10, gutterY: 10, cellW: 200, cellH: 'auto', onResize: function() { this.fitWidth(); } }); var $images = $wall.container.find('.brick'); $images.find('img').load(function() { $wall.fitWidth(); }); /** * -------------------------------------------------- * jQuery Validation 表格輸入驗證 * -------------------------------------------------- */ // 驗證註冊頁面欄位 if ( $("#sc-registry-form").length ) { $("#sc-registry-form").validate({ rules: { username: { required: true }, password: { required: true, minlength: 5 }, passwordConfirm: { required: true, // minlength: 5, equalTo: "#sc-input-password" }, nickname: { required: true }, termsAndConditions: { required: true } }, errorPlacement: function( error, element ) { error.insertAfter( element ); } }); }; // 驗證登入頁面欄位 if ( $("#sc-login-form").length ) { $("#sc-login-form").validate({ rules: { username: { required: true }, password: { required: true } }, errorPlacement: function( error, element ) { error.insertAfter( element ); } }); }; /** * -------------------------------------------------- * Bootstrap Modal 顯示位置調整置中 * -------------------------------------------------- */ function adjustModalMaxHeightAndPosition(){ $('.modal').each(function(){ if($(this).hasClass('in') == false){ $(this).show(); /* Need this to get modal dimensions */ }; var contentHeight = $(window).height() - 60; var headerHeight = $(this).find('.modal-header').outerHeight() || 2; var footerHeight = $(this).find('.modal-footer').outerHeight() || 2; $(this).find('.modal-content').css({ 'max-height': function () { return contentHeight; } }); $(this).find('.modal-body').css({ 'max-height': function () { return (contentHeight - (headerHeight + footerHeight)); } }); $(this).find('.modal-dialog').addClass('modal-dialog-center').css({ 'margin-top': function () { return -($(this).outerHeight() / 2); }, 'margin-left': function () { return -($(this).outerWidth() / 2); } }); if($(this).hasClass('in') == false){ $(this).hide(); /* Hide modal */ }; }); }; if ($(window).height() >= 320){ $(window).resize(adjustModalMaxHeightAndPosition).trigger("resize"); } /** * -------------------------------------------------- * Video Carousel * -------------------------------------------------- */ $(".sc-carousel").owlCarousel({ items: 5, itemsDesktop : [1199,4], itemsDesktopSmall : [980,3], itemsTablet: [768,3], itemsTabletSmall: false, itemsMobile : [479,2], itemsScaleUp: false, slideSpeed: 400, paginationSpeed: 400, rewindSpeed : 600, navigation: true, navigationText: [ "", "" ], rewindNav : false, scrollPerPage: true, pagination: false, lazyLoad: true, autoHeight: true }); var readmore_config = { speed: 90, collapsedHeight: 64, moreLink: 'Show More', lessLink: 'Show Less' }; /** * -------------------------------------------------- * Video Play * -------------------------------------------------- */ var video = { init: function(e) { e.preventDefault(); var $this = $(this), yid = $this.closest('.sc-item').data('yid'), player = ' ', title = $this.closest('.sc-item').data('title'), description = $this.closest('.sc-item').data('description'); // change player, title and description $video_player.html(player); $video_title.html(title); $video_description .html(description) // autolink .each(function() { $(this).html( $(this).html().replace(/((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g, '$1 ') ); }) .readmore(readmore_config); // scroll to top scrollToTop(); } } $play_link.on('click', video.init); // autolink $video_description .each(function() { $(this).html( $(this).html().replace(/((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g, '$1 ') ); }); /** * -------------------------------------------------- * Read More * -------------------------------------------------- */ $video_description.readmore(readmore_config); });