18516761980
2021-06-07 f5da19565cebc364d23a65ebe931b3c38cecfa09
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
Bootstrap datefield input - modification for inline mode.
Shows normal <input type="text"> and binds popup datepicker.
Automatically shown in inline mode.
 
@class datefield
@extends date
 
@since 1.4.0
**/
(function ($) {
    "use strict";
 
    var DateField = function (options) {
        this.init('datefield', options, DateField.defaults);
        this.initPicker(options, DateField.defaults);
    };
 
    $.fn.editableutils.inherit(DateField, $.fn.editabletypes.date);
 
    $.extend(DateField.prototype, {
        render: function () {
            this.$input = this.$tpl.find('input');
            this.setClass();
            this.setAttr('placeholder');
 
            //bootstrap-datepicker is set `bdateicker` to exclude conflict with jQuery UI one. (in date.js)
            this.$input.bdatepicker(this.options.datepicker);
 
            //need to disable original event handlers
            this.$input.off('focus keydown');
 
            //update value of datepicker
            this.$input.keyup($.proxy(function(){
               this.$tpl.removeData('date');
               this.$tpl.bdatepicker('update');
            }, this));
 
        },
 
       value2input: function(value) {
           this.$input.val(value ? this.dpg.formatDate(value, this.parsedViewFormat, this.options.datepicker.language) : '');
           this.$tpl.bdatepicker('update');
       },
 
       input2value: function() {
           return this.html2value(this.$input.val());
       },
 
       activate: function() {
           $.fn.editabletypes.text.prototype.activate.call(this);
       },
 
       autosubmit: function() {
         //reset autosubmit to empty
       }
    });
 
    DateField.defaults = $.extend({}, $.fn.editabletypes.date.defaults, {
        /**
        @property tpl
        **/
        tpl:'<div class="input-append date"><input type="text"/><span class="add-on"><i class="icon-th"></i></span></div>',
        /**
        @property inputclass
        @default 'input-small'
        **/
        inputclass: 'input-small',
 
        /* datepicker config */
        datepicker: {
            weekStart: 0,
            startView: 0,
            minViewMode: 0,
            autoclose: true
        }
    });
 
    $.fn.editabletypes.datefield = DateField;
 
}(window.jQuery));