common/corpus-common-addon/addon/components/doc-literal.js
author Chloe Laisne <chloe.laisne@gmail.com>
Thu, 23 Jun 2016 23:21:02 +0200
changeset 202 0446e07981db
parent 141 c0e8626a271c
child 502 74fba571487e
permissions -rw-r--r--
Add interval to filter component Add filter.date observer to visu-chrono Minor playlist component styling
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
});