mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-25 14:10:28 +01:00
14 lines
1.7 KiB
JavaScript
14 lines
1.7 KiB
JavaScript
|
/**
|
||
|
* inputLight plugin
|
||
|
* Copyright (c) 2010 Nick Obrien (http://www.nickobrien.nl)
|
||
|
* Licensed under the MIT License:
|
||
|
* http://www.opensource.org/licenses/mit-license.php
|
||
|
*
|
||
|
* NOTICE:
|
||
|
* This plugin is for non-browser-themed inputs only! So always
|
||
|
* set a border for the input you would like to light.
|
||
|
* Supported inputs are: input, textarea, select
|
||
|
*
|
||
|
* Version: 0.2
|
||
|
*/
|
||
|
(function($){$.fn.inputLight=function(options){var defaults={outer_width:'2',outer_color:'#fafaab',inner_color:'#eec857'};var s=$.extend(defaults,options);return this.each(function(){var e=$(this);var old_border_color=e.css('border-color');if(e.is('input, textarea, select')){var w=$('<div></div>');$(this).click(function(){hightlight(e,w,old_border_color)})}});function hightlight(e,w,old_border_color){e.css({'position':'relative','border-color':s.inner_color,'padding':s.inner_padding});var e_total_height=parseInt(e.css('border-top-width'))+parseInt(e.css('border-bottom-width'))+e.height();var e_border_height=parseInt(e.css('border-top-width'))+parseInt(e.css('border-bottom-width'));var e_border_width=parseInt(e.css('border-left-width'))+parseInt(e.css('border-right-width'));var w_height=e.height()+e_border_height+parseInt(s.outer_width*2);var w_width=e.width()+e_border_width+parseInt(s.outer_width*2);var w_padding=parseInt((w_height-e_total_height)/2)+'px';w.css({'display':'block','position':'absolute','width':w_width,'height':e_total_height,'margin-left':'-'+s.outer_width,'margin-top':'-'+s.outer_width,'padding-top':w_padding,'padding-bottom':w_padding,'background':s.outer_color,'text-align':'center','vertical-align':'middle'});e.before(w).focus();e.blur(function(){w.fadeOut(300,function(){e.css('border-color',old_border_color)})})}}})(jQuery);
|