1/** 2* This will take care of all like functionality 3* 4* @author Slavic 5*/ 6var iLike = { 7 _likeFeedback: "You liked it!", 8 _latency:250 , // ms to wait before a request for details is submitted 9 _pendingReqs: {}, 10 _server: '/like/get_list', 11 /** 12 * Will bind a like handler to the $trigger element. 13 * The response from the server should come in JSON format with 14 * a mandatory "status" key and optional "msg", "html". 15 * It will also enable detailed view, by hovering on the feedback element 16 * 17 * Parameters: 18 * trigger: element that will trigger a like submit 19 * feedback: element that will show feedback and serve as detailed view trigger 20 * data: hash with "type" and "id" of the likeable content 21 */ 22 addHandler: function(trigger,feedback,data){ 23 if(trigger && trigger.length>0) 24 $(trigger).ajaxForm({ 25 success: function(resp){ 26 if(resp.status!==0){ 27 iLike._notify(resp.msg,'error',true) 28 return ; 29 } 30 if(feedback && resp.html) feedback.html(resp.html) 31 var text = (resp.msg) ? resp.msg : iLike._likeFeedback 32 iLike._notify(text,'ok') 33 } 34 }) 35 if(feedback){ 36 feedback.hover( 37 function(){ 38 /* set is as a pending request so that it is executed after latency ms, 39 * if it wasn't cancelled by then */ 40 iLike._pendingReqs[data.type + data.id] = 1 41 window.setTimeout(function(){
42 iLike._showDetails(feedback,data.type,data.id) 43 },iLike._latency) 44 }, 45 function(){ 46 delete(iLike._pendingReqs[data.type + data.id]) 47 $(iLike.currentWindow).remove() 48 } 49 ) 50 } 51 }, 52 _showDetails: function(e,type,id){ 53 54 if(iLike._pendingReqs[type + id]){ 55 delete(iLike._pendingReqs[type + id]) 56 $.ajax({ 57 url: iLike._server + "/" + type + "/" + id, 58 success: function(resp){ 59 if(resp.status==0){ 60 if(resp.list) new Tooltip(e,resp.list,{maxwidth:280}) 61 $(e).html(resp.summary) 62 } else{ 63 new Tooltip(e,resp.msg) 64 } 65 } 66 }) 67 } 68 }, 69 _notify: function(msg,type,insist){ 70 if(typeof myJgrowl === 'undefined' && insist){ 71 alert(text) 72 } else { 73 if(typeof myJgrowl !== 'undefined') myJgrowl(msg,type) 74 } 75 } 76}
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.