Fixed #720. The run button now sets requested/withAlerts

Also tidying up some code and removing old files.

Note that the rejig of order in live.js is because the renderLivePreview needs to assigned before we create a throttled version of the code.
This commit is contained in:
Remy Sharp 2013-08-10 11:20:19 +01:00
parent 5569413015
commit 950d7cdff9
3 changed files with 15 additions and 43 deletions

View File

@ -185,7 +185,7 @@ $('#runwithalerts').click(function () {
});
$('#runconsole').click(function () {
editors.console.render();
editors.console.render(true);
return false;
});

View File

@ -1,33 +0,0 @@
// fake objects to help detect those infinite loops
var noop = function () {};
var document = {
createElement: function () {
return document;
},
appendChild: noop,
addEventListener: noop
},
alert = noop,
console = {
log: noop,
dir: noop
},
window = {
document: document,
console: console
};
this.addEventListener('message', function(e) {
this.postMessage({ code: 'READY' });
setTimeout(function () {
try {
eval(e.data);
} catch (e) {
this.postMessage({ code: 'ERROR', msg: e.toString() }); // 3 is excpetion and don't run
return;
}
this.postMessage({ code: 'DONE' });
}, 10);
}, false);

View File

@ -1,3 +1,6 @@
var $live = $('#live'),
showlive = $('#showlive')[0];
/**
* Defer callable. Kinda tricky to explain. Basically:
* "Don't make newFn callable until I tell you via this trigger callback."
@ -48,11 +51,6 @@ var deferCallable = function (newFn, trigger) {
* =============================================================================
*/
var $live = $('#live'),
showlive = $('#showlive')[0],
throttledPreview = throttle(renderLivePreview, 200),
liveScrollTop = null;
function sendReload() {
if (saveChecksum) {
$.ajax({
@ -67,8 +65,6 @@ function sendReload() {
}
}
var deferredLiveRender = null;
function codeChangeLive(event, data) {
clearTimeout(deferredLiveRender);
@ -101,8 +97,6 @@ function codeChangeLive(event, data) {
}
}
$document.bind('codeChange.live', codeChangeLive);
/** ============================================================================
* JS Bin Renderer
* Messages to and from the runner.
@ -336,3 +330,14 @@ var renderLivePreview = (function () {
}());
// this needs to be after renderLivePreview is set (as it's defined using
// var instead of a first class function).
var throttledPreview = throttle(renderLivePreview, 200),
liveScrollTop = null;
// timer value: used in the delayed render (because iframes don't have
// innerHeight/Width) in Chrome & WebKit
var deferredLiveRender = null;
$document.bind('codeChange.live', codeChangeLive);