home *** CD-ROM | disk | FTP | other *** search
/ Photo Explosion 2.5 (Special Edition) / NovaDevelopment-PhotoExplosionSE-v2.5-Windows.iso / Data / Data1.cab / _47894F9349D04E4DA7536B6A22284C84 < prev    next >
Encoding:
Text File  |  2005-12-12  |  9.4 KB  |  413 lines

  1. var curElement;
  2. var curParentDiv;
  3. var curPickDiv;
  4. var nStartX        = 0;
  5. var nStartY        = 0;
  6. var nStartLeft    = 0;
  7. var nStartTop    = 0;
  8. var oldCursor = "hand";
  9. var IsShowVideoBorder = false;
  10.  
  11. var bDebugVersion = false;
  12.  
  13. function MyTest(strID)
  14. {
  15.     var oldParentDiv = curParentDiv;
  16.     var oldElement = curElement;
  17.  
  18.     onClickElement(document.all[strID]);
  19.  
  20.     if (oldParentDiv != curParentDiv) 
  21.     {
  22.         if (oldParentDiv != null) 
  23.         {
  24.             oldParentDiv.style.borderWidth = "0px";
  25.             oldParentDiv.style.pixelLeft += 5;
  26.             oldParentDiv.style.pixelTop += 5;
  27.         //    oldParentDiv.style.pixelWidth -= 10;
  28.         //    oldParentDiv.style.pixelHeight -= 10;
  29.             if (oldElement != null)
  30.                 oldElement.style.cursor = oldCursor;
  31.         }
  32.  
  33.         if (curParentDiv != null) 
  34.         {
  35.             curParentDiv.style.borderWidth = "5px";
  36.         //    curParentDiv.style.pixelLeft -= 5;
  37.         //    curParentDiv.style.pixelTop -= 5;
  38.  
  39.         //    curParentDiv.style.pixelWidth = curParentDiv.clientWidth + 10;
  40.         //    curParentDiv.style.pixelHeight = curParentDiv.clientHeight + 10;
  41.  
  42.         //    oldCursor = curElement.style.cursor;
  43.             oldCursor = "hand";
  44.             curElement.style.cursor = "move";
  45.         }
  46.     }
  47.  
  48.     if (curParentDiv != null) 
  49.     {
  50.     //    nStartX = event.clientX;
  51.     //    nStartY = event.clientY;
  52.     //    nStartLeft = curParentDiv.style.pixelLeft;
  53.     //    nStartTop = curParentDiv.style.pixelTop;
  54.     }
  55. }
  56.  
  57. function UpdateVideoBorder()
  58. {
  59.     var  pLayer    = document.all("VideoLayer");
  60.     var  pBorder = document.all("VideoBorder");
  61.  
  62.     if(pLayer && pBorder)
  63.     {
  64.         if(pLayer == curParentDiv)
  65.             pBorder.style.visibility = pLayer.style.visibility;
  66.         else
  67.             pBorder.style.visibility = "hidden";
  68.     }
  69. }
  70.  
  71. function ShowDebugMessage(str)
  72. {
  73.     if (bDebugVersion == true)
  74.         window.alert(str);
  75. }
  76.  
  77. function doMouseMove() 
  78. {
  79.     var nNewLeft=0, nNewTop = 0
  80.     
  81.     event.returnValue = false;
  82.     event.cancelBubble = true;
  83.  
  84.     if (curPickDiv == null)
  85.         return;
  86.     
  87.     if (event.clientX < 0 ||
  88.         event.clientY < 0 ||
  89.         event.clientX >= document.body.clientWidth ||
  90.         event.clientY >= document.body.clientHeight)
  91.     {
  92.         return;
  93.     }
  94.     
  95.     if ((event.button==1) && (curParentDiv!=null)) 
  96.     {
  97.         // position alien
  98.         nNewLeft = nStartLeft + (event.clientX - nStartX);        
  99.         curParentDiv.style.pixelLeft = nNewLeft;
  100.     //    if(VideoBorder)
  101.     //        VideoBorder.style.pixelLeft = nNewLeft - 5;
  102.         
  103.         nNewTop = nStartTop + (event.clientY - nStartY);        
  104.         curParentDiv.style.pixelTop = nNewTop;
  105.     //    if(VideoBorder)
  106.     //        VideoBorder.style.pixelTop = nNewTop - 5;
  107.     }
  108. }
  109.  
  110.  
  111. function doDragStart() 
  112. {
  113.     // Don't do default drag operation.
  114.     if ("IMG"==event.srcElement.tagName)
  115.       event.returnValue=false;
  116. }
  117.  
  118. function doMouseUp() 
  119. {
  120.     event.returnValue = false;
  121.     event.cancelBubble = true;
  122.  
  123.     if (curPickDiv != null) {
  124.         if ((event.button==1) && (curParentDiv!=null)) {
  125.             if (curParentDiv.style.pixelLeft < 0)
  126.                 curParentDiv.style.pixelLeft = 0;
  127.             if (curParentDiv.style.pixelTop < 0)
  128.                 curParentDiv.style.pixelTop = 0;
  129.         }
  130.  
  131.         curPickDiv = null;
  132.     }
  133. }
  134.  
  135. function ReplaceVideo(str)
  136. {
  137.     uVideo01.outerHTML = str;
  138. }
  139.  
  140. var nAkuo=0;
  141.  
  142.  
  143. function SelectNone()
  144. {
  145.     var oldParentDiv = curParentDiv;
  146.     var oldElement = curElement;
  147.  
  148.     curElement = null;
  149.     curParentDiv = null;
  150.  
  151.     if (oldParentDiv != curParentDiv) {
  152.         if (oldParentDiv != null) {
  153.             oldParentDiv.style.borderWidth = "0px";
  154.             oldParentDiv.style.pixelLeft += 5;
  155.             oldParentDiv.style.pixelTop += 5;
  156.         //    oldParentDiv.style.pixelWidth -= 10;
  157.         //    oldParentDiv.style.pixelHieght -= 10;
  158.             if (oldElement != null)
  159.                 oldElement.style.cursor = oldCursor;
  160.         }
  161.     }
  162. }
  163.  
  164. function onClickElement(srcElement)
  165. {
  166.     var ElementClicked;
  167.  
  168.     if (srcElement == null)
  169.            ElementClicked = event.srcElement;
  170.     else
  171.         ElementClicked = srcElement;
  172.  
  173. //    alert(ElementClicked.id);
  174. //    alert(ElementClicked.tagName);
  175.  
  176.     if (ElementClicked.tagName == "BODY" ||
  177.         ElementClicked.tagName == "body") {
  178.     //    alert("Body");
  179.         ElementClicked = null;
  180.     }    
  181.     else {
  182.         var bHasID = false;
  183.         var strID = "";
  184.  
  185.         if (ElementClicked.id != null &&
  186.             ElementClicked.id != "" &&
  187.             ElementClicked.id != "undefined") {
  188.             bHasID = true;
  189.             strID = ElementClicked.id;
  190.         }
  191.  
  192.         if (!bHasID &&
  193.             ElementClicked.name != null &&
  194.             ElementClicked.name != "" &&
  195.             ElementClicked.name != "undefined") {
  196.             bHasID = true;
  197.             strID = ElementClicked.name;
  198.         }
  199.  
  200.         if (!bHasID) {
  201.             ShowDebugMessage("The element you clicked does not have an ID or NAME, so it cannot be selected.");
  202.         //    alert("No ID");
  203.             ElementClicked = null;
  204.         }
  205.         else if (strID.indexOf("u") != 0) 
  206.         {
  207.             ShowDebugMessage("The element you clicked does not have an ID start with \'u\', so it cannot be selected.");
  208.         //    alert("U");
  209.             ElementClicked = null;
  210.         }
  211.         else 
  212.         {
  213.             var strClass = ElementClicked.className;
  214.             var strSub = strClass.substring(0, 5);
  215.             if (strSub == "Fixed") 
  216.             {
  217.                 ShowDebugMessage("The element you clicked is a fixed decoration element.");
  218.             //    alert(ElementClicked.id);
  219.             //    alert(ElementClicked.tagName);
  220.             //    alert("Fixed");
  221.                 ElementClicked = null;
  222.             }
  223.  
  224.             strSub = strClass.substring(0, 7);
  225.             if (strSub == "Dynamic") 
  226.             {
  227.                 ShowDebugMessage("The element you clicked is a dynamic element.");
  228.             //    alert("Dynamic");
  229.                 ElementClicked = null;
  230.             }
  231.         }
  232.     }
  233.  
  234.     curParentDiv = null;    
  235.     
  236.     if (ElementClicked != null) {
  237.         var Parent;
  238.  
  239.         if (ElementClicked.tagName == "DIV" ||
  240.             ElementClicked.tagName == "div")
  241.             curParentDiv = ElementClicked;
  242.  
  243.         Parent = ElementClicked.parentElement;
  244.         while (Parent != null) {
  245.             if (Parent.tagName == "DIV" ||
  246.                 Parent.tagName == "div")
  247.                 curParentDiv = Parent;
  248.             Parent = Parent.parentElement;
  249.         }
  250.  
  251.         if (curParentDiv == null) {                                
  252.             if (ElementClicked.tagName != "BODY" &&
  253.                 ElementClicked.tagName != "body")
  254.                 ShowDebugMessage("The element you clicked does not have a DIV parent element. This is a design error.");
  255.             ElementClicked = null;
  256.         }
  257.  
  258.         curPickDiv = curParentDiv;
  259.  
  260.     }
  261.  
  262.  
  263.     status = "Liao Cheng Kuo"; // begin of ulead private string 
  264.     
  265.     if (ElementClicked == null) 
  266.         status = "Akuo";
  267.     else {
  268.         curElement = ElementClicked;
  269.  
  270.         status = "TagName~" + curElement.tagName;
  271.  
  272.         status = "ID~" + curElement.id;
  273.                     
  274.         status = "Name~" + curElement.name;
  275.                     
  276.         status = "Src~" + curElement.src;
  277.  
  278.         status = "DynSrc~" + curElement.dynsrc;
  279.  
  280.         if (curElement.href)
  281.             status = "Href~" + curElement.href;
  282.             
  283.         status = "InnerText~" + curElement.innerText;
  284.  
  285.         status = "OuterText~" + curElement.outerText;
  286.  
  287.         status = "InnerHTML~" + curElement.innerHTML;
  288.  
  289.         status = "OuterHTML~" + curElement.outerHTML;
  290.     }
  291.  
  292.     status = "Kuo Cheng Liao"; // end of ulead private string
  293. }
  294.  
  295.  
  296. function doMouseDown() 
  297. {
  298.     event.returnValue = false;
  299.     event.cancelBubble = true;
  300.  
  301.     if (event.clientX <= 0 ||
  302.         event.clientY <= 0 ||
  303.         event.clientX >= document.body.clientWidth ||
  304.         event.clientY >= document.body.clientHeight)
  305.         return;
  306.  
  307.     if ((event.button==1)){// && ) {
  308.         var oldParentDiv = curParentDiv;
  309.         var oldElement = curElement;
  310.  
  311.         onClickElement(null)
  312.  
  313.         if (oldParentDiv != curParentDiv) {
  314.             if (oldParentDiv != null) {
  315.                 if(-1 == oldParentDiv.id.indexOf("VideoLayer"))
  316.                 {
  317.                     oldParentDiv.style.borderWidth = "0px";
  318.                     oldParentDiv.style.pixelLeft += 5;
  319.                     oldParentDiv.style.pixelTop += 5;
  320.                 //    oldParentDiv.style.pixelWidth -= 10;
  321.                 //    oldParentDiv.style.pixelHeight -= 10;
  322.                 }
  323.                 else
  324.                 {
  325.                     if(VideoBorder)
  326.                         VideoBorder.style.visibility    = "hidden";
  327.                 }
  328.                 if (oldElement != null)
  329.                     oldElement.style.cursor = oldCursor;
  330.             }
  331.  
  332.             if (curParentDiv != null) {
  333.                 if(-1 == curParentDiv.id.indexOf("VideoLayer"))
  334.                 {
  335.                 //    alert(curParentDiv.id);
  336.                     curParentDiv.style.borderWidth = "5px";
  337.                     curParentDiv.style.pixelLeft -= 5;
  338.                     curParentDiv.style.pixelTop -= 5;
  339.                 //    curParentDiv.style.pixelWidth += 10;
  340.                 //    curParentDiv.style.pixelHeight += 10;
  341.                 }
  342.                 else
  343.                 {
  344.                     if(VideoBorder)
  345.                     {
  346.                         VideoBorder.style.pixelLeft        = curParentDiv.style.pixelLeft - 5;
  347.                         VideoBorder.style.pixelTop        = curParentDiv.style.pixelTop - 5;
  348.                         VideoBorder.style.pixelWidth    = curParentDiv.clientWidth + 10;
  349.                         VideoBorder.style.pixelHeight    = curParentDiv.clientHeight + 10;
  350.                         VideoBorder.style.visibility    = "visible";
  351.                     }
  352.                 }
  353.  
  354.                 oldCursor = curElement.style.cursor;
  355.                 curElement.style.cursor = "move";
  356.             }
  357.         }
  358.  
  359.         if (curParentDiv != null) {
  360.             nStartX = event.clientX;
  361.             nStartY = event.clientY;
  362.             nStartLeft = curParentDiv.style.pixelLeft;
  363.             nStartTop = curParentDiv.style.pixelTop;
  364.         }
  365.     }
  366. }
  367.  
  368. function doMouseOver() 
  369. {
  370. }
  371.  
  372.  
  373. function doKeyDown()
  374. {
  375.     var nNewLeft=0, nNewTop = 0
  376.     
  377.     if (curParentDiv == null)
  378.         return;
  379.  
  380.     nNewTop = curParentDiv.style.pixelTop;
  381.     nNewLeft = curParentDiv.style.pixelLeft;
  382.  
  383.     if (event.keyCode == 37)
  384.         nNewLeft -= 1;
  385.     else if (event.keyCode == 38)
  386.         nNewTop -= 1;
  387.     else if (event.keyCode == 39)
  388.         nNewLeft += 1;
  389.     else if (event.keyCode == 40)
  390.         nNewTop += 1;
  391.     else
  392.         return;
  393.  
  394.     event.returnValue = false;
  395.     event.cancelBubble = true;
  396.  
  397.     if (nNewLeft >= 0)    
  398.         curParentDiv.style.pixelLeft = nNewLeft;
  399.  
  400.     if (nNewTop >= 0)
  401.         curParentDiv.style.pixelTop = nNewTop;
  402. }
  403.  
  404. document.ondragstart = doDragStart;
  405. document.onmousedown = doMouseDown;
  406. document.onmousemove = doMouseMove;
  407. document.onmouseover = doMouseOver;
  408. document.onmouseup = doMouseUp;
  409. document.onkeydown = doKeyDown;
  410.  
  411.  
  412.  
  413.