Skip to content

Commit 5b472f0

Browse files
committed
0.8.1 update
1 parent 588ab99 commit 5b472f0

File tree

6 files changed

+56
-29
lines changed

6 files changed

+56
-29
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# jQuery MsgBox
22

3-
0.8.0 BETA
3+
0.8.1 BETA
44

55
## What is it?
66

@@ -11,7 +11,7 @@ Firefox style simplist dialog form.
1111

1212
before install, you must have [jQuery](http://jquery.com/download/) >= 1.5.0, I strongly recommand you have a lastest version.
1313

14-
That's very simple. just download below,
14+
That's very simple. just download below lastest version,
1515

1616
- [Minified (for production)](https://raw.github.com/composite/jQuery.MsgBox/master/jquery.msgbox.min.js)
1717
- [Unminified (for development)](https://raw.github.com/composite/jQuery.MsgBox/master/jquery.msgbox.js)
@@ -126,6 +126,11 @@ Sorry. that is prevent changing width dynamically after center align on IE. I do
126126

127127
## What's new?
128128

129+
### 0.8.1
130+
131+
- Some code optimization.
132+
- Use UglifyJS for minification, instead of YUI compressor.
133+
129134
### 0.8.0
130135

131136
- Major UI changes: more compatibility to view, Wrapped more a div to centering layer using only CSS (but still vertical centering using JS).

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "msgbox",
3-
"version": "0.8.0",
3+
"version": "0.8.1",
44
"description": "The Message box for web, Firefox style, User notification made simple.",
55
"keywords": ["alert","confirm","prompt","msgbox","dialog","notification","ui","simple"],
66
"authors": ["Composite"],

demo.min.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8"/>
5+
<title>MsgBox 데모</title>
6+
</head>
7+
<body>
8+
<button onclick="alert('테스트 경고창입니다.')">일반 경고창</button>
9+
<button onclick="$.alert('테스트 경고창입니다.')">경고창</button>
10+
<button onclick="$.alert('테스트 경고창입니다. 세상에서 가장 긴 그림은 긴 기린 보고 그린 길다란 기린 그림 \n 대우로얄뉴로얄~',function(){$.alert('참 길죠잉?');})">긴 경고창</button>
11+
<button onclick="$.confirm('테스트 하시겠습니까?',function(b){$.alert((b?'확인':'취소')+' 하셨습니다.');})">질문창</button>
12+
<button onclick="$.prompt('이름을 입력하세요.',function(s){$.alert('이름은 : '+s);})">입력창</button>
13+
<button onclick="$.prompt('이름을 입력하세요. 세상에서 가장 긴 그림은 긴 기린 보고 그린 길다란 기린 그림 ','test',function(s){$.alert('이름은 : '+s);})">긴 입력창</button>
14+
<button onclick="alert(prompt('이름을 입력하세요. 세상에서 가장 긴 그림은 긴 기린 보고 그린 길다란 기린 그림 ','test'))">일반 입력창</button>
15+
<script>document.write('<script src="'+(~location.protocol.indexOf('http')?'':'http:')+'//code.jquery.com/jquery-1.10.2.min.js"><\/script>');</script>
16+
<script src="jquery.msgbox.min.js"></script>
17+
<script>
18+
for(var i=0;i<100;i++){
19+
document.write('<br/>');
20+
}
21+
</script>
22+
</body>
23+
</html>

jquery.msgbox.js

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**************************************************************************************
2-
* jQuery MsgBox 0.8.0
2+
* jQuery MsgBox 0.8.1
33
* by composite (ukjinplant@msn.com)
44
* http://blog.hazard.kr
55
* This project licensed under a MIT License.
@@ -9,7 +9,7 @@
99
window.console = {};
1010
window.console.log = $.noop;
1111
}
12-
var fixed = 'fixed', div = 'div', kp = 'keypress', rs = 'resize', legacy = 'v' == '\v' //IE 8 대응.
12+
var fixed = 'fixed', div = 'div', kp = 'keypress', rs = 'resize', mb = 'msgbox-', dmb = '.' + mb, cst = mb + '-style', btn = 'button', clk = 'click', legacy = 'v' == '\v' //IE 8 대응.
1313
,isCssDef = function(css){
1414
return !css || css == 'auto';
1515
},$$ = function(tag){return $(document.createElement(tag));};
@@ -18,13 +18,13 @@
1818
var styleGen = function(style, repl){
1919
if(styleGen.once && !repl) return;
2020
style = style || {};
21-
var css = styleGen.style ? styleGen.style : (styleGen.style = $$('style').addClass('msgbox-style').attr('type','text/css')), builder = [];
21+
var css = styleGen.style ? styleGen.style : (styleGen.style = $$('style').addClass(cst).attr('type','text/css')), builder = [];
2222

2323
for(var part in style){
2424
if(!style[part]){continue;}
2525
var cs = style[part];
2626

27-
builder.push('.msgbox-' + part);
27+
builder.push(dmb + part);
2828
builder.push('{');
2929

3030
for(var name in cs){
@@ -58,11 +58,10 @@
5858
options = $.extend({}, $.msgbox.options, options);
5959

6060
//스타일 생성
61-
if(!$('.msgbox-style').length){styleGen($.msgbox.css);}
61+
if(!$(cst).length){styleGen($.msgbox.css);}
6262

6363
//변수 및 요소 정의
6464
var io = {},
65-
mb = 'msgbox-',
6665
cok = mb + 'ok',
6766
cno = mb + 'no',
6867
pw = 'password',
@@ -73,7 +72,7 @@
7372
q = !!options.confirm,
7473
iae = function(e) { //포커스된 요소가 메시지박스 아니면 메시지박스로 강제 포커스 이동
7574
setTimeout(function(){
76-
var act=$(document.activeElement),ms=['.'+mb+'input','.'+mb+'button'];
75+
var act=$(document.activeElement),ms=[dmb+'input',dmb+btn];
7776
if(act.length&&(act.is(ms[0])||act.is(ms[1]))){
7877
//console.log('good.');
7978
}
@@ -82,7 +81,7 @@
8281
},
8382
$W = $(window),
8483
//경고창
85-
$C = $$('div').addClass(mb + 'container').append($$(div).addClass(mb + 'ui').addClass(mb + (p ? 'prompt' : (q ? 'confirm' : 'alert')))).children(),
84+
$C = $$(div).addClass(mb + 'container').append($$(div).addClass(mb + 'ui').addClass(mb + (p ? 'prompt' : (q ? 'confirm' : 'alert')))).children(),
8685
//경고창 배경
8786
$M = $$(div).addClass(mb + 'modal'),
8887
//경고 내용
@@ -94,16 +93,16 @@
9493
var code = e.which;
9594
if(code == 9 && e.shiftKey){
9695
e.preventDefault();
97-
$C.find('.'+mb+'button').filter(':last').focus();
96+
$C.find(dmb+btn).filter(':last').focus();
9897
}else{
9998
switch(code){
10099
case 13://엔터는 확인
101100
e.preventDefault();
102-
$C.find('button.' + cok).trigger('click');
101+
$C.find(btn + '.' + cok).trigger(clk);
103102
return false;
104103
case 27://ESC는 취소
105104
e.preventDefault();
106-
$C.find('button.' + (p || q ? cno : cok)).trigger('click');
105+
$C.find(btn + '.' + (p || q ? cno : cok)).trigger(clk);
107106
break;
108107
}
109108
}
@@ -112,7 +111,7 @@
112111
//경고 버튼 나열
113112
$B = $$(div).addClass(mb + 'buttons').appendTo($C),
114113
//기본 버튼
115-
$BT = $$("button").addClass(mb + 'button').bind('keydown',function(e){
114+
$BT = $$(btn).addClass(mb + btn).bind('keydown',function(e){
116115
if(this!=document.activeElement) return;
117116

118117
e.stopPropagation();
@@ -121,19 +120,19 @@
121120
case 9://탭키 누르면 다음 버튼 및 입력창 포커스
122121
case 39://오른쪽키 누르면 다음 버튼으로만 포커스
123122
e.preventDefault();
124-
if(target=that[code==9&&shift?'prev':'next']('button'),target.length) target.focus();
123+
if(target=that[code==9&&shift?'prev':'next'](btn),target.length) target.focus();
125124
else if(code==9){
126-
if(target=$C.find('.'+mb+'input'),target.length) target.select();
127-
else if(target=that[shift?'next':'prev']('button'),target.length) target.focus();
125+
if(target=$C.find(dmb+'input'),target.length) target.select();
126+
else if(target=that[shift?'next':'prev'](btn),target.length) target.focus();
128127
}
129128
break;
130129
case 37://왼쪽키는 이전 버튼으로만 포커스
131130
e.preventDefault();
132-
if(target=that.prev('button'),target.length) target.focus();
131+
if(target=that.prev(btn),target.length) target.focus();
133132
break;
134133
case 27://ESC는 무조건 취소처리
135134
e.preventDefault();
136-
$C.find('button.' + (p || q ? cno : cok)).trigger('click');
135+
$C.find(btn + '.' + (p || q ? cno : cok)).trigger(clk);
137136
break;
138137
}
139138
}).bind('blur',iae),
@@ -169,20 +168,20 @@
169168
var code = window.event ? window.event.keyCode : e.which;
170169
//전역 메시지박스에도 before가 붙으므로 격리.
171170
if(e.target.type=='text'&&!code){
172-
$C.find('button.' + (p || q ? cno : cok)).trigger('click');
171+
$C.find(btn + '.' + (p || q ? cno : cok)).trigger(clk);
173172
return f;
174173
}
175174
switch (code) {
176175
case 13:
177-
$C.find('button:focus').trigger('click');
176+
$C.find(btn + ':focus').trigger('click');
178177
return f;
179178
case 27:
180-
$C.find('button.' + (p || q ? cno : cok)).trigger('click');
179+
$C.find(btn + '.' + (p || q ? cno : cok)).trigger(clk);
181180
return f;
182181
}
183182
};
184183
//body에 삽입 후 레이아웃 잡기
185-
var kt = '.' + mb + 'ui,.' + mb + 'modal',
184+
var kt = dmb + 'ui,' + dmb + 'modal',
186185
$D = $(document.documentElement || document.body).append($M).append($C.parent()).bind(kp, io.before);
187186
//경고창 비활성화 후
188187
io.after = function (b, v) {
@@ -202,7 +201,7 @@
202201
$W.unbind(rs, io[rs]);
203202
};
204203
//공통 경고 클릭 시 조치
205-
$C.delegate('button', 'click', function (e) {
204+
$C.delegate(btn, clk, function (e) {
206205
var cleanup = function(){
207206
$C.parent().add($M).remove();
208207
},onclose = options.onclose || $.msgbox.onclose;
@@ -218,7 +217,7 @@
218217
$W.trigger(rs);
219218
//경고창 포커스
220219
if (p) $C.find('input:text').select();
221-
else $C.find('button:eq(0)').focus();
220+
else $C.find(btn + ':eq(0)').focus();
222221
//onopen 이벤트 발생
223222
var onopen = options.onopen || $.msgbox.onopen;
224223
if($.isFunction(onopen)) onopen.call($C[0], options);

0 commit comments

Comments
 (0)