From 42d242ffa51c3526d1694c2f99f734537013426c Mon Sep 17 00:00:00 2001 From: Ukjin Yang Date: Wed, 11 Dec 2013 11:58:15 +0900 Subject: [PATCH 01/23] Applied more compatibility. Use <div> with white-space: pre; instead of <pre> for more better view of MsgBox with CSS Framework such as Bootstrap. Remove Browser compatibility for position:fixed is buggy under IE 7, so this will support jQuery over 1.8! I'll never test freaking old browsers. --- README.md | 22 +++++++++++++++++----- demo.html | 4 ++-- jquery-1.7.2.min.js | 4 ---- jquery.msgbox.js | 19 +++++++++++-------- jquery.msgbox.min.js | 8 ++++---- readme.txt | 7 ++++--- 6 files changed, 38 insertions(+), 26 deletions(-) delete mode 100644 jquery-1.7.2.min.js diff --git a/README.md b/README.md index cbdae1f..243a633 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ jQuery MsgBox ============= -0.3.7 BETA +0.5.0 BETA What is it? ----------- @@ -67,12 +67,12 @@ It's Very simple. ```js $.alert("click me.",function(){ - $.alert('you clicked'); + $.alert('you are clicked!'); }); ``` ```js $.confirm("press OK or Cancel.",function(bool){ - $.alert('you clicked'+(bool?'OK':'cancel')); + $.alert('you are clicked '+(bool?'OK':'cancel')); }); ``` ```js @@ -84,7 +84,7 @@ $.prompt("what's your name?",function(string){ I want view live example. ------------------------- -OK. [here's an example](http://jsfiddle.net/preFy/ "live example"). +Sure. [here's an example](http://jsfiddle.net/preFy/ "live example"). What browser can run with this plugin? -------------------------------------- @@ -99,12 +99,24 @@ Wow! It's simple and cool! can I join with you for make better this plugin? Sure. contributes are welcome! just fork this plugin and get involved to make a better place for you and for me. +Hey, I'm using IE version under 9, Msgbox flicking when showing MsgBox. What's happening? +------------------------------------------------------------------------------------------ + +Sorry. that is prevent changing width dynamically after center align on IE. I don't know it is bug, but I'll figure out it. + Goals ----- - More Simplify and Optimization. - Less Size and Unresolved Issues. - - **All Methods will returns Deferred Object instead of DOM Container** + - **All Methods will returns Deferred Object instead of DOM Container** ??? Well, I'll think about it. + +What's new? +----- + + - Use <div> with white-space: pre; instead of <pre> for more better view of MsgBox with CSS Framework such as Bootstrap. + - Remove Browser compatibility for position:fixed is buggy under IE 7, so this will support jQuery over 1.8! I'll never test freaking old browsers. + - Remove jQuery in my repository, Use any available jQuery CDN in demo instead. License diff --git a/demo.html b/demo.html index 51b685b..5d004bc 100644 --- a/demo.html +++ b/demo.html @@ -7,12 +7,12 @@ - + - + ``` -alert("i'm alert"); --> $.alert("i'm alert"); + alert("i'm alert"); + -> $.alert("i'm alert"); -confirm("Are you sure?"); --> $.confirm("Are you sure?"); + confirm("Are you sure?"); + -> $.confirm("Are you sure?"); -prompt("please text me."); --> $.prompt("please text me."); + prompt("please text me."); + -> $.prompt("please text me."); -Wait! YOU MUST SEE BEFORE USE THIS PLUGIN, ------------------------------------------- +## Wait! YOU MUST SEE BEFORE USE THIS PLUGIN, this plugin is can't replace as javascript standard function (alert, etc.) because, this plugin cannot wait user action while showing dialog. If you want get user's action, put a callback function in next of message param. @@ -46,6 +42,7 @@ form.submit=function(){ } ``` **So, what can I do?** + ```js form.submit=function(){ if(!form.confirm){//Use variables or DOM objects or whatever you want. @@ -59,8 +56,7 @@ form.submit=function(){ ``` * You can use another solution to solve this. -OK. so, How to use with callback function? ------------------------------------------- +## OK. so, How to use with callback function? jQuery.MsgBox can add your callback function for provide next action after user clicked. It's Very simple. @@ -81,59 +77,51 @@ $.prompt("what's your name?",function(string){ }); ``` -I want view live example. -------------------------- +## I want view live example. Sure. [here's an example](http://jsfiddle.net/preFy/ "live example"). -What browser can run with this plugin? --------------------------------------- +## What browser can run with this plugin? + first, jQuery 1.4 or later needed. and, You can run with most popular major browser, Internet Explorer 8 or above, Firefox 3 or above, Safari 4 or above, Chrome 10 or above, Opera 9 or above. NOTE : Old school browser, such as IE 7 or lower is have a problem with CSS issue. that's all. this plugin have NO images or other resources. -I want use as own style, is it possible? ----------------------------------------- +## I want use as own style, is it possible? Yes. check out [Wiki](https://github.com/composite/jQuery.MsgBox/wiki) for detailed usage. -Wow! It's simple and cool! can I join with you for make better this plugin? ---------------------------------------------------------------------------- +## Wow! It's simple and cool! can I join with you for make better this plugin? Sure. contributes are welcome! just fork this plugin and get involved to make a better place for you and for me. -Hey, I'm using IE version under 9, Msgbox flicking when showing MsgBox. What's happening? ------------------------------------------------------------------------------------------- +## Hey, I'm using IE version under 9, Msgbox flicking when showing MsgBox. What's happening? Sorry. that is prevent changing width dynamically after center align on IE. I don't know it is bug, but I'll figure out it. -Goals ------ +## Goals - More Simplify and Optimization. - Less Size and Unresolved Issues. - **Use CSS instead of inline style!!!** - **All Methods will returns Deferred Object instead of DOM Container** ??? Well, I'll think about it. -What's new? ------ +## What's new? -0.5.0 -===== +### 0.5.0 - Use <div> with white-space: pre; instead of <pre> for more better view of MsgBox with CSS Framework such as Bootstrap. - Remove Browser compatibility for position:fixed is buggy under IE 7, so this will support jQuery over 1.8! I'll never test freaking old browsers. - Remove jQuery in my repository, Use any available jQuery CDN in demo instead. -0.6.0 -===== +### 0.6.0 + - Auto resizing added. Msgbox will show full size when window size less than alert size, If not, revert original size. -License -------- +## License (The MIT License) From 4b97e0e7c431ab1bb44abedc4bd240235c38033c Mon Sep 17 00:00:00 2001 From: Ukjin Yang Date: Thu, 12 Dec 2013 13:43:05 +0900 Subject: [PATCH 08/23] spelling --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 53966c1..c375ed6 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ Sorry. that is prevent changing width dynamically after center align on IE. I do ### 0.6.0 - - Auto resizing added. Msgbox will show full size when window size less than alert size, If not, revert original size. + - Auto resizing added. Msgbox will show full size when window size less than alert size, If not, revert to original size. ## License From ec3ccfbfe9faf49b3c43c1d1aebb7ad4390443ba Mon Sep 17 00:00:00 2001 From: Ukjin Yang Date: Thu, 12 Dec 2013 14:12:36 +0900 Subject: [PATCH 09/23] Fixed enter key event Fixed forced true callback after press ENTER key. focused button will fired event if you press ENTER key. --- README.md | 11 +++++++---- jquery.msgbox.js | 13 +++++++------ jquery.msgbox.min.js | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c375ed6..edb71e7 100644 --- a/README.md +++ b/README.md @@ -110,16 +110,19 @@ Sorry. that is prevent changing width dynamically after center align on IE. I do ## What's new? -### 0.5.0 +### 0.6.1 - - Use <div> with white-space: pre; instead of <pre> for more better view of MsgBox with CSS Framework such as Bootstrap. - - Remove Browser compatibility for position:fixed is buggy under IE 7, so this will support jQuery over 1.8! I'll never test freaking old browsers. - - Remove jQuery in my repository, Use any available jQuery CDN in demo instead. + - Fixed forced true callback after press ENTER key. focused button will fired event if you press ENTER key. ### 0.6.0 - Auto resizing added. Msgbox will show full size when window size less than alert size, If not, revert to original size. +### 0.5.0 + + - Use <div> with white-space: pre; instead of <pre> for more better view of MsgBox with CSS Framework such as Bootstrap. + - Remove Browser compatibility for position:fixed is buggy under IE 7, so this will support jQuery over 1.8! I'll never test freaking old browsers. + - Remove jQuery in my repository, Use any available jQuery CDN in demo instead. ## License diff --git a/jquery.msgbox.js b/jquery.msgbox.js index dd7fd3f..164aa6c 100644 --- a/jquery.msgbox.js +++ b/jquery.msgbox.js @@ -1,5 +1,5 @@ /************************************************************************************** - * jQuery MsgBox 0.6.0 + * jQuery MsgBox 0.6.1 * by composite (ukjinplant@msn.com) * http://blog.hazard.kr * This project licensed under a MIT License. @@ -55,12 +55,13 @@ //경고 버튼 나열 $BT = $("").addClass(mb + 'button').css(styles.button || {}).bind('keydown',function(e){ if(this!=document.activeElement) return; - e.stopPropagation(); + + e.stopPropagation(); var code = window.event ? window.event.keyCode : e.which,that=$(this),target,shift=e.shiftKey; switch (code) { case 9://탭키 누르면 다음 버튼 및 입력창 포커스 case 39://오른쪽키 누르면 다음 버튼으로만 포커스 - e.preventDefault(); + e.preventDefault(); if(target=that[code==9&&shift?'prev':'next']('button'),target.length) target.focus(); else if(code==9){ if(target=$C.find('.'+mb+'input'),target.length) target.select(); @@ -68,11 +69,11 @@ } break; case 37://왼쪽키는 이전 버튼으로만 포커스 - e.preventDefault(); + e.preventDefault(); if(target=that.prev('button'),target.length) target.focus(); break; case 27://ESC는 무조건 취소처리 - e.preventDefault(); + e.preventDefault(); $C.find('button.' + (p || q ? cno : cok)).trigger('click'); break; } @@ -130,7 +131,7 @@ } switch (code) { case 13: - $C.find('button.' + cok).trigger('click'); + $C.find('button:focus').trigger('click'); return f; case 27: $C.find('button.' + (p || q ? cno : cok)).trigger('click'); diff --git a/jquery.msgbox.min.js b/jquery.msgbox.min.js index 2dfb8fe..c5a279e 100644 --- a/jquery.msgbox.min.js +++ b/jquery.msgbox.min.js @@ -1,7 +1,7 @@ /************************************************************************************** - * jQuery MsgBox 0.6.0 + * jQuery MsgBox 0.6.1 * by composite (ukjinplant@msn.com) * http://blog.hazard.kr * This project licensed under a MIT License. **************************************************************************************/; -(function(e){if(!window.console){window.console={};window.console.log=e.noop}var d="fixed",b="keypress",a="resize",c=function(f){return !f||f=="auto"};e.msgbox=function(i,h){h=e.extend({},e.msgbox.options,h);var k={},g="msgbox-",j=g+"ok",D=g+"no",s="password",l=h.css||{},o=!0,A=!1,w=("input" in h),u=!!h.confirm,F=function(f){setTimeout(function(){var p=e(document.activeElement),q=["."+g+"input","."+g+"button"];if(p.length&&(p.is(q[0])||p.is(q[1]))){console.log("good.")}else{B.find(q+"").eq(0).focus()}},0)},m=e(window),B=e("
").addClass(g+"ui").addClass(g+(w?"prompt":(u?"confirm":"alert"))).css(l.ui||{}),x=e("
­
").addClass(g+"modal").css(l.modal||{}),n=e("
").addClass(g+"msg").css(l.msg||{}).html(i).appendTo(B),y=w?e("
").addClass(g+"inbox").css(l.inbox||{}).children().addClass(g+"input").css(l.input||{}).bind("keydown",function(f){if((window.event?window.event.keyCode:f.which)==9&&f.shiftKey){f.preventDefault();B.find("."+g+"button").filter(":last").focus()}}).bind("blur",F).end().appendTo(B):null,C=e("
").addClass(g+"buttons").css(l.buttons||{}).appendTo(B),r=e("").addClass(g+"button").css(l.button||{}).bind("keydown",function(G){if(this!=document.activeElement){return}G.stopPropagation();var q=window.event?window.event.keyCode:G.which,p=e(this),t,f=G.shiftKey;switch(q){case 9:case 39:G.preventDefault();if(t=p[q==9&&f?"prev":"next"]("button"),t.length){t.focus()}else{if(q==9){if(t=B.find("."+g+"input"),t.length){t.select()}else{if(t=p[f?"next":"prev"]("button"),t.length){t.focus()}}}}break;case 37:G.preventDefault();if(t=p.prev("button"),t.length){t.focus()}break;case 27:G.preventDefault();B.find("button."+(w||u?D:j)).trigger("click");break}}).bind("blur",F),v=[r.clone(o).addClass(j).text(u?h.yes:h.ok).appendTo(C),w||u?r.clone(o).addClass(D).text(h.no).appendTo(C):null];B.add(x).bind("keydown",function(){});if(w){h.confirm=o;if(typeof(h.input)=="string"){y.children().val(h.input)}}m.bind(a,k[a]=function(){if(!k.firstWidth){k.firstUnder=true;k.firstWidth=B.outerWidth();console.log(k.firstWidth)}var f=m.width()-20<=k.firstWidth;if(l.ui){if(f&&!k.isOver){console.log("OVER");k.isOver=true;B.css({width:"auto",left:"10px",right:"10px","margin-left":"0","margin-top":~~(-B.outerHeight()*0.32)+"px"})}else{if((!f&&k.isOver)||k.firstUnder){console.log("UNDER");k.firstUnder=false;k.isOver=false;B.css({width:k.firstWidth+"px",left:l.ui.left||"auto",right:l.ui.right||"auto","margin-left":~~(-k.firstWidth*0.5)+"px","margin-top":~~(-B.outerHeight()*0.32)+"px"})}}}});k.before=function(p){p.stopPropagation();var f=window.event?window.event.keyCode:p.which;if(p.target.type=="text"&&!f){B.find("button."+(w||u?D:j)).trigger("click");return A}switch(f){case 13:B.find("button."+j).trigger("click");return A;case 27:B.find("button."+(w||u?D:j)).trigger("click");return A}};var E="."+g+"ui,."+g+"modal",z=e(document.documentElement?document.documentElement:document.body).append(x).append(B).bind(b,k.before);k.after=function(f,p){for(var q=0,t=f.className.split(" ");q