a776e21f87db8318cbd6e596a357bb199138262a
[ccsdk/features.git] /
1 (function( $, app, i18n ) {
2
3         var ui = app.ns("ui");
4
5         ui.RefreshButton = ui.SplitButton.extend({
6                 defaults: {
7                         timer: -1
8                 },
9                 init: function( parent ) {
10                         this.config.label = i18n.text("General.RefreshResults");
11                         this._super( parent );
12                         this.set( this.config.timer );
13                 },
14                 set: function( value ) {
15                         this.value = value;
16                         window.clearInterval( this._timer );
17                         if( this.value > 0 ) {
18                                 this._timer = window.setInterval( this._refresh_handler, this.value );
19                         }
20                 },
21                 _click_handler: function() {
22                         this._refresh_handler();
23                 },
24                 _select_handler: function( el, event ) {
25                         this.set( event.value );
26                         this.fire("change", this );
27                 },
28                 _refresh_handler: function() {
29                         this.fire("refresh", this );
30                 },
31                 _getItems: function() {
32                         return [
33                                 { text: i18n.text("General.ManualRefresh"), value: -1 },
34                                 { text: i18n.text("General.RefreshQuickly"), value: 100 },
35                                 { text: i18n.text("General.Refresh5seconds"), value: 5000 },
36                                 { text: i18n.text("General.Refresh1minute"), value: 60000 }
37                         ];
38                 }
39         });
40
41 })( this.jQuery, this.app, this.i18n );