Skip to content

Commit efede1f

Browse files
committed
Update with a few tweaks for Tokbox
1 parent 3d37f2d commit efede1f

File tree

1 file changed

+12
-138
lines changed

1 file changed

+12
-138
lines changed

README.md

Lines changed: 12 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
1. [Testing](#testing)
3131
1. [Performance](#performance)
3232
1. [Resources](#resources)
33-
1. [In the Wild](#in-the-wild)
34-
1. [Translation](#translation)
35-
1. [The JavaScript Style Guide Guide](#the-javascript-style-guide-guide)
3633
1. [Contributors](#contributors)
3734
1. [License](#license)
3835

@@ -1109,20 +1106,20 @@
11091106
## Accessors
11101107

11111108
- Accessor functions for properties are not required
1112-
- If you do make accessor functions use getVal() and setVal('hello')
1109+
- If you do make accessor functions use val() and val('hello')
11131110

11141111
```javascript
11151112
// bad
1116-
dragon.age();
1113+
dragon.getAge();
11171114
11181115
// good
1119-
dragon.getAge();
1116+
dragon.age();
11201117
11211118
// bad
1122-
dragon.age(25);
1119+
dragon.setAge(25);
11231120
11241121
// good
1125-
dragon.setAge(25);
1122+
dragon.age(25);
11261123
```
11271124

11281125
- If the property is a boolean, use isVal() or hasVal()
@@ -1139,24 +1136,6 @@
11391136
}
11401137
```
11411138

1142-
- It's okay to create get() and set() functions, but be consistent.
1143-
1144-
```javascript
1145-
function Jedi(options) {
1146-
options || (options = {});
1147-
var lightsaber = options.lightsaber || 'blue';
1148-
this.set('lightsaber', lightsaber);
1149-
}
1150-
1151-
Jedi.prototype.set = function(key, val) {
1152-
this[key] = val;
1153-
};
1154-
1155-
Jedi.prototype.get = function(key) {
1156-
return this[key];
1157-
};
1158-
```
1159-
11601139
**[⬆ back to top](#table-of-contents)**
11611140

11621141

@@ -1247,7 +1226,7 @@
12471226

12481227
## Events
12491228

1250-
- When attaching data payloads to events (whether DOM events or something more proprietary like Backbone events), pass a hash instead of a raw value. This allows a subsequent contributor to add more data to the event payload without finding and updating every handler for the event. For example, instead of:
1229+
- When attaching data payloads to events (whether DOM events, TokBox trigger or node.js EventEmitter), pass a hash instead of a raw value. This allows a subsequent contributor to add more data to the event payload without finding and updating every handler for the event. For example, instead of:
12511230

12521231
```js
12531232
// bad
@@ -1275,12 +1254,10 @@
12751254

12761255
**[⬆ back to top](#table-of-contents)**
12771256

1278-
12791257
## Modules
12801258

12811259
- The module should start with a `!`. This ensures that if a malformed module forgets to include a final semicolon there aren't errors in production when the scripts get concatenated. [Explanation](https://github.com/airbnb/javascript/issues/44#issuecomment-13063933)
1282-
- The file should be named with camelCase, live in a folder with the same name, and match the name of the single export.
1283-
- Add a method called noConflict() that sets the exported module to the previous version and returns this one.
1260+
- If your module is adding to the global scope, add a method called noConflict() that sets the exported module to the previous version and returns this one.
12841261
- Always declare `'use strict';` at the top of the module.
12851262
12861263
```javascript
@@ -1309,65 +1286,7 @@
13091286
13101287
## jQuery
13111288
1312-
- Prefix jQuery object variables with a `$`.
1313-
1314-
```javascript
1315-
// bad
1316-
var sidebar = $('.sidebar');
1317-
1318-
// good
1319-
var $sidebar = $('.sidebar');
1320-
```
1321-
1322-
- Cache jQuery lookups.
1323-
1324-
```javascript
1325-
// bad
1326-
function setSidebar() {
1327-
$('.sidebar').hide();
1328-
1329-
// ...stuff...
1330-
1331-
$('.sidebar').css({
1332-
'background-color': 'pink'
1333-
});
1334-
}
1335-
1336-
// good
1337-
function setSidebar() {
1338-
var $sidebar = $('.sidebar');
1339-
$sidebar.hide();
1340-
1341-
// ...stuff...
1342-
1343-
$sidebar.css({
1344-
'background-color': 'pink'
1345-
});
1346-
}
1347-
```
1348-
1349-
- For DOM queries use Cascading `$('.sidebar ul')` or parent > child `$('.sidebar > ul')`. [jsPerf](http://jsperf.com/jquery-find-vs-context-sel/16)
1350-
- Use `find` with scoped jQuery object queries.
1351-
1352-
```javascript
1353-
// bad
1354-
$('ul', '.sidebar').hide();
1355-
1356-
// bad
1357-
$('.sidebar').find('ul').hide();
1358-
1359-
// good
1360-
$('.sidebar ul').hide();
1361-
1362-
// good
1363-
$('.sidebar > ul').hide();
1364-
1365-
// good
1366-
$sidebar.find('ul').hide();
1367-
```
1368-
1369-
**[⬆ back to top](#table-of-contents)**
1370-
1289+
See [You Might Not Need jQuery](http://youmightnotneedjquery.com/).
13711290
13721291
## ECMAScript 5 Compatibility
13731292
@@ -1395,7 +1314,6 @@
13951314
- [String vs Array Concat](http://jsperf.com/string-vs-array-concat/2)
13961315
- [Try/Catch Cost In a Loop](http://jsperf.com/try-catch-in-loop-cost)
13971316
- [Bang Function](http://jsperf.com/bang-function)
1398-
- [jQuery Find vs Context, Selector](http://jsperf.com/jquery-find-vs-context-sel/13)
13991317
- [innerHTML vs textContent for script text](http://jsperf.com/innerhtml-vs-textcontent-for-script-text)
14001318
- [Long String Concatenation](http://jsperf.com/ya-string-concat)
14011319
- Loading...
@@ -1413,7 +1331,6 @@
14131331
**Other Styleguides**
14141332

14151333
- [Google JavaScript Style Guide](http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml)
1416-
- [jQuery Core Style Guidelines](http://docs.jquery.com/JQuery_Core_Style_Guidelines)
14171334
- [Principles of Writing Consistent, Idiomatic JavaScript](https://github.com/rwldrn/idiomatic.js/)
14181335

14191336
**Other Styles**
@@ -1463,62 +1380,19 @@
14631380

14641381
## In the Wild
14651382

1466-
This is a list of organizations that are using this style guide. Send us a pull request or open an issue and we'll add you to the list.
1467-
1468-
- **Aan Zee**: [AanZee/javascript](https://github.com/AanZee/javascript)
1469-
- **Airbnb**: [airbnb/javascript](https://github.com/airbnb/javascript)
1470-
- **American Insitutes for Research**: [AIRAST/javascript](https://github.com/AIRAST/javascript)
1471-
- **Compass Learning**: [compasslearning/javascript-style-guide](https://github.com/compasslearning/javascript-style-guide)
1472-
- **Digitpaint** [digitpaint/javascript](https://github.com/digitpaint/javascript)
1473-
- **ExactTarget**: [ExactTarget/javascript](https://github.com/ExactTarget/javascript)
1474-
- **Gawker Media**: [gawkermedia/javascript](https://github.com/gawkermedia/javascript)
1475-
- **GeneralElectric**: [GeneralElectric/javascript](https://github.com/GeneralElectric/javascript)
1476-
- **GoodData**: [gooddata/gdc-js-style](https://github.com/gooddata/gdc-js-style)
1477-
- **Grooveshark**: [grooveshark/javascript](https://github.com/grooveshark/javascript)
1478-
- **How About We**: [howaboutwe/javascript](https://github.com/howaboutwe/javascript)
1479-
- **Mighty Spring**: [mightyspring/javascript](https://github.com/mightyspring/javascript)
1480-
- **MinnPost**: [MinnPost/javascript](https://github.com/MinnPost/javascript)
1481-
- **ModCloth**: [modcloth/javascript](https://github.com/modcloth/javascript)
1482-
- **Money Advice Service**: [moneyadviceservice/javascript](https://github.com/moneyadviceservice/javascript)
1483-
- **National Geographic**: [natgeo/javascript](https://github.com/natgeo/javascript)
1484-
- **National Park Service**: [nationalparkservice/javascript](https://github.com/nationalparkservice/javascript)
1485-
- **Peerby**: [Peerby/javascript](https://github.com/Peerby/javascript)
1486-
- **Razorfish**: [razorfish/javascript-style-guide](https://github.com/razorfish/javascript-style-guide)
1487-
- **SeekingAlpha**: [seekingalpha/javascript-style-guide](https://github.com/seekingalpha/javascript-style-guide)
1488-
- **REI**: [reidev/js-style-guide](https://github.com/reidev/js-style-guide)
1489-
- **Ripple**: [ripple/javascript-style-guide](https://github.com/ripple/javascript-style-guide)
1490-
- **Shutterfly**: [shutterfly/javascript](https://github.com/shutterfly/javascript)
1491-
- **Userify**: [userify/javascript](https://github.com/userify/javascript)
1492-
- **Zillow**: [zillow/javascript](https://github.com/zillow/javascript)
1493-
- **ZocDoc**: [ZocDoc/javascript](https://github.com/ZocDoc/javascript)
1494-
1495-
## Translation
1496-
1497-
This style guide is also available in other languages:
1498-
1499-
- :de: **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide)
1500-
- :jp: **Japanese**: [mitsuruog/javacript-style-guide](https://github.com/mitsuruog/javacript-style-guide)
1501-
- :br: **Portuguese**: [armoucar/javascript-style-guide](https://github.com/armoucar/javascript-style-guide)
1502-
- :cn: **Chinese**: [adamlu/javascript-style-guide](https://github.com/adamlu/javascript-style-guide)
1503-
- :es: **Spanish**: [paolocarrasco/javascript-style-guide](https://github.com/paolocarrasco/javascript-style-guide)
1504-
- :kr: **Korean**: [tipjs/javascript-style-guide](https://github.com/tipjs/javascript-style-guide)
1505-
- :fr: **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide)
1506-
- :ru: **Russian**: [uprock/javascript](https://github.com/uprock/javascript)
1507-
- :bg: **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript)
1508-
1509-
## The JavaScript Style Guide Guide
1510-
1511-
- [Reference](https://github.com/airbnb/javascript/wiki/The-JavaScript-Style-Guide-Guide)
1383+
The list of organizations using similar style guides (including translations) can be found at
1384+
the original from [Airbnb](https://github.com/airbnb/javascript).
15121385

15131386
## Contributors
15141387

1515-
- [View Contributors](https://github.com/airbnb/javascript/graphs/contributors)
1388+
- [View Contributors](https://github.com/opentok/javascript/graphs/contributors)
15161389

15171390

15181391
## License
15191392

15201393
(The MIT License)
15211394

1395+
Copyright (c) 2014 Tokbox Inc.
15221396
Copyright (c) 2014 Airbnb
15231397

15241398
Permission is hereby granted, free of charge, to any person obtaining

0 commit comments

Comments
 (0)