pandora/static/js/pandora/placesDialog.js

100 lines
3.5 KiB
JavaScript
Raw Normal View History

2011-07-29 18:37:11 +00:00
// 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';
2011-05-25 19:42:45 +00:00
pandora.ui.placesDialog = function() {
2011-08-17 11:39:55 +00:00
var height = Math.round((window.innerHeight - 48) * 0.9),
2011-06-02 07:01:29 +00:00
width = Math.round(window.innerWidth * 0.9),
$content = Ox.ListMap({
height: height - 48,
places: function(data, callback) {
return pandora.api.findPlaces(Ox.extend({
query: {conditions: [], operator: ''}
}, data), callback);
},
addPlace: function(place, callback) {
pandora.api.addPlace(place, function(result) {
Ox.Request.clearCache(); // fixme: remove
callback(result);
});
},
editPlace: function(place, callback) {
pandora.api.editPlace(place, function(result) {
Ox.Request.clearCache(); // fixme: remove
callback(result);
});
},
2011-10-30 14:59:54 +00:00
getMatches: function(names, callback) {
// fixme: the results of this are of course
// not identical to actual place matches
2012-01-02 15:29:43 +00:00
var key = pandora.site.layers.filter(function(layer) {
return layer.type == 'place' || layer.hasPlaces;
}).map(function(layer) {
return layer.id;
})[0],
operator = Ox.getObjectById(pandora.site.layers, key).type == 'place' ?
'==' : '=';
2011-10-30 14:59:54 +00:00
pandora.api.findClips({
query: {
conditions: names.map(function(name) {
2012-01-02 15:29:43 +00:00
return {key: key, value: name, operator: operator};
2011-10-30 14:59:54 +00:00
}),
operator: names.length == 1 ? '&' : '|'
}
}, function(result) {
callback(result.data.items);
});
},
removePlace: function(place, callback) {
pandora.api.removePlace(place, function(result) {
Ox.Request.clearCache(); // fixme: remove
callback(result);
});
},
showControls: pandora.user.ui.showMapControls,
showLabels: pandora.user.ui.showMapLabels,
showTypes: true,
width: width
}),
2011-06-19 17:49:25 +00:00
that = Ox.Dialog({
2011-05-25 19:42:45 +00:00
buttons: [
2011-10-11 16:30:06 +00:00
Ox.Button({
id: 'manageEvents',
title: 'Manage Events...'
}).bindEvent({
click: function() {
// ...
}
}),
{},
2011-06-19 17:49:25 +00:00
Ox.Button({
2011-05-25 19:42:45 +00:00
id: 'done',
title: 'Done',
width: 48
2011-05-25 19:42:45 +00:00
}).bindEvent({
click: function() {
that.close();
}
})
],
2011-08-17 11:39:55 +00:00
closeButton: true,
content: $content,
2011-05-25 19:42:45 +00:00
height: height,
2011-08-17 11:39:55 +00:00
maximizeButton: true,
minHeight: 256,
minWidth: 512,
2011-06-02 08:03:41 +00:00
//keys: {enter: 'done', escape: 'done'},
2011-05-25 19:42:45 +00:00
padding: 0,
title: 'Manage Places',
width: width
})
.bindEvent({
resize: function(data) {
// data is {width: ..., height: ...}
$content.options(data);
}
2011-05-25 19:42:45 +00:00
});
return that;
};