Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit c7a1142

Browse files
committed
* 'master' of https://github.com/orthes/medium-editor-images-plugin: fix line cut-off causing jshint to fail fix line cut-off causing jshint to fail re #140: Console.log not always defined in IE re #136: Check that p is defined in positionButtons re #140: Console.log not always defined in IE re #136: Check that is defined in positionButtons
2 parents 9af9601 + aacb72a commit c7a1142

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

dist/js/medium-editor-insert-plugin.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,11 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
486486
left, top;
487487

488488
// Left position is set according to an active paragraph
489-
left = $p.position().left - parseInt($buttons.find('.medium-insert-buttons-addons').css('left'), 10) - parseInt($buttons.find('.medium-insert-buttons-addons a:first').css('margin-left'), 10);
490-
left = left < 0 ? $p.position().left : left;
491-
$buttons.css('left', left);
489+
if ($p.length) {
490+
left = $p.position().left - parseInt($buttons.find('.medium-insert-buttons-addons').css('left'), 10) - parseInt($buttons.find('.medium-insert-buttons-addons a:first').css('margin-left'), 10);
491+
left = left < 0 ? $p.position().left : left;
492+
$buttons.css('left', left);
493+
}
492494

493495
if ($current) {
494496
// Top position is set according to a current active element
@@ -808,7 +810,11 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
808810
} catch(e) {}
809811
})();
810812

811-
window.console.log((responseJSON && responseJSON.error) || jqXHR.status || errorThrown.message);
813+
if (typeof window.console !== 'undefined') {
814+
window.console.log((responseJSON && responseJSON.error) || jqXHR.status || errorThrown.message);
815+
} else {
816+
window.alert('Error requesting media from ' + that.options.oembedProxy + ' to insert: ' + errorThrown + ' (response status: ' + jqXHR.status + ')');
817+
}
812818

813819
$.proxy(that, 'convertBadEmbed', url)();
814820
}

src/js/core.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,11 @@
391391
left, top;
392392

393393
// Left position is set according to an active paragraph
394-
left = $p.position().left - parseInt($buttons.find('.medium-insert-buttons-addons').css('left'), 10) - parseInt($buttons.find('.medium-insert-buttons-addons a:first').css('margin-left'), 10);
395-
left = left < 0 ? $p.position().left : left;
396-
$buttons.css('left', left);
394+
if ($p.length) {
395+
left = $p.position().left - parseInt($buttons.find('.medium-insert-buttons-addons').css('left'), 10) - parseInt($buttons.find('.medium-insert-buttons-addons a:first').css('margin-left'), 10);
396+
left = left < 0 ? $p.position().left : left;
397+
$buttons.css('left', left);
398+
}
397399

398400
if ($current) {
399401
// Top position is set according to a current active element

src/js/embeds.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@
239239
} catch(e) {}
240240
})();
241241

242-
window.console.log((responseJSON && responseJSON.error) || jqXHR.status || errorThrown.message);
242+
if (typeof window.console !== 'undefined') {
243+
window.console.log((responseJSON && responseJSON.error) || jqXHR.status || errorThrown.message);
244+
} else {
245+
window.alert('Error requesting media from ' + that.options.oembedProxy + ' to insert: ' + errorThrown + ' (response status: ' + jqXHR.status + ')');
246+
}
243247

244248
$.proxy(that, 'convertBadEmbed', url)();
245249
}

0 commit comments

Comments
 (0)