Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

user interaction and easier management of warnings to our user; right…

…/left within proper bounds, now.
  • Loading branch information...
commit 59fddd3975d88d199166c3e6ae8a64d69fffe74c 1 parent bc043bd
@jzacsh authored
Showing with 67 additions and 19 deletions.
  1. +15 −2 input/inc/global.css
  2. +52 −17 input/inc/slides.js
View
17 input/inc/global.css
@@ -310,6 +310,14 @@ body.beerand .list.active {
clear: both;
}
+#sliderjs.reached-low {
+ border-left: 1px solid #ffc0cb;
+}
+
+#sliderjs.reached-high {
+ border-right: 1px solid #ffc0cb;
+}
+
.slide {
cursor: pointer;
width: 175px;
@@ -323,11 +331,11 @@ body.beerand .list.active {
outline: 1px solid #cccccc;
}
-#viewer.reached-beginning img {
+#viewer.reached-low img {
border-left: 1px solid #ffc0cb;
}
-#viewer.reached-end img {
+#viewer.reached-high img {
border-right: 1px solid #ffc0cb;
}
@@ -354,6 +362,11 @@ body.beerand .list.active {
text-shadow: 2px 2px 1px #ffffff;
}
+.slider.disabled {
+ color: #dddddd;
+ cursor: normal;
+}
+
#prev-page {
float: left;
}
View
69 input/inc/slides.js
@@ -460,6 +460,13 @@
*/
Slides.prototype.setPage = function (page, current) {
current = (typeof(current) == 'undefined')? this.pageNumber(this.conf.current) : current;
+ if (this.checkPageBounds(page)) {
+ //keep track of the new page
+ this.conf.currentPage = page;
+ }
+ else {
+ return false;
+ }
var i = 0, $slide,
liveSlides = this.slidesOnPage(current),
@@ -488,8 +495,7 @@
$slide.show();
}
- //keep track of the new page
- this.conf.currentPage = page;
+ //update hash for our user
if (this.conf.current == null) {
//viewer is closed, appropriate to update #page/x
document.location.hash = 'page/' + (this.conf.currentPage + 1);
@@ -517,30 +523,59 @@
}
/**
- * Determine if the proposed index is within our bounds.
- *
- * @TODO: this should be "protected/private".
+ * Determine if the proposed slide index is within our bounds.
*/
Slides.prototype.checkViewerBounds = function (index) {
- var $viewer = this.conf.jq('#' + this.conf.viewerID, this.conf.jqc);
if (index > this.conf.images.length || index < 0) {
- //let the user know
- $viewer.addClass('reach');
+ var $viewer = this.conf.jq('#' + this.conf.viewerID, this.conf.jqc);
- //be more specific
+ //warn our user
+ var bound;
if (index < 0) {
- $viewer.addClass('reached-beginning');
+ bound = 'low';
}
else {
- $viewer.addClass('reached-end');
+ bound = 'high';
}
- window.setTimeout(function() {
- $viewer
- .removeClass('reach')
- .removeClass('reached-beginning')
- .removeClass('reached-end');
- }, 1500);
+ this.warnOutOfBounds($viewer, bound);
+
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Modify the dom by addeding a few classes to let our user know they've
+ * reached out of their bounds in some way.
+ */
+ Slides.prototype.warnOutOfBounds = function (boundedBy, limit, warning) {
+ warning = parseInt(warning, 10)? warning : 1500;
+
+ boundedBy.addClass('reach');
+ boundedBy.addClass('reached-' + limit);
+ window.setTimeout(function() {
+ boundedBy
+ .removeClass('reach')
+ .removeClass('reached-' + limit);
+ }, warning);
+ }
+ /**
+ * Determine if the proposed page index is within our bounds.
+ */
+ Slides.prototype.checkPageBounds = function (page) {
+ page = parseInt(page, 10);
+
+ var lastPage = this.pageNumber(this.conf.images.length - 1);
+ if (page == NaN || page < 0 || page > lastPage) {
+ var limit;
+ if (page < 0) {
+ limit = 'low';
+ }
+ else {
+ limit = 'high';
+ }
+ this.warnOutOfBounds(this.conf.slider, limit);
return false;
}
return true;
Please sign in to comment.
Something went wrong with that request. Please try again.