2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
\r
3 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
\r
5 * == BEGIN LICENSE ==
\r
7 * Licensed under the terms of any of the following licenses at your
\r
10 * - GNU General Public License Version 2 or later (the "GPL")
\r
11 * http://www.gnu.org/licenses/gpl.html
\r
13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
\r
14 * http://www.gnu.org/licenses/lgpl.html
\r
16 * - Mozilla Public License Version 1.1 or later (the "MPL")
\r
17 * http://www.mozilla.org/MPL/MPL-1.1.html
\r
21 * FCKIcon Class: renders an icon from a single image, a strip or even a
\r
25 var FCKIcon = function( iconPathOrStripInfoArray )
\r
27 var sTypeOf = iconPathOrStripInfoArray ? typeof( iconPathOrStripInfoArray ) : 'undefined' ;
\r
31 this.Path = FCKConfig.SkinPath + 'fck_strip.gif' ;
\r
33 this.Position = iconPathOrStripInfoArray ;
\r
37 this.Path = FCK_SPACER_PATH ;
\r
41 this.Path = iconPathOrStripInfoArray ;
\r
45 // It is an array in the format [ StripFilePath, IconSize, IconPosition ]
\r
46 this.Path = iconPathOrStripInfoArray[0] ;
\r
47 this.Size = iconPathOrStripInfoArray[1] ;
\r
48 this.Position = iconPathOrStripInfoArray[2] ;
\r
52 FCKIcon.prototype.CreateIconElement = function( document )
\r
54 var eIcon, eIconImage ;
\r
56 if ( this.Position ) // It is using an icons strip image.
\r
58 var sPos = '-' + ( ( this.Position - 1 ) * this.Size ) + 'px' ;
\r
60 if ( FCKBrowserInfo.IsIE )
\r
62 // <div class="TB_Button_Image"><img src="strip.gif" style="top:-16px"></div>
\r
64 eIcon = document.createElement( 'DIV' ) ;
\r
66 eIconImage = eIcon.appendChild( document.createElement( 'IMG' ) ) ;
\r
67 eIconImage.src = this.Path ;
\r
68 eIconImage.style.top = sPos ;
\r
72 // <img class="TB_Button_Image" src="spacer.gif" style="background-position: 0px -16px;background-image: url(strip.gif);">
\r
74 eIcon = document.createElement( 'IMG' ) ;
\r
75 eIcon.src = FCK_SPACER_PATH ;
\r
76 eIcon.style.backgroundPosition = '0px ' + sPos ;
\r
77 eIcon.style.backgroundImage = 'url("' + this.Path + '")' ;
\r
80 else // It is using a single icon image.
\r
82 if ( FCKBrowserInfo.IsIE )
\r
84 // IE makes the button 1px higher if using the <img> directly, so we
\r
85 // are changing to the <div> system to clip the image correctly.
\r
86 eIcon = document.createElement( 'DIV' ) ;
\r
88 eIconImage = eIcon.appendChild( document.createElement( 'IMG' ) ) ;
\r
89 eIconImage.src = this.Path ? this.Path : FCK_SPACER_PATH ;
\r
93 // This is not working well with IE. See notes above.
\r
94 // <img class="TB_Button_Image" src="smiley.gif">
\r
95 eIcon = document.createElement( 'IMG' ) ;
\r
96 eIcon.src = this.Path ? this.Path : FCK_SPACER_PATH ;
\r
100 eIcon.className = 'TB_Button_Image' ;
\r