Revision 35a62b9d astakos/im/static/im/grnetstyles/js/form-errors.js

b/astakos/im/static/im/grnetstyles/js/form-errors.js
3 3
  $.fn.formErrors = function(options) {  
4 4
    return this.each(function() {
5 5
        var $this = $(this);
6

  
7
        // does the field has any errors ?
6 8
        var errors = $this.find(".errorlist");
7 9
        if (errors.length == 0) {
8 10
            return;
9 11
        }
10

  
12
        
13
        // create the custom error message block
14
        // and copy the contents of the original
15
        // error list
11 16
        var el = $('<div class="form-error" />');
12 17
        errors.find("li").each(function(){
13 18
            el.html(el.html() + $(this).text() + "<br />");
14 19
        })
20
        
21
        var formel = $this.find("input, select");
22
        var lbl = $this.find("label");
23
        var form = $this.closest("form");
15 24

  
16
        $("body").append(el);
17
        var left = $this.offset().left + $this.width() - 20;
18
        var top = $this.offset().top + el.height()/2 - 2;
19 25

  
20
        el.css({left: left + "px", top: top + "px", width: 'auto'});
26
        // append element on form row 
27
        // and apply the appropriate styles
28
        formel.closest(".form-row").append(el);
21 29
        errors.remove();
30
        var left = formel.width();
31
        var top = formel.height();
32
        var marginleft = lbl.width();
33
        
34
        // identify the position
35
        // forms with innerlbales class
36
        // display the label within the input fields
37
        if ($(form).hasClass("innerlabels")) {
38
            marginleft = 0;
39
        }
40
        
41
        var styles = {
42
            left: left + "px", 
43
            top: top + "px", 
44
            width: formel.outerWidth() - 10,
45
            marginLeft: marginleft,
46
            marginBottom: 5
47
        }
48
        el.css(styles);
22 49
    });
23 50

  
24 51
  };

Also available in: Unified diff