aboutsummaryrefslogtreecommitdiff
path: root/docs/assets
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2011-07-01 22:16:29 -0700
committerMark Otto <[email protected]>2011-07-01 22:16:29 -0700
commit163e68ade6eb9e1a8a2e52aadf975612ab850579 (patch)
tree6071bb83bfb00173196f32e1f847e63537822691 /docs/assets
parent7962b36dae6d0d793e2bfa04d69ae1a2e5dbd611 (diff)
parent26f9e8c4e8580c2d41f31a4fb504ee8c0fdeb145 (diff)
downloadbootstrap-163e68ade6eb9e1a8a2e52aadf975612ab850579.tar.xz
bootstrap-163e68ade6eb9e1a8a2e52aadf975612ab850579.zip
resolve merge conflict
Diffstat (limited to 'docs/assets')
-rw-r--r--docs/assets/js/application.js121
1 files changed, 89 insertions, 32 deletions
diff --git a/docs/assets/js/application.js b/docs/assets/js/application.js
index 4b377f704..82cf307e9 100644
--- a/docs/assets/js/application.js
+++ b/docs/assets/js/application.js
@@ -1,6 +1,47 @@
$(document).ready(function(){
- // Example dropdown for topbar nav
+ // scroll spy logic
+ // ================
+
+ var activeTarget,
+ $window = $(window),
+ position = {},
+ nav = $('body > .topbar li a'),
+ targets = nav.map(function () {
+ return $(this).attr('href');
+ }),
+ offsets = $.map(targets, function (id) {
+ return $(id).offset().top;
+ });
+
+
+ function setButton(id) {
+ nav.parent("li").removeClass('active');
+ $(nav[$.inArray(id, targets)]).parent("li").addClass('active');
+ }
+
+ function processScroll(e) {
+ var scrollTop = $window.scrollTop() + 10, i;
+ for (i = offsets.length; i--;) {
+ if (activeTarget != targets[i] && scrollTop >= offsets[i] && (!offsets[i + 1] || scrollTop <= offsets[i + 1])) {
+ activeTarget = targets[i];
+ setButton(activeTarget);
+ }
+ }
+ }
+
+ nav.click(function () {
+ processScroll();
+ });
+
+ processScroll();
+
+ $window.scroll(processScroll);
+
+
+ // Dropdown example for topbar nav
+ // ===============================
+
$("body").bind("click", function(e) {
$("ul.menu-dropdown").hide();
$('a.menu').parent("li").removeClass("open").children("ul.menu-dropdown").hide();
@@ -23,10 +64,16 @@ $(document).ready(function(){
return false;
});
+
// table sort example
+ // ==================
+
$("#sortTableExample").tablesorter( {sortList: [[1,0]]} );
- // add on
+
+ // add on logic
+ // ============
+
$('.add-on :checkbox').click(function() {
if ($(this).attr('checked')) {
$(this).parents('.add-on').addClass('active');
@@ -34,8 +81,11 @@ $(document).ready(function(){
$(this).parents('.add-on').removeClass('active');
}
});
-
- // Disable certain links and buttons in docs
+
+
+ // Disable certain links in docs
+ // =============================
+
$('ul.tabs a, ul.pills a, .pagination a, .well .btn, .actions .btn, .alert-message .btn, a.close').click(function(e) {
e.preventDefault();
});
@@ -49,39 +99,46 @@ $(document).ready(function(){
});
- // scroll spyer
- var activeTarget,
- $window = $(window),
- position = {},
- nav = $('body > .topbar li a'),
- targets = nav.map(function () {
- return $(this).attr('href');
- }),
- offsets = $.map(targets, function (id) {
- return $(id).offset().top;
- });
+ // POSITION TWIPSIES
+ // =================
+ $('.twipsies.well a').each(function () {
+ var type = this.title
+ , $anchor = $(this)
+ , $twipsy = $('.twipsy.' + type)
- function setButton(id) {
- nav.parent("li").removeClass('active');
- $(nav[$.inArray(id, targets)]).parent("li").addClass('active');
- }
+ , twipsy = {
+ width: $twipsy.width() + 10
+ , height: $twipsy.height() + 10
+ }
- function processScroll(e) {
- var scrollTop = $window.scrollTop() + 10, i;
- for (i = offsets.length; i--;) {
- if (activeTarget != targets[i] && scrollTop >= offsets[i] && (!offsets[i + 1] || scrollTop <= offsets[i + 1])) {
- activeTarget = targets[i];
- setButton(activeTarget);
+ , anchor = {
+ position: $anchor.position()
+ , width: $anchor.width()
+ , height: $anchor.height()
+ }
+
+ , offset = {
+ above: {
+ top: anchor.position.top - twipsy.height
+ , left: anchor.position.left + (anchor.width/2) - (twipsy.width/2)
+ }
+ , below: {
+ top: anchor.position.top + anchor.height
+ , left: anchor.position.left + (anchor.width/2) - (twipsy.width/2)
+ }
+ , left: {
+ top: anchor.position.top + (anchor.height/2) - (twipsy.height/2)
+ , left: anchor.position.left - twipsy.width - 5
+ }
+ , right: {
+ top: anchor.position.top + (anchor.height/2) - (twipsy.height/2)
+ , left: anchor.position.left + anchor.width + 5
+ }
}
- }
- }
- nav.click(function () {
- processScroll();
- });
+ $twipsy.css(offset[type])
- processScroll();
+ });
- $window.scroll(processScroll);
}); \ No newline at end of file