|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /home/queenjbs/yuchun_before_X/js/ |
Upload File : |
var MYSTIC = typeof MYSTIC === "undefined"? {} : console.log(".");
(function ($) {
MYSTIC = {
_menuOpenBool:false,
appInit:function(){
var _this = MYSTIC;
_this.layout();
_this.reset();
_this.resetInit();
_this.resizeInit();
setTimeout(function(){
_this._menuScroll = new IScroll('.main-menu', {mouseWheel:true});
}, 500);
},
layout:function(){
var _this = MYSTIC;
_this.$body = $('body');
_this.$wrap = $('#wrap');
_this.$btnMenuList = $('#btn-menu-list');
_this.$mainMenu = $('#main-menu');
_this.$mainMenuEl = _this.$mainMenu.find('.main-menu');
_this.$mainMenuScrollEl = $('#main-menu-scroll');
},
reset:function(){
var _this = MYSTIC;
},
resetInit:function(){
var _this = MYSTIC;
_this.$wrap.bind('click.wrap', _this.onWrapClick);
_this.$btnMenuList.bind('click.mystic.menu', _this.onBtnMenuListClick);
},
removeInit:function(){
},
onWrapClick:function(e){
var _this = MYSTIC, target = $(e.target);
if(_this._menuAniBool) return;
if(_this._menuOpenBool){
if(target.parents('#main-menu').length == 0){
e.preventDefault();
e.stopPropagation();
_this.view(true);
}
}
},
onBtnMenuListClick:function(e){
e.preventDefault();
var _this = MYSTIC;
if(_this._menuAniBool) return;
if(!_this.$mainMenu.hasClass('selected')){
_this.view();
}else{
_this.view(true);
}
},
view:function(b){
var _this = MYSTIC, bool = (b)? b:false;
_this._menuAniBool = true;
if(!bool){
_this.$mainMenu.addClass('selected');
_this.$btnMenuList.addClass('selected');
setTimeout(function(){_this._menuOpenBool = true, _this._menuAniBool = false;},200);
}else{
_this.$mainMenu.removeClass('selected');
_this.$btnMenuList.removeClass('selected');
setTimeout(function(){_this._menuOpenBool = false, _this._menuAniBool = false;},200);
}
},
onResize:function(){
var _this = MYSTIC, menuH;
_this._resizeBool = true;
_this.$body.addClass('resize');
menuH = $(window).height();
if(760 > menuH){
TweenLite.set(_this.$mainMenuEl, {css:{height:menuH - 71}});
_this.$mainMenu.addClass('min');
}else{
TweenLite.set(_this.$mainMenuEl, {css:{height:_this.$mainMenuScrollEl.height()}});
_this.$mainMenu.removeClass('min');
}
_this.$mainMenu.scrollTop(0);
_this.$body.removeClass('resize');
_this._resizeBool = false;
},
resizeInit:function(){
var _this = MYSTIC;
$(window).bind('resize.mystic',function(){
_this.onResize();
});
if(window.onorientationchange!==undefined) {
$(window).bind('orientationchange.mystic', function() {
_this.onResize();
});
}
$(window).trigger('resize.mystic');
},
resizeRemoveInit:function(){
$(window).unbind('resize.mystic');
if(window.onorientationchange!==undefined){
$(window).unbind('orientationchange.mystic');
}
}
};
MYSTIC.popup = {
_aniBool:false,
_openBool:false,
_clickBool:false,
_backBool:false,
_callback:'',
init:function(){
var _this = MYSTIC.popup;
_this.layout();
_this.resetInit();
},
layout:function(){
var _this = MYSTIC.popup;
_this.$html = $('html');
_this.$popup = $('#popup');
_this.$popupDeem = $('#popup-deem');
_this.$popupContainer = $('#popup-container');
_this.$popupContent = _this.$popupContainer.find('.popup-content');
_this.$btnClose = $('#popup-btn-close');
},
archiveLoad:function(u, c){
var _this = MYSTIC.popup;
if(c != undefined){
_this._callback = c;
}
$.get(u, _this.archiveHtml);
//$.get('http://blacblak.com/archive/226', _this.archiveHtml);
},
archiveHtml:function(d){
var _this = MYSTIC.popup;
_this.$popupContent.empty().html($(d).find('.archive-detail-content').html());
_this.view();
},
resetInit:function(){
var _this = MYSTIC.popup;
_this.$btnClose.bind('click.popup.close', _this.onCloseClick);
_this.$popup.bind('click.popup', _this.onPopupClick);
_this.$popup.bind('mousemove.popup', _this.onPopupMove);
},
view:function(b){
var _this = MYSTIC.popup, bool = (b)? b:false;
if(!bool){
_this._aniBool = true;
_this._openBool = true;
_this.$html.css({'overflow':'hidden'});
_this.$popup.show();
_this.$popupDeem.show();
TweenLite.set(_this.$popup, {css:{autoAlpha:0}});
TweenLite.set(_this.$popupDeem, {css:{autoAlpha:0}});
TweenLite.to(_this.$popup, 0.5, {css:{autoAlpha:1}, onComplete:function(){
_this._aniBool = false;
}});
TweenLite.to(_this.$popupDeem, 0.3, {css:{autoAlpha:0.85}});
}else{
_this._aniBool = true;
_this.$popupContent.empty();
_this.$html.css({'overflow-y':'scroll'});
TweenLite.to(_this.$popupDeem, 0.3, {css:{autoAlpha:0}});
TweenLite.to(_this.$popup, 0.3, {css:{autoAlpha:0}, onComplete:function(){
_this.$popupDeem.hide();
_this.$popup.hide();
_this._aniBool = false;
_this._openBool = false;
if(_this._callback != ''){
_this._callback();
}
_this._callback = '';
}});
}
},
onCloseClick:function(e){
e.preventDefault();
var _this = MYSTIC.popup;
if(_this._aniBool) return;
_this.view(true);
_this._clickBool = true;
if(!_this._backBool){
History.back();
_this._backBool = false;
}
},
onPopupMove:function(e){
e.preventDefault();
var _this = MYSTIC.popup, target = $(e.target);
if(!_this._openBool) return;
if(_this._aniBool) return;
if(target.parents('#popup-container').length == 0){
_this.$popup.addClass('cursor');
}else{
_this.$popup.removeClass('cursor');
}
},
onPopupClick:function(e){
var _this = MYSTIC.popup, target = $(e.target);
if(_this._aniBool) return;
if(target.parents('#popup-container').length == 0){
e.preventDefault();
_this.view(true);
_this._clickBool = true;
if(!_this._backBool){
History.back();
_this._backBool = false;
}
}
}
};
MYSTIC.galleryPopup = {
_data:'',
_openBool:false,
_aniBool:false,
_imgW:0,
_imgH:0,
init:function(){
var _this = MYSTIC.galleryPopup;
_this.layout();
_this.resetInit();
},
layout:function(){
var _this = MYSTIC.galleryPopup;
_this.$html = $('html');
_this.$content = $('.content');
_this.$galleryPopup = $('#gallery-popup');
_this.$galleryPopupLoader = _this.$galleryPopup.find('.gallery-loader');
_this.$galleryPopupImage = _this.$galleryPopup.find('.gallery-image');
_this.$galleryPopupDeem = $('#gallery-popup-deem');
_this.$galleryPopupPaddle = _this.$galleryPopup.find('.gallery-popup-paddle-nav');
_this.$galleryPopupPaddleEl = _this.$galleryPopupPaddle.find('a');
_this.$galleryPopupPaddlePrevEl = _this.$galleryPopupPaddle.find('a.prev');
_this.$galleryPopupPaddleNextEl = _this.$galleryPopupPaddle.find('a.next');
},
resetInit:function(){
var _this = MYSTIC.galleryPopup;
_this.$galleryPopupDeem.bind('click.gallery.popup', _this.onCloseClick);
_this.$galleryPopupPaddleEl.bind('click.gallery.paddle', _this.onPaddleClick);
$(window).bind('keyup.gallery.popup', _this.onKeyUp);
},
onKeyUp:function(e){
e.preventDefault();
var _this = MYSTIC.galleryPopup;
if(!_this._openBool) return;
if(_this._aniBool) return;
if(e.which == 37){
_this._curId--;
}else if(e.which == 39){
_this._curId++;
}else if(e.which == 27){
_this.view(true);
}
if(_this._curId <= 0){
_this._curId = 0;
}else if(_this._curId >= _this._data.max-1){
_this._curId = _this._data.max-1;
}
if(_this._exId != _this._curId){
_this.galleryChange();
}
},
onPaddleClick:function(e){
e.preventDefault();
var _this = MYSTIC.galleryPopup, $el = $(this);
if($el.hasClass('prev')){
_this._curId--;
}else if($el.hasClass('next')){
_this._curId++;
}
_this.galleryChange();
},
galleryChange:function(){
var _this = MYSTIC.galleryPopup, $targetEl = _this._data.target.eq(_this._curId), imgTop, imgLeft, imgUrl;
_this._aniBool = true;
_this._imgW = $targetEl.attr('data-width');
_this._imgH = $targetEl.attr('data-height');
imgUrl = $targetEl.attr('href');
imgTop = Math.round($(window).height()/2 - _this._imgH/2);
imgLeft = Math.round($(window).width()/2 - _this._imgW/2);
_this.$galleryPopupImage.empty();
_this.paddleCheck();
TweenLite.to(_this.$galleryPopup, 0.3, {css:{top:imgTop, left:imgLeft, width:_this._imgW, height:_this._imgH}, onComplete:function(){
_this.$galleryPopupLoader.show();
var img = new Image();
img.onload = function(){
_this.$galleryPopupLoader.hide();
var imgEl = $(img);
TweenLite.set(imgEl, {css:{autoAlpha:0}});
_this.$galleryPopupImage.html(imgEl);
TweenLite.to(imgEl, 0.3, {delay:0.2, css:{autoAlpha:1}, onComplete:function(){
_this._aniBool = false;
}});
}
img.src = imgUrl;
_this._exId = _this._curId;
}});
},
view:function(b){
var _this = MYSTIC.galleryPopup, bool = (b)? b:false;
_this._aniBool = true;
if(!bool){
_this._curId = _this._data.id;
_this._exId = _this._curId;
_this._max = _this._data.max;
_this.paddleCheck();
_this._openBool = true;
_this.$html.css({'overflow':'hidden'});
_this.$galleryPopup.show();
_this.$galleryPopupDeem.show();
//_this.$content.addClass('blur');
TweenLite.set(_this.$galleryPopup, {css:{autoAlpha:1}});
TweenLite.set(_this.$galleryPopupDeem, {css:{autoAlpha:0}});
TweenLite.to(_this.$galleryPopupDeem, 0.1, {css:{autoAlpha:0.85}, onComplete:function(){
_this.popupAnim();
}});
}else{
_this.$html.css({'overflow-y':'scroll'});
//_this.$content.removeClass('blur');
TweenLite.to(_this.$galleryPopupDeem, 0.1, {css:{autoAlpha:0}});
TweenLite.to(_this.$galleryPopup, 0.1, {css:{autoAlpha:0}, onComplete:function(){
_this.$galleryPopupDeem.hide();
_this.$galleryPopup.hide();
_this.popupAnim(true);
_this._openBool = false;
}});
}
},
paddleCheck:function(){
var _this = MYSTIC.galleryPopup;
if(_this._curId <= 0){
_this.$galleryPopupPaddlePrevEl.addClass('disabled');
_this.$galleryPopupPaddleNextEl.removeClass('disabled');
}else if(_this._curId >= _this._max-1){
_this.$galleryPopupPaddlePrevEl.removeClass('disabled');
_this.$galleryPopupPaddleNextEl.addClass('disabled');
}else{
_this.$galleryPopupPaddlePrevEl.removeClass('disabled');
_this.$galleryPopupPaddleNextEl.removeClass('disabled');
}
},
popupAnim:function(b){
var _this = MYSTIC.galleryPopup, bool = (b)? b:false;
if(!bool){
_this._aniBool = true;
_this._imgW = _this._data.width;
_this._imgH = _this._data.height;
var endT, startL, endL;
endT = Math.round($(window).height()/2 - _this._imgH/2);
startL = Math.round($(window).width()/2);
endL = Math.round($(window).width()/2 - _this._imgW/2);
_this.$galleryPopupLoader.hide();
TweenLite.set(_this.$galleryPopup, {css:{top:endT, left:startL, width:0, height:_this._imgH}});
TweenLite.to(_this.$galleryPopup, 0.3, {delay:0.15, css:{left:endL, width:_this._imgW}, onComplete:function(){
_this.$galleryPopupPaddle.show();
_this.$galleryPopupLoader.show();
TweenLite.set(_this.$galleryPopupPaddle, {css:{autoAlpha:0}});
TweenLite.to(_this.$galleryPopupPaddle, 0.3, {delay:0.15, css:{autoAlpha:1}});
_this.resizeInit();
var img = new Image();
img.onload = function(){
_this.$galleryPopupLoader.hide();
var imgEl = $(img);
TweenLite.set(imgEl, {css:{autoAlpha:0}});
_this.$galleryPopupImage.empty().html(imgEl);
TweenLite.to(imgEl, 0.5, {delay:0.2, css:{autoAlpha:1}, onComplete:function(){
_this._aniBool = false;
}});
}
img.src = _this._data.url;
}});
}else{
_this._aniBool = true;
_this.resizeRemoveInit();
_this.$galleryPopupImage.empty();
TweenLite.set(_this.$galleryPopup, {css:{top:0, left:0, width:0, height:0}});
TweenLite.set(_this.$galleryPopupPaddle, {css:{autoAlpha:0}});
_this.$galleryPopupPaddle.hide();
_this._data = '';
_this._imgW = 0;
_this._imgH = 0;
_this._aniBool = false;
}
},
onCloseClick:function(e){
e.preventDefault();
var _this = MYSTIC.galleryPopup;
_this.view(true);
},
onResize:function(){
var _this = MYSTIC.galleryPopup, endT, endL;
endT = Math.round($(window).height()/2 - _this._imgH/2);
endL = Math.round($(window).width()/2 - _this._imgW/2);
TweenLite.set(_this.$galleryPopup, {css:{left:endL, top:endT}});
},
resizeInit:function(){
var _this = MYSTIC.galleryPopup;
$(window).bind('resize.gallery.popup',function(){
_this.onResize();
});
if(window.onorientationchange!==undefined) {
$(window).bind('orientationchange.gallery.popup', function() {
_this.onResize();
});
}
$(window).trigger('resize.gallery.popup');
},
resizeRemoveInit:function(){
$(window).unbind('resize.gallery.popup');
if(window.onorientationchange!==undefined){
$(window).unbind('orientationchange.gallery.popup');
}
}
};
$(document).ready(function(){
MYSTIC.appInit();
MYSTIC.popup.init();
MYSTIC.galleryPopup.init();
});
})(jQuery);