easy_menu 0.4.17 → 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: 8c74da57817315dcfcff6acaf5d4fff133d0bb836878027f2d509c2660e1e7f0
4
- data.tar.gz: 95fbbfca37f5f27a38042d31a64d439b6e8e84308d3f35067d0d77cb1f409454
3
+ metadata.gz: 3b1e9ced377fa41ccde18eb63585c26db224c90265189c18630cf3912bb4df9f
4
+ data.tar.gz: dd2dfb7d78dc212fa78c3b4f129d5ce5537fe6ef32e13677fe9506fc01b5b4e1
5
5
  SHA512:
6
- metadata.gz: a32e544bc8e0cb80fc1b993d38d99ff78865dcc3a2346f446bba16ad4704f3a850462ea5430ae4f0b65ba9a93ea30d5596f2a744b20d3de6387ee89429e69b15
7
- data.tar.gz: a9b0fbd467c361a7266e556304b375b830a6d7fbe38f3ee0bac37bf3ae18292fa2faa8470f5c64a97c05d5aa9bca215d7a5284c10da38ad7f0886404f26b92f0
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
  });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.17
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-08-28 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
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
64
  requirements: []
65
- rubygems_version: 3.5.13
65
+ rubygems_version: 3.4.1
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: Simple menu bar DSL for Rails views