this._ranges = []; this.addRange = function(r, /*boolean*/internal){ this._ranges.push(r); if(!internal){ r._select(); } this.rangeCount = this._ranges.length; }; this.removeAllRanges = function(){ //don't detach, the range may be used later // for(var i=0;i<this._ranges.length;i++){ // this._ranges[i].detach(); // } this._ranges = []; this.rangeCount = 0; }; var _initCurrentRange = function(){ var r = win.document.selection.createRange(); var type=win.document.selection.type.toUpperCase(); if(type == "CONTROL"){ //TODO: multiple range selection(?) return new dijit.range.W3CRange(dijit.range.ie.decomposeControlRange(r)); }else{ return new dijit.range.W3CRange(dijit.range.ie.decomposeTextRange(r)); } }; this.getRangeAt = function(i){ return this._ranges[i]; }; this._getCurrentSelection = function(){ this.removeAllRanges(); var r=_initCurrentRange(); if(r){ this.addRange(r, true); } };