mirror of
https://github.com/jasny/bootstrap.git
synced 2026-01-14 08:58:02 -05:00
Added rowlink
This commit is contained in:
73
js/rowlink.js
Normal file
73
js/rowlink.js
Normal file
@@ -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);
|
||||
20
less/rowlink.less
Normal file
20
less/rowlink.less
Normal file
@@ -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%);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user