3 $.fn.formCheckBoxes = function(options) {
\r
5 return this.each(function() {
\r
6 // process checkboxes
\r
8 var el = $('<a class="checkbox-widget" href="javascript:void(0)"/>');
\r
9 var form = $this.closest(".form-row");
\r
11 // add class to identify form rows which contain a checkbox
\r
12 form.addClass("with-checkbox");
\r
14 if ($this.prev().length > 0) {
\r
15 var lbl = $this.prev()[0];
\r
16 if (lbl.nodeName == "LABEL" || lbl.nodeName == "label") {
\r
17 $(lbl).addClass("checkbox-label");
\r
19 $(lbl).click(function(e){
\r
20 var src = e.srcElement.nodeName;
\r
21 if (src == "LABEL" || src == "label") {
\r
22 el.toggleClass("checked");
\r
29 if ($this.attr('checked')) {
\r
30 el.addClass("checked");
\r
33 el.click(function() {
\r
34 el.toggleClass("checked");
\r
35 $this.attr('checked', el.hasClass("checked"));
\r
38 el.keypress(function(e){
\r
40 if (e.keyCode == 0 || e.keyCode == 32){
\r
42 el.toggleClass("checked");
\r
43 $this.attr('checked', el.hasClass("checked"));
\r
47 $this.prev('label').before(el);
\r
53 $.fn.formErrors = function(options) {
\r
54 return this.each(function() {
\r
55 var $this = $(this);
\r
57 // does the field has any errors ?
\r
58 var errors = $this.find(".errorlist");
\r
59 if (errors.length == 0) {
\r
63 // create the custom error message block
\r
64 // and copy the contents of the original
\r
66 var el = $('<div class="form-error" />');
\r
67 errors.find("li").each(function(){
\r
68 el.html(el.html() + $(this).text() + "<br />");
\r
71 var formel = $this.find("input, select");
\r
72 var lbl = $this.find("label");
\r
73 var form = $this.closest("form");
\r
76 // append element on form row
\r
77 // and apply the appropriate styles
\r
78 formel.closest(".form-row").append(el);
\r
80 var left = formel.width();
\r
81 var top = formel.height();
\r
82 var marginleft = lbl.width();
\r
84 // identify the position
\r
85 // forms with innerlbales class
\r
86 // display the label within the input fields
\r
87 if ($(form).hasClass("innerlabels")) {
\r
94 width: formel.outerWidth() - 10,
\r
95 marginLeft: marginleft,
\r
99 if (formel.attr("type") != "checkbox") {
\r
102 el.css("margin-top", "5px");
\r