initEditor is overriding globally scoped name
davidnewcomb opened this issue · comments
David Newcomb commented
From kv-markdown.js:
function initEditor(params) {
var input = params.source,
editor = params.editor,
preview = params.preview,
target = params.target,
maximize = params.maximize,
container = params.container,
modal = editor.slice(1) + '-modal',
export1 = params.export1,
export2 = params.export2,
defHeight = params.height,
$iframe = $('#' + params.iframeId),
$form = $iframe.contents().find('form'),
fullscreen = input.slice(1) + '-fullscreen';
filename = params.filename; //// <--------
$(input).focus(function () {
$(editor).addClass('active');
});
filename
is not defined inside your file, and the area where it is used is in the global space. So by setting this variable here you are potentially overwriting someone else' variable. It is difficult to say what the effect is. It could be nothing or everything!
I think you want:
$form = $iframe.contents().find('form'),
fullscreen = input.slice(1) + '-fullscreen', /// <---
filename = params.filename; //// <--------
$(input).focus(function () {
$(editor).addClass('active');
});