-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
Copy pathnone_location.js
91 lines (77 loc) · 2.03 KB
/
none_location.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set';
import EmberObject from 'ember-runtime/system/object';
/**
@module ember
@submodule ember-routing
*/
/**
Ember.NoneLocation does not interact with the browser. It is useful for
testing, or when you need to manage state with your Router, but temporarily
don't want it to muck with the URL (for example when you embed your
application in a larger page).
@class NoneLocation
@namespace Ember
@extends Ember.Object
@private
*/
export default EmberObject.extend({
implementation: 'none',
path: '',
/**
Returns the current path.
@private
@method getURL
@return {String} path
*/
getURL() {
return get(this, 'path');
},
/**
Set the path and remembers what was set. Using this method
to change the path will not invoke the `updateURL` callback.
@private
@method setURL
@param path {String}
*/
setURL(path) {
set(this, 'path', path);
},
/**
Register a callback to be invoked when the path changes. These
callbacks will execute when the user presses the back or forward
button, but not after `setURL` is invoked.
@private
@method onUpdateURL
@param callback {Function}
*/
onUpdateURL(callback) {
this.updateCallback = callback;
},
/**
Sets the path and calls the `updateURL` callback.
@private
@method handleURL
@param callback {Function}
*/
handleURL(url) {
set(this, 'path', url);
this.updateCallback(url);
},
/**
Given a URL, formats it to be placed into the page as part
of an element's `href` attribute.
This is used, for example, when using the {{action}} helper
to generate a URL based on an event.
@private
@method formatURL
@param url {String}
@return {String} url
*/
formatURL(url) {
// The return value is not overly meaningful, but we do not want to throw
// errors when test code renders templates containing {{action href=true}}
// helpers.
return url;
}
});