1 | (function() {
|
2 | 'use strict';
|
3 |
|
4 | window.Ractive.controller('pl-layout-platform', function(component, data, el, config, done) {
|
5 | var sectionsUsed = ['usebrand', 'usetitle', 'useprofile', 'usehelp', 'usemask'],
|
6 | Title = null;
|
7 |
|
8 | data.titleAreaHeight = 90;
|
9 | data.loaded = false;
|
10 |
|
11 | for (var i = 0; i < sectionsUsed.length; i++) {
|
12 | var use = sectionsUsed[i];
|
13 |
|
14 | data[use] = typeof data[use] == 'undefined' ? true : data[use];
|
15 | data[use] = data[use] == 'true' ? true : data[use];
|
16 | data[use] = data[use] == 'false' ? false : data[use];
|
17 | }
|
18 |
|
19 | var LayoutPlateform = component({
|
20 | plName: 'pl-layout-plateform',
|
21 | data: data
|
22 | }),
|
23 | Page = LayoutPlateform.parentRequire;
|
24 |
|
25 | function _updateTitleAreaHeight(height) {
|
26 | height += 50;
|
27 |
|
28 | LayoutPlateform.set('titleAreaHeight', height);
|
29 | LayoutPlateform.fire('titleAreaHeightChanged', {
|
30 | height: height,
|
31 | waiting: 550
|
32 | });
|
33 | }
|
34 |
|
35 | LayoutPlateform.on('titleOpen', function(args) {
|
36 | _updateTitleAreaHeight(args.height);
|
37 | });
|
38 |
|
39 | LayoutPlateform.on('titleClose', function(args) {
|
40 | _updateTitleAreaHeight(args.height);
|
41 | });
|
42 |
|
43 | LayoutPlateform.selectApp = function(name, fireFunc, callback) {
|
44 | if (!Title) {
|
45 | return;
|
46 | }
|
47 |
|
48 | Title.selectApp(name, fireFunc, callback);
|
49 | };
|
50 |
|
51 | LayoutPlateform.addApp = function(app, indexOrPosition) {
|
52 | if (!Title) {
|
53 | return;
|
54 | }
|
55 |
|
56 | Title.addTitle(app, indexOrPosition);
|
57 | };
|
58 |
|
59 | LayoutPlateform.removeApp = function(name) {
|
60 | if (!Title) {
|
61 | return;
|
62 | }
|
63 |
|
64 | Title.removeTitle(name);
|
65 | };
|
66 |
|
67 | setTimeout(function() {
|
68 | if (data.onloaded) {
|
69 | data.onloaded(LayoutPlateform);
|
70 | }
|
71 |
|
72 | LayoutPlateform.set('loaded', true);
|
73 |
|
74 | setTimeout(function() {
|
75 | LayoutPlateform.set('beforeStart', true);
|
76 |
|
77 | setTimeout(function() {
|
78 | $(LayoutPlateform.el).find('.pl-layout-mask').remove();
|
79 |
|
80 | var beforeRequire = data.beforerequire || function(l, callback) {
|
81 | callback();
|
82 | };
|
83 |
|
84 | beforeRequire(LayoutPlateform, function() {
|
85 | LayoutPlateform.set('beforerequire', null);
|
86 | data.beforerequire = null;
|
87 |
|
88 | LayoutPlateform.set('start', true);
|
89 |
|
90 | LayoutPlateform.require().then(function() {
|
91 | Title = LayoutPlateform.findChild('name', 'pl-dropdown-title');
|
92 |
|
93 | if (Title) {
|
94 | Title.on('open', function(args) {
|
95 | LayoutPlateform.fire('titleOpen', args);
|
96 | });
|
97 |
|
98 | Title.on('close', function(args) {
|
99 | LayoutPlateform.fire('titleClose', args);
|
100 | });
|
101 |
|
102 | Title.on('titleSelected', function(args) {
|
103 | var cls = Page.get('cls') || [];
|
104 | cls = cls.filter(function(value) {
|
105 | return value.indexOf('app-') !== 0;
|
106 | });
|
107 |
|
108 | cls.push('app-' + args.title.name
|
109 | .toLowerCase()
|
110 | .replace(/[^a-z0-9]/gi, '')
|
111 | );
|
112 |
|
113 | Page.set('cls', cls);
|
114 | });
|
115 |
|
116 | Title.fireSelected();
|
117 | }
|
118 |
|
119 | done();
|
120 | });
|
121 | });
|
122 | }, 550);
|
123 |
|
124 | }, 1500);
|
125 | });
|
126 | });
|
127 |
|
128 | })();
|