mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-17 06:20:26 +00:00
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
/*
|
|
* jQuery Mobile Framework : "customTextInput" plugin for text inputs, textareas (based on code from Filament Group,Inc)
|
|
* Copyright (c) jQuery Project
|
|
* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
|
|
* Note: Code is in draft form and is subject to change
|
|
*/
|
|
(function($){
|
|
jQuery.fn.customTextInput = function(options){
|
|
return $(this).each(function(){
|
|
var input = $(this);
|
|
|
|
var o = $.extend({
|
|
search: input.is('[data-role="search"]')
|
|
//defaultTheme: "a"
|
|
}, options);
|
|
|
|
$('label[for='+input.attr('id')+']').addClass('ui-input-text');
|
|
|
|
input.addClass('ui-input-text');
|
|
|
|
var focusedEl = input;
|
|
if(o.search){
|
|
focusedEl = input.wrap('<div class="ui-input-search ui-btn-corner-all ui-body-c ui-btn-shadow ui-icon-search"></div>').parent();
|
|
}
|
|
else{
|
|
input.addClass('ui-corner-all ui-body-c');
|
|
}
|
|
|
|
input
|
|
.focus(function(){
|
|
focusedEl.addClass('ui-focus');
|
|
})
|
|
.blur(function(){
|
|
focusedEl.removeClass('ui-focus');
|
|
});
|
|
|
|
//autogrow
|
|
if(input.is('textarea')){
|
|
input.keydown(function(){
|
|
if( input[0].offsetHeight < input[0].scrollHeight ){
|
|
input.css({height: input[0].scrollHeight + 10 });
|
|
}
|
|
})
|
|
}
|
|
});
|
|
};
|
|
})(jQuery);
|