The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#4
|
||||
|
||||
![]()
Because of an issue reported to me by one of my fellow administrators, who uses a different OS (I use Windows 7 and he uses Xubuntu and we both use Firefox), I have moved the focus method to the end of the moveCaret function, and this alleviates the need to make two calls to the moveCaret function (which I used previously so that Chrome did not lose the cursor).
So, the updated functions are: Code:
function copyMathToPost() { var content = document.getElementById('MathInput').value, el = document.getElementsByClassName('cke_source')[0]; if (el) { var pos = getCaretPosition(el); el.value = el.value.substr(0, pos) + content + el.value.substr(pos); setCaretPosition(el,pos + content.length); el.focus(); } else { var iFrame = document.getElementsByTagName('iframe')[0]; insertHtmlAtCursor(iFrame,content); moveCaret(iFrame, 0); } } function insertHtmlAtCursor(iFrame,html) { var sel, range, node; html = html.replace(/\r\n?|\n/g, '<br>'); if (iFrame.contentWindow.getSelection && iFrame.contentWindow.getSelection().getRangeAt) { sel = iFrame.contentWindow.getSelection(); try{range = sel.getRangeAt(0);} catch (e){alert("This function is not supported by your browser. Please switch editor to Source Mode.");} node = range.createContextualFragment(html); range.insertNode(node); range = range.cloneRange(); range.collapse(); sel.removeAllRanges(); sel.addRange(range); } else if (iFrame.contentWindow.selection && iFrame.contentWindow.selection.createRange) { iFrame.contentWindow.selection.createRange().pasteHTML(html); } else { alert("This function is not supported by your browser. Please switch editor to Source Mode."); } } function moveCaret(win, charCount) { var sel, range; if (win.contentWindow.getSelection) { sel = win.contentWindow.getSelection(); if (sel.rangeCount > 0) { var textNode = sel.focusNode; var newOffset = sel.focusOffset + charCount; sel.collapse(textNode, newOffset); } } else if (sel = win.contentDocument.selection) { if (sel.type != "Control") { range = sel.createRange(); range.move("character", charCount); range.select(); } } win.focus(); } |
Благодарность от: | ||
tbworld |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|