Skip to content

Commit

Permalink
Merge branch 'codemirror-3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
dyoo committed Jan 31, 2013
2 parents 56de2dc + 11904d6 commit e6fc495
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 43 deletions.
2 changes: 1 addition & 1 deletion build-console-and-editor.rkt
Expand Up @@ -169,4 +169,4 @@


;; ###################################################################### ;; ######################################################################
(printf "Compressing JavaScript libraries. This may take a few minutes, depending if this is the first time this has been run.\n") (printf "Compressing JavaScript libraries. This may take a few minutes, depending if this is the first time this has been run.\n")
(call-system "racket" "bin/compress-js.rkt" "--quiet" "war") (call-system "racket" "bin/compress-js.rkt" #;"--quiet" "--permissive" "war")
2 changes: 1 addition & 1 deletion war-src/js/openEditor/index.js
Expand Up @@ -323,7 +323,7 @@ var initializeEditor;
goog.events.EventType.RESIZE, goog.events.EventType.RESIZE,
onResize); onResize);
myEditor.setOnResize(onResize); myEditor.setOnResize(onResize);
jQuery.bind("fullscreenchange", jQuery(window).bind("fullscreenchange",
function() { function() {
onResize(); onResize();
}); });
Expand Down
3 changes: 2 additions & 1 deletion war-src/js/openEditor/interaction.js
Expand Up @@ -173,7 +173,8 @@ WeSchemeInteractions = (function () {
//stylesheet: "/js/codemirror/contrib/scheme/css/schemecolors-interactive.css", //stylesheet: "/js/codemirror/contrib/scheme/css/schemecolors-interactive.css",
content: nextCode, content: nextCode,
makeTransparentIframe: true, makeTransparentIframe: true,
readOnly: true }, readOnly: 'nocursor',
matchBrackets: false },
function(container) { function(container) {
var newId = makeFreshId(); var newId = makeFreshId();
that.interactions.previousInteractionsTextContainers[newId] = container; that.interactions.previousInteractionsTextContainers[newId] = container;
Expand Down
40 changes: 18 additions & 22 deletions war-src/js/openEditor/textcontainer.js
Expand Up @@ -180,15 +180,17 @@ var WeSchemeTextContainer;
theme: (options.theme || "scheme"), theme: (options.theme || "scheme"),
mode: "scheme2", mode: "scheme2",
extraKeys: km, extraKeys: km,
lineNumbers: (typeof (options.lineNumbers) !== 'undefined'? options.lineNumbers : true), lineNumbers: (typeof (options.lineNumbers) !== undefined? options.lineNumbers : true),
lineWrapping: true, lineWrapping: true,
matchBrackets: true, matchBrackets: (options.matchBrackets !== undefined ? options.matchBrackets : true),
value: options.content || "", value: options.content || "",
readOnly: (typeof (options.readOnly) !== 'undefined'? options.readOnly : false), readOnly: (typeof (options.readOnly) !== undefined? options.readOnly : false)


onChange: function() { });
that.behaviorE.sendEvent(that.editor.getValue()); this.editor.on('change',
}}); function() {
that.behaviorE.sendEvent(that.editor.getValue());
});


extendEditorWithIOSKeys(this.editor); extendEditorWithIOSKeys(this.editor);


Expand Down Expand Up @@ -232,8 +234,8 @@ var WeSchemeTextContainer;
this.behaviorE.sendEvent(code); this.behaviorE.sendEvent(code);
} }


if (typeof(startOffset) !== 'undefined') { if (typeof(startOffset) !== undefined) {
if (typeof(endOffset) !== 'undefined') { if (typeof(endOffset) !== undefined) {
return code.substring(startOffset, endOffset); return code.substring(startOffset, endOffset);
} else { } else {
return code.substring(startOffset); return code.substring(startOffset);
Expand Down Expand Up @@ -283,13 +285,13 @@ var WeSchemeTextContainer;
stylesheet.insertRule("." + name + " { background-color: " + color + ";}", 0); stylesheet.insertRule("." + name + " { background-color: " + color + ";}", 0);
} else { } else {
// IE8 compatibility // IE8 compatibility
stylesheet.addRule("." + name, "{ background-color: " + color + "", 0); stylesheet.addRule("." + name, "background-color: " + color + "", 0);
} }




var highlightedArea = this.editor.markText(this.handleAndColumnToPos(startHandleAndColumn), var highlightedArea = this.editor.markText(this.handleAndColumnToPos(startHandleAndColumn),
this.handleAndColumnToPos(endHandleAndColumn), this.handleAndColumnToPos(endHandleAndColumn),
name); {className: name});


this.highlightedAreas.push(highlightedArea); this.highlightedAreas.push(highlightedArea);
this.moveCursor(offset, span); this.moveCursor(offset, span);
Expand Down Expand Up @@ -397,18 +399,12 @@ var WeSchemeTextContainer;




CodeMirrorImplementation.prototype.focus = function() { CodeMirrorImplementation.prototype.focus = function() {
// Hack: if iPad, ignore focus attempts: it doesn't make // The try/catch blocks are meant to work around
// the keyboard show up. // an issue in IE8 and CodeMirror 3.1. It may be obsolete
if (navigator.userAgent.match(/iPad/i) != null) { // as soon as the issue is resolved:
return; // https://github.com/marijnh/CodeMirror/issues/1200
} try { this.editor.focus(); } catch (e) {}

try { this.editor.refresh(); } catch (e) {}
this.editor.focus();
/*
var start = this.editor.getCursor(true);
var end = this.editor.getCursor(false);
this.editor.setSelection(start,end);
*/
}; };


CodeMirrorImplementation.prototype.refresh = function() { CodeMirrorImplementation.prototype.refresh = function() {
Expand Down
2 changes: 1 addition & 1 deletion war/js/codemirror2
Submodule codemirror2 updated from e8c795 to dfc45b
8 changes: 3 additions & 5 deletions war/js/ios-keyboard/iOSkeyboard.js
Expand Up @@ -137,18 +137,16 @@
* Connect Event Handlers */ * Connect Event Handlers */
var _onBlur = cm.getOption('onBlur'); var _onBlur = cm.getOption('onBlur');
var _onFocus = cm.getOption('onFocus'); var _onFocus = cm.getOption('onFocus');
cm.setOption("onBlur", cm.on("blur",function(cm, blur) {
function() {
if (_onBlur) { _onBlur(); } if (_onBlur) { _onBlur(); }
keysVisible = false; keysVisible = false;
drawKeyboard(); drawKeyboard();
}); });
cm.setOption("onFocus", cm.on("focus", function(cm, focus){
function(){
if (_onFocus) { _onFocus(); } if (_onFocus) { _onFocus(); }
keysVisible = true; keysVisible = true;
drawKeyboard(); drawKeyboard();
}); });
window.addEventListener('orientationchange', drawKeyboard, false); window.addEventListener('orientationchange', drawKeyboard, false);
window.addEventListener('scroll', drawKeyboard, false); window.addEventListener('scroll', drawKeyboard, false);
} }
Expand Down
4 changes: 3 additions & 1 deletion war/openEditor/index.jsp
Expand Up @@ -52,6 +52,8 @@
<script src="/js/jquery/jquery.blockUI-min.js" type="text/javascript"></script> <script src="/js/jquery/jquery.blockUI-min.js" type="text/javascript"></script>


<script src="/js/codemirror2/lib/codemirror-min.js" type="text/javascript"></script> <script src="/js/codemirror2/lib/codemirror-min.js" type="text/javascript"></script>

<script src="/js/codemirror2/addon/edit/matchbrackets.js" type="text/javascript"></script>
<script src="/js/codemirror2-contrib/scheme2/scheme2-min.js" type="text/javascript"></script> <script src="/js/codemirror2-contrib/scheme2/scheme2-min.js" type="text/javascript"></script>


<link rel="stylesheet" type="text/css" href="/css/codemirror.css" id="style" /> <link rel="stylesheet" type="text/css" href="/css/codemirror.css" id="style" />
Expand All @@ -66,7 +68,7 @@
<link rel="stylesheet" type="text/css" href="/css/definitions.css"></link> <link rel="stylesheet" type="text/css" href="/css/definitions.css"></link>


<!-- Design recipe widget stuff --> <!-- Design recipe widget stuff -->
<script src="/widget/js/DRwidget-min.js" type="text/javascript"></script> <script src="/widget/js/DRwidget.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/widget/css/editor.css"></link> <link rel="stylesheet" type="text/css" href="/widget/css/editor.css"></link>




Expand Down
3 changes: 2 additions & 1 deletion war/widget/css/editor.css
Expand Up @@ -2,7 +2,8 @@ div#design-recipe-form .CodeMirror {background: white; border: solid 1px black;
div#design-recipe-form .CodeMirror-scroll {height: 300px;} div#design-recipe-form .CodeMirror-scroll {height: 300px;}
div#design-recipe-form .activeline{background: wheat !important;} div#design-recipe-form .activeline{background: wheat !important;}


div#design-recipe-form div#form .CodeMirror{border: none;} /* override CM's default height of 300px */
div#design-recipe-form .CodeMirror{height: auto;}
div#design-recipe-form .CodeMirror-scroll{ div#design-recipe-form .CodeMirror-scroll{
height: auto; height: auto;
overflow-y: hidden; overflow-y: hidden;
Expand Down
29 changes: 19 additions & 10 deletions war/widget/js/DRwidget.js
Expand Up @@ -161,11 +161,11 @@ var initializeWidget = (function () {
extraKeys: km, extraKeys: km,
mode: "scheme2", mode: "scheme2",
value: "", value: "",
onChange: onChange,
onBlur: onBlur,
onFocus: onFocus,
lineWrapping: true lineWrapping: true
}); });
this.codeMirrorElement.on('change', onChange);
this.codeMirrorElement.on('blur', onBlur);
this.codeMirrorElement.on('focus', onFocus);
}; };


ValidatedTextInputElement.prototype.isOk = function() { ValidatedTextInputElement.prototype.isOk = function() {
Expand Down Expand Up @@ -207,7 +207,7 @@ var initializeWidget = (function () {






// editor: CodeMirror2 editor // editor: CodeMirror editor
var initializeWidget = function(editor, tokenizer) { var initializeWidget = function(editor, tokenizer) {


var contract_name, contract_domain, contract_range, var contract_name, contract_domain, contract_range,
Expand Down Expand Up @@ -602,12 +602,15 @@ var initializeWidget = (function () {
if (this.preventDefault) {this.preventDefault(); this.stopPropagation();} if (this.preventDefault) {this.preventDefault(); this.stopPropagation();}
else {this.returnValue = false; this.cancelBubble = true;} else {this.returnValue = false; this.cancelBubble = true;}
}; };
var addStop = function(event) { var addStopAndTarget = function(event) {
if (!event.stop) { event.stop = stopEvent; } if (!event.stop) { event.stop = stopEvent; }
if (event.target === undefined) {
event.target = event.srcElement;
}
return event; return event;
}; };
var connect = function(node, type, handler) { var connect = function(node, type, handler) {
function wrapHandler(event) {handler(addStop(event || window.event));} function wrapHandler(event) {handler(addStopAndTarget(event || window.event));}
if (typeof node.addEventListener === "function") { if (typeof node.addEventListener === "function") {
node.addEventListener(type, wrapHandler, false); node.addEventListener(type, wrapHandler, false);
} else { } else {
Expand Down Expand Up @@ -732,9 +735,15 @@ var initializeWidget = (function () {
pos = editor.getCursor(true); // get the current cursor location pos = editor.getCursor(true); // get the current cursor location
pos.ch = 0; // force the character to 0 pos.ch = 0; // force the character to 0
var node= document.getElementById('design-recipe-form'); var node= document.getElementById('design-recipe-form');
connect(node, "click", function(event){event.target.focus(); event.stop(); return false;}); connect(node, "click",
function(event){
event.target.focus();
event.stop();
return false;});
editor.addWidget(pos, node, true); // display the DR widget just below the line, and scroll so it's visible editor.addWidget(pos, node, true); // display the DR widget just below the line, and scroll so it's visible
hlLine = editor.setLineClass(editor.getCursor().line, "activeline"); hlLine = editor.addLineClass(editor.getCursor().line,
"wrap",
"activeline");
contract_name.focus(); contract_name.focus();
}; };


Expand Down Expand Up @@ -772,7 +781,7 @@ var initializeWidget = (function () {


var hideWidget = function (widget){ var hideWidget = function (widget){
document.getElementById('design-recipe-form').style.left = '-1000px'; document.getElementById('design-recipe-form').style.left = '-1000px';
editor.setLineClass(hlLine, ""); editor.removeLineClass(hlLine, "wrap", "activeline");
editor.focus(); editor.focus();
clearForm(); clearForm();
}; };
Expand Down Expand Up @@ -917,4 +926,4 @@ var initializeWidget = (function () {
}; };


return initializeWidget; return initializeWidget;
}()); }());

0 comments on commit e6fc495

Please sign in to comment.