use OxKeyboardFocus class for input-like elements

This commit is contained in:
rlx 2014-09-26 12:24:34 +02:00
parent c69858ca2d
commit 2aec28f105
4 changed files with 10 additions and 11 deletions

View file

@ -14,11 +14,7 @@ Ox.Focus = (function() {
},
focusedElementIsInput: function() {
var $element = that.focusedElement();
return $element && (
$element.hasClass('OxInput')
|| $element.hasClass('OxEditableElement')
|| $element.hasClass('OxAutocompleteMenu')
);
return $element && $element.hasClass('OxKeyboardFocus');
},
gainFocus: function($element) {
var $focusedElement = that.focusedElement(),

View file

@ -67,7 +67,10 @@ Ox.Editable = function(options, self) {
self.$value.html(formatValue());
}
})
.addClass('OxEditableElement' + (self.options.editable ? ' OxEditable' : ''))
.addClass(
'OxEditableElement OxKeyboardFocus'
+ (self.options.editable ? ' OxEditable' : '')
)
.on({
click: function(e) {
var $target = $(e.target);

View file

@ -43,7 +43,7 @@ Ox.EditableContent = function(options, self) {
!self.options.editing && that.html(formatValue());
}
})
.addClass('OxEditableContent')
.addClass('OxEditableContent OxKeyboardFocus')
.on({
blur: self.options.submitOnBlur ? submit : blur,
click: function(e) {

View file

@ -154,7 +154,7 @@ Ox.Input = function(options, self) {
}
})
.addClass(
'OxInput OxMedium Ox' + Ox.toTitleCase(self.options.style)
'OxInput OxKeyboardFocus OxMedium Ox' + Ox.toTitleCase(self.options.style)
+ (self.options.type == 'textarea' ? ' OxTextarea' : '') /*+ (
self.options.overlap != 'none' ?
' OxOverlap' + Ox.toTitleCase(self.options.overlap) : ''
@ -278,7 +278,7 @@ Ox.Input = function(options, self) {
}
self.$input = $(self.options.type == 'textarea' ? '<textarea>' : '<input>')
.addClass('OxInput OxMedium Ox' + Ox.toTitleCase(self.options.style))
.addClass('OxInput OxKeyboardFocus OxMedium Ox' + Ox.toTitleCase(self.options.style))
.attr({
disabled: self.options.disabled,
type: self.options.type == 'password' ? 'password' : 'text'
@ -345,7 +345,7 @@ Ox.Input = function(options, self) {
if (self.hasPasswordPlaceholder) {
self.$input.hide();
self.$placeholder = $('<input>')
.addClass('OxInput OxMedium Ox' +
.addClass('OxInput OxKeyboardFocus OxMedium Ox' +
Ox.toTitleCase(self.options.style) +
' OxPlaceholder')
.attr({type: 'text'})
@ -730,7 +730,7 @@ Ox.Input = function(options, self) {
top: 0
}
})
.addClass('OxAutocompleteMenu')
.addClass('OxAutocompleteMenu OxKeyboardFocus')
.bindEvent({
click: clickMenu,
key_enter: function() {