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
= button_tag(t(:save), class: 'btn btn-warning')
:coffee
$("#admin_user_password").removeAttr('required')
$("#admin_user_password_confirmation").removeAttr('required')
:javascript
window.addEventListener('load', function() {
$("#admin_user_password").removeAttr('required');
$("#admin_user_password_confirmation").removeAttr('required');
});

View file

@ -36,10 +36,15 @@
= render 'admin/domains/partials/version',
domain: version.reify, version: version.previous
:coffee
$(document).on 'click', '.js-pending, .js-event', (e) ->
e.preventDefault()
:javascript
window.addEventListener('load', function() {
$(document).on('click', '.js-pending, .js-event', function(e) {
return e.preventDefault();
});
$(document).on 'mousedown', '.js-pending, .js-event', (e) ->
target = $(e.target)
target.parents('tr').nextUntil('tr.small' ,'tr.' + this.className).toggle()
$(document).on('mousedown', '.js-pending, .js-event', function(e) {
var target;
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]
= text_field_tag "#{model}[status_notes_array][]", value, class: 'form-control'
:coffee
$("#js-statuses").nestedAttributes
bindAddTo: $(".js-add-status")
afterAdd: (el) ->
if el.find('.js-disabled-value')
el.find('.js-disabled-value').remove()
el.find('.js-select').show()
el.find('.hide-when-new').hide()
el.find('.js-destroy-status').show()
:javascript
window.addEventListener('load', function() {
$("#js-statuses").nestedAttributes({
bindAddTo: $(".js-add-status"),
afterAdd: function(el) {
if (el.find('.js-disabled-value')) {
el.find('.js-disabled-value').remove();
el.find('.js-select').show();
el.find('.hide-when-new').hide();
return el.find('.js-destroy-status').show();
}
}
});
$(document).on 'click', '.js-destroy-status', (e) ->
e.preventDefault()
$(this).parents('.panel').remove()
$(document).on('click', '.js-destroy-status', function(e) {
e.preventDefault();
return $(this).parents('.panel').remove();
});
});