author | ymh <ymh.work@gmail.com> |
Fri, 02 Dec 2016 00:22:31 +0100 | |
changeset 454 | 710a2ae08a74 |
parent 445 | b1e5ad6b2a29 |
permissions | -rw-r--r-- |
433
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
// inspired by http://stackoverflow.com/a/36368522 |
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
|
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
import Ember from 'ember'; |
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
|
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
export default Ember.Helper.extend({ |
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
router: Ember.computed(function() { |
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
return Ember.getOwner(this).lookup('router:main'); |
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
}), |
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
|
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
compute([routeName, ...routeParams]) { |
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
let router = this.get('router'); |
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
|
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
var resUrl = Ember.isEmpty(routeParams) ? |
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
router.generate(routeName) : router.generate(routeName, routeParams[0]); |
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
var location = window.location; |
441
65a6c640de7a
correct absolute url creation in helper, again
ymh <ymh.work@gmail.com>
parents:
439
diff
changeset
|
16 |
return location.protocol + "//" + location.host + location.pathname + resUrl; |
433
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
} |
65e357e5eecb
correct document permalinks in notice and share buttons
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
}); |