1"use strict"; 2 3/** 4 * WP E-Signature core class for dom handle 5 * @since 1.5.7.0 6 */ 7 8 9function wpEsig(selector) 10{ 11 // check for instance if true return with selector. 12 if (!(this instanceof wpEsig)) 13 { 14 return new wpEsig(selector); // return new object. 15 } 16 // select a document element 17 this.selector = document.querySelector(selector); 18} 19 20// wp esig prototype object to handle html dom. 21wpEsig.prototype = { 22 // This on method to handle document event. 23 on: function (eventType, callBack) { 24 if (this.selector) { 25 this.selector.addEventListener( 26 eventType, 27 function (event) { 28 callBack.call(this, event); 29 }.bind(this), 30 false 31 ); 32 } 33 return this; 34 }, 35 // show method to show html element 36 show: function () { 37 this.selector.style.display = "flex"; // it will show element in display flex mode. 38 return this; 39 }, 40 // Hide an element from dom 41 hide: function () { 42 this.selector.style.display = "none"; 43 return this; 44 }, 45 // This method remove a html element from dom 46 remove: function () { 47 this.selector.remove(); 48 return this; 49 }, 50 // Insert html content into document. 51 html: function (content) { 52 this.selector.innerHTML = content; // It will insert new content or replace existing html content. 53 return this; 54 }, 55 // return value for wp esignature input element 56 value: function () { 57 return this.selector.value; 58 }, 59 // add a custom css 60 css: function (cssPropertyName, value) { 61 this.selector.style[cssPropertyName] = value; 62 return this; 63 }, 64 // add a custom css 65 removeCss: function (cssPropertyName) { 66 this.selector.style[cssPropertyName] = null; 67 return this; 68 }, 69 // add new css class 70 addClass: function (className) { 71 this.selector.classList.add(className); 72 return this; 73 }, 74 // remove new css class 75 removeClass: function (className) { 76 // check for existing css class 77 if (this.selector.classList.contains(className)) { 78 this.selector.classList.remove(className); 79 } 80 return this; 81 }, 82 // replace existing css class with new one 83 replaceClass: function (className) { 84 this.selector.className = className; 85 return this; 86 }, 87 // add a border color to an input element 88 errorBorder: function () { 89 this.selector.style.borderColor = "#ff4378"; 90 return this; 91 }, 92 // insert html content Just inside the element, before its first child. 93 html: function (htmlContent) { 94 this.selector.innerHTML = htmlContent; 95 return this; 96 }, 97 // insert html content Just inside the element, after its last child. 98 append: function (htmlContent) { 99 this.selector.insertAdjacentHTML("beforeend", htmlContent); 100 return this; 101 }, 102}; 103 104 105/** 106 * Checking next element id by selector provided. 107 * @param {*} elementId 108 */ 109wpEsig.prototype.checkNextElement = function(elementId) 110{ 111 // check if next eleme is not null 112 if (document.getElementById(this.selector.id).nextElementSibling !== null) 113 { 114 // Grab the id from next sibling 115 var idExists = document.getElementById(this.selector.id).nextElementSibling.id; 116 // compare with provided element id and return true 117 if (idExists && idExists === elementId) { 118 return true 119 } 120 } 121 // If no element id found return false. 122 return false; 123} 124 125/** 126 * Insert a validation message for given element id 127 * @param {*} message 128 * @param {*} border 129 */ 130 131wpEsig.prototype.insertAfterValidationMsg = function(message,border=false) 132{ 133 if (!this.checkNextElement("esig-form-input-validation")) 134 { 135 document.getElementById(this.selector.id).insertAdjacentHTML( 136 "afterend", '<div id="esig-form-input-validation" class="esig-input-error"> <span class="esig-icon-esig-alert"></span> <span class="error-msg">' + message + '</span></div>' 137 ); 138 139 if(border) 140 { 141 this.css.call(this,"borderColor","#c51244"); 142 } 143 144 } 145 146} 147 148/** 149 * Remove validation message if it exists. 150 * @param {*} border 151 */ 152wpEsig.prototype.removeValidationMsg = function(border=false) 153{ 154 if (this.checkNextElement.call(this, "esig-form-input-validation")) 155 { 156 this.selector.nextElementSibling.remove(); 157 } 158 // if border tru then remove it 159 if(border) 160 { 161 this.removeCss.call(this, "borderColor"); 162 } 163} 164 165
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.