blob: e9be6638eac022884ee99d71f2e86f9f7755bbc9 (
plain)
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
128
129
130
131
132
133
134
135
136
|
var Scenery = new function(){
var base = this;
base.list = {}
base.nextMedia = null
base.nextWallpaper = null
base.mouse = new mouse ({ use_offset: false, mousedownUsesCapture: true })
base.init = function(){
base.resize.init()
base.sound.init()
}
base.add = function(opt){
var scene_media
switch (opt.media.type) {
case 'image':
scene_media = new Scenery.types.image (opt)
break
case 'video':
case 'youtube':
case 'vimeo':
if (is_mobile) return
scene_media = new Scenery.types.video (opt)
break
case 'soundcloud':
if (is_mobile) return
scene_media = new Scenery.types.audio (opt)
break
case 'text':
scene_media = new Scenery.types.text (opt)
scene_media.focused = !! opt.newMedia
break
}
base.list[scene_media.id] = scene_media
return scene_media
}
base.addNextToWall = function(opt){
opt.newMedia = true
opt.media = base.nextMedia
opt.index = opt.index || 0
var scene_media = base.add(opt)
// test if scenery was placed here
if (! scene_media) {
return null
}
else if (! scene_media.bounds) {
base.remove( scene_media.id )
return null
}
else {
base.nextMedia = null
return scene_media
}
}
base.find = function(id){
return base.list[id] || null
}
base.remove = function(id){
var scene_media = base.list[id]
delete base.list[id]
scene_media && scene_media.destroy()
}
base.removeAll = function(){
base.forEach(function(scene_media){
base.remove(scene_media.id)
})
}
base.uid = new UidGenerator(base.list)
base.forEach = function(f){
return base.values().forEach(f)
}
base.map = function(f){
return base.values().map(f)
}
base.values = function(){
return _.values(base.list)
}
base.serialize = function(){
var scenery = base.map(function(media){
return media.serialize()
})
return scenery
}
base.deserialize = function(scenery_data){
var added = []
scenery_data.forEach(function(data){
var wall = Walls.lookup[data.wall_id] || Walls.first()
var scene_media = base.add({
data: data,
wall: wall,
media: data.media,
id: data.id
})
added.push(scene_media)
})
return added
}
base.rewindAll = function(){
base.forEach(function(scenery){
if (scenery.type == "video") scenery.seek(0)
})
}
base.playAll = function(){
base.forEach(function(scenery){
if (scenery.type == "video") scenery.play()
})
}
base.pauseAll = function(){
base.forEach(function(scenery){
if (scenery.type == "video") scenery.pause()
})
}
return base
}
Scenery.types = {}
|