The Google personalized homepage is similar to how to save the final layout of the 3_php tutorial.

Source: Internet
Author: User
Google's personalized homepage is similar to how to save the final layout 3. The Google personalized homepage is similar to how to save the final layout of three varDrag {dragged: false, ao: null, tdiv: null, dragStart: function () {Drag. aoevent. srcElement; if (Drag. ao. the tagName Google personalized homepage is similar to how to save the final layout 3.

Var Drag = {
Dragged: false,
Ao: null,
Tp: null,

DragStart: function (){
Drag. ao = event. srcElement;
If (Drag. ao. tagName = "TD") | (Drag. ao. tagName = "TR ")){

Drag. ao = Drag. ao. offsetParent;
Drag. ao. style. zIndex = 100;
} Else {
Return;
}

Drag. dragged = true;
Drag. tp = document. createElement ("p ");
Drag. tp. innerHTML = Drag. ao. outerHTML;
Drag. ao. style. border = "1px dashed blue ";
Drag. tp. style. display = "block ";
Drag. tp. style. position = "absolute ";
Drag. tp. style. filter = "alpha (opacity = 70 )";
Drag. tp. style. cursor = "move ";
Drag. tp. style. border = "1px solid #000000 ";
Drag. tp. style. width = Drag. ao. offsetWidth;
Drag. tp. style. height = Drag. ao. offsetHeight;
Drag. tp. style. top = Drag. getInfo (Drag. ao). top;
Drag. tp. style. left = Drag. getInfo (Drag. ao). left;
Document. body. appendChild (Drag. tp );
Drag. lastX = event. clientX;
Drag. lastY = event. clientY;
Drag. lastLeft = Drag. tp. style. left;
Drag. lastTop = Drag. tp. style. top;
} // End function dragStart ()
,
Draging: function () {// important: judge the MOUSE position
If (! Drag. dragged | Drag. ao = null) return;
Var tX = event. clientX;
Var tY = event. clientY;
Drag. tp. style. left = parseInt (Drag. lastLeft) + tX-Drag.lastX;
Drag. tp. style. top = parseInt (Drag. lastTop) + tY-Drag.lastY;
For (var I = 0; I Var parentCell = Drag. getInfo (parentTable. cells [I]);
If (tX> = parentCell. left &&
TX <= parentCell. right &&
TY> = parentCell. top &&
TY <= parentCell. bottom ){
Var subTables = parentTable. cells [I]. getElementsByTagName ("table ");
If (subTables. length = 0 ){
If (tX> = parentCell. left &&
TX <= parentCell. right &&
TY> = parentCell. top &&
TY <= parentCell. bottom ){
ParentTable. cells [I]. appendChild (Drag. ao );
}
Break;
}
For (var j = 0; j Var subTable = Drag. getInfo (subTables [j]);
If (tX> = subTable. left &&
TX <= subTable. right &&
TY> = subTable. top &&
TY <= subTable. bottom ){
ParentTable. cells [I]. insertBefore (Drag. ao, subTables [j]);
Break;
} Else {
ParentTable. cells [I]. appendChild (Drag. ao );
}
}
}
}
} // End function draging
,
DragEnd: function (){
If (! Drag. dragged) return;
Drag. dragged = false;
Drag. mm = Drag. repos (150,15 );
Drag. ao. style. borderWidth = "0px ";
// Drag. ao. style. borderTop = "1px solid # 3366cc ";
Drag. tp. style. borderWidth = "0px ";
Drag. ao. style. zIndex = 1;
// Alert (Drag. ao. outerHTML );
Drag. saveLayout ();
DisplaySaveLayout ();
} // End function dragEnd ()
,
SaveLayout: function ()
{// Place the current layout in the Cookie. press "Save page layout" and save it to the background.
For (var I = 0; I Var subTables = parentTable. cells [I]. getElementsByTagName ("table ");
For (var j = 0; j If (subTables [j]. className! = "DragTable") break;
// I _cell index of parentTable
// J_node index of parentTable. rows [0] [I]. childNodes
SetCookie (subTables [j]. id + "pos", I + ":" + j + ":" + subTables [j]. id );
}
}
} // End function saveLayout ()
,
InitTablePos: function ()
{
// Obtain the value from the Cookie first. If no value is obtained, select the data from the database.
Var _ tablepos = new Array ();
Var _ dragTableHtmlArray = new Array (); // store the html code in the drag table
Var _ cookies = new Array ();
Var _ c = 0;
// Get the content on the screen to Javascript and then relay the layout.
For (var I = 0; I Var subTables = parentTable. cells [I]. getElementsByTagName ("table ");
For (var j = 0; j If (subTables [j]. className! = "DragTable") break;
_ Cookies [_ c] = getCookie (subTables [j]. id + "pos ");
_ DragTableHtmlArray [subTables [j]. id] = subTables [j]. outerHTML;
_ C ++;
}

If (_ cookies. toString (). indexOf ("::")! =-1)
{
ParentTable. cells [I]. innerHTML = ""; // clear the image and drag the Table
}

}
_ Cookies. sort (); // add innerHTML in sequence
If (_ cookies. toString (). indexOf ("::")! =-1)
{
For (var _ k = 0; _ k <_ cookies. length; _ k ++)
{
If (_ cookies [_ k]! = Null)
{
_ Tablepos = _ cookies [_ k]. split ("::");
// Alert (_ tablepos );
If (typeof (_ tablepos) = "object ")
{
// Alert (_ dragTableHtmlArray [_ tablepos [2]);
ParentTable. cells [_ tablepos [0]. innerHTML + = _ dragTableHtmlArray [_ tablepos [2];
// ParentTable. cells [_ tablepos [0]. innerText + = _ dragTableHtmlArray [_ tablepos [2];
}
}
}
}
// _ Cookies. sort ();
// Alert (_ cookies );
_ DragTableHtmlArray = null; // release memoery
} // End function initDragTablePos ()
,
GetInfo: function (o) {// Get coordinates
Var to = new Object ();
To. left = to. right = to. top = to. bottom = 0;
Var twidth = o. offsetWidth;
Var theight = o. offsetHeight;
While (o! = Document. body ){
To. left + = o. offsetLeft;
To. top + = o. offsetTop;
O = o. offsetParent;
}
To. right = to. left + twidth;
To. bottom = to. top + theight;
Return;
} // End function getInfo ()
,
Repos: function (aa, AB ){
Var f = Drag. tp. filters. alpha. opacity;
Var tl = parseInt (Drag. getInfo (Drag. tp). left );
Var tt = parseInt (Drag. getInfo (Drag. tp). top );
Var kl = (tl-Drag.getInfo (Drag. ao). left)/AB;
Var kt = (tt-Drag.getInfo (Drag. ao). top)/AB;
Var kf = f/AB;
Return setInterval (
Function (){
If (AB <1 ){
ClearInterval (Drag. mm );
Drag. tp. removeNode (true );
Drag. ao = null;
Return;
}
AB --;
Tl-= kl;
Tt-= kt;
F-= kf;
Drag. tp. style. left = parseInt (tl) + "px ";
Drag. tp. style. top = parseInt (tt) + "px ";
Drag. tp. filters. alpha. opacity = f;
} // End animation effect
, Aa/AB)
} // End function repos ()
,
Inint: function () {// Initialization
Drag. initTablePos ();
For (var I = 0; I Var subTables = parentTable. cells [I]. getElementsByTagName ("table ");
For (var j = 0; j If (subTables [j]. className! = "DragTable") break;
SubTables [j]. rows [0]. className = "dragTR ";
SubTables [j]. rows [0]. attachEvent ("onmousedown", Drag. dragStart );
}
}

Document. onmousemove = Drag. draging;
Document. onmouseup = Drag. dragEnd;
} // End function inint ()
} // End of Object Drag

Drag. inint ();


The http://www.bkjia.com/PHPjc/445131.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445131.htmlTechArticleGoogle personalization homepage is similar to how to save the final layout of three var Drag = {dragged: false, ao: null, tp: null, dragStart: function () {Drag. ao = event. srcElement; if (Drag. ao. tagName...

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.