[ 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/ -> fck_2.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: fck_2.js
  14   *     This is the second part of the "FCK" object creation. This is the main
  15   *     object that represents an editor instance.
  16   * 
  17   * File Authors:
  18   *         Frederico Caldeira Knabben (fredck@fckeditor.net)
  19   */
  20  
  21  // This collection is used by the browser specific implementations to tell
  22  // wich named commands must be handled separately.
  23  FCK.RedirectNamedCommands = new Object() ;
  24  
  25  FCK.ExecuteNamedCommand = function( commandName, commandParameter, noRedirect )
  26  {
  27      FCKUndo.SaveUndoStep() ;
  28  
  29      if ( !noRedirect && FCK.RedirectNamedCommands[ commandName ] != null )
  30          FCK.ExecuteRedirectedNamedCommand( commandName, commandParameter ) ;
  31      else
  32      {
  33          FCK.Focus() ;
  34          FCK.EditorDocument.execCommand( commandName, false, commandParameter ) ; 
  35          FCK.Events.FireEvent( 'OnSelectionChange' ) ;
  36      }
  37      
  38      FCKUndo.SaveUndoStep() ;
  39  }
  40  
  41  FCK.GetNamedCommandState = function( commandName )
  42  {
  43      try
  44      {
  45          if ( !FCK.EditorDocument.queryCommandEnabled( commandName ) )
  46              return FCK_TRISTATE_DISABLED ;
  47          else
  48              return FCK.EditorDocument.queryCommandState( commandName ) ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF ;
  49      }
  50      catch ( e )
  51      {
  52          return FCK_TRISTATE_OFF ;
  53      }
  54  }
  55  
  56  FCK.GetNamedCommandValue = function( commandName )
  57  {
  58      var sValue = '' ;
  59      var eState = FCK.GetNamedCommandState( commandName ) ;
  60      
  61      if ( eState == FCK_TRISTATE_DISABLED ) 
  62          return null ;
  63      
  64      try
  65      {
  66          sValue = this.EditorDocument.queryCommandValue( commandName ) ;
  67      }
  68      catch(e) {}
  69      
  70      return sValue ? sValue : '' ;
  71  }
  72  
  73  FCK.PasteFromWord = function()
  74  {
  75      FCKDialog.OpenDialog( 'FCKDialog_Paste', FCKLang.PasteFromWord, 'dialog/fck_paste.html', 400, 330, 'Word' ) ;
  76  }
  77  
  78  // TODO: Wait Stable and remove this block.
  79  //FCK.CleanAndPaste = function( html )
  80  //{
  81      // Remove all SPAN tags
  82  //    html = html.replace(/<\/?SPAN[^>]*>/gi, "" );
  83  
  84  //    html = html.replace(/<o:p>&nbsp;<\/o:p>/g, "") ;
  85  //    html = html.replace(/<o:p><\/o:p>/g, "") ;
  86      
  87      // Remove mso-xxx styles.
  88  //    html = html.replace( /mso-.[^:]:.[^;"]/g, "" ) ;
  89      
  90      // Remove Class attributes
  91  //    html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
  92      
  93      // Remove Style attributes
  94  //    html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ;
  95      
  96      // Remove Lang attributes
  97  //    html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
  98      
  99      // Remove XML elements and declarations
 100  //    html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
 101      
 102      // Remove Tags with XML namespace declarations: <o:p></o:p>
 103  //    html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
 104      
 105      // Replace the &nbsp;
 106  //    html = html.replace(/&nbsp;/, " " );
 107      // Replace the &nbsp; from the beggining.
 108  //    html = html.replace(/^&nbsp;[\s\r\n]*/, ""); 
 109      
 110      // Transform <P> to <DIV>
 111  //    var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ;    // Different because of a IE 5.0 error
 112  //    html = html.replace( re, "<div$2</div>" ) ;
 113      
 114  //    FCK.InsertHtml( html ) ;
 115  //}
 116  
 117  FCK.Preview = function()
 118  {
 119      var iWidth    = FCKConfig.ScreenWidth * 0.8 ;
 120      var iHeight    = FCKConfig.ScreenHeight * 0.7 ;
 121      var iLeft    = ( FCKConfig.ScreenWidth - iWidth ) / 2 ;
 122      var oWindow = window.open( '', null, 'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + iWidth + ',height=' + iHeight + ',left=' + iLeft ) ;
 123      
 124      var sHTML ;
 125      
 126      if ( FCKConfig.FullPage )
 127      {
 128          if ( FCK.TempBaseTag.length > 0 )
 129              sHTML = FCK.GetXHTML().replace( FCKRegexLib.HeadOpener, '$&' + FCK.TempBaseTag ) ;
 130          else
 131              sHTML = FCK.GetXHTML() ;
 132      }
 133      else
 134      {
 135          sHTML = 
 136              FCKConfig.DocType +
 137              '<html dir="' + FCKConfig.ContentLangDirection + '">' +
 138              '<head><title>' + FCKLang.Preview + '</title>' +
 139              '<link href="' + FCKConfig.EditorAreaCSS + '" rel="stylesheet" type="text/css" />' +
 140              FCK.TempBaseTag +
 141              '</head><body>' + 
 142              FCK.GetXHTML() + 
 143              '</body></html>' ;
 144      }
 145      
 146      oWindow.document.write( sHTML );
 147      oWindow.document.close();
 148  }
 149  
 150  FCK.SwitchEditMode = function()
 151  {
 152      // Check if the actual mode is WYSIWYG.
 153      var bWYSIWYG = ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ) ;
 154      
 155      // Display/Hide the TRs.
 156      document.getElementById('eWysiwyg').style.display    = bWYSIWYG ? 'none' : '' ;
 157      document.getElementById('eSource').style.display    = bWYSIWYG ? '' : 'none' ;
 158  
 159      // Update the HTML in the view output to show.
 160      if ( bWYSIWYG )
 161      {
 162          if ( FCKBrowserInfo.IsIE )
 163              FCKUndo.SaveUndoStep() ;
 164  
 165          // EnableXHTML and EnableSourceXHTML has been deprecated
 166  //        document.getElementById('eSourceField').value = ( FCKConfig.EnableXHTML && FCKConfig.EnableSourceXHTML ? FCK.GetXHTML( FCKConfig.FormatSource ) : FCK.GetHTML( FCKConfig.FormatSource ) ) ;
 167          document.getElementById('eSourceField').value = FCK.GetXHTML( FCKConfig.FormatSource ) ;
 168      }
 169      else
 170          FCK.SetHTML( document.getElementById('eSourceField').value, true ) ;
 171  
 172      // Updates the actual mode status.
 173      FCK.EditMode = bWYSIWYG ? FCK_EDITMODE_SOURCE : FCK_EDITMODE_WYSIWYG ;
 174      
 175      // Update the toolbar.
 176      FCKToolbarSet.RefreshModeState() ;
 177  
 178      // Set the Focus.
 179      FCK.Focus() ;
 180  }
 181  
 182  FCK.CreateElement = function( tag )
 183  {
 184      var e = FCK.EditorDocument.createElement( tag ) ;
 185      return FCK.InsertElementAndGetIt( e ) ;
 186  }
 187  
 188  FCK.InsertElementAndGetIt = function( e )
 189  {
 190      e.setAttribute( '__FCKTempLabel', 1 ) ;
 191      
 192      this.InsertElement( e ) ;
 193      
 194      var aEls = FCK.EditorDocument.getElementsByTagName( e.tagName ) ;
 195      
 196      for ( var i = 0 ; i < aEls.length ; i++ )
 197      {
 198          if ( aEls[i].getAttribute( '__FCKTempLabel' ) )
 199          {
 200              aEls[i].removeAttribute( '__FCKTempLabel' ) ;
 201              return aEls[i] ;
 202          }
 203      }
 204      return null ;
 205  }


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