jqr-helpers 1.0.4 → 1.0.5
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.
- data/app/assets/javascripts/jqr-helpers.js +3 -0
- data/jqr-helpers.gemspec +1 -1
- data/lib/jqr-helpers/helpers.rb +13 -11
- data/lib/jqr-helpers/version.rb +1 -1
- metadata +1 -1
@@ -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
data/lib/jqr-helpers/helpers.rb
CHANGED
@@ -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 =
|
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(
|
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(
|
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(
|
151
|
+
def button_to_remote_dialog(url, html_content, dialog_options={},
|
156
152
|
html_options={})
|
157
|
-
link_to_remote_dialog(
|
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.
|
data/lib/jqr-helpers/version.rb
CHANGED