/*!
* jQuery Ajax Smoother Library v1.0
* http://www.logic-design.co.jp/
*
* Copyright 2014- LogicDesign Inc.
* Released under the Creative Commons license
* 1. Attribution, BY
* 2. Noncommercial, NC
* http://www.logic-design.co.jp/ license
*
* Date: 2014-05-31
*
* Base: jQuery(http://jquery.com/)
*/
/*
################################# REFERENCE ##################################
$.fn.popup
@description
指定要素をポップアップとして表示する。
@parameters
-options: 以下の要素からなる連想配列を指定する。
-title: ポップアップのタイトル(省略時: 要素のdata-title属性値),
-closeButton: ×ボタンの表示フラグ,
-closeBackGround: 背景クリックによるポップアップ終了を行うか,
-closeEvent: ポップアップ終了時イベント,
-fadeSpeed: フェードのスピード,
-draggable: タイトル部がドラッグ可能とするか,
-marginTop: マージン(上),
-marginLeft: マージン(左),
-marginRight: マージン(右),
-marginBottom: マージン(下),
-wrapperClass: ポップアップの外枠に設定するクラス,
*/
(function($) {
var popup_state = 0;
var first_event = true;
$.fn.popup = function(over_options){
var $this = $(this);
var id = "jqpid" + (+new Date());
var $tmp = $("
").attr("id", id);
var attributes = $this[0].attributes;
for(var i = 0; i < attributes.length; i++){
$tmp.attr("data-jqp-" + attributes[i].name, attributes[i].value);
}
$this.data("jqp-position-id", id);
$tmp.insertAfter($this);
var options = {
wrapperClass: $this.data("class"),
title: $this.data("jq-title"),
closeButton: true,
closeBackGround: true,
closeEvent: null,
fadeSpeed: 100,
draggable: true,
marginTop: 0,
marginLeft: 0,
marginRight: 0,
marginBottom: 0
}
var tag_options = $this.data("jq-popup");
if(tag_options != null) eval("$.extend(options, {" + tag_options + "});");
$.extend(options, over_options);
var $frame;
var $background;
var $wrapper;
var $title;
var $close;
var $header;
$this.appendTo($("body"));
var this_width = $this[0] != null ? $this[0].style.width : null;
var this_height = $this[0] != null ? $this[0].style.height : null;
var this_max_width = $this.css("max-width");
var this_max_height = $this.css("max-height");
$this.attr("data-jq-popup-wrapped", 1);
$this.data("jq-popup-fade", options.fadeSpeed);
$this.css({visibility: "hidden", position: "fixed"}).show();
var max_sx, max_sy;
var sx, sy;
if((this_width != null) && (this_width.indexOf("%") != -1)){
sx = $(window).width() * parseInt(this_width.replace("%", ""), 10) / 100;
if(parseInt(this_max_width, 10) < sx){
sx = parseInt(this_max_width, 10);
}
} else {
sx = $this.width();
}
if((this_height != null) && (this_height.indexOf("%") != -1)){
sy = $(window).height() * parseInt(this_height.replace("%", ""), 10) / 100;
if(parseInt(this_max_height, 10) < sy){
sy = parseInt(this_max_height, 10);
}
} else {
sy = $this.height();
}
$frame = $("