Skip to content

Commit

Permalink
lesson pagination fixes mainly, some other fixes included & clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
misfir3 committed Nov 17, 2016
1 parent 1436839 commit d11635f
Showing 1 changed file with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ define(['jquery',
this.currentPage = 0;
this.$contentPages = this.$el.find('.lesson-page-wrapper');
this.numPages = this.$contentPages.length;

//
this.addPaginationControls();
if (this.numPages > 1) {
//no animation on init
this.$contentPages.hide();
this.$el.find(this.$contentPages[this.currentPage]).show();
this.addPaginationControls();
this.showNextPageButton();
this.hidePrevPageButton();
} else if (this.numPages === 1) {
this.hideNextPageButton();
this.hidePrevPageButton();
}
},

Expand Down Expand Up @@ -110,31 +116,25 @@ define(['jquery',
},

addPaginationControls: function() {
var pagingControlsDiv
var pagingControlsDiv;
this.$el.html();
// remove this.$prevPageButton refs ??? hide/show not really working
this.$prevPageButton = $('<span>',{class:'glyphicon-class glyphicon glyphicon-circle-arrow-left show-prev-page'});
this.$prevPageButton.unbind().on('click',this.decrementPageView.bind(this));

this.$nextPageButton = $('<span>',{class:'glyphicon-class glyphicon glyphicon-circle-arrow-right show-next-page'});
this.$nextPageButton.unbind().on('click',this.incrementPageView.bind(this));

//prev
var prevPageButton = $('<span>',{class:'glyphicon-class glyphicon glyphicon-circle-arrow-left show-prev-page'});
prevPageButton.unbind().on('click',this.decrementPageView.bind(this));
//next
var nextPageButton = $('<span>',{class:'glyphicon-class glyphicon glyphicon-circle-arrow-right show-next-page'});
nextPageButton.unbind().on('click',this.incrementPageView.bind(this));
//add to DOM
if (this.$el.find('#lesson-page-controls').length < 1) {
pagingControlsDiv = $('<div>',{class:'panel-body', id:'lesson-page-controls'});
pagingControlsDiv.append(this.$prevPageButton);
pagingControlsDiv.append(this.$nextPageButton);
pagingControlsDiv.append(prevPageButton);
pagingControlsDiv.append(nextPageButton);
this.$el.append(pagingControlsDiv);
}

this.$prevPageButton.hide();

if (this.numPages > 0 ) {
this.$nextPageButton.show();
}


},

/* show & hide pagination controls */
showPrevPageButton: function() {
$('span.glyphicon-class.glyphicon.glyphicon-circle-arrow-left.show-prev-page').show();
},
Expand All @@ -151,6 +151,7 @@ define(['jquery',
$('span.glyphicon-class.glyphicon.glyphicon-circle-arrow-right.show-next-page').hide();
},

/* increment, decrement & display handlers */
incrementPageView: function() {
if (this.currentPage < this.numPages -1) {
this.currentPage++;
Expand Down

0 comments on commit d11635f

Please sign in to comment.