Project

General

Profile

Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (1.36 KB)

1
/*
2
 * Datepicker for Jeditable (currently buggy, not for production)
3
 *
4
 * Copyright (c) 2007-2008 Mika Tuupola
5
 *
6
 * Licensed under the MIT license:
7
 *   http://www.opensource.org/licenses/mit-license.php
8
 *
9
 * Depends on Datepicker jQuery plugin by Kelvin Luck:
10
 *   http://kelvinluck.com/assets/jquery/datePicker/v2/demo/
11
 *
12
 * Project home:
13
 *   http://www.appelsiini.net/projects/jeditable
14
 *
15
 * Revision: $Id$
16
 *
17
 */
18
 
19
$.editable.addInputType('datepicker', {
20
    /* create input element */
21
    element : function(settings, original) {
22
        var input = $('<input>');
23
        $(this).append(input);
24
        //$(input).css('opacity', 0.01);
25
        return(input);
26
    },
27
    /* attach 3rd party plugin to input element */
28
    plugin : function(settings, original) {
29
        /* Workaround for missing parentNode in IE */
30
        var form = this;
31
        settings.onblur = 'cancel';
32
        $("input", this)
33
        .datePicker({createButton:false})
34
        .bind('click', function() {
35
            //$(this).blur();
36
            $(this).dpDisplay();
37
            return false;
38
        })
39
        .bind('dateSelected', function(e, selectedDate, $td) {
40
            $(form).submit();
41
        })
42
        .bind('dpClosed', function(e, selected) {
43
            /* TODO: unneseccary calls reset() */
44
            //$(this).blur();
45
        })
46
        .trigger('change')
47
        .click();
48
    }
49
});