comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:1d038bc9b3d2
1 /*
2 * Name: Oscar
3 * Written by: Unifato - (http://unifato.com)
4 * Version: 1.0.0
5 */
6
7 (function($) {
8 'use strict';
9
10 var el = $('input:not([type=checkbox]):not([type=radio]), textarea');
11 if( !el.length ) return;
12 el.each(function() {
13 var $this = $(this),
14 self = this;
15
16 var hasValueFunction = function() {
17 if( self.value.length > 0 ) {
18 self.parentNode.classList.add('input-has-value');
19 $(self).closest('.form-group').addClass('input-has-value');
20 }
21 else {
22 self.parentNode.classList.remove('input-has-value');
23 $(self).closest('.form-group').removeClass('input-has-value');
24 }
25 };
26
27 hasValueFunction(this);
28 $this.on('input', hasValueFunction);
29
30 $this.focusin(function() {
31 this.parentNode.classList.add('input-focused');
32 $this.closest('.form-group').addClass('input-focused');
33 });
34 $this.focusout(function() {
35 this.parentNode.classList.remove('input-focused');
36 $this.closest('.form-group').removeClass('input-focused');
37 });
38
39 $this.find('.remove-focus').on('click',function() {
40 $this.emit('focusout');
41 });
42 });
43
44 })(jQuery);