The problem with this module is that if in the CSS file there is font-size set up for HTML elements, they are not resized. I have rewritten the javascript implementation of this module. Now it works that way:
1) Saves in the cookie how many times the larger/smaller button is clicked;
2) Resizes the text in the scope (can be multiple scopes seperated by comma)
3) Resizing is done recursively for each of the subelements of the scope
4) Resizing is done proportionally (e.g. 10% added for each of the element font size) for each of the elements;
Attachment contains the javascript file and the module. In the module file the scope field is changed to textarea and added small comment for the scope.
Hope to see the changes in the next version of the module!

Comments

milchbar’s picture

Thanks a lot! This seems to work and solves the problem for me.

Great work!

Matt-H’s picture

Does this rewrite include code for the reset button? I'm not seeing anything for 'text_resize_reset'.

attheshow’s picture

Status: Needs review » Needs work

Please submit patches instead of module zip files. Here are the instructions on how to create patches: http://drupal.org/patch/create

arski’s picture

Status: Needs work » Needs review
StatusFileSize
new12.07 KB

k, tried to make a patch out of that.. there were some weird changes, like t() wrappers being removed around text.. I assumed that they were due to an older version of -dev being taken and removed them.. so take a look.

arski’s picture

Status: Needs review » Needs work

quite some issues with this:

1. on load, the font size of the elements selected in the config of the module are set to the maximum size..
2. the proportional increase is slightly buggy, say im increasing two elements, one of which starts at 15 and one at 10, and say the maximum is 18. Now when the first reaches 18, the second will still be at around 14 or something. However, you can still increase it to 18 by clicking on (note that now the first element just stays at 18) so eventually the proportions are lost..

thanks

arski’s picture

erm, you should have also mentioned that your code doesn't work with spaces between the class/id/tag names.. so if in the config it says "field-a, field-b" it will look for ". field-b" and "# field-b" - fail :(

arski’s picture

As for the weird on-load bug, is this code really necessary when a document is loaded??:

		if(font_size != 0)
		for(i=0;i<trs.length;i++) //initialize
		{
			text_resize_scope = trs[i];
			element_to_resize = getResizeScope(text_resize_scope);
			
			element_to_resize.each(function()
			{
				initTextElementSize(this,font_size,resize_step);
			});
		}
arski’s picture

Hey, added a check that checks if all elements are resizable before actually doing it, it's called just before the resize loop around line 30:

			for(i=0;i<trs.length;i++)
			{
				text_resize_scope = trs[i];
				element_to_resize = getResizeScope(text_resize_scope);
				if (!resizableTextElement(element_to_resize,click_id,resize_step)) {
				  return false;
				}
			}
function resizableTextElement(elem,click_id,resize_step)
{
		//check if the children elements are resizable too
		var resizablechildren = true;
		$(elem).children().each(function()
		{
			if (!resizableTextElement(this,click_id,resize_step)) {
			  resizablechildren = false;
			  return;
			}					
		});
		if (!resizablechildren) {
		  return false;
		}
		// Set the current font size of the specified section as a variable
		var currentFontSize = parseFloat($(elem).css('font-size'), 10);
		// javascript lets us choose which link was clicked, by ID
		if (click_id == 'text_resize_increase') {
			var newFontSize = currentFontSize * resize_step;
			// Allow resizing as long as font size doesn't go above text_resize_maximum.
			if (newFontSize > text_resize_maximum)
			{
				return false;
			}
		}
		else if (click_id == 'text_resize_decrease') {
			var newFontSize = currentFontSize / resize_step;
			if (newFontSize < text_resize_minimum-0.001) {
				return false;
			}
		}
		return true;
}

The checks can be then removed from the resizeTextElement function..

I'll leave it to you to put this all together and look through it.. ;)

j.slemmer’s picture

sub

nor4a’s picture

About the text restet to normal size - it happens if the reset button is pressed.
It resets the resize cookie value to 0 - e.g. no resize.
Line: 37. of the code I've submitted.

nor4a’s picture

Reply to #5.
1) We have site running with this module - www.een.lv. Nobady has complained about such a bug so far. Can you tell how to reproduce it?
2) The proportional increase is not buggy, but made exactly the way we wanted to make it. The main purpose of the text increasing feature is accessibility. So - if somebody cannot read the text in the small font - he can use this feature to enlarge the font for reading. If the font is big enough - it is not necessary to enlarge it more, because it is already readable... So we set the "maximum" font size - which we think everybody can read...

arski’s picture

Hey,

I'm not sure how to reproduce it.. sometimes it happens and sometimes not.. not having the code that I mentioned in #7 fixes the issue, and considering that there seems to be no point in that anyway..

As for the proportional resize, your reply does not say anything about the issue. Yes, the idea of this module/plugin is to increase text size. And yes, if it is not big enough it is not necessary to enlarge more. But what I was trying to point out is that it's possible that texts will be selected with different initial sizes, like the usual p tags, together with some headings or whatever.. And in that case, things need to stay proportional.

Cheers

arski’s picture

OK, checked your site, and both issues appear on it:

1. If you go to the page, increase the font size, then reload the page, the sizes will increase automatically without any click. Are you storing this in some cookie or something? Anyway, it's very confusing and annoying.

2. On the home page, the news items in the middle start out with 12px for the text and 13px for the titles. And the maximum you have seems to be 16px. The first 2 times you click to increase the font size, both the title and the text increase simultaneously. However, if you click a 3rd time, the titles will not increase because they're already at the maximum limit, but the text still will increase once, actually becoming slightly bigger than the titles.. either way this breaks the proportions, as mentiong.

Hope this helps.

Cheers

nor4a’s picture

Version: 6.x-1.x-dev » 6.x-1.6
StatusFileSize
new32.6 KB

Yes, I agree... If you start playing with texts more than they are starting to look bad.
So I rewrited the code. Now the text resize limitation is not in pixels, but in "resize times" - e.g. how many times user can click the A button to enlarge the text. Also a new setting now available - "resize step" in %. So by how many % you want to enlarge the text by clicking on the button 1 time.
I'm submitting a patch... for 6.x-1.6 version. The javascript code is completely rewritten. The module code just adds the resize_step setting, makes the scope field as textarea and hides the line_height limitations as I think they are not necessary. Do not know why, but the latest 64bit tortoise SVN created the .module patch as it is is rewritten completely.

arski’s picture

Status: Needs work » Needs review

I'm not a maintainer here, but all patches should be made against the latest -dev, and if you submit one, then set the status to "needs review" so that people can see that there is something to check here ;)

nor4a’s picture

Version: 6.x-1.6 » 6.x-1.x-dev
StatusFileSize
new17.32 KB

Patch against the latest dev release attached.
It seams that majority of the font resizing problems fixed.
Small configuration changes implemented to avoid unexpected font sizes in IE which can occure with CSS features such as providing font sizes in %.

mgifford’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)
mgifford’s picture

Unless this should be bumped to D7 or D8...