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() { focusedElementIsInput: function() {
var $element = that.focusedElement(); var $element = that.focusedElement();
return $element && ( return $element && $element.hasClass('OxKeyboardFocus');
$element.hasClass('OxInput')
|| $element.hasClass('OxEditableElement')
|| $element.hasClass('OxAutocompleteMenu')
);
}, },
gainFocus: function($element) { gainFocus: function($element) {
var $focusedElement = that.focusedElement(), var $focusedElement = that.focusedElement(),

View file

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

View file

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

View file

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