compile() public method

gather together all script needing to be output
public compile ( string $view_var = 'script_foot', boolean $script_tags = TRUE ) : string
$view_var string
$script_tags boolean
return string
コード例 #1
0
ファイル: EE_Javascript.php プロジェクト: realfluid/umbaugh
    /**
     * Extending the compile function to add the globals
     *
     * @access	public
     */
    function compile($view_var = 'script_foot', $script_tags = TRUE)
    {
        parent::compile($view_var, $script_tags);
        $global_js = $this->inline('
			document.documentElement.className += "js";

			var EE = ' . json_encode($this->global_vars) . ';

			if (typeof console === "undefined" || ! console.log) {
				console = { log: function() { return false; }};
			}
		');
        $this->CI->view->cp_global_js = $global_js;
    }
コード例 #2
0
    /**
     * Extending the compile function to add the globals
     *
     * @access	public
     */
    function compile($view_var = 'script_foot', $script_tags = TRUE)
    {
        // Experimental reduction of inline js
        /*
        foreach($this->js->jquery_code_for_compile as $k => $v)
        {
        	// Remove Comments
        	$v = preg_replace('/\/\/[^\n\r\'";{}]*[\n\r]/', ' ', $v);
        	$v = preg_replace('/\/\*[^*]*\*+([^\/\'";{}][^*]*\*+)*\//', ' ', $v);
        	
        	// Safe Whitespace Replacements
        	$v = preg_replace('/[\t ]+/', ' ', $v);
        	$v = preg_replace('/(\s*?\n+\s*?)+/', "\n", $v);
        	
        	// Common Ones
        	$v = preg_replace('/([;]\n|\) \{|\{\n)/', '', $v);
        	
        	$this->js->jquery_code_for_compile[$k] = $v;
        }
        */
        parent::compile($view_var, $script_tags);
        $global_js = $this->inline('
			document.documentElement.className += "js";

			if (typeof console === "undefined" || ! console.log) {
				console = { log: function() { return false; }};
			}
			
			if (typeof EE === "undefined" || ! EE) {
				var EE = ' . $this->generate_json($this->global_vars, TRUE) . ';
			}
		');
        $this->CI->cp->set_variable('cp_global_js', $global_js);
    }