Modified confirm box…

This commit is contained in:
Harry Bomrah 2012-04-19 15:36:03 +08:00
parent 4bad25e682
commit 3c5b7a5de3
2 changed files with 31 additions and 27 deletions

View File

@ -619,25 +619,29 @@ var orbitDesktop = function(dom){
}); });
$("a#theme_submit").click(function(){ $("a#theme_submit").click(function(){
o.confirm("Are you sure that you want to set this custom theme?",["Yes","No"],3,function(reply){ o.confirm({
message : "Are you sure that you want to save custom theme?",
highlighted : 1,
buttons : ["Yes","No"]
},function(reply){
if(reply){ if(reply){
var colors = new Array; var colors = new Array;
$("#color_input input").each(function(){ $("#color_input input").each(function(){
colors[$(this).attr("for")] = $(this).val(); colors[$(this).attr("for")] = $(this).val();
}) })
var dhtml ="<style> .thmc1 { background: "+colors['thmc1']+"; }.thmc2 { background: "+colors['thmc2']+"; }.thmc3 { background: #FFFFFF; }.thmc4 { background: "+colors['thmc4']+"; }.thmtxt { color: "+colors['thmtxt']+"; }.thmtxth { color: "+colors['thmtxth']+"; }.g_sep { border-color: "+colors['g_sep']+";} body{background-color: "+colors['background']+"} </style>"; var dhtml ="<style> .thmc1 { background: "+colors['thmc1']+"; }.thmc2 { background: "+colors['thmc2']+"; }.thmc3 { background: #FFFFFF; }.thmc4 { background: "+colors['thmc4']+"; }.thmtxt { color: "+colors['thmtxt']+"; }.thmtxth { color: "+colors['thmtxth']+"; }.g_sep { border-color: "+colors['g_sep']+";} body{background-color: "+colors['background']+"} </style>";
$("head").find("#dyn_css").remove(); $("head").find("#dyn_css").remove();
$("head").append(dhtml); $("head").append(dhtml);
$.post("/desktop/save_desktop_settings",{"save":"customtheme","desktopid":o.desktopId,"theme":dhtml},function(result,status){ $.post("/desktop/save_desktop_settings",{"save":"customtheme","desktopid":o.desktopId,"theme":dhtml},function(result,status){
if(status=="success"){ if(status=="success"){
if(result[0].success=="true") if(result[0].success=="true")
o.notify("Custom theme saved!!","success",2); o.notify("Custom theme saved!!","success",2);
else else
o.notify("Custom theme saving failed!!","imp",2); o.notify("Custom theme saving failed!!","imp",2);
}else{ }else{
o.notify("Connection problem!!","alert",2); o.notify("Connection problem!!","alert",2);
} }
}) })
} }
}) })
}); });

View File

@ -54,24 +54,24 @@ var orbitDesktopAPI = function(){
$("img#thmbackground").attr("src",o.wallpaperPath+wallpaper); $("img#thmbackground").attr("src",o.wallpaperPath+wallpaper);
o.saveWallpaper(wallpaper); o.saveWallpaper(wallpaper);
}; };
this.confirm = function(msg,btnvalues,highlighted,callbackfn){ this.confirm = function(settings,callbackfn){
if(!btnvalues)btnvalues=["Ok","Cancel"]; if(!settings.buttons)settings.buttons=["Ok","Cancel"];
if(highlighted!=1 || highlighted!=2)highlighted=2; if(settings.highlighted!=1 || settings.highlighted!=2)settings.highlighted=2;
if(!msg)msg = "Are you sure?" if(!settings.message)settings.message = "Are you sure?"
var $confirm = $("#orbitdiag"); var $confirm = $("#orbitdiag");
$confirm.find(".diag_action a").addClass("admbg admtxt"); $confirm.find(".diag_action a").addClass("admbg admtxt");
$confirm.find(".diag_message").text(msg); $confirm.find(".diag_message").text(settings.message);
if(highlighted == 1) if(settings.highlighted == 1)
$confirm.find("#diag_confirm").removeClass("admbg admtxt").addClass("thmc1 thmtxt"); $confirm.find("#diag_confirm").removeClass("admbg admtxt").addClass("thmc1 thmtxt");
if(highlighted == 2) if(settings.highlighted == 2)
$confirm.find("#diag_cancel").removeClass("admbg admtxt").addClass("thmc1 thmtxt"); $confirm.find("#diag_cancel").removeClass("admbg admtxt").addClass("thmc1 thmtxt");
$confirm.find("#diag_confirm").text(btnvalues[0]).one("click",function(){ $confirm.find("#diag_confirm").text(settings.buttons[0]).one("click",function(){
$confirm.hide(); $confirm.hide();
$confirm.find(".diag_action a").unbind(); $confirm.find(".diag_action a").unbind();
if(typeof callbackfn=="function") if(typeof callbackfn=="function")
callbackfn.call(this,true); callbackfn.call(this,true);
}); });
$confirm.find("#diag_cancel").text(btnvalues[1]).one("click",function(){ $confirm.find("#diag_cancel").text(settings.buttons[1]).one("click",function(){
$confirm.hide(); $confirm.hide();
$confirm.find(".diag_action a").unbind(); $confirm.find(".diag_action a").unbind();
if(typeof callbackfn=="function") if(typeof callbackfn=="function")