pandora/static/js/pandora/siteDialog.js

95 lines
3.5 KiB
JavaScript
Raw Normal View History

2011-10-06 15:39:28 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
2011-08-24 21:21:25 +00:00
pandora.ui.siteDialog = function(section) {
var tabs = Ox.merge(
Ox.clone(pandora.site.sitePages),
[{id: 'software', title: 'Software'}]
);
2011-08-24 21:21:25 +00:00
Ox.getObjectById(tabs, section).selected = true;
var $tabPanel = Ox.TabPanel({
content: function(id) {
2011-10-27 08:47:57 +00:00
var $content = Ox.Element().css({padding: '16px', overflowY: 'auto'});
2011-10-06 15:39:28 +00:00
if (id == 'contact') {
2011-10-27 08:47:57 +00:00
$content.append(pandora.ui.contactForm());
2011-10-06 15:39:28 +00:00
} else {
2011-10-27 08:47:57 +00:00
pandora.api.getPage({name: id}, function(result) {
Ox.print('DATA::', result.data)
Ox.Editable({
2011-10-27 18:47:52 +00:00
clickLink: pandora.clickLink,
2011-10-27 08:47:57 +00:00
editable: pandora.site.capabilities.canEditSitePages[pandora.user.level],
tooltip: 'Doubleclick to edit',
type: 'textarea',
value: result.data.body
})
2011-10-27 18:47:52 +00:00
.css({width: '100%'/*, height: '100%'*/})
2011-10-27 08:47:57 +00:00
.bindEvent({
submit: function(data) {
Ox.Request.clearCache('getPage');
pandora.api.editPage({
name: id,
body: data.value
});
}
})
.appendTo($content)
2011-10-06 15:39:28 +00:00
});
}
2011-08-24 21:21:25 +00:00
return Ox.SplitPanel({
elements: [
{
element: Ox.Element()
.css({padding: '16px'})
.append(
$('<img>')
2011-08-26 00:22:26 +00:00
.attr({src: '/static/png/' + (
2011-10-27 22:17:28 +00:00
id == 'software' ? 'pandora/icon' : 'logo'
2011-08-26 00:22:26 +00:00
) + '256.png'})
.css({width: '256px'})
2011-08-24 21:21:25 +00:00
),
size: 272
2011-08-24 21:21:25 +00:00
},
{
2011-10-27 08:47:57 +00:00
element: $content
2011-08-24 21:21:25 +00:00
}
],
orientation: 'horizontal'
});
},
tabs: tabs
})
.bindEvent({
change: function(data) {
$dialog.options({
title: Ox.getObjectById(tabs, data.selected).title
});
2011-09-30 10:33:45 +00:00
//fixme: this should be using URL.push / UI.set
//but that currenlty causes another dialog to be opened
history.pushState({}, '', '/' + data.selected);
2011-08-24 21:21:25 +00:00
}
});
var $dialog = Ox.Dialog({
buttons: [
Ox.Button({
id: 'close',
title: 'Close'
}).bindEvent({
click: function() {
$dialog.close();
pandora.URL.update();
2011-08-24 21:21:25 +00:00
}
})
],
//closeButton: true,
content: $tabPanel,
height: Math.round((window.innerHeight - 24) * 0.75),
//maximizeButton: true,
minHeight: 256,
minWidth: 640,
title: 'About',
width: Math.round(window.innerWidth * 0.75),
});
return $dialog;
};