Changes between Version 10 and Version 11 of TracDev/JavaScript
- Timestamp:
- Jan 23, 2016, 10:20:29 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/JavaScript
v10 v11 1 = JavaScript for Trac and plugin development 1 [[PageOutline(2-5,Contents,pullout)]] 2 2 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: 4 6 * expanding/folding in the TracBrowser 5 7 * providing [TracAccessibility keyboard shortcuts] 6 8 * and many other features 9 10 This page lists some of the uses of this language in Trac. 7 11 8 12 {{{ … … 15 19 === jQuery 16 20 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.21 Trac 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. 18 22 19 23 You will see many blocks in Trac that use $ for jQuery. They do it in their local scope defined by nameless function or closure: … … 21 25 (function($) { /* some code that uses $ */ })(jQuery) 22 26 }}} 27 23 28 There is a good description of closures and `(function(){})()` construct at http://ajaxian.com/archives/secrets-of-the-javascript-ninja-a-sneak-peak-for-ajaxians. 24 29 … … 29 34 $(document).ready(function_name); 30 35 }}} 36 31 37 In non-conflicting mode, code that executed in Trac on page startup is enveloped in closure and looks like: 32 38 {{{ … … 43 49 === jQuery UI 44 50 45 Since Trac version 1.0, we also bundle [http://jqueryui.com jQuery UI], a set of standard UI elements.51 Since Trac version 1.0, we also bundle [http://jqueryui.com jQuery UI], a set of standard user interface elements (UI). 46 52 47 53 ==== Upgrade … … 51 57 `http://code.jquery.com/ui/x.y.z/jquery-ui.min.js` 52 58 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 thejQuery UI components.59 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 all jQuery UI components. 54 60 55 61 We use a custom theme for the CSS, built using the jQuery UI Theme Roller.