This repository has been archived by the owner on Dec 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
/
TimezoneChooser.js
91 lines (80 loc) · 2.92 KB
/
TimezoneChooser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* Tine 2.0
*
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @author Philipp Schuele <p.schuele@metaways.de>
* @copyright Copyright (c) 2007-2008 Metaways Infosystems GmbH (http://www.metaways.de)
*
* @deprecated is replaced by preferences dialog / perhaps we need this again in calendar (event edit dialog)
*/
Ext.ns('Tine.widgets');
/**
* timezone chooser widget
*
* @namespace Tine.widgets
* @class Tine.widgets.TimezoneChooser
* @extends Ext.form.ComboBox
*/
Tine.widgets.TimezoneChooser = Ext.extend(Ext.form.ComboBox, {
/**
* @cfg {String}
*/
fieldLabel: null,
displayField: 'timezoneTranslation',
valueField: 'timezone',
triggerAction: 'all',
width: 100,
listWidth: 250,
editable: false,
initComponent: function() {
this.value = Tine.Tinebase.registry.get('timeZone');
this.fieldLabel = this.fieldLabel ? this.fieldLabel : i18n._('Timezone');
this.tpl = new Ext.XTemplate(
'<tpl for=".">' +
'<div class="x-combo-list-item">' +
'{[this.translate(values.timezone, values.timezoneTranslation)]}' +
'</div>' +
'</tpl>',{
translate: function(timezone, timezoneTranslation) {
// use timezoneTranslation as fallback
var translation = (Locale.getTranslationData('CityToTimezone', timezone))
? Locale.getTranslationData('CityToTimezone', timezone)
: timezoneTranslation;
return timezone + (translation ? (' - <i>(' + translation + ')</i>') : '');
}
}
);
this.store = new Ext.data.JsonStore({
id: 'timezone',
root: 'results',
totalProperty: 'totalcount',
fields: Tine.Tinebase.Model.Timezone,
baseParams: {
method: 'Tinebase.getAvailableTimezones'
}
});
Tine.widgets.TimezoneChooser.superclass.initComponent.call(this);
this.on('select', this.onTimezoneSelect, this);
},
/**
* timezone selection ajax call
*/
onTimezoneSelect: function(combo, record, idx) {
var currentTimezone = Tine.Tinebase.registry.get('timeZone');
var newTimezone = record.get('timezone');
if (newTimezone != currentTimezone) {
Ext.MessageBox.wait(i18n._('Setting new timezone...'), i18n._('Please Wait'));
Ext.Ajax.request({
scope: this,
params: {
method: 'Tinebase.setTimezone',
timezoneString: newTimezone,
saveaspreference: true
},
success: function(result, request){
Tine.Tinebase.common.reload({});
}
});
}
}
});