# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: Joomla root # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. --- administrator/components/com_comprofiler/plugin.foundation.php +++ administrator/components/com_comprofiler/plugin.foundation.php @@ -2074,6 +2074,24 @@ $this->_renderCheckOutput(); // } } + /** + * Adds custom $html into portion before all other headers are loaded + * + * @param string $html + */ + function addPreHeadCustomHtml( $html ) { + $this->_head['preHeader'][] = $html; + $this->_renderCheckOutput(); + } + /** + * Adds custom $html into portion after all other headers are loaded + * + * @param string $html + */ + function addPostHeadCustomHtml( $html ) { + $this->_head['postHeader'][] = $html; + $this->_renderCheckOutput(); + } /** * Returns direction 'ltr' or 'rtl' for global document * @@ -2153,7 +2171,7 @@ } } function _renderingInit() { - $this->_head = array( 'metaTags' => array(), 'linksCustom' => array(), 'stylesheets' => array(), 'styles' => array(), 'scriptsUrl' => array(), 'scripts' => array(), 'custom' => array() ); + $this->_head = array( 'metaTags' => array(), 'linksCustom' => array(), 'stylesheets' => array(), 'styles' => array(), 'scriptsUrl' => array(), 'scripts' => array(), 'custom' => array(), 'preHeader' => array(), 'postHeader' => array() ); } /** * Renders the portion going into the if CMS doesn't support correct ordering @@ -2164,6 +2182,10 @@ function _renderHead( ) { $html = null; if ( $this->_output == 'html' ) { + // if there are pre header things: + foreach ( $this->_head['preHeader'] as $preheader ) { + $html[] = $preheader; + } if ( $this->_cmsDoc === null ) { // is done outside // metaTags: @@ -2201,6 +2223,10 @@ foreach ( $this->_head['custom'] as $custom ) { $html[] = $custom; } + // if there are post header things: + foreach ( $this->_head['postHeader'] as $postheader ) { + $html[] = $postheader; + } } // reset the headers, in case we get late callers from outside the component (modules): $this->_renderingInit(); @@ -3208,10 +3234,27 @@ // 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 { */ + static $cbjqueryloaded = false; 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();' ); + // Store previous defines if present so they can be restored later: + $preJquery = "if ( typeof $ != 'undefined' ) { var \$OLD = $; } if ( typeof jQuery != 'undefined' ) { var jQueryOLD = jQuery; }"; + // Pre head is used because it loads first before all other CB header content: + $this->document->addPreHeadCustomHtml( '' ); + // Define CBs deep no conflict and redefine jquery variables for usage inside of CB plugins and jquery scripts: + $postJquery = "var cbjQuery = jQuery.noConflict( true ); var $ = cbjQuery; var jQuery = cbjQuery;"; + $this->document->addHeadScriptUrl( '/components/com_comprofiler/js/jquery-' . _CB_JQUERY_VERSION . '/jquery-' . _CB_JQUERY_VERSION . '.js', true, null, $postJquery ); define( 'J_JQUERY_LOADED', 1 ); + $cbjqueryloaded = true; } + // Lets restore the jquery selector if cbs jquery was never used: + if ( ! $cbjqueryloaded ) { + static $cbjqueryrestore = 0; + // Check if we've already restored CBs jquery selector to normal jquery selector: + if ( ! $cbjqueryrestore++ ) { + // Reroute cbjQuery to jQuery if CB jquery loading is disabled: + $this->document->addPreHeadCustomHtml( '' ); + } + } foreach ( $this->_jQueryPlugins as $plugin => $pluginPath ) { if ( ! isset( $this->_jQueryPluginsSent[$plugin] ) ) { $this->document->addHeadScriptUrl( $pluginPath, true, null, null, ( $plugin == 'excanvas' ? '' : '' ) ); @@ -3233,13 +3276,28 @@ */ $jQcodes = trim( implode( "\n", $this->_jQueryCodes ) ); if ( $jQcodes !== '' ) { - $jsCodeTxt = 'jQuery(document).ready(function($){' . "\n" - . $jQcodes - . "});" - ; + $jsCodeTxt = "cbjQuery( document ).ready( function( $ ) {" + . "\n" + . "var jQuery = $;" // lets ensure plugins using jQuery inline are getting cbs jquery object (for late loaded jquery) + . "\n" + . $jQcodes + . "\n" + . "});"; $this->document->addHeadScriptDeclaration( $jsCodeTxt ); } $this->_jQueryCodes = array(); + // Check if CBs actual jquery was loaded as it's a define so it can be disabled externally: + if ( $cbjqueryloaded ) { + static $cbjqueryrevert = 0; + // Check if we've already reverted jquerys selectors: + if ( ! $cbjqueryrevert++ ) { + // Revert the jQuery defines to their previous values if they were defined; otherwise keep CBs: + $revertJquery = "if ( typeof \$OLD != 'undefined' ) { var $ = \$OLD; } if ( typeof jQueryOLD != 'undefined' ) { var jQuery = jQueryOLD; }"; + // Post head is used because it loads last after all other CB header content + // This won't fix jquery that's loaded in late, but that's ok as we're just fixing jquery plugins loaded in that are using jQuery and $: + $this->document->addPostHeadCustomHtml( '' ); + } + } /* } */