Skip to content

Instantly share code, notes, and snippets.

@seungjin
Created November 19, 2010 18:27
Show Gist options
  • Save seungjin/706907 to your computer and use it in GitHub Desktop.
Save seungjin/706907 to your computer and use it in GitHub Desktop.
notice or popup. server can push msg into function. so browser can get notice or push msg from server
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>MessageBox</title>
<link rel="stylesheet" type="text/css" href="ext-all.css" />
<script type="text/javascript" src="ext-base.js"></script>
<script type="text/javascript" src="ext-all.js"></script>
<style type="text/css">
#msg-div {
position:absolute;
left:35%;
top:10px;
width:250px;
z-index: 20000;
}
</style>
<script type="text/javascript">
notice = function(){
var msgCt;
function createBox(t, s){
return ['<div class="msg">',
'<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>', t, '</h3>', s, '</div></div></div>',
'<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
'</div>'].join('');
}
return {
msg : function(title, format){
if(!msgCt){
msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
}
msgCt.alignTo(document, 't-t');
var s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));
var m = Ext.DomHelper.append(msgCt, {html:createBox(title, s)}, true);
m.slideIn('t').pause(1).ghost("t", {remove:true});
}
};
}();
</script>
</head>
<body>
</body>
</html>
@seungjin
Copy link
Author

actual use in my application.
check this youtube: http://www.youtube.com/watch?v=FGKR_g7Goqw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment