/**
* Super simple wysiwyg editor v0.8.12
* https://summernote.org
*
* Copyright 2013- Alan Hong. and other contributors
* summernote may be freely distributed under the MIT license.
*
* Date: 2019-05-16T08:16Z
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jquery')) :
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
(global = global || self, factory(global.jQuery));
}(this, function ($$1) { 'use strict';
$$1 = $$1 && $$1.hasOwnProperty('default') ? $$1['default'] : $$1;
var Renderer = /** @class */ (function () {
function Renderer(markup, children, options, callback) {
this.markup = markup;
this.children = children;
this.options = options;
this.callback = callback;
}
Renderer.prototype.render = function ($parent) {
var $node = $$1(this.markup);
if (this.options && this.options.contents) {
$node.html(this.options.contents);
}
if (this.options && this.options.className) {
$node.addClass(this.options.className);
}
if (this.options && this.options.data) {
$$1.each(this.options.data, function (k, v) {
$node.attr('data-' + k, v);
});
}
if (this.options && this.options.click) {
$node.on('click', this.options.click);
}
if (this.children) {
var $container_1 = $node.find('.note-children-container');
this.children.forEach(function (child) {
child.render($container_1.length ? $container_1 : $node);
});
}
if (this.callback) {
this.callback($node, this.options);
}
if (this.options && this.options.callback) {
this.options.callback($node);
}
if ($parent) {
$parent.append($node);
}
return $node;
};
return Renderer;
}());
var renderer = {
create: function (markup, callback) {
return function () {
var options = typeof arguments[1] === 'object' ? arguments[1] : arguments[0];
var children = Array.isArray(arguments[0]) ? arguments[0] : [];
if (options && options.children) {
children = options.children;
}
return new Renderer(markup, children, options, callback);
};
}
};
var TooltipUI = /** @class */ (function () {
function TooltipUI($node, options) {
this.$node = $node;
this.options = $.extend({}, {
title: '',
target: options.container,
trigger: 'hover focus',
placement: 'bottom'
}, options);
// create tooltip node
this.$tooltip = $([
'
',
].join(''));
// define event
if (this.options.trigger !== 'manual') {
var showCallback_1 = this.show.bind(this);
var hideCallback_1 = this.hide.bind(this);
var toggleCallback_1 = this.toggle.bind(this);
this.options.trigger.split(' ').forEach(function (eventName) {
if (eventName === 'hover') {
$node.off('mouseenter mouseleave');
$node.on('mouseenter', showCallback_1).on('mouseleave', hideCallback_1);
}
else if (eventName === 'click') {
$node.on('click', toggleCallback_1);
}
else if (eventName === 'focus') {
$node.on('focus', showCallback_1).on('blur', hideCallback_1);
}
});
}
}
TooltipUI.prototype.show = function () {
var $node = this.$node;
var offset = $node.offset();
var $tooltip = this.$tooltip;
var title = this.options.title || $node.attr('title') || $node.data('title');
var placement = this.options.placement || $node.data('placement');
$tooltip.addClass(placement);
$tooltip.addClass('in');
$tooltip.find('.note-tooltip-content').text(title);
$tooltip.appendTo(this.options.target);
var nodeWidth = $node.outerWidth();
var nodeHeight = $node.outerHeight();
var tooltipWidth = $tooltip.outerWidth();
var tooltipHeight = $tooltip.outerHeight();
if (placement === 'bottom') {
$tooltip.css({
top: offset.top + nodeHeight,
left: offset.left + (nodeWidth / 2 - tooltipWidth / 2)
});
}
else if (placement === 'top') {
$tooltip.css({
top: offset.top - tooltipHeight,
left: offset.left + (nodeWidth / 2 - tooltipWidth / 2)
});
}
else if (placement === 'left') {
$tooltip.css({
top: offset.top + (nodeHeight / 2 - tooltipHeight / 2),
left: offset.left - tooltipWidth
});
}
else if (placement === 'right') {
$tooltip.css({
top: offset.top + (nodeHeight / 2 - tooltipHeight / 2),
left: offset.left + nodeWidth
});
}
};
TooltipUI.prototype.hide = function () {
this.$tooltip.removeClass('in');
this.$tooltip.remove();
};
TooltipUI.prototype.toggle = function () {
if (this.$tooltip.hasClass('in')) {
this.hide();
}
else {
this.show();
}
};
return TooltipUI;
}());
var DropdownUI = /** @class */ (function () {
function DropdownUI($node, options) {
this.$button = $node;
this.options = $.extend({}, {
target: options.container
}, options);
this.setEvent();
}
DropdownUI.prototype.setEvent = function () {
var _this = this;
this.$button.on('click', function (e) {
_this.toggle();
e.stopImmediatePropagation();
});
};
DropdownUI.prototype.clear = function () {
var $parent = $('.note-btn-group.open');
$parent.find('.note-btn.active').removeClass('active');
$parent.removeClass('open');
};
DropdownUI.prototype.show = function () {
this.$button.addClass('active');
this.$button.parent().addClass('open');
var $dropdown = this.$button.next();
var offset = $dropdown.offset();
var width = $dropdown.outerWidth();
var windowWidth = $(window).width();
var targetMarginRight = parseFloat($(this.options.target).css('margin-right'));
if (offset.left + width > windowWidth - targetMarginRight) {
$dropdown.css('margin-left', windowWidth - targetMarginRight - (offset.left + width));
}
else {
$dropdown.css('margin-left', '');
}
};
DropdownUI.prototype.hide = function () {
this.$button.removeClass('active');
this.$button.parent().removeClass('open');
};
DropdownUI.prototype.toggle = function () {
var isOpened = this.$button.parent().hasClass('open');
this.clear();
if (isOpened) {
this.hide();
}
else {
this.show();
}
};
return DropdownUI;
}());
$(document).on('click', function (e) {
if (!$(e.target).closest('.note-btn-group').length) {
$('.note-btn-group.open').removeClass('open');
}
});
$(document).on('click.note-dropdown-menu', function (e) {
$(e.target).closest('.note-dropdown-menu').parent().removeClass('open');
});
var ModalUI = /** @class */ (function () {
function ModalUI($node, options) {
this.options = $.extend({}, {
target: options.container || 'body'
}, options);
this.$modal = $node;
this.$backdrop = $('');
}
ModalUI.prototype.show = function () {
if (this.options.target === 'body') {
this.$backdrop.css('position', 'fixed');
this.$modal.css('position', 'fixed');
}
else {
this.$backdrop.css('position', 'absolute');
this.$modal.css('position', 'absolute');
}
this.$backdrop.appendTo(this.options.target).show();
this.$modal.appendTo(this.options.target).addClass('open').show();
this.$modal.trigger('note.modal.show');
this.$modal.off('click', '.close').on('click', '.close', this.hide.bind(this));
};
ModalUI.prototype.hide = function () {
this.$modal.removeClass('open').hide();
this.$backdrop.hide();
this.$modal.trigger('note.modal.hide');
};
return ModalUI;
}());
var editor = renderer.create('');
var toolbar = renderer.create('');
var editingArea = renderer.create('');
var codable = renderer.create('');
var editable = renderer.create('');
var statusbar = renderer.create([
'',
'',
].join(''));
var airEditor = renderer.create('');
var airEditable = renderer.create([
'',
'',
].join(''));
var buttonGroup = renderer.create('');
var button = renderer.create('