root/branches/Abonament/Wierszowki/Wierszowki.Web/Scripts/spiffy.js @ 787

Wersja 752, 2.7 KB (wprowadzona przez marek, 17 years temu)

wiersz

Line 
1$(document).ready(function() {
2$.dpText = {
3    TEXT_PREV_YEAR: 'Poprzedni rok',
4    TEXT_PREV_MONTH: 'Poprzedni miesiąc',
5    TEXT_NEXT_YEAR: 'Następny rok',
6    TEXT_NEXT_MONTH: 'Następny miesiąc',
7    TEXT_CLOSE: 'Zamknij',
8    TEXT_CHOOSE_DATE: 'Wybierz datę'
9}
10
11
12    // date pickers
13    Date.firstDayOfWeek = 1;
14    Date.format = 'yyyy-mm';
15
16    $('.date-pick').datePicker({ selectMonth: true, startDate: '2009-01-01'}).val(new Date().asString()).trigger('change');
17
18    // watermarks and row highlights     
19    $("[watermark]").each(function() {
20        this.value = $(this).attr("watermark");
21        $(this).addClass("watermark");
22    })
23    .focus(function() {
24        if (this.value === $(this).attr("watermark")) {
25            this.value = "";
26            $(this).removeClass("watermark");
27        }
28        // add row highlight
29        $(this).parents(".formitem").css("background-color", "#ddd");
30    })
31    .blur(function() {
32        if (this.value === "") {
33            this.value = $(this).attr("watermark");
34            $(this).addClass("watermark");
35        }
36        //remove row highlight
37        $(this).parents(".formitem").css("background-color", "");
38    });
39
40    //remove watermark when form is submitted
41    $("input:image, input:button, input:submit").click(function() {
42        $(this.form.elements).select("[watermark]").each(function() {
43            if (this.value === $(this).attr("watermark")) {
44                this.value = "";
45            }
46        });
47    });
48
49    // tooltips               
50    $(":text[title]").focus(function() {
51        var field = $(this);
52        field.after("<p id='tooltip'>" + this.title + "</p>");
53        var position = field.offset();
54        $("#tooltip")
55            .css("top", (position.top + 10) + "px")
56            .css("left", (position.left + field.width() + 10) + "px")
57            .fadeIn("slow");
58    })
59    .blur(function() {
60        $("#tooltip").remove();
61    });
62
63//    var options = {
64//        beforeSubmit: function(formData) {
65//            $.blockUI();
66//            formData.push({ name: 'ajax_submit', value: '1' });
67//        },
68//        success: function(result) {
69//            $.unblockUI();
70//            if (result.length == 0) {
71//                $("#messages").empty().append("Thanks!");
72//            }
73//            else {
74//                var list = $("#messages").empty().append($("<ul class=\"errors\">"));
75//                jQuery.each(result, function(index, item) {
76//                    list.append($("<li>").append(item));
77//                });               
78//            }
79//        },
80//        dataType: 'json'
81//    };
82//    $("form").ajaxForm(options);
83});
Notatka: Zobacz TracBrowser aby uzyskać więcej informacji.