diff --git a/www/code/main.js b/www/code/main.js index 5da41d054..6a04c73ec 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -27,19 +27,6 @@ define([ var toolbar; var editor; - var $iframe = $('#pad-iframe').contents(); - var $previewContainer = $iframe.find('#previewContainer'); - var $preview = $iframe.find('#preview'); - $preview.click(function (e) { - if (!e.target) { return; } - var $t = $(e.target); - if ($t.is('a') || $t.parents('a').length) { - e.preventDefault(); - var $a = $t.is('a') ? $t : $t.parents('a').first(); - var href = $a.attr('href'); - window.open(href); - } - }); var secret = Cryptpad.getSecrets(); var readOnly = secret.keys && !secret.keys.editKeyStr; @@ -52,6 +39,20 @@ define([ }; var andThen = function (CMeditor) { + var $iframe = $('#pad-iframe').contents(); + var $previewContainer = $iframe.find('#previewContainer'); + var $preview = $iframe.find('#preview'); + $preview.click(function (e) { + if (!e.target) { return; } + var $t = $(e.target); + if ($t.is('a') || $t.parents('a').length) { + e.preventDefault(); + var $a = $t.is('a') ? $t : $t.parents('a').first(); + var href = $a.attr('href'); + window.open(href); + } + }); + var CodeMirror = Cryptpad.createCodemirror(CMeditor, ifrw, Cryptpad); $iframe.find('.CodeMirror').addClass('fullPage'); editor = CodeMirror.editor;