Skip to content

Instantly share code, notes, and snippets.

@rgrove
Created September 8, 2010 22:40
Show Gist options
  • Save rgrove/570979 to your computer and use it in GitHub Desktop.
Save rgrove/570979 to your computer and use it in GitHub Desktop.
Monkeypatch to support Edit->Paste via the browser menubar for auto-focused elements in YUI 3.2.0's event-valuechange.
var VC = Y.ValueChange;
VC._onFocus = function (e) {
VC._startPolling(e.currentTarget, null, e);
};
VC._onSubscribe = function (node, subscription, notifier) {
var stamp = Y.stamp(node),
notifiers = VC._notifiers[stamp];
VC._history[stamp] = node.get('value');
notifier._handles = node.on({
keydown : VC._onKeyDown,
keyup : VC._onKeyUp,
focus : VC._onFocus,
mousedown: VC._onMouseDown
});
if (!notifiers) {
notifiers = VC._notifiers[stamp] = [];
}
notifiers.push(notifier);
};
Y.Event.define('valueChange', {
detach: VC._onUnsubscribe,
on : VC._onSubscribe,
publishConfig: {
emitFacade: true
}
}, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment