Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. Copyright 2013-2015 ASIAL CORPORATION
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. import util from './util';
  14. /**
  15. * @object ons.modifier
  16. * @category visual
  17. * @description
  18. * [en]
  19. * Utility methods to change modifier attributes of Onsen UI elements..
  20. * [/en]
  21. * [ja][/ja]
  22. * @example
  23. * ons.modifier.add(myOnsInputElement, 'underbar');
  24. * ons.modifier.toggle(myOnsToastElement, 'custom-modifier');
  25. *
  26. */
  27. export default {
  28. /**
  29. * @method add
  30. * @signature add(element, modifier [, modifier])
  31. * @description
  32. * [en]Add the specified modifiers to the element if they are not already included.[/en]
  33. * [ja][/ja]
  34. * @param {HTMLElement} element
  35. * [en]Target element.[/en]
  36. * [ja][/ja]
  37. * @param {String} modifier
  38. * [en]Name of the modifier.[/en]
  39. * [ja][/ja]
  40. */
  41. add: function add(element) {
  42. for (var _len = arguments.length, modifiers = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  43. modifiers[_key - 1] = arguments[_key];
  44. }
  45. return modifiers.forEach(function (modifier) {
  46. return util.addModifier(element, modifier);
  47. });
  48. },
  49. /**
  50. * @method remove
  51. * @signature remove(element, modifier [, modifier])
  52. * @description
  53. * [en]Remove the specified modifiers from the element if they are included.[/en]
  54. * [ja][/ja]
  55. * @param {HTMLElement} element
  56. * [en]Target element.[/en]
  57. * [ja][/ja]
  58. * @param {String} modifier
  59. * [en]Name of the modifier.[/en]
  60. * [ja][/ja]
  61. */
  62. remove: function remove(element) {
  63. for (var _len2 = arguments.length, modifiers = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  64. modifiers[_key2 - 1] = arguments[_key2];
  65. }
  66. return modifiers.forEach(function (modifier) {
  67. return util.removeModifier(element, modifier);
  68. });
  69. },
  70. /**
  71. * @method contains
  72. * @signature contains(element, modifier)
  73. * @description
  74. * [en]Check whether the specified modifier is included in the element.[/en]
  75. * [ja][/ja]
  76. * @param {HTMLElement} element
  77. * [en]Target element.[/en]
  78. * [ja][/ja]
  79. * @param {String} modifier
  80. * [en]Name of the modifier.[/en]
  81. * [ja][/ja]
  82. * @return {Boolean}
  83. * [en]`true` when the specified modifier is found in the element's `modifier` attribute. `false` otherwise.[/en]
  84. * [ja][/ja]
  85. */
  86. contains: util.hasModifier,
  87. /**
  88. * @method toggle
  89. * @signature toggle(element, modifier [, force])
  90. * @description
  91. * [en]Toggle the specified modifier.[/en]
  92. * [ja][/ja]
  93. * @param {HTMLElement} element
  94. * [en]Target element.[/en]
  95. * [ja][/ja]
  96. * @param {String} modifier
  97. * [en]Name of the modifier.[/en]
  98. * [ja][/ja]
  99. * @param {String} force
  100. * [en]If it evaluates to true, add specified modifier value, and if it evaluates to false, remove it.[/en]
  101. * [ja][/ja]
  102. */
  103. toggle: util.toggleModifier
  104. };