1/*modal*/ 2$.fn.codemodal=function(){ 3 var offerDetailsEndPoint=$("[name='offerDetails']").val(); 4 $(this).each(function(){ 5 var $offer=$(this); 6 var $modalMask=$offer.closest(".merchant-details").next(); 7 var $modal=$modalMask.find(".code-modal"); 8 $offer.click(function(){ 9 var offerData={ 10 code:$offer.find("input").val() 11 }; 12 $modalMask.addClass("active"); 13 $modal.addClass("loading"); 14 $modal.removeClass("copied"); 15 setTimeout(function(){ 16 $modalMask.addClass("visible"); 17 },10); 18 $.post(offerDetailsEndPoint,offerData,function(res){ 19 setTimeout(function(){ 20 $modal.find(".details .code").val(res.value); 21 $modal.find(".additional .description").html(res.description); 22 $modal.removeClass("loading"); 23 },1000); 24 }); 25 }); 26 var cb=new ClipboardJS($modal.find(".copy")[0],{ 27 target: function(trigger) { 28 return $modal.find(".details .code")[0]; 29 } 30 }); 31 cb.on('success', function(e) { 32 $modal.addClass("copied"); 33 e.clearSelection(); 34 }); 35 $modal.find(".close").click(function(){ 36 $modalMask.removeClass("visible"); 37 setTimeout(function(){ 38 $modalMask.removeClass("active"); 39 },500); 40 }); 41 }); 42}; 43/*autocomplete plugins*/ 44$.fn.autocomplete = function(options) { 45 var merchants=[]; 46 var $container=options.container; 47 $(this).each(function(){ 48 var template=$("#merchantDealUrl").val(); 49 var $input=$(this); 50 var $form=$input.closest("form"); 51 var refresh=function(){ 52 var name=$input.val(); 53 if(name.length<=2){ 54 $container.removeClass("visible"); 55 return; 56 } 57 var pmts=_.filter(merchants,function(m){ 58 if(m.name.toLowerCase().indexOf(name.toLowerCase())>-1){ 59 return true; 60 } 61 return false; 62 }); 63 $container.html(""); 64 if(pmts.length>0){ 65 $container.addClass("visible"); 66 }else{ 67 $container.removeClass("visible"); 68 } 69 for (var i = 0; i < pmts.length; i++) { 70 $container.append("<li>"+pmts[i].name+"</li>"); 71 } 72 } 73 $input.keyup(function(){ 74 refresh(); 75 }); 76 $container.on("click","li",function(e){ 77 var $chosed=$(e.target); 78 $input.val($chosed.text()); 79 //refresh(); 80 // 81 $container.removeClass("visible"); 82 location.href=template.replace("%m",$chosed.text()); 83 }) 84 }); 85 $.post(vP.eP,function(mts){ 86 merchants=mts; 87 }); 88}; 89var vP={ 90 eP:false, 91 allAction:function(){ 92 $(".get-all-merchants-action").click(function(e){ 93 var $action=$(e.target); 94 $action.addClass("loading"); 95 $.get(vP.eP,function(html){ 96 $(".merchants-list.all").html(html); 97 $action.addClass("hide"); 98 }); 99 }); 100 }, 101 topAction:function(){ 102 var $action=$(".search-results .top-merchants"); 103 $action.find(".more").click(function(){ 104 $action.find(".more").addClass("loading"); 105 setTimeout(function(){ 106 $action.find(".more").hide(); 107 $action.find(".merchants-list").css("display","block"); 108 },1000); 109 }); 110 }, 111 autocompleteMerchants:function(){ 112 $("#search_bar_merchant").autocomplete({ 113 "container":$("#autocomplete_container") 114 }); 115 $("#search_bar_product").autocomplete({ 116 "container":$("#autocomplete_container") 117 }); 118 $("#search").autocomplete({ 119 "container":$("#autocomplete_container") 120 }); 121 }, 122 modals:function(){ 123 $(".offers-list .offer.nc").codemodal(); 124 }, 125 vars:function(){ 126 $("[vars-link]").each(function(){ 127 var $link=$(this); 128 $link.click(function(){ 129 var varsIndex=$link.attr("vars-link"); 130 $("[vars="+varsIndex+"]").css({ 131 display:"table" 132 }); 133 }) 134 }); 135 $("[vars]").click(function(e){ 136 $("[vars]").css({ 137 display:"none" 138 }); 139 }); 140 }, 141 bootstrap:function(){ 142 vP.eP=$("#merchants_ajax").val(); 143 vP.allAction(); 144 vP.topAction(); 145 vP.autocompleteMerchants(); 146 vP.modals(); 147 vP.vars(); 148 } 149}; 150vP.bootstrap();
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.