| | 223 | sapi.prototype.cacheSelection = function() { |
|---|
| | 224 | var w = this.parent._iframe.contentWindow; |
|---|
| | 225 | var d = this.parent._doc; |
|---|
| | 226 | if (w.getSelection) { |
|---|
| | 227 | var selection = w.getSelection(); |
|---|
| | 228 | if (selection.rangeCount > 0) { |
|---|
| | 229 | var selectedRange = selection.getRangeAt(0); |
|---|
| | 230 | w._selection = selectedRange.cloneRange(); |
|---|
| | 231 | } |
|---|
| | 232 | else { |
|---|
| | 233 | return null; |
|---|
| | 234 | } |
|---|
| | 235 | } |
|---|
| | 236 | else if (d.selection) { |
|---|
| | 237 | var selection = d.selection; |
|---|
| | 238 | if (selection.type.toLowerCase() == 'text') { |
|---|
| | 239 | w._selection = selection.createRange().getBookmark(); |
|---|
| | 240 | } |
|---|
| | 241 | else { |
|---|
| | 242 | w._selection = null; |
|---|
| | 243 | } |
|---|
| | 244 | } |
|---|
| | 245 | else { |
|---|
| | 246 | w._selection = null; |
|---|
| | 247 | } |
|---|
| | 248 | }; |
|---|
| | 249 | |
|---|
| | 250 | sapi.prototype.restoreSelection = function(index) { |
|---|
| | 251 | var w = this.parent._iframe.contentWindow; |
|---|
| | 252 | var d = this.parent._doc; |
|---|
| | 253 | try {jQuery(d).focus();} catch(e) {} |
|---|
| | 254 | if (w._selection) { |
|---|
| | 255 | if (w.getSelection) { |
|---|
| | 256 | var selection = w.getSelection(); |
|---|
| | 257 | selection.removeAllRanges(); |
|---|
| | 258 | selection.addRange(w._selection); |
|---|
| | 259 | w._selection = null; |
|---|
| | 260 | } |
|---|
| | 261 | else if (d.selection && d.body.createTextRange) { |
|---|
| | 262 | var range = d.body.createTextRange(); |
|---|
| | 263 | range.moveToBookmark(w._selection); |
|---|
| | 264 | range.select(); |
|---|
| | 265 | w._selection = null; |
|---|
| | 266 | } |
|---|
| | 267 | } |
|---|
| | 268 | }; |
|---|
| | 269 | |
|---|