Ajax pop-up window plugin

Source: Internet
Author: User

//identification of each pop-up windowvarX =0;varIdzt =New Array();varWindow =function(config) {//ID is not duplicatedIDZT[X] = "Zhuti" +X;//Popup ID//initialization, receive parametersThis.config ={width: Config.width | | 300,//widthHeight:config.height | | 200,//Heightbuttons:config.buttons | | ‘‘,//Default No buttonTitle:config.title | | ' Title ',//titlecontent:config.content | | ' Content ',//contentIsMask:config.isMask = =false?false: Config.ismask | |true,//whether or not to maskIsDrag:config.isDrag = =false?false: Config.isdrag | |true,//whether to move        }; //loading pop-up windows    varW = ($ (window). Width ()-this.config.width)/2; varH = ($ (window). Height ()-this.config.height)/2; varNR = "<div class= ' Zhuti ' id= '" +idzt[x]+ "' bs= '" +x+ "' style= ' width:" +this.config.width+ "PX; Height: "+this.config.height+" PX; Background-color:white; Left: "+w+" PX; Top: "+h+" PX; ' ></div> "; $("Body").append (NR); //load pop-up window title    varContent = "<div id= ' title" +x+ "' class= ' title ' bs= '" +x+ "' >" +this.config.title+ "<div id= ' Close" +x+ "' class= ' Close ' bs= ' "+x+" >x</div></div> "; //loading pop-up window content    varNrh = this.config.height-75; Content= content+ "<div id= ' content" +x+ "' bs= '" +x+ "' class= ' content ' style= ' width:100%; Height: "+nrh+" PX; ' > "+this.config.content+" </div> "; //Load ButtonContent = content+ "<div id= ' btnx" +x+ "' bs= '" +x+ "' class= ' btnx ' >" +this.config.buttons+ "</div>"; //add titles, content, and buttons to the window$ (' # ' +idzt[x]).HTML (content); //creating a matte layer    if(This.config.ismask) {        varZZ = "<div id= ' zz ' ></div>"; $("Body").append (ZZ); $("#zz"). CSS (' Display ', ' block '); }        //maximum minimum limit to avoid moving to the outside of the page    varMaxX = $ (window). Width ()-this.config.width; varMaxy = $ (window). Height ()-this.config.height; varMinX = 0,Miny= 0; //window Movement    if(This.config.Isdrag) {        //Mouse Move pop-up window$ (". Title"). Bind ("MouseDown",function(e) {varn = This.getattribute ("BS");//take the logo//Make the selected to the top$ (". Zhuti"). CSS ("Z-index", 3); $(' # ' +idzt[n]). CSS ("Z-index", 4); //take the initial coordinates                varEndX = 0,//x-coordinate after movingEndY = 0,//y-coordinate after moveStartX = parseint ($ (' # ' +idzt[n]). CSS ("left"),//initial x-coordinate of the popup layerStarty = parseint ($ (' # ' +idzt[n]). CSS ("top"),//the initial y-coordinate of the popup layerDownx = E.clientx,//when the mouse is pressed, the x-coordinate of the mouseDownY = E.clienty;//Mouse down, y coordinates//mouse movement Event$ ("body"). Bind ("MouseMove",function(es) {endx= Es.clientx-downx + StartX;//x-coordinate movementEndY = Es.clienty-downy + starty;//y-coordinate movement//maximum minimum limit                    if(EndX >MaxX) {EndX=MaxX; } Else if(EndX < 0) {EndX= 0; }                    if(EndY >Maxy) {EndY=Maxy; } Else if(EndY < 0) {EndY= 0; }                                        $(' # ' +idzt[n]). CSS ("Top", endy+ "px"); $(' # ' +idzt[n]). CSS ("left", endx+ "px"); Window. getselection? Window.getselection (). Removeallranges ():d ocument.selection.Empty();//Uncheck Text                                        });        }); //mouse button lift, release move event$ ("body"). Bind ("MouseUp",function(){                            $("Body"). Unbind ("MouseMove"));    }); }        //Close Window$ (". Close"). Click (function(){                    varm = This.getattribute ("BS");//Find Identification$ (' # ' +idzt[m]). Remove ();//removing pop -up windows$ (' #zz '). Remove ();//Remove Matte}) x++;//Identity Increase        }

Ajax pop-up window plugin

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.