'use strict'; CKEDITOR.dialog.add( 'variablessob', function(editor) { let validNameRegex = /^\$\{[a-zA-z0-9_.]+\}/; let value = ''; return { title: "Собственник", minHeight: 60, minWidth: 280, contents: [ { id: 'infosob', label: "Собственник", title: "Собственник", elements: [ { id: 'name', type: 'select', style: 'width: 100%;', className: 'fastselect', label: "Выберите переменную:", multiple: true, items: editor.config.customValues.variablesListSob, 'default': '', // required: true, //validate: CKEDITOR.dialog.validate.regex(validNameRegex, "Неверный формат переменной"), setup: function(widget) { //console.log(widget.data); value = ''; this.setValue("${*" + widget.data.name + "*}"); }, onLoad: function(elem) { value = ''; let select_id = '#' + this._.inputId; let select = $(select_id).clone(); select.find('option').first().before(''); $(select_id).closest('.cke_dialog_ui_labeled_content').html(select); $(select_id).closest('.cke_dialog_container').removeClass('cke_reset_all'); $(select_id).closest('.cke_dialog_container').find('label[for="'+this._.inputId+'"]').remove(); $(select_id).fastselect({ placeholder: "Выберите поля собственника", onItemSelect: function(item, model) { console.log(item); console.log(model); if(value != ''){ value += ' '; } value += model.value; }, }); $(select_id).closest(".fstElement").find(".fstControls input.hidenClass").attr('type', "text"); $(select_id).closest(".fstElement").find(".fstControls input.hidenClass").removeClass('hidenClass'); }, onShow: function(widget) { value = ''; let select_id = '#' + this._.inputId; let select = $(select_id).clone(); $(select_id).closest('.cke_dialog_ui_labeled_content').html(select); $(select_id).closest('.cke_dialog_container').removeClass('cke_reset_all'); $(select_id).closest('.cke_dialog_container').find('label[for="'+this._.inputId+'"]').remove(); $(select_id).fastselect({ placeholder: "Выберите переменную", onItemSelect: function(item, model) { console.log(item); console.log(model); if(value != ''){ value += ' '; } value += model.value; }, onItemDelete: function(model) { // console.log('%'+model.value+'%'); value = value.replace(model.value,''); value = value.replace(' ',' '); console.log(value); } }); $(select_id).closest(".fstElement").find(".fstControls input.hidenClass").attr('type', "text"); $(select_id).closest(".fstElement").find(".fstControls input.hidenClass").removeClass('hidenClass'); }, commit: function(widget) { let select_id = '#' + this._.inputId; let vals = $(select_id).val(); //console.log($(select_id)); console.log(value); /*let variable = ''; for(var i=0; i