cablegates/static/js/pandora/ui/placesDialog.js

68 lines
2.7 KiB
JavaScript
Raw Normal View History

2011-05-25 19:42:45 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=js
pandora.ui.placesDialog = function() {
var height = Math.round(document.height * 0.8),
width = Math.round(document.width * 0.8),
that = new Ox.Dialog({
buttons: [
new Ox.Button({
id: 'done',
title: 'Done'
}).bindEvent({
click: function() {
that.close();
}
})
],
content: app.$ui.placesElement = new Ox.ListMap({
height: height - 48,
places: function(data, callback) {
return pandora.api.findPlaces($.extend(data, {
query: {conditions: [], operator: ''}
}), callback);
},
width: width
})
.bindEvent({
addplace: function(event, data) {
Ox.print('ADDPLACE', data)
pandora.api.addPlace(data.place, function(result) {
var id = result.data.id;
Ox.print("ID", result.data.id, result)
Ox.Request.clearCache(); // fixme: remove
Ox.print('AAAAA')
app.$ui.placesElement
.reloadList()
.bindEventOnce({
loadlist: function() {
app.$ui.placesElement
.focusList()
.options({selected: [id]});
}
});
});
},
removeplace: function(event, data) {
pandora.api.removePlace(data.id, function(result) {
// fixme: duplicated
Ox.Request.clearCache(); // fixme: remove
app.$ui.placesElement
.reloadList()
.bindEventOnce({
loadlist: function(event, data) {
app.$ui.placesElement
.focusList();
}
});
});
}
}),
height: height,
keys: {enter: 'done', escape: 'done'},
padding: 0,
title: 'Manage Places',
width: width
});
return that;
};