adaptive.ext.js 883 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * Adaptive
  3. */
  4. module.exports = {
  5. name: 'adaptive',
  6. methods: {
  7. // @extend
  8. _init: function () {
  9. var self = this;
  10. var $dummy = $('<p class="idealforms-field-width"/>').appendTo('body');
  11. this.opts.adaptiveWidth = $dummy.css('width').replace('px','')
  12. function adapt() {
  13. var formWidth = self.$form.outerWidth()
  14. , isAdaptive = self.opts.adaptiveWidth > formWidth;
  15. self.$form.toggleClass('adaptive', isAdaptive);
  16. if (self._hasExtension('steps')) {
  17. self.$stepsContainer.toggleClass('adaptive', isAdaptive);
  18. }
  19. $('#ui-datepicker-div').hide();
  20. }
  21. $(window).resize(adapt);
  22. adapt();
  23. this.$form.find('select, .datepicker').each(function() {
  24. self._getField(this).find(self.opts.error).addClass('hidden');
  25. });
  26. $dummy.remove();
  27. }
  28. }
  29. };