common/corpus-common-addon/addon/components/doc-literal.js
author ymh <ymh.work@gmail.com>
Thu, 09 Feb 2017 17:22:58 +0100
changeset 505 9175ea22f1b1
parent 502 74fba571487e
permissions -rw-r--r--
Do not map language info for text. This should correct bug #0025932
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',
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
     7
  value: Ember.computed('url', function () {
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
     8
    const url = this.get('url');
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
     9
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    10
    if (typeof url === 'string') {
141
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
      return url;
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    12
    } else if (typeof url === 'object' && !Array.isArray(url) && 'value' in url) {
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    13
      return url.value;
141
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
    }
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    15
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    16
    return null;
141
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
  }),
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    18
  lang: Ember.computed('url', function () {
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    19
    const url = this.get('url');
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    20
141
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) {
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    22
      return url.lang;
141
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
    }
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    24
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    25
    return null;
141
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
  }),
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    27
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    28
  datatype: Ember.computed('url', function () {
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    29
    const url = this.get('url');
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    30
141
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
    if (typeof url === 'object' && !Array.isArray(url) && 'datatype' in url) {
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    32
      return url.datatype;
141
c0e8626a271c literal are now objects if one of lang or datatype is not null
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
    }
502
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    34
74fba571487e Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents: 141
diff changeset
    35
    return null;
141
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
});