11/*
2- * Copyright 2017 Nitrite author or authors.
3- *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
6- * You may obtain a copy of the License at
7- *
8- * http://www.apache.org/licenses/LICENSE-2.0
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.1 - 3/14/2010
16+ * http://benalman.com/projects/jquery-resize-plugin/
917 *
10- * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- * See the License for the specific language governing permissions and
14- * limitations under the License.
18+ * Copyright (c) 2010 "Cowboy" Ben Alman
19+ * Dual licensed under the MIT and GPL licenses.
20+ * http://benalman.com/about/license/
1521 */
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 ) ;
1623
17- function ( $ , e , t ) { "$:nomunge" ; var i = [ ] , n = $ . resize = $ . extend ( $ . resize , { } ) , a , r = false , s = "setTimeout" , u = "resize" , m = u + "-special-event" , o = "pendingDelay" , l = "activeDelay" , f = "throttleWindow" ; n [ o ] = 200 ; n [ l ] = 20 ; n [ f ] = true ; $ . event . special [ u ] = { setup :function ( ) { if ( ! n [ f ] && this [ s ] ) { return false } var e = $ ( this ) ; i . push ( this ) ; e . data ( m , { w :e . width ( ) , h :e . height ( ) } ) ; if ( i . length === 1 ) { a = t ; h ( ) } } , teardown :function ( ) { if ( ! n [ f ] && this [ s ] ) { return false } var e = $ ( this ) ; for ( var t = i . length - 1 ; t >= 0 ; t -- ) { if ( i [ t ] == this ) { i . splice ( t , 1 ) ; break } } e . removeData ( m ) ; if ( ! i . length ) { if ( r ) { cancelAnimationFrame ( a ) } else { clearTimeout ( a ) } a = null } } , add :function ( e ) { if ( ! n [ f ] && this [ s ] ) { return false } var i ; function a ( e , n , a ) { var r = $ ( this ) , s = r . data ( m ) || { } ; s . w = n !== t ?n :r . width ( ) ; s . h = a !== t ?a :r . height ( ) ; i . apply ( this , arguments ) } if ( $ . isFunction ( e ) ) { i = e ; return a } else { i = e . handler ; e . handler = a } } } ; function h ( t ) { if ( r === true ) { r = t || 1 } for ( var s = i . length - 1 ; s >= 0 ; s -- ) { var l = $ ( i [ s ] ) ; if ( l [ 0 ] == e || l . is ( ":visible" ) ) { var f = l . width ( ) , c = l . height ( ) , d = l . data ( m ) ; if ( d && ( f !== d . w || c !== d . h ) ) { l . trigger ( u , [ d . w = f , d . h = c ] ) ; r = t || true } } else { d = l . data ( m ) ; d . w = 0 ; d . h = 0 } } if ( a !== null ) { if ( r && ( t == null || t - r < 1e3 ) ) { a = e . requestAnimationFrame ( h ) } else { a = setTimeout ( h , n [ o ] ) ; r = false } } } if ( ! e . requestAnimationFrame ) { e . requestAnimationFrame = function ( ) { return e . webkitRequestAnimationFrame || e . mozRequestAnimationFrame || e . oRequestAnimationFrame || e . msRequestAnimationFrame || function ( t , i ) { return e . setTimeout ( function ( ) { t ( ( new Date ) . getTime ( ) ) } , n [ l ] ) } } ( ) } if ( ! e . cancelAnimationFrame ) { e . cancelAnimationFrame = function ( ) { return e . webkitCancelRequestAnimationFrame || e . mozCancelRequestAnimationFrame || e . oCancelRequestAnimationFrame || e . msCancelRequestAnimationFrame || clearTimeout } ( ) } } ) ( jQuery , this ) ;
1824
1925( function ( $ ) {
2026 var options = { } ; // no options
@@ -32,23 +38,23 @@ function($,e,t){"$:nomunge";var i=[],n=$.resize=$.extend($.resize,{}),a,r=false,
3238 plot . setupGrid ( ) ;
3339 plot . draw ( ) ;
3440 }
35-
41+
3642 function bindEvents ( plot , eventHolder ) {
3743 plot . getPlaceholder ( ) . resize ( onResize ) ;
3844 }
3945
4046 function shutdown ( plot , eventHolder ) {
4147 plot . getPlaceholder ( ) . unbind ( "resize" , onResize ) ;
4248 }
43-
49+
4450 plot . hooks . bindEvents . push ( bindEvents ) ;
4551 plot . hooks . shutdown . push ( shutdown ) ;
4652 }
47-
53+
4854 $ . plot . plugins . push ( {
4955 init : init ,
5056 options : options ,
5157 name : 'resize' ,
5258 version : '1.0'
5359 } ) ;
54- } ) ( jQuery ) ;
60+ } ) ( jQuery ) ;
0 commit comments