fence-slider.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. $.fn.input = function(options) {
  2. var inputApis = [];
  3. this.each(function() {
  4. var inputApi = null;
  5. var actions = [];
  6. var row = findRow(this.parentNode);
  7. if (this.type === 'range' && row.classList.contains('mui-input-range')) {
  8. actions.push('slider');
  9. } else {
  10. var classList = this.classList;
  11. if (classList.contains('mui-input-clear')) {
  12. actions.push('clear');
  13. }
  14. if (!($.os.android && $.os.stream) && classList.contains('mui-input-speech')) {
  15. actions.push('speech');
  16. }
  17. if (classList.contains('mui-input-password')) {
  18. actions.push('password');
  19. }
  20. if (this.type === 'search' && row.classList.contains('mui-search')) {
  21. actions.push('search');
  22. }
  23. }
  24. var id = this.getAttribute('data-input-' + actions[0]);
  25. if (!id) {
  26. id = ++$.uuid;
  27. inputApi = $.data[id] = new Input(this, {
  28. actions: actions.join(',')
  29. });
  30. for (var i = 0, len = actions.length; i < len; i++) {
  31. this.setAttribute('data-input-' + actions[i], id);
  32. }
  33. } else {
  34. inputApi = $.data[id];
  35. }
  36. inputApis.push(inputApi);
  37. });
  38. return inputApis.length === 1 ? inputApis[0] : inputApis;
  39. };
  40. $.ready(function() {
  41. $('.mui-input-row input').input();
  42. });