Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a feature to reverse order of albums #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions js/plusgallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@


jQuery.ajaxSetup({ cache: false });

/**
* jQuery reverse hack
* http://stackoverflow.com/questions/1394020/jquery-each-backwards
*/

jQuery.fn.reverse = [].reverse;

/*
SLIDEFADE
------------------------------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -58,6 +66,12 @@ SLIDEFADE
exclude: null,
include: null,
imageData: null,
/**
* Option to reverse album order
* Added by Wouter Spaak
* 01-30-2014
*/
reverse: false,


/*don't touch*/
Expand Down Expand Up @@ -256,6 +270,20 @@ SLIDEFADE
pg.imagePath = dataAttr;
}

/**
* Reverse order of albums
* Parse from HTML string
* Added by Wouter Spaak
* 01-30-2014
*/
dataAttr = lmnt.attr('data-reverse');
if(dataAttr == 'true') {
pg.reverse = true;
}
else {
pg.reverse = false;
}

//JSON string containing image data *required only for local
dataAttr = lmnt.attr('data-image-data');
if(dataAttr) {
Expand Down Expand Up @@ -338,7 +366,14 @@ SLIDEFADE

//remove excluded galleries if there are any.
//albumTotal = albumTotal - pg.exclude.length;


/**
* Added method to reverse album order.
*/
if(pg.reverse) {
objPath.reverse();
}

if(albumTotal > 0){
$.each(objPath,function(i,obj){
//obj is entry
Expand All @@ -364,6 +399,13 @@ SLIDEFADE
if(albumTotal > pg.albumLimit) {
albumTotal = pg.albumLimit;
}

/**
* Added method to reverse album order.
*/
if(pg.reverse) {
objPath.reverse();
}

if(albumTotal > 0 ) {
$.each(objPath,function(i,obj){
Expand All @@ -388,6 +430,13 @@ SLIDEFADE
if(albumTotal > pg.albumLimit) {
albumTotal = pg.albumLimit;
}

/**
* Added method to reverse album order.
*/
if(pg.reverse) {
objPath.reverse();
}

if(albumTotal > 0) {
$.each(objPath,function(i,obj){
Expand All @@ -411,6 +460,13 @@ SLIDEFADE
if(albumTotal > pg.albumLimit) {
albumTotal = pg.albumLimit;
}

/**
* Added method to reverse album order.
*/
if(pg.reverse) {
objPath.reverse();
}

if(albumTotal > 0 ) {
$.each(objPath,function(i,obj){
Expand Down Expand Up @@ -896,4 +952,4 @@ SLIDEFADE
$.extend(pg, options);
pg.init();
};
})( jQuery );
})( jQuery );