Jump to content


- - - - -

100% Canvas Height for Manager iframe/textarea elements


  • You cannot reply to this topic
9 replies to this topic

#1 elephant

    Etomite Forum Newbie

  • Member
  • 38 posts

Posted 10 March 2007 - 05:25 AM

Hi,

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:

<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>


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 Randy

    Likes Etomite Forums!

  • Member
  • PipPip
  • 309 posts

Posted 10 March 2007 - 05:46 AM

Great! Just haven't had the time. Thanks for doing this.

Ralph.... test for 0614 please :D

#3 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 10 March 2007 - 04:02 PM

I will test the code but must also stress that hacks of the code base should be passed by me before public posting... That is, unless the poster, elephant, wants to take over managing code base support... We, as a support team, cannot support a code base that has had this hack and that hack tossed in without our knowledge... So, at this time this code is to be classified as an "unofficial mod"... I will, however, leave this thread open for discussion...

#4 Randy

    Likes Etomite Forums!

  • Member
  • PipPip
  • 309 posts

Posted 10 March 2007 - 04:33 PM

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.

Edited by Randy, 10 March 2007 - 04:34 PM.


#5 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 10 March 2007 - 05:16 PM

View PostRandy, on Mar 10 2007, 11:33 AM, said:

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.
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...

#6 elephant

    Etomite Forum Newbie

  • Member
  • 38 posts

Posted 10 March 2007 - 11:45 PM

View PostRalph, on Mar 11 2007, 04:16 AM, said:

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 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 11 March 2007 - 04:41 AM

View Postelephant, on Mar 10 2007, 06:45 PM, said:

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
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...

NUFF SAID...

#8 cathode

    Loves Etomite Forums!

  • Staff
  • 648 posts
  • Gender:Male

Posted 11 March 2007 - 08:07 PM

I like this idea, I hope it makes the cut.

#9 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 11 March 2007 - 09:33 PM

So far these modifications appear to be working well in all browsers tested... At this point they will most likely be included in the 0614 code base... I see no reason not to unless I run into problems with some obscure OS/Browser combination...

#10 Randy

    Likes Etomite Forums!

  • Member
  • PipPip
  • 309 posts

Posted 19 March 2007 - 12:50 AM

Hello everyone,

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users