Re-engineered toggles' commit.
Post new topic   Reply to topic   Printer Friendly Page     Forum IndexCVS Info
Author Message
NanoCaiordo
Developer


Joined: Jun 29, 2004
Posts: 3661
Location: Melbourne, AU

PostPost subject: Re-engineered toggles' commit.
Posted: Wed Nov 09, 2011 12:04 pm
Reply with quote

The classic Javascript used to collapse and expand blocks and theme sides has changed.

It now have a name and its used to improve the overall usability of the software and take the burden off plug-ins (modules and blocks) developers. Less PHP, less HTML, less Javascript it's now required to run this feature within themes, modules and blocks it self. It also stops using the Blocks PHP class.

Togglers and toggles.
Every HTMLElement having "toggle" in the class attribute list will be used to collapse or expand another HTMLElement.
Basically the same actions provided by the current javascript functions but done at DOM level with a very little help from HTML and handled by one object only.

Moreover it was written to be configurable and dynamic as possible. Configurable items are:
  • The Toggler class name to be used instead of default "toggle" value.
  • The cookie to be used.
  • Image names if you wish to use different defaults.

What you should know:
It needs to be loaded from theme.php.
The theme can either use the default JavaScript file by directly loading themes/default/javascript/toggle.js or be packaged with its own.
In the latter the new theme.php needs no modifications.
Please refer to the current 16 lines shorter theme.php and updated header.html.

Changing class name:
By changing this value your theme will use both shared and own data.
Off course it needs to use the shared cookie to be able to work with shared data.

Changing cookie name:
If you have many themes, lot of blocks and many modules using this feature will keep the internal processing fast as it should.

Note that by changing any of the above settings in all your active themes, performances will gradually deteriorate because http requests and responses will have more cookie data.
Talking only about a bunch of milliseconds but not wise to have big cookies.

Having said this, webmasters of websites with many modules and dozens of blocks must be aware of the consequences of having each theme with its own settings.

Changing images name
Nothing special but might be useful to some.
An image as Toggler will always automatically have the image source replaced. No more php/html/javascript code is needed.

How to use it:
In theme.php
PHP:
	JS::add(THEME_PATH. 'javascript/toggle.js');

In your .html
Quote:
/* Static call. Notice that in html files you should always use minus.gif. */
<img class="toggle" id="toggleLeftSide" src="{THEME_PATH}/images/minus.gif" alt="L_(TOGGLE)" title="L_(TOGGLE)" />
<td id="LeftSide">


/* Dynamic call within template BEGINs blocks . */
<!-- BEGIN leftblock -->
<div class="toggle" id="toggleBlock{leftblock.S_BID}" title="_(TOGGLE)"></div>
<div id="Block{leftblock.S_BID}"></div>
<!-- END leftblock -->


Note: The Toggler's id "toggleLeftSide" is composed by two parts.
Part 1. "toggle" the class name
Part 2. "LeftSide" the id to collapse/expand.
The HTMLElement id needs to be accordingly written to match the class name in use.

Feature request
Probably the most important feature of many now existing: Ability to define the default state of the HTMLElement (collapsed or expanded).

_________________
.:: I met php the 03 December 2003 :: Unforgettable day! ::.

NanoCaiordo's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
MySQL 5.1 / PHP 5.3 / NextGen()
Back to top
View user's profile Visit poster's website
greenday2k
Forum Admin


Joined: Aug 11, 2005
Posts: 485
Location: CO

PostPost subject: Re: Re-engineered toggles' commit.
Posted: Fri Nov 11, 2011 4:58 am
Reply with quote

Neat solution Nano.

JS::add(THEME_PATH. 'javascript/toggle.js');

Will laod the javascript as JS::add(insertJSfile.js);

But and the Head or at the end of the body?

Is it possible to suggest to load all the java scripts right before the </body> tag?

(I need to test more the CVS), will be loading the java-scripts asynchronous if not?


Edit: Checked the theme.php, nah is soo easy to control ;D
Great my site uses all the javascript wirtten to be loaded at the end ;D.

_________________
www.greenday2k.net



greenday2k's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website MSN Messenger Yahoo Messenger
NanoCaiordo
Developer


Joined: Jun 29, 2004
Posts: 3661
Location: Melbourne, AU

PostPost subject: Re: Re-engineered toggles' commit.
Posted: Fri Nov 11, 2011 9:25 am
Reply with quote

Glad you like it along other changes ... and more to come Shocked
_________________
.:: I met php the 03 December 2003 :: Unforgettable day! ::.

NanoCaiordo's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
MySQL 5.1 / PHP 5.3 / NextGen()
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   Printer Friendly Page     Forum IndexCVS Info All times are GMT
Page 1 of 1


Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

stopsoftwarepatents.eu petition banner
User Info [x]

Welcome Anonymous

Nickname
Password
(Register)

Last CVS commits [x]

Languages [x]

Community [x]

Support for DragonflyCMS in a other languages:

Deutsch
Español

X-links [x]
UltraEdit Browse Happy logo Firefox MySQL PostgreSQL Valid CSS! Valid XHTML 1.0! Unicode Encoded Badge NukeBiz Resources Raven DragonflyCMS Dedicated Now InsideSupport Lampe Berger

Preview theme [x]
Each user can view the site with a different theme.
Themes marked with a * also change the forum look.


You are seeing squares or questionmarks on this page?

All content of this website is copyrighted by the Creative Commons NC-SA
The logos and trademarks used on this site are the property of their respective owners
We are not responsible for comments posted by our users, as they are the property of the poster.
Our server runs on a P3 1.2GHz with 512MB RAM with no accelerators
Support GoPHP5.org
This page generated in 1.0986 seconds with 20 DB Queries in 0.1303 seconds
Memory Usage: 2.88 MB
Interactive software released under GNU GPL, Code Credits, Privacy Policy