[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/maximebf/debugbar/src/DebugBar/Resources/widgets/templates/ -> widget.js (source)

   1  (function($) {
   2  
   3      var csscls = PhpDebugBar.utils.makecsscls('phpdebugbar-widgets-');
   4  
   5      /**
   6       * Widget for the displaying templates data
   7       *
   8       * Options:
   9       *  - data
  10       */
  11      var TemplatesWidget = PhpDebugBar.Widgets.TemplatesWidget = PhpDebugBar.Widget.extend({
  12  
  13          className: csscls('templates'),
  14  
  15          render: function() {
  16              this.$status = $('<div />').addClass(csscls('status')).appendTo(this.$el);
  17  
  18              this.$list = new  PhpDebugBar.Widgets.ListWidget({ itemRenderer: function(li, tpl) {
  19                  $('<span />').addClass(csscls('name')).text(tpl.name).appendTo(li);
  20  
  21                  if (typeof tpl.xdebug_link !== 'undefined' && tpl.xdebug_link !== null) {
  22                      if (tpl.xdebug_link.ajax) {
  23                          $('<a title="' + tpl.xdebug_link.url + '"></a>').on('click', function () {
  24                              $.ajax(tpl.xdebug_link.url);
  25                          }).addClass(csscls('editor-link')).appendTo(li);
  26                      } else {
  27                          $('<a href="' + tpl.xdebug_link.url + '"></a>').addClass(csscls('editor-link')).appendTo(li);
  28                      }
  29                  }
  30                  if (tpl.render_time_str) {
  31                      $('<span title="Render time" />').addClass(csscls('render-time')).text(tpl.render_time_str).appendTo(li);
  32                  }
  33                  if (tpl.memory_str) {
  34                      $('<span title="Memory usage" />').addClass(csscls('memory')).text(tpl.memory_str).appendTo(li);
  35                  }
  36                  if (typeof(tpl.param_count) != 'undefined') {
  37                      $('<span title="Parameter count" />').addClass(csscls('param-count')).text(tpl.param_count).appendTo(li);
  38                  }
  39                  if (typeof(tpl.type) != 'undefined' && tpl.type) {
  40                      $('<span title="Type" />').addClass(csscls('type')).text(tpl.type).appendTo(li);
  41                  }
  42                  if (tpl.params && !$.isEmptyObject(tpl.params)) {
  43                      var table = $('<table><tr><th colspan="2">Params</th></tr></table>').addClass(csscls('params')).appendTo(li);
  44                      for (var key in tpl.params) {
  45                          if (typeof tpl.params[key] !== 'function') {
  46                              table.append('<tr><td class="' + csscls('name') + '">' + key + '</td><td class="' + csscls('value') +
  47                              '"><pre><code>' + tpl.params[key] + '</code></pre></td></tr>');
  48                          }
  49                      }
  50                      li.css('cursor', 'pointer').click(function() {
  51                          if (table.is(':visible')) {
  52                              table.hide();
  53                          } else {
  54                              table.show();
  55                          }
  56                      });
  57                  }
  58              }});
  59              this.$list.$el.appendTo(this.$el);
  60              this.$callgraph = $('<div />').addClass(csscls('callgraph')).appendTo(this.$el);
  61  
  62              this.bindAttr('data', function(data) {
  63                  this.$list.set('data', data.templates);
  64                  this.$status.empty();
  65                  this.$callgraph.empty();
  66  
  67                  var sentence = data.sentence || "templates were rendered";
  68                  $('<span />').text(data.nb_templates + " " + sentence).appendTo(this.$status);
  69  
  70                  if (data.accumulated_render_time_str) {
  71                      this.$status.append($('<span title="Accumulated render time" />').addClass(csscls('render-time')).text(data.accumulated_render_time_str));
  72                  }
  73                  if (data.memory_usage_str) {
  74                      this.$status.append($('<span title="Memory usage" />').addClass(csscls('memory')).text(data.memory_usage_str));
  75                  }
  76                  if (data.nb_blocks > 0) {
  77                      $('<div />').text(data.nb_blocks + " blocks were rendered").appendTo(this.$status);
  78                  }
  79                  if (data.nb_macros > 0) {
  80                      $('<div />').text(data.nb_macros + " macros were rendered").appendTo(this.$status);
  81                  }
  82                  if (typeof data.callgraph !== 'undefined') {
  83                      this.$callgraph.html(data.callgraph);
  84                  }
  85              });
  86          }
  87  
  88      });
  89  
  90  })(PhpDebugBar.$);


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer