PDA

View Full Version : Joomla 1.5 Pagebreak Inserts at Top: Solved


Olin Coles
26th November 2008, 01:08 PM
I've had a go at solving the issues with inserting pagebreaks in articles using Internet Explorer.
Currently, when you insert a pagebreak in IE it inserts it at the top of the document, not at the current caret position. In IE it's possible to drag the pagebreak to the correct location, but our client desired a uniform behaviour across all browsers so here goes....

In IE the editor loses focus and the selection when the "light-box" pops up prompting the page title, so we have to save and restore the current position before the insert. We can achieve this in tinyMCE using it's getBookmark and moveToBookmark methods.

We need to change two Joomla files.

First one, /administrator/components/com_content/admin.content.html.php

Find "function insertPagebreak()" and before the "var tag=" line add the following.

Code:
var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
var isOpera = window['opera'] && opera.buildNumber ? true : false;
var isRealIE = isMSIE && !isOpera;
if (isRealIE && window.parent.tinyMCE) {
window.parent.tinyMCE.selectedInstance.selection.m oveToBookmark(window.parent.pagebreak_bookmark);
}



Second file, /plugins/editors-xtd/pagebreak.php

Find "function onDisplay"

Between the "$doc=" and "$template=" lines add the following...


Code:
$js = "
var pagebreak_bookmark;
function prePagebreak(editor) {
if (typeof(window['tinyMCE']) == \"undefined\" ) return true;
var isMSIE = (navigator.appName == \"Microsoft Internet Explorer\");
var isOpera = window['opera'] && opera.buildNumber ? true : false;
var isRealIE = isMSIE && !isOpera;
if (!isRealIE) return true;
if (!tinyMCE) return true;
pagebreak_bookmark = tinyMCE.selectedInstance.selection.getBookmark();
var e = window.event;
return true;
}
";
$doc->addScriptDeclaration($js);



Then add the following before the "return $button" line.

Code:
$button->set('onclick', 'prePagebreak(\''.$name.'\');');



I'm very new to Joomla so there may be a better way of excluding the code from non-IE browsers, but this code does seem to work.

Cheers,
Allan McDaniels

egrueda
4th May 2009, 03:04 PM
It's been a time since you left this post, but anyway I wanted to let you know it's been really useful for me, now this "bug" is solved and I thank you so much.

Cheers from Spain, and thanks again