jquery Imitation Renren pop-up layer effect

Source: Internet
Author: User
Tags extend

The main function of this section is to modify the default style of the pop-up layer
----------================================== Gorgeous split line ================================---
1//blockui Extend function


2//below three methods to add a Onlick event call to a point button or text when a page is called


3//confirm Delete or any other events


4//1, this method pops up a layer with confirmation and cancellation of two buttons, click Confirm Trigger Clickevent () method


5 $.confirm = function (settings) {


6 var htmldom = $ ("<div id=" Displaypanle "style=" display:none;border:1px solid #005eac "></div>");


7 Htmldom.css Tutorial ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


8 var msg = $ ("<table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "><tr><td width=" 8 0% "style=" text-align:left;padding-left:20px; " > "+ settings.msg +" </td><td id= "CONFIRMTD" ><input type= "button" class= "Standard-button" value= "confirm" Id= "ConfirmButton"/></td><td style= "padding-left:10px" ><input type= "button" id= "Close" class= "  Standard-button "value=" cancels "onclick=" Web Effects: Closeblockuinofresh (); " Style= "margin-right:20px;" /></td></tr></table> ");


9 Htmldom.append (msg);


Msg.find (' #confirmbutton '). Click (settings.clickevent);


One $.blockui ({


Message:htmldom,


[CSS: {width: "650px", Height: "70px", "Background-color": "#fff"}


14});


Pressescout ();


16}


17
This screenshot is the result of the Confrim () method above. There is a confirmation button, and then there is a Cancel button.
The call is also very simple
1 $ (function () {
2 Var settings={
3 msg: "Confirm deletion of selected records?",//messages to be displayed on the pop-up layer
4 Clickevent:function () {
5//do Something here is the binding method for the OK button
6}}
7 $.confirm (settings); The method is called here and then the defined Settings object above is passed as a parameter to the
8});
The above method click Cancel or Confirm button after the page is not refreshed, but sometimes after the operation needs to refresh the page that use the following method, the call method with the above consistent, but the method name changed.
1 $.confirmwithrefresh = function (settings) {


2 var htmldom = $ ("<div id=" Displaypanle "style=" display:none;border:1px solid #005eac "></div>");


3 Htmldom.css ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


4 var msg = $ ("<table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "><tr><td width=" 8 0% "style=" text-align:left;padding-left:20px; " > "+ settings.msg +" </td><td id= "CONFIRMTD" ><input type= "button" class= "Standard-button" value= "confirm" Id= "ConfirmButton"/></td><td style= "padding-left:10px" ><input type= "button" id= "Close" class= " Standard-button "id=" CancelButton "value=" to cancel "onclick=" Javascript:closeblockuinofresh (); "Style=" margin-right:20px ;" /></td></tr></table> ");


5 htmldom.append (msg);


6 Msg.find (' #confirmbutton '). Click (settings.clickevent);


7 $.blockui ({


8 Message:htmldom,


9 css: {width: "650px", Height: "70px", "Background-color": "#fff"}


10});


One pressescout ();


12}


13//For some pages to close the layer does not need to refresh the page, so use a different way to close


$.confirmnorefresh = function (settings) {


var htmldom = $ ("<div id=" Displaypanle "style=" display:none;border:1px solid #005eac "></div>");


Htmldom.css ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


var msg = $ ("<table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "><tr><td width=" 80% "style=" text-align:left;padding-left:20px; " > "+ settings.msg +" </td><td id= "CONFIRMTD" ><input type= "button" class= "Standard-button" value= "confirm" Id= "ConfirmButton"/></td><td style= "padding-left:10px" ><input type= "button" id= "Close" class= " Standard-button "id=" CancelButton "value=" to cancel "onclick=" Javascript:closeblockuinofresh (); "Style=" margin-right:20px ;" /></td></tr></table> ");


Htmldom.append (msg);


Msg.find (' #confirmbutton '). Click (settings.clickevent);


$.blockui ({


Message:htmldom,


CSS: {width: "650px", Height: "70px", "Background-color": "#fff"}


23});


Pressescout ();
}

The above method only prompts the function, displays a message. It's much nicer than alert.
Call method
$.prompt ({msg: "delete Successful"});
The following method is to refresh the page
1 $.promptwithrefresh = function (settings) {


2 var htmldom = $ ("<div id=" Displaypanle "style=" display:none;border:1px solid #005eac "></div>");


3 Htmldom.css ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


4 Htmldom.append ("<table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "><TR><TD" Width= "80%" style= "text-align:left;padding-left:20px;" > "+ settings.msg +" </td><td><input type= "button" id= "Confirm" value= "confirm" class= "Standard-button" Onclick= "Javascript:closeblockui ();"/></td></tr></table> ");


5 $.blockui ({


6 Message:htmldom,


7 css: {width: "550px", Height: "70px", "Background-color": "#fff", "Z-index": Settings.basez}


8});


9 Pressescout ();


10}


One $.promptwithrefreshoverride = function (settings) {


var htmldom = $ ("<div id=" Displaypanle "style=" display:none;border:1px solid #005eac "></div>");


Htmldom.css ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


var msg = $ ("<table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "><tr><td width=" 80% "style=" text-align:left;padding-left:20px; " > "+ settings.msg +" </td><td><input type= "button" id= "Confirm" value= "confirm" class= "Standard-button"/ ></td></tr></table> ");


Htmldom.append (msg);


Msg.find (' #confirm '). Click (settings.clickevent);


$.blockui ({


Message:htmldom,


CSS: {width: "550px", Height: "70px", "Background-color": "#fff", "Z-index": Settings.basez}


20});


Pressescout ();


22}


23//Pop-up prompt box no refresh


$.promptnorefresh = function (settings) {


var htmldom = $ ("<div id=" Displaypanle "style=" display:none;border:1px solid #005eac "></div>");


Htmldom.css ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


Htmldom.append ("<table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "><TR><TD" Width= "80%" style= "text-align:left;padding-left:20px;" > "+ settings.msg +" </td><td><input type= "button" id= "Confirm" value= "confirm" class= "Standard-button" Onclick= "Javascript:closeblockuinofresh ();"/></td></tr></table> ");


$.blockui ({


Message:htmldom,


CSS: {width: "550px", Height: "70px", "Background-color": "#fff", "Z-index": Settings.basez}


31});


Pressescout ();
33}
The method pops up the layer that is added or modified, and the call needs to pass a DOM and the title of the layer. Methods are Formtitle (), appendtable (), and the method has two buttons to confirm and cancel, confirming that the button event needs to be overridden in page JS is clickevent ()
1 $.msgbox = function (settings) {


2 var temps tutorial creen = (document.body.clientwidth-settings.width.replace ("px", ""))/2;


3 var htmldom = $ ("<div id=" Displaypanle "style=" display:none;border:1px solid #005eac "></div>");


 4     var msg = $ ("<table cellpadding=" 0 "  cellspacing= "0"  border= "0"  class= "inndertable"  style= "vertical-align:top;width:100%" ><tr ><td width= "80%"  style= "text-align:left;font-size:14px;padding-left:15px;padding-top:10px; Padding-bottom:10px;background-color: #3777bc; Vertical-align:middle;color: #fff; Font-weight:bold ">"  +  settings.title +  "</td><td id=" CONFIRMTD " style=" text-align:right; Padding-right:5px;padding-top:10px;padding-bottom:10px;background-color: #3777bc; Vertical-align:middle;cursor: Pointer;color: #fff; font-weight:bold " onclick=" Javascript:closeblockuinofresh (); > Close </td></tr><tr><td colspan= "2"  style= "text-align:center;width:100%" > "  + settings.dom +  "</td></tr><tr><td colspan=" 2 " style=" text-align:right;padding-right:10px;padding-bottom:10px; " ><iNput type= "button"  class= "Standard-button"  id= "ConfirmButton"  value= "Confirmation"/>   <input type= "button"  id= "Close" class= "Standard-button"  value= "Cancel"  onclick= " Javascript:closeblockuinofresh (); " /></td></tr></table> ");


5 htmldom.append (msg);


6 msg.parent (). Find (' #confirmbutton '). Click (settings.clickevent);


7 $.blockui ({


8 Message:htmldom,


9 css: {width:settings.width, "Background-color": "#fff", "Z-index": Settings.basez, Left:tempscreen}


10});


One pressescout ();


12}
This method is more powerful, you can pass a DOM in.
Looks like everyone's network pop-up layer bar, the style is really imitate the renren.
The calling method also defines an object first. Assign a value to a property. What do you see in the code above? Settings.xxxx This xxxxx is the attribute. can also be added according to their own needs, or reduce.
var settings={
Title: "Add User",//title
Width: "600px",
Clickevent:function () {
Do something
}
}
$.msgbox (settings);
1//The method pops up the layer that is added or modified, and the call needs to pass a DOM as well as a layer header. Methods are Formtitle (), appendtable (), and the method has two buttons to confirm and cancel, confirming that the button event needs to be overridden in page JS is clickevent ()


2 $.msgboxwithrefresh = function (settings) {


3 var Tempscreen = (Document.body.clientwidth-settings.width.replace ("px", ""))/2;


4 var htmldom = $ ("<div id=" Displaypanle "style=" display:none;border:1px solid #005eac "></div>");


 5     var msg = $ ("<table cellpadding=" 0 "  cellspacing= "0"  border= "0"  class= "inndertable"  style= "vertical-align:top;width:100%" ><tr ><td width= "80%"  style= "text-align:left;font-size:14px;padding-left:15px;padding-top:10px; Padding-bottom:10px;background-color: #3777bc; Vertical-align:middle;color: #fff; Font-weight:bold ">"  +  settings.title +  "</td><td id=" CONFIRMTD " style=" text-align:right; Padding-right:5px;padding-top:10px;padding-bottom:10px;background-color: #3777bc; Vertical-align:middle;cursor: Pointer;color: #fff; font-weight:bold " onclick=" Javascript:closeblockuinofresh (); > Close </td></tr><tr><td colspan= "2"  style= "text-align:center;width:100%" > "  + settings.dom +  "</td></tr><tr><td colspan=" 2 " style=" text-align:right;padding-right:10px;padding-bottom:10px; " ><iNput type= "button"  class= "Standard-button"  id= "ConfirmButton"  value= "Confirmation"/>   <input type= "button"  id= "Close" class= "Standard-button"  value= "Cancel"  onclick= " Javascript:closeblockuinofresh (); " /></td></tr></table> ");


6 htmldom.append (msg);


7 msg.parent (). Find (' #confirmbutton '). Click (settings.clickevent);


8 $.blockui ({


9 Message:htmldom,


CSS: {width:settings.width, "Background-color": "#fff", "Z-index": Settings.basez, Left:tempscreen}


11});


Pressescout ();


13}


14//Close Blcokui, this method is the default method, do not need to change.


function Closeblockui () {


$.unblockui ();


Location.reload ();


return false;


19}


20//Close Blockui but not refresh page


function Closeblockuinofresh () {


$.unblockui ();


23}


function Pressescout () {


$ ("*"). KeyPress (function (event) {


var Jianzhi = Event.keycode;


var Input_keydown = $ (this);


Switch (Jianzhi) {


Case 27:


Closeblockuinofresh ();


to break;


32}


33});


34}


35

Save As JS file

; (function ($) {

if (/1. ( 0|1|2). (0|1|2)/.test ($.fn.jquery) | | /^1.1/.test ($.fn.jquery)) {
Alert (' Blockui requires jquery v1.2.3 or later! You are using V ' + $.fn.jquery);
Return
}

$.fn._fadein = $.fn.fadein;

var noop = function () {};

This bit are to ensure we don ' t call SetExpression when we shouldn ' t (with extra muscle to handle
Retarded useragent strings on Vista)
var mode = Document.documentmode | | 0;
var setexpr = $.browser.msie && ($.browser.version < 8 &&!mode) | | Mode < 8);
var ie6 = $.browser.msie &&/msie 6.0/.test (navigator.useragent) &&!mode;

Global $ methods for blocking/unblocking the entire page
$.blockui = function (opts) {Install (window, opts); Open method
$.unblockui = function (opts) {Remove (window, opts); Close method

Convenience method for quick growl-like notifications (Http://www.google.com/search?q=growl)


$.growlui = function (title, message, timeout, onclose) {


var $m = $ (' &lt;div class= ' growlui ' &gt;&lt;/div&gt; ');


if (title) $m. Append (' &lt;h1&gt; ' + title + ' &lt;/h1&gt; ');


if (message) $m. Append (' &lt;h2&gt; ' + message + ' &lt;/h2&gt; ');


if (timeout = = undefined) Timeout = 3000;


$.blockui ({


Message: $m, fadein:700, fadeout:1000, Centery:false,


Timeout:timeout, Showoverlay:false,


Onunblock:onclose,


CSS: $.blockui.defaults.growlcss


});


};

   //plugin method for blocking element content
    $.fn.block = function (opts) {         return This.unblock ({fadeout:0}). each (function () {
  & nbsp;         if ($.css (this, ' position ') = = ' static ')
                 this.style.position = ' relative ';
            if ($.browser.msie)
                 this.style.zoom = 1; Force ' haslayout '
            Install (this, opts);
       });
   };

Plugin method for unblocking element content
$.fn.unblock = function (opts) {
Return This.each (function () {
Remove (this, opts);
});
};

$.blockui.version = 2.35; 2nd generation blocking at no extra cost!

Override the Your code to change the default behavior and style
$.blockui.defaults = {//Popup layer default style
Message displayed when blocking (with NULL for no message)
Message: '

Title:null,//title string; Only used when theme = = True
Draggable:true,//Only used when theme = = True (requires Jquery-ui.js to is loaded)

Theme:false,//set to True to use with jquery UI themes

Styles for the "when blocking; If you are wish to disable


These and use a external stylesheet then do this in your code:


$.blockui.defaults.css = {};


CSS: {


padding:0,


margin:0,


Width: ' 30% ',


Top: ' 40% ',


Left: ' 35% ',


TextAlign: ' Center ',


Color: ' #000 ',


border: ' 3px solid #aaa ',


BackgroundColor: ' #fff ',


Cursor: ' Wait '


},

Minimal style set used when themes are used
THEMEDCSS: {
Width: ' 30% ',
Top: ' 40% ',
Left: ' 35% '
},

Styles for the overlay
OVERLAYCSS: {//Mask background color and transparency modification
BackgroundColor: ' #ccc ',
opacity:0.4,
Cursor: ' Wait '
},

Styles applied when using $.growlui


GROWLCSS: {


Width: ' 350px ',


Top: ' 10px ',


Left: ',


Right: ' 10px ',


border: ' None ',


padding: ' 5px ',


opacity:0.6,


Cursor: ' Default ',


Color: ' #fff ',


BackgroundColor: ' #000 ',


'-webkit-border-radius ': ' 10px ',


'-moz-border-radius ': ' 10px ',


' Border-radius ': ' 10px '


},

IE issues: ' About:blank ' fails on HTTPS and Javascript:false is s-l-o-w
(Hat tip to Jorge H. N. de Vasconcelos)
IFRAMESRC:/^https/i.test (window.location.href | | '') ? ' Javascript:false ': ' About:blank ',

Force usage of IFRAME in Non-ie browsers (handy for blocking applets)
Forceiframe:false,

Z-index for the blocking overlay
basez:999,

Set this to true to have the message automatically centered
Centerx:true,//<--only effects element blocking (page block controlled via CSS above)
Centery:true,

The Allow BODY element is stetched in IE6; This makes blocking look better
On ' short ' pages. Disable if you wish to prevent changes to the body height
Allowbodystretch:true,

Enable if you are want key and mouse events to being disabled for content this is blocked
Bindevents:true,

Be default Blockui would supress tab navigation from leaving blocking content
(if Bindevents is true)
Constraintabkey:true,

Fadein time in Millis; Set to 0 to disable Fadein in block
FADEIN:200,

Fadeout time in Millis; Set to 0 to disable fadeout on unblock
fadeout:400,

Time in Millis to wait before auto-unblocking; Set to 0 to disable Auto-unblock
timeout:0,

Disable if you don ' t want to show the overlay
Showoverlay:true,

If true, focus'll is placed in the ' the ' available input field when
Page blocking
Focusinput:true,

Suppresses the use of overlay styles on ff/linux (due to performance issues with opacity)
Applyplatformopacityrules:true,

callback method invoked when Fadein has completed and blocking message is visible
Onblock:null,

callback method invoked when unblocking has completed; The callback is
Passed the element that has been unblocked (which are the Window object for page
Blocks) and the options that were passed to the unblock call:
Onunblock (element, options)
Onunblock:null,

Don ' t ask; If you really must know:http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/ 2f6a79a77a78e493#2f6a79a77a78e493
Quirksmodeoffsethack:4,

Class name of the message block
Blockmsgclass: ' Blockmsg '
};

Private data and functions follow ...

var pageblock = null;
var pageblockels = [];

    function Install (EL, opts) {
        var full = (el = = Windo W);
        var msg = opts && opts.message!== undefined? opts.message:unde fined;
        opts = $.extend ({}, $.blockui.defaults, opts | | {});
        opts.overlaycss = $.extend ({}, $.blockui.defaults.overlaycss, Opts.overlaycss | | {});
        var css = $.extend ({}, $.blockui.defaults.css, OPTS.CSS | | {});
        var themedcss = $.extend ({}, $.blockui.defaults.themedcss, Opts.themedcss | | {});
        msg = msg = undefined opts.message:msg;

Remove the current block (if there is one)
if (full && pageblock)
Remove (window, {fadeout:0});

If a existing element is being used as blocking content then we capture


Its-in-dom (and current display style) so we can restore


It when we unblock


if (msg &amp;&amp; typeof msg!= ' string ' &amp;&amp; (Msg.parentnode | | msg.jquery)) {


var node = msg.jquery? Msg[0]: msg;


var data = {};


$ (EL). Data (' blockui.history ', data);


Data.el = node;


Data.parent = Node.parentnode;


Data.display = Node.style.display;


Data.position = node.style.position;


if (data.parent)


Data.parent.removechild (node);


}

var z = opts.basez;

Blockui uses 3 layers for blocking for simplicity they the all are on used every;
Layer1 is the IFRAME layer which are used to supress bleed through of underlying content
Layer2 is the overlay layer which has opacity and a wait cursor (by default)
Layer3 is the message content this is displayed while blocking

var lyr1 = ($.browser.msie | | opts.forceiframe)
? $ (' <iframe class= "Blockui" style= "Z-index: ' + (z++) + ';d isplay:none;border:none;margin:0;padding:0;position: absolute;width:100%;height:100%;top:0;left:0 "src=" ' + opts.iframesrc + ' "></iframe> ')
: $ (' <div class= "Blockui" style= "Display:none" ></div> ");
var lyr2 = $ (' <div class= "Blockui blockoverlay" style= "Z-index: ' + (z++) + ';d isplay:none;border:none;margin:0; padding:0;width:100%;height:100%;top:0;left:0 "></div>");

var lyr3, S;


if (Opts.theme &amp;&amp; full) {


s = ' &lt;div class= ' blockui ' + opts.blockmsgclass + ' blockpage ui-dialog ui-widget ui-corner-all ' style= ' z-index: ' + z + ';d isplay:none;position:fixed ' &gt; ' +


' &lt;div class= ' ui-widget-header ui-dialog-titlebar ui-corner-all blocktitle ' &gt; ' + (opts.title | | ' &amp;nbsp; ') + ' &lt;/div&gt; ' +


' &lt;div class= ' ui-widget-content ui-dialog-content ' &gt;&lt;/div&gt; ' +


' &lt;/div&gt; ';


}


else if (opts.theme) {


s = ' &lt;div class= ' blockui ' + opts.blockmsgclass + ' blockelement ui-dialog ui-widget ui-corner-all ' style= ' z-index: ' + z + ';d isplay:none;position:absolute ' &gt; ' +


' &lt;div class= ' ui-widget-header ui-dialog-titlebar ui-corner-all blocktitle ' &gt; ' + (opts.title | | ' &amp;nbsp; ') + ' &lt;/div&gt; ' +


' &lt;div class= ' ui-widget-content ui-dialog-content ' &gt;&lt;/div&gt; ' +


' &lt;/div&gt; ';


}


else if (full) {


s = ' &lt;div class= ' blockui ' + opts.blockmsgclass + ' blockpage ' style= ' z-index: ' + z + ';d isplay:none;position:fixed ' ;&lt;/div&gt; ';


}


else {


s = ' &lt;div class= ' blockui ' + opts.blockmsgclass + ' blockelement ' style= ' z-index: ' + z + ';d isplay:none;position:absolu TE "&gt;&lt;/div&gt;";


}


LYR3 = $ (s);

       //If we have a message, style it
         if (msg) {
            if (opts.theme) {
& nbsp;               lyr3.css (THEMEDCSS);
                Lyr3.addclass (' Ui-widget-content ');
           }
            Else
                 lyr3.css (CSS);
       }

Style The overlay
if (!opts.applyplatformopacityrules | |!) ( $.browser.mozilla &&/linux/.test (navigator.platform))
Lyr2.css (OPTS.OVERLAYCSS);
Lyr2.css (' position ', full? ' Fixed ': ' absolute ');

Make IFRAME layer transparent in IE
if ($.browser.msie | | opts.forceiframe)
Lyr1.css (' opacity ', 0.0);

       //$ ([lyr1[0],lyr2[0],lyr3[0]]). Appendto (full? ' Body ': EL);
        var layers = [Lyr1, LYR2, Lyr3], $par = full? $ (' Body '): $ (EL);
        $.each (layers, function () {
             this.appendto ($par);
       });

        if (opts.theme && opts.draggable && $.fn.draggable) {
            lyr3.draggable ({
                 handle: '. Ui-dialog-titlebar ',
                cancel: ' Li '
           });
       }

       //IE7 must use absolute positioning into quirks mode and to account for Activ Ex issues (when scrolling)
        var expr = setexpr && (!$.boxmodel | | $ ( ' object,embed ', full? Null:el). length > 0);
        if (IE6 | | expr) {
            //Give body 100% height
             if (full && opts.allowbodystretch && $.boxmodel)
                 $ (' html,body '). CSS (' height ', ' 100% ');

Fix IE6 issue when blocked element has a border width
if ((IE6 | |!$.boxmodel) &&!full) {
var t = sz (el, ' borderTopWidth '), L = Sz (el, ' borderLeftWidth ');
var fixt = t? ' (0-' + t + ') ': 0;
var FIXL = l? ' (0-' + L + ') ': 0;
}

Simulate fixed position


$.each ([Lyr1, LYR2, Lyr3], function (i, O) {


var s = o[0].style;


s.position = ' absolute ';


if (I &lt; 2) {


Full? S.setexpression (' height ', ' Math.max (Document.body.scrollheight, Document.body.offsetheight)-(jquery.boxmodel?0: ' + Opts.quirksmodeoffsethack + ') + "px")


: s.setexpression (' height ', ' this.parentnode.offsetheight + ' px ');


Full? S.setexpression (' width ', ' Jquery.boxmodel &amp;&amp; document.documentelement.clientwidth | | Document.body.clientwidth + "px")


: S.setexpression (' width ', ' this.parentnode.offsetwidth + ' px ');


if (FIXL) s.setexpression (' left ', FIXL);


if (fixt) s.setexpression (' Top ', fixt);


}


else if (opts.centery) {


if (full) s.setexpression (' Top ', ' (Document.documentelement.clientheight | | document.body.clientheight)/2-( THIS.OFFSETHEIGHT/2) + (blah = document.documentelement.scrolltop? document.documentelement.scrolltop:document.body . scrolltop) + "px");


s.margintop = 0;


}


else if (!opts.centery &amp;&amp; full) {


var top = (opts.css &amp;&amp; opts.css.top)? parseint (Opts.css.top): 0;


var expression = ' (Document.documentelement.scrolltop? document.documentelement.scrolltop:document.body.scrolltop + ' + top + ') + ' px ';


S.setexpression (' top ', expression);


}


});


}

Show the message
if (msg) {
if (opts.theme)
Lyr3.find ('. Ui-widget-content '). Append (msg);
Else
Lyr3.append (msg);
if (Msg.jquery | | msg.nodetype)
$ (msg). Show ();
}

if (($.browser.msie | | opts.forceiframe) &amp;&amp; opts.showoverlay)


Lyr1.show (); Opacity is zero


if (Opts.fadein) {


var cb = Opts.onblock? Opts.onblock:noop;


var CB1 = (Opts.showoverlay &amp;&amp;!msg)? Cb:noop;


var CB2 = msg? Cb:noop;


if (Opts.showoverlay)


Lyr2._fadein (Opts.fadein, CB1);


if (msg)


Lyr3._fadein (Opts.fadein, CB2);


}


else {


if (Opts.showoverlay)


Lyr2.show ();


if (msg)


Lyr3.show ();


if (Opts.onblock)


Opts.onblock ();


}

Bind key and mouse events
Bind (1, El, opts);

        if (full) {
             pageblock = lyr3[0];
            pageblockels = $ (': Input:enabled:visible ', Pageblock);
            if (opts.focusinput)
                 settimeout (Focus, 20);
       }
        Else
             Center (lyr3[0], Opts.centerx, opts.centery);

        if (opts.timeout) {
            //Auto-unblock
            var to = settimeout (function () {
                 full? $.unblockui (opts): $ (EL). unblock (opts);
           }, Opts.timeout);
            $ (EL). Data (' Blockui.timeout ', to);
       }
   };

   //Remove the block
    function Remove (el, opts) {
         var full = (el = = window);
        var $el = $ (EL);
        var data = $el. Data (' blockui.history ');
        var to = $el. Data (' blockui.timeout ');
        if (to) {
             cleartimeout (to);
            $el. Removedata (' blockui.timeout ');
       }
        opts = $.extend ({}, $.blockui.defaults, opts | | {});
        bind (0, El, opts);//Unbind Events

var Els;
if (full)//crazy selector to handle odd field errors in Ie6/7
Els = $ (' body '). Children (). Filter ('. Blockui '). Add (' Body > Blockui ');
Else
Els = $ ('. Blockui ', EL);

if (full)
Pageblock = Pageblockels = null;

        if (opts.fadeout) {
             els.fadeout (opts.fadeout);
            settimeout (function () {Reset (ELS, data, OPTs, EL); }, Opts.fadeout);
       }
        Else
             Reset (Els, data, opts, EL);
   };

   //move blocking element back into the DOM where it started
    function Reset (el s, data, opts, EL) {
        Els.each (function (i, O) {
   & nbsp;       //Remove via DOM calls so we don ' t lose event handlers
&NBSP;&NBSP;&N bsp;         if (this.parentnode)
                 This.parentnode.removechild (this);
       });

if (data && data.el) {
Data.el.style.display = Data.display;
Data.el.style.position = data.position;
if (data.parent)
Data.parent.appendchild (Data.el);
$ (EL). Removedata (' blockui.history ');
}

if (typeof Opts.onunblock = = ' function ')
Opts.onunblock (el, opts);
};

Bind/unbind the handler
function bind (b, El, opts) {
var full = el = = window, $el = $ (EL);

Don ' t bother unbinding if there is no to unbind
if (!b && (full &&!pageblock | |!full &&! $el. Data (' blockui.isblocked '))
Return
if (!full)
$el. Data (' blockui.isblocked ', b);

Don ' t bind events when overlay isn't in or if bindevents is False
if (!opts.bindevents | | (b &&!opts.showoverlay))
Return

Bind anchors and inputs for mouse and key events
var events = ' MouseDown mouseup keydown keypress ';
B? $ (document). Bind (events, opts, handler): $ (document). Unbind (events, Handler);

Former impl ...
var $e = $ (' a,:input ');
B? $e. Bind (events, opts, handler): $e. Unbind (events, Handler);
};

event handler to suppress Keyboard/mouse events when blocking


function Handler (e) {


Allow tab navigation (conditionally)


if (e.keycode &amp;&amp; E.keycode = 9) {


if (Pageblock &amp;&amp; e.data.constraintabkey) {


var els = pageblockels;


var fwd =!e.shiftkey &amp;&amp; E.target = = Els[els.length-1];


var back = E.shiftkey &amp;&amp; E.target = = Els[0];


if (fwd | | back) {


settimeout (function () {focus (back)}, 10);


return false;


}


}


}


var opts = E.data;


Allow events within the message content


if ($ (e.target). Parents (' div. ' + opts.blockmsgclass). length &gt; 0)


return true;

Allow events for content, not being blocked
return $ (e.target). Parents (). Children (). Filter (' Div.blockui '). length = = 0;
};

    function focus (back) {
        if (!pageblockels)
            return;
        var e = Pageblockels[back = true? pageblockels.length-1:0];
        if (e)
             E.focus ();
   };

Function Center (el, X, y) {
var p = el.parentnode, s = el.style;
var L = ((p.offsetwidth-el.offsetwidth)/2)-SZ (P, ' borderleftwidth ');
var t = ((p.offsetheight-el.offsetheight)/2)-SZ (P, ' bordertopwidth ');
if (x) S.left = l > 0? (l + ' px '): ' 0 ';
if (y) s.top = t > 0? (t + ' px '): ' 0 ';
};

function sz (EL, p) {
Return parseint ($.css (El, p)) | | 0;
};

}) (jquery);

---------------------------------------Blockui part End-----------------------------------
Change Blockui default settings
Change Blockui border
$.blockui.defaults.css.border = ' 5px solid #ccc ';
$.blockui.defaults.css.cursor = ' default ';
$.blockui.defaults.css.top = ' 20% ';
$.blockui.defaults.css.left = ' 30% ';
$.blockui.defaults.overlaycss.cursor = ' default ';

Change fadeout effact Speed
$.blockui.defaults.fadeout = 100;
$.blockui.defaults.fadein = 100;




----------================================== Gorgeous split line ================================---


Blockui Extend function


The following three methods add Onlick event calls to a point button or text when a page is called


Confirm Delete or any other events


1, the method pops up a layer with confirmation and cancellation of two buttons, click Confirm Trigger Clickevent () method


$.confirm = function (settings) {


var htmldom = $ ("&lt;div id=" Displaypanle "style=" display:none;border:1px solid #005eac "&gt;&lt;/div&gt;");


Htmldom.css ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


var msg = $ ("&lt;table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "&gt;&lt;tr&gt;&lt;td width=" 80% "Style=" text-align:left;padding-left:20px;font-family: Song Body "&gt;" + settings.msg + "&lt;/td&gt;&lt;td id=" CONFIRMTD " &gt;&lt;input type= "button" class= "Standard-button" value= "Confirm" id= "ConfirmButton"/&gt;&lt;/td&gt;&lt;td style= " padding-left:10px "&gt;&lt;input type=" button "id=" Close "class=" Standard-button "value=" to cancel "onclick=" javascript:  Closeblockuinofresh (); " Style= "margin-right:20px;" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; ");


Htmldom.append (msg);


Msg.find (' #confirmbutton '). Click (settings.clickevent);


$.blockui ({


Message:htmldom,


CSS: {width: "650px", Height: "70px", "Background-color": "#fff"}


});


Pressescout ();


}

$.confirmwithrefresh = function (settings) {


var htmldom = $ ("&lt;div id=" Displaypanle "style=" display:none;border:1px solid #005eac "&gt;&lt;/div&gt;");


Htmldom.css ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


var msg = $ ("&lt;table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "&gt;&lt;tr&gt;&lt;td width=" 80% "Style=" text-align:left;padding-left:20px;font-family: Song Body "&gt;" + settings.msg + "&lt;/td&gt;&lt;td id=" CONFIRMTD " &gt;&lt;input type= "button" class= "Standard-button" value= "Confirm" id= "ConfirmButton"/&gt;&lt;/td&gt;&lt;td style= " padding-left:10px "&gt;&lt;input type=" button "id=" Close "class=" Standard-button "id=" CancelButton "value=" Cancel " Onclick= "Javascript:closeblockuinofresh ();" style= "margin-right:20px;" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; ");


Htmldom.append (msg);


Msg.find (' #confirmbutton '). Click (settings.clickevent);


$.blockui ({


Message:htmldom,


CSS: {width: "650px", Height: "70px", "Background-color": "#fff"}


});


Pressescout ();


}

For some pages to close the layer does not need to refresh the page, so use a different way to close


$.confirmnorefresh = function (settings) {


var htmldom = $ ("&lt;div id=" Displaypanle "style=" display:none;border:1px solid #005eac "&gt;&lt;/div&gt;");


Htmldom.css ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


var msg = $ ("&lt;table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "&gt;&lt;tr&gt;&lt;td width=" 80% "Style=" text-align:left;padding-left:20px;font-family: Song Body "&gt;" + settings.msg + "&lt;/td&gt;&lt;td id=" CONFIRMTD " &gt;&lt;input type= "button" class= "Standard-button" value= "Confirm" id= "ConfirmButton"/&gt;&lt;/td&gt;&lt;td style= " padding-left:10px "&gt;&lt;input type=" button "id=" Close "class=" Standard-button "id=" CancelButton "value=" Cancel " Onclick= "Javascript:closeblockuinofresh ();" style= "margin-right:20px;" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; ");


Htmldom.append (msg);


Msg.find (' #confirmbutton '). Click (settings.clickevent);


$.blockui ({


Message:htmldom,


CSS: {width: "650px", Height: "70px", "Background-color": "#fff"}


});


Pressescout ();


}

Pop-up Cue box


$.prompt = function (settings) {


var htmldom = $ ("&lt;div id=" Displaypanle "style=" display:none;border:1px solid #005eac "&gt;&lt;/div&gt;");


Htmldom.css ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


Htmldom.append ("&lt;table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "&GT;&LT;TR&GT;&LT;TD" Width= "80%" style= "text-align:left;padding-left:20px;font-family: Song Body" &gt; "+ settings.msg +" &lt;/td&gt;&lt;td&gt; &lt;input type= "button" id= "Confirm" value= "confirms" class= "Standard-button" onclick= "Javascript:closeblockuinofresh ();" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; ");


$.blockui ({


Message:htmldom,


CSS: {width: "550px", Height: "70px", "Background-color": "#fff", "Z-index": Settings.basez}


});


Pressescout ();


}

$.promptwithrefresh = function (settings) {


var htmldom = $ ("&lt;div id=" Displaypanle "style=" display:none;border:1px solid #005eac "&gt;&lt;/div&gt;");


Htmldom.css ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


Htmldom.append ("&lt;table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "&GT;&LT;TR&GT;&LT;TD" Width= "80%" style= "text-align:left;padding-left:20px;font-family: Song Body" &gt; "+ settings.msg +" &lt;/td&gt;&lt;td&gt; &lt;input type= "button" id= "Confirm" value= "confirms" class= "Standard-button" onclick= "Javascript:closeblockui ();"/&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; ");


$.blockui ({


Message:htmldom,


CSS: {width: "550px", Height: "70px", "Background-color": "#fff", "Z-index": Settings.basez}


});


Pressescout ();


}

$.promptwithrefreshoverride = function (settings) {


var htmldom = $ ("&lt;div id=" Displaypanle "style=" display:none;border:1px solid #005eac "&gt;&lt;/div&gt;");


Htmldom.css ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


var msg = $ ("&lt;table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "&gt;&lt;tr&gt;&lt;td width=" 80% "Style=" text-align:left;padding-left:20px;font-family: Song Body "&gt;" + settings.msg + "&lt;/td&gt;&lt;td&gt;&lt;input Type= "button" id= "Confirm" value= "confirms" class= "Standard-button"/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; ");


Htmldom.append (msg);


Msg.find (' #confirm '). Click (settings.clickevent);


$.blockui ({


Message:htmldom,


CSS: {width: "550px", Height: "70px", "Background-color": "#fff", "Z-index": Settings.basez}


});


Pressescout ();


}

Pop-up hint box no refresh


$.promptnorefresh = function (settings) {


var htmldom = $ ("&lt;div id=" Displaypanle "style=" display:none;border:1px solid #005eac "&gt;&lt;/div&gt;");


Htmldom.css ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


Htmldom.append ("&lt;table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "&GT;&LT;TR&GT;&LT;TD" Width= "80%" style= "text-align:left;padding-left:20px;font-family: Song Body" &gt; "+ settings.msg +" &lt;/td&gt;&lt;td&gt; &lt;input type= "button" id= "Confirm" value= "confirms" class= "Standard-button" onclick= "Javascript:closeblockuinofresh ();" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; ");


$.blockui ({


Message:htmldom,


CSS: {width: "550px", Height: "70px", "Background-color": "#fff", "Z-index": Settings.basez}


});


Pressescout ();


}

The method pops up the layer that is added or modified, and the call needs to pass a DOM and the title of the layer. Methods are Formtitle (), appendtable (), and the method has two buttons to confirm and cancel, confirming that the button event needs to be overridden in page JS is clickevent ()


$.msgbox = function (settings) {


var tempscreen = (Document.body.clientwidth-settings.width.replace ("px", ""))/2;


var htmldom = $ ("&lt;div id=" Displaypanle "style=" display:none;border:1px solid #005eac "&gt;&lt;/div&gt;");


&nbsp;&nbsp;&nbsp; var msg = $ ("&lt;table cellpadding=" 0 "cellspacing=" 0 "border=" 0 "class=" inndertable "style=" vertical-align:top;width:100% "&gt;&lt;tr&gt;&lt;td width=" 80% "style=" text-align:left;font-family: Song body; font-size : 14px;padding-left:15px;padding-top:10px;padding-bottom:10px;background-color: #3777bc; vertical-align:middle; Color: #fff; Font-weight:bold "&gt;" + settings.title + "&lt;/td&gt;&lt;td id=" CONFIRMTD "style=" text-align:right; Padding-right:5px;padding-top:10px;padding-bottom:10px;background-color: #3777bc; Vertical-align:middle;cursor: Pointer;color: #fff; font-weight:bold "onclick=" Javascript:closeblockuinofresh (); &gt; Close &LT;/TD&GT;&LT;/TR&GT;&LT;TR&GT;&LT;TD colspan= "2" style= "text-align:center;width:100%" &gt; "+ settings.dom + "&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=" 2 "style=" Text-align:right;padding-right:10px;padding-bottom : 10px; " &gt;&lt;input type= "button" class= "Standard-button" id= "ConfirmButton" value= "Confirm"/&gt;&amp;nbsp;&amp;nbsp;&lt; Input type= "button" id= "CloSe "class=" Standard-button "value=" cancels "onclick=" Javascript:closeblockuinofresh (); /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; ");


Htmldom.append (msg);


Msg.parent (). Find (' #confirmbutton '). Click (settings.clickevent);


$.blockui ({


Message:htmldom,


CSS: {width:settings.width, "Background-color": "#fff", "Z-index": Settings.basez, Left:tempscreen}


});


Pressescout ();


}

The method pops up the layer that is added or modified, and the call needs to pass a DOM and the title of the layer. Methods are Formtitle (), appendtable (), and the method has two buttons to confirm and cancel, confirming that the button event needs to be overridden in page JS is clickevent ()


$.msgboxwithrefresh = function (settings) {


var tempscreen = (Document.body.clientwidth-settings.width.replace ("px", ""))/2;


var htmldom = $ ("&lt;div id=" Displaypanle "style=" display:none;border:1px solid #005eac "&gt;&lt;/div&gt;");


&nbsp;&nbsp;&nbsp; var msg = $ ("&lt;table cellpadding=" 0 "cellspacing=" 0 "border=" 0 "class=" inndertable "style=" vertical-align:top;width:100% "&gt;&lt;tr&gt;&lt;td width=" 80% "style=" text-align:left;font-family: Song body; font-size : 14px;padding-left:15px;padding-top:10px;padding-bottom:10px;background-color: #3777bc; vertical-align:middle; Color: #fff; Font-weight:bold "&gt;" + settings.title + "&lt;/td&gt;&lt;td id=" CONFIRMTD "style=" text-align:right; Padding-right:5px;padding-top:10px;padding-bottom:10px;background-color: #3777bc; Vertical-align:middle;cursor: Pointer;color: #fff; font-weight:bold "onclick=" Javascript:closeblockuinofresh (); &gt; Close &LT;/TD&GT;&LT;/TR&GT;&LT;TR&GT;&LT;TD colspan= "2" style= "text-align:center;width:100%" &gt; "+ settings.dom + "&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=" 2 "style=" Text-align:right;padding-right:10px;padding-bottom : 10px; " &gt;&lt;input type= "button" class= "Standard-button" id= "ConfirmButton" value= "Confirm"/&gt;&amp;nbsp;&amp;nbsp;&lt; Input type= "button" id= "CloSe "class=" Standard-button "value=" cancels "onclick=" Javascript:closeblockuinofresh (); /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; ");


Htmldom.append (msg);


Msg.parent (). Find (' #confirmbutton '). Click (settings.clickevent);


$.blockui ({


Message:htmldom,


CSS: {width:settings.width, "Background-color": "#fff", "Z-index": Settings.basez, Left:tempscreen}


});


Pressescout ();


}


Closes Blcokui, which is the default method and does not need to be changed.
function Closeblockui () {
$.unblockui ();
Location.reload ();
return false;
}

Close Blockui but not refresh page
function Closeblockuinofresh () {
$.unblockui ();
}

function Pressescout () {
$ ("*"). KeyPress (function (event) {
var Jianzhi = Event.keycode;
var Input_keydown = $ (this);
Switch (Jianzhi) {
Case 27:
Closeblockuinofresh ();
Break
}
});
}

1//Pop-up prompt box


2 $.prompt = function (settings) {


3 var htmldom = $ ("&lt;div id=" Displaypanle "style=" display:none;border:1px solid #005eac "&gt;&lt;/div&gt;");


4 Htmldom.css ({"Text-align": "Center", "Vertical-align": "Middle", "line-height": "70px"});


5 Htmldom.append ("&lt;table cellpadding=" 0 "cellspacing=" 0 "class=" inndertable "width=" 100% "&GT;&LT;TR&GT;&LT;TD" Width= "80%" style= "text-align:left;padding-left:20px;" &gt; "+ settings.msg +" &lt;/td&gt;&lt;td&gt;&lt;input type= "button" id= "Confirm" value= "confirm" class= "Standard-button" Onclick= "Javascript:closeblockuinofresh ();" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; ");


6 $.blockui ({


7 Message:htmldom,


8 css: {width: "550px", Height: "70px", "Background-color": "#fff", "Z-index": Settings.basez}


9});


Ten pressescout ();


11}


12

1//---------------------------------------Blockui part end-----------------------------------


2//change blockui default settings


3//change Blockui Border


4 $.blockui.defaults.css.border = ' 5px solid #ccc '; Border Style


5 $.blockui.defaults.css.cursor = ' Default '; Mouse style


6 $.blockui.defaults.css.top = ' 20% '; The location of the pop-up layer


7 $.blockui.defaults.css.left = ' 30% ';


8 $.blockui.defaults.overlaycss.cursor = ' Default ';


9//change fadeout effact speed


Ten $.blockui.defaults.fadeout = 100; The speed of fade effect


One $.blockui.defaults.fadein = 100;


12

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.