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

Commit 67b0946

Browse files
committed
build dist files
1 parent e647897 commit 67b0946

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,12 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
579579
if ($p.length && (($p.text().trim() === '' && !activeAddon) || activeAddon === 'images')) {
580580
$p.addClass('medium-insert-active');
581581

582+
if (activeAddon === 'images') {
583+
this.$el.find('.medium-insert-buttons').attr('data-active-addon', activeAddon);
584+
} else {
585+
this.$el.find('.medium-insert-buttons').removeAttr('data-active-addon');
586+
}
587+
582588
// If buttons are displayed on addon paragraph, wait 100ms for possible captions to display
583589
setTimeout(function () {
584590
that.positionButtons(activeAddon);
@@ -637,29 +643,26 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
637643
$lastCaption = $p.hasClass('medium-insert-images-grid') ? [] : $p.find('figure:last figcaption'),
638644
elementsContainer = this.getEditor() ? this.getEditor().options.elementsContainer : $('body').get(0),
639645
elementsContainerAbsolute = ['absolute', 'fixed'].indexOf(window.getComputedStyle(elementsContainer).getPropertyValue('position')) > -1,
640-
elementsContainerBoundary = elementsContainerAbsolute ? elementsContainer.getBoundingClientRect() : null,
641646
position = {};
642647

643648
if ($p.length) {
649+
position.left = $p.position().left;
650+
position.top = $p.position().top;
651+
644652
if (activeAddon) {
645-
position.left = $p.offset().left + $p.width() - $buttons.find('.medium-insert-buttons-show').width() - 10;
646-
position.top = $p.offset().top + $p.height() - 20 + ($lastCaption.length ? -$lastCaption.height() - parseInt($lastCaption.css('margin-top'), 10) : 10);
653+
position.left += $p.width() - $buttons.find('.medium-insert-buttons-show').width() - 10;
654+
position.top += $p.height() - 20 + ($lastCaption.length ? -$lastCaption.height() - parseInt($lastCaption.css('margin-top'), 10) : 10);
647655
} else {
648-
position.left = $p.offset().left - parseInt($buttons.find('.medium-insert-buttons-addons').css('left'), 10) - parseInt($buttons.find('.medium-insert-buttons-addons button:first').css('margin-left'), 10);
649-
position.top = $p.offset().top;
656+
position.left += -parseInt($buttons.find('.medium-insert-buttons-addons').css('left'), 10) - parseInt($buttons.find('.medium-insert-buttons-addons button:first').css('margin-left'), 10);
657+
position.top += parseInt($p.css('margin-top'), 10);
650658
}
651659

652660
if (elementsContainerAbsolute) {
653-
position.top += elementsContainer.scrollTop - elementsContainerBoundary.top;
654-
position.left -= elementsContainerBoundary.left;
661+
position.top += elementsContainer.scrollTop;
655662
}
656663

657664
if (this.$el.hasClass('medium-editor-placeholder') === false && position.left < 0) {
658-
position.left = $p.offset().left;
659-
660-
if (elementsContainerAbsolute) {
661-
position.left -= elementsContainerBoundary.left;
662-
}
665+
position.left = $p.position().left;
663666
}
664667

665668
$buttons.css(position);
@@ -673,6 +676,11 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
673676
*/
674677

675678
Core.prototype.toggleAddons = function () {
679+
if (this.$el.find('.medium-insert-buttons').attr('data-active-addon') === 'images') {
680+
this.$el.find('.medium-insert-buttons').find('button[data-addon="images"]').click();
681+
return;
682+
}
683+
676684
this.$el.find('.medium-insert-buttons-addons').fadeToggle();
677685
this.$el.find('.medium-insert-buttons-show').toggleClass('medium-insert-buttons-rotate');
678686
};

0 commit comments

Comments
 (0)