What?

The javascript_libs plugin is a Squirrelmail "library" plugin that allows Squirrelmail plugin developers to easily take advantage and make use of popular javascript libraries and frameworks.

Why?

The Sieve Mail filters plugin (avelsieve) was in need of some usability improvements and UI effects. These had to be done as an option, so that the UI would degrade nicely if a browser would not support Javascript. Thus, javascript_libs was born.

And because other plugin authors might want to take advantage of the plugin's feature, in order to take advantage of Javascript frameworks or introduce Javascript effects themselves, this small piece of documentation was written and the plugin is released properly.

A Guide to Users / Administrators

Simply untar the plugin under your Squirrelmail plugins/ directory and enable it in Squirrelmail configuration.

A Guide to Plugin Authors / Developers

Purpose / Motivation

The purpose of the plugin is to:

  1. Provide some popular javascript libraries and frameworks (prototype, scriptaculous, lightbox) in an easy to install squirrelmail plugin package.
  2. Provide plugins or Squirrelmail core code, with a function that they can use to enable the usage of such a library / framework very easily. How easily you say?

    This easily:
    javascript_libs_register('src/read_body.php', array('prototype-1.6.0/prototype.js','scriptaculous/scriptaculous.js'));
    
  3. Handle some basic dependencies between libraries. For instance, if a plugin wants to use scriptaculous, then prototype.js is also included.
  4. Allow two or more plugins to use the same javascript files / libraries, in the same page, but in the end include them only once.
  5. Usage

    All is accomplished by a simple hook called javascript_libs_register.

    In your plugin's setup.php, you need to do two things:

    In the plugin register function, make a hook to a custom function:

    function squirrelmail_plugin_init_example_plugin() {
        global $squirrelmail_plugin_hooks;
        $squirrelmail_plugin_hooks['javascript_libs_register']['example_plugin'] = 'image_lightbox_register';
        /* Other plugin hooks... */
    }
    

    And then, create the corresponding function, which should look like this:

    function example_plugin_register_jslibs() {
        global $plugins;
        if(in_array('javascript_libs', $plugins)) {
            javascript_libs_register('plugins/example_plugin/script.php', array('prototype-1.6.0/prototype.js','scriptaculous/scriptaculous.js'));
            javascript_libs_register('src/right_main.php', array('prototype-1.6.0/prototype.js'));
        }
    }
    

    The javascript_libs_register() takes two arguments:

    Future Work and Ideas

    The javascript_libs plugin is focusing toward usage of plugins in the Squirrelmail stable (1.4) branch. The development branch of Squirrelmail, 1.5.x, has implemented templating. So, if certain javascript functionality is desired, especially across many pages of the Squirrelmail interface, it would be best to create or extend the actual templates themselves.

    However, when the 1.5.x tree grows up to more widespread usage, and if the usage of javascript_libs is becoming popular among plugins, it is expected that this plugin will work nicely in Squirrelmail 1.5.x too, in a backward-compatible way.

    License

    javascript_libs License

    Copyright © 2007 Alexandros Vellis, The Squirrelmail Project Team

    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    Invididual Libraries / Scripts

    The licenses for each library and script bundled in this file, are included in the subdirectory docs/module_name of the plugin.

    minify License

    javascript_libs comes with minify, a javascript / CSS optimizer, which has the following copyright notice and license terms:

    Copyright © 2007 Ryan Grove 
    All rights reserved.
    
    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:
    
      * Redistributions of source code must retain the above copyright notice,
        this list of conditions and the following disclaimer.
      * Redistributions in binary form must reproduce the above copyright notice,
        this list of conditions and the following disclaimer in the documentation
        and/or other materials provided with the distribution.
      * Neither the name of this project nor the names of its contributors may be
        used to endorse or promote products derived from this software without
        specific prior written permission.
    
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
    ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    

    TODO

    Links

    Bundled javascript libraries and scripts

    Prototype Javascript Framework
    http://prototypejs.org/

    Scriptaculous
    http://script.aculo.us/

    LightBox 2.0
    http://www.huddletogether.com/projects/lightbox2/

    LightBox Plus
    http://serennz.sakura.ne.jp/toybox/lightbox/?en