2011-11-05 17:04:10 +00:00
|
|
|
'use strict';
|
|
|
|
|
2011-08-24 21:21:25 +00:00
|
|
|
pandora.ui.preferencesDialog = function() {
|
|
|
|
|
|
|
|
var tabs = [
|
|
|
|
{id: 'account', title: 'Account', selected: true},
|
2011-12-22 15:48:48 +00:00
|
|
|
{id: 'advanced', title: 'Advanced'}
|
2011-08-24 21:21:25 +00:00
|
|
|
];
|
|
|
|
var $tabPanel = Ox.TabPanel({
|
|
|
|
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',
|
|
|
|
label: 'Username',
|
|
|
|
labelWidth: 120,
|
|
|
|
value: pandora.user.username,
|
|
|
|
width: 320
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
2011-10-22 14:50:53 +00:00
|
|
|
autovalidate: /.+/,
|
|
|
|
id: 'password',
|
|
|
|
label: 'New Password',
|
|
|
|
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',
|
|
|
|
label: 'E-Mail Address',
|
|
|
|
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',
|
|
|
|
label: 'Level',
|
|
|
|
labelWidth: 120,
|
|
|
|
value: Ox.toTitleCase(pandora.user.level),
|
|
|
|
width: 320
|
2011-12-22 15:48:48 +00:00
|
|
|
}),
|
|
|
|
Ox.Checkbox({
|
|
|
|
id: 'newsletter',
|
|
|
|
label: 'Newsletter',
|
|
|
|
labelWidth: 120,
|
|
|
|
title: pandora.user.newsletter ? 'Subscribed' : 'Unsubscribed',
|
|
|
|
value: pandora.user.newsletter,
|
|
|
|
width: 320
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
pandora.user.newsletter = data.value;
|
|
|
|
this.options({
|
|
|
|
title: pandora.user.newsletter ? 'Subscribed' : 'Unsubscribed'
|
|
|
|
});
|
|
|
|
pandora.api.editPreferences({
|
|
|
|
newsletter: pandora.user.newsletter
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2011-10-18 17:08:35 +00:00
|
|
|
]
|
|
|
|
})
|
|
|
|
.css({position: 'absolute', left: '96px', top: '16px'})
|
|
|
|
);
|
2011-09-24 23:09:48 +00:00
|
|
|
} else {
|
2011-10-22 14:50:53 +00:00
|
|
|
$content.append(
|
|
|
|
Ox.Button({
|
|
|
|
title: 'Reset UI Settings',
|
2012-05-28 21:04:27 +00:00
|
|
|
width: 128
|
2011-10-22 14:50:53 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
pandora.UI.reset();
|
|
|
|
pandora.$ui.appPanel.reload();
|
|
|
|
}
|
|
|
|
})
|
2011-12-22 15:48:48 +00:00
|
|
|
.css({position: 'absolute', left: '96px', top: '16px'})
|
2011-10-22 14:50:53 +00:00
|
|
|
);
|
2012-05-28 21:04:27 +00:00
|
|
|
$content.append(
|
|
|
|
Ox.Button({
|
|
|
|
title: 'Run Script on Load',
|
|
|
|
width: 128
|
|
|
|
})
|
|
|
|
.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
|
|
|
|
});
|
|
|
|
var $dialog = Ox.Dialog({
|
|
|
|
buttons: [
|
|
|
|
Ox.Button({
|
2011-10-18 17:08:35 +00:00
|
|
|
id: 'done',
|
|
|
|
title: 'Done'
|
2011-08-24 21:21:25 +00:00
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
$dialog.close();
|
2011-12-18 09:27:15 +00:00
|
|
|
pandora.UI.set({page: ''});
|
2011-08-24 21:21:25 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
//closeButton: true,
|
|
|
|
content: $tabPanel,
|
2011-10-18 17:08:35 +00:00
|
|
|
height: 192,
|
2011-08-24 21:21:25 +00:00
|
|
|
//maximizeButton: true,
|
2011-10-18 17:08:35 +00:00
|
|
|
minHeight: 192,
|
|
|
|
minWidth: 432,
|
2011-08-24 21:21:25 +00:00
|
|
|
title: 'Preferences',
|
2011-10-18 17:08:35 +00:00
|
|
|
width: 432
|
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
|
|
|
};
|