Changeset 044d664 in github


Ignore:
Timestamp:
Mar 1, 2011 5:33:12 PM (2 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
79cd6ce
Parents:
e490642
Message:

Make it easier to add code to $(document).ready()

Location:
program/include
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • program/include/main.inc

    rf572575 r044d664  
    16621662  $quota = rcmail_quota_content($attrib); 
    16631663 
    1664   $OUTPUT->add_script('$(document).ready(function(){ 
    1665         rcmail.set_quota('.json_serialize($quota).')});', 'foot'); 
     1664  $OUTPUT->add_script('rcmail.set_quota('.json_serialize($quota).');', 'docready'); 
    16661665 
    16671666  return html::span($attrib, ''); 
  • program/include/rcube_html_page.php

    r798764c r044d664  
    66 |                                                                       | 
    77 | This file is part of the Roundcube PHP suite                          | 
    8  | Copyright (C) 2005-2009, The Roundcube Dev Team                       | 
     8 | Copyright (C) 2005-2011 The Roundcube Dev Team                       | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    3434 
    3535    protected $script_tag_file = "<script type=\"text/javascript\" src=\"%s\"></script>\n"; 
    36     protected $script_tag  =  "<script type=\"text/javascript\">\n/* <![CDATA[ */\n%s\n/* ]]> */\n</script>"; 
     36    protected $script_tag  =  "<script type=\"text/javascript\">\n/* <![CDATA[ */\n%s\n/* ]]> */\n</script>\n"; 
    3737    protected $link_css_file = "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\n"; 
    3838    protected $default_template = "<html>\n<head><title></title></head>\n<body></body>\n</html>"; 
     
    209209        } 
    210210 
     211        // put docready commands into page footer 
     212        if (!empty($this->scripts['docready'])) { 
     213            $this->add_script('$(document).ready(function(){ ' . $this->scripts['docready'] . "\n});", 'foot'); 
     214        } 
     215         
    211216        if (is_array($this->script_files['foot'])) { 
    212217            foreach ($this->script_files['foot'] as $file) { 
  • program/include/rcube_template.php

    rae39c47 r044d664  
    66 |                                                                       | 
    77 | This file is part of the Roundcube Webmail client                     | 
    8  | Copyright (C) 2006-2010, The Roundcube Dev Team                       | 
     8 | Copyright (C) 2006-2011, The Roundcube Dev Team                       | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    5858     * Constructor 
    5959     * 
    60      * @todo   Use jQuery's $(document).ready() here. 
    6160     * @todo   Replace $this->config with the real rcube_config object 
    6261     */ 
     
    8079 
    8180        // don't wait for page onload. Call init at the bottom of the page (delayed) 
    82         $javascript_foot = '$(document).ready(function(){ '.JS_OBJECT_NAME.'.init(); });'; 
     81        $this->add_script(JS_OBJECT_NAME.'.init();', 'docready'); 
    8382 
    8483        $this->add_script($javascript, 'head_top'); 
    85         $this->add_script($javascript_foot, 'foot'); 
    8684        $this->scripts_path = 'program/js/'; 
    8785        $this->include_script('jquery-1.5.min.js'); 
     
    11531151            return; 
    11541152 
    1155         $this->add_script('$(document).ready(function(){ 
    1156             var images = ' . json_serialize($images) .'; 
     1153        $this->add_script('var images = ' . json_serialize($images) .'; 
    11571154            for (var i=0; i<images.length; i++) { 
    11581155                img = new Image(); 
    11591156                img.src = images[i]; 
    1160             }});', 'foot'); 
     1157            }', 'docready'); 
    11611158    } 
    11621159 
Note: See TracChangeset for help on using the changeset viewer.