Changeset 9580


Ignore:
Timestamp:
03/09/11 11:17:14 (9 years ago)
Author:
patdenice
Message:

feature:2114
footer_script can use multiple required scripts (like combine_script).
automaticaly load know scripts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/template.class.php

    r9559 r9580  
    659659    if ( !empty($content) ) 
    660660    { // second call 
    661       $this->scriptLoader->add_inline( $content, @$params['require'] ); 
     661      $this->scriptLoader->add_inline( 
     662        $content, 
     663        empty($params['require']) ? array() : explode(',', $params['require']) 
     664      ); 
    662665    } 
    663666  } 
     
    935938    if(!empty($require)) 
    936939    { 
    937       if(!isset($this->registered_scripts[$require])) 
    938         fatal_error("inline script not found require $require"); 
    939       $s = $this->registered_scripts[$require]; 
    940       if($s->load_mode==2) 
    941         $s->load_mode=1; // until now the implementation does not allow executing inline script depending on another async script 
     940      foreach ($require as $id) 
     941      { 
     942        if(!isset($this->registered_scripts[$id])) 
     943          $this->load_known_required_script($id, 1) or fatal_error("inline script not found require $id"); 
     944        $s = $this->registered_scripts[$id]; 
     945        if($s->load_mode==2) 
     946          $s->load_mode=1; // until now the implementation does not allow executing inline script depending on another async script 
     947      } 
    942948    } 
    943949    $this->inline_scripts[] = $code; 
     
    974980      foreach (self::$ui_core_dependencies as $script_id => $required_ids) 
    975981        $this->add($script_id, $load_mode, $required_ids, null, $version); 
     982    } 
     983 
     984    // Try to load undefined required script 
     985    foreach ($script->precedents as $script_id) 
     986    { 
     987      if (! isset( $this->registered_scripts[$script_id] ) ) 
     988        $this->load_known_required_script($script_id, $load_mode); 
    976989    } 
    977990  } 
     
    11141127 
    11151128        if ( empty($script->path) ) 
    1116           $script->path = dirname(self::$known_paths['jquery.ui'])."/$id.min.js"; 
     1129          $script->path = dirname(self::$known_paths['jquery.effects'])."/$id.min.js"; 
    11171130      } 
    11181131 
     
    11231136      } 
    11241137    } 
     1138  } 
     1139 
     1140  private function load_known_required_script($id, $load_mode) 
     1141  { 
     1142    if ( isset(self::$known_paths[$id]) or strncmp($id, 'jquery.ui.', 10)==0 or strncmp($id, 'jquery.effetcs.', 15)==0 ) 
     1143    { 
     1144      $this->add($id, $load_mode, array(), null); 
     1145      return true; 
     1146    } 
     1147    return false; 
    11251148  } 
    11261149 
Note: See TracChangeset for help on using the changeset viewer.