var App = App || {}; App.dateControls = { element: $('input.datetimepicker'), init: function() { that = this; that.element.each(function(){ var $control = $(this); var type = $control.attr('data-type'); var options = JSON.parse($control.attr('data-options')); if (type === 'date') { $control.datepicker(options); } else if (type === 'time') { options['timeOnly'] = true; $control.datetimepicker(options); } else { $control.datetimepicker(options); } }); } }; App.sliderControl = { element: $('.slider-control'), init: function() { that = this; that.element.each(function(){ var $this = $(this); var $input = $('#' + $this.attr('data-slider-input')); var $value = $('#' + $this.attr('data-slider-value-element')); $this.slider({ range: $this.attr('data-slider-range'), min: parseFloat($this.attr('data-slider-min')), max: parseFloat($this.attr('data-slider-max')), values: [ $this.attr('data-slider-value1'), $this.attr('data-slider-value2') ], slide: function(event, ui) { $input.val(ui.values[0] + ';' + ui.values[1]); $value.html($this.attr('data-slider-caption') + ': ' + ui.values[0] + ' - ' + ui.values[1] + ' ' + $this.attr('data-slider-units')); }, stop: function(event, ui) { $input.trigger('change'); } }); }); } }; App.inputs = { init: function() { if (jQuery().niceSelect) { $('select').niceSelect(); } if (jQuery().filestyle) { $("input[type=file]").filestyle({ image: BASE_PATH + "/images/layout/form-file.png", imageheight: 29, imagewidth: 258, width: 258 }); } if (jQuery().prettyCheckable) { $('input[type=checkbox]').prettyCheckable(); } if (jQuery().dependentSelectBox) { $('[data-dependent-select]').dependentSelectBox(); } } }; $(function() { App.dateControls.init(); App.sliderControl.init(); App.inputs.init(); });