# all files / keystone/fields/types/code/ CodeType.js

100% Statements 18/18
100% Branches 6/6
100% Functions 1/1
100% Lines 18/18

    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
    331×
    1×
    1×
    1×

    1×
    5×
    5×
    5×
    5×
    5×
    5×
    5×
    5×

    1×

    1×
    1×

    1×

    1×
     var assign = require('object-assign');
    var FieldType = require('../Type');
    var TextType = require('../text/TextType');
    var util = require('util');

    /**
     * HTML FieldType Constructor
     * @extends Field
     * @api public
     */
    function code (list, path, options) {
    	this._nativeType = String;
    	this._defaultSize = 'full';
    	this.height = options.height || 180;
    	this.lang = options.lang || options.language;
    	this._properties = ['editor', 'height', 'lang'];
    	this.codemirror = options.codemirror || {};
    	this.editor = assign({ mode: this.lang }, this.codemirror);
    	code.super_.call(this, list, path, options);
    }
    util.inherits(code, FieldType);

    code.prototype.validateInput = TextType.prototype.validateInput;
    code.prototype.validateRequiredInput = TextType.prototype.validateRequiredInput;

    /* Inherit from TextType prototype */
    code.prototype.addFilterToQuery = TextType.prototype.addFilterToQuery;

    /* Export Field Type */
    module.exports = code;