"use strict"; function TInvWL($, h) { this.pf = 'tinvwl'; this.g = '_'; this.ho = h || false; this.n = 'TInvWL'; this.aj_act = function (a) { return [this.pf, a].join(this.g); }; this._csel = function (a, b) { var b = b || '.'; return '{0}{1}{2}'.format(b, this.pf, a); }; this._tm = function (a) { var c = $('script#{0}[type=\'text/template\']'.format(a)); if (c.length) { return c.html(); } return ''; }; this.formElm = function () { $(this._csel('-form-onoff')).tiwl_onoff(); $('input[type=checkbox][tiwl-show], input[type=checkbox][tiwl-hide]').tiwl_onoffblock(); $('[tiwl-value][tiwl-show], [tiwl-value][tiwl-hide]').tiwl_byvalueblock(); if ('undefined' !== typeof $.fn.wpColorPicker) { var calcLuminance = function calcLuminance(rgb) { var c = rgb.substring(1); var _rgb = parseInt(c, 16); var r = _rgb >> 16 & 0xff; var g = _rgb >> 8 & 0xff; var b = _rgb >> 0 & 0xff; return 0.2126 * r + 0.7152 * g + 0.0722 * b; }; var formColor = this._csel('-form-color'); $(formColor).each(function () { var picker = $(this); var pickerWrap = $(this).closest('.tinvwl-color-picker'); var eyedropper = pickerWrap.find('.tinvwl-eyedropper'); picker.css('background-color', picker.val()); if (175 < calcLuminance(picker.val())) { picker.css('color', '#000000'); } picker.iris({ mode: 'hsv', target: $(this).parent().parent(), change: function change(event, ui) { if (175 < calcLuminance(ui.color.toCSS())) { $(this).css('color', '#000000'); } else { $(this).css('color', ''); } $(this).css('background-color', ui.color.toCSS()); } }); pickerWrap.on('click', '.iris-square-value', function (e) { e.preventDefault(); picker.iris('toggle'); }); eyedropper.on('click', function (e) { e.preventDefault(); picker.iris('show'); }); picker.on('focusin', function () { picker.iris('show'); }); }); $(document).on('click', function (e) { if (!$(e.target).is(formColor + ', .iris-picker, .iris-picker-inner, .iris-slider-offset, .tinvwl-eyedropper, .tinvwl-eyedropper .ftinvwl-eyedropper')) { $(formColor).iris('hide'); } else { $(formColor).not($(e.target).closest('.tinvwl-color-picker').find(formColor)).iris('hide'); } }); } }; this.wizard_page = function (a) { $(a).find('select').change(this._wizard_page_ch); this.wizard_page_ch($(a).find('select')); }; this.wizard_page_ch = function (a) { var a = $(a), b = a.parent(this._csel('-page-select')), c = b.find('input[type=hidden]').val(), d = b.find(this._csel('-error-icon')), e = b.find(this._csel('-error-desc')); if ('' === a.val()) { if (0 == c) { b.addClass('tinvwl-error'); d.show(); e.show(); } return; } b.removeClass('tinvwl-error'); d.hide(); e.hide(); }; this.pageElm = function () { $(this._csel('-header', 'div.')).prependTo('#wpbody-content'); $(this._csel('-page-select')).each(this._wizard_page); $('.bulkactions [type=submit]').each(this._control_bulkactions); $('.action-search [type=submit]').each(this._control_search); }; this.control_bulkactions = function (a) { $(a).on('click', this._control_bulkactions_ck); }; this.control_bulkactions_ck = function (a, b) { var a = $(a), c = a.parents('.bulkactions').eq(0).find('[name=action]'), d = a.parents('form').eq(0); if (c) { if ('-1' === c.val()) { b.preventDefault(); } else { if (!d.find('input[type=checkbox]:checked').length) { b.preventDefault(); } } } }; this.control_search = function (a) { $(a).on('click', this._control_search_ck); }; this.control_search_ck = function (a, b) { var a = $(a), c = a.parents('.action-search').eq(0).find('[name=s]'); if (c) { if ('' === c.val()) { b.preventDefault(); } } }; this.Run = function () { this.formElm(); this.pageElm(); }; this.cg = function () { var n = this.n; if (this.ho) { var t = new Date(); n = n + t.getFullYear() + t.getMonth() + t.getDate(); } window[n] = this; }; this.cg(); if (!String.prototype.format) { String.prototype.format = function () { var args = arguments; return this.replace(/{(\d+)}/g, function (match, number) { return 'undefined' !== typeof args[number] ? args[number] : match; }); }; } (function (o) { var n = o.n, ho = o.ho, c = ''; if (ho) { c = 't=new Date(),n=n+t.getFullYear()+t.getMonth()+t.getDate(),'; } for (var i in o) { if ('function' === typeof o[i] && '_' !== i[0] && !o.hasOwnProperty('_' + i)) { eval('o._' + i + '=function(a,b,c,d){var n=\'' + n + '\',' + c + 'o=window[n]||null;if (o) {return o.' + i + '(this,a,b,c,d);};};'); } } })(this); } (function ($) { $.fn.tiwl_onoff = function (so) { var sd = { value: { on: '', off: '' }, class: 'tiwlform-onoff', wrap: 'container', button: 'button' }, s = $.extend(true, {}, sd, so); return $(this).each(function () { var a = $(this), b1 = $('