Permalink
Browse files

Handle stp-full-height class in Sidetap.

  • Loading branch information...
1 parent d42dc0d commit 8c7ad1ce0bc74975fc038035ecebb754e7bea636 @pfiller pfiller committed Jun 27, 2012
Showing with 17 additions and 13 deletions.
  1. +3 −3 demo/stonehenge/index.html
  2. +2 −2 src/coffee/sidetap_ios.coffee
  3. +3 −1 src/coffee/sidetap_standard.coffee
  4. +5 −3 src/sidetap.js
  5. +1 −1 src/sidetap.min.js
  6. +3 −3 src/skeleton.html
@@ -13,10 +13,10 @@
<link type="text/css" rel="stylesheet" media="screen" href="assets/css/stonehenge.css" />
</head>
<body>
- <div class="sidetap stp-full-height">
+ <div class="sidetap">
<!-- Navigation -->
- <div class="stp-nav stp-full-height">
+ <div class="stp-nav">
<nav>
<a href="#" class="selected">On Stage</a>
<a href="#">Goes to 11</a>
@@ -25,7 +25,7 @@
</nav>
</div>
- <div class="stp-content stp-full-height" id="content">
+ <div class="stp-content" id="content">
<header class="stp-fake-header">&nbsp;</header>
<div class="stp-overlay nav-toggle">&nbsp;</div>
@@ -14,7 +14,7 @@ class this.SidetapIos extends SidetapStandard
show_address_bar: (evt) ->
@address_bar_showing = true
- $(".stp-full-height").css("minHeight", 160)
+ @full_heights.css("minHeight", 160)
setTimeout(@set_window_size_2, 1)
set_window_size: ->
@@ -24,7 +24,7 @@ class this.SidetapIos extends SidetapStandard
setTimeout(@set_window_size_2,50)
set_window_size_2: =>
- $(".stp-full-height").css("minHeight", window.innerHeight)
+ @full_heights.css("minHeight", window.innerHeight)
$("body").css("paddingBottom","0")
if @stp.hasClass("nav-showing") then @set_nav_showing() else @set_nav_hiding()
@@ -6,12 +6,14 @@ class this.SidetapStandard
@stp = @detect_primary_element("sidetap")
@stp_nav = @detect_primary_element("stp-nav")
@stp_content = @detect_primary_element("stp-content")
+ @full_heights = $(".stp-full-height")
@set_up_observers()
detect_primary_element: (css_class) ->
el = $(".#{css_class}")
console?.warn("Sidetap: too many elements of class \"#{css_class}\". There must be only one.") if el.length > 1
+ el.addClass("stp-full-height")
el.first()
getScrollTop: ->
@@ -24,7 +26,7 @@ class this.SidetapStandard
$(".nav-toggle").click (evt) => @toggle_nav(evt)
set_window_size: =>
- $(".stp-full-height").css("minHeight", window.innerHeight)
+ @full_heights.css("minHeight", window.innerHeight)
if @stp.hasClass("nav-showing") then @set_nav_showing() else @set_nav_hiding()
toggle_nav: (e) =>
View
@@ -15,6 +15,7 @@ this.SidetapStandard = (function() {
this.stp = this.detect_primary_element("sidetap");
this.stp_nav = this.detect_primary_element("stp-nav");
this.stp_content = this.detect_primary_element("stp-content");
+ this.full_heights = $(".stp-full-height");
this.set_up_observers();
}
@@ -26,6 +27,7 @@ this.SidetapStandard = (function() {
console.warn("Sidetap: too many elements of class \"" + css_class + "\". There must be only one.");
}
}
+ el.addClass("stp-full-height");
return el.first();
};
@@ -44,7 +46,7 @@ this.SidetapStandard = (function() {
};
SidetapStandard.prototype.set_window_size = function() {
- $(".stp-full-height").css("minHeight", window.innerHeight);
+ this.full_heights.css("minHeight", window.innerHeight);
if (this.stp.hasClass("nav-showing")) {
return this.set_nav_showing();
} else {
@@ -154,7 +156,7 @@ this.SidetapIos = (function(_super) {
SidetapIos.prototype.show_address_bar = function(evt) {
this.address_bar_showing = true;
- $(".stp-full-height").css("minHeight", 160);
+ this.full_heights.css("minHeight", 160);
return setTimeout(this.set_window_size_2, 1);
};
@@ -166,7 +168,7 @@ this.SidetapIos = (function(_super) {
};
SidetapIos.prototype.set_window_size_2 = function() {
- $(".stp-full-height").css("minHeight", window.innerHeight);
+ this.full_heights.css("minHeight", window.innerHeight);
$("body").css("paddingBottom", "0");
if (this.stp.hasClass("nav-showing")) {
return this.set_nav_showing();
View
@@ -1 +1 @@
-var __bind=function(a,b){return function(){return a.apply(b,arguments)}};this.SidetapStandard=function(){function a(){this.nav_toggle_complete=__bind(this.nav_toggle_complete,this),this.toggle_nav=__bind(this.toggle_nav,this),this.set_window_size=__bind(this.set_window_size,this),this.stp=this.detect_primary_element("sidetap"),this.stp_nav=this.detect_primary_element("stp-nav"),this.stp_content=this.detect_primary_element("stp-content"),this.set_up_observers()}return a.name="SidetapStandard",a.ios_5=!1,a.prototype.detect_primary_element=function(a){var b;return b=$("."+a),b.length>1&&typeof console!="undefined"&&console!==null&&console.warn('Sidetap: too many elements of class "'+a+'". There must be only one.'),b.first()},a.prototype.getScrollTop=function(){var a;return a=window.pageYOffset||document.compatMode==="CSS1Compat"&&document.documentElement.scrollTop||document.body.scrollTop||0},a.prototype.set_up_observers=function(){var a=this;return this.set_window_size(),$(window).resize(this.set_window_size),$(".nav-toggle").click(function(b){return a.toggle_nav(b)})},a.prototype.set_window_size=function(){return $(".stp-full-height").css("minHeight",window.innerHeight),this.stp.hasClass("nav-showing")?this.set_nav_showing():this.set_nav_hiding()},a.prototype.toggle_nav=function(a){a!=null&&a.preventDefault(),this.stp_content.on("webkitAnimationEnd",this.nav_toggle_complete),this.stp.hasClass("nav-showing")?(this.stp_content.removeClass("showing-nav").addClass("hide-nav"),this.set_nav_hiding()):(this.stp_nav.show(),this.stp_content.removeClass("hide-nav").addClass("showing-nav"),this.set_nav_showing()),this.stp.toggleClass("nav-showing");if(this.ios_5)return this.address_bar_showing&&this.set_window_size(),window.scrollTo(0,1)},a.prototype.nav_toggle_complete=function(){this.stp_content.off("webkitAnimationEnd",this.nav_toggle_complete);if(!this.stp_content.hasClass("showing-nav"))return this.stp_nav.hide()},a.prototype.set_nav_showing=function(){return this.stp_nav.css("maxHeight","none"),this.stp_content.css("maxHeight",this.stp_nav.height())},a.prototype.set_nav_hiding=function(){return this.stp_content.css("maxHeight","none"),this.stp_nav.css("maxHeight",this.stp_content.height())},a.prototype.scroll_to=function(a){return $("body").scrollTop(a.offset().top-10)},a.prototype.show_section=function(a,b){b==null&&(b={}),this.stp_content.find(".stp-content-panel").not(".hidden").addClass("hidden"),a.removeClass("hidden").show();if(b.callback!=null)return b.callback.apply()},a}();var __bind=function(a,b){return function(){return a.apply(b,arguments)}},__hasProp={}.hasOwnProperty,__extends=function(a,b){function d(){this.constructor=a}for(var c in b)__hasProp.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};this.SidetapIos=function(a){function b(){this.in_from_left_complete=__bind(this.in_from_left_complete,this),this.in_from_right_complete=__bind(this.in_from_right_complete,this),this.down_from_top_complete=__bind(this.down_from_top_complete,this),this.up_from_bottom_complete=__bind(this.up_from_bottom_complete,this),this.set_window_size_2=__bind(this.set_window_size_2,this),$("body").addClass("ios"),this.ios_5=!0,b.__super__.constructor.call(this)}return __extends(b,a),b.name="SidetapIos",b.prototype.set_up_observers=function(){var a=this;return this.set_window_size(),$("header h1").click(function(b){return a.show_address_bar(b)}),$(window).on("orientationchange",function(b){return a.set_window_size(b)}),$(".nav-toggle").click(function(b){return a.toggle_nav(b)}),$("#stp-overlay").click(function(b){return a.toggle_nav(b)})},b.prototype.show_address_bar=function(a){return this.address_bar_showing=!0,$(".stp-full-height").css("minHeight",160),setTimeout(this.set_window_size_2,1)},b.prototype.set_window_size=function(){return this.address_bar_showing=!1,$("body").css("paddingBottom","5000px"),window.scrollTo(0,1),setTimeout(this.set_window_size_2,50)},b.prototype.set_window_size_2=function(){return $(".stp-full-height").css("minHeight",window.innerHeight),$("body").css("paddingBottom","0"),this.stp.hasClass("nav-showing")?this.set_nav_showing():this.set_nav_hiding()},b.prototype.scroll_to=function(a){var b,c,d;return d=a.parents(".stp-content-body").first(),c=d.scrollTop(),d.scrollTop(0),b=a.offset().top-98,d.scrollTop(c),d.stop().animate({scrollTop:b},"slow")},b.prototype.show_section=function(a,b){var c;return b==null&&(b={}),c=b.animation!=null?b.animation:"default",b.callback!=null&&(this.pending_callback=b.callback),c==="upfrombottom"?this.up_from_bottom(a):c==="downfromtop"?this.down_from_top(a):c==="infromright"?this.in_from_right(a):c==="infromleft"?this.in_from_left(a):(this.stp_content.find(".stp-content-panel").not(".hidden").addClass("hidden"),a.removeClass("hidden").show(),this.animation_callback())},b.prototype.up_from_bottom=function(a){return a.on("webkitAnimationEnd",this.up_from_bottom_complete).removeClass("hidden").addClass("up-from-bottom")},b.prototype.up_from_bottom_complete=function(){return this.slide_up_previous=$(".stp-content-panel").not(".up-from-bottom").addClass("hidden"),$(".up-from-bottom").off("webkitAnimationEnd",this.up_from_bottom_complete).removeClass("up-from-bottom"),this.animation_callback()},b.prototype.down_from_top=function(a){var b;return b=this.stp_content.find(".stp-content-panel").not(".hidden"),a.removeClass("hidden"),b.on("webkitAnimationEnd",this.down_from_top_complete).addClass("down-to-bottom")},b.prototype.down_from_top_complete=function(){var a;return a=$(".down-to-bottom"),a.off("webkitAnimationEnd",this.down_from_top_complete).removeClass("down-to-bottom").hide(),a.addClass("hidden").show(),this.animation_callback()},b.prototype.in_from_right=function(a){return $(".stp-content-panel").not(".hidden").addClass("slide-out-to-left"),a.on("webkitAnimationEnd",this.in_from_right_complete).removeClass("hidden").addClass("slide-in-from-right")},b.prototype.in_from_right_complete=function(){return $(".slide-out-to-left").addClass("hidden").removeClass("slide-out-to-left"),$(".slide-in-from-right").off("webkitAnimationEnd",this.in_from_right_complete).removeClass("slide-in-from-right"),this.animation_callback()},b.prototype.in_from_left=function(a){return $(".stp-content-panel").not(".hidden").addClass("slide-out-to-right"),a.on("webkitAnimationEnd",this.in_from_left_complete).removeClass("hidden").addClass("slide-in-from-left")},b.prototype.in_from_left_complete=function(){return $(".slide-out-to-right").removeClass("slide-out-to-right").addClass("hidden"),$(".slide-in-from-left").off("webkitAnimationEnd",this.in_from_left_complete).removeClass("slide-in-from-left"),this.animation_callback()},b.prototype.animation_callback=function(){return this.pending_callback&&this.pending_callback.call(),this.pending_callback=null},b}(SidetapStandard),this.sidetap=function(){var a;return a=window.SharedWorker&&navigator.userAgent.match(/^((?!android).)*webkit.*$/i),a?new SidetapIos:new SidetapStandard};
+var __bind=function(a,b){return function(){return a.apply(b,arguments)}};this.SidetapStandard=function(){function a(){this.nav_toggle_complete=__bind(this.nav_toggle_complete,this),this.toggle_nav=__bind(this.toggle_nav,this),this.set_window_size=__bind(this.set_window_size,this),this.stp=this.detect_primary_element("sidetap"),this.stp_nav=this.detect_primary_element("stp-nav"),this.stp_content=this.detect_primary_element("stp-content"),this.full_heights=$(".stp-full-height"),this.set_up_observers()}return a.name="SidetapStandard",a.ios_5=!1,a.prototype.detect_primary_element=function(a){var b;return b=$("."+a),b.length>1&&typeof console!="undefined"&&console!==null&&console.warn('Sidetap: too many elements of class "'+a+'". There must be only one.'),b.addClass("stp-full-height"),b.first()},a.prototype.getScrollTop=function(){var a;return a=window.pageYOffset||document.compatMode==="CSS1Compat"&&document.documentElement.scrollTop||document.body.scrollTop||0},a.prototype.set_up_observers=function(){var a=this;return this.set_window_size(),$(window).resize(this.set_window_size),$(".nav-toggle").click(function(b){return a.toggle_nav(b)})},a.prototype.set_window_size=function(){return this.full_heights.css("minHeight",window.innerHeight),this.stp.hasClass("nav-showing")?this.set_nav_showing():this.set_nav_hiding()},a.prototype.toggle_nav=function(a){a!=null&&a.preventDefault(),this.stp_content.on("webkitAnimationEnd",this.nav_toggle_complete),this.stp.hasClass("nav-showing")?(this.stp_content.removeClass("showing-nav").addClass("hide-nav"),this.set_nav_hiding()):(this.stp_nav.show(),this.stp_content.removeClass("hide-nav").addClass("showing-nav"),this.set_nav_showing()),this.stp.toggleClass("nav-showing");if(this.ios_5)return this.address_bar_showing&&this.set_window_size(),window.scrollTo(0,1)},a.prototype.nav_toggle_complete=function(){this.stp_content.off("webkitAnimationEnd",this.nav_toggle_complete);if(!this.stp_content.hasClass("showing-nav"))return this.stp_nav.hide()},a.prototype.set_nav_showing=function(){return this.stp_nav.css("maxHeight","none"),this.stp_content.css("maxHeight",this.stp_nav.height())},a.prototype.set_nav_hiding=function(){return this.stp_content.css("maxHeight","none"),this.stp_nav.css("maxHeight",this.stp_content.height())},a.prototype.scroll_to=function(a){return $("body").scrollTop(a.offset().top-10)},a.prototype.show_section=function(a,b){b==null&&(b={}),this.stp_content.find(".stp-content-panel").not(".hidden").addClass("hidden"),a.removeClass("hidden").show();if(b.callback!=null)return b.callback.apply()},a}();var __bind=function(a,b){return function(){return a.apply(b,arguments)}},__hasProp={}.hasOwnProperty,__extends=function(a,b){function d(){this.constructor=a}for(var c in b)__hasProp.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};this.SidetapIos=function(a){function b(){this.in_from_left_complete=__bind(this.in_from_left_complete,this),this.in_from_right_complete=__bind(this.in_from_right_complete,this),this.down_from_top_complete=__bind(this.down_from_top_complete,this),this.up_from_bottom_complete=__bind(this.up_from_bottom_complete,this),this.set_window_size_2=__bind(this.set_window_size_2,this),$("body").addClass("ios"),this.ios_5=!0,b.__super__.constructor.call(this)}return __extends(b,a),b.name="SidetapIos",b.prototype.set_up_observers=function(){var a=this;return this.set_window_size(),$("header h1").click(function(b){return a.show_address_bar(b)}),$(window).on("orientationchange",function(b){return a.set_window_size(b)}),$(".nav-toggle").click(function(b){return a.toggle_nav(b)}),$("#stp-overlay").click(function(b){return a.toggle_nav(b)})},b.prototype.show_address_bar=function(a){return this.address_bar_showing=!0,this.full_heights.css("minHeight",160),setTimeout(this.set_window_size_2,1)},b.prototype.set_window_size=function(){return this.address_bar_showing=!1,$("body").css("paddingBottom","5000px"),window.scrollTo(0,1),setTimeout(this.set_window_size_2,50)},b.prototype.set_window_size_2=function(){return this.full_heights.css("minHeight",window.innerHeight),$("body").css("paddingBottom","0"),this.stp.hasClass("nav-showing")?this.set_nav_showing():this.set_nav_hiding()},b.prototype.scroll_to=function(a){var b,c,d;return d=a.parents(".stp-content-body").first(),c=d.scrollTop(),d.scrollTop(0),b=a.offset().top-98,d.scrollTop(c),d.stop().animate({scrollTop:b},"slow")},b.prototype.show_section=function(a,b){var c;return b==null&&(b={}),c=b.animation!=null?b.animation:"default",b.callback!=null&&(this.pending_callback=b.callback),c==="upfrombottom"?this.up_from_bottom(a):c==="downfromtop"?this.down_from_top(a):c==="infromright"?this.in_from_right(a):c==="infromleft"?this.in_from_left(a):(this.stp_content.find(".stp-content-panel").not(".hidden").addClass("hidden"),a.removeClass("hidden").show(),this.animation_callback())},b.prototype.up_from_bottom=function(a){return a.on("webkitAnimationEnd",this.up_from_bottom_complete).removeClass("hidden").addClass("up-from-bottom")},b.prototype.up_from_bottom_complete=function(){return this.slide_up_previous=$(".stp-content-panel").not(".up-from-bottom").addClass("hidden"),$(".up-from-bottom").off("webkitAnimationEnd",this.up_from_bottom_complete).removeClass("up-from-bottom"),this.animation_callback()},b.prototype.down_from_top=function(a){var b;return b=this.stp_content.find(".stp-content-panel").not(".hidden"),a.removeClass("hidden"),b.on("webkitAnimationEnd",this.down_from_top_complete).addClass("down-to-bottom")},b.prototype.down_from_top_complete=function(){var a;return a=$(".down-to-bottom"),a.off("webkitAnimationEnd",this.down_from_top_complete).removeClass("down-to-bottom").hide(),a.addClass("hidden").show(),this.animation_callback()},b.prototype.in_from_right=function(a){return $(".stp-content-panel").not(".hidden").addClass("slide-out-to-left"),a.on("webkitAnimationEnd",this.in_from_right_complete).removeClass("hidden").addClass("slide-in-from-right")},b.prototype.in_from_right_complete=function(){return $(".slide-out-to-left").addClass("hidden").removeClass("slide-out-to-left"),$(".slide-in-from-right").off("webkitAnimationEnd",this.in_from_right_complete).removeClass("slide-in-from-right"),this.animation_callback()},b.prototype.in_from_left=function(a){return $(".stp-content-panel").not(".hidden").addClass("slide-out-to-right"),a.on("webkitAnimationEnd",this.in_from_left_complete).removeClass("hidden").addClass("slide-in-from-left")},b.prototype.in_from_left_complete=function(){return $(".slide-out-to-right").removeClass("slide-out-to-right").addClass("hidden"),$(".slide-in-from-left").off("webkitAnimationEnd",this.in_from_left_complete).removeClass("slide-in-from-left"),this.animation_callback()},b.prototype.animation_callback=function(){return this.pending_callback&&this.pending_callback.call(),this.pending_callback=null},b}(SidetapStandard),this.sidetap=function(){var a;return a=window.SharedWorker&&navigator.userAgent.match(/^((?!android).)*webkit.*$/i),a?new SidetapIos:new SidetapStandard};
View
@@ -10,8 +10,8 @@
<link type="text/css" rel="stylesheet" media="screen" href="theme/default/default.css" />
</head>
<body>
- <div class="sidetap stp-full-height">
- <div class="stp-nav stp-full-height">
+ <div class="sidetap">
+ <div class="stp-nav">
<div>
<nav>
<a href="#" class="selected">Selected Nav Item</a>
@@ -22,7 +22,7 @@
</div>
</div>
- <div class="stp-content stp-full-height" id="content">
+ <div class="stp-content" id="content">
<header class="stp-fake-header">&nbsp;</header>
<div class="stp-overlay nav-toggle">&nbsp;</div>

0 comments on commit 8c7ad1c

Please sign in to comment.