//A dhtml replacemnt of the basic JS confirmation box (which is fugly) //Assumptions: // -caller of Confirm has a click() function // -confirm will be show above anything with a zindex of less than 13,000 // // /****************************USAGE**************************************** // btn.OnClientClick = "return SConfirm.Confirm( this, \"" + msg + "\" );"; or OnClientClick="return SConfirm.Confirm(this,'Are you sure?')" // *************************************************************************/ var SConfirm = { OverlayDiv: "
", HorizonDiv: "
", ContentDiv: "
Confirmation
", MessageDiv: "
", ButtonsDiv: "
    
", Done: false, Confirmed: false, ConfirmInterval: 0, CheckIntervalLength: 100, PostBackTarget: '', SecondPass: false, OverlayCSS: { 'position': 'absolute', 'top': '0px', 'left': '0px', 'width': '100%', 'height': '100%', 'background-color': 'white', 'opacity': '0.80', 'filter': 'alpha(opacity=80)', '-moz-opacity': '.80', 'z-index': '13000' }, ContainerCSS: { 'width': '600px', 'left': '50%', 'visibility': 'visible', 'position': 'absolute', 'margin-left': '-300px', 'font': '10pt Tahoma', 'text-align': 'center', 'color': 'black', 'border': 'solid 1px #0f2d6d' }, HeaderCSS: { 'background-color': '#84DC82', 'height': '20px', 'top': '-62px', 'border-bottom': 'none', 'background': 'url(img.axd?gb=grouphdr) top left repeat-x' }, ContentCSS: { 'background-color': '#edf3ff', 'top': '-42px', 'height': '85px' }, HorizonCSS: { 'background-color': 'transparent', 'text-align': 'center', 'position': 'absolute', 'top': '50%', 'left': '0px', 'width': '100%', 'height': '1px', 'overflow': 'visible', 'visibility': 'visible', 'display': 'block', 'z-index': '13001' }, MessageCSS: { 'text-align': 'center', 'width': '100%', 'height': '40px', 'padding-top': '10px' }, ButtonDivCSS: { 'text-align': 'center', 'width': '100%', 'height': '35px' }, ButtonCSS: { 'background-color': 'transparent', 'color': 'black', 'margin-bottom': '5px', 'width': '100px', 'height': '30px', 'border': 'none', 'background-image': 'url(img.axd?btn=sshort)' }, ImageCSS: { 'float': 'left', 'margin-left': '5px' }, Confirm: function(target, msg) { if (SConfirm.SecondPass) { return SConfirm.Confirmed; } $("body").prepend(SConfirm.OverlayDiv); $("body").prepend(SConfirm.HorizonDiv); $("#SConfirm_Horizon").append(SConfirm.ContentDiv); $("#SConfirm_Content").append(SConfirm.MessageDiv); $("#SConfirm_Content").append(SConfirm.ButtonsDiv); $("#SConfirm_Msg").text(msg); SConfirm.ApplyCSS(); SConfirm.ConfirmInterval = setInterval(function() { SConfirm.CheckIfDone(); }, SConfirm.CheckIntervalLength); SConfirm.PostBackTarget = target; $("#SConfirm_OkButton").focus(); return false; }, ApplyCSS: function() { $("#SConfirm_Overlay").css(SConfirm.OverlayCSS); $("#SConfirm_Horizon").css(SConfirm.HorizonCSS); $("#SConfirm_Content").css(SConfirm.ContentCSS); $("#SConfirm_Message").css(SConfirm.MessageCSS); $("#SConfirm_Buttons").css(SConfirm.ButtonDivCSS); $(".SConfirm_Container").css(SConfirm.ContainerCSS); $("#SConfirm_Header").css(SConfirm.HeaderCSS); $(".SConfirm_Button").css(SConfirm.ButtonCSS); $(".SConfirm_Image").css(SConfirm.ImageCSS); $(".SConfirm_Button").hover( function() { $(this).css('background-image', 'url(img.axd?btn=sshort_hover)'); }, function() { $(this).css('background-image', 'url(img.axd?btn=sshort)'); } ); }, SetConfirm: function() { SConfirm.Done = true; SConfirm.Confirmed = true; }, Cancel: function() { SConfirm.Done = true; SConfirm.Confirmed = false; }, CheckIfDone: function() { if (SConfirm.Done) { clearInterval(SConfirm.ConfirmInterval); SConfirm.Unload(); } }, Unload: function() { if (SConfirm.Confirmed) { SConfirm.SecondPass = true; SConfirm.PostBackTarget.click(); SConfirm.SecondPass = false; } SConfirm.Done = false; SConfirm.Confirmed = false; $("#SConfirm_Overlay").remove(); $("#SConfirm_Horizon").remove(); return false; } };