pandora/static/js/siteDialog.js

171 lines
7.2 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-11-05 17:04:10 +00:00
'use strict';
2011-08-24 21:21:25 +00:00
pandora.ui.siteDialog = function(section) {
var canSeeVersion = pandora.site.capabilities.canSeeSoftwareVersion[pandora.user.level],
dialogHeight = Math.round((window.innerHeight - 48) * 0.75),
2012-02-18 16:59:18 +00:00
dialogWidth = Math.round(window.innerWidth * 0.75),
2012-02-18 13:58:49 +00:00
isEditable = pandora.site.capabilities.canEditSitePages[pandora.user.level],
2013-07-17 10:25:01 +00:00
tabs = Ox.clone(pandora.site.sitePages, true).map(function(page) {
page.title = Ox._(page.title);
return page;
}).concat([{id: 'software', title: Ox._('Software')}]);
Ox.getObjectById(tabs, section).selected = true;
2011-08-24 21:21:25 +00:00
var $tabPanel = Ox.TabPanel({
content: function(id) {
var $content = Ox.Element()
.css({padding: '16px', overflowY: 'auto'});
2013-03-08 09:34:14 +00:00
if (id != 'contact') {
$content.addClass('OxTextPage');
}
2012-02-18 13:58:49 +00:00
if (id == 'contact') {
pandora.$ui.contactForm = pandora.ui.contactForm().appendTo($content);
} else if (id == 'news') {
2012-02-18 16:59:18 +00:00
pandora.$ui.news = pandora.ui.news(dialogWidth, dialogHeight).appendTo($content);
2012-02-18 13:58:49 +00:00
} else if (id == 'software') {
2017-08-30 19:20:10 +00:00
var about = '<h1><b>pan.do/ra</b></h1>'
+ '<sub>open media archive</sub>'
+ '<p><b>{0}</b> is based on <b>pan.do/ra</b>, '
+ 'a free, open source platform for media archives.</p>'
+ '<b>pan.do/ra</b> includes <b>OxJS</b>, '
2017-08-30 19:20:28 +00:00
+ 'a JavaScript library for web applications.</p>'
2017-08-30 19:20:10 +00:00
+ '<p>To learn more about <b>pan.do/ra</b> and <b>OxJS</b>, '
+ 'please visit <a href="https://pan.do/ra" target="_blank">pan.do/ra</a> '
+ 'and <a href="https://oxjs.org" target="_blank">oxjs.org</a>.</p>'
+ (
canSeeVersion
? '<sub><b>{0}'
+ '</b> is running <b>pan.do/ra</b> revision '
+ '{1}.</sub>'
: ''
);
if (pandora.site.site.name.toLocaleLowerCase() == 'pan.do/ra') {
about = about
.replace('<b>{0}</b> is based on <b>pan.do/ra</b>, ',
'<b>pan.do/ra</b> is ')
.replace('<b>{0}</b> is running <b>pan.do/ra</b> ',
'This instances runs <b>pan.do/ra</b> ');
}
2011-11-08 13:09:21 +00:00
Ox.Element()
2017-08-30 19:20:10 +00:00
.html(Ox._(about,
[pandora.site.site.name, pandora.site.site.version]
))
2011-11-08 13:09:21 +00:00
.appendTo($content);
2013-03-10 13:32:25 +00:00
pandora.createLinks($content);
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.Editable({
2011-10-27 18:47:52 +00:00
clickLink: pandora.clickLink,
2012-02-18 13:58:49 +00:00
editable: isEditable,
tooltip: isEditable ? pandora.getEditTooltip() : '',
2011-10-27 08:47:57 +00:00
type: 'textarea',
2013-05-09 10:13:58 +00:00
placeholder: isEditable ? Ox._('Doubleclick to insert text') : '',
2012-02-18 13:58:49 +00:00
value: result.data.text
2011-10-27 08:47:57 +00:00
})
.css({
width: '100%'
})
2011-10-27 08:47:57 +00:00
.bindEvent({
submit: function(data) {
Ox.Request.clearCache('getPage');
pandora.api.editPage({
name: id,
2012-02-18 13:58:49 +00:00
text: data.value
2011-10-27 08:47:57 +00:00
});
}
})
.appendTo($content);
2012-06-12 13:43:38 +00:00
});
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>')
.attr({
src: '/static/png/' + (
id == 'software' ? 'software' : 'logo'
) + '.png'
})
.css({
width: '256px',
height: 'auto',
marginTop: id == 'software' ? '-16px' : 0
})
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) {
that.options({
2013-08-03 20:20:42 +00:00
title: Ox.getObjectById(tabs, data.selected).title
2011-08-24 21:21:25 +00:00
});
2011-11-09 22:32:54 +00:00
pandora.UI.set({page: data.selected});
2011-08-24 21:21:25 +00:00
}
});
var that = Ox.Dialog({
2011-11-02 10:22:19 +00:00
buttons: [
Ox.Button({
id: 'close',
2013-05-09 10:13:58 +00:00
title: Ox._('Close')
2011-11-02 10:22:19 +00:00
}).bindEvent({
click: function() {
that.close();
2011-11-02 10:22:19 +00:00
}
})
],
closeButton: true,
2011-11-02 10:22:19 +00:00
content: $tabPanel,
2012-02-18 16:59:18 +00:00
height: dialogHeight,
maximizeButton: true,
2011-11-02 10:22:19 +00:00
minHeight: 256,
minWidth: 688, // 16 + 256 + 16 + 384 + 16
removeOnClose: true,
2013-08-03 20:20:42 +00:00
title: Ox.getObjectById(tabs, section).title,
2012-02-18 13:58:49 +00:00
width: dialogWidth
2011-11-02 10:22:19 +00:00
})
.bindEvent({
2011-11-09 22:32:54 +00:00
close: function(data) {
Ox.getObjectById(tabs, pandora.user.ui.page) && pandora.UI.set({page: ''});
2011-11-09 22:32:54 +00:00
},
2011-11-02 10:22:19 +00:00
resize: function(data) {
2012-02-18 13:58:49 +00:00
var selected = $tabPanel.selected();
dialogHeight = data.height;
dialogWidth = data.width;
2012-02-18 13:58:49 +00:00
if (selected == 'contact') {
pandora.$ui.contactForm.resizeElement();
2012-02-18 13:58:49 +00:00
} else if (selected == 'news') {
pandora.$ui.news.resizeElement(data);
2011-08-24 21:21:25 +00:00
}
2013-08-27 08:44:41 +00:00
},
key_down: function() {
pandora.user.ui.page == 'news' && pandora.$ui.news.selectItem(1);
},
key_up: function() {
pandora.user.ui.page == 'news' && pandora.$ui.news.selectItem(-1);
2011-11-02 10:22:19 +00:00
}
});
2011-08-24 21:21:25 +00:00
that.select = function(id) {
2011-11-09 09:49:59 +00:00
$tabPanel.select(id);
return that;
2011-11-09 09:49:59 +00:00
};
return that;
2011-10-29 17:46:46 +00:00
};