nice 0.0.3 → 0.0.4
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.
- data/lib/assets/javascripts/nice_imp_jquery.js.coffee +65 -4
- data/lib/nice/js/caller.rb +6 -0
- data/lib/nice/version.rb +1 -1
- metadata +4 -4
|
@@ -3,11 +3,13 @@ class NiceJquery
|
|
|
3
3
|
|
|
4
4
|
# insert element after referencing node
|
|
5
5
|
@insert_after: (event) ->
|
|
6
|
-
|
|
6
|
+
act = (ref,ins) -> ref.after(ins)
|
|
7
|
+
NiceJquery.perform_transition(event.ref_node, event.new_node, act)
|
|
7
8
|
|
|
8
9
|
# insert element at first position inside referencing node
|
|
9
10
|
@insert_inside: (event) ->
|
|
10
|
-
|
|
11
|
+
act = (ref,ins) -> ref.prepend(ins)
|
|
12
|
+
NiceJquery.perform_transition(event.ref_node, event.new_node, act)
|
|
11
13
|
|
|
12
14
|
# remove all elements which are not of current state and all elements
|
|
13
15
|
# which are of current state and secondly annotated to be always updated.
|
|
@@ -30,11 +32,70 @@ class NiceJquery
|
|
|
30
32
|
xmlHttp.send(null)
|
|
31
33
|
eval(xmlHttp.responseText)
|
|
32
34
|
)
|
|
33
|
-
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# each DOM Manipulation should call this method which will apply the transition animation start values
|
|
40
|
+
# to the elements before inserting into the DOM tree and the trigger the animation
|
|
41
|
+
@perform_transition: (elem_ref, elem_new, action) ->
|
|
42
|
+
|
|
43
|
+
# get jquery obj of element to insert
|
|
44
|
+
e = $(elem_new)
|
|
45
|
+
e_ref = $(elem_ref)
|
|
46
|
+
return if !e? || !e_ref?
|
|
47
|
+
|
|
48
|
+
filter = '[data-state-transition][data-state-transition!="none"]'
|
|
49
|
+
animated_elements = e.find('*').andSelf().filter(filter)
|
|
50
|
+
|
|
51
|
+
styles = []
|
|
52
|
+
durations = []
|
|
53
|
+
easing = []
|
|
54
|
+
|
|
55
|
+
animated_elements.each (index,elem) =>
|
|
56
|
+
|
|
57
|
+
# get transition style
|
|
58
|
+
a_e = $(elem)
|
|
59
|
+
transition = a_e.data('state-transition')
|
|
60
|
+
|
|
61
|
+
# get custom defined transition definitions
|
|
62
|
+
if( NiceTransitions? )
|
|
63
|
+
transition_def = if(transition) then NiceTransitions[transition] else NiceTransitions.default
|
|
64
|
+
|
|
65
|
+
# if no custom definitions exist - generate a default to do something at least
|
|
66
|
+
if( !transition_def? )
|
|
67
|
+
if transition?
|
|
68
|
+
console.log("Custom Transition Definition for \"#{transition}\" is missing! Please create a NiceTransitions class and configure your transitions.")
|
|
69
|
+
|
|
70
|
+
# rescue default transition
|
|
71
|
+
transition_def =
|
|
72
|
+
duration: 200
|
|
73
|
+
easing: "linear"
|
|
74
|
+
properties:
|
|
75
|
+
opacity: 0.0
|
|
76
|
+
|
|
77
|
+
durations.push transition_def.duration
|
|
78
|
+
easing.push transition_def.easing
|
|
79
|
+
|
|
80
|
+
# get current style values and apply start values
|
|
81
|
+
style = {}
|
|
82
|
+
for style_key, style_val of transition_def.properties
|
|
83
|
+
old_value = a_e.css(style_key)
|
|
84
|
+
a_e.css(style_key, style_val)
|
|
85
|
+
style[style_key] = old_value
|
|
86
|
+
|
|
87
|
+
styles.push style
|
|
88
|
+
|
|
89
|
+
# insert element
|
|
90
|
+
action(e_ref, e)
|
|
91
|
+
|
|
92
|
+
# animate
|
|
93
|
+
animated_elements.each (index,elem) =>
|
|
94
|
+
$(elem).animate(styles[index],durations[index],easing[index]) if styles[index]?
|
|
34
95
|
|
|
35
96
|
## add event listener
|
|
36
97
|
document.addEventListener "nice.dom.InsertAfterEvent", NiceJquery.insert_after, false
|
|
37
98
|
document.addEventListener "nice.dom.InsertInsideEvent", NiceJquery.insert_inside, false
|
|
38
99
|
document.addEventListener "nice.dom.RemoveStateEvent", NiceJquery.remove_state_elements, false
|
|
39
100
|
document.addEventListener "nice.hist.ChangeURLEvent", NiceJquery.move_to_url, false
|
|
40
|
-
document.addEventListener "nice.hist.PopHistoryEvent", NiceJquery.insert_or_update_back_listener, false
|
|
101
|
+
document.addEventListener "nice.hist.PopHistoryEvent", NiceJquery.insert_or_update_back_listener, false
|
data/lib/nice/js/caller.rb
CHANGED
|
@@ -29,6 +29,12 @@ module Nice
|
|
|
29
29
|
def self.state_did_change prev_state, new_state
|
|
30
30
|
"NiceEventDispatcher.dispatch_event(\'nice.ui.StateDidChangeEvent\',{prev_state:\'#{prev_state}\', new_state:\"#{new_state}\"});"
|
|
31
31
|
end
|
|
32
|
+
|
|
33
|
+
# State Transition Animations
|
|
34
|
+
def self.perform_transition_animations
|
|
35
|
+
"NiceEventDispatcher.dispatch_event(\'nice.trsn.AnimateEvent\');"
|
|
36
|
+
end
|
|
37
|
+
|
|
32
38
|
end
|
|
33
39
|
end
|
|
34
40
|
end
|
data/lib/nice/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nice
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-06-
|
|
12
|
+
date: 2012-06-18 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|
|
@@ -97,7 +97,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
97
97
|
version: '0'
|
|
98
98
|
segments:
|
|
99
99
|
- 0
|
|
100
|
-
hash: -
|
|
100
|
+
hash: -2243244646297613030
|
|
101
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
none: false
|
|
103
103
|
requirements:
|
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
106
106
|
version: '0'
|
|
107
107
|
segments:
|
|
108
108
|
- 0
|
|
109
|
-
hash: -
|
|
109
|
+
hash: -2243244646297613030
|
|
110
110
|
requirements: []
|
|
111
111
|
rubyforge_project:
|
|
112
112
|
rubygems_version: 1.8.22
|