tres 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/javascripts/tres.coffee +20 -4
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|
data/javascripts/tres.coffee
CHANGED
@@ -21,6 +21,10 @@ defaultTemplate = _.template """
|
|
21
21
|
"""
|
22
22
|
# ---
|
23
23
|
|
24
|
+
# Keep a copy by reference of all screens that were instantiated so we
|
25
|
+
# can do things like tearing down the whole app.
|
26
|
+
Tres.screens = []
|
27
|
+
|
24
28
|
# Tres.Device handles/exposes device events (orientation change, accellerometer,
|
25
29
|
# etc), screen width, and other hardware-related goodies
|
26
30
|
class Device
|
@@ -60,6 +64,7 @@ class Tres.Screen extends Backbone.View
|
|
60
64
|
|
61
65
|
initialize: (options = {}) ->
|
62
66
|
_.extend @, options
|
67
|
+
Tres.screens.push @
|
63
68
|
|
64
69
|
# Returns the title of the screen, which will only exist if there's a
|
65
70
|
# header with a <h1> inside of it
|
@@ -83,7 +88,14 @@ class Tres.Screen extends Backbone.View
|
|
83
88
|
return false if @embedded
|
84
89
|
@render()
|
85
90
|
$body.prepend @el
|
86
|
-
@embedded =
|
91
|
+
@embedded = yes
|
92
|
+
@
|
93
|
+
|
94
|
+
# Destroys the element associated with the screen and flags as
|
95
|
+
# not embedded
|
96
|
+
teardown: ->
|
97
|
+
@$el.remove()
|
98
|
+
@embedded = no
|
87
99
|
@
|
88
100
|
|
89
101
|
# Runs whatever @submit method is declared, with the added bonus of
|
@@ -244,9 +256,6 @@ class Tres.App
|
|
244
256
|
constructor: (options = {}) ->
|
245
257
|
_.extend @, options
|
246
258
|
|
247
|
-
# All the screens that are currently instanced
|
248
|
-
screens: []
|
249
|
-
|
250
259
|
# Takes a hash to use as a mapping of URLs -> Tres.Screen objects
|
251
260
|
on: (map = {}) ->
|
252
261
|
_.each _.keys(map), (url) =>
|
@@ -269,6 +278,13 @@ class Tres.App
|
|
269
278
|
__super.apply Backbone.history, arguments
|
270
279
|
Backbone.history.start options
|
271
280
|
|
281
|
+
# Tears down every screen that was instantiated. Pass a list
|
282
|
+
# of arguments for types of screen that you'd like to stay
|
283
|
+
# intact
|
284
|
+
reboot: ->
|
285
|
+
for screen in Tres.screens
|
286
|
+
screen.teardown()
|
287
|
+
|
272
288
|
# ---
|
273
289
|
|
274
290
|
# Export to `window`
|