[ Index ]

PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10)

title

Body

[close]

/include/inc_front/lib/ -> js.mootools-1.2.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2010 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  define('PHPWCMS_JSLIB', 'mootools-1.2');
  24  
  25  
  26  /**
  27   * Init Mootools 1.2.x Library
  28   */
  29  function initJSLib() {
  30      if(empty($GLOBALS['block']['custom_htmlhead']['mootools.js'])) {
  31          if(!USE_GOOGLE_AJAX_LIB) {
  32              $GLOBALS['block']['custom_htmlhead']['mootools.js'] = getJavaScriptSourceLink(TEMPLATE_PATH.'lib/mootools/mootools-1.2-core-yc.js');
  33          } else {
  34              $GLOBALS['block']['custom_htmlhead']['mootools.js'] = getJavaScriptSourceLink(USE_GOOGLE_AJAX_LIB.'mootools/1.2/mootools-yui-compressed.js');
  35          }
  36      }
  37      return TRUE;
  38  }
  39  
  40  /**
  41   * Initialize Slimbox CSS and JavaScript for MooTools 1.2
  42   */
  43  function initSlimbox() {
  44      initJSLib();
  45      $GLOBALS['block']['custom_htmlhead']['lightbox.css'] = '  <link href="'.TEMPLATE_PATH.'lib/slimbox/slimbox.css" rel="stylesheet" type="text/css" media="screen" />';
  46      $GLOBALS['block']['custom_htmlhead']['slimbox.js'] = getJavaScriptSourceLink(TEMPLATE_PATH.'lib/slimbox/slimbox.mootools-1.2.js');
  47  }
  48  
  49  /**
  50   * Initialize Frontend Edit DomReady JavaScript
  51   */
  52  function init_frontend_edit_js() {
  53      
  54      initJSLib();
  55      $GLOBALS['block']['js_ondomready'][] = '        var felink_status = 0;
  56          $$("a.fe-link").each(function(r) { r.setStyle("display", "none"); });
  57          $("fe-link").addEvent("click", function() {
  58              if(felink_status == 1) {
  59                  $$("a.fe-link").each(function(r) { r.setStyle("display", "none"); });
  60                  $("fe-link").removeClass("enabled"); $("fe-link").addClass("disabled");    felink_status = 0;
  61              } else {
  62                  $$("a.fe-link").each(function(r) { r.setStyle("display", ""); });
  63                  $("fe-link").removeClass("disabled"); $("fe-link").addClass("enabled");    felink_status = 1;
  64              }
  65          });';
  66      
  67  }
  68  
  69  /**
  70   * Create JavaScript Domready Section
  71   */
  72  function jsOnDomReady($js='', $return=false, $prefix='  ') {
  73      
  74      if($js) {
  75          
  76          initJSLib();
  77          
  78          $_js  = $prefix . '<script type="text/javascript">'.LF.SCRIPT_CDATA_START.LF;
  79          $_js .= '    window.addEvent("domready", function() {' . LF. $js . LF . '    });';
  80          $_js .= LF.SCRIPT_CDATA_END.LF.$prefix.'</script>';
  81          
  82          if($return) {
  83              return $_js;
  84          }
  85          
  86          $GLOBALS['block']['custom_htmlhead'][] = $_js;
  87      }
  88  }
  89  
  90  /**
  91   * Create JavaScript UnLoad Section
  92   */
  93  function jsOnUnLoad($js='', $return=false, $prefix='  ') {
  94      
  95      if($js) {
  96          
  97          initJSLib();
  98          
  99          $_js  = $prefix . '<script type="text/javascript">'.LF.SCRIPT_CDATA_START.LF;
 100          $_js .= '    window.addEvent("unload", function() {' . LF . $js . LF . '    });';
 101          $_js .= LF.SCRIPT_CDATA_END.LF.$prefix.'</script>';
 102          
 103          if($return) {
 104              return $_js;
 105          }
 106          
 107          $GLOBALS['block']['custom_htmlhead'][] = $_js;
 108      }
 109  }
 110  
 111  
 112  /**
 113   * Simple MooTools Plugin Loader
 114   */
 115  function initJSPlugin($plugin='', $more=false) {
 116      // enhance teplate JS parser for MooTools More
 117      // sample: <!-- JS: MORE:Fx/Fx.Elements,Fx/Fx.Accordion -->
 118      if(is_string($plugin) && $more === false && substr(strtoupper($plugin), 0, 5) == 'MORE:') {
 119          $plugin    = trim(substr($plugin, 5));
 120          $more    = true;
 121      }
 122      if($more === false) {
 123          $plugin = 'mootools.'.$plugin.'.js';
 124          if(empty($GLOBALS['block']['custom_htmlhead'][$plugin])) {
 125              initJSLib();
 126              $GLOBALS['block']['custom_htmlhead'][$plugin] = getJavaScriptSourceLink(TEMPLATE_PATH.'lib/mootools/plugin-1.2/'.$plugin);
 127          }
 128      } else {
 129          // Load MooTools More Plugins - simple Wrapper 'Fx/Fx.Slide,Fx/Fx.Scroll...'
 130          // it does not check dependends
 131          if(!is_array($plugin)) {
 132              $plugin = convertStringToArray($plugin);
 133          }
 134          if(count($plugin)) {
 135              initJSLib();
 136              // add mootools more core
 137              array_unshift($plugin, 'Core/More');
 138              foreach($plugin as $more) {
 139                  if(empty($GLOBALS['block']['custom_htmlhead'][$more]) && is_file(PHPWCMS_TEMPLATE.'lib/mootools/more/'.$more.'.js')) {
 140                      $GLOBALS['block']['custom_htmlhead'][$more] = getJavaScriptSourceLink(TEMPLATE_PATH.'lib/mootools/more/'.$more.'.js');
 141                  }
 142              }
 143          }
 144      }    
 145      return TRUE;
 146  }
 147  
 148  ?>


Generated: Tue Nov 16 22:51:00 2010 Cross-referenced by PHPXref 0.7