�PNG  IHDR22?�� pHYs  �� OiCCPPhotoshop ICC profilexڝSgTS�=���BK���KoR RB���&*! J�!��Q�EEȠ�����Q, � ��!���������{�kּ������>���� �H3Q5� �B�������.@� $p�d!s�#�~<<+"��x� �M��0���B�\���t�8K�@z�B�@F���&S�`�cb�P-`'������{[�!�� e�Dh;��V�EX0fK�9�-0IWfH���� � 0Q��){`�##x��F�W<�+��*x��<�$9E�[-qWW.(�I+6aa�@.�y�2�4���������x����6��_-��"bb���ϫp@�t~��,/��;�m��%�h^ �u��f�@����W�p�~<�5�j>{�-�]c�K'Xt����o��(�h���w��?�G�%�fI�q^D$.Tʳ?�D��*�A��,���� �`6�B$��BB d�r`)��B(�Ͱ*`/�@4�Qh��p.�U�=p�a��(�� A�a!ڈb�X#����!�H�$ ɈQ"K�5H1R�T UH�=r9�\F��;�2����G1���Q=� �C��7�F� �dt1�����r�=�6��Ыhڏ>C�0��3�l0.��B�8, �c˱"� ���V����cϱw�E� 6wB aAHXLXN�H� $4� 7 �Q�'"��K�&���b21�XH,#��/{�C�7$�C2'��I��T��F�nR#�,��4H#���dk�9�, +ȅ����3��!�[ �b@q��S�(R�jJ��4�e�2AU��Rݨ�T5�ZB���R�Q��4u�9̓IK�����hh�i��t�ݕN��W���G���w ��Ljg(�gw��L�Ӌ�T071���oUX*�*|�� �J�&�*/T����ު U�U�T��^S}�FU3S� Ԗ�U��P�SSg�;���g�oT?�~Y��Y�L�OC�Q��_�� c�x,!k ��u�5�&���|v*�����=���9C3J3W�R�f?�q��tN �(���~���)�)�4L�1e\k����X�H�Q�G�6������E�Y��A�J'\'Gg����S�Sݧ �M=:��.�k���Dw�n��^��Lo��y���}/�T�m���G X� $� �<�5qo</���QC]�@C�a�a�ᄑ��<��F�F�i�\�$�m�mƣ&&!&KM�M�RM��)�;L;L���͢�֙5�=1�2��כ߷`ZxZ,����eI��Z�Yn�Z9Y�XUZ]�F���%ֻ�����N�N���gð�ɶ�����ۮ�m�}agbg�Ů��}�}��= ���Z~s�r:V:ޚΜ�?}����/gX���3��)�i�S��Ggg�s�󈋉K��.�>.���Ƚ�Jt�q]�z���������ۯ�6�i�ܟ�4�)�Y3s���C�Q��? ��0k߬~OCO�g��#/c/�W�װ��w��a�>�>r��>�<7�2�Y_�7��ȷ�O�o�_��C#�d�z����%g��A�[��z|!��?:�e����A���AA�������!h�쐭!��Α�i�P~���a�a��~ '���W�?�p�X�1�5w��Cs�D�D�Dޛg1O9�-J5*>�.j<�7�4�?�.fY��X�XIlK9.*�6nl������� �{�/�]py�����.,:�@L�N8��A*��%�w%� y��g"/�6ш�C\*N�H*Mz�쑼5y$�3�,幄'���L Lݛ:��v m2=:�1����qB�!M��g�g�fvˬe����n��/��k���Y- �B��TZ(�*�geWf�͉�9���+��̳�ې7�����ᒶ��KW-X潬j9�������(�x��oʿ�ܔ���Ĺd�f�f���-�[����n �ڴ �V����E�/��(ۻ��C���<��e����;?T�T�T�T6��ݵa��n��{��4���[���>ɾ�UUM�f�e�I���?�������m]�Nmq����#�׹���=TR��+�G�����w- 6 U����#pDy��� �� :�v�{���vg/jB��F�S��[b[�O�>����z�G��499�?r����C�d�&����ˮ/~�����јѡ�򗓿m|������������x31^�V���w�w��O�| (�h���SЧ��������c3-� cHRMz%������u0�`:�o�_�F5IDATx��ytUս�?�;���fN$$��@B�!�k��� -*�gE���j�O�kQ�ʠ`U�B_ �AÐ0%�Ȕ�@r3ޛ;߳��$�@��v����^�s����������$��ߢ !�W��5�̱'-٘������4�>�Rƫ$�G��0U�H}�_ _� #��k�MJ/=�9Du *ڲ�k�PQ;0��j|�*�$�^컂脛y���>�z×� B��� ��(�:$�ʔ_�6��C!B����MVx��a��ζyY����j��ƋY2�9�F�{r��r�딟F��Q��hY6��� x��[l��RC��������nt@��;P��3��� F�w��7��:�P���ɋ'���mj���Bƪ�$�Q�L��y��߷g��\���z����v5�p�v$�v櫻�`6~K �Y�X����,�:��"�o�e0II"(��,������l_�C���/4�+f�E�!q��:����u����c��樼.UE�@� �]K�W���$-�h]�JG���Dz)�`��.�A/ ���mᏣc�3jK� �!�>���$�Q�!�_�? \�C2(E �M$Z I{�U���s�ǣ���=��@Բe ޻��W�����@ �w����}�9v,)��.}*|"�s��di���,���G�]W�AC�������|<����[��ߕ������K�*�G nߴ!��‹��J�!��6(L�a)��Am��������;adf��:�xm��nh�;֦I��(���o�C~ډa?�=��s����h��E������xp����)���_���t��W�����´;8���`dz=(��@@�+,�;�`�fhl��XȌ�3,uI�~z(J����� �ZX�A����H'�À�㜦�82|��a�n�z2��I���� ���EY�h�ε<�0�q�{��C��v�˅��?"@��χ�x�WS+��N�~�KQ�J�8ل�� _.W��� !TU{�����,��"�� �;�������HI S� ��))�o�1�H�D� ���� (� ;����"Ҕ��,���� �F=���O��&�Ph>�`���y��߲ &S��P�<��'��1s�1cĂ�N����2)����@�u��tv��<�+�-&�����h��[!FSG���' � z z0��<����8d&�����E0�,��<��"!P�b4��� �{S�����X����.�囤���T��hEF��X�q0"-<����h���]�Py*����F⩍��@v�˂�Y08�� .q��a��s����(!<̫1�3�L�H��7sYW�`��qtu�\7��?�@�Y�� %Ka�x�GZ�*W�P��y�����N0r9��Z�c�%���q,��k�����!!,��>���IB��� �x1�Xu�Y���v-���ֺ��N������JP��a�2`�e5��w��u;�6�i���̃��(K���ťa��(l51��JL��O'%���]���ٖ뿉!��{*�p+f ���i8��D�ȑ���ܩ�M��V��ӟz��x�7Z�1i}�^͜���6e����x��)u�d�ˏ�V�eG�\�X1�����=n�U'�~Y����L�\,�(d!x ,�:�TW8� M`r���@��r+v�Q0��>^;˴�VbF��('����� �*O��i��j�Ӆ����^�S3&� ���{������.ی�� N;��NU%d0�Ce\r"�C�b��&t7N�7��� �ȪD�[%l�۪�$��'m?�A9tI�9>��NVL ��� 6v~M�����ъ�B���0����9$&=ώm��W�0���L���&��E���f�f��'+�9��hv��7,���M��6�D�&�^� �����8 D֮�����o��k^z��O��hP�8q�5d*��YVq3�{��������#LX4�?��jP=3�~�؅c�ݰ�̱�ұ��8̲��2�G�����j��έ�9��w7���U�X�w�85C��?!I&���o&����L���I#�^�eV�,�^t5�k� �xs˛\��U�8��."���{���ǵ�l4��ݼ�;��r"���G�/~���gJV�N糦��ZZ^k+NN�D��I$�=OE�z����|*�*{��%k���G��>�`9��b;�s���8,�qs��c��.b��q�%�>r��n�R�Ƨ�%�,�A��le#�8���}; 21�0�b�&�QX�f���q�00����$>�h�N�'�a3��A���/�r ��L5�8�GԲ'�����w;��c#�q1���h$*��V^�k��QĽ�b:i������� ����H F#�_���,��]g����Ը����`RUU���� ��"�qD���>-��ϤI�~��3�̴�����NZ[[555�eeek7�m����YF#[��Đ��R��i��L�H�r ��@��J-�Pŝ��_|�-��6y��ks�V�U~��6���w.����(��0A� 4��f��� /���C�xŊ�ٳ����z=6�����rg���mKo��o�/����a�g���?'9%9��P��斓��~���L{�� �H��{AW��B��$����v�1b�&Mb�ر��ر#�0`�`xMBp! )Z�Nmo�mZ�g�}�eذaWTVV ���'99��C5��&�&+5�bT>|8��PUUETT����&���t��~TE%��'������b�tEGG;RSS�S�N�v��ѯ��t����u1@�ޚ"f��͈���r'L�Ph��m��ƌ�74o��`�x�q�P���NRSS�X,�����l&&&��MFFA!-��`��ҷ�n��Yuu�����x<I�LB%����KԒ50�!�3�bz�����ʸKL���;---�l6[��`��������Ȏ;�����egg4��!D�T��jWujyZ��������K����%����p�^���X,6��sV=�ܖ����6�3�X ���4ҿ��A2�&����_k�;d�� �VfOIEND�B`�
Warning: session_start(): Session cannot be started after headers have already been sent in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 124

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 130

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 131

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 132

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 133

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 134

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 135
0x0x
PHP 8.2.31
Preview: module.js Size: 24.33 KB
/home/mciraet/www/wp-content/plugins/js_composer/modules/automapper/assets/js/module.js
/* =========================================================
 * composer-automapper.js v0.2.1
 * =========================================================
 * Copyright 2013 Wpbakery
 *
 * WPBakery Page Builder automapper for shortcodes
 * ========================================================= */
var vc_am = {
	current_form: false
};
window.i18nLocaleVcAutomapper = window.i18nLocaleSettings;
( function ( $ ) {
	'use strict';

	function VCS4 () {
		return ( ( ( 1 + Math.random() ) * 0x10000 ) | 0 ).toString( 16 ).substring( 1 );
	}

	var EditFormView;
	var request_url, sync_callback;
	vc_am.vcGuid = function () {
		return ( VCS4() + VCS4() + '-' + VCS4() );
	};
	_.extend( wp.shortcode.prototype, {
		taggedString: function () {
			var text = '[<span class="vc_preview-tag">' + _.escape( this.tag ) + '</span>';

			_.each( this.attrs.numeric, function ( value ) {
				if ( /\s/.test( value ) ) {
					text += ' <span class="vc_preview-param">"' + _.escape( value ) + '"</span>';
				} else {
					text += ' <span class="vc_preview-param">' + _.escape( value ) + '</span>';
				}
			});

			_.each( this.attrs.named, function ( value, name ) {
				text += ' <span class="vc_preview-param">' + _.escape( name ) + '="' + _.escape( value ) + '"</span>';
			});

			// If the tag is marked as `single` or `self-closing`, close the
			// tag and ignore any additional content.
			if ( 'single' === this.type ) {
				return text + ']';
			} else if ( 'self-closing' === this.type ) {
				return text + ' /]';
			}

			// Complete the opening tag.
			text += ']';

			if ( this.content ) {
				text += '<span class="vc_preview-content">' + _.escape( this.content ) + '</span>';
			}

			// Add the closing tag.
			return text + '[/<span class="vc_preview-tag">' + _.escape( this.tag ) + '</span>]';
		}
	});
	wp.shortcode.atmPreview = function ( options ) {
		return new wp.shortcode( options ).taggedString();
	};

	var $vcSettings = $( '#vc_settings-automapper' );

	function show_message ( text, type ) {
		if ( message_timer ) {
			window.clearTimeout( message_timer );
			$( '.vc_settings-automapper' ).remove();
			message_timer = false;
		}
		var $message = $( '<div class="vc_atm-message updated' + ( type ? ' vc_message-' + type : '' ) + '" style="display: none;"></div>' );
		$message.text( text );
		$message.prependTo( $vcSettings ).fadeIn( 500, function () {
			var $message = $( this );
			window.setTimeout( function () {
				$message.remove();
			}, 5000 );
		});
	}

	var message_timer, to_title;

	to_title = function ( string ) {
		string = string.replace( /_|-/, ' ' );
		return string.charAt( 0 ).toUpperCase() + string.slice( 1 );
	};

	function showMessageMore ( text, typeClass, timeout, remove ) {
		if ( remove ) {
			$( '.vc_atm-message' ).remove();
		}
		var $message = $( '<div class="vc_atm-message ' + ( typeClass ? typeClass : '' ) + '" style="display: none;"></div>' );
		$message.text( text );
		if ( !_.isUndefined( timeout ) ) {
			window.setTimeout( function () {
				$message.remove();
			}, timeout );
		}
		return $message;
	}

	function showValidationError ( text, $el ) {
		if ( _.isUndefined( $el ) || !$el.length ) {
			$el = $( '.tab_intro' );
		}
		showMessageMore( text, 'error', undefined, true ).insertBefore( $el ).fadeIn( 500 );
	}

	var question = '?';
	if ( window.ajaxurl.indexOf( '?' ) > - 1 ) {
		question = '&';
	}
	request_url = window.ajaxurl + question + 'vc_action=automapper';
	sync_callback = function ( method, model, options ) {
		var data;
		if ( 'create' === method ) {
			model.set( 'id', vc_am.vcGuid() );
			data = {
				vc_action: 'create',
				action: 'vc_automapper_create',
				data: model.toJSON()
			};
		} else if ( 'update' === method ) {
			data = {
				vc_action: 'update',
				action: 'vc_automapper_update',
				id: model.get( 'id' ),
				data: model.toJSON()
			};
		} else if ( 'delete' === method ) {
			data = {
				vc_action: 'delete',
				action: 'vc_automapper_delete',
				id: model.get( 'id' )
			};
		} else {
			data = {
				vc_action: 'read',
				action: 'vc_automapper_read'
			};
		}
		$.ajax({
			method: 'POST',
			url: request_url,
			dataType: 'json',
			data: _.extend( data, { _vcnonce: window.vcAdminNonce }),
			context: this
		}).done( function ( response ) {
			if ( !response.success ) {
				return;
			}
			var data = response.data;
			var result = model;
			if ( data && 'read' === method ) {
				result = data;
			}
			// Response
			if ( result ) {
				if ( 'read' === method ) {
					options.success( result );
				}
			} else {
				options.error( 'Not found' );
			}
		}).fail( function ( response ) {
			options.error( response );
		});
	};
	var ShortcodeModel = Backbone.Model.extend({
		defaults: function () {
			return {
				tag: '',
				name: '',
				category: '',
				description: '',
				params: []
			};
		},
		sync: sync_callback
	});
	var ShortcodesCollection = Backbone.Collection.extend({
		model: ShortcodeModel,
		sync: sync_callback
	});
	vc_am.shortcodes = new ShortcodesCollection();

	// TODO: check if ShortcodeView is used
	// eslint-disable-next-line no-unused-vars
	var ShortcodeView = Backbone.View.extend({
		tagName: 'li',
		// className: 'vc_automapper-item',
		className: 'widget',
		events: {
			'click .vc_automapper-edit-btn': 'edit',
			'click h4, widget-action': 'edit',
			'click .vc_automapper-delete-btn': 'clear'
		},
		template_html: $( '#vc_automapper-item-tpl' ).html() || '<span>{{ tag }}</span>',
		initialize: function () {
			this.listenTo( this.model, 'change', this.render );
			this.listenTo( this.model, 'destroy', this.removeView );
		},
		render: function () {
			var template = vc.template( this.template_html, vc.templateOptions.custom );
			this.$el.html( template( this.model.toJSON() ) ).attr( 'data-item-id', this.model.get( 'id' ) );
			return this;
		},
		edit: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			new EditFormView({ model: this.model }).render();
		},
		clear: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			if ( confirm( window.i18nLocaleVcAutomapper.are_you_sure_delete ) ) {
				this.model.destroy();
			}
		},
		removeView: function () {
			this.$el.remove();
		}
	});
	var FormView = Backbone.View.extend({
		render: function () {
			if ( vc_am.current_form ) {
				vc_am.current_form.close();
			}
			vc_am.current_form = this;
			return this;
		},
		getType: function () {
			return 'form';
		},
		validate: function ( attrs ) {
			var result = false;
			if ( !attrs.name ) {
				return window.i18nLocaleVcAutomapper.error_shortcode_name_is_required;
			}
			if ( !attrs.tag || !attrs.tag.match( /^\S+$/ ) ) {
				return window.i18nLocaleVcAutomapper.error_enter_valid_shortcode_tag;
			}
			var fields_required = [
				'param_name',
				'heading',
				'type'
			];
			_.each( attrs.params, function ( param ) {
				_.each( fields_required, function ( field ) {
					if ( '' === param[ field ]) {
						result = window.i18nLocaleVcAutomapper.error_enter_required_fields; // '';
					} else if ( 'param_name' === field && !param[ field ].match( /^[a-z0-9_]+$/g ) ) {
						result = window.i18nLocaleVcAutomapper.error_enter_required_fields;
					}
				}, this );
			}, this );
			return result || null;
		},
		isValid: function ( data ) {
			this.validationError = this.validate( data );
			return this.validationError ? false : true;
		},
		close: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			vc_am.current_form = false;
			this.remove();
		}
	});
	var ComplexShortcodeView = Backbone.View.extend({
		_$widget_title: false,
		_$form_view: false,
		edit_view: false,
		tagName: 'li',
		className: 'widget',
		events: {
			'click .vc_automapper-edit-btn': 'edit',
			'click h4, .widget-action': 'edit'
		},
		template_html: $( '#vc_automapper-item-complex-tpl' ).html() || '<span>{{ tag }}</span>',
		header_template_html: '<h4>{{ name }}<span class="in-widget-title"></span></h4>',
		initialize: function () {
			_.bindAll( this, 'removeEditForm' );
			this.listenTo( this.model, 'destroy', this.removeView );
			this.model.view = this;
		},
		render: function () {
			var template = vc.template( this.template_html, vc.templateOptions.custom );
			this.$el.html( template( this.model.toJSON() ) ).attr( 'data-item-id', this.model.get( 'id' ) );
			return this;
		},
		renderTitle: function () {
			var template = vc.template( this.header_template_html, vc.templateOptions.custom );
			this.$widgetTitle().html( template( this.model.toJSON() ) );
		},
		edit: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			if ( this.$editForm().is( ':animated' ) ) {
				return false;
			}
			this.$el.addClass( 'vc_opened' );
			if ( this.edit_view ) {
				this.close();
			} else {
				this.edit_view = new EditFormInnerView({ model: this.model }).render();
			}
		},
		$widgetTitle: function () {
			if ( !this._$widget_title ) {
				this._$widget_title = this.$el.find( '.widget-title' );
			}
			return this._$widget_title;
		},
		$editForm: function () {
			if ( !this._$edit_form ) {
				this._$edit_form = this.$el.find( '.widget-inside' );
			}
			return this._$edit_form;
		},
		removeEditForm: function () {
			if ( this.edit_view ) {
				this.edit_view.remove();
			}
			this.edit_view = false;
		},
		beforeSave: function () {
			this.$el.find( '#vc_atm-name' ).val( $( '#vc_atm-header-name' ).val() );
		},
		close: function () {
			vc_am.current_form = false;
			this.$el.removeClass( 'vc_opened' );
			this.renderTitle();
			this.$editForm().slideUp( 200 );
			this.removeEditForm(); // delayed call causes bug with empty params(remove called with delay)
		},
		clear: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			this.model.destroy();
		},
		removeView: function () {
			this.remove();
		}
	});

	var AddFormView = FormView.extend({
		className: 'vc_add-form-atm',
		template_html: $( '#vc_automapper-add-form-tpl' ).html(),
		events: {
			'click #vc_atm-parse-string': 'parseShortcode',
			'click .vc_atm-cancel': 'close'
		},
		getType: function () {
			return 'create';
		},
		render: function () {
			AddFormView.__super__.render.call( this );
			var template = vc.template( this.template_html, vc.templateOptions.custom );
			this.$el.html( template() );
			this.$el.insertAfter( '.vc_automapper-toolbar' );
			return this;
		},
		shortcodesRegexp: _.memoize( function () {
			return new RegExp( '\\[(\\[?)([\\w|\-]+\\b)(?![\\w\-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)' );
		}),
		parseShortcode: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			var string, matches, data, params = [], attr;
			string = $( '#vc_atm-shortcode-string' ).val();
			if ( _.isEmpty( string ) ) {
				this.$el.addClass( 'form-invalid' );
				showValidationError( window.i18nLocaleVcAutomapper.error_enter_valid_shortcode, this.$el );
				return false;
			}
			matches = string.match( this.shortcodesRegexp() );
			if ( !matches ) {
				this.$el.addClass( 'form-invalid' );
				showValidationError( window.i18nLocaleVcAutomapper.error_enter_valid_shortcode, this.$el );
				return false;
			}
			attr = wp.shortcode.attrs( matches[ 3 ]);
			_.each( attr.named, function ( value, key ) {
				params.push({
					param_name: key,
					type: 'textfield',
					heading: to_title( key ),
					description: 'Example: ' + value,
					value: value
				});
			}, this );
			if ( matches[ 5 ]) {
				params.push({
					param_name: 'content',
					type: 'textarea',
					heading: 'Content',
					description: '',
					value: matches[ 5 ]
				});
			}
			data = {
				tag: matches[ 2 ],
				name: to_title( matches[ 2 ]),
				category: window.i18nLocaleVcAutomapper.my_shortcodes_category,
				params: params
			};
			if ( this.isValid( data ) ) {
				vc_am.shortcodes.create( data );
				show_message( window.i18nLocaleVcAutomapper.new_shortcode_mapped, 'success' );
				$( '.vc_atm-message' ).remove();
				vc_am.shortcodes.last().view.edit();
			} else {
				this.$el.addClass( 'form-invalid' );
				showValidationError( this.validationError );
			}
		}
	});
	EditFormView = FormView.extend({
		className: 'vc_edit-form',
		active_preview: false,
		events: {
			'click #vc_atm-save': 'save',
			'click .vc_atm-cancel': 'close',
			'click .vc_atm-delete': 'clear',
			'click #vc_atm-add-param': 'addParam',
			'click .vc_delete-param': 'deleteParam',
			'change #vc_atm-is-container': 'setContentParam',
			'keyup .vc_param-name, .vc_param-value, #vc_atm-tag': 'setPreview',
			'focus #vc_atm-tag': 'setTagFieldActive',
			'focus .vc_params input, .vc_params textarea': 'setParamFieldActive',
			'focus .vc_param.vc_content input, .vc_param.vc_content textarea': 'setContentParamFieldActive',
			'blur #vc_atm-tag, vc_param input': 'unsetFieldActive',
			'change .vc_param-field [name="type"]': 'changeParamType'
		},
		new: false,
		template_html: $( '#vc_automapper-form-tpl' ).html(),
		param_template_html: $( '#vc_atm-form-param-tpl' ).html(),
		getType: function () {
			return 'edit';
		},
		render: function () {
			EditFormView.__super__.render.call( this );
			var template = vc.template( this.template_html, vc.templateOptions.custom );
			this.$el.html( template( this.model.toJSON() ) );
			this.$el.insertAfter( $( '[data-item-id=' + this.model.id + ']' ).hide() );
			this.addAllParams();
			return this;
		},
		changeParamType: function ( e ) {
			var $this, $parent;

			$this = $( e.currentTarget );
			$parent = $this.parents( '.vc_fields' );
			if ( 'hidden' === $this.val() ) {
				$parent.find( '[name="heading"]' ).attr( 'disabled', true );
				$parent.find( '[name="description"]' ).attr( 'disabled', true );
			} else {
				$parent.find( '[name="heading"]' ).attr( 'disabled', false );
				$parent.find( '[name="description"]' ).attr( 'disabled', false );
			}
		},
		setTagFieldActive: function () {
			if ( this.active_preview ) {
				$( this.active_preview ).removeClass( 'vc_active' );
			}
			this.active_preview = '#vc_shortcode-preview .vc_preview-tag';
			$( this.active_preview ).addClass( 'vc_active' );
		},
		setParamFieldActive: function ( e ) {
			var $control, index;
			$control = $( e.currentTarget );
			index = $control.parents( '.vc_param:first' ).index();
			if ( this.active_preview ) {
				$( this.active_preview ).removeClass( 'vc_active' );
			}
			this.active_preview = '#vc_shortcode-preview .vc_preview-param:eq(' + index + ')';
			$( this.active_preview ).addClass( 'vc_active' );
		},
		setContentParamFieldActive: function () {
			if ( this.active_preview ) {
				$( this.active_preview ).removeClass( 'vc_active' );
			}
			this.active_preview = '#vc_shortcode-preview .vc_preview-content';
			$( this.active_preview ).addClass( 'vc_active' );
		},
		unsetFieldActive: function () {
			$( this.active_preview ).removeClass( 'vc_active' );
			this.active_preview = false;
		},
		/**
		 * Escape double quotes in params value.
		 * @param value
		 * @return {*}
		 */
		escapeParam: function ( value ) {
			return value && value.replace( /"/g, '``' );
		},
		getPreview: function ( data ) {
			var params = data.params,
				content = false,
				params_to_string = {};
			_.each( params, function ( value ) {
				if ( 'content' !== value.param_name ) {
					params_to_string[ value.param_name ] = this.escapeParam( value.value );
				} else {
					content = value.value;
				}

			}, this );

			return wp.shortcode.atmPreview({
				tag: data.tag,
				attrs: params_to_string,
				content: content,
				type: false === content ? 'single' : ''
			});
		},
		setPreview: function () {
			var data = {
				params: this.getParams(),
				tag: $( '#vc_atm-tag' ).val()
			};
			$( '#vc_shortcode-preview' ).html( this.getPreview( data ) );
			if ( this.active_preview ) {
				$( this.active_preview ).addClass( 'vc_active' );
			}
		},
		save: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			this.$el.find( '.vc_error' ).removeClass( 'vc_error' );
			var data = {
				tag: $( '#vc_atm-tag' ).val(),
				name: $( '#vc_atm-name' ).val(),
				category: $( '#vc_atm-category' ).val(),
				description: $( '#vc_atm-description' ).val(),
				params: this.getParams()
			};
			if ( this.isValid( data ) ) {
				this.model.save( data );
				show_message( window.i18nLocaleVcAutomapper.shortcode_updated, 'success' );
				this.close();
			} else {
				showValidationError( this.validationError, this.$el.find( '#vc_atm-save' ) );
			}
		},
		validate: function ( attrs ) {
			var result, added_param_names;
			$( '.vc_error,.form-invalid' ).removeClass( 'vc_error form-invalid' );
			result = false;
			added_param_names = {};
			if ( !attrs.name ) {
				$( '#vc_atm-name' ).addClass( 'vc_error' );
				$( '#vc_atm-header-name' ).parent().addClass( 'form-invalid' );
				return window.i18nLocaleVcAutomapper.error_shortcode_name_is_required;
			}
			if ( !attrs.tag || !attrs.tag.match( /^\S+$/ ) ) {
				$( '#vc_atm-tag' ).addClass( 'vc_error' ).parent().addClass( 'form-invalid' );
				return window.i18nLocaleVcAutomapper.error_enter_valid_shortcode_tag;
			}
			var fields_required = [
				'param_name',
				'heading',
				'type'
			];
			_.each( attrs.params, function ( param, index ) {
				var $field_el = $( '#vc_atm-params-list [name=param_name]:eq(' + index + ')' );
				if ( 'content' === param.param_name && !$field_el.data( 'system' ) ) {
					result = window.i18nLocaleVcAutomapper.error_content_param_not_manually;
					$field_el.addClass( 'vc_error' );
					$field_el.closest( '.vc_param-field' ).addClass( 'form-invalid' );
					return;
				}
				if ( _.isBoolean( added_param_names[ param.param_name ]) && true == added_param_names[ param.param_name ]) {
					$field_el.addClass( 'vc_error' );
					$field_el.closest( '.vc_param-field' ).addClass( 'form-invalid' );
					if ( !result ) {
						result = window.i18nLocaleVcAutomapper.error_param_already_exists.replace( /\%s/,
							param.param_name );
					}
				}
				added_param_names[ param.param_name ] = true;
				_.each( fields_required, function ( field ) {
					if ( ( 'hidden' !== param.type && '' === param[ field ]) || ( 'hidden' === param.type && 'heading' !== field && '' === param[ field ]) ) {
						$( '#vc_atm-params-list [name=' + field + ']:eq(' + index + ')' )
							.addClass( 'vc_error' )
							.closest( '.vc_param-field' )
							.addClass( 'form-invalid' );
						if ( !result ) {
							result = window.i18nLocaleVcAutomapper.error_enter_required_fields;
						}
					} else if ( 'param_name' === field && !param[ field ].match( /^[a-z0-9_]+$/g ) ) {
						$field_el
							.addClass( 'vc_error' )
							.closest( '.vc_param-field' )
							.addClass( 'form-invalid' );
						if ( !result ) {
							result = window.i18nLocaleVcAutomapper.error_wrong_param_name;
						}
					}
				}, this );
			}, this );

			return result || null;
		},
		setContentParam: function ( e ) {
			var $control = $( e.currentTarget );
			if ( $control[ 0 ].checked ) {
				this.addParamField({
					type: 'textarea',
					heading: 'Content',
					description: '',
					param_name: 'content',
					value: ''
				});
				this.setParamSorting();
			} else {
				this.removeParamField( 'content' );
			}
			$( '.edit-form-info' ).initializeTooltips( '.vc_wrapper' );
			this.setPreview();
		},
		addAllParams: function () {
			$( '#vc_atm-params-list' ).empty();
			_.each( this.model.get( 'params' ), function ( param ) {
				this.addParamField( param );
				if ( 'content' === param.param_name ) {
					$( '#vc_atm-is-container' ).prop( 'checked', true );
				}
			}, this );
			this.setParamSorting();
		},
		getParams: function () {
			var params = [];
			_.each( $( '.vc_param' ), function ( param ) {
				var $param = $( param );
				params.push({
					param_name: $param.find( '[name=param_name]' ).val(),
					type: $param.find( '[name=type]' ).val(),
					description: $param.find( '[name=description]' ).val(),
					heading: $param.find( '[name=heading]' ).val(),
					value: $param.find( '[name=value]' ).val()
				});
			}, this );
			return params;
		},
		addParam: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			this.addParamField({ type: '', heading: '', description: '', param_name: '', value: '' });
			$( '.edit-form-info' ).initializeTooltips( '.vc_wrapper' );
			this.setPreview();
		},
		removeParamField: function ( name ) {
			$( '.vc_param-name[value="' + name + '"]' ).parents( '.vc_param' ).remove();
		},
		addParamField: function ( attr ) {
			var $block = $( '<div class="vc_param wpb_vc_row' + ( 'content' === attr.param_name ? ' vc_content' : '' ) + '"/>' ).appendTo( '#vc_atm-params-list' );
			var template = vc.template( this.param_template_html, vc.templateOptions.custom );
			$block.html( template( attr ) );
		},
		setParamSorting: function () {
			$( '#vc_atm-params-list' ).sortable({
				items: '> .vc_param',
				tolerance: 'pointer',
				handle: '.vc_move-param',
				update: this.setPreview,
				placeholder: 'vc_sortable-placeholder'
			});
		},
		deleteParam: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			var $control;
			if ( confirm( window.i18nLocaleVcAutomapper.are_you_sure_delete_param ) ) {
				$control = $( e.currentTarget );
				$control.parents( '.vc_param' ).remove();
				this.setPreview();
			}
		},
		close: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			if ( this.model ) {
				$( '[data-item-id=' + this.model.get( 'id' ) + ']' ).show();
			}
			vc_am.current_form = false;
			$( '.vc_atm-message' ).remove();
			this.remove();
		},
		clear: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			if ( confirm( window.i18nLocaleVcAutomapper.are_you_sure_delete ) ) {
				this.model.destroy();
				this.close();
			}
		}
	});
	var EditFormInnerView = EditFormView.extend({
		template_html: $( '#vc_automapper-form-tpl' ).html(),
		getType: function () {
			return 'edit';
		},
		initialize: function () {
			_.bindAll( this, 'setPreview' );
		},
		render: function () {
			var parent = this.model.view;
			EditFormView.__super__.render.call( this );
			var template = vc.template( this.template_html, vc.templateOptions.custom );
			this.$el.html( template( _.extend({ shortcode_preview: this.getPreview( this.model.toJSON() ) }, this.model.toJSON() ) ) );
			this.$el.appendTo( parent.$editForm() );
			parent.$widgetTitle().html(
				'<span class="vc_atm-header"><input type="text" name="name" value="" id="vc_atm-header-name" class="vc_header-name"></span><span class="in-widget-title"></span>' );
			$( '#vc_atm-header-name' ).val( this.model.get( 'name' ) );
			this.addAllParams();
			parent.$editForm().slideDown();
			$( '.edit-form-info' ).initializeTooltips( '.vc_wrapper' );
			return this;
		},
		save: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			this.model.view.beforeSave();
			EditFormInnerView.__super__.save.call( this );
		},
		close: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			vc_am.current_form = false;
			this.model.view.close();
		},
		clear: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			if ( confirm( window.i18nLocaleVcAutomapper.are_you_sure_delete ) ) {
				this.model.view.clear();
				this.remove();
			}
		}
	});
	var AppView = Backbone.View.extend({
		events: {
			'click #vc_automapper-add-btn': 'create',
			'submit': 'formSubmit'
		},
		className: 'vc_atm-form',
		addFormView: false,
		initialize: function () {
			this.listenTo( vc_am.shortcodes, 'add', this.addOne );
			this.listenTo( vc_am.shortcodes, 'reset', this.addAll );
			this.listenTo( vc_am.shortcodes, 'all', this.render );
			this.$list = $( '.vc_automapper-list' );
			vc_am.shortcodes.fetch();
		},
		formSubmit: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			if ( _.isObject( e ) && this.addFormView && !_.isEmpty( e.currentTarget ) && !_.isEmpty( e.currentTarget[ 0 ]) ) {
				var node, $el;
				node = e.currentTarget[ 0 ];
				$el = $( node );
				if ( $el.is( '#vc_atm-shortcode-string' ) ) {
					this.addFormView.parseShortcode();
				}
			}
		},
		addAll: function ( models ) {
			models.each( function ( model ) {
				this.addOne( model );
			}, this );
		},
		addOne: function ( model ) {
			var view = new ComplexShortcodeView({ model: model });
			this.$list.append( view.render().el );
		},
		create: function ( e ) {
			if ( e && e.preventDefault ) {
				e.preventDefault();
			}
			if ( !vc_am.current_form || 'create' !== vc_am.current_form.getType() ) {
				this.addFormView = new AddFormView().render();
			}
		},
		render: function () {
		}
	});
	if ( $vcSettings.length ) {
		new AppView({ el: $vcSettings });
	}
})( window.jQuery );

Directory Contents

Dirs: 0 × Files: 1
Name Size Perms Modified Actions
24.33 KB lrw-r--r-- 2026-06-02 10:25:31
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).
© 2026 0xNothings — Secure File Manager. All rights reserved. Built with ❤️ & Tailwind x Dark UI