Skip to content

Commit

Permalink
Merge branch 'master' of github.com:tilleryd/bootstrap-wysiwyg
Browse files Browse the repository at this point in the history
Changes by @tilleryd to match #99 "Fix range selection in IE8"
  • Loading branch information
Steve King committed Apr 27, 2014
2 parents ed95965 + b4b766d commit 4e5bf51
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions bootstrap-wysiwyg.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,39 @@
});
},
getCurrentRange = function () {
var sel = window.getSelection();
if (sel.getRangeAt && sel.rangeCount) {
return sel.getRangeAt(0);
}
var sel, range;
if (window.getSelection) {
sel = window.getSelection();
if (sel.getRangeAt && sel.rangeCount) {
range = sel.getRangeAt(0);
}
} else if (document.selection) {
range = document.selection.createRange();
}
return range;
},
saveSelection = function () {
selectedRange = getCurrentRange();
},
restoreSelection = function () {
var selection = window.getSelection();
if (selectedRange) {
try {
selection.removeAllRanges();
} catch (ex) {
document.body.createTextRange().select();
document.selection.empty();
}
var selection;
if (window.getSelection || document.createRange) {
selection = window.getSelection();
if (selectedRange) {
try {
selection.removeAllRanges();
} catch (ex) {
document.body.createTextRange().select();
document.selection.empty();
}

selection.addRange(selectedRange);
}
selection.addRange(selectedRange);
}
} else if (document.selection) {
if (selectedRange) {
selectedRange.select()
}
}
},
insertFiles = function (files) {
editor.focus();
Expand Down Expand Up @@ -160,7 +173,7 @@
}
});
};
options = $.extend({}, $.fn.wysiwyg.defaults, userOptions);
options = $.extend(true, {}, $.fn.wysiwyg.defaults, userOptions);
toolbarBtnSelector = 'a[data-' + options.commandRole + '],button[data-' + options.commandRole + '],input[type=button][data-' + options.commandRole + ']';
bindHotkeys(options.hotKeys);
if (options.dragAndDropImages) {
Expand Down

0 comments on commit 4e5bf51

Please sign in to comment.