Project

General

Profile

Statistics
| Branch: | Revision:

root / docs / www / colonyscout / internal / jeditable / contributed / jquery.jeditable.datepicker.js @ f59acf11

History | View | Annotate | Download (2.33 KB)

1
/*
2
    DatePicker plugin for Jeditable(http://www.appelsiini.net/projects/jeditable), 
3
    using datepicker plugin for jquery (http://www.eyecon.ro/datepicker/)
4
    Copyright (C) 2009 Enjalbert Vincent (WinWinWeb)
5

6
    Permission is hereby granted, free of charge, to any person obtaining a copy
7
        of this software and associated documentation files (the "Software"), to deal
8
        in the Software without restriction, including without limitation the rights
9
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
        copies of the Software, and to permit persons to whom the Software is
11
        furnished to do so, subject to the following conditions:
12
        # The above copyright notice and this permission notice shall be included in
13
        all copies or substantial portions of the Software.
14
        
15
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
        THE SOFTWARE.
22
    
23
    vincent.enjalbert at gmail dot com (French, English)
24

25
 */
26

    
27

    
28
$.editable.addInputType('datepicker', {
29
    /* create input element */
30
    element : function(settings, original) {
31
        var input = $('<input style="display:none">');
32
        var picker = $('<div id="datepicker_">');
33
        
34
        $(this).append(input);
35
        $(this).append(picker);
36
        return(input);
37
    },
38
    
39
    
40
    submit: function (settings, original) {
41
             $("input", this).val( $("#datepicker_", this).DatePickerGetDate('d/m/Y') );
42
    },
43
    
44
    
45
    content : function(string, settings, original) {
46
        $('input', this).val('');
47
    },
48
    
49
    
50
    /* attach 3rd party plugin to input element */
51
    plugin : function(settings, original) {
52
        var form = this;
53
        settings.onblur = null;
54
        if(settings.datepicker == null)
55
                $("#datepicker_", this).DatePicker({
56
                                        flat: true,
57
                                        date: '29/10/1985',
58
                                        format: 'd/m/Y',
59
                                        view: 'years',
60
                                        current: '29/10/1985',
61
                                        calendars: 1,
62
                                        starts: 1
63
                                });
64
        else
65
                $("#datepicker_", this).DatePicker(settings.datepicker);
66
    }
67
});