General ⇒ DVCS Info (Mercurial/CVS) ⇒ Re-engineered toggles' commit. ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum IndexDVCS Info (Mercurial/CVS)

Re-engineered toggles' commit. Reply to topic


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
	JS::add(THEME_PATH. 'javascript/toggle.js');


In your .html
/* 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! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


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

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


Glad you like it along other changes ... and more to come Shocked

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

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS

All times are UTC


Jump to: