Skip to content

Commit e9bb095

Browse files
committed
Converted ember-routing docs
1 parent e33fe96 commit e9bb095

File tree

9 files changed

+163
-36
lines changed

9 files changed

+163
-36
lines changed

packages/ember-routing/lib/location/api.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
/**
2+
@module ember
3+
@submodule ember-routing
4+
*/
5+
16
var get = Ember.get, set = Ember.set;
27

3-
/**
8+
/*
49
This file implements the `location` API used by Ember's router.
510
611
That API is:
@@ -12,17 +17,19 @@ var get = Ember.get, set = Ember.set;
1217
1318
Calling setURL will not trigger onUpdateURL callbacks.
1419
15-
TODO: This, as well as the Ember.Location documentation below, should
16-
perhaps be moved so that it's visible in the JsDoc output.
20+
TODO: This should perhaps be moved so that it's visible in the doc output.
1721
*/
18-
/**
19-
@class
2022

23+
/**
2124
Ember.Location returns an instance of the correct implementation of
2225
the `location` API.
2326
2427
You can pass it a `implementation` ('hash', 'history', 'none') to force a
2528
particular implementation.
29+
30+
@class Location
31+
@namespace Ember
32+
@static
2633
*/
2734
Ember.Location = {
2835
create: function(options) {

packages/ember-routing/lib/location/hash_location.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1+
/**
2+
@module ember
3+
@submodule ember-routing
4+
*/
5+
16
var get = Ember.get, set = Ember.set;
27

38
/**
4-
@class
5-
69
Ember.HashLocation implements the location API using the browser's
710
hash. At present, it relies on a hashchange event existing in the
811
browser.
912
13+
@class HashLocation
14+
@namespace Ember
1015
@extends Ember.Object
1116
*/
12-
Ember.HashLocation = Ember.Object.extend(
13-
/** @scope Ember.HashLocation.prototype */ {
17+
Ember.HashLocation = Ember.Object.extend({
1418

15-
/** @private */
1619
init: function() {
1720
set(this, 'location', get(this, 'location') || window.location);
1821
},
@@ -21,6 +24,8 @@ Ember.HashLocation = Ember.Object.extend(
2124
@private
2225
2326
Returns the current `location.hash`, minus the '#' at the front.
27+
28+
@method getURL
2429
*/
2530
getURL: function() {
2631
return get(this, 'location').hash.substr(1);
@@ -32,6 +37,9 @@ Ember.HashLocation = Ember.Object.extend(
3237
Set the `location.hash` and remembers what was set. This prevents
3338
`onUpdateURL` callbacks from triggering when the hash was set by
3439
`HashLocation`.
40+
41+
@method setURL
42+
@param path {String}
3543
*/
3644
setURL: function(path) {
3745
get(this, 'location').hash = path;
@@ -44,6 +52,9 @@ Ember.HashLocation = Ember.Object.extend(
4452
Register a callback to be invoked when the hash changes. These
4553
callbacks will execute when the user presses the back or forward
4654
button, but not after `setURL` is invoked.
55+
56+
@method onUpdateURL
57+
@param callback {Function}
4758
*/
4859
onUpdateURL: function(callback) {
4960
var self = this;
@@ -67,12 +78,14 @@ Ember.HashLocation = Ember.Object.extend(
6778
6879
This is used, for example, when using the {{action}} helper
6980
to generate a URL based on an event.
81+
82+
@method formatURL
83+
@param url {String}
7084
*/
7185
formatURL: function(url) {
7286
return '#'+url;
7387
},
7488

75-
/** @private */
7689
willDestroy: function() {
7790
var guid = Ember.guidFor(this);
7891

packages/ember-routing/lib/location/history_location.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,49 @@
1+
/**
2+
@module ember
3+
@submodule ember-routing
4+
*/
5+
16
var get = Ember.get, set = Ember.set;
27

38
/**
4-
@class
5-
69
Ember.HistoryLocation implements the location API using the browser's
710
history.pushState API.
811
12+
@class HistoryLocation
13+
@namespace Ember
914
@extends Ember.Object
1015
*/
11-
Ember.HistoryLocation = Ember.Object.extend(
12-
/** @scope Ember.HistoryLocation.prototype */ {
16+
Ember.HistoryLocation = Ember.Object.extend({
1317

14-
/** @private */
1518
init: function() {
1619
set(this, 'location', get(this, 'location') || window.location);
1720
set(this, '_initialURL', get(this, 'location').pathname);
1821
},
1922

2023
/**
2124
Will be pre-pended to path upon state change
22-
*/
25+
26+
@property rootURL
27+
@default '/'
28+
*/
2329
rootURL: '/',
2430

2531
/**
2632
@private
2733
2834
Used to give history a starting reference
29-
*/
35+
36+
@property _initialURL
37+
@default null
38+
*/
3039
_initialURL: null,
3140

3241
/**
3342
@private
3443
3544
Returns the current `location.pathname`.
45+
46+
@method getURL
3647
*/
3748
getURL: function() {
3849
return get(this, 'location').pathname;
@@ -42,6 +53,9 @@ Ember.HistoryLocation = Ember.Object.extend(
4253
@private
4354
4455
Uses `history.pushState` to update the url without a page reload.
56+
57+
@method setURL
58+
@param path {String}
4559
*/
4660
setURL: function(path) {
4761
var state = window.history.state,
@@ -59,6 +73,9 @@ Ember.HistoryLocation = Ember.Object.extend(
5973
6074
Register a callback to be invoked whenever the browser
6175
history changes, including using forward and back buttons.
76+
77+
@method onUpdateURL
78+
@param callback {Function}
6279
*/
6380
onUpdateURL: function(callback) {
6481
var guid = Ember.guidFor(this);
@@ -72,6 +89,9 @@ Ember.HistoryLocation = Ember.Object.extend(
7289
@private
7390
7491
Used when using {{action}} helper. The url is always appended to the rootURL.
92+
93+
@method formatURL
94+
@param url {String}
7595
*/
7696
formatURL: function(url) {
7797
var rootURL = get(this, 'rootURL');
@@ -83,7 +103,6 @@ Ember.HistoryLocation = Ember.Object.extend(
83103
return rootURL + url;
84104
},
85105

86-
/** @private */
87106
willDestroy: function() {
88107
var guid = Ember.guidFor(this);
89108

packages/ember-routing/lib/location/none_location.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
/**
2+
@module ember
3+
@submodule ember-routing
4+
*/
5+
16
var get = Ember.get, set = Ember.set;
27

38
/**
4-
@class
5-
69
Ember.NoneLocation does not interact with the browser. It is useful for
710
testing, or when you need to manage state with your Router, but temporarily
811
don't want it to muck with the URL (for example when you embed your
912
application in a larger page).
1013
14+
@class NoneLocation
15+
@namespace Ember
1116
@extends Ember.Object
1217
*/
13-
Ember.NoneLocation = Ember.Object.extend(
14-
/** @scope Ember.NoneLocation.prototype */ {
18+
Ember.NoneLocation = Ember.Object.extend({
1519
path: '',
1620

1721
getURL: function() {

packages/ember-routing/lib/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@
77
require('ember-states');
88
require('ember-routing/route');
99
require('ember-routing/router');
10+
11+
/**
12+
Ember Routing
13+
14+
@module ember
15+
@submodule ember-routing
16+
@requires ember-states
17+
*/

0 commit comments

Comments
 (0)