forked from 0x2620/oxjs
fix event handlers and split panel resize event
This commit is contained in:
parent
3f90e96c3a
commit
da9e5dbb29
27 changed files with 722 additions and 118 deletions
|
|
@ -183,15 +183,15 @@ Ox.Resizebar = function(options, self) {
|
|||
}
|
||||
|
||||
function triggerEvents(event) {
|
||||
self.options.elements[0].triggerEvent(event,
|
||||
self.isLeftOrTop ?
|
||||
self.options.size :
|
||||
self.options.elements[0][self.dimensions[1]]()
|
||||
);
|
||||
self.options.elements[1].triggerEvent(event,
|
||||
self.isLeftOrTop ?
|
||||
self.options.elements[1][self.dimensions[1]]() :
|
||||
self.options.size
|
||||
self.options.elements[0].triggerEvent(event, {
|
||||
size: self.isLeftOrTop
|
||||
? self.options.size
|
||||
: self.options.elements[0][self.dimensions[1]]()
|
||||
});
|
||||
self.options.elements[1].triggerEvent(event, {
|
||||
size: self.isLeftOrTop
|
||||
? self.options.elements[1][self.dimensions[1]]()
|
||||
: self.options.size
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ Ox.Calendar = function(options, self) {
|
|||
|
||||
}
|
||||
|
||||
function changeZoom(event, data) {
|
||||
function changeZoom(data) {
|
||||
self.options.zoom = data.value;
|
||||
renderCalendar();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,11 +101,10 @@ Ox.Element = function(options, self) {
|
|||
|
||||
function bind(action, event, fn) {
|
||||
self.$eventHandler[action]('ox_' + event, function(event, data) {
|
||||
// fixme: remove second parameter (legacy)
|
||||
fn(Ox.extend({
|
||||
_element: that.$element,
|
||||
_event: event
|
||||
}, data), data);
|
||||
}, data));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Ox.ColorInput = function(options, self) {
|
|||
self.$inputs[4] = Ox.ColorPicker({
|
||||
id: 'picker'
|
||||
})
|
||||
.bindEvent('change', function(event, data) {
|
||||
.bindEvent('change', function(data) {
|
||||
//Ox.print('change function called');
|
||||
self.options.value = data.value;
|
||||
self.values = data.value.split(', ');
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ Ox.ColorPicker = function(options, self) {
|
|||
position: 'absolute',
|
||||
top: (i * 15) + 'px'
|
||||
})
|
||||
.bindEvent('change', function(event, data) {
|
||||
.bindEvent('change', function(data) {
|
||||
change(i, data.value);
|
||||
})
|
||||
.appendTo(that);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ Ox.DateInput = function(options, self) {
|
|||
})
|
||||
.bindEvent('autocomplete', changeMonthOrYear),
|
||||
year: Ox.Input({
|
||||
autocomplete: $.map($.merge(Ox.range(1900, 3000), Ox.range(1000, 1900)), function(v, i) {
|
||||
autocomplete: Ox.merge(Ox.range(1900, 3000), Ox.range(1000, 1900)).map(function(v) {
|
||||
return v.toString();
|
||||
}),
|
||||
autocompleteReplace: true,
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ Ox.Filter = function(options, self) {
|
|||
}
|
||||
}
|
||||
|
||||
function changeOperator(event, data) {
|
||||
function changeOperator(data) {
|
||||
self.options.query.operator = data.selected[0].id;
|
||||
that.$element.find('.OxGroupLabel').html(self.options.query.operator == '&' ? 'and' : 'or');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Ox.Form = function(options, self) {
|
|||
that.append(self.$items[i] = Ox.FormItem({element: item}));
|
||||
item.bindEvent({
|
||||
/*
|
||||
blur: function(event, data) {
|
||||
blur: function(data) {
|
||||
validate(i, data.valid);
|
||||
if (data.valid) {
|
||||
self.$messages[i].html('').hide();
|
||||
|
|
@ -50,15 +50,15 @@ Ox.Form = function(options, self) {
|
|||
}
|
||||
},
|
||||
*/
|
||||
autovalidate: function(event, data) {
|
||||
autovalidate: function(data) {
|
||||
data.valid = !!data.value.length;
|
||||
validate(i, data.valid);
|
||||
data.valid && self.$items[i].setMessage('');
|
||||
},
|
||||
submit: function(event, data) {
|
||||
submit: function(data) {
|
||||
self.formIsValid && that.submit();
|
||||
},
|
||||
validate: function(event, data) {
|
||||
validate: function(data) {
|
||||
validate(i, data.valid);
|
||||
self.$items[i].setMessage(data.valid ? '' : data.message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ Ox.FormElementGroup = function(options, self) {
|
|||
float: self.options.float // fixme: make this a class
|
||||
})
|
||||
.bindEvent({
|
||||
validate: function(event, data) {
|
||||
validate: function(data) {
|
||||
that.triggerEvent({
|
||||
validate: data
|
||||
});
|
||||
|
|
|
|||
|
|
@ -616,7 +616,7 @@ Ox.Input = function(options, self) {
|
|||
self.$input.val(self.options.value);//.focus();
|
||||
}
|
||||
|
||||
function clickMenu(event, data) {
|
||||
function clickMenu(data) {
|
||||
//Ox.print('clickMenu', data);
|
||||
self.options.value = data.title;
|
||||
self.$input.val(self.options.value).focus();
|
||||
|
|
@ -724,7 +724,7 @@ Ox.Input = function(options, self) {
|
|||
data.text && self.$input.val(data.text);
|
||||
}
|
||||
|
||||
function selectMenu(event, data) {
|
||||
function selectMenu(data) {
|
||||
var pos = cursor();
|
||||
//if (self.options.value) {
|
||||
//Ox.print('selectMenu', pos, data.title)
|
||||
|
|
@ -1242,7 +1242,7 @@ Ox.Input_ = function(options, self) {
|
|||
|
||||
//width(self.options.width);
|
||||
|
||||
function changeKey(event, data) {
|
||||
function changeKey(data) {
|
||||
//Ox.print('changeKey', data);
|
||||
if (data) { // fixme: necessary?
|
||||
self.key = {
|
||||
|
|
@ -1591,7 +1591,7 @@ Ox.InputElement_ = function(options, self) {
|
|||
that.$element.val('').focus();
|
||||
}
|
||||
|
||||
function clickMenu(event, data) {
|
||||
function clickMenu(data) {
|
||||
//Ox.print('clickMenu', data);
|
||||
that.$element.val(data.title);
|
||||
//self.$autosuggestMenu.hideMenu();
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ Ox.InputGroup = function(options, self) {
|
|||
.appendTo(that);
|
||||
});
|
||||
|
||||
function change(event, data) {
|
||||
function change(data) {
|
||||
//Ox.print('InputGroup change')
|
||||
that.triggerEvent('change', {
|
||||
value: self.options.inputs.map(function($input) {
|
||||
|
|
@ -110,7 +110,7 @@ Ox.InputGroup = function(options, self) {
|
|||
});
|
||||
}
|
||||
|
||||
function validate(event, data) {
|
||||
function validate(data) {
|
||||
//Ox.print('INPUTGROUP TRIGGER VALIDATE')
|
||||
that.triggerEvent('validate', data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ Ox.PlacePicker = function(options, self) {
|
|||
|
||||
self.map = false;
|
||||
|
||||
function changeZoom(event, data) {
|
||||
function changeZoom(data) {
|
||||
//Ox.print('changeZoom')
|
||||
self.$map.zoom(data.value);
|
||||
}
|
||||
|
|
@ -114,18 +114,18 @@ Ox.PlacePicker = function(options, self) {
|
|||
}
|
||||
}
|
||||
|
||||
function findPlace(event, data) {
|
||||
function findPlace(data) {
|
||||
//Ox.print('findPlace', data);
|
||||
self.$map.find(data.value, function(place) {
|
||||
place && that.$label.html(place.geoname);
|
||||
});
|
||||
}
|
||||
|
||||
function onSelect(event, data) {
|
||||
function onSelect(data) {
|
||||
that.$label.html(data.geoname);
|
||||
}
|
||||
|
||||
function onZoom(event, data) {
|
||||
function onZoom(data) {
|
||||
self.$range.options({
|
||||
value: data.value
|
||||
});
|
||||
|
|
|
|||
|
|
@ -135,11 +135,11 @@ Ox.Select = function(options, self) {
|
|||
|
||||
self.options.type == 'image' && self.$menu.addClass('OxRight');
|
||||
|
||||
function clickMenu(event, data) {
|
||||
function clickMenu(data) {
|
||||
that.triggerEvent('click', data);
|
||||
}
|
||||
|
||||
function changeMenu(event, data) {
|
||||
function changeMenu(data) {
|
||||
//Ox.print('clickMenu: ', self.options.id, data)
|
||||
self.checked = self.optionGroup.checked();
|
||||
self.$title && self.$title.html(
|
||||
|
|
|
|||
|
|
@ -1486,7 +1486,7 @@ Ox.List = function(options, self) {
|
|||
function remove() {
|
||||
that.triggerEvent('remove', item.id);
|
||||
}
|
||||
function submit(event, data) {
|
||||
function submit(data) {
|
||||
item.value = data.value;
|
||||
//$input.loseFocus().remove();
|
||||
// fixme: leaky, inputs remain in focus stack
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ Ox.TextList = function(options, self) {
|
|||
that.$body.reloadPages();
|
||||
}
|
||||
|
||||
function changeColumns(event, data) {
|
||||
function changeColumns(data) {
|
||||
var add,
|
||||
ids = [];
|
||||
Ox.forEach(data.selected, function(column) {
|
||||
|
|
@ -522,6 +522,7 @@ Ox.TextList = function(options, self) {
|
|||
|
||||
function dragendResize(id, e) {
|
||||
var pos = getColumnPositionById(id);
|
||||
// fixme: shouldn't this be resizecolumn?
|
||||
that.triggerEvent('columnresize', {
|
||||
id: id,
|
||||
width: self.columnWidths[pos]
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ Ox.TreeList = function(options, self) {
|
|||
that.$element.removeItems(pos + 1, parseItems(item.items, item.level + 1).length);
|
||||
}
|
||||
|
||||
function toggleItems(event, data) {
|
||||
function toggleItems(data) {
|
||||
data.ids.forEach(function(id, i) {
|
||||
var item = getItemById(id);
|
||||
if (item.items && data.expanded != !!item.expanded) {
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ Ox.ListMap = function(options, self) {
|
|||
})
|
||||
.bindEvent({
|
||||
/*
|
||||
addplace: function(event, data) {
|
||||
addplace: function(data) {
|
||||
that.triggerEvent('addplace', data);
|
||||
},
|
||||
*/
|
||||
|
|
@ -317,9 +317,11 @@ Ox.ListMap = function(options, self) {
|
|||
geocode: function(data) {
|
||||
that.triggerEvent('geocode', data);
|
||||
},
|
||||
/*
|
||||
resize: function() {
|
||||
self.$map.resizeMap(); // fixme: don't need event
|
||||
},
|
||||
*/
|
||||
selectplace: selectPlace
|
||||
});
|
||||
|
||||
|
|
@ -616,11 +618,11 @@ Ox.ListMap = function(options, self) {
|
|||
orientation: 'vertical'
|
||||
})
|
||||
.bindEvent({
|
||||
resize: function(foo, size) {
|
||||
self.$placeTitleName.options({width: size - 48});
|
||||
resize: function(data) {
|
||||
self.$placeTitleName.options({width: data.size - 48});
|
||||
// fixme: pass width through form
|
||||
self.$placeFormItems.forEach(function($item) {
|
||||
$item.options({width: size - 16});
|
||||
$item.options({width: data.size - 16});
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
|
@ -705,18 +707,18 @@ Ox.ListMap = function(options, self) {
|
|||
);
|
||||
}
|
||||
|
||||
function openItem(event, data) {
|
||||
selectItem(event, data);
|
||||
function openItem(data) {
|
||||
selectItem(data);
|
||||
self.$map.zoomToPlace(data.ids[0]);
|
||||
}
|
||||
|
||||
function removeItem(event, data) {
|
||||
function removeItem(data) {
|
||||
var id = data.ids[0];
|
||||
that.triggerEvent('removeplace', {id: id});
|
||||
self.$map.removePlace(id);
|
||||
}
|
||||
|
||||
function selectItem(event, data) {
|
||||
function selectItem(data) {
|
||||
Ox.print('selectItem', data.ids[0])
|
||||
var id = data.ids.length ? data.ids[0] : null;
|
||||
self.$map.options({selected: id});
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ Ox.Map = function(options, self) {
|
|||
self.centerChanged = true;
|
||||
}
|
||||
|
||||
function changeZoom(event, data) {
|
||||
function changeZoom(data) {
|
||||
self.map.setZoom(data.value);
|
||||
}
|
||||
|
||||
|
|
@ -1094,7 +1094,7 @@ Ox.Map = function(options, self) {
|
|||
//Ox.print('STATUS DONE');
|
||||
}
|
||||
|
||||
function submitFind(event, data) {
|
||||
function submitFind(data) {
|
||||
that.findPlace(data.value, function(place) {
|
||||
setStatus(place);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
tooltip: 'Add',
|
||||
type: 'image'
|
||||
}).bindEvent({
|
||||
click: function(event, data) {
|
||||
click: function(data) {
|
||||
that.triggerEvent('add', {value: ''});
|
||||
}
|
||||
})
|
||||
|
|
@ -72,13 +72,13 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
//reset in/out points
|
||||
selectAnnotation({}, {ids: [item.id]});
|
||||
},
|
||||
open: function(event, data) {
|
||||
open: function(data) {
|
||||
if (data.ids.length == 1) {
|
||||
var pos = Ox.getPositionById(self.$annotations.options('items'), data.ids[0]);
|
||||
self.$annotations.editItem(pos);
|
||||
}
|
||||
},
|
||||
remove: function(event, data) {
|
||||
remove: function(data) {
|
||||
that.triggerEvent('remove', data);
|
||||
},
|
||||
select: selectAnnotation,
|
||||
|
|
@ -100,7 +100,7 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
.appendTo(self.$annotations);
|
||||
});
|
||||
*/
|
||||
function selectAnnotation(event, data) {
|
||||
function selectAnnotation(data) {
|
||||
var item = Ox.getObjectById(self.options.items, data.ids[0]);
|
||||
item && that.triggerEvent('select', {
|
||||
'in': item['in'],
|
||||
|
|
@ -108,7 +108,7 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
'layer': self.options.id
|
||||
});
|
||||
}
|
||||
function updateAnnotation(event, data) {
|
||||
function updateAnnotation(data) {
|
||||
var item = Ox.getObjectById(self.options.items, data.id);
|
||||
item.value = data.value;
|
||||
that.triggerEvent('submit', item);
|
||||
|
|
|
|||
|
|
@ -267,26 +267,26 @@ Ox.VideoEditor = function(options, self) {
|
|||
}, layer)
|
||||
)
|
||||
.bindEvent({
|
||||
add: function(event, data) {
|
||||
add: function(data) {
|
||||
data.layer = layer.id;
|
||||
data['in'] = self.options['in'];
|
||||
data.out = self.options.out;
|
||||
that.triggerEvent('addannotation', data);
|
||||
},
|
||||
remove: function(event, data) {
|
||||
remove: function(data) {
|
||||
data = {
|
||||
ids: [data],
|
||||
layer: layer.id
|
||||
};
|
||||
that.triggerEvent('removeannotations', data);
|
||||
},
|
||||
select: function(event, data) {
|
||||
select: function(data) {
|
||||
self.options.layers.forEach(function(l, j) { // fixme: l? j?
|
||||
if(l.id != layer.id) {
|
||||
self.$annotationPanel[j].deselectItems();
|
||||
}
|
||||
});
|
||||
selectAnnotation(event, data);
|
||||
selectAnnotation(data);
|
||||
},
|
||||
submit: updateAnnotation
|
||||
});
|
||||
|
|
@ -852,13 +852,13 @@ Ox.VideoEditor = function(options, self) {
|
|||
self.$player[0].playInToOut();
|
||||
}
|
||||
|
||||
function resizeAnnotations(event, data) {
|
||||
self.options.annotationsSize = data;
|
||||
function resizeAnnotations(data) {
|
||||
self.options.annotationsSize = data.size;
|
||||
setSizes();
|
||||
}
|
||||
|
||||
function resizeEditor(event, data) {
|
||||
var width = data - 2 * margin + 100;
|
||||
function resizeEditor(data) {
|
||||
var width = data.size - 2 * margin + 100;
|
||||
resizeVideoPlayers(width);
|
||||
$timelineLarge.options({
|
||||
width: width
|
||||
|
|
@ -881,12 +881,12 @@ Ox.VideoEditor = function(options, self) {
|
|||
});
|
||||
}
|
||||
|
||||
function selectAnnotation(event, data) {
|
||||
function selectAnnotation(data) {
|
||||
setPosition(data['in']);
|
||||
setPoint('in', data['in']);
|
||||
setPoint('out', data.out);
|
||||
}
|
||||
function updateAnnotation(event, data) {
|
||||
function updateAnnotation(data) {
|
||||
data['in'] = self.options['in'];
|
||||
data.out = self.options.out;
|
||||
that.triggerEvent('updateannotation', data);
|
||||
|
|
@ -983,7 +983,7 @@ Ox.VideoEditor = function(options, self) {
|
|||
}
|
||||
}
|
||||
|
||||
function toggleAnnotations(event, data) {
|
||||
function toggleAnnotations(data) {
|
||||
self.options.showAnnotations = !data.collapsed;
|
||||
setSizes();
|
||||
that.triggerEvent('toggleannotations', {
|
||||
|
|
|
|||
|
|
@ -251,11 +251,11 @@ Ox.VideoEditorPlayer = function(options, self) {
|
|||
});
|
||||
}
|
||||
|
||||
function paused(event, data) {
|
||||
function paused() {
|
||||
self.$playButton.toggleTitle();
|
||||
}
|
||||
|
||||
function playing(event, data) {
|
||||
function playing(data) {
|
||||
self.options.position = data.position;
|
||||
setMarkers();
|
||||
setSubtitle();
|
||||
|
|
@ -365,7 +365,7 @@ Ox.VideoEditorPlayer = function(options, self) {
|
|||
self.video.paused ? that.play() : that.pause();
|
||||
}
|
||||
|
||||
function toggleSize(event, data) {
|
||||
function toggleSize(data) {
|
||||
self.options.size = data.id
|
||||
that.triggerEvent('togglesize', {
|
||||
size: self.options.size
|
||||
|
|
|
|||
|
|
@ -182,9 +182,9 @@ Ox.VideoPanelPlayer = function(options, self) {
|
|||
self.options.annotationsSize - 16 - 1;
|
||||
}
|
||||
|
||||
function resizeAnnotations(event, data) {
|
||||
function resizeAnnotations(data) {
|
||||
// called on annotations resize
|
||||
self.options.annotationsSize = data;
|
||||
self.options.annotationsSize = data.size;
|
||||
self.$video.options({
|
||||
width: getPlayerWidth()
|
||||
});
|
||||
|
|
@ -193,22 +193,22 @@ Ox.VideoPanelPlayer = function(options, self) {
|
|||
});
|
||||
}
|
||||
|
||||
function resizeendAnnotations(event, data) {
|
||||
self.options.annotationsSize = data;
|
||||
function resizeendAnnotations(data) {
|
||||
self.options.annotationsSize = data.size;
|
||||
that.triggerEvent('resizeannotations', {
|
||||
annotationsSize: self.options.annotationsSize
|
||||
});
|
||||
}
|
||||
|
||||
function resizeElement(event, data) {
|
||||
function resizeElement(data) {
|
||||
// called on browser toggle
|
||||
self.options.height = data;
|
||||
self.options.height = data.size;
|
||||
self.$video.options({
|
||||
height: getPlayerHeight()
|
||||
});
|
||||
}
|
||||
|
||||
function resizePanel(event, data) {
|
||||
function resizePanel(data) {
|
||||
// called on annotations toggle
|
||||
self.$video.options({
|
||||
width: getPlayerWidth()
|
||||
|
|
@ -218,7 +218,7 @@ Ox.VideoPanelPlayer = function(options, self) {
|
|||
});
|
||||
}
|
||||
|
||||
function setPosition(event, data) {
|
||||
function setPosition(data) {
|
||||
self.options.position = data.position;
|
||||
//self.$video.position(self.options.position);
|
||||
self.$timeline.options({
|
||||
|
|
@ -226,7 +226,7 @@ Ox.VideoPanelPlayer = function(options, self) {
|
|||
});
|
||||
}
|
||||
|
||||
function toggleAnnotations(event, data) {
|
||||
function toggleAnnotations(data) {
|
||||
self.options.showAnnotations = !data.collapsed;
|
||||
self.$video.options({
|
||||
height: getPlayerHeight()
|
||||
|
|
@ -236,7 +236,7 @@ Ox.VideoPanelPlayer = function(options, self) {
|
|||
});
|
||||
}
|
||||
|
||||
function toggleControls(event, data) {
|
||||
function toggleControls(data) {
|
||||
self.options.showControls = !data.collapsed;
|
||||
self.$video.options({
|
||||
height: getPlayerHeight()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue