Permalink
Browse files

Merge remote-tracking branch 'paulirish/master'

  • Loading branch information...
1 parent e35a978 commit a477cd0f51a129519b59191739c9456140be3bb2 @samcleaver samcleaver committed Dec 17, 2012
View
@@ -162,13 +162,13 @@
};
// callback loading
- opts.callback = function(instance,data) {
+ opts.callback = function(instance, data, url) {
if (!!opts.behavior && instance['_callback_'+opts.behavior] !== undefined) {
- instance['_callback_'+opts.behavior].call($(opts.contentSelector)[0], data);
+ instance['_callback_'+opts.behavior].call($(opts.contentSelector)[0], data, url);
}
if (callback) {
- callback.call($(opts.contentSelector)[0], data, opts);
+ callback.call($(opts.contentSelector)[0], data, opts, url);
}
if (opts.prefill) {
@@ -320,8 +320,7 @@
},
// Load Callback
- _loadcallback: function infscr_loadcallback(box, data) {
-
+ _loadcallback: function infscr_loadcallback(box, data, url) {
var opts = this.options,
callback = this.options.callback, // GLOBAL OBJECT FOR CALLBACK
result = (opts.state.isDone) ? 'done' : (!opts.appendCallback) ? 'no-append' : 'append',
@@ -383,7 +382,7 @@
opts.state.isDuringAjax = false;
}
- callback(this,data);
+ callback(this, data, url);
if (opts.prefill) {
this._prefill();
@@ -547,10 +546,9 @@
switch (method) {
case 'html+callback':
-
instance._debug('Using HTML via .load() method');
box.load(desturl + ' ' + opts.itemSelector, undefined, function infscr_ajax_callback(responseText) {
- instance._loadcallback(box, responseText);
+ instance._loadcallback(box, responseText, desturl);
});
break;
@@ -564,7 +562,7 @@
complete: function infscr_ajax_callback(jqXHR, textStatus) {
condition = (typeof (jqXHR.isResolved) !== 'undefined') ? (jqXHR.isResolved()) : (textStatus === "success" || textStatus === "notmodified");
if (condition) {
- instance._loadcallback(box, jqXHR.responseText);
+ instance._loadcallback(box, jqXHR.responseText, desturl);
} else {
instance._error('end');
}
@@ -598,7 +596,7 @@
} else {
// if appendCallback is false, we will pass in the JSON object. you should handle it yourself in your callback.
if (condition) {
- instance._loadcallback(box, data);
+ instance._loadcallback(box, data, desturl);
} else {
instance._error('end');
}

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -74,21 +74,20 @@
$('#content').infinitescroll({
- navSelector : "p#next:last",
+ navSelector : "#next:last",
nextSelector : "a#next:last",
itemSelector : "#content p",
debug : true,
dataType : 'html',
// prefill : true,
// path: ["http://nuvique/infinite-scroll/test/index", ".html"]
path: function(index) {
- return "http://nuvique/infinite-scroll/test/index" + index + ".html";
+ return "index" + index + ".html";
}
// behavior : 'twitter',
// appendCallback : false, // USE FOR PREPENDING
// pathParse : function( pathStr, nextPage ){ return pathStr.replace('2', nextPage ); }
- }, function(newElements){
-
+ }, function(newElements, data, url){
//USE FOR PREPENDING
// $(newElements).css('background-color','#ffef00');
// $(this).prepend(newElements);
@@ -73,6 +73,9 @@ function validate( $options ) {
if ( empty( $options["loading"]['img'] ) )
$options["loading"]['img'] = $this->loading["img"];
+ // force `debug` to be a bool
+ $options["debug"] = (bool)$options["debug"];
+
return apply_filters( $this->parent->prefix . 'options_validate', $options );
}
@@ -21,6 +21,8 @@
* @package Infinite_Scroll
*/
+require_once(ABSPATH . "/wp-admin/includes/theme.php");
+
class Infinite_Scroll_Presets {
private $parent;
@@ -58,6 +60,22 @@ function __get( $preset ) {
return $this->get_preset( $preset );
}
+ function getThemes($args) {
+ if (function_exists("wp_get_themes")) {
+ return wp_get_themes($args);
+ } else {
+ return get_themes();
+ }
+ }
+
+ function getTheme($theme) {
+ if (function_exists("wp_get_theme")) {
+ return wp_get_theme($theme);
+ } else {
+ return get_theme($theme);
+ }
+ }
+
/**
* Pulls preset array from cache, or retrieves and parses
@@ -115,7 +133,7 @@ function get_preset( $theme = null ) {
//WP version 3.4+, use the new wp_get_themes function
if ( function_exists( 'wp_get_theme' ) ) {
- $theme = wp_get_theme( $theme );
+ $theme = $this->getTheme($theme);
//not a theme or not a child
if ( is_wp_error( $theme ) || !is_object( $theme->parent() ) )
@@ -128,7 +146,7 @@ function get_preset( $theme = null ) {
//pre 3.4 back compat..
//get theme by slug
$name = $this->get_name( $theme );
- $themes = get_themes();
+ $themes = $this->getThemes(array());
$child = $themes[ $name ];
//not a child theme
@@ -524,17 +542,16 @@ function migrate() {
* @return bool true if insalled, otherwise false
*/
function theme_installed( $theme ) {
-
//3.4+
- if ( function_exists( 'wp_get_theme' ) )
+ if ( function_exists( 'wp_get_theme' ) ) {
return wp_get_theme( $theme->theme )->exists();
-
- //pre 3.4
- $themes = get_themes();
- $name = $this->get_name( $theme );
-
- return array_key_exists( $name, $themes );
-
+ } else {
+ //pre 3.4
+ $themes = get_themes();
+ $name = $this->get_name( $theme );
+
+ return array_key_exists( $name, $themes );
+ }
}
/**
@@ -551,14 +568,14 @@ function get_stylesheet( $name ) {
//pre 3.4
if ( !function_exists( 'wp_get_themes' ) ) {
- if ( $theme = get_theme( $name ) )
+ if ( $theme = get_theme( $name ) )
return $theme->stylesheet;
//3.4+
} else {
//we can't use wp_filter_list_object with WP_Theme objects, so filter manually
- foreach ( wp_get_themes() as $theme )
+ foreach ( $this->getThemes(null) as $theme )
if ( $theme->name = $name )
return $theme->stylesheet;
@@ -588,7 +605,7 @@ function get_name( $stylesheet ) {
//pre 3.4
} else {
- foreach ( get_themes as $theme )
+ foreach ( get_themes() as $theme )
if ( $theme->stylesheet == $stylesheet )
return $theme->name;
@@ -692,7 +709,7 @@ function prepare_items() {
$data = array_filter( $data, array( &$infinite_scroll->presets, 'theme_installed' ) );
//merge in themes
- $themes = get_themes();
+ $themes = $infinite_scroll->presets->getThemes(null);
foreach ( $themes as $theme => $theme_data ) {
@@ -734,4 +751,4 @@ function prepare_items() {
}
-}
+}
Oops, something went wrong.

0 comments on commit a477cd0

Please sign in to comment.