jqr-helpers 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -85,6 +85,9 @@
85
85
  if (dialogElement.length == 0) {
86
86
  $('body').append("<div id='" + dialogID + "'>");
87
87
  dialogElement = $('#' + dialogID);
88
+ if ($(this).data('close-x')) {
89
+ dialogElement.prepend('<span class="ujs-dialog-x"></span>');
90
+ }
88
91
  }
89
92
  dialogElement.load(url, function() {
90
93
  $('.ui-widget-overlay').remove();
data/jqr-helpers.gemspec CHANGED
@@ -1,7 +1,7 @@
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.4'
4
+ s.version = '1.0.5'
5
5
  s.date = '2013-11-19'
6
6
  s.summary = 'Helpers to print unobtrusive jQuery-UI tags.'
7
7
  s.description = <<-EOF
@@ -1,3 +1,5 @@
1
+ require 'securerandom'
2
+
1
3
  module JqrHelpers
2
4
  module Helpers
3
5
 
@@ -27,7 +29,7 @@ module JqrHelpers
27
29
  else
28
30
  options = url_or_options
29
31
  content = yield
30
- id = (0...8).map { (65 + rand(26)).chr }.join # random string
32
+ id = _random_string
31
33
  url = '#' + id
32
34
  end
33
35
  options.merge!(:id => id)
@@ -119,9 +121,6 @@ module JqrHelpers
119
121
  # using content already on the page.
120
122
  # If a block is given, dialog_options and html_options are shifted left by
121
123
  # 1 and the block is used as the html_content.
122
- # @param id [String] A unique ID to use to reference the dialog options.
123
- # This is ultimately created as an element with that ID in the DOM,
124
- # but the element does not have to exist already, unlike link_to_dialog.
125
124
  # @param url [String] The URL to load the content from.
126
125
  # @param html_content [String] Text or HTML tags to use as the link body.
127
126
  # @param dialog_options [Hash] See above.
@@ -129,7 +128,7 @@ module JqrHelpers
129
128
  # a special :tag_name option that can be used to change the tag being
130
129
  # created. Default is :a, but you can pass :div, :span, etc.
131
130
  # @return [String]
132
- def link_to_remote_dialog(id, url, html_content, dialog_options={},
131
+ def link_to_remote_dialog(url, html_content, dialog_options={},
133
132
  html_options={}, &block)
134
133
 
135
134
  if block_given?
@@ -139,22 +138,19 @@ module JqrHelpers
139
138
  end
140
139
 
141
140
  html_options[:'data-dialog-url'] = url
142
- link_to_dialog(id, html_content, dialog_options, html_options)
141
+ link_to_dialog(_random_string, html_content, dialog_options, html_options)
143
142
  end
144
143
 
145
144
  # Same as button_to_dialog, but loads content from a remote URL instead of
146
145
  # using content already on the page.
147
- # @param id [String] A unique ID to use to reference the dialog options.
148
- # This is ultimately created as an element with that ID in the DOM,
149
- # but the element does not have to exist already, unlike button_to_dialog.
150
146
  # @param url [String] The URL to load the content from.
151
147
  # @param html_content [String] Text or HTML tags to use as the button body.
152
148
  # @param dialog_options [Hash] See above.
153
149
  # @param html_options [Hash] Attributes to put on the button tag.
154
150
  # @return [String]
155
- def button_to_remote_dialog(id, url, html_content, dialog_options={},
151
+ def button_to_remote_dialog(url, html_content, dialog_options={},
156
152
  html_options={})
157
- link_to_remote_dialog(id, url, html_content, dialog_options,
153
+ link_to_remote_dialog(url, html_content, dialog_options,
158
154
  html_options.merge(:tag_name => 'button'))
159
155
  end
160
156
 
@@ -284,6 +280,12 @@ module JqrHelpers
284
280
 
285
281
  private
286
282
 
283
+ # Generate a random string for IDs.
284
+ # @return [String]
285
+ def _random_string
286
+ SecureRandom.hex(16)
287
+ end
288
+
287
289
  # Process options related to Ajax requests (e.g. button_to_ajax).
288
290
  # @param options [Hash]
289
291
  # @return [Hash] HTML options to inject.
@@ -1,5 +1,5 @@
1
1
  module JqrHelpers
2
2
  module Rails
3
- VERSION = '1.0.4'
3
+ VERSION = '1.0.5'
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jqr-helpers
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.4
5
+ version: 1.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Daniel Orner