easy_menu 0.4.16 → 0.5.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5865091b943899a2c6656442bc6287895a06b330e1e36c7535145662d92971e3
4
- data.tar.gz: a109da0848084d2b4c064abfe5a5219f6351598d313534fbf9cda844d9e8154b
3
+ metadata.gz: 3b1e9ced377fa41ccde18eb63585c26db224c90265189c18630cf3912bb4df9f
4
+ data.tar.gz: dd2dfb7d78dc212fa78c3b4f129d5ce5537fe6ef32e13677fe9506fc01b5b4e1
5
5
  SHA512:
6
- metadata.gz: ac51bc463ae8bf829d71eca14efc0642f86df2be21b8653a0d70a1cb0f875be6703ef89d30ce2f61b6709e4a6b69c2208684e2de968ed6b46742d60a8bb9f416
7
- data.tar.gz: 3cf5fce8beb564f08aa4008eadb8d62e1f3be3fdb00109f5ee6397a1bf730f4a84b17eed496d499613f5103f633fe3ac3a5d3b38c3af92ca8c0c6211145ad490
6
+ metadata.gz: f1f95ffcbff00e46f1ba6eaef34244b86da72c97d73daf97a530b712c025457d8d9f2b6ce1aef57fa5d41fcf8f329176ec5c61530244f8fde5fd25c127edbf15
7
+ data.tar.gz: 6a5f6e530e9c2da66101db87c0bab4002322aa75b8f3f9ea21c3eaeae42de23b4c2da3f74a2d854aeffdc5bc0f782fb87d93bff4b67dcbaf48a074ed56081718
@@ -4,7 +4,10 @@ $(document).ready(function() {
4
4
  // Because some browsers don't support submit buttons outside of forms triggering form submits,
5
5
  // do it in javascript just to make sure it happens
6
6
  $(document).on('click', 'input[type=submit][form]', function(){
7
- if (form = document.getElementById(this.getAttribute('form'))) {
7
+ var formId = $(this).attr('form');
8
+ var form = document.getElementById(formId);
9
+
10
+ if (form) {
8
11
  // If the form is already submitting, we want don't want to submit it again.
9
12
  if ($(form).hasClass('submitting')) {
10
13
  return false;
@@ -13,56 +16,62 @@ $(document).ready(function() {
13
16
  var tempCommit = $("<input type='submit' name='commit' style='display:none'>");
14
17
  tempCommit.attr('value', $(this).attr('value'));
15
18
  form.appendChild(tempCommit[0]);
16
- tempCommit.click();
19
+ tempCommit.trigger('click');
17
20
  return false;
18
21
  }
19
22
  });
20
23
  // Used by the above click handler to determine if the browser already submitted the form.
21
- $('form').submit(function() {
24
+ $(document).on('submit', 'form', function() {
22
25
  $(this).addClass('submitting');
23
26
  });
24
27
 
25
28
  // Allow users to open and close menus by clicking
26
29
  $(menuBarRootSelector + '.menu_bar_content.with_menu').removeClass('no_js');
27
- $(menuBarRootSelector + '.menu_bar_content.with_menu .menu_bar_item').click(function(){
30
+ $(document).on('click', menuBarRootSelector + '.menu_bar_content.with_menu .menu_bar_item', function(){
28
31
  var mbc = $(this).closest('.menu_bar_content');
29
32
  $(menuBarRootSelector + '.menu_bar_content.with_menu').not(mbc).removeClass('open');
30
33
  mbc.toggleClass('open')
31
- .find('.menu').trigger('opened')
34
+ .find('.menu').trigger('opened');
32
35
  });
33
36
 
34
37
  // Close the menu when the user clicks or there is a form submission
35
38
  $(document).on('click submit', function(event) {
36
39
  // Don't close the menu if the click was on a menu_bar_item. This case is handled by the previous event handler
37
- if ($(event.target).closest('.menu_bar_content.with_menu .menu_bar_item').length > 0) { return }
40
+ if ($(event.target).closest('.menu_bar_content.with_menu .menu_bar_item').length > 0) { return; }
38
41
 
39
42
  // Don't close if we clicked inside a menu but not on a menu_item
40
- if ($(event.target).closest('.menu').length > 0 && $(event.target).closest('.menu_item').length === 0) { return }
43
+ if ($(event.target).closest('.menu').length > 0 && $(event.target).closest('.menu_item').length === 0) { return; }
41
44
 
42
45
  $(menuBarRootSelector + '.menu_bar_content.with_menu.open')
43
46
  .removeClass('open')
44
- .find('.menu').trigger('closed')
47
+ .find('.menu').trigger('closed');
45
48
  });
46
49
 
47
50
  // Disable Elements with a disable condition when that condition is met
48
51
  $(menuBarRootSelector + '.menu_bar_item[data-disable-event-element]').each(function(){
49
52
  var mbi = $(this);
50
- var observableElement = eval(mbi.getAttribute('data-disable-event-element'));
51
- var event = mbi.getAttribute('data-disable-event');
52
- var condition = mbi.getAttribute('data-disable-condition') || true;
53
+ var observableElementCode = mbi.attr('data-disable-event-element');
54
+ var event = mbi.attr('data-disable-event');
55
+ var conditionCode = mbi.attr('data-disable-condition') || 'true';
53
56
 
54
57
  var setState = function(){
55
- if (eval(condition)){
58
+ var observableElement = eval(observableElementCode);
59
+ var condition = eval(conditionCode);
60
+
61
+ if (condition){
56
62
  mbi.addClass('disabled');
57
63
  } else {
58
64
  mbi.removeClass('disabled');
59
65
  }
60
- }
66
+ };
61
67
 
62
68
  // Init the current state and bind the observer
63
- if (observableElement && event){
69
+ if (observableElementCode && event){
64
70
  setState();
65
- observableElement.bind(event, setState);
71
+ var observableElement = eval(observableElementCode);
72
+ if (observableElement) {
73
+ $(observableElement).on(event, setState);
74
+ }
66
75
  }
67
76
  });
68
77
  });
@@ -137,10 +137,9 @@
137
137
 
138
138
  }
139
139
  &.with_menu {
140
- .menu_bar_item .arrow{
140
+ .menu_bar_item .arrow {
141
141
  @include easy_menu_icon(5, center);
142
- margin: -12px -9px -12px -4px;
143
- padding: 24px 14px 0 0;
142
+ padding: 24px 0 0 0;
144
143
  vertical-align: middle;
145
144
  width: 10px;
146
145
  display: inline-block;
data/lib/menu_bar.rb CHANGED
@@ -84,7 +84,7 @@ class MenuBar
84
84
  arrow = @template.content_tag(:span, '', :class => config[:menu_bar_item_arrow_class])
85
85
 
86
86
  m = Menu.new(config, options)
87
- mbt = MenuBarTrigger.new(config, button_text.html_safe + arrow, m, options[:menu_bar_item])
87
+ mbt = MenuBarTrigger.new(config, button_text.html_safe + ' ' + arrow, m, options[:menu_bar_item])
88
88
 
89
89
  yield m if block_given?
90
90
 
@@ -170,7 +170,7 @@ class MenuBar
170
170
  end
171
171
 
172
172
  def to_s
173
- empty? ? '' : wrap_content(@content.join.html_safe) # Don't render anything if empty
173
+ empty? ? ''.html_safe : wrap_content(@content.join.html_safe) # Don't render anything if empty
174
174
  end
175
175
 
176
176
  def right_aligned?
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.16
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen
8
8
  - Ryan Wallace
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-03-11 00:00:00.000000000 Z
12
+ date: 2026-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -25,8 +25,8 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '3.1'
28
- description:
29
- email:
28
+ description:
29
+ email:
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
@@ -44,10 +44,10 @@ files:
44
44
  - lib/easy_menu_configuration.rb
45
45
  - lib/easy_menu_helpers.rb
46
46
  - lib/menu_bar.rb
47
- homepage:
47
+ homepage:
48
48
  licenses: []
49
49
  metadata: {}
50
- post_install_message:
50
+ post_install_message:
51
51
  rdoc_options: []
52
52
  require_paths:
53
53
  - lib
@@ -62,8 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
64
  requirements: []
65
- rubygems_version: 3.3.23
66
- signing_key:
65
+ rubygems_version: 3.4.1
66
+ signing_key:
67
67
  specification_version: 4
68
68
  summary: Simple menu bar DSL for Rails views
69
69
  test_files: []