/
splitterContent.js
94 lines (80 loc) · 2.78 KB
/
splitterContent.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
/**
* @ngdoc directive
* @id splitter-content
* @name ons-splitter-content
* @category control
* @description
* [en]The "ons-splitter-content" element is used as a child element of "ons-splitter".[/en]
* [ja]ons-splitter-content要素は、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 attribute
* @name ons-destroy
* @extensionOf angular
* @initonly
* @type {Expression}
* @description
* [en]Allows you to specify custom behavior when the "destroy" event is fired.[/en]
* [ja]"destroy"イベントが発火された時の挙動を独自に指定できます。[/ja]
*/
/**
* @ngdoc attribute
* @name page
* @initonly
* @type {String}
* @description
* [en]The url of the menu page.[/en]
* [ja]ons-splitter-side要素に表示するページのURLを指定します。[/ja]
*/
/**
* @ngdoc method
* @signature load(pageUrl)
* @param {String} pageUrl
* [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]
*/
(function() {
'use strict';
var lastReady = window.OnsSplitterContentElement.rewritables.ready;
window.OnsSplitterContentElement.rewritables.ready = ons._waitDiretiveInit('ons-splitter-content', lastReady);
var lastLink = window.OnsSplitterContentElement.rewritables.link;
window.OnsSplitterContentElement.rewritables.link = function(element, target, callback) {
var view = angular.element(element).data('ons-splitter-content');
lastLink(element, target, function(target) {
view._link(target, callback);
});
};
angular.module('onsen').directive('onsSplitterContent', function($compile, SplitterContent, $onsen) {
return {
restrict: 'E',
compile: function(element, attrs) {
CustomElements.upgrade(element[0]);
return function(scope, element, attrs) {
CustomElements.upgrade(element[0]);
var view = new SplitterContent(scope, element, attrs);
$onsen.declareVarAttribute(attrs, view);
$onsen.registerEventHandlers(view, 'destroy');
element.data('ons-splitter-content', view);
scope.$on('$destroy', function() {
view._events = undefined;
element.data('ons-splitter-content', undefined);
});
$onsen.fireComponentEvent(element[0], 'init');
};
}
};
});
})();