author | ymh <ymh.work@gmail.com> |
Thu, 20 Oct 2016 17:27:36 +0200 | |
changeset 377 | 52169c718513 |
parent 141 | c0e8626a271c |
child 502 | 74fba571487e |
permissions | -rw-r--r-- |
141
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
import Ember from 'ember'; |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
import layout from '../templates/components/doc-literal'; |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
|
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
export default Ember.Component.extend({ |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
layout: layout, |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
tagName: 'span', |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
value: Ember.computed('url', function() { |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
var url = this.get('url'); |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
if(typeof url === 'string') { |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
return url; |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
} |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
else if (typeof url === 'object' && !Array.isArray(url) && 'value' in url) { |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
return url['value']; |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
} |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
else { |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
return null; |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
} |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
}), |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
lang: Ember.computed('url', function() { |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
var url = this.get('url'); |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
if (typeof url === 'object' && !Array.isArray(url) && 'lang' in url) { |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
return url['lang']; |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
} |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
else { |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
return null; |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
} |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
}), |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
datatype: Ember.computed('url', function() { |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
var url = this.get('url'); |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
if (typeof url === 'object' && !Array.isArray(url) && 'datatype' in url) { |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
return url['datatype']; |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
} |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
else { |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
return null; |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
} |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
}) |
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
|
c0e8626a271c
literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
38 |
}); |