-
Notifications
You must be signed in to change notification settings - Fork 51
/
zindex.module.js
127 lines (108 loc) · 3.27 KB
/
zindex.module.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
(function() {
if (!this.require) {
var modules = {}, cache = {};
var require = function(name, root) {
var path = expand(root, name), indexPath = expand(path, './index'), module, fn;
module = cache[path] || cache[indexPath];
if (module) {
return module;
} else if (fn = modules[path] || modules[path = indexPath]) {
module = {id: path, exports: {}};
cache[path] = module.exports;
fn(module.exports, function(name) {
return require(name, dirname(path));
}, module);
return cache[path] = module.exports;
} else {
throw 'module ' + name + ' not found';
}
};
var expand = function(root, name) {
var results = [], parts, part;
// If path is relative
if (/^\.\.?(\/|$)/.test(name)) {
parts = [root, name].join('/').split('/');
} else {
parts = name.split('/');
}
for (var i = 0, length = parts.length; i < length; i++) {
part = parts[i];
if (part == '..') {
results.pop();
} else if (part != '.' && part != '') {
results.push(part);
}
}
return results.join('/');
};
var dirname = function(path) {
return path.split('/').slice(0, -1).join('/');
};
this.require = function(name) {
return require(name, '');
};
this.require.define = function(bundle) {
for (var key in bundle) {
modules[key] = bundle[key];
}
};
this.require.modules = modules;
this.require.cache = cache;
}
return this.require;
}).call(this);
this.require.define({"app/controllers/stage/zindex":function(exports, require, module){(function() {
var Collection, ZIndex;
Collection = require('lib/collection');
ZIndex = (function() {
function ZIndex(stage) {
this.stage = stage;
this.order = this.stage.elements;
}
ZIndex.prototype.bringForward = function(element) {
var index;
index = this.order.indexOf(element);
if (index !== -1 || index !== (this.order.length - 1)) {
this.order[index] = this.order[index + 1];
this.order[index + 1] = element;
}
return this.set();
};
ZIndex.prototype.bringBack = function(element) {
var index;
index = this.order.indexOf(element);
if (index !== -1 || index !== 0) {
this.order[index] = this.order[index - 1];
this.order[index - 1] = element;
}
return this.set();
};
ZIndex.prototype.bringToFront = function(element) {
var index;
index = this.order.indexOf(element);
this.order.splice(index, 1);
this.order.push(element);
return this.set();
};
ZIndex.prototype.bringToBack = function(element) {
var index;
index = this.order.indexOf(element);
this.order.splice(index, 1);
this.order.unshift(element);
return this.set();
};
ZIndex.prototype.set = function() {
var element, index, _len, _ref, _results;
_ref = this.order;
_results = [];
for (index = 0, _len = _ref.length; index < _len; index++) {
element = _ref[index];
_results.push(element.set('order', index));
}
return _results;
};
return ZIndex;
})();
module.exports = ZIndex;
}).call(this);
;}});