.bind -> .on, .unbind -> .off

This commit is contained in:
rolux 2012-05-28 16:06:22 +02:00
parent f45f993f42
commit 461a237880
22 changed files with 54 additions and 54 deletions

View file

@ -175,7 +175,7 @@ Ox.load(function() {
} else if (!url.page) { } else if (!url.page) {
app.$ui.logo app.$ui.logo
.css({cursor: 'pointer'}) .css({cursor: 'pointer'})
.bind({ .on({
click: app.toggle click: app.toggle
}); });
['label', 'menu', 'switch'].forEach(function(element) { ['label', 'menu', 'switch'].forEach(function(element) {
@ -201,7 +201,7 @@ Ox.load(function() {
.animate({opacity: 1}, 500, function() { .animate({opacity: 1}, 500, function() {
app.$ui.logo app.$ui.logo
.css({cursor: 'pointer'}) .css({cursor: 'pointer'})
.bind({ .on({
click: app.toggle click: app.toggle
}); });
}); });
@ -210,7 +210,7 @@ Ox.load(function() {
}, 500); }, 500);
}); });
} }
Ox.$window.bind({ Ox.$window.on({
hashchange: app.urlchange hashchange: app.urlchange
}); });
app.state.loaded = true; app.state.loaded = true;
@ -241,7 +241,7 @@ Ox.load(function() {
callback(); callback();
} }
}); });
Ox.$(window).bind({ Ox.$(window).on({
resize: app.resize resize: app.resize
}); });
}, },
@ -407,7 +407,7 @@ Ox.load(function() {
paddingBottom: '4px', paddingBottom: '4px',
borderRadius: '6px' borderRadius: '6px'
}) })
.bind({ .on({
click: app.toggle click: app.toggle
}); });
}, },
@ -491,7 +491,7 @@ Ox.load(function() {
.css({ .css({
width: 224 - Ox.UI.SCROLLBAR_SIZE + 'px' width: 224 - Ox.UI.SCROLLBAR_SIZE + 'px'
}) })
.bind({ .on({
click: function(e) { click: function(e) {
if (!$(this).is('.selected')) { if (!$(this).is('.selected')) {
selectItem(item.id); selectItem(item.id);

View file

@ -105,7 +105,7 @@ Ox.load.UI = function(options, callback) {
width: '32px', width: '32px',
height: '32px' height: '32px'
}, css)) }, css))
.bind({ .on({
mousedown: function(e) { mousedown: function(e) {
e.preventDefault(); e.preventDefault();
} }
@ -125,7 +125,7 @@ Ox.load.UI = function(options, callback) {
width: '32px', width: '32px',
height: '32px' height: '32px'
}, css)) }, css))
.bind({ .on({
mousedown: function(e) { mousedown: function(e) {
e.preventDefault() e.preventDefault()
} }
@ -191,7 +191,7 @@ Ox.load.UI = function(options, callback) {
border: 0, border: 0,
cursor: 'pointer' cursor: 'pointer'
}, css)) }, css))
.bind({ .on({
mousedown: function(e) { mousedown: function(e) {
e.preventDefault(); e.preventDefault();
} }
@ -269,7 +269,7 @@ Ox.load.UI = function(options, callback) {
Ox.$head = Ox.UI.$head = $('head'); Ox.$head = Ox.UI.$head = $('head');
Ox.$window = Ox.UI.$window = $(window); Ox.$window = Ox.UI.$window = $(window);
// fixme: is this the right place to do this? // fixme: is this the right place to do this?
$.browser.mozilla && Ox.$document.bind('dragstart', function() { $.browser.mozilla && Ox.$document.on('dragstart', function() {
return false; return false;
}); });
callbacks.forEach(function(callback) { callbacks.forEach(function(callback) {

View file

@ -47,8 +47,9 @@ Ox.Resizebar = function(options, self) {
.append($('<div>').addClass('OxSpace')); .append($('<div>').addClass('OxSpace'));
if (self.options.tooltip) { if (self.options.tooltip) {
// FIXME: Use Ox.Element's tooltip
self.$tooltip = Ox.Tooltip({title: getTitle()}); self.$tooltip = Ox.Tooltip({title: getTitle()});
that.bind({ that.on({
mouseenter: self.$tooltip.show, mouseenter: self.$tooltip.show,
mouseleave: self.$tooltip.hide mouseleave: self.$tooltip.hide
}); });

View file

@ -357,7 +357,7 @@ Ox.Calendar = function(options, self) {
top: (self.options.showToolbar * 24) + 16 + 'px', top: (self.options.showToolbar * 24) + 16 + 'px',
bottom: (self.options.showZoombar * 16) + 16 + 'px' bottom: (self.options.showZoombar * 16) + 16 + 'px'
}) })
.bind({ .on({
mouseleave: mouseleave, mouseleave: mouseleave,
mousemove: mousemove, mousemove: mousemove,
mousewheel: mousewheel mousewheel: mousewheel

View file

@ -179,7 +179,7 @@ Ox.ExamplePage = function(options, self) {
!self.hasUI && self.$switchButton.options({disabled: true}); !self.hasUI && self.$switchButton.options({disabled: true});
}); });
Ox.$window.bind({ Ox.$window.on({
resize: function() { resize: function() {
setSize(); setSize();
} }

View file

@ -23,7 +23,7 @@ Ox.Event = (function() {
that.bind = function() { that.bind = function() {
Ox.forEach(Ox.makeObject(arguments), function(callback, event) { Ox.forEach(Ox.makeObject(arguments), function(callback, event) {
var foo = event; var foo = event;
self.$eventHandler.bind('ox_' + event, function(event, data) { self.$eventHandler.on('ox_' + event, function(event, data) {
Ox.Log('Core', 'CALLBACK', foo, data.value); Ox.Log('Core', 'CALLBACK', foo, data.value);
callback(data.value); callback(data.value);
}); });
@ -82,10 +82,10 @@ Ox.Event = (function() {
@*/ @*/
that.unbind = function() { that.unbind = function() {
if (arguments.length == 0) { if (arguments.length == 0) {
self.$eventHandler.unbind(); self.$eventHandler.off();
} else { } else {
Ox.toArray(arguments).forEach(function(event) { Ox.toArray(arguments).forEach(function(event) {
self.$eventHandler.unbind('ox_' + event); self.$eventHandler.off('ox_' + event);
}); });
} }
return that; return that;

View file

@ -80,7 +80,7 @@ Ox.ArrayInput = function(options, self) {
type: 'image' type: 'image'
}) })
.css({float: 'left', marginLeft: '8px'}) .css({float: 'left', marginLeft: '8px'})
.bind({ .on({
click: function() { click: function() {
var index = $(this).parent().data('index'); var index = $(this).parent().data('index');
if (self.$input[index].value() !== '') { if (self.$input[index].value() !== '') {
@ -104,7 +104,7 @@ Ox.ArrayInput = function(options, self) {
type: 'image' type: 'image'
}) })
.css({float: 'left', marginLeft: '8px'}) .css({float: 'left', marginLeft: '8px'})
.bind({ .on({
click: function() { click: function() {
var index = $(this).parent().data('index'); var index = $(this).parent().data('index');
addInput(index + 1, '', true); addInput(index + 1, '', true);

View file

@ -35,7 +35,7 @@ Ox.Editable = function(options, self) {
}) })
.options(options || {}) .options(options || {})
.addClass('OxEditableElement' + (self.options.editable ? ' OxEditable' : '')) .addClass('OxEditableElement' + (self.options.editable ? ' OxEditable' : ''))
.bind({ .on({
click: function() { click: function() {
return false; return false;
} }

View file

@ -92,7 +92,7 @@ Ox.FileButton = function(options, self) {
marginLeft: -self.options.width + 'px', marginLeft: -self.options.width + 'px',
opacity: 0 opacity: 0
}) })
.bind({ .on({
change: selectFiles change: selectFiles
}) })
.appendTo(that); .appendTo(that);

View file

@ -277,7 +277,7 @@ Ox.FileInput = function(options, self) {
margin: '-1px -7px 0 -16px', margin: '-1px -7px 0 -16px',
opacity: 0 opacity: 0
}) })
.bind({ .on({
change: addFiles change: addFiles
}) })
.appendTo(self.$bar); .appendTo(self.$bar);

View file

@ -596,7 +596,7 @@ Ox.Input = function(options, self) {
self.options.autovalidate && autovalidate(true); self.options.autovalidate && autovalidate(true);
self.options.placeholder && setPlaceholder(); self.options.placeholder && setPlaceholder();
self.options.validate && validate(); self.options.validate && validate();
self.bindKeyboard && Ox.UI.$document.unbind('keydown', keydown); self.bindKeyboard && Ox.UI.$document.off('keydown', keydown);
if (!self.cancelled && !self.submitted) { if (!self.cancelled && !self.submitted) {
that.triggerEvent('blur', { that.triggerEvent('blur', {
value: self.options.value value: self.options.value

View file

@ -77,7 +77,7 @@ Ox.ObjectArrayInput = function(options, self) {
width: self.buttonWidth width: self.buttonWidth
}) })
.css({float: 'left', margin: '8px 4px 0 0'}) .css({float: 'left', margin: '8px 4px 0 0'})
.bind({ .on({
click: function() { click: function() {
var index = $(this).parent().data('index'); var index = $(this).parent().data('index');
if (self.$input.length > 1) { if (self.$input.length > 1) {
@ -97,7 +97,7 @@ Ox.ObjectArrayInput = function(options, self) {
width: self.buttonWidth width: self.buttonWidth
}) })
.css({float: 'left', margin: '8px 0 0 4px'}) .css({float: 'left', margin: '8px 0 0 4px'})
.bind({ .on({
click: function() { click: function() {
var index = $(this).parent().data('index'); var index = $(this).parent().data('index');
addInput(index + 1, getDefaultValue()); addInput(index + 1, getDefaultValue());

View file

@ -92,7 +92,7 @@ Ox.PlacePicker = function(options, self) {
}, self) }, self)
.bindEvent('show', showPicker); .bindEvent('show', showPicker);
that.$label.bind('click', clickLabel); that.$label.on('click', clickLabel);
self.map = false; self.map = false;

View file

@ -868,7 +868,7 @@ Ox.TextList = function(options, self) {
value: column.unformat ? column.unformat(html) : html, value: column.unformat ? column.unformat(html) : html,
width: width width: width
}) })
.bind({ .on({
mousedown: function(e) { mousedown: function(e) {
// keep mousedown from reaching list // keep mousedown from reaching list
e.stopPropagation(); e.stopPropagation();

View file

@ -49,7 +49,7 @@ Ox.Menu = function(options, self) {
'OxMenu Ox' + Ox.toTitleCase(self.options.side) + 'OxMenu Ox' + Ox.toTitleCase(self.options.side) +
' Ox' + Ox.toTitleCase(self.options.size) ' Ox' + Ox.toTitleCase(self.options.size)
) )
.bind({ .on({
click: click, click: click,
mouseenter: mouseenter, mouseenter: mouseenter,
mouseleave: mouseleave, mouseleave: mouseleave,

View file

@ -29,7 +29,7 @@ Ox.BlockVideoTimeline = function(options, self) {
.css({ .css({
position: 'absolute' position: 'absolute'
}) })
.bind({ .on({
mousedown: mousedown, mousedown: mousedown,
mouseleave: mouseleave, mouseleave: mouseleave,
mousemove: mousemove mousemove: mousemove

View file

@ -94,7 +94,7 @@ Ox.VideoElement = function(options, self) {
} }
return $('<video>') return $('<video>')
.css({position: 'absolute'}) .css({position: 'absolute'})
.bind({ .on({
ended: function() { ended: function() {
if (i < item.parts - 1) { if (i < item.parts - 1) {
setCurrentPart(self.currentPart + 1); setCurrentPart(self.currentPart + 1);

View file

@ -146,7 +146,7 @@ Ox.VideoPlayer = function(options, self) {
Ox.Log('VIDEO', 'VIDEO PLAYER OPTIONS', self.options) Ox.Log('VIDEO', 'VIDEO PLAYER OPTIONS', self.options)
Ox.UI.$window.bind({ Ox.UI.$window.on({
resize: function() { resize: function() {
self.options.fullscreen && setSizes(); self.options.fullscreen && setSizes();
} }
@ -233,7 +233,7 @@ Ox.VideoPlayer = function(options, self) {
key_space: togglePaused key_space: togglePaused
}); });
if (self.options.focus == 'mouseenter') { if (self.options.focus == 'mouseenter') {
that.bind({ that.on({
mouseenter: function() { mouseenter: function() {
if (!self.inputHasFocus) { if (!self.inputHasFocus) {
that.gainFocus(); that.gainFocus();
@ -244,7 +244,7 @@ Ox.VideoPlayer = function(options, self) {
} }
}); });
} else { } else {
that.bind({ that.on({
click: function() { click: function() {
var focused = Ox.Focus.focused(); var focused = Ox.Focus.focused();
if ( if (
@ -269,7 +269,7 @@ Ox.VideoPlayer = function(options, self) {
(self.options.controlsTop.length || self.options.controlsBottom.length)) || (self.options.controlsTop.length || self.options.controlsBottom.length)) ||
self.options.showIcon self.options.showIcon
) { ) {
that.bind({ that.on({
mouseenter: function() { mouseenter: function() {
showControls(); showControls();
self.mouseHasLeft = false; self.mouseHasLeft = false;
@ -338,7 +338,7 @@ Ox.VideoPlayer = function(options, self) {
} else { } else {
self.options.enableMouse && self.$videoContainer.bind({ self.options.enableMouse && self.$videoContainer.on({
click: function(e) { click: function(e) {
if (!$(e.target).is('.OxLogo')) { if (!$(e.target).is('.OxLogo')) {
goToPoint(); goToPoint();
@ -671,7 +671,7 @@ Ox.VideoPlayer = function(options, self) {
width: self.positionWidth - 4 + 'px' width: self.positionWidth - 4 + 'px'
}) })
.html(formatPosition()) .html(formatPosition())
.bind({ .on({
click: function() { click: function() {
if (self.options.enablePosition) { if (self.options.enablePosition) {
if (self.options.type == 'play') { if (self.options.type == 'play') {
@ -1149,7 +1149,7 @@ Ox.VideoPlayer = function(options, self) {
} }
function enterFullscreen() { function enterFullscreen() {
that.bind({ that.on({
mousemove: function() { mousemove: function() {
showControls(); showControls();
hideControls(); hideControls();
@ -1157,7 +1157,7 @@ Ox.VideoPlayer = function(options, self) {
}); });
showControls(); showControls();
hideControls(); hideControls();
that.find('.OxControls').bind({ that.find('.OxControls').on({
mouseenter: function() { mouseenter: function() {
self.mouseIsInControls = true; self.mouseIsInControls = true;
}, },
@ -1585,9 +1585,9 @@ Ox.VideoPlayer = function(options, self) {
top: getCSS('logo').top, top: getCSS('logo').top,
opacity: 0.25 opacity: 0.25
}, 250, function() { }, 250, function() {
self.options.logoLink && self.$logo.unbind('click'); self.options.logoLink && self.$logo.off('click');
self.options.logoTitle && self.options.logoTitle &&
self.$logo.unbind('mouseenter').unbind('mouseleave'); self.$logo.off('mouseenter mouseleave');
}); });
self.$subtitle && self.$subtitle.animate({ self.$subtitle && self.$subtitle.animate({
bottom: getCSS('subtitle').bottom bottom: getCSS('subtitle').bottom
@ -1766,7 +1766,7 @@ Ox.VideoPlayer = function(options, self) {
function renderSettings() { function renderSettings() {
var $settings = $('<div>') var $settings = $('<div>')
.addClass('OxControls OxSettings') .addClass('OxControls OxSettings')
.bind({ .on({
click: function(e) { click: function(e) {
var $target = $(e.target), resolution, title; var $target = $(e.target), resolution, title;
self.$settings.hide(); self.$settings.hide();
@ -1825,7 +1825,7 @@ Ox.VideoPlayer = function(options, self) {
if (item.title) { if (item.title) {
$item = $('<div>') $item = $('<div>')
.addClass('OxItem') .addClass('OxItem')
.bind({ .on({
mouseenter: function() { mouseenter: function() {
$(this).addClass('OxSelected'); $(this).addClass('OxSelected');
}, },
@ -2096,13 +2096,13 @@ Ox.VideoPlayer = function(options, self) {
opacity: 0.5 opacity: 0.5
}, 250, function() { }, 250, function() {
self.options.logoLink && self.$logo self.options.logoLink && self.$logo
.bind({ .on({
click: function() { click: function() {
document.location.href = self.options.logoLink; document.location.href = self.options.logoLink;
} }
}); });
self.options.logoTitle && self.$logo self.options.logoTitle && self.$logo
.bind({ .on({
mouseenter: function(e) { mouseenter: function(e) {
self.$logoTooltip.show(e); self.$logoTooltip.show(e);
}, },
@ -2213,11 +2213,10 @@ Ox.VideoPlayer = function(options, self) {
} else { } else {
// exitFullscreen flag makes the animation end on absolute position // exitFullscreen flag makes the animation end on absolute position
self.exitFullscreen = true; self.exitFullscreen = true;
that.unbind('mousemove'); that.off('mousemove');
that.find('.OxControls') that.find('.OxControls')
.trigger('mouseleave') .trigger('mouseleave')
.unbind('mouseenter') .off('mouseenter mouseleave');
.unbind('mouseleave');
clearTimeout(self.interfaceTimeout); clearTimeout(self.interfaceTimeout);
setSizes(true, function() { setSizes(true, function() {
self.exitFullscreen = false; self.exitFullscreen = false;

View file

@ -59,7 +59,7 @@ Ox.VideoPreview = function(options, self) {
} }
}) })
.addClass('OxInterface') .addClass('OxInterface')
.bind({ .on({
click: click, click: click,
mouseenter: startLoading, mouseenter: startLoading,
mouseleave: function() { mouseleave: function() {

View file

@ -119,7 +119,7 @@ Ox.VideoTimelinePlayer = function(options, self) {
self.$timelinePlayer = Ox.Element() self.$timelinePlayer = Ox.Element()
.css({overflowX: 'hidden', overflowY: 'auto'}) .css({overflowX: 'hidden', overflowY: 'auto'})
.bind({ .on({
mousedown: mousedown, mousedown: mousedown,
mouseleave: mouseleave, mouseleave: mouseleave,
mousemove: mousemove, mousemove: mousemove,
@ -206,7 +206,7 @@ Ox.VideoTimelinePlayer = function(options, self) {
width: self.positionWidth - 4 + 'px' width: self.positionWidth - 4 + 'px'
}) })
.html(formatPosition()) .html(formatPosition())
.bind({ .on({
click: function() { click: function() {
if (!self.options.paused) { if (!self.options.paused) {
self.playOnSubmit = true; self.playOnSubmit = true;

View file

@ -715,7 +715,7 @@ Ox.Dialog = function(options, self) {
self.$layer.show(); self.$layer.show();
that.gainFocus(); that.gainFocus();
} }
Ox.UI.$window.bind({ Ox.UI.$window.on({
resize: function() { resize: function() {
var offset = that.offset(); var offset = that.offset();
setMinAndMax(); setMinAndMax();

View file

@ -17,7 +17,7 @@ Ox.Layer = function(options, self) {
}) })
.options(options || {}) .options(options || {})
.addClass('OxLayer Ox' + Ox.toTitleCase(self.options.type) + 'Layer') .addClass('OxLayer Ox' + Ox.toTitleCase(self.options.type) + 'Layer')
.bind(self.options.type == 'dialog' ? { .on(self.options.type == 'dialog' ? {
mousedown: mousedown mousedown: mousedown
} : { } : {
click: click click: click
@ -41,7 +41,7 @@ Ox.Layer = function(options, self) {
@*/ @*/
that.hide = function() { that.hide = function() {
if (self.options.type == 'dialog') { if (self.options.type == 'dialog') {
Ox.UI.$window.unbind({mouseup: mouseup}); Ox.$window.off({mouseup: mouseup});
} }
that.remove(); that.remove();
}; };
@ -52,9 +52,9 @@ Ox.Layer = function(options, self) {
@*/ @*/
that.show = function() { that.show = function() {
if (self.options.type == 'dialog') { if (self.options.type == 'dialog') {
Ox.UI.$window.bind({mouseup: mouseup}); Ox.$window.on({mouseup: mouseup});
} }
that.appendTo(Ox.UI.$body); that.appendTo(Ox.$body);
return that; return that;
} }