intercooler
Version:
Making AJAX as easy as anchor tags
2 lines • 20.9 kB
JavaScript
/*! intercooler 0.4.7 2015-01-05 */
;var Intercooler=Intercooler||function(){function _defineTransition(a,b){null==b.newContent&&(b.newContent=function(a,b,c,d,e){d?e($(b).replaceAll(a)):(a.html(b),e())}),null==b.remove&&(b.remove=function(a){a.remove()}),null==b.show&&(b.show=function(a){a.show()}),null==b.hide&&(b.hide=function(a){a.hide()}),_transitions[a]=b}function fingerprint(a){if(null==a||void 0==a)return 0;var b,c,d,e=a.toString(),f=0;if(0==e.length)return f;for(b=0,d=e.length;d>b;b++)c=e.charCodeAt(b),f=(f<<5)-f+c,f|=0;return f}function log(a,b,c){null==a&&(a=$("body")),a.trigger("log.ic",[b,c,a])}function uuid(){return _UUID++}function icSelectorFor(a){return"[ic-id='"+getIntercoolerId(a)+"']"}function findById(a){return $("#"+a)}function parseInterval(a){return log(null,"POLL: Parsing interval string "+a,"DEBUG"),"null"==a||"false"==a||""==a?null:a.lastIndexOf("ms")==a.length-2?parseInt(a.substr(0,a.length-2)):a.lastIndexOf("s")==a.length-1?1e3*parseInt(a.substr(0,a.length-1)):1e3}function initScrollHandler(){null==_scrollHandler&&(_scrollHandler=function(){$("[ic-trigger-on='scrolled-into-view']").each(function(){isScrolledIntoView($(this))&&1!=$(this).data("ic-scrolled-into-view-loaded")&&($(this).data("ic-scrolled-into-view-loaded",!0),fireICRequest($(this)))})},$(window).scroll(_scrollHandler))}function getTarget(a){var b=closestAttrValue(a,"ic-target");return b&&0!=b.indexOf("this.")?0==b.indexOf("closest ")?a.closest(b.substr(8)):$(b):a}function processHeaders(elt,xhr,pop){elt.trigger("beforeHeaders.ic",elt,xhr),log(elt,"response headers: "+xhr.getAllResponseHeaders(),"DEBUG");var target=null;if(xhr.getResponseHeader("X-IC-Refresh")){var pathsToRefresh=xhr.getResponseHeader("X-IC-Refresh").split(",");log(elt,"X-IC-Refresh: refreshing "+pathsToRefresh,"DEBUG"),$.each(pathsToRefresh,function(a,b){refreshDependencies(b.replace(/ /g,""),elt)})}if(xhr.getResponseHeader("X-IC-Script")&&(log(elt,"X-IC-Script: evaling "+xhr.getResponseHeader("X-IC-Script"),"DEBUG"),eval(xhr.getResponseHeader("X-IC-Script"))),xhr.getResponseHeader("X-IC-Redirect")&&(log(elt,"X-IC-Redirect: redirecting to "+xhr.getResponseHeader("X-IC-Redirect"),"DEBUG"),window.location=xhr.getResponseHeader("X-IC-Redirect")),"true"==xhr.getResponseHeader("X-IC-CancelPolling")&&cancelPolling(elt),xhr.getResponseHeader("X-IC-Open")&&(log(elt,"X-IC-Open: opening "+xhr.getResponseHeader("X-IC-Open"),"DEBUG"),window.open(xhr.getResponseHeader("X-IC-Open"))),xhr.getResponseHeader("X-IC-SetLocation")&&1!=pop&&(log(elt,"X-IC-SetLocation: pushing "+xhr.getResponseHeader("X-IC-SetLocation"),"DEBUG"),_historySupport.pushUrl(xhr.getResponseHeader("X-IC-SetLocation"),elt)),xhr.getResponseHeader("X-IC-Transition")&&(log(elt,"X-IC-Transition: setting transition to "+xhr.getResponseHeader("X-IC-Transition"),"DEBUG"),target=getTarget(elt),target.data("ic-tmp-transition",xhr.getResponseHeader("X-IC-Transition"))),xhr.getResponseHeader("X-IC-Trigger")){log(elt,"X-IC-Trigger: found trigger "+xhr.getResponseHeader("X-IC-Trigger"),"DEBUG"),target=getTarget(elt);var triggerArgs=[];xhr.getResponseHeader("X-IC-Trigger-Data")&&(triggerArgs=$.parseJSON(xhr.getResponseHeader("X-IC-Trigger-Data"))),target.trigger(xhr.getResponseHeader("X-IC-Trigger"),triggerArgs)}if(xhr.getResponseHeader("X-IC-Remove")&&elt){target=getTarget(elt),log(elt,"X-IC-REMOVE header found.","DEBUG");var transition=getTransition(elt,target);transition.remove(target)}return elt.trigger("afterHeaders.ic",elt,xhr),!0}function beforeRequest(a){a.addClass("disabled"),a.data("ic-request-in-flight",!0)}function afterRequest(a){a.removeClass("disabled"),a.data("ic-request-in-flight",!1),a.data("ic-next-request")&&(a.data("ic-next-request")(),a.data("ic-next-request",null))}function replaceOrAddMethod(a,b){var c=/(&|^)_method=[^&]*/,d="&_method="+b;return c.test(a)?a.replace(c,d):a+"&"+d}function globalEval(a){return window.eval.call(window,a)}function closestAttrValue(a,b){var c=$(a).closest("["+b+"]");return c?c.attr(b):null}function handleRemoteRequest(a,b,c,d,e){beforeRequest(a),d=replaceOrAddMethod(d,b);var f=d.indexOf("&ic-handle-pop=true")>=0,g=findIndicator(a),h=getTransition(g,g);g.length>0&&h.show(g);var i=uuid(),j=new Date;_remote.ajax({type:b,url:c,data:d,dataType:"text",headers:{Accept:"text/html-partial, */*; q=0.9","X-IC-Request":!0,"X-HTTP-Method-Override":b},beforeSend:function(e,f){a.trigger("beforeSend.ic",a,d,f,e),log(a,"before AJAX request "+i+": "+b+" to "+c,"DEBUG");var g=closestAttrValue(a,"ic-on-beforeSend");g&&globalEval("(function (data, settings, xhr) {"+g+"})")(d,f,e)},success:function(b,c,d){a.trigger("success.ic",a,b,c,d),log(a,"AJAX request "+i+" was successful.","DEBUG");var g=closestAttrValue(a,"ic-on-success");if(!g||0!=globalEval("(function (data, textStatus, xhr) {"+g+"})")(b,c,d)){var h=getTarget(a);h.data("ic-tmp-transition",closestAttrValue(a,"ic-transition"));var j=new Date;if(processHeaders(a,d,f)){log(a,"Processed headers for request "+i+" in "+(new Date-j)+"ms","DEBUG");{new Date}e(b,c,a,d),log(a,"Process content for request "+i+" in "+(new Date-j)+"ms","DEBUG")}h.data("ic-tmp-transition",null)}},error:function(b,c,d){a.trigger("error.ic",a,c,d,b);var e=closestAttrValue(a,"ic-on-error");e&&globalEval("(function (status, str, xhr) {"+e+"})")(c,d,b),log(a,"AJAX request "+i+" experienced an error: "+d,"ERROR")},complete:function(b,c){log(a,"AJAX request "+i+" completed in "+(new Date-j)+"ms","DEBUG"),afterRequest(a),a.trigger("complete.ic",a,d,c,b);var e=closestAttrValue(a,"ic-on-complete");e&&globalEval("(function (xhr, status) {"+e+"})")(b,c),g.length>0&&h.hide(g)}})}function findIndicator(a){var b=null;if($(a).attr("ic-indicator"))b=$($(a).attr("ic-indicator")).first();else if(b=$(a).find(".ic-indicator").first(),0==b.length){var c=closestAttrValue(a,"ic-indicator");c&&(b=$(c).first())}return b}function processIncludes(a){var b="";return $(a).each(function(){b+="&"+$(this).serialize()}),b}function getParametersForElement(a,b){var c=getTarget(a),d="ic-request=true";d+=a.closest("form").length>0?"&"+a.closest("form").serialize():"&"+a.serialize(),a.attr("id")&&(d+="&ic-element-id="+a.attr("id")),a.attr("name")&&(d+="&ic-element-name="+a.attr("name")),c.attr("ic-id")&&(d+="&ic-id="+c.attr("ic-id")),b&&b.attr("id")&&(d+="&ic-trigger-id="+b.attr("id")),b&&b.attr("name")&&(d+="&ic-trigger-name="+b.attr("name")),c.attr("ic-last-refresh")&&(d+="&ic-last-refresh="+c.attr("ic-last-refresh")),c.attr("ic-fingerprint")&&(d+="&ic-fingerprint="+c.attr("ic-fingerprint"));var e=closestAttrValue(a,"ic-include");return e&&(d+=processIncludes(e)),log(a,"request parameters "+d,"DEBUG"),d}function maybeSetIntercoolerInfo(a){var b=getTarget(a);getIntercoolerId(b),maybeSetIntercoolerMetadata(b),1!=a.data("elementAdded.ic")&&(a.data("elementAdded.ic",!0),a.trigger("elementAdded.ic"))}function updateIntercoolerMetaData(a){a.attr("ic-fingerprint",fingerprint(a.html())),a.attr("ic-last-refresh",(new Date).getTime())}function maybeSetIntercoolerMetadata(a){a.attr("ic-fingerprint")||updateIntercoolerMetaData(a)}function getIntercoolerId(a){return a.attr("ic-id")||a.attr("ic-id",uuid()),a.attr("ic-id")}function processNodes(a){processMacros(a),processSources(a),processPolling(a),processTriggerOn(a),$(a).trigger("nodesProcessed.ic")}function processSources(a){$(a).is("[ic-src]")&&maybeSetIntercoolerInfo($(a)),$(a).find("[ic-src]").each(function(){maybeSetIntercoolerInfo($(this))})}function startPolling(a){if(null==a.data("ic-poll-interval-id")){var b=parseInterval(a.attr("ic-poll"));if(null!=b){var c=icSelectorFor(a),d=parseInt(a.attr("ic-poll-repeats"))||-1,e=0;log(a,"POLL: Starting poll for element "+c,"DEBUG");var f=setInterval(function(){var b=$(c);a.trigger("onPoll.ic",b),0==b.length||e==d?(log(a,"POLL: Clearing poll for element "+c,"DEBUG"),clearTimeout(f)):fireICRequest(b),e++},b);a.data("ic-poll-interval-id",f)}}}function cancelPolling(a){null!=a.data("ic-poll-interval-id")&&clearTimeout(a.data("ic-poll-interval-id"))}function processPolling(a){$(a).is("[ic-poll]")&&(maybeSetIntercoolerInfo($(a)),startPolling(a)),$(a).find("[ic-poll]").each(function(){maybeSetIntercoolerInfo($(this)),startPolling($(this))})}function refreshDependencies(a,b){log(b,"refreshing dependencies for path "+a,"DEBUG"),$("[ic-src]").each(function(){var c=!1;"GET"==verbFor($(this))&&"ignore"!=$(this).attr("ic-deps")&&(isDependent(a,$(this).attr("ic-src"))?(null==b||$(b)[0]!=$(this)[0])&&(fireICRequest($(this)),c=!0):(isDependent(a,$(this).attr("ic-deps"))||"*"==$(this).attr("ic-deps"))&&(null==b||$(b)[0]!=$(this)[0])&&(fireICRequest($(this)),c=!0)),c&&log($(this),"depends on path "+a+", refreshing...","DEBUG")})}function isDependent(a,b){return a&&b&&(0==b.indexOf(a)||0==a.indexOf(b))}function verbFor(a){return a.attr("ic-verb")?a.attr("ic-verb").toUpperCase():"GET"}function eventFor(a,b){return"default"==a?$(b).is("button")?"click":$(b).is("form")?"submit":$(b).is(":input")?"change":"click":a}function preventDefault(a){return a.is("form")||a.is(":submit")&&1==a.closest("form").length}function handleTriggerOn(a){if($(a).attr("ic-trigger-on"))if("load"==$(a).attr("ic-trigger-on"))fireICRequest(a);else if("scrolled-into-view"==$(a).attr("ic-trigger-on"))initScrollHandler(),setTimeout(function(){$(window).trigger("scroll")},100);else{var b=$(a).attr("ic-trigger-on").split(" ");$(a).on(eventFor(b[0],$(a)),function(c){if("changed"==b[1]){var d=$(a).val(),e=$(a).data("ic-previous-val");$(a).data("ic-previous-val",d),d!=e&&fireICRequest($(a))}else fireICRequest($(a));return preventDefault(a)?(c.preventDefault(),!1):!0})}}function processTriggerOn(a){handleTriggerOn(a),$(a).find("[ic-trigger-on]").each(function(){handleTriggerOn($(this))})}function processMacros(a){$.each(_MACROS,function(b,c){$(a).is("["+c+"]")&&processMacro(c,$(a)),$(a).find("["+c+"]").each(function(){processMacro(c,$(this))})})}function processMacro(a,b){"ic-post-to"==a&&(setIfAbsent(b,"ic-src",b.attr("ic-post-to")),setIfAbsent(b,"ic-verb","POST"),setIfAbsent(b,"ic-trigger-on","default"),setIfAbsent(b,"ic-deps","ignore")),"ic-put-to"==a&&(setIfAbsent(b,"ic-src",b.attr("ic-put-to")),setIfAbsent(b,"ic-verb","PUT"),setIfAbsent(b,"ic-trigger-on","default"),setIfAbsent(b,"ic-deps","ignore")),"ic-get-from"==a&&(setIfAbsent(b,"ic-src",b.attr("ic-get-from")),setIfAbsent(b,"ic-trigger-on","default"),setIfAbsent(b,"ic-deps","ignore")),"ic-delete-from"==a&&(setIfAbsent(b,"ic-src",b.attr("ic-delete-from")),setIfAbsent(b,"ic-verb","DELETE"),setIfAbsent(b,"ic-trigger-on","default"),setIfAbsent(b,"ic-deps","ignore"));var c=null,d=null;if("ic-style-src"==a){c=b.attr("ic-style-src").split(":");var e=c[0];d=c[1],setIfAbsent(b,"ic-src",d),setIfAbsent(b,"ic-target","this.style."+e)}if("ic-attr-src"==a){c=b.attr("ic-attr-src").split(":");var f=c[0];d=c[1],setIfAbsent(b,"ic-src",d),setIfAbsent(b,"ic-target","this."+f)}"ic-prepend-from"==a&&(setIfAbsent(b,"ic-src",b.attr("ic-prepend-from")),setIfAbsent(b,"ic-transition","prepend")),"ic-append-from"==a&&(setIfAbsent(b,"ic-src",b.attr("ic-append-from")),setIfAbsent(b,"ic-transition","append"))}function setIfAbsent(a,b,c){null==a.attr(b)&&a.attr(b,c)}function isScrolledIntoView(a){var b=$(window).scrollTop(),c=b+$(window).height(),d=$(a).offset().top,e=d+$(a).height();return e>=b&&c>=d&&c>=e&&d>=b}function getTransition(a,b){var c=null;return a.attr("ic-transition")&&(c=_transitions[a.attr("ic-transition")]),b.attr("ic-transition")&&(c=_transitions[b.attr("ic-transition")]),b.data("ic-tmp-transition")&&(c=_transitions[b.data("ic-tmp-transition")]),null==c&&(c=_transitions[_defaultTransition]),null==c&&(c=_transitions.none),c}function processICResponse(a,b){if(a&&/\S/.test(a)){log(b,"response content: \n"+a,"DEBUG");var c=getTarget(b),d="true"==closestAttrValue(b,"ic-always-update")||a.indexOf("<script>")>=0;if(0==d){var e=document.createElement("div");e.innerHTML=a,processMacros(e),d=fingerprint($(e).html())!=c.attr("ic-fingerprint"),e.remove&&e.remove()}if(d){var f=getTransition(b,c),g="true"==closestAttrValue(b,"ic-replace-target");f.newContent(c,a,!1,g,function(a){a?(processNodes(a),updateIntercoolerMetaData(c)):($(c).children().each(function(){processNodes($(this))}),updateIntercoolerMetaData(c)),updateIntercoolerMetaData(c)})}}}function getStyleTarget(a){var b=closestAttrValue(a,"ic-target");return b&&0==b.indexOf("this.style.")?b.substr(11):null}function getAttrTarget(a){var b=closestAttrValue(a,"ic-target");return b&&0==b.indexOf("this.")?b.substr(5):null}function fireICRequest(a){var b=a;a.is("[ic-src]")||(a=a.closest("[ic-src]"));var c=closestAttrValue(a,"ic-confirm");if((!c||confirm(c))&&a.length>0){var d=uuid();a.data("ic-event-id",d);var e=function(){if(1==a.data("ic-request-in-flight"))return void a.data("ic-next-request",e);if(a.data("ic-event-id")==d){var c=getStyleTarget(a),f=c?null:getAttrTarget(a),g=verbFor(a);handleRemoteRequest(a,g,a.attr("ic-src"),getParametersForElement(a,b),function(b){c?a.css(c,b):f?a.attr(f,b):(processICResponse(b,a),"GET"!=g&&refreshDependencies(a.attr("ic-src"),a))})}},f=closestAttrValue(a,"ic-trigger-delay");f?setTimeout(e,parseInterval(f)):e()}}var _MACROS=["ic-get-from","ic-post-to","ic-put-to","ic-delete-from","ic-style-src","ic-attr-src","ic-prepend-from","ic-append-from"],_remote=$,_scrollHandler=null,_UUID=1,_transitions={},_defaultTransition="fadeFast";_defineTransition("none",{}),_defineTransition("fadeFast",{newContent:function(a,b,c,d,e){a.fadeOut("fast",function(){d?e($(b).replaceAll(a)):(a.html(b),e()),a.fadeIn("fast")})},remove:function(a){a.fadeOut("fast",function(){a.remove()})},show:function(a){a.fadeIn("fast")},hide:function(a){a.fadeOut("fast")}}),_defineTransition("prepend",{newContent:function(a,b,c,d,e){var f=$(b);if(f.hide(),a.prepend(f),e(),f.fadeIn(),a.attr("ic-limit-children")){var g=parseInt(a.attr("ic-limit-children"));a.children().length>g&&a.children().slice(g,a.children().length).remove()}}}),_defineTransition("append",{newContent:function(a,b,c,d,e){var f=$(b);if(f.hide(),a.append(f),e(),f.fadeIn(),a.attr("ic-limit-children")){var g=parseInt(a.attr("ic-limit-children"));a.children().length>g&&a.children().slice(0,a.children().length-g).remove()}}});var _historySupport={stateCache:null,popping:!1,getRestorationURL:function(a){var b=closestAttrValue(a,"ic-restore-from");return b||window.location.pathname+window.location.search+window.location.hash},onPageLoad:function(){if(_historySupport.stateCache={"ic-setlocation":!0,"restore-from":window.location.pathname+window.location.search+window.location.hash,timestamp:(new Date).getTime()},null==window.onpopstate||1!=window.onpopstate["ic-on-pop-state-handler"]){var a=window.onpopstate;window.onpopstate=function(b){_historySupport.handlePop(b)||a&&a(b)},window.onpopstate["ic-on-pop-state-handler"]=!0}},pushUrl:function(a,b){log(b,"pushing location into history: "+a,"DEBUG");var c=getTarget(b),d=c.attr("id");if(null==d)return void log(b,"To support history for a given element, you must have a valid id attribute on the element","ERROR");_historySupport.initHistory(b);var e={"ic-setlocation":!0,"id-to-restore":d.toString(),"restore-from":a,timestamp:(new Date).getTime()};b.trigger("pushUrl.ic",c,e),window.history.pushState(e,"",a)},initHistory:function(a){if(_historySupport.stateCache){var b=getTarget(a),c=b.attr("id");_historySupport.stateCache["id-to-restore"]=c.toString(),window.history.replaceState(_historySupport.stateCache,"",_historySupport.stateCache["restore-from"]),_historySupport.stateCache=null}},handlePop:function(a){var b=a.state;if(b&&b["ic-setlocation"]){var c=findById(b["id-to-restore"]),d=getParametersForElement(c,null);return d+="&ic-handle-pop=true",handleRemoteRequest(c,"GET",b["restore-from"],d,function(a){c.trigger("handlePop.ic",c,a),processICResponse(a,c)}),!0}return!1}};return $(function(){processNodes("body"),_historySupport.onPageLoad(),location.search&&location.search.indexOf("ic-launch-debugger=true")>=0&&Intercooler.debug()}),{refresh:function(a){return"string"==typeof a||a instanceof String?refreshDependencies(a):fireICRequest(a),Intercooler},processNodes:function(a){return processNodes(a)},defaultTransition:function(a){_defaultTransition=a},defineTransition:function(a,b){_defineTransition(a,b)},debug:function(){var a=$(window).data("ic-debug-panel");null==a?!function(){function b(a){var b=$("<div><div><strong>Details</strong></div><div><strong>URL: </strong>"+a.attr("ic-src")+"</div><div><strong>Verb: </strong>"+verbFor(a)+"</div>"+(a.attr("ic-trigger-on")?"<div><strong>Trigger: </strong>"+a.attr("ic-trigger-on")+"</div>":"")+"</div>");if(a.attr("ic-target")&&b.append($("<div><strong>Target: </strong></div>").append(c(getTarget(a)))),a.attr("ic-deps")&&b.append($("<div><strong>Dependencies: </strong></div>").append(a.attr("ic-deps"))),"GET"!=verbFor(a)){var d=$("<div><strong>Dependant Elements:</strong><ul style='list-style-position: inside;font-size:12px;'></ul></div>").appendTo(b).find("ul");$("[ic-src]").each(function(){"GET"==verbFor($(this))&&"ignore"!=$(this).attr("ic-deps")&&(isDependent(a.attr("ic-src"),$(this).attr("ic-src"))||isDependent(a.attr("ic-src"),$(this).attr("ic-deps"))||"*"==$(this).attr("ic-deps"))&&(null==a||a[0]!=$(this)[0])&&$("<li style='font-size:12px'></li>").append(c($(this))).appendTo(d)})}return b}function c(a){return a&&a.length>0?$("<a style='border-bottom: 1px solid #d3d3d3'><"+a.prop("tagName").toLowerCase()+">"+(a.attr("ic-src")?" - "+a.attr("ic-src"):"")+"</a>").data("ic-debug-elt",a):$("<span>no element</span>")}function d(){return $("<div id='ic-debug-panel' style='font-size: 14px;font-family: Arial;border-radius: 4px 4px 0 0; background:white;width:800px;height:400px;position:fixed;border: 1px solid gray;'> <div style='border-radius: 4px 4px 0 0;padding:4px;width:100%;border-bottom: 1px solid gray;background: #f5f5f5'><strong>intercooler.js debugging console</strong> <span style='float:right'><a>Hide</a> | <a>[x]</a></span> </div> <div style='padding:4px;width:100%;border-bottom: 1px solid gray;'> <a style='font-weight: bold'>Elements</a> | <a>Logs</a> | <a>Errors</a> </div> <div> <div id='ic-debug-Elements'> <div id='ic-debug-Elements-list' style='width:200px;float: left;height: 342px;overflow-y: scroll;'> </div> <div id='ic-debug-Elements-detail'> </div> </div> <div id='ic-debug-Logs' style='display:none;overflow-y: scroll;height: 342px'> </div> <div id='ic-debug-Errors' style='display:none;overflow-y: scroll;height: 342px'> </div> </div></div>")}function e(a){var b=c(a);b.clone(!0).css({display:"block"}).appendTo($("#ic-debug-Elements-list")),a.attr("ic-target")&&0==getTarget(a).length&&$("<div> - bad target selector:"+a.attr("ic-target")+"</div>").prepend(b.clone(!0)).appendTo($("#ic-debug-Errors")),a.attr("ic-indicator")&&0==$(a.attr("ic-indicator")).length&&$("<div> - bad indicator selector:"+a.attr("ic-indicator")+"</div>").prepend(b.clone(!0)).appendTo($("#ic-debug-Errors"))}function f(){$("#ic-debug-Elements-list").find("a").each(function(){$(this).data("ic-debug-elt")&&$.contains(document.body,$(this).data("ic-debug-elt")[0])||$(this).remove()})}a=d().appendTo($("body")),$(window).data("ic-debug-panel",a);var g;$("#ic-debug-panel").on("click","a",function(){if("Hide"==$(this).text())$("#ic-debug-panel").data("ic-minimized",!0),$(this).text("Show"),$(window).resize();else if("Show"==$(this).text())$("#ic-debug-panel").data("ic-minimized",!1),$(this).text("Hide"),$(window).resize();else if("[x]"==$(this).text())g&&g.css({border:""}),a.hide();else if(["Elements","Logs","Errors"].indexOf($(this).text())>=0)$(this).parent().find("a").css({"font-weight":"normal"}),$(this).css({"font-weight":"bold"}),$("#ic-debug-"+$(this).text()).parent().children().hide(),$("#ic-debug-"+$(this).text()).show();else if($(this).data("ic-debug-elt")){var c=$(this),d=c.data("ic-debug-elt"),e=Math.min(d.offset().top-75,300);$("html, body").animate({scrollTop:d.offset().top-75},e),g&&g.css({border:""}),g=d,d.css({border:"2px solid red"}),"ic-debug-Elements-list"==c.parent().attr("id")&&$("#ic-debug-Elements-detail").html(b(d))}}),$("[ic-src]").each(function(){e($(this))}),$(window).on("log.ic",function(a,b,d){$("<div style='border-bottom: 1px solid #d3d3d3'>] - "+b.replace(/</g,"<")+"</div>").appendTo($("#ic-debug-Logs")).prepend(c($(a.target))).prepend(d+" [")}).on("elementAdded.ic",function(a){e($(a.target))}).on("nodesProcessed.ic",function(){f()}).on("resize",function(){a.css({top:$(window).height()-(1==a.data("ic-minimized")?29:400)+"px",left:$(window).width()-820+"px"})})}():a.show(),$(window).resize()},addURLHandler:function(){throw"This method is no longer supported. Please use the jQuery mockjax plugin instead: https://github.com/jakerella/jquery-mockjax"},setRemote:function(a){return _remote=a,Intercooler}}}();