Changeset 654


Ignore:
Timestamp:
04/10/10 15:04:13 (2 years ago)
Author:
mr_lundis
Message:

Fixing broken setFocusToNode implementation in browsers other than IE, and implementing it for Opera. Also added toStart option, defaults to false.

Location:
trunk/src/wymeditor
Files:
5 edited

Legend:

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

    r648 r654  
    193193}; 
    194194 
    195 WYMeditor.WymClassExplorer.prototype.setFocusToNode = function(node) { 
    196     var range = this._doc.selection.createRange(); 
     195WYMeditor.WymClassExplorer.prototype.setFocusToNode = function(node, toStart) { 
     196    var range = this._doc.selection.createRange(); 
     197    toStart = toStart ? true : false; 
     198     
    197199    range.moveToElementText(node); 
    198     range.collapse(false); 
    199     range.move('character',-1); 
     200    range.collapse(toStart); 
    200201    range.select(); 
    201202    node.focus(); 
  • trunk/src/wymeditor/jquery.wymeditor.js

    r653 r654  
    12701270}; 
    12711271 
     1272WYMeditor.editor.prototype.setFocusToNode = function(node, toStart) { 
     1273    var range = this._doc.createRange(), 
     1274        selection = this._iframe.contentWindow.getSelection(); 
     1275    toStart = toStart ? 0 : 1; 
     1276     
     1277    range.selectNodeContents(node); 
     1278    selection.addRange(range); 
     1279    selection.collapse(node, toStart); 
     1280    this._iframe.contentWindow.focus(); 
     1281}; 
     1282 
    12721283WYMeditor.editor.prototype.addCssRules = function(doc, aCss) { 
    12731284  var styles = doc.styleSheets[0]; 
  • trunk/src/wymeditor/jquery.wymeditor.mozilla.js

    r650 r654  
    249249}; 
    250250 
    251 WYMeditor.WymClassMozilla.prototype.setFocusToNode = function(node) { 
    252     var range = document.createRange(); 
    253     range.selectNode(node); 
    254     var selected = this._iframe.contentWindow.getSelection(); 
    255     selected.addRange(range); 
    256     selected.collapse(node, node.childNodes.length); 
    257     this._iframe.contentWindow.focus(); 
    258 }; 
    259  
    260251WYMeditor.WymClassMozilla.prototype.openBlockTag = function(tag, attributes) 
    261252{ 
  • trunk/src/wymeditor/jquery.wymeditor.opera.js

    r648 r654  
    118118  wym._selected_image = null; 
    119119}; 
    120  
    121 // TODO: implement me 
    122 WYMeditor.WymClassOpera.prototype.setFocusToNode = function(node) { 
    123  
    124 }; 
    125  
  • trunk/src/wymeditor/jquery.wymeditor.safari.js

    r648 r654  
    217217}; 
    218218 
    219 WYMeditor.WymClassSafari.prototype.setFocusToNode = function(node) { 
    220     var range = this._iframe.contentDocument.createRange(); 
    221     range.selectNode(node); 
    222     var selected = this._iframe.contentWindow.getSelection(); 
    223     selected.addRange(range); 
    224     selected.collapse(node, node.childNodes.length); 
    225     this._iframe.contentWindow.focus(); 
    226 }; 
    227  
    228219WYMeditor.WymClassSafari.prototype.openBlockTag = function(tag, attributes) 
    229220{ 
Note: See TracChangeset for help on using the changeset viewer.