This commit is contained in:
parent
1e72294b35
commit
c0fcae05f1
|
@ -19,7 +19,7 @@ var playground = {
|
||||||
pid: undefined,
|
pid: undefined,
|
||||||
_resize: function () {
|
_resize: function () {
|
||||||
$("#editor, #output").height($(window).height() - 57 - $(".footer").height());
|
$("#editor, #output").height($(window).height() - 57 - $(".footer").height());
|
||||||
// playground.editor.setSize($("#editor").width(), $("#editor").height() + 4);
|
playground.editor.setSize("auto", $("#editor").height() + "px");
|
||||||
},
|
},
|
||||||
_initShare: function () {
|
_initShare: function () {
|
||||||
$(".share-panel .font-ico").click(function () {
|
$(".share-panel .font-ico").click(function () {
|
||||||
|
@ -42,7 +42,7 @@ var playground = {
|
||||||
"&url=" + url + "&pic=" + pic;
|
"&url=" + url + "&pic=" + pic;
|
||||||
|
|
||||||
window.open(urls[key], "_blank", "top=100,left=200,width=648,height=618");
|
window.open(urls[key], "_blank", "top=100,left=200,width=648,height=618");
|
||||||
|
|
||||||
$(".menu .share-panel").hide();
|
$(".menu .share-panel").hide();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -59,9 +59,12 @@ var playground = {
|
||||||
tabSize: 4,
|
tabSize: 4,
|
||||||
indentUnit: 4,
|
indentUnit: 4,
|
||||||
foldGutter: true,
|
foldGutter: true,
|
||||||
cursorHeight: 1
|
cursorHeight: 1,
|
||||||
|
viewportMargin: 1000
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#editorDiv").show();
|
||||||
|
|
||||||
$(window).resize(function () {
|
$(window).resize(function () {
|
||||||
playground._resize();
|
playground._resize();
|
||||||
});
|
});
|
||||||
|
@ -178,7 +181,16 @@ var playground = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
stop: function () {
|
stop: function () {
|
||||||
if (!playground.editor || !playground.pid) {
|
if (!playground.editor) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var cursor = playground.editor.getCursor();
|
||||||
|
playground.editor.focus();
|
||||||
|
|
||||||
|
playground.editor.setCursor(cursor);
|
||||||
|
|
||||||
|
if (!playground.pid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,6 +209,9 @@ var playground = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cursor = playground.editor.getCursor();
|
||||||
|
playground.editor.focus();
|
||||||
|
|
||||||
var code = playground.editor.getValue();
|
var code = playground.editor.getValue();
|
||||||
|
|
||||||
// Step 1. save & format code
|
// Step 1. save & format code
|
||||||
|
@ -213,6 +228,7 @@ var playground = {
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
playground.editor.setValue(data.code);
|
playground.editor.setValue(data.code);
|
||||||
|
playground.editor.setCursor(cursor);
|
||||||
|
|
||||||
if (!data.succ) {
|
if (!data.succ) {
|
||||||
return;
|
return;
|
||||||
|
@ -259,6 +275,9 @@ var playground = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cursor = playground.editor.getCursor();
|
||||||
|
playground.editor.focus();
|
||||||
|
|
||||||
var code = playground.editor.getValue();
|
var code = playground.editor.getValue();
|
||||||
|
|
||||||
var request = newWideRequest();
|
var request = newWideRequest();
|
||||||
|
@ -271,6 +290,7 @@ var playground = {
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
playground.editor.setValue(data.code);
|
playground.editor.setValue(data.code);
|
||||||
|
playground.editor.setCursor(cursor);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fn-clear">
|
<div class="fn-clear">
|
||||||
<div id="editorDiv">
|
<div id="editorDiv" style="display: none;">
|
||||||
<textarea id='editor'>{{.code}}</textarea>
|
<textarea id='editor'>{{.code}}</textarea>
|
||||||
</div>
|
</div>
|
||||||
<textarea id="output" rows="20" readonly="readonly" ></textarea>
|
<textarea id="output" rows="20" readonly="readonly" ></textarea>
|
||||||
|
|
Loading…
Reference in New Issue