jqr-helpers 1.0.52 → 1.0.53

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmUyZDcyNTQwYTY5YmEwNGNlMjA1Y2MxYzIwMGExYWEwNjJhMmJkMg==
4
+ YTQ2ZWU3NWNhZThjZGIyNTQyODBkOTQyN2I4MTVhY2EyYzJmMjZmNg==
5
5
  data.tar.gz: !binary |-
6
- YTEyYWQwNjU0Y2M4MTFmMWEzYmRhYWJjMzQxNjc4ODNmNGI4OTcyOA==
6
+ Y2MxMjZlMmI2NjIxMmQ3YTFiMGViYzhmM2MzOWQxZGM4YmQ0YjNhMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmVlZDRlNTM2YzcyYmYyODFhN2MxZTc5YWIzZjQyZTNmM2ViMmNmMmI1NTQ3
10
- NDgxNDBhZTc0MTFiYjNkZWFhYjU4ZTY4YWM2NjBmN2ZkOGM2MzU4NTZhMGE2
11
- YTA0YWRmNGQ1M2FjZmVkNDJiNzlmMDdjMzkxYTk5M2M1NmExMjk=
9
+ ZWZjMGFlYzE4ODQxNjE4OTI3NWYyYzQ5YzczYjRmN2UzZDkxMzQ1MmJkMDQw
10
+ MzBmNWY4N2U4ODEyN2FjOTJkZTMwYmI4Nzc4NDJlMjllODBlY2UxZTNkOTI1
11
+ OGNkYzZhZmJhNjcyMjgwNzRlNjU3ZDMwN2U3YzFlNTAwZDkxOTM=
12
12
  data.tar.gz: !binary |-
13
- NmU2NmFjZDU1NWRkNjNjMTZhMjc0ODQxYjc5Njc5NGY0MzcxMTc5MDdlZTc5
14
- NGM1NGM3ZjgwMmE4MGZjZDU3OGY4MTMzNjRjMmM3MGJkNjJiZjU0MmQyZDhm
15
- MjE5MTdkODA2OGJkY2E4Mzc1NGNlNDQ3NTgzMzllZWU5NTZhMDQ=
13
+ YmY0ZWE2NWE3ZDYyOWY4NWQ2YjVhNWU5ZDUxNTUyNDlhYmI1OWViYTdiMTU0
14
+ YzViNmE5MDQ2NDVkZjQ4ZTJhYzYxYWVmYjIxY2Q4MWE4ODQ1ODJkNzVmNmMw
15
+ ZDJiYzE1NTg3MTU1ZTQzNDAxMDM2N2MwMTZhZjBjY2VhYWEyMzE=
data/Readme.md CHANGED
@@ -39,6 +39,8 @@ Full documentation can be found [here](https://rawgithub.com/wishabi/jqr-helpers
39
39
  * `link_to_dialog` - open a dialog when a link is clicked
40
40
  * `button_to_dialog` - open a dialog when a button is clicked
41
41
  * `confirm_button` - open a nice jQuery confirm dialog (rather than a built-in browser one)
42
+ * `link_to_toggle` - when clicked, the link will toggle visibility for another element
43
+ * `button_to_toggle`- when clicked, the button will toggle visibility for another element
42
44
  * `link_to_remote_dialog` - open a remote dialog when a link is clicked (i.e. load
43
45
  the dialog content from a remote route)
44
46
  * `button_to_remote_dialog` - open a remote dialog when a button is clicked
@@ -389,6 +389,11 @@
389
389
  $(event.currentTarget).toggleClass('ui-state-hover');
390
390
  }
391
391
 
392
+ function ujsToggleClick() {
393
+ var id = $(this).data('id');
394
+ $('#' + id).toggle();
395
+ }
396
+
392
397
  function ujsLoadPlugins(event) {
393
398
 
394
399
  $('.ujs-quick-buttonset input:checked').change();
@@ -500,6 +505,7 @@
500
505
  ujsQuickButtonClick);
501
506
  $(document).on('mouseenter mouseleave', '.ujs-quick-buttonset label',
502
507
  ujsQuickButtonHover);
508
+ $(document).on('click', '.ujs-toggle', ujsToggleClick);
503
509
  }
504
510
  else {
505
511
  $('body').live('jqr.load', ujsLoadPlugins);
@@ -515,6 +521,7 @@
515
521
  $('.ujs-quick-buttonset label').live('click', ujsQuickButtonClick);
516
522
  $('.ujs-quick-buttonset label').live('mouseenter mouseleave',
517
523
  ujsQuickButtonHover);
524
+ $('.ujs-toggle').live('click', ujsToggleClick);
518
525
  }
519
526
  $('body').trigger('jqr.beforeload').trigger('jqr.load');
520
527
  });
data/jqr-helpers.gemspec CHANGED
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jqr-helpers'
3
3
  s.require_paths = %w(. lib lib/jqr-helpers)
4
- s.version = '1.0.52'
5
- s.date = '2014-06-26'
4
+ s.version = '1.0.53'
5
+ s.date = '2014-07-09'
6
6
  s.summary = 'Helpers to print unobtrusive jQuery-UI tags.'
7
7
  s.description = <<-EOF
8
8
  This gem adds helper methods to create unobtrusive jQuery code. It outputs
@@ -385,6 +385,25 @@ module JqrHelpers
385
385
  content_tag(:button, content, options)
386
386
  end
387
387
 
388
+ # Add a link which toggles the visibility of a separate element.
389
+ # @param body [String] the text for the link.
390
+ # @param id [String] the ID of the element to toggle.
391
+ # @param options [Hash] HTML options for the link.
392
+ def link_to_toggle(body, id, options={})
393
+ tag_name = options.delete(:tag_name) || :a
394
+ options[:class] ||= ''
395
+ options[:class] << ' ujs-toggle'
396
+ content_tag tag_name, body, options.merge(:'data-id' => id)
397
+ end
398
+
399
+ # Add a button which toggles the visibility of a separate element.
400
+ # @param body [String] the text for the button.
401
+ # @param id [String] the ID of the element to toggle.
402
+ # @param options [Hash] HTML options for the button.
403
+ def button_to_toggle(body, id, options={})
404
+ link_to_toggle(body, id, options.merge(:tag_name => 'button'))
405
+ end
406
+
388
407
  # Observe a field for changes.
389
408
  # On change, post to the Ajax URL and calculate callbacks.
390
409
  # @param url [String] the URL to send to.
@@ -1,6 +1,6 @@
1
1
  module JqrHelpers
2
2
  # @private
3
3
  module Rails
4
- VERSION = '1.0.52'
4
+ VERSION = '1.0.53'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jqr-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.52
4
+ version: 1.0.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-26 00:00:00.000000000 Z
11
+ date: 2014-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement