예제 #1
0
	function getAllJsPageCodes( ) {
		$jsCodeTxt			=	'';

		// jQuery code loading:

		if ( count( $this->_jQueryCodes ) > 0 ) {
			foreach ( array_keys( $this->_jQueryPlugins ) as $plugin ) {
				if ( isset( $this->_jqueryCssFiles[$plugin] ) ) {
					foreach ( $this->_jqueryCssFiles[$plugin] as $templateFile => $minExistsmedia ) {
						$templateFileWPath	=	selectTemplate( 'absolute_path' ) . '/' . $templateFile;
						if ( file_exists( $templateFileWPath ) ) {
							$templateFileUrl	=	selectTemplate( 'live_site' ) . $templateFile;
						} else {
							$templateFileUrl	=	selectTemplate( 'live_site', 'default' ) . $templateFile;
						}
						if ( ! isset( $this->_jQueryPluginsSent[$templateFileUrl] ) ) {
							$this->document->addHeadStyleSheet( $templateFileUrl, $minExistsmedia[0], $minExistsmedia[1] );
							$this->_jQueryPluginsSent[$templateFileUrl]		=	true;
						}
					}
				}
			}
			if ( ! defined( 'J_JQUERY_LOADED' ) ) {
				$this->document->addHeadScriptUrl( '/components/com_comprofiler/js/jquery-' . _CB_JQUERY_VERSION . '/jquery-' . _CB_JQUERY_VERSION . '.js', true, null, 'jQuery.noConflict();' );
				define( 'J_JQUERY_LOADED', 1 );
			}
			foreach ( $this->_jQueryPlugins as $plugin => $pluginPath ) {
				if ( ! isset( $this->_jQueryPluginsSent[$plugin] ) ) {
					$this->document->addHeadScriptUrl( $pluginPath, true, null, null, ( $plugin == 'excanvas' ? '<!--[if IE]>' : '' ), ( $plugin == 'excanvas' ? '<![endif]-->' : '' ) );
					$this->_jQueryPluginsSent[$plugin]		=	true;
				}
			}
/*
			$jsCodeTxt		=	"var cbJFrame = window.cbJFrame = function() { return new cbJFrame.prototype.init(); };\n"
							.	"cbJFrame.fn = cbJFrame.prototype = {\n"
							.	"  init: function() { return this; },\n"
							.	"  cbjframe: '" . $ueConfig['version'] . "',\n"
							.	"  jquery: null\n"
							.	"};\n"
							.	"cbJFrame.prototype.init.prototype = cbJFrame.prototype;\n"
							//.	"cbJFrame.jquery = jQuery.noConflict();\n"
							.	'cbJFrame.jquery(document).ready(function($){' . "\n"
							.	implode( "\n", $this->_jQueryCodes )
							.	"});\n";
*/
			$jQcodes		=	trim( implode( "\n", $this->_jQueryCodes ) );
			if ( $jQcodes !== '' ) {
				$jsCodeTxt	=	'jQuery(document).ready(function($){' . "\n"
							.	$jQcodes
							.	"});"
							;
				$this->document->addHeadScriptDeclaration( $jsCodeTxt );
			}
			$this->_jQueryCodes		=	array();
		}

		// classical standalone javascript loading (for compatibility), depreciated ! :

		if ( count( $this->_jsCodes ) > 0 ) {
			$this->document->addHeadScriptDeclaration( implode( "\n", $this->_jsCodes ) );
			$this->_jsCodes	=	array();
		}
	}
예제 #2
0
 /**
  * Method to load jQuery frameworks and non-conflicting javascript code into the document head
  * Loading and use is done in "deep non-conflict mode", which allows several concurent versions of jQuery to be loaded and run simultaneously with any other javascript framework, including another conflicting jQuery instance.
  * It means that the window's Javascript global namespace is not used in a fixed way: neither $ nor jQuery global variables are used. Reference: http://api.jquery.com/jQuery.noConflict/
  *
  * Outputs to head
  *
  * @return void
  */
 function getAllJsPageCodes()
 {
     // jQuery code loading:
     if (count($this->_jQueryCodes) > 0) {
         foreach (array_keys($this->_jQueryPlugins) as $plugin) {
             if (isset($this->_jqueryCssFiles[$plugin])) {
                 foreach ($this->_jqueryCssFiles[$plugin] as $templateFile => $minExistsmedia) {
                     $templateFileWPath = selectTemplate('absolute_path') . '/' . $templateFile;
                     if (file_exists($templateFileWPath)) {
                         $templateFileUrl = selectTemplate('relative_path') . '/' . $templateFile;
                     } else {
                         $templateFileUrl = selectTemplate('relative_path', 'default') . '/' . $templateFile;
                     }
                     if (!isset($this->_jQueryPluginsSent[$templateFileUrl])) {
                         $this->document->addHeadStyleSheet($templateFileUrl, $minExistsmedia[0], $minExistsmedia[1]);
                         $this->_jQueryPluginsSent[$templateFileUrl] = true;
                     }
                 }
             }
             if (isset($this->_jqueryJsFiles[$plugin])) {
                 foreach ($this->_jqueryJsFiles[$plugin] as $jsFile => $minExists) {
                     $jsFilePath = '/components/com_comprofiler/js/' . $jsFile;
                     if (!isset($this->_jQueryPluginsSent[$jsFilePath])) {
                         $this->document->addHeadScriptUrl($jsFilePath, $minExists);
                         $this->_jQueryPluginsSent[$jsFilePath] = true;
                     }
                 }
             }
         }
         /*
         			if ( FALSE && checkJversion() >= 2 && is_callable( array( 'JHtml', 'isCallable_' ) ) && JHtml::isCallable_('behavior.jquery' ) ) {
         				// Based on proposed contribution of 12.01.2012 to Joomla:
         				JHtml::_('behavior.jquery', _CB_JQUERY_VERSION, 'components/com_comprofiler/js/jquery-' . _CB_JQUERY_VERSION . '/', null, trim( implode( "\n", $this->_jQueryCodes ) ));
         				$plugins = array();
         				foreach ($this->_jQueryPlugins as $k => $v) {
         					$matches	=	null;
         					if ( preg_match( '|^/?(.+/)([^/]+)(?:\.min)?\.js$|', $v, $matches ) ) {
         						JHtml::_('behavior.jquery', _CB_JQUERY_VERSION, $matches[1], array( $matches[2] ) );
         					}
         				}
         				// JHtml::_('behavior.jquery', _CB_JQUERY_VERSION, 'components/com_comprofiler/../com_comprofiler/js/jquery-' . _CB_JQUERY_VERSION . '/', array( 'jquery.autogrow', 'jquery.colorinput', 'jquery.jmap'), '$("p").css("color","red");');
         				// JHtml::_('behavior.jquery', '1.6.7', 'components/com_comprofiler/js/../js/jquery-' . _CB_JQUERY_VERSION . '/', array( 'jquery.autogrow', 'jquery.colorinput', 'jquery.jmap'), '$("p").css("color","red") ;');
         			} else {
         */
         // Store previous defines if present so they can be restored later:
         $preJquery = "if ( typeof window.\$ != 'undefined' ) {" . "\n\t" . 'window.cbjqldr_tmpsave$ = window.$;' . "\n" . '}' . "\n" . "if ( typeof window.jQuery != 'undefined' ) {" . "\n\t" . 'window.cbjqldr_tmpsavejquery = window.jQuery;' . "\n" . '}';
         static $cbjqueryloaded = false;
         if (!defined('CB_JQUERY_LOADED')) {
             global $ueConfig;
             $loadJquery = isset($ueConfig['jsJquery']) ? (int) $ueConfig['jsJquery'] : 1;
             if ($loadJquery || $this->getUi() == 2) {
                 // Define CBs deep no conflict and redefine jquery variables for usage inside of CB plugins and jquery scripts:
                 $postJquery = 'var cbjQuery = jQuery.noConflict( true );';
                 $this->document->addHeadScriptUrl('/components/com_comprofiler/js/jquery/jquery-' . _CB_JQUERY_VERSION . '.js', true, $preJquery, $postJquery);
                 $cbjqueryloaded = true;
                 $preJquery = '';
             }
             define('CB_JQUERY_LOADED', 1);
         }
         // Let's set the cbjquery selector if cb's jquery was never used:
         if (!$cbjqueryloaded) {
             static $cbjquerySet = 0;
             if (!$cbjquerySet++) {
                 $preJquery .= "\n" . 'var cbjQuery = window.jQuery;' . "\n";
             }
         }
         // Now that the existing $ and jQuery are saved, impose use of CB's jQuery for CB plugins:
         $preJquery .= 'window.$ = cbjQuery;' . "\n" . 'window.jQuery = cbjQuery;';
         foreach ($this->_jQueryPlugins as $plugin => $pluginPath) {
             if (!isset($this->_jQueryPluginsSent[$plugin])) {
                 $this->document->addHeadScriptUrl($pluginPath, true, $preJquery, null, $plugin == 'excanvas' ? '<!--[if lte IE 8]>' : '', $plugin == 'excanvas' ? '<![endif]-->' : '');
                 $preJquery = null;
                 $this->_jQueryPluginsSent[$plugin] = true;
             }
         }
         // If no plugins outputed, we still need to have the $preJquery initializations:
         $jsCodeTxt = $preJquery;
         $jQcodes = trim(implode("\n", $this->_jQueryCodes));
         if ($jQcodes !== '') {
             $jsCodeTxt .= 'cbjQuery( document ).ready( function( $ ) {' . "\n" . 'var jQuery = $;' . "\n" . $jQcodes . "\n" . "});" . "\n";
         }
         $this->_jQueryCodes = array();
         $jsCodeTxt .= "if ( typeof window.cbjqldr_tmpsave\$ != 'undefined' ) {" . "\n\t" . 'window.$ = window.cbjqldr_tmpsave$;' . "\n" . '}' . "\n" . "if ( typeof window.cbjqldr_tmpsavejquery != 'undefined' ) {" . "\n\t" . 'window.jQuery = window.cbjqldr_tmpsavejquery;' . "\n" . '}';
         $this->document->addHeadScriptDeclaration($jsCodeTxt);
         /*
         			}
         */
     }
     // classical standalone javascript loading (for compatibility), depreciated ! :
     if (count($this->_jsCodes) > 0) {
         $this->document->addHeadScriptDeclaration(implode("\n", $this->_jsCodes));
         $this->_jsCodes = array();
     }
 }