Permalink
Browse files

Merge branch 'codemirror-3.1'

  • Loading branch information...
2 parents 56de2dc + 11904d6 commit e6fc4959d5e31f76ae06ca11ebf46b4a69d649ac @dyoo committed Jan 31, 2013
@@ -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")
-(call-system "racket" "bin/compress-js.rkt" "--quiet" "war")
+(call-system "racket" "bin/compress-js.rkt" #;"--quiet" "--permissive" "war")
@@ -323,7 +323,7 @@ var initializeEditor;
goog.events.EventType.RESIZE,
onResize);
myEditor.setOnResize(onResize);
- jQuery.bind("fullscreenchange",
+ jQuery(window).bind("fullscreenchange",
function() {
onResize();
});
@@ -173,7 +173,8 @@ WeSchemeInteractions = (function () {
//stylesheet: "/js/codemirror/contrib/scheme/css/schemecolors-interactive.css",
content: nextCode,
makeTransparentIframe: true,
- readOnly: true },
+ readOnly: 'nocursor',
+ matchBrackets: false },
function(container) {
var newId = makeFreshId();
that.interactions.previousInteractionsTextContainers[newId] = container;
@@ -180,15 +180,17 @@ var WeSchemeTextContainer;
theme: (options.theme || "scheme"),
mode: "scheme2",
extraKeys: km,
- lineNumbers: (typeof (options.lineNumbers) !== 'undefined'? options.lineNumbers : true),
+ lineNumbers: (typeof (options.lineNumbers) !== undefined? options.lineNumbers : true),
lineWrapping: true,
- matchBrackets: true,
+ matchBrackets: (options.matchBrackets !== undefined ? options.matchBrackets : true),
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);
@@ -232,8 +234,8 @@ var WeSchemeTextContainer;
this.behaviorE.sendEvent(code);
}
- if (typeof(startOffset) !== 'undefined') {
- if (typeof(endOffset) !== 'undefined') {
+ if (typeof(startOffset) !== undefined) {
+ if (typeof(endOffset) !== undefined) {
return code.substring(startOffset, endOffset);
} else {
return code.substring(startOffset);
@@ -283,13 +285,13 @@ var WeSchemeTextContainer;
stylesheet.insertRule("." + name + " { background-color: " + color + ";}", 0);
} else {
// IE8 compatibility
- stylesheet.addRule("." + name, "{ background-color: " + color + "", 0);
+ stylesheet.addRule("." + name, "background-color: " + color + "", 0);
}
var highlightedArea = this.editor.markText(this.handleAndColumnToPos(startHandleAndColumn),
this.handleAndColumnToPos(endHandleAndColumn),
- name);
+ {className: name});
this.highlightedAreas.push(highlightedArea);
this.moveCursor(offset, span);
@@ -397,18 +399,12 @@ var WeSchemeTextContainer;
CodeMirrorImplementation.prototype.focus = function() {
- // Hack: if iPad, ignore focus attempts: it doesn't make
- // the keyboard show up.
- if (navigator.userAgent.match(/iPad/i) != null) {
- return;
- }
-
- this.editor.focus();
- /*
- var start = this.editor.getCursor(true);
- var end = this.editor.getCursor(false);
- this.editor.setSelection(start,end);
- */
+ // The try/catch blocks are meant to work around
+ // an issue in IE8 and CodeMirror 3.1. It may be obsolete
+ // as soon as the issue is resolved:
+ // https://github.com/marijnh/CodeMirror/issues/1200
+ try { this.editor.focus(); } catch (e) {}
+ try { this.editor.refresh(); } catch (e) {}
};
CodeMirrorImplementation.prototype.refresh = function() {
@@ -137,18 +137,16 @@
* Connect Event Handlers */
var _onBlur = cm.getOption('onBlur');
var _onFocus = cm.getOption('onFocus');
- cm.setOption("onBlur",
- function() {
+ cm.on("blur",function(cm, blur) {
if (_onBlur) { _onBlur(); }
keysVisible = false;
drawKeyboard();
});
- cm.setOption("onFocus",
- function(){
+ cm.on("focus", function(cm, focus){
if (_onFocus) { _onFocus(); }
keysVisible = true;
drawKeyboard();
- });
+ });
window.addEventListener('orientationchange', drawKeyboard, false);
window.addEventListener('scroll', drawKeyboard, false);
}
View
@@ -52,6 +52,8 @@
<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/addon/edit/matchbrackets.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" />
@@ -66,7 +68,7 @@
<link rel="stylesheet" type="text/css" href="/css/definitions.css"></link>
<!-- 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>
@@ -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 .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{
height: auto;
overflow-y: hidden;
View
@@ -161,11 +161,11 @@ var initializeWidget = (function () {
extraKeys: km,
mode: "scheme2",
value: "",
- onChange: onChange,
- onBlur: onBlur,
- onFocus: onFocus,
lineWrapping: true
});
+ this.codeMirrorElement.on('change', onChange);
+ this.codeMirrorElement.on('blur', onBlur);
+ this.codeMirrorElement.on('focus', onFocus);
};
ValidatedTextInputElement.prototype.isOk = function() {
@@ -207,7 +207,7 @@ var initializeWidget = (function () {
- // editor: CodeMirror2 editor
+ // editor: CodeMirror editor
var initializeWidget = function(editor, tokenizer) {
var contract_name, contract_domain, contract_range,
@@ -602,12 +602,15 @@ var initializeWidget = (function () {
if (this.preventDefault) {this.preventDefault(); this.stopPropagation();}
else {this.returnValue = false; this.cancelBubble = true;}
};
- var addStop = function(event) {
+ var addStopAndTarget = function(event) {
if (!event.stop) { event.stop = stopEvent; }
+ if (event.target === undefined) {
+ event.target = event.srcElement;
+ }
return event;
};
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") {
node.addEventListener(type, wrapHandler, false);
} else {
@@ -732,9 +735,15 @@ var initializeWidget = (function () {
pos = editor.getCursor(true); // get the current cursor location
pos.ch = 0; // force the character to 0
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
- hlLine = editor.setLineClass(editor.getCursor().line, "activeline");
+ hlLine = editor.addLineClass(editor.getCursor().line,
+ "wrap",
+ "activeline");
contract_name.focus();
};
@@ -772,7 +781,7 @@ var initializeWidget = (function () {
var hideWidget = function (widget){
document.getElementById('design-recipe-form').style.left = '-1000px';
- editor.setLineClass(hlLine, "");
+ editor.removeLineClass(hlLine, "wrap", "activeline");
editor.focus();
clearForm();
};
@@ -917,4 +926,4 @@ var initializeWidget = (function () {
};
return initializeWidget;
-}());
+}());

0 comments on commit e6fc495

Please sign in to comment.