Skip to content

Commit

Permalink
Worked more on the DOM folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
swilliams committed Jul 14, 2010
1 parent 4efaf76 commit 628d86c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
23 changes: 11 additions & 12 deletions src/wysihat/dom/bookmark.js
@@ -1,22 +1,21 @@
//= require "selection"

if (Prototype.Browser.IE) {
Object.extend(Selection.prototype, (function() {
if ($.browser.msie) {
jQuery.extend(Selection.prototype, (function() {
function setBookmark() {
var bookmark = $('bookmark');
var bookmark = $('#bookmark');
if (bookmark) bookmark.remove();

bookmark = new Element('span', { 'id': 'bookmark' }).update(" ");
var parent = new Element('div');
parent.appendChild(bookmark);
bookmark = $('<span id="bookmark">&nbsp;</span>');
var parent = $('<div></div>').html(bookmark);

var range = this._document.selection.createRange();
range.collapse();
range.pasteHTML(parent.innerHTML);
range.pasteHTML(parent.html());
}

function moveToBookmark() {
var bookmark = $('bookmark');
var bookmark = $('#bookmark');
if (!bookmark) return;

var range = this._document.selection.createRange();
Expand All @@ -33,17 +32,17 @@ if (Prototype.Browser.IE) {
}
})());
} else {
Object.extend(Selection.prototype, (function() {
jQuery.extend(Selection.prototype, (function() {
function setBookmark() {
var bookmark = $('bookmark');
var bookmark = $('#bookmark');
if (bookmark) bookmark.remove();

bookmark = new Element('span', { 'id': 'bookmark' }).update("&nbsp;");
bookmark = $('<span id="bookmark">&nbsp;</span>');
this.getRangeAt(0).insertNode(bookmark);
}

function moveToBookmark() {
var bookmark = $('bookmark');
var bookmark = $('#bookmark');
if (!bookmark) return;

var range = document.createRange();
Expand Down
6 changes: 3 additions & 3 deletions src/wysihat/dom/selection.js
@@ -1,8 +1,8 @@
//= require "ierange"
//= require "range"

if (Prototype.Browser.IE) {
Object.extend(Selection.prototype, (function() {
if ($.browser.msie) {
jQuery.extend(Selection.prototype, (function() {
// TODO: More robust getNode
function getNode() {
var range = this._document.selection.createRange();
Expand All @@ -28,7 +28,7 @@ if (Prototype.Browser.IE) {
Selection.prototype = window.getSelection().__proto__;
}

Object.extend(Selection.prototype, (function() {
jQuery.extend(Selection.prototype, (function() {
function getNode() {
if (this.rangeCount > 0)
return this.getRangeAt(0).getNode();
Expand Down

0 comments on commit 628d86c

Please sign in to comment.