Changeset 0e99d37 in github


Ignore:
Timestamp:
Jun 1, 2009 11:35:53 AM (4 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
47f0725
Parents:
0ce11986
Message:

Use event system on the client to handle ajax callbacks

Location:
program
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_json_output.php

    r69f18a09 r0e99d37  
    3434    private $texts = array(); 
    3535    private $commands = array(); 
     36    private $callbacks = array(); 
    3637    private $message = null; 
    3738 
     
    123124    public function command() 
    124125    { 
    125         $this->commands[] = func_get_args(); 
     126        $cmd = func_get_args(); 
     127         
     128        if (strpos($cmd[0], 'plugin.') === 0) 
     129          $this->callbacks[] = $cmd; 
     130        else 
     131          $this->commands[] = $cmd; 
    126132    } 
    127133     
     
    228234          $response['texts'] = $this->texts; 
    229235 
    230         // send response code 
     236        // send function calls 
    231237        $response['exec'] = $this->get_js_commands() . $add; 
     238         
     239        if (!empty($this->callbacks)) 
     240          $response['callbacks'] = $this->callbacks; 
    232241 
    233242        echo json_serialize($response); 
  • program/include/rcube_template.php

    ra17fe62 r0e99d37  
    202202    public function command() 
    203203    { 
    204         $this->js_commands[] = func_get_args(); 
     204        $cmd = func_get_args(); 
     205        if (strpos($cmd[0], 'plugin.') === false) 
     206          $this->js_commands[] = $cmd; 
    205207    } 
    206208 
  • program/js/app.js

    r52818559 r0e99d37  
    39243924      eval(response.exec); 
    39253925    } 
     3926     
     3927    // execute callback functions of plugins 
     3928    if (response.callbacks && response.callbacks.length) { 
     3929      for (var i=0; i < response.callbacks.length; i++) 
     3930        this.triggerEvent(response.callbacks[i][0], response.callbacks[i][1]); 
     3931    } 
    39263932  
    39273933    // process the response data according to the sent action 
  • program/js/common.js

    r309d2f4 r0e99d37  
    289289  var ret, h; 
    290290  if (typeof e == 'undefined') 
    291     e = {}; 
    292   if (typeof e == 'object') 
     291    e = this; 
     292  else if (typeof e == 'object') 
    293293    e.event = evt; 
    294294   
     
    298298      if ((h = this._events[evt][i])) { 
    299299        if (typeof h.func == 'function') 
    300           ret = h.func.call ? h.func.call(h.obj, this, e) : h.func(this, e); 
     300          ret = h.func.call ? h.func.call(h.obj, e) : h.func(e); 
    301301        else if (typeof h.obj[h.func] == 'function') 
    302           ret = h.obj[h.func](this, e); 
     302          ret = h.obj[h.func](e); 
    303303               
    304304        // cancel event execution 
Note: See TracChangeset for help on using the changeset viewer.