1jQuery(document).ready(function($) { 2 var contents = {}, 3 current = null, 4 loading = true, 5 timeout = null; 6 7 function getContent(element, container) { 8 var $container = $(container), 9 $element = $(element), 10 $data = $element.data(), 11 data = {}, 12 identifier = $element.data('identifier'), 13 locale = $element.data('locale'); 14 15 if(contents[locale] && contents[locale][identifier]) { 16 return contents[locale][identifier]; 17 } else { 18 for(var p in $data) { 19 if('object' !== typeof $data[p] && 'function' !== typeof $data[p]) { 20 data[p] = $data[p]; 21 } 22 } 23 24 $.post( 25 EasyAzon_Addition_Components_Popovers.ajaxUrl, 26 { 27 action: EasyAzon_Addition_Components_Popovers.ajaxAction, 28 atts: data, 29 }, 30 function(data, status) { 31 saveContent(identifier, locale, data.markup); 32 33 $container.html(data.markup); 34 }, 35 'json' 36 ); 37 38 return saveContent(identifier, locale, EasyAzon_Addition_Components_Popovers.loading); 39 } 40 } 41 42 function saveContent(identifier, locale, content) { 43 if(!contents[locale]) { 44 contents[locale] = {}; 45 } 46 47 contents[locale][identifier] = content; 48 49 return contents[locale][identifier]; 50 } 51 52 function popoverTimeoutClear() { 53 if(null !== timeout) { 54 clearTimeout(timeout); 55 timeout = null; 56 } 57 } 58 59 function popoverTimeoutSet() { 60 timeout = setTimeout(function() { 61 if(null !== current) { 62 $(current).removeClass('easyazon-popover-link-wrapper-hovered'); 63 64 current = null; 65 timeout = null; 66 } 67 }, parseInt(EasyAzon_Addition_Components_Popovers.timeout)); 68 } 69 70 $('[data-identifier][data-locale][data-popups="y"]').each(function(index, element) { 71 var $element = $(element).addClass('easyazon-popover-link'), 72 $block = $element.parents('.easyazon-block'), 73 $container = $('<span class="easyazon-popover"></span>'); 74 75 if(!$block.size()) { 76 $element.wrap('<span class="easyazon-popover-link-wrapper"></span>').parent().prepend($container); 77 78 $element.parent().on('mouseenter', function(event) { 79 var $wrapper = $(this), 80 element = $wrapper.get(0); 81 82 popoverTimeoutClear(); 83 84 if(current !== element) { 85 if(null !== current) { 86 $(current).removeClass('easyazon-popover-link-wrapper-hovered'); 87 } 88 89 $container.html(getContent($element, $container)); 90 91 $wrapper.addClass('easyazon-popover-link-wrapper-hovered'); 92 93 current = element; 94 } 95 }).on('mouseleave', function(event) { 96 popoverTimeoutSet(); 97 }); 98 } 99 }); 100 101 $(document).on('mouseenter', '.easyazon-popover', function() { 102 popoverTimeoutClear(); 103 }).on('mouseleave', '.easyazon-popover', function() { 104 popoverTimeoutSet(); 105 }); 106});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.