home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / servis / ovladace / drivers / 850win2000.exe / tek850.chm / fh_dhtml.js < prev    next >
Encoding:
JavaScript  |  1999-12-09  |  8.3 KB  |  308 lines

  1. /* Copyright 1998 ForeFront Inc.  All rights reserved.
  2.  
  3.  
  4. This file contains all necessary JavaScript funtions to apply the following
  5. Dynamic HTML effects:
  6.  
  7.     Blend Transitions
  8.     Reveal Transitions
  9.     Application of Visual Filters
  10.     Application of Text Formatting
  11.     Cursor Changes
  12.     Toggle of Display and Visibility Attributes
  13.  
  14. This file is designed to be used with ForeHTML Pro 3.5. */
  15.  
  16.  
  17. /////////////////////////////////////////////////////////////////////////////////////////////
  18.  
  19.  
  20. /********************************************************************************************
  21.  
  22.     ChangeTextFormat (element id, new style values)
  23.  
  24.         - This function can alter the following style attributes:
  25.             fontSize, fontFamily, fontWeight, fontVariant, fontStyle, textDecoration, & verticalAlign
  26.  
  27.         - format of style string:
  28.             fontSize:#;fontFamily:$...
  29.  
  30.         - to leave a default value do not add the attribute to the list
  31.         - to clear an attribute specify a * for example: textDecoration:*
  32.  
  33. *********************************************************************************************/
  34.  
  35.  
  36. function ChangeTextFormat (eID, newStyle) {
  37.  
  38.     var        attr;
  39.     var        value;
  40.     var        index;
  41.  
  42.     if (! FullDHTML ())
  43.         return;
  44.  
  45.     index = newStyle.indexOf (';');
  46.     while (index != -1) {
  47.         attr = newStyle.substring (0, index);    // this is the actual attribute
  48.         newStyle = newStyle.substring (index + 1, newStyle.length);    // chop off the current attribute
  49.  
  50.         index = attr.indexOf (':');
  51.         if (index != -1) {     // we have a valid attribute
  52.             value = attr.substring (index + 1, attr.length);
  53.             attr = attr.substring (0, index);
  54.  
  55.             if (value == '*')
  56.                 value = "";
  57.  
  58.             eID.style[attr] = value;
  59.  
  60.             // go through sub P's, DIV's and SPANS's and set styles there too, they override
  61.             for (i = 0; i < eID.all.tags("p").length; i++) {    
  62.                 sub = eID.all.tags("p")[i];
  63.                 sub.style[attr] = value;
  64.                 }
  65.  
  66.             for (i = 0; i < eID.all.tags("div").length; i++) {    
  67.                 sub = eID.all.tags("div")[i];
  68.                 sub.style[attr] = value;
  69.                 }
  70.  
  71.             for (i = 0; i < eID.all.tags("span").length; i++) {    
  72.                 sub = eID.all.tags("span")[i];
  73.                 sub.style[attr] = value;
  74.                 }
  75.             }
  76.  
  77.         if (newStyle != "")    
  78.             index = newStyle.indexOf (';');
  79.         else
  80.             index = -1;
  81.         }
  82.  
  83.  
  84.     if (newStyle != "") {    // we still have one attr left
  85.         attr = newStyle;
  86.         index = attr.indexOf (':');
  87.         if (index != -1) {     // we have a valid attribute
  88.             value = attr.substring (index + 1, attr.length);
  89.             attr = attr.substring (0, index);
  90.  
  91.             if (value == '*')
  92.                 value = "";
  93.  
  94.             eID.style[attr] = value;
  95.  
  96.             // go through sub P's, DIV's and SPANS's and set styles there too, they override
  97.             for (i = 0; i < eID.all.tags("p").length; i++) {    
  98.                 sub = eID.all.tags("p")[i];
  99.                 sub.style[attr] = value;
  100.                 }
  101.  
  102.             for (i = 0; i < eID.all.tags("div").length; i++) {    
  103.                 sub = eID.all.tags("div")[i];
  104.                 sub.style[attr] = value;
  105.                 }
  106.  
  107.             for (i = 0; i < eID.all.tags("span").length; i++) {    
  108.                 sub = eID.all.tags("span")[i];
  109.                 sub.style[attr] = value;
  110.                 }
  111.             }
  112.         }
  113.     }
  114.  
  115.  
  116.  
  117. /********************************************************************************************
  118.  
  119.     PlayTransition (element ID)
  120.  
  121.         - this function will play an assigned reveal or blend transition
  122.         - the transition must be defined in the style of the object
  123.         - the duration and type (if reveal) must also be defined
  124.         - if the transition has already been played, it will not be played again
  125.         - you must also set in the style: vivibility:hidden; width:auto
  126.  
  127. *********************************************************************************************/
  128.  
  129. function PlayTransition (eID) {
  130.  
  131.     if (! FullDHTML ())
  132.         return;
  133.  
  134.     if (eID.filters.revealTrans) {
  135.         if (eID.filters.revealTrans.status == 0) {
  136.             eID.filters.revealTrans.apply();
  137.             eID.style.visibility = ""; 
  138.             eID.filters.revealTrans.play();  
  139.             }
  140.         }
  141.     else if (eID.filters.blendTrans) {
  142.         if (eID.filters.blendTrans.status == 0) {
  143.             eID.filters.blendTrans.apply();
  144.             eID.style.visibility = ""; 
  145.             eID.filters.blendTrans.play();  
  146.             }
  147.         }
  148.     }
  149.  
  150.  
  151. /********************************************************************************************
  152.  
  153.     PlayAllTransitions ()
  154.  
  155.         - this function will be called duing onLoad, all DIV and SPAN objects will be checked
  156.             for playTransOnLoad = 1 attribute
  157.         - the transition must be defined in the style of the object
  158.         - the duration and type (if reveal) must also be defined
  159.         - if the transition has already been played, it will not be played again
  160.         - you must also set in the style: vivibility:hidden; width:auto
  161.  
  162. *********************************************************************************************/
  163.  
  164. function PlayAllTransitions () {
  165.  
  166.     if (! FullDHTML ())
  167.         return;
  168.  
  169.     var        eID;
  170.  
  171.     for (i = 0; i < document.all.tags("div").length; i++) {
  172.         eID = document.all.tags("div")[i];
  173.         if (eID.getAttribute ("playTransOnLoad") == 1)
  174.             PlayTransition (eID);
  175.         }
  176.  
  177.     for (i = 0; i < document.all.tags("span").length; i++) {
  178.         eID = document.all.tags("span")[i];
  179.         if (eID.getAttribute ("playTransOnLoad") == 1)
  180.             PlayTransition (eID);
  181.         }
  182.  
  183.     for (i = 0; i < document.all.tags("img").length; i++) {
  184.         eID = document.all.tags("img")[i];
  185.         if (eID.getAttribute ("playTransOnLoad") == 1)
  186.             PlayTransition (eID);
  187.         }
  188.     }
  189.  
  190.  
  191. /********************************************************************************************
  192.  
  193.     ToggleDisplay (element ID)
  194.  
  195.         - this function will toggle the display attribute of an object
  196.         - when hidden, no space in the document will be reserved for this object
  197.  
  198. *********************************************************************************************/
  199.  
  200. function ToggleDisplay (eID) {
  201.  
  202.     if (! FullDHTML ())
  203.         return;
  204.  
  205.     if (eID.style.display == "none")
  206.         eID.style.display = "";
  207.     else
  208.         eID.style.display = "none";
  209.     }
  210.  
  211.  
  212. /********************************************************************************************
  213.  
  214.     ToggleVisibility (element ID)
  215.  
  216.         - this function will toggle the visibility attribute of an object
  217.         - when hidden, space in the document will be reserved for this object
  218.  
  219. *********************************************************************************************/
  220.  
  221. function ToggleVisibility (eID) {
  222.  
  223.     if (! FullDHTML ())
  224.         return;
  225.  
  226.     if (eID.style.visibility == "hidden")
  227.         eID.style.visibility = "visible";
  228.     else
  229.         eID.style.visibility = "hidden";
  230.     }
  231.  
  232.  
  233. /********************************************************************************************
  234.  
  235.     ChangeCursor (element ID, cursor type)
  236.  
  237.         - this function will change the cursor when over the current object
  238.         - to reset value, use cursor type 'auto'
  239.  
  240. *********************************************************************************************/
  241.  
  242. function ChangeCursor (eID, cursorType) {
  243.  
  244.     if (! FullDHTML ())
  245.         return;
  246.  
  247.     eID.style.cursor = cursorType;
  248.     }
  249.  
  250.  
  251. /********************************************************************************************
  252.  
  253.     ApplyFilter (element ID, filter string)
  254.  
  255.         - this function will apply a visible filter to the current object
  256.         - you may only apply one filter at a time
  257.         - to remove the filter set filter string to ""
  258.         - you must set style="width:auto"
  259.         - the syntax of the filter string is for example: ApplyFilter (eID, 'Glow(color=#FF0000,strength=2)')
  260.  
  261. *********************************************************************************************/
  262.  
  263. function ApplyFilter (eID, filterStr) {
  264.  
  265.     if (! FullDHTML ())
  266.         return;
  267.  
  268.     eID.style.filter = filterStr;
  269.     }
  270.  
  271.  
  272. /********************************************************************************************
  273.  
  274.     ChangeImage (element ID, image)
  275.  
  276.         - this function will toggle between two images
  277.         - the original image will be stored in a origImage attribute
  278.         - the secondary image will be stored in secImage attribute
  279.         - if image parameter is non-empty, the image will be set to that image
  280.  
  281. *********************************************************************************************/
  282.  
  283. function ChangeImage (eID, image) {
  284.  
  285.     if (! FullDHTML ())
  286.         return;
  287.  
  288.     var            orig;
  289.  
  290.     if (eID.imgArray == null) {
  291.         eID.imgArray = new Array (5);
  292.         eID.imgCt = 0;
  293.         }
  294.     
  295.     if (image == "" && eID.imgCt != 0) {
  296.         image = eID.imgArray[eID.imgCt];
  297.         eID.imgCt--;
  298.         eID.src = image;
  299.         }
  300.     else if (image != "") {
  301.         eID.imgCt++;
  302.         eID.imgArray[eID.imgCt] = eID.src;
  303.         eID.src = image;
  304.         }
  305.     }
  306.  
  307.  
  308.