Commit 2371d805d9ff211d1cf3e01899c031c1081af2dc
1 parent
8833aaa2
adding div switch js lib
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2156 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
120 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/js/divSwitch.js
0 → 100644
| 1 | +// function switchDiv() | ||
| 2 | +// this function takes the id of a div | ||
| 3 | +// and calls the other functions required | ||
| 4 | +// to show that div | ||
| 5 | +// | ||
| 6 | +function switchDiv(div_id) | ||
| 7 | +{ | ||
| 8 | + var style_sheet = getStyleObject(div_id); | ||
| 9 | + if (style_sheet) | ||
| 10 | + { | ||
| 11 | + hideAll(); | ||
| 12 | + changeObjectVisibility(div_id,"visible"); | ||
| 13 | + } | ||
| 14 | + else | ||
| 15 | + { | ||
| 16 | + alert("sorry, this only works in browsers that do Dynamic HTML (" + div_id + ")"); | ||
| 17 | + } | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +// function hideAll() | ||
| 21 | +// hides a bunch of divs | ||
| 22 | +// | ||
| 23 | + | ||
| 24 | +function hideAll() | ||
| 25 | +{ | ||
| 26 | + changeObjectVisibility("documentData","hidden"); | ||
| 27 | + changeObjectVisibility("genericMetaData","hidden"); | ||
| 28 | + changeObjectVisibility("typeSpecificMetaData","hidden"); | ||
| 29 | + changeObjectVisibility("archiveSettings","hidden"); | ||
| 30 | + changeObjectVisibility("documentRouting","hidden"); | ||
| 31 | + changeObjectVisibility("linkedDocuments","hidden"); | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +// function getStyleObject(string) -> returns style object | ||
| 35 | +// given a string containing the id of an object | ||
| 36 | +// the function returns the stylesheet of that object | ||
| 37 | +// or false if it can't find a stylesheet. Handles | ||
| 38 | +// cross-browser compatibility issues. | ||
| 39 | +// | ||
| 40 | +function getStyleObject(objectId) { | ||
| 41 | + // checkW3C DOM, then MSIE 4, then NN 4. | ||
| 42 | + // | ||
| 43 | + if(document.getElementById && document.getElementById(objectId)) { | ||
| 44 | + return document.getElementById(objectId).style; | ||
| 45 | + } | ||
| 46 | + else if (document.all && document.all(objectId)) { | ||
| 47 | + return document.all(objectId).style; | ||
| 48 | + } | ||
| 49 | + else if (document.layers && document.layers[objectId]) { | ||
| 50 | + return document.layers[objectId]; | ||
| 51 | + } else { | ||
| 52 | + return false; | ||
| 53 | + } | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +function changeObjectVisibility(objectId, newVisibility) { | ||
| 57 | + // first get a reference to the cross-browser style object | ||
| 58 | + // and make sure the object exists | ||
| 59 | + var styleObject = getStyleObject(objectId); | ||
| 60 | + if(styleObject) { | ||
| 61 | + styleObject.visibility = newVisibility; | ||
| 62 | + return true; | ||
| 63 | + } else { | ||
| 64 | + // we couldn't find the object, so we can't change its visibility | ||
| 65 | + return false; | ||
| 66 | + } | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | +// Copyright © 2000 by Apple Computer, Inc., All Rights Reserved. | ||
| 70 | +// | ||
| 71 | +// You may incorporate this Apple sample code into your own code | ||
| 72 | +// without restriction. This Apple sample code has been provided "AS IS" | ||
| 73 | +// and the responsibility for its operation is yours. You may redistribute | ||
| 74 | +// this code, but you are not permitted to redistribute it as | ||
| 75 | +// "Apple sample code" after having made changes. | ||
| 76 | +// | ||
| 77 | +// ************************ | ||
| 78 | +// layer utility routines * | ||
| 79 | +// ************************ | ||
| 80 | + | ||
| 81 | +function getStyleObject(objectId) { | ||
| 82 | + // cross-browser function to get an object's style object given its id | ||
| 83 | + if(document.getElementById && document.getElementById(objectId)) { | ||
| 84 | + // W3C DOM | ||
| 85 | + return document.getElementById(objectId).style; | ||
| 86 | + } else if (document.all && document.all(objectId)) { | ||
| 87 | + // MSIE 4 DOM | ||
| 88 | + return document.all(objectId).style; | ||
| 89 | + } else if (document.layers && document.layers[objectId]) { | ||
| 90 | + // NN 4 DOM.. note: this won't find nested layers | ||
| 91 | + return document.layers[objectId]; | ||
| 92 | + } else { | ||
| 93 | + return false; | ||
| 94 | + } | ||
| 95 | +} // getStyleObject | ||
| 96 | + | ||
| 97 | +function changeObjectVisibility(objectId, newVisibility) { | ||
| 98 | + // get a reference to the cross-browser style object and make sure the object exists | ||
| 99 | + var styleObject = getStyleObject(objectId); | ||
| 100 | + if(styleObject) { | ||
| 101 | + styleObject.visibility = newVisibility; | ||
| 102 | + return true; | ||
| 103 | + } else { | ||
| 104 | + // we couldn't find the object, so we can't change its visibility | ||
| 105 | + return false; | ||
| 106 | + } | ||
| 107 | +} // changeObjectVisibility | ||
| 108 | + | ||
| 109 | +function moveObject(objectId, newXCoordinate, newYCoordinate) { | ||
| 110 | + // get a reference to the cross-browser style object and make sure the object exists | ||
| 111 | + var styleObject = getStyleObject(objectId); | ||
| 112 | + if(styleObject) { | ||
| 113 | + styleObject.left = newXCoordinate; | ||
| 114 | + styleObject.top = newYCoordinate; | ||
| 115 | + return true; | ||
| 116 | + } else { | ||
| 117 | + // we couldn't find the object, so we can't very well move it | ||
| 118 | + return false; | ||
| 119 | + } | ||
| 120 | +} // moveObject | ||
| 0 | \ No newline at end of file | 121 | \ No newline at end of file |