home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 January / 01_02.iso / software / netscape62win / browser.xpi / bin / chrome / comm.jar / content / editor / sb-FileWidgetFileHandler.js < prev    next >
Encoding:
JavaScript  |  1999-10-13  |  2.9 KB  |  79 lines

  1. /* 
  2.  * The contents of this file are subject to the Netscape Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/NPL/
  6.  *  
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  *  
  12.  * The Original Code is Mozilla Communicator client code, released
  13.  * March 31, 1998.
  14.  * 
  15.  * The Initial Developer of the Original Code is Netscape
  16.  * Communications Corporation. Portions created by Netscape are
  17.  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
  18.  * Rights Reserved.
  19.  * 
  20.  * Contributor(s): 
  21.  *    Ben Goodger
  22.  */
  23.  
  24. function EditorAutoInsertImage(url)
  25. {
  26.     var imageElement = top.editorShell.CreateElementWithDefaults("img");
  27.     // TODO: do some smartass string parsing to find relative file
  28.     //       location so we don't need this big chunky URLs.. 
  29.     //       must utilize document dirty flag.
  30.     imageElement.setAttribute("src",url);
  31.     // TODO: make this show the file name and size in bytes. 
  32.     var altString = url.substring(url.lastIndexOf("/")+1,url.length);
  33.     imageElement.setAttribute("alt",altString);
  34.     imageElement.setAttribute("border","0");
  35.     // TODO: collect width and height attributes and insert those
  36.     //       also.
  37.     // insert the image
  38.     try {
  39.       top.editorShell.InsertElementAtSelection(imageElement,true);
  40.     } catch (e) {
  41.       dump("Exception occured in InsertElementAtSelection\n");
  42.     }
  43. }
  44.  
  45. function EditorInsertBackgroundImage(url)
  46. {
  47.     
  48. }
  49.  
  50. function EditorInsertJSFile(url)
  51. {
  52.     var scriptElement = top.editorShell.CreateElementWithDefaults("script");
  53.     // TODO: do some smartass string parsing to find relative file
  54.     //       location so we don't need this big chunky URLs.. 
  55.     //       must utilize document dirty flag.
  56.     scriptElement.setAttribute("src",url);
  57.     scriptElement.setAttribute("language","JavaScript");    
  58.     try {
  59.       top.editorShell.InsertElementAtSelection(scriptElement,true);
  60.     } catch (e) {
  61.       dump("Exception occured in InsertElementAtSelection\n");
  62.     }
  63. }
  64.  
  65. function EditorInsertCSSFile(url)
  66. {
  67.     var cssElement = top.editorShell.CreateElementWithDefaults("link");
  68.     // TODO: do some smartass string parsing to find relative file
  69.     //       location so we don't need this big chunky URLs.. 
  70.     //       must utilize document dirty flag.
  71.     cssElement.setAttribute("href",url);
  72.     cssElement.setAttribute("type","text/css");    
  73.     cssElement.setAttribute("rel","stylesheet");    
  74.     try {
  75.       top.editorShell.InsertElementAtSelection(cssElement,true);
  76.     } catch (e) {
  77.       dump("Exception occured in InsertElementAtSelection\n");
  78.     }
  79. }