move 0xdb siteDialog special case into siteDialog.0xdb.js, fixes #767

This commit is contained in:
j 2012-06-11 10:17:15 +02:00
parent 8d637a33f0
commit ef3c63badc
2 changed files with 167 additions and 36 deletions

View file

@ -0,0 +1,166 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict';
pandora.ui.siteDialog = function(section) {
var dialogHeight = Math.round((window.innerHeight - 48) * 0.75),
dialogWidth = Math.round(window.innerWidth * 0.75),
isEditable = pandora.site.capabilities.canEditSitePages[pandora.user.level],
tabs = pandora.site.sitePages.concat([{id: 'software', title: 'Software'}]);
Ox.getObjectById(tabs, section).selected = true;
var $tabPanel = Ox.TabPanel({
content: function(id) {
var $content = Ox.Element().css({padding: '16px', overflowY: 'auto'});
if (id == 'contact') {
pandora.$ui.contactForm = pandora.ui.contactForm().appendTo($content);
} else if (id == 'news') {
pandora.$ui.news = pandora.ui.news(dialogWidth, dialogHeight).appendTo($content);
} else if (id == 'software') {
Ox.Element()
.html(
'<h1><b>pan.do/ra</b></h1>'
+ '<sub>open media archive</sub>'
+ '<p><b>' + pandora.site.site.name + '</b> is based on <b>pan.do/ra</b>, '
+ 'a free open source framework for media archives.</p>'
+ '<b>pan.do/ra</b> includes <b>OxJS</b>, '
+ 'a new JavaScript library for web applications.</p>'
+ 'Both <a href="https://pan.do/ra"><b>pan.do/ra</b></a> '
+ 'and <a href="https://oxjs.org"><b>OxJS</b></a> '
+ 'will be released in 2012. More soon...'
)
.appendTo($content);
} else {
pandora.api.getPage({name: id}, function(result) {
var $right, risk;
Ox.Editable({
clickLink: pandora.clickLink,
editable: isEditable,
tooltip: isEditable ? 'Doubleclick to edit' : '',
type: 'textarea',
placeholder: isEditable ? 'Doubleclick to insert text' : '',
value: result.data.text
})
.css(id == 'rights' ? {
// this will get applied twice,
// total is 144px
marginRight: '72px'
} : {
width: '100%'
})
.bindEvent({
submit: function(data) {
Ox.Request.clearCache('getPage');
pandora.api.editPage({
name: id,
text: data.value
});
}
})
.appendTo($content);
if (id == 'rights') {
$right = $('<div>')
.css({position: 'absolute', top: '16px', right: '16px', width: '128px'})
.appendTo($content);
$('<img>')
.attr({src: '/static/png/rights.png'})
.css({width: '128px', height: '128px', marginBottom: '8px'})
.appendTo($right);
risk = ['Unknown', 'Severe', 'High', 'Significant', 'General', 'Low'];
[].concat(
['Unknown'],
pandora.site.rightsLevels.map(function(rightsLevel) {
return rightsLevel.name;
}).reverse()
).forEach(function(name, i) {
Ox.Theme.formatColor(330 + 30 * i, 'gradient')
.css({
padding: '4px',
marginTop: '8px'
})
.html(
'<b>' + name + '</b><br/><div style="padding-top: 2px; font-size: 9px; opacity: 0.75">'
+ risk[i] + ' Risk'
+ (risk[i].length > 6 ? '<br/> of ' : ' of<br/>')
+ 'Legal Action</div>'
)
.appendTo($right);
});
}
});
}
return Ox.SplitPanel({
elements: [
{
element: Ox.Element()
.css({padding: '16px'})
.append(
$('<img>')
.attr({src: '/static/png/' + (
id == 'software' ? 'software' : 'logo'
) + '.png'})
.css({width: '256px'})
),
size: 272
},
{
element: $content
}
],
orientation: 'horizontal'
});
},
tabs: tabs
})
.bindEvent({
change: function(data) {
that.options({
title: Ox.getObjectById(tabs, data.selected).title
});
pandora.UI.set({page: data.selected});
}
});
var that = Ox.Dialog({
buttons: [
Ox.Button({
id: 'close',
title: 'Close'
}).bindEvent({
click: function() {
that.close();
}
})
],
closeButton: true,
content: $tabPanel,
height: dialogHeight,
maximizeButton: true,
minHeight: 256,
minWidth: 688, // 16 + 256 + 16 + 384 + 16
removeOnClose: true,
title: Ox.getObjectById(tabs, section).title,
width: dialogWidth
})
.bindEvent({
close: function(data) {
pandora.UI.set({page: ''});
},
resize: function(data) {
var selected = $tabPanel.selected();
if (selected == 'contact') {
pandora.$ui.contactForm.resize();
} else if (selected == 'news') {
pandora.$ui.news.resize(data);
}
}
});
that.select = function(id) {
$tabPanel.select(id);
return that;
};
return that;
};

View file

@ -32,7 +32,6 @@ pandora.ui.siteDialog = function(section) {
.appendTo($content); .appendTo($content);
} else { } else {
pandora.api.getPage({name: id}, function(result) { pandora.api.getPage({name: id}, function(result) {
var $right, risk;
Ox.Editable({ Ox.Editable({
clickLink: pandora.clickLink, clickLink: pandora.clickLink,
editable: isEditable, editable: isEditable,
@ -41,11 +40,7 @@ pandora.ui.siteDialog = function(section) {
placeholder: isEditable ? 'Doubleclick to insert text' : '', placeholder: isEditable ? 'Doubleclick to insert text' : '',
value: result.data.text value: result.data.text
}) })
.css(id == 'rights' ? { .css({
// this will get applied twice,
// total is 144px
marginRight: '72px'
} : {
width: '100%' width: '100%'
}) })
.bindEvent({ .bindEvent({
@ -58,36 +53,6 @@ pandora.ui.siteDialog = function(section) {
} }
}) })
.appendTo($content); .appendTo($content);
if (id == 'rights') {
$right = $('<div>')
.css({position: 'absolute', top: '16px', right: '16px', width: '128px'})
.appendTo($content);
$('<img>')
.attr({src: '/static/png/rights.png'})
.css({width: '128px', height: '128px', marginBottom: '8px'})
.appendTo($right);
risk = ['Unknown', 'Severe', 'High', 'Significant', 'General', 'Low'];
[].concat(
['Unknown'],
pandora.site.rightsLevels.map(function(rightsLevel) {
return rightsLevel.name;
}).reverse()
).forEach(function(name, i) {
Ox.Theme.formatColor(330 + 30 * i, 'gradient')
.css({
padding: '4px',
marginTop: '8px'
})
.html(
'<b>' + name + '</b><br/><div style="padding-top: 2px; font-size: 9px; opacity: 0.75">'
+ risk[i] + ' Risk'
+ (risk[i].length > 6 ? '<br/> of ' : ' of<br/>')
+ 'Legal Action</div>'
)
.appendTo($right);
});
}
});
} }
return Ox.SplitPanel({ return Ox.SplitPanel({
elements: [ elements: [