/gi, '\n'); } function html2text(html){ return $('
').html(html).text(); } var $tip = $('').appendTo(document.body); var showTimer = null; function showTip(html, e){ var text = html2text( br2nl(html||'') ).trim(); if (!text) { $tip.hide(); return; } $tip.text(text).show(); moveTip(e); } function moveTip(e){ var x = e.clientX + 14, y = e.clientY + 36; var w = $tip.outerWidth(), h = $tip.outerHeight(); var vw = window.innerWidth, vh = window.innerHeight; if (x + w + 10 > vw) x = vw - w - 10; if (y + h + 10 > vh) y = vh - h - 10; $tip.css({left:x+'px', top:y+'px'}); } function hideTip(){ clearTimeout(showTimer); showTimer = null; $tip.hide(); } var EXCLUDE = '.column-existing_stock, .column-desired_qty, .column-status'; function wireRow($row){ var $log = $row.find('td.column-logger'); if (!$log.length) return; var html = $log.html(); var $targets = $row.children('td:visible').not(EXCLUDE); var idx = $row.index(); $('table.DTFC_Cloned').each(function(){ var $cloneRow = $(this).find('tbody > tr').eq(idx); $targets = $targets.add( $cloneRow.children('td:visible').not(EXCLUDE) ); }); $targets.off('.aieotip') .on('mouseenter.aieotip', function(e){ clearTimeout(showTimer); var ev = e; showTimer = setTimeout(function(){ showTip(html, ev); }, 150); }) .on('mousemove.aieotip', moveTip) .on('mouseleave.aieotip', hideTip) .on('focusin.aieotip', hideTip); } function applyTooltips($scope){ var $tables = ($scope && $scope.length ? $scope : $(document)).find('.wpDataTable'); $tables.each(function(){ $(this).find('tbody > tr').each(function(){ wireRow($(this)); }); }); } function applyWithDelay($scope){ applyTooltips($scope); setTimeout(function(){ applyTooltips($scope); }, 150); } applyWithDelay($(document)); $(document).on('wpdt.initComplete wpdt.tableLoaded wpdt.drawTable draw.dt', function(e){ var $root = $(e.target).closest('.wpDataTable'); applyWithDelay($root.length ? $root : $(document)); }); if (window.MutationObserver){ var mo = new MutationObserver(function(muts){ for (var i=0;iexists() && !empty($user->user_login)) ? $user->user_login : 'anonymous'; global $wpdb; $wpdb->query($wpdb->prepare("SET @ORIGIN_USER = %s", $origin_user)); $wpdb->query("SET @ORIGIN_TYPE = 'table_entry'"); } }