Javascript Coding Standards
Created by: seamuslee001
@seanmadsen @totten @colemanw This may need some input from others but i think its reasonably good for review now, The original document is here https://wiki.civicrm.org/confluence/display/CRMDOC/Javascript+Reference
Merge request reports
Activity
Created by: seamuslee001
@seanmadsen done
145 Because translated strings are added to the client-side by CRM_Core_Resources addScriptFile method, they will not be automatically added if you include your js on the page any other way. The ts() function will still work and perform variable substitution, but the localized string will not be available. There are 3 solutions to this problem depending on your context: 146 147 1. If this is an inline script in a smarty template, use the {ts} function (see legacy issues below for an example). Note that {ts} cannot handle client-side variable substitution, only server-side template variables. 148 2. If this is an inline script in a php file, use the php ts() function to do your translation and concatenate the result into your script. Or, if you need client-side variable substitution use the 3rd solution: 149 3. If this is a javascript file being added to the page in a nonstandard way (or is one of the above two scenarios but you need client-side variable substitution), you could manually add any needed strings using the CRM_Core_Resources addString method 150 151 ## UI Elements 152 153 CiviCRM ships with a number of UI widgets and plugins to create standardized "look and feel" More information can be found in [UI Elements Reference](https://wiki.civicrm.org/confluence/display/CRMDOC/UI+Elements+Reference). 154 155 ## Quality Control 156 157 CiviCRM has a number of mechanisms that it uses to ensure quality of javascript that is submitted to core. 158 159 ### JSHint 160 Created by: seamuslee001
@totten @seanmadsen i copied this across from Wiki but thinking that because we have a section up the top on coding standards I think perhaps we loose this part on JSHint and change this section to be test tools perhaps?
Created by: seamuslee001
@seanmadsen @totten have just done some rewrites pls check over
Please register or sign in to reply