File Editor
Directories:
.. (Back)
Files:
admin-utils.js
admin-utils.min.js
contrast-checker.js
contrast-checker.min.js
list-table-ext.js
list-table-ext.min.js
xor.js
xor.min.js
Create New File
Create
Edit File: contrast-checker.min.js
!function(t,e){var r="WPFormsColorContrastChecker";"function"==typeof define&&define.amd?define([],e(r)):"object"==typeof exports?module.exports=e(r):t[r]=e(r)}(this,function(e){"use strict";class o extends Error{constructor(t){super(t),this.name=e}}function s(t){console.error(t)}return class r{static defaults={textColor:"",bgColor:"",contrastThreshold:4.5,message:{contrastPass:"The contrast ratio between the text and background color is sufficient.",contrastFail:"The contrast ratio between the text and background color is insufficient. Please choose a darker text color or a lighter background color."}};constructor(t){this.args=Object.assign({},r.defaults,t)}hexToRgb(t){var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return/^#?([a-f\d])([a-f\d])([a-f\d])$/i.test(t)?e?[17*parseInt(e[1],16),17*parseInt(e[2],16),17*parseInt(e[3],16)]:null:e?[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]:null}calculateRelativeLuminance(e){for(let t=0;t<e.length;t++)e[t]/=255,e[t]=e[t]<=.03928?e[t]/12.92:Math.pow((e[t]+.055)/1.055,2.4);return.2126*e[0]+.7152*e[1]+.0722*e[2]}getContrastRatio(){try{var t,e,r=this.hexToRgb(this.args.textColor),a=this.hexToRgb(this.args.bgColor);if(r&&a)return[t,e]=[this.calculateRelativeLuminance(r),this.calculateRelativeLuminance(a)],(Math.max(t,e)+.05)/(Math.min(t,e)+.05);throw new o("Invalid color format. Provide valid hex color codes.")}catch(t){return s(t.message),null}}checkContrast(){try{var t=this.getContrastRatio();if(null===t)throw new o("Invalid contrast ratio. Provide valid contrast ratio between two colors.");return t<this.args.contrastThreshold?this.args.message.contrastFail:this.args.message.contrastPass}catch(t){return s(t.message),null}}}});
Save Changes
Rename File
Rename