home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2000 November / APC5112K.ISO / patch / microsoft / i386 / appwiz.cp_ / appwiz.cpl / HTML / PLACES.HTC < prev    next >
Encoding:
Text File  |  2000-07-21  |  12.7 KB  |  543 lines

  1. <PUBLIC:HTC URN="shellctls"><METHOD name="SetExecButton" /><METHOD name="ShowButton" /><METHOD name="focus" /><METHOD name="blur" /><EVENT id=onSelectItem name="onSelectItem" /><EVENT id=onExecItem name="onExecItem" /><EVENT id=onComplete name="onComplete" /><ATTACH event="oncontentready" handler=_OnContentReady /><ATTACH event="ondragstart" handler=_CancelDragStart /><SCRIPT language="javascript">
  2. var _bLoading = true; 
  3. var _iBtnPressed = -1; 
  4. var _iBtnHot = -1; 
  5. var _iBtnTabIndex = -1; 
  6. var _iBtnCapture = -1; 
  7. var _cButtons = 0; 
  8. var _rgbtn = new Array(); 
  9. var _rgdivButtons = new Array(); 
  10. var _styleinfo = null; 
  11. var _mpStyle = new Object(); 
  12. var _bHasFocus = false; 
  13. var _bInternalFocusChange = false; 
  14. var BS_PRESSED = 0x01;
  15. var BS_HOT = 0x02;
  16. var c_szStyle_ButtonNormal = 
  17. ' style="'                      +
  18.         'position:relative; '           +
  19.         'padding:2px; '                 +
  20.         'border-style:solid; '          +
  21.         'border-width:1px; '            +
  22.         'border-top-color:threedshadow; '    +
  23.         'border-left-color:threedshadow; '   +
  24.         'border-right-color:threedshadow; '  +
  25.         'border-bottom-color:threedshadow; ' +
  26.         '"';
  27. var c_szStyle_ButtonText = 
  28. ' style="'                      +
  29.         'position:relative; '           +
  30.         'color:white; '                 +
  31.         'cursor:default; '              +
  32.         '"';
  33. var c_szStyle_Background = 
  34. ' style="'                      +
  35.         'position:relative; '           +
  36.         'width:87px; '                  +
  37.         'height:100%; '                 +
  38.         'padding:2px; '                 +
  39.         'background-color:threedshadow; ' +
  40.         '"';
  41. element.attachEvent("onerror", _OnError);
  42. _GetPropertyDefaults();
  43. function get_button() { return _iBtnPressed; }
  44. function put_button(iBtn) 
  45. if (_bLoading)
  46. return;
  47. _PushButton(parseInt(iBtn), 0);
  48. }
  49. function _OnContentReady()
  50. {
  51. _bLoading = false;
  52. _ScanSpecialElements();
  53. _CreateHTML();
  54. }
  55. function _OnDocumentLoad()
  56. {
  57. _Initialize();
  58. }
  59. function _GetPropertyDefaults()
  60. {
  61. if (element.currentButton)
  62. _iBtnPressed = parseInt(element.currentButton);
  63. }
  64. function _IDName(szID, idx)
  65. {
  66. return szID + idx + '_' + uniqueID;
  67. }
  68. function _StoreButton(elem, ibtn)
  69. {
  70. var btn = new Object;
  71. var szBtnIndex = ' _ibtn=' + ibtn;
  72. var L_PlacesGraphic_Text = 'Graphic';
  73. btn.id = elem.id;
  74. btn._idBtn = _IDName('idBtn', ibtn);
  75. btn._ibtn = ibtn;
  76. btn._idBR = _IDName('idBtnBR', ibtn);
  77. btn._bHidden = false;
  78. if ("undefined" != typeof elem.execItem)
  79. btn._bExecButton = true;
  80. else
  81. btn._bExecButton = false;
  82. btn.innerHTML = 
  83. '<DIV id=' + btn._idBtn + c_szStyle_ButtonNormal + szBtnIndex + ' _btnState=0> ' +
  84. '   <CENTER id=' + _IDName('idCtr', ibtn) + szBtnIndex + '> ' +
  85. '       <IMG id=' + _IDName('idImg', ibtn) + ' style="position:relative" src=' + elem.img + szBtnIndex + ' title="" alt="' + L_PlacesGraphic_Text + '" >' +
  86. '       <BR>' +
  87. '       <SPAN id=' + _IDName('idSpan', ibtn) + c_szStyle_ButtonText + szBtnIndex + ' nofocusrect>' + 
  88. elem.innerHTML + 
  89. '       </SPAN>' +
  90. '   </CENTER> ' + 
  91. '</DIV>';
  92. _rgbtn[ibtn] = btn;
  93. }
  94. function _ScanSpecialElements()
  95. {
  96. var i;
  97. var rgspan = element.all.tags("SPAN");
  98. var cspan = rgspan.length;
  99. for (i = 0; i < cspan; i++)
  100. {
  101. var span = rgspan[i];
  102. _StoreButton(span, _cButtons++);
  103. span.innerHTML = "";
  104. }
  105. }
  106. function _CreateHTML()
  107. {
  108. var i;
  109. var szButtons = '';
  110. element.style.visibility = 'hidden';
  111. for (i = 0; i < _cButtons; i++)
  112. {
  113. szButtons = szButtons + _rgbtn[i].innerHTML + '<BR id=' + _rgbtn[i]._idBR + '>';
  114. }
  115. element.innerHTML = 
  116. '<DIV ' + c_szStyle_Background + ' _ibtn=-1> ' + 
  117. szButtons + 
  118. '</DIV>';
  119. var rgdivs = element.all.tags("DIV");
  120. for (i = 0; i < _cButtons; i++)
  121. {
  122. var elem = rgdivs[_rgbtn[i]._idBtn];
  123. _rgdivButtons[i] = elem;
  124. elem.attachEvent('onmouseover', _OnMouseOver);
  125. elem.attachEvent('onmouseout', _OnMouseOut);
  126. elem.attachEvent('onmousedown', _OnMouseDown);
  127. elem.attachEvent('onmouseup', _OnMouseUp);
  128. var spanCaption = _GetCaptionElem(i);
  129. spanCaption.attachEvent('onblur', _OnBlurDiv);
  130. spanCaption.attachEvent('onfocus', _OnFocusDiv);
  131. spanCaption.attachEvent('onkeydown', _OnKeyDownDiv);
  132. elem.all(_IDName('idCtr', i)).attachEvent('ondragstart', _CancelDragStart);
  133. }
  134. window.attachEvent("onload", _OnDocumentLoad);
  135. _FireComplete();
  136. element.style.visibility = 'visible';
  137. }
  138. function _Initialize()
  139. {
  140. if (-1 != _iBtnPressed)
  141. {
  142. var ibtn = _iBtnPressed;
  143. _iBtnPressed = -1;
  144. _PushButton(ibtn, 0);
  145. }
  146. window.document.attachEvent("onkeydown", _OnKeyDownDocument);
  147. }
  148. function _BtnFromElement(elem)
  149. {
  150. var ibtn = -1;
  151. if (elem && null == elem._ibtn)
  152. {
  153. while (elem)
  154. {
  155. if (elem._ibtn)
  156. break;
  157. elem = elem.parentElement;
  158. }
  159. }
  160. if (elem)
  161. ibtn = elem._ibtn;
  162. return ibtn;
  163. }
  164. function _BtnFromID(idBtn)
  165. {
  166. var ibtn;
  167. for (ibtn = 0; ibtn < _rgbtn.length; ibtn++)
  168. {
  169. if (idBtn == _rgbtn[ibtn].id)
  170. return ibtn;
  171. }
  172. return -1;
  173. }
  174. function _DrawButtonFrame(elem, szState)
  175. {
  176. switch (szState)
  177. {
  178. case 'normal':
  179. elem.style.borderTopColor = 'threedshadow';
  180. elem.style.borderLeftColor = 'threedshadow';
  181. elem.style.borderRightColor = 'threedshadow';
  182. elem.style.borderBottomColor = 'threedshadow';
  183. break;
  184. case 'hotitem':
  185. elem.style.borderTopColor = 'threedhighlight';
  186. elem.style.borderLeftColor = 'threedhighlight';
  187. elem.style.borderRightColor = 'threeddarkshadow';
  188. elem.style.borderBottomColor = 'threeddarkshadow';
  189. break;
  190. case 'pushed':
  191. elem.style.borderTopColor = 'threeddarkshadow';
  192. elem.style.borderLeftColor = 'threeddarkshadow';
  193. elem.style.borderRightColor = 'threedhighlight';
  194. elem.style.borderBottomColor = 'threedhighlight';
  195. break;
  196. }
  197. }
  198. function _DrawButton(ibtn, bDown)
  199. {
  200. var div = _rgdivButtons[ibtn];
  201. var bDownCur = (div._btnState & BS_PRESSED) ? true : false;
  202. var elemImg = div.all(_IDName('idImg', div._ibtn));
  203. var elemText = div.all(_IDName('idSpan', div._ibtn));
  204. if (bDownCur == bDown)
  205. return; 
  206. if (bDown)
  207. {
  208. _DrawButtonFrame(div, 'pushed');
  209. elemImg.style.pixelLeft = elemImg.style.pixelLeft + 1;
  210. elemImg.style.pixelTop = elemImg.style.pixelTop + 1;
  211. elemText.style.pixelLeft = elemText.style.pixelLeft + 1;
  212. elemText.style.pixelTop = elemText.style.pixelTop + 1;
  213. div._btnState |= BS_PRESSED;
  214. }
  215. else
  216. {
  217. if (ibtn == _iBtnHot)
  218. _DrawButtonFrame(div, 'hotitem');
  219. else
  220. _DrawButtonFrame(div, 'normal');
  221. elemImg.style.pixelLeft = elemImg.style.pixelLeft - 1;
  222. elemImg.style.pixelTop = elemImg.style.pixelTop - 1;
  223. elemText.style.pixelLeft = elemText.style.pixelLeft - 1;
  224. elemText.style.pixelTop = elemText.style.pixelTop - 1;
  225. div._btnState &= ~ BS_PRESSED;
  226. }
  227. }
  228. function _GetCaptionElem(ibtn)
  229. {
  230. var spanCaption = null;
  231. var div = _rgdivButtons[ibtn];
  232. if (div)
  233. spanCaption = div.children[0].children[2];
  234. return spanCaption;
  235. }
  236. function _SetTabIndex(ibtn, bSetFocus)
  237. {
  238. if (ibtn == _iBtnTabIndex)
  239. return;
  240. var elem = _GetCaptionElem(_iBtnTabIndex);
  241. if (elem)
  242. elem.tabIndex = -1; 
  243. elem = _GetCaptionElem(ibtn);
  244. if (elem)
  245. {
  246. elem.tabIndex = 0; 
  247. if (bSetFocus)
  248. {
  249. _bInternalFocusChange = true;
  250. elem.focus();
  251. }
  252. }
  253. _iBtnTabIndex = ibtn;
  254. }
  255. var PBF_SETFOCUS = 0x01;
  256. var PBF_MOUSE = 0x02;
  257. function _PushButton(ibtn, dwFlags)
  258. {
  259. var btn = _rgbtn[ibtn];
  260. if (btn && btn._bHidden)
  261. {
  262. return;
  263. }
  264. if (btn && btn._bExecButton)
  265. {
  266. _DrawButton(ibtn, false);
  267. _FireExecItem(btn);
  268. }
  269. else
  270. {
  271. if ((dwFlags & PBF_MOUSE) && ibtn == _iBtnPressed)
  272. return;
  273. if (-1 != _iBtnPressed && ibtn != _iBtnPressed)
  274. {
  275. _DrawButton(_iBtnPressed, false);
  276. }
  277. _iBtnPressed = ibtn;
  278. _SetTabIndex(ibtn, dwFlags & PBF_SETFOCUS);
  279. if (0 <= _iBtnPressed && _iBtnPressed < _cButtons)
  280. {
  281. _DrawButton(_iBtnPressed, true);
  282. _FireSelectItem(btn);
  283. }
  284. }
  285. }
  286. var SHIF_SETTABINDEX = 0x01;
  287. var SHIF_RESETTABSTOP = 0x02;
  288. var SHIF_MOUSE = 0x04;
  289. function _SetHotItem(ibtn, dwFlags)
  290. {
  291. var div;
  292. if (ibtn == _iBtnHot)
  293. return;
  294. if (-1 != _iBtnHot && _iBtnHot != ibtn)
  295. {
  296. div = _rgdivButtons[_iBtnHot];
  297. if (_iBtnHot == _iBtnPressed)
  298. _DrawButtonFrame(div, 'pushed');
  299. else
  300. _DrawButtonFrame(div, 'normal');
  301. }
  302. if (-1 != ibtn)
  303. {
  304. div = _rgdivButtons[ibtn];
  305. if ( !(dwFlags & SHIF_MOUSE) || ibtn != _iBtnPressed)
  306. _DrawButtonFrame(div, 'hotitem');
  307. }
  308. _iBtnHot = ibtn;
  309. if (dwFlags & SHIF_SETTABINDEX)
  310. {
  311. if (dwFlags & SHIF_RESETTABSTOP)
  312. {
  313. _SetTabIndex(_iBtnPressed, false);
  314. }
  315. else
  316. {
  317. _SetTabIndex(ibtn, true);
  318. }
  319. }
  320. }
  321. function _FireSelectItem(btn)
  322. {
  323. var evt = createEventObject();
  324. evt.srcID = btn.id;
  325. onSelectItem.fire(evt);
  326. }
  327. function _FireExecItem(btn)
  328. {
  329. var evt = createEventObject();
  330. evt.srcID = btn.id;
  331. onExecItem.fire(evt);
  332. }
  333. function _FireComplete()
  334. {
  335. var evt = createEventObject();
  336. onComplete.fire(evt);
  337. }
  338. var LMOUSE_BUTTON = 1
  339. function _OnMouseDown()
  340. {
  341. var ibtn = _BtnFromElement(window.event.srcElement);
  342. var div;
  343. if (LMOUSE_BUTTON != window.event.button)
  344. return;
  345. _DrawButton(ibtn, true);
  346. _iBtnCapture = ibtn;
  347. div = _rgdivButtons[ibtn];
  348. div.setCapture(false);
  349. }
  350. function _OnMouseUp()
  351. {
  352. var ibtn = _BtnFromElement(window.event.srcElement);
  353. if (LMOUSE_BUTTON != window.event.button)
  354. return;
  355. if (-1 != _iBtnCapture)
  356. {
  357. var div = _rgdivButtons[_iBtnCapture];
  358. div.releaseCapture();
  359. if (_iBtnCapture != ibtn)
  360. _DrawButton(_iBtnCapture, (_iBtnPressed == _iBtnCapture));
  361. if (-1 != ibtn && ibtn == _iBtnCapture)
  362. _PushButton(ibtn, PBF_SETFOCUS | PBF_MOUSE);
  363. _iBtnCapture = -1;
  364. }
  365. }
  366. function _OnMouseOver()
  367. {
  368. var ibtnTo = _BtnFromElement(window.event.toElement);
  369. var ibtnFrom = _BtnFromElement(window.event.fromElement);
  370. if (-1 != _iBtnCapture)
  371. {
  372. if (ibtnTo == _iBtnCapture && ibtnFrom != _iBtnCapture)
  373. {
  374. _DrawButton(_iBtnCapture, true);
  375. }
  376. }
  377. else
  378. {
  379. _SetHotItem(ibtnTo, SHIF_MOUSE);
  380. }
  381. }
  382. function _OnMouseOut()
  383. {
  384. var event = window.event;
  385. var ibtnTo = _BtnFromElement(event.toElement);
  386. var ibtnFrom = _BtnFromElement(event.fromElement);
  387. if (ibtnTo != ibtnFrom)
  388. {
  389. _SetHotItem(-1, SHIF_MOUSE);
  390. if (ibtnFrom == _iBtnCapture && _iBtnCapture != _iBtnPressed)
  391. _DrawButton(_iBtnCapture, false);
  392. }
  393. }
  394. var CYCLE_PUSHED = 1;
  395. var CYCLE_HOT = 2;
  396. function _CycleButton(bDown, ibtnStart, cycle)
  397. {
  398. var ibtn = ibtnStart;
  399. var n = bDown ? 1 : -1;
  400. var btn;
  401. var cbtns = 0;
  402. while (true)
  403. {
  404. if (++cbtns > _cButtons)
  405. break; 
  406. if (bDown)
  407. ibtn = (ibtn + 1) % _cButtons;
  408. else
  409. ibtn = ((ibtn - 1) + _cButtons) % _cButtons;
  410. btn = _rgbtn[ibtn];
  411. if (CYCLE_PUSHED == cycle)
  412. {
  413. if (ibtn == _iBtnPressed || btn._bExecButton || btn._bHidden)
  414. continue; 
  415. else
  416. break;
  417. }
  418. else 
  419. {
  420. if (btn._bHidden)
  421. continue; 
  422. else
  423. break;
  424. }
  425. }
  426. return ibtn;
  427. }
  428. function _CycleHotItem(bDown)
  429. {
  430. _SetHotItem(_CycleButton(bDown, _iBtnHot, CYCLE_HOT), SHIF_SETTABINDEX);
  431. }
  432. function _CyclePushedButton(bDown)
  433. {
  434. _PushButton(_CycleButton(bDown, _iBtnPressed, CYCLE_PUSHED), 0);
  435. }
  436. function SetExecButton(idBtn, bVal)
  437. {
  438. var ibtn = _BtnFromID(idBtn);
  439. if (-1 != ibtn)
  440. {
  441. _rgbtn[ibtn]._bExecButton = bVal;
  442. }
  443. }
  444. function ShowButton(idBtn, bShow)
  445. {
  446. var ibtn = _BtnFromID(idBtn);
  447. if (-1 != ibtn)
  448. {
  449. var btn = _rgbtn[ibtn];
  450. if (btn)
  451. {
  452. var idBtnUnique = btn._idBtn;
  453. var elemBtn = element.all[idBtnUnique];
  454. if (bShow)
  455. {
  456. elemBtn.style.display = 'block';
  457. element.all[btn._idBR].style.display = 'block';
  458. }
  459. else
  460. {
  461. elemBtn.style.display = 'none';
  462. element.all[btn._idBR].style.display = 'none';
  463. }
  464. btn._bHidden = !bShow;
  465. }
  466. }
  467. }
  468. function focus()
  469. {
  470. var div = _rgdivButtons[_iBtnTabIndex];
  471. if (div)
  472. div.focus();
  473. }
  474. function blur()
  475. {
  476. var div = _rgdivButtons[_iBtnTabIndex];
  477. if (div)
  478. div.blur();
  479. }
  480. var KC_LEFT = 37;
  481. var KC_UP = 38;
  482. var KC_RIGHT = 39;
  483. var KC_DOWN = 40;
  484. var KC_SPACE = 32;
  485. var KC_RETURN = 13;
  486. var KC_TAB = 9;
  487. function _OnKeyDownDocument()
  488. {
  489. var evt = window.event;
  490. if (KC_TAB == evt.keyCode && evt.ctrlKey)
  491. {
  492. var bDir = evt.shiftKey ? false : true;
  493. _CyclePushedButton(bDir);
  494. evt.returnValue = false;
  495. }
  496. }
  497. function _OnKeyDownDiv()
  498. {
  499. var keyCode = window.event.keyCode;
  500. if (KC_UP == keyCode || KC_LEFT == keyCode)
  501. {
  502. _CycleHotItem(false);
  503. window.event.returnValue = false;
  504. }
  505. else if (KC_DOWN == keyCode || KC_RIGHT == keyCode)
  506. {
  507. _CycleHotItem(true);
  508. window.event.returnValue = false;
  509. }
  510. else if (KC_SPACE == keyCode || KC_RETURN == keyCode)
  511. {
  512. _PushButton(_iBtnHot, PBF_SETFOCUS);
  513. }
  514. }
  515. function _OnBlurDiv()
  516. {
  517. if (false == _bInternalFocusChange && true == _bHasFocus)
  518. {
  519. _bHasFocus = false;
  520. _SetHotItem(-1, SHIF_SETTABINDEX | SHIF_RESETTABSTOP);
  521. }
  522. }
  523. function _OnFocusDiv()
  524. {
  525. if (false == _bInternalFocusChange && false == _bHasFocus && 
  526. "complete" == window.document.readyState)
  527. {
  528. _bHasFocus = true;
  529. _CycleHotItem(true);
  530. }
  531. _bInternalFocusChange = false; 
  532. }
  533. function _OnError(szMsg, szUrl, iLine)
  534. {
  535. alert("An unexpected error occurred.\n\n" + szMsg + "\n" + szUrl + "\nLine: " + iLine);
  536. return true; 
  537. }
  538. function _CancelDragStart()
  539. {
  540. window.event.returnValue = false;
  541. }
  542. </SCRIPT><PROPERTY name="currentButton" get=get_button put=put_button /></PUBLIC:HTC>