Use the "input" event as much as possible.
This event fires when a text input element's value changes, always when it changes, only when it changes. It fires on keyup, keydown, paste, cut, with the keyboard, with shortcuts, with the context menu, etc... It works on Chrome, Firefox 12+ and Opera.
This commit is contained in:
parent
0160eb7b9e
commit
3e9b5b029e
@ -1938,7 +1938,7 @@
|
|||||||
return new QR.reply().select();
|
return new QR.reply().select();
|
||||||
});
|
});
|
||||||
$.on($('form', QR.el), 'submit', QR.submit);
|
$.on($('form', QR.el), 'submit', QR.submit);
|
||||||
$.on($('textarea', QR.el), 'keyup', function() {
|
$.on($('textarea', QR.el), 'input', function() {
|
||||||
return QR.selected.el.lastChild.textContent = this.value;
|
return QR.selected.el.lastChild.textContent = this.value;
|
||||||
});
|
});
|
||||||
$.on(fileInput, 'change', QR.fileInput);
|
$.on(fileInput, 'change', QR.fileInput);
|
||||||
@ -1955,7 +1955,7 @@
|
|||||||
_ref1 = ['name', 'email', 'sub', 'com'];
|
_ref1 = ['name', 'email', 'sub', 'com'];
|
||||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||||
name = _ref1[_j];
|
name = _ref1[_j];
|
||||||
$.on($("[name=" + name + "]", QR.el), 'input keyup change paste', function() {
|
$.on($("[name=" + name + "]", QR.el), 'input', function() {
|
||||||
var _ref2;
|
var _ref2;
|
||||||
QR.selected[this.name] = this.value;
|
QR.selected[this.name] = this.value;
|
||||||
if (QR.cooldown.auto && QR.selected === QR.replies[0] && (0 < (_ref2 = QR.cooldown.seconds) && _ref2 < 6)) {
|
if (QR.cooldown.auto && QR.selected === QR.replies[0] && (0 < (_ref2 = QR.cooldown.seconds) && _ref2 < 6)) {
|
||||||
@ -2315,12 +2315,12 @@
|
|||||||
(back = $('[name=backlink]', dialog)).value = $.get('backlink', Conf['backlink']);
|
(back = $('[name=backlink]', dialog)).value = $.get('backlink', Conf['backlink']);
|
||||||
(time = $('[name=time]', dialog)).value = $.get('time', Conf['time']);
|
(time = $('[name=time]', dialog)).value = $.get('time', Conf['time']);
|
||||||
(fileInfo = $('[name=fileInfo]', dialog)).value = $.get('fileInfo', Conf['fileInfo']);
|
(fileInfo = $('[name=fileInfo]', dialog)).value = $.get('fileInfo', Conf['fileInfo']);
|
||||||
$.on(back, 'keyup', $.cb.value);
|
$.on(back, 'input', $.cb.value);
|
||||||
$.on(back, 'keyup', Options.backlink);
|
$.on(back, 'input', Options.backlink);
|
||||||
$.on(time, 'keyup', $.cb.value);
|
$.on(time, 'input', $.cb.value);
|
||||||
$.on(time, 'keyup', Options.time);
|
$.on(time, 'input', Options.time);
|
||||||
$.on(fileInfo, 'keyup', $.cb.value);
|
$.on(fileInfo, 'input', $.cb.value);
|
||||||
$.on(fileInfo, 'keyup', Options.fileInfo);
|
$.on(fileInfo, 'input', Options.fileInfo);
|
||||||
favicon = $('select', dialog);
|
favicon = $('select', dialog);
|
||||||
favicon.value = $.get('favicon', Conf['favicon']);
|
favicon.value = $.get('favicon', Conf['favicon']);
|
||||||
$.on(favicon, 'change', $.cb.value);
|
$.on(favicon, 'change', $.cb.value);
|
||||||
@ -2447,10 +2447,10 @@
|
|||||||
Conf[input.name] = input.checked;
|
Conf[input.name] = input.checked;
|
||||||
}
|
}
|
||||||
} else if (input.name === 'Interval') {
|
} else if (input.name === 'Interval') {
|
||||||
$.on(input, 'change', function() {
|
$.on(input, 'input', function() {
|
||||||
return Conf['Interval'] = this.value = parseInt(this.value, 10) || Conf['Interval'];
|
this.value = parseInt(this.value, 10) || Conf['Interval'];
|
||||||
|
return $.cb.value.call(this);
|
||||||
});
|
});
|
||||||
$.on(input, 'change', $.cb.value);
|
|
||||||
} else if (input.type === 'button') {
|
} else if (input.type === 'button') {
|
||||||
$.on(input, 'click', this.update);
|
$.on(input, 'click', this.update);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1444,7 +1444,7 @@ QR =
|
|||||||
$.on $('#dump', QR.el), 'click', -> QR.el.classList.toggle 'dump'
|
$.on $('#dump', QR.el), 'click', -> QR.el.classList.toggle 'dump'
|
||||||
$.on $('#addReply', QR.el), 'click', -> new QR.reply().select()
|
$.on $('#addReply', QR.el), 'click', -> new QR.reply().select()
|
||||||
$.on $('form', QR.el), 'submit', QR.submit
|
$.on $('form', QR.el), 'submit', QR.submit
|
||||||
$.on $('textarea', QR.el), 'keyup', -> QR.selected.el.lastChild.textContent = @value
|
$.on $('textarea', QR.el), 'input', -> QR.selected.el.lastChild.textContent = @value
|
||||||
$.on fileInput, 'change', QR.fileInput
|
$.on fileInput, 'change', QR.fileInput
|
||||||
$.on fileInput, 'click', (e) -> if e.shiftKey then QR.selected.rmFile() or e.preventDefault()
|
$.on fileInput, 'click', (e) -> if e.shiftKey then QR.selected.rmFile() or e.preventDefault()
|
||||||
$.on spoiler.firstChild, 'change', -> $('input', QR.selected.el).click()
|
$.on spoiler.firstChild, 'change', -> $('input', QR.selected.el).click()
|
||||||
@ -1454,8 +1454,8 @@ QR =
|
|||||||
# save selected reply's data
|
# save selected reply's data
|
||||||
for name in ['name', 'email', 'sub', 'com']
|
for name in ['name', 'email', 'sub', 'com']
|
||||||
# The input event replaces keyup, change and paste events.
|
# The input event replaces keyup, change and paste events.
|
||||||
# XXX Opera?
|
# XXX Does Opera support the `input` event?
|
||||||
$.on $("[name=#{name}]", QR.el), 'input keyup change paste', ->
|
$.on $("[name=#{name}]", QR.el), 'input', ->
|
||||||
QR.selected[@name] = @value
|
QR.selected[@name] = @value
|
||||||
# Disable auto-posting if you're typing in the first reply
|
# Disable auto-posting if you're typing in the first reply
|
||||||
# during the last 5 seconds of the cooldown.
|
# during the last 5 seconds of the cooldown.
|
||||||
@ -1790,12 +1790,12 @@ Options =
|
|||||||
(back = $ '[name=backlink]', dialog).value = $.get 'backlink', Conf['backlink']
|
(back = $ '[name=backlink]', dialog).value = $.get 'backlink', Conf['backlink']
|
||||||
(time = $ '[name=time]', dialog).value = $.get 'time', Conf['time']
|
(time = $ '[name=time]', dialog).value = $.get 'time', Conf['time']
|
||||||
(fileInfo = $ '[name=fileInfo]', dialog).value = $.get 'fileInfo', Conf['fileInfo']
|
(fileInfo = $ '[name=fileInfo]', dialog).value = $.get 'fileInfo', Conf['fileInfo']
|
||||||
$.on back, 'keyup', $.cb.value
|
$.on back, 'input', $.cb.value
|
||||||
$.on back, 'keyup', Options.backlink
|
$.on back, 'input', Options.backlink
|
||||||
$.on time, 'keyup', $.cb.value
|
$.on time, 'input', $.cb.value
|
||||||
$.on time, 'keyup', Options.time
|
$.on time, 'input', Options.time
|
||||||
$.on fileInfo, 'keyup', $.cb.value
|
$.on fileInfo, 'input', $.cb.value
|
||||||
$.on fileInfo, 'keyup', Options.fileInfo
|
$.on fileInfo, 'input', Options.fileInfo
|
||||||
favicon = $ 'select', dialog
|
favicon = $ 'select', dialog
|
||||||
favicon.value = $.get 'favicon', Conf['favicon']
|
favicon.value = $.get 'favicon', Conf['favicon']
|
||||||
$.on favicon, 'change', $.cb.value
|
$.on favicon, 'change', $.cb.value
|
||||||
@ -1907,8 +1907,9 @@ Updater =
|
|||||||
# Required for the QR's update after posting.
|
# Required for the QR's update after posting.
|
||||||
Conf[input.name] = input.checked
|
Conf[input.name] = input.checked
|
||||||
else if input.name is 'Interval'
|
else if input.name is 'Interval'
|
||||||
$.on input, 'change', -> Conf['Interval'] = @value = parseInt(@value, 10) or Conf['Interval']
|
$.on input, 'input', ->
|
||||||
$.on input, 'change', $.cb.value
|
@value = parseInt(@value, 10) or Conf['Interval']
|
||||||
|
$.cb.value.call @
|
||||||
else if input.type is 'button'
|
else if input.type is 'button'
|
||||||
$.on input, 'click', @update
|
$.on input, 'click', @update
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user