org.symbian.tools.wrttools.doc.WebDeveloper/html/js/gui.js
changeset 229 716254ccbcc0
equal deleted inserted replaced
228:913c9751c067 229:716254ccbcc0
       
     1 var TOC_CLASS_ACTIVE = "on3";
       
     2 var TOC_CLASS_COLLAPSED = "toc-controller-closed";
       
     3 var TOC_CLASS_EXPANDED = "toc-controller-open";
       
     4 var TOC_CLASS_CONTROL = "toc-controller";
       
     5 var TOC_CLASS_SPACE = "toc-space";
       
     6 var TOC_DISPLAY_COLLAPSED = "none";
       
     7 var TOC_DISPLAY_EXPANDED = "block";
       
     8 
       
     9 /**
       
    10  * Check required support for TOC.
       
    11  */
       
    12 function support() {
       
    13 	if (document.getElementsByTagName && document.styleSheets) {
       
    14 		tocSupported = true;
       
    15 	} else {
       
    16 		//alert("Dynamic TOC not available.");		
       
    17 	}
       
    18 }
       
    19 
       
    20 /** Flag if dynamic TOC is supported */
       
    21 var tocSupported = false;
       
    22 support();
       
    23 /** Current active TOC node. */
       
    24 var currentHighlight = null;
       
    25 /** Process start time stamp. */
       
    26 var processStart;
       
    27 /** Process end time stamp. */
       
    28 var processEnd;
       
    29 /** Last process duration. */
       
    30 var processDuration
       
    31 
       
    32 
       
    33 /**
       
    34  * Hightlight TOC node.
       
    35  *
       
    36  * @param node TOC node to highlight
       
    37  */
       
    38 function highlightTocItem(node) {
       
    39 	if (tocSupported) {
       
    40 		// turn old off
       
    41 		if (currentHighlight === null || !isClass(currentHighlight, TOC_CLASS_ACTIVE)) {
       
    42 			// turn all off
       
    43 			var li = getFirstElementByClassName(node.ownerDocument, TOC_CLASS_ACTIVE, TOC_ITEM);
       
    44 			if (li !== null) {
       
    45 			  removeClass(li, TOC_CLASS_ACTIVE);
       
    46 			}
       
    47 		} else {
       
    48 			removeClass(currentHighlight, TOC_CLASS_ACTIVE);
       
    49 		}
       
    50 		// turn this on
       
    51 		addClass(node.parentNode, TOC_CLASS_ACTIVE);
       
    52 		currentHighlight = node.parentNode;
       
    53 	}
       
    54 }
       
    55 
       
    56 /**
       
    57  * Toggle child node display.
       
    58  *
       
    59  * @param n Target node of the event.
       
    60  */
       
    61 function toggle(n) {
       
    62 	if (isClass(n, TOC_CLASS_EXPANDED)) {
       
    63 		tocNodeCollapse(n);
       
    64 	} else {
       
    65 	  tocNodeExpand(n);
       
    66 	}
       
    67 }
       
    68 
       
    69 /**
       
    70  * Expand TOC node.
       
    71  *
       
    72  * @param n TOC node
       
    73  */
       
    74 function tocNodeExpand(n, collapseOverride) {
       
    75   if (collapseOverride === undefined) {
       
    76     collapseOverride = true;
       
    77   }
       
    78   n.firstChild.data = TOC_SYMBOL_EXPANDED;
       
    79   switchClass(n, TOC_CLASS_EXPANDED, TOC_CLASS_COLLAPSED);
       
    80   var ul = getNextSiblingByTagName(n.nextSibling, TOC_ELEMENT_BLOCK);
       
    81   if (ul !== null) {
       
    82     if (childCollapse && collapseOverride) {
       
    83       var li = getChildElementsByTagName(ul, "li");
       
    84       for (var i = 0; i < li.length; i++) {
       
    85         collapseChildBlocks(li[i]);
       
    86       }
       
    87     }
       
    88     ul.style.display = TOC_DISPLAY_EXPANDED;
       
    89     //switchClass(ul, "toc-expanded", "toc-collapsed");
       
    90   }
       
    91 }
       
    92 
       
    93 /**
       
    94  * Collapse TOC node.
       
    95  *
       
    96  * @param n TOC node
       
    97  */
       
    98 function tocNodeCollapse(n) {
       
    99   n.firstChild.data = TOC_SYMBOL_COLLAPSED;
       
   100   switchClass(n, TOC_CLASS_COLLAPSED, TOC_CLASS_EXPANDED);
       
   101   var ul = getNextSiblingByTagName(n.nextSibling, TOC_ELEMENT_BLOCK);
       
   102   if (ul !== null) {
       
   103     ul.style.display = TOC_DISPLAY_COLLAPSED;
       
   104     //switchClass(ul, "toc-collapsed", "toc-expanded");
       
   105   }
       
   106 }
       
   107 
       
   108 /**
       
   109  * Signal start of processing.
       
   110  *
       
   111  * @param message Message description of the process start
       
   112  */
       
   113 function startProcess(message) {
       
   114     processStart = new Date();
       
   115     window.status = (message === undefined ? "" : message);    
       
   116 }
       
   117 
       
   118 /**
       
   119  * Signal end of processing.
       
   120  *
       
   121  * @param message Message description of the process result
       
   122  */
       
   123 function endProcess(message) {
       
   124     processEnd = new Date();
       
   125     window.status = (message === undefined ? "" : message);
       
   126     processDuration = processEnd - processStart;
       
   127 }
       
   128