Changeset 20755

Show
Ignore:
Timestamp:
03/02/09 23:35:23 (2 years ago)
Author:
bergie
Message:

Forward-port r19715: Enable loading jQuery from Google's hosted service, refs #638

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom_core/configuration/defaults.yml

    r20616 r20755  
    1919enable_included_list: false 
    2020enable_jquery_framework: true 
     21jquery_load_from_google: true 
    2122enable_js_midcom: false 
    2223enable_uimessages: false 
  • trunk/midcom/midcom_core/helpers/head.php

    r19573 r20755  
    1818    private $link_head_urls = array(); 
    1919    private $meta_head = array(); 
     20    private $configuration = null; 
    2021 
    2122    private $js_head = array(); 
     
    3536    public $jsmidcom_enabled = false; 
    3637     
    37     public function __construct($enable_jquery = false, $enable_jsmidcom = false, $jsmidcom_config = null) 
    38     { 
    39         if ($enable_jquery) 
     38    public function __construct(&$configuration) 
     39    { 
     40        $this->configuration = $configuration; 
     41        if ($this->configuration->enable_jquery_framework) 
    4042        { 
    4143            $this->enable_jquery(); 
    4244        } 
    4345         
    44         if ($enable_jsmidcom) 
    45         { 
    46             $this->enable_jsmidcom($jsmidcom_config); 
     46        if ($this->configuration->enable_js_midcom) 
     47        { 
     48            $this->enable_jsmidcom($this->configuration->js_midcom_config); 
    4749        } 
    4850    } 
     
    5557        } 
    5658         
    57         $url = MIDCOM_STATIC_URL . "/midcom_core/jQuery/jquery-{$version}.js"; 
    58         $this->jquery_inits = "<script type=\"text/javascript\" src=\"{$url}\"></script>\n";         
     59        if ($this->configuration->jquery_load_from_google) 
     60        { 
     61            // Let Google host jQuery for us 
     62            $this->jquery_inits  = "<script src=\"http://www.google.com/jsapi\"></script>\n"; 
     63            $this->jquery_inits .= "<script>\n"; 
     64            $this->jquery_inits .= "    google.load('jquery', '{$version}');\n";  
     65            $this->jquery_inits .= "</script>\n"; 
     66        } 
     67        else 
     68        { 
     69            // Load from a locally installed PEAR package 
     70            $url = MIDCOM_STATIC_URL . "/midcom_core/jQuery/jquery-{$version}.js"; 
     71            $this->jquery_inits = "<script type=\"text/javascript\" src=\"{$url}\"></script>\n"; 
     72        } 
    5973         
    6074        $script = 'var $j = jQuery.noConflict();'."\n"; 
  • trunk/midcom/midcom_core/midcom.php

    r20620 r20755  
    6060 
    6161        // Load the head helper 
    62         $this->head = new midcom_core_helpers_head 
    63         ( 
    64             $this->configuration->enable_jquery_framework, 
    65             $this->configuration->enable_js_midcom, 
    66             $this->configuration->js_midcom_config 
    67         ); 
     62        $this->head = new midcom_core_helpers_head($this->configuration); 
    6863    } 
    6964