PageSourceSearch

https://fedgar.com/site/assets/js/uni-form.jquery.js

js fedgar.com collected 2026-10-05 03:41:11 UTC 3,773 bytes, 105 lines download raw bytes

1/**
2 * Uni-Form jQuery Plugin without Validation
3 *
4 * Provides form actions for use with the Uni-Form markup style
5 *
6 * Author: Ilija Studen for the purposes of Uni-Form
7 * 
8 * Modified by Aris Karageorgos to use the parents function
9 * 
10 * Modified by Toni Karlheinz to support input fields' text
11 * coloring and removal of their initial values on focus
12 * 
13 * Modified by Jason Brumwell for optimization, addition
14 * of valid and invalid states and default data attribues
15 * 
16 *
17 * @see http://sprawsm.com/uni-form/
18 * @license MIT http://www.opensource.org/licenses/mit-license.php
19 */
20jQuery.fn.uniform = function(settings) {
21    settings = jQuery.extend({
22        valid_class    : 'valid',
23        invalid_class  : 'invalid',
24        error_class    : 'error',
25        focused_class  : 'focused',
26        holder_class   : 'ctrlHolder',
27        field_selector : 'input, textarea, select',
28        default_value_color: "#AFAFAF"
29    }, settings);
30  
31    return this.each(function() {
32        var form = jQuery(this),
33            validate = function($input,valid,text) {
34                var $p = $input.closest('div.'+settings.holder_class)
35                               .andSelf()
36                               .toggleClass(settings.invalid_class,!valid)
37                               .toggleClass(settings.error_class,!valid)
38                               .toggleClass(settings.valid_class,valid)
39                               .find('p.formHint');
40
41                if (! valid && ! $p.data('info-text')) {
42                    $p.data('info-text',$p.html());
43                } else if (valid) {
44                    text = $p.data('info-text');
45                }
46
47                if (text) {
48                    $p.html(text);
49                }
50            };
51
52        form.submit(function(){
53            form.find(settings.field_selector).each(function(){
54                if($(this).val() == $(this).data('default-value')) $(this).val("");
55            });
56        })
57
58        // Select form fields and attach them higlighter functionality
59        form.find(settings.field_selector).each(function(){
60            var $input = $(this),
61                value = $input.val();
62
63            $input.data('default-color',$input.css('color'));
64
65            if (value == $input.data('default-value') || ! value) {
66                $input.not('select').css("color",settings.default_value_color);
67                $input.val($input.data('default-value'));
68
69            }
70        })
71
72        form.delegate(settings.field_selector,'focus',function() {
73            form.find('.' + settings.focused_class).removeClass(settings.focused_class);
74
75            var $input = $(this);
76
77            $input.parents().filter('.'+settings.holder_class+':first').addClass(settings.focused_class);
78            
79            if($input.val() == $input.data('default-value')){
80                $input.val("");
81            }
82
83            $input.not('select').css('color',$input.data('default-color'));
84        });
85
86        form.delegate(settings.field_selector,'blur',function() {
87            var $input = $(this);
88            form.find('.' + settings.focused_class).removeClass(settings.focused_class);
89            if($input.val() == "" || $input.val() == $input.data('default-value')){
90                $input.not('select').css("color",settings.default_value_color);
91                $input.val($input.data('default-value'));
92            } else {
93                $input.css('color',$input.data('default-color'));
94            }
95        });
96
97        form.delegate(settings.field_selector,'error',function(e,text) {
98            validate($(this),false,text);
99        });
100
101        form.delegate(settings.field_selector,'success',function(e,text) {
102            validate($(this),true);
103        });
104    });
105};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.