[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/public_html/fckeditor/editor/_source/classes/ -> fckmenublock.js (source)

   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: fckmenublock.js
  14   *     Renders a list of menu items.
  15   * 
  16   * File Authors:
  17   *         Frederico Caldeira Knabben (fredck@fckeditor.net)
  18   */
  19  
  20  
  21  var FCKMenuBlock = function()
  22  {
  23      this._Items    = new Array() ;
  24  }
  25  
  26  
  27  FCKMenuBlock.prototype.AddItem = function( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled )
  28  {
  29      var oItem = new FCKMenuItem( this, name, label, iconPathOrStripInfoArrayOrIndex, isDisabled ) ;
  30      
  31      oItem.OnClick        = FCKTools.CreateEventListener( FCKMenuBlock_Item_OnClick, this ) ;
  32      oItem.OnActivate    = FCKTools.CreateEventListener( FCKMenuBlock_Item_OnActivate, this ) ;
  33      
  34      this._Items.push( oItem ) ;
  35  
  36      return oItem ;
  37  }
  38  
  39  FCKMenuBlock.prototype.AddSeparator = function()
  40  {
  41      this._Items.push( new FCKMenuSeparator() ) ;
  42  }
  43  
  44  FCKMenuBlock.prototype.RemoveAllItems = function()
  45  {
  46      this._Items = new Array() ;
  47      
  48      var eItemsTable = this._ItemsTable ;
  49      if ( eItemsTable )
  50      {
  51          while ( eItemsTable.rows.length > 0 )
  52              eItemsTable.deleteRow( 0 ) ;
  53      }
  54  }
  55  
  56  FCKMenuBlock.prototype.Create = function( parentElement )
  57  {
  58      if ( !this._ItemsTable )
  59      {
  60          if ( FCK.IECleanup )
  61              FCK.IECleanup.AddItem( this, FCKMenuBlock_Cleanup ) ;
  62  
  63          this._Window = FCKTools.GetElementWindow( parentElement ) ;
  64  
  65          var oDoc = FCKTools.GetElementDocument( parentElement ) ;
  66  
  67          var eTable = parentElement.appendChild( oDoc.createElement( 'table' ) ) ;
  68          eTable.cellPadding = 0 ;
  69          eTable.cellSpacing = 0 ;
  70  
  71          FCKTools.DisableSelection( eTable ) ;
  72          
  73          var oMainElement = eTable.insertRow(-1).insertCell(-1) ;
  74          oMainElement.className = 'MN_Menu' ;
  75      
  76          var eItemsTable = this._ItemsTable = oMainElement.appendChild( oDoc.createElement( 'table' ) ) ;
  77          eItemsTable.cellPadding = 0 ;
  78          eItemsTable.cellSpacing = 0 ;        
  79      }
  80      
  81      for ( var i = 0 ; i < this._Items.length ; i++ )
  82          this._Items[i].Create( this._ItemsTable ) ;
  83  }
  84  
  85  /* Events */
  86  
  87  function FCKMenuBlock_Item_OnClick( clickedItem, menuBlock )
  88  {
  89      FCKTools.RunFunction( menuBlock.OnClick, menuBlock, [ clickedItem ] ) ;
  90  }
  91  
  92  function FCKMenuBlock_Item_OnActivate( menuBlock )
  93  {
  94      var oActiveItem = menuBlock._ActiveItem ;
  95      
  96      if ( oActiveItem && oActiveItem != this )
  97      {
  98          // Set the focus to this menu block window (to fire OnBlur on opened panels).
  99          if ( !FCKBrowserInfo.IsIE && oActiveItem.HasSubMenu && !this.HasSubMenu )
 100              menuBlock._Window.focus() ;
 101  
 102          oActiveItem.Deactivate() ;        
 103      }
 104  
 105      menuBlock._ActiveItem = this ;
 106  }
 107  
 108  function FCKMenuBlock_Cleanup()
 109  {
 110      this._Window = null ;
 111      this._ItemsTable = null ;
 112  }
 113  
 114  // ################# //
 115  
 116  var FCKMenuSeparator = function()
 117  {}
 118  
 119  FCKMenuSeparator.prototype.Create = function( parentTable )
 120  {
 121      var oDoc = FCKTools.GetElementDocument( parentTable ) ;
 122  
 123      var r = parentTable.insertRow(-1) ;
 124      
 125      var eCell = r.insertCell(-1) ;
 126      eCell.className = 'MN_Separator MN_Icon' ;
 127  
 128      eCell = r.insertCell(-1) ;
 129      eCell.className = 'MN_Separator' ;
 130      eCell.appendChild( oDoc.createElement( 'DIV' ) ).className = 'MN_Separator_Line' ;
 131  
 132      eCell = r.insertCell(-1) ;
 133      eCell.className = 'MN_Separator' ;
 134      eCell.appendChild( oDoc.createElement( 'DIV' ) ).className = 'MN_Separator_Line' ;
 135  }


Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics