2 lines
2.7 KiB
JavaScript
2 lines
2.7 KiB
JavaScript
(function(t){var a=PhpDebugBar.utils.makecsscls("phpdebugbar-widgets-"),p=PhpDebugBar.Widgets.TemplatesWidget=PhpDebugBar.Widget.extend({className:a("templates"),render:function(){this.$status=t("<div />").addClass(a("status")).appendTo(this.$el),this.$list=new PhpDebugBar.Widgets.ListWidget({itemRenderer:function(s,e){if(t("<span />").addClass(a("name")).text(e.name).appendTo(s),typeof e.xdebug_link<"u"&&e.xdebug_link!==null){var i=t("<span />").addClass(a("filename")).text(e.xdebug_link.filename+(e.xdebug_link.line?"#"+e.xdebug_link.line:""));e.xdebug_link&&(e.xdebug_link.ajax?t('<a title="'+e.xdebug_link.url+'"></a>').on("click",function(){fetch(e.xdebug_link.url)}).addClass(a("editor-link")).appendTo(i):t('<a href="'+e.xdebug_link.url+'"></a>').addClass(a("editor-link")).appendTo(i)),i.appendTo(s)}if(e.render_time_str&&t('<span title="Render time" />').addClass(a("render-time")).text(e.render_time_str).appendTo(s),e.memory_str&&t('<span title="Memory usage" />').addClass(a("memory")).text(e.memory_str).appendTo(s),typeof e.param_count<"u"&&t('<span title="Parameter count" />').addClass(a("param-count")).text(e.param_count).appendTo(s),typeof e.type<"u"&&e.type&&t('<span title="Type" />').addClass(a("type")).text(e.type).appendTo(s),typeof e.editorLink<"u"&&e.editorLink&&t('<a href="'+e.editorLink+'" />').on("click",function(r){r.stopPropagation()}).addClass(a("editor-link")).text("file").appendTo(s),e.params&&!t.isEmptyObject(e.params)){var n=t('<table><tr><th colspan="2">Params</th></tr></table>').addClass(a("params")).appendTo(s);for(var d in e.params)typeof e.params[d]!="function"&&n.append('<tr><td class="'+a("name")+'">'+d+'</td><td class="'+a("value")+'"><pre><code>'+e.params[d]+"</code></pre></td></tr>");s.css("cursor","pointer").click(function(){if(window.getSelection().type=="Range")return"";n.is(":visible")?n.hide():n.show()})}}}),this.$list.$el.appendTo(this.$el),this.$callgraph=t("<div />").addClass(a("callgraph")).appendTo(this.$el),this.bindAttr("data",function(s){this.$list.set("data",s.templates),this.$status.empty(),this.$callgraph.empty();var e=s.sentence||"templates were rendered";t("<span />").text(s.nb_templates+" "+e).appendTo(this.$status),s.accumulated_render_time_str&&this.$status.append(t('<span title="Accumulated render time" />').addClass(a("render-time")).text(s.accumulated_render_time_str)),s.memory_usage_str&&this.$status.append(t('<span title="Memory usage" />').addClass(a("memory")).text(s.memory_usage_str)),s.nb_blocks>0&&t("<div />").text(s.nb_blocks+" blocks were rendered").appendTo(this.$status),s.nb_macros>0&&t("<div />").text(s.nb_macros+" macros were rendered").appendTo(this.$status),typeof s.callgraph<"u"&&this.$callgraph.html(s.callgraph)})}})})(PhpDebugBar.$);
|