@urso/core 0.5.2 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/js/index.js +1 -1
- package/package.json +1 -1
- package/src/js/components/fullscreen/controller.js +1 -1
- package/src/js/modules/assets/service.js +1 -1
- package/src/js/modules/objects/_info.js +3 -2
- package/src/js/modules/objects/find.js +16 -98
- package/src/js/modules/objects/models/imagesAnimation.js +1 -1
- package/src/js/modules/objects/models/scrollbox.js +17 -14
- package/src/js/modules/objects/proxy.js +1 -1
- package/src/js/modules/objects/selector.js +136 -0
- package/src/js/modules/objects/service.js +1 -1
- package/src/js/modules/objects/styles.js +97 -7
- package/src/js/modules/template/types.js +32 -32
package/package.json
CHANGED
|
@@ -112,7 +112,7 @@ class ModulesAssetsService {
|
|
|
112
112
|
let texture = imageData.textures[i];
|
|
113
113
|
let newFilename = frame.filename;
|
|
114
114
|
|
|
115
|
-
if (frame.filename.
|
|
115
|
+
if (!frame.filename.includes('/'))
|
|
116
116
|
newFilename = folderPath + '/' + frame.filename;
|
|
117
117
|
|
|
118
118
|
Urso.cache.addFile(newFilename, texture);
|
|
@@ -3,9 +3,10 @@ Urso.Core.Modules.Objects = {
|
|
|
3
3
|
Cache: require('./cache.js'),
|
|
4
4
|
Controller: require('./controller.js'),
|
|
5
5
|
Find: require('./find.js'),
|
|
6
|
+
PropertyAdapter: require('./propertyAdapter.js'),
|
|
6
7
|
Proxy: require('./proxy.js'),
|
|
8
|
+
Selector: require('./selector.js'),
|
|
7
9
|
Service: require('./service.js'),
|
|
8
|
-
Styles: require('./styles.js')
|
|
9
|
-
PropertyAdapter: require('./propertyAdapter.js')
|
|
10
|
+
Styles: require('./styles.js')
|
|
10
11
|
};
|
|
11
12
|
require('./models/_info.js');
|
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
class ModulesObjectsFind {
|
|
2
|
+
|
|
2
3
|
constructor() {
|
|
3
4
|
this.singleton = true;
|
|
5
|
+
this._selector = this.getInstance('Selector');
|
|
4
6
|
};
|
|
5
7
|
|
|
8
|
+
/**
|
|
9
|
+
* find object(s) by selector (find, findOne, findAll)
|
|
10
|
+
* @param {String} selector
|
|
11
|
+
* @param {Boolean} findOneFlag
|
|
12
|
+
* @returns {mixed}
|
|
13
|
+
*/
|
|
6
14
|
do(selector, findOneFlag) {
|
|
7
15
|
let result = [];
|
|
8
|
-
let selectorsPartsParsed = this.
|
|
16
|
+
let selectorsPartsParsed = this._selector.parse(selector);
|
|
9
17
|
let lastRule = selectorsPartsParsed[selectorsPartsParsed.length - 1][0];
|
|
10
18
|
|
|
11
|
-
//get elements
|
|
19
|
+
//get elements by last rule
|
|
12
20
|
let testObjects = this.getInstance('Cache')[
|
|
13
21
|
'get' + Urso.helper.capitaliseFirstLetter(lastRule.type)
|
|
14
22
|
](lastRule.value);
|
|
15
23
|
|
|
16
|
-
if
|
|
24
|
+
//if its name or id we will transform one element to array of elements to test
|
|
25
|
+
if (lastRule.type !== 'class' && testObjects)
|
|
17
26
|
testObjects = [testObjects];
|
|
18
27
|
|
|
28
|
+
//no objects found to test --> return false
|
|
19
29
|
if (!testObjects || testObjects.length === 0)
|
|
20
30
|
return false;
|
|
21
31
|
|
|
22
|
-
//return findOneFlag with simple selector
|
|
32
|
+
//return findOneFlag with simple selector (selector with one rule)
|
|
23
33
|
if (
|
|
24
34
|
findOneFlag &&
|
|
25
35
|
selectorsPartsParsed.length === 1 &&
|
|
@@ -27,9 +37,9 @@ class ModulesObjectsFind {
|
|
|
27
37
|
)
|
|
28
38
|
return testObjects;
|
|
29
39
|
|
|
30
|
-
//check test objects all selectors parts
|
|
40
|
+
//check test objects for all selectors parts conformity
|
|
31
41
|
for (let testObject of testObjects) {
|
|
32
|
-
let testResult = this.
|
|
42
|
+
let testResult = this._selector.testObjectWithParsedSelector(
|
|
33
43
|
testObject,
|
|
34
44
|
selectorsPartsParsed
|
|
35
45
|
);
|
|
@@ -43,98 +53,6 @@ class ModulesObjectsFind {
|
|
|
43
53
|
|
|
44
54
|
return result;
|
|
45
55
|
};
|
|
46
|
-
|
|
47
|
-
_testObjectsForSelector(testObject, selectorsPartsParsed) {
|
|
48
|
-
let properties = selectorsPartsParsed[
|
|
49
|
-
selectorsPartsParsed.length - 1
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
if (!this._testObjectsProperties(testObject, properties))
|
|
53
|
-
return false;
|
|
54
|
-
|
|
55
|
-
if (selectorsPartsParsed.length === 1)
|
|
56
|
-
return true;
|
|
57
|
-
|
|
58
|
-
//now we will check objects parents (for complex selectors)
|
|
59
|
-
let parent = testObject.parent;
|
|
60
|
-
|
|
61
|
-
for (let i = selectorsPartsParsed.length - 2; i >= 0; i--) {
|
|
62
|
-
let parentProperties = selectorsPartsParsed[i];
|
|
63
|
-
let expectedParentFoundFlag = 0;
|
|
64
|
-
|
|
65
|
-
while (expectedParentFoundFlag !== 1 && parent) {
|
|
66
|
-
if (this._testObjectsProperties(parent, parentProperties))
|
|
67
|
-
expectedParentFoundFlag = 1;
|
|
68
|
-
|
|
69
|
-
parent = parent.parent;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (expectedParentFoundFlag === 1 && i === 0) //last propertie from selector and all is good
|
|
73
|
-
return true;
|
|
74
|
-
|
|
75
|
-
if (expectedParentFoundFlag === 0)
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
_testObjectsProperties(object, properties) {
|
|
81
|
-
for (let propertie of properties) {
|
|
82
|
-
if (propertie.type === 'class') {
|
|
83
|
-
if (
|
|
84
|
-
!object[propertie.type] ||
|
|
85
|
-
object[propertie.type].split(' ').indexOf(propertie.value) === -1
|
|
86
|
-
)
|
|
87
|
-
return false;
|
|
88
|
-
|
|
89
|
-
} else if (object[propertie.type] !== propertie.value)
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return true;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
_parseSelector(selector) {
|
|
97
|
-
let selectorsParts = selector.split(' ');
|
|
98
|
-
let selectorsPartsParsed = [];
|
|
99
|
-
|
|
100
|
-
for (let selectorsPart of selectorsParts) {
|
|
101
|
-
let selectorPartParsed = this._parseSelectorPart(selectorsPart);
|
|
102
|
-
|
|
103
|
-
if (!selectorPartParsed)
|
|
104
|
-
Urso.logger.error('ModulesObjectsService error, cannot parse selector part: ' + selectorsPart);
|
|
105
|
-
|
|
106
|
-
selectorsPartsParsed.push(selectorPartParsed);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return selectorsPartsParsed;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
_parseSelectorPart(selectorPart) {
|
|
113
|
-
const characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+";
|
|
114
|
-
const matchExpr = {
|
|
115
|
-
"id": new RegExp("^#(" + characterEncoding + ")"),
|
|
116
|
-
"name": new RegExp("^\\^(" + characterEncoding + ")"),
|
|
117
|
-
"class": new RegExp("^\\.(" + characterEncoding + ")")
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
let result = [];
|
|
121
|
-
|
|
122
|
-
for (let type in matchExpr) {
|
|
123
|
-
let foundItem = matchExpr[type].exec(selectorPart);
|
|
124
|
-
|
|
125
|
-
if (foundItem) {
|
|
126
|
-
result.push({ type: type, value: foundItem[1] });
|
|
127
|
-
|
|
128
|
-
let restSelectorPart = Urso.helper.stringReplace(foundItem[0], '', selectorPart);
|
|
129
|
-
let restItems = this._parseSelectorPart(restSelectorPart);
|
|
130
|
-
|
|
131
|
-
if (restItems)
|
|
132
|
-
return Urso.helper.mergeArrays(result, restItems);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return (result && result.length > 0) ? result : false;
|
|
137
|
-
};
|
|
138
56
|
}
|
|
139
57
|
|
|
140
58
|
module.exports = ModulesObjectsFind;
|
|
@@ -4,18 +4,21 @@ class ModulesObjectsModelsScrollbox extends Urso.Core.Modules.Objects.BaseModel
|
|
|
4
4
|
|
|
5
5
|
this.type = Urso.types.objects.SCROLLBOX;
|
|
6
6
|
this._addBaseObject();
|
|
7
|
-
this.
|
|
7
|
+
this._createScrollContent();
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
setupParams(params) {
|
|
11
11
|
super.setupParams(params);
|
|
12
12
|
|
|
13
|
-
this.
|
|
13
|
+
this.scrollContent = Urso.helper.recursiveGet('scrollContent', params, []);
|
|
14
14
|
this.dragScroll = Urso.helper.recursiveGet('dragScroll', params, true);
|
|
15
|
-
this.scrollType = Urso.helper.recursiveGet('scrollType', params,
|
|
15
|
+
this.scrollType = Urso.helper.recursiveGet('scrollType', params, 'auto'); // hidden / hiddenVertical / hiddenHorizontal / auto
|
|
16
|
+
|
|
17
|
+
this.width = Urso.helper.recursiveGet('width', params, false); //number format
|
|
18
|
+
this.height = Urso.helper.recursiveGet('height', params, false); //number format
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
_getScrollboxParams(){
|
|
21
|
+
_getScrollboxParams() {
|
|
19
22
|
return {
|
|
20
23
|
boxWidth: this.width,
|
|
21
24
|
boxHeight: this.height,
|
|
@@ -25,25 +28,25 @@ class ModulesObjectsModelsScrollbox extends Urso.Core.Modules.Objects.BaseModel
|
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
_setScrollWidth(){
|
|
29
|
-
if(this.scrollType ===
|
|
31
|
+
_setScrollWidth() {
|
|
32
|
+
if (this.scrollType === 'hiddenHorizontal' || this.scrollType === 'hidden') {
|
|
30
33
|
this._baseObject.scrollWidth = this.width;
|
|
31
34
|
this._baseObject.overflowX = 'hidden';
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
|
|
35
|
-
_setScrollHeight(){
|
|
36
|
-
if(this.scrollType ===
|
|
38
|
+
_setScrollHeight() {
|
|
39
|
+
if (this.scrollType === 'hiddenVertical' || this.scrollType === 'hidden') {
|
|
37
40
|
this._baseObject.scrollHeight = this.height;
|
|
38
|
-
this._baseObject.overflowY = 'hidden'
|
|
41
|
+
this._baseObject.overflowY = 'hidden';
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
let object = Urso.objects.create(child)
|
|
45
|
-
this._baseObject.content.addChild(object._baseObject)
|
|
46
|
-
})
|
|
45
|
+
_createScrollContent() {
|
|
46
|
+
this.scrollContent.forEach(child => {
|
|
47
|
+
let object = Urso.objects.create(child);
|
|
48
|
+
this._baseObject.content.addChild(object._baseObject);
|
|
49
|
+
});
|
|
47
50
|
|
|
48
51
|
this._baseObject.update();
|
|
49
52
|
}
|
|
@@ -155,7 +155,7 @@ class ModulesObjectsProxy {
|
|
|
155
155
|
|
|
156
156
|
_checkSelectorProperties(key) {
|
|
157
157
|
if (!this._safeFlag && this._getSelectorProperties().includes(key)) {
|
|
158
|
-
Urso.logger.error('ModulesObjectsProxy error: you are trying to change selector
|
|
158
|
+
Urso.logger.error('ModulesObjectsProxy error: you are trying to change selector property: ' + key);
|
|
159
159
|
Urso.logger.error('Notice: use functions addClass, removeClass, setId, setName');
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tools for selector parse and objects check
|
|
3
|
+
*/
|
|
4
|
+
class ModulesObjectsSelector {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
this.singleton = true;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* test object for selector
|
|
12
|
+
* @param {Object} testObject
|
|
13
|
+
* @param {String} selector
|
|
14
|
+
* @returns {Boolean}
|
|
15
|
+
*/
|
|
16
|
+
testObject(testObject, selector) {
|
|
17
|
+
let selectorsPartsParsed = this.parse(selector);
|
|
18
|
+
return this.testObjectWithParsedSelector(testObject, selectorsPartsParsed);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* test object for selector parts array
|
|
23
|
+
* @param {Object} testObject
|
|
24
|
+
* @param {Array} selectorsPartsParsed
|
|
25
|
+
* @returns {Boolean}
|
|
26
|
+
*/
|
|
27
|
+
testObjectWithParsedSelector(testObject, selectorsPartsParsed) {
|
|
28
|
+
let properties = selectorsPartsParsed[
|
|
29
|
+
selectorsPartsParsed.length - 1
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
if (!this._testObjectsProperties(testObject, properties))
|
|
33
|
+
return false;
|
|
34
|
+
|
|
35
|
+
if (selectorsPartsParsed.length === 1)
|
|
36
|
+
return true;
|
|
37
|
+
|
|
38
|
+
//now we will check objects parents (for complex selectors)
|
|
39
|
+
let parent = testObject.parent;
|
|
40
|
+
|
|
41
|
+
for (let i = selectorsPartsParsed.length - 2; i >= 0; i--) {
|
|
42
|
+
let parentProperties = selectorsPartsParsed[i];
|
|
43
|
+
let expectedParentFoundFlag = 0;
|
|
44
|
+
|
|
45
|
+
while (expectedParentFoundFlag !== 1 && parent) {
|
|
46
|
+
if (this._testObjectsProperties(parent, parentProperties))
|
|
47
|
+
expectedParentFoundFlag = 1;
|
|
48
|
+
|
|
49
|
+
parent = parent.parent;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (expectedParentFoundFlag === 1 && i === 0) //last property from selector and all is good
|
|
53
|
+
return true;
|
|
54
|
+
|
|
55
|
+
if (expectedParentFoundFlag === 0)
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* test object for properties list
|
|
62
|
+
* @param {Object} object
|
|
63
|
+
* @param {Array} properties - class, id or name with value. [{type:'class',value:'someClassName'}...]
|
|
64
|
+
* @returns {Boolean}
|
|
65
|
+
*/
|
|
66
|
+
_testObjectsProperties(object, properties) {
|
|
67
|
+
for (let property of properties) {
|
|
68
|
+
if (property.type === 'class') {
|
|
69
|
+
if (
|
|
70
|
+
!object[property.type] ||
|
|
71
|
+
!object[property.type].split(' ').includes(property.value)
|
|
72
|
+
)
|
|
73
|
+
return false;
|
|
74
|
+
|
|
75
|
+
} else if (object[property.type] !== property.value)
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return true;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* parse selector to a array of parts
|
|
84
|
+
* @param {String} selector
|
|
85
|
+
* @returns {Array}
|
|
86
|
+
*/
|
|
87
|
+
parse(selector) {
|
|
88
|
+
let selectorsParts = selector.split(' ');
|
|
89
|
+
let selectorsPartsParsed = [];
|
|
90
|
+
|
|
91
|
+
for (let selectorsPart of selectorsParts) {
|
|
92
|
+
let selectorPartParsed = this._parseSelectorPart(selectorsPart);
|
|
93
|
+
|
|
94
|
+
if (!selectorPartParsed)
|
|
95
|
+
Urso.logger.error('ModulesObjectsService error, cannot parse selector part: ' + selectorsPart);
|
|
96
|
+
|
|
97
|
+
selectorsPartsParsed.push(selectorPartParsed);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return selectorsPartsParsed;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* parse selectors one object part
|
|
105
|
+
* @param {String} selectorPart
|
|
106
|
+
* @returns {mixed}
|
|
107
|
+
*/
|
|
108
|
+
_parseSelectorPart(selectorPart) {
|
|
109
|
+
const characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+";
|
|
110
|
+
const matchExpr = {
|
|
111
|
+
"id": new RegExp("^#(" + characterEncoding + ")"),
|
|
112
|
+
"name": new RegExp("^\\^(" + characterEncoding + ")"),
|
|
113
|
+
"class": new RegExp("^\\.(" + characterEncoding + ")")
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
let result = [];
|
|
117
|
+
|
|
118
|
+
for (let type in matchExpr) {
|
|
119
|
+
let foundItem = matchExpr[type].exec(selectorPart);
|
|
120
|
+
|
|
121
|
+
if (foundItem) {
|
|
122
|
+
result.push({ type: type, value: foundItem[1] });
|
|
123
|
+
|
|
124
|
+
let restSelectorPart = Urso.helper.stringReplace(foundItem[0], '', selectorPart);
|
|
125
|
+
let restItems = this._parseSelectorPart(restSelectorPart);
|
|
126
|
+
|
|
127
|
+
if (restItems)
|
|
128
|
+
return Urso.helper.mergeArrays(result, restItems);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return (result && result.length > 0) ? result : false;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
module.exports = ModulesObjectsSelector;
|
|
@@ -92,7 +92,7 @@ class ModulesObjectsService {
|
|
|
92
92
|
case Urso.types.objects.HITAREA:
|
|
93
93
|
model = this.getInstance('Models.HitArea', object);
|
|
94
94
|
break;
|
|
95
|
-
case Urso.types.objects.
|
|
95
|
+
case Urso.types.objects.IMAGESANIMATION:
|
|
96
96
|
model = this.getInstance('Models.ImagesAnimation', object);
|
|
97
97
|
break;
|
|
98
98
|
case Urso.types.objects.TEXTINPUT:
|
|
@@ -5,8 +5,13 @@ class ModulesObjectsStyles {
|
|
|
5
5
|
this._cache = {};
|
|
6
6
|
this._tempObject = this.getInstance('BaseModel', {})
|
|
7
7
|
this._tempTextObject = this.getInstance('Models.Text', {})
|
|
8
|
+
this._selector = this.getInstance('Selector');
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* refresh styles
|
|
13
|
+
* @param {mixed} parent
|
|
14
|
+
*/
|
|
10
15
|
refresh(parent) {
|
|
11
16
|
if (!parent)
|
|
12
17
|
parent = this.getInstance('Controller').getWorld();
|
|
@@ -14,6 +19,16 @@ class ModulesObjectsStyles {
|
|
|
14
19
|
let template = Urso.template.get();
|
|
15
20
|
let styles = template.styles;
|
|
16
21
|
|
|
22
|
+
this._removeInactualStylesAndAddNew(parent, styles);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated
|
|
27
|
+
* remove all styles and re-add
|
|
28
|
+
* @param {Object} parent
|
|
29
|
+
* @param {Object} styles
|
|
30
|
+
*/
|
|
31
|
+
_removeAllStylesAndReAdd(parent, styles) {
|
|
17
32
|
this._globalResetStyles();
|
|
18
33
|
|
|
19
34
|
//todo consider parent
|
|
@@ -22,6 +37,22 @@ class ModulesObjectsStyles {
|
|
|
22
37
|
this._apply(selector, style);
|
|
23
38
|
}
|
|
24
39
|
|
|
40
|
+
/**
|
|
41
|
+
* remove inactual styles and add new if need
|
|
42
|
+
* @param {Object} parent
|
|
43
|
+
* @param {Object} styles
|
|
44
|
+
*/
|
|
45
|
+
_removeInactualStylesAndAddNew(parent, styles) {
|
|
46
|
+
this._resetInactualStyles();
|
|
47
|
+
|
|
48
|
+
for (let [selector, style] of Object.entries(styles))
|
|
49
|
+
this._apply(selector, style);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* refresh styles by changed className (when addClass or removeClass)
|
|
54
|
+
* @param {String} className
|
|
55
|
+
*/
|
|
25
56
|
refreshByChangedClassName(className) {
|
|
26
57
|
let template = Urso.template.get();
|
|
27
58
|
let styles = template.styles;
|
|
@@ -29,25 +60,46 @@ class ModulesObjectsStyles {
|
|
|
29
60
|
this._restoreDefaultsByCache(className);
|
|
30
61
|
|
|
31
62
|
for (let [selector, style] of Object.entries(styles))
|
|
32
|
-
if (selector.
|
|
63
|
+
if (selector.includes('.' + className))
|
|
33
64
|
this._apply(selector, style);
|
|
34
65
|
}
|
|
35
66
|
|
|
67
|
+
/**
|
|
68
|
+
* remove object from styles cache
|
|
69
|
+
* @param {Object} object
|
|
70
|
+
*/
|
|
36
71
|
removeFromCache(object) {
|
|
37
72
|
for (let selector in this._cache) {
|
|
38
73
|
if (this._cache[selector][object._uid]) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!Object.keys(this._cache[selector]).length)
|
|
42
|
-
delete this._cache[selector];
|
|
74
|
+
this._deleteFromCacheBySelector(selector, object);
|
|
43
75
|
}
|
|
44
76
|
}
|
|
45
77
|
}
|
|
46
78
|
|
|
79
|
+
/**
|
|
80
|
+
* delete object from inner cache by selector
|
|
81
|
+
* @param {String} selector
|
|
82
|
+
* @param {Object} object
|
|
83
|
+
*/
|
|
84
|
+
_deleteFromCacheBySelector(selector, object) {
|
|
85
|
+
delete this._cache[selector][object._uid];
|
|
86
|
+
|
|
87
|
+
if (!Object.keys(this._cache[selector]).length)
|
|
88
|
+
delete this._cache[selector];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* apply style to selector
|
|
93
|
+
* @param {String} selector
|
|
94
|
+
* @param {Object} style
|
|
95
|
+
*/
|
|
47
96
|
_apply(selector, style) {
|
|
48
97
|
let objectsArray = this.getInstance('Controller').findAll(selector);
|
|
49
98
|
|
|
50
99
|
for (let object of objectsArray) {
|
|
100
|
+
if (object._styles[selector])
|
|
101
|
+
continue;
|
|
102
|
+
|
|
51
103
|
this._addObjectToCache(selector, object);
|
|
52
104
|
object._styles[selector] = style;
|
|
53
105
|
|
|
@@ -57,6 +109,11 @@ class ModulesObjectsStyles {
|
|
|
57
109
|
}
|
|
58
110
|
}
|
|
59
111
|
|
|
112
|
+
/**
|
|
113
|
+
* add object to inner cache by selector
|
|
114
|
+
* @param {String} selector
|
|
115
|
+
* @param {Object} object
|
|
116
|
+
*/
|
|
60
117
|
_addObjectToCache(selector, object) {
|
|
61
118
|
if (!this._cache[selector])
|
|
62
119
|
this._cache[selector] = {};
|
|
@@ -64,6 +121,10 @@ class ModulesObjectsStyles {
|
|
|
64
121
|
this._cache[selector][object._uid] = object;
|
|
65
122
|
}
|
|
66
123
|
|
|
124
|
+
/**
|
|
125
|
+
* global reset(remove) all styles
|
|
126
|
+
* @deprecated
|
|
127
|
+
*/
|
|
67
128
|
_globalResetStyles() {
|
|
68
129
|
for (let [selector, selectorCache] of Object.entries(this._cache)) {
|
|
69
130
|
for (let [uid, object] of Object.entries(selectorCache))
|
|
@@ -73,9 +134,26 @@ class ModulesObjectsStyles {
|
|
|
73
134
|
}
|
|
74
135
|
}
|
|
75
136
|
|
|
137
|
+
/**
|
|
138
|
+
* reset(remove) inactual styles
|
|
139
|
+
*/
|
|
140
|
+
_resetInactualStyles() {
|
|
141
|
+
for (let [selector, selectorCache] of Object.entries(this._cache)) {
|
|
142
|
+
for (let [uid, object] of Object.entries(selectorCache))
|
|
143
|
+
if (!this._selector.testObject(object, selector)) {
|
|
144
|
+
this._removeSelectorStyles(object, selector);
|
|
145
|
+
this._deleteFromCacheBySelector(selector, object);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* restore default values after reset styles (when addClass or removeClass)
|
|
152
|
+
* @param {String} className
|
|
153
|
+
*/
|
|
76
154
|
_restoreDefaultsByCache(className) {
|
|
77
155
|
for (let [selector, selectorCache] of Object.entries(this._cache))
|
|
78
|
-
if (selector.
|
|
156
|
+
if (selector.includes('.' + className)) {
|
|
79
157
|
for (let [uid, object] of Object.entries(selectorCache))
|
|
80
158
|
this._removeSelectorStyles(object, selector);
|
|
81
159
|
|
|
@@ -83,12 +161,18 @@ class ModulesObjectsStyles {
|
|
|
83
161
|
}
|
|
84
162
|
}
|
|
85
163
|
|
|
164
|
+
/**
|
|
165
|
+
* remove all selector styles
|
|
166
|
+
* @param {Object} object
|
|
167
|
+
* @param {String} selector
|
|
168
|
+
* @param {Boolean} globalResetFlag
|
|
169
|
+
*/
|
|
86
170
|
_removeSelectorStyles(object, selector, globalResetFlag) {
|
|
87
171
|
delete object._styles[selector];
|
|
88
172
|
let template = Urso.template.get();
|
|
89
173
|
let styles = template.styles[selector];
|
|
90
174
|
|
|
91
|
-
if(!styles){
|
|
175
|
+
if (!styles) {
|
|
92
176
|
return;
|
|
93
177
|
}
|
|
94
178
|
|
|
@@ -98,6 +182,12 @@ class ModulesObjectsStyles {
|
|
|
98
182
|
|
|
99
183
|
}
|
|
100
184
|
|
|
185
|
+
/**
|
|
186
|
+
* restore value by key from original model
|
|
187
|
+
* @param {String} key
|
|
188
|
+
* @param {Object} object
|
|
189
|
+
* @param {Boolean} globalResetFlag
|
|
190
|
+
*/
|
|
101
191
|
_restoreValueByKey(key, object, globalResetFlag) {
|
|
102
192
|
//check own
|
|
103
193
|
if (object._originalModel[key])
|
|
@@ -2,42 +2,42 @@ class ModulesTemplateTypes {
|
|
|
2
2
|
constructor() {
|
|
3
3
|
this.list = {
|
|
4
4
|
assets: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
ATLAS: 1,
|
|
6
|
+
AUDIOSPRITE: 2,
|
|
7
|
+
BITMAPFONT: 3,
|
|
8
|
+
CONTAINER: 4,
|
|
9
|
+
FONT: 5,
|
|
10
|
+
IMAGE: 6,
|
|
11
|
+
JSON: 7,
|
|
12
|
+
SOUND: 8,
|
|
13
|
+
SPINE: 9
|
|
14
14
|
},
|
|
15
15
|
|
|
16
16
|
objects: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
17
|
+
ATLASIMAGE: 1,
|
|
18
|
+
BITMAPTEXT: 2,
|
|
19
|
+
BUTTON: 3,
|
|
20
|
+
BUTTONCOMPOSITE: 4,
|
|
21
|
+
CHECKBOX: 5,
|
|
22
|
+
COLLECTION: 6,
|
|
23
|
+
COMPONENT: 7,
|
|
24
|
+
CONTAINER: 8,
|
|
25
|
+
EMITTER: 9,
|
|
26
|
+
EMITTERFX: 10,
|
|
27
|
+
GRAPHICS: 11,
|
|
28
|
+
GROUP: 12,
|
|
29
|
+
HITAREA: 13,
|
|
30
|
+
IMAGE: 14,
|
|
31
|
+
IMAGESANIMATION: 15,
|
|
32
|
+
MASK: 16,
|
|
33
|
+
NINESLICEPLANE: 17,
|
|
34
|
+
SCROLLBOX: 18,
|
|
35
|
+
SLIDER: 19,
|
|
36
|
+
SPINE: 20,
|
|
37
|
+
TEXT: 21,
|
|
38
38
|
TEXTINPUT: 22,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
TOGGLE: 23,
|
|
40
|
+
WORLD: 24
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|