Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Ravi Teja
Font-Resize using Cookie is not working for Hooks and Theam Content
March 18, 2013 4:45 AM
Answer

Ravi Teja

Rank: New Member

Posts: 21

Join Date: July 9, 2012

Recent Posts

Hi All,

In my Project i got The requirement to change the Font(in 3 different sizes)Like thisurl.
I followed this link and implementedJqueryFontchanger
It is working. I included Js&Css file in Theam.
But it working for Portlets and web-contents.
But it is not working for Hooks & Theams (The content present inside theam). & Control panel alsoemoticon

My requirement is i need to change the Font in Entire Portal and need to set the font size in Cookies.

Could you please some will help on this issue.

Thanks in advance.
Ravi
Apoorva Prakash
RE: Font-Resize using Cookie is not working for Hooks and Theam Content
March 18, 2013 5:02 AM
Answer

Apoorva Prakash

Rank: Liferay Master

Posts: 659

Join Date: June 15, 2010

Recent Posts

Ravi Teja:
Hi All,

In my Project i got The requirement to change the Font(in 3 different sizes)Like thisurl.
I followed this link and implementedJqueryFontchanger
It is working. I included Js&Css file in Theam.
But it working for Portlets and web-contents.
But it is not working for Hooks & Theams (The content present inside theam). & Control panel alsoemoticon

My requirement is i need to change the Font in Entire Portal and need to set the font size in Cookies.

Could you please some will help on this issue.

Thanks in advance.
Ravi


Hi Ravi,

I'm not sure about jQuery, but I did used some javascript code, have a look:

 1var min=8;
 2var max=18;
 3function increaseFontSize() {
 4
 5   var p = document.getElementsByTagName('p');
 6   for(i=0;i<p.length;i++) {
 7
 8      if(p[i].style.fontSize) {
 9         var s = parseInt(p[i].style.fontSize.replace("px",""));
10      } else {
11
12         var s = 12;
13      }
14      if(s!=max) {
15
16         s += 1;
17      }
18      p[i].style.fontSize = s+"px"
19
20   }
21}
22function decreaseFontSize() {
23   var p = document.getElementsByTagName('p');
24   for(i=0;i<p.length;i++) {
25
26      if(p[i].style.fontSize) {
27         var s = parseInt(p[i].style.fontSize.replace("px",""));
28      } else {
29
30         var s = 12;
31      }
32      if(s!=min) {
33
34         s -= 1;
35      }
36      p[i].style.fontSize = s+"px"
37
38   }
39}


see this link also, I was taken it form here...

Hope this will help...

Thanks and Regards,
Apoorva Prakash
Ravi Teja
RE: Font-Resize using Cookie is not working for Hooks and Theam Content
March 18, 2013 5:58 AM
Answer

Ravi Teja

Rank: New Member

Posts: 21

Join Date: July 9, 2012

Recent Posts

Hi Prakash,

Thanks for Reply.

I already Tried in this way.But after refreshing the page. again the font is going to original size.
and that to it is not reflecting on Entire portal. just it is Effecting on current page only.
My requirement is i need to change the Font-size in Entire portal.
That means if i changed Font-size in one page the same Font-size i have to maintain in all the pages.

Any Idea?

Thanks
Ravi
Apoorva Prakash
RE: Font-Resize using Cookie is not working for Hooks and Theam Content
March 18, 2013 6:33 AM
Answer

Apoorva Prakash

Rank: Liferay Master

Posts: 659

Join Date: June 15, 2010

Recent Posts

Hi Ravi,

Ravi Teja:
But after refreshing the page. again the font is going to original size.

You have to modify code for reading the changed font value from cookie.

Ravi Teja:
and that to it is not reflecting on Entire portal. just it is Effecting on current page only.
My requirement is i need to change the Font-size in Entire portal.
That means if i changed Font-size in one page the same Font-size i have to maintain in all the pages.

You need to put the code in theme js and call it in portal_normal.vm so that every page read value from same cookie. and obviously the value will be reflected on other pages after refreshing the page.

Hope this will help...

Thanks and Regards,
Apoorva Prakash
Ravi Teja
RE: Font-Resize using Cookie is not working for Hooks and Theam Content
March 18, 2013 7:18 AM
Answer

Ravi Teja

Rank: New Member

Posts: 21

Join Date: July 9, 2012

Recent Posts

Apoorva Prakash:
Hi Ravi,

Ravi Teja:
But after refreshing the page. again the font is going to original size.

You have to modify code for reading the changed font value from cookie.


HI Prakash,

I Done the same thing in 2 days back.I have posted this link also but the problem with that it is not working for theam content, Hooks and as well as control panel.
Here i am sending image regarding the issue.Can you please observe the Image.

How can i solve? can you please help me regarding this.

Thanks & Regards
Ravi
Attachment

Attachments: testFont.png (114.7k)
Ravi Teja
RE: Font-Resize using Cookie is not working for Hooks and Theam Content
March 19, 2013 2:36 AM
Answer

Ravi Teja

Rank: New Member

Posts: 21

Join Date: July 9, 2012

Recent Posts

Any idea Regarding the above Issue?

kindly Help me.

Thanks in Advance
Ravi
Ravi Teja
RE: Font-Resize using Cookie is not working for Hooks and Theam Content
March 21, 2013 12:02 PM
Answer

Ravi Teja

Rank: New Member

Posts: 21

Join Date: July 9, 2012

Recent Posts

hi Friends,

Finally i got the solution.

I used cookies to store Font size.
Below is my sample code.
1.Keep this code in Theam.
 1
 2<head>
 3<script type="text/javascript">ndeSetTextSize();</script>
 4</head>
 5<body onload="init()">
 6<div>Font size:
 7<font size="3"><a href="javascript:void(0);" onclick="ndeSetTextSize('decr');">A</a></font>
 8<font size="5"><a href="javascript:void(0);" onclick="ndeSetTextSize('reset');">A</a></font>
 9<font size="6"><a href="javascript:void(0);" onclick="ndeSetTextSize('incr');">A</a></font> 
10</div>
11</body>

2.Add Javascript in main.js
(please find attachment for js file)

If you want to restrict maximum and minimum size of Font do the Following changes in Js file
// here minimum size
if (newSize < 12)
{
newSize = 12;
}
//
here maximum size
if (newSize > 16)
{
newSize = 16;
}

Here i am attaching a simple portlet also.

i think This code will help to some one like me emoticon

and thanks Apoorva Prakashemoticon For helping.

Thanks&Regards
Ravi
Attachments: Font-Resize-portlet.rar (22.5k), fontresize.js (2.7k)
Apoorva Prakash
RE: Font-Resize using Cookie is not working for Hooks and Theam Content
March 21, 2013 7:23 AM
Answer

Apoorva Prakash

Rank: Liferay Master

Posts: 659

Join Date: June 15, 2010

Recent Posts

Ravi Teja:
Any idea Regarding the above Issue?

kindly Help me.

Thanks in Advance
Ravi


It should work, there is no doubt about it!
Ravi Teja
RE: Font-Resize using Cookie is not working for Hooks and Theam Content
March 21, 2013 8:19 AM
Answer

Ravi Teja

Rank: New Member

Posts: 21

Join Date: July 9, 2012

Recent Posts

Apoorva Prakash:
Ravi Teja:
Any idea Regarding the above Issue?

kindly Help me.

Thanks in Advance
Ravi


It should work, there is no doubt about it!



HI prakash,
yes,i got the solution.Thanks for your help.



Thanks&Regards
Ravi
Apoorva Prakash
RE: Font-Resize using Cookie is not working for Hooks and Theam Content
March 21, 2013 10:24 AM
Answer

Apoorva Prakash

Rank: Liferay Master

Posts: 659

Join Date: June 15, 2010

Recent Posts

Ravi Teja:

i think This code will help to some one like me emoticon

and thank Apoorva Prakashemoticon For helping.


Welcome Ravi...