home *** CD-ROM | disk | FTP | other *** search
/ internet.au CDrom 42 / NETCD42.iso / web / w95 / dream2.exe / data1.cab / Program_Files / Configuration / Behaviors / Actions / Open Browser Window.js < prev    next >
Encoding:
JavaScript  |  1998-11-30  |  4.7 KB  |  140 lines

  1. // Copyright 1998 Macromedia, Inc. All rights reserved.
  2.  
  3. //*************** GLOBALS VARS *****************
  4.  
  5. //******************* BEHAVIOR FUNCTION **********************
  6.  
  7. //Opens a new browser windows, with a number of options.
  8. //Accepts the following arguments:
  9. //  theURL   - URL, often a filename, URL encoded. (ex: file.htm, http://www.x.com/y.htm)
  10. //  winName  - optional name for the window, used to access the window via javascript
  11. //  features - series of window options, none are required. Setting all of them gives:
  12. //                toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,
  13. //                resizable=yes,width=300,height=200
  14. //
  15. //Calls the window.open() method and passes it the desired features.
  16.  
  17. function MM_openBrWindow(theURL,winName,features) { //v2.0
  18.   window.open(theURL,winName,features);
  19. }
  20.  
  21.  
  22. //******************* API **********************
  23.  
  24.  
  25. //Checks to see to which tags or events this behavior applies.
  26. //This behavior can be used with any tag and any event.
  27.  
  28. function canAcceptBehavior(){
  29.   return true;
  30. }
  31.  
  32.  
  33.  
  34. //Returns a Javascript function to be inserted in HTML head with script tags.
  35.  
  36. function behaviorFunction(){
  37.   return "MM_openBrWindow";
  38. }
  39.  
  40.  
  41.  
  42. //Returns the MM_openBrWindow function call and arguments as
  43. //inputted by the user. The function call is inserted in the
  44. //HTML tag after the selected event
  45. //(<TAG...onEvent="functionCall(arg,arg,arg)">).
  46.  
  47. function applyBehavior() {
  48.   var i,theURL,theName,arrayIndex = 0;
  49.   var argArray = new Array; //use array to produce correct number of commas w/o spaces
  50.   var checkBoxNames = new Array("toolbar","location","status","menubar","scrollbars","resizable");
  51.  
  52.   for (i=0; i<checkBoxNames.length; i++) {
  53.     theCheckBox = eval("document.theForm." + checkBoxNames[i]);
  54.     if (theCheckBox.checked) argArray[arrayIndex++] = (checkBoxNames[i] + "=yes");
  55.   }
  56.   if (document.theForm.width.value)
  57.     argArray[arrayIndex++] = ("width=" + document.theForm.width.value);
  58.   if (document.theForm.height.value)
  59.     argArray[arrayIndex++] = ("height=" + document.theForm.height.value);
  60.   theURL = escape(document.theForm.URL.value);
  61.   theName = document.theForm.winName.value;
  62.   if (badChars(theName)) return MSG_BadChars;
  63.   else return "MM_openBrWindow('"+theURL+"','"+theName+"','"+argArray.join()+"')";
  64. }
  65.  
  66.  
  67.  
  68. //Returns a dummy function call to inform Dreamweaver the type of certain behavior
  69. //call arguments. This information is used by DW to fixup behavior args when the
  70. //document is moved or changed.
  71. //
  72. //It is passed an actual function call string generated by applyBehavior(), which
  73. //may have a variable list of arguments, and this should return a matching mask.
  74. //
  75. //The return values are:
  76. //  URL     : argument could be a file path, which DW will update during Save As...
  77. //  NS4.0ref: arg is an object ref that may be changed by Convert Tables to Layers
  78. //  IE4.0ref: arg is an object ref that may be changed by Convert Tables to Layers
  79. //  other...: argument is ignored
  80.  
  81. function identifyBehaviorArguments(fnCallStr) {
  82.   var argArray;
  83.  
  84.   argArray = extractArgs(fnCallStr);
  85.   if (argArray.length == 4) {
  86.     return "NAV,other,other";
  87.   } else {
  88.     return "";
  89.   }
  90. }
  91.  
  92.  
  93.  
  94. //Upon returning to the Behavior Inspector after applying a behavior,
  95. //inspectBehavior is called. It looks at the user's HTML document,
  96. //extracts the values from the behavior handler, and inserts them into
  97. //the form UI.
  98.  
  99. function inspectBehavior(enteredStr) {
  100.   var i;
  101.   var argArray = extractArgs(enteredStr);
  102.  
  103.   if (argArray.length == 4) {  //first arg is fn name, so ignore that
  104.     document.theForm.URL.value = unescape(argArray[1]);
  105.     document.theForm.winName.value = argArray[2];
  106.     var featuresStr = argArray[3];
  107.     var tokArray = getTokens(featuresStr, "=,");
  108.  
  109.     var checkBoxNames = new Array("toolbar","location","status","menubar","scrollbars","resizable");
  110.     for (i in checkBoxNames) {
  111.       if (featuresStr.indexOf(checkBoxNames[i]) != -1)
  112.         theCheckBox = eval("document.theForm." + checkBoxNames[i] + ".checked = true");
  113.     }
  114.     for (i=0; i < (tokArray.length-1); i++) {
  115.       if (tokArray[i] == "height") document.theForm.height.value = tokArray[i+1];
  116.       if (tokArray[i] == "width")  document.theForm.width.value = tokArray[i+1];
  117.     }
  118.   }
  119. }
  120.  
  121.  
  122.  
  123. //***************** LOCAL FUNCTIONS  ******************
  124.  
  125.  
  126. //Set the insertion point
  127.  
  128. function initializeUI(){
  129.   document.theForm.URL.focus(); //set focus on textbox
  130.   document.theForm.URL.select(); //set insertion point into textbox
  131. }
  132.  
  133.  
  134.  
  135. //**************** GENERIC FUNCTIONS ****************
  136.  
  137. //function extractArgs(upStr){
  138. //function badChars(theStr){
  139. //function browseFile(fieldToStoreURL){
  140.