ruby_motion_query 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b38cbb8732d87fe11fa1177e562b9a289deecd2
4
- data.tar.gz: cecadfac15e816785d48ce4cbb23d9e930aec07a
3
+ metadata.gz: 06135a6091495e91324d14b0618089880d6aa351
4
+ data.tar.gz: 67755dca95594e80099768f3fc59020ed6cdd9e2
5
5
  SHA512:
6
- metadata.gz: 7cc1c6ebbd69132ddabb6a1ace110abca6c2e26911ee6e132f4478a117765d9316eea38cfe68d4f268a80947a65216929065a5a757f7513ccf5dab4430752cce
7
- data.tar.gz: a1d71f312572308d267a4d70823f1a0ae6304015e7e199d74706ecb64c5d0941ab604f3adad2c2c82b7958868a24db826db2db420f6dd12f6e60e0459c7c3cad
6
+ metadata.gz: 2c5a21dbe01295ee3a7f3b132f33c49a11baf6074788bb2349c68a7b9920faaac99cf6d52544452b784da32787f939db17e1b94ee947edbf81da0bcd93b9f23d
7
+ data.tar.gz: 6b282403f1eaf0a2b2a00ac22f37bac65f6dcc3472ee78e696d7da5f2197bc71c286503f1424faef08571ddbcf8b27f4e8dbf2bd33c07fbf70b62caf66392a1b
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  ![RMQ logo](https://raw.github.com/infinitered/rmq/master/resources/logo@2x.png?raw=true)
2
2
 
3
+ <br />
4
+
3
5
  # RMQ - RubyMotion Front-end Library
4
6
 
5
7
  [![Dependency Status](https://gemnasium.com/infinitered/rmq.png)](https://gemnasium.com/infinitered/rmq)
@@ -15,7 +17,17 @@ One of RMQ's goals is to have the best [documentation][1] of any RubyMotion UI l
15
17
 
16
18
  ----------
17
19
 
18
- ## Read the [RMQ Documentation][1] here
20
+ <br />
21
+ <br />
22
+
23
+ [![image](http://ir_wp.s3.amazonaws.com/wp-content/uploads/sites/19/2015/04/rmq_docs1.png)](http://rubymotionquery.com)
24
+
25
+ **Read the [RMQ Documentation][1] here**<-
26
+
27
+ **If you like RMQ, check out [RedPotion](http://redpotion.org), the ultimate gem for RubyMotion.**<-
28
+
29
+ <br />
30
+ <br />
19
31
 
20
32
  ----------
21
33
 
@@ -94,10 +106,8 @@ RMQ is available under the MIT license. See the [LICENSE](https://github.com/inf
94
106
 
95
107
  <br />
96
108
 
97
- ----------
98
109
 
99
110
  ## Read the [RMQ Documentation][1] here
100
111
 
101
- ----------
102
112
 
103
113
  [1]: http://rubymotionquery.com
data/motion/ext.rb CHANGED
@@ -82,7 +82,8 @@ if RUBYMOTION_ENV == "development"
82
82
  out[klass_name] = {
83
83
  class_name: klass_name,
84
84
  path: stylesheet_path_file,
85
- modified: File.mtime(stylesheet_path_file),
85
+ modified: File.mtime(stylesheet_path_file)
86
+ # TODO, for each stylehsheet find every view_controller that uses it and sub stylesheets
86
87
  }
87
88
  out
88
89
  end
@@ -109,10 +110,41 @@ if RUBYMOTION_ENV == "development"
109
110
 
110
111
  end
111
112
 
112
- rmq.view_controller.rmq.all.and_self.reapply_styles if style_changed
113
+ if style_changed
114
+ rmq_live_current_view_controllers.each do |vc|
115
+ vc.rmq.all.and_self.reapply_styles
116
+ end
117
+ end
113
118
  end
114
119
 
115
120
  "Live reloading of RMQ stylesheets is now on."
116
121
  end
122
+
123
+ def rmq_live_current_view_controllers(vc = nil)
124
+ vc = rmq.window.rootViewController unless vc
125
+ vcs = []
126
+
127
+ if vc.rmq.stylesheet
128
+ vcs << vc
129
+ end
130
+
131
+ if children_vcs = vc.childViewControllers
132
+ children_vcs.each do |child_vc|
133
+ vcs << rmq_live_current_view_controllers(child_vc)
134
+ end
135
+ end
136
+
137
+ vcs.flatten
138
+ end
139
+ end
140
+
141
+ module RubyMotionQuery
142
+ module Stylers
143
+ class UIViewStyler
144
+ def method_missing method, *args
145
+ puts "Sorry, #{method} is not implemented on #{self.class}. This will produce a crash when not in debug mode."
146
+ end
147
+ end
148
+ end
117
149
  end
118
150
  end
@@ -3,6 +3,8 @@ module RubyMotionQuery
3
3
  attr_accessor :block, :recognizer, :event, :sdk_event_or_recognizer, :gesture, :sender
4
4
 
5
5
  def initialize(sender, event, block)
6
+ block = block.respond_to?('weak!') ? block.weak! : block
7
+
6
8
  if CONTROL_EVENTS[event] == ValidationEvent
7
9
  return ValidationEvent.new(block)
8
10
  elsif @sdk_event_or_recognizer = VIEW_GESTURES[event]
@@ -50,8 +52,8 @@ module RubyMotionQuery
50
52
  if opts[:debounce]
51
53
  @debounce_length = opts[:debounce]
52
54
  @debounce_stamp = Time.now
53
- end
54
-
55
+ end
56
+
55
57
  if gesture?
56
58
  @recognizer.tap do |o|
57
59
  o.cancelsTouchesInView = opts[:cancels_touches_in_view] if opts.include?(:cancels_touches_in_view)
@@ -87,7 +89,7 @@ module RubyMotionQuery
87
89
 
88
90
  def location
89
91
  if gesture?
90
- @recognizer.locationInView(@sender)
92
+ @recognizer.locationInView(@sender)
91
93
  else
92
94
  @sender.convertRect(@sender.bounds, toView: nil).origin
93
95
  end
@@ -95,7 +97,7 @@ module RubyMotionQuery
95
97
 
96
98
  def location_in(view)
97
99
  if gesture?
98
- @recognizer.locationInView(view)
100
+ @recognizer.locationInView(view)
99
101
  else
100
102
  @sender.convertRect(@sender.bounds, toView: view).origin
101
103
  end
@@ -111,7 +113,7 @@ module RubyMotionQuery
111
113
  end
112
114
  end
113
115
 
114
- CONTROL_EVENTS = {
116
+ CONTROL_EVENTS = {
115
117
  touch: UIControlEventTouchUpInside,
116
118
  touch_up: UIControlEventTouchUpInside,
117
119
  touch_down: UIControlEventTouchDown,
@@ -18,7 +18,7 @@ module RubyMotionQuery
18
18
  st.hidden = true
19
19
  st.frame = :full
20
20
  st.background_color = color.clear
21
- st.z_position = 999
21
+ st.z_position = 999
22
22
  #st.scale = @view_scale
23
23
  end
24
24
 
@@ -22,4 +22,4 @@ module RubyMotionQuery
22
22
  end
23
23
 
24
24
  end
25
- end
25
+ end
@@ -1,7 +1,7 @@
1
1
  module RubyMotionQuery
2
2
  module Stylers
3
3
 
4
- class UIImageViewStyler < UIViewStyler
4
+ class UIImageViewStyler < UIViewStyler
5
5
  def image=(value)
6
6
  @view.image = value
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module RubyMotionQuery
2
2
  module Stylers
3
3
 
4
- class UINavigationBarStyler < UIViewStyler
4
+ class UINavigationBarStyler < UIViewStyler
5
5
  end
6
6
 
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module RubyMotionQuery
2
2
  module Stylers
3
3
 
4
- class UIRefreshControlStyler < UIControlStyler
4
+ class UIRefreshControlStyler < UIControlStyler
5
5
  end
6
6
 
7
7
  end
@@ -15,6 +15,10 @@ module RubyMotionQuery
15
15
  end
16
16
  alias :unshift= :prepend_segments=
17
17
 
18
+ def init_with_segments=(value)
19
+ self.prepend_segments = value unless view_has_been_styled?
20
+ end
21
+
18
22
  end
19
23
  end
20
- end
24
+ end
@@ -1,7 +1,7 @@
1
1
  module RubyMotionQuery
2
2
  module Stylers
3
3
 
4
- class UISliderStyler < UIControlStyler
4
+ class UISliderStyler < UIControlStyler
5
5
  end
6
6
 
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module RubyMotionQuery
2
2
  module Stylers
3
3
 
4
- class UIStepperStyler < UIControlStyler
4
+ class UIStepperStyler < UIControlStyler
5
5
  end
6
6
 
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module RubyMotionQuery
2
2
  module Stylers
3
3
 
4
- class UISwitchStyler < UIControlStyler
4
+ class UISwitchStyler < UIControlStyler
5
5
  def on=(value) ; @view.setOn(value) ; end
6
6
  def on ; @view.isOn ; end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module RubyMotionQuery
2
2
  module Stylers
3
3
 
4
- class UITabBarStyler < UIViewStyler
4
+ class UITabBarStyler < UIViewStyler
5
5
  end
6
6
 
7
7
  end
@@ -43,6 +43,18 @@ module RubyMotionQuery
43
43
  end
44
44
  alias :apply_styles :apply_style
45
45
 
46
+ def remove_style(*style_names)
47
+ if style_names
48
+ selected.each do |view|
49
+ style_names.each do |style|
50
+ view.rmq_data.styles.delete(style)
51
+ end
52
+ end
53
+ end
54
+ self
55
+ end
56
+ alias :remove_styles :remove_style
57
+
46
58
  # Pass a block to apply styles, an inline way of applynig a style
47
59
  # @example
48
60
  # rmq(view).style{|st| st.background_color = rmq.color.blue}
@@ -1,13 +1,13 @@
1
- module RubyMotionQuery
1
+ module RubyMotionQuery
2
2
  class RMQ
3
3
 
4
4
  # Most everything uses filter to do its work. This is mostly used internally
5
5
  # but you can use it too. Just pass a block that returns views, it will be
6
6
  # called for every view that is *selected*
7
7
  #
8
- # @param return_array returns array not rmq: return_array: true
9
- # @param uniq removes duplicate views: uniq: true
10
- # @param limit limits the number of views *per selected view*: limit: true
8
+ # @param return_array returns array not rmq: return_array: true
9
+ # @param uniq removes duplicate views: uniq: true
10
+ # @param limit limits the number of views *per selected view*: limit: true
11
11
  #
12
12
  # @return [RMQ]
13
13
  def filter(opts = {}, &block)
@@ -17,7 +17,7 @@ module RubyMotionQuery
17
17
  selected.each do |view|
18
18
  results = yield(view)
19
19
  unless RMQ.is_blank?(results)
20
- out << results
20
+ out << results
21
21
  break if limit && (out.length >= limit)
22
22
  end
23
23
  end
@@ -85,7 +85,7 @@ module RubyMotionQuery
85
85
  end
86
86
  end
87
87
  alias :add_self :and_self
88
-
88
+
89
89
  # @return [RMQ] The parent rmq instance. This is useful when you want to go down
90
90
  # into the tree, then move back up to do more work. Like jQuery's "end"
91
91
  #
@@ -104,7 +104,7 @@ module RubyMotionQuery
104
104
  end
105
105
  alias :superview :parent
106
106
 
107
- # @return [RMQ] Instance selecting the parents, grandparents, etc, all the way up the tree
107
+ # @return [RMQ] Instance selecting the parents, grandparents, etc, all the way up the tree
108
108
  # of the selected view(s)
109
109
  #
110
110
  # @param selectors
@@ -232,7 +232,7 @@ module RubyMotionQuery
232
232
  end
233
233
  end
234
234
 
235
- # For each selected view, get the first view that matches the selector(s) by testing the view's parent and
235
+ # For each selected view, get the first view that matches the selector(s) by testing the view's parent and
236
236
  # traversing up through its ancestors in the tree
237
237
  #
238
238
  # @return [RMQ] Instance selecting the first parent or grandparent or ancestor up the tree of the selected view(s)
@@ -253,15 +253,15 @@ module RubyMotionQuery
253
253
  # Be mindful of that.
254
254
  #
255
255
  # When you call rmq within a controller or view, a new instance of RMQ is created with the selectors you may or may
256
- # not have supplied. That instance will determine what view_controller it should use for stuff like traversing,
256
+ # not have supplied. That instance will determine what view_controller it should use for stuff like traversing,
257
257
  # stylesheet, etc.
258
258
  #
259
259
  # * rmq method called in a controller: that controller is used
260
260
  #
261
- # * rmq method called in a view and that view is within the subview tree of a controller: that controller is used
261
+ # * rmq method called in a view and that view is within the subview tree of a controller: that controller is used
262
262
  #
263
263
  #
264
- # * rmq method called in a view and that view is NOT within any subview tree of any controller (common in a UITableViewCell
264
+ # * rmq method called in a view and that view is NOT within any subview tree of any controller (common in a UITableViewCell
265
265
  # for example). In this case it will use the view's controller or the "current controller". Generally
266
266
  # that is what is desired, however there are some situations where another controller should be used. In that
267
267
  # situation create your own rmq instance and assign the controller you'd rather use
@@ -291,9 +291,9 @@ module RubyMotionQuery
291
291
 
292
292
  #debug.assert(vc.is_a?(UIViewController), 'Invalid controller in weak_view_controller') do
293
293
  #{
294
- #vc: vc,
295
- #context: @context,
296
- #parent_rmq: self.parent_rmq,
294
+ #vc: vc,
295
+ #context: @context,
296
+ #parent_rmq: self.parent_rmq,
297
297
  #current_view_controller: RMQ.app.current_view_controller
298
298
  #}
299
299
  #end
@@ -333,7 +333,7 @@ module RubyMotionQuery
333
333
  self.root_view.window
334
334
  end
335
335
 
336
- protected
336
+ protected
337
337
 
338
338
  def closest_view(view, working_selectors)
339
339
  if nr = view.nextResponder
@@ -344,7 +344,7 @@ module RubyMotionQuery
344
344
  end
345
345
  else
346
346
  nil
347
- end
347
+ end
348
348
  end
349
349
 
350
350
  end
@@ -1,5 +1,5 @@
1
1
  module RubyMotionQuery
2
- VERSION = "1.3.4"
2
+ VERSION = "1.3.5"
3
3
 
4
4
  class RMQ
5
5
  def version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_motion_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Werth
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-20 00:00:00.000000000 Z
12
+ date: 2015-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon
@@ -152,4 +152,3 @@ signing_key:
152
152
  specification_version: 4
153
153
  summary: RubyMotionQuery - RMQ
154
154
  test_files: []
155
- has_rdoc: