UNPKG

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