jquery analog alert Phone, PC, tablet 3 in all

Source: Internet
Author: User

$.kw = {title: "System Information",//default title can be modified speed:400,//default speed can be modified buttonname: "OK",//OK button default name to modify content: "Content",//Remove cover Layer Del:function () {$ ("#alert-layer"). Remove ();},//Response ESC keyboard to exit Esc:function () {$ (document). KeyUp (Fu Nction (Event) {if (Event.which = =) {$.kw.del ();}}); },//content display function alert:function (scontent, Stitle, CallBack) {var title = Stitle | | this.title; var layer = "<DivID= ' Alert-layer '><DivID= ' Alert-container '><Divclass= ' Alert-top '></Div><Divclass= ' Alert-box '><DivID= ' Alert-title '>"+ title +"<DivID= ' Alert-close 'title= ' Close '></Div></Div><DivID= ' alert-content '>"+ Scontent +"</Div><Divclass= ' Alert-button '><ButtonID= ' Alert-button '>"+ This.buttonname +"</Button></Div></Div><Divclass= ' Alert-bottom '></Div></Div></Div>"; $ (layer). FadeIn (This.speed). AppendTo ("body"); This.setting (); $ ("#alert-button"). focus (); $ ("#alert-close"). Bind ("click", This.del); Remove the layer $ ("#alert-button"). Bind ("click", Function () {if (callBack) {callBack ();} $.kw.del ();}); removing layer this.esc (); },//Box drag function Move:function () {$ ("#alert-title"). MouseDown (function (event) {var L = parseint ($ ("#alert-container"). CSS ( "Left"), T = parseint ($ ("#alert-container"). CSS ("top")); x = event.pagex-l; y = event.pagey-t; $ ("body"). Bind ("MouseMove", function (event) {$ ("#alert-container"). CSS ({"Left": (Event.pagex-x)}); $ ("#alert-conta Iner "). CSS ({" Top ": (EVENT.PAGEY-Y)}); $ ("#alert-container"). FadeTo (0,0.9)}); }); $ ("Body"). MouseUp (function () {$ ("body"). Unbind ("MouseMove");//$ ("#alert-container"). FadeTo (0,1)}); },//Set the background layer with the inside position setting:function () {var BCW = $ (window). Width (), BCH = $ (window). Height (), BSH = $ (document). Height (), AW = $ ("#alert-container"). Width ()/2, ah = $ ("#alert-container"). Height ()/2; $ ("#alert-layer "). CSS (" height ", BSH); $ ("#alert-container"). CSS ({"Top": BCH/2-Ah, "left": BCW/2-aw}); }//$.kw End}; $ (window). Resize (function () {if ($ ("#alert-layer")) {$ ("#alert-layer"). CSS ("height", 0); var strheight= $ (document). Height (); $ ("#alert-layer"). CSS ("height", strheight); var aw = $ ("#alert-container"). Width ()/2, ah = $ ("#alert-container"). Height ()/2; $ ("#alert-container"). CSS ({"Top": $ (window). Height ()/2-ah, "left": $ (window). Width ()/2-aw}); }}); /* Mock alert style */#alert-layer Button:focus {border:1px solid #AAA!important; background: #789!important; color:white; outl Ine:none} #alert-layer {position:absolute; left:0; top:0; width:100%; height:100%; color: #333; line-height:1; z-in dex:10000; Background:rgba (0,0,0,0.2)} #alert-layer #alert-container {border-radius:3px;-moz-border-radius:3px;- webkit-border-radius:3px; padding:10px; width:30%; position:fixed; _position:absolute;} #alert-layer. alert-top {background: #F1F1F1; height:10px;border-radius:3px 3px 0 0; -moz-border-radius:3px 3px 0 0; -webkit-border-radius:3px 3px 0 0;} #alert-layer alert-bottom {background: #F1F1F1; height:10px; border-radius:0 0 3px 3px-moz-border-radius:0 0 3px 3p X -webkit-border-radius:0 0 3px 3px;} #alert-layer #alert-title {font-size:. 875em; height:30px; line-height:25px; padding:0 10px; position:relative; font- Weight:bold; Background: #F1F1F1; border-bottom:1px solid #B9B9B9;} #alert-layer #alert-close {background:url (/images/icon_close.png) no-repeat Center Center; width:25px; height:25px; po Sition:absolute; Cursor:pointer; right:2px; top:0px;} #alert-layer. Alert-button {padding:5px 10px; text-align:right; border-top:1px solid #B9B9B9; background: #F1F1F1;} #alert-layer #alert-content {padding:10px 15px; font-size:.725em;}. Alert-box {background: #fff;} #alert-layer button {padding:5px; border:1px solid #CCC; Margin:auto 5px; border-radius:2px; min-width:60px; font-si Ze:.725em;} #alert-layer H1, #aleRt-layer H2, #alert-layer H3, #alert-layer h4 {margin:10px auto; Font-size:1em} according to http://kingwell-leng.iteye.com/blog/ 1592881 a little bit of processing. The main credit is the original author. Put the code on it. This section of the code to the phone, PC Test no problem can be directly copied to use. I used it when I was doing a responsive website. The alert on the PC station is too ugly. So use jquery to simulate one.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.