update video editor (maps)

This commit is contained in:
rlx 2012-01-16 19:32:30 +05:30
parent 408ebf54cb
commit f5d587cf5b
5 changed files with 81 additions and 44 deletions

View file

@ -1370,6 +1370,7 @@ Maps
top: 0; top: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
overflow: hidden;
} }
.OxMap > * { .OxMap > * {
position: absolute; position: absolute;
@ -1383,6 +1384,7 @@ Maps
.OxMap .OxPlaceControl { .OxMap .OxPlaceControl {
position: absolute; position: absolute;
border-width: 2px; border-width: 2px;
z-index: 1;
} }
.OxMap .OxMapControl.OxButton, .OxMap .OxMapControl.OxButton,
.OxMap .OxPlaceControl.OxButton { .OxMap .OxPlaceControl.OxButton {

View file

@ -61,7 +61,6 @@ Ox.ArrayEditable = function(options, self) {
Ox.print('BLURRED EDITING', self.blurred, self.editing) Ox.print('BLURRED EDITING', self.blurred, self.editing)
if ($parent.is('.OxEditableElement')) { if ($parent.is('.OxEditableElement')) {
// select another item // select another item
Ox.print('AAAAA')
selectItem( selectItem(
e.metaKey && position == self.selected e.metaKey && position == self.selected
? '' : $parent.data('position') ? '' : $parent.data('position')
@ -198,21 +197,27 @@ Ox.ArrayEditable = function(options, self) {
} }
function selectItem(idOrPosition) { function selectItem(idOrPosition) {
if (Ox.isString(idOrPosition)) { var isId = Ox.isString(idOrPosition);
self.options.selected = idOrPosition; if (
self.selected = getSelectedPosition(); (isId && idOrPosition != self.options.selected)
} else { || (!isId && idOrPosition != self.selected)
self.selected = idOrPosition; ) {
self.options.selected = getSelectedId(); if (isId) {
self.options.selected = idOrPosition;
self.selected = getSelectedPosition();
} else {
self.selected = idOrPosition;
self.options.selected = getSelectedId();
}
if (/*self.options.selected == '' && */self.editing) {
self.editing = false;
that.blurItem();
}
Ox.print('SELECT ITEM', self.options.selected, self.selected);
that.find('.OxSelected').removeClass('OxSelected');
self.selected > -1 && self.$items[self.selected].addClass('OxSelected');
triggerSelectEvent();
} }
if (/*self.options.selected == '' && */self.editing) {
self.editing = false;
that.blurItem();
}
Ox.print('SELECT ITEM', self.options.selected, self.selected);
that.find('.OxSelected').removeClass('OxSelected');
self.selected > -1 && self.$items[self.selected].addClass('OxSelected');
triggerSelectEvent();
} }
function selectLast() { function selectLast() {
@ -269,6 +274,9 @@ Ox.ArrayEditable = function(options, self) {
self.setOption = function(key, value) { self.setOption = function(key, value) {
if (key == 'items') { if (key == 'items') {
if (self.options.selected && getSelectedPosition() == -1) {
selectNone();
}
renderItems(true); renderItems(true);
} else if (key == 'selected') { } else if (key == 'selected') {
selectItem(value); selectItem(value);

View file

@ -114,7 +114,7 @@ Ox.Input = function(options, self) {
height: self.options.height + 'px' height: self.options.height + 'px'
} : {}) } : {})
) )
.bindEvent(Ox.extend(self.options.type == 'input' ? { .bindEvent(Ox.extend(self.options.type != 'textarea' ? {
key_enter: submit key_enter: submit
} : {}, { } : {}, {
key_control_v: paste, key_control_v: paste,

View file

@ -458,6 +458,23 @@ Ox.Map = function(options, self) {
); );
} }
function addPlaces() {
Ox.forEach(self.$placeControls, function($placeControl) {
$placeControl.hide();
});
self.places && self.places.forEach(function(place) {
place.remove();
});
self.places = [];
if (!self.isAsync) {
self.options.places.forEach(function(place) {
self.places.push(new Ox.MapPlace(Ox.extend({
map: that
}, place)));
});
}
}
function addPlaceToMap(place) { function addPlaceToMap(place) {
// via find, click, shift-click, or new place button // via find, click, shift-click, or new place button
Ox.Log('Map', 'addPlaceToMap', place) Ox.Log('Map', 'addPlaceToMap', place)
@ -790,6 +807,7 @@ Ox.Map = function(options, self) {
disableDefaultUI: true, disableDefaultUI: true,
disableDoubleClickZoom: true, disableDoubleClickZoom: true,
mapTypeId: google.maps.MapTypeId[getMapType()], mapTypeId: google.maps.MapTypeId[getMapType()],
noClear: true,
zoom: self.zoom zoom: self.zoom
}); });
google.maps.event.addListener(self.map, 'bounds_changed', boundsChanged); google.maps.event.addListener(self.map, 'bounds_changed', boundsChanged);
@ -798,6 +816,7 @@ Ox.Map = function(options, self) {
google.maps.event.addListener(self.map, 'idle', mapChanged); google.maps.event.addListener(self.map, 'idle', mapChanged);
google.maps.event.addListener(self.map, 'zoom_changed', zoomChanged); google.maps.event.addListener(self.map, 'zoom_changed', zoomChanged);
google.maps.event.addListenerOnce(self.map, 'tilesloaded', tilesLoaded); google.maps.event.addListenerOnce(self.map, 'tilesloaded', tilesLoaded);
google.maps.event.trigger(self.map, 'resize');
// needed to get mouse x/y coordinates on marker mouseover, // needed to get mouse x/y coordinates on marker mouseover,
// see http://code.google.com/p/gmaps-api-issues/issues/detail?id=2342 // see http://code.google.com/p/gmaps-api-issues/issues/detail?id=2342
@ -811,16 +830,27 @@ Ox.Map = function(options, self) {
} }
that.overlayView.draw(); that.overlayView.draw();
addPlaces();
Ox.forEach(self.$controls, function($control) {
$control.appendTo(self.$map);
});
Ox.forEach(self.$placeControls, function($placeControl) {
$placeControl.appendTo(self.$map);
});
if (self.options.find) { if (self.options.find) {
self.$findInput.value(self.options.find) self.$findInput.value(self.options.find)
.triggerEvent('submit', {value: self.options.find}); .triggerEvent('submit', {value: self.options.find});
} else if (self.options.selected) {
selectPlace(self.options.selected, true);
} else { } else {
if (self.options.selected) {
selectPlace(self.options.selected, true);
}
if (mapBounds) { if (mapBounds) {
if (isEmpty(mapBounds)) { if (isEmpty(mapBounds)) {
self.map.setZoom(self.minZoom); self.map.setZoom(self.minZoom);
} else { } else {
Ox.print("FITTING BOUNDS")
self.map.fitBounds(mapBounds); self.map.fitBounds(mapBounds);
} }
} }
@ -830,32 +860,16 @@ Ox.Map = function(options, self) {
} }
updateFormElements(); updateFormElements();
// fixme: this is just guessing
// setTimeout(updateFormElements, 2500);
self.places = [];
if (!self.isAsync) {
self.options.places.forEach(function(place) {
self.places.push(new Ox.MapPlace(Ox.extend({
map: that
}, place)));
});
}
google.maps.event.trigger(self.map, 'resize');
//that.gainFocus(); //that.gainFocus();
self.loaded = true;
that.triggerEvent('load'); that.triggerEvent('load');
function tilesLoaded() {
setTimeout(formatTerms, 250);
}
}); });
function tilesLoaded() {
// fixme: can add earlier, use don't replace map contents option
Ox.forEach(self.$controls, function($control) {
$control.appendTo(self.$map);
});
Ox.forEach(self.$placeControls, function($placeControl) {
$placeControl.appendTo(self.$map);
});
}
} }
function isEmpty(bounds) { function isEmpty(bounds) {
@ -1101,6 +1115,7 @@ Ox.Map = function(options, self) {
} }
} }
// fixme: removePlacefromMap?
function removePlace() { function removePlace() {
var place = getSelectedPlace(); var place = getSelectedPlace();
place.id = '_' + place.id; place.id = '_' + place.id;
@ -1369,12 +1384,21 @@ Ox.Map = function(options, self) {
that.$element.css(key, value + 'px'); that.$element.css(key, value + 'px');
that.resizeMap(); that.resizeMap();
} else if (key == 'places') { } else if (key == 'places') {
// fixme: assumes !self.isAsync
Ox.print('MAP SET OPTIONS PLACES', value); Ox.print('MAP SET OPTIONS PLACES', value);
addPlaces();
getMapBounds(function(mapBounds) { getMapBounds(function(mapBounds) {
self.map.fitBounds(mapBounds); self.map.fitBounds(mapBounds);
}); });
if (self.options.selected) {
if (getSelectedPlace()) {
selectPlace(self.options.selected);
} else {
self.options.selected = '';
}
}
} else if (key == 'selected') { } else if (key == 'selected') {
selectPlace(value || null); self.loaded && selectPlace(value || null);
} else if (key == 'type') { } else if (key == 'type') {
} }

View file

@ -246,14 +246,13 @@ Ox.AnnotationFolder = function(options, self) {
} }
self.$resizebar.css({top: self.options.widgetSize + 'px'}); self.$resizebar.css({top: self.options.widgetSize + 'px'});
self.$inner.css({height: self.options.widgetSize + 'px'}); self.$inner.css({height: self.options.widgetSize + 'px'});
self.$widget.css({ self.$widget.options({height: self.options.widgetSize});
height: self.options.widgetSize + 'px'
});
} }
//self.options.type == 'place' && self.$map.resizeMap(); //self.options.type == 'place' && self.$map.resizeMap();
} }
function dragend(e) { function dragend(e) {
//self.options.type == 'place' && self.$map.resizeMap();
if (self.options.showWidget) { if (self.options.showWidget) {
that.triggerEvent('resizewidget', {size: self.options.widgetSize}); that.triggerEvent('resizewidget', {size: self.options.widgetSize});
} }
@ -404,11 +403,13 @@ Ox.AnnotationFolder = function(options, self) {
} }
} else if (key == 'position') { } else if (key == 'position') {
if (self.options.range == 'position') { if (self.options.range == 'position') {
Ox.print('POSITION CHANGED, UPDATING')
self.widget && updateWidget(); self.widget && updateWidget();
updateAnnotations(); updateAnnotations();
} }
} else if (key == 'range') { } else if (key == 'range') {
self.$annotations.options({items: getAnnotations()}); self.widget && updateWidget();
updateAnnotations();
} else if (key == 'selected') { } else if (key == 'selected') {
if (value === '') { if (value === '') {
self.editing = false; self.editing = false;
@ -450,11 +451,13 @@ Ox.AnnotationFolder = function(options, self) {
}; };
that.blurItem = function() { that.blurItem = function() {
self.editing = false;
self.$annotations.blurItem(); self.$annotations.blurItem();
return that; return that;
}; };
that.editItem = function() { that.editItem = function() {
self.editing = true;
self.$annotations.editItem(); self.$annotations.editItem();
return that; return that;
}; };