diff --git a/_build/build.config.php b/_build/build.config.php
index 3dc251a..07a08b5 100644
--- a/_build/build.config.php
+++ b/_build/build.config.php
@@ -4,9 +4,9 @@
define('PKG_NAME', 'ms2form');
define('PKG_NAME_LOWER', strtolower(PKG_NAME));
-define('PKG_VERSION', '1.3.1');
+define('PKG_VERSION', '1.3.5');
define('PKG_RELEASE', 'beta');
-define('PKG_AUTO_INSTALL', true);
+define('PKG_AUTO_INSTALL', false);
/* define paths */
if (isset($_SERVER['MODX_BASE_PATH'])) {
diff --git a/_build/data/transport.settings.php b/_build/data/transport.settings.php
index 1e3cc46..d0c7552 100644
--- a/_build/data/transport.settings.php
+++ b/_build/data/transport.settings.php
@@ -13,6 +13,11 @@
'value' => PKG_ASSETS_URL,
'area' => 'ms2form.main',
),
+ 'categories_parent' => array(
+ 'xtype' => 'textfield',
+ 'value' => '0',
+ 'area' => 'ms2form.main',
+ ),
'frontend_css' => array(
'xtype' => 'textfield',
'value' => PKG_ASSETS_URL . 'css/web/ms2form.css',
diff --git a/_build/properties/properties.ms2form.php b/_build/properties/properties.ms2form.php
index 9bb7933..e00f2ac 100644
--- a/_build/properties/properties.ms2form.php
+++ b/_build/properties/properties.ms2form.php
@@ -122,6 +122,10 @@
'value' => true,
'desc' => 'ms2form_prop_tagsNew'
),
+ 'allowedTags' => array(
+ 'type' => 'textfield',
+ 'value' => '',
+ ),
'editor' => array(
'type' => 'list',
'options' => array(
diff --git a/assets/components/ms2form/js/web/ms2form.js b/assets/components/ms2form/js/web/ms2form.js
index 391e1ca..adfdef5 100755
--- a/assets/components/ms2form/js/web/ms2form.js
+++ b/assets/components/ms2form/js/web/ms2form.js
@@ -1,657 +1,658 @@
-(function() {
- var ms2form = {
- config : {
- actionUrl : Ms2formConfig.actionUrl
- ,assetsUrl : Ms2formConfig.assetsUrl
- ,vendorUrl : Ms2formConfig.vendorUrl
- ,locale: Ms2formConfig.cultureKey
- ,editor: Ms2formConfig.editor
- }
- ,selectors: {
- form: '#ms2form'
- , formKey: '#ms2formFormKey'
- , mse2form: '#ms2formParentMse2form'
- , content: '#content'
- , editor: '#ms2formEditor'
- , editorId: 'ms2formEditor'
- , editorContainer: '#formGroupContent'
- , editorToolbar: '#ms2formEditorToolbar'
- , tags: '#ms2formTags'
- , categories: '#ms2formSections'
- , tagsNew: '#ms2formTagsNew'
- , file: '.ticket-file'
- , fileLink: '.ticket-file-link'
- , fileInsert: '.ms2-file-insert'
- , fileDelete: '.ms2-file-delete'
- , sisyphus: '#ms2form.create'
- , sisyphusDisable: '#ms2form .disable-sisyphus, #ms2form :hidden'
- , uploader: {
- browse_button: 'ticket-files-select'
- //, upload_button: document.getElementById('ticket-files-upload')
- , container: 'ticket-files-container'
- , filelist: 'ticket-files-list'
- , progress: 'ticket-files-progress'
- , progress_bar: 'ticket-files-progress-bar'
- , progress_count: 'ticket-files-progress-count'
- , progress_percent: 'ticket-files-progress-percent'
- , drop_element: 'ticket-files-list'
- }
- }
- ,_loadConfig: function (actionUrl, callback){
- var request = new XMLHttpRequest();
- actionUrl = actionUrl + '?action=config/get&form_key='
- + $(ms2form.selectors.formKey).val();
- request.open('GET', actionUrl, true);
-
- request.onload = function () {
- if (request.status >= 200 && request.status < 400) {
- // Success!
- var data = JSON.parse(request.responseText);
- $.extend(ms2form.config, data);
- callback();
- } else {
- console.error('We reached our target server, but it returned an error')
- }
- };
- request.onerror = function () {
- console.error('There was a connection error of some sort')
- };
- request.send();
- }
- ,_loadScripts: function(callback) {
- var firstLibs;
- if (typeof jQuery == "undefined") {
- firstLibs = [
- ms2form.config.vendorUrl + 'when/when'
- , 'js!' + ms2form.config.vendorUrl + 'jquery/jquery.min.js'
- ];
-
- } else {
- firstLibs = [
- ms2form.config.vendorUrl + 'when/when'
- ]
- }
- curl(firstLibs).then(function(when) {
- var deferreds = [];
-
- if (!jQuery().autocomplete){
- deferreds.push(curl(['js!' + ms2form.config.assetsUrl + '/js/web/msearch2/lib/jquery-ui-1.10.4.custom.min.js']));
- }
-
- if (!jQuery().sortable){
- deferreds.push(curl(['js!' + ms2form.config.vendorUrl + 'jquery-ui-sortable/jquery-ui-1.10.4.sortable.min.js']));
- }
-
- if (!jQuery().ajaxForm){
- deferreds.push(curl(['js!' + ms2form.config.vendorUrl + 'jquery-form/jquery.form.js' ]));
- }
-
- if (!jQuery().jGrowl){
- deferreds.push(curl(['js!' + ms2form.config.vendorUrl + 'jgrowl/jquery.jgrowl.min.js']));
- }
-
- if (!jQuery().sisyphus){
- deferreds.push(curl([ 'js!' + ms2form.config.vendorUrl + 'sisyphus/sisyphus.js' ]));
- }
-
- //editor load
- if(ms2form.config.editor == 'bootstrapMarkdown'){
- if (typeof marked !== 'function') {
- deferreds.push(curl([
- ms2form.config.vendorUrl + 'marked/marked.min.js'
- ]).then(function (marked) {
- window.marked = marked
- }));
- }
- if (!jQuery().markdown) {
- deferreds.push(curl([
- 'js!' + ms2form.config.vendorUrl + 'he/he.js'
- , 'js!' + ms2form.config.vendorUrl + 'to-markdown/src/to-markdown.js'
- ]).next(['js!' + ms2form.config.vendorUrl + 'bootstrap-markdown/js/bootstrap-markdown.js'])
- .next(['js!' + ms2form.config.vendorUrl + 'bootstrap-markdown/locale/bootstrap-markdown.' + ms2form.config.locale + '.js']));
- }
- }
- else if(ms2form.config.editor == 'quill'){
- if (typeof Quill == "undefined"){
- deferreds.push(curl([ms2form.config.vendorUrl + 'quill/dist/quill.js'])
- .then(function(quill){
- ms2form.editor.constructor = quill;
- }));
- }
- }
-
- if (!jQuery().select2){
- deferreds.push(curl(
- [ 'js!' + ms2form.config.vendorUrl + 'select2/select2.min.js' ]
- ).next([
- 'js!' + ms2form.config.vendorUrl + 'select2/select2_locale_' + ms2form.config.locale + '.js'
- ]));
- }
-
- if(typeof plupload == "undefined"){
- deferreds.push(curl([ 'js!' + ms2form.config.vendorUrl + 'plupload/js/plupload.full.min.js' ]).next([ 'js!' + ms2form.config.vendorUrl + 'plupload/js/i18n/'+ ms2form.config.locale+'.js']));
- }
-
- when.all(deferreds).then(callback)
- })
- }
- ,load: function(callback){
- ms2form._loadScripts(function(){
- ms2form._loadConfig(ms2form.config.actionUrl, function(){
- callback()
- })
- })
- }
- , editor: {
- initialize: function (name) {
- ms2form.product.$content = $(ms2form.selectors.content);
- jQuery.extend(this, this._editors[name]);
- this.init();
- }
- ,insertFile: function (element) {}
- ,getContent: function () {}
- ,constructor: null
- ,_editors: {
- bootstrapMarkdown: {
- init: function () {
- $(ms2form.selectors.editorContainer).append(
- '
'
- );
- $(ms2form.selectors.editor).append(ms2form.product.$content.val());
- $(ms2form.selectors.editor).markdown({
- resize: true
- , language: ms2form.config.locale
- });
- ms2form.editor._inst = $('#formGroupContent textarea').data('markdown');
- }
- , insertFile: function (element) {
- var $text = $('#formGroupContent .md-input');
- var srcImage = $(element).parents(ms2form.selectors.file).find(ms2form.selectors.fileLink).attr('href');
- var template = '';
- $text.focus();
- ms2form.editor._inst.replaceSelection(template);
- }
- , getContent: function () {
- return this._inst.parseContent()
- }
- }
- ,quill: {
- init: function () {
- this._inst = new this.constructor(ms2form.selectors.editor, {
- modules: {
- 'toolbar': {container: ms2form.selectors.editorToolbar}
- , 'image-tooltip': true
- , 'link-tooltip': true
- },
- theme: 'snow'
- });
- }
- , insertFile: function (element) {
- var srcImage = $(element).parents(ms2form.selectors.file).find(ms2form.selectors.fileLink).attr('href');
- this._inst.focus();
- var index = this._inst.getSelection().end;
- this._inst.insertEmbed(index, 'image', srcImage);
- }
- , getContent: function () {
- return this._inst.getHTML()
-
- }
- }
- }
- , _inst: null
- }
- ,initialize: function(){
- var form = $(ms2form.selectors.form);
- var pid = form.find('[name="pid"]').val();
- var form_key = ms2form.config.formKey;
-
- // content editor init
- if (ms2form.config.editor !== '0') {
- ms2form.editor.initialize(ms2form.config.editor);
- }
-
- $(document).on('click', '#question', function (e) {
- e.preventDefault();
- $('.popover-help').popover('toggle');
- return false;
- });
- $(document).on('click', '.popover', function (e) {
- $(this).prev('.popover-help').popover('toggle');
- });
- $(document).on('click', '.popover a', function (e) {
- e.stopPropagation();
- });
-
- // init list catecories product
- var categories;
- $.post(ms2form.config.actionUrl, {
- action: 'product/getlist_category',
- pid: pid,
- form_key: form_key
- }, function (response, textStatus, jqXHR) {
- if (response.success) {
- categories = response.data.all;
- $(ms2form.selectors.categories).select2({
- multiple: true,
- placeholder: 'Категории',
- tags: categories
- });
- if (response.data.product) {
- $(ms2form.selectors.categories).select2('val', response.data.product);
- }
- }
- else {
- ms2form.message.error(response.message);
- }
- }, 'json');
-
- // init list tags products
- var tags;
- $.post(ms2form.config.actionUrl, {
- action: 'product/getlist_tag',
- pid: pid,
- form_key: form_key
- }, function (response, textStatus, jqXHR) {
- if (response.success) {
- tags = response.data.all;
- var select2TagsConfig = {
- multiple: true,
- placeholder: 'Теги'
- };
- // check allow add new tags
- if (form.find(ms2form.selectors.tagsNew).val() === '1') {
- select2TagsConfig.tags = tags
- } else {
- select2TagsConfig.data = tags
- }
- $(ms2form.selectors.tags).select2(select2TagsConfig);
- if (response.data.product) {
- $(ms2form.selectors.tags).select2('val', response.data.product);
- }
-
- }
- else {
- ms2form.message.error(response.message);
- }
- }, 'json');
-
- // Uploader
- ms2form.Uploader = new plupload.Uploader({
- runtimes: 'html5,flash,silverlight,html4',
- browse_button: ms2form.selectors.uploader.browse_button,
- //upload_button: document.getElementById('ticket-files-upload'),
- container: ms2form.selectors.uploader.container,
- filelist: ms2form.selectors.uploader.filelist,
- progress: ms2form.selectors.uploader.progress,
- progress_bar: ms2form.selectors.uploader.progress_bar,
- progress_count: ms2form.selectors.uploader.progress_count,
- progress_percent: ms2form.selectors.uploader.progress_percent,
- drop_element: ms2form.selectors.uploader.drop_element,
- form: form,
- multipart_params: {
- action: $('#' + this.container).data('action') || 'gallery/upload',
- pid: pid,
- form_key: form_key
- },
- url: ms2form.config.actionUrl,
- filters: {
- max_file_size: ms2form.config.sourceProperties.maxUploadSize.value,
- mime_types: [{
- title: 'Files',
- extensions: ms2form.config.sourceProperties.allowedFileTypes.value
- }]
- },
- resize: {
- width: ms2form.config.sourceProperties.maxUploadWidth.value,
- height: ms2form.config.sourceProperties.maxUploadHeight.value,
- quality: 100
- },
- flash_swf_url: ms2form.config.vendorUrl + 'lib/plupload/js/Moxie.swf',
- silverlight_xap_url: ms2form.config.vendorUrl + 'lib/plupload/js/Moxie.xap',
- init: {
- Init: function (up) {
- if (this.runtime == 'html5') {
- var element = $(this.settings.drop_element);
- element.addClass('droppable');
- element.on('dragover', function () {
- if (!element.hasClass('dragover')) {
- element.addClass('dragover');
- }
- });
- element.on('dragleave drop', function () {
- element.removeClass('dragover');
- });
- }
- },
- PostInit: function (up) {
- },
- FilesAdded: function (up, files) {
- this.settings.form.find('[type="submit"]').attr('disabled', true);
- up.start();
- },
- UploadProgress: function (up, file) {
- $(up.settings.browse_button).hide();
- $('#' + up.settings.progress).show();
- $('#' + up.settings.progress_count).text((up.total.uploaded + 1) + ' / ' + up.files.length);
- $('#' + up.settings.progress_percent).text(up.total.percent + '%');
- $('#' + up.settings.progress_bar).css('width', up.total.percent + '%');
- },
- FileUploaded: function (up, file, response) {
- response = $.parseJSON(response.response);
- if (response.success) {
- $('#' + up.settings.filelist + ' .note').hide();
- // Successfull action
- var files = $('#' + up.settings.filelist);
- var clearfix = files.find('.clearfix');
- if (clearfix.length != 0) {
- $(response.data.html).insertBefore(clearfix);
- } else {
- files.append(response.data.html);
- }
- } else {
- ms2form.message.error(response.message);
- }
- },
- UploadComplete: function (up, file, response) {
- $(up.settings.browse_button).show();
- $('#' + up.settings.progress).hide();
- up.total.reset();
- up.splice();
- this.settings.form.find('[type="submit"]').attr('disabled', false);
- },
- Error: function (up, err) {
- ms2form.message.error(err.message);
- }
- }
- });
- ms2form.Uploader.init();
-
- // init form save sisyphus
- $(ms2form.selectors.sisyphus).sisyphus({
- excludeFields: $(ms2form.selectors.sisyphusDisable)
- });
-
- //Sort files
- $('#' + ms2form.selectors.uploader.filelist).sortable({
- items: ms2form.selectors.file,
- update: function( event, ui ) {
- var rank = {};
- $('#' + ms2form.selectors.uploader.filelist).find(ms2form.selectors.file).each(function(i){
- rank[i] = $(this).data('id');
- });
-
- var data = {
- action: 'gallery/sort'
- , rank: rank
- , form_key: ms2form.config.formKey
- };
-
- $.post(ms2form.config.actionUrl, data, function(response) {
- if (!response.success) {
- ms2form.message.error(response.message);
- }
- }, 'json');
- }
- });
-
- // Forms listeners
- $(document).on('click', ms2form.selectors.fileDelete, function (e) {
- e.preventDefault();
- var $this = $(this);
- var $form = $this.parents('form');
- var $parent = $this.parents(ms2form.selectors.file);
- var id = $parent.data('id');
-
- $.post(ms2form.config.actionUrl, {
- action: 'gallery/delete',
- id: id,
- form_key: form_key
- }, function (response, textStatus, jqXHR) {
- if (response.success) {
- $(ms2form.selectors.file + '[data-id="' + response.data.id + '"]').remove();
- }
- else {
- ms2form.message.error(response.message);
- }
- }, 'json');
- return false;
- });
- $(document).on('click', ms2form.selectors.fileInsert, function (e) {
- e.preventDefault();
- ms2form.editor.insertFile(this);
- return false;
- });
- $(document).on('click', '.btn.preview', function (e) {
- e.preventDefault();
- });
- $(document).on('submit', ms2form.selectors.form , function (e) {
- e.preventDefault();
- ms2form.product.save(this, $(this).find('[type="submit"]')[0]);
- return false;
- });
- $('#btn-send').removeAttr('disabled');
- }
- ,form: null
- ,button: null
- ,product: {
- content: null,
- $content: null,
- parent: null,
- parents: null,
- save: function (form, button) {
- ms2form.form = form;
- ms2form.button = button;
- // set content
- this._setContent();
-
- // set parent
- if (!this._setParents()) return;
-
- // mse2form processing
- var $mse2form = $(ms2form.selectors.mse2form);
- if($mse2form.length){
- var categoryId = $mse2form.data('id');
- if(categoryId){
- this.parent = categoryId;
- this._ajaxSubmit()
- }else{
- var categoryTitle = $mse2form.val();
- var data = {
- action: 'category/create'
- , form_key: ms2form.config.formKey
- , parent: ms2form.config.parent
- , pagetitle: categoryTitle
- };
- data[ms2form.config.parentMse2form.queryVar] = categoryTitle;
- $.post(ms2form.config.actionUrl, data)
- .done(function (response) {
- response = JSON.parse(response);
- if (response.success) {
- ms2form.product.parent = response.data.id;
- ms2form.product._ajaxSubmit()
- }
- })
- .fail(ms2form.product._error);
- }
- }else{
- this._ajaxSubmit()
- }
- }
- ,_setContent: function() {
- var content = ms2form.editor.getContent();
- this.$content.val(content);
- this.content = content;
- }
- ,_setParents: function (){
- var parent = $('input[name="parent"]',ms2form.form).val();
- var parents = $.map($(ms2form.selectors.categories).select2("data"), function (val) {
- return val.id
- });
- if (parent == '0') {
- if (parents[0]) {
- parent = parents[0];
- parents.splice(0, 1);
- } else {
- ms2form.message.error('parent is empty');
- return false;
- }
- } else {
- if (parents.indexOf(parent) > -1) {
- parents.splice(parents.indexOf(parent), 1);
- }
- }
- this.parent = parent;
- this.parents = parents;
- return true
- }
- ,_ajaxSubmit: function (){
- $(ms2form.form).ajaxSubmit({
- data: {
- action: 'product/save',
- content: ms2form.product.content,
- parent: ms2form.product.parent,
- parents: ms2form.product.parents,
- tags: $.map($(ms2form.selectors.tags).select2("data"), function (val) {
- return val.text
- }),
- files: $(ms2form.form).find(ms2form.selectors.file).map(function () {
- return $(this).attr('data-id')
- }).get()
- },
- url: ms2form.config.actionUrl,
- form: ms2form.form,
- button: ms2form.button,
- dataType: 'json',
- beforeSubmit: function (formData, jqForm, options) {
- $(ms2form.button).attr('disabled', 'disabled');
- $('.error', ms2form.form).text('');
- return true;
- },
- success: ms2form.product._success,
- error: ms2form.product._error
- });
- }
- ,_success: function (response){
- $(ms2form.selectors.sisyphus).sisyphus().manuallyReleaseData();
- if (response.success) {
- if (response.message) {
- ms2form.message.success(response.message);
- } else if (response.data.redirect) {
- document.location.href = response.data.redirect;
- }
- $(ms2form.form).resetForm();
- $(ms2form.button).removeAttr('disabled');
- } else {
- ms2form.product._error(response)
- }
- }
- ,_error: function (response){
- if(!response.message){
- response = JSON.parse(response.responseText);
- }
- var message = response.message;
- console.error(response.data);
- if (response.data) {
- var i;
- for (i in response.data) {
- $(ms2form.form).find('[name="' + i + '"]').closest('.form-group').addClass('has-error');
- }
- message = response.message + '
' + JSON.stringify(response.data)
- }
- ms2form.message.error(message);
- // form error report
- $(ms2form.button).removeAttr('disabled');
- }
- }
- ,message: {
- success: function (message) {
- if (message) {
- $.jGrowl(message, {theme: 'tickets-message-success'});
- }
- }
- ,error: function (message) {
- if (message) {
- $.jGrowl(message, {
- theme: 'tickets-message-error'
- //, sticky: true
- });
- }
- }
- ,info: function (message) {
- if (message) {
- $.jGrowl(message, {theme: 'tickets-message-info'});
- }
- }
- ,close: function () {
- $.jGrowl('close');
- }
- }
- };
-
- var mse2form = {
- initialize: function (selector) {
- var $this = $(selector);
- if (!$this.length) return;
- var config = ms2form.config.parentMse2form;
- var cache = {};
-
- $this.autocomplete({
- source: function (request, callback) {
- if (request.term in cache) {
- callback(cache[request.term]);
- return;
- }
- var data = {
- action: 'search'
- , key: $this.data('key')
- , pageId: config.pageId
- };
- data[config.queryVar] = request.term;
- $.post(config.actionUrl, data, function (response) {
- if (response.data.log) {
- ms2form.message.info(response.data.log)
- }
- cache[request.term] = response.data.results;
- callback(response.data.results)
- }, 'json');
- }
- , minLength: config.minQuery || 3
- , select: function (event, ui) {
- if (ui.item.id) {
- $this.data('id', ui.item.id); // save msCategory Id
- $this.data('title', ui.item.value);
- console.log('save msCategory Id');
- }
- }
- , change: function (event, ui){
- if($this.val() != $this.data('title')){
- console.log('remove msCategory Id');
- $this.removeData('id'); // remove msCategory Id
- }
- }
- })
- .data("ui-autocomplete")._renderItem = function (ul, item) {
- return $("")
- .data("item.autocomplete", item)
- .addClass("mse2-ac-wrapper")
- .append("" + item.label + "")
- .appendTo(ul);
- };
- // event listeners
- $(document).on('keypress', ms2form.selectors.mse2form, function (e) {
- if (e.which == 13) {
- e.preventDefault();
- return false;
- }
- });
- }
- };
-
- ms2form.load(function() {
- ms2form.initialize();
- mse2form.initialize(ms2form.selectors.mse2form);
- });
-
- //todo-me delete this
- window.ms2form = ms2form;
-})();
+(function() {
+ var ms2form = {
+ config : {
+ actionUrl : Ms2formConfig.actionUrl
+ ,assetsUrl : Ms2formConfig.assetsUrl
+ ,vendorUrl : Ms2formConfig.vendorUrl
+ ,locale: Ms2formConfig.cultureKey
+ ,editor: Ms2formConfig.editor
+ }
+ ,selectors: {
+ form: '#ms2form'
+ , formKey: '#ms2formFormKey'
+ , mse2form: '#ms2formParentMse2form'
+ , content: '#ms2form #content'
+ , editor: '#ms2formEditor'
+ , editorId: 'ms2formEditor'
+ , editorContainer: '#formGroupContent'
+ , editorToolbar: '#ms2formEditorToolbar'
+ , tags: '#ms2formTags'
+ , categories: '#ms2formSections'
+ , tagsNew: '#ms2formTagsNew'
+ , file: '.ticket-file'
+ , fileLink: '.ticket-file-link'
+ , fileInsert: '.ms2-file-insert'
+ , fileDelete: '.ms2-file-delete'
+ , sisyphus: '#ms2form.create'
+ , sisyphusDisable: '#ms2form .disable-sisyphus, #ms2form :hidden'
+ , uploader: {
+ browse_button: 'ticket-files-select'
+ //, upload_button: document.getElementById('ticket-files-upload')
+ , container: 'ticket-files-container'
+ , filelist: 'ticket-files-list'
+ , progress: 'ticket-files-progress'
+ , progress_bar: 'ticket-files-progress-bar'
+ , progress_count: 'ticket-files-progress-count'
+ , progress_percent: 'ticket-files-progress-percent'
+ , drop_element: 'ticket-files-list'
+ }
+ }
+ ,_loadConfig: function (actionUrl, callback){
+ var request = new XMLHttpRequest();
+ actionUrl = actionUrl + '?action=config/get&form_key='
+ + $(ms2form.selectors.formKey).val();
+ request.open('GET', actionUrl, true);
+
+ request.onload = function () {
+ if (request.status >= 200 && request.status < 400) {
+ // Success!
+ var data = JSON.parse(request.responseText);
+ $.extend(ms2form.config, data);
+ callback();
+ } else {
+ console.error('We reached our target server, but it returned an error')
+ }
+ };
+ request.onerror = function () {
+ console.error('There was a connection error of some sort')
+ };
+ request.send();
+ }
+ ,_loadScripts: function(callback) {
+ var firstLibs;
+ if (typeof jQuery == "undefined") {
+ firstLibs = [
+ ms2form.config.vendorUrl + 'when/when'
+ , 'js!' + ms2form.config.vendorUrl + 'jquery/jquery.min.js'
+ ];
+
+ } else {
+ firstLibs = [
+ ms2form.config.vendorUrl + 'when/when'
+ ]
+ }
+ curl(firstLibs).then(function(when) {
+ var deferreds = [];
+
+ if (!jQuery().autocomplete){
+ deferreds.push(curl(['js!' + ms2form.config.assetsUrl + '/js/web/msearch2/lib/jquery-ui-1.10.4.custom.min.js']));
+ }
+
+ if (!jQuery().sortable){
+ deferreds.push(curl(['js!' + ms2form.config.vendorUrl + 'jquery-ui-sortable/jquery-ui-1.10.4.sortable.min.js']));
+ }
+
+ if (!jQuery().ajaxForm){
+ deferreds.push(curl(['js!' + ms2form.config.vendorUrl + 'jquery-form/jquery.form.js' ]));
+ }
+
+ if (!jQuery().jGrowl){
+ deferreds.push(curl(['js!' + ms2form.config.vendorUrl + 'jgrowl/jquery.jgrowl.min.js']));
+ }
+
+ if (!jQuery().sisyphus){
+ deferreds.push(curl([ 'js!' + ms2form.config.vendorUrl + 'sisyphus/sisyphus.js' ]));
+ }
+
+ //editor load
+ if(ms2form.config.editor == 'bootstrapMarkdown'){
+ if (typeof marked !== 'function') {
+ deferreds.push(curl([
+ ms2form.config.vendorUrl + 'marked/marked.min.js'
+ ]).then(function (marked) {
+ window.marked = marked
+ }));
+ }
+ if (!jQuery().markdown) {
+ deferreds.push(curl([
+ 'js!' + ms2form.config.vendorUrl + 'he/he.js'
+ , 'js!' + ms2form.config.vendorUrl + 'to-markdown/src/to-markdown.js'
+ ]).next(['js!' + ms2form.config.vendorUrl + 'bootstrap-markdown/js/bootstrap-markdown.js'])
+ .next(['js!' + ms2form.config.vendorUrl + 'bootstrap-markdown/locale/bootstrap-markdown.' + ms2form.config.locale + '.js']));
+ }
+ }
+ else if(ms2form.config.editor == 'quill'){
+ if (typeof Quill == "undefined"){
+ deferreds.push(curl([ms2form.config.vendorUrl + 'quill/dist/quill.js'])
+ .then(function(quill){
+ ms2form.editor.constructor = quill;
+ }));
+ }
+ }
+
+ if (!jQuery().select2){
+ deferreds.push(curl(
+ [ 'js!' + ms2form.config.vendorUrl + 'select2/select2.min.js' ]
+ ).next([
+ 'js!' + ms2form.config.vendorUrl + 'select2/select2_locale_' + ms2form.config.locale + '.js'
+ ]));
+ }
+
+ if(typeof plupload == "undefined"){
+ deferreds.push(curl([ 'js!' + ms2form.config.vendorUrl + 'plupload/js/plupload.full.min.js' ]).next([ 'js!' + ms2form.config.vendorUrl + 'plupload/js/i18n/'+ ms2form.config.locale+'.js']));
+ }
+
+ when.all(deferreds).then(callback)
+ })
+ }
+ ,load: function(callback){
+ ms2form._loadScripts(function(){
+ ms2form._loadConfig(ms2form.config.actionUrl, function(){
+ callback()
+ })
+ })
+ }
+ , editor: {
+ initialize: function (name) {
+ ms2form.product.$content = $(ms2form.selectors.content);
+ jQuery.extend(this, this._editors[name]);
+ this.init();
+ }
+ ,insertFile: function (element) {}
+ ,getContent: function () {}
+ ,constructor: null
+ ,_editors: {
+ bootstrapMarkdown: {
+ init: function () {
+ $(ms2form.selectors.editorContainer).append(
+ ''
+ );
+ $(ms2form.selectors.editor).append(ms2form.product.$content.val());
+ $(ms2form.selectors.editor).markdown({
+ resize: true
+ , language: ms2form.config.locale
+ });
+ ms2form.editor._inst = $('#formGroupContent textarea').data('markdown');
+ }
+ , insertFile: function (element) {
+ var $text = $('#formGroupContent .md-input');
+ var srcImage = $(element).parents(ms2form.selectors.file).find(ms2form.selectors.fileLink).attr('href');
+ var template = '';
+ $text.focus();
+ ms2form.editor._inst.replaceSelection(template);
+ }
+ , getContent: function () {
+ return this._inst.parseContent()
+ }
+ }
+ ,quill: {
+ init: function () {
+ this._inst = new this.constructor(ms2form.selectors.editor, {
+ modules: {
+ 'toolbar': {container: ms2form.selectors.editorToolbar}
+ , 'image-tooltip': true
+ , 'link-tooltip': true
+ },
+ theme: 'snow'
+ });
+ }
+ , insertFile: function (element) {
+ var srcImage = $(element).parents(ms2form.selectors.file).find(ms2form.selectors.fileLink).attr('href');
+ this._inst.focus();
+ var index = this._inst.getSelection().end;
+ this._inst.insertEmbed(index, 'image', srcImage);
+ }
+ , getContent: function () {
+ return this._inst.getHTML()
+
+ }
+ }
+ }
+ , _inst: null
+ }
+ ,initialize: function(){
+ var form = $(ms2form.selectors.form);
+ var pid = form.find('[name="pid"]').val();
+ var form_key = ms2form.config.formKey;
+
+ // content editor init
+ if (ms2form.config.editor !== '0') {
+ ms2form.editor.initialize(ms2form.config.editor);
+ }
+
+ $(document).on('click', '#question', function (e) {
+ e.preventDefault();
+ $('.popover-help').popover('toggle');
+ return false;
+ });
+ $(document).on('click', '.popover', function (e) {
+ $(this).prev('.popover-help').popover('toggle');
+ });
+ $(document).on('click', '.popover a', function (e) {
+ e.stopPropagation();
+ });
+
+ // init list catecories product
+ var categories;
+ $.post(ms2form.config.actionUrl, {
+ action: 'product/getlist_category',
+ pid: pid,
+ form_key: form_key
+ }, function (response, textStatus, jqXHR) {
+ if (response.success) {
+ categories = response.data.all;
+ $(ms2form.selectors.categories).select2({
+ multiple: true,
+ placeholder: 'Категории',
+ tags: categories
+ });
+ if (response.data.product) {
+ $(ms2form.selectors.categories).select2('val', response.data.product);
+ }
+ }
+ else {
+ ms2form.message.error(response.message);
+ }
+ }, 'json');
+
+ // init list tags products
+ var tags;
+ $.post(ms2form.config.actionUrl, {
+ action: 'product/getlist_tag',
+ pid: pid,
+ form_key: form_key,
+ allowedTags: ( typeof Ms2formConfig.allowedTags == 'string' ) ? Ms2formConfig.allowedTags : ''
+ }, function (response, textStatus, jqXHR) {
+ if (response.success) {
+ tags = response.data.all;
+ var select2TagsConfig = {
+ multiple: true,
+ placeholder: 'Теги'
+ };
+ // check allow add new tags
+ if (form.find(ms2form.selectors.tagsNew).val() === '1') {
+ select2TagsConfig.tags = tags
+ } else {
+ select2TagsConfig.data = tags
+ }
+ $(ms2form.selectors.tags).select2(select2TagsConfig);
+ if (response.data.product) {
+ $(ms2form.selectors.tags).select2('val', response.data.product);
+ }
+
+ }
+ else {
+ ms2form.message.error(response.message);
+ }
+ }, 'json');
+
+ // Uploader
+ ms2form.Uploader = new plupload.Uploader({
+ runtimes: 'html5,flash,silverlight,html4',
+ browse_button: ms2form.selectors.uploader.browse_button,
+ //upload_button: document.getElementById('ticket-files-upload'),
+ container: ms2form.selectors.uploader.container,
+ filelist: ms2form.selectors.uploader.filelist,
+ progress: ms2form.selectors.uploader.progress,
+ progress_bar: ms2form.selectors.uploader.progress_bar,
+ progress_count: ms2form.selectors.uploader.progress_count,
+ progress_percent: ms2form.selectors.uploader.progress_percent,
+ drop_element: ms2form.selectors.uploader.drop_element,
+ form: form,
+ multipart_params: {
+ action: $('#' + this.container).data('action') || 'gallery/upload',
+ pid: pid,
+ form_key: form_key
+ },
+ url: ms2form.config.actionUrl,
+ filters: {
+ max_file_size: ms2form.config.sourceProperties.maxUploadSize.value,
+ mime_types: [{
+ title: 'Files',
+ extensions: ms2form.config.sourceProperties.allowedFileTypes.value
+ }]
+ },
+ resize: {
+ width: ms2form.config.sourceProperties.maxUploadWidth.value,
+ height: ms2form.config.sourceProperties.maxUploadHeight.value,
+ quality: 100
+ },
+ flash_swf_url: ms2form.config.vendorUrl + 'lib/plupload/js/Moxie.swf',
+ silverlight_xap_url: ms2form.config.vendorUrl + 'lib/plupload/js/Moxie.xap',
+ init: {
+ Init: function (up) {
+ if (this.runtime == 'html5') {
+ var element = $(this.settings.drop_element);
+ element.addClass('droppable');
+ element.on('dragover', function () {
+ if (!element.hasClass('dragover')) {
+ element.addClass('dragover');
+ }
+ });
+ element.on('dragleave drop', function () {
+ element.removeClass('dragover');
+ });
+ }
+ },
+ PostInit: function (up) {
+ },
+ FilesAdded: function (up, files) {
+ this.settings.form.find('[type="submit"]').attr('disabled', true);
+ up.start();
+ },
+ UploadProgress: function (up, file) {
+ $(up.settings.browse_button).hide();
+ $('#' + up.settings.progress).show();
+ $('#' + up.settings.progress_count).text((up.total.uploaded + 1) + ' / ' + up.files.length);
+ $('#' + up.settings.progress_percent).text(up.total.percent + '%');
+ $('#' + up.settings.progress_bar).css('width', up.total.percent + '%');
+ },
+ FileUploaded: function (up, file, response) {
+ response = $.parseJSON(response.response);
+ if (response.success) {
+ $('#' + up.settings.filelist + ' .note').hide();
+ // Successfull action
+ var files = $('#' + up.settings.filelist);
+ var clearfix = files.find('.clearfix');
+ if (clearfix.length != 0) {
+ $(response.data.html).insertBefore(clearfix);
+ } else {
+ files.append(response.data.html);
+ }
+ } else {
+ ms2form.message.error(response.message);
+ }
+ },
+ UploadComplete: function (up, file, response) {
+ $(up.settings.browse_button).show();
+ $('#' + up.settings.progress).hide();
+ up.total.reset();
+ up.splice();
+ this.settings.form.find('[type="submit"]').attr('disabled', false);
+ },
+ Error: function (up, err) {
+ ms2form.message.error(err.message);
+ }
+ }
+ });
+ ms2form.Uploader.init();
+
+ // init form save sisyphus
+ $(ms2form.selectors.sisyphus).sisyphus({
+ excludeFields: $(ms2form.selectors.sisyphusDisable)
+ });
+
+ //Sort files
+ $('#' + ms2form.selectors.uploader.filelist).sortable({
+ items: ms2form.selectors.file,
+ update: function( event, ui ) {
+ var rank = {};
+ $('#' + ms2form.selectors.uploader.filelist).find(ms2form.selectors.file).each(function(i){
+ rank[i] = $(this).data('id');
+ });
+
+ var data = {
+ action: 'gallery/sort'
+ , rank: rank
+ , form_key: ms2form.config.formKey
+ };
+
+ $.post(ms2form.config.actionUrl, data, function(response) {
+ if (!response.success) {
+ ms2form.message.error(response.message);
+ }
+ }, 'json');
+ }
+ });
+
+ // Forms listeners
+ $(document).on('click', ms2form.selectors.fileDelete, function (e) {
+ e.preventDefault();
+ var $this = $(this);
+ var $form = $this.parents('form');
+ var $parent = $this.parents(ms2form.selectors.file);
+ var id = $parent.data('id');
+
+ $.post(ms2form.config.actionUrl, {
+ action: 'gallery/delete',
+ id: id,
+ form_key: form_key
+ }, function (response, textStatus, jqXHR) {
+ if (response.success) {
+ $(ms2form.selectors.file + '[data-id="' + response.data.id + '"]').remove();
+ }
+ else {
+ ms2form.message.error(response.message);
+ }
+ }, 'json');
+ return false;
+ });
+ $(document).on('click', ms2form.selectors.fileInsert, function (e) {
+ e.preventDefault();
+ ms2form.editor.insertFile(this);
+ return false;
+ });
+ $(document).on('click', '.btn.preview', function (e) {
+ e.preventDefault();
+ });
+ $(document).on('submit', ms2form.selectors.form , function (e) {
+ e.preventDefault();
+ ms2form.product.save(this, $(this).find('[type="submit"]')[0]);
+ return false;
+ });
+ $('#btn-send').removeAttr('disabled');
+ }
+ ,form: null
+ ,button: null
+ ,product: {
+ content: null,
+ $content: null,
+ parent: null,
+ parents: null,
+ save: function (form, button) {
+ ms2form.form = form;
+ ms2form.button = button;
+ // set content
+ this._setContent();
+
+ // set parent
+ if (!this._setParents()) return;
+
+ // mse2form processing
+ var $mse2form = $(ms2form.selectors.mse2form);
+ if($mse2form.length){
+ var categoryId = $mse2form.data('id');
+ if(categoryId){
+ this.parent = categoryId;
+ this._ajaxSubmit()
+ }else{
+ var categoryTitle = $mse2form.val();
+ var data = {
+ action: 'category/create'
+ , form_key: ms2form.config.formKey
+ , parent: ms2form.config.parent
+ , pagetitle: categoryTitle
+ };
+ data[ms2form.config.parentMse2form.queryVar] = categoryTitle;
+ $.post(ms2form.config.actionUrl, data)
+ .done(function (response) {
+ response = JSON.parse(response);
+ if (response.success) {
+ ms2form.product.parent = response.data.id;
+ ms2form.product._ajaxSubmit()
+ }
+ })
+ .fail(ms2form.product._error);
+ }
+ }else{
+ this._ajaxSubmit()
+ }
+ }
+ ,_setContent: function() {
+ var content = ms2form.editor.getContent();
+ this.$content.val(content);
+ this.content = content;
+ }
+ ,_setParents: function (){
+ var parent = $('input[name="parent"]',ms2form.form).val();
+ var parents = $.map($(ms2form.selectors.categories).select2("data"), function (val) {
+ return val.id
+ });
+ if (parent == '0') {
+ if (parents[0]) {
+ parent = parents[0];
+ parents.splice(0, 1);
+ } else {
+ ms2form.message.error('parent is empty');
+ return false;
+ }
+ } else {
+ if (parents.indexOf(parent) > -1) {
+ parents.splice(parents.indexOf(parent), 1);
+ }
+ }
+ this.parent = parent;
+ this.parents = parents;
+ return true
+ }
+ ,_ajaxSubmit: function (){
+ $(ms2form.form).ajaxSubmit({
+ data: {
+ action: 'product/save',
+ content: ms2form.product.content,
+ parent: ms2form.product.parent,
+ parents: ms2form.product.parents,
+ tags: $.map($(ms2form.selectors.tags).select2("data"), function (val) {
+ return val.text
+ }),
+ files: $(ms2form.form).find(ms2form.selectors.file).map(function () {
+ return $(this).attr('data-id')
+ }).get()
+ },
+ url: ms2form.config.actionUrl,
+ form: ms2form.form,
+ button: ms2form.button,
+ dataType: 'json',
+ beforeSubmit: function (formData, jqForm, options) {
+ $(ms2form.button).attr('disabled', 'disabled');
+ $('.error', ms2form.form).text('');
+ return true;
+ },
+ success: ms2form.product._success,
+ error: ms2form.product._error
+ });
+ }
+ ,_success: function (response){
+ $(ms2form.selectors.sisyphus).sisyphus().manuallyReleaseData();
+ if (response.success) {
+ if (response.message) {
+ ms2form.message.success(response.message);
+ } else if (response.data.redirect) {
+ document.location.href = response.data.redirect;
+ }
+ $(ms2form.form).resetForm();
+ $(ms2form.button).removeAttr('disabled');
+ } else {
+ ms2form.product._error(response)
+ }
+ }
+ ,_error: function (response){
+ if(!response.message){
+ response = JSON.parse(response.responseText);
+ }
+ var message = response.message;
+ console.error(response.data);
+ if (response.data) {
+ var i;
+ for (i in response.data) {
+ $(ms2form.form).find('[name="' + i + '"]').closest('.form-group').addClass('has-error');
+ }
+ message = response.message + '
' + JSON.stringify(response.data)
+ }
+ ms2form.message.error(message);
+ // form error report
+ $(ms2form.button).removeAttr('disabled');
+ }
+ }
+ ,message: {
+ success: function (message) {
+ if (message) {
+ $.jGrowl(message, {theme: 'tickets-message-success'});
+ }
+ }
+ ,error: function (message) {
+ if (message) {
+ $.jGrowl(message, {
+ theme: 'tickets-message-error'
+ //, sticky: true
+ });
+ }
+ }
+ ,info: function (message) {
+ if (message) {
+ $.jGrowl(message, {theme: 'tickets-message-info'});
+ }
+ }
+ ,close: function () {
+ $.jGrowl('close');
+ }
+ }
+ };
+
+ var mse2form = {
+ initialize: function (selector) {
+ var $this = $(selector);
+ if (!$this.length) return;
+ var config = ms2form.config.parentMse2form;
+ var cache = {};
+
+ $this.autocomplete({
+ source: function (request, callback) {
+ if (request.term in cache) {
+ callback(cache[request.term]);
+ return;
+ }
+ var data = {
+ action: 'search'
+ , key: $this.data('key')
+ , pageId: config.pageId
+ };
+ data[config.queryVar] = request.term;
+ $.post(config.actionUrl, data, function (response) {
+ if (response.data.log) {
+ ms2form.message.info(response.data.log)
+ }
+ cache[request.term] = response.data.results;
+ callback(response.data.results)
+ }, 'json');
+ }
+ , minLength: config.minQuery || 3
+ , select: function (event, ui) {
+ if (ui.item.id) {
+ $this.data('id', ui.item.id); // save msCategory Id
+ $this.data('title', ui.item.value);
+ console.log('save msCategory Id');
+ }
+ }
+ , change: function (event, ui){
+ if($this.val() != $this.data('title')){
+ console.log('remove msCategory Id');
+ $this.removeData('id'); // remove msCategory Id
+ }
+ }
+ })
+ .data("ui-autocomplete")._renderItem = function (ul, item) {
+ return $("")
+ .data("item.autocomplete", item)
+ .addClass("mse2-ac-wrapper")
+ .append("" + item.label + "")
+ .appendTo(ul);
+ };
+ // event listeners
+ $(document).on('keypress', ms2form.selectors.mse2form, function (e) {
+ if (e.which == 13) {
+ e.preventDefault();
+ return false;
+ }
+ });
+ }
+ };
+
+ ms2form.load(function() {
+ ms2form.initialize();
+ mse2form.initialize(ms2form.selectors.mse2form);
+ });
+
+ //todo-me delete this
+ window.ms2form = ms2form;
+})();
diff --git a/assets/components/ms2form/vendor/quill/dist/quill.js b/assets/components/ms2form/vendor/quill/dist/quill.js
index 3281189..1ac3d03 100644
--- a/assets/components/ms2form/vendor/quill/dist/quill.js
+++ b/assets/components/ms2form/vendor/quill/dist/quill.js
@@ -7652,7 +7652,7 @@ dom = _.extend(dom, {
NOBREAK_SPACE: " ",
TEXT_NODE: 3,
ZERO_WIDTH_NOBREAK_SPACE: "\uFEFF",
- DEFAULT_BLOCK_TAG: 'DIV',
+ DEFAULT_BLOCK_TAG: 'P',
DEFAULT_BREAK_TAG: 'BR',
DEFAULT_INLINE_TAG: 'SPAN',
EMBED_TEXT: '!',
diff --git a/assets/components/ms2form/vendor/quill/dist/quill.min.js b/assets/components/ms2form/vendor/quill/dist/quill.min.js
index 5434d29..24df983 100644
--- a/assets/components/ms2form/vendor/quill/dist/quill.min.js
+++ b/assets/components/ms2form/vendor/quill/dist/quill.min.js
@@ -6,5 +6,5 @@
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.Quill=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g=200?Dc(b):null,j=b.length;i&&(g=m,h=!1,b=i);a:for(;++fb&&(b=-b>e?0:e+b),c="undefined"==typeof c||c>e?e:+c||0,0>c&&(c+=e),e=b>c?0:c-b>>>0,b>>>=0;for(var f=Array(e);++d=e){for(;e>d;){var f=d+e>>>1,g=a[f];(c?b>=g:b>g)?d=f+1:e=f}return e}return S(a,b,Xa,c)}function S(a,b,c,d){b=c(b);for(var e=0,f=a?a.length:0,g=b!==b,h="undefined"==typeof b;f>e;){var i=hc((e+f)/2),j=c(a[i]),k=j===j;if(g)var l=k||d;else l=h?k&&(d||"undefined"!=typeof j):d?b>=j:b>j;l?e=i+1:f=i}return sc(f,vc)}function T(a,b,c){if("function"!=typeof a)return Xa;if("undefined"==typeof b)return a;switch(c){case 1:return function(c){return a.call(b,c)};case 3:return function(c,d,e){return a.call(b,c,d,e)};case 4:return function(c,d,e,f){return a.call(b,c,d,e,f)};case 5:return function(c,d,e,f,g){return a.call(b,c,d,e,f,g)}}return function(){return a.apply(b,arguments)}}function U(a){return gc.call(a,0)}function V(a,b,c){for(var d=c.length,e=-1,f=rc(a.length-d,0),g=-1,h=b.length,i=Array(f+h);++gc||null==d)return d;var e=b[c-2],f=b[c-1],g=b[3];c>3&&"function"==typeof e?(e=T(e,f,5),c-=2):(e=c>2&&"function"==typeof f?f:null,c-=e?1:0),g&&la(b[1],b[2],g)&&(e=3==c?null:e,c=2);for(var h=0;++hv){var A=h?o(h):null,B=rc(k-v,0),C=q?z:null,D=q?null:z,E=q?x:null,F=q?null:x;b|=q?gb:hb,b&=~(q?hb:gb),r||(b&=~(bb|cb));var G=$(a,b,c,E,C,F,D,A,i,B);return G.placeholder=y,G}}var H=n?c:this;p&&(a=H[u]),h&&(x=ra(x,h)),m&&ii))return!1;for(;k&&++h-1&&a%1==0&&b>a}function la(a,b,c){if(!La(c))return!1;var d=typeof b;if("number"==d)var e=c.length,f=ma(e)&&ka(b,e);else f="string"==d&&b in c;if(f){var g=c[b];return a===a?a===g:g!==g}return!1}function ma(a){return"number"==typeof a&&a>-1&&a%1==0&&yc>=a}function na(a){return a===a&&(0===a?1/a>0:!La(a))}function oa(a,b){var c=a[1],d=b[1],e=c|d,f=jb|ib,g=bb|cb,h=f|g|db|fb,i=c&jb&&!(d&jb),k=c&ib&&!(d&ib),l=(k?a:b)[7],m=(i?a:b)[8],n=!(c>=ib&&d>g||c>g&&d>=ib),p=e>=f&&h>=e&&(ib>c||(k||i)&&l.length<=m);if(!n&&!p)return a;d&bb&&(a[2]=b[2],e|=c&bb?0:db);var q=b[3];if(q){var r=a[3];a[3]=r?V(r,q,b[4]):o(q),a[4]=r?j(a[3],nb):o(b[4])}return q=b[5],q&&(r=a[5],a[5]=r?W(r,q,b[6]):o(q),a[6]=r?j(a[5],nb):o(b[6])),q=b[7],q&&(a[7]=o(q)),d&jb&&(a[8]=null==a[8]?b[8]:sc(a[8],b[8])),null==a[9]&&(a[9]=b[9]),a[0]=b[0],a[1]=e,a}function pa(a,b){a=ua(a);for(var c=-1,d=b.length,e={};++cc?rc(d+c,0):c;else if(c){var f=R(a,b),g=a[f];return(b===b?b===g:g!==g)?f:-1}return e(a,b,c||0)}function xa(){for(var a=[],b=-1,c=arguments.length,d=[],f=fa(),g=f==e;++b=120?Dc(b&&h):null))}c=a.length;var i=a[0],j=-1,k=i?i.length:0,l=[],n=d[0];a:for(;++j2){var d=P(arguments,2),e=j(d,Ea.placeholder);c|=gb}return aa(a,c,b,d,e)}function Fa(a){return y(a,1,arguments,1)}function Ga(a){var b=P(arguments,1),c=j(b,Ga.placeholder);return aa(a,gb,null,b,c)}function Ha(a,b,c,d){return b&&"boolean"!=typeof b&&la(a,b,c)?b=!1:"function"==typeof b&&(d=c,c=b,b=!1),c="function"==typeof c&&T(c,d,1),x(a,b,c)}function Ia(a){var b=i(a)?a.length:_a;return ma(b)&&dc.call(a)==ob||!1}function Ja(a){return a&&1===a.nodeType&&i(a)&&dc.call(a).indexOf("Element")>-1||!1}function Ka(a,b,c,d){if(c="function"==typeof c&&T(c,d,3),!c&&na(a)&&na(b))return a===b;var e=c?c(a,b):_a;return"undefined"==typeof e?H(a,b,c):!!e}function La(a){var b=typeof a;return"function"==b||a&&"object"==b||!1}function Ma(a){return null==a?!1:dc.call(a)==tb?ec.test(ac.call(a)):i(a)&&Nb.test(a)||!1}function Na(a){return"number"==typeof a||i(a)&&dc.call(a)==vb||!1}function Oa(a){return"string"==typeof a||i(a)&&dc.call(a)==zb||!1}function Pa(a){return i(a)&&ma(a.length)&&Rb[dc.call(a)]||!1}function Qa(a){if(null==a)return a;var b=o(arguments);return b.push(t),Kc.apply(_a,b)}function Ra(a){if(null==a)return[];La(a)||(a=Object(a));var b=a.length;b=b&&ma(b)&&(Hc(a)||Ac.nonEnumArgs&&Ia(a))&&b||0;for(var c=a.constructor,d=-1,e="function"==typeof c&&c.prototype===a,f=Array(b),g=b>0;++d>>1,xc=nc?nc.BYTES_PER_ELEMENT:0,yc=Math.pow(2,53)-1,zc=mc&&new mc,Ac=k.support={};!function(){Ac.funcDecomp=!Ma(Zb.WinRTError)&&Qb.test(function(){return this}),Ac.funcNames="string"==typeof Function.name;try{Ac.dom=11===_b.createDocumentFragment().nodeType}catch(a){Ac.dom=!1}try{Ac.nonEnumArgs=!jc.call(arguments,1)}catch(a){Ac.nonEnumArgs=!0}}(0,0);var Bc=function(){function a(){}return function(b){if(La(b)){a.prototype=b;var c=new a;a.prototype=null}return c||Zb.Object()}}(),Cc=zc?function(a,b){return zc.set(a,b),a}:Xa;gc||(U=fc&&lc?function(a){var b=a.byteLength,c=nc?hc(b/xc):0,d=c*xc,e=new fc(b);if(c){var f=new nc(e,0,c);f.set(new nc(a,0,c))}return b!=d&&(f=new lc(e,d),f.set(new lc(a,d))),e}:Wa(null));var Dc=pc&&kc?function(a){return new l(a)}:Wa(null),Ec=zc?function(a){return zc.get(a)}:Za,Fc=function(){var a=0,b=0;return function(c,d){var e=Gc(),f=lb-(e-b);if(b=e,f>0){if(++a>=kb)return c}else a=0;return Cc(c,d)}}(),Gc=tc||function(){return(new Date).getTime()},Hc=oc||function(a){return i(a)&&ma(a.length)&&dc.call(a)==pb||!1};Ac.dom||(Ja=function(a){return a&&1===a.nodeType&&i(a)&&!Jc(a)||!1});var Ic=f(/x/)||lc&&!f(lc)?function(a){return dc.call(a)==tb}:f,Jc=ic?function(a){if(!a||dc.call(a)!=wb)return!1;var b=a.valueOf,c=Ma(b)&&(c=ic(b))&&ic(c);return c?a==c||ic(a)==c:sa(a)}:sa,Kc=X(u),Lc=qc?function(a){if(a)var b=a.constructor,c=a.length;return"function"==typeof b&&b.prototype===a||"function"!=typeof a&&c&&ma(c)?ta(a):La(a)?qc(a):[]}:ta;l.prototype.push=n,k.assign=Kc,k.bind=Ea,k.callback=Va,k.constant=Wa,k.defaults=Qa,k.defer=Fa,k.difference=va,k.forEach=Aa,k.intersection=xa,k.invoke=Ba,k.keys=Lc,k.keysIn=Ra,k.map=Ca,k.matches=Ya,k.omit=Sa,k.partial=Ga,k.values=Ta,k.collect=Ca,k.each=Aa,k.extend=Kc,k.iteratee=Va,k.clone=Ha,k.escapeRegExp=Ua,k.every=za,k.identity=Xa,k.indexOf=wa,k.isArguments=Ia,k.isArray=Hc,k.isElement=Ja,k.isEqual=Ka,k.isFunction=Ic,k.isNative=Ma,k.isNumber=Na,k.isObject=La,k.isPlainObject=Jc,k.isString=Oa,k.isTypedArray=Pa,k.last=ya,k.noop=Za,k.now=Gc,k.reduce=Da,k.uniqueId=$a,k.all=za,k.foldl=Da,k.inject=Da,k.VERSION=ab,p(["bind","partial"],function(a){k[a].placeholder=k}),"function"==typeof a&&"object"==typeof a.amd&&a.amd?(Zb._=k,a(function(){return k})):Ub&&Vb?Yb?(Vb.exports=k)._=k:Ub._=k:Zb._=k}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(b,c,d){!function(){function b(){this._events={},this._conf&&c.call(this,this._conf)}function c(a){a&&(this._conf=a,a.delimiter&&(this.delimiter=a.delimiter),a.maxListeners&&(this._events.maxListeners=a.maxListeners),a.wildcard&&(this.wildcard=a.wildcard),a.newListener&&(this.newListener=a.newListener),this.wildcard&&(this.listenerTree={}))}function e(a){this._events={},this.newListener=!1,c.call(this,a)}function f(a,b,c,d){if(!c)return[];var e,g,h,i,j,k,l,m=[],n=b.length,o=b[d],p=b[d+1];if(d===n&&c._listeners){if("function"==typeof c._listeners)return a&&a.push(c._listeners),[c];for(e=0,g=c._listeners.length;g>e;e++)a&&a.push(c._listeners[e]);return[c]}if("*"===o||"**"===o||c[o]){if("*"===o){for(h in c)"_listeners"!==h&&c.hasOwnProperty(h)&&(m=m.concat(f(a,b,c[h],d+1)));return m}if("**"===o){l=d+1===n||d+2===n&&"*"===p,l&&c._listeners&&(m=m.concat(f(a,b,c,n)));for(h in c)"_listeners"!==h&&c.hasOwnProperty(h)&&("*"===h||"**"===h?(c[h]._listeners&&!l&&(m=m.concat(f(a,b,c[h],n))),m=m.concat(f(a,b,c[h],d))):m=m.concat(h===p?f(a,b,c[h],d+2):f(a,b,c[h],d)));return m}m=m.concat(f(a,b,c[o],d+1))}if(i=c["*"],i&&f(a,b,i,d+1),j=c["**"])if(n>d){j._listeners&&f(a,b,j,n);for(h in j)"_listeners"!==h&&j.hasOwnProperty(h)&&(h===p?f(a,b,j[h],d+2):h===o?f(a,b,j[h],d+1):(k={},k[h]=j[h],f(a,b,{"**":k},d+1)))}else j._listeners?f(a,b,j,n):j["*"]&&j["*"]._listeners&&f(a,b,j["*"],n);return m}function g(a,b){a="string"==typeof a?a.split(this.delimiter):a.slice();for(var c=0,d=a.length;d>c+1;c++)if("**"===a[c]&&"**"===a[c+1])return;for(var e=this.listenerTree,f=a.shift();f;){if(e[f]||(e[f]={}),e=e[f],0===a.length){if(e._listeners){if("function"==typeof e._listeners)e._listeners=[e._listeners,b];else if(h(e._listeners)&&(e._listeners.push(b),!e._listeners.warned)){var g=i;"undefined"!=typeof this._events.maxListeners&&(g=this._events.maxListeners),g>0&&e._listeners.length>g&&(e._listeners.warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",e._listeners.length),console.trace())}}else e._listeners=b;return!0}f=a.shift()}return!0}var h=Array.isArray?Array.isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},i=10;e.prototype.delimiter=".",e.prototype.setMaxListeners=function(a){this._events||b.call(this),this._events.maxListeners=a,this._conf||(this._conf={}),this._conf.maxListeners=a},e.prototype.event="",e.prototype.once=function(a,b){return this.many(a,1,b),this},e.prototype.many=function(a,b,c){function d(){0===--b&&e.off(a,d),c.apply(this,arguments)}var e=this;if("function"!=typeof c)throw new Error("many only accepts instances of Function");return d._origin=c,this.on(a,d),e},e.prototype.emit=function(){this._events||b.call(this);var a=arguments[0];if("newListener"===a&&!this.newListener&&!this._events.newListener)return!1;if(this._all){for(var c=arguments.length,d=new Array(c-1),e=1;c>e;e++)d[e-1]=arguments[e];for(e=0,c=this._all.length;c>e;e++)this.event=a,this._all[e].apply(this,d)}if("error"===a&&!(this._all||this._events.error||this.wildcard&&this.listenerTree.error))throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");var g;if(this.wildcard){g=[];var h="string"==typeof a?a.split(this.delimiter):a.slice();f.call(this,g,h,this.listenerTree,0)}else g=this._events[a];if("function"==typeof g){if(this.event=a,1===arguments.length)g.call(this);else if(arguments.length>1)switch(arguments.length){case 2:g.call(this,arguments[1]);break;case 3:g.call(this,arguments[1],arguments[2]);break;default:for(var c=arguments.length,d=new Array(c-1),e=1;c>e;e++)d[e-1]=arguments[e];g.apply(this,d)}return!0}if(g){for(var c=arguments.length,d=new Array(c-1),e=1;c>e;e++)d[e-1]=arguments[e];for(var i=g.slice(),e=0,c=i.length;c>e;e++)this.event=a,i[e].apply(this,d);return i.length>0||!!this._all}return!!this._all},e.prototype.on=function(a,c){if("function"==typeof a)return this.onAny(a),this;if("function"!=typeof c)throw new Error("on only accepts instances of Function");if(this._events||b.call(this),this.emit("newListener",a,c),this.wildcard)return g.call(this,a,c),this;if(this._events[a]){if("function"==typeof this._events[a])this._events[a]=[this._events[a],c];else if(h(this._events[a])&&(this._events[a].push(c),!this._events[a].warned)){var d=i;"undefined"!=typeof this._events.maxListeners&&(d=this._events.maxListeners),d>0&&this._events[a].length>d&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}}else this._events[a]=c;return this},e.prototype.onAny=function(a){if("function"!=typeof a)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),this._all.push(a),this},e.prototype.addListener=e.prototype.on,e.prototype.off=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");var c,d=[];if(this.wildcard){var e="string"==typeof a?a.split(this.delimiter):a.slice();d=f.call(this,null,e,this.listenerTree,0)}else{if(!this._events[a])return this;c=this._events[a],d.push({_listeners:c})}for(var g=0;gk;k++)if(c[k]===b||c[k].listener&&c[k].listener===b||c[k]._origin&&c[k]._origin===b){j=k;break}if(0>j)continue;return this.wildcard?i._listeners.splice(j,1):this._events[a].splice(j,1),0===c.length&&(this.wildcard?delete i._listeners:delete this._events[a]),this}(c===b||c.listener&&c.listener===b||c._origin&&c._origin===b)&&(this.wildcard?delete i._listeners:delete this._events[a])}return this},e.prototype.offAny=function(a){var b,c=0,d=0;if(a&&this._all&&this._all.length>0){for(b=this._all,c=0,d=b.length;d>c;c++)if(a===b[c])return b.splice(c,1),this}else this._all=[];return this},e.prototype.removeListener=e.prototype.off,e.prototype.removeAllListeners=function(a){if(0===arguments.length)return!this._events||b.call(this),this;if(this.wildcard)for(var c="string"==typeof a?a.split(this.delimiter):a.slice(),d=f.call(this,null,c,this.listenerTree,0),e=0;e0&&(c.attributes=b),this.push(c)},g.prototype["delete"]=function(a){return 0>=a?this:this.push({"delete":a})},g.prototype.retain=function(a,b){if(0>=a)return this;var c={retain:a};return d.object(b)&&Object.keys(b).length>0&&(c.attributes=b),this.push(c)},g.prototype.push=function(a){var b=this.ops.length,c=this.ops[b-1];if(a=e.clone(a),d.object(c)){if(d.number(a["delete"])&&d.number(c["delete"]))return this.ops[b-1]={"delete":c["delete"]+a["delete"]},this;if(d.number(c["delete"])&&(d.string(a.insert)||d.number(a.insert))&&(b-=1,c=this.ops[b-1],!d.object(c)))return this.ops.unshift(a),this;if(d.equal(a.attributes,c.attributes)){if(d.string(a.insert)&&d.string(c.insert))return this.ops[b-1]={insert:c.insert+a.insert},d.object(a.attributes)&&(this.ops[b-1].attributes=a.attributes),this;if(d.number(a.retain)&&d.number(c.retain))return this.ops[b-1]={retain:c.retain+a.retain},d.object(a.attributes)&&(this.ops[b-1].attributes=a.attributes),this}}return this.ops.splice(b,0,a),this},g.prototype.chop=function(){var a=this.ops[this.ops.length-1];return a&&a.retain&&!a.attributes&&this.ops.pop(),this},g.prototype.length=function(){return this.ops.reduce(function(a,b){return a+e.length(b)},0)},g.prototype.slice=function(a,b){a=a||0,d.number(b)||(b=1/0);for(var c=new g,f=e.iterator(this.ops),h=0;b>h&&f.hasNext();){var i;a>h?i=f.next(a-h):(i=f.next(b-h),c.push(i)),h+=e.length(i)}return c},g.prototype.compose=function(a){var b=e.iterator(this.ops),c=e.iterator(a.ops);for(this.ops=[];b.hasNext()||c.hasNext();)if("insert"===c.peekType())this.push(c.next());else if("delete"===b.peekType())this.push(b.next());else{var f=Math.min(b.peekLength(),c.peekLength()),g=b.next(f),h=c.next(f);if(d.number(h.retain)){var i={};d.number(g.retain)?i.retain=f:i.insert=g.insert;var j=e.attributes.compose(g.attributes,h.attributes,d.number(g.retain));j&&(i.attributes=j),this.push(i)}else d.number(h["delete"])&&d.number(g.retain)&&this.push(h)}return this.chop()},g.prototype.diff=function(a){var b=[this.ops,a.ops].map(function(b){return b.map(function(c){if(d.string(c.insert))return c.insert;if(d.number(c.insert))return f;var e=b===a.ops?"on":"with";throw new Error("diff() called "+e+" non-document")}).join("")}),h=c(b[0],b[1]),i=e.iterator(this.ops),j=e.iterator(a.ops),k=new g;return h.forEach(function(a){for(var b=a[1].length;b>0;){var d=0;switch(a[0]){case c.INSERT:d=Math.min(j.peekLength(),b),k.push(j.next(d));break;case c.DELETE:d=Math.min(b,i.peekLength()),i.next(d),k["delete"](d);break;case c.EQUAL:d=Math.min(i.peekLength(),j.peekLength(),b);var f=i.next(d),g=j.next(d);f.insert===g.insert?k.retain(d,e.attributes.diff(f.attributes,g.attributes)):k.push(g)["delete"](d)}b-=d}}),k.chop()},g.prototype.transform=function(a,b){if(b=!!b,d.number(a))return this.transformPosition(a,b);for(var c=e.iterator(this.ops),f=e.iterator(a.ops),h=new g;c.hasNext()||f.hasNext();)if("insert"!==c.peekType()||!b&&"insert"===f.peekType())if("insert"===f.peekType())h.push(f.next());else{var i=Math.min(c.peekLength(),f.peekLength()),j=c.next(i),k=f.next(i);if(j["delete"])continue;k["delete"]?h.push(k):h.retain(i,e.attributes.transform(j.attributes,k.attributes,b))}else h.retain(e.length(c.next()));return h.chop()},g.prototype.transformPosition=function(a,b){b=!!b;for(var c=e.iterator(this.ops),d=0;c.hasNext()&&a>=d;){var f=c.peekLength(),g=c.peekType();c.next(),"delete"!==g?("insert"===g&&(a>d||!b)&&(a+=f),d+=f):a-=Math.min(f,a-d)}return a},b.exports=g},{"./is":4,"./op":5,"fast-diff":6}],4:[function(a,b){b.exports={equal:function(a,b){if(a===b)return!0;if(null==a&&null==b)return!0;if(null==a||null==b)return!1;if(Object.keys(a).length!=Object.keys(b).length)return!1;for(var c in a)if(a[c]!==b[c])return!1;return!0},array:function(a){return Array.isArray(a)},number:function(a){return"number"==typeof a?!0:"object"==typeof a&&"[object Number]"===Object.prototype.toString.call(a)?!0:!1},object:function(a){return a?"function"==typeof a||"object"==typeof a:!1},string:function(a){return"string"==typeof a?!0:"object"==typeof a&&"[object String]"===Object.prototype.toString.call(a)?!0:!1}}},{}],5:[function(a,b){function c(a){this.ops=a,this.index=0,this.offset=0}var d=a("./is"),e={attributes:{clone:function(a,b){return d.object(a)?Object.keys(a).reduce(function(c,d){return void 0===a[d]||null===a[d]&&!b||(c[d]=a[d]),c},{}):{}},compose:function(a,b,c){d.object(a)||(a={}),d.object(b)||(b={});var e=this.clone(b,c);for(var f in a)void 0!==a[f]&&void 0===b[f]&&(e[f]=a[f]);return Object.keys(e).length>0?e:void 0},diff:function(a,b){d.object(a)||(a={}),d.object(b)||(b={});var c=Object.keys(a).concat(Object.keys(b)).reduce(function(c,d){return a[d]!==b[d]&&(c[d]=void 0===b[d]?null:b[d]),c},{});return Object.keys(c).length>0?c:void 0},transform:function(a,b,c){if(!d.object(a))return b;if(!d.object(b))return void 0;if(!c)return b;var e=Object.keys(b).reduce(function(c,d){return void 0===a[d]&&(c[d]=b[d]),c},{});return Object.keys(e).length>0?e:void 0}},clone:function(a){var b=this.attributes.clone(a);return d.object(b.attributes)&&(b.attributes=this.attributes.clone(b.attributes,!0)),b},iterator:function(a){return new c(a)},length:function(a){return d.number(a["delete"])?a["delete"]:d.number(a.retain)?a.retain:d.string(a.insert)?a.insert.length:1;
}};c.prototype.hasNext=function(){return this.peekLength()<1/0},c.prototype.next=function(a){a||(a=1/0);var b=this.ops[this.index];if(b){var c=this.offset,f=e.length(b);if(a>=f-c?(a=f-c,this.index+=1,this.offset=0):this.offset+=a,d.number(b["delete"]))return{"delete":a};var g={};return b.attributes&&(g.attributes=b.attributes),d.number(b.retain)?g.retain=a:g.insert=d.string(b.insert)?b.insert.substr(c,a):b.insert,g}return{retain:1/0}},c.prototype.peekLength=function(){return this.ops[this.index]?e.length(this.ops[this.index])-this.offset:1/0},c.prototype.peekType=function(){return this.ops[this.index]?d.number(this.ops[this.index]["delete"])?"delete":d.number(this.ops[this.index].retain)?"retain":"insert":"retain"},b.exports=e},{"./is":4}],6:[function(a,b){function c(a,b){if(a==b)return a?[[m,a]]:[];var c=g(a,b),e=a.substring(0,c);a=a.substring(c),b=b.substring(c),c=h(a,b);var f=a.substring(a.length-c);a=a.substring(0,a.length-c),b=b.substring(0,b.length-c);var i=d(a,b);return e&&i.unshift([m,e]),f&&i.push([m,f]),j(i),i}function d(a,b){var d;if(!a)return[[l,b]];if(!b)return[[k,a]];var f=a.length>b.length?a:b,g=a.length>b.length?b:a,h=f.indexOf(g);if(-1!=h)return d=[[l,f.substring(0,h)],[m,g],[l,f.substring(h+g.length)]],a.length>b.length&&(d[0][0]=d[2][0]=k),d;if(1==g.length)return[[k,a],[l,b]];var j=i(a,b);if(j){var n=j[0],o=j[1],p=j[2],q=j[3],r=j[4],s=c(n,p),t=c(o,q);return s.concat([[m,r]],t)}return e(a,b)}function e(a,b){for(var c=a.length,d=b.length,e=Math.ceil((c+d)/2),g=e,h=2*e,i=new Array(h),j=new Array(h),m=0;h>m;m++)i[m]=-1,j[m]=-1;i[g+1]=0,j[g+1]=0;for(var n=c-d,o=n%2!=0,p=0,q=0,r=0,s=0,t=0;e>t;t++){for(var u=-t+p;t-q>=u;u+=2){var v,w=g+u;v=u==-t||u!=t&&i[w-1]v&&d>x&&a.charAt(v)==b.charAt(x);)v++,x++;if(i[w]=v,v>c)q+=2;else if(x>d)p+=2;else if(o){var y=g+n-u;if(y>=0&&h>y&&-1!=j[y]){var z=c-j[y];if(v>=z)return f(a,b,v,x)}}}for(var A=-t+r;t-s>=A;A+=2){var z,y=g+A;z=A==-t||A!=t&&j[y-1]z&&d>B&&a.charAt(c-z-1)==b.charAt(d-B-1);)z++,B++;if(j[y]=z,z>c)s+=2;else if(B>d)r+=2;else if(!o){var w=g+n-A;if(w>=0&&h>w&&-1!=i[w]){var v=i[w],x=g+v-w;if(z=c-z,v>=z)return f(a,b,v,x)}}}}return[[k,a],[l,b]]}function f(a,b,d,e){var f=a.substring(0,d),g=b.substring(0,e),h=a.substring(d),i=b.substring(e),j=c(f,g),k=c(h,i);return j.concat(k)}function g(a,b){if(!a||!b||a.charAt(0)!=b.charAt(0))return 0;for(var c=0,d=Math.min(a.length,b.length),e=d,f=0;e>c;)a.substring(f,e)==b.substring(f,e)?(c=e,f=c):d=e,e=Math.floor((d-c)/2+c);return e}function h(a,b){if(!a||!b||a.charAt(a.length-1)!=b.charAt(b.length-1))return 0;for(var c=0,d=Math.min(a.length,b.length),e=d,f=0;e>c;)a.substring(a.length-e,a.length-f)==b.substring(b.length-e,b.length-f)?(c=e,f=c):d=e,e=Math.floor((d-c)/2+c);return e}function i(a,b){function c(a,b,c){for(var d,e,f,i,j=a.substring(c,c+Math.floor(a.length/4)),k=-1,l="";-1!=(k=b.indexOf(j,k+1));){var m=g(a.substring(c),b.substring(k)),n=h(a.substring(0,c),b.substring(0,k));l.length=a.length?[d,e,f,i,l]:null}var d=a.length>b.length?a:b,e=a.length>b.length?b:a;if(d.length<4||2*e.lengthj[4].length?i:j:i;var k,l,m,n;a.length>b.length?(k=f[0],l=f[1],m=f[2],n=f[3]):(m=f[0],n=f[1],k=f[2],l=f[3]);var o=f[4];return[k,l,m,n,o]}function j(a){a.push([m,""]);for(var b,c=0,d=0,e=0,f="",i="";c1?(0!==d&&0!==e&&(b=g(i,f),0!==b&&(c-d-e>0&&a[c-d-e-1][0]==m?a[c-d-e-1][1]+=i.substring(0,b):(a.splice(0,0,[m,i.substring(0,b)]),c++),i=i.substring(b),f=f.substring(b)),b=h(i,f),0!==b&&(a[c][1]=i.substring(i.length-b)+a[c][1],i=i.substring(0,i.length-b),f=f.substring(0,f.length-b))),0===d?a.splice(c-e,d+e,[l,i]):0===e?a.splice(c-d,d+e,[k,f]):a.splice(c-d-e,d+e,[k,f],[l,i]),c=c-d-e+(d?1:0)+(e?1:0)+1):0!==c&&a[c-1][0]==m?(a[c-1][1]+=a[c][1],a.splice(c,1)):c++,e=0,d=0,f="",i=""}""===a[a.length-1][1]&&a.pop();var n=!1;for(c=1;c0))return[null,a];if(c=this.toDelta().length(),a===c)return[this.lines.last,this.lines.last.length];if(a>c)return[null,a-c];for(b=this.lines.first;null!=b;){if(a\s+\ <"),a=document.createElement("div"),a.innerHTML=b,i.each(a.querySelectorAll("."+f.CLASS_NAME),function(a){return j(a).removeClass(f.CLASS_NAME),a.removeAttribute("id")}),a.innerHTML},a.prototype.insertLineBefore=function(a,b){var c;return c=new f(this,a),null!=b?(j(a.parentNode).isElement()||this.root.insertBefore(a,b.node),this.lines.insertAfter(b.prev,c)):(j(a.parentNode).isElement()||this.root.appendChild(a),this.lines.append(c)),this.lineMap[c.id]=c,c},a.prototype.mergeLines=function(a,b){return b.length>1&&(1===a.length&&j(a.leaves.last.node).remove(),i.each(j(b.node).childNodes(),function(b){return b.tagName!==j.DEFAULT_BREAK_TAG?a.node.appendChild(b):void 0})),this.removeLine(b),a.rebuild()},a.prototype.optimizeLines=function(){return i.each(this.lines.toArray(),function(a){return a.optimize(),!0})},a.prototype.rebuild=function(){var a,b,c;for(b=this.lines.toArray(),a=this.root.firstChild,null!=a&&null!=j.LIST_TAGS[a.tagName]&&(a=a.firstChild),i.each(b,function(b){return function(c){for(var d,e;c.node!==a;){if(c.node.parentNode!==b.root&&(null!=(e=c.node.parentNode)?e.parentNode:void 0)!==b.root)return b.removeLine(c);a=b.normalizer.normalizeLine(a),d=b.insertLineBefore(a,c),a=j(a).nextLineNode(b.root)}return c.outerHTML!==a.outerHTML&&(c.node=b.normalizer.normalizeLine(c.node),c.rebuild()),a=j(a).nextLineNode(b.root)}}(this)),c=[];null!=a;)a=this.normalizer.normalizeLine(a),this.appendLine(a),c.push(a=j(a).nextLineNode(this.root));return c},a.prototype.removeLine=function(a){return null!=a.node.parentNode&&(j.LIST_TAGS[a.node.parentNode.tagName]&&1===a.node.parentNode.childNodes.length?j(a.node.parentNode).remove():j(a.node).remove()),delete this.lineMap[a.id],this.lines.remove(a)},a.prototype.setHTML=function(a){return a=h.stripComments(a),a=h.stripWhitespace(a),this.root.innerHTML=a,this.lines=new g,this.lineMap={},this.rebuild()},a.prototype.splitLine=function(a,b){var c,d,e,f;return b=Math.min(b,a.length-1),f=j(a.node).split(b,!0),c=f[0],d=f[1],a.node=c,a.rebuild(),e=this.insertLineBefore(d,a.next),e.formats=i.clone(a.formats),e.resetContent(),e},a.prototype.toDelta=function(){var a,b;return b=this.lines.toArray(),a=new c,i.each(b,function(b){return i.each(b.delta.ops,function(b){return a.push(b)})}),a},a}(),b.exports=d},{"../lib/dom":17,"../lib/linked-list":18,"./format":10,"./line":12,"./normalizer":13,lodash:1,"rich-text/lib/delta":3}],9:[function(a,b){var c,d,e,f,g,h;g=a("lodash"),h=a("../lib/dom"),c=a("./document"),e=a("./line"),f=a("./selection"),d=function(){function a(a,b,d){this.root=a,this.quill=b,this.options=null!=d?d:{},this.root.setAttribute("id",this.options.id),this.doc=new c(this.root,this.options),this.delta=this.doc.toDelta(),this.length=this.delta.length(),this.selection=new f(this.doc,this.quill),this.timer=setInterval(g.bind(this.checkUpdate,this),this.options.pollInterval),this.options.readOnly||this.enable()}return a.sources={API:"api",SILENT:"silent",USER:"user"},a.prototype.destroy=function(){return clearInterval(this.timer)},a.prototype.disable=function(){return this.enable(!1)},a.prototype.enable=function(a){return null==a&&(a=!0),this.root.setAttribute("contenteditable",a)},a.prototype.applyDelta=function(b,c){var d;return d=this._update(),d&&(b=d.transform(b,!0),d=b.transform(d,!1)),b.ops.length>0&&(b=this._trackDelta(function(a){return function(){var c;return c=0,g.each(b.ops,function(b){return g.isString(b.insert)?(a._insertAt(c,b.insert,b.attributes),c+=b.insert.length):g.isNumber(b.insert)?(a._insertAt(c,h.EMBED_TEXT,b.attributes),c+=1):g.isNumber(b["delete"])?a._deleteAt(c,b["delete"]):g.isNumber(b.retain)?(g.each(b.attributes,function(d,e){return a._formatAt(c,b.retain,e,d)}),c+=b.retain):void 0}),a.selection.shiftAfter(0,0,g.bind(a.doc.optimizeLines,a.doc))}}(this)),this.delta=this.doc.toDelta(),this.length=this.delta.length(),this.innerHTML=this.root.innerHTML,b&&c!==a.sources.SILENT&&this.quill.emit(this.quill.constructor.events.TEXT_CHANGE,b,c)),d&&d.ops.length>0&&c!==a.sources.SILENT?this.quill.emit(this.quill.constructor.events.TEXT_CHANGE,d,a.sources.USER):void 0},a.prototype.checkUpdate=function(b){var c;return null==b&&(b="user"),null==this.root.parentNode?clearInterval(this.timer):(c=this._update(),c&&(this.delta.compose(c),this.length=this.delta.length(),this.quill.emit(this.quill.constructor.events.TEXT_CHANGE,c,b)),c&&(b=a.sources.SILENT),this.selection.update(b))},a.prototype.focus=function(){return null!=this.selection.range?this.selection.setRange(this.selection.range):this.root.focus()},a.prototype.getBounds=function(a){var b,c,d,e,f,g,i;if(this.checkUpdate(),g=this.doc.findLeafAt(a,!0),d=g[0],e=g[1],null==d)throw new Error("Invalid index");return c=this.root.parentNode.getBoundingClientRect(),i="left",0===d.length?b=d.node.parentNode.getBoundingClientRect():h.VOID_TAGS[d.node.tagName]?(b=d.node.getBoundingClientRect(),1===e&&(i="right")):(f=document.createRange(),e=b?void 0:this.selection.shiftAfter(a,-1*b,function(c){return function(){var d,e,f,g,h,i,j;for(j=c.doc.findLineAt(a),f=j[0],i=j[1],d=f,g=f.length-i<=b&&i>0;null!=d&&b>0;)h=d.next,e=Math.min(d.length-i,b),0===i&&b>=d.length?c.doc.removeLine(d):d.deleteText(i,e),b-=e,d=h,i=0;return g&&f.next?c.doc.mergeLines(f,f.next):void 0}}(this))},a.prototype._formatAt=function(a,b,c,d){return this.selection.shiftAfter(a,0,function(e){return function(){var f,g,h,i,j;for(i=e.doc.findLineAt(a),g=i[0],h=i[1],j=[];null!=g&&b>0;)f=Math.min(b,g.length-h-1),g.formatText(h,f,c,d),b-=f,b>0&&g.format(c,d),b-=1,h=0,j.push(g=g.next);return j}}(this))},a.prototype._insertAt=function(a,b,c){return null==c&&(c={}),this.selection.shiftAfter(a,b.length,function(d){return function(){var e,f,i,j;return b=b.replace(/\r\n?/g,"\n"),f=b.split("\n"),j=d.doc.findLineAt(a),e=j[0],i=j[1],g.each(f,function(a,b){var j;return null==e||e.length<=i?(b0)&&(e=d.doc.appendLine(document.createElement(h.DEFAULT_BLOCK_TAG)),i=0,e.insertText(i,a,c),e.format(c),j=null):(e.insertText(i,a,c),b0?a:!1)},a}(),b.exports=d},{"../lib/dom":17,"./document":8,"./line":12,"./selection":14,lodash:1}],10:[function(a,b){var c,d,e;d=a("lodash"),e=a("../lib/dom"),c=function(){function a(a){this.config=a}return a.types={LINE:"line"},a.FORMATS={bold:{tag:"B",prepare:"bold"},italic:{tag:"I",prepare:"italic"},underline:{tag:"U",prepare:"underline"},strike:{tag:"S",prepare:"strikeThrough"},color:{style:"color","default":"rgb(0, 0, 0)",prepare:"foreColor"},background:{style:"backgroundColor","default":"rgb(255, 255, 255)",prepare:"backColor"},font:{style:"fontFamily","default":"'Helvetica', 'Arial', sans-serif",prepare:"fontName"},size:{style:"fontSize","default":"13px",prepare:function(a){return document.execCommand("fontSize",!1,e.convertFontSize(a))}},link:{tag:"A",attribute:"href"},image:{tag:"IMG",attribute:"src"},align:{type:a.types.LINE,style:"textAlign","default":"left"},bullet:{type:a.types.LINE,exclude:"list",parentTag:"UL",tag:"LI"},list:{type:a.types.LINE,exclude:"bullet",parentTag:"OL",tag:"LI"}},a.prototype.add=function(b,c){var f,g,h,i,j;return c?this.value(b)===c?b:(d.isString(this.config.parentTag)&&(h=document.createElement(this.config.parentTag),e(b).wrap(h),b.parentNode.tagName===(null!=(i=b.parentNode.previousSibling)?i.tagName:void 0)&&e(b.parentNode.previousSibling).merge(b.parentNode),b.parentNode.tagName===(null!=(j=b.parentNode.nextSibling)?j.tagName:void 0)&&e(b.parentNode).merge(b.parentNode.nextSibling)),d.isString(this.config.tag)&&(f=document.createElement(this.config.tag),null!=e.VOID_TAGS[f.tagName]?(null!=b.parentNode&&e(b).replace(f),b=f):this.isType(a.types.LINE)?b=e(b).switchTag(this.config.tag):(e(b).wrap(f),b=f)),(d.isString(this.config.style)||d.isString(this.config.attribute)||d.isString(this.config["class"]))&&(d.isString(this.config["class"])&&(b=this.remove(b)),e(b).isTextNode()&&(g=document.createElement(e.DEFAULT_INLINE_TAG),e(b).wrap(g),b=g),d.isString(this.config.style)&&c!==this.config["default"]&&(b.style[this.config.style]=c),d.isString(this.config.attribute)&&b.setAttribute(this.config.attribute,c),d.isString(this.config["class"])&&e(b).addClass(this.config["class"]+c)),b):this.remove(b)},a.prototype.isType=function(a){return a===this.config.type},a.prototype.match=function(a){var b,c,f,g,h;if(!e(a).isElement())return!1;if(d.isString(this.config.parentTag)&&(null!=(g=a.parentNode)?g.tagName:void 0)!==this.config.parentTag)return!1;if(d.isString(this.config.tag)&&a.tagName!==this.config.tag)return!1;if(d.isString(this.config.style)&&(!a.style[this.config.style]||a.style[this.config.style]===this.config["default"]))return!1;if(d.isString(this.config.attribute)&&!a.hasAttribute(this.config.attribute))return!1;if(d.isString(this.config["class"])){for(h=e(a).classes(),c=0,f=h.length;f>c;c++)if(b=h[c],0===b.indexOf(this.config["class"]))return!0;return!1}return!0},a.prototype.prepare=function(a){return d.isString(this.config.prepare)?document.execCommand(this.config.prepare,!1,a):d.isFunction(this.config.prepare)?this.config.prepare(a):void 0},a.prototype.remove=function(b){var c,f,g,h;if(!this.match(b))return b;if(d.isString(this.config.style)&&(b.style[this.config.style]="",b.getAttribute("style")||b.removeAttribute("style")),d.isString(this.config.attribute)&&b.removeAttribute(this.config.attribute),d.isString(this.config["class"]))for(h=e(b).classes(),f=0,g=h.length;g>f;f++)c=h[f],0===c.indexOf(this.config["class"])&&e(b).removeClass(c);return d.isString(this.config.tag)&&(this.isType(a.types.LINE)?(d.isString(this.config.parentTag)&&(null!=b.previousSibling&&e(b).splitBefore(b.parentNode.parentNode),null!=b.nextSibling&&e(b.nextSibling).splitBefore(b.parentNode.parentNode)),b=e(b).switchTag(e.DEFAULT_BLOCK_TAG)):(b=e(b).switchTag(e.DEFAULT_INLINE_TAG),null!=e.EMBED_TAGS[this.config.tag]&&e(b).text(e.EMBED_TEXT))),d.isString(this.config.parentTag)&&e(b.parentNode).unwrap(),b.tagName!==e.DEFAULT_INLINE_TAG||b.hasAttributes()||(b=e(b).unwrap()),b},a.prototype.value=function(a){var b,c,f,g;if(!this.match(a))return void 0;if(d.isString(this.config.attribute))return a.getAttribute(this.config.attribute)||void 0;if(d.isString(this.config.style))return a.style[this.config.style]||void 0;if(d.isString(this.config["class"])){for(g=e(a).classes(),c=0,f=g.length;f>c;c++)if(b=g[c],0===b.indexOf(this.config["class"]))return b.slice(this.config["class"].length)}else if(d.isString(this.config.tag))return!0;return void 0},a}(),b.exports=c},{"../lib/dom":17,lodash:1}],11:[function(a,b){var c,d,e,f,g,h=function(a,b){function c(){this.constructor=a}for(var d in b)i.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},i={}.hasOwnProperty;f=a("lodash"),g=a("../lib/dom"),c=a("./format"),e=a("../lib/linked-list"),d=function(a){function b(a,c){this.node=a,this.formats=f.clone(c),this.id=f.uniqueId(b.ID_PREFIX),this.text=g(this.node).text(),this.length=this.text.length}return h(b,a),b.ID_PREFIX="ql-leaf-",b.isLeafNode=function(a){return g(a).isTextNode()||null==a.firstChild},b.prototype.deleteText=function(a,b){var c;if(b>0)return this.text=this.text.slice(0,a)+this.text.slice(a+b),this.length=this.text.length,null!=g.EMBED_TAGS[this.node.tagName]?(c=document.createTextNode(this.text),this.node=g(this.node).replace(c)):g(this.node).text(this.text)},b.prototype.insertText=function(a,b){var c;return this.text=this.text.slice(0,a)+b+this.text.slice(a),g(this.node).isTextNode()?g(this.node).text(this.text):(c=document.createTextNode(b),this.node.tagName===g.DEFAULT_BREAK_TAG?this.node=g(this.node).replace(c):(this.node.appendChild(c),this.node=c)),this.length=this.text.length},b}(e.Node),b.exports=d},{"../lib/dom":17,"../lib/linked-list":18,"./format":10,lodash:1}],12:[function(a,b){var c,d,e,f,g,h,i,j,k=function(a,b){function c(){this.constructor=a}for(var d in b)l.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},l={}.hasOwnProperty;i=a("lodash"),c=a("rich-text/lib/delta"),j=a("../lib/dom"),d=a("./format"),e=a("./leaf"),f=a("./line"),g=a("../lib/linked-list"),h=a("./normalizer"),f=function(a){function b(a,c){this.doc=a,this.node=c,this.id=i.uniqueId(b.ID_PREFIX),this.formats={},j(this.node).addClass(b.CLASS_NAME),this.rebuild(),b.__super__.constructor.call(this,this.node)}return k(b,a),b.CLASS_NAME="ql-line",b.ID_PREFIX="ql-line-",b.prototype.buildLeaves=function(a,b){return i.each(j(a).childNodes(),function(a){return function(c){var f;return c=a.doc.normalizer.normalizeNode(c),f=i.clone(b),i.each(a.doc.formats,function(a,b){return!a.isType(d.types.LINE)&&a.match(c)?f[b]=a.value(c):void 0}),e.isLeafNode(c)?a.leaves.append(new e(c,f)):a.buildLeaves(c,f)}}(this))},b.prototype.deleteText=function(a,b){var c,d,e;if(b>0){for(e=this.findLeafAt(a),d=e[0],a=e[1];null!=d&&b>0;)c=Math.min(b,d.length-a),d.deleteText(a,c),b-=c,d=d.next,a=0;return this.rebuild()}},b.prototype.findLeaf=function(a){var b;for(b=this.leaves.first;null!=b;){if(b.node===a)return b;b=b.next}return null},b.prototype.findLeafAt=function(a,b){var c;if(null==b&&(b=!1),a>=this.length-1)return[this.leaves.last,this.leaves.last.length];for(c=this.leaves.first;null!=c;){if(a0;){if(k=g.next,e&&g.formats[c]!==e||!e&&null!=g.formats[c]){if(p=g.node,null!=g.formats[c]){for(j(p).splitBefore(this.node);!f.match(p);)p=p.parentNode;j(p).split(g.length)}h>0&&(m=j(p).split(h),i=m[0],p=m[1]),g.length>h+b&&(n=j(p).split(b),p=n[0],o=n[1]),f.add(p,e)}b-=g.length-h,h=0,g=k}return this.rebuild()}},b.prototype.insertText=function(a,b,c){var d,e,f,g,h,k,l;return null==c&&(c={}),b.length>0?(k=this.findLeafAt(a),d=k[0],e=k[1],i.isEqual(d.formats,c)?(d.insertText(e,b),this.resetContent()):(g=i.reduce(c,function(a){return function(b,c,d){var e;return e=a.doc.formats[d],null!=e&&(b=e.add(b,c)),b}}(this),document.createTextNode(b)),l=j(d.node).split(e),h=l[0],f=l[1],f&&(f=j(f).splitBefore(this.node).get()),this.node.insertBefore(g,f),this.rebuild())):void 0},b.prototype.optimize=function(){return h.optimizeLine(this.node),this.rebuild()},b.prototype.rebuild=function(a){return null==a&&(a=!1),!a&&null!=this.outerHTML&&this.outerHTML===this.node.outerHTML&&i.all(this.leaves.toArray(),function(a){return function(b){return j(b.node).isAncestor(a.node)}}(this))?!1:(this.node=this.doc.normalizer.normalizeNode(this.node),0!==j(this.node).length()||this.node.querySelector(j.DEFAULT_BREAK_TAG)||this.node.appendChild(document.createElement(j.DEFAULT_BREAK_TAG)),this.leaves=new g,this.formats=i.reduce(this.doc.formats,function(a){return function(b,c,e){return c.isType(d.types.LINE)&&(c.match(a.node)?b[e]=c.value(a.node):delete b[e]),b}}(this),this.formats),this.buildLeaves(this.node,{}),this.resetContent(),!0)},b.prototype.resetContent=function(){return this.node.id!==this.id&&(this.node.id=this.id),this.outerHTML=this.node.outerHTML,this.length=1,this.delta=new c,i.each(this.leaves.toArray(),function(a){return function(b){return a.length+=b.length,null!=j.EMBED_TAGS[b.node.tagName]?a.delta.insert(1,b.formats):a.delta.insert(b.text,b.formats)}}(this)),this.delta.insert("\n",this.formats)},b}(g.Node),b.exports=f},{"../lib/dom":17,"../lib/linked-list":18,"./format":10,"./leaf":11,"./line":12,"./normalizer":13,lodash:1,"rich-text/lib/delta":3}],13:[function(a,b){var c,d,e,f;d=a("lodash"),f=a("../lib/dom"),e=function(a){return a=a.replace(/(?:^|[-_])(\w)/g,function(a,b){return b?b.toUpperCase():""}),a.charAt(0).toLowerCase()+a.slice(1)},c=function(){function a(){this.whitelist={styles:{},tags:{}},this.whitelist.tags[f.DEFAULT_BREAK_TAG]=!0,this.whitelist.tags[f.DEFAULT_BLOCK_TAG]=!0,this.whitelist.tags[f.DEFAULT_INLINE_TAG]=!0}return a.ALIASES={STRONG:"B",EM:"I",DEL:"S",STRIKE:"S"},a.ATTRIBUTES={color:"color",face:"fontFamily",size:"fontSize"},a.prototype.addFormat=function(a){return null!=a.tag&&(this.whitelist.tags[a.tag]=!0),null!=a.parentTag&&(this.whitelist.tags[a.parentTag]=!0),null!=a.style?this.whitelist.styles[a.style]=!0:void 0},a.prototype.normalizeLine=function(b){return b=a.wrapInline(b),b=a.handleBreaks(b),b=a.pullBlocks(b),b=this.normalizeNode(b),a.unwrapText(b),null!=b&&null!=f.LIST_TAGS[b.tagName]&&(b=b.firstChild),b},a.prototype.normalizeNode=function(b){return f(b).isTextNode()?b:(d.each(a.ATTRIBUTES,function(a,c){var d;return b.hasAttribute(c)?(d=b.getAttribute(c),"size"===c&&(d=f.convertFontSize(d)),b.style[a]=d,b.removeAttribute(c)):void 0}),this.whitelistStyles(b),this.whitelistTags(b))},a.prototype.whitelistStyles=function(a){var b,c;return b=f(a).styles(),c=d.omit(b,function(a){return function(b,c){return null==a.whitelist.styles[e(c)]}}(this)),Object.keys(c).length0?f(a).styles(c,!0):a.removeAttribute("style"):void 0},a.prototype.whitelistTags=function(b){return f(b).isElement()?(null!=a.ALIASES[b.tagName]?b=f(b).switchTag(a.ALIASES[b.tagName]):null==this.whitelist.tags[b.tagName]&&(b=null!=f.BLOCK_TAGS[b.tagName]?f(b).switchTag(f.DEFAULT_BLOCK_TAG):b.hasAttributes()||null==b.firstChild?f(b).switchTag(f.DEFAULT_INLINE_TAG):f(b).unwrap()),b):b},a.handleBreaks=function(a){var b;return b=d.map(a.querySelectorAll(f.DEFAULT_BREAK_TAG)),d.each(b,function(){return function(b){return null==b.nextSibling||f.isIE(10)&&null==b.previousSibling?void 0:f(b.nextSibling).splitBefore(a.parentNode)}}(this)),a},a.optimizeLine=function(a){var b,c,e,g;for(a.normalize(),b=f(a).length(),e=f(a).descendants(),g=[];e.length>0;)c=e.pop(),null!=(null!=c?c.parentNode:void 0)&&null==f.EMBED_TAGS[c.tagName]&&(c.tagName===f.DEFAULT_BREAK_TAG?g.push(0!==b?f(c).remove():void 0):0===f(c).length()?(e.push(c.nextSibling),g.push(f(c).unwrap())):null!=c.previousSibling&&c.tagName===c.previousSibling.tagName&&d.isEqual(f(c).attributes(),f(c.previousSibling).attributes())?(e.push(c.firstChild),g.push(f(c.previousSibling).merge(c))):g.push(void 0));return g},a.pullBlocks=function(b){var c;for(c=b.firstChild;null!=c;){if(null!=f.BLOCK_TAGS[c.tagName]&&"LI"!==c.tagName){f(c).isolate(b.parentNode),null!=f.LIST_TAGS[c.tagName]&&c.firstChild?(f(c.parentNode).unwrap(),null==b.parentNode&&(b=c)):(f(c).unwrap(),a.pullBlocks(b));break}c=c.nextSibling}return b},a.stripComments=function(a){return a.replace(//g,"")},a.stripWhitespace=function(a){return a=a.trim(),a=a.replace(/(\r?\n|\r)+/g," "),a=a.replace(/\>\s+\<")},a.wrapInline=function(a){var b,c;if(null!=f.BLOCK_TAGS[a.tagName])return a;for(b=document.createElement(f.DEFAULT_BLOCK_TAG),a.parentNode.insertBefore(b,a);null!=a&&null==f.BLOCK_TAGS[a.tagName];)c=a.nextSibling,b.appendChild(a),a=c;return b},a.unwrapText=function(a){var b;return b=d.map(a.querySelectorAll(f.DEFAULT_INLINE_TAG)),d.each(b,function(a){return a.hasAttributes()?void 0:f(a).unwrap()})},a}(),b.exports=c},{"../lib/dom":17,lodash:1}],14:[function(a,b){var c,d,e,f,g,h;g=a("lodash"),h=a("../lib/dom"),c=a("./leaf"),d=a("./normalizer"),e=a("../lib/range"),f=function(){function a(a,b){this.doc=a,this.emitter=b,this.focus=!1,this.range=new e(0,0),this.nullDelay=!1,this.update("silent")}return a.prototype.checkFocus=function(){return document.activeElement===this.doc.root},a.prototype.getRange=function(a){var b,c,d;return null==a&&(a=!1),this.checkFocus()?(c=this._getNativeRange(),null==c?null:(d=this._positionToIndex(c.startContainer,c.startOffset),b=c.startContainer===c.endContainer&&c.startOffset===c.endOffset?d:this._positionToIndex(c.endContainer,c.endOffset),new e(Math.min(d,b),Math.max(d,b)))):a?this.range:null},a.prototype.preserve=function(a){var b,c,d,e,f,g,h,i,j;return d=this._getNativeRange(),null!=d&&this.checkFocus()?(e=this._encodePosition(d.startContainer,d.startOffset),i=e[0],j=e[1],f=this._encodePosition(d.endContainer,d.endOffset),b=f[0],c=f[1],a(),g=this._decodePosition(i,j),i=g[0],j=g[1],h=this._decodePosition(b,c),b=h[0],c=h[1],this._setNativeRange(i,j,b,c)):a()},a.prototype.setRange=function(a,b){var c,d,e,f,g,h,i;return null!=a?(e=this._indexToPosition(a.start),h=e[0],i=e[1],a.isCollapsed()?(f=[h,i],c=f[0],d=f[1]):(g=this._indexToPosition(a.end),c=g[0],d=g[1]),this._setNativeRange(h,i,c,d)):this._setNativeRange(null),this.update(b)},a.prototype.shiftAfter=function(a,b,c){var d;return d=this.getRange(),c(),null!=d?(d.shift(a,b),this.setRange(d,"silent")):void 0},a.prototype.update=function(a){var b,c,d,f;return c=this.checkFocus(),d=this.getRange(!0),b="silent"!==a&&(!e.compare(d,this.range)||c!==this.focus),f=c?d:null,null!==f||"user"!==a||this.nullDelay?(this.nullDelay=!1,this.range=d,this.focus=c,b?this.emitter.emit(this.emitter.constructor.events.SELECTION_CHANGE,f,a):void 0):this.nullDelay=!0},a.prototype._decodePosition=function(a,b){var c;return h(a).isElement()&&(c=h(a.parentNode).childNodes().indexOf(a),b+=c,a=a.parentNode),[a,b]},a.prototype._encodePosition=function(a,b){for(var c;;){if(h(a).isTextNode()||a.tagName===h.DEFAULT_BREAK_TAG||null!=h.EMBED_TAGS[a.tagName])return[a,b];if(b0&&(a=b.getRangeAt(0),h(a.startContainer).isAncestor(this.doc.root,!0)&&(a.startContainer===a.endContainer||h(a.endContainer).isAncestor(this.doc.root,!0)))?a:null},a.prototype._indexToPosition=function(a){var b,c,d;return 0===this.doc.lines.length?[this.doc.root,0]:(d=this.doc.findLeafAt(a,!0),b=d[0],c=d[1],this._decodePosition(b.node,c))},a.prototype._positionToIndex=function(a,b){var c,d,e,f,g,i;if(h.isIE(10)&&"BR"===a.tagName&&1===b&&(b=0),i=this._encodePosition(a,b),d=i[0],b=i[1],f=this.doc.findLine(d),null==f)return 0;for(c=f.findLeaf(d),g=0;null!=f.prev;)f=f.prev,g+=f.length;if(null==c)return g;for(e=0;null!=c.prev;)c=c.prev,e+=c.length;return g+e+b},a.prototype._setNativeRange=function(a,b,c,d){var e,f;if(f=document.getSelection())if(null!=a){if(this.checkFocus()||this.doc.root.focus(),e=this._getNativeRange(),null==e||a!==e.startContainer||b!==e.startOffset||c!==e.endContainer||d!==e.endOffset)return f.removeAllRanges(),e=document.createRange(),e.setStart(a,b),e.setEnd(c,d),f.addRange(e)}else if(f.removeAllRanges(),this.doc.root.blur(),h.isIE(11)&&!h.isIE(9))return document.body.focus()},a}(),b.exports=f},{"../lib/dom":17,"../lib/range":20,"./leaf":11,"./normalizer":13,lodash:1}],15:[function(a,b){a("./modules/authorship"),a("./modules/image-tooltip"),a("./modules/keyboard"),a("./modules/link-tooltip"),a("./modules/multi-cursor"),a("./modules/paste-manager"),a("./modules/toolbar"),a("./modules/tooltip"),a("./modules/undo-manager"),b.exports=a("./quill")},{"./modules/authorship":21,"./modules/image-tooltip":22,"./modules/keyboard":23,"./modules/link-tooltip":24,"./modules/multi-cursor":25,"./modules/paste-manager":26,"./modules/toolbar":27,"./modules/tooltip":28,"./modules/undo-manager":29,"./quill":30}],16:[function(a,b){var c,d,e,f=function(a,b){function c(){this.constructor=a}for(var d in b)g.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},g={}.hasOwnProperty;e=a("./dom"),d=a("./picker"),c=function(a){function b(){b.__super__.constructor.apply(this,arguments),e(this.container).addClass("ql-color-picker")}return f(b,a),b.prototype.buildItem=function(a,c,d){var e;return e=b.__super__.buildItem.call(this,a,c,d),e.style.backgroundColor=c.value,e},b}(d),b.exports=c},{"./dom":17,"./picker":19}],17:[function(a,b){var c,d,e,f,g,h=function(a,b){return function(){return a.apply(b,arguments)}},i=function(a,b){function c(){this.constructor=a}for(var d in b)j.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},j={}.hasOwnProperty;e=a("lodash"),g=null,d=function(){function a(a){this.node=a,this.trigger=h(this.trigger,this)}return a.prototype.addClass=function(a){return this.hasClass(a)?void 0:(null!=this.node.classList?this.node.classList.add(a):null!=this.node.className&&(this.node.className=(this.node.className+" "+a).trim()),this)},a.prototype.attributes=function(a){var b,c,d,f,g,h;if(a)return e.each(a,function(a){return function(b,c){return a.node.setAttribute(c,b)}}(this)),this;if(null==this.node.attributes)return{};for(a={},g=this.node.attributes,
-c=d=0,f=g.length;f>d;c=++d)h=g[c],b=this.node.attributes[c],a[b.name]=b.value;return a},a.prototype.child=function(a){var b,c;for(b=this.node.firstChild,c=f(b).length();null!=b&&!(c>a);)a-=c,b=b.nextSibling,c=f(b).length();return null==b&&(b=this.node.lastChild,a=f(b).length()),[b,a]},a.prototype.childNodes=function(){return e.map(this.node.childNodes)},a.prototype.classes=function(){return this.node.className.split(/\s+/)},a.prototype.descendants=function(){return e.map(this.node.getElementsByTagName("*"))},a.prototype.get=function(){return this.node},a.prototype.hasClass=function(a){return null!=this.node.classList?this.node.classList.contains(a):null!=this.node.className?this.classes().indexOf(a)>-1:!1},a.prototype.isAncestor=function(a,b){var c;if(null==b&&(b=!1),a===this.node)return b;for(c=this.node;c;){if(c===a)return!0;c=c.parentNode}return!1},a.prototype.isElement=function(){var a;return(null!=(a=this.node)?a.nodeType:void 0)===f.ELEMENT_NODE},a.prototype.isTextNode=function(){var a;return(null!=(a=this.node)?a.nodeType:void 0)===f.TEXT_NODE},a.prototype.isolate=function(a){return null!=this.node.nextSibling&&f(this.node.nextSibling).splitBefore(a),this.splitBefore(a),this},a.prototype.length=function(){var a;return null==this.node?0:(a=this.text().length,this.isElement()&&(a+=this.node.querySelectorAll(Object.keys(f.EMBED_TAGS).join(",")).length),a)},a.prototype.merge=function(a){var b;return b=f(a),this.isElement()?(b.moveChildren(this.node),this.normalize()):this.text(this.text()+b.text()),b.remove(),this},a.prototype.moveChildren=function(a){return e.each(this.childNodes(),function(b){return a.appendChild(b)}),this},a.prototype.nextLineNode=function(a){var b;return b=this.node.nextSibling,null==b&&this.node.parentNode!==a&&(b=this.node.parentNode.nextSibling),null!=b&&null!=f.LIST_TAGS[b.tagName]&&(b=b.firstChild),b},a.prototype.normalize=function(){var a,b,c,d;for(b=this.node.firstChild;null!=b;)d=b.nextSibling,a=f(b),null!=d&&f(d).isTextNode()&&(0===a.text().length?a.remove():a.isTextNode()&&(c=d.nextSibling,a.merge(d),d=c)),b=d;return this},a.prototype.on=function(a,b){return this.node.addEventListener(a,function(c){return function(d){var e,f;return e=!g||"keydown"!==a&&"keyup"!==a?d:g,f=b.call(c.node,e),f||(d.preventDefault(),d.stopPropagation()),f}}(this)),this},a.prototype.remove=function(){var a;return null!=(a=this.node.parentNode)&&a.removeChild(this.node),this.node=null,null},a.prototype.removeClass=function(a){var b;if(this.hasClass(a))return null!=this.node.classList?this.node.classList.remove(a):null!=this.node.className&&(b=this.classes(),b.splice(b.indexOf(a),1),this.node.className=b.join(" ")),this.node.getAttribute("class")||this.node.removeAttribute("class"),this},a.prototype.replace=function(a){return this.node.parentNode.replaceChild(a,this.node),this.node=a,a},a.prototype.splitBefore=function(a,b){var c,d,e,g;if(null==b&&(b=!1),this.node===a||this.node.parentNode===a)return this;if(null!=this.node.previousSibling||b){for(e=this.node.parentNode,d=e.cloneNode(!1),e.parentNode.insertBefore(d,e.nextSibling),g=this.node;null!=g;)c=g.nextSibling,d.appendChild(g),g=c;return f(d).splitBefore(a)}return f(this.node.parentNode).splitBefore(a)},a.prototype.split=function(a,b){var c,d,e,g,h,i,j,k,l,m;if(null==b&&(b=!1),j=this.length(),a=Math.max(0,a),a=Math.min(a,j),!b&&0===a)return[this.node.previousSibling,this.node,!1];if(!b&&a===j)return[this.node,this.node.nextSibling,!1];if(this.node.nodeType===f.TEXT_NODE)return c=this.node.splitText(a),[this.node,c,!0];for(h=this.node,m=this.node.cloneNode(!1),this.node.parentNode.insertBefore(m,h.nextSibling),k=this.child(a),d=k[0],a=k[1],l=f(d).split(a),e=l[0],g=l[1];null!==g;)i=g.nextSibling,m.appendChild(g),g=i;return[h,m,!0]},a.prototype.styles=function(a,b){var c,d;return null==b&&(b=!1),a?(b||(a=e.defaults(a,this.styles())),d=e.map(a,function(a,b){return b+": "+a}).join("; ")+";",this.node.setAttribute("style",d),this):(d=this.node.getAttribute("style")||"",c=e.reduce(d.split(";"),function(a,b){var c,d,e;return d=b.split(":"),c=d[0],e=d[1],c&&e&&(c=c.trim(),e=e.trim(),a[c.toLowerCase()]=e),a},{}))},a.prototype.switchTag=function(a){var b,c;return a=a.toUpperCase(),this.node.tagName===a?this:(c=document.createElement(a),b=this.attributes(),null==f.VOID_TAGS[a]&&this.moveChildren(c),this.replace(c),this.attributes(b).get())},a.prototype.text=function(a){if(null!=a){switch(this.node.nodeType){case f.ELEMENT_NODE:this.node.textContent=a;break;case f.TEXT_NODE:this.node.data=a}return this}switch(this.node.nodeType){case f.ELEMENT_NODE:return this.node.tagName===f.DEFAULT_BREAK_TAG?"":null!=f.EMBED_TAGS[this.node.tagName]?f.EMBED_TEXT:null!=this.node.textContent?this.node.textContent:"";case f.TEXT_NODE:return this.node.data||"";default:return""}},a.prototype.textNodes=function(){var a,b,c;for(c=document.createTreeWalker(this.node,NodeFilter.SHOW_TEXT,null,!1),b=[];a=c.nextNode();)b.push(a);return b},a.prototype.toggleClass=function(a,b){return null==b&&(b=!this.hasClass(a)),b?this.addClass(a):this.removeClass(a),this},a.prototype.trigger=function(a,b){var c,d,h;return null==b&&(b={}),["keypress","keydown","keyup"].indexOf(a)<0?(c=document.createEvent("Event"),c.initEvent(a,b.bubbles,b.cancelable)):(c=document.createEvent("KeyboardEvent"),g=e.clone(b),g.which=e.isNumber(b.key)?b.key:e.isString(b.key)?b.key.toUpperCase().charCodeAt(0):0,f.isIE(10)?(h=[],b.altKey&&h.push("Alt"),b.ctrlKey&&h.push("Control"),b.metaKey&&h.push("Meta"),b.shiftKey&&h.push("Shift"),c.initKeyboardEvent(a,b.bubbles,b.cancelable,window,0,0,h.join(" "),null,null)):(d=e.isFunction(c.initKeyboardEvent)?"initKeyboardEvent":"initKeyEvent",c[d](a,b.bubbles,b.cancelable,window,b.ctrlKey,b.altKey,b.shiftKey,b.metaKey,0,0))),this.node.dispatchEvent(c),g=null,this},a.prototype.unwrap=function(){var a,b;return b=this.node.firstChild,a=this.node.nextSibling,e.each(this.childNodes(),function(b){return function(c){return b.node.parentNode.insertBefore(c,a)}}(this)),this.remove(),b},a.prototype.wrap=function(a){var b;for(null!=this.node.parentNode&&this.node.parentNode.insertBefore(a,this.node),b=a;null!=b.firstChild;)b=a.firstChild;return b.appendChild(this.node),this},a}(),c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return i(b,a),b.prototype["default"]=function(){return this.node.querySelector("option[selected]")},b.prototype.option=function(a,b){var c,d,f,g,h,i;if(null==b&&(b=!0),i=e.isElement(a)?a.value:a){for(i=i.replace(/[^\w]+/g,""),h=this.node.children,d=f=0,g=h.length;g>f;d=++f)if(c=h[d],c.value.replace(/[^\w]+/g,"")===i){this.node.selectedIndex=d;break}}else this.node.selectedIndex=-1;return b&&this.trigger("change"),this},b.prototype.reset=function(a){var b;return null==a&&(a=!0),b=this["default"](),null!=b?b.selected=!0:this.node.selectedIndex=0,a&&this.trigger("change"),this},b.prototype.value=function(){return this.node.selectedIndex>-1?this.node.options[this.node.selectedIndex].value:""},b}(d),f=function(a){return"SELECT"===(null!=a?a.tagName:void 0)?new c(a):new d(a)},f=e.extend(f,{ELEMENT_NODE:1,NOBREAK_SPACE:" ",TEXT_NODE:3,ZERO_WIDTH_NOBREAK_SPACE:"\ufeff",DEFAULT_BLOCK_TAG:"DIV",DEFAULT_BREAK_TAG:"BR",DEFAULT_INLINE_TAG:"SPAN",EMBED_TEXT:"!",FONT_SIZES:{"10px":1,"13px":2,"16px":3,"18px":4,"24px":5,"32px":6,"48px":7},KEYS:{BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46},BLOCK_TAGS:{ADDRESS:"ADDRESS",ARTICLE:"ARTICLE",ASIDE:"ASIDE",AUDIO:"AUDIO",BLOCKQUOTE:"BLOCKQUOTE",CANVAS:"CANVAS",DD:"DD",DIV:"DIV",DL:"DL",FIGCAPTION:"FIGCAPTION",FIGURE:"FIGURE",FOOTER:"FOOTER",FORM:"FORM",H1:"H1",H2:"H2",H3:"H3",H4:"H4",H5:"H5",H6:"H6",HEADER:"HEADER",HGROUP:"HGROUP",LI:"LI",OL:"OL",OUTPUT:"OUTPUT",P:"P",PRE:"PRE",SECTION:"SECTION",TABLE:"TABLE",TBODY:"TBODY",TD:"TD",TFOOT:"TFOOT",TH:"TH",THEAD:"THEAD",TR:"TR",UL:"UL",VIDEO:"VIDEO"},EMBED_TAGS:{IMG:"IMG"},LINE_TAGS:{DIV:"DIV",LI:"LI"},LIST_TAGS:{OL:"OL",UL:"UL"},VOID_TAGS:{AREA:"AREA",BASE:"BASE",BR:"BR",COL:"COL",COMMAND:"COMMAND",EMBED:"EMBED",HR:"HR",IMG:"IMG",INPUT:"INPUT",KEYGEN:"KEYGEN",LINK:"LINK",META:"META",PARAM:"PARAM",SOURCE:"SOURCE",TRACK:"TRACK",WBR:"WBR"},convertFontSize:function(a){var b,c,d,g;e.isString(a)&&a.indexOf("px")>-1?(d=Object.keys(f.FONT_SIZES),g=e.values(f.FONT_SIZES)):(g=Object.keys(f.FONT_SIZES),d=e.values(f.FONT_SIZES));for(b in d)if(c=d[b],parseInt(a)<=parseInt(c))return g[b];return e.last(g)},isIE:function(a){var b;return b=document.documentMode,b&&a>=b},isIOS:function(){return/iPhone|iPad/i.test(navigator.userAgent)},isMac:function(){return/Mac/i.test(navigator.platform)}}),b.exports=f},{lodash:1}],18:[function(a,b){var c,d;d=function(){function a(a){this.data=a,this.prev=this.next=null}return a}(),c=function(){function a(){this.length=0,this.first=this.last=null}return a.Node=d,a.prototype.append=function(a){return null!=this.first?(a.next=null,this.last.next=a):this.first=a,a.prev=this.last,this.last=a,this.length+=1},a.prototype.insertAfter=function(a,b){return b.prev=a,null!=a?(b.next=a.next,null!=a.next&&(a.next.prev=b),a.next=b,a===this.last&&(this.last=b)):(b.next=this.first,this.first.prev=b,this.first=b),this.length+=1},a.prototype.remove=function(a){return this.length>1?(null!=a.prev&&(a.prev.next=a.next),null!=a.next&&(a.next.prev=a.prev),a===this.first&&(this.first=a.next),a===this.last&&(this.last=a.prev)):this.first=this.last=null,a.prev=a.next=null,this.length-=1},a.prototype.toArray=function(){var a,b;for(a=[],b=this.first;null!=b;)a.push(b),b=b.next;return a},a}(),b.exports=c},{}],19:[function(a,b){var c,d,e,f;e=a("lodash"),f=a("./dom"),c=a("../core/normalizer"),d=function(){function a(a){this.select=a,this.container=document.createElement("span"),this.buildPicker(),f(this.container).addClass("ql-picker"),this.select.style.display="none",this.select.parentNode.insertBefore(this.container,this.select),f(document).on("click",function(a){return function(){return a.close(),!0}}(this)),f(this.label).on("click",function(a){return function(){return e.defer(function(){return f(a.container).toggleClass("ql-expanded")}),!1}}(this)),f(this.select).on("change",function(a){return function(){var b,c;return a.select.selectedIndex>-1&&(b=a.container.querySelectorAll(".ql-picker-item")[a.select.selectedIndex],c=a.select.options[a.select.selectedIndex]),a.selectItem(b,!1),f(a.label).toggleClass("ql-active",c!==f(a.select)["default"]())}}(this))}return a.TEMPLATE='',a.prototype.buildItem=function(a,b,c){var d;return d=document.createElement("span"),d.setAttribute("data-value",b.getAttribute("value")),f(d).addClass("ql-picker-item").text(f(b).text()).on("click",function(a){return function(){return a.selectItem(d,!0),a.close()}}(this)),this.select.selectedIndex===c&&this.selectItem(d,!1),d},a.prototype.buildPicker=function(){var b;return e.each(f(this.select).attributes(),function(a){return function(b,c){return a.container.setAttribute(c,b)}}(this)),this.container.innerHTML=c.stripWhitespace(a.TEMPLATE),this.label=this.container.querySelector(".ql-picker-label"),b=this.container.querySelector(".ql-picker-options"),e.each(this.select.options,function(a){return function(c,d){var e;return e=a.buildItem(b,c,d),b.appendChild(e)}}(this))},a.prototype.close=function(){return f(this.container).removeClass("ql-expanded")},a.prototype.selectItem=function(a,b){var c,d;return c=this.container.querySelector(".ql-selected"),null!=c&&f(c).removeClass("ql-selected"),null!=a?(d=a.getAttribute("data-value"),f(a).addClass("ql-selected"),f(this.label).text(f(a).text()),f(this.select).option(d,b),this.label.setAttribute("data-value",d)):(this.label.innerHTML=" ",this.label.removeAttribute("data-value"))},a}(),b.exports=d},{"../core/normalizer":13,"./dom":17,lodash:1}],20:[function(a,b){var c,d;d=a("lodash"),c=function(){function a(a,b){this.start=a,this.end=b}return a.compare=function(a,b){return a===b?!0:null==a||null==b?!1:a.equals(b)},a.prototype.equals=function(a){return null==a?!1:this.start===a.start&&this.end===a.end},a.prototype.shift=function(a,b){var c;return c=d.map([this.start,this.end],function(c){return a>c?c:b>=0?c+b:Math.max(a,c+b)}),this.start=c[0],this.end=c[1],c},a.prototype.isCollapsed=function(){return this.start===this.end},a}(),b.exports=c},{lodash:1}],21:[function(a,b){var c,d,e,f,g;e=a("../quill"),f=e.require("lodash"),g=e.require("dom"),d=e.require("delta"),c=function(){function a(a,b){this.quill=a,this.options=b,null!=this.options.button&&this.attachButton(this.options.button),this.options.enabled&&this.enable(),this.quill.addFormat("author",{"class":"author-"}),null!=this.options.authorId&&(this.quill.on(this.quill.constructor.events.PRE_EVENT,function(a){return function(b,c,g){var h,i;return b===a.quill.constructor.events.TEXT_CHANGE&&"user"===g?(h=new d,i={author:a.options.authorId},f.each(c.ops,function(b){return null==b["delete"]?null!=b.insert||null!=b.retain&&null!=b.attributes?(b.attributes||(b.attributes={}),b.attributes.author=a.options.authorId,h.retain(b.retain||b.insert.length||1,i)):h.retain(b.retain):void 0}),a.quill.updateContents(h,e.sources.SILENT)):void 0}}(this)),this.addAuthor(this.options.authorId,this.options.color))}return a.DEFAULTS={authorId:null,color:"transparent",enabled:!1},a.prototype.addAuthor=function(a,b){var c;return c={},c[".authorship .author-"+a]={"background-color":""+b},this.quill.theme.addStyles(c)},a.prototype.attachButton=function(a){var b;return b=g(a),b.on("click",function(a){return function(){return b.toggleClass("ql-on"),a.enable($dom.hasClass("ql-on"))}}(this))},a.prototype.enable=function(a){return null==a&&(a=!0),g(this.quill.root).toggleClass("authorship",a)},a.prototype.disable=function(){return this.enable(!1)},a}(),e.registerModule("authorship",c),b.exports=c},{"../quill":30}],22:[function(a,b){var c,d,e,f,g,h,i,j=function(a,b){function c(){this.constructor=a}for(var d in b)k.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},k={}.hasOwnProperty;e=a("../quill"),g=a("./tooltip"),h=e.require("lodash"),i=e.require("dom"),c=e.require("delta"),f=e.require("range"),d=function(a){function b(a,c){this.quill=a,this.options=c,this.options=h.defaults(this.options,g.DEFAULTS),b.__super__.constructor.call(this,this.quill,this.options),this.preview=this.container.querySelector(".preview"),this.textbox=this.container.querySelector(".input"),i(this.container).addClass("ql-image-tooltip"),this.initListeners()}return j(b,a),b.DEFAULTS={template:' Preview
Cancel Insert'},b.prototype.initListeners=function(){return i(this.container.querySelector(".insert")).on("click",h.bind(this.insertImage,this)),i(this.container.querySelector(".cancel")).on("click",h.bind(this.hide,this)),i(this.textbox).on("input",h.bind(this._preview,this)),this.initTextbox(this.textbox,this.insertImage,this.hide),this.quill.onModuleLoad("toolbar",function(a){return function(b){return b.initFormat("image",h.bind(a._onToolbar,a))}}(this))},b.prototype.insertImage=function(){var a,b;return b=this._normalizeURL(this.textbox.value),null==this.range&&(this.range=new f(0,0)),this.range&&(this.preview.innerHTML="Preview",this.textbox.value="",a=this.range.end,this.quill.insertEmbed(a,"image",b,"user"),this.quill.setSelection(a+1,a+1)),this.hide()},b.prototype._onToolbar=function(a,b){return b?(this.textbox.value||(this.textbox.value="http://"),this.show(),this.textbox.focus(),h.defer(function(a){return function(){return a.textbox.setSelectionRange(a.textbox.value.length,a.textbox.value.length)}}(this))):this.quill.deleteText(a,"user")},b.prototype._preview=function(){var a;if(this._matchImageURL(this.textbox.value))return"IMG"===this.preview.firstChild.tagName?this.preview.firstChild.setAttribute("src",this.textbox.value):(a=document.createElement("img"),a.setAttribute("src",this.textbox.value),this.preview.replaceChild(a,this.preview.firstChild))},b.prototype._matchImageURL=function(a){return/^https?:\/\/.+\.(jpe?g|gif|png)$/.test(a)},b.prototype._normalizeURL=function(a){return/^https?:\/\//.test(a)||(a="http://"+a),a},b}(g),e.registerModule("image-tooltip",d),b.exports=d},{"../quill":30,"./tooltip":28}],23:[function(a,b){var c,d,e,f,g;e=a("../quill"),f=e.require("lodash"),g=e.require("dom"),c=e.require("delta"),d=function(){function a(a){this.quill=a,this.hotkeys={},this._initListeners(),this._initHotkeys(),this._initDeletes()}return a.hotkeys={BOLD:{key:"B",metaKey:!0},INDENT:{key:g.KEYS.TAB},ITALIC:{key:"I",metaKey:!0},OUTDENT:{key:g.KEYS.TAB,shiftKey:!0},UNDERLINE:{key:"U",metaKey:!0}},a.prototype.addHotkey=function(a,b){return Array.isArray(a)||(a=[a]),f.each(a,function(a){return function(c){var d,e;return c=f.isObject(c)?f.clone(c):{key:c},c.callback=b,e=f.isNumber(c.key)?c.key:c.key.toUpperCase().charCodeAt(0),null==(d=a.hotkeys)[e]&&(d[e]=[]),a.hotkeys[e].push(c)}}(this))},a.prototype.toggleFormat=function(a,b){var c,d,g;return c=a.isCollapsed()?this.quill.getContents(Math.max(0,a.start-1),a.end):this.quill.getContents(a),g=0===c.ops.length||!f.all(c.ops,function(a){var c;return null!=(c=a.attributes)?c[b]:void 0}),a.isCollapsed()?this.quill.prepareFormat(b,g,e.sources.USER):this.quill.formatText(a,b,g,e.sources.USER),d=this.quill.getModule("toolbar"),null!=d?d.setActive(b,g):void 0},a.prototype._initDeletes=function(){return this.addHotkey([g.KEYS.DELETE,g.KEYS.BACKSPACE],function(a){return function(b,c){var d,f,h,i;return null!=b&&a.quill.getLength()>0&&(b.start!==b.end?a.quill.deleteText(b.start,b.end,e.sources.USER):c.key===g.KEYS.BACKSPACE?(i=a.quill.editor.doc.findLineAt(b.start),f=i[0],h=i[1],0===h&&(f.formats.bullet||f.formats.list)?(d=f.format.bullet?"bullet":"list",a.quill.formatLine(b.start,b.start,d,!1)):b.start>0&&a.quill.deleteText(b.start-1,b.start,e.sources.USER)):b.startVisit URL: - Change Remove Done'},b.hotkeys={LINK:{key:"K",metaKey:!0}},b.prototype.initListeners=function(){return this.quill.on(this.quill.constructor.events.SELECTION_CHANGE,function(a){return function(b){var c;if(null!=b&&b.isCollapsed())return c=a._findAnchor(b),c?(a.setMode(c.href,!1),a.show(c)):(a.range=null,a.hide())}}(this)),g(this.container.querySelector(".done")).on("click",f.bind(this.saveLink,this)),g(this.container.querySelector(".remove")).on("click",function(a){return function(){return a.removeLink(a.range)}}(this)),g(this.container.querySelector(".change")).on("click",function(a){return function(){return a.setMode(a.link.href,!0)}}(this)),this.initTextbox(this.textbox,this.saveLink,this.hide),this.quill.onModuleLoad("toolbar",function(a){return function(b){return a.toolbar=b,b.initFormat("link",f.bind(a._onToolbar,a))}}(this)),this.quill.onModuleLoad("keyboard",function(a){return function(c){return c.addHotkey(b.hotkeys.LINK,f.bind(a._onKeyboard,a))}}(this))},b.prototype.saveLink=function(){var a,b;return b=this._normalizeURL(this.textbox.value),null!=this.range&&(this.range.isCollapsed()?(a=this._findAnchor(this.range),null!=a&&(a.href=b)):this.quill.formatText(this.range,"link",b,"user")),this.setMode(b,!1)},b.prototype.removeLink=function(a){return a.isCollapsed()&&(a=this._expandRange(a)),this.quill.formatText(a,"link",!1,"user"),null!=this.toolbar?this.toolbar.setActive("link",!1):void 0},b.prototype.setMode=function(a,b){var c;return null==b&&(b=!1),b?(this.textbox.value=a,f.defer(function(b){return function(){return b.textbox.focus(),b.textbox.setSelectionRange(a.length,a.length)}}(this))):(this.link.href=a,c=a.length>this.options.maxLength?a.slice(0,this.options.maxLength)+"...":a,g(this.link).text(c)),g(this.container).toggleClass("editing",b)},b.prototype._findAnchor=function(a){var b,c,d,e;for(e=this.quill.editor.doc.findLeafAt(a.start,!0),b=e[0],d=e[1],null!=b&&(c=b.node);null!=c;){if("A"===c.tagName)return c;c=c.parentNode}return null},b.prototype._expandRange=function(a){var b,c,d,e,f;return e=this.quill.editor.doc.findLeafAt(a.start,!0),c=e[0],d=e[1],f=a.start-d,b=f+c.length,{start:f,end:b}},b.prototype._onToolbar=function(a,b){return this._toggle(a,b)},b.prototype._onKeyboard=function(){var a;return a=this.quill.getSelection(),this._toggle(a,!0)},b.prototype._toggle=function(a,b){var c;if(a)return b&&!a.isCollapsed()?(this.setMode(this._suggestURL(a),!0),c=this.quill.editor.selection._getNativeRange(),this.show(c)):this.removeLink(a)},b.prototype._normalizeURL=function(a){return/^(https?:\/\/|mailto:)/.test(a)||(a="http://"+a),a},b.prototype._suggestURL=function(a){var b;return b=this.quill.getText(a),this._normalizeURL(b)},b}(e),d.registerModule("link-tooltip",c),b.exports=c},{"../quill":30,"./tooltip":28}],25:[function(a,b){var c,d,e,f,g,h=function(a,b){function c(){this.constructor=a}for(var d in b)i.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},i={}.hasOwnProperty;e=a("../quill"),c=a("eventemitter2").EventEmitter2,f=e.require("lodash"),g=e.require("dom"),d=function(a){function b(a,b){this.quill=a,this.options=b,this.cursors={},this.container=this.quill.addContainer("ql-multi-cursor",!0),this.quill.on(this.quill.constructor.events.TEXT_CHANGE,f.bind(this._applyDelta,this))}return h(b,a),b.DEFAULTS={template:' ',timeout:2500},b.events={CURSOR_ADDED:"cursor-addded",CURSOR_MOVED:"cursor-moved",CURSOR_REMOVED:"cursor-removed"},b.prototype.clearCursors=function(){return f.each(Object.keys(this.cursors),f.bind(this.removeCursor,this)),this.cursors={}},b.prototype.moveCursor=function(a,b){var c;return c=this.cursors[a],c.index=b,g(c.elem).removeClass("hidden"),clearTimeout(c.timer),c.timer=setTimeout(function(){return function(){return g(c.elem).addClass("hidden"),c.timer=null}}(this),this.options.timeout),this._updateCursor(c),c},b.prototype.removeCursor=function(a){var c;return c=this.cursors[a],this.emit(b.events.CURSOR_REMOVED,c),null!=c&&c.elem.parentNode.removeChild(c.elem),delete this.cursors[a]},b.prototype.setCursor=function(a,c,d,e){var g;return null==this.cursors[a]&&(this.cursors[a]=g={userId:a,index:c,color:e,elem:this._buildCursor(d,e)},this.emit(b.events.CURSOR_ADDED,g)),f.defer(function(b){return function(){return b.moveCursor(a,c)}}(this)),this.cursors[a]},b.prototype.shiftCursors=function(a,b,c){return null==c&&(c=null),f.each(this.cursors,function(){return function(d){return d&&(d.index>a||d.userId===c)?d.index+=Math.max(b,a-d.index):void 0}}(this))},b.prototype.update=function(){return f.each(this.cursors,function(a){return function(b){return null!=b?(a._updateCursor(b),!0):void 0}}(this))},b.prototype._applyDelta=function(a){var b;return b=0,f.each(a.ops,function(a){return function(c){var d,e;return d=0,null!=c.insert?(d=c.insert.length||1,a.shiftCursors(b,d,null!=(e=c.attributes)?e.author:void 0)):null!=c["delete"]?a.shiftCursors(b,-1*c["delete"],null):null!=c.retain&&(a.shiftCursors(b,0,null),d=c.retain),b+=d}}(this)),this.update()},b.prototype._buildCursor=function(a,b){var c,d,e,f;return c=document.createElement("span"),g(c).addClass("cursor"),c.innerHTML=this.options.template,e=c.querySelector(".cursor-flag"),f=c.querySelector(".cursor-name"),g(f).text(a),d=c.querySelector(".cursor-caret"),d.style.backgroundColor=f.style.backgroundColor=b,this.container.appendChild(c),c},b.prototype._updateCursor=function(a){var c,d;return c=this.quill.getBounds(a.index),a.elem.style.top=c.top-this.quill.container.scrollTop+"px",a.elem.style.left=c.left+"px",a.elem.style.height=c.height+"px",d=a.elem.querySelector(".cursor-flag"),g(a.elem).toggleClass("top",parseInt(a.elem.style.top)<=d.offsetHeight).toggleClass("left",parseInt(a.elem.style.left)<=d.offsetWidth).toggleClass("right",this.quill.root.offsetWidth-parseInt(a.elem.style.left)<=d.offsetWidth),this.emit(b.events.CURSOR_MOVED,a)},b}(c),e.registerModule("multi-cursor",d),b.exports=d},{"../quill":30,eventemitter2:2}],26:[function(a,b){var c,d,e,f,g,h;f=a("../quill"),d=a("../core/document"),g=f.require("lodash"),h=f.require("dom"),c=f.require("delta"),e=function(){function a(a,b){this.quill=a,this.options=b,this.container=this.quill.addContainer("ql-paste-manager"),this.container.setAttribute("contenteditable",!0),h(this.quill.root).on("paste",g.bind(this._paste,this))}return a.prototype._paste=function(){var a,b;return a=this.quill.getLength(),b=this.quill.getSelection(),null!=b?(this.container.focus(),g.defer(function(a){return function(){var e,f,g,h,i,j,k,l;return f=new d(a.container,a.quill.options),e=f.toDelta(),g=e.length()-1,e.compose((new c).retain(g)["delete"](1)),b.start>0&&e.ops.unshift({retain:b.start}),e["delete"](b.end-b.start),a.quill.updateContents(e,"user"),a.quill.setSelection(b.start+g,b.start+g),k=a.quill.editor.doc.findLineAt(b.start+g),h=k[0],j=k[1],i=h.node.getBoundingClientRect().bottom,l=document.documentElement.clientHeight,i>l&&h.node.scrollIntoView(!1),a.container.innerHTML=""}}(this))):void 0},a}(),f.registerModule("paste-manager",e),b.exports=e},{"../core/document":8,"../quill":30}],27:[function(a,b){var c,d,e,f;c=a("../quill"),e=c.require("lodash"),f=c.require("dom"),d=function(){function a(b,c){if(this.quill=b,this.options=c,(e.isString(this.options)||e.isElement(this.options))&&(this.options={container:this.options}),null==this.options.container)throw new Error("container required for toolbar",this.options);this.container=e.isString(this.options.container)?document.querySelector(this.options.container):this.options.container,this.inputs={},this.preventUpdate=!1,this.triggering=!1,e.each(this.quill.options.formats,function(b){return function(c){return null==a.formats.TOOLTIP[c]?b.initFormat(c,function(d,f){return b.triggering?void 0:(d.isCollapsed()?b.quill.prepareFormat(c,f,"user"):null!=a.formats.LINE[c]?b.quill.formatLine(d,c,f,"user"):b.quill.formatText(d,c,f,"user"),e.defer(function(){return b.updateActive(d,["bullet","list"]),b.setActive(c,f)}))}):void 0}}(this)),this.quill.on(this.quill.constructor.events.SELECTION_CHANGE,function(a){return function(b){return null!=b?a.updateActive(b):void 0}}(this)),this.quill.onModuleLoad("keyboard",function(a){return function(b){return b.addHotkey([f.KEYS.BACKSPACE,f.KEYS.DELETE,f.KEYS.ENTER],function(){return e.defer(e.bind(a.updateActive,a))})}}(this)),f(this.container).addClass("ql-toolbar"),f.isIOS()&&f(this.container).addClass("ios"),f.isIE(11)&&f(this.container).on("mousedown",function(){return function(){return!1}}(this))}return a.DEFAULTS={container:null},a.formats={LINE:{align:"align",bullet:"bullet",list:"list"},SELECT:{align:"align",background:"background",color:"color",font:"font",size:"size"},TOGGLE:{bold:"bold",bullet:"bullet",image:"image",italic:"italic",link:"link",list:"list",strike:"strike",underline:"underline"},TOOLTIP:{image:"image",link:"link"}},a.prototype.initFormat=function(b,c){var d,e,g;return g=".ql-"+b,null!=a.formats.SELECT[b]?(g="select"+g,d="change"):d="click",e=this.container.querySelector(g),null!=e?(this.inputs[b]=e,f(e).on(d,function(a){return function(){var b,g;return g="change"===d?f(e).value():!f(e).hasClass("ql-active"),a.preventUpdate=!0,a.quill.focus(),b=a.quill.getSelection(),null!=b&&c(b,g),a.preventUpdate=!1,!0}}(this))):void 0},a.prototype.setActive=function(a,b){var c,d,e,g;return d=this.inputs[a],null!=d?(c=f(d),"SELECT"===d.tagName?(this.triggering=!0,g=c.value(d),null==b&&(b=null!=(e=c["default"]())?e.value:void 0),Array.isArray(b)&&(b=""),b!==g&&(null!=b?c.option(b):c.reset()),this.triggering=!1):c.toggleClass("ql-active",b||!1)):void 0},a.prototype.updateActive=function(a,b){var c;return null==b&&(b=null),a||(a=this.quill.getSelection()),null==a||this.preventUpdate?void 0:(c=this._getActive(a),e.each(this.inputs,function(a){return function(d,e){return(!Array.isArray(b)||b.indexOf(e)>-1)&&a.setActive(e,c[e]),!0}}(this)))},a.prototype._getActive=function(a){var b,c;return b=this._getLeafActive(a),c=this._getLineActive(a),e.defaults({},b,c)},a.prototype._getLeafActive=function(a){var b,c,d,f,g;return a.isCollapsed()?(g=this.quill.editor.doc.findLineAt(a.start),d=g[0],f=g[1],b=0===f?this.quill.getContents(a.start,a.end+1):this.quill.getContents(a.start-1,a.end)):b=this.quill.getContents(a),c=e.map(b.ops,"attributes"),this._intersectFormats(c)},a.prototype._getLineActive=function(a){var b,c,d,f,g,h;for(c=[],g=this.quill.editor.doc.findLineAt(a.start),b=g[0],f=g[1],h=this.quill.editor.doc.findLineAt(a.end),d=h[0],f=h[1],null!=d&&d===b&&(d=d.next);null!=b&&b!==d;)c.push(e.clone(b.formats)),b=b.next;return this._intersectFormats(c)},a.prototype._intersectFormats=function(b){return e.reduce(b.slice(1),function(b,c){var d,f,g,h,i;return null==c&&(c={}),d=Object.keys(b),g=null!=c?Object.keys(c):{},h=e.intersection(d,g),i=e.difference(d,g),f=e.difference(g,d),e.each(h,function(d){if(null!=a.formats.SELECT[d])if(Array.isArray(b[d])){if(b[d].indexOf(c[d])<0)return b[d].push(c[d])}else if(b[d]!==c[d])return b[d]=[b[d],c[d]]}),e.each(i,function(c){return null!=a.formats.TOGGLE[c]?delete b[c]:null==a.formats.SELECT[c]||Array.isArray(b[c])?void 0:b[c]=[b[c]]}),e.each(f,function(d){return null!=a.formats.SELECT[d]?b[d]=[c[d]]:void 0}),b},b[0]||{})},a}(),c.registerModule("toolbar",d),b.exports=d},{"../quill":30}],28:[function(a,b){var c,d,e,f,g;d=a("../quill"),f=d.require("lodash"),g=d.require("dom"),c=d.require("normalizer"),e=function(){function a(b,d){this.quill=b,this.options=d,this.container=this.quill.addContainer("ql-tooltip"),this.container.innerHTML=c.stripWhitespace(this.options.template),g(this.quill.root).on("focus",f.bind(this.hide,this)),this.hide(),this.quill.on(this.quill.constructor.events.TEXT_CHANGE,function(b){return function(c,d){return"user"===d&&b.container.style.left!==a.HIDE_MARGIN?(b.range=null,
+c=d=0,f=g.length;f>d;c=++d)h=g[c],b=this.node.attributes[c],a[b.name]=b.value;return a},a.prototype.child=function(a){var b,c;for(b=this.node.firstChild,c=f(b).length();null!=b&&!(c>a);)a-=c,b=b.nextSibling,c=f(b).length();return null==b&&(b=this.node.lastChild,a=f(b).length()),[b,a]},a.prototype.childNodes=function(){return e.map(this.node.childNodes)},a.prototype.classes=function(){return this.node.className.split(/\s+/)},a.prototype.descendants=function(){return e.map(this.node.getElementsByTagName("*"))},a.prototype.get=function(){return this.node},a.prototype.hasClass=function(a){return null!=this.node.classList?this.node.classList.contains(a):null!=this.node.className?this.classes().indexOf(a)>-1:!1},a.prototype.isAncestor=function(a,b){var c;if(null==b&&(b=!1),a===this.node)return b;for(c=this.node;c;){if(c===a)return!0;c=c.parentNode}return!1},a.prototype.isElement=function(){var a;return(null!=(a=this.node)?a.nodeType:void 0)===f.ELEMENT_NODE},a.prototype.isTextNode=function(){var a;return(null!=(a=this.node)?a.nodeType:void 0)===f.TEXT_NODE},a.prototype.isolate=function(a){return null!=this.node.nextSibling&&f(this.node.nextSibling).splitBefore(a),this.splitBefore(a),this},a.prototype.length=function(){var a;return null==this.node?0:(a=this.text().length,this.isElement()&&(a+=this.node.querySelectorAll(Object.keys(f.EMBED_TAGS).join(",")).length),a)},a.prototype.merge=function(a){var b;return b=f(a),this.isElement()?(b.moveChildren(this.node),this.normalize()):this.text(this.text()+b.text()),b.remove(),this},a.prototype.moveChildren=function(a){return e.each(this.childNodes(),function(b){return a.appendChild(b)}),this},a.prototype.nextLineNode=function(a){var b;return b=this.node.nextSibling,null==b&&this.node.parentNode!==a&&(b=this.node.parentNode.nextSibling),null!=b&&null!=f.LIST_TAGS[b.tagName]&&(b=b.firstChild),b},a.prototype.normalize=function(){var a,b,c,d;for(b=this.node.firstChild;null!=b;)d=b.nextSibling,a=f(b),null!=d&&f(d).isTextNode()&&(0===a.text().length?a.remove():a.isTextNode()&&(c=d.nextSibling,a.merge(d),d=c)),b=d;return this},a.prototype.on=function(a,b){return this.node.addEventListener(a,function(c){return function(d){var e,f;return e=!g||"keydown"!==a&&"keyup"!==a?d:g,f=b.call(c.node,e),f||(d.preventDefault(),d.stopPropagation()),f}}(this)),this},a.prototype.remove=function(){var a;return null!=(a=this.node.parentNode)&&a.removeChild(this.node),this.node=null,null},a.prototype.removeClass=function(a){var b;if(this.hasClass(a))return null!=this.node.classList?this.node.classList.remove(a):null!=this.node.className&&(b=this.classes(),b.splice(b.indexOf(a),1),this.node.className=b.join(" ")),this.node.getAttribute("class")||this.node.removeAttribute("class"),this},a.prototype.replace=function(a){return this.node.parentNode.replaceChild(a,this.node),this.node=a,a},a.prototype.splitBefore=function(a,b){var c,d,e,g;if(null==b&&(b=!1),this.node===a||this.node.parentNode===a)return this;if(null!=this.node.previousSibling||b){for(e=this.node.parentNode,d=e.cloneNode(!1),e.parentNode.insertBefore(d,e.nextSibling),g=this.node;null!=g;)c=g.nextSibling,d.appendChild(g),g=c;return f(d).splitBefore(a)}return f(this.node.parentNode).splitBefore(a)},a.prototype.split=function(a,b){var c,d,e,g,h,i,j,k,l,m;if(null==b&&(b=!1),j=this.length(),a=Math.max(0,a),a=Math.min(a,j),!b&&0===a)return[this.node.previousSibling,this.node,!1];if(!b&&a===j)return[this.node,this.node.nextSibling,!1];if(this.node.nodeType===f.TEXT_NODE)return c=this.node.splitText(a),[this.node,c,!0];for(h=this.node,m=this.node.cloneNode(!1),this.node.parentNode.insertBefore(m,h.nextSibling),k=this.child(a),d=k[0],a=k[1],l=f(d).split(a),e=l[0],g=l[1];null!==g;)i=g.nextSibling,m.appendChild(g),g=i;return[h,m,!0]},a.prototype.styles=function(a,b){var c,d;return null==b&&(b=!1),a?(b||(a=e.defaults(a,this.styles())),d=e.map(a,function(a,b){return b+": "+a}).join("; ")+";",this.node.setAttribute("style",d),this):(d=this.node.getAttribute("style")||"",c=e.reduce(d.split(";"),function(a,b){var c,d,e;return d=b.split(":"),c=d[0],e=d[1],c&&e&&(c=c.trim(),e=e.trim(),a[c.toLowerCase()]=e),a},{}))},a.prototype.switchTag=function(a){var b,c;return a=a.toUpperCase(),this.node.tagName===a?this:(c=document.createElement(a),b=this.attributes(),null==f.VOID_TAGS[a]&&this.moveChildren(c),this.replace(c),this.attributes(b).get())},a.prototype.text=function(a){if(null!=a){switch(this.node.nodeType){case f.ELEMENT_NODE:this.node.textContent=a;break;case f.TEXT_NODE:this.node.data=a}return this}switch(this.node.nodeType){case f.ELEMENT_NODE:return this.node.tagName===f.DEFAULT_BREAK_TAG?"":null!=f.EMBED_TAGS[this.node.tagName]?f.EMBED_TEXT:null!=this.node.textContent?this.node.textContent:"";case f.TEXT_NODE:return this.node.data||"";default:return""}},a.prototype.textNodes=function(){var a,b,c;for(c=document.createTreeWalker(this.node,NodeFilter.SHOW_TEXT,null,!1),b=[];a=c.nextNode();)b.push(a);return b},a.prototype.toggleClass=function(a,b){return null==b&&(b=!this.hasClass(a)),b?this.addClass(a):this.removeClass(a),this},a.prototype.trigger=function(a,b){var c,d,h;return null==b&&(b={}),["keypress","keydown","keyup"].indexOf(a)<0?(c=document.createEvent("Event"),c.initEvent(a,b.bubbles,b.cancelable)):(c=document.createEvent("KeyboardEvent"),g=e.clone(b),g.which=e.isNumber(b.key)?b.key:e.isString(b.key)?b.key.toUpperCase().charCodeAt(0):0,f.isIE(10)?(h=[],b.altKey&&h.push("Alt"),b.ctrlKey&&h.push("Control"),b.metaKey&&h.push("Meta"),b.shiftKey&&h.push("Shift"),c.initKeyboardEvent(a,b.bubbles,b.cancelable,window,0,0,h.join(" "),null,null)):(d=e.isFunction(c.initKeyboardEvent)?"initKeyboardEvent":"initKeyEvent",c[d](a,b.bubbles,b.cancelable,window,b.ctrlKey,b.altKey,b.shiftKey,b.metaKey,0,0))),this.node.dispatchEvent(c),g=null,this},a.prototype.unwrap=function(){var a,b;return b=this.node.firstChild,a=this.node.nextSibling,e.each(this.childNodes(),function(b){return function(c){return b.node.parentNode.insertBefore(c,a)}}(this)),this.remove(),b},a.prototype.wrap=function(a){var b;for(null!=this.node.parentNode&&this.node.parentNode.insertBefore(a,this.node),b=a;null!=b.firstChild;)b=a.firstChild;return b.appendChild(this.node),this},a}(),c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return i(b,a),b.prototype["default"]=function(){return this.node.querySelector("option[selected]")},b.prototype.option=function(a,b){var c,d,f,g,h,i;if(null==b&&(b=!0),i=e.isElement(a)?a.value:a){for(i=i.replace(/[^\w]+/g,""),h=this.node.children,d=f=0,g=h.length;g>f;d=++f)if(c=h[d],c.value.replace(/[^\w]+/g,"")===i){this.node.selectedIndex=d;break}}else this.node.selectedIndex=-1;return b&&this.trigger("change"),this},b.prototype.reset=function(a){var b;return null==a&&(a=!0),b=this["default"](),null!=b?b.selected=!0:this.node.selectedIndex=0,a&&this.trigger("change"),this},b.prototype.value=function(){return this.node.selectedIndex>-1?this.node.options[this.node.selectedIndex].value:""},b}(d),f=function(a){return"SELECT"===(null!=a?a.tagName:void 0)?new c(a):new d(a)},f=e.extend(f,{ELEMENT_NODE:1,NOBREAK_SPACE:" ",TEXT_NODE:3,ZERO_WIDTH_NOBREAK_SPACE:"\ufeff",DEFAULT_BLOCK_TAG:"P",DEFAULT_BREAK_TAG:"BR",DEFAULT_INLINE_TAG:"SPAN",EMBED_TEXT:"!",FONT_SIZES:{"10px":1,"13px":2,"16px":3,"18px":4,"24px":5,"32px":6,"48px":7},KEYS:{BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46},BLOCK_TAGS:{ADDRESS:"ADDRESS",ARTICLE:"ARTICLE",ASIDE:"ASIDE",AUDIO:"AUDIO",BLOCKQUOTE:"BLOCKQUOTE",CANVAS:"CANVAS",DD:"DD",DIV:"DIV",DL:"DL",FIGCAPTION:"FIGCAPTION",FIGURE:"FIGURE",FOOTER:"FOOTER",FORM:"FORM",H1:"H1",H2:"H2",H3:"H3",H4:"H4",H5:"H5",H6:"H6",HEADER:"HEADER",HGROUP:"HGROUP",LI:"LI",OL:"OL",OUTPUT:"OUTPUT",P:"P",PRE:"PRE",SECTION:"SECTION",TABLE:"TABLE",TBODY:"TBODY",TD:"TD",TFOOT:"TFOOT",TH:"TH",THEAD:"THEAD",TR:"TR",UL:"UL",VIDEO:"VIDEO"},EMBED_TAGS:{IMG:"IMG"},LINE_TAGS:{DIV:"DIV",LI:"LI"},LIST_TAGS:{OL:"OL",UL:"UL"},VOID_TAGS:{AREA:"AREA",BASE:"BASE",BR:"BR",COL:"COL",COMMAND:"COMMAND",EMBED:"EMBED",HR:"HR",IMG:"IMG",INPUT:"INPUT",KEYGEN:"KEYGEN",LINK:"LINK",META:"META",PARAM:"PARAM",SOURCE:"SOURCE",TRACK:"TRACK",WBR:"WBR"},convertFontSize:function(a){var b,c,d,g;e.isString(a)&&a.indexOf("px")>-1?(d=Object.keys(f.FONT_SIZES),g=e.values(f.FONT_SIZES)):(g=Object.keys(f.FONT_SIZES),d=e.values(f.FONT_SIZES));for(b in d)if(c=d[b],parseInt(a)<=parseInt(c))return g[b];return e.last(g)},isIE:function(a){var b;return b=document.documentMode,b&&a>=b},isIOS:function(){return/iPhone|iPad/i.test(navigator.userAgent)},isMac:function(){return/Mac/i.test(navigator.platform)}}),b.exports=f},{lodash:1}],18:[function(a,b){var c,d;d=function(){function a(a){this.data=a,this.prev=this.next=null}return a}(),c=function(){function a(){this.length=0,this.first=this.last=null}return a.Node=d,a.prototype.append=function(a){return null!=this.first?(a.next=null,this.last.next=a):this.first=a,a.prev=this.last,this.last=a,this.length+=1},a.prototype.insertAfter=function(a,b){return b.prev=a,null!=a?(b.next=a.next,null!=a.next&&(a.next.prev=b),a.next=b,a===this.last&&(this.last=b)):(b.next=this.first,this.first.prev=b,this.first=b),this.length+=1},a.prototype.remove=function(a){return this.length>1?(null!=a.prev&&(a.prev.next=a.next),null!=a.next&&(a.next.prev=a.prev),a===this.first&&(this.first=a.next),a===this.last&&(this.last=a.prev)):this.first=this.last=null,a.prev=a.next=null,this.length-=1},a.prototype.toArray=function(){var a,b;for(a=[],b=this.first;null!=b;)a.push(b),b=b.next;return a},a}(),b.exports=c},{}],19:[function(a,b){var c,d,e,f;e=a("lodash"),f=a("./dom"),c=a("../core/normalizer"),d=function(){function a(a){this.select=a,this.container=document.createElement("span"),this.buildPicker(),f(this.container).addClass("ql-picker"),this.select.style.display="none",this.select.parentNode.insertBefore(this.container,this.select),f(document).on("click",function(a){return function(){return a.close(),!0}}(this)),f(this.label).on("click",function(a){return function(){return e.defer(function(){return f(a.container).toggleClass("ql-expanded")}),!1}}(this)),f(this.select).on("change",function(a){return function(){var b,c;return a.select.selectedIndex>-1&&(b=a.container.querySelectorAll(".ql-picker-item")[a.select.selectedIndex],c=a.select.options[a.select.selectedIndex]),a.selectItem(b,!1),f(a.label).toggleClass("ql-active",c!==f(a.select)["default"]())}}(this))}return a.TEMPLATE='',a.prototype.buildItem=function(a,b,c){var d;return d=document.createElement("span"),d.setAttribute("data-value",b.getAttribute("value")),f(d).addClass("ql-picker-item").text(f(b).text()).on("click",function(a){return function(){return a.selectItem(d,!0),a.close()}}(this)),this.select.selectedIndex===c&&this.selectItem(d,!1),d},a.prototype.buildPicker=function(){var b;return e.each(f(this.select).attributes(),function(a){return function(b,c){return a.container.setAttribute(c,b)}}(this)),this.container.innerHTML=c.stripWhitespace(a.TEMPLATE),this.label=this.container.querySelector(".ql-picker-label"),b=this.container.querySelector(".ql-picker-options"),e.each(this.select.options,function(a){return function(c,d){var e;return e=a.buildItem(b,c,d),b.appendChild(e)}}(this))},a.prototype.close=function(){return f(this.container).removeClass("ql-expanded")},a.prototype.selectItem=function(a,b){var c,d;return c=this.container.querySelector(".ql-selected"),null!=c&&f(c).removeClass("ql-selected"),null!=a?(d=a.getAttribute("data-value"),f(a).addClass("ql-selected"),f(this.label).text(f(a).text()),f(this.select).option(d,b),this.label.setAttribute("data-value",d)):(this.label.innerHTML=" ",this.label.removeAttribute("data-value"))},a}(),b.exports=d},{"../core/normalizer":13,"./dom":17,lodash:1}],20:[function(a,b){var c,d;d=a("lodash"),c=function(){function a(a,b){this.start=a,this.end=b}return a.compare=function(a,b){return a===b?!0:null==a||null==b?!1:a.equals(b)},a.prototype.equals=function(a){return null==a?!1:this.start===a.start&&this.end===a.end},a.prototype.shift=function(a,b){var c;return c=d.map([this.start,this.end],function(c){return a>c?c:b>=0?c+b:Math.max(a,c+b)}),this.start=c[0],this.end=c[1],c},a.prototype.isCollapsed=function(){return this.start===this.end},a}(),b.exports=c},{lodash:1}],21:[function(a,b){var c,d,e,f,g;e=a("../quill"),f=e.require("lodash"),g=e.require("dom"),d=e.require("delta"),c=function(){function a(a,b){this.quill=a,this.options=b,null!=this.options.button&&this.attachButton(this.options.button),this.options.enabled&&this.enable(),this.quill.addFormat("author",{"class":"author-"}),null!=this.options.authorId&&(this.quill.on(this.quill.constructor.events.PRE_EVENT,function(a){return function(b,c,g){var h,i;return b===a.quill.constructor.events.TEXT_CHANGE&&"user"===g?(h=new d,i={author:a.options.authorId},f.each(c.ops,function(b){return null==b["delete"]?null!=b.insert||null!=b.retain&&null!=b.attributes?(b.attributes||(b.attributes={}),b.attributes.author=a.options.authorId,h.retain(b.retain||b.insert.length||1,i)):h.retain(b.retain):void 0}),a.quill.updateContents(h,e.sources.SILENT)):void 0}}(this)),this.addAuthor(this.options.authorId,this.options.color))}return a.DEFAULTS={authorId:null,color:"transparent",enabled:!1},a.prototype.addAuthor=function(a,b){var c;return c={},c[".authorship .author-"+a]={"background-color":""+b},this.quill.theme.addStyles(c)},a.prototype.attachButton=function(a){var b;return b=g(a),b.on("click",function(a){return function(){return b.toggleClass("ql-on"),a.enable($dom.hasClass("ql-on"))}}(this))},a.prototype.enable=function(a){return null==a&&(a=!0),g(this.quill.root).toggleClass("authorship",a)},a.prototype.disable=function(){return this.enable(!1)},a}(),e.registerModule("authorship",c),b.exports=c},{"../quill":30}],22:[function(a,b){var c,d,e,f,g,h,i,j=function(a,b){function c(){this.constructor=a}for(var d in b)k.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},k={}.hasOwnProperty;e=a("../quill"),g=a("./tooltip"),h=e.require("lodash"),i=e.require("dom"),c=e.require("delta"),f=e.require("range"),d=function(a){function b(a,c){this.quill=a,this.options=c,this.options=h.defaults(this.options,g.DEFAULTS),b.__super__.constructor.call(this,this.quill,this.options),this.preview=this.container.querySelector(".preview"),this.textbox=this.container.querySelector(".input"),i(this.container).addClass("ql-image-tooltip"),this.initListeners()}return j(b,a),b.DEFAULTS={template:' Preview
Cancel Insert'},b.prototype.initListeners=function(){return i(this.container.querySelector(".insert")).on("click",h.bind(this.insertImage,this)),i(this.container.querySelector(".cancel")).on("click",h.bind(this.hide,this)),i(this.textbox).on("input",h.bind(this._preview,this)),this.initTextbox(this.textbox,this.insertImage,this.hide),this.quill.onModuleLoad("toolbar",function(a){return function(b){return b.initFormat("image",h.bind(a._onToolbar,a))}}(this))},b.prototype.insertImage=function(){var a,b;return b=this._normalizeURL(this.textbox.value),null==this.range&&(this.range=new f(0,0)),this.range&&(this.preview.innerHTML="Preview",this.textbox.value="",a=this.range.end,this.quill.insertEmbed(a,"image",b,"user"),this.quill.setSelection(a+1,a+1)),this.hide()},b.prototype._onToolbar=function(a,b){return b?(this.textbox.value||(this.textbox.value="http://"),this.show(),this.textbox.focus(),h.defer(function(a){return function(){return a.textbox.setSelectionRange(a.textbox.value.length,a.textbox.value.length)}}(this))):this.quill.deleteText(a,"user")},b.prototype._preview=function(){var a;if(this._matchImageURL(this.textbox.value))return"IMG"===this.preview.firstChild.tagName?this.preview.firstChild.setAttribute("src",this.textbox.value):(a=document.createElement("img"),a.setAttribute("src",this.textbox.value),this.preview.replaceChild(a,this.preview.firstChild))},b.prototype._matchImageURL=function(a){return/^https?:\/\/.+\.(jpe?g|gif|png)$/.test(a)},b.prototype._normalizeURL=function(a){return/^https?:\/\//.test(a)||(a="http://"+a),a},b}(g),e.registerModule("image-tooltip",d),b.exports=d},{"../quill":30,"./tooltip":28}],23:[function(a,b){var c,d,e,f,g;e=a("../quill"),f=e.require("lodash"),g=e.require("dom"),c=e.require("delta"),d=function(){function a(a){this.quill=a,this.hotkeys={},this._initListeners(),this._initHotkeys(),this._initDeletes()}return a.hotkeys={BOLD:{key:"B",metaKey:!0},INDENT:{key:g.KEYS.TAB},ITALIC:{key:"I",metaKey:!0},OUTDENT:{key:g.KEYS.TAB,shiftKey:!0},UNDERLINE:{key:"U",metaKey:!0}},a.prototype.addHotkey=function(a,b){return Array.isArray(a)||(a=[a]),f.each(a,function(a){return function(c){var d,e;return c=f.isObject(c)?f.clone(c):{key:c},c.callback=b,e=f.isNumber(c.key)?c.key:c.key.toUpperCase().charCodeAt(0),null==(d=a.hotkeys)[e]&&(d[e]=[]),a.hotkeys[e].push(c)}}(this))},a.prototype.toggleFormat=function(a,b){var c,d,g;return c=a.isCollapsed()?this.quill.getContents(Math.max(0,a.start-1),a.end):this.quill.getContents(a),g=0===c.ops.length||!f.all(c.ops,function(a){var c;return null!=(c=a.attributes)?c[b]:void 0}),a.isCollapsed()?this.quill.prepareFormat(b,g,e.sources.USER):this.quill.formatText(a,b,g,e.sources.USER),d=this.quill.getModule("toolbar"),null!=d?d.setActive(b,g):void 0},a.prototype._initDeletes=function(){return this.addHotkey([g.KEYS.DELETE,g.KEYS.BACKSPACE],function(a){return function(b,c){var d,f,h,i;return null!=b&&a.quill.getLength()>0&&(b.start!==b.end?a.quill.deleteText(b.start,b.end,e.sources.USER):c.key===g.KEYS.BACKSPACE?(i=a.quill.editor.doc.findLineAt(b.start),f=i[0],h=i[1],0===h&&(f.formats.bullet||f.formats.list)?(d=f.format.bullet?"bullet":"list",a.quill.formatLine(b.start,b.start,d,!1)):b.start>0&&a.quill.deleteText(b.start-1,b.start,e.sources.USER)):b.startVisit URL: - Change Remove Done'},b.hotkeys={LINK:{key:"K",metaKey:!0}},b.prototype.initListeners=function(){return this.quill.on(this.quill.constructor.events.SELECTION_CHANGE,function(a){return function(b){var c;if(null!=b&&b.isCollapsed())return c=a._findAnchor(b),c?(a.setMode(c.href,!1),a.show(c)):(a.range=null,a.hide())}}(this)),g(this.container.querySelector(".done")).on("click",f.bind(this.saveLink,this)),g(this.container.querySelector(".remove")).on("click",function(a){return function(){return a.removeLink(a.range)}}(this)),g(this.container.querySelector(".change")).on("click",function(a){return function(){return a.setMode(a.link.href,!0)}}(this)),this.initTextbox(this.textbox,this.saveLink,this.hide),this.quill.onModuleLoad("toolbar",function(a){return function(b){return a.toolbar=b,b.initFormat("link",f.bind(a._onToolbar,a))}}(this)),this.quill.onModuleLoad("keyboard",function(a){return function(c){return c.addHotkey(b.hotkeys.LINK,f.bind(a._onKeyboard,a))}}(this))},b.prototype.saveLink=function(){var a,b;return b=this._normalizeURL(this.textbox.value),null!=this.range&&(this.range.isCollapsed()?(a=this._findAnchor(this.range),null!=a&&(a.href=b)):this.quill.formatText(this.range,"link",b,"user")),this.setMode(b,!1)},b.prototype.removeLink=function(a){return a.isCollapsed()&&(a=this._expandRange(a)),this.quill.formatText(a,"link",!1,"user"),null!=this.toolbar?this.toolbar.setActive("link",!1):void 0},b.prototype.setMode=function(a,b){var c;return null==b&&(b=!1),b?(this.textbox.value=a,f.defer(function(b){return function(){return b.textbox.focus(),b.textbox.setSelectionRange(a.length,a.length)}}(this))):(this.link.href=a,c=a.length>this.options.maxLength?a.slice(0,this.options.maxLength)+"...":a,g(this.link).text(c)),g(this.container).toggleClass("editing",b)},b.prototype._findAnchor=function(a){var b,c,d,e;for(e=this.quill.editor.doc.findLeafAt(a.start,!0),b=e[0],d=e[1],null!=b&&(c=b.node);null!=c;){if("A"===c.tagName)return c;c=c.parentNode}return null},b.prototype._expandRange=function(a){var b,c,d,e,f;return e=this.quill.editor.doc.findLeafAt(a.start,!0),c=e[0],d=e[1],f=a.start-d,b=f+c.length,{start:f,end:b}},b.prototype._onToolbar=function(a,b){return this._toggle(a,b)},b.prototype._onKeyboard=function(){var a;return a=this.quill.getSelection(),this._toggle(a,!0)},b.prototype._toggle=function(a,b){var c;if(a)return b&&!a.isCollapsed()?(this.setMode(this._suggestURL(a),!0),c=this.quill.editor.selection._getNativeRange(),this.show(c)):this.removeLink(a)},b.prototype._normalizeURL=function(a){return/^(https?:\/\/|mailto:)/.test(a)||(a="http://"+a),a},b.prototype._suggestURL=function(a){var b;return b=this.quill.getText(a),this._normalizeURL(b)},b}(e),d.registerModule("link-tooltip",c),b.exports=c},{"../quill":30,"./tooltip":28}],25:[function(a,b){var c,d,e,f,g,h=function(a,b){function c(){this.constructor=a}for(var d in b)i.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},i={}.hasOwnProperty;e=a("../quill"),c=a("eventemitter2").EventEmitter2,f=e.require("lodash"),g=e.require("dom"),d=function(a){function b(a,b){this.quill=a,this.options=b,this.cursors={},this.container=this.quill.addContainer("ql-multi-cursor",!0),this.quill.on(this.quill.constructor.events.TEXT_CHANGE,f.bind(this._applyDelta,this))}return h(b,a),b.DEFAULTS={template:' ',timeout:2500},b.events={CURSOR_ADDED:"cursor-addded",CURSOR_MOVED:"cursor-moved",CURSOR_REMOVED:"cursor-removed"},b.prototype.clearCursors=function(){return f.each(Object.keys(this.cursors),f.bind(this.removeCursor,this)),this.cursors={}},b.prototype.moveCursor=function(a,b){var c;return c=this.cursors[a],c.index=b,g(c.elem).removeClass("hidden"),clearTimeout(c.timer),c.timer=setTimeout(function(){return function(){return g(c.elem).addClass("hidden"),c.timer=null}}(this),this.options.timeout),this._updateCursor(c),c},b.prototype.removeCursor=function(a){var c;return c=this.cursors[a],this.emit(b.events.CURSOR_REMOVED,c),null!=c&&c.elem.parentNode.removeChild(c.elem),delete this.cursors[a]},b.prototype.setCursor=function(a,c,d,e){var g;return null==this.cursors[a]&&(this.cursors[a]=g={userId:a,index:c,color:e,elem:this._buildCursor(d,e)},this.emit(b.events.CURSOR_ADDED,g)),f.defer(function(b){return function(){return b.moveCursor(a,c)}}(this)),this.cursors[a]},b.prototype.shiftCursors=function(a,b,c){return null==c&&(c=null),f.each(this.cursors,function(){return function(d){return d&&(d.index>a||d.userId===c)?d.index+=Math.max(b,a-d.index):void 0}}(this))},b.prototype.update=function(){return f.each(this.cursors,function(a){return function(b){return null!=b?(a._updateCursor(b),!0):void 0}}(this))},b.prototype._applyDelta=function(a){var b;return b=0,f.each(a.ops,function(a){return function(c){var d,e;return d=0,null!=c.insert?(d=c.insert.length||1,a.shiftCursors(b,d,null!=(e=c.attributes)?e.author:void 0)):null!=c["delete"]?a.shiftCursors(b,-1*c["delete"],null):null!=c.retain&&(a.shiftCursors(b,0,null),d=c.retain),b+=d}}(this)),this.update()},b.prototype._buildCursor=function(a,b){var c,d,e,f;return c=document.createElement("span"),g(c).addClass("cursor"),c.innerHTML=this.options.template,e=c.querySelector(".cursor-flag"),f=c.querySelector(".cursor-name"),g(f).text(a),d=c.querySelector(".cursor-caret"),d.style.backgroundColor=f.style.backgroundColor=b,this.container.appendChild(c),c},b.prototype._updateCursor=function(a){var c,d;return c=this.quill.getBounds(a.index),a.elem.style.top=c.top-this.quill.container.scrollTop+"px",a.elem.style.left=c.left+"px",a.elem.style.height=c.height+"px",d=a.elem.querySelector(".cursor-flag"),g(a.elem).toggleClass("top",parseInt(a.elem.style.top)<=d.offsetHeight).toggleClass("left",parseInt(a.elem.style.left)<=d.offsetWidth).toggleClass("right",this.quill.root.offsetWidth-parseInt(a.elem.style.left)<=d.offsetWidth),this.emit(b.events.CURSOR_MOVED,a)},b}(c),e.registerModule("multi-cursor",d),b.exports=d},{"../quill":30,eventemitter2:2}],26:[function(a,b){var c,d,e,f,g,h;f=a("../quill"),d=a("../core/document"),g=f.require("lodash"),h=f.require("dom"),c=f.require("delta"),e=function(){function a(a,b){this.quill=a,this.options=b,this.container=this.quill.addContainer("ql-paste-manager"),this.container.setAttribute("contenteditable",!0),h(this.quill.root).on("paste",g.bind(this._paste,this))}return a.prototype._paste=function(){var a,b;return a=this.quill.getLength(),b=this.quill.getSelection(),null!=b?(this.container.focus(),g.defer(function(a){return function(){var e,f,g,h,i,j,k,l;return f=new d(a.container,a.quill.options),e=f.toDelta(),g=e.length()-1,e.compose((new c).retain(g)["delete"](1)),b.start>0&&e.ops.unshift({retain:b.start}),e["delete"](b.end-b.start),a.quill.updateContents(e,"user"),a.quill.setSelection(b.start+g,b.start+g),k=a.quill.editor.doc.findLineAt(b.start+g),h=k[0],j=k[1],i=h.node.getBoundingClientRect().bottom,l=document.documentElement.clientHeight,i>l&&h.node.scrollIntoView(!1),a.container.innerHTML=""}}(this))):void 0},a}(),f.registerModule("paste-manager",e),b.exports=e},{"../core/document":8,"../quill":30}],27:[function(a,b){var c,d,e,f;c=a("../quill"),e=c.require("lodash"),f=c.require("dom"),d=function(){function a(b,c){if(this.quill=b,this.options=c,(e.isString(this.options)||e.isElement(this.options))&&(this.options={container:this.options}),null==this.options.container)throw new Error("container required for toolbar",this.options);this.container=e.isString(this.options.container)?document.querySelector(this.options.container):this.options.container,this.inputs={},this.preventUpdate=!1,this.triggering=!1,e.each(this.quill.options.formats,function(b){return function(c){return null==a.formats.TOOLTIP[c]?b.initFormat(c,function(d,f){return b.triggering?void 0:(d.isCollapsed()?b.quill.prepareFormat(c,f,"user"):null!=a.formats.LINE[c]?b.quill.formatLine(d,c,f,"user"):b.quill.formatText(d,c,f,"user"),e.defer(function(){return b.updateActive(d,["bullet","list"]),b.setActive(c,f)}))}):void 0}}(this)),this.quill.on(this.quill.constructor.events.SELECTION_CHANGE,function(a){return function(b){return null!=b?a.updateActive(b):void 0}}(this)),this.quill.onModuleLoad("keyboard",function(a){return function(b){return b.addHotkey([f.KEYS.BACKSPACE,f.KEYS.DELETE,f.KEYS.ENTER],function(){return e.defer(e.bind(a.updateActive,a))})}}(this)),f(this.container).addClass("ql-toolbar"),f.isIOS()&&f(this.container).addClass("ios"),f.isIE(11)&&f(this.container).on("mousedown",function(){return function(){return!1}}(this))}return a.DEFAULTS={container:null},a.formats={LINE:{align:"align",bullet:"bullet",list:"list"},SELECT:{align:"align",background:"background",color:"color",font:"font",size:"size"},TOGGLE:{bold:"bold",bullet:"bullet",image:"image",italic:"italic",link:"link",list:"list",strike:"strike",underline:"underline"},TOOLTIP:{image:"image",link:"link"}},a.prototype.initFormat=function(b,c){var d,e,g;return g=".ql-"+b,null!=a.formats.SELECT[b]?(g="select"+g,d="change"):d="click",e=this.container.querySelector(g),null!=e?(this.inputs[b]=e,f(e).on(d,function(a){return function(){var b,g;return g="change"===d?f(e).value():!f(e).hasClass("ql-active"),a.preventUpdate=!0,a.quill.focus(),b=a.quill.getSelection(),null!=b&&c(b,g),a.preventUpdate=!1,!0}}(this))):void 0},a.prototype.setActive=function(a,b){var c,d,e,g;return d=this.inputs[a],null!=d?(c=f(d),"SELECT"===d.tagName?(this.triggering=!0,g=c.value(d),null==b&&(b=null!=(e=c["default"]())?e.value:void 0),Array.isArray(b)&&(b=""),b!==g&&(null!=b?c.option(b):c.reset()),this.triggering=!1):c.toggleClass("ql-active",b||!1)):void 0},a.prototype.updateActive=function(a,b){var c;return null==b&&(b=null),a||(a=this.quill.getSelection()),null==a||this.preventUpdate?void 0:(c=this._getActive(a),e.each(this.inputs,function(a){return function(d,e){return(!Array.isArray(b)||b.indexOf(e)>-1)&&a.setActive(e,c[e]),!0}}(this)))},a.prototype._getActive=function(a){var b,c;return b=this._getLeafActive(a),c=this._getLineActive(a),e.defaults({},b,c)},a.prototype._getLeafActive=function(a){var b,c,d,f,g;return a.isCollapsed()?(g=this.quill.editor.doc.findLineAt(a.start),d=g[0],f=g[1],b=0===f?this.quill.getContents(a.start,a.end+1):this.quill.getContents(a.start-1,a.end)):b=this.quill.getContents(a),c=e.map(b.ops,"attributes"),this._intersectFormats(c)},a.prototype._getLineActive=function(a){var b,c,d,f,g,h;for(c=[],g=this.quill.editor.doc.findLineAt(a.start),b=g[0],f=g[1],h=this.quill.editor.doc.findLineAt(a.end),d=h[0],f=h[1],null!=d&&d===b&&(d=d.next);null!=b&&b!==d;)c.push(e.clone(b.formats)),b=b.next;return this._intersectFormats(c)},a.prototype._intersectFormats=function(b){return e.reduce(b.slice(1),function(b,c){var d,f,g,h,i;return null==c&&(c={}),d=Object.keys(b),g=null!=c?Object.keys(c):{},h=e.intersection(d,g),i=e.difference(d,g),f=e.difference(g,d),e.each(h,function(d){if(null!=a.formats.SELECT[d])if(Array.isArray(b[d])){if(b[d].indexOf(c[d])<0)return b[d].push(c[d])}else if(b[d]!==c[d])return b[d]=[b[d],c[d]]}),e.each(i,function(c){return null!=a.formats.TOGGLE[c]?delete b[c]:null==a.formats.SELECT[c]||Array.isArray(b[c])?void 0:b[c]=[b[c]]}),e.each(f,function(d){return null!=a.formats.SELECT[d]?b[d]=[c[d]]:void 0}),b},b[0]||{})},a}(),c.registerModule("toolbar",d),b.exports=d},{"../quill":30}],28:[function(a,b){var c,d,e,f,g;d=a("../quill"),f=d.require("lodash"),g=d.require("dom"),c=d.require("normalizer"),e=function(){function a(b,d){this.quill=b,this.options=d,this.container=this.quill.addContainer("ql-tooltip"),this.container.innerHTML=c.stripWhitespace(this.options.template),g(this.quill.root).on("focus",f.bind(this.hide,this)),this.hide(),this.quill.on(this.quill.constructor.events.TEXT_CHANGE,function(b){return function(c,d){return"user"===d&&b.container.style.left!==a.HIDE_MARGIN?(b.range=null,
b.hide()):void 0}}(this))}return a.DEFAULTS={offset:10,template:""},a.HIDE_MARGIN="-10000px",a.prototype.initTextbox=function(a,b,c){return g(a).on("keyup",function(a){return function(d){switch(d.which){case g.KEYS.ENTER:return b.call(a);case g.KEYS.ESCAPE:return c.call(a);default:return!0}}}(this))},a.prototype.hide=function(){return this.container.style.left=a.HIDE_MARGIN,this.range&&this.quill.setSelection(this.range),this.range=null},a.prototype.position=function(a){var b,c,d,e,f,g,h;return null!=a?(g=a.getBoundingClientRect(),f=this.quill.container.getBoundingClientRect(),d=g.left-f.left,e=g.top-f.top,c=g.bottom-f.bottom,b=d+g.width/2-this.container.offsetWidth/2,h=e+g.height+this.options.offset,h+this.container.offsetHeight>this.quill.container.offsetHeight&&(h=e-this.container.offsetHeight-this.options.offset),b=Math.max(0,Math.min(b,this.quill.container.offsetWidth-this.container.offsetWidth)),h=Math.max(0,Math.min(h,this.quill.container.offsetHeight-this.container.offsetHeight))):(b=this.quill.container.offsetWidth/2-this.container.offsetWidth/2,h=this.quill.container.offsetHeight/2-this.container.offsetHeight/2),h+=this.quill.container.scrollTop,[b,h]},a.prototype.show=function(a){var b,c,d;return this.range=this.quill.getSelection(),c=this.position(a),b=c[0],d=c[1],this.container.style.left=b+"px",this.container.style.top=d+"px",this.container.focus()},a}(),d.registerModule("tooltip",e),b.exports=e},{"../quill":30}],29:[function(a,b){var c,d,e,f;d=a("../quill"),f=d.require("lodash"),c=d.require("delta"),e=function(){function a(a,b){this.quill=a,this.options=null!=b?b:{},this.lastRecorded=0,this.ignoreChange=!1,this.clear(),this.initListeners()}return a.DEFAULTS={delay:1e3,maxStack:100},a.hotkeys={UNDO:{key:"Z",metaKey:!0},REDO:{key:"Z",metaKey:!0,shiftKey:!0}},a.prototype.initListeners=function(){return this.quill.onModuleLoad("keyboard",function(b){return function(c){return c.addHotkey(a.hotkeys.UNDO,function(){return b.quill.editor.checkUpdate(),b.undo(),!1}),c.addHotkey(a.hotkeys.REDO,function(){return b.quill.editor.checkUpdate(),b.redo(),!1})}}(this)),this.quill.on(this.quill.constructor.events.TEXT_CHANGE,function(a){return function(b){return a.ignoreChange?void 0:(a.record(b,a.oldDelta),a.oldDelta=a.quill.getContents())}}(this))},a.prototype.clear=function(){return this.stack={undo:[],redo:[]},this.oldDelta=this.quill.getContents()},a.prototype.record=function(a){var b,c,d,e;if(a.ops.length>0){this.stack.redo=[];try{if(e=this.quill.getContents().diff(this.oldDelta),d=(new Date).getTime(),this.lastRecorded+this.options.delay>d&&this.stack.undo.length>0?(b=this.stack.undo.pop(),e=e.compose(b.undo),a=b.redo.compose(a)):this.lastRecorded=d,this.stack.undo.push({redo:a,undo:e}),this.stack.undo.length>this.options.maxStack)return this.stack.undo.unshift()}catch(f){return c=f,console.warn("Could not record change... clearing undo stack."),this.clear()}}},a.prototype.redo=function(){return this._change("redo","undo")},a.prototype.undo=function(){return this._change("undo","redo")},a.prototype._getLastChangeIndex=function(a){var b,c;return c=0,b=0,f.each(a.ops,function(a){return null!=a.insert?c=Math.max(b+(a.insert.length||1),c):null!=a["delete"]?c=Math.max(b,c):null!=a.retain?(null!=a.attributes&&(c=Math.max(b+a.retain,c)),b+=a.retain):void 0}),c},a.prototype._change=function(a,b){var c,d;return this.stack[a].length>0?(c=this.stack[a].pop(),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(c[a],"user"),this.ignoreChange=!1,d=this._getLastChangeIndex(c[a]),this.quill.setSelection(d,d),this.oldDelta=this.quill.getContents(),this.stack[b].push(c)):void 0},a}(),d.registerModule("undo-manager",e),b.exports=e},{"../quill":30}],30:[function(a,b){var c,d,e,f,g,h,i,j,k,l,m=function(a,b){function c(){this.constructor=a}for(var d in b)n.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},n={}.hasOwnProperty,o=[].slice;j=a("lodash"),l=a("../package.json"),c=a("rich-text/lib/delta"),e=a("eventemitter2").EventEmitter2,k=a("./lib/dom"),d=a("./core/editor"),f=a("./core/format"),g=a("./core/normalizer"),i=a("./lib/range"),h=function(a){function b(a,c){var e,f,g;if(this.container=a,null==c&&(c={}),j.isString(this.container)&&(this.container=document.querySelector(this.container)),null==this.container)throw new Error("Invalid Quill container");if(f=j.defaults(c.modules||{},b.DEFAULTS.modules),e=this.container.innerHTML,this.container.innerHTML="",this.options=j.defaults(c,b.DEFAULTS),this.options.modules=f,this.options.id=this.id="ql-editor-"+(b.editors.length+1),this.modules={},this.root=this.addContainer("ql-editor"),this.editor=new d(this.root,this,this.options),b.editors.push(this),this.setHTML(e,b.sources.SILENT),g=b.themes[this.options.theme],null==g)throw new Error("Cannot load "+this.options.theme+" theme. Are you sure you registered it?");this.theme=new g(this,this.options),j.each(this.options.modules,function(a){return function(b,c){return a.addModule(c,b)}}(this))}return m(b,a),b.version=l.version,b.editors=[],b.modules=[],b.themes=[],b.DEFAULTS={formats:["align","bold","italic","strike","underline","color","background","font","size","link","image","bullet","list"],modules:{keyboard:!0,"paste-manager":!0,"undo-manager":!0},pollInterval:100,readOnly:!1,styles:{},theme:"base"},b.events={MODULE_INIT:"module-init",POST_EVENT:"post-event",PRE_EVENT:"pre-event",SELECTION_CHANGE:"selection-change",TEXT_CHANGE:"text-change"},b.sources=d.sources,b.registerModule=function(a,c){return null!=b.modules[a]&&console.warn("Overwriting "+a+" module"),b.modules[a]=c},b.registerTheme=function(a,c){return null!=b.themes[a]&&console.warn("Overwriting "+a+" theme"),b.themes[a]=c},b.require=function(a){switch(a){case"lodash":return j;case"delta":return c;case"normalizer":return g;case"dom":return k;case"range":return i;default:return null}},b.prototype.destroy=function(){var a;return a=this.getHTML(),j.each(this.modules,function(a){return j.isFunction(a.destroy)?a.destroy():void 0}),this.editor.destroy(),this.removeAllListeners(),b.editors.splice(j.indexOf(b.editors,this),1),this.container.innerHTML=a},b.prototype.addContainer=function(a,b){var c,d;return null==b&&(b=!1),d=b?this.root:null,c=document.createElement("div"),k(c).addClass(a),this.container.insertBefore(c,d),c},b.prototype.addFormat=function(a,b){return this.editor.doc.addFormat(a,b)},b.prototype.addModule=function(a,c){var d;if(d=b.modules[a],null==d)throw new Error("Cannot load "+a+" module. Are you sure you registered it?");return c===!0&&(c={}),c=j.defaults(c,this.theme.constructor.OPTIONS[a]||{},d.DEFAULTS||{}),this.modules[a]=new d(this,c),this.emit(b.events.MODULE_INIT,a,this.modules[a]),this.modules[a]},b.prototype.deleteText=function(a,d,e){var f,g,h;return null==e&&(e=b.sources.API),h=this._buildParams(a,d,{},e),a=h[0],d=h[1],g=h[2],e=h[3],d>a?(f=(new c).retain(a)["delete"](d-a),this.editor.applyDelta(f,e)):void 0},b.prototype.emit=function(){var a,c;return c=arguments[0],a=2<=arguments.length?o.call(arguments,1):[],b.__super__.emit.apply(this,[b.events.PRE_EVENT,c].concat(o.call(a))),b.__super__.emit.apply(this,[c].concat(o.call(a))),b.__super__.emit.apply(this,[b.events.POST_EVENT,c].concat(o.call(a)))},b.prototype.focus=function(){return this.editor.focus()},b.prototype.formatLine=function(a,b,c,d,e){var f,g,h,i,j;return i=this._buildParams(a,b,c,d,e),a=i[0],b=i[1],f=i[2],e=i[3],j=this.editor.doc.findLineAt(b),g=j[0],h=j[1],null!=g&&(b+=g.length-h),this.formatText(a,b,f,e)},b.prototype.formatText=function(a,b,d,e,f){var g,h,i;return i=this._buildParams(a,b,d,e,f),a=i[0],b=i[1],h=i[2],f=i[3],h=j.reduce(h,function(a){return function(b,c,d){var e;return e=a.editor.doc.formats[d],c&&c!==e.config["default"]||(b[d]=null),b}}(this),h),g=(new c).retain(a).retain(b-a,h),this.editor.applyDelta(g,f)},b.prototype.getBounds=function(a){return this.editor.getBounds(a)},b.prototype.getContents=function(a,b){return null==a&&(a=0),null==b&&(b=null),j.isObject(a)&&(b=a.end,a=a.start),this.editor.delta.slice(a,b)},b.prototype.getHTML=function(){return this.editor.doc.getHTML()},b.prototype.getLength=function(){return this.editor.length},b.prototype.getModule=function(a){return this.modules[a]},b.prototype.getSelection=function(){return this.editor.checkUpdate(),this.editor.selection.getRange()},b.prototype.getText=function(a,b){return null==a&&(a=0),null==b&&(b=null),j.map(this.getContents(a,b).ops,function(a){return j.isString(a.insert)?a.insert:""}).join("")},b.prototype.insertEmbed=function(a,b,c,d){return this.insertText(a,k.EMBED_TEXT,b,c,d)},b.prototype.insertText=function(a,b,d,e,f){var g,h,i,j;return j=this._buildParams(a,0,d,e,f),a=j[0],h=j[1],i=j[2],f=j[3],b.length>0?(g=(new c).retain(a).insert(b,i),this.editor.applyDelta(g,f)):void 0},b.prototype.onModuleLoad=function(a,c){return this.modules[a]?c(this.modules[a]):this.on(b.events.MODULE_INIT,function(b,d){return b===a?c(d):void 0})},b.prototype.prepareFormat=function(a,c,d){var e,g;return null==d&&(d=b.sources.API),e=this.editor.doc.formats[a],null!=e&&(g=this.getSelection(),null!=g?g.isCollapsed():void 0)?e.isType(f.types.LINE)?this.formatLine(g,a,c,d):e.prepare(c):void 0},b.prototype.setContents=function(a,c){return null==c&&(c=b.sources.API),a=Array.isArray(a)?{ops:a.slice()}:{ops:a.ops.slice()},a.ops.push({"delete":this.getLength()}),this.updateContents(a,c)},b.prototype.setHTML=function(a,c){return null==c&&(c=b.sources.API),a.trim()||(a="<"+k.DEFAULT_BLOCK_TAG+"><"+k.DEFAULT_BREAK_TAG+">"+k.DEFAULT_BLOCK_TAG+">"),this.editor.doc.setHTML(a),this.editor.checkUpdate(c)},b.prototype.setSelection=function(a,c,d){var e;return null==d&&(d=b.sources.API),j.isNumber(a)&&j.isNumber(c)?e=new i(a,c):(e=a,d=c||d),this.editor.selection.setRange(e,d)},b.prototype.setText=function(a,d){var e;return null==d&&(d=b.sources.API),e=(new c).insert(a),this.setContents(e,d)},b.prototype.updateContents=function(a,c){return null==c&&(c=b.sources.API),Array.isArray(a)&&(a={ops:a}),this.editor.applyDelta(a,c)},b.prototype._buildParams=function(){var a,c;return c=1<=arguments.length?o.call(arguments,0):[],j.isObject(c[0])&&c.splice(0,1,c[0].start,c[0].end),j.isString(c[2])&&(a={},a[c[2]]=c[3],c.splice(2,2,a)),null==c[3]&&(c[3]=b.sources.API),c},b}(e),h.registerTheme("base",a("./themes/base")),h.registerTheme("snow",a("./themes/snow")),b.exports=h},{"../package.json":7,"./core/editor":9,"./core/format":10,"./core/normalizer":13,"./lib/dom":17,"./lib/range":20,"./themes/base":32,"./themes/snow":33,eventemitter2:2,lodash:1,"rich-text/lib/delta":3}],31:[function(a,b){b.exports='.ql-image-tooltip{padding:10px;width:300px}.ql-image-tooltip:after{clear:both;content:"";display:table}.ql-image-tooltip a{border:1px solid #000;box-sizing:border-box;display:inline-block;float:left;padding:5px;text-align:center;width:50%}.ql-image-tooltip img{bottom:0;left:0;margin:auto;max-height:100%;max-width:100%;position:absolute;right:0;top:0}.ql-image-tooltip .input{box-sizing:border-box;width:100%}.ql-image-tooltip .preview{margin:10px 0;position:relative;border:1px dashed #000;height:200px}.ql-image-tooltip .preview span{display:inline-block;position:absolute;text-align:center;top:40%;width:100%}.ql-link-tooltip{padding:5px 10px}.ql-link-tooltip input.input{width:170px}.ql-link-tooltip a.done,.ql-link-tooltip input.input{display:none}.ql-link-tooltip a.change{margin-right:4px}.ql-link-tooltip.editing a.done,.ql-link-tooltip.editing input.input{display:inline-block}.ql-link-tooltip.editing a.change,.ql-link-tooltip.editing a.remove,.ql-link-tooltip.editing a.url{display:none}.ql-multi-cursor{position:absolute;left:0;top:0;z-index:1000}.ql-multi-cursor .cursor{margin-left:-1px;position:absolute}.ql-multi-cursor .cursor-flag{bottom:100%;position:absolute;white-space:nowrap}.ql-multi-cursor .cursor-name{display:inline-block;color:#fff;padding:2px 8px}.ql-multi-cursor .cursor-caret{height:100%;position:absolute;width:2px}.ql-multi-cursor .cursor.hidden .cursor-flag{display:none}.ql-multi-cursor .cursor.top .cursor-flag{bottom:auto;top:100%}.ql-multi-cursor .cursor.right .cursor-flag{right:-2px}.ql-paste-manager{left:-100000px;position:absolute;top:50%}.ql-toolbar{box-sizing:border-box}.ql-tooltip{background-color:#fff;border:1px solid #000;box-sizing:border-box;position:absolute;top:0;white-space:nowrap;z-index:2000}.ql-tooltip a{cursor:pointer;text-decoration:none}.ql-container{box-sizing:border-box;cursor:text;font-family:Helvetica,Arial,sans-serif;font-size:13px;height:100%;line-height:1.42;margin:0;overflow-x:hidden;overflow-y:auto;padding:12px 15px;position:relative}.ql-editor{box-sizing:border-box;min-height:100%;outline:0;tab-size:4;white-space:pre-wrap}.ql-editor div{margin:0;padding:0}.ql-editor a{text-decoration:underline}.ql-editor b{font-weight:700}.ql-editor i{font-style:italic}.ql-editor s{text-decoration:line-through}.ql-editor u{text-decoration:underline}.ql-editor img{max-width:100%}.ql-editor blockquote,.ql-editor ol,.ql-editor ul{margin:0 0 0 2em;padding:0}.ql-editor ol{list-style-type:decimal}.ql-editor ul{list-style-type:disc}.ql-editor.ql-ie-10 br,.ql-editor.ql-ie-9 br{display:none}'},{}],32:[function(a,b){var c,d,e,f;d=a("lodash"),f=a("../../lib/dom"),e=a("./base.styl"),c=function(){function a(b,c){var d;this.quill=b,this.options=c,f(this.quill.container).addClass("ql-container"),this.options.styles&&this.addStyles(e+a.objToCss(this.options.styles)),f.isIE(10)&&(d=f.isIE(9)?"9":"10",f(this.quill.root).addClass("ql-ie-"+d))}return a.OPTIONS={},a.objToCss=function(a){return d.map(a,function(a,b){var c;return c=d.map(a,function(a,b){return b+": "+a+";"}).join(" "),b+" { "+c+" }"}).join("\n")},a.prototype.addStyles=function(b){var c;return d.isObject(b)&&(b=a.objToCss(b)),c=document.createElement("style"),c.type="text/css",c.appendChild(document.createTextNode(b)),document.head.appendChild(c)},a}(),b.exports=c},{"../../lib/dom":17,"./base.styl":31,lodash:1}],33:[function(a,b){var c,d,e,f,g,h,i=function(a,b){function c(){this.constructor=a}for(var d in b)j.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},j={}.hasOwnProperty;g=a("lodash"),d=a("../../lib/color-picker"),c=a("../base"),h=a("../../lib/dom"),e=a("../../lib/picker"),f=function(a){function b(a,c){this.quill=a,this.options=c,b.__super__.constructor.apply(this,arguments),h(this.quill.container).addClass("ql-snow"),this.pickers=[],this.quill.on(this.quill.constructor.events.SELECTION_CHANGE,function(a){return function(b){return null!=b?g.invoke(a.pickers,"close"):void 0}}(this)),this.quill.onModuleLoad("multi-cursor",g.bind(this.extendMultiCursor,this)),this.quill.onModuleLoad("toolbar",g.bind(this.extendToolbar,this))}return i(b,a),b.COLORS=["#000000","#e60000","#ff9900","#ffff00","#008A00","#0066cc","#9933ff","#ffffff","#facccc","#ffebcc","#ffffcc","#cce8cc","#cce0f5","#ebd6ff","#bbbbbb","#f06666","#ffc266","#ffff66","#66b966","#66a3e0","#c285ff","#888888","#a10000","#b26b00","#b2b200","#006100","#0047b2","#6b24b2","#444444","#5c0000","#663d00","#666600","#003700","#002966","#3d1466"],b.OPTIONS={"multi-cursor":{template:' '}},b.prototype.extendMultiCursor=function(a){return a.on(a.constructor.events.CURSOR_ADDED,function(a){var b,c;return b=a.elem.querySelector(".cursor-triangle.bottom"),c=a.elem.querySelector(".cursor-triangle.top"),b.style.borderTopColor=c.style.borderBottomColor=a.color})},b.prototype.extendToolbar=function(a){return h(a.container).addClass("ql-snow"),g.each(["color","background","font","size","align"],function(b){return function(c){var f,i;if(i=a.container.querySelector(".ql-"+c),null!=i){switch(c){case"font":case"size":case"align":f=new e(i);break;case"color":case"background":f=new d(i),g.each(f.container.querySelectorAll(".ql-picker-item"),function(a,b){return 7>b?h(a).addClass("ql-primary-color"):void 0})}return null!=f?b.pickers.push(f):void 0}}}(this)),g.each(h(a.container).textNodes(),function(a){return 0===h(a).text().trim().length?h(a).remove():void 0})},b}(c),b.exports=f},{"../../lib/color-picker":16,"../../lib/dom":17,"../../lib/picker":19,"../base":32,lodash:1}]},{},[15])(15)});
\ No newline at end of file
diff --git a/core/components/ms2form/docs/changelog.txt b/core/components/ms2form/docs/changelog.txt
index 4c0c4f4..1bb80e6 100644
--- a/core/components/ms2form/docs/changelog.txt
+++ b/core/components/ms2form/docs/changelog.txt
@@ -1,5 +1,23 @@
Changelog for ms2form.
+1.3.5-beta FORK
+==============
+- создание новых категорий при сохранении товаров
+
+1.3.4-beta FORK
+==============
+- при формировании превью картинок учитывается формат, указанное в настройках источника файлов
+- добавленные картинки более не фильтруются по создателю
+
+1.3.3-beta FORK
+==============
+- в значении поля `content` более не экранизируются теги при выводе формы редактирования товара
+
+1.3.2-beta FORK
+==============
+- добавлен параметр allowedTags в сниппете ms2form
+- тег параграфа по умолчанию P в редакторе quill
+
1.3.1-beta
==============
- при включенной опции minifyx_process_registered скрипты теперь подключаются в правильной последовательности.
@@ -42,8 +60,4 @@ Changelog for ms2form.
- поддержка мультикатегорий
- поддержка тегов
- поддержка дополнительных TV
-- поддержка шаблонов
-
-
-
-
+- поддержка шаблонов
\ No newline at end of file
diff --git a/core/components/ms2form/elements/chunks/chunk.update.tpl b/core/components/ms2form/elements/chunks/chunk.update.tpl
index fe68cee..176afc0 100644
--- a/core/components/ms2form/elements/chunks/chunk.update.tpl
+++ b/core/components/ms2form/elements/chunks/chunk.update.tpl
@@ -35,7 +35,7 @@
-
+
[[$tpl.ms2form.editor.[[+editor]]?content=`[[+content]]`]]
@@ -75,4 +75,4 @@
-->
\ No newline at end of file
+-->
diff --git a/core/components/ms2form/elements/snippets/snippet.ms2form.php b/core/components/ms2form/elements/snippets/snippet.ms2form.php
index 5b5cba2..55fa5c2 100644
--- a/core/components/ms2form/elements/snippets/snippet.ms2form.php
+++ b/core/components/ms2form/elements/snippets/snippet.ms2form.php
@@ -3,7 +3,7 @@
/* @var ms2form $ms2form */
if (!$modx->user->isAuthenticated()) {
- return $modx->lexicon('ms2form_err_no_auth');
+ //return $modx->lexicon('ms2form_err_no_auth');
}
$ms2form = $modx->getService('ms2form', 'ms2form', $modx->getOption('ms2form_core_path', null, $modx->getOption('core_path') . 'components/ms2form/') . 'model/ms2form/', $scriptProperties);
@@ -47,7 +47,7 @@
$tvId = (int)trim($field, 'tv');
$value = $product->getTVValue($tvId);
}
- if (is_string($value)) {
+ if (is_string($value) && $field != 'content') {
$value = html_entity_decode($value, ENT_QUOTES, $charset);
$value = str_replace(array('[^', '^]', '[', ']'), array('[^', '^]', '{{{{{', '}}}}}'), $value);
$value = htmlentities($value, ENT_QUOTES, $charset);
@@ -111,13 +111,13 @@
$q->where(array(
'product_id' => 0
,'parent' => 0
- ,'createdby' => $modx->user->id
+ //,'createdby' => $modx->user->id
));
}else{
$q->where(array(
'product_id' => $pid
, 'parent' => 0
- , 'createdby' => $modx->user->id
+ //, 'createdby' => $modx->user->id
));
}
$q->sortby('rank', 'ASC');
@@ -127,7 +127,9 @@
foreach ($collection as $item) {
$item = $item->toArray();
$item['size'] = round($item['size'] / 1024, 2);
- $item['thumb'] = '/'.$sourceProperties['baseUrl'].$item['path']. $ms2_product_thumbnail_size.'/'. $item['file'];
+ $tmp = explode('.', $item['file']);
+ $extension = strtolower(end($tmp));
+ $item['thumb'] = '/'.$sourceProperties['baseUrl'].$item['path']. $ms2_product_thumbnail_size.'/'. str_replace('.'.$extension, '.'.strtolower($sourceProperties['thumbnailType']), $item['file']);
$tpl = $item['type'] == 'image'
? $tplImage
: $tplFile;
diff --git a/core/components/ms2form/lexicon/en/setting.inc.php b/core/components/ms2form/lexicon/en/setting.inc.php
index d23b642..3da768b 100644
--- a/core/components/ms2form/lexicon/en/setting.inc.php
+++ b/core/components/ms2form/lexicon/en/setting.inc.php
@@ -13,6 +13,8 @@
$_lang['setting_ms2form_frontend_css_desc'] = 'Path to file with styles of the shop. If you want to use your own styles - specify them here, or clean this parameter and load them in site template.';
$_lang['setting_ms2form_frontend_js'] = 'Frontend scripts';
$_lang['setting_ms2form_frontend_js_desc'] = 'Path to file with scripts of the shop. If you want to use your own sscripts - specify them here, or clean this parameter and load them in site template.';
+$_lang['setting_ms2form_categories_parent'] = 'Parent of new categories';
+$_lang['setting_ms2form_categories_parent_desc'] = 'Parent for new categories';
$_lang['setting_ms2form_disable_htmlpurifier'] = 'Отключить фильтрацию контента';
$_lang['setting_ms2form_disable_htmlpurifier_desc'] = 'Эта настройка отключает фильтрацию контента с помощью HTML Purifier';
diff --git a/core/components/ms2form/lexicon/ru/setting.inc.php b/core/components/ms2form/lexicon/ru/setting.inc.php
index c3e0717..094087b 100644
--- a/core/components/ms2form/lexicon/ru/setting.inc.php
+++ b/core/components/ms2form/lexicon/ru/setting.inc.php
@@ -13,6 +13,8 @@
$_lang['setting_ms2form_frontend_css_desc'] = 'Путь к файлу со стилями магазина. Если вы хотите использовать собственные стили - укажите путь к ним здесь, или очистите параметр и загрузите их вручную через шаблон сайта.';
$_lang['setting_ms2form_frontend_js'] = 'Скрипты фронтенда';
$_lang['setting_ms2form_frontend_js_desc'] = 'Путь к файлу со скриптами магазина. Если вы хотите использовать собственные скрипты - укажите путь к ним здесь, или очистите параметр и загрузите их вручную через шаблон сайта.';
+$_lang['setting_ms2form_categories_parent'] = 'Родитель для категорий';
+$_lang['setting_ms2form_categories_parent_desc'] = 'Укажите родителя, который будет контейнером для новых категорий, создаваемых компонентом';
$_lang['setting_ms2form_disable_htmlpurifier'] = 'Отключить фильтрацию контента';
$_lang['setting_ms2form_disable_htmlpurifier_desc'] = 'Эта настройка отключает фильтрацию контента с помощью HTML Purifier';
diff --git a/core/components/ms2form/model/ms2form/ms2form.class.php b/core/components/ms2form/model/ms2form/ms2form.class.php
index 2864e8d..874f50f 100755
--- a/core/components/ms2form/model/ms2form/ms2form.class.php
+++ b/core/components/ms2form/model/ms2form/ms2form.class.php
@@ -1,607 +1,610 @@
-modx =& $modx;
- $corePath = $this->modx->getOption('ms2form_core_path', $config, $this->modx->getOption('core_path') . 'components/ms2form/');
- $assetsUrl = $this->modx->getOption('ms2form_assets_url', $config, $this->modx->getOption('assets_url') . 'components/ms2form/');
- $actionUrl = $this->modx->getOption('ms2form_action_url', $config, $assetsUrl . 'action.php');
- $disableHtmlpurifier = $this->modx->getOption('ms2form_disable_htmlpurifier');
- if (empty($config['source'])) {
- $config['source'] = $this->modx->getOption('ms2_product_source_default');
- }
- $connectorUrl = $assetsUrl . 'connector.php';
-
- $this->config = array_merge(array(
- 'assetsUrl' => $assetsUrl
- , 'cssUrl' => $assetsUrl . 'css/'
- , 'vendorUrl' => $assetsUrl . 'vendor/'
- , 'connectorUrl' => $connectorUrl
- , 'actionUrl' => $actionUrl
- , 'modelPath' => $corePath . 'model/'
- , 'corePath' => $corePath
- , 'cultureKey' => $this->modx->getOption('cultureKey')
- , 'disableHtmlpurifier' => $disableHtmlpurifier
- , 'json_response' => true
- ), $config);
-
- $this->modx->lexicon->load('ms2form:default');
-
- $this->authenticated = $this->modx->user->isAuthenticated($this->modx->context->get('key'));
- }
-
- /**
- * Initializes component into different contexts.
- *
- * @param string $ctx The context to load. Defaults to web.
- *
- * @return array
- */
- public function initialize($ctx = 'web')
- {
- if (!$this->pdoTools) {
- $this->loadPdoTools();
- }
- $this->pdoTools->setConfig($this->config);
-
- $this->config['ctx'] = $ctx;
- $this->initializeMediaSource($this->config['ctx']);
-
- if (!empty($this->initialized[$ctx]) or ($ctx == 'mgr') or (MODX_API_MODE )) {
- return $this->config;
- }
-
- $sorceProperties = $this->mediaSource->properties;
- $this->config['sourceProperties'] = $sorceProperties;
- $this->config['close_all_message'] = $this->modx->lexicon('ms2form_message_close_all');
- $this->config['cssUrl'] = $this->config['cssUrl'] . 'web/';
-
- //msearchform
- if(!empty($this->config['parentMse2form'])){
- $mse2FormConfig = array(
- 'autocomplete' => 'results'
- , 'queryVar' => 'query'
- , 'minQuery' => 3
- , 'fields' => 'pagetitle:1'
- , 'pageId' => $this->modx->resource->id
- , 'tplForm' => 'tpl.ms2form.mSearch2.form'
- , 'tpl' => 'tpl.ms2form.mSearch2.ac'
- , 'element' => 'mSearch2'
- , 'limit' => 5
- , 'onlyIndex' => false
- , 'actionUrl' => '/assets/components/msearch2/action.php'
- );
- $mse2FormConfig = array_merge($mse2FormConfig, json_decode($this->config['parentMse2form'], true));
- $mse2FormHash = sha1(serialize($mse2FormConfig));
- $this->config['parentMse2form'] = $mse2FormConfig;
- $this->config['mse2formKey'] = $mse2FormHash;
- $_SESSION['mSearch2'][$mse2FormHash] = $mse2FormConfig;
- }
-
- // ms2form
- $hash = sha1(serialize($this->config));
- $this->config['formKey'] = $hash;
- $_SESSION['ms2form'][$hash] = $this->config;
-
- $config_js = preg_replace(array('/^\n/', '/\t{6}/'), '', '
- Ms2formConfig = {
- vendorUrl: "' . $this->config['vendorUrl'] . '"
- ,assetsUrl: "' . $this->config['assetsUrl'] . '"
- ,actionUrl: "' . $this->config['actionUrl'] . '"
- ,cultureKey: "' . $this->config['cultureKey'] . '"
- ,editor: "' . $this->config['editor'] . '"
- };
- ');
- $config_js = "";
- $this->modx->regClientStartupScript($config_js, true);
- if ($css = trim($this->modx->getOption('ms2form_frontend_css'))) {
- $this->modx->regClientCSS($css);
- }
- if ($js = trim($this->modx->getOption('ms2form_frontend_js'))) {
- if (!empty($js) && preg_match('/\.js/i', $js)) {
- $jsCurl = $this->config['vendorUrl'] . 'curl/dist/curl-with-js-and-domReady/curl.js';
- $this->modx->regClientScript($jsCurl);
- $this->modx->regClientScript($js);
- }
- }
- $this->initialized[$ctx] = true;
- return $this->config;
- }
-
- /**
- * Loads an instance of pdoTools
- *
- * @return boolean
- */
- public function loadPdoTools()
- {
- if (!is_object($this->pdoTools) || !($this->pdoTools instanceof pdoTools)) {
- /** @var pdoFetch $pdoFetch */
- $fqn = $this->modx->getOption('pdoFetch.class', null, 'pdotools.pdofetch', true);
- if ($pdoClass = $this->modx->loadClass($fqn, '', false, true)) {
- $this->pdoTools = new $pdoClass($this->modx, $this->config);
- }
- return true;
- }
- return false;
- }
-
- /**
- * Method for transform array to placeholders
- *
- * @var array $array With keys and values
- * @var string $prefix Prefix for array keys
- *
- * @return array $array Two nested arrays with placeholders and values
- */
- public function makePlaceholders(array $array = array(), $prefix = '')
- {
- if (!$this->pdoTools) {
- $this->loadPdoTools();
- }
- return $this->pdoTools->makePlaceholders($array, $prefix);
- }
-
- /**
- * Upload file for msproduct
- *
- * @param $data
- *
- * @return array|string
- */
- public function fileUpload($data)
- {
- if (!$this->authenticated || empty($this->config['allowFiles'])) {
- return $this->error('ms2form_err_access_denied');
- }
- $data['file'] = $_FILES['file'];
- $data['rank'] = $_REQUEST['rank'];
- $data['source'] = $this->config['source'];
- /* @var modProcessorResponse $response */
- $response = $this->modx->runProcessor('web/gallery/upload', $data, array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
- if ($response->isError()) {
- return $this->error($response->getMessage());
- }
- $file = $response->getObject();
- $tpl = $file['type'] == 'image'
- ? $this->config['tplImage']
- : $this->config['tplFile'];
- $html = $this->getChunk($tpl, $file);
- return $this->success("ok", ['html' => $html, 'file' => $file]);
- }
-
- /**
- * Delete uploaded file
- *
- * @param $id
- *
- * @return array|string
- */
- public function fileDelete($id)
- {
- if (!$this->authenticated || empty($this->config['allowFiles'])) {
- return $this->error('ms2form_err_access_denied');
- }
- /** @var modProcessorResponse $response */
- $response = $this->modx->runProcessor('web/gallery/delete', array('id' => $id, 'source' => $this->config['source']), array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
- if ($response->isError()) {
- return $this->error($response->getMessage());
- }
-
- return $this->success('', array('id' => $id));
- }
-
- /**
- * Sort uploaded files
- *
- * @param $rank
- *
- * @return array|string
- */
- public function fileSort($rank) {
- if (!$this->authenticated || empty($this->config['allowFiles'])) {
- return $this->error('ms2form_err_access_denied');
- }
- /** @var modProcessorResponse $response */
- $response = $this->modx->runProcessor('web/gallery/sort', array('rank' => $rank), array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
- if ($response->isError()) {
- return $this->error($response->getMessage());
- }
- return $this->success();
- }
-
- /**
- * This method returns an error
- *
- * @param string $message A lexicon key for error message
- * @param array $data .Additional data, for example cart status
- * @param array $placeholders Array with placeholders for lexicon entry
- *
- * @return array|string $response
- */
- public function error($message = '', $data = array(), $placeholders = array())
- {
- header('HTTP/1.1 400 Bad Request');
- $messageTranslation = $this->modx->lexicon($message, $placeholders);
- if($messageTranslation){
- $message = $messageTranslation;
- }
- $response = array(
- 'success' => false
- , 'message' => $message
- , 'data' => $data
- );
- $this->modx->log(modX::LOG_LEVEL_ERROR, $message);
- return $this->config['json_response']
- ? $this->modx->toJSON($response)
- : $response;
- }
-
- /**
- * Process and return the output from a Chunk by name.
- *
- * @param string $name The name of the chunk.
- * @param array $properties An associative array of properties to process the Chunk with, treated as placeholders within the scope of the Element.
- * @param boolean $fastMode If false, all MODX tags in chunk will be processed.
- *
- * @return string The processed output of the Chunk.
- */
- public function getChunk($name, array $properties = array(), $fastMode = false)
- {
- if (!$this->modx->parser) {
- $this->modx->getParser();
- }
- if (!$this->pdoTools) {
- $this->loadPdoTools();
- }
-
- return $this->pdoTools->getChunk($name, $properties, $fastMode);
- }
-
- /**
- * This method returns an success
- *
- * @param string $message A lexicon key for success message
- * @param array $data .Additional data, for example cart status
- * @param array $placeholders Array with placeholders for lexicon entry
- *
- * @return array|string $response
- * */
- public function success($message = '', $data = array(), $placeholders = array())
- {
- $response = array(
- 'success' => true
- , 'message' => $this->modx->lexicon($message, $placeholders)
- , 'data' => $data
- );
- return $this->config['json_response']
- ? $this->modx->toJSON($response)
- : $response;
- }
-
- /**
- * Create Product through processor and redirect
- *
- * @param array $data section, pagetitle, text, etc
- *
- * @return array
- */
- public function productSave(array $data)
- {
- $source = $this->config['source'];
-
- $allowedFields = array_map('trim', explode(',', $this->config['allowedFields']));
- $allowedFields = array_unique(array_merge($allowedFields, array('parent', 'pagetitle', 'content')));
- $allowedFields = array_diff($allowedFields, array(''));
- $requiredFields = array_map('trim', explode(',', $this->config['requiredFields']));
- $requiredFields = array_unique(array_merge($requiredFields, array('parent', 'pagetitle')));
- $requiredFields = array_diff($requiredFields, array(''));
- if(!empty($this->config['parentMse2form'])){
- $allowedFields[] = $this->config['parentMse2form']['queryVar'];
- $requiredFields[] = $this->config['parentMse2form']['queryVar'];
- }
-
- $fields = array();
- foreach ($allowedFields as $field) {
- if (in_array($field, $allowedFields) && array_key_exists($field, $data)) {
- $value = $data[$field];
- if(is_array($value)){
- foreach($value as $key => $item){
- $value[$key] = $this->sanitizeString($item);
- }
- }else if($field !== 'content'){
- $value = $this->sanitizeString($value);
- }
- $fields[$field] = $value;
- }
- }
- // fix empty tags bug
- if (!$data['tags']) {
- $fields['tags'] = array();
- }
-
- $errors = array();
- foreach ($requiredFields as $v) {
- if (empty($fields[$v])) {
- $errors[$v] = $this->modx->lexicon('field_required');
- }
- }
- if (!empty($errors)) {
- return $this->error($this->modx->lexicon('ms2form_err_form'), $errors);
- }
-
- $fields['class_key'] = 'msProduct';
- $fields['source'] = $source;
-
- //filter content
- if(!$this->config['disableHtmlpurifier']){
- require_once $this->config['corePath'] . '/vendor/autoload.php';
- $purifierConfig = HTMLPurifier_Config::createDefault();
- $purifier = new HTMLPurifier($purifierConfig);
- $fields['content'] = $purifier->purify($fields['content']);
- }
-
- //update or create product
- if (!empty($data['pid'])) {
- $fields['id'] = (integer)$data['pid'];
- $fields['context_key'] = $data['context_key'];
- $fields['alias'] = $data['alias'];
- $response = $this->modx->runProcessor('mgr/product/update', $fields, array('processors_path' => MODX_CORE_PATH . 'components/minishop2/processors/'));
- $flagNew = false;
- } else {
- $response = $this->modx->runProcessor('mgr/product/create', $fields, array('processors_path' => MODX_CORE_PATH . 'components/minishop2/processors/'));
- $flagNew = true;
- }
-
- /* @var modProcessorResponse $response */
- if ($response->isError()) {
- $message = $response->getMessage();
- if (empty($message)) {
- $message = $this->modx->lexicon('ms2form_err_form');
- }
- $tmp = $response->getFieldErrors();
- $errors = array();
- foreach ($tmp as $v) {
- $errors[$v->field] = $v->message;
- }
- return $this->error($message, $errors);
- }
- $productId = $response->response['object']['id'];
-
- //msProductCategoreisMemberProcessor
- $responseCategories = $this->modx->runProcessor('web/product/categories', array('productId' => $productId, 'categories' => $data['parents'], 'new' => $flagNew), array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
- if ($responseCategories->isError()) {
- return $this->error($responseCategories->getMessage());
- }
-
- // move msProductFiles
- if (empty($data['pid']) and $data['files']) {
- /** @var modProcessorResponse $responseMove */
- $responseMove = $this->modx->runProcessor('web/gallery/move_multiple', array('productId' => $productId, 'files' => $data['files'], 'source' => $source), array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
- if ($responseMove->isError()) {
- return $this->error($responseMove->getMessage(), $responseMove->getFieldErrors());
- }
- }
-
- // send email
- if ($bcc = $this->modx->getOption('ms2form_mail_bcc')) {
- $bcc = array_map('trim', explode(',', $bcc));
- if (!empty($bcc) && $resource = $this->modx->getObject('msProduct', $productId)) {
- $resource = $resource->toArray();
- foreach ($bcc as $uid) {
- if (!$this->modx->getOption('ms2form_mail_createdby')) {
- if ($uid == $resource['createdby']) {
- continue;
- }
- }
- $this->sendMail(
- $uid,
- $this->modx->lexicon('ms2form_email_bcc', $resource),
- $this->getChunk($this->config['tplEmailBcc'], $resource, false)
- );
- }
- }
- }
-
-
- // updateProductImage
- /* @var msProduct $product */
- $product = $this->modx->getObject('msProduct', $productId);
- $product->updateProductImage();
-
- //redirect
- $successMessage = '';
- $successData = array();
- if($data['redirectPublished'] == '0'){
- $successMessage = 'ms2form_published';
- }else if ($data['redirectPublished'] == 'new'){
- if (empty($data['published'])) {
- $productId = $data['parent'];
- }
- $successData['redirect'] = $this->modx->makeUrl($productId, '', '', $this->config['redirectScheme']);
- } else if ($data['redirectPublished']){
- $successData['redirect'] = $this->modx->makeUrl($data['redirectPublished'], '', '', $this->config['redirectScheme']);
- }
- return $this->success($successMessage, $successData);
- }
-
- /**
- * Create msCategory through processor
- *
- * @param array $data section, pagetitle, text, etc
- *
- * @return array
- */
-// public function categoryCreate (array $data){
-// $allowedFields = array_map('trim', explode(',', $this->config['allowedFields']));
-// $allowedFields = array_unique(array_merge($allowedFields, array('parent', 'pagetitle', 'content')));
-// $requiredFields = array_map('trim', explode(',', $this->config['requiredFields']));
-// $requiredFields = array_unique(array_merge($requiredFields, array('parent', 'pagetitle')));
-// if (!empty($this->config['parentMse2form'])) {
-// $allowedFields[] = $this->config['parentMse2form']['queryVar'];
-// $requiredFields[] = $this->config['parentMse2form']['queryVar'];
-// }
-// $fields = array();
-// foreach ($allowedFields as $field) {
-// if (in_array($field, $allowedFields) && array_key_exists($field, $data)) {
-// $value = $data[$field];
-// if ($field !== 'content') {
-// $value = $this->sanitizeString($value);
-// }
-// $fields[$field] = $value;
-// }
-// }
-// $errors = array();
-// foreach ($requiredFields as $v) {
-// if (empty($fields[$v])) {
-// $errors[$v] = $this->modx->lexicon('field_required');
-// }
-// }
-// if (!empty($errors)) {
-// return $this->error($this->modx->lexicon('ms2form_err_form'), $errors);
-// }
-//
-// $fields['class_key'] = 'msCategory';
-// $fields['content'] = $this->modx->getOption('ms2_category_content_default');
-//
-// //check of existence
-// $category = $this->modx->getObject('modResource', array(
-// 'parent' => $fields['parent']
-// ,'pagetitle' => $fields['pagetitle']
-// ));
-// if($category){
-// return $this->success('', array('id' => $category->get('id')));
-// }
-//
-// $response = $this->modx->runProcessor('resource/create', $fields);
-//
-// /* @var modProcessorResponse $response */
-// if ($response->isError()) {
-// $message = $response->getMessage();
-// if (empty($message)) {
-// $message = $this->modx->lexicon('ms2form_err_form');
-// }
-// $tmp = $response->getFieldErrors();
-// $errors = array();
-// foreach ($tmp as $v) {
-// $errors[$v->field] = $v->message;
-// }
-// return $this->error($message, $errors);
-// }
-// $categoryId = $response->response['object']['id'];
-//
-// return $this->success('', array('id'=> $categoryId));
-// }
-
- public function initializeMediaSource($ctx = '')
- {
- if (is_object($this->mediaSource) && $this->mediaSource instanceof modMediaSource) {
- return $this->mediaSource;
- } else {
- if ($this->mediaSource = $this->modx->getObject('sources.modMediaSource', $this->config['source'])) {
- if (empty($ctx)) {
- $ctx = $this->config['ctx'];
- }
- $this->mediaSource->set('ctx', $ctx);
- $this->mediaSource->initialize();
- $this->mediaSource->properties = $this->mediaSource->getProperties();
- return $this->mediaSource;
- } else {
- return false;
- }
- }
- }
-
- /**
- * Sanitize MODX tags
- *
- * @param string $string Any string with MODX tags
- *
- * @return string String with html entities
- */
- public function sanitizeString($string = '')
- {
- $string = htmlentities(trim($string), ENT_QUOTES, "UTF-8");
- $string = preg_replace('/^@.*\b/', '', $string);
-
- $arr1 = array('[', ']', '`');
- $arr2 = array('[', ']', '`');
- return str_replace($arr1, $arr2, $string);
- }
-
- public function getListTag($data)
- {
- /** @var modProcessorResponse $response */
- $response = $this->modx->runProcessor('web/product/getlist_tag', $data, array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
- if ($response->isError()) {
- return $this->error($response->getMessage());
- }
- $tags = $response->getObject();
- return $this->success('', $tags);
- }
-
- public function getListCategory($data)
- {
- $data['config'] = $this->config;
- /** @var modProcessorResponse $response */
- $response = $this->modx->runProcessor('web/product/getlist_category', $data, array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
- if ($response->isError()) {
- return $this->error($response->getMessage());
- }
- $tags = $response->getObject();
- return $this->success('', $tags);
- }
-
- public function sendMail($uid, $subject, $body)
- {
- /* @var modPHPMailer $mail */
- $mail = $this->modx->getService('mail', 'mail.modPHPMailer');
- $mail->setHTML(true);
- $mail->set(modMail::MAIL_SUBJECT, $subject);
- $mail->set(modMail::MAIL_BODY, $body);
- $mail->set(modMail::MAIL_SENDER, $this->modx->getOption('ms2form.mail_from', null, $this->modx->getOption('emailsender'), true));
- $mail->set(modMail::MAIL_FROM, $this->modx->getOption('ms2form.mail_from', null, $this->modx->getOption('emailsender'), true));
- $mail->set(modMail::MAIL_FROM_NAME, $this->modx->getOption('ms2form.mail_from_name', null, $this->modx->getOption('site_name'), true));
-
- /* get user and profile by user id */
- if ($user = $this->modx->getObject('modUser', $uid)) {
- $profile = $user->getOne('Profile');
- if (!$user->get('active') || $profile->get('blocked')) {
- return 'This user is not active.';
- }
- $email = $profile->get('email');
- } else {
- return "can not get user $uid";
- }
-
- $mail->address('to', $email);
- if (!$mail->send()) {
- $this->modx->log(xPDO::LOG_LEVEL_ERROR, 'An error occurred while trying to send the email: ' . $mail->mailer->ErrorInfo);
-
- $mail->reset();
- return false;
- }
-
- $mail->reset();
- return true;
-
- }
-}
+modx =& $modx;
+ $corePath = $this->modx->getOption('ms2form_core_path', $config, $this->modx->getOption('core_path') . 'components/ms2form/');
+ $assetsUrl = $this->modx->getOption('ms2form_assets_url', $config, $this->modx->getOption('assets_url') . 'components/ms2form/');
+ $actionUrl = $this->modx->getOption('ms2form_action_url', $config, $assetsUrl . 'action.php');
+ $disableHtmlpurifier = $this->modx->getOption('ms2form_disable_htmlpurifier');
+ if (empty($config['source'])) {
+ $config['source'] = $this->modx->getOption('ms2_product_source_default');
+ }
+ $connectorUrl = $assetsUrl . 'connector.php';
+
+ $this->config = array_merge(array(
+ 'assetsUrl' => $assetsUrl
+ , 'cssUrl' => $assetsUrl . 'css/'
+ , 'vendorUrl' => $assetsUrl . 'vendor/'
+ , 'connectorUrl' => $connectorUrl
+ , 'actionUrl' => $actionUrl
+ , 'modelPath' => $corePath . 'model/'
+ , 'corePath' => $corePath
+ , 'cultureKey' => $this->modx->getOption('cultureKey')
+ , 'disableHtmlpurifier' => $disableHtmlpurifier
+ , 'json_response' => true
+ , 'allowedTags' => $this->modx->getOption('allowedTags', $config, null)
+ ), $config);
+
+ $this->modx->lexicon->load('ms2form:default');
+
+ $this->authenticated = $this->modx->user->isAuthenticated($this->modx->context->get('key'));
+ }
+
+ /**
+ * Initializes component into different contexts.
+ *
+ * @param string $ctx The context to load. Defaults to web.
+ *
+ * @return array
+ */
+ public function initialize($ctx = 'web')
+ {
+ if (!$this->pdoTools) {
+ $this->loadPdoTools();
+ }
+ $this->pdoTools->setConfig($this->config);
+
+ $this->config['ctx'] = $ctx;
+ $this->initializeMediaSource($this->config['ctx']);
+
+ if (!empty($this->initialized[$ctx]) or ($ctx == 'mgr') or (MODX_API_MODE )) {
+ return $this->config;
+ }
+
+ $sorceProperties = $this->mediaSource->properties;
+ $this->config['sourceProperties'] = $sorceProperties;
+ $this->config['close_all_message'] = $this->modx->lexicon('ms2form_message_close_all');
+ $this->config['cssUrl'] = $this->config['cssUrl'] . 'web/';
+
+ //msearchform
+ if(!empty($this->config['parentMse2form'])){
+ $mse2FormConfig = array(
+ 'autocomplete' => 'results'
+ , 'queryVar' => 'query'
+ , 'minQuery' => 3
+ , 'fields' => 'pagetitle:1'
+ , 'pageId' => $this->modx->resource->id
+ , 'tplForm' => 'tpl.ms2form.mSearch2.form'
+ , 'tpl' => 'tpl.ms2form.mSearch2.ac'
+ , 'element' => 'mSearch2'
+ , 'limit' => 5
+ , 'onlyIndex' => false
+ , 'actionUrl' => '/assets/components/msearch2/action.php'
+ );
+ $mse2FormConfig = array_merge($mse2FormConfig, json_decode($this->config['parentMse2form'], true));
+ $mse2FormHash = sha1(serialize($mse2FormConfig));
+ $this->config['parentMse2form'] = $mse2FormConfig;
+ $this->config['mse2formKey'] = $mse2FormHash;
+ $_SESSION['mSearch2'][$mse2FormHash] = $mse2FormConfig;
+ }
+
+ // ms2form
+ $hash = sha1(serialize($this->config));
+ $this->config['formKey'] = $hash;
+ $_SESSION['ms2form'][$hash] = $this->config;
+
+ $config_js = preg_replace(array('/^\n/', '/\t{6}/'), '', '
+ Ms2formConfig = {
+ vendorUrl: "' . $this->config['vendorUrl'] . '"
+ ,assetsUrl: "' . $this->config['assetsUrl'] . '"
+ ,actionUrl: "' . $this->config['actionUrl'] . '"
+ ,cultureKey: "' . $this->config['cultureKey'] . '"
+ ,editor: "' . $this->config['editor'] . '"
+ '.(($this->config['allowedTags'])?',allowedTags: "'.implode(',', array_map('trim', explode(',', $this->config['allowedTags']))).'"':'').'
+ };
+ ');
+ $config_js = "";
+ $this->modx->regClientStartupScript($config_js, true);
+ if ($css = trim($this->modx->getOption('ms2form_frontend_css'))) {
+ $this->modx->regClientCSS($css);
+ }
+ if ($js = trim($this->modx->getOption('ms2form_frontend_js'))) {
+ if (!empty($js) && preg_match('/\.js/i', $js)) {
+ $jsCurl = $this->config['vendorUrl'] . 'curl/dist/curl-with-js-and-domReady/curl.js';
+ $this->modx->regClientScript($jsCurl);
+ $this->modx->regClientScript($js);
+ }
+ }
+ $this->initialized[$ctx] = true;
+ return $this->config;
+ }
+
+ /**
+ * Loads an instance of pdoTools
+ *
+ * @return boolean
+ */
+ public function loadPdoTools()
+ {
+ if (!is_object($this->pdoTools) || !($this->pdoTools instanceof pdoTools)) {
+ /** @var pdoFetch $pdoFetch */
+ $fqn = $this->modx->getOption('pdoFetch.class', null, 'pdotools.pdofetch', true);
+ if ($pdoClass = $this->modx->loadClass($fqn, '', false, true)) {
+ $this->pdoTools = new $pdoClass($this->modx, $this->config);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Method for transform array to placeholders
+ *
+ * @var array $array With keys and values
+ * @var string $prefix Prefix for array keys
+ *
+ * @return array $array Two nested arrays with placeholders and values
+ */
+ public function makePlaceholders(array $array = array(), $prefix = '')
+ {
+ if (!$this->pdoTools) {
+ $this->loadPdoTools();
+ }
+ return $this->pdoTools->makePlaceholders($array, $prefix);
+ }
+
+ /**
+ * Upload file for msproduct
+ *
+ * @param $data
+ *
+ * @return array|string
+ */
+ public function fileUpload($data)
+ {
+ if (!$this->authenticated || empty($this->config['allowFiles'])) {
+ //return $this->error('ms2form_err_access_denied');
+ }
+ $data['file'] = $_FILES['file'];
+ $data['rank'] = $_REQUEST['rank'];
+ $data['source'] = $this->config['source'];
+ /* @var modProcessorResponse $response */
+ $response = $this->modx->runProcessor('web/gallery/upload', $data, array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
+ if ($response->isError()) {
+ return $this->error($response->getMessage());
+ }
+ $file = $response->getObject();
+ $tpl = $file['type'] == 'image'
+ ? $this->config['tplImage']
+ : $this->config['tplFile'];
+ $html = $this->getChunk($tpl, $file);
+ return $this->success("ok", ['html' => $html, 'file' => $file]);
+ }
+
+ /**
+ * Delete uploaded file
+ *
+ * @param $id
+ *
+ * @return array|string
+ */
+ public function fileDelete($id)
+ {
+ if (!$this->authenticated || empty($this->config['allowFiles'])) {
+ return $this->error('ms2form_err_access_denied');
+ }
+ /** @var modProcessorResponse $response */
+ $response = $this->modx->runProcessor('web/gallery/delete', array('id' => $id, 'source' => $this->config['source']), array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
+ if ($response->isError()) {
+ return $this->error($response->getMessage());
+ }
+
+ return $this->success('', array('id' => $id));
+ }
+
+ /**
+ * Sort uploaded files
+ *
+ * @param $rank
+ *
+ * @return array|string
+ */
+ public function fileSort($rank) {
+ if (!$this->authenticated || empty($this->config['allowFiles'])) {
+ return $this->error('ms2form_err_access_denied');
+ }
+ /** @var modProcessorResponse $response */
+ $response = $this->modx->runProcessor('web/gallery/sort', array('rank' => $rank), array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
+ if ($response->isError()) {
+ return $this->error($response->getMessage());
+ }
+ return $this->success();
+ }
+
+ /**
+ * This method returns an error
+ *
+ * @param string $message A lexicon key for error message
+ * @param array $data .Additional data, for example cart status
+ * @param array $placeholders Array with placeholders for lexicon entry
+ *
+ * @return array|string $response
+ */
+ public function error($message = '', $data = array(), $placeholders = array())
+ {
+ header('HTTP/1.1 400 Bad Request');
+ $messageTranslation = $this->modx->lexicon($message, $placeholders);
+ if($messageTranslation){
+ $message = $messageTranslation;
+ }
+ $response = array(
+ 'success' => false
+ , 'message' => $message
+ , 'data' => $data
+ );
+ $this->modx->log(modX::LOG_LEVEL_ERROR, $message);
+ return $this->config['json_response']
+ ? $this->modx->toJSON($response)
+ : $response;
+ }
+
+ /**
+ * Process and return the output from a Chunk by name.
+ *
+ * @param string $name The name of the chunk.
+ * @param array $properties An associative array of properties to process the Chunk with, treated as placeholders within the scope of the Element.
+ * @param boolean $fastMode If false, all MODX tags in chunk will be processed.
+ *
+ * @return string The processed output of the Chunk.
+ */
+ public function getChunk($name, array $properties = array(), $fastMode = false)
+ {
+ if (!$this->modx->parser) {
+ $this->modx->getParser();
+ }
+ if (!$this->pdoTools) {
+ $this->loadPdoTools();
+ }
+
+ return $this->pdoTools->getChunk($name, $properties, $fastMode);
+ }
+
+ /**
+ * This method returns an success
+ *
+ * @param string $message A lexicon key for success message
+ * @param array $data .Additional data, for example cart status
+ * @param array $placeholders Array with placeholders for lexicon entry
+ *
+ * @return array|string $response
+ * */
+ public function success($message = '', $data = array(), $placeholders = array())
+ {
+ $response = array(
+ 'success' => true
+ , 'message' => $this->modx->lexicon($message, $placeholders)
+ , 'data' => $data
+ );
+ return $this->config['json_response']
+ ? $this->modx->toJSON($response)
+ : $response;
+ }
+
+ /**
+ * Create Product through processor and redirect
+ *
+ * @param array $data section, pagetitle, text, etc
+ *
+ * @return array
+ */
+ public function productSave(array $data)
+ {
+ $source = $this->config['source'];
+
+ $allowedFields = array_map('trim', explode(',', $this->config['allowedFields']));
+ $allowedFields = array_unique(array_merge($allowedFields, array('parent', 'pagetitle', 'content')));
+ $allowedFields = array_diff($allowedFields, array(''));
+ $requiredFields = array_map('trim', explode(',', $this->config['requiredFields']));
+ $requiredFields = array_unique(array_merge($requiredFields, array('parent', 'pagetitle')));
+ $requiredFields = array_diff($requiredFields, array(''));
+ if(!empty($this->config['parentMse2form'])){
+ $allowedFields[] = $this->config['parentMse2form']['queryVar'];
+ $requiredFields[] = $this->config['parentMse2form']['queryVar'];
+ }
+
+ $fields = array();
+ foreach ($allowedFields as $field) {
+ if (in_array($field, $allowedFields) && array_key_exists($field, $data)) {
+ $value = $data[$field];
+ if(is_array($value)){
+ foreach($value as $key => $item){
+ $value[$key] = $this->sanitizeString($item);
+ }
+ }else if($field !== 'content'){
+ $value = $this->sanitizeString($value);
+ }
+ $fields[$field] = $value;
+ }
+ }
+ // fix empty tags bug
+ if (!$data['tags']) {
+ $fields['tags'] = array();
+ }
+
+ $errors = array();
+ foreach ($requiredFields as $v) {
+ if (empty($fields[$v])) {
+ $errors[$v] = $this->modx->lexicon('field_required');
+ }
+ }
+ if (!empty($errors)) {
+ return $this->error($this->modx->lexicon('ms2form_err_form'), $errors);
+ }
+
+ $fields['class_key'] = 'msProduct';
+ $fields['source'] = $source;
+
+ //filter content
+ if(!$this->config['disableHtmlpurifier']){
+ require_once $this->config['corePath'] . '/vendor/autoload.php';
+ $purifierConfig = HTMLPurifier_Config::createDefault();
+ $purifier = new HTMLPurifier($purifierConfig);
+ $fields['content'] = $purifier->purify($fields['content']);
+ }
+ $fields['content'] = str_replace('
', '
', $fields['content']);
+
+ //update or create product
+ if (!empty($data['pid'])) {
+ $fields['id'] = (integer)$data['pid'];
+ $fields['context_key'] = $data['context_key'];
+ $fields['alias'] = $data['alias'];
+ $response = $this->modx->runProcessor('mgr/product/update', $fields, array('processors_path' => MODX_CORE_PATH . 'components/minishop2/processors/'));
+ $flagNew = false;
+ } else {
+ $response = $this->modx->runProcessor('mgr/product/create', $fields, array('processors_path' => MODX_CORE_PATH . 'components/minishop2/processors/'));
+ $flagNew = true;
+ }
+
+ /* @var modProcessorResponse $response */
+ if ($response->isError()) {
+ $message = $response->getMessage();
+ if (empty($message)) {
+ $message = $this->modx->lexicon('ms2form_err_form');
+ }
+ $tmp = $response->getFieldErrors();
+ $errors = array();
+ foreach ($tmp as $v) {
+ $errors[$v->field] = $v->message;
+ }
+ return $this->error($message, $errors);
+ }
+ $productId = $response->response['object']['id'];
+
+ //msProductCategoreisMemberProcessor
+ $responseCategories = $this->modx->runProcessor('web/product/categories', array('productId' => $productId, 'categories' => $data['parents'], 'new' => $flagNew), array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
+ if ($responseCategories->isError()) {
+ return $this->error($responseCategories->getMessage());
+ }
+
+ // move msProductFiles
+ if (empty($data['pid']) and $data['files']) {
+ /** @var modProcessorResponse $responseMove */
+ $responseMove = $this->modx->runProcessor('web/gallery/move_multiple', array('productId' => $productId, 'files' => $data['files'], 'source' => $source), array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
+ if ($responseMove->isError()) {
+ return $this->error($responseMove->getMessage(), $responseMove->getFieldErrors());
+ }
+ }
+
+ // send email
+ if ($bcc = $this->modx->getOption('ms2form_mail_bcc')) {
+ $bcc = array_map('trim', explode(',', $bcc));
+ if (!empty($bcc) && $resource = $this->modx->getObject('msProduct', $productId)) {
+ $resource = $resource->toArray();
+ foreach ($bcc as $uid) {
+ if (!$this->modx->getOption('ms2form_mail_createdby')) {
+ if ($uid == $resource['createdby']) {
+ continue;
+ }
+ }
+ $this->sendMail(
+ $uid,
+ $this->modx->lexicon('ms2form_email_bcc', $resource),
+ $this->getChunk($this->config['tplEmailBcc'], $resource, false)
+ );
+ }
+ }
+ }
+
+
+ // updateProductImage
+ /* @var msProduct $product */
+ $product = $this->modx->getObject('msProduct', $productId);
+ $product->updateProductImage();
+
+ //redirect
+ $successMessage = '';
+ $successData = array();
+ if($data['redirectPublished'] == '0'){
+ $successMessage = 'ms2form_published';
+ }else if ($data['redirectPublished'] == 'new'){
+ if (empty($data['published'])) {
+ $productId = $data['parent'];
+ }
+ $successData['redirect'] = $this->modx->makeUrl($productId, '', '', $this->config['redirectScheme']);
+ } else if ($data['redirectPublished']){
+ $successData['redirect'] = $this->modx->makeUrl($data['redirectPublished'], '', '', $this->config['redirectScheme']);
+ }
+ return $this->success($successMessage, $successData);
+ }
+
+ /**
+ * Create msCategory through processor
+ *
+ * @param array $data section, pagetitle, text, etc
+ *
+ * @return array
+ */
+ public function categoryCreate (array $data){
+ $allowedFields = array_map('trim', explode(',', $this->config['allowedFields']));
+ $allowedFields = array_unique(array_merge($allowedFields, array('parent', 'pagetitle', 'content')));
+ $requiredFields = array('parent', 'pagetitle');
+ if (!empty($this->config['parentMse2form'])) {
+ $allowedFields[] = $this->config['parentMse2form']['queryVar'];
+ $requiredFields[] = $this->config['parentMse2form']['queryVar'];
+ }
+ $fields = array();
+ foreach ($allowedFields as $field) {
+ if (in_array($field, $allowedFields) && array_key_exists($field, $data)) {
+ $value = $data[$field];
+ if ($field !== 'content') {
+ $value = $this->sanitizeString($value);
+ }
+ $fields[$field] = $value;
+ }
+ }
+ $errors = array();
+ foreach ($requiredFields as $v) {
+ if (empty($fields[$v])) {
+ $errors[$v] = $this->modx->lexicon('field_required');
+ }
+ }
+ if (!empty($errors)) {
+ return $this->error($this->modx->lexicon('ms2form_err_form'), $errors);
+ }
+
+ $fields['class_key'] = 'msCategory';
+ $fields['content'] = $this->modx->getOption('ms2_category_content_default');
+ $fields['published'] = 1;
+
+ //check of existence
+ $category = $this->modx->getObject('modResource', array(
+ 'parent' => $fields['parent']
+ ,'pagetitle' => $fields['pagetitle']
+ ));
+ if($category){
+ return $this->success('', array('id' => $category->get('id')));
+ }
+
+ $response = $this->modx->runProcessor('resource/create', $fields);
+
+ /* @var modProcessorResponse $response */
+ if ($response->isError()) {
+ $message = $response->getMessage();
+ if (empty($message)) {
+ $message = $this->modx->lexicon('ms2form_err_form');
+ }
+ $tmp = $response->getFieldErrors();
+ $errors = array();
+ foreach ($tmp as $v) {
+ $errors[$v->field] = $v->message;
+ }
+ return $this->error($message, $errors);
+ }
+ $categoryId = $response->response['object']['id'];
+
+ return $this->success('', array('id'=> $categoryId));
+ }
+
+ public function initializeMediaSource($ctx = '')
+ {
+ if (is_object($this->mediaSource) && $this->mediaSource instanceof modMediaSource) {
+ return $this->mediaSource;
+ } else {
+ if ($this->mediaSource = $this->modx->getObject('sources.modMediaSource', $this->config['source'])) {
+ if (empty($ctx)) {
+ $ctx = $this->config['ctx'];
+ }
+ $this->mediaSource->set('ctx', $ctx);
+ $this->mediaSource->initialize();
+ $this->mediaSource->properties = $this->mediaSource->getProperties();
+ return $this->mediaSource;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Sanitize MODX tags
+ *
+ * @param string $string Any string with MODX tags
+ *
+ * @return string String with html entities
+ */
+ public function sanitizeString($string = '')
+ {
+ $string = htmlentities(trim($string), ENT_QUOTES, "UTF-8");
+ $string = preg_replace('/^@.*\b/', '', $string);
+
+ $arr1 = array('[', ']', '`');
+ $arr2 = array('[', ']', '`');
+ return str_replace($arr1, $arr2, $string);
+ }
+
+ public function getListTag($data)
+ {
+ /** @var modProcessorResponse $response */
+ $response = $this->modx->runProcessor('web/product/getlist_tag', $data, array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
+ if ($response->isError()) {
+ return $this->error($response->getMessage());
+ }
+ $tags = $response->getObject();
+ return $this->success('', $tags);
+ }
+
+ public function getListCategory($data)
+ {
+ $data['config'] = $this->config;
+ /** @var modProcessorResponse $response */
+ $response = $this->modx->runProcessor('web/product/getlist_category', $data, array('processors_path' => dirname(dirname(dirname(__FILE__))) . '/processors/'));
+ if ($response->isError()) {
+ return $this->error($response->getMessage());
+ }
+ $tags = $response->getObject();
+ return $this->success('', $tags);
+ }
+
+ public function sendMail($uid, $subject, $body)
+ {
+ /* @var modPHPMailer $mail */
+ $mail = $this->modx->getService('mail', 'mail.modPHPMailer');
+ $mail->setHTML(true);
+ $mail->set(modMail::MAIL_SUBJECT, $subject);
+ $mail->set(modMail::MAIL_BODY, $body);
+ $mail->set(modMail::MAIL_SENDER, $this->modx->getOption('ms2form.mail_from', null, $this->modx->getOption('emailsender'), true));
+ $mail->set(modMail::MAIL_FROM, $this->modx->getOption('ms2form.mail_from', null, $this->modx->getOption('emailsender'), true));
+ $mail->set(modMail::MAIL_FROM_NAME, $this->modx->getOption('ms2form.mail_from_name', null, $this->modx->getOption('site_name'), true));
+
+ /* get user and profile by user id */
+ if ($user = $this->modx->getObject('modUser', $uid)) {
+ $profile = $user->getOne('Profile');
+ if (!$user->get('active') || $profile->get('blocked')) {
+ return 'This user is not active.';
+ }
+ $email = $profile->get('email');
+ } else {
+ return "can not get user $uid";
+ }
+
+ $mail->address('to', $email);
+ if (!$mail->send()) {
+ $this->modx->log(xPDO::LOG_LEVEL_ERROR, 'An error occurred while trying to send the email: ' . $mail->mailer->ErrorInfo);
+
+ $mail->reset();
+ return false;
+ }
+
+ $mail->reset();
+ return true;
+
+ }
+}
diff --git a/core/components/ms2form/processors/web/product/categories.class.php b/core/components/ms2form/processors/web/product/categories.class.php
index ef089fc..e3511ca 100755
--- a/core/components/ms2form/processors/web/product/categories.class.php
+++ b/core/components/ms2form/processors/web/product/categories.class.php
@@ -24,6 +24,19 @@ public function process() {
return $this->error('empty property product_id');
}
+ foreach ( $catIds as $key => $tmp ) {
+ $tmpcat = $this->modx->getObject('msCategory', intval($tmp));
+ if ( !$tmpcat ) {
+ $tmpcat = $this->modx->newObject('msCategory');
+ $tmpcat->fromArray(array(
+ 'pagetitle' => $tmp,
+ 'parent' => $this->modx->getOption('ms2form_categories_parent', $scriptProperties, 0),
+ 'published' => 1
+ ));
+ $tmpcat->save();
+ $catIds[$key] = $tmpcat->get('id');
+ }
+ }
if (!$flagNew) {
$msCatMembers = $this->modx->getCollection('msCategoryMember', array('product_id' => $productId));
diff --git a/core/components/ms2form/processors/web/product/getlist_tag.class.php b/core/components/ms2form/processors/web/product/getlist_tag.class.php
index 4367729..6fe6de1 100755
--- a/core/components/ms2form/processors/web/product/getlist_tag.class.php
+++ b/core/components/ms2form/processors/web/product/getlist_tag.class.php
@@ -10,6 +10,7 @@ class ms2FormProductGetTagsListProcessor extends modObjectProcessor{
/** @var pdoFetch $pdoFetch */
private $pdoFetch;
private $pid;
+ private $allowedTags;
public $languageTopics = array('ms2form:default');
public function initialize() {
@@ -18,30 +19,40 @@ public function initialize() {
$properties = $this->getProperties();
$this->pdoFetch = new $pdoClass( $this->modx, (empty($properties))? array() : $properties);
$this->pid = $this->getProperty('pid');
+ $this->allowedTags = explode(',', $this->getProperty('allowedTags'));
return true;
}
public function process(){
$result = array();
- $queryAll = array(
- 'class' => $this->classKey
- ,'where' => $this->modx->toJSON(['key'=>'tags'])
- ,'select' => $this->modx->toJSON(['value'=>'msProductOption.value'])
- ,'groupby' => 'msProductOption.value'
- ,'limit' => 0
- ,'fastMode' => true
- ,'sortby' => 'msProductOption.value'
- ,'sortdir' => 'ASC'
- ,'return' => 'data'
- );
- $this->pdoFetch->setConfig($queryAll);
- $tagsAll = $this->pdoFetch->run();
- $tagsAll = array_map(function($tag) {
- return array(
- 'id' => $tag['value'],
- 'text' => $tag['value']
- );
- }, $tagsAll);
- $result['all'] = $tagsAll;
+ if ( !empty($this->allowedTags[0]) ) {
+ $tagsAll = array_map(function($tag) {
+ return array(
+ 'id' => trim($tag),
+ 'text' => trim($tag)
+ );
+ }, $this->allowedTags);
+ } else {
+ $queryAll = array(
+ 'class' => $this->classKey
+ ,'where' => $this->modx->toJSON(['key'=>'tags'])
+ ,'select' => $this->modx->toJSON(['value'=>'msProductOption.value'])
+ ,'groupby' => 'msProductOption.value'
+ ,'limit' => 0
+ ,'fastMode' => true
+ ,'sortby' => 'msProductOption.value'
+ ,'sortdir' => 'ASC'
+ ,'return' => 'data'
+ );
+ $this->pdoFetch->setConfig($queryAll);
+ $tagsAll = $this->pdoFetch->run();
+ $tagsAll = array_map(function($tag) {
+ return array(
+ 'id' => $tag['value'],
+ 'text' => $tag['value']
+ );
+ }, $tagsAll);
+ }
+ $result['all'] = $tagsAll;
if($this->pid !== '0'){
$queryProduct = array(
diff --git a/ms2form-1.3.2-beta.transport.zip b/ms2form-1.3.2-beta.transport.zip
new file mode 100644
index 0000000..2445249
Binary files /dev/null and b/ms2form-1.3.2-beta.transport.zip differ
diff --git a/ms2form-1.3.3-beta.transport.zip b/ms2form-1.3.3-beta.transport.zip
new file mode 100644
index 0000000..3f748bb
Binary files /dev/null and b/ms2form-1.3.3-beta.transport.zip differ
diff --git a/ms2form-1.3.4-beta.transport.zip b/ms2form-1.3.4-beta.transport.zip
new file mode 100644
index 0000000..bac95f2
Binary files /dev/null and b/ms2form-1.3.4-beta.transport.zip differ
diff --git a/ms2form-1.3.5-beta.transport.zip b/ms2form-1.3.5-beta.transport.zip
new file mode 100644
index 0000000..a82f395
Binary files /dev/null and b/ms2form-1.3.5-beta.transport.zip differ