diff --git a/js/rowlink.js b/js/rowlink.js new file mode 100644 index 00000000..6f66ca02 --- /dev/null +++ b/js/rowlink.js @@ -0,0 +1,73 @@ +/* ============================================================ + * Bootstrap: rowlink.js v3.0.0-p7 + * http://jasny.github.io/bootstrap/javascript.html#rowlink + * ============================================================ + * Copyright 2012 Jasny BV, Netherlands. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + ++function ($) { "use strict"; + + var Rowlink = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Rowlink.DEFAULTS, options) + + this.$element.on('click.bs.rowlink', 'td:not(.nolink)', $.proxy(this.click, this)) + } + + Rowlink.DEFAULTS = { + target: "a" + } + + Rowlink.prototype.click = function(e) { + if ($(e.target).is('a')) return + + e.preventDefault(); + $(e.currentTarget).closest('tr').find(this.options.target).trigger('click') + } + + + // ROWLINK PLUGIN DEFINITION + // =========================== + + $.fn.rowlink = function (options) { + return this.each(function () { + var $this = $(this) + var data = $this.data('rowlink') + if (!data) $this.data('rowlink', (data = new Rowlink(this, options))) + }) + } + + $.fn.rowlink.Constructor = Rowlink + + + // ROWLINK NO CONFLICT + // ==================== + + $.fn.rowlink.noConflict = function () { + $.fn.inputmask = old + return this + } + + + // ROWLINK DATA-API + // ================== + + $(document).on('click.bs.rowlink.data-api', '[data-link="row"]', function (e) { + var $this = $(this) + if ($this.data('rowlink')) return + $this.rowlink($this.data()) + }) + +}(window.jQuery); diff --git a/less/rowlink.less b/less/rowlink.less new file mode 100644 index 00000000..9240ea72 --- /dev/null +++ b/less/rowlink.less @@ -0,0 +1,20 @@ +// +// Rowlink +// -------------------------------------------------- + +.table.rowlink, +.table .rowlink { + td:not(.nolink) { + cursor: pointer; + + a { + color: inherit; + font: inherit; + text-decoration: inherit; + } + } + + tr:hover td { + background-color: darken(@tableBackgroundHover, 15%); + } +} \ No newline at end of file