Sha256: b3e89f86938d05cc5e0482a51b0eac9a4996eb3bdf3b82da989e42638f647547

Contents?: true

Size: 1.97 KB

Versions: 4

Compression:

Stored size: 1.97 KB

Contents

function datetimepicker_init(){
    $(document).on('click', '.dpicker', function(e){
        e.stopPropagation();
        e.stopImmediatePropagation();
        $(this).datepicker({ format : 'dd/mm/yyyy', language : $('html').attr("lang") }).on('changeDate', function(ev){
            var eltid = ev.currentTarget.id;
            //eltid = $('#' + ev.currentTarget.id).data('id');
            $('#' + eltid + '_3i').val(ev.date.getDate());          // Day
            $('#' + eltid + '_2i').val(ev.date.getMonth()+1);       // Month
            $('#' + eltid + '_1i').val(ev.date.getFullYear());      // Year
        });
        $(this).change(function(){
            if( !$(this).val() ){
                id = '#' + $(this).data('id');
                $(id + '_3i').val("");
                $(id + '_2i').val("");
                $(id + '_1i').val("");
            }
        });
        $(this).trigger('focus');
        $(this).trigger('select');
    });
    $(document).on('click', '.input-group-addon', function(){
        try{
            dpick = $(this).parent().find('.dpicker');
            dpick.trigger('focus');
            dpick.trigger('select');
        }catch (e){
        }
    });
    $(document).on('click', '.tpicker', function(){
        $(this).timepicker({ template: 'modal', showMeridian: false, minuteStep: 1, defaultTime: false, showInputs: false, disableFocus: true }).on('change', function(ev){
            tpickerdate = new Date("01/01/1970 " + ev.currentTarget.value);
            var eltid = ev.currentTarget.id;
            //eltid = $('#' + ev.currentTarget.id).data('id');
            $('#' + eltid + '_4i').val(tpickerdate.getHours());  // Hour
            $('#' + eltid + '_5i').val(tpickerdate.getMinutes()); // Min
        });
        $(this).change(function(){
            if( !$(this).val() ){
                id = '#' + $(this).data('id');
                $(id + '_4i').val("");
                $(id + '_5i').val("");
            }
        });
        $(this).click();
    });
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
beautiful_scaffold-1.0.0.pre lib/generators/templates/app/assets/javascripts/bootstrap-datetimepicker-for-beautiful-scaffold.js
beautiful_scaffold-0.3.6 lib/generators/templates/app/assets/javascripts/bootstrap-datetimepicker-for-beautiful-scaffold.js
beautiful_scaffold-0.3.5 lib/generators/templates/app/assets/javascripts/bootstrap-datetimepicker-for-beautiful-scaffold.js
beautiful_scaffold-0.3.4 lib/generators/templates/app/assets/javascripts/bootstrap-datetimepicker-for-beautiful-scaffold.js