Mercurial > nebulaweb3
diff default/assets/js/material-design.js @ 0:1d038bc9b3d2 default tip
Up:default
author | Liny <dev@neowd.com> |
---|---|
date | Sat, 31 May 2025 09:21:51 +0800 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/default/assets/js/material-design.js Sat May 31 09:21:51 2025 +0800 @@ -0,0 +1,44 @@ +/* +* Name: Oscar +* Written by: Unifato - (http://unifato.com) +* Version: 1.0.0 +*/ + +(function($) { + 'use strict'; + + var el = $('input:not([type=checkbox]):not([type=radio]), textarea'); + if( !el.length ) return; + el.each(function() { + var $this = $(this), + self = this; + + var hasValueFunction = function() { + if( self.value.length > 0 ) { + self.parentNode.classList.add('input-has-value'); + $(self).closest('.form-group').addClass('input-has-value'); + } + else { + self.parentNode.classList.remove('input-has-value'); + $(self).closest('.form-group').removeClass('input-has-value'); + } + }; + + hasValueFunction(this); + $this.on('input', hasValueFunction); + + $this.focusin(function() { + this.parentNode.classList.add('input-focused'); + $this.closest('.form-group').addClass('input-focused'); + }); + $this.focusout(function() { + this.parentNode.classList.remove('input-focused'); + $this.closest('.form-group').removeClass('input-focused'); + }); + + $this.find('.remove-focus').on('click',function() { + $this.emit('focusout'); + }); + }); + +})(jQuery);