OpenSencillo  2016.106
Long live the simplicity of PHP
 All Data Structures Namespaces Files Functions Pages
jquery.flot.resize.js
1 /*
2 Flot plugin for automatically redrawing plots when the placeholder
3 size changes, e.g. on window resizes.
4 
5 It works by listening for changes on the placeholder div (through the
6 jQuery resize event plugin) - if the size changes, it will redraw the
7 plot.
8 
9 There are no options. If you need to disable the plugin for some
10 plots, you can just fix the size of their placeholders.
11 */
12 
13 
14 /* Inline dependency:
15  * jQuery resize event - v1.2 - 3/14/2010
16  * http://benalman.com/projects/jquery-resize-plugin/
17  *
18  * Copyright (c) 2010 "Cowboy" Ben Alman
19  * Dual licensed under the MIT and GPL licenses.
20  * http://benalman.com/about/license/
21  */
22 (function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
23 
24 
25 (function ($) {
26  var redrawing = 0;
27  var options = { }; // no options
28 
29  function init(plot) {
30  function bindEvents(plot, eventHolder) {
31  if (!redrawing)
32  plot.getPlaceholder().resize(onResize);
33 
34  function onResize() {
35  var placeholder = plot.getPlaceholder();
36 
37  // somebody might have hidden us and we can't plot
38  // when we don't have the dimensions
39  if (placeholder.width() == 0 || placeholder.height() == 0)
40  return;
41 
42  ++redrawing;
43  $.plot(placeholder, plot.getData(), plot.getOptions());
44  --redrawing;
45  }
46  }
47 
48  plot.hooks.bindEvents.push(bindEvents);
49  }
50 
51  $.plot.plugins.push({
52  init: init,
53  options: options,
54  name: 'resize',
55  version: '1.0'
56  });
57 })(jQuery);