pandora/static/js/pandora/eventsDialog.js

108 lines
3.7 KiB
JavaScript
Raw Normal View History

// vim: et:ts=4:sw=4:sts=4:ft=javascript
2011-10-03 16:38:07 +00:00
2011-11-05 17:04:10 +00:00
'use strict';
pandora.ui.eventsDialog = function(options) {
// options can be {id: '...'} or {name: '...'}
var height = Math.round((window.innerHeight - 48) * 0.9),
width = Math.round(window.innerWidth * 0.9),
that = Ox.Dialog({
buttons: [
2011-10-11 16:30:06 +00:00
Ox.Button({
id: 'managePlaces',
title: 'Manage Places...'
}).bindEvent({
click: function() {
// ...
}
}),
{},
Ox.Button({
id: 'done',
title: 'Done',
width: 48
}).bindEvent({
click: function() {
that.close();
}
})
],
closeButton: true,
content: Ox.Element().append(
$('<img>')
.attr({src: Ox.UI.getImageURL('symbolLoadingAnimated')})
.css({
position: 'absolute',
width: '32px',
height: '32px',
left: 0,
top: 0,
right: 0,
bottom: 0,
margin: 'auto'
})
),
height: height,
maximizeButton: true,
minHeight: 256,
minWidth: 512,
padding: 0,
title: 'Manage Events',
width: width
})
.bindEvent({
resize: function(data) {
// setting width would cause an expensive calendar redraw
$content && $content.options({height: data.height});
},
resizeend: function(data) {
$content && $content.options({height: data.height, width: data.width});
}
}),
$content;
2011-10-03 16:38:07 +00:00
pandora.api.findEvents({
2011-10-29 17:46:46 +00:00
query: {conditions: [], operator: '&'}
2011-10-03 16:38:07 +00:00
}, function(result) {
pandora.api.findEvents({
query: {conditions: [], operator: '&'},
keys: [],
range: [0, result.data.items],
sort: [{key: 'name', operator: '+'}]
}, function(result) {
that.options({
content: $content = Ox.ListCalendar({
2011-10-09 21:12:50 +00:00
addEvent: function(event, callback) {
pandora.api.addEvent(event, function(result) {
Ox.Request.clearCache(); // fixme: remove
callback(result);
});
},
editEvent: function(event, callback) {
pandora.api.editEvent(event, function(result) {
Ox.Request.clearCache(); // fixme: remove
callback(result);
});
},
2011-10-03 16:38:07 +00:00
events: result.data.items,
2012-02-20 18:31:26 +00:00
hasMatches: true,
height: height,
2012-02-20 18:31:26 +00:00
mode: pandora.site.calendar == 'auto' ? 'add' : 'define',
2011-10-09 21:12:50 +00:00
removeEvent: function(event, callback) {
pandora.api.removeEvent(event, function(result) {
Ox.Request.clearCache(); // fixme: remove
callback(result);
});
},
selected: options ? options.id : '',
showControls: pandora.user.ui.showCalendarControls,
2011-10-03 16:38:07 +00:00
width: width
})
});
})
})
return that;
};