mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-01 14:05:07 +03:00
фикс панели редактора текста в IE
This commit is contained in:
parent
57144ec582
commit
ef5922787f
|
@ -6,8 +6,14 @@ var lsPanelClass = new Class({
|
|||
putText: function(obj,text) {
|
||||
obj=$(obj);
|
||||
var scrollLeft=obj.scrollLeft;
|
||||
var scrollTop=obj.scrollTop;
|
||||
obj.insertAtCursor(text);
|
||||
var scrollTop=obj.scrollTop;
|
||||
if (Browser.Engine.trident && document.selection) {
|
||||
obj.focus();
|
||||
sel=document.selection.createRange();
|
||||
sel.text=text;
|
||||
} else {
|
||||
obj.insertAtCursor(text);
|
||||
}
|
||||
obj.scrollLeft=scrollLeft;
|
||||
obj.scrollTop=scrollTop;
|
||||
},
|
||||
|
@ -19,12 +25,18 @@ var lsPanelClass = new Class({
|
|||
putTextAround: function(obj,textStart,textEnd) {
|
||||
obj=$(obj);
|
||||
var scrollLeft=obj.scrollLeft;
|
||||
var scrollTop=obj.scrollTop;
|
||||
obj.insertAroundCursor({
|
||||
before: textStart,
|
||||
defaultMiddle: '',
|
||||
after: textEnd
|
||||
});
|
||||
var scrollTop=obj.scrollTop;
|
||||
if (Browser.Engine.trident && document.selection) {
|
||||
obj.focus();
|
||||
sel=document.selection.createRange();
|
||||
sel.text = textStart+sel.text+textEnd;
|
||||
} else {
|
||||
obj.insertAroundCursor({
|
||||
before: textStart,
|
||||
defaultMiddle: '',
|
||||
after: textEnd
|
||||
});
|
||||
}
|
||||
obj.scrollLeft=scrollLeft;
|
||||
obj.scrollTop=scrollTop;
|
||||
},
|
||||
|
@ -46,23 +58,22 @@ var lsPanelClass = new Class({
|
|||
|
||||
putQuote: function(obj) {
|
||||
obj=$(obj);
|
||||
if (selText=window.getSelected()) {
|
||||
if (selText=this.getSelectedText()) {
|
||||
this.putText(obj,'<blockquote>'+selText+'</blockquote>');
|
||||
} else {
|
||||
this.putTagAround(obj,'blockquote');
|
||||
}
|
||||
},
|
||||
|
||||
getSelectedText: function(){
|
||||
if (Browser.Engine.trident) return document.selection.createRange().text;
|
||||
//if (window.khtml) return window.getSelection();
|
||||
return document.getSelection();
|
||||
}
|
||||
});
|
||||
|
||||
var lsPanel;
|
||||
|
||||
window.addEvent('domready', function() {
|
||||
$extend(window,{
|
||||
getSelected: function(){
|
||||
if (this.ie) return document.selection.createRange().text;
|
||||
if (this.khtml) return this.getSelection();
|
||||
return document.getSelection();
|
||||
}
|
||||
});
|
||||
window.addEvent('domready', function() {
|
||||
lsPanel = new lsPanelClass();
|
||||
});
|
Loading…
Reference in a new issue