2 * Copyright 2010-2013 Ben Birch
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this software except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 (function( $, app, i18n ) {
18 var ui = app.ns("ui");
20 ui.RefreshButton = ui.SplitButton.extend({
24 init: function( parent ) {
25 this.config.label = i18n.text("General.RefreshResults");
26 this._super( parent );
27 this.set( this.config.timer );
29 set: function( value ) {
31 window.clearInterval( this._timer );
32 if( this.value > 0 ) {
33 this._timer = window.setInterval( this._refresh_handler, this.value );
36 _click_handler: function() {
37 this._refresh_handler();
39 _select_handler: function( el, event ) {
40 this.set( event.value );
41 this.fire("change", this );
43 _refresh_handler: function() {
44 this.fire("refresh", this );
46 _getItems: function() {
48 { text: i18n.text("General.ManualRefresh"), value: -1 },
49 { text: i18n.text("General.RefreshQuickly"), value: 100 },
50 { text: i18n.text("General.Refresh5seconds"), value: 5000 },
51 { text: i18n.text("General.Refresh1minute"), value: 60000 }
56 })( this.jQuery, this.app, this.i18n );