easy_menu 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/menu_bar.rb +33 -15
  2. metadata +13 -9
  3. checksums.yaml +0 -7
data/lib/menu_bar.rb CHANGED
@@ -32,7 +32,7 @@ class MenuBar
32
32
 
33
33
  yield mbg if block_given?
34
34
 
35
- store_menu_bar_content(mbc)
35
+ store_menu_bar_content(mbc, options)
36
36
  @groups << mbg
37
37
 
38
38
  return mbg
@@ -48,7 +48,7 @@ class MenuBar
48
48
 
49
49
  mbc = MenuBarContent.new(config, content, options)
50
50
 
51
- store_menu_bar_content(mbc)
51
+ store_menu_bar_content(mbc, options)
52
52
 
53
53
  return mbc
54
54
  end
@@ -61,7 +61,7 @@ class MenuBar
61
61
  mbi = MenuBarItem.new config, content, options
62
62
  mbc = MenuBarContent.new(config, mbi, options[:menu_bar_content])
63
63
 
64
- store_menu_bar_content(mbc)
64
+ store_menu_bar_content(mbc, options)
65
65
 
66
66
  return mbi
67
67
  end
@@ -73,7 +73,7 @@ class MenuBar
73
73
  mbi = MenuBarItem.new config, mbin, options[:menu_bar_item]
74
74
  mbc = MenuBarContent.new(config, mbi, options[:menu_bar_content])
75
75
 
76
- store_menu_bar_content(mbc)
76
+ store_menu_bar_content(mbc, options)
77
77
 
78
78
  return mbi
79
79
  end
@@ -91,7 +91,7 @@ class MenuBar
91
91
  # We give the menu bar content a special class so we can treat its contents differently than one without a menu inside
92
92
  mbc = MenuBarContent.new(config, mbt, merge_class(options[:menu_bar_content], config[:menu_bar_content_with_menu_class]))
93
93
 
94
- store_menu_bar_content(mbc)
94
+ store_menu_bar_content(mbc, options)
95
95
 
96
96
  return m
97
97
  end
@@ -100,7 +100,7 @@ class MenuBar
100
100
  s = @template.content_tag :div, '', :class => config[:menu_bar_separator_class]
101
101
  mbc = MenuBarContent.new(config, s, options.reverse_merge(:remove_if_dangling => @options[:remove_dangling_separators]))
102
102
 
103
- store_menu_bar_content(mbc)
103
+ store_menu_bar_content(mbc, options)
104
104
 
105
105
  return s
106
106
  end
@@ -140,9 +140,11 @@ class MenuBar
140
140
  return html_opts
141
141
  end
142
142
 
143
- # Ensure that right aligned menu bar content appears on the page in the order it is inserted
144
- def store_menu_bar_content(mbc)
145
- if mbc.right_aligned?
143
+ def store_menu_bar_content(mbc, options = {})
144
+ if options[:index]
145
+ @content.insert(options[:index], mbc)
146
+ # Ensure that right aligned menu bar content appears on the page in the order it is inserted
147
+ elsif mbc.right_aligned?
146
148
  @content.prepend(mbc)
147
149
  else
148
150
  @content << mbc
@@ -164,7 +166,7 @@ class MenuBar
164
166
  end
165
167
 
166
168
  def empty?
167
- @content.join.blank?
169
+ @content.all?(&:blank?)
168
170
  end
169
171
 
170
172
  def to_s
@@ -291,7 +293,9 @@ class MenuBar
291
293
 
292
294
  yield mg if block_given?
293
295
 
294
- @content << MenuContent.new(config, [mgt, mg], options[:menu_content])
296
+ mc = MenuContent.new(config, [mgt, mg], options[:menu_content])
297
+
298
+ store_menu_content(mc, options)
295
299
 
296
300
  return mg
297
301
  end
@@ -304,21 +308,27 @@ class MenuBar
304
308
  content = block.call
305
309
  end
306
310
 
307
- @content << MenuContent.new(config, content, options)
311
+ mc = MenuContent.new(config, content, options)
312
+
313
+ store_menu_content(mc, options)
308
314
  end
309
315
 
310
316
  def menu_item(content, options = {})
311
317
  initialize_options(options)
312
318
 
313
319
  mi = MenuItem.new(config, content, options)
314
- @content << MenuContent.new(config, mi, options[:menu_content])
320
+ mc = MenuContent.new(config, mi, options[:menu_content])
321
+
322
+ store_menu_content(mc, options)
315
323
 
316
324
  return mi
317
325
  end
318
326
 
319
- def separator
327
+ def separator(options = {})
320
328
  s = @template.content_tag :div, '', :class => config[:menu_separator_class]
321
- @content << MenuContent.new(config, s)
329
+ mc = MenuContent.new(config, s)
330
+
331
+ store_menu_content(mc, options)
322
332
 
323
333
  return s
324
334
  end
@@ -332,6 +342,14 @@ class MenuBar
332
342
 
333
343
  return options
334
344
  end
345
+
346
+ def store_menu_content(mc, options = {})
347
+ if options[:index]
348
+ @content.insert(options[:index], mc)
349
+ else
350
+ @content << mc
351
+ end
352
+ end
335
353
  end
336
354
 
337
355
  class MenuGroup < Menu
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Nicholas Jakobsen
@@ -9,11 +10,12 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2015-03-10 00:00:00.000000000 Z
13
+ date: 2015-05-13 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: rails
16
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
20
  - - ">="
19
21
  - !ruby/object:Gem::Version
@@ -21,6 +23,7 @@ dependencies:
21
23
  type: :runtime
22
24
  prerelease: false
23
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
24
27
  requirements:
25
28
  - - ">="
26
29
  - !ruby/object:Gem::Version
@@ -31,41 +34,42 @@ executables: []
31
34
  extensions: []
32
35
  extra_rdoc_files: []
33
36
  files:
34
- - Gemfile
35
- - MIT-LICENSE
36
- - README
37
37
  - app/assets/images/icons.png
38
38
  - app/assets/javascripts/easy_menu_jquery.js
39
39
  - app/assets/javascripts/easy_menu_prototype.js
40
40
  - app/assets/stylesheets/_easy_menu_mixins.scss
41
41
  - app/assets/stylesheets/easy_menu.css.scss
42
42
  - app/helpers/menu_bar_helper.rb
43
- - config/initializers/easy_menu_scss_extensions.rb
44
43
  - lib/easy_menu.rb
45
44
  - lib/easy_menu_configuration.rb
46
45
  - lib/easy_menu_helpers.rb
47
46
  - lib/menu_bar.rb
47
+ - config/initializers/easy_menu_scss_extensions.rb
48
+ - MIT-LICENSE
49
+ - Gemfile
50
+ - README
48
51
  homepage:
49
52
  licenses: []
50
- metadata: {}
51
53
  post_install_message:
52
54
  rdoc_options: []
53
55
  require_paths:
54
56
  - lib
55
57
  required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
56
59
  requirements:
57
60
  - - ">="
58
61
  - !ruby/object:Gem::Version
59
62
  version: '0'
60
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
61
65
  requirements:
62
66
  - - ">="
63
67
  - !ruby/object:Gem::Version
64
68
  version: '0'
65
69
  requirements: []
66
70
  rubyforge_project:
67
- rubygems_version: 2.2.2
71
+ rubygems_version: 1.8.25
68
72
  signing_key:
69
- specification_version: 4
73
+ specification_version: 3
70
74
  summary: Simple menu bar dsl for Rails views
71
75
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 5ab5af8a5c2025b34e45706804f14bc1491c70e0
4
- data.tar.gz: 4f090a2e0b784be7622b7944cf61c9e0b352fa3d
5
- SHA512:
6
- metadata.gz: ad02588e586a6e13dbb820270cf6087e5c3890bc3cac9e147e9115c4e1f3e6aa0bf21cf49b018c2097307aae1fd7dfc882cc0cf725aa6a3200a3932d34f7b412
7
- data.tar.gz: ee776677c8ed61894ec0f1fc9d945d3ef4318df27a4036bd8f01a51bca3c0a7147140850782030d8401f7e1336427bb639406604dc126c30fb7727cc0501c58f