Edgewall Software

Changes between Version 10 and Version 11 of TracDev/JavaScript


Ignore:
Timestamp:
Jan 23, 2016, 10:20:29 AM (8 years ago)
Author:
figaro
Comment:

Further cosmetic changes

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/JavaScript

    v10 v11  
    1 = JavaScript for Trac and plugin development
     1[[PageOutline(2-5,Contents,pullout)]]
    22
    3 JavaScript is used in Trac to add dynamics to web interface elements on the browser side:
     3= !JavaScript for Trac and plugin development
     4
     5!JavaScript is used in Trac to add dynamics to web interface elements on the browser side:
    46 * expanding/folding in the TracBrowser
    57 * providing [TracAccessibility keyboard shortcuts]
    68 * and many other features
     9
     10This page lists some of the uses of this language in Trac.
    711
    812{{{
     
    1519=== jQuery
    1620
    17 Trac makes heavy use of [http://en.wikipedia.org/wiki/JQuery jQuery] library. Access to this library contents is provided through the main function named $, which is just a shortcut for ''jQuery'' namespace and it is possible to use the full name instead. However, other libraries may use $ too, which may cause conflicts. To avoid these conflicts, switch jQuery into non-conflict mode with ''jQuery.noConflict()'' call. This is well explained in http://docs.jquery.com/Using_jQuery_with_Other_Libraries.
     21Trac makes heavy use of [wikipedia:JQuery jQuery] library. Access to this library contents is provided through the main function named `$`, which is just a shortcut for the ''jQuery'' namespace and it is possible to use the full name instead. However, other libraries may use `$` too, which may cause conflicts. To avoid these conflicts, switch jQuery into non-conflict mode with ''jQuery.noConflict()'' call. This is well explained in http://docs.jquery.com/Using_jQuery_with_Other_Libraries.
    1822
    1923You will see many blocks in Trac that use $ for jQuery. They do it in their local scope defined by nameless function or closure:
     
    2125(function($) { /* some code that uses $ */ })(jQuery)
    2226}}}
     27
    2328There is a good description of closures and `(function(){})()` construct at http://ajaxian.com/archives/secrets-of-the-javascript-ninja-a-sneak-peak-for-ajaxians.
    2429
     
    2934$(document).ready(function_name);
    3035}}}
     36
    3137In non-conflicting mode, code that executed in Trac on page startup is enveloped in closure and looks like:
    3238{{{
     
    4349=== jQuery UI
    4450
    45 Since Trac version 1.0, we also bundle [http://jqueryui.com jQuery UI], a set of standard UI elements.
     51Since Trac version 1.0, we also bundle [http://jqueryui.com jQuery UI], a set of standard user interface elements (UI).
    4652
    4753==== Upgrade
     
    5157  `http://code.jquery.com/ui/x.y.z/jquery-ui.min.js`
    5258
    53 This correspond to the minified version of the whole of jQuery UI, ie we don't use a subset of what is currently used by Trac on purpose, so that plugins can assume they have access to the all the jQuery UI components.
     59This correspond to the minified version of the whole of jQuery UI, ie we don't use a subset of what is currently used by Trac on purpose, so that plugins can assume they have access to all jQuery UI components.
    5460
    5561We use a custom theme for the CSS, built using the jQuery UI Theme Roller.