source: trunk/admin/inc/FCKeditor/editor/_source/classes/fckicon.js@ 2

Last change on this file since 2 was 2, checked in by root, 15 years ago

importo il progetto

File size: 2.8 KB
Line 
1/*
2 * FCKeditor - The text editor for internet
3 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
4 *
5 * Licensed under the terms of the GNU Lesser General Public License:
6 * http://www.opensource.org/licenses/lgpl-license.php
7 *
8 * For further information visit:
9 * http://www.fckeditor.net/
10 *
11 * "Support Open Source software. What about a donation today?"
12 *
13 * File Name: fckicon.js
14 * FCKIcon Class: renders an icon from a single image, a strip or even a
15 * spacer.
16 *
17 * File Authors:
18 * Frederico Caldeira Knabben (fredck@fckeditor.net)
19 */
20
21var FCKIcon = function( iconPathOrStripInfoArray )
22{
23 var sTypeOf = iconPathOrStripInfoArray ? typeof( iconPathOrStripInfoArray ) : 'undefined' ;
24 switch ( sTypeOf )
25 {
26 case 'number' :
27 this.Path = FCKConfig.SkinPath + 'fck_strip.gif' ;
28 this.Size = 16 ;
29 this.Position = iconPathOrStripInfoArray ;
30 break ;
31
32 case 'undefined' :
33 this.Path = FCK_SPACER_PATH ;
34 break ;
35
36 case 'string' :
37 this.Path = iconPathOrStripInfoArray ;
38 break ;
39
40 default :
41 // It is an array in the format [ StripFilePath, IconSize, IconPosition ]
42 this.Path = iconPathOrStripInfoArray[0] ;
43 this.Size = iconPathOrStripInfoArray[1] ;
44 this.Position = iconPathOrStripInfoArray[2] ;
45 }
46}
47
48FCKIcon.prototype.CreateIconElement = function( document )
49{
50 var eIcon ;
51
52 if ( this.Position ) // It is using an icons strip image.
53 {
54 var sPos = '-' + ( ( this.Position - 1 ) * this.Size ) + 'px' ;
55
56 if ( FCKBrowserInfo.IsIE )
57 {
58 // <div class="TB_Button_Image"><img src="strip.gif" style="top:-16px"></div>
59
60 eIcon = document.createElement( 'DIV' ) ;
61
62 var eIconImage = eIcon.appendChild( document.createElement( 'IMG' ) ) ;
63 eIconImage.src = this.Path ;
64 eIconImage.style.top = sPos ;
65 }
66 else
67 {
68 // <img class="TB_Button_Image" src="spacer.gif" style="background-position: 0px -16px;background-image: url(strip.gif);">
69
70 eIcon = document.createElement( 'IMG' ) ;
71 eIcon.src = FCK_SPACER_PATH ;
72 eIcon.style.backgroundPosition = '0px ' + sPos ;
73 eIcon.style.backgroundImage = 'url(' + this.Path + ')' ;
74 }
75 }
76 else // It is using a single icon image.
77 {
78 // This is not working well with IE. See notes bellow.
79 // <img class="TB_Button_Image" src="smiley.gif">
80// eIcon = document.createElement( 'IMG' ) ;
81// eIcon.src = this.Path ? this.Path : FCK_SPACER_PATH ;
82
83 // IE makes the button 1px higher if using the <img> directly, so we
84 // are changing to the <div> system to clip the image correctly.
85 eIcon = document.createElement( 'DIV' ) ;
86
87 var eIconImage = eIcon.appendChild( document.createElement( 'IMG' ) ) ;
88 eIconImage.src = this.Path ? this.Path : FCK_SPACER_PATH ;
89 }
90
91 eIcon.className = 'TB_Button_Image' ;
92
93 return eIcon ;
94}
Note: See TracBrowser for help on using the repository browser.