Plugin Directory

Changeset 3211834


Ignore:
Timestamp:
12/22/2024 02:04:21 PM (15 months ago)
Author:
mihdan
Message:

Update to version 6.3.0 from GitHub

Location:
cyr2lat
Files:
34 edited
1 copied

Legend:

Unmodified
Added
Removed
  • cyr2lat/tags/6.3.0/assets/css/tables.css

    r2944888 r3211834  
    3030}
    3131
    32 #ctl-success, #ctl-error {
     32#ctl-success, #ctl-error, #ctl-warning {
    3333    max-height: 0;
    3434    color: #fff;
     
    4343
    4444#ctl-error {
     45    background: #d63638;
     46}
     47
     48#ctl-warning {
    4549    background: #FF9800;
    4650}
    4751
    48 #ctl-success.active, #ctl-error.active {
    49     padding: 10px 25px;
     52#ctl-success.active, #ctl-error.active, #ctl-warning.active {
     53    padding: 10px 15px;
    5054    max-height: 34px;
    5155    height: 14px;
  • cyr2lat/tags/6.3.0/assets/css/tables.min.css

    r2944888 r3211834  
    1 #ctl-options.ctl-tables h2,#ctl-options.ctl-tables table{display:none}#ctl-options.ctl-tables h2.nav-tab,#ctl-options.ctl-tables table.active{border-radius:4px;display:block;font-size:14px}#ctl-options.ctl-tables h2.nav-tab{overflow-wrap:break-word;padding:5px;white-space:pre-line}#ctl-options .form-table th{display:none}#ctl-options table tbody tr td{display:table-cell;padding:15px 10px}.ctl-table{display:none}#ctl-error,#ctl-success{color:#fff;font-size:14px;max-height:0;padding:0;transition:all .5s}#ctl-success{background:#8bc34a}#ctl-error{background:#ff9800}#ctl-error.active,#ctl-success.active{height:14px;line-height:14px;margin-top:15px;max-height:34px;padding:10px 25px}#ctl-options .nav-tab-wrapper{border-bottom:none;float:left;padding-top:22px;text-align:center;width:120px}body.js #ctl-options .ctl-table{clear:none;float:left;width:calc(100% - 120px)}#ctl-options .nav-tab{border:1px solid #c3c4c7;box-sizing:border-box;clear:both;cursor:pointer;margin:0 0 23px;width:100%}#ctl-convert-existing-slugs,#ctl-options .submit{clear:both;float:left;margin-top:0;padding-bottom:0}#ctl-convert-existing-slugs .submit{margin-top:0}#ctl-options .nav-tab-active{background:#4f94d4;border-color:#2271b1;color:#fff}#ctl-options .nav-tab-current.nav-tab-active{background:#2271b1;border-color:#0a4b78;color:#fff}.ctl-table.active{display:block}.ctl-table-cell{display:flex;float:left;justify-content:space-between;margin:0 .2em 1em;position:relative;width:6.2em}td fieldset .ctl-table-cell label{border:1px solid transparent;border-radius:4px;box-sizing:border-box;display:inline-block;height:30px;line-height:30px;margin:0!important;overflow:hidden;padding:0 8px;text-align:right;vertical-align:middle;width:3em;word-break:break-all}.ctl-table-cell input{border-width:1px;display:inline-block;margin:0;vertical-align:middle;width:3em!important}.ctl-table-cell #ctl-edit-label{border:1px solid #007cba!important;border-radius:4px;box-shadow:0 0 0 1px #007cba;height:30px;left:0;margin:0;outline:none;padding:0 8px;position:absolute;top:0;width:3em!important}.ctl-table-cell #ctl-edit-label:focus-visible{outline:none}.ctl-edit-label-error{background:#ff9800}.ctl-plus{align-items:center;display:flex;height:30px;justify-content:center;position:relative;width:6.2em}.ctl-plus button{border:none;cursor:pointer;height:24px;padding:0;width:24px}.ctl-plus button:focus{outline:none}@media screen and (max-width:782px){.ctl-table-cell{width:100px}td fieldset .ctl-table-cell label{height:40px;line-height:40px;width:48px}.ctl-table-cell #ctl-edit-label{height:40px}#ctl-options table tbody tr td{padding:15px 1px}.ctl-plus{height:40px;width:100px}}
     1#ctl-options.ctl-tables h2,#ctl-options.ctl-tables table{display:none}#ctl-options.ctl-tables h2.nav-tab,#ctl-options.ctl-tables table.active{border-radius:4px;display:block;font-size:14px}#ctl-options.ctl-tables h2.nav-tab{overflow-wrap:break-word;padding:5px;white-space:pre-line}#ctl-options .form-table th{display:none}#ctl-options table tbody tr td{display:table-cell;padding:15px 10px}.ctl-table{display:none}#ctl-error,#ctl-success,#ctl-warning{color:#fff;font-size:14px;max-height:0;padding:0;transition:all .5s}#ctl-success{background:#8bc34a}#ctl-error{background:#d63638}#ctl-warning{background:#ff9800}#ctl-error.active,#ctl-success.active,#ctl-warning.active{height:14px;line-height:14px;margin-top:15px;max-height:34px;padding:10px 15px}#ctl-options .nav-tab-wrapper{border-bottom:none;float:left;padding-top:22px;text-align:center;width:120px}body.js #ctl-options .ctl-table{clear:none;float:left;width:calc(100% - 120px)}#ctl-options .nav-tab{border:1px solid #c3c4c7;box-sizing:border-box;clear:both;cursor:pointer;margin:0 0 23px;width:100%}#ctl-convert-existing-slugs,#ctl-options .submit{clear:both;float:left;margin-top:0;padding-bottom:0}#ctl-convert-existing-slugs .submit{margin-top:0}#ctl-options .nav-tab-active{background:#4f94d4;border-color:#2271b1;color:#fff}#ctl-options .nav-tab-current.nav-tab-active{background:#2271b1;border-color:#0a4b78;color:#fff}.ctl-table.active{display:block}.ctl-table-cell{display:flex;float:left;justify-content:space-between;margin:0 .2em 1em;position:relative;width:6.2em}td fieldset .ctl-table-cell label{border:1px solid transparent;border-radius:4px;box-sizing:border-box;display:inline-block;height:30px;line-height:30px;margin:0!important;overflow:hidden;padding:0 8px;text-align:right;vertical-align:middle;width:3em;word-break:break-all}.ctl-table-cell input{border-width:1px;display:inline-block;margin:0;vertical-align:middle;width:3em!important}.ctl-table-cell #ctl-edit-label{border:1px solid #007cba!important;border-radius:4px;box-shadow:0 0 0 1px #007cba;height:30px;left:0;margin:0;outline:none;padding:0 8px;position:absolute;top:0;width:3em!important}.ctl-table-cell #ctl-edit-label:focus-visible{outline:none}.ctl-edit-label-error{background:#ff9800}.ctl-plus{align-items:center;display:flex;height:30px;justify-content:center;position:relative;width:6.2em}.ctl-plus button{border:none;cursor:pointer;height:24px;padding:0;width:24px}.ctl-plus button:focus{outline:none}@media screen and (max-width:782px){.ctl-table-cell{width:100px}td fieldset .ctl-table-cell label{height:40px;line-height:40px;width:48px}.ctl-table-cell #ctl-edit-label{height:40px}#ctl-options table tbody tr td{padding:15px 1px}.ctl-plus{height:40px;width:100px}}
  • cyr2lat/tags/6.3.0/assets/js/apps/tables.js

    r3188005 r3211834  
    1 (()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?n(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function i(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,a(i.key),i)}}function a(t){var n=function(t,n){if("object"!=e(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var a=i.call(t,n||"default");if("object"!=e(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==e(n)?n:n+""}var s=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.OPTIONS_FORM_SELECTOR="#ctl-options",this.HEADER_SELECTOR=this.OPTIONS_FORM_SELECTOR+" h2",this.TABLE_SELECTOR=this.OPTIONS_FORM_SELECTOR+" table",this.SUBMIT_SELECTOR=this.OPTIONS_FORM_SELECTOR+" #submit",this.CURRENT_STUB_ID="ctl-current",this.CURRENT_NAV_TAB_CLASS="nav-tab-current",this.ACTIVE_NAV_TAB_CLASS="nav-tab-active",this.ACTIVE_TABLE_CLASS="active",this.EDIT_LABEL_ID="ctl-edit-label",this.EDIT_LABEL_ERROR_CLASS="ctl-edit-label-error",this.plusButton='<button type="button" aria-haspopup="true" aria-expanded="false" class="components-button block-editor-inserter__toggle has-icon" aria-label="Добавить блок"><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 24 24" role="img" aria-hidden="true" focusable="false"><path d="M10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6zM10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6z"></path></svg></button>',this.PLUS_CLASS="ctl-plus",this.optionsForm=document.querySelector(this.OPTIONS_FORM_SELECTOR),this.tablesData=this.getTablesData(),this.submitButton=document.querySelector(this.SUBMIT_SELECTOR),this.addWrapper(),this.addMessageLines(),this.moveTabs(),this.addEditLabelInput(),this.hideTables(),this.bindEvents(),this.setSubmitStatus()},n=[{key:"getHeaders",value:function(){return t(document.querySelectorAll(this.HEADER_SELECTOR))}},{key:"getActiveHeader",value:function(){return document.querySelector(this.HEADER_SELECTOR+"."+this.ACTIVE_NAV_TAB_CLASS)}},{key:"getActiveIndex",value:function(){return this.getActiveHeader().dataset.index}},{key:"getTables",value:function(){return t(document.querySelectorAll(this.TABLE_SELECTOR))}},{key:"getActiveTable",value:function(){return document.querySelector(this.TABLE_SELECTOR+"."+this.ACTIVE_TABLE_CLASS)}},{key:"getInputs",value:function(){return t(document.querySelectorAll(this.OPTIONS_FORM_SELECTOR+" input"))}},{key:"getLabels",value:function(){return t(document.querySelectorAll(this.OPTIONS_FORM_SELECTOR+" label"))}},{key:"getPlusButtons",value:function(){return t(document.querySelectorAll(this.OPTIONS_FORM_SELECTOR+" ."+this.PLUS_CLASS))}},{key:"isActiveTableChanged",value:function(){var e=this.getActiveIndex();return JSON.stringify(this.getActiveTableData())!==JSON.stringify(this.tablesData[e])}},{key:"setSubmitStatus",value:function(){this.submitButton.disabled=!this.isActiveTableChanged()}},{key:"saveActiveTable",value:function(){var e=this;if(this.isActiveTableChanged()){var n=this.getActiveTable(),i=document.createElement("form");i.action=this.optionsForm.getAttribute("action"),i.method=this.optionsForm.method,i.appendChild(n.cloneNode(!0)),t(n.querySelectorAll("input")).map((function(e){return i.querySelector("#"+e.id).value=e.value})),t(this.optionsForm.querySelectorAll('input[type="hidden"]')).map((function(e){return i.appendChild(e.cloneNode(!0))})),document.body.appendChild(i);var a=new URLSearchParams(t(new FormData(i)));return a.append("action",Cyr2LatTablesObject.action),a.append("nonce",Cyr2LatTablesObject.nonce),fetch(Cyr2LatTablesObject.ajaxUrl,{method:"POST",body:a}).then((function(e){if(!e.ok)throw new Error(e.statusText);return e.json()})).then((function(t){t.success?(e.showMessage(e.successMessage,t.data),e.tablesData=e.getTablesData()):e.showMessage(e.errorMessage,t.data)})).catch((function(t){return e.showMessage(e.errorMessage,t),{}})).finally((function(){i.parentNode.removeChild(i),e.setSubmitStatus()}))}}},{key:"getTableData",value:function(e){var n=this,i=t(e.querySelectorAll("input")),a={};return i.forEach((function(e){var t=document.querySelector(n.OPTIONS_FORM_SELECTOR+' label[for="'+e.id+'"]');a[t.innerHTML]=e.value})),a}},{key:"getTablesData",value:function(){var e=this;return this.getTables().map((function(t){return e.getTableData(t)}))}},{key:"getActiveTableData",value:function(){return this.getTableData(this.getActiveTable())}},{key:"addWrapper",value:function(){this.wrapper=document.createElement("ul"),this.wrapper.classList.add("nav-tab-wrapper"),this.optionsForm.insertBefore(this.wrapper,this.optionsForm.firstChild)}},{key:"addMessageLine",value:function(e){var t=document.createElement("div");return t.id=e,this.optionsForm.insertBefore(t,this.optionsForm.firstChild),t}},{key:"addMessageLines",value:function(){this.successMessage=this.addMessageLine("ctl-success"),this.errorMessage=this.addMessageLine("ctl-error")}},{key:"moveTabs",value:function(){var e=document.querySelector(".ctl-settings-tabs");e&&this.optionsForm.insertBefore(e,this.optionsForm.firstChild)}},{key:"addEditLabelInput",value:function(){this.editLabelInput=document.createElement("input"),this.editLabelInput.id=this.EDIT_LABEL_ID,this.editLabelInput.style.display="none",document.body.appendChild(this.editLabelInput)}},{key:"hideEditLabelInput",value:function(){this.editLabelInput.style.display="none",this.editLabelInput.classList.remove(this.EDIT_LABEL_ERROR_CLASS),document.body.appendChild(this.editLabelInput)}},{key:"getLastCell",value:function(){return document.querySelector(this.OPTIONS_FORM_SELECTOR+" ."+this.ACTIVE_TABLE_CLASS+" ."+this.PLUS_CLASS).previousElementSibling}},{key:"addCell",value:function(){var e=this.getLastCell();e.parentElement.insertBefore(e.cloneNode(!0),e.nextElementSibling);var t=(e=this.getLastCell()).querySelector("label"),n=e.querySelector("input"),i=n.id.split("-"),a=i[0]+"-"+(parseInt(i[1])+1);t.htmlFor=a,t.innerHTML="",n.id=a,n.value="",n.setAttribute("value",""),this.replaceName(n,""),this.bindEvents(),this.editLabel(t)}},{key:"hideTables",value:function(){var e=this,t=0;this.getTables().map((function(n,i){n.classList.add("ctl-table"),e.CURRENT_STUB_ID===n.previousElementSibling.id&&(t=i,n.classList.add(e.ACTIVE_TABLE_CLASS));var a=document.createElement("div");return a.classList.add(e.PLUS_CLASS),a.innerHTML=e.plusButton,n.querySelector("td fieldset").appendChild(a),null})),this.getHeaders().map((function(n,i){return n.classList.add("nav-tab"),n.dataset.index=i.toString(),e.wrapper.appendChild(n),i===t&&(n.classList.add(e.CURRENT_NAV_TAB_CLASS),n.classList.add(e.ACTIVE_NAV_TAB_CLASS)),null}))}},{key:"bindEvents",value:function(){var e=this;this.getHeaders().map((function(t,n,i){return t.onclick=function(t){t.preventDefault();var n=t.target.dataset.index;if(n===e.getActiveIndex())return!1;e.saveActiveTable(),i.map((function(t){return t.classList.remove(e.ACTIVE_NAV_TAB_CLASS)})),i[n].classList.add(e.ACTIVE_NAV_TAB_CLASS);var a=e.getTables();return a.map((function(t){return t.classList.remove(e.ACTIVE_TABLE_CLASS)})),a[n].classList.add(e.ACTIVE_TABLE_CLASS),e.setSubmitStatus(),!1},null})),this.getInputs().map((function(t){return t.oninput=function(){e.setSubmitStatus()},null})),this.getLabels().map((function(t){return t.onclick=function(t){return t.preventDefault(),e.editLabel(t.target),!1},null})),this.editLabelInput.onblur=function(){e.saveLabel()},this.editLabelInput.onkeyup=function(t){"Escape"===t.key&&e.saveLabel(!0),"Enter"===t.key&&e.saveLabel()},this.getPlusButtons().map((function(t){return t.onclick=function(t){return t.preventDefault(),e.addCell(t.target),!1},null})),this.submitButton.onclick=function(t){return t.preventDefault(),e.saveActiveTable(),!1}}},{key:"editLabel",value:function(e){e.parentNode.insertBefore(this.editLabelInput,e.nextSibling),this.editLabelInput.value=e.innerHTML,this.editLabelInput.classList.remove(this.EDIT_LABEL_ERROR_CLASS),this.editLabelInput.style.display="block",this.editLabelInput.focus()}},{key:"isUniqueLabel",value:function(e){return t(this.getActiveTable().querySelectorAll("label")).reduce((function(t,n){return t&&n.innerHTML!==e}),!0)}},{key:"saveLabel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if("none"!==this.editLabelInput.style.display){var t=this.editLabelInput.value.trim();if(""===t){var n=document.getElementById(this.EDIT_LABEL_ID).parentElement;return this.hideEditLabelInput(),n.parentNode.removeChild(n),void this.setSubmitStatus()}var i=this.editLabelInput.parentNode.querySelector("label");if(e||t===i.innerHTML)this.hideEditLabelInput();else if(this.isUniqueLabel(t)){var a=this.editLabelInput.nextElementSibling;this.hideEditLabelInput(),i.innerHTML=t,this.replaceName(a,t),this.setSubmitStatus()}else this.editLabelInput.classList.add(this.EDIT_LABEL_ERROR_CLASS)}}},{key:"replaceName",value:function(e,t){e.name=e.name.replace(/(.+\[.+])\[.*]/g,"$1["+t+"]")}},{key:"clearMessage",value:function(e){e.innerHTML="",e.classList.remove("active")}},{key:"clearMessages",value:function(){this.clearMessage(this.successMessage),this.clearMessage(this.errorMessage),clearTimeout(this.msgTimer)}},{key:"showMessage",value:function(e,t){var n=this;e.innerHTML=t,e.classList.add("active"),this.msgTimer=setTimeout((function(){n.clearMessages()}),5e3)}}],n&&i(e.prototype,n),a&&i(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,a}();const r=s;document.addEventListener("DOMContentLoaded",(function(){new r}))})();
     1(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i<t;i++)n[i]=e[i];return n}function n(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function a(t){var i=function(t,i){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var a=n.call(t,i||"default");if("object"!=e(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===i?String:Number)(t)}(t,"string");return"symbol"==e(i)?i:i+""}var s=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.OPTIONS_FORM_SELECTOR="#ctl-options",this.HEADER_SELECTOR=this.OPTIONS_FORM_SELECTOR+" h2",this.TABLE_SELECTOR=this.OPTIONS_FORM_SELECTOR+" table",this.SUBMIT_SELECTOR=this.OPTIONS_FORM_SELECTOR+" #submit",this.CURRENT_STUB_ID="ctl-current",this.CURRENT_NAV_TAB_CLASS="nav-tab-current",this.ACTIVE_NAV_TAB_CLASS="nav-tab-active",this.ACTIVE_TABLE_CLASS="active",this.EDIT_LABEL_ID="ctl-edit-label",this.EDIT_LABEL_ERROR_CLASS="ctl-edit-label-error",this.plusButton='<button type="button" aria-haspopup="true" aria-expanded="false" class="components-button block-editor-inserter__toggle has-icon" aria-label="Добавить блок"><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 24 24" role="img" aria-hidden="true" focusable="false"><path d="M10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6zM10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6z"></path></svg></button>',this.PLUS_CLASS="ctl-plus",this.optionsForm=document.querySelector(this.OPTIONS_FORM_SELECTOR),this.tablesData=this.getTablesData(),this.submitButton=document.querySelector(this.SUBMIT_SELECTOR),this.addWrapper(),this.addMessageLines(),this.moveTabs(),this.addEditLabelInput(),this.hideTables(),this.bindEvents(),this.setSubmitStatus(),this.checkLocale()},i=[{key:"getHeaders",value:function(){return t(document.querySelectorAll(this.HEADER_SELECTOR))}},{key:"getActiveHeader",value:function(){return document.querySelector(this.HEADER_SELECTOR+"."+this.ACTIVE_NAV_TAB_CLASS)}},{key:"getActiveIndex",value:function(){return this.getActiveHeader().dataset.index}},{key:"getTables",value:function(){return t(document.querySelectorAll(this.TABLE_SELECTOR))}},{key:"getActiveTable",value:function(){return document.querySelector(this.TABLE_SELECTOR+"."+this.ACTIVE_TABLE_CLASS)}},{key:"getInputs",value:function(){return t(document.querySelectorAll(this.OPTIONS_FORM_SELECTOR+" input"))}},{key:"getLabels",value:function(){return t(document.querySelectorAll(this.OPTIONS_FORM_SELECTOR+" label"))}},{key:"getPlusButtons",value:function(){return t(document.querySelectorAll(this.OPTIONS_FORM_SELECTOR+" ."+this.PLUS_CLASS))}},{key:"isActiveTableChanged",value:function(){var e=this.getActiveIndex();return JSON.stringify(this.getActiveTableData())!==JSON.stringify(this.tablesData[e])}},{key:"setSubmitStatus",value:function(){this.submitButton.disabled=!this.isActiveTableChanged()}},{key:"checkLocale",value:function(){var e=Cyr2LatTablesObject.ctlLocale;e="ru_RU"===e?"ISO9":e;var t=this.getActiveTableLocale();t!==e?this.showMessage(this.warningMessage,Cyr2LatTablesObject.localeWarning.replace("{active_table}",t)):this.clearMessage(this.warningMessage)}},{key:"saveActiveTable",value:function(){var e=this;if(this.isActiveTableChanged()){var i=this.getActiveTable(),n=document.createElement("form");n.action=this.optionsForm.getAttribute("action"),n.method=this.optionsForm.method,n.appendChild(i.cloneNode(!0)),t(i.querySelectorAll("input")).map((function(e){return n.querySelector("#"+e.id).value=e.value})),t(this.optionsForm.querySelectorAll('input[type="hidden"]')).map((function(e){return n.appendChild(e.cloneNode(!0))})),document.body.appendChild(n);var a=new URLSearchParams(t(new FormData(n)));return a.append("action",Cyr2LatTablesObject.action),a.append("nonce",Cyr2LatTablesObject.nonce),fetch(Cyr2LatTablesObject.ajaxUrl,{method:"POST",body:a}).then((function(e){if(!e.ok)throw new Error(e.statusText);return e.json()})).then((function(t){t.success?(e.showMessage(e.successMessage,t.data),e.tablesData=e.getTablesData()):e.showMessage(e.errorMessage,t.data)})).catch((function(t){return e.showMessage(e.errorMessage,t),{}})).finally((function(){n.parentNode.removeChild(n),e.setSubmitStatus()}))}}},{key:"getTableData",value:function(e){var i=this,n=t(e.querySelectorAll("input")),a={};return n.forEach((function(e){var t=document.querySelector(i.OPTIONS_FORM_SELECTOR+' label[for="'+e.id+'"]');a[t.innerHTML]=e.value})),a}},{key:"getTablesData",value:function(){var e=this;return this.getTables().map((function(t){return e.getTableData(t)}))}},{key:"getActiveTableData",value:function(){return this.getTableData(this.getActiveTable())}},{key:"getActiveTableLocale",value:function(){return this.getActiveTable().querySelector("tr").classList[0].replace("cyr-to-lat-tables-","").replace("-","_")}},{key:"addWrapper",value:function(){this.wrapper=document.createElement("ul"),this.wrapper.classList.add("nav-tab-wrapper"),this.optionsForm.insertBefore(this.wrapper,this.optionsForm.firstChild)}},{key:"addMessageLine",value:function(e){var t=document.createElement("div");return t.id=e,this.optionsForm.insertBefore(t,this.optionsForm.firstChild),t}},{key:"addMessageLines",value:function(){this.successMessage=this.addMessageLine("ctl-success"),this.errorMessage=this.addMessageLine("ctl-error"),this.warningMessage=this.addMessageLine("ctl-warning")}},{key:"moveTabs",value:function(){var e=document.querySelector(".ctl-settings-tabs");e&&this.optionsForm.insertBefore(e,this.optionsForm.firstChild)}},{key:"addEditLabelInput",value:function(){this.editLabelInput=document.createElement("input"),this.editLabelInput.id=this.EDIT_LABEL_ID,this.editLabelInput.style.display="none",document.body.appendChild(this.editLabelInput)}},{key:"hideEditLabelInput",value:function(){this.editLabelInput.style.display="none",this.editLabelInput.classList.remove(this.EDIT_LABEL_ERROR_CLASS),document.body.appendChild(this.editLabelInput)}},{key:"getLastCell",value:function(){return document.querySelector(this.OPTIONS_FORM_SELECTOR+" ."+this.ACTIVE_TABLE_CLASS+" ."+this.PLUS_CLASS).previousElementSibling}},{key:"addCell",value:function(){var e=this.getLastCell();e.parentElement.insertBefore(e.cloneNode(!0),e.nextElementSibling);var t=(e=this.getLastCell()).querySelector("label"),i=e.querySelector("input"),n=i.id.split("-"),a=n[0]+"-"+(parseInt(n[1])+1);t.htmlFor=a,t.innerHTML="",i.id=a,i.value="",i.setAttribute("value",""),this.replaceName(i,""),this.bindEvents(),this.editLabel(t)}},{key:"hideTables",value:function(){var e=this,t=0;this.getTables().map((function(i,n){i.classList.add("ctl-table"),e.CURRENT_STUB_ID===i.previousElementSibling.id&&(t=n,i.classList.add(e.ACTIVE_TABLE_CLASS));var a=document.createElement("div");return a.classList.add(e.PLUS_CLASS),a.innerHTML=e.plusButton,i.querySelector("td fieldset").appendChild(a),null})),this.getHeaders().map((function(i,n){return i.classList.add("nav-tab"),i.dataset.index=n.toString(),e.wrapper.appendChild(i),n===t&&(i.classList.add(e.CURRENT_NAV_TAB_CLASS),i.classList.add(e.ACTIVE_NAV_TAB_CLASS)),null}))}},{key:"bindEvents",value:function(){var e=this;this.getHeaders().map((function(t,i,n){return t.onclick=function(t){t.preventDefault();var i=t.target.dataset.index;if(i===e.getActiveIndex())return!1;e.saveActiveTable(),n.map((function(t){return t.classList.remove(e.ACTIVE_NAV_TAB_CLASS)})),n[i].classList.add(e.ACTIVE_NAV_TAB_CLASS);var a=e.getTables();return a.map((function(t){return t.classList.remove(e.ACTIVE_TABLE_CLASS)})),a[i].classList.add(e.ACTIVE_TABLE_CLASS),e.setSubmitStatus(),e.checkLocale(),!1},null})),this.getInputs().map((function(t){return t.oninput=function(){e.setSubmitStatus()},null})),this.getLabels().map((function(t){return t.onclick=function(t){return t.preventDefault(),e.editLabel(t.target),!1},null})),this.editLabelInput.onblur=function(){e.saveLabel()},this.editLabelInput.onkeyup=function(t){"Escape"===t.key&&e.saveLabel(!0),"Enter"===t.key&&e.saveLabel()},this.getPlusButtons().map((function(t){return t.onclick=function(t){return t.preventDefault(),e.addCell(t.target),!1},null})),this.submitButton.onclick=function(t){return t.preventDefault(),e.saveActiveTable(),!1}}},{key:"editLabel",value:function(e){e.parentNode.insertBefore(this.editLabelInput,e.nextSibling),this.editLabelInput.value=e.innerHTML,this.editLabelInput.classList.remove(this.EDIT_LABEL_ERROR_CLASS),this.editLabelInput.style.display="block",this.editLabelInput.focus()}},{key:"isUniqueLabel",value:function(e){return t(this.getActiveTable().querySelectorAll("label")).reduce((function(t,i){return t&&i.innerHTML!==e}),!0)}},{key:"saveLabel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if("none"!==this.editLabelInput.style.display){var t=this.editLabelInput.value.trim();if(""===t){var i=document.getElementById(this.EDIT_LABEL_ID).parentElement;return this.hideEditLabelInput(),i.parentNode.removeChild(i),void this.setSubmitStatus()}var n=this.editLabelInput.parentNode.querySelector("label");if(e||t===n.innerHTML)this.hideEditLabelInput();else if(this.isUniqueLabel(t)){var a=this.editLabelInput.nextElementSibling;this.hideEditLabelInput(),n.innerHTML=t,this.replaceName(a,t),this.setSubmitStatus()}else this.editLabelInput.classList.add(this.EDIT_LABEL_ERROR_CLASS)}}},{key:"replaceName",value:function(e,t){e.name=e.name.replace(/(.+\[.+])\[.*]/g,"$1["+t+"]")}},{key:"clearMessage",value:function(e){e.innerHTML="",e.classList.remove("active")}},{key:"clearMessages",value:function(){this.clearMessage(this.successMessage),this.clearMessage(this.errorMessage),clearTimeout(this.msgTimer)}},{key:"showMessage",value:function(e,t){var i=this;e.innerHTML=t,e.classList.add("active"),this.msgTimer=setTimeout((function(){i.clearMessages()}),5e3)}}],i&&n(e.prototype,i),a&&n(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,i,a}();const r=s;document.addEventListener("DOMContentLoaded",(function(){new r}))})();
  • cyr2lat/tags/6.3.0/bin/update-tests

    r3021540 r3211834  
    5151elif [[ $PHP_VERSION == '7.2' ]]; then
    5252  PHP_UNIT='8.5'
    53 elif [[ $PHP_VERSION == '7.3' || $PHP_VERSION == '7.4' || $PHP_VERSION == '8.0' || $PHP_VERSION == '8.1' || $PHP_VERSION == '8.2' || $PHP_VERSION == '8.3' ]]; then
     53elif [[ $PHP_VERSION == '7.3' || $PHP_VERSION == '7.4' || $PHP_VERSION == '8.0' || $PHP_VERSION == '8.1' || $PHP_VERSION == '8.2' || $PHP_VERSION == '8.3' || $PHP_VERSION == '8.4' ]]; then
    5454  PHP_UNIT='9.5'
    5555fi
     
    7272if [[ $PHP_UNIT == '6.5' || $PHP_UNIT == '7.5' ]]; then
    7373  echo "Preparing tests for phpunit-$PHP_UNIT"
    74   find $TEST_DIR -type f -exec sed -i "s/: void / /g" {} \;
     74  find $TEST_DIR -type f -exec sed -i "s/: void//g" {} \;
    7575fi
    7676
  • cyr2lat/tags/6.3.0/changelog.txt

    r3195936 r3211834  
    274274* Added Belorussian, Macedonian, Kazakh tables.
    275275* Fixed bug with MariaDB during old slug conversion.
    276 * Fixed not saving of user modifications in default iso9 table.
     276* Fixed not saving of user modifications in default ISO9 table.
    277277
    278278= 3.6.5 (11.02.2019) =
  • cyr2lat/tags/6.3.0/cyr-to-lat.php

    r3195936 r3211834  
    1111 * Plugin URI:        https://kagg.eu/cyr-to-lat/
    1212 * Description:       Convert Non-Latin characters in post and term slugs to Latin characters. Useful for creating human-readable URLs. Based on the original plugin by Anton Skorobogatov.
    13  * Version:           6.2.3
     13 * Version:           6.3.0
    1414 * Requires at least: 5.3
    1515 * Requires PHP:      7.2.0
     
    4242 * Plugin version.
    4343 */
    44 define( 'CYR_TO_LAT_VERSION', '6.2.3' );
     44define( 'CYR_TO_LAT_VERSION', '6.3.0' );
    4545
    4646/**
     
    7777 * Minimum required php version.
    7878 */
    79 define( 'CYR_TO_LAT_MINIMUM_PHP_REQUIRED_VERSION', '7.0' );
     79define( 'CYR_TO_LAT_MINIMUM_PHP_REQUIRED_VERSION', '7.2' );
    8080
    8181/**
  • cyr2lat/tags/6.3.0/readme.txt

    r3195936 r3211834  
    44Requires at least: 5.3
    55Tested up to: 6.7
    6 Stable tag: 6.2.3
     6Stable tag: 6.3.0
    77Requires PHP: 7.2.0
    88License: GPLv2 or later
     
    222222== Changelog ==
    223223
     224= 6.3.0 (22.12.2024) =
     225* Added warning message on the Tables page when active table does not match the site locale.
     226* Removed fix for translation after WordPress 6.5+ due to performance issues.
     227
    224228= 6.2.3 (24.11.2024) =
    225229* Fixed deprecation error with PHP 8.4.
  • cyr2lat/tags/6.3.0/src/php/ConversionTables.php

    r3188005 r3211834  
    11191119                ];
    11201120                break;
    1121             case 'iso9':
     1121            case 'ISO9':
    11221122            default:
    11231123                $table = [
  • cyr2lat/tags/6.3.0/src/php/ErrorHandler.php

    r3189796 r3211834  
    3939            add_action( 'doing_it_wrong_run', [ $this, 'action_doing_it_wrong_run' ], 20, 3 );
    4040            add_filter( 'doing_it_wrong_trigger_error', [ $this, 'filter_doing_it_wrong_trigger_error' ], 10, 4 );
    41         }
    42 
    43         // Fix WP 6.5+ translation error.
    44         if ( version_compare( $GLOBALS['wp_version'], '6.5', '>=' ) ) {
    45             add_filter( 'gettext', [ $this, 'filter_gettext' ], 10, 3 );
    4641        }
    4742    }
     
    110105
    111106    /**
    112      * Filter for gettext.
    113      *
    114      * @param string|mixed $translation Translated text.
    115      * @param string|mixed $text        Text to translate.
    116      * @param string|mixed $domain      Text domain. Unique identifier for retrieving translated strings.
    117      *
    118      * @return string
    119      */
    120     public function filter_gettext( $translation, $text, $domain ): string {
    121 
    122         $translation = (string) $translation;
    123         $text        = (string) $text;
    124         $domain      = (string) $domain;
    125 
    126         if ( '' === $translation && 'cyr2lat' === $domain ) {
    127             $translation = $text;
    128         }
    129 
    130         return $translation;
    131     }
    132 
    133     /**
    134107     * Whether it is the just_in_time_error for plugin-related domain.
    135108     *
  • cyr2lat/tags/6.3.0/src/php/Settings/Settings.php

    r3188005 r3211834  
    204204        $table  = $this->get( $locale );
    205205        if ( empty( $table ) ) {
    206             $table = $this->get( 'iso9' );
     206            $table = $this->get( 'ISO9' );
    207207        }
    208208
  • cyr2lat/tags/6.3.0/src/php/Settings/SystemInfo.php

    r3188005 r3211834  
    151151        $locales        = $tables->get_locales();
    152152        $current_locale = $tables->get_current_locale();
    153         $current_locale = 'iso9' === $current_locale ? 'ISO9' : $current_locale;
    154153
    155154        $data .= $this->data( 'Version', CYR_TO_LAT_VERSION );
     
    167166            }
    168167
    169             $table_name = 'iso9' === $key ? 'ISO9' : $key;
     168            $table_name = $key;
    170169
    171170            $data .= $this->header( "--- $table_name table customization ---" );
  • cyr2lat/tags/6.3.0/src/php/Settings/Tables.php

    r3188005 r3211834  
    8585
    8686        $this->locales = [
    87             'iso9'  => __( 'Default', 'cyr2lat' ) . '<br>ISO9',
     87            'ISO9'  => __( 'Default', 'cyr2lat' ) . '<br>ISO9',
    8888            'bel'   => __( 'Belarusian', 'cyr2lat' ) . '<br>bel',
    8989            'uk'    => __( 'Ukrainian', 'cyr2lat' ) . '<br>uk',
     
    106106     */
    107107    public function get_current_locale(): string {
    108         $current_locale = (string) apply_filters( 'ctl_locale', get_locale() );
    109 
    110         return array_key_exists( $current_locale, $this->locales ) ? $current_locale : 'iso9';
     108        $ctl_locale = $this->get_ctl_locale();
     109
     110        return array_key_exists( $ctl_locale, $this->locales ) ? $ctl_locale : 'ISO9';
    111111    }
    112112
     
    163163            self::OBJECT,
    164164            [
    165                 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
    166                 'action'  => self::SAVE_TABLE_ACTION,
    167                 'nonce'   => wp_create_nonce( self::SAVE_TABLE_ACTION ),
     165                'ajaxUrl'       => admin_url( 'admin-ajax.php' ),
     166                'action'        => self::SAVE_TABLE_ACTION,
     167                'nonce'         => wp_create_nonce( self::SAVE_TABLE_ACTION ),
     168                'ctlLocale'     => $this->get_ctl_locale(),
     169                'localeWarning' => sprintf(
     170                /* translators: 1: Site locale. Do not touch text in {} */
     171                    __( 'Active table "{active_table}" does not match the current site locale: "%1$s". The "%2$s" table will be used for transliteration.', 'cyr2lat' ),
     172                    $this->get_ctl_locale(),
     173                    $this->get_current_locale()
     174                ),
    168175            ]
    169176        );
     
    212219        wp_send_json_success( esc_html__( 'Options saved.', 'cyr2lat' ) );
    213220    }
     221
     222    /**
     223     * Get Cyr To Lat locale.
     224     *
     225     * @return string
     226     */
     227    protected function get_ctl_locale(): string {
     228        return (string) apply_filters( 'ctl_locale', get_locale() );
     229    }
    214230}
  • cyr2lat/tags/6.3.0/vendor/autoload.php

    r3188005 r3211834  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInitc5b7344a4117fb2177a762f1895475b0::getLoader();
     25return ComposerAutoloaderInitd288e5bc05ffec7fab5c5946a88b734e::getLoader();
  • cyr2lat/tags/6.3.0/vendor/composer/InstalledVersions.php

    r2890969 r3211834  
    323323
    324324        $installed = array();
     325        $copiedLocalDir = false;
    325326
    326327        if (self::$canGetVendors) {
     
    331332                    /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
    332333                    $required = require $vendorDir.'/composer/installed.php';
    333                     $installed[] = self::$installedByVendor[$vendorDir] = $required;
    334                     if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
    335                         self::$installed = $installed[count($installed) - 1];
     334                    self::$installedByVendor[$vendorDir] = $required;
     335                    $installed[] = $required;
     336                    if (strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
     337                        self::$installed = $required;
     338                        $copiedLocalDir = true;
    336339                    }
    337340                }
     
    351354        }
    352355
    353         if (self::$installed !== array()) {
     356        if (self::$installed !== array() && !$copiedLocalDir) {
    354357            $installed[] = self::$installed;
    355358        }
  • cyr2lat/tags/6.3.0/vendor/composer/autoload_real.php

    r3188005 r3211834  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitc5b7344a4117fb2177a762f1895475b0
     5class ComposerAutoloaderInitd288e5bc05ffec7fab5c5946a88b734e
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInitc5b7344a4117fb2177a762f1895475b0', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInitd288e5bc05ffec7fab5c5946a88b734e', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInitc5b7344a4117fb2177a762f1895475b0', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInitd288e5bc05ffec7fab5c5946a88b734e', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInitc5b7344a4117fb2177a762f1895475b0::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInitd288e5bc05ffec7fab5c5946a88b734e::getInitializer($loader));
    3131
    3232        $loader->setClassMapAuthoritative(true);
    3333        $loader->register(true);
    3434
    35         $filesToLoad = \Composer\Autoload\ComposerStaticInitc5b7344a4117fb2177a762f1895475b0::$files;
     35        $filesToLoad = \Composer\Autoload\ComposerStaticInitd288e5bc05ffec7fab5c5946a88b734e::$files;
    3636        $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
    3737            if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • cyr2lat/tags/6.3.0/vendor/composer/autoload_static.php

    r3189796 r3211834  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitc5b7344a4117fb2177a762f1895475b0
     7class ComposerStaticInitd288e5bc05ffec7fab5c5946a88b734e
    88{
    99    public static $files = array (
     
    5454    {
    5555        return \Closure::bind(function () use ($loader) {
    56             $loader->prefixLengthsPsr4 = ComposerStaticInitc5b7344a4117fb2177a762f1895475b0::$prefixLengthsPsr4;
    57             $loader->prefixDirsPsr4 = ComposerStaticInitc5b7344a4117fb2177a762f1895475b0::$prefixDirsPsr4;
    58             $loader->classMap = ComposerStaticInitc5b7344a4117fb2177a762f1895475b0::$classMap;
     56            $loader->prefixLengthsPsr4 = ComposerStaticInitd288e5bc05ffec7fab5c5946a88b734e::$prefixLengthsPsr4;
     57            $loader->prefixDirsPsr4 = ComposerStaticInitd288e5bc05ffec7fab5c5946a88b734e::$prefixDirsPsr4;
     58            $loader->classMap = ComposerStaticInitd288e5bc05ffec7fab5c5946a88b734e::$classMap;
    5959
    6060        }, null, ClassLoader::class);
  • cyr2lat/tags/6.3.0/vendor/composer/installed.php

    r3195936 r3211834  
    22    'root' => array(
    33        'name' => 'mihdan/cyr2lat',
    4         'pretty_version' => '6.2.3',
    5         'version' => '6.2.3.0',
    6         'reference' => '96e24a2f49e80d51a6c791a0463458bdef431200',
     4        'pretty_version' => '6.3.0',
     5        'version' => '6.3.0.0',
     6        'reference' => 'c7b6b33351a5234f9616fadd1ef03857b8216d1b',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        'mihdan/cyr2lat' => array(
    14             'pretty_version' => '6.2.3',
    15             'version' => '6.2.3.0',
    16             'reference' => '96e24a2f49e80d51a6c791a0463458bdef431200',
     14            'pretty_version' => '6.3.0',
     15            'version' => '6.3.0.0',
     16            'reference' => 'c7b6b33351a5234f9616fadd1ef03857b8216d1b',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
  • cyr2lat/trunk/assets/css/tables.css

    r2944888 r3211834  
    3030}
    3131
    32 #ctl-success, #ctl-error {
     32#ctl-success, #ctl-error, #ctl-warning {
    3333    max-height: 0;
    3434    color: #fff;
     
    4343
    4444#ctl-error {
     45    background: #d63638;
     46}
     47
     48#ctl-warning {
    4549    background: #FF9800;
    4650}
    4751
    48 #ctl-success.active, #ctl-error.active {
    49     padding: 10px 25px;
     52#ctl-success.active, #ctl-error.active, #ctl-warning.active {
     53    padding: 10px 15px;
    5054    max-height: 34px;
    5155    height: 14px;
  • cyr2lat/trunk/assets/css/tables.min.css

    r2944888 r3211834  
    1 #ctl-options.ctl-tables h2,#ctl-options.ctl-tables table{display:none}#ctl-options.ctl-tables h2.nav-tab,#ctl-options.ctl-tables table.active{border-radius:4px;display:block;font-size:14px}#ctl-options.ctl-tables h2.nav-tab{overflow-wrap:break-word;padding:5px;white-space:pre-line}#ctl-options .form-table th{display:none}#ctl-options table tbody tr td{display:table-cell;padding:15px 10px}.ctl-table{display:none}#ctl-error,#ctl-success{color:#fff;font-size:14px;max-height:0;padding:0;transition:all .5s}#ctl-success{background:#8bc34a}#ctl-error{background:#ff9800}#ctl-error.active,#ctl-success.active{height:14px;line-height:14px;margin-top:15px;max-height:34px;padding:10px 25px}#ctl-options .nav-tab-wrapper{border-bottom:none;float:left;padding-top:22px;text-align:center;width:120px}body.js #ctl-options .ctl-table{clear:none;float:left;width:calc(100% - 120px)}#ctl-options .nav-tab{border:1px solid #c3c4c7;box-sizing:border-box;clear:both;cursor:pointer;margin:0 0 23px;width:100%}#ctl-convert-existing-slugs,#ctl-options .submit{clear:both;float:left;margin-top:0;padding-bottom:0}#ctl-convert-existing-slugs .submit{margin-top:0}#ctl-options .nav-tab-active{background:#4f94d4;border-color:#2271b1;color:#fff}#ctl-options .nav-tab-current.nav-tab-active{background:#2271b1;border-color:#0a4b78;color:#fff}.ctl-table.active{display:block}.ctl-table-cell{display:flex;float:left;justify-content:space-between;margin:0 .2em 1em;position:relative;width:6.2em}td fieldset .ctl-table-cell label{border:1px solid transparent;border-radius:4px;box-sizing:border-box;display:inline-block;height:30px;line-height:30px;margin:0!important;overflow:hidden;padding:0 8px;text-align:right;vertical-align:middle;width:3em;word-break:break-all}.ctl-table-cell input{border-width:1px;display:inline-block;margin:0;vertical-align:middle;width:3em!important}.ctl-table-cell #ctl-edit-label{border:1px solid #007cba!important;border-radius:4px;box-shadow:0 0 0 1px #007cba;height:30px;left:0;margin:0;outline:none;padding:0 8px;position:absolute;top:0;width:3em!important}.ctl-table-cell #ctl-edit-label:focus-visible{outline:none}.ctl-edit-label-error{background:#ff9800}.ctl-plus{align-items:center;display:flex;height:30px;justify-content:center;position:relative;width:6.2em}.ctl-plus button{border:none;cursor:pointer;height:24px;padding:0;width:24px}.ctl-plus button:focus{outline:none}@media screen and (max-width:782px){.ctl-table-cell{width:100px}td fieldset .ctl-table-cell label{height:40px;line-height:40px;width:48px}.ctl-table-cell #ctl-edit-label{height:40px}#ctl-options table tbody tr td{padding:15px 1px}.ctl-plus{height:40px;width:100px}}
     1#ctl-options.ctl-tables h2,#ctl-options.ctl-tables table{display:none}#ctl-options.ctl-tables h2.nav-tab,#ctl-options.ctl-tables table.active{border-radius:4px;display:block;font-size:14px}#ctl-options.ctl-tables h2.nav-tab{overflow-wrap:break-word;padding:5px;white-space:pre-line}#ctl-options .form-table th{display:none}#ctl-options table tbody tr td{display:table-cell;padding:15px 10px}.ctl-table{display:none}#ctl-error,#ctl-success,#ctl-warning{color:#fff;font-size:14px;max-height:0;padding:0;transition:all .5s}#ctl-success{background:#8bc34a}#ctl-error{background:#d63638}#ctl-warning{background:#ff9800}#ctl-error.active,#ctl-success.active,#ctl-warning.active{height:14px;line-height:14px;margin-top:15px;max-height:34px;padding:10px 15px}#ctl-options .nav-tab-wrapper{border-bottom:none;float:left;padding-top:22px;text-align:center;width:120px}body.js #ctl-options .ctl-table{clear:none;float:left;width:calc(100% - 120px)}#ctl-options .nav-tab{border:1px solid #c3c4c7;box-sizing:border-box;clear:both;cursor:pointer;margin:0 0 23px;width:100%}#ctl-convert-existing-slugs,#ctl-options .submit{clear:both;float:left;margin-top:0;padding-bottom:0}#ctl-convert-existing-slugs .submit{margin-top:0}#ctl-options .nav-tab-active{background:#4f94d4;border-color:#2271b1;color:#fff}#ctl-options .nav-tab-current.nav-tab-active{background:#2271b1;border-color:#0a4b78;color:#fff}.ctl-table.active{display:block}.ctl-table-cell{display:flex;float:left;justify-content:space-between;margin:0 .2em 1em;position:relative;width:6.2em}td fieldset .ctl-table-cell label{border:1px solid transparent;border-radius:4px;box-sizing:border-box;display:inline-block;height:30px;line-height:30px;margin:0!important;overflow:hidden;padding:0 8px;text-align:right;vertical-align:middle;width:3em;word-break:break-all}.ctl-table-cell input{border-width:1px;display:inline-block;margin:0;vertical-align:middle;width:3em!important}.ctl-table-cell #ctl-edit-label{border:1px solid #007cba!important;border-radius:4px;box-shadow:0 0 0 1px #007cba;height:30px;left:0;margin:0;outline:none;padding:0 8px;position:absolute;top:0;width:3em!important}.ctl-table-cell #ctl-edit-label:focus-visible{outline:none}.ctl-edit-label-error{background:#ff9800}.ctl-plus{align-items:center;display:flex;height:30px;justify-content:center;position:relative;width:6.2em}.ctl-plus button{border:none;cursor:pointer;height:24px;padding:0;width:24px}.ctl-plus button:focus{outline:none}@media screen and (max-width:782px){.ctl-table-cell{width:100px}td fieldset .ctl-table-cell label{height:40px;line-height:40px;width:48px}.ctl-table-cell #ctl-edit-label{height:40px}#ctl-options table tbody tr td{padding:15px 1px}.ctl-plus{height:40px;width:100px}}
  • cyr2lat/trunk/assets/js/apps/tables.js

    r3188005 r3211834  
    1 (()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?n(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function i(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,a(i.key),i)}}function a(t){var n=function(t,n){if("object"!=e(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var a=i.call(t,n||"default");if("object"!=e(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==e(n)?n:n+""}var s=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.OPTIONS_FORM_SELECTOR="#ctl-options",this.HEADER_SELECTOR=this.OPTIONS_FORM_SELECTOR+" h2",this.TABLE_SELECTOR=this.OPTIONS_FORM_SELECTOR+" table",this.SUBMIT_SELECTOR=this.OPTIONS_FORM_SELECTOR+" #submit",this.CURRENT_STUB_ID="ctl-current",this.CURRENT_NAV_TAB_CLASS="nav-tab-current",this.ACTIVE_NAV_TAB_CLASS="nav-tab-active",this.ACTIVE_TABLE_CLASS="active",this.EDIT_LABEL_ID="ctl-edit-label",this.EDIT_LABEL_ERROR_CLASS="ctl-edit-label-error",this.plusButton='<button type="button" aria-haspopup="true" aria-expanded="false" class="components-button block-editor-inserter__toggle has-icon" aria-label="Добавить блок"><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 24 24" role="img" aria-hidden="true" focusable="false"><path d="M10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6zM10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6z"></path></svg></button>',this.PLUS_CLASS="ctl-plus",this.optionsForm=document.querySelector(this.OPTIONS_FORM_SELECTOR),this.tablesData=this.getTablesData(),this.submitButton=document.querySelector(this.SUBMIT_SELECTOR),this.addWrapper(),this.addMessageLines(),this.moveTabs(),this.addEditLabelInput(),this.hideTables(),this.bindEvents(),this.setSubmitStatus()},n=[{key:"getHeaders",value:function(){return t(document.querySelectorAll(this.HEADER_SELECTOR))}},{key:"getActiveHeader",value:function(){return document.querySelector(this.HEADER_SELECTOR+"."+this.ACTIVE_NAV_TAB_CLASS)}},{key:"getActiveIndex",value:function(){return this.getActiveHeader().dataset.index}},{key:"getTables",value:function(){return t(document.querySelectorAll(this.TABLE_SELECTOR))}},{key:"getActiveTable",value:function(){return document.querySelector(this.TABLE_SELECTOR+"."+this.ACTIVE_TABLE_CLASS)}},{key:"getInputs",value:function(){return t(document.querySelectorAll(this.OPTIONS_FORM_SELECTOR+" input"))}},{key:"getLabels",value:function(){return t(document.querySelectorAll(this.OPTIONS_FORM_SELECTOR+" label"))}},{key:"getPlusButtons",value:function(){return t(document.querySelectorAll(this.OPTIONS_FORM_SELECTOR+" ."+this.PLUS_CLASS))}},{key:"isActiveTableChanged",value:function(){var e=this.getActiveIndex();return JSON.stringify(this.getActiveTableData())!==JSON.stringify(this.tablesData[e])}},{key:"setSubmitStatus",value:function(){this.submitButton.disabled=!this.isActiveTableChanged()}},{key:"saveActiveTable",value:function(){var e=this;if(this.isActiveTableChanged()){var n=this.getActiveTable(),i=document.createElement("form");i.action=this.optionsForm.getAttribute("action"),i.method=this.optionsForm.method,i.appendChild(n.cloneNode(!0)),t(n.querySelectorAll("input")).map((function(e){return i.querySelector("#"+e.id).value=e.value})),t(this.optionsForm.querySelectorAll('input[type="hidden"]')).map((function(e){return i.appendChild(e.cloneNode(!0))})),document.body.appendChild(i);var a=new URLSearchParams(t(new FormData(i)));return a.append("action",Cyr2LatTablesObject.action),a.append("nonce",Cyr2LatTablesObject.nonce),fetch(Cyr2LatTablesObject.ajaxUrl,{method:"POST",body:a}).then((function(e){if(!e.ok)throw new Error(e.statusText);return e.json()})).then((function(t){t.success?(e.showMessage(e.successMessage,t.data),e.tablesData=e.getTablesData()):e.showMessage(e.errorMessage,t.data)})).catch((function(t){return e.showMessage(e.errorMessage,t),{}})).finally((function(){i.parentNode.removeChild(i),e.setSubmitStatus()}))}}},{key:"getTableData",value:function(e){var n=this,i=t(e.querySelectorAll("input")),a={};return i.forEach((function(e){var t=document.querySelector(n.OPTIONS_FORM_SELECTOR+' label[for="'+e.id+'"]');a[t.innerHTML]=e.value})),a}},{key:"getTablesData",value:function(){var e=this;return this.getTables().map((function(t){return e.getTableData(t)}))}},{key:"getActiveTableData",value:function(){return this.getTableData(this.getActiveTable())}},{key:"addWrapper",value:function(){this.wrapper=document.createElement("ul"),this.wrapper.classList.add("nav-tab-wrapper"),this.optionsForm.insertBefore(this.wrapper,this.optionsForm.firstChild)}},{key:"addMessageLine",value:function(e){var t=document.createElement("div");return t.id=e,this.optionsForm.insertBefore(t,this.optionsForm.firstChild),t}},{key:"addMessageLines",value:function(){this.successMessage=this.addMessageLine("ctl-success"),this.errorMessage=this.addMessageLine("ctl-error")}},{key:"moveTabs",value:function(){var e=document.querySelector(".ctl-settings-tabs");e&&this.optionsForm.insertBefore(e,this.optionsForm.firstChild)}},{key:"addEditLabelInput",value:function(){this.editLabelInput=document.createElement("input"),this.editLabelInput.id=this.EDIT_LABEL_ID,this.editLabelInput.style.display="none",document.body.appendChild(this.editLabelInput)}},{key:"hideEditLabelInput",value:function(){this.editLabelInput.style.display="none",this.editLabelInput.classList.remove(this.EDIT_LABEL_ERROR_CLASS),document.body.appendChild(this.editLabelInput)}},{key:"getLastCell",value:function(){return document.querySelector(this.OPTIONS_FORM_SELECTOR+" ."+this.ACTIVE_TABLE_CLASS+" ."+this.PLUS_CLASS).previousElementSibling}},{key:"addCell",value:function(){var e=this.getLastCell();e.parentElement.insertBefore(e.cloneNode(!0),e.nextElementSibling);var t=(e=this.getLastCell()).querySelector("label"),n=e.querySelector("input"),i=n.id.split("-"),a=i[0]+"-"+(parseInt(i[1])+1);t.htmlFor=a,t.innerHTML="",n.id=a,n.value="",n.setAttribute("value",""),this.replaceName(n,""),this.bindEvents(),this.editLabel(t)}},{key:"hideTables",value:function(){var e=this,t=0;this.getTables().map((function(n,i){n.classList.add("ctl-table"),e.CURRENT_STUB_ID===n.previousElementSibling.id&&(t=i,n.classList.add(e.ACTIVE_TABLE_CLASS));var a=document.createElement("div");return a.classList.add(e.PLUS_CLASS),a.innerHTML=e.plusButton,n.querySelector("td fieldset").appendChild(a),null})),this.getHeaders().map((function(n,i){return n.classList.add("nav-tab"),n.dataset.index=i.toString(),e.wrapper.appendChild(n),i===t&&(n.classList.add(e.CURRENT_NAV_TAB_CLASS),n.classList.add(e.ACTIVE_NAV_TAB_CLASS)),null}))}},{key:"bindEvents",value:function(){var e=this;this.getHeaders().map((function(t,n,i){return t.onclick=function(t){t.preventDefault();var n=t.target.dataset.index;if(n===e.getActiveIndex())return!1;e.saveActiveTable(),i.map((function(t){return t.classList.remove(e.ACTIVE_NAV_TAB_CLASS)})),i[n].classList.add(e.ACTIVE_NAV_TAB_CLASS);var a=e.getTables();return a.map((function(t){return t.classList.remove(e.ACTIVE_TABLE_CLASS)})),a[n].classList.add(e.ACTIVE_TABLE_CLASS),e.setSubmitStatus(),!1},null})),this.getInputs().map((function(t){return t.oninput=function(){e.setSubmitStatus()},null})),this.getLabels().map((function(t){return t.onclick=function(t){return t.preventDefault(),e.editLabel(t.target),!1},null})),this.editLabelInput.onblur=function(){e.saveLabel()},this.editLabelInput.onkeyup=function(t){"Escape"===t.key&&e.saveLabel(!0),"Enter"===t.key&&e.saveLabel()},this.getPlusButtons().map((function(t){return t.onclick=function(t){return t.preventDefault(),e.addCell(t.target),!1},null})),this.submitButton.onclick=function(t){return t.preventDefault(),e.saveActiveTable(),!1}}},{key:"editLabel",value:function(e){e.parentNode.insertBefore(this.editLabelInput,e.nextSibling),this.editLabelInput.value=e.innerHTML,this.editLabelInput.classList.remove(this.EDIT_LABEL_ERROR_CLASS),this.editLabelInput.style.display="block",this.editLabelInput.focus()}},{key:"isUniqueLabel",value:function(e){return t(this.getActiveTable().querySelectorAll("label")).reduce((function(t,n){return t&&n.innerHTML!==e}),!0)}},{key:"saveLabel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if("none"!==this.editLabelInput.style.display){var t=this.editLabelInput.value.trim();if(""===t){var n=document.getElementById(this.EDIT_LABEL_ID).parentElement;return this.hideEditLabelInput(),n.parentNode.removeChild(n),void this.setSubmitStatus()}var i=this.editLabelInput.parentNode.querySelector("label");if(e||t===i.innerHTML)this.hideEditLabelInput();else if(this.isUniqueLabel(t)){var a=this.editLabelInput.nextElementSibling;this.hideEditLabelInput(),i.innerHTML=t,this.replaceName(a,t),this.setSubmitStatus()}else this.editLabelInput.classList.add(this.EDIT_LABEL_ERROR_CLASS)}}},{key:"replaceName",value:function(e,t){e.name=e.name.replace(/(.+\[.+])\[.*]/g,"$1["+t+"]")}},{key:"clearMessage",value:function(e){e.innerHTML="",e.classList.remove("active")}},{key:"clearMessages",value:function(){this.clearMessage(this.successMessage),this.clearMessage(this.errorMessage),clearTimeout(this.msgTimer)}},{key:"showMessage",value:function(e,t){var n=this;e.innerHTML=t,e.classList.add("active"),this.msgTimer=setTimeout((function(){n.clearMessages()}),5e3)}}],n&&i(e.prototype,n),a&&i(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,a}();const r=s;document.addEventListener("DOMContentLoaded",(function(){new r}))})();
     1(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i<t;i++)n[i]=e[i];return n}function n(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function a(t){var i=function(t,i){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var a=n.call(t,i||"default");if("object"!=e(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===i?String:Number)(t)}(t,"string");return"symbol"==e(i)?i:i+""}var s=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.OPTIONS_FORM_SELECTOR="#ctl-options",this.HEADER_SELECTOR=this.OPTIONS_FORM_SELECTOR+" h2",this.TABLE_SELECTOR=this.OPTIONS_FORM_SELECTOR+" table",this.SUBMIT_SELECTOR=this.OPTIONS_FORM_SELECTOR+" #submit",this.CURRENT_STUB_ID="ctl-current",this.CURRENT_NAV_TAB_CLASS="nav-tab-current",this.ACTIVE_NAV_TAB_CLASS="nav-tab-active",this.ACTIVE_TABLE_CLASS="active",this.EDIT_LABEL_ID="ctl-edit-label",this.EDIT_LABEL_ERROR_CLASS="ctl-edit-label-error",this.plusButton='<button type="button" aria-haspopup="true" aria-expanded="false" class="components-button block-editor-inserter__toggle has-icon" aria-label="Добавить блок"><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 24 24" role="img" aria-hidden="true" focusable="false"><path d="M10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6zM10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6z"></path></svg></button>',this.PLUS_CLASS="ctl-plus",this.optionsForm=document.querySelector(this.OPTIONS_FORM_SELECTOR),this.tablesData=this.getTablesData(),this.submitButton=document.querySelector(this.SUBMIT_SELECTOR),this.addWrapper(),this.addMessageLines(),this.moveTabs(),this.addEditLabelInput(),this.hideTables(),this.bindEvents(),this.setSubmitStatus(),this.checkLocale()},i=[{key:"getHeaders",value:function(){return t(document.querySelectorAll(this.HEADER_SELECTOR))}},{key:"getActiveHeader",value:function(){return document.querySelector(this.HEADER_SELECTOR+"."+this.ACTIVE_NAV_TAB_CLASS)}},{key:"getActiveIndex",value:function(){return this.getActiveHeader().dataset.index}},{key:"getTables",value:function(){return t(document.querySelectorAll(this.TABLE_SELECTOR))}},{key:"getActiveTable",value:function(){return document.querySelector(this.TABLE_SELECTOR+"."+this.ACTIVE_TABLE_CLASS)}},{key:"getInputs",value:function(){return t(document.querySelectorAll(this.OPTIONS_FORM_SELECTOR+" input"))}},{key:"getLabels",value:function(){return t(document.querySelectorAll(this.OPTIONS_FORM_SELECTOR+" label"))}},{key:"getPlusButtons",value:function(){return t(document.querySelectorAll(this.OPTIONS_FORM_SELECTOR+" ."+this.PLUS_CLASS))}},{key:"isActiveTableChanged",value:function(){var e=this.getActiveIndex();return JSON.stringify(this.getActiveTableData())!==JSON.stringify(this.tablesData[e])}},{key:"setSubmitStatus",value:function(){this.submitButton.disabled=!this.isActiveTableChanged()}},{key:"checkLocale",value:function(){var e=Cyr2LatTablesObject.ctlLocale;e="ru_RU"===e?"ISO9":e;var t=this.getActiveTableLocale();t!==e?this.showMessage(this.warningMessage,Cyr2LatTablesObject.localeWarning.replace("{active_table}",t)):this.clearMessage(this.warningMessage)}},{key:"saveActiveTable",value:function(){var e=this;if(this.isActiveTableChanged()){var i=this.getActiveTable(),n=document.createElement("form");n.action=this.optionsForm.getAttribute("action"),n.method=this.optionsForm.method,n.appendChild(i.cloneNode(!0)),t(i.querySelectorAll("input")).map((function(e){return n.querySelector("#"+e.id).value=e.value})),t(this.optionsForm.querySelectorAll('input[type="hidden"]')).map((function(e){return n.appendChild(e.cloneNode(!0))})),document.body.appendChild(n);var a=new URLSearchParams(t(new FormData(n)));return a.append("action",Cyr2LatTablesObject.action),a.append("nonce",Cyr2LatTablesObject.nonce),fetch(Cyr2LatTablesObject.ajaxUrl,{method:"POST",body:a}).then((function(e){if(!e.ok)throw new Error(e.statusText);return e.json()})).then((function(t){t.success?(e.showMessage(e.successMessage,t.data),e.tablesData=e.getTablesData()):e.showMessage(e.errorMessage,t.data)})).catch((function(t){return e.showMessage(e.errorMessage,t),{}})).finally((function(){n.parentNode.removeChild(n),e.setSubmitStatus()}))}}},{key:"getTableData",value:function(e){var i=this,n=t(e.querySelectorAll("input")),a={};return n.forEach((function(e){var t=document.querySelector(i.OPTIONS_FORM_SELECTOR+' label[for="'+e.id+'"]');a[t.innerHTML]=e.value})),a}},{key:"getTablesData",value:function(){var e=this;return this.getTables().map((function(t){return e.getTableData(t)}))}},{key:"getActiveTableData",value:function(){return this.getTableData(this.getActiveTable())}},{key:"getActiveTableLocale",value:function(){return this.getActiveTable().querySelector("tr").classList[0].replace("cyr-to-lat-tables-","").replace("-","_")}},{key:"addWrapper",value:function(){this.wrapper=document.createElement("ul"),this.wrapper.classList.add("nav-tab-wrapper"),this.optionsForm.insertBefore(this.wrapper,this.optionsForm.firstChild)}},{key:"addMessageLine",value:function(e){var t=document.createElement("div");return t.id=e,this.optionsForm.insertBefore(t,this.optionsForm.firstChild),t}},{key:"addMessageLines",value:function(){this.successMessage=this.addMessageLine("ctl-success"),this.errorMessage=this.addMessageLine("ctl-error"),this.warningMessage=this.addMessageLine("ctl-warning")}},{key:"moveTabs",value:function(){var e=document.querySelector(".ctl-settings-tabs");e&&this.optionsForm.insertBefore(e,this.optionsForm.firstChild)}},{key:"addEditLabelInput",value:function(){this.editLabelInput=document.createElement("input"),this.editLabelInput.id=this.EDIT_LABEL_ID,this.editLabelInput.style.display="none",document.body.appendChild(this.editLabelInput)}},{key:"hideEditLabelInput",value:function(){this.editLabelInput.style.display="none",this.editLabelInput.classList.remove(this.EDIT_LABEL_ERROR_CLASS),document.body.appendChild(this.editLabelInput)}},{key:"getLastCell",value:function(){return document.querySelector(this.OPTIONS_FORM_SELECTOR+" ."+this.ACTIVE_TABLE_CLASS+" ."+this.PLUS_CLASS).previousElementSibling}},{key:"addCell",value:function(){var e=this.getLastCell();e.parentElement.insertBefore(e.cloneNode(!0),e.nextElementSibling);var t=(e=this.getLastCell()).querySelector("label"),i=e.querySelector("input"),n=i.id.split("-"),a=n[0]+"-"+(parseInt(n[1])+1);t.htmlFor=a,t.innerHTML="",i.id=a,i.value="",i.setAttribute("value",""),this.replaceName(i,""),this.bindEvents(),this.editLabel(t)}},{key:"hideTables",value:function(){var e=this,t=0;this.getTables().map((function(i,n){i.classList.add("ctl-table"),e.CURRENT_STUB_ID===i.previousElementSibling.id&&(t=n,i.classList.add(e.ACTIVE_TABLE_CLASS));var a=document.createElement("div");return a.classList.add(e.PLUS_CLASS),a.innerHTML=e.plusButton,i.querySelector("td fieldset").appendChild(a),null})),this.getHeaders().map((function(i,n){return i.classList.add("nav-tab"),i.dataset.index=n.toString(),e.wrapper.appendChild(i),n===t&&(i.classList.add(e.CURRENT_NAV_TAB_CLASS),i.classList.add(e.ACTIVE_NAV_TAB_CLASS)),null}))}},{key:"bindEvents",value:function(){var e=this;this.getHeaders().map((function(t,i,n){return t.onclick=function(t){t.preventDefault();var i=t.target.dataset.index;if(i===e.getActiveIndex())return!1;e.saveActiveTable(),n.map((function(t){return t.classList.remove(e.ACTIVE_NAV_TAB_CLASS)})),n[i].classList.add(e.ACTIVE_NAV_TAB_CLASS);var a=e.getTables();return a.map((function(t){return t.classList.remove(e.ACTIVE_TABLE_CLASS)})),a[i].classList.add(e.ACTIVE_TABLE_CLASS),e.setSubmitStatus(),e.checkLocale(),!1},null})),this.getInputs().map((function(t){return t.oninput=function(){e.setSubmitStatus()},null})),this.getLabels().map((function(t){return t.onclick=function(t){return t.preventDefault(),e.editLabel(t.target),!1},null})),this.editLabelInput.onblur=function(){e.saveLabel()},this.editLabelInput.onkeyup=function(t){"Escape"===t.key&&e.saveLabel(!0),"Enter"===t.key&&e.saveLabel()},this.getPlusButtons().map((function(t){return t.onclick=function(t){return t.preventDefault(),e.addCell(t.target),!1},null})),this.submitButton.onclick=function(t){return t.preventDefault(),e.saveActiveTable(),!1}}},{key:"editLabel",value:function(e){e.parentNode.insertBefore(this.editLabelInput,e.nextSibling),this.editLabelInput.value=e.innerHTML,this.editLabelInput.classList.remove(this.EDIT_LABEL_ERROR_CLASS),this.editLabelInput.style.display="block",this.editLabelInput.focus()}},{key:"isUniqueLabel",value:function(e){return t(this.getActiveTable().querySelectorAll("label")).reduce((function(t,i){return t&&i.innerHTML!==e}),!0)}},{key:"saveLabel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if("none"!==this.editLabelInput.style.display){var t=this.editLabelInput.value.trim();if(""===t){var i=document.getElementById(this.EDIT_LABEL_ID).parentElement;return this.hideEditLabelInput(),i.parentNode.removeChild(i),void this.setSubmitStatus()}var n=this.editLabelInput.parentNode.querySelector("label");if(e||t===n.innerHTML)this.hideEditLabelInput();else if(this.isUniqueLabel(t)){var a=this.editLabelInput.nextElementSibling;this.hideEditLabelInput(),n.innerHTML=t,this.replaceName(a,t),this.setSubmitStatus()}else this.editLabelInput.classList.add(this.EDIT_LABEL_ERROR_CLASS)}}},{key:"replaceName",value:function(e,t){e.name=e.name.replace(/(.+\[.+])\[.*]/g,"$1["+t+"]")}},{key:"clearMessage",value:function(e){e.innerHTML="",e.classList.remove("active")}},{key:"clearMessages",value:function(){this.clearMessage(this.successMessage),this.clearMessage(this.errorMessage),clearTimeout(this.msgTimer)}},{key:"showMessage",value:function(e,t){var i=this;e.innerHTML=t,e.classList.add("active"),this.msgTimer=setTimeout((function(){i.clearMessages()}),5e3)}}],i&&n(e.prototype,i),a&&n(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,i,a}();const r=s;document.addEventListener("DOMContentLoaded",(function(){new r}))})();
  • cyr2lat/trunk/bin/update-tests

    r3021540 r3211834  
    5151elif [[ $PHP_VERSION == '7.2' ]]; then
    5252  PHP_UNIT='8.5'
    53 elif [[ $PHP_VERSION == '7.3' || $PHP_VERSION == '7.4' || $PHP_VERSION == '8.0' || $PHP_VERSION == '8.1' || $PHP_VERSION == '8.2' || $PHP_VERSION == '8.3' ]]; then
     53elif [[ $PHP_VERSION == '7.3' || $PHP_VERSION == '7.4' || $PHP_VERSION == '8.0' || $PHP_VERSION == '8.1' || $PHP_VERSION == '8.2' || $PHP_VERSION == '8.3' || $PHP_VERSION == '8.4' ]]; then
    5454  PHP_UNIT='9.5'
    5555fi
     
    7272if [[ $PHP_UNIT == '6.5' || $PHP_UNIT == '7.5' ]]; then
    7373  echo "Preparing tests for phpunit-$PHP_UNIT"
    74   find $TEST_DIR -type f -exec sed -i "s/: void / /g" {} \;
     74  find $TEST_DIR -type f -exec sed -i "s/: void//g" {} \;
    7575fi
    7676
  • cyr2lat/trunk/changelog.txt

    r3195936 r3211834  
    274274* Added Belorussian, Macedonian, Kazakh tables.
    275275* Fixed bug with MariaDB during old slug conversion.
    276 * Fixed not saving of user modifications in default iso9 table.
     276* Fixed not saving of user modifications in default ISO9 table.
    277277
    278278= 3.6.5 (11.02.2019) =
  • cyr2lat/trunk/cyr-to-lat.php

    r3195936 r3211834  
    1111 * Plugin URI:        https://kagg.eu/cyr-to-lat/
    1212 * Description:       Convert Non-Latin characters in post and term slugs to Latin characters. Useful for creating human-readable URLs. Based on the original plugin by Anton Skorobogatov.
    13  * Version:           6.2.3
     13 * Version:           6.3.0
    1414 * Requires at least: 5.3
    1515 * Requires PHP:      7.2.0
     
    4242 * Plugin version.
    4343 */
    44 define( 'CYR_TO_LAT_VERSION', '6.2.3' );
     44define( 'CYR_TO_LAT_VERSION', '6.3.0' );
    4545
    4646/**
     
    7777 * Minimum required php version.
    7878 */
    79 define( 'CYR_TO_LAT_MINIMUM_PHP_REQUIRED_VERSION', '7.0' );
     79define( 'CYR_TO_LAT_MINIMUM_PHP_REQUIRED_VERSION', '7.2' );
    8080
    8181/**
  • cyr2lat/trunk/readme.txt

    r3195936 r3211834  
    44Requires at least: 5.3
    55Tested up to: 6.7
    6 Stable tag: 6.2.3
     6Stable tag: 6.3.0
    77Requires PHP: 7.2.0
    88License: GPLv2 or later
     
    222222== Changelog ==
    223223
     224= 6.3.0 (22.12.2024) =
     225* Added warning message on the Tables page when active table does not match the site locale.
     226* Removed fix for translation after WordPress 6.5+ due to performance issues.
     227
    224228= 6.2.3 (24.11.2024) =
    225229* Fixed deprecation error with PHP 8.4.
  • cyr2lat/trunk/src/php/ConversionTables.php

    r3188005 r3211834  
    11191119                ];
    11201120                break;
    1121             case 'iso9':
     1121            case 'ISO9':
    11221122            default:
    11231123                $table = [
  • cyr2lat/trunk/src/php/ErrorHandler.php

    r3189796 r3211834  
    3939            add_action( 'doing_it_wrong_run', [ $this, 'action_doing_it_wrong_run' ], 20, 3 );
    4040            add_filter( 'doing_it_wrong_trigger_error', [ $this, 'filter_doing_it_wrong_trigger_error' ], 10, 4 );
    41         }
    42 
    43         // Fix WP 6.5+ translation error.
    44         if ( version_compare( $GLOBALS['wp_version'], '6.5', '>=' ) ) {
    45             add_filter( 'gettext', [ $this, 'filter_gettext' ], 10, 3 );
    4641        }
    4742    }
     
    110105
    111106    /**
    112      * Filter for gettext.
    113      *
    114      * @param string|mixed $translation Translated text.
    115      * @param string|mixed $text        Text to translate.
    116      * @param string|mixed $domain      Text domain. Unique identifier for retrieving translated strings.
    117      *
    118      * @return string
    119      */
    120     public function filter_gettext( $translation, $text, $domain ): string {
    121 
    122         $translation = (string) $translation;
    123         $text        = (string) $text;
    124         $domain      = (string) $domain;
    125 
    126         if ( '' === $translation && 'cyr2lat' === $domain ) {
    127             $translation = $text;
    128         }
    129 
    130         return $translation;
    131     }
    132 
    133     /**
    134107     * Whether it is the just_in_time_error for plugin-related domain.
    135108     *
  • cyr2lat/trunk/src/php/Settings/Settings.php

    r3188005 r3211834  
    204204        $table  = $this->get( $locale );
    205205        if ( empty( $table ) ) {
    206             $table = $this->get( 'iso9' );
     206            $table = $this->get( 'ISO9' );
    207207        }
    208208
  • cyr2lat/trunk/src/php/Settings/SystemInfo.php

    r3188005 r3211834  
    151151        $locales        = $tables->get_locales();
    152152        $current_locale = $tables->get_current_locale();
    153         $current_locale = 'iso9' === $current_locale ? 'ISO9' : $current_locale;
    154153
    155154        $data .= $this->data( 'Version', CYR_TO_LAT_VERSION );
     
    167166            }
    168167
    169             $table_name = 'iso9' === $key ? 'ISO9' : $key;
     168            $table_name = $key;
    170169
    171170            $data .= $this->header( "--- $table_name table customization ---" );
  • cyr2lat/trunk/src/php/Settings/Tables.php

    r3188005 r3211834  
    8585
    8686        $this->locales = [
    87             'iso9'  => __( 'Default', 'cyr2lat' ) . '<br>ISO9',
     87            'ISO9'  => __( 'Default', 'cyr2lat' ) . '<br>ISO9',
    8888            'bel'   => __( 'Belarusian', 'cyr2lat' ) . '<br>bel',
    8989            'uk'    => __( 'Ukrainian', 'cyr2lat' ) . '<br>uk',
     
    106106     */
    107107    public function get_current_locale(): string {
    108         $current_locale = (string) apply_filters( 'ctl_locale', get_locale() );
    109 
    110         return array_key_exists( $current_locale, $this->locales ) ? $current_locale : 'iso9';
     108        $ctl_locale = $this->get_ctl_locale();
     109
     110        return array_key_exists( $ctl_locale, $this->locales ) ? $ctl_locale : 'ISO9';
    111111    }
    112112
     
    163163            self::OBJECT,
    164164            [
    165                 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
    166                 'action'  => self::SAVE_TABLE_ACTION,
    167                 'nonce'   => wp_create_nonce( self::SAVE_TABLE_ACTION ),
     165                'ajaxUrl'       => admin_url( 'admin-ajax.php' ),
     166                'action'        => self::SAVE_TABLE_ACTION,
     167                'nonce'         => wp_create_nonce( self::SAVE_TABLE_ACTION ),
     168                'ctlLocale'     => $this->get_ctl_locale(),
     169                'localeWarning' => sprintf(
     170                /* translators: 1: Site locale. Do not touch text in {} */
     171                    __( 'Active table "{active_table}" does not match the current site locale: "%1$s". The "%2$s" table will be used for transliteration.', 'cyr2lat' ),
     172                    $this->get_ctl_locale(),
     173                    $this->get_current_locale()
     174                ),
    168175            ]
    169176        );
     
    212219        wp_send_json_success( esc_html__( 'Options saved.', 'cyr2lat' ) );
    213220    }
     221
     222    /**
     223     * Get Cyr To Lat locale.
     224     *
     225     * @return string
     226     */
     227    protected function get_ctl_locale(): string {
     228        return (string) apply_filters( 'ctl_locale', get_locale() );
     229    }
    214230}
  • cyr2lat/trunk/vendor/autoload.php

    r3188005 r3211834  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInitc5b7344a4117fb2177a762f1895475b0::getLoader();
     25return ComposerAutoloaderInitd288e5bc05ffec7fab5c5946a88b734e::getLoader();
  • cyr2lat/trunk/vendor/composer/InstalledVersions.php

    r2890969 r3211834  
    323323
    324324        $installed = array();
     325        $copiedLocalDir = false;
    325326
    326327        if (self::$canGetVendors) {
     
    331332                    /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
    332333                    $required = require $vendorDir.'/composer/installed.php';
    333                     $installed[] = self::$installedByVendor[$vendorDir] = $required;
    334                     if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
    335                         self::$installed = $installed[count($installed) - 1];
     334                    self::$installedByVendor[$vendorDir] = $required;
     335                    $installed[] = $required;
     336                    if (strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
     337                        self::$installed = $required;
     338                        $copiedLocalDir = true;
    336339                    }
    337340                }
     
    351354        }
    352355
    353         if (self::$installed !== array()) {
     356        if (self::$installed !== array() && !$copiedLocalDir) {
    354357            $installed[] = self::$installed;
    355358        }
  • cyr2lat/trunk/vendor/composer/autoload_real.php

    r3188005 r3211834  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitc5b7344a4117fb2177a762f1895475b0
     5class ComposerAutoloaderInitd288e5bc05ffec7fab5c5946a88b734e
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInitc5b7344a4117fb2177a762f1895475b0', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInitd288e5bc05ffec7fab5c5946a88b734e', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInitc5b7344a4117fb2177a762f1895475b0', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInitd288e5bc05ffec7fab5c5946a88b734e', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInitc5b7344a4117fb2177a762f1895475b0::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInitd288e5bc05ffec7fab5c5946a88b734e::getInitializer($loader));
    3131
    3232        $loader->setClassMapAuthoritative(true);
    3333        $loader->register(true);
    3434
    35         $filesToLoad = \Composer\Autoload\ComposerStaticInitc5b7344a4117fb2177a762f1895475b0::$files;
     35        $filesToLoad = \Composer\Autoload\ComposerStaticInitd288e5bc05ffec7fab5c5946a88b734e::$files;
    3636        $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
    3737            if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • cyr2lat/trunk/vendor/composer/autoload_static.php

    r3189796 r3211834  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitc5b7344a4117fb2177a762f1895475b0
     7class ComposerStaticInitd288e5bc05ffec7fab5c5946a88b734e
    88{
    99    public static $files = array (
     
    5454    {
    5555        return \Closure::bind(function () use ($loader) {
    56             $loader->prefixLengthsPsr4 = ComposerStaticInitc5b7344a4117fb2177a762f1895475b0::$prefixLengthsPsr4;
    57             $loader->prefixDirsPsr4 = ComposerStaticInitc5b7344a4117fb2177a762f1895475b0::$prefixDirsPsr4;
    58             $loader->classMap = ComposerStaticInitc5b7344a4117fb2177a762f1895475b0::$classMap;
     56            $loader->prefixLengthsPsr4 = ComposerStaticInitd288e5bc05ffec7fab5c5946a88b734e::$prefixLengthsPsr4;
     57            $loader->prefixDirsPsr4 = ComposerStaticInitd288e5bc05ffec7fab5c5946a88b734e::$prefixDirsPsr4;
     58            $loader->classMap = ComposerStaticInitd288e5bc05ffec7fab5c5946a88b734e::$classMap;
    5959
    6060        }, null, ClassLoader::class);
  • cyr2lat/trunk/vendor/composer/installed.php

    r3195936 r3211834  
    22    'root' => array(
    33        'name' => 'mihdan/cyr2lat',
    4         'pretty_version' => '6.2.3',
    5         'version' => '6.2.3.0',
    6         'reference' => '96e24a2f49e80d51a6c791a0463458bdef431200',
     4        'pretty_version' => '6.3.0',
     5        'version' => '6.3.0.0',
     6        'reference' => 'c7b6b33351a5234f9616fadd1ef03857b8216d1b',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        'mihdan/cyr2lat' => array(
    14             'pretty_version' => '6.2.3',
    15             'version' => '6.2.3.0',
    16             'reference' => '96e24a2f49e80d51a6c791a0463458bdef431200',
     14            'pretty_version' => '6.3.0',
     15            'version' => '6.3.0.0',
     16            'reference' => 'c7b6b33351a5234f9616fadd1ef03857b8216d1b',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.