/
splitterSide.js
336 lines (302 loc) · 11.2 KB
/
splitterSide.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/**
* @ngdoc directive
* @id splitter-side
* @name ons-splitter-side
* @category control
* @description
* [en]The "ons-splitter-side" element is used as a child element of "ons-splitter".[/en]
* [ja]ons-splitter-side要素は、ons-splitter要素の子要素として利用します。[/ja]
* @example
* <ons-splitter>
* <ons-splitter-content>
* ...
* </ons-splitter-content>
*
* <ons-splitter-side side="left" width="80%" collapse>
* ...
* </ons-splitter-side>
* </ons-splitter>
*/
/**
* @ngdoc event
* @name modechange
* @description
* [en]Fired just after the component's mode changes.[/en]
* [ja]この要素のモードが変化した際に発火します。[/ja]
* @param {Object} event
* [en]Event object.[/en]
* [ja]イベントオブジェクトです。[/ja]
* @param {Object} event.side
* [en]Component object.[/en]
* [ja]コンポーネントのオブジェクト。[/ja]
* @param {String} event.mode
* [en]Returns the current mode. Can be either "collapse" or "split".[/en]
* [ja]現在のモードを返します。[/ja]
*/
/**
* @ngdoc event
* @name preopen
* @description
* [en]Fired just before the sliding menu is opened.[/en]
* [ja]スライディングメニューが開く前に発火します。[/ja]
* @param {Object} event
* [en]Event object.[/en]
* [ja]イベントオブジェクトです。[/ja]
* @param {Function} event.cancel
* [en]Call to cancel opening sliding menu.[/en]
* [ja]スライディングメニューが開くのをキャンセルします。[/ja]
* @param {Object} event.side
* [en]Component object.[/en]
* [ja]コンポーネントのオブジェクト。[/ja]
*/
/**
* @ngdoc event
* @name postopen
* @description
* [en]Fired just after the sliding menu is opened.[/en]
* [ja]スライディングメニューが開いた後に発火します。[/ja]
* @param {Object} event
* [en]Event object.[/en]
* [ja]イベントオブジェクトです。[/ja]
* @param {Object} event.side
* [en]Component object.[/en]
* [ja]コンポーネントのオブジェクト。[/ja]
*/
/**
* @ngdoc event
* @name preclose
* @description
* [en]Fired just before the sliding menu is closed.[/en]
* [ja]スライディングメニューが閉じる前に発火します。[/ja]
* @param {Object} event
* [en]Event object.[/en]
* [ja]イベントオブジェクトです。[/ja]
* @param {Object} event.side
* [en]Component object.[/en]
* [ja]コンポーネントのオブジェクト。[/ja]
* @param {Function} event.cancel
* [en]Call to cancel opening sliding-menu.[/en]
* [ja]スライディングメニューが閉じるのをキャンセルします。[/ja]
*/
/**
* @ngdoc event
* @name postclose
* @description
* [en]Fired just after the sliding menu is closed.[/en]
* [ja]スライディングメニューが閉じた後に発火します。[/ja]
* @param {Object} event
* [en]Event object.[/en]
* [ja]イベントオブジェクトです。[/ja]
* @param {Object} event.side
* [en]Component object.[/en]
* [ja]コンポーネントのオブジェクト。[/ja]
*/
/**
* @ngdoc attribute
* @name animation
* @initonly
* @type {String}
* @description
* [en]Specify the animation. Use one of "overlay", and "default".[/en]
* [ja]アニメーションを指定します。"overlay", "default"のいずれかを指定できます。[/ja]
*/
/**
* @ngdoc attribute
* @name animation-options
* @type {Expression}
* @description
* [en]Specify the animation's duration, timing and delay with an object literal. E.g. <code>{duration: 0.2, delay: 1, timing: 'ease-in'}</code>[/en]
* [ja]アニメーション時のduration, timing, delayをオブジェクトリテラルで指定します。e.g. <code>{duration: 0.2, delay: 1, timing: 'ease-in'}</code>[/ja]
*/
/**
* @ngdoc attribute
* @name ons-destroy
* @initonly
* @extensionOf angular
* @type {Expression}
* @description
* [en]Allows you to specify custom behavior when the "destroy" event is fired.[/en]
* [ja]"destroy"イベントが発火された時の挙動を独自に指定できます。[/ja]
*/
/**
* @ngdoc attribute
* @name ons-preopen
* @initonly
* @extensionOf angular
* @type {Expression}
* @description
* [en]Allows you to specify custom behavior when the "preopen" event is fired.[/en]
* [ja]"preopen"イベントが発火された時の挙動を独自に指定できます。[/ja]
*/
/**
* @ngdoc attribute
* @name ons-preclose
* @initonly
* @extensionOf angular
* @type {Expression}
* @description
* [en]Allows you to specify custom behavior when the "preclose" event is fired.[/en]
* [ja]"preclose"イベントが発火された時の挙動を独自に指定できます。[/ja]
*/
/**
* @ngdoc attribute
* @name ons-postopen
* @extensionOf angular
* @initonly
* @type {Expression}
* @description
* [en]Allows you to specify custom behavior when the "postopen" event is fired.[/en]
* [ja]"postopen"イベントが発火された時の挙動を独自に指定できます。[/ja]
*/
/**
* @ngdoc attribute
* @name ons-postclose
* @extensionOf angular
* @initonly
* @type {Expression}
* @description
* [en]Allows you to specify custom behavior when the "postclose" event is fired.[/en]
* [ja]"postclose"イベントが発火された時の挙動を独自に指定できます。[/ja]
*/
/**
* @ngdoc attribute
* @name collapse
* @type {String}
* @description
* [en]
* Specify the collapse behavior. Valid values are "portrait", "landscape" or a media query.
* "portrait" or "landscape" means the view will collapse when device is in landscape or portrait orientation.
* If the value is a media query, the view will collapse when the media query is true.
* If the value is not defined, the view always be in "collapse" mode.
* [/en]
* [ja]
* 左側のページを非表示にする条件を指定します。portrait, landscape、width #pxもしくはメディアクエリの指定が可能です。
* portraitもしくはlandscapeを指定すると、デバイスの画面が縦向きもしくは横向きになった時に適用されます。
* メディアクエリを指定すると、指定したクエリに適合している場合に適用されます。
* 値に何も指定しない場合には、常にcollapseモードになります。
* [/ja]
*/
/**
* @ngdoc attribute
* @name swipe-target-width
* @type {String}
* @description
* [en]The width of swipeable area calculated from the edge (in pixels). Use this to enable swipe only when the finger touch on the screen edge.[/en]
* [ja]スワイプの判定領域をピクセル単位で指定します。画面の端から指定した距離に達するとページが表示されます。[/ja]
*/
/**
* @ngdoc attribute
* @name width
* @type {String}
* @description
* [en]Can be specified in either pixels or as a percentage, e.g. "90%" or "200px".[/en]
* [ja]この要素の横幅を指定します。pxと%での指定が可能です。eg. 90%, 200px[/ja]
*/
/**
* @ngdoc attribute
* @name side
* @type {String}
* @description
* [en]Specify which side of the screen the ons-splitter-side element is located on. Possible values are "left" and "right".[/en]
* [ja]この要素が左か右かを指定します。指定できる値は"left"か"right"のみです。[/ja]
*/
/**
* @ngdoc attribute
* @name mode
* @type {String}
* @description
* [en]Current mode. Possible values are "collapse" or "split". This attribute is read only.[/en]
* [ja]現在のモードが設定されます。"collapse"もしくは"split"が指定されます。この属性は読み込み専用です。[/ja]
*/
/**
* @ngdoc attribute
* @name page
* @initonly
* @type {String}
* @description
* [en]The url of the menu page.[/en]
* [ja]ons-splitter-side要素に表示するページのURLを指定します。[/ja]
*/
/**
* @ngdoc attribute
* @name swipeable
* @type {Boolean}
* @description
* [en]Whether to enable swipe interaction on collapse mode.[/en]
* [ja]collapseモード時にスワイプ操作を有効にする場合に指定します。[/ja]
*/
/**
* @ngdoc method
* @signature load(page)
* @param {String} page
* [en]Page URL. Can be either an HTML document or an <ons-template>.[/en]
* [ja]pageのURLか、ons-templateで宣言したテンプレートのid属性の値を指定します。[/ja]
* @description
* [en]Show the page specified in pageUrl in the right section[/en]
* [ja]指定したURLをメインページを読み込みます。[/ja]
*/
/**
* @ngdoc method
* @signature open([options])
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクト。[/ja]
* @param {Function} [options.callback]
* [en]This function will be called after the menu has been opened.[/en]
* [ja]メニューが開いた後に呼び出される関数オブジェクトを指定します。[/ja]
* @description
* [en]Open menu in collapse mode.[/en]
* [ja]collapseモードになっているons-splitterside要素を開きます。[/ja]
*/
/**
* @ngdoc method
* @signature close([options])
* @param {Object} [options]
* [en]Parameter object.[/en]
* [ja]オプションを指定するオブジェクト。[/ja]
* @param {Function} [options.callback]
* [en]This function will be called after the menu has been closed.[/en]
* [ja]メニューが閉じた後に呼び出される関数オブジェクトを指定します。[/ja]
* @description
* [en]Close menu in collapse mode.[/en]
* [ja]collapseモードになっているons-splitter-side要素を閉じます。[/ja]
*/
/**
* @ngdoc method
* @signature getCurrentMode()
* @return {String}
* [en]Get current mode. Possible values are "collapse" or "split".[/en]
* [ja]このons-splitter-side要素の現在のモードを返します。"split"かもしくは"collapse"のどちらかです。[/ja]
*/
(function() {
'use strict';
var lastReady = window.OnsSplitterSideElement.rewritables.ready;
window.OnsSplitterSideElement.rewritables.ready = ons._waitDiretiveInit('ons-splitter-side', lastReady);
var lastLink = window.OnsSplitterSideElement.rewritables.link;
window.OnsSplitterSideElement.rewritables.link = function(element, target, callback) {
var view = angular.element(element).data('ons-splitter-side');
lastLink(element, target, function(target) {
view._link(target, callback);
});
};
angular.module('onsen').directive('onsSplitterSide', function($compile, SplitterSide, $onsen) {
return {
restrict: 'E',
compile: function(element, attrs) {
CustomElements.upgrade(element[0]);
return function(scope, element, attrs) {
CustomElements.upgrade(element[0]);
var view = new SplitterSide(scope, element, attrs);
$onsen.declareVarAttribute(attrs, view);
$onsen.registerEventHandlers(view, 'destroy');
element.data('ons-splitter-side', view);
scope.$on('$destroy', function() {
view._events = undefined;
element.data('ons-splitter-side', undefined);
});
$onsen.fireComponentEvent(element[0], 'init');
};
}
};
});
})();