home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 86 / PIWD86.iso / pc / contents / dreamweaver / software / dwmx2004.exe / Disk1 / data1.cab / Configuration_En / Commands / ImageOptions.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  2.9 KB  |  124 lines

  1. //
  2. // Copyright 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  3. // ----------------------------------------------------
  4. //
  5. // Accessibility.js
  6. //
  7. // This command adds 
  8. // 
  9. //
  10. // Version 1.0
  11. // Added functions...
  12. // ----------------------------------------------------
  13.  
  14.  
  15. var globalFormItem;
  16. var returnTag='';
  17. var helpDoc = MM.HELP_objImageAccessOptions;
  18.  
  19. function commandButtons() {
  20.    return new Array(MM.BTN_OK,         "setImageStr();window.close()",
  21.                     MM.BTN_Cancel,     "window.close()",
  22.                     MM.BTN_Help,       "displayHelp()"    );
  23.  
  24.  
  25. }
  26.  
  27. function isDOMRequired() { 
  28.     // Return false, indicating that this object is available in code view.
  29.     return false;
  30. }
  31.  
  32. function setFormItem(formItem) {
  33.     globalFormItem = formItem;
  34.     returnTag = globalFormItem;
  35. }
  36.  
  37. function setImageStr()
  38. {
  39.     var rtnStr='';
  40.  
  41.     rtnStr= globalFormItem;
  42.  
  43.  
  44. ////////////////////////////////////////////////////////////////
  45. // Attributes: Compose rtnStr with the attributes that have a value
  46. // Possible attributes are: alt and longdesc
  47.  
  48.  
  49. // if 'alt attribute' has a value, apply it to the initStr
  50.  
  51.     altIndexSelected = document.forms[0].alt.selectedIndex;
  52.     altText = document.forms[0].alt.editText;
  53.  
  54.     if( altText == null || altIndexSelected == 0){} 
  55.     else {
  56.         
  57.             var dom = dw.getDocumentDOM();
  58.         var encoding = "";
  59.         if( dom )
  60.           encoding = dom.getCharSet();
  61.         if (encoding.toLowerCase() == "iso-8859-1" ) 
  62.         {
  63.             altText = dwscripts_minEntityNameEncode(altText);
  64.             altText = entityNameEncode(altText);
  65.         }
  66.                 else
  67.                 {
  68.                        altText = dwscripts_minEntityNameEncode(altText);
  69.                 } 
  70.  
  71.         rtnStr= addAttribute("alt", altText, rtnStr);
  72.     }
  73.  
  74. // if 'longdesc attribute' has a value, apply it to the initStr
  75.  
  76.     longdescValue=document.forms[0].longdesc.value;
  77.  
  78.     if( (longdescValue == null) || (longdescValue == "") || (longdescValue == "http://") ){} 
  79.     else {
  80.         rtnStr= addAttribute("longdesc", longdescValue, rtnStr);
  81.     }
  82.  
  83.  
  84.     returnTag= rtnStr;
  85. }
  86.  
  87. function returnAccessibilityStr () {
  88.  
  89.     return returnTag;
  90. }
  91.  
  92. ///////////////////////////////////////////////////////////////
  93. // other functions
  94. //////////////////////////////////////////////////////////////
  95. function initUI(){
  96.   document.forms[0].alt.focus();
  97. }
  98.  
  99. function addAttribute(tagName, tagVal, initStr){
  100.  
  101.     arrayElem= initStr.split(">");
  102.     rtnStr= arrayElem[0] + " " + tagName + "=" + '\"' + tagVal + '\"' + ">" + arrayElem[1];
  103.     
  104.     return rtnStr;
  105. }
  106.  
  107.  
  108. function getImageSrc(tagStr){
  109.  
  110.     arrayElements= tagStr.split("src=\"");
  111.     arrayStrings=  arrayElements[1].split("\"");
  112.     src= arrayStrings[0];
  113.     return src;
  114. }
  115.  
  116. function browseForURL(){
  117.   var urlField = document.forms[0].browseBtn.value;
  118.   var url = dw.browseForFileURL('select');
  119.   if (url != ""){
  120.     document.longdesc.value = url;
  121.     document.longdesc.focus();
  122.   }
  123. }
  124.