PluginProbe ʕ •ᴥ•ʔ
Cost Calculator for Elementor / 1.2.8
Cost Calculator for Elementor v1.2.8
trunk 1.2.8 1.2.9 1.3.0 1.3.1 1.3.5 1.4.0
cost-calculator-for-elementor / libs / calculator_editor.js
cost-calculator-for-elementor / libs Last commit date
tribute 2 years ago autoNumeric-1.9.45.js 2 years ago calculator.css 2 years ago calculator.js 2 years ago calculator_editor.js 2 years ago formula_evaluator-min.js 2 years ago wpforms-calculator-admin.js 2 years ago
calculator_editor.js
89 lines
1 (function($) {
2 "use strict";
3 $( document ).ready( function () {
4 $("body").on("click",'.elementor-control-tag-area[data-setting="formula"]',function(e){
5 var container = $(this).closest('.wpforms-field-option-row');
6 var id = $(this).attr("id").match(/\d+/)[0];
7 if( $(this).data("check") != "ok" ) {
8 var value = $(this).val();
9 $(this).focus().val('').val(value);
10 $(this).after('<div class="elementor-control-dynamic-switcher elementor-control-unit-1 elementor-cost-calculator-add-tag" data-tooltip="add Tags" original-title=""><i class="eicon-database" aria-hidden="true"></i><span class="elementor-screen-only">Dynamic Tags</span></div>');
11 $(this).data("check","ok");
12 $(this).wrap( "<div id='elementor-control-default-container-"+id+"' class='elementor-control-default-container'></div>" );
13 if (typeof elementor_calculator !== 'undefined' && elementor_calculator !== null) {
14 var tributeAttributes = {
15 autocompleteMode: true,
16 noMatchTemplate: "",
17 values: elementor_calculator.data,
18 selectTemplate: function(item) {
19 if (typeof item === "undefined") return null;
20 if (this.range.isContentEditable(this.current.element)) {
21 return (
22 '<span contenteditable="false"><a>' +
23 item.original.key +
24 "</a></span>"
25 );
26 }
27
28 return item.original.value;
29 },
30 menuItemTemplate: function(item) {
31 return item.string;
32 }
33 };
34 var tributeAutocompleteTestArea = new Tribute(
35 Object.assign(
36 {
37 menuContainer: document.getElementById("elementor-control-default-container-"+id),
38 replaceTextSuffix: "",
39 },
40 tributeAttributes
41 )
42 );
43 tributeAutocompleteTestArea.attach(
44 document.getElementById("elementor-control-default-c"+id)
45 );
46 }
47 }
48 })
49 $("body").on("click",".elementor-cost-calculator-add-tag",function(e){
50 var html ='<ul class="elementor-cost-calculator-sync">';
51 var form = $(this).closest(".elementor-repeater-fields-wrapper");
52 $(".elementor-form-field-shortcode",form).each(function() {
53 const regex = /\".*?\"/gm;
54 let m;
55 var name = $(this).val();
56 while ((m = regex.exec(name)) !== null) {
57 if (m.index === regex.lastIndex) {
58 regex.lastIndex++;
59 }
60 m.forEach((match, groupIndex) => {
61 name = match.replaceAll('"',"");
62 });
63 }
64 html +='<li title="Copy shortcode name">'+name+'</li>';
65 });
66 html +='</ul>';
67 $(this).closest(".elementor-control-input-wrapper").append(html);
68 })
69
70 $(document).mouseup(function(e)
71 {
72 var container = $(".elementor-cost-calculator-sync");
73
74 // if the target of the click isn't the container nor a descendant of the container
75 if (!container.is(e.target) && container.has(e.target).length === 0)
76 {
77 container.hide();
78 }
79 });
80 $("body").on("click",".elementor-cost-calculator-sync li",function(e){
81 var vl = $(this).html();
82 navigator.clipboard.writeText(vl);
83 $(this).html("Copied to Clipboard");
84 setTimeout(function(){
85 $(".elementor-cost-calculator-sync").remove();
86 }, 500);
87 })
88 })
89 })(jQuery);