Skip to content

Commit

Permalink
ax5dialog 0.5.0 / ax5modal test
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasJang committed Jan 14, 2016
1 parent 223d72a commit 5018294
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 51 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap-ax5dialog",
"version": "0.4.0",
"version": "0.5.0",
"authors": [
"ThomasJ <tom@axisj.com>"
],
Expand Down
2 changes: 1 addition & 1 deletion dist/ax5dialog.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 45 additions & 22 deletions dist/ax5dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
msg: '',
lang: {
"ok": "ok", "cancel": "cancel"
}
},
animateTime: 250
};
}).apply(this, arguments);

Expand Down Expand Up @@ -238,24 +239,20 @@
opts.id = (opts.id || cfg.id);

box = {
width: opts.width || cfg.width
width: opts.width
};
jQuery(document.body).append(this.getContent(opts.id, opts));

this.activeDialog = jQuery('#' + opts.id);
this.activeDialog.css({width: box.width});

// dialog 높이 구하기 - 너비가 정해지면 높이가 변경 될 것.
box.height = this.activeDialog.height();
opts.height = box.height = this.activeDialog.height();

//- position 정렬
if (typeof opts.position === "undefined" || opts.position === "center") {
var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
var w = window.innerWidth;
var h = window.innerHeight;

pos.top = h / 2 - box.height / 2;
pos.left = w / 2 - box.width / 2;
Expand Down Expand Up @@ -283,6 +280,10 @@
this.onKeyup(e || window.event, opts, callBack);
}).bind(this));

jQuery(window).bind("resize.ax-dialog", (function (e) {
this.align(e || window.event);
}).bind(this));

if (opts && opts.onStateChanged) {
that = {
state: "open"
Expand All @@ -292,6 +293,26 @@
return this;
};

this.align = function(e){
if(!this.activeDialog) return this;
var opts = self.dialogConfig,
box = {
width: opts.width,
height: opts.height
};
//- position 정렬
if (typeof opts.position === "undefined" || opts.position === "center") {
box.top = window.innerHeight / 2 - box.height / 2;
box.left = window.innerWidth / 2 - box.width / 2;
}
else {
box.left = opts.position.left || 0;
box.top = opts.position.top || 0;
}
this.activeDialog.css(box);
return this;
};

this.btnOnClick = function (e, opts, callBack, target, k) {
if (e.srcElement) e.target = e.srcElement;

Expand Down Expand Up @@ -378,21 +399,23 @@
* myDialog.close();
* ```
*/
this.close = function () {
var
that = {},
opts = self.dialogConfig;

this.close = function (opts, that) {
if (this.activeDialog) {
this.activeDialog.remove();
this.activeDialog = null;
opts = self.dialogConfig;
this.activeDialog.addClass("destroy");
jQuery(window).unbind("keydown.ax-dialog");
if (opts && opts.onStateChanged) {
that = {
state: "close"
};
opts.onStateChanged.call(that, that);
}
jQuery(window).unbind("resize.ax-dialog");

setTimeout((function () {
this.activeDialog.remove();
this.activeDialog = null;
if (opts && opts.onStateChanged) {
that = {
state: "close"
};
opts.onStateChanged.call(that, that);
}
}).bind(this), cfg.animateTime);
}
return this;
}
Expand Down
Loading

0 comments on commit 5018294

Please sign in to comment.