Convert coffeescript to javascript in admin area

#341
This commit is contained in:
Artur Beljajev 2017-01-18 08:35:38 +02:00
parent 40459e8b2e
commit 2c9a8b555b
3 changed files with 34 additions and 22 deletions

View file

@ -59,7 +59,8 @@
.col-md-8.text-right .col-md-8.text-right
= button_tag(t(:save), class: 'btn btn-warning') = button_tag(t(:save), class: 'btn btn-warning')
:coffee :javascript
$("#admin_user_password").removeAttr('required') window.addEventListener('load', function() {
$("#admin_user_password_confirmation").removeAttr('required') $("#admin_user_password").removeAttr('required');
$("#admin_user_password_confirmation").removeAttr('required');
});

View file

@ -36,10 +36,15 @@
= render 'admin/domains/partials/version', = render 'admin/domains/partials/version',
domain: version.reify, version: version.previous domain: version.reify, version: version.previous
:coffee :javascript
$(document).on 'click', '.js-pending, .js-event', (e) -> window.addEventListener('load', function() {
e.preventDefault() $(document).on('click', '.js-pending, .js-event', function(e) {
return e.preventDefault();
});
$(document).on 'mousedown', '.js-pending, .js-event', (e) -> $(document).on('mousedown', '.js-pending, .js-event', function(e) {
target = $(e.target) var target;
target.parents('tr').nextUntil('tr.small' ,'tr.' + this.className).toggle() target = $(e.target);
return target.parents('tr').nextUntil('tr.small', 'tr.' + this.className).toggle();
});
});

View file

@ -31,16 +31,22 @@
- value = f.object.new_record? ? '' : f.object.status_notes[s] - value = f.object.new_record? ? '' : f.object.status_notes[s]
= text_field_tag "#{model}[status_notes_array][]", value, class: 'form-control' = text_field_tag "#{model}[status_notes_array][]", value, class: 'form-control'
:coffee :javascript
$("#js-statuses").nestedAttributes window.addEventListener('load', function() {
bindAddTo: $(".js-add-status") $("#js-statuses").nestedAttributes({
afterAdd: (el) -> bindAddTo: $(".js-add-status"),
if el.find('.js-disabled-value') afterAdd: function(el) {
el.find('.js-disabled-value').remove() if (el.find('.js-disabled-value')) {
el.find('.js-select').show() el.find('.js-disabled-value').remove();
el.find('.hide-when-new').hide() el.find('.js-select').show();
el.find('.js-destroy-status').show() el.find('.hide-when-new').hide();
return el.find('.js-destroy-status').show();
}
}
});
$(document).on 'click', '.js-destroy-status', (e) -> $(document).on('click', '.js-destroy-status', function(e) {
e.preventDefault() e.preventDefault();
$(this).parents('.panel').remove() return $(this).parents('.panel').remove();
});
});