# 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 @@ -3208,10 +3208,25 @@ // 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; }"; + // 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, $preJquery, $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->addHeadScriptDeclaration( "var cbjQuery = jQuery" ); + } + } foreach ( $this->_jQueryPlugins as $plugin => $pluginPath ) { if ( ! isset( $this->_jQueryPluginsSent[$plugin] ) ) { $this->document->addHeadScriptUrl( $pluginPath, true, null, null, ( $plugin == 'excanvas' ? '' : '' ) ); @@ -3233,13 +3248,26 @@ */ $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 + // NOTE 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->addHeadScriptDeclaration( "if ( typeof \$OLD != 'undefined' ) { var $ = \$OLD; } if ( typeof jQueryOLD != 'undefined' ) { var jQuery = jQueryOLD; }" ); + } + } /* } */