From dc77bd68d6564376536248442cd009aaa8dc3c2b Mon Sep 17 00:00:00 2001 From: Arnold Daniels Date: Tue, 21 Feb 2012 23:45:34 +0100 Subject: [PATCH] Implemented table-href Added bootstap-table-href.js Added css for `td[data-href]` in tables.less Conflicts: Makefile docs/templates/layout.mustache docs/templates/pages/javascript.mustache --- Makefile | 2 +- docs/templates/layout.mustache | 1 + docs/templates/pages/javascript.mustache | 43 ++++++++++++++++++++++++ js/bootstrap-table-href.js | 26 ++++++++++++++ less/tables.less | 14 ++++++++ 5 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 js/bootstrap-table-href.js diff --git a/Makefile b/Makefile index 6f04438c..28062078 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ bootstrap: lessc --compress ${BOOTSTRAP_LESS} > bootstrap/css/bootstrap.min.css lessc ${BOOTSTRAP_RESPONSIVE_LESS} > bootstrap/css/bootstrap-responsive.css lessc --compress ${BOOTSTRAP_RESPONSIVE_LESS} > bootstrap/css/bootstrap-responsive.min.css - cat js/bootstrap-transition.js js/bootstrap-alert.js js/bootstrap-button.js js/bootstrap-carousel.js js/bootstrap-collapse.js js/bootstrap-dropdown.js js/bootstrap-modal.js js/bootstrap-tooltip.js js/bootstrap-popover.js js/bootstrap-scrollspy.js js/bootstrap-tab.js js/bootstrap-typeahead.js js/bootstrap-inputmask.js js/bootstrap-placeholder.js > bootstrap/js/bootstrap.js + cat js/bootstrap-transition.js js/bootstrap-alert.js js/bootstrap-button.js js/bootstrap-carousel.js js/bootstrap-collapse.js js/bootstrap-dropdown.js js/bootstrap-modal.js js/bootstrap-tooltip.js js/bootstrap-popover.js js/bootstrap-scrollspy.js js/bootstrap-tab.js js/bootstrap-typeahead.js js/bootstrap-inputmask.js js/bootstrap-placeholder.js js/bootstrap-table-href.js > bootstrap/js/bootstrap.js uglifyjs -nc bootstrap/js/bootstrap.js > bootstrap/js/bootstrap.min.js # diff --git a/docs/templates/layout.mustache b/docs/templates/layout.mustache index dd4240fa..da9cb6fe 100644 --- a/docs/templates/layout.mustache +++ b/docs/templates/layout.mustache @@ -111,6 +111,7 @@ + {{#production}} diff --git a/docs/templates/pages/javascript.mustache b/docs/templates/pages/javascript.mustache index 1b292bb4..d7ac97f8 100644 --- a/docs/templates/pages/javascript.mustache +++ b/docs/templates/pages/javascript.mustache @@ -19,6 +19,7 @@
  • {{_i}}Typeahead{{/i}}
  • {{_i}}Placeholder{{/i}}
  • {{_i}}Input mask{{/i}}
  • +
  • {{_i}}Table href{{/i}}
  • @@ -116,6 +117,12 @@

    {{_i}}Make sure the user types in the data that you want, by using an input mask.{{/i}}

    +
    + +
    +<<<<<<< HEAD +
    + +
    +
    +

    {{_i}}About{{/i}}

    +

    {{_i}}A plugin to turn a table row into a clickable link.{{/i}}

    + {{_i}}Download file{{/i}} +
    +
    +

    {{_i}}Example{{/i}}

    + + + + + + + +
    {{_i}}Name{{/i}}{{_i}}Description{{/i}}Actions
    {{_i}}Modals{{/i}}{{_i}}A streamlined, but flexible, take on the traditional javascript modal plugin with only the minimum required functionality and smart defaults.{{/i}}Action
    {{_i}}Dropdowns{{/i}}{{_i}}Add dropdown menus to nearly anything in Bootstrap with this simple plugin. Bootstrap features full dropdown menu support on in the navbar, tabs, and pills.{{/i}}Action
    {{_i}}Scrollspy{{/i}}{{_i}}Use scrollspy to automatically update the links in your navbar to show the current active link based on scroll position.{{/i}}Action
    {{_i}}Togglable tabs{{/i}}{{_i}}Use this plugin to make tabs and pills more useful by allowing them to toggle through tabbable panes of local content.{{/i}}Action
    {{_i}}Tooltips{{/i}}{{_i}}A new take on the jQuery Tipsy plugin, Tooltips don't rely on images, uss CSS3 for animations, and data-attributes for local title storage.{{/i}}Action
    +

    {{_i}}Markup{{/i}}

    +

    {{_i}}Add the data-href attribute to a tr element. A column can be excluded by adding the .nohref class.{{/i}}

    +
    +<table>
    +  <tr data-href="javascript.html#modals"><td>Modals</td><td class="nohref"><a href="#">Action</a></td></tr>
    +</table>
    +
    +
    +
    \ No newline at end of file diff --git a/js/bootstrap-table-href.js b/js/bootstrap-table-href.js new file mode 100644 index 00000000..b0417c52 --- /dev/null +++ b/js/bootstrap-table-href.js @@ -0,0 +1,26 @@ +/* ============================================================ + * bootstrap-table-href.js v2.0.0 + * http://jasny.github.com/bootstrap/javascript.html#table-href + * ============================================================ + * Copyright 2011 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. + * ============================================================ */ + +/* TODO: Turn this into a proper jquery plugin */ + +$(function () { + $('tr[data-href] > td').not('.nohref').click(function() { + window.location = $(this).parent().attr('data-href'); + }); +}) diff --git a/less/tables.less b/less/tables.less index c069ed58..70bbe419 100644 --- a/less/tables.less +++ b/less/tables.less @@ -113,6 +113,20 @@ table { } +// TABLE HREF +// ---------- +tr[data-href] { + td { + cursor: pointer; + &.nohref { + cursor: auto; + } + } + &:hover td, &:nth-child(odd):hover td { + background-color: #eee; + } +} + // TABLE CELL SIZING // -----------------