-
Notifications
You must be signed in to change notification settings - Fork 9
/
InputfieldSeoMaestro.js
10 lines (9 loc) · 7.62 KB
/
InputfieldSeoMaestro.js
1
2
3
4
5
6
7
8
9
10
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"T2Xs":[function(require,module,exports) {
},{}],"44Yw":[function(require,module,exports) {
"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function n(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var i=function(){function e(n,i){t(this,e),this.$inputTitle=document.querySelector('[name="'.concat(i,'_meta_title"]')),this.$inputTitleInherit=document.querySelector('[name="'.concat(i,'_meta_title_inherit"]')),this.$title=n.querySelector("[data-title]"),this.$inputDesc=document.querySelector('[name="'.concat(i,'_meta_description"]')),this.$desc=n.querySelector("[data-desc]"),this.$inputDescInherit=document.querySelector('[name="'.concat(i,'_meta_description_inherit"]')),this.titleFormat=n.dataset.seomaestroTitleFormat,this.maxLengths={title:60,desc:160}}return n(e,[{key:"init",value:function(){return this.$title.innerHTML=this.truncateString(this.$title.innerHTML,this.maxLengths.title),this.$desc.innerHTML=this.truncateString(this.$desc.innerHTML,this.maxLengths.desc),this.initEventListeners()}},{key:"initEventListeners",value:function(){var t=this;return["keyup","blur"].forEach(function(e){t.$inputTitle.addEventListener(e,function(){t.$title.innerHTML=t.renderTitleFromInput()}),t.$inputDesc.addEventListener(e,function(){t.$desc.innerHTML=t.renderDescriptionFromInput()})}),this.$inputTitleInherit.addEventListener("change",function(){var e=t.maxLengths.title;t.$inputTitleInherit.checked?t.$title.innerHTML=t.truncateString(t.$title.dataset.title,e):t.$inputTitle.value&&(t.$title.innerHTML=t.renderTitleFromInput())}),this.$inputDescInherit.addEventListener("change",function(){var e=t.maxLengths.desc;t.$inputDescInherit.checked?t.$desc.innerHTML=t.truncateString(t.$desc.dataset.desc,e):t.$inputDesc.value&&(t.$desc.innerHTML=t.renderDescriptionFromInput())}),this}},{key:"renderTitleFromInput",value:function(){if(!this.titleFormat)return this.truncateString(this.$inputTitle.value,this.maxLengths.title);var t=this.titleFormat.replace("{meta_title}",this.$inputTitle.value);return this.truncateString(t,this.maxLengths.title)}},{key:"renderDescriptionFromInput",value:function(){return this.truncateString(this.$inputDesc.value,this.maxLengths.desc)}},{key:"truncateString",value:function(t,e){if(t.length<e)return t;var n=t.substring(0,e);return n?"".concat(n,"..."):""}}]),e}();exports.default=i;
},{}],"YDMJ":[function(require,module,exports) {
"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function n(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var i=function(){function t(n,i){e(this,t),this.$inputTitle=document.querySelector('[name="'.concat(i,'_opengraph_title"]')),this.$inputTitleInherit=document.querySelector('[name="'.concat(i,'_opengraph_title_inherit"]')),this.$inputDesc=document.querySelector('[name="'.concat(i,'_opengraph_description"]')),this.$inputDescInherit=document.querySelector('[name="'.concat(i,'_opengraph_description_inherit"]')),this.$inputImage=document.querySelector('[name="'.concat(i,'_opengraph_image"]')),this.$inputImageInherit=document.querySelector('[name="'.concat(i,'_opengraph_image_inherit"]')),this.$title=n.querySelector("[data-title]"),this.$desc=n.querySelector("[data-desc]"),this.$image=n.querySelector("[data-image]"),this.maxLengths={title:60,desc:75}}return n(t,[{key:"init",value:function(){return this.$title.innerHTML=this.truncateString(this.$title.innerHTML,this.maxLengths.title),this.$desc.innerHTML=this.truncateString(this.$desc.innerHTML,this.maxLengths.desc),this.initEventListeners()}},{key:"initEventListeners",value:function(){var e=this;return["keyup","blur"].forEach(function(t){e.$inputTitle.addEventListener(t,function(){e.$title.innerHTML=e.renderTitleFromInput()}),e.$inputDesc.addEventListener(t,function(){e.$desc.innerHTML=e.renderDescriptionFromInput()})}),this.$inputImage.addEventListener("blur",function(){e.setBackgroundImage(e.$inputImage.value)}),this.$inputTitleInherit.addEventListener("change",function(){var t=e.maxLengths.title;e.$inputTitleInherit.checked?e.$title.innerHTML=e.truncateString(e.$title.dataset.title,t):e.$inputTitle.value&&(e.$title.innerHTML=e.renderTitleFromInput())}),this.$inputDescInherit.addEventListener("change",function(){var t=e.maxLengths.desc;e.$inputDescInherit.checked?e.$desc.innerHTML=e.truncateString(e.$desc.dataset.desc,t):e.$inputDesc.value&&(e.$desc.innerHTML=e.renderDescriptionFromInput())}),this.$inputImageInherit.addEventListener("change",function(){e.$inputImageInherit.checked?e.setBackgroundImage(e.$image.dataset.image):e.$inputImage.value&&e.setBackgroundImage(e.$inputImage.value)}),this}},{key:"renderTitleFromInput",value:function(){return this.truncateString(this.$inputTitle.value,this.maxLengths.title)}},{key:"renderDescriptionFromInput",value:function(){return this.truncateString(this.$inputDesc.value,this.maxLengths.desc)}},{key:"setBackgroundImage",value:function(e){this.$image.setAttribute("style","background-image: url('".concat(e,"');"))}},{key:"truncateString",value:function(e,t){if(e.length<t)return e;var n=e.substring(0,t);return n?"".concat(n,"..."):""}}]),t}();exports.default=i;
},{}],"Focm":[function(require,module,exports) {
"use strict";require("../scss/styles.scss");var e=o(require("./components/InputfieldGooglePreview")),t=o(require("./components/InputfieldFacebookSharePreview"));function o(e){return e&&e.__esModule?e:{default:e}}document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll("[data-seomaestro-googlepreview]").forEach(function(t){new e.default(t,t.dataset.seomaestroGooglepreview).init()}),document.querySelectorAll("[data-seomaestro-facebookpreview]").forEach(function(e){new t.default(e,e.dataset.seomaestroFacebookpreview).init()}),document.querySelectorAll("[data-seomaestro-metadata-inherit]").forEach(function(e){e.addEventListener("change",function(t){if(!t.target.checked){var o=e.dataset.seomaestroMetadataInherit,a=document.querySelector('input[name="'.concat(o,'"], textarea[name="').concat(o,'"]'));a&&a.focus()}})})});
},{"../scss/styles.scss":"T2Xs","./components/InputfieldGooglePreview":"44Yw","./components/InputfieldFacebookSharePreview":"YDMJ"}]},{},["Focm"], null)
//# sourceMappingURL=/InputfieldSeoMaestro.js.map