aboutsummaryrefslogtreecommitdiff
path: root/atom/packages/ex-mode/node_modules/atom-space-pen-views/lib/text-editor-view.js
blob: 8aecdaf627be0520620dc31cc0db3056c1406496 (plain)
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
(function() {
  var $, TextEditorView, View, _ref,
    __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  _ref = require('space-pen'), View = _ref.View, $ = _ref.$;

  module.exports = TextEditorView = (function(_super) {
    __extends(TextEditorView, _super);

    function TextEditorView(params) {
      var attributes, editor, mini, name, placeholderText, value;
      if (params == null) {
        params = {};
      }
      mini = params.mini, placeholderText = params.placeholderText, attributes = params.attributes, editor = params.editor;
      if (attributes == null) {
        attributes = {};
      }
      if (mini != null) {
        attributes['mini'] = mini;
      }
      if (placeholderText != null) {
        attributes['placeholder-text'] = placeholderText;
      }
      if (editor != null) {
        this.element = atom.views.getView(editor);
      } else {
        this.element = document.createElement('atom-text-editor');
      }
      for (name in attributes) {
        value = attributes[name];
        this.element.setAttribute(name, value);
      }
      if (this.element.__spacePenView != null) {
        this.element.__spacePenView = this;
        this.element.__allowViewAccess = true;
      }
      TextEditorView.__super__.constructor.apply(this, arguments);
      this.setModel(this.element.getModel());
    }

    TextEditorView.prototype.setModel = function(model) {
      this.model = model;
    };

    TextEditorView.prototype.getModel = function() {
      return this.model;
    };

    TextEditorView.prototype.getText = function() {
      return this.model.getText();
    };

    TextEditorView.prototype.setText = function(text) {
      return this.model.setText(text);
    };

    TextEditorView.prototype.hasFocus = function() {
      return this.element.hasFocus();
    };

    return TextEditorView;

  })(View);

}).call(this);