refactor: pass in ifrw.CodeMirror into andThen()
This commit is contained in:
parent
663e987345
commit
84c0ea6d26
@ -8,7 +8,6 @@ define([
|
|||||||
'/customize/pad.js'
|
'/customize/pad.js'
|
||||||
var $ = window.jQuery;
|
var $ = window.jQuery;
|
||||||
var ifrw = $('#pad-iframe')[0].contentWindow;
|
var ifrw = $('#pad-iframe')[0].contentWindow;
|
||||||
var CMeditor;
|
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
$(window).on('hashchange', function() {
|
$(window).on('hashchange', function() {
|
||||||
@ -19,7 +18,7 @@ define([
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var andThen = function () {
|
var andThen = function (CMeditor) {
|
||||||
var key = Crypto.parseKey(window.location.hash.substring(1));
|
var key = Crypto.parseKey(window.location.hash.substring(1));
|
||||||
var editor = CMeditor.fromTextArea($('#pad-iframe').contents().find('#editor1')[0], {
|
var editor = CMeditor.fromTextArea($('#pad-iframe').contents().find('#editor1')[0], {
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
@ -52,11 +51,11 @@ define([
|
|||||||
var interval = 100;
|
var interval = 100;
|
||||||
|
|
||||||
var first = function () {
|
var first = function () {
|
||||||
if (CMeditor = ifrw.CodeMirror) {
|
if (ifrw.CodeMirror) {
|
||||||
// it exists, call your continuation
|
// it exists, call your continuation
|
||||||
andThen();
|
andThen(ifrw.CodeMirror);
|
||||||
} else {
|
} else {
|
||||||
console.log("CMeditor was not defined. Trying again in %sms", interval);
|
console.log("CodeMirror was not defined. Trying again in %sms", interval);
|
||||||
// try again in 'interval' ms
|
// try again in 'interval' ms
|
||||||
setTimeout(first, interval);
|
setTimeout(first, interval);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user