Beruflich Dokumente
Kultur Dokumente
jQuery
Document Owners: Daniel Martin, Online Content Administrator
Joris de Beer, Online Content Administrator
Telstra Digital
Table of Contents
TELSTRA ONLINE STANDARDS ......................................................................................................................1
JQUERY ........................................................................................................................................ 1
INTRODUCTION............................................................................................................................. 2
AVAILABILITY ...........................................................................................................................................2
IMPLEMENTATION...................................................................................................................................32
File Locations .................................................................................................................................32
Implementation Code .....................................................................................................................32
USAGE ...................................................................................................................................................3
Naming Conventions ......................................................................................................................43
Best Practices .................................................................................................................................54
Minify Scripts (Compression) ..........................................................................................................54
DEVELOPMENT REQUIREMENTS .................................................................................................................65
PLUG-INS ..............................................................................................................................................65
Global Plug-ins ...............................................................................................................................65
Page Specific Plug-ins .......................................................................................................................6
In-House Development ...................................................................................................................76
jQuery UI ..........................................................................................................................................7
CSS .................................................................................................................................................87
GLOBAL.JS COMMANDS ............................................................................................................................87
CONTRIBUTION EFFORTS ............................................................................................................................8
PROCESSES ................................................................................................................................. 98
JQUERY ........................................................................................................................................ 1
INTRODUCTION............................................................................................................................. 2
AVAILABILITY ...........................................................................................................................................2
IMPLEMENTATION.....................................................................................................................................2
File Locations ...................................................................................................................................2
Implementation Code .......................................................................................................................2
USAGE ...................................................................................................................................................3
Naming Conventions ........................................................................................................................3
Best Practices ...................................................................................................................................4
Minify Scripts (Compression) ............................................................................................................4
DEVELOPMENT REQUIREMENTS ...................................................................................................................5
PLUG-INS ................................................................................................................................................5
Approved & Available.......................................................................................................................5
In-House Development .....................................................................................................................6
jQuery UI ..........................................................................................................................................6
CSS ...................................................................................................................................................7
GLOBAL.JS COMMANDS ..............................................................................................................................7
CONTRIBUTION EFFORTS ............................................................................................................................7
PROCESSES ................................................................................................................................... 8
Introduction
This standard provides the guidelines for the use of jQuery in Telstras web
environment. The document covers how jQuery is implemented, how you can take
advantage of it, what plug-ins are available and defines processes for future activities.
Please check the Wiki page for the most up to date information.
The Standard
Availability
- jQuery is available in UCM on a Template by Template basis. Current
templates that include jQuery are:
File name: t.com jQuery Standards v1.7.1.doc Page
2 of 10
This hardcopy version of the standard may be out of date. For the latest copy of this standard visit
http://www.telstra.com.au/standards
Telstra Online Standards Effective Date of this standard
1. PT_T.COM_TEMPLATE_GENERIC
For Flat Files, each file will require its own inclusion of the jQuery core. See
Implementation Flat Files for more details.
Implementation
File Locations
Core Directories:
/global/javascript/jquery/
/global/javascript/jquery/plugins/
/global/javascript/jquery/plugins-src/
Implementation Code
To implement jQuery into a template or page, use the following command
UCM Template
If you experience namespace issues when implementing jQuery, you can attempt
to load it in no-conflict mode as per the jQuery documentation.
Usage
As all the minimum files needed to take advantage of the jQuery framework have been
loaded for you, you are able to add commands on the fly.
For jQuery code to work it must be within a document/window ready function. This
ensures that the jQuery code has fully loaded before trying to execute the command.
This command where possible, should be placed towards the end of the page code,
just before the closing </body> tag, not within the <head> section.
<script type=text/javascript>
$(document).ready( function() {
// Code Goes Here
});
</script>
<script type=text/javascript>
$(function() {
// Code Goes Here
});
</script>
Please refer to the jQuery documentation for detailed instructions on using jQuery and
its functions: docs.jquery.com
Naming Conventions
Best Practices
To ensure that all Telstras scripts are professionally written and perform to their
maximum capability, adopt the following practices whenever creating jQuery scripts.
Place all scripts and codes at the base of the page, just before the closing
body tag
Appropriate tab indenting and line breaks must be used to enhance the
readability of code. This also applies when chaining many events to one
selector.
Be specific with your selectors. The more defined a selector is the less that
jQuery has to navigate the DOM to locate it and the less chance there is for
conflicts on other pages.
Avoid over-looping through the DOM use functions such as .find() and
.each() only when needed on specified selectors
Convert functions into a plug-in where appropriate and provide options.
Refer to the jQuery documentation for plug-in development
Avoid using multiple JavaScript files where possible more scripts will mean
more HTTP requests and larger page load.
Comment your functions with a short description of the purpose the serve
Ensure that your scripts do not reduce the accessibility of the site. Using
display: none; to hide content before jQuery loads is bad practice, if
unavoidable then use a <noscript> tag to change this property to visible.
jQuery commands are always slower than native JavaScript if there is a
native command available use it in preference to jQuery. Eg:
$(this).attr(id) is slower than this.id
Development Requirements
You are responsible for validating that code works with version 1.4.4 of the
jQuery JavaScript library.
You must not link to an additional copy (newer or older) of the jQuery
library. If you are working on a page that has a reference to any jQuery
library, please remove it as this reference is no longer required.
You must not link to external plugins. Only the features listed within the
Plug-ins section are available. If you wish to make use of a new plug in,
please follow the process to submit a plug-in for a team discussion and
investigation before proceeding.
Plug-ins
Lightbox (OrangeBox)
(/global/javascript/jquery/plugins/orangebox/orangebox.min.js
, /global/javascript/jquery/pluginss/orangebox/orangebox.css)
Accordion (/global/javascript/jquery/plugins/accordion/jquery-
contentAccordion.js)
Feature Banner (Under Review)
(/global/javascript/plugins/featurebanner/jquery-
featureBanner.js,
/global/javascript/jquery/plugins/featurebanner/featureBanner.cs
s)
Tabs
(/global/javascript/plugins/labeloverlay/jquery.tabs.js)
Label Overlay
(/global/javascript/plugins/labeloverlay/jquery-labeloverlay-
0.0.1.min.js)
For more information on each jQuery plug-in including initialisation, structure and
options, please see the corresponding WIKI page.
Custom plug-ins must contain a commented link to their respective WIKI page and
their appropriate Copyright disclaimer
There are many advantages to restricting the plugins used on Telstra.com, please see
the Adding a Plugin section for further details.
If the page requires a particular plug-in to be loaded and it is not required globally, an
exception can be made.
Page specific plug-ins should be stored within the appropriate folder for the site.
Example if a plug-in was required for a page within the home-phones section of the
site, it should be stored in a directory similar to:
Con formato: Fuente:
/home-phone/javascript/plugin/ (Predeterminado) Courier New, Color
de fuente: Color personalizado(RGB(12
8,100,162))
The same guidelines apply to the implementation of the plug-in, the main Con formato: Sangra: Primera lnea:
considerations are: 1.27 cm
InIn-House Development
Cases that require a plug-in to be developed are usually when there is functionality
that needs to be used on multiple pages in multiple sitelets. There is no need to
develop a plug-in for page specific functionality.
Please see the Adding a new Plug-in within the Processes section of this document to
submit your plug-in for release.
jQuery UI
Currently there is no support for jQuery UI or its add-ons. This is primarily due to the
page weight this would add and the CSS methods employed by the UI addition.
jQuery UI additions rely heavily on a style sheet created via the jQuery Themeroller
(http://jqueryui.com/themeroller/) which is incompatible with the way Telstra.com has
been developed.
If you require a UI function that does not exist in an alternative external plug-in or
cannot be created in-house there may be the case for a page specific exception. Please
consult with your Manager before proceeding with any UI implementations.
CSS
It is understood that there is usually the requirement to develop a CSS sheet to layout
the content of the jQuery plug-in. To handle this effectively you may store your CSS
file under the following rules.
global.js Commands
Location: /global/javascript/global.js
The common file is designed to hold functions that are implemented site-wide. This is
not for page specific functions and additions should be carefully considered as the size
of this file will add weight to every page load.
The types of functions within this file are style elements (such as table striping), hover
effects and possibly pop-up events. Please see the Updating the Common functions in
the Processes section of this document.
Contribution Efforts
Processes
Accessibility
Page load & cache
Consistent with the feel of the site
Add to user experience
If you wish to have either your own plug-in or an external plug-in added to the
approved plug-in list, you must follow the steps below:
If your function does have an applicable use site wide then you may follow the
following steps to incorporate it into the common js file.
1. First you must do an investigation into the effects your function may have
some questions for consideration:
a. Is it class specific and does that class apply site wide?
b. Are there other functions that may collide with it?
c. Do all sitelets perform the expected way?
2. Complete an Impact Assessment and distribute out to developers for peer
review. The IA must contain the exact function you would like to add.
3. Once feedback has been received and any appropriate adjustments have
been made you can start the End to End Project Delivery Process.
4. First, complete your work in the Dev environment and move it through to
UAT
5. Thoroughly test your function not just on the page / section you are
concentrating on but all sites and various page. You may need to add
content to UAT to test your changes
6. Confirm with your Configuration Manager that it is okay to move from UAT
to production
7. Upon approval you may migrate the change to Production.