app/assets/javascripts/jqr-helpers.js in jqr-helpers-1.0.60 vs app/assets/javascripts/jqr-helpers.js in jqr-helpers-1.0.61
- old
+ new
@@ -413,54 +413,51 @@
else {
$(this).removeClass('ujs-toggle-open').addClass('ujs-toggle-closed');
}
}
- function ujsLoadPlugins(event) {
+ function addHiddenField(form, name, value) {
+ var input = $('<input type="hidden">');
+ input.attr('name', name);
+ input.attr('value', value);
+ form.append(input);
+ }
- $('.ujs-quick-buttonset input:checked').change();
-
- function addHiddenField(form, name, value) {
- var input = $('<input type="hidden">');
- input.attr('name', name);
- input.attr('value', value);
- form.append(input);
+ function ujsExternalClick(event) {
+ event.stopImmediatePropagation();
+ var button = $(this);
+ if (!$.rails.allowAction(button)) {
+ return false;
}
+ if (button.data('disable-with')) {
+ button.html(button.data('disable-with'));
+ button.attr('disabled', 'disabled');
+ button.attr('autocomplete', 'off');
+ }
+ var form = $('<form>');
+ var method = button.data('method');
+ if (method == 'put' || method == 'delete') {
+ form.attr('method', 'post');
+ addHiddenField(form, '_method', method);
+ }
+ else {
+ form.attr('method', method);
+ }
+ form.attr('action', button.data('url'));
+ form.attr('target', button.data('target'));
+ if (method != 'get') {
+ form.attr('rel', 'nofollow');
+ addHiddenField(form, button.data('token-name'),
+ button.data('token-value'));
+ }
+ $('body').append(form);
+ form.submit();
+ return false;
+ }
- $('.ujs-external-button').each(function() {
- var button = $(this);
- var form = $('<form>');
- var method = button.data('method');
- if (method == 'put' || method == 'delete') {
- form.attr('method', 'post');
- addHiddenField(form, '_method', method);
- }
- else {
- form.attr('method', method);
- }
- form.attr('action', button.data('url'));
- form.attr('target', button.data('target'));
- if (method != 'get') {
- form.attr('rel', 'nofollow');
- addHiddenField(form, button.data('token-name'),
- button.data('token-value'));
- }
- $('body').append(form);
- button.click(function(event) {
- event.stopImmediatePropagation();
- if (!$.rails.allowAction(button)) {
- return false;
- }
- if (button.data('disable-with')) {
- button.html(button.data('disable-with'));
- button.attr('disabled', 'disabled');
- button.attr('autocomplete', 'off');
- }
- form.submit();
- return false;
- });
- });
+ function ujsLoadPlugins(event) {
+
$('.ujs-date-picker', event.target).each(function() {
var options = $(this).data('date-options');
$(this).datepicker(options);
});
@@ -525,10 +522,11 @@
$(document).on('click', '.ujs-quick-buttonset label',
ujsQuickButtonClick);
$(document).on('mouseenter mouseleave', '.ujs-quick-buttonset label',
ujsQuickButtonHover);
$(document).on('click', '.ujs-toggle', ujsToggleClick);
+ $(document).on('click', '.ujs-external-button', ujsExternalClick);
}
else {
$('body').live('jqr.load', ujsLoadPlugins);
$('input[type=submit]').live('click', ujsSubmitClick);
$('.ujs-dialog').live('click', ujsDialogClick);
@@ -541,9 +539,10 @@
$('.ujs-quick-buttonset input').live('change', ujsQuickButtonChange);
$('.ujs-quick-buttonset label').live('click', ujsQuickButtonClick);
$('.ujs-quick-buttonset label').live('mouseenter mouseleave',
ujsQuickButtonHover);
$('.ujs-toggle').live('click', ujsToggleClick);
+ $('.ujs-external-button').live('click', ujsExternalClick);
}
$('body').trigger('jqr.beforeload').trigger('jqr.load');
});
}(jQuery));