Skip to content
Extraits de code Groupes Projets
Valider cdfaa83e rédigé par Raphael Sofaer's avatar Raphael Sofaer
Parcourir les fichiers

Let mobile users see getting_started, fix profile page infinite scroll on the mobile site

parent 3c4f6527
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -4,15 +4,17 @@ ...@@ -4,15 +4,17 @@
// version 2.0b1.110420 // version 2.0b1.110420
// home and docs: http://www.infinite-scroll.com // home and docs: http://www.infinite-scroll.com
// Modified by Diaspora:
// A few callbacks were made options and generateInstanceID was make jquery 162 compatible
*/ */
; (function ($) { ; (function ($) {
/* Define 'infinitescroll' function /* Define 'infinitescroll' function
---------------------------------------------------*/ ---------------------------------------------------*/
$.fn.infinitescroll = function infscr(options, callback) { $.fn.infinitescroll = function infscr(options, callback) {
// grab each selector option and see if any fail. // grab each selector option and see if any fail.
function areSelectorsValid(opts) { function areSelectorsValid(opts) {
var debug = $.fn.infinitescroll._debug; var debug = $.fn.infinitescroll._debug;
...@@ -28,29 +30,29 @@ ...@@ -28,29 +30,29 @@
// find the number to increment in the path. // find the number to increment in the path.
function determinePath(path) { function determinePath(path) {
if ($.isFunction(opts.pathParse)) { if ($.isFunction(opts.pathParse)) {
debug('pathParse'); debug('pathParse');
return [path]; return [path];
} else if (path.match(/^(.*?)\b2\b(.*?$)/)) { } else if (path.match(/^(.*?)\b2\b(.*?$)/)) {
path = path.match(/^(.*?)\b2\b(.*?$)/).slice(1); path = path.match(/^(.*?)\b2\b(.*?$)/).slice(1);
// if there is any 2 in the url at all. // if there is any 2 in the url at all.
} else if (path.match(/^(.*?)2(.*?$)/)) { } else if (path.match(/^(.*?)2(.*?$)/)) {
// page= is used in django: // page= is used in django:
// http://www.infinite-scroll.com/changelog/comment-page-1/#comment-127 // http://www.infinite-scroll.com/changelog/comment-page-1/#comment-127
if (path.match(/^(.*?page=)2(\/.*|$)/)) { if (path.match(/^(.*?page=)2(\/.*|$)/)) {
path = path.match(/^(.*?page=)2(\/.*|$)/).slice(1); path = path.match(/^(.*?page=)2(\/.*|$)/).slice(1);
return path; return path;
} }
path = path.match(/^(.*?)2(.*?$)/).slice(1); path = path.match(/^(.*?)2(.*?$)/).slice(1);
} else { } else {
// page= is used in drupal too but second page is page=1 not page=2: // page= is used in drupal too but second page is page=1 not page=2:
// thx Jerod Fritz, vladikoff // thx Jerod Fritz, vladikoff
if (path.match(/^(.*?page=)1(\/.*|$)/)) { if (path.match(/^(.*?page=)1(\/.*|$)/)) {
...@@ -64,8 +66,8 @@ ...@@ -64,8 +66,8 @@
debug('determinePath',path); debug('determinePath',path);
return path; return path;
} }
// Calculate internal height (used for local scroll) // Calculate internal height (used for local scroll)
function hiddenHeight(element) { function hiddenHeight(element) {
var height = 0; var height = 0;
...@@ -74,30 +76,37 @@ ...@@ -74,30 +76,37 @@
}); });
return height; return height;
} }
//Generate InstanceID based on random data (to give consistent but different ID's) //Generate InstanceID based on random data (to give consistent but different ID's)
function generateInstanceID(element) { function generateInstanceID(element) {
var number = $(element).length + $(element).html().length + $(element).attr("class").length + $(element).attr("id").length; var $element = $(element)
var number = $element.length + $element.html().length
if($element.attr("class") !== undefined){
number += $element.attr("class").length
}
if($element.attr("id") !== undefined){
number += $element.attr("id").length
}
opts.infid = number; opts.infid = number;
} }
// if options is a string, use as a command // if options is a string, use as a command
if (typeof options=='string') { if (typeof options=='string') {
var command = options, var command = options,
argument = callback, argument = callback,
validCommand = (command == 'pause' || command == 'destroy' || command == 'retrieve' || command == 'binding'), validCommand = (command == 'pause' || command == 'destroy' || command == 'retrieve' || command == 'binding'),
debug = $.fn.infinitescroll._debug; debug = $.fn.infinitescroll._debug;
argument = argument || null; argument = argument || null;
command = (validCommand) ? $.fn.infinitescroll[command](argument) : debug('Invalid command'); command = (validCommand) ? $.fn.infinitescroll[command](argument) : debug('Invalid command');
return false; return false;
} }
// lets get started. // lets get started.
var opts = $.infinitescroll.opts = $.extend({}, $.infinitescroll.defaults, options), var opts = $.infinitescroll.opts = $.extend({}, $.infinitescroll.defaults, options),
props = $.infinitescroll, // shorthand props = $.infinitescroll, // shorthand
...@@ -108,68 +117,68 @@ ...@@ -108,68 +117,68 @@
pause = $.fn.infinitescroll.pause, pause = $.fn.infinitescroll.pause,
destroy = $.fn.infinitescroll.destroy, destroy = $.fn.infinitescroll.destroy,
binding = $.fn.infinitescroll.binding; binding = $.fn.infinitescroll.binding;
// if selectors from opts aren't valid, return false // if selectors from opts aren't valid, return false
if (!areSelectorsValid(opts)) { return false; } if (!areSelectorsValid(opts)) { return false; }
opts.container = opts.container || document.documentElement; opts.container = opts.container || document.documentElement;
// contentSelector we'll use for our ajax call // contentSelector we'll use for our ajax call
opts.contentSelector = opts.contentSelector || this; opts.contentSelector = opts.contentSelector || this;
// Generate unique instance ID // Generate unique instance ID
opts.infid = (opts.infid == 0) ? generateInstanceID(opts.contentSelector) : opts.infid; opts.infid = (opts.infid == 0) ? generateInstanceID(opts.contentSelector) : opts.infid;
// loadMsgSelector - if we want to place the load message in a specific selector, defaulted to the contentSelector // loadMsgSelector - if we want to place the load message in a specific selector, defaulted to the contentSelector
opts.loadMsgSelector = opts.loadMsgSelector || opts.contentSelector; opts.loadMsgSelector = opts.loadMsgSelector || opts.contentSelector;
// get the relative URL - everything past the domain name. // get the relative URL - everything past the domain name.
var relurl = /(.*?\/\/).*?(\/.*)/, var relurl = /(.*?\/\/).*?(\/.*)/,
path = $(opts.nextSelector).attr('href'); path = $(opts.nextSelector).attr('href');
if (!path) { debug('Navigation selector not found'); return; } if (!path) { debug('Navigation selector not found'); return; }
// set the path to be a relative URL from root. // set the path to be a relative URL from root.
opts.path = determinePath(path); opts.path = determinePath(path);
// define loading msg // define loading msg
props.loadingMsg = $('<div id="infscr-loading" style="text-align: center;"><img alt="Loading..." src="' + props.loadingMsg = $('<div id="infscr-loading" style="text-align: center;"><img alt="Loading..." src="' +
opts.loadingImg + '" /><div>' + opts.loadingText + '</div></div>'); opts.loadingImg + '" /><div>' + opts.loadingText + '</div></div>');
// preload the image // preload the image
(new Image()).src = opts.loadingImg; (new Image()).src = opts.loadingImg;
//Check if its HTML (window scroll) and set innerContainerHeight //Check if its HTML (window scroll) and set innerContainerHeight
opts.binder = (opts.container.nodeName == "HTML") ? $(window) : $(opts.container); opts.binder = (opts.container.nodeName == "HTML") ? $(window) : $(opts.container);
innerContainerHeight = (opts.container.nodeName == "HTML") ? $(document).height() : innerContainerHeight = hiddenHeight(opts.container); innerContainerHeight = (opts.container.nodeName == "HTML") ? $(document).height() : innerContainerHeight = hiddenHeight(opts.container);
debug('Scrolling in: ',(opts.container.nodeName == "HTML") ? 'window' : opts.container); debug('Scrolling in: ',(opts.container.nodeName == "HTML") ? 'window' : opts.container);
// distance from nav links to bottom // distance from nav links to bottom
// computed as: height of the document + top offset of container - top offset of nav link // computed as: height of the document + top offset of container - top offset of nav link
opts.pixelsFromNavToBottom = innerContainerHeight + opts.pixelsFromNavToBottom = innerContainerHeight +
(opts.container == document.documentElement ? 0 : $(opts.container).offset().top) - (opts.container == document.documentElement ? 0 : $(opts.container).offset().top) -
$(opts.navSelector).offset().top; $(opts.navSelector).offset().top;
// set up our bindings // set up our bindings
// bind scroll handler to element (if its a local scroll) or window // bind scroll handler to element (if its a local scroll) or window
binding('bind'); binding('bind');
opts.binder.trigger('smartscroll.infscr.' + opts.infid); // trigger the event, in case it's a short page opts.binder.trigger('smartscroll.infscr.' + opts.infid); // trigger the event, in case it's a short page
return this; return this;
} // end of $.fn.infinitescroll() } // end of $.fn.infinitescroll()
/* Defaults and read-only properties object /* Defaults and read-only properties object
---------------------------------------------------*/ ---------------------------------------------------*/
$.infinitescroll = { $.infinitescroll = {
defaults: { defaults: {
debug: false, debug: false,
...@@ -207,35 +216,35 @@ ...@@ -207,35 +216,35 @@
loadingMsg: undefined, loadingMsg: undefined,
currDOMChunk: null // defined in setup()'s load() currDOMChunk: null // defined in setup()'s load()
}; };
/* Methods + Commands /* Methods + Commands
---------------------------------------------------*/ ---------------------------------------------------*/
// Console log wrapper. // Console log wrapper.
$.fn.infinitescroll._debug = function infscr_debug() { $.fn.infinitescroll._debug = function infscr_debug() {
if ($.infinitescroll.opts.debug) { if ($.infinitescroll.opts.debug) {
return window.console && console.log.call(console, arguments); return window.console && console.log.call(console, arguments);
} }
} }
// shortcut function for...getting shortcuts // shortcut function for...getting shortcuts
$.fn.infinitescroll._shorthand = function infscr_shorthand() { $.fn.infinitescroll._shorthand = function infscr_shorthand() {
// someone should write this, and it would rule // someone should write this, and it would rule
}; };
// Near Bottom (isNearBottom) // Near Bottom (isNearBottom)
$.fn.infinitescroll._nearbottom = function infscr_nearbottom() { $.fn.infinitescroll._nearbottom = function infscr_nearbottom() {
// replace with shorthand function // replace with shorthand function
var opts = $.infinitescroll.opts, var opts = $.infinitescroll.opts,
debug = $.fn.infinitescroll._debug, debug = $.fn.infinitescroll._debug,
hiddenHeight = $.fn.infinitescroll._hiddenheight; hiddenHeight = $.fn.infinitescroll._hiddenheight;
// distance remaining in the scroll // distance remaining in the scroll
// computed as: document height - distance already scroll - viewport height - buffer // computed as: document height - distance already scroll - viewport height - buffer
...@@ -256,31 +265,31 @@ ...@@ -256,31 +265,31 @@
// if distance remaining in the scroll (including buffer) is less than the orignal nav to bottom.... // if distance remaining in the scroll (including buffer) is less than the orignal nav to bottom....
return (pixelsFromWindowBottomToBottom - opts.bufferPx < opts.pixelsFromNavToBottom); return (pixelsFromWindowBottomToBottom - opts.bufferPx < opts.pixelsFromNavToBottom);
} }
// Setup function (infscrSetup) // Setup function (infscrSetup)
$.fn.infinitescroll._setup = function infscr_setup() { $.fn.infinitescroll._setup = function infscr_setup() {
// replace with shorthand function // replace with shorthand function
var props = $.infinitescroll, var props = $.infinitescroll,
opts = $.infinitescroll.opts, opts = $.infinitescroll.opts,
isNearBottom = $.fn.infinitescroll._nearbottom, isNearBottom = $.fn.infinitescroll._nearbottom,
kickOffAjax = $.fn.infinitescroll.retrieve; kickOffAjax = $.fn.infinitescroll.retrieve;
if (opts.isDuringAjax || opts.isInvalidPage || opts.isDone || opts.isDestroyed || opts.isPaused) return; if (opts.isDuringAjax || opts.isInvalidPage || opts.isDone || opts.isDestroyed || opts.isPaused) return;
if (!isNearBottom(opts, props)) return; if (!isNearBottom(opts, props)) return;
kickOffAjax(); kickOffAjax();
}; };
// Ajax function (kickOffAjax) // Ajax function (kickOffAjax)
$.fn.infinitescroll.retrieve = function infscr_retrieve() { $.fn.infinitescroll.retrieve = function infscr_retrieve() {
// replace with shorthand function // replace with shorthand function
var props = $.infinitescroll, var props = $.infinitescroll,
opts = props.opts, opts = props.opts,
...@@ -289,17 +298,17 @@ ...@@ -289,17 +298,17 @@
error = $.fn.infinitescroll._error, error = $.fn.infinitescroll._error,
path = opts.path, // get this path = opts.path, // get this
box, frag, desturl, method, condition; box, frag, desturl, method, condition;
// we dont want to fire the ajax multiple times // we dont want to fire the ajax multiple times
opts.isDuringAjax = true; opts.isDuringAjax = true;
// show the loading message quickly // show the loading message quickly
// then hide the previous/next links after we're // then hide the previous/next links after we're
// sure the loading message was visible // sure the loading message was visible
props.loadingMsg.appendTo(opts.loadMsgSelector).show(); props.loadingMsg.appendTo(opts.loadMsgSelector).show();
$(opts.navSelector).hide(); $(opts.navSelector).hide();
// increment the URL bit. e.g. /page/3/ // increment the URL bit. e.g. /page/3/
...@@ -309,31 +318,31 @@ ...@@ -309,31 +318,31 @@
// if we're dealing with a table we can't use DIVs // if we're dealing with a table we can't use DIVs
box = $(opts.contentSelector).is('table') ? $('<tbody/>') : $('<div/>'); box = $(opts.contentSelector).is('table') ? $('<tbody/>') : $('<div/>');
// INSERT DEBUG ERROR FOR invalid desturl // INSERT DEBUG ERROR FOR invalid desturl
desturl = ($.isFunction(opts.pathParse)) ? opts.pathParse(path.join('2'), opts.currPage) : desturl = path.join(opts.currPage); desturl = ($.isFunction(opts.pathParse)) ? opts.pathParse(path.join('2'), opts.currPage) : desturl = path.join(opts.currPage);
// desturl = path.join(opts.currPage); // desturl = path.join(opts.currPage);
// create switch parameter for append / callback // create switch parameter for append / callback
// MAKE SURE CALLBACK EXISTS??? // MAKE SURE CALLBACK EXISTS???
method = (opts.dataType == 'html' || opts.dataType == 'json') ? opts.dataType : 'html+callback'; method = (opts.dataType == 'html' || opts.dataType == 'json') ? opts.dataType : 'html+callback';
if (opts.appendCallback && opts.dataType == 'html') method += '+callback'; if (opts.appendCallback && opts.dataType == 'html') method += '+callback';
switch (method) { switch (method) {
case 'html+callback': case 'html+callback':
debug('Using HTML via .load() method'); debug('Using HTML via .load() method');
box.load(desturl + ' ' + opts.itemSelector, null, function(jqXHR,textStatus) { box.load(desturl + ' ' + opts.itemSelector, null, function(jqXHR,textStatus) {
loadCallback(box,jqXHR.responseText); loadCallback(box,jqXHR.responseText);
}); });
break; break;
case 'html': case 'html':
case 'json': case 'json':
debug('Using '+(method.toUpperCase())+' via $.ajax() method'); debug('Using '+(method.toUpperCase())+' via $.ajax() method');
$.ajax({ $.ajax({
// params // params
...@@ -344,16 +353,16 @@ ...@@ -344,16 +353,16 @@
(condition) ? loadCallback(box,jqXHR.responseText) : error([404]); (condition) ? loadCallback(box,jqXHR.responseText) : error([404]);
} }
}); });
break; break;
} }
}; };
// Load callback // Load callback
$.fn.infinitescroll._loadcallback = function infscr_loadcallback(box,data) { $.fn.infinitescroll._loadcallback = function infscr_loadcallback(box,data) {
// replace with shorthand function // replace with shorthand function
var props = $.infinitescroll, var props = $.infinitescroll,
opts = $.infinitescroll.opts, opts = $.infinitescroll.opts,
...@@ -361,81 +370,81 @@ ...@@ -361,81 +370,81 @@
showDoneMsg = $.fn.infinitescroll._donemsg, showDoneMsg = $.fn.infinitescroll._donemsg,
callback = $.fn.infinitescroll._callback, // GLOBAL OBJECT FOR CALLBACK callback = $.fn.infinitescroll._callback, // GLOBAL OBJECT FOR CALLBACK
result, frag; result, frag;
result = (opts.isDone) ? 'done' : (!opts.appendCallback) ? 'no-append' : 'append'; result = (opts.isDone) ? 'done' : (!opts.appendCallback) ? 'no-append' : 'append';
switch (result) { switch (result) {
case 'done': case 'done':
showDoneMsg(); showDoneMsg();
return false; return false;
break; break;
case 'no-append': case 'no-append':
if (opts.dataType == 'html') { if (opts.dataType == 'html') {
data = '<div>'+data+'</div>'; data = '<div>'+data+'</div>';
data = $(data).find(opts.itemSelector); data = $(data).find(opts.itemSelector);
}; };
break; break;
case 'append': case 'append':
var children = box.children(); var children = box.children();
// if it didn't return anything // if it didn't return anything
if (children.length == 0 || children.hasClass('error404')) { if (children.length == 0 || children.hasClass('error404')) {
// trigger a 404 error so we can quit. // trigger a 404 error so we can quit.
return error([404]); return error([404]);
} }
// use a documentFragment because it works when content is going into a table or UL // use a documentFragment because it works when content is going into a table or UL
frag = document.createDocumentFragment(); frag = document.createDocumentFragment();
while (box[0].firstChild) { while (box[0].firstChild) {
frag.appendChild(box[0].firstChild); frag.appendChild(box[0].firstChild);
} }
$(opts.contentSelector)[0].appendChild(frag); $(opts.contentSelector)[0].appendChild(frag);
// previously, we would pass in the new DOM element as context for the callback // previously, we would pass in the new DOM element as context for the callback
// however we're now using a documentfragment, which doesnt havent parents or children, // however we're now using a documentfragment, which doesnt havent parents or children,
// so the context is the contentContainer guy, and we pass in an array // so the context is the contentContainer guy, and we pass in an array
// of the elements collected as the first argument. // of the elements collected as the first argument.
data = children.get(); data = children.get();
break; break;
} }
// fadeout currently makes the <em>'d text ugly in IE6 // fadeout currently makes the <em>'d text ugly in IE6
props.loadingMsg.hide(); props.loadingMsg.hide();
// smooth scroll to ease in the new content // smooth scroll to ease in the new content
if (opts.animate) { if (opts.animate) {
var scrollTo = $(window).scrollTop() + $('#infscr-loading').height() + opts.extraScrollPx + 'px'; var scrollTo = $(window).scrollTop() + $('#infscr-loading').height() + opts.extraScrollPx + 'px';
$('html,body').animate({ scrollTop: scrollTo }, 800, function () { opts.isDuringAjax = false; }); $('html,body').animate({ scrollTop: scrollTo }, 800, function () { opts.isDuringAjax = false; });
} }
if (!opts.animate) opts.isDuringAjax = false; // once the call is done, we can allow it again. if (!opts.animate) opts.isDuringAjax = false; // once the call is done, we can allow it again.
callback.call($(opts.contentSelector)[0], data); callback.call($(opts.contentSelector)[0], data);
}; };
// Show done message. // Show done message.
$.fn.infinitescroll._donemsg = function infscr_donemsg() { $.fn.infinitescroll._donemsg = function infscr_donemsg() {
// replace with shorthand function // replace with shorthand function
var props = $.infinitescroll, var props = $.infinitescroll,
opts = $.infinitescroll.opts; opts = $.infinitescroll.opts;
props.loadingMsg props.loadingMsg
.find('img') .find('img')
.hide() .hide()
...@@ -444,24 +453,24 @@ ...@@ -444,24 +453,24 @@
$(this).parent().fadeOut('normal'); $(this).parent().fadeOut('normal');
}); });
// user provided callback when done // user provided callback when done
opts.errorCallback(); opts.errorCallback();
} }
// Pause function // Pause function
$.fn.infinitescroll.pause = function infscr_pause(pause) { $.fn.infinitescroll.pause = function infscr_pause(pause) {
// if pauseValue is not 'pause' or 'resume', toggle it's value // if pauseValue is not 'pause' or 'resume', toggle it's value
var debug = $.fn.infinitescroll._debug, var debug = $.fn.infinitescroll._debug,
opts = $.infinitescroll.opts; opts = $.infinitescroll.opts;
if (pause !== 'pause' && pause !== 'resume' && pause !== 'toggle' && pause !== null) { if (pause !== 'pause' && pause !== 'resume' && pause !== 'toggle' && pause !== null) {
debug('Invalid argument. Toggling pause value instead'); debug('Invalid argument. Toggling pause value instead');
}; };
pause = (pause && (pause == 'pause' || pause == 'resume')) ? pause : 'toggle'; pause = (pause && (pause == 'pause' || pause == 'resume')) ? pause : 'toggle';
switch (pause) { switch (pause) {
case 'pause': case 'pause':
opts.isPaused = true; opts.isPaused = true;
...@@ -475,26 +484,26 @@ ...@@ -475,26 +484,26 @@
opts.isPaused = !opts.isPaused; opts.isPaused = !opts.isPaused;
break; break;
} }
debug('Paused',opts.isPaused); debug('Paused',opts.isPaused);
return false; return false;
} }
// Error function // Error function
$.fn.infinitescroll._error = function infscr_error(xhr) { $.fn.infinitescroll._error = function infscr_error(xhr) {
// replace with shorthand function // replace with shorthand function
var opts = $.infinitescroll.opts, var opts = $.infinitescroll.opts,
binder = (opts.container.nodeName == "HTML") ? $(window) : $(opts.container), binder = (opts.container.nodeName == "HTML") ? $(window) : $(opts.container),
debug = $.fn.infinitescroll._debug, debug = $.fn.infinitescroll._debug,
showDoneMsg = $.fn.infinitescroll._donemsg, showDoneMsg = $.fn.infinitescroll._donemsg,
error = (!opts.isDone && xhr == 404) ? 'end' : (opts.isDestroyed && xhr == 302) ? 'destroy' : 'unknown'; error = (!opts.isDone && xhr == 404) ? 'end' : (opts.isDestroyed && xhr == 302) ? 'destroy' : 'unknown';
switch (error) { switch (error) {
case 'end': case 'end':
// die if we're out of pages. // die if we're out of pages.
debug('Page not found. Self-destructing...'); debug('Page not found. Self-destructing...');
showDoneMsg(); showDoneMsg();
...@@ -502,86 +511,86 @@ ...@@ -502,86 +511,86 @@
opts.currPage = 1; // if you need to go back to this instance opts.currPage = 1; // if you need to go back to this instance
opts.isPaused = false; opts.isPaused = false;
binder.unbind('smartscroll.infscr.' + opts.infid); binder.unbind('smartscroll.infscr.' + opts.infid);
break; break;
case 'destroy': case 'destroy':
// die if destroyed. // die if destroyed.
debug('Destroyed. Going to next instance...'); debug('Destroyed. Going to next instance...');
opts.isDone = true; opts.isDone = true;
opts.currPage = 1; // if you need to go back to this instance opts.currPage = 1; // if you need to go back to this instance
opts.isPaused = false; opts.isPaused = false;
binder.unbind('smartscroll.infscr.' + opts.infid); binder.unbind('smartscroll.infscr.' + opts.infid);
break; break;
case 'unknown': case 'unknown':
// unknown error. // unknown error.
debug('Unknown Error. WHAT DID YOU DO?!...'); debug('Unknown Error. WHAT DID YOU DO?!...');
showDoneMsg(); showDoneMsg();
opts.isDone = true; opts.isDone = true;
opts.currPage = 1; // if you need to go back to this instance opts.currPage = 1; // if you need to go back to this instance
binder.unbind('smartscroll.infscr.' + opts.infid); binder.unbind('smartscroll.infscr.' + opts.infid);
break; break;
} }
} }
// Destroy current instance of the plugin // Destroy current instance of the plugin
$.fn.infinitescroll.destroy = function infscr_destroy() { $.fn.infinitescroll.destroy = function infscr_destroy() {
// replace with shorthand function // replace with shorthand function
var opts = $.infinitescroll.opts, var opts = $.infinitescroll.opts,
error = $.fn.infinitescroll._error; error = $.fn.infinitescroll._error;
opts.isDestroyed = true; opts.isDestroyed = true;
return error([302]); return error([302]);
} }
// Scroll binding + unbinding // Scroll binding + unbinding
$.fn.infinitescroll.binding = function infscr_binding(binding) { $.fn.infinitescroll.binding = function infscr_binding(binding) {
// replace with shorthand function // replace with shorthand function
var opts = $.infinitescroll.opts, var opts = $.infinitescroll.opts,
setup = $.fn.infinitescroll._setup, setup = $.fn.infinitescroll._setup,
error = $.fn.infinitescroll._error, error = $.fn.infinitescroll._error,
debug = $.fn.infinitescroll._debug; debug = $.fn.infinitescroll._debug;
switch(binding) { switch(binding) {
case 'bind': case 'bind':
opts.binder.bind('smartscroll.infscr.'+opts.infid, setup); opts.binder.bind('smartscroll.infscr.'+opts.infid, setup);
break; break;
case 'unbind': case 'unbind':
opts.binder.unbind('smartscroll.infscr.'+opts.infid); opts.binder.unbind('smartscroll.infscr.'+opts.infid);
break; break;
} }
debug('Binding',binding); debug('Binding',binding);
return false; return false;
} }
/* /*
* smartscroll: debounced scroll event for jQuery * * smartscroll: debounced scroll event for jQuery *
* https://github.com/lukeshumard/smartscroll * https://github.com/lukeshumard/smartscroll
* Based on smartresize by @louis_remi: https://github.com/lrbabe/jquery.smartresize.js * * Based on smartresize by @louis_remi: https://github.com/lrbabe/jquery.smartresize.js *
* Copyright 2011 Louis-Remi & Luke Shumard * Licensed under the MIT license. * * Copyright 2011 Louis-Remi & Luke Shumard * Licensed under the MIT license. *
*/ */
var event = $.event, var event = $.event,
scrollTimeout; scrollTimeout;
event.special.smartscroll = { event.special.smartscroll = {
setup: function() { setup: function() {
$(this).bind( "scroll", event.special.smartscroll.handler ); $(this).bind( "scroll", event.special.smartscroll.handler );
...@@ -593,17 +602,17 @@ ...@@ -593,17 +602,17 @@
// Save the context // Save the context
var context = this, var context = this,
args = arguments; args = arguments;
// set correct event type // set correct event type
event.type = "smartscroll"; event.type = "smartscroll";
if (scrollTimeout) { clearTimeout(scrollTimeout); } if (scrollTimeout) { clearTimeout(scrollTimeout); }
scrollTimeout = setTimeout(function() { scrollTimeout = setTimeout(function() {
jQuery.event.handle.apply( context, args ); jQuery.event.handle.apply( context, args );
}, execAsap === "execAsap"? 0 : 100); }, execAsap === "execAsap"? 0 : 100);
} }
}; };
$.fn.smartscroll = function( fn ) { $.fn.smartscroll = function( fn ) {
return fn ? this.bind( "smartscroll", fn ) : this.trigger( "smartscroll", ["execAsap"] ); return fn ? this.bind( "smartscroll", fn ) : this.trigger( "smartscroll", ["execAsap"] );
}; };
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter