Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11423: exec_patch.diff

File exec_patch.diff, 1.6 kB (added by jdalton, 2 years ago)

addition of the exec() method to Prototype object

  • event.js

    old new  
    292292  function fireContentLoadedEvent() { 
    293293    if (document.loaded) return; 
    294294    if (timer) window.clearInterval(timer); 
     295    document.loaded = true; 
    295296    document.fire("dom:loaded"); 
    296     document.loaded = true; 
    297297  } 
    298298   
    299299  if (document.addEventListener) { 
  • prototype.js

    old new  
    1919      document.createElement('div').__proto__ !==  
    2020        document.createElement('form').__proto__ 
    2121  }, 
    22  
     22   
     23  exec: function(code){ 
     24    if((code+='').blank()) return; 
     25     
     26    var script,scriptId, 
     27    head = $$('head').first() || $(document.documentElement); 
     28     
     29    if(document.loaded){ 
     30      script = new Element('script', { type:'text/javascript'}); 
     31      try { 
     32         //appendChild(), not insert(), must be used to trigger error 
     33         script.appendChild( document.createTextNode(code) ); 
     34      } catch (e) { script.text = code } 
     35      head.insert(script); 
     36    } 
     37    else{ 
     38      //firefox 2.0.0.2/camino 1.0.4 don't execute inserted scripts synchronously when dom not loaded 
     39      scriptId = '__prototype_exec_script'; 
     40      document.write('<script id="'+scriptId+'" type="text/javascript">'+ code +'<\/script>'); 
     41      script = $(scriptId); 
     42    } 
     43    script.remove(); 
     44  }, 
     45   
    2346  ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>', 
    2447  JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,   
    2548