[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/include/fckeditor/editor/_source/internals/ -> fckcontextmenu.js (source)

   1  /*
   2   * FCKeditor - The text editor for internet
   3   * Copyright (C) 2003-2005 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: fckcontextmenu.js
  14   *     Defines the FCKContextMenu object that is responsible for all
  15   *     Context Menu operations.
  16   * 
  17   * File Authors:
  18   *         Frederico Caldeira Knabben (fredck@fckeditor.net)
  19   */
  20  
  21  var FCKContextMenu = new Object() ;
  22  
  23  FCKContextMenu._Panel = new FCKPanel( FCKBrowserInfo.IsIE ? window : window.parent ) ;
  24  FCKContextMenu._Panel.PanelDiv.className = 'CM_ContextMenu' ;
  25  FCKContextMenu._Panel.AppendStyleSheet( FCKConfig.SkinPath + 'fck_contextmenu.css' ) ;
  26  FCKContextMenu._Panel.IsContextMenu = true ;
  27  
  28  FCKContextMenu._Document = FCKContextMenu._Panel.Document ;
  29  
  30  // This property is internally used to indicate that the context menu has been created.
  31  FCKContextMenu._IsLoaded = false ;
  32  
  33  FCKContextMenu.Show = function( x, y )
  34  {
  35      if ( !this._IsLoaded )
  36          this.Reload() ;
  37      
  38      this.RefreshState() ;
  39  
  40      // If not IE, x and y are relative to the editing area, so we must "fix" it.
  41      if ( !FCKBrowserInfo.IsIE )
  42      {
  43          var oCoordsA = FCKTools.GetElementPosition( FCK.EditorWindow.frameElement, this._Panel._Window ) ;
  44          x += oCoordsA.X ;
  45          y += oCoordsA.Y ;
  46      }
  47  
  48      this._Panel.Show( x, y ) ;
  49  }
  50  
  51  FCKContextMenu.Hide = function()
  52  {
  53      this._Panel.Hide() ;
  54  }
  55  
  56  // This method creates the context menu inside a DIV tag. Take a look at the end of this file for a sample output.
  57  FCKContextMenu.Reload = function()
  58  {
  59      // Create the Main DIV that holds the Context Menu.
  60  //    this._Div = this._Document.createElement( 'DIV' ) ;
  61  //    this._Div.className            = 'CM_ContextMenu' ;
  62  //    this._Div.style.position    = 'absolute' ;
  63  //    this._Div.style.visibility    = 'hidden' ;
  64  //    this._Document.body.appendChild( this._Div );
  65  
  66      // Create the main table for the menu items.
  67      var oTable = this._Document.createElement( 'TABLE' ) ;
  68      oTable.cellSpacing = 0 ;
  69      oTable.cellPadding = 0 ;
  70      this._Panel.PanelDiv.appendChild( oTable ) ;
  71  //    this._Div.appendChild( oTable ) ;
  72  
  73      // Load all configured groups.
  74      this.Groups = new Object() ;
  75      
  76      for ( var i = 0 ; i < FCKConfig.ContextMenu.length ; i++ )
  77      {
  78          var sGroup = FCKConfig.ContextMenu[i] ;
  79          this.Groups[ sGroup ] = this._GetGroup( sGroup ) ;
  80          this.Groups[ sGroup ].CreateTableRows( oTable ) ;
  81      }
  82  
  83      FCKTools.DisableSelection( this._Panel.Document.body ) ;
  84  
  85      this._IsLoaded = true ;
  86  }
  87  
  88  FCKContextMenu._GetGroup = function( groupName )
  89  {
  90      var oGroup ;
  91  
  92      switch ( groupName )
  93      {
  94          case 'Generic' :
  95              // Generic items that are always available.
  96              oGroup = new FCKContextMenuGroup() ;
  97  
  98              oGroup.Add( new FCKContextMenuItem( this, 'Cut'        , FCKLang.Cut    , true ) ) ;
  99              oGroup.Add( new FCKContextMenuItem( this, 'Copy'    , FCKLang.Copy    , true ) ) ;
 100              oGroup.Add( new FCKContextMenuItem( this, 'Paste'    , FCKLang.Paste    , true ) ) ;
 101  
 102              break ;
 103  
 104          case 'Link' :
 105              oGroup = new FCKContextMenuGroup() ;
 106  
 107              oGroup.Add( new FCKContextMenuSeparator() ) ;
 108              oGroup.Add( new FCKContextMenuItem( this, 'Link'    , FCKLang.EditLink    , true ) ) ;
 109              oGroup.Add( new FCKContextMenuItem( this, 'Unlink'    , FCKLang.RemoveLink, true ) ) ;
 110  
 111              break ;
 112  
 113          case 'TableCell' :
 114              oGroup = new FCKContextMenuGroup() ;
 115  
 116              oGroup.Add( new FCKContextMenuSeparator() ) ;
 117              oGroup.Add( new FCKContextMenuItem( this, 'TableInsertRow'        , FCKLang.InsertRow, true ) ) ;
 118              oGroup.Add( new FCKContextMenuItem( this, 'TableDeleteRows'        , FCKLang.DeleteRows, true ) ) ;
 119              oGroup.Add( new FCKContextMenuSeparator() ) ;
 120              oGroup.Add( new FCKContextMenuItem( this, 'TableInsertColumn'    , FCKLang.InsertColumn, true ) ) ;
 121              oGroup.Add( new FCKContextMenuItem( this, 'TableDeleteColumns'    , FCKLang.DeleteColumns, true ) ) ;
 122              oGroup.Add( new FCKContextMenuSeparator() ) ;
 123              oGroup.Add( new FCKContextMenuItem( this, 'TableInsertCell'        , FCKLang.InsertCell, true ) ) ;
 124              oGroup.Add( new FCKContextMenuItem( this, 'TableDeleteCells'    , FCKLang.DeleteCells, true ) ) ;
 125              oGroup.Add( new FCKContextMenuItem( this, 'TableMergeCells'        , FCKLang.MergeCells, true ) ) ;
 126              oGroup.Add( new FCKContextMenuItem( this, 'TableSplitCell'        , FCKLang.SplitCell, true ) ) ;
 127              oGroup.Add( new FCKContextMenuSeparator() ) ;
 128              oGroup.Add( new FCKContextMenuItem( this, 'TableDelete'            , FCKLang.TableDelete, false ) ) ;
 129              oGroup.Add( new FCKContextMenuSeparator() ) ;
 130              oGroup.Add( new FCKContextMenuItem( this, 'TableCellProp'        , FCKLang.CellProperties, true ) ) ;
 131              oGroup.Add( new FCKContextMenuItem( this, 'TableProp'            , FCKLang.TableProperties, true ) ) ;
 132  
 133              break ;
 134  
 135          case 'Table' :
 136              oGroup = new FCKContextMenuGroup() ;
 137              
 138              oGroup.Add( new FCKContextMenuSeparator() ) ;
 139              oGroup.Add( new FCKContextMenuItem( this, 'TableDelete'    , FCKLang.TableDelete, false ) ) ;
 140              oGroup.Add( new FCKContextMenuSeparator() ) ;
 141              oGroup.Add( new FCKContextMenuItem( this, 'Table'        , FCKLang.TableProperties, true ) ) ;
 142              
 143              break ;
 144  
 145          case 'Image' :
 146              return new FCKContextMenuGroup( true, this, 'Image', FCKLang.ImageProperties, true ) ;
 147  
 148          case 'Flash' :
 149              return new FCKContextMenuGroup( true, this, 'Flash', FCKLang.FlashProperties, true ) ;
 150  
 151          case 'Form' :
 152              return new FCKContextMenuGroup( true, this, 'Form', FCKLang.FormProp, true ) ;
 153  
 154          case 'Checkbox' :
 155              return new FCKContextMenuGroup( true, this, 'Checkbox', FCKLang.CheckboxProp, true ) ;
 156  
 157          case 'Radio' :
 158              return new FCKContextMenuGroup( true, this, 'Radio', FCKLang.RadioButtonProp, true ) ;
 159  
 160          case 'TextField' :
 161              return new FCKContextMenuGroup( true, this, 'TextField', FCKLang.TextFieldProp, true ) ;
 162  
 163          case 'HiddenField' :
 164              return new FCKContextMenuGroup( true, this, 'HiddenField', FCKLang.HiddenFieldProp, true ) ;
 165  
 166          case 'ImageButton' :
 167              return new FCKContextMenuGroup( true, this, 'ImageButton', FCKLang.ImageButtonProp, true ) ;
 168  
 169          case 'Button' :
 170              return new FCKContextMenuGroup( true, this, 'Button', FCKLang.ButtonProp, true ) ;
 171  
 172          case 'Select' :
 173              return new FCKContextMenuGroup( true, this, 'Select', FCKLang.SelectionFieldProp, true ) ;
 174  
 175          case 'Textarea' :
 176              return new FCKContextMenuGroup( true, this, 'Textarea', FCKLang.TextareaProp, true ) ;
 177  
 178          case 'BulletedList' :
 179              return new FCKContextMenuGroup( true, this, 'BulletedList', FCKLang.BulletedListProp, true ) ;
 180  
 181          case 'NumberedList' :
 182              return new FCKContextMenuGroup( true, this, 'NumberedList', FCKLang.NumberedListProp, true ) ;
 183  
 184          case 'Anchor' :
 185              return new FCKContextMenuGroup( true, this, 'Anchor', FCKLang.AnchorProp, true ) ;
 186      }
 187      
 188      return oGroup ;
 189  }
 190  
 191  FCKContextMenu.RefreshState = function()
 192  {
 193        // Get the actual selected tag (if any).
 194      var oTag = FCKSelection.GetSelectedElement() ;
 195      var sTagName ;
 196  
 197      if ( oTag )
 198          sTagName = oTag.tagName ;
 199  
 200      // Set items visibility.
 201  
 202  //    var bIsAnchor = ( sTagName == 'A' && oTag.name.length > 0 && oTag.href.length == 0 ) ;
 203  
 204  //    if ( this.Groups['Link'] )            this.Groups['Link'].SetVisible( !bIsAnchor && FCK.GetNamedCommandState( 'Unlink' ) != FCK_TRISTATE_DISABLED ) ;
 205      if ( this.Groups['Link'] )            this.Groups['Link'].SetVisible( FCK.GetNamedCommandState( 'Unlink' ) != FCK_TRISTATE_DISABLED ) ;
 206  
 207      if ( this.Groups['TableCell'] )        this.Groups['TableCell'].SetVisible( sTagName != 'TABLE' && FCKSelection.HasAncestorNode('TABLE') ) ;
 208      if ( this.Groups['Table'] )            this.Groups['Table'].SetVisible( sTagName == 'TABLE' ) ;
 209      
 210      if ( this.Groups['Image'] )            this.Groups['Image'].SetVisible( sTagName == 'IMG' && !oTag.getAttribute('_fckfakelement') ) ;
 211      if ( this.Groups['Flash'] )            this.Groups['Flash'].SetVisible( sTagName == 'IMG' && oTag.getAttribute('_fckflash') ) ;
 212      if ( this.Groups['Anchor'] )        this.Groups['Anchor'].SetVisible( sTagName == 'IMG' && oTag.getAttribute('_fckanchor') ) ;
 213  
 214      if ( this.Groups['BulletedList'] )    this.Groups['BulletedList'].SetVisible( FCKSelection.HasAncestorNode('UL') ) ;
 215      if ( this.Groups['NumberedList'] )    this.Groups['NumberedList'].SetVisible( FCKSelection.HasAncestorNode('OL') ) ;
 216  
 217      if ( this.Groups['Select'] )        this.Groups['Select'].SetVisible( sTagName == 'SELECT' ) ;
 218      if ( this.Groups['Textarea'] )        this.Groups['Textarea'].SetVisible( sTagName == 'TEXTAREA' ) ;
 219      if ( this.Groups['Form'] )            this.Groups['Form'].SetVisible( FCKSelection.HasAncestorNode('FORM') ) ;
 220      if ( this.Groups['Checkbox'] )        this.Groups['Checkbox'].SetVisible(        sTagName == 'INPUT' && oTag.type == 'checkbox' ) ;
 221      if ( this.Groups['Radio'] )            this.Groups['Radio'].SetVisible(        sTagName == 'INPUT' && oTag.type == 'radio' ) ;
 222      if ( this.Groups['TextField'] )        this.Groups['TextField'].SetVisible(    sTagName == 'INPUT' && ( oTag.type == 'text' || oTag.type == 'password' ) ) ;
 223      if ( this.Groups['HiddenField'] )    this.Groups['HiddenField'].SetVisible(    sTagName == 'INPUT' && oTag.type == 'hidden' ) ;
 224      if ( this.Groups['ImageButton'] )    this.Groups['ImageButton'].SetVisible(    sTagName == 'INPUT' && oTag.type == 'image' ) ;
 225      if ( this.Groups['Button'] )        this.Groups['Button'].SetVisible(        sTagName == 'INPUT' && ( oTag.type == 'button' || oTag.type == 'submit' || oTag.type == 'reset' ) ) ;
 226  
 227      // Refresh the state of all visible items (active/disactive)
 228      for ( var o in this.Groups )
 229      {
 230          this.Groups[o].RefreshState() ;
 231      }
 232  }
 233  
 234  /*
 235  Sample Context Menu Output
 236  -----------------------------------------
 237  <div class="CM_ContextMenu">
 238      <table cellSpacing="0" cellPadding="0" border="0">
 239          <tr class="CM_Disabled">
 240              <td class="CM_Icon"><img alt="" src="icons/cut.gif" width="21" height="20"></td>
 241              <td class="CM_Label">Cut</td>
 242          </tr>
 243          <tr class="CM_Disabled">
 244              <td class="CM_Icon"><img height="20" alt="" src="icons/copy.gif" width="21"></td>
 245              <td class="CM_Label">Copy</td>
 246          </tr>
 247          <tr class="CM_Option" onmouseover="OnOver(this);" onmouseout="OnOut(this);">
 248              <td class="CM_Icon"><img height="20" alt="" src="icons/paste.gif" width="21"></td>
 249              <td class="CM_Label">Paste</td>
 250          </tr>
 251          <tr class="CM_Separator">
 252              <td class="CM_Icon"></td>
 253              <td class="CM_Label"><div></div></td>
 254          </tr>
 255          <tr class="CM_Option" onmouseover="OnOver(this);" onmouseout="OnOut(this);">
 256              <td class="CM_Icon"><img height="20" alt="" src="icons/print.gif" width="21"></td>
 257              <td class="CM_Label">Print</td>
 258          </tr>
 259          <tr class="CM_Separator">
 260              <td class="CM_Icon"></td>
 261              <td class="CM_Label"><div></div></td>
 262          </tr>
 263          <tr class="CM_Option" onmouseover="OnOver(this);" onmouseout="OnOut(this);">
 264              <td class="CM_Icon"></td>
 265              <td class="CM_Label">Do Something</td>
 266          </tr>
 267          <tr class="CM_Option" onmouseover="OnOver(this);" onmouseout="OnOut(this);">
 268              <td class="CM_Icon"></td>
 269              <td class="CM_Label">Just Testing</td>
 270          </tr>
 271      </table>
 272  </div>
 273  */


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7