Source for file textdiff.php

Documentation is available at textdiff.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  HTML
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * HTML utility class for creating text diffs using jQuery, diff_patch_match.js and jquery.pretty-text-diff.js JavaScript libraries.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_contenthistory.HTML
  17.  * @since       3.2
  18.  */
  19. abstract class JHtmlTextdiff
  20. {
  21.     /**
  22.      * @var    array  Array containing information for loaded files
  23.      * @since  3.2
  24.      */
  25.     protected static $loaded array();
  26.  
  27.     /**
  28.      * Method to load Javascript text diff
  29.      *
  30.      * @param   string  $containerId  DOM id of the element where the diff will be rendered
  31.      *
  32.      * @return  void 
  33.      *
  34.      * @since   3.2
  35.      */
  36.     public static function textdiff($containerId)
  37.     {
  38.         // Only load once
  39.         if (isset(static::$loaded[__METHOD__]))
  40.         {
  41.             return;
  42.         }
  43.  
  44.         // Depends on jQuery UI
  45.         JHtml::_('bootstrap.framework');
  46.         JHtml::_('script''com_contenthistory/diff_match_patch.js'falsetrue);
  47.         JHtml::_('script''com_contenthistory/jquery.pretty-text-diff.min.js'falsetrue);
  48.         JHtml::_('stylesheet''com_contenthistory/jquery.pretty-text-diff.css'falsetruefalse);
  49.  
  50.         // Attach diff to document
  51.         JFactory::getDocument()->addScriptDeclaration("
  52.             (function ($){
  53.                 $(document).ready(function (){
  54.                      $('#" $containerId " tr').prettyTextDiff();
  55.                  });
  56.             })(jQuery);
  57.             "
  58.         );
  59.  
  60.         // Set static array
  61.         static::$loaded[__METHOD__true;
  62.  
  63.         return;
  64.     }
  65. }

Documentation generated on Tue, 19 Nov 2013 15:15:43 +0100 by phpDocumentor 1.4.3