[TYPO3-ect] New Extension JS-Manager
Steve Ryan
stever at syntithenai.com
Fri Nov 9 04:38:14 CET 2007
Hi Jeorg,
a few thoughts
Jquery is great. You've jquery and prototype and yahoo?? offering a
low level selector/ajax/dom library and then things like ext and
scriptaculous offering widgets and windows. A lot of the widgets and
windows features are available as extensions to jquery (albeit not quite
so smooth as the big libraries). Purely for the extension community
(similar to our own) providing lots of examples (excellent and not so
excellent), Jquery is my favorite.
Dynamic Inclusion
PHP registration so that an application can choose at runtime what js
libraries are required. For example, generating dynamic forms, the color
selector js is not required if the the color field type is not in use.
For that reason I like your jquery implementation.
Rendering at the end of the page
On slower connections the argument for rendering js at the end of a
page has merit. Is header data the right place to be putting all the
javascript includes? or rendered as the last content object on a page.
Integration with individual js extensions
Fundamentally a javascript extension is a collection of the scripts
and css files in that particular js library.
These scripts can be typically be grouped as a css file and js file
and possibly some script output in a fileset. Typically there are
dependancies between the filesets eg jquery.ui depends jquery.base
We want to be able to ask from our extensions to ensure that the
output contains references to a particular functioning library and its
dependancies.
Sometimes we want to ask for the library excluding certain
dependancies because they already loaded in the page and our ajax
request only needs one extra library.
We have typoscript cascading configuration to work with.
We may need to ask for specific versions of a library.
A js lib extension could register itself by providing TS for the
jsmanager when its static template is installed
eg in the jquery extension a static template could provide
plugin.jsmanager.libraries.jquery {
base {
include=EXT:jquery/jquery.base.js
include.compressed=EXT:jquery/jquery.base.compressed.js
css=
script (
$(document).ready(
function () {
$('myselector').enable();
}
);
)
depends=
}
ui.base {
include=EXT:jquery.ui.base.js
depends=jquery.base
}
}
plugin.jsmanager.libraries.jquery.versions.011 <
plugin.jsmanager.libraries.jquery
class jsmanager {
$librariesToLoad;
/***********************************
* provide reference to single global singleton instance
***********************************/
function getInstance() {}
/***********************************
* This function is called on a singleton by various extensions using
js libraries
* parameter $libraryKey comma and dot seperated string eg
jquery.base,jquery.ui.window
***********************************/
function requestJSLibrary($libraryKey,$noDeps=false) {
// add requested libraries (explode comma) into the librariesToLoad arrray
// ?? what happens if library is not available (or version not available)
// if not $noDeps, cascade dependancies
}
/***********************************
* This function is called on the singleton js manager to output the
sum of the javascript library resources.
***********************************/
function renderJSLibraries() {
// iterate $librariesToLoad building unique include, css, and script
strings for each library key built from the available libraries conf (at
this point in the tree) which are concatenated and returned.for
injection into the base of the page
}
}
.
Including a section of TS in a static template is fairly easy way for
javascript library extension developers to offer/register their libraries
What do you think?
Steve
Joerg Schoppet wrote:
> Hi,
>
> after some discussion with Steffen Kamper about a general way for
> including external js-libraries, here are my thoughts about it:
>
> The extension will be called "jsmanager". The extension on its own can
> do nothing :-)
>
> Every js-library have to be added to the ter with its own extension
> (e.g. jquery, extjs)
>
> Each extension have to implement an interface of jsmanager and have to
> register itself to jsmanager.
>
> After this, on each page, where you need it, you can include a
> ts-template for jsmanager, within this there is some predefined ts-code.
> jsmanager can now check each condition (saying which jslib to include
> and calls a predefined (interface) method of the adequate class in the
> specific js-lib-extension. the class in each js-lib-extension is
> responsible for defining all the necessary script-, css-tags and
> returning them to jsmanager.
> After processing the config, jsmanager does the inclusing in the page-hader.
>
> Additionally there will be perhaps a programming-interface to call the
> jsmanager-functions directly within an extension.
>
> The last step will be a backend-module, which lists all registered
> js-libs and the possible config-options.
>
>
> Any comments?
>
> Regards
>
> Joerg Schoppet
More information about the TYPO3-team-extension-coordination
mailing list