Difference: BehaviourContrib (1 vs. 10)

Revision 1006 Jul 2018 - TWikiContributor

Line: 1 to 1
 

Behaviour Javascript Framework Contrib

Revision 917 Feb 2015 - TWikiContributor

Line: 1 to 1
 

Behaviour Javascript Framework Contrib

Changed:
<
<
>
>
  Behaviour Javascript event library to create Javascript based interactions that degrade well when Javascript is not available
Line: 270 to 270
 

Installation Instructions

Changed:
<
<
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server where TWiki is running.

Like many other TWiki extensions, this module is shipped with a fully automatic installer script written using the BuildContrib.

  • If you have TWiki 4.2 or later, you can install from the configure interface (Go to Plugins->Find More Extensions)
>
>
  • For an automated installation, run the configure script and follow "Find More Extensions" in the in the Extensions section.
 
Deleted:
<
<
  • If you have any problems, then you can still install manually from the command-line:
    1. Download one of the .zip or .tgz archives
    2. Unpack the archive in the root directory of your TWiki installation.
    3. Run the installer script ( perl <module>_installer )
    4. Run configure and enable the module, if it is a plugin.
    5. Repeat for any missing dependencies.
  • If you are still having problems, then instead of running the installer script:
    1. Make sure that the file permissions allow the webserver user to access all files.
    2. Check in any installed files that have existing ,v files in your existing install (take care not to lock the files when you check in)
    3. Manually edit LocalSite.cfg to set any configuration variables.
 
Changed:
<
<
>
>
  • Or, follow these manual installation steps:
    • Download the ZIP file from the extension home on twiki.org (see below).
    • Unzip BehaviourContrib.zip in your twiki installation directory.
    • Set the ownership of the extracted directories and files to the webserver user.
    • Install the dependencies (if any).
 

Contrib Settings

Line: 299 to 289
 

Contrib Info

Author: TWiki:Main/ArthurClemens
Changed:
<
<
Copyright: Code: behaviour.js version 1.1 - Copyright (c) Ben Nolan and Simon Willison.
TWiki distribution and updates/additions: © TWiki:Main/ArthurClemens.
© 2006-2010 TWiki:TWiki/TWikiContributor
>
>
Copyright: Code: behaviour.js version 1.1 - Copyright (c) Ben Nolan and Simon Willison.
TWiki distribution and updates/additions: © TWiki:Main/ArthurClemens.
© 2006-2015 TWiki:TWiki/TWikiContributor
 
License: BSD for behaviour.js
GPL (GNU General Public License) for TWiki BehaviourContrib
Changed:
<
<
Version: 18694 (2010-05-29)
>
>
Version: 29499 (2015-11-29)
 
Dependencies: None
Contrib Version: 1.4
Change History:
<-- specify latest version first -->
 
Added:
>
>
2015-02-16: TWikibug:Item7604: Switch from GPL v2 to v3
 
2010-05-15: TWikibug:Item6433 - doc improvements; replacing TWIKIWEB with SYSTEMWEB
17 Oct 2007 1.3 Replaced "faster code" by other code from Dean Edwards, [[ packed by http://groups.google.com/group/behaviour/browse_thread/thread/85137977bedf5ed/3cf3ba8065d41a8c#3cf3ba8065d41a8c][Raymond Irving]].
02 Jul 2007 1.2 Integrated other faster code by Dean Edwards: faster onload (again).

Revision 816 May 2010 - TWikiContributor

Line: 1 to 1
Changed:
<
<

Behaviour Javascript framework Contrib

This contrib packages the third-party Behaviour Javascript event library, available from http://bennolan.com/behaviour/.

>
>

Behaviour Javascript Framework Contrib

<--
   Contributions to this TWiki extension are appreciated. Please update the contrib page
   at http://twiki.org/cgi-bin/view/Plugins/BehaviourContrib or provide feedback
   at http://twiki.org/cgi-bin/view/Plugins/BehaviourContribDev.
   If you are a TWiki contributor please update the extension in the SVN repository.
-->
Behaviour Javascript event library to create Javascript based interactions that degrade well when Javascript is not available
 
Changed:
<
<
Behaviour uses CSS selectors to subscribe to javascript event handlers. This allows to create clean code, separated from HTML (and well suited to create javascript based interaction that degrades nicely when javascript is not available).
>
>

Introduction

 
Changed:
<
<
>
>
This contrib packages the third-party Behaviour Javascript event library, available from http://bennolan.com/behaviour/.
 
Added:
>
>
Behaviour uses CSS selectors to subscribe to Javascript event handlers. This allows to create clean code, separated from HTML (and well suited to create Javascript based interaction that degrades nicely when Javascript is not available).
 
Deleted:
<
<

Introduction

 From the website:
After all the work of WASP and others to promote clean markup, valid pages and graceful degradation via css - it sucks that we're going back to tag soup days by throwing javascript tags into our html.
Line: 55 to 61
 
Deleted:
<
<
 

Usage

Changed:
<
<
Include the javascript file:
>
>
Include the Javascript file:
 
Changed:
<
<
>
>
 
Line: 107 to 111
 
Deleted:
<
<
 

Example

Changed:
<
<
If we have a 'normal' link to TWiki Web hometopic: TWiki Web Home, we can use javascript to make it open a popup window. When javascript is not available the link behaviour defaults to opening the page in the current window.
>
>
If we have a 'normal' link to TWiki Web hometopic: TWiki Web Home, we can use javascript to make it open a popup window. When javascript is not available the link behaviour defaults to opening the page in the current window.
 
Line: 171 to 174
 // ]]>
Added:
>
>
  Creates:
Line: 231 to 235
 // ]]>
Added:
>
>

Leaking Danger

 
Deleted:
<
<

Leaking danger

 Behaviour code leaks memory on Windows Explorer prior to version 7. To prevent leaking, set the element variable to null:
Line: 255 to 259
 
Deleted:
<
<
 

License

Deleted:
<
<
Behaviour is freely distributable under the terms of an BSD license. For details see the Behaviour website.
 
Added:
>
>
Behaviour is freely distributable under the terms of an BSD license. For details see the Behaviour website.
 

Links

Added:
>
>
 
Line: 288 to 291
 

Contrib Settings

Changed:
<
<
  • Set SHORTDESCRIPTION = Behaviour Javascript event library to create javascript based interactions that degrade well when javascript is not available
>
>
  • Set SHORTDESCRIPTION = Behaviour Javascript event library to create Javascript based interactions that degrade well when Javascript is not available
  You can also set the global TWiki variable BEHAVIOURCONTRIB_DEBUG to 1 to make the contrib use uncompressed javascript sources, in the event of problems.

Contrib Info

Changed:
<
<
Author: TWiki:Main.ArthurClemens
Copyright: Code: behaviour.js version 1.1 - Copyright (c) Ben Nolan and Simon Willison. TWiki distribution and updates/additions: TWiki:Main.ArthurClemens.
License: BSD
Version: 15675 (02 Sep 2009)
>
>
Author: TWiki:Main/ArthurClemens
Copyright: Code: behaviour.js version 1.1 - Copyright (c) Ben Nolan and Simon Willison.
TWiki distribution and updates/additions: © TWiki:Main/ArthurClemens.
© 2006-2010 TWiki:TWiki/TWikiContributor
License: BSD for behaviour.js
GPL (GNU General Public License) for TWiki BehaviourContrib
Version: 18694 (2010-05-29)
 
Dependencies: None
Changed:
<
<
Contrib Version: 1.3.1
>
>
Contrib Version: 1.4
 
Change History:
<-- specify latest version first -->
 
Added:
>
>
2010-05-15: TWikibug:Item6433 - doc improvements; replacing TWIKIWEB with SYSTEMWEB
 
17 Oct 2007 1.3 Replaced "faster code" by other code from Dean Edwards, [[ packed by http://groups.google.com/group/behaviour/browse_thread/thread/85137977bedf5ed/3cf3ba8065d41a8c#3cf3ba8065d41a8c][Raymond Irving]].
02 Jul 2007 1.2 Integrated other faster code by Dean Edwards: faster onload (again).
08 Mar 2007 1.1 Integrated code by Dean Edwards (see Code update version 1.1 with faster DOM queries).
Line: 308 to 314
 
Feedback: http://TWiki.org/cgi-bin/view/Plugins/BehaviourContribDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/BehaviourContribAppraisal
Changed:
<
<
Related Topics: TWikiPreferences

META FILEATTACHMENT attr="" autoattached="1" comment="" date="1162075796" name="behaviour.js" path="behaviour.compressed.js" size="2902" user="UnknownUser" version=""
>
>
Related Topics: TWikiPreferences
 
Added:
>
>
META FILEATTACHMENT attr="" comment="" date="1162075796" name="behaviour.js" path="behaviour.compressed.js" size="2902" user="TWikiContributor" version="1"

Revision 708 Jul 2007 - TWikiContributor

Line: 1 to 1
 

Behaviour Javascript framework Contrib

This contrib packages the third-party Behaviour Javascript event library, available from http://bennolan.com/behaviour/.

Line: 296 to 296
 
Author: TWiki:Main.ArthurClemens
Copyright: Code: behaviour.js version 1.1 - Copyright (c) Ben Nolan and Simon Willison. TWiki distribution and updates/additions: TWiki:Main.ArthurClemens.
License: BSD
Changed:
<
<
Version: 15675 (29 Apr 2009)
>
>
Version: 15675 (02 Sep 2009)
 
Dependencies: None
Contrib Version: 1.3.1
Change History:
<-- specify latest version first -->
 

Revision 608 Jul 2007 - TWikiContributor

Line: 1 to 1
 

Behaviour Javascript framework Contrib

This contrib packages the third-party Behaviour Javascript event library, available from http://bennolan.com/behaviour/.

Line: 296 to 296
 
Author: TWiki:Main.ArthurClemens
Copyright: Code: behaviour.js version 1.1 - Copyright (c) Ben Nolan and Simon Willison. TWiki distribution and updates/additions: TWiki:Main.ArthurClemens.
License: BSD
Changed:
<
<
Version: 15675 (30 Mar 2009)
>
>
Version: 15675 (29 Apr 2009)
 
Dependencies: None
Contrib Version: 1.3.1
Change History:
<-- specify latest version first -->
 

Revision 508 Jul 2007 - TWikiContributor

Line: 1 to 1
 

Behaviour Javascript framework Contrib

This contrib packages the third-party Behaviour Javascript event library, available from http://bennolan.com/behaviour/.

Line: 296 to 296
 
Author: TWiki:Main.ArthurClemens
Copyright: Code: behaviour.js version 1.1 - Copyright (c) Ben Nolan and Simon Willison. TWiki distribution and updates/additions: TWiki:Main.ArthurClemens.
License: BSD
Changed:
<
<
Version: 15675 (06 Dec 2008)
>
>
Version: 15675 (30 Mar 2009)
 
Dependencies: None
Contrib Version: 1.3.1
Change History:
<-- specify latest version first -->
 

Revision 408 Jul 2007 - TWikiContributor

Line: 1 to 1
 

Behaviour Javascript framework Contrib

This contrib packages the third-party Behaviour Javascript event library, available from http://bennolan.com/behaviour/.

Line: 296 to 296
 
Author: TWiki:Main.ArthurClemens
Copyright: Code: behaviour.js version 1.1 - Copyright (c) Ben Nolan and Simon Willison. TWiki distribution and updates/additions: TWiki:Main.ArthurClemens.
License: BSD
Changed:
<
<
Version: 15675 (04 Aug 2008)
>
>
Version: 15675 (06 Dec 2008)
 
Dependencies: None
Contrib Version: 1.3.1
Change History:
<-- specify latest version first -->
 

Revision 308 Jul 2007 - TWikiContributor

Line: 1 to 1
 

Behaviour Javascript framework Contrib

This contrib packages the third-party Behaviour Javascript event library, available from http://bennolan.com/behaviour/.

Line: 296 to 296
 
Author: TWiki:Main.ArthurClemens
Copyright: Code: behaviour.js version 1.1 - Copyright (c) Ben Nolan and Simon Willison. TWiki distribution and updates/additions: TWiki:Main.ArthurClemens.
License: BSD
Changed:
<
<
Version: 15675 (22 Jan 2008)
>
>
Version: 15675 (04 Aug 2008)
 
Dependencies: None
Contrib Version: 1.3.1
Change History:
<-- specify latest version first -->
 

Revision 208 Jul 2007 - TWikiContributor

Line: 1 to 1
 

Behaviour Javascript framework Contrib

This contrib packages the third-party Behaviour Javascript event library, available from http://bennolan.com/behaviour/.

Changed:
<
<
Behaviour is suited to create javascript based interaction that degrades well when javascript is not available.

Javascript file: behaviour.js (8.1K). The compressed javascript file (2.9K) has been processed by ShrinkSafe.

>
>
Behaviour uses CSS selectors to subscribe to javascript event handlers. This allows to create clean code, separated from HTML (and well suited to create javascript based interaction that degrades nicely when javascript is not available).
 
Line: 56 to 55
 
Added:
>
>
 

Usage

Include the javascript file:

Changed:
<
<
>
>
 
Line: 107 to 108
 
Changed:
<
<

Example

>
>

Example

 If we have a 'normal' link to TWiki Web hometopic: TWiki Web Home, we can use javascript to make it open a popup window. When javascript is not available the link behaviour defaults to opening the page in the current window.

Changed:
<
<
TWiki Web Home
>
>
MOUSE OVER ME
 
Deleted:
<
<
The class name link%TWIKIWEB%%HOMETOPIC% will get expanded to linkTWikiWebHome
 Creates:
Changed:
<
<
TWiki Web Home
>
>
MOUSE OVER ME
 
Added:
>
>

Leaking danger

Behaviour code leaks memory on Windows Explorer prior to version 7. To prevent leaking, set the element variable to null:
var myrules = {
   'table.test td' : function(element) {
      element.onmouseover = function() {
         this.style.backgroundColor = highlightColor;
         return false;
      }
      element = null; // by setting this IE will not leak  
   }
};   
Behaviour.register(myrules);
 

Development

Changed:
<
<
>
>
 

License

Behaviour is freely distributable under the terms of an BSD license.
Changed:
<
<
For details, see the Behaviour website.
>
>
For details see the Behaviour website.
 

Links

Changed:
<
<

Contrib Info

>
>

Installation Instructions

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server where TWiki is running.

Like many other TWiki extensions, this module is shipped with a fully automatic installer script written using the BuildContrib.

  • If you have TWiki 4.2 or later, you can install from the configure interface (Go to Plugins->Find More Extensions)
  • If you have any problems, then you can still install manually from the command-line:
    1. Download one of the .zip or .tgz archives
    2. Unpack the archive in the root directory of your TWiki installation.
    3. Run the installer script ( perl <module>_installer )
    4. Run configure and enable the module, if it is a plugin.
    5. Repeat for any missing dependencies.
  • If you are still having problems, then instead of running the installer script:
    1. Make sure that the file permissions allow the webserver user to access all files.
    2. Check in any installed files that have existing ,v files in your existing install (take care not to lock the files when you check in)
    3. Manually edit LocalSite.cfg to set any configuration variables.

 
Added:
>
>

Contrib Settings

  • Set SHORTDESCRIPTION = Behaviour Javascript event library to create javascript based interactions that degrade well when javascript is not available

You can also set the global TWiki variable BEHAVIOURCONTRIB_DEBUG to 1 to make the contrib use uncompressed javascript sources, in the event of problems.

Contrib Info

 
Author: TWiki:Main.ArthurClemens
Changed:
<
<
Copyright: version 1.1 - Copyright (c) Ben Nolan and Simon Willison
>
>
Copyright: Code: behaviour.js version 1.1 - Copyright (c) Ben Nolan and Simon Willison. TWiki distribution and updates/additions: TWiki:Main.ArthurClemens.
 
License: BSD
Added:
>
>
Version: 15675 (22 Jan 2008)
 
Dependencies: None
Changed:
<
<
4 June 2006 1.000 First Version. Included Behaviour version: 1.1
>
>
Contrib Version: 1.3.1
Change History:
<-- specify latest version first -->
 
17 Oct 2007 1.3 Replaced "faster code" by other code from Dean Edwards, [[ packed by http://groups.google.com/group/behaviour/browse_thread/thread/85137977bedf5ed/3cf3ba8065d41a8c#3cf3ba8065d41a8c][Raymond Irving]].
02 Jul 2007 1.2 Integrated other faster code by Dean Edwards: faster onload (again).
08 Mar 2007 1.1 Integrated code by Dean Edwards (see Code update version 1.1 with faster DOM queries).
04 Jun 2006 1.0 First Version. Included Behaviour version: 1.1.
 
Home: http://TWiki.org/cgi-bin/view/Plugins/BehaviourContrib
Feedback: http://TWiki.org/cgi-bin/view/Plugins/BehaviourContribDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/BehaviourContribAppraisal

Related Topics: TWikiPreferences

Changed:
<
<
META FILEATTACHMENT attr="" autoattached="1" comment="" date="1162075796" name="behaviour.compressed.js" path="behaviour.compressed.js" size="2902" user="UnknownUser" version=""
META FILEATTACHMENT attr="" autoattached="1" comment="" date="1161199153" name="behaviour.js" path="behaviour.js" size="8149" user="UnknownUser" version=""
>
>
META FILEATTACHMENT attr="" autoattached="1" comment="" date="1162075796" name="behaviour.js" path="behaviour.compressed.js" size="2902" user="UnknownUser" version=""

Revision 101 Nov 2006 - TWikiContributor

Line: 1 to 1
Added:
>
>

Behaviour Javascript framework Contrib

This contrib packages the third-party Behaviour Javascript event library, available from http://bennolan.com/behaviour/.

Behaviour is suited to create javascript based interaction that degrades well when javascript is not available.

Javascript file: behaviour.js (8.1K). The compressed javascript file (2.9K) has been processed by ShrinkSafe.

Introduction

From the website:
After all the work of WASP and others to promote clean markup, valid pages and graceful degradation via css - it sucks that we're going back to tag soup days by throwing javascript tags into our html.

The better way to do javascript is to do it unobtrusively. PPK and Simon Willison have been recommending this approach for ages. And it's definitely the way to go. The only problem is that it's a bit of a pain in the ass.

That's why I came up with Behaviour - my solution to unobtrusive javascript behaviours.

How does it work?

Behaviour lets you use CSS selectors to specify elements to add javascript events to. This means that instead of writing:

<li>
   <a onclick="this.parentNode.removeChild(this)" href="#">
      Click me to delete me
   </a>
</li>

You can use:

<ul id="example">
   <li>
      <a href="/someurl">Click me to delete me</a>
   </li>
</ul>

And then use css selectors to select that element and add javascript functions to it.

var myrules = {
   '#example li' : function(el){
      el.onclick = function(){
         this.parentNode.removeChild(this);

      }
   }
};

Behaviour.register(myrules);

Usage

Include the javascript file:

<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/BehaviourContrib/behaviour.compressed.js"></script>

In your code you create a "rules" object, with sub-objects for each html element class name or id:

var myrules = {
   '.classname' : function(element) {
      // element event
      element.onclick = function() {
         // code here
      }
   },
   
   '#id' : function(element) {
      // element event
      element.onclick = function() {
         // code here
      }
   }
};

Or use nested identifiers:

var myrules = {
   '.menu li a' : function(element) {
      element.onclick = function() {
         // code here
      }
   }
};

Apply the rules with:

Behaviour.register(myrules);

Example

If we have a 'normal' link to TWiki Web hometopic: TWiki Web Home, we can use javascript to make it open a popup window. When javascript is not available the link behaviour defaults to opening the page in the current window.

<span class="link%TWIKIWEB%%HOMETOPIC%">[[%TWIKIWEB%.%HOMETOPIC%][TWiki Web Home]]</span>

<script type="text/javascript">
// <![CDATA[
var myrules = {
   '.link%TWIKIWEB%%HOMETOPIC% a' : function(el){
      el.onclick = function() {
         // open in a popup with no other attributes than template 'viewplain'
         launchTheWindow(this.href,null,null,null,"viewplain");
         return false;
      }
   }
};

Behaviour.register(myrules);
// ]]>
</script>

The class name link%TWIKIWEB%%HOMETOPIC% will get expanded to linkTWikiWebHome

Creates:

TWiki Web Home

Development

License

Behaviour is freely distributable under the terms of an BSD license. For details, see the Behaviour website.

Links

Contrib Info

Author: TWiki:Main.ArthurClemens
Copyright: version 1.1 - Copyright (c) Ben Nolan and Simon Willison
License: BSD
Dependencies: None
4 June 2006 1.000 First Version. Included Behaviour version: 1.1
Home: http://TWiki.org/cgi-bin/view/Plugins/BehaviourContrib
Feedback: http://TWiki.org/cgi-bin/view/Plugins/BehaviourContribDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/BehaviourContribAppraisal

Related Topics: TWikiPreferences

META FILEATTACHMENT attr="" autoattached="1" comment="" date="1162075796" name="behaviour.compressed.js" path="behaviour.compressed.js" size="2902" user="UnknownUser" version=""
META FILEATTACHMENT attr="" autoattached="1" comment="" date="1161199153" name="behaviour.js" path="behaviour.js" size="8149" user="UnknownUser" version=""
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.BehaviourContrib.