|
1 | 1 | /*global MediumEditor*/ |
2 | 2 |
|
3 | | -;(function ($, window, document, Util, undefined) { |
| 3 | +; (function ($, window, document, Util, undefined) { |
4 | 4 |
|
5 | 5 | 'use strict'; |
6 | 6 |
|
|
87 | 87 | * @return {void} |
88 | 88 | */ |
89 | 89 |
|
90 | | - function Images (el, options) { |
| 90 | + function Images(el, options) { |
91 | 91 | this.el = el; |
92 | 92 | this.$el = $(el); |
93 | 93 | this.$currentImage = null; |
94 | 94 | this.templates = window.MediumInsert.Templates; |
95 | | - this.core = this.$el.data('plugin_'+ pluginName); |
| 95 | + this.core = this.$el.data('plugin_' + pluginName); |
96 | 96 |
|
97 | 97 | this.options = $.extend(true, {}, defaults, options); |
98 | 98 |
|
|
253 | 253 |
|
254 | 254 | // Replace paragraph with div, because figure elements can't be inside paragraph |
255 | 255 | if ($place.is('p')) { |
256 | | - $place.replaceWith('<div class="medium-insert-active">'+ $place.html() +'</div>'); |
| 256 | + $place.replaceWith('<div class="medium-insert-active">' + $place.html() + '</div>'); |
257 | 257 | $place = this.$el.find('.medium-insert-active'); |
258 | | - this.core.moveCaret($place); |
| 258 | + if ($place.next().is('p')) { |
| 259 | + this.core.moveCaret($place.next()); |
| 260 | + } |
| 261 | + else { |
| 262 | + $place.after('<p><br></p>'); // add empty paragraph so we can move the caret to the next line. |
| 263 | + this.core.moveCaret($place.next()); |
| 264 | + } |
259 | 265 | } |
260 | 266 |
|
261 | 267 | $place.addClass('medium-insert-images'); |
|
324 | 330 | progress = 100 - parseInt(data.loaded / data.total * 100, 10); |
325 | 331 | $progressbar = data.context.find('.medium-insert-images-progress'); |
326 | 332 |
|
327 | | - $progressbar.css('width', progress +'%'); |
| 333 | + $progressbar.css('width', progress + '%'); |
328 | 334 |
|
329 | 335 | if (progress === 0) { |
330 | 336 | $progressbar.remove(); |
|
388 | 394 |
|
389 | 395 | if (this.options.autoGrid && $place.find('figure').length >= this.options.autoGrid) { |
390 | 396 | $.each(this.options.styles, function (style, options) { |
391 | | - var className = 'medium-insert-images-'+ style; |
| 397 | + var className = 'medium-insert-images-' + style; |
392 | 398 |
|
393 | 399 | $place.removeClass(className); |
394 | 400 |
|
|
428 | 434 | */ |
429 | 435 |
|
430 | 436 | Images.prototype.selectImage = function (e) { |
431 | | - if(this.core.options.enabled) { |
| 437 | + if (this.core.options.enabled) { |
432 | 438 | var $image = $(e.target), |
433 | 439 | that = this; |
434 | 440 |
|
|
584 | 590 | .show(); |
585 | 591 |
|
586 | 592 | $toolbar.find('button').each(function () { |
587 | | - if ($p.hasClass('medium-insert-images-'+ $(this).data('action'))) { |
| 593 | + if ($p.hasClass('medium-insert-images-' + $(this).data('action'))) { |
588 | 594 | $(this).addClass('medium-editor-button-active'); |
589 | 595 | active = true; |
590 | 596 | } |
|
615 | 621 | $li.siblings().find('.medium-editor-button-active').removeClass('medium-editor-button-active'); |
616 | 622 |
|
617 | 623 | $lis.find('button').each(function () { |
618 | | - var className = 'medium-insert-images-'+ $(this).data('action'); |
| 624 | + var className = 'medium-insert-images-' + $(this).data('action'); |
619 | 625 |
|
620 | 626 | if ($(this).hasClass('medium-editor-button-active')) { |
621 | 627 | $p.addClass(className); |
|
0 commit comments