1 | import { dom, guid } from '../util';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | var lockcache = [];
|
17 |
|
18 | function lock(container, style) {
|
19 | var originStyle = container.getAttribute('style');
|
20 | var uuid = guid();
|
21 | lockcache.push({
|
22 | uuid: uuid,
|
23 | container: container,
|
24 | originStyle: originStyle
|
25 | });
|
26 | dom.setStyle(container, style);
|
27 | return uuid;
|
28 | }
|
29 |
|
30 | function unlock(container, uuid) {
|
31 | var list = lockcache.filter(function (i) {
|
32 | return i.container === container;
|
33 | });
|
34 | var item = list.find(function (i) {
|
35 | return i.uuid === uuid;
|
36 | });
|
37 | if (item) {
|
38 | var idx = list.indexOf(item);
|
39 |
|
40 | if (idx !== -1 && idx < list.length - 1) {
|
41 | var originStyle = item.originStyle;
|
42 |
|
43 | list[idx + 1].originStyle = originStyle;
|
44 | lockcache.splice(lockcache.indexOf(item), 1);
|
45 |
|
46 | return;
|
47 | }
|
48 |
|
49 | container.setAttribute('style', item.originStyle || '');
|
50 | lockcache.pop();
|
51 | }
|
52 | }
|
53 |
|
54 | export default {
|
55 | lock: lock,
|
56 | unlock: unlock
|
57 | }; |
\ | No newline at end of file |