/*----------------------------------------------
jquery.cookie.js
----------------------------------------------*/
jQuery.cookies = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
var path = options.path ? '; path=' + options.path : '';
var domain = options.domain ? '; domain=' + options.domain : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};
/**
* "smartModalWindow" jQuery plugin
*
* @author RaNa design associates, inc.
* @copyright 2010 RaNa design associates, inc.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version Release: 0.5.1
* @link http://kaelab.ranadesign.com/blog/demo/smartModalWindow/
* @since 2010-10-27
* @update 2010-11-01
*/
(function($) {
/**
* jQuery interface
*/
$.fn.smartModalWindow = function(args) {
if (this[0]) {
this.each(function() {
this.modalWindow = new SmartModalWindow(args, this);
});
}
return this;
}
/**
* constructor
*/
function SmartModalWindow(options, triggerElement) {
this.options = {
url: $(triggerElement).attr('href'),
triggerEvent: 'click',
enableClassName : 'modal_on',
disableClassName : 'modal_off',
bodyContainer: 'div.area_container', // container of normal contents
modalContainerClassName: 'modal_container', // class name of modal contents
closeModalTriggerButton: 'a.closeModal',
closeModalTriggerEvent: 'click',
overlayClassName: 'modal_overlay',
overlayEnableClassName: 'modal_overlay_on',
//loadingImgSrc: '/ntt/sp/cmn/img/loading.gif',
//loadingImgClassName: 'loadingImg'
};
$.extend(this.options, options);
this.element = triggerElement;
this.$bodyContainer = $(this.options.bodyContainer);
/*@cc_on this.$bodyContainer.css({ "zoom": 1 }); @*/
this.$bodyContainer.css({'z-index': 10})
this.$bodyContainer.cssOverflow = this.$bodyContainer.css('overflow');
this.scrollTop = 0;
this.initialize();
}
SmartModalWindow.prototype = {
utils: {
isWebkit: (navigator.userAgent.toLowerCase().indexOf('webkit') != -1) ? 1 : 0
},
$modalContainer: $('
'),
//$loadingImg: $('
'),
$overlay: $(''),
initialize: function() {
var self = this;
/*this.$loadingImg.attr({
'src': this.options.loadingImgSrc,
'class': this.options.loadingImgClassName
}).appendTo(this.$overlay);*/
this.$overlay.attr({
'class': this.options.overlayClassName}).hide().appendTo(document.body);
this.$modalContainer.attr({
'class': this.options.modalContainerClassName
}).appendTo(document.body);
if (this.utils.isWebkit) {
this.$modalContainer.bind('webkitAnimationEnd', function() {
self.hideModalContentsComplete_();
});
}
this.layoutLoadingImg_();
this.layoutOverlay_();
$(window).bind('resize', function() {
self.layoutLoadingImg_();
self.layoutOverlay_();
});
$(this.element).bind(this.options.triggerEvent, function(e) {
//
var url = $(this).attr("rel");
self.showModalContents(url);
e.preventDefault();
});
},
layoutLoadingImg_: function() {
/*var scrollY = (window.scrollY || window.pageYOffset || document.documentElement.scrollTop),
windowHeight = (window.innerHeight || document.documentElement.clientHeight);
this.$loadingImg.css({
'top': Math.floor(scrollY) + Math.floor(windowHeight / 2),
'left': '50%'
});*/
},
layoutOverlay_: function() {
var docHeight = ($(document.body).height() < this.$bodyContainer.height()) ? this.$bodyContainer.height() : $(document.body).height();
this.$overlay.originalHeight = docHeight;
this.$overlay.css({ 'height': docHeight });
},
showModalContents: function(url) {
if(1 === parseInt($.cookies('modalAlert'))) {
window.open(url, '_self');
} else {
var self = this;
$("object.OoyalaVideoPlayer").css("visibility","hidden");
this.layoutLoadingImg_();
this.$overlay.show();
this.scrollTop = (document.documentElement.scrollTop || document.body.scrollTop || $(window).scrollTop());
// load contents on ajax
this.$modalContainer.load(this.options.url, function() {
// callback
$(self.options.closeModalTriggerButton).bind(self.options.closeModalTriggerEvent, function(e) {
self.hideModalContents_();
e.preventDefault();
});
$("#btnYes a").bind(self.options.closeModalTriggerEvent, function(e) {
$.cookies("modalAlert", null);
$.cookies("modalAlert",1,{path:'/'});
self.hideModalContents_();
setTimeout(function(){window.open(url, '_self');}, 400);
return false;
}).attr("href",url);
var contentsHeight = self.$modalContainer.height();
self.$overlay.toggleClass(self.options.overlayEnableClassName)/*.css({ 'height': contentsHeight })*/;
self.$bodyContainer.css({
'height': contentsHeight,
'overflow': 'hidden'
});
//self.$loadingImg.hide();
window.scrollTo(0, 0);
setTimeout(function() {
self.$modalContainer.addClass(self.options.enableClassName).removeClass(self.options.disableClassName).show();
}, 350);
});
}
},
hideModalContents_: function() {
this.$overlay.css({ 'height': this.$overlay.originalHeight });
this.$modalContainer.addClass(this.options.disableClassName).removeClass(this.options.enableClassName);
if (!this.utils.isWebkit) { this.hideModalContentsComplete_(); }
},
hideModalContentsComplete_: function() {
var self = this;
this.modalDisplayFlag = !!(this.modalDisplayFlag) ? 0 : 1;
if (!this.utils.isWebkit || this.modalDisplayFlag === 0) {
this.$modalContainer.hide();
this.$overlay.toggleClass(this.options.overlayEnableClassName).fadeOut(function() {
self.$bodyContainer.css({
'height': 'auto',
'overflow': self.$bodyContainer.cssOverflow
});
window.scrollTo(0, self.scrollTop);
$("object.OoyalaVideoPlayer").css("visibility","visible");
//self.$loadingImg.show();
});
}
},
};
})(jQuery);
$(function(){
//menuList呼び出し
$("#menuList").css("display","none");
$("#btnMenu01").click(function(){
if($("#menuList").css("display") == "none"){
$("div.modal_overlay").fadeIn();
$("#menuList").slideDown();
};
return false;
});
$("a.closeMenu").click(function(){
$("#menuList").slideUp();
$("div.modal_overlay").fadeOut();
});
});
jQuery.event.add(window, "load", function(){
//modal window 呼び出し
$(".openModal").smartModalWindow();
$("iframe#detail").contents().find(".openModal").smartModalWindow();
//iFrame内のページ内リンクを、似た挙動で再現
$("iframe#detail").contents().find("a[href^='#']").click(function(){
var fHref = $(this).attr("href");
var fTarget = $('iframe#detail').contents().find(fHref).offset().top;
$('body,html').scrollTop(fTarget);
});
});
//iframe Fix
function doIframe(){
o = document.getElementsByTagName('iframe');
for(i=0;i