100% Canvas Height for Manager iframe/textarea elements
#1
Posted 10 March 2007 - 05:25 AM
I have come up with some javascript that automatically re-sizes, manager: iframe and textarea elements to the height of the available browser canvas area.
I have personally implemented this in:
resource -> templates/snippets/chunks management [textarea]
content -> edit [textarea] (I don't use an editor)
content -> preview [iframe]
The changes have been tested in Firefox 2.0.0.2/Win and IE6/Win.
The code is essentially the same, apart from minor differences addressing the iframe and textarea elements and adjustments to the x-factor (an allowance for top frame)
The code politely handles existing onloads (this is probably unnecessary at the moment)
This is the javascript for a textarea:
[codebox]<script type="text/javascript">
// 2007/03/09 ~sl - Dynamically Resize textarea
// handle onload
var nowOnload = window.onload; // save any existing assignment
window.onload = function () {
resizer();
if(nowOnload != null && typeof(nowOnload) == 'function') {
nowOnload();
}
}
// handle browser resize
onresize=resizer;
function resizer() {
scrollTo(0,0);
var x = 27 // allowance
var y = window.innerHeight ? window.innerHeight : document.body.clientHeight;
var t = document.mutate.post; // the textarea
var o = y-findTop(t)-x;
t.style.height=Math.max(1,o);
}
function findTop(obj) {
curtop = 0;
if (obj.offsetParent) {
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curtop += obj.offsetTop
}
}
return curtop;
}
</script>[/codebox]
Instructions:
To implement for resource -> templates/snippets/chunks management [textarea], add the code to these three files:
/manager/actions/dynamic/mutate_snippet.dynamic.action.php
/manager/actions/dynamic/mutate_templates.dynamic.action.php
/manager/actions/dynamic/mutate_htmlsnippet.dynamic.action.php
_____________________________________________________
To implement for content -> edit [textarea], add the code to:
/manager/actions/dynamic/mutate_content.dynamic.action.php
There is 1 other change required to this file.
Replace:
20 var t = document.mutate.post; // the textarea
With:
20 var t = document.mutate.ta; // the textarea
** NOTE ** I do not use an editor and have not tested this with an editor ! **
_____________________________________________________
To implement for content -> preview [iframe], add the code to:
/manager/actions/static/document_data.static.action.php
Then:
Replace:
18 var x = 27 // allowance
20 var t = document.mutate.post; // the textarea
With:
18 var x = 42 // allowance
20 var t = document.getElementById("preview"); // the iframe
Finally, an id needs to be added to the iframe -> id="preview".
_____________________________________________________
I am sure the code could be streamlined somewhat, and perhaps implemented at a higher level, but at least it is a start.
Good Luck.
Sean
#2
Posted 10 March 2007 - 05:46 AM
Ralph.... test for 0614 please
#3
Posted 10 March 2007 - 04:02 PM
#4
Posted 10 March 2007 - 04:33 PM
For clarity, I have made no source changes at all related to this.
Edited by Randy, 10 March 2007 - 04:34 PM.
#5
Posted 10 March 2007 - 05:16 PM
My comment was in relation to this thread being started by elephant, Randy, and had no reference to your post... Our stance on posting core modifications is clearly stated in the forum guidelines, or at least was, and I was merely re-iterating that policy here - just as I do with every other forum thread of this nature... While not one of my favorite tasks, someone has to "administer" the forums and that is why Dean and I are Admins... I'll be checking out the code later today, hopefully...My request was for you to review and consider. This (screen size vs. edit box size) is something that affects me every day with Eto and think it is worthy of your consideration.
For clarity, I have made no source changes at all related to this.
#6
Posted 10 March 2007 - 11:45 PM
My comment was in relation to this thread being started by elephant, Randy, and had no reference to your post... Our stance on posting core modifications is clearly stated in the forum guidelines, or at least was, and I was merely re-iterating that policy here - just as I do with every other forum thread of this nature... While not one of my favorite tasks, someone has to "administer" the forums and that is why Dean and I are Admins... I'll be checking out the code later today, hopefully...
Ralph,
Apologies for not checking this with you first.
I assumed that "Unofficial Manager Mods" was an appropriate place for this sort of thing. I was not aware that it needed to be cleared first.
The modifications were designed to be dropped in with minimal impact on the existing code. In most cases there is no change required to existing code, only the addition of javascript.
Sean
#7
Posted 11 March 2007 - 04:41 AM
No problem... While this is the right place, I just don't like surprises... To elaborate, if I don't get a chance to do some testing then I could end up with a whole lot of new support issues that might creep up due to changes to the code base that seemingly come out of nowhere and then I'm scrambling to figure out where they came from... In light of the possibility of such a scenario, having had examined the code and having done some testing might possibly either circumvent such a fiasco or might at least give some insight as to where to look based on whether or not the code base in question had been modified... It would really suck to waste a day attempting to debug a site only to find the the problem was due to a hacked code base... Needless to say, I wouldn't be a happy camper...Ralph,
Apologies for not checking this with you first.
I assumed that "Unofficial Manager Mods" was an appropriate place for this sort of thing. I was not aware that it needed to be cleared first.
The modifications were designed to be dropped in with minimal impact on the existing code. In most cases there is no change required to existing code, only the addition of javascript.
Sean
NUFF SAID...
#8
Posted 11 March 2007 - 08:07 PM
#9
Posted 11 March 2007 - 09:33 PM
#10
Posted 19 March 2007 - 12:50 AM
These mods have [tentatively] been added to the 0614 base. I tested with the available editors without any problems at all. Dean will test with Safari for me and Ralph still needs to validate and approve the changes. As long as I didn't miss anything in the testing, it appears this will make the cut.
That's good news!
Sean, If you have more ideas, please PM one of us with the details. And a big THANKS for contributing.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











