2011-11-05 17:04:10 +00:00
|
|
|
'use strict';
|
|
|
|
|
2011-08-24 21:21:25 +00:00
|
|
|
pandora.ui.preferencesDialog = function() {
|
|
|
|
|
2013-08-08 11:15:23 +00:00
|
|
|
var isReloading = false,
|
|
|
|
tabs = [
|
2013-08-08 11:03:06 +00:00
|
|
|
{id: 'account', title: Ox._('Account')},
|
|
|
|
{id: 'appearance', title: Ox._('Appearance')},
|
2013-05-09 10:13:58 +00:00
|
|
|
{id: 'advanced', title: Ox._('Advanced')}
|
2013-08-08 11:03:06 +00:00
|
|
|
];
|
|
|
|
Ox.getObjectById(tabs, pandora.user.ui.part.preferences || 'account').selected = true;
|
|
|
|
var $tabPanel = Ox.TabPanel({
|
2011-08-24 21:21:25 +00:00
|
|
|
content: function(id) {
|
2011-10-18 17:08:35 +00:00
|
|
|
var $content = Ox.Element()
|
|
|
|
.css({overflowY: 'auto'})
|
|
|
|
.append(
|
|
|
|
$('<img>')
|
2012-04-20 10:22:32 +00:00
|
|
|
.attr({src: '/static/png/icon.png'})
|
2012-05-22 16:36:52 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: '16px',
|
|
|
|
top: '16px',
|
|
|
|
width: '64px',
|
|
|
|
height: '64px'
|
|
|
|
})
|
2011-10-18 17:08:35 +00:00
|
|
|
);
|
2011-09-24 23:09:48 +00:00
|
|
|
if (id == 'account') {
|
2011-10-18 17:08:35 +00:00
|
|
|
$content.append(
|
|
|
|
Ox.Form({
|
|
|
|
items: [
|
|
|
|
Ox.Input({
|
|
|
|
disabled: true,
|
|
|
|
id: 'username',
|
2013-05-09 10:13:58 +00:00
|
|
|
label: Ox._('Username'),
|
2011-10-18 17:08:35 +00:00
|
|
|
labelWidth: 120,
|
|
|
|
value: pandora.user.username,
|
|
|
|
width: 320
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
2011-10-22 14:50:53 +00:00
|
|
|
autovalidate: /.+/,
|
|
|
|
id: 'password',
|
2013-05-09 10:13:58 +00:00
|
|
|
label: Ox._('New Password'),
|
2011-10-22 14:50:53 +00:00
|
|
|
labelWidth: 120,
|
|
|
|
type: 'password',
|
|
|
|
validate: pandora.validateNewPassword,
|
|
|
|
width: 320
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
validate: function(data) {
|
|
|
|
data.valid && pandora.api.editPreferences({password: data.value});
|
|
|
|
}
|
|
|
|
}),
|
2011-10-18 17:08:35 +00:00
|
|
|
Ox.Input({
|
2011-10-22 14:50:53 +00:00
|
|
|
autovalidate: pandora.autovalidateEmail,
|
|
|
|
id: 'email',
|
2013-05-09 10:13:58 +00:00
|
|
|
label: Ox._('E-Mail Address'),
|
2011-10-22 14:50:53 +00:00
|
|
|
labelWidth: 120,
|
|
|
|
validate: pandora.validateNewEmail,
|
|
|
|
value: pandora.user.email,
|
|
|
|
width: 320
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
validate: function(data) {
|
|
|
|
if (data.valid && data.value != pandora.user.email) {
|
|
|
|
pandora.user.email = data.value;
|
|
|
|
pandora.api.editPreferences({email: data.value});
|
|
|
|
}
|
|
|
|
}
|
2011-10-24 10:04:41 +00:00
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
disabled: true,
|
|
|
|
id: 'level',
|
2013-05-09 10:13:58 +00:00
|
|
|
label: Ox._('Level'),
|
2011-10-24 10:04:41 +00:00
|
|
|
labelWidth: 120,
|
|
|
|
value: Ox.toTitleCase(pandora.user.level),
|
|
|
|
width: 320
|
2011-12-22 15:48:48 +00:00
|
|
|
}),
|
|
|
|
Ox.Checkbox({
|
|
|
|
id: 'newsletter',
|
2013-05-09 10:13:58 +00:00
|
|
|
label: Ox._('Newsletter'),
|
2011-12-22 15:48:48 +00:00
|
|
|
labelWidth: 120,
|
2013-05-09 10:13:58 +00:00
|
|
|
title: pandora.user.newsletter ? Ox._('Subscribed') : Ox._('Unsubscribed'),
|
2011-12-22 15:48:48 +00:00
|
|
|
value: pandora.user.newsletter,
|
|
|
|
width: 320
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
pandora.user.newsletter = data.value;
|
|
|
|
this.options({
|
2013-05-09 10:13:58 +00:00
|
|
|
title: pandora.user.newsletter ? Ox._('Subscribed') : Ox._('Unsubscribed')
|
2011-12-22 15:48:48 +00:00
|
|
|
});
|
|
|
|
pandora.api.editPreferences({
|
|
|
|
newsletter: pandora.user.newsletter
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2011-10-18 17:08:35 +00:00
|
|
|
]
|
|
|
|
})
|
|
|
|
.css({position: 'absolute', left: '96px', top: '16px'})
|
|
|
|
);
|
2013-08-08 11:03:06 +00:00
|
|
|
} else if (id == 'appearance') {
|
|
|
|
$content.append(
|
|
|
|
Ox.Form({
|
|
|
|
items: [
|
|
|
|
Ox.Select({
|
|
|
|
id: 'theme',
|
|
|
|
items: pandora.site.themes.map(function(theme) {
|
|
|
|
return {id: theme, title: Ox.Theme.getThemeData(theme).themeName}
|
|
|
|
}),
|
|
|
|
label: Ox._('Theme'),
|
|
|
|
labelWidth: 120,
|
|
|
|
value: pandora.user.ui.theme,
|
|
|
|
width: 320
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
pandora.UI.set({theme: data.value});
|
|
|
|
pandora.setTheme(data.value);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Ox.Select({
|
|
|
|
id: 'locale',
|
|
|
|
items: Object.keys(Ox.LOCALE_NAMES).map(function(locale) {
|
|
|
|
return {id: locale, title: Ox.LOCALE_NAMES[locale]}
|
|
|
|
}),
|
|
|
|
label: Ox._('Language'),
|
|
|
|
labelWidth: 120,
|
|
|
|
value: pandora.user.ui.locale,
|
|
|
|
width: 320
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
pandora.UI.set({locale: data.value});
|
2013-08-08 11:12:06 +00:00
|
|
|
pandora.setLocale(data.value, function() {
|
2013-08-08 11:15:23 +00:00
|
|
|
isReloading = true;
|
|
|
|
$dialog.close();
|
2013-08-08 11:12:06 +00:00
|
|
|
pandora.$ui.appPanel.reload();
|
|
|
|
});
|
2013-08-08 11:03:06 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
]
|
|
|
|
})
|
|
|
|
.css({position: 'absolute', left: '96px', top: '16px'})
|
|
|
|
);
|
|
|
|
} else if (id == 'advanced') {
|
2011-10-22 14:50:53 +00:00
|
|
|
$content.append(
|
|
|
|
Ox.Button({
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Reset UI Settings...'),
|
2012-06-04 10:57:55 +00:00
|
|
|
width: 160
|
2011-10-22 14:50:53 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
2012-06-04 10:57:55 +00:00
|
|
|
pandora.$ui.resetUIDialog = pandora.ui.resetUIDialog().open();
|
2011-10-22 14:50:53 +00:00
|
|
|
}
|
|
|
|
})
|
2011-12-22 15:48:48 +00:00
|
|
|
.css({position: 'absolute', left: '96px', top: '16px'})
|
2013-08-08 11:03:06 +00:00
|
|
|
).append(
|
2012-05-28 21:04:27 +00:00
|
|
|
Ox.Button({
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Run Script on Load...'),
|
2012-06-04 10:57:55 +00:00
|
|
|
width: 160
|
2012-05-28 21:04:27 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
pandora.$ui.onloadDialog = pandora.ui.onloadDialog().open();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.css({position: 'absolute', left: '96px', top: '40px'})
|
|
|
|
);
|
2011-09-24 23:09:48 +00:00
|
|
|
}
|
2011-10-18 17:08:35 +00:00
|
|
|
return $content;
|
2011-08-24 21:21:25 +00:00
|
|
|
},
|
|
|
|
tabs: tabs
|
2013-08-08 11:03:06 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
pandora.UI.set({'part.preferences': data.selected});
|
|
|
|
}
|
2012-06-11 07:31:24 +00:00
|
|
|
}),
|
2013-08-08 11:03:06 +00:00
|
|
|
|
2012-06-11 07:31:24 +00:00
|
|
|
$dialog = Ox.Dialog({
|
|
|
|
buttons: [
|
2013-03-03 08:05:09 +00:00
|
|
|
Ox.Button({
|
|
|
|
id: 'signout',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Sign Out...')
|
2013-03-03 08:05:09 +00:00
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
pandora.UI.set({page: 'signout'});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
{},
|
2012-06-11 07:31:24 +00:00
|
|
|
Ox.Button({
|
|
|
|
id: 'done',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Done')
|
2012-06-11 07:31:24 +00:00
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
$dialog.close();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
closeButton: true,
|
|
|
|
content: $tabPanel,
|
|
|
|
height: 192,
|
|
|
|
minHeight: 192,
|
|
|
|
minWidth: 432,
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Preferences'),
|
2012-06-11 07:31:24 +00:00
|
|
|
width: 432
|
2013-03-04 12:54:06 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
close: function() {
|
2013-08-08 11:15:23 +00:00
|
|
|
if (pandora.user.ui.page == 'preferences' && !isReloading) {
|
|
|
|
pandora.UI.set({page: ''});
|
|
|
|
}
|
2013-08-08 11:03:06 +00:00
|
|
|
},
|
|
|
|
'pandora_part.preferences': function(data) {
|
|
|
|
if (pandora.user.ui.page == 'preferences') {
|
|
|
|
$tabPanel.select(data.value == '' ? 'account' : data.value);
|
|
|
|
}
|
2013-03-04 12:54:06 +00:00
|
|
|
}
|
|
|
|
});
|
2011-08-24 21:21:25 +00:00
|
|
|
|
|
|
|
return $dialog;
|
2011-10-29 17:46:46 +00:00
|
|
|
|
2011-09-24 23:09:48 +00:00
|
|
|
};
|