Packages

An Elixir Phoenix Auto Administration Package.

Current section

Files

Jump to
phx_admin web static vendor active_admin lib table-checkbox-toggler.js.js
Raw

web/static/vendor/active_admin/lib/table-checkbox-toggler.js.js

// Generated by CoffeeScript 1.10.0
(function() {
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
ActiveAdmin.TableCheckboxToggler = (function(superClass) {
extend(TableCheckboxToggler, superClass);
function TableCheckboxToggler() {
return TableCheckboxToggler.__super__.constructor.apply(this, arguments);
}
TableCheckboxToggler.prototype._init = function() {
return TableCheckboxToggler.__super__._init.apply(this, arguments);
};
TableCheckboxToggler.prototype._bind = function() {
TableCheckboxToggler.__super__._bind.apply(this, arguments);
return this.$container.find('tbody td').click((function(_this) {
return function(e) {
if (e.target.type !== 'checkbox') {
return _this._didClickCell(e.target);
}
};
})(this));
};
TableCheckboxToggler.prototype._didChangeCheckbox = function(checkbox) {
var $row;
TableCheckboxToggler.__super__._didChangeCheckbox.apply(this, arguments);
$row = $(checkbox).parents('tr');
if (checkbox.checked) {
return $row.addClass('selected');
} else {
return $row.removeClass('selected');
}
};
TableCheckboxToggler.prototype._didClickCell = function(cell) {
return $(cell).parent('tr').find(':checkbox').click();
};
return TableCheckboxToggler;
})(ActiveAdmin.CheckboxToggler);
$.widget.bridge('tableCheckboxToggler', ActiveAdmin.TableCheckboxToggler);
}).call(this);