Permalink
Browse files

JavaScript autocomplete

  • Loading branch information...
pboyer committed Jun 16, 2015
1 parent 30602f3 commit 47926b7a44a6a6d697b448338f658f0e6339f287
Showing with 28 additions and 7 deletions.
  1. +2 −1 Gruntfile.js
  2. +1 −0 app/app.html
  3. +18 −4 app/scripts/views/NodeViews/Script.js
  4. +6 −0 app/styles/main.css
  5. +1 −2 server/app.js
View
@@ -106,8 +106,9 @@ module.exports = function (grunt) {
'<%= yeoman.app %>/bower_components/jquery.ui/themes/base/*.css',
'<%= yeoman.app %>/bower_components/components-font-awesome/css/font-awesome.min.css',
'<%= yeoman.app %>/styles/bootstrap.css',
- '<%= yeoman.app %>/styles/main.css',
'<%= yeoman.app %>/bower_components/CodeMirror/lib/codemirror.css',
+ '<%= yeoman.app %>/bower_components/CodeMirror/addon/hint/show-hint.css',
+ '<%= yeoman.app %>/styles/main.css',
],
'<%= yeoman.dist %>/customizer.min.css': [
'.tmp/styles/{,*/}*.css',
View
@@ -15,6 +15,7 @@
<link rel="stylesheet" href="bower_components/components-font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="styles/bootstrap.css">
<link rel="stylesheet" href="bower_components/CodeMirror/lib/codemirror.css">
+ <link rel="stylesheet" href="bower_components/CodeMirror/addon/hint/show-hint.css">
<link rel="stylesheet" href="styles/main.css">
<!-- /build -->
@@ -1,4 +1,4 @@
-define(['backbone', 'underscore', 'jquery', 'ThreeCSGNodeView', 'FLOOD', 'codemirror', 'codemirror/mode/javascript/javascript'], function(Backbone, _, $, ThreeCSGNodeView, FLOOD, CodeMirror) {
+define(['backbone', 'underscore', 'jquery', 'ThreeCSGNodeView', 'FLOOD', 'codemirror', 'codemirror/mode/javascript/javascript','codemirror/addon/hint/show-hint', 'codemirror/addon/hint/javascript-hint' ], function(Backbone, _, $, ThreeCSGNodeView, FLOOD, CodeMirror) {
return ThreeCSGNodeView.extend({
@@ -62,13 +62,27 @@ define(['backbone', 'underscore', 'jquery', 'ThreeCSGNodeView', 'FLOOD', 'codemi
},
+ extendScope: _.once(function(){
+
+ var or = CodeMirror.hint.javascript;
+ CodeMirror.hint.javascript = function(editor, options){
+ options.globalScope = FLOOD.nodeTypes;
+ return or(editor, options);
+ }
+ }),
+
renderNode: function() {
ThreeCSGNodeView.prototype.renderNode.apply(this, arguments);
- var ta = this.$el.find('.script-text-input');
- var cm = CodeMirror.fromTextArea(ta[0], { mode: "javascript" });
+ this.extendScope();
- var that = this;
+ var ta = this.$el.find('.script-text-input');
+ var cm = CodeMirror.fromTextArea(ta[0],
+ { extraKeys: {"Ctrl-Space": "autocomplete"},
+ mode: { name :"javascript" }
+ });
+
+ var that = this;
cm.on("focus",function(e){
that.selectable = false;
View
@@ -239,10 +239,16 @@ input[type="button"].btn-block {
}
.CodeMirror {
+ font-family: monospace;
height: auto;
border: 1px solid rgba(0,0,0,0.2);
}
+.CodeMirror-hints {
+ z-index: 150;
+ font-size: 10px;
+}
+
.workspace-runner-status {
top: 90px;
right: 60px;
View
@@ -59,7 +59,6 @@ mongoose.connection.on('error', function() {
/**
* Express configuration.
*/
-
var hour = 3600000;
var day = hour * 24;
var week = day * 7;
@@ -96,7 +95,7 @@ app.use(function(req, res, next) {
});
app.use(flash());
-var staticFolder = process.env.FLOOD_STATIC || '../dist';
+var staticFolder = process.env.FLOOD_STATIC || '../app';
app.use(express.static(path.join(__dirname, staticFolder )));
app.use(function(req, res, next) {
// Keep track of previous URL

0 comments on commit 47926b7

Please sign in to comment.