2011-04-23 16:45:50 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=js
|
2011-05-16 08:24:46 +00:00
|
|
|
|
|
|
|
/*@
|
|
|
|
Ox.ListMap <f:Ox.Element> ListMap Object
|
|
|
|
() -> <f> ListMap Object
|
|
|
|
(options) -> <f> ListMap Object
|
|
|
|
(options, self) -> <f> ListMap Object
|
|
|
|
options <o> Options object
|
2011-05-16 10:49:48 +00:00
|
|
|
addPlace <f|null>
|
|
|
|
height <n|256>
|
|
|
|
labels <b|false>
|
|
|
|
places <f|null>
|
|
|
|
selected <a|[]>
|
|
|
|
width <n|256>
|
2011-05-16 08:24:46 +00:00
|
|
|
self <o> shared private variable
|
|
|
|
@*/
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
Ox.ListMap = function(options, self) {
|
|
|
|
|
|
|
|
var self = self || {},
|
2011-05-21 17:56:15 +00:00
|
|
|
that = Ox.Element({}, self)
|
2011-04-22 22:03:10 +00:00
|
|
|
.defaults({
|
|
|
|
addPlace: null,
|
|
|
|
height: 256,
|
|
|
|
labels: false,
|
|
|
|
places: null,
|
|
|
|
selected: [],
|
|
|
|
width: 256
|
|
|
|
})
|
|
|
|
.addClass('OxListMap')
|
|
|
|
.options(options || {})
|
|
|
|
.css({
|
|
|
|
width: self.options.width + 'px',
|
|
|
|
height: self.options.height + 'px'
|
|
|
|
});
|
|
|
|
|
|
|
|
self.columns = [
|
|
|
|
{
|
|
|
|
addable: false, // fixme: implement
|
|
|
|
id: 'id',
|
|
|
|
unique: true,
|
|
|
|
visible: false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
format: function(value) {
|
|
|
|
return $('<img>')
|
|
|
|
.attr({
|
2011-04-27 19:24:33 +00:00
|
|
|
// fixme: not the right place to do this
|
|
|
|
src: Ox.PATH + 'Ox.Geo/png/icons/16/' + (value || 'NTHH') + '.png'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '14px',
|
2011-05-22 17:12:21 +00:00
|
|
|
height: '14px',
|
|
|
|
marginLeft: '-3px',
|
|
|
|
marginTop: 0
|
2011-04-27 19:24:33 +00:00
|
|
|
});
|
|
|
|
/*
|
|
|
|
.css({
|
|
|
|
width: '21px',
|
|
|
|
height: '14px'
|
2011-04-22 22:03:10 +00:00
|
|
|
})
|
|
|
|
.load(function() {
|
2011-04-27 19:24:33 +00:00
|
|
|
var $this = $(this);
|
|
|
|
Ox.print($this.width() / $this.height())
|
|
|
|
$this.css({
|
|
|
|
width: Math.round(14 * $this.width() / $this.height()) + 'px',
|
2011-04-22 22:03:10 +00:00
|
|
|
height: '14px',
|
|
|
|
padding: '1px 0 0 1px'
|
2011-04-27 19:24:33 +00:00
|
|
|
});
|
2011-04-22 22:03:10 +00:00
|
|
|
});
|
2011-04-27 19:24:33 +00:00
|
|
|
*/
|
2011-04-22 22:03:10 +00:00
|
|
|
},
|
|
|
|
id: 'countryCode',
|
2011-05-22 17:12:21 +00:00
|
|
|
resizable: false, // fixme: implement
|
|
|
|
title: '<img src="' + Ox.UI.getImagePath('symbolFlag.svg') +
|
|
|
|
'" style="width: 10px; height: 10px; padding: 3px 1px 1px 3px"/>',
|
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
},
|
|
|
|
{
|
|
|
|
editable: true,
|
|
|
|
id: 'name',
|
|
|
|
operator: '+',
|
|
|
|
removable: false,
|
|
|
|
title: 'Name',
|
|
|
|
visible: true,
|
|
|
|
width: 144
|
|
|
|
},
|
2011-05-24 10:44:34 +00:00
|
|
|
{
|
|
|
|
editable: false,
|
|
|
|
format: function(value) {
|
|
|
|
return value.join('; ');
|
|
|
|
},
|
|
|
|
id: 'alternativeNames',
|
|
|
|
removable: false,
|
|
|
|
operator: '+',
|
|
|
|
title: 'Alternative Names',
|
|
|
|
visible: true,
|
|
|
|
width: 144
|
|
|
|
},
|
2011-05-22 17:12:21 +00:00
|
|
|
{
|
|
|
|
editable: true,
|
|
|
|
id: 'geoname',
|
|
|
|
removable: false,
|
2011-05-24 12:50:16 +00:00
|
|
|
map: function(v) {
|
2011-05-22 17:12:21 +00:00
|
|
|
return v.split(', ').reverse().join(', ')
|
|
|
|
},
|
2011-05-24 12:50:16 +00:00
|
|
|
operator: '+',
|
2011-05-22 17:12:21 +00:00
|
|
|
title: 'Geoname',
|
2011-04-22 22:03:10 +00:00
|
|
|
visible: true,
|
2011-05-22 17:12:21 +00:00
|
|
|
width: 192
|
2011-04-22 22:03:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
format: toFixed,
|
2011-05-24 11:43:27 +00:00
|
|
|
id: 'south',
|
2011-04-22 22:03:10 +00:00
|
|
|
operator: '+',
|
2011-05-24 11:43:27 +00:00
|
|
|
title: 'South',
|
|
|
|
visible: false,
|
2011-04-22 22:03:10 +00:00
|
|
|
width: 96
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
2011-05-24 11:43:27 +00:00
|
|
|
id: 'west',
|
2011-04-22 22:03:10 +00:00
|
|
|
operator: '+',
|
2011-05-24 11:43:27 +00:00
|
|
|
title: 'West',
|
|
|
|
visible: false,
|
2011-04-22 22:03:10 +00:00
|
|
|
width: 96
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
format: toFixed,
|
2011-05-24 11:43:27 +00:00
|
|
|
id: 'north',
|
2011-04-22 22:03:10 +00:00
|
|
|
operator: '+',
|
2011-05-24 11:43:27 +00:00
|
|
|
title: 'North',
|
2011-04-22 22:03:10 +00:00
|
|
|
visible: false,
|
|
|
|
width: 96
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
2011-05-24 11:43:27 +00:00
|
|
|
format: toFixed,
|
|
|
|
id: 'east',
|
2011-04-22 22:03:10 +00:00
|
|
|
operator: '+',
|
2011-05-24 11:43:27 +00:00
|
|
|
title: 'East',
|
2011-04-22 22:03:10 +00:00
|
|
|
visible: false,
|
|
|
|
width: 96
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
format: toFixed,
|
2011-05-24 11:43:27 +00:00
|
|
|
id: 'lat',
|
2011-04-22 22:03:10 +00:00
|
|
|
operator: '+',
|
2011-05-24 11:43:27 +00:00
|
|
|
title: 'Latitude',
|
|
|
|
visible: true,
|
2011-04-22 22:03:10 +00:00
|
|
|
width: 96
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
format: toFixed,
|
2011-05-24 11:43:27 +00:00
|
|
|
id: 'lng',
|
2011-04-22 22:03:10 +00:00
|
|
|
operator: '+',
|
2011-05-24 11:43:27 +00:00
|
|
|
title: 'Longitude',
|
|
|
|
visible: true,
|
2011-04-22 22:03:10 +00:00
|
|
|
width: 96
|
|
|
|
},
|
2011-05-24 11:43:27 +00:00
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
format: {type: 'area', args: [0]},
|
|
|
|
id: 'area',
|
|
|
|
operator: '-',
|
|
|
|
title: 'Area',
|
|
|
|
visible: true,
|
|
|
|
width: 128
|
|
|
|
},
|
2011-04-22 22:03:10 +00:00
|
|
|
{
|
|
|
|
id: 'user',
|
|
|
|
operator: '+',
|
|
|
|
title: 'User',
|
|
|
|
visible: false,
|
|
|
|
width: 96
|
|
|
|
},
|
|
|
|
{
|
|
|
|
format: 'date',
|
|
|
|
id: 'created',
|
|
|
|
operator: '-',
|
|
|
|
title: 'Date Created',
|
|
|
|
visible: false,
|
|
|
|
width: 96,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
format: 'date',
|
|
|
|
id: 'modified',
|
|
|
|
operator: '-',
|
|
|
|
title: 'Date Modified',
|
|
|
|
visible: false,
|
|
|
|
width: 96,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
id: 'matches',
|
|
|
|
operator: '-',
|
|
|
|
title: 'Matches',
|
|
|
|
visible: false,
|
|
|
|
width: 96,
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2011-05-21 17:56:15 +00:00
|
|
|
self.$listToolbar = Ox.Bar({
|
2011-04-22 22:03:10 +00:00
|
|
|
size: 24
|
|
|
|
});
|
|
|
|
|
2011-05-21 17:56:15 +00:00
|
|
|
self.$findElement = Ox.FormElementGroup({
|
2011-04-22 22:03:10 +00:00
|
|
|
elements: [
|
2011-05-21 17:56:15 +00:00
|
|
|
self.$findSelect = Ox.Select({
|
2011-04-22 22:03:10 +00:00
|
|
|
items: [
|
|
|
|
{id: 'all', title: 'Find: All'},
|
|
|
|
{id: 'name', title: 'Find: Name'},
|
|
|
|
{id: 'geoname', title: 'Find: Geoname'},
|
|
|
|
{id: 'country', title: 'Find: Country'}
|
|
|
|
],
|
|
|
|
overlap: 'right',
|
|
|
|
width: 128
|
|
|
|
}),
|
2011-05-21 17:56:15 +00:00
|
|
|
self.$findInput = Ox.Input({
|
2011-04-22 22:03:10 +00:00
|
|
|
clear: true,
|
|
|
|
width: 192
|
|
|
|
})
|
|
|
|
]
|
|
|
|
})
|
|
|
|
.css({float: 'right', margin: '4px'})
|
2011-05-21 17:56:15 +00:00
|
|
|
.appendTo(self.$listToolbar)
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2011-05-21 17:56:15 +00:00
|
|
|
self.$list = Ox.TextList({
|
2011-04-22 22:03:10 +00:00
|
|
|
columns: self.columns,
|
|
|
|
columnsRemovable: true,
|
|
|
|
columnsVisible: true,
|
2011-05-24 10:44:34 +00:00
|
|
|
items: Ox.clone(self.options.places),
|
2011-04-22 22:03:10 +00:00
|
|
|
pageLength: 100,
|
|
|
|
scrollbarVisible: true,
|
|
|
|
sort: [
|
|
|
|
{key: 'name', operator: '+'}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
'delete': removeItem,
|
|
|
|
init: initList,
|
2011-05-24 14:51:40 +00:00
|
|
|
// fixme: do we need 0/shift-0? return already zooms to place
|
2011-05-24 14:32:03 +00:00
|
|
|
key_0: function() {
|
|
|
|
self.$map.panToPlace();
|
|
|
|
},
|
|
|
|
key_equal: function() {
|
|
|
|
self.$map.zoom(1);
|
|
|
|
},
|
|
|
|
key_minus: function() {
|
|
|
|
self.$map.zoom(-1);
|
|
|
|
},
|
|
|
|
key_shift_0: function() {
|
|
|
|
self.$map.zoomToPlace();
|
|
|
|
},
|
2011-04-22 22:03:10 +00:00
|
|
|
load: function() {
|
|
|
|
that.triggerEvent('loadlist');
|
|
|
|
},
|
|
|
|
open: openItem,
|
|
|
|
select: selectItem
|
|
|
|
});
|
|
|
|
|
2011-05-21 17:56:15 +00:00
|
|
|
self.$listStatusbar = Ox.Bar({
|
|
|
|
size: 16
|
|
|
|
});
|
|
|
|
|
|
|
|
self.$status = Ox.Element()
|
|
|
|
.css({paddingTop: '2px', margin: 'auto', fontSize: '9px', textAlign: 'center'})
|
|
|
|
.html(self.options.places.length + ' Place' + (self.options.places.length == 1 ? '' : 's'))
|
|
|
|
.appendTo(self.$listStatusbar);
|
|
|
|
|
2011-05-22 17:12:21 +00:00
|
|
|
self.$placeTitlebar = Ox.Bar({
|
2011-05-21 17:56:15 +00:00
|
|
|
size: 24
|
|
|
|
});
|
2011-05-24 06:15:44 +00:00
|
|
|
self.$placeTitle = $('<div>')
|
|
|
|
.hide()
|
|
|
|
.appendTo(self.$placeTitlebar.$element)
|
2011-05-22 17:12:21 +00:00
|
|
|
self.$placeTitleFlag = $('<img>')
|
|
|
|
.addClass('OxFlag')
|
|
|
|
.attr({
|
|
|
|
src: Ox.PATH + 'Ox.Geo/png/icons/16/NTHH.png'
|
|
|
|
})
|
|
|
|
.css({float: 'left', margin: '4px 0 0 4px'})
|
2011-05-24 06:15:44 +00:00
|
|
|
.appendTo(self.$placeTitle);
|
2011-05-22 17:12:21 +00:00
|
|
|
self.$placeTitleName = Ox.Label({
|
|
|
|
title: '',
|
|
|
|
width: 228
|
2011-05-21 17:56:15 +00:00
|
|
|
})
|
|
|
|
.css({float: 'left', margin: '4px'})
|
2011-05-24 06:15:44 +00:00
|
|
|
.appendTo(self.$placeTitle);
|
2011-05-21 17:56:15 +00:00
|
|
|
|
|
|
|
self.$placeFormItems = Ox.merge([
|
|
|
|
Ox.Input({
|
|
|
|
id: 'name',
|
|
|
|
label: 'Name',
|
|
|
|
labelWidth: 64,
|
|
|
|
width: 240
|
2011-05-24 06:15:44 +00:00
|
|
|
}).bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
Ox.getObjectById(self.options.places, self.selectedPlace).name = data.value;
|
|
|
|
self.$list.value(self.selectedPlace, 'name', data.value);
|
|
|
|
self.$map.value(self.selectedPlace, 'name', data.value);
|
|
|
|
}
|
2011-05-21 17:56:15 +00:00
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
id: 'geoname',
|
|
|
|
label: 'Geoname',
|
|
|
|
labelWidth: 64,
|
|
|
|
width: 240
|
2011-05-24 06:15:44 +00:00
|
|
|
}).bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
Ox.getObjectById(self.options.places, self.selectedPlace).geoname = data.value;
|
|
|
|
self.$list.value(self.selectedPlace, 'geoname', data.value);
|
|
|
|
self.$map.value(self.selectedPlace, 'geoname', data.value);
|
|
|
|
self.$placeTitleName.options({
|
|
|
|
title: data.value
|
|
|
|
});
|
|
|
|
}
|
2011-05-21 17:56:15 +00:00
|
|
|
}),
|
|
|
|
Ox.ArrayInput({
|
|
|
|
id: 'alternativeNames',
|
|
|
|
label: 'Alternative Names',
|
|
|
|
max: 10,
|
|
|
|
//sort: true,
|
|
|
|
values: [],
|
|
|
|
width: 240
|
2011-05-24 10:44:34 +00:00
|
|
|
}).bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
Ox.print('CHANGE........', data)
|
|
|
|
}
|
2011-05-21 17:56:15 +00:00
|
|
|
}),
|
2011-05-22 12:39:57 +00:00
|
|
|
], ['South', 'West', 'North', 'East', 'Latitude', 'Longitude'].map(function(v) {
|
|
|
|
var id = (
|
2011-05-21 17:56:15 +00:00
|
|
|
v == 'Latitude' ? 'lat' : v == 'Longitude' ? 'lng' : v
|
|
|
|
).toLowerCase(),
|
|
|
|
max = ['Latitude', 'South', 'North'].indexOf(v) > -1 ? Ox.MAX_LATITUDE : 180;
|
|
|
|
return Ox.Input({
|
|
|
|
decimals: 8,
|
2011-05-22 12:39:57 +00:00
|
|
|
disabled: ['Latitude', 'Longitude'].indexOf(v) > -1,
|
|
|
|
id: id,
|
2011-05-21 17:56:15 +00:00
|
|
|
label: v,
|
|
|
|
labelWidth: 80,
|
|
|
|
min: -max,
|
|
|
|
max: max,
|
|
|
|
type: 'float',
|
|
|
|
width: 240
|
2011-05-24 06:15:44 +00:00
|
|
|
}).bindEvent({
|
|
|
|
focus: function() {
|
|
|
|
Ox.print('---- FOCUS ----')
|
|
|
|
}
|
2011-04-22 22:03:10 +00:00
|
|
|
});
|
2011-05-22 12:39:57 +00:00
|
|
|
}), [
|
2011-05-24 10:44:34 +00:00
|
|
|
self.$areaInput = Ox.Input({
|
2011-05-22 12:39:57 +00:00
|
|
|
disabled: true,
|
2011-05-24 10:44:34 +00:00
|
|
|
id: 'area',
|
|
|
|
label: 'Area',
|
2011-05-22 12:39:57 +00:00
|
|
|
labelWidth: 80,
|
|
|
|
textAlign: 'right',
|
2011-05-24 11:43:27 +00:00
|
|
|
type: 'float',
|
2011-05-22 12:39:57 +00:00
|
|
|
width: 240
|
|
|
|
})
|
|
|
|
]);
|
2011-05-21 17:56:15 +00:00
|
|
|
|
|
|
|
self.$placeForm = Ox.Form({
|
|
|
|
items: self.$placeFormItems,
|
|
|
|
width: 240
|
|
|
|
})
|
2011-05-24 06:15:44 +00:00
|
|
|
.css({margin: '8px'})
|
|
|
|
.hide();
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2011-05-21 17:56:15 +00:00
|
|
|
self.$placeStatusbar = Ox.Bar({
|
2011-05-24 06:15:44 +00:00
|
|
|
size: 24
|
|
|
|
});
|
|
|
|
|
2011-05-24 10:44:34 +00:00
|
|
|
self.$placeButton = Ox.Button({
|
2011-05-24 08:40:17 +00:00
|
|
|
title: 'New Place',
|
|
|
|
width: 96
|
2011-05-24 06:15:44 +00:00
|
|
|
})
|
2011-05-24 10:44:34 +00:00
|
|
|
.css({float: 'left', margin: '4px 2px 4px 4px'})
|
2011-05-24 08:40:17 +00:00
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
2011-05-24 10:44:34 +00:00
|
|
|
var title = self.$placeButton.options('title');
|
|
|
|
if (title == 'New Place') {
|
|
|
|
self.$map.newPlace();
|
|
|
|
self.$placeButton.options({title: 'Add Place'})
|
|
|
|
} else if (title == 'Add Place') {
|
2011-05-24 11:43:27 +00:00
|
|
|
var place = self.$placeForm.values(),
|
|
|
|
country = Ox.getCountryByGeoname(place.geoname);
|
|
|
|
place.countryCode = country ? country.code : '';
|
2011-05-24 10:44:34 +00:00
|
|
|
place.id = self.selectedPlace.substr(1); // fixme: safe?
|
|
|
|
self.options.places.push(place);
|
|
|
|
self.$map.addPlace(place);
|
2011-05-24 11:43:27 +00:00
|
|
|
//self.$placeButton.options({title: 'Please Wait...'})
|
2011-05-24 10:44:34 +00:00
|
|
|
self.$list.options({items: Ox.clone(self.options.places)});
|
|
|
|
self.$list.options({selected: [place.id]});
|
|
|
|
//self.$list.addItem(place);
|
|
|
|
self.$placeButton.options({title: 'Remove Place'})
|
|
|
|
} else if (title == 'Remove Place') {
|
|
|
|
var index = Ox.getPositionById(self.options.places, self.selectedPlace);
|
|
|
|
self.options.places.splice(index, 1);
|
|
|
|
self.$list.options({items: Ox.clone(self.options.places)});
|
|
|
|
self.$map.removePlace();
|
|
|
|
self.$placeButton.options({title: 'Add Place'});
|
|
|
|
}
|
|
|
|
Ox.print('PLACES.LENGTH', self.options.places.length)
|
|
|
|
Ox.print('ITEMS.LENGTH', self.$list.options('items').length)
|
2011-05-24 08:40:17 +00:00
|
|
|
}
|
|
|
|
})
|
2011-05-24 06:15:44 +00:00
|
|
|
.appendTo(self.$placeStatusbar);
|
|
|
|
|
2011-05-24 10:44:34 +00:00
|
|
|
self.$revertButton = Ox.Button({
|
2011-05-24 06:15:44 +00:00
|
|
|
title: 'Revert',
|
2011-05-24 08:40:17 +00:00
|
|
|
width: 96
|
2011-05-24 06:15:44 +00:00
|
|
|
})
|
2011-05-24 10:44:34 +00:00
|
|
|
.css({float: 'right', margin: '4px 4px 4px 2px'})
|
2011-05-24 08:40:17 +00:00
|
|
|
.hide()
|
2011-05-21 17:56:15 +00:00
|
|
|
.appendTo(self.$placeStatusbar);
|
|
|
|
|
|
|
|
/*
|
2011-04-22 22:03:10 +00:00
|
|
|
self.mapResize = [
|
|
|
|
Math.round(self.options.width * 0.25),
|
|
|
|
Math.round(self.options.width * 0.5),
|
|
|
|
Math.round(self.options.width * 0.75)
|
|
|
|
];
|
2011-05-21 17:56:15 +00:00
|
|
|
*/
|
2011-04-22 22:03:10 +00:00
|
|
|
|
|
|
|
if (Ox.isArray(self.options.places)) {
|
|
|
|
init(self.options.places)
|
|
|
|
} else {
|
|
|
|
self.options.places({}, function(result) {
|
|
|
|
Ox.print('$$$$', result.data.items)
|
|
|
|
self.options.places({
|
|
|
|
keys: self.columns.map(function(column) {
|
|
|
|
return column.id
|
|
|
|
}),
|
|
|
|
range: [0, result.data.items]
|
|
|
|
}, function(result) {
|
|
|
|
Ox.print('DATA', result)
|
|
|
|
init(result.data.items);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function init(places) {
|
2011-04-27 07:13:12 +00:00
|
|
|
//Ox.print('PLACES', places)
|
2011-05-21 17:56:15 +00:00
|
|
|
self.$map = Ox.Map({
|
2011-04-22 22:03:10 +00:00
|
|
|
clickable: true,
|
|
|
|
editable: true,
|
|
|
|
findPlaceholder: 'Find on Map',
|
|
|
|
height: self.options.height,
|
|
|
|
places: places,
|
2011-05-24 06:15:44 +00:00
|
|
|
//statusbar: true,
|
2011-04-22 22:03:10 +00:00
|
|
|
toolbar: true,
|
2011-05-21 17:56:15 +00:00
|
|
|
width: self.options.width - 514,//self.mapResize[1],
|
2011-04-22 22:03:10 +00:00
|
|
|
zoombar: true
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
addplace: function(event, data) {
|
|
|
|
that.triggerEvent('addplace', data);
|
|
|
|
},
|
2011-05-22 12:39:57 +00:00
|
|
|
changeplace: function(event, data) {
|
|
|
|
self.$placeForm.values(Ox.map(data, function(val, key) {
|
2011-05-24 10:44:34 +00:00
|
|
|
// fixme: no size key anymore
|
2011-05-22 12:39:57 +00:00
|
|
|
return key == 'size' ? Ox.formatArea(val) : val;
|
2011-05-24 06:15:44 +00:00
|
|
|
})).show();
|
2011-05-22 12:39:57 +00:00
|
|
|
},
|
2011-04-29 14:56:40 +00:00
|
|
|
geocode: function(event, data) {
|
|
|
|
that.triggerEvent('geocode', data);
|
|
|
|
},
|
2011-04-22 22:03:10 +00:00
|
|
|
resize: function() {
|
|
|
|
self.$map.resizeMap(); // fixme: don't need event
|
|
|
|
},
|
|
|
|
selectplace: selectPlace
|
|
|
|
});
|
|
|
|
that.$element.replaceWith(
|
2011-05-21 17:56:15 +00:00
|
|
|
that.$element = Ox.SplitPanel({
|
2011-04-22 22:03:10 +00:00
|
|
|
elements: [
|
|
|
|
{
|
2011-05-21 17:56:15 +00:00
|
|
|
element: Ox.SplitPanel({
|
2011-04-22 22:03:10 +00:00
|
|
|
elements: [
|
|
|
|
{
|
2011-05-21 17:56:15 +00:00
|
|
|
element: self.$listToolbar,
|
2011-04-22 22:03:10 +00:00
|
|
|
size: 24
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: self.$list
|
|
|
|
},
|
|
|
|
{
|
2011-05-21 17:56:15 +00:00
|
|
|
element: self.$listStatusbar,
|
|
|
|
size: 16
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
2011-05-21 17:56:15 +00:00
|
|
|
}),
|
|
|
|
resizable: true,
|
|
|
|
resize: [256, 384, 512],
|
|
|
|
size: 256
|
2011-04-22 22:03:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
element: self.$map,
|
2011-05-21 17:56:15 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
collapsible: true,
|
|
|
|
element: Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
2011-05-22 17:12:21 +00:00
|
|
|
element: self.$placeTitlebar,
|
2011-05-21 17:56:15 +00:00
|
|
|
size: 24
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: self.$placeForm
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: self.$placeStatusbar,
|
2011-05-24 06:15:44 +00:00
|
|
|
size: 24
|
2011-05-21 17:56:15 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
2011-05-22 12:39:57 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resize: function(foo, size) {
|
2011-05-22 17:12:21 +00:00
|
|
|
self.$placeTitleName.options({width: size - 28});
|
|
|
|
// fixme: pass width through form
|
2011-05-22 12:39:57 +00:00
|
|
|
self.$placeFormItems.forEach(function($item) {
|
|
|
|
$item.options({width: size - 16});
|
|
|
|
});
|
|
|
|
}
|
2011-05-21 17:56:15 +00:00
|
|
|
}),
|
2011-05-22 12:39:57 +00:00
|
|
|
resizable: true,
|
2011-05-24 10:44:34 +00:00
|
|
|
resize: [204, 256, 384],
|
2011-05-21 17:56:15 +00:00
|
|
|
size: 256
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'horizontal'
|
|
|
|
}).$element
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function initList(event, data) {
|
|
|
|
self.$status.html(data.items + ' place' + (data.items == 1 ? '' : 's'))
|
|
|
|
}
|
|
|
|
|
|
|
|
function openItem(event, data) {
|
|
|
|
selectItem(event, data);
|
|
|
|
self.$map.zoomToPlace(data.ids[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeItem(event, data) {
|
|
|
|
var id = data.ids[0];
|
|
|
|
that.triggerEvent('removeplace', {id: id});
|
|
|
|
self.$map.removePlace(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectItem(event, data) {
|
|
|
|
Ox.print('selectItem', data.ids[0])
|
|
|
|
var id = data.ids.length ? data.ids[0] : null;
|
|
|
|
self.$map.options({selected: id});
|
|
|
|
id && self.$map.panToPlace();
|
|
|
|
}
|
|
|
|
|
2011-05-22 17:12:21 +00:00
|
|
|
function selectPlace(place) {
|
|
|
|
var country = place.id ? Ox.getCountryByGeoname(place.geoname) : '',
|
|
|
|
code = country ? country.code : 'NTHH';
|
2011-05-24 06:15:44 +00:00
|
|
|
if (place.id) {
|
2011-05-24 08:40:17 +00:00
|
|
|
isResult = place.id[0] == '_';
|
2011-05-24 06:15:44 +00:00
|
|
|
self.selectedPlace = place.id;
|
|
|
|
place.id[0] != '_' && self.$list.options({
|
|
|
|
selected: place.id ? [place.id] : []
|
|
|
|
});
|
|
|
|
self.$placeTitleFlag.attr({
|
|
|
|
src: Ox.PATH + 'Ox.Geo/png/icons/16/' + code + '.png'
|
|
|
|
});
|
|
|
|
self.$placeTitleName.options({title: place.geoname || ''});
|
|
|
|
self.$placeTitle.show();
|
2011-05-24 10:44:34 +00:00
|
|
|
Ox.print('>>>>', place)
|
2011-05-24 06:15:44 +00:00
|
|
|
self.$placeForm.values(Ox.map(place, function(val, key) {
|
|
|
|
return key == 'size' ? Ox.formatArea(val) : val;
|
|
|
|
})).show();
|
2011-05-24 10:44:34 +00:00
|
|
|
self.$placeButton.options({title: isResult ? 'Add Place' : 'Remove Place'});
|
|
|
|
self.$revertButton.options({disabled: true}).show();
|
2011-05-24 06:15:44 +00:00
|
|
|
} else {
|
|
|
|
self.selectedPlace = null;
|
|
|
|
self.$placeTitle.hide();
|
|
|
|
self.$placeForm.hide();
|
2011-05-24 10:44:34 +00:00
|
|
|
self.$placeButton.options({title: 'New Place'});
|
|
|
|
self.$revertButton.hide();
|
2011-05-24 06:15:44 +00:00
|
|
|
}
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function toFixed(val) {
|
2011-05-24 10:44:34 +00:00
|
|
|
return Ox.isNumber(val) ? val.toFixed(8) : val; // fixme: why can a string be passed ??
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
|
2011-05-16 10:49:48 +00:00
|
|
|
/*@
|
|
|
|
setOption <f> setOption
|
|
|
|
@*/
|
2011-04-29 12:40:51 +00:00
|
|
|
self.setOption = function(key, value) {
|
2011-04-22 22:03:10 +00:00
|
|
|
Ox.print('ONCHANGE')
|
|
|
|
if (key == 'height' || key == 'width') {
|
|
|
|
Ox.print('ONCHANGE...')
|
|
|
|
self.$map.options({
|
|
|
|
height: self.options.height,
|
|
|
|
width: self.options.width
|
|
|
|
})
|
|
|
|
} else if (key == 'selected') {
|
|
|
|
self.$list.options({selected: value});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-16 10:49:48 +00:00
|
|
|
/*@
|
|
|
|
focusList <f> focusList
|
|
|
|
@*/
|
2011-04-22 22:03:10 +00:00
|
|
|
that.focusList = function() {
|
|
|
|
self.$list.gainFocus();
|
|
|
|
return that;
|
|
|
|
}
|
|
|
|
|
2011-05-16 10:49:48 +00:00
|
|
|
/*@
|
|
|
|
reloadList <f> reloadList
|
|
|
|
@*/
|
2011-04-22 22:03:10 +00:00
|
|
|
that.reloadList = function() {
|
|
|
|
self.$list.reloadList();
|
|
|
|
return that;
|
|
|
|
}
|
|
|
|
|
2011-05-16 10:49:48 +00:00
|
|
|
/*@
|
|
|
|
resizeMap <f> resizeMap
|
|
|
|
@*/
|
2011-04-22 22:03:10 +00:00
|
|
|
that.resizeMap = function() {
|
|
|
|
Ox.print('Ox.ListMap.resizeMap()')
|
|
|
|
self.$map.resizeMap();
|
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|