EasyUI Forum
May 04, 2024, 02:42:23 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Messager password prompt and login screen  (Read 6925 times)
chrwei
Full Member
***
Posts: 219


View Profile Email
« on: December 16, 2014, 08:54:18 AM »

This code adds a password prompt and a simple login form to the Messager.  the Password works just like the Prompt method just using a masked input instead of a normal one.  the login method is also similar, but the callback takes 2 parameters instead of 1.
Code:
//add a password prompt to the messenger
(function($){
function createWindow(title,content,buttons){
var win=$("<div class=\"messager-body\"></div>").appendTo("body");
win.append(content);
if(buttons){
var tb=$("<div class=\"messager-button\"></div>").appendTo(win);
for(var btn in buttons){
$("<a></a>").attr("href","javascript:void(0)").text(btn).css("margin-left",10).bind("click",eval(buttons[btn])).appendTo(tb).linkbutton();
}
}
win.window({
title:title,
noheader:(title?false:true),
width:300,
height:"auto",
modal:true,
collapsible:false,
minimizable:false,
maximizable:false,
resizable:false,
onClose:function(){
setTimeout(function(){
win.window("destroy");
},100);
}
});
win.window("window").addClass("messager-window");
win.children("div.messager-button").children("a:first").focus();
return win;
};
$.extend($.messager, {
password:function(title,msg,fn){
var content="<div class=\"messager-icon messager-question\"></div>"+"<div>"+msg+"</div>"+"<br/>"+"<div style=\"clear:both;\"/>"+"<div><input class=\"messager-input\" type=\"password\"/></div>";
var buttons={};
buttons[$.messager.defaults.ok]=function(){
win.window("close");
if(fn){
fn($(".messager-input",win).val());
return false;
}
};
buttons[$.messager.defaults.cancel]=function(){
win.window("close");
if(fn){
fn();
return false;
}
};
var win=createWindow(title,content,buttons);
win.find("input.messager-input").focus();
return win;
},
login:function(title,msg,fn){
var content="<div class=\"messager-icon messager-question\"></div>"+"<div>"+msg+"</div>"+"<br/>"+"<div style=\"clear:both;\"/>"
+"<div class=\"righttext\">Login ID: <input class=\"messager-id \" type=\"text\"/></div>"
+"<div class=\"righttext\">Password: <input class=\"messager-pass\" type=\"password\"/></div>";
var buttons={};
buttons[$.messager.defaults.ok]=function(){
win.window("close");
if(fn){
fn($(".messager-id",win).val(), $(".messager-pass",win).val());
return false;
}
};
buttons[$.messager.defaults.cancel]=function(){
win.window("close");
if(fn){
fn();
return false;
}
};
var win=createWindow(title,content,buttons);
win.find("input.messager-id").focus();
return win;
}
});
})(jQuery);
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!