all repos — litestore @ 49ecdd02163f833c379137fcfe0564e5b8fa3063

A minimalist nosql document store.

app/js/components.js

 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
(function(){
  'use strict';  
  var app = window.LS || (window.LS = {});
  app.editor = {};


  app.editor.config = function(obj){
    return function(element, isInitialized, context){
      var e = element;
      var setHeight = function(){
        e.style.height = (window.innerHeight-250)+"px";
      };

      if (!isInitialized) {
        var editor = ace.edit(e);
        obj.editor = editor;
        e.style.position = "relative";
        setHeight();
        window.addEventListener("resize", setHeight);
        editor.setReadOnly(true);
        editor.setShowPrintMargin(false);
        editor.setTheme("ace/theme/github");
        editor.getSession().setMode("ace/mode/"+obj.mode);
        editor.getSession().setUseWrapMode(true);
      }
    };
  };

  /**
   * @param obj
   *  - content The content of the editor
   */
  app.editor.view = function(obj) {
    return m(".editor.panel.panal-default", {config: app.editor.config(obj)}, obj.content);
    
  };
  
}());