Changeset 648


Ignore:
Timestamp:
01/09/10 17:07:38 (2 years ago)
Author:
mr_lundis
Message:

Modified the mouse event handling to use event delegation rather than listening to all the elements. Fixes #121 and django-cms-2.0 issue 184.  http://github.com/digi604/django-cms-2.0/issues#issue/184

Location:
trunk/src/wymeditor
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wymeditor/jquery.wymeditor.explorer.js

    r632 r648  
    119119    break; 
    120120        } 
    121      
    122     this.listen(); 
     121 
    123122}; 
    124123 
  • trunk/src/wymeditor/jquery.wymeditor.js

    r647 r648  
    940940      this.update(); 
    941941      this.toggleHtml(); 
    942  
    943       //partially fixes #121 when the user manually inserts an image 
    944       if(!jQuery(this._box).find(this._options.htmlSelector).is(':visible')) 
    945         this.listen(); 
    946942    break; 
    947943     
     
    13331329 
    13341330WYMeditor.editor.prototype.listen = function() { 
    1335  
    1336   //don't use jQuery.find() on the iframe body 
    1337   //because of MSIE + jQuery + expando issue (#JQ1143) 
    1338   //jQuery(this._doc.body).find("*").bind("mouseup", this.mouseup); 
    1339    
    1340   jQuery(this._doc.body).bind("mousedown", this.mousedown); 
    1341   var images = this._doc.body.getElementsByTagName("img"); 
    1342   for(var i=0; i < images.length; i++) { 
    1343     jQuery(images[i]).bind("mousedown", this.mousedown); 
    1344   } 
     1331    //don't use jQuery.find() on the iframe body 
     1332    //because of MSIE + jQuery + expando issue (#JQ1143) 
     1333    //jQuery(this._doc.body).find("*").bind("mouseup", this.mouseup); 
     1334 
     1335    jQuery(this._doc.body).bind("mousedown", this.mousedown); 
    13451336}; 
    13461337 
    13471338WYMeditor.editor.prototype.mousedown = function(evt) { 
    1348    
    1349   var wym = WYMeditor.INSTANCES[this.ownerDocument.title]; 
    1350   wym._selected_image = (this.tagName.toLowerCase() == WYMeditor.IMG) ? this : null; 
    1351   evt.stopPropagation(); 
     1339    var wym = WYMeditor.INSTANCES[this.ownerDocument.title]; 
     1340    wym._selected_image = (evt.target.tagName.toLowerCase() == WYMeditor.IMG) ? evt.target : null; 
    13521341}; 
    13531342 
  • trunk/src/wymeditor/jquery.wymeditor.mozilla.js

    r632 r648  
    137137    if(container.tagName.toLowerCase() == WYMeditor.BODY) 
    138138        this._exec(WYMeditor.FORMAT_BLOCK, WYMeditor.P); 
    139      
    140     //add event handlers on doc elements 
    141  
    142     this.listen(); 
    143139}; 
    144140 
  • trunk/src/wymeditor/jquery.wymeditor.opera.js

    r632 r648  
    6969    if(param) this._doc.execCommand(cmd,false,param); 
    7070    else this._doc.execCommand(cmd); 
    71      
    72     this.listen(); 
     71 
    7372}; 
    7473 
  • trunk/src/wymeditor/jquery.wymeditor.safari.js

    r632 r648  
    119119        this._exec(WYMeditor.FORMAT_BLOCK, WYMeditor.P); 
    120120 
    121     //add event handlers on doc elements 
    122     this.listen(); 
    123121}; 
    124122 
Note: See TracChangeset for help on using the changeset viewer.