Permalink
Browse files

Issue #271 Added support for existing behaviors

  • Loading branch information...
1 parent faba1b3 commit c950fb6c1b818d446cbf5a1e276d66b8aa3fd281 @67726e 67726e committed Dec 5, 2012
View
15 behaviors/cufon.js
@@ -11,11 +11,10 @@
+ Documentation: http://infinite-scroll.com/
*/
-
-$.extend($.infinitescroll.prototype,{
-
- _callback_cufon: function infscr_callback_cufon(newElements) {
- Cufon.refresh(newElements);
- }
-
-});
+(function ($, undefined) {
+ $.extend($.infinitescroll.prototype,{
+ _callback_cufon: function infscr_callback_cufon(newElements) {
+ Cufon.refresh(newElements);
+ }
+ });
+})(jQuery);
View
86 behaviors/manual-trigger.js
@@ -12,48 +12,50 @@
*/
-$.extend($.infinitescroll.prototype,{
-
- _setup_twitter: function infscr_setup_twitter () {
- var opts = this.options,
- instance = this;
-
- // Bind nextSelector link to retrieve
- $(opts.nextSelector).click(function(e) {
- if (e.which == 1 && !e.metaKey && !e.shiftKey) {
- e.preventDefault();
- instance.retrieve();
+(function($, undefined) {
+ $.extend($.infinitescroll.prototype,{
+
+ _setup_twitter: function infscr_setup_twitter () {
+ var opts = this.options,
+ instance = this;
+
+ // Bind nextSelector link to retrieve
+ $(opts.nextSelector).click(function(e) {
+ if (e.which == 1 && !e.metaKey && !e.shiftKey) {
+ e.preventDefault();
+ instance.retrieve();
+ }
+ });
+
+ // Define loadingStart to never hide pager
+ instance.options.loading.start = function (opts) {
+ opts.loading.msg
+ .appendTo(opts.loading.selector)
+ .show(opts.loading.speed, function () {
+ instance.beginAjax(opts);
+ });
}
- });
-
- // Define loadingStart to never hide pager
- instance.options.loading.start = function (opts) {
+ },
+ _showdonemsg_twitter: function infscr_showdonemsg_twitter () {
+ var opts = this.options,
+ instance = this;
+
+ //Do all the usual stuff
opts.loading.msg
- .appendTo(opts.loading.selector)
- .show(opts.loading.speed, function () {
- instance.beginAjax(opts);
- });
+ .find('img')
+ .hide()
+ .parent()
+ .find('div').html(opts.loading.finishedMsg).animate({ opacity: 1 }, 2000, function () {
+ $(this).parent().fadeOut('normal');
+ });
+
+ //And also hide the navSelector
+ $(opts.navSelector).fadeOut('normal');
+
+ // user provided callback when done
+ opts.errorCallback.call($(opts.contentSelector)[0],'done');
+
}
- },
- _showdonemsg_twitter: function infscr_showdonemsg_twitter () {
- var opts = this.options,
- instance = this;
-
- //Do all the usual stuff
- opts.loading.msg
- .find('img')
- .hide()
- .parent()
- .find('div').html(opts.loading.finishedMsg).animate({ opacity: 1 }, 2000, function () {
- $(this).parent().fadeOut('normal');
- });
-
- //And also hide the navSelector
- $(opts.navSelector).fadeOut('normal');
-
- // user provided callback when done
- opts.errorCallback.call($(opts.contentSelector)[0],'done');
-
- }
-
-});
+
+ });
+})(jQuery);
View
14 behaviors/masonry-isotope.js
@@ -12,10 +12,10 @@
*/
-$.extend($.infinitescroll.prototype,{
-
- _callback_masonry: function infscr_callback_masonry (newElements) {
- $(this).masonry('appended',$(newElements));
- }
-
-});
+(function($, undefined) {
+ $.extend($.infinitescroll.prototype,{
+ _callback_masonry: function infscr_callback_masonry (newElements) {
+ $(this).masonry('appended',$(newElements));
+ }
+ });
+})(jQuery);
View
10 behaviors/sausage.js
@@ -12,8 +12,8 @@
*/
-$.extend($.infinitescroll.prototype,{
-
-
-
-});
+(function($, undefined) {
+ $.extend($.infinitescroll.prototype,{
+ // TODO: Implement
+ });
+})(jQuery);
View
15 wordpress-plugin/behaviors/cufon.js
@@ -11,11 +11,10 @@
+ Documentation: http://infinite-scroll.com/
*/
-
-$.extend($.infinitescroll.prototype,{
-
- _callback_cufon: function infscr_callback_cufon(newElements) {
- Cufon.refresh(newElements);
- }
-
-});
+(function ($, undefined) {
+ $.extend($.infinitescroll.prototype,{
+ _callback_cufon: function infscr_callback_cufon(newElements) {
+ Cufon.refresh(newElements);
+ }
+ });
+})(jQuery);
View
86 wordpress-plugin/behaviors/manual-trigger.js
@@ -12,48 +12,50 @@
*/
-$.extend($.infinitescroll.prototype,{
-
- _setup_twitter: function infscr_setup_twitter () {
- var opts = this.options,
- instance = this;
-
- // Bind nextSelector link to retrieve
- $(opts.nextSelector).click(function(e) {
- if (e.which == 1 && !e.metaKey && !e.shiftKey) {
- e.preventDefault();
- instance.retrieve();
+(function($, undefined) {
+ $.extend($.infinitescroll.prototype,{
+
+ _setup_twitter: function infscr_setup_twitter () {
+ var opts = this.options,
+ instance = this;
+
+ // Bind nextSelector link to retrieve
+ $(opts.nextSelector).click(function(e) {
+ if (e.which == 1 && !e.metaKey && !e.shiftKey) {
+ e.preventDefault();
+ instance.retrieve();
+ }
+ });
+
+ // Define loadingStart to never hide pager
+ instance.options.loading.start = function (opts) {
+ opts.loading.msg
+ .appendTo(opts.loading.selector)
+ .show(opts.loading.speed, function () {
+ instance.beginAjax(opts);
+ });
}
- });
-
- // Define loadingStart to never hide pager
- instance.options.loading.start = function (opts) {
+ },
+ _showdonemsg_twitter: function infscr_showdonemsg_twitter () {
+ var opts = this.options,
+ instance = this;
+
+ //Do all the usual stuff
opts.loading.msg
- .appendTo(opts.loading.selector)
- .show(opts.loading.speed, function () {
- instance.beginAjax(opts);
- });
+ .find('img')
+ .hide()
+ .parent()
+ .find('div').html(opts.loading.finishedMsg).animate({ opacity: 1 }, 2000, function () {
+ $(this).parent().fadeOut('normal');
+ });
+
+ //And also hide the navSelector
+ $(opts.navSelector).fadeOut('normal');
+
+ // user provided callback when done
+ opts.errorCallback.call($(opts.contentSelector)[0],'done');
+
}
- },
- _showdonemsg_twitter: function infscr_showdonemsg_twitter () {
- var opts = this.options,
- instance = this;
-
- //Do all the usual stuff
- opts.loading.msg
- .find('img')
- .hide()
- .parent()
- .find('div').html(opts.loading.finishedMsg).animate({ opacity: 1 }, 2000, function () {
- $(this).parent().fadeOut('normal');
- });
-
- //And also hide the navSelector
- $(opts.navSelector).fadeOut('normal');
-
- // user provided callback when done
- opts.errorCallback.call($(opts.contentSelector)[0],'done');
-
- }
-
-});
+
+ });
+})(jQuery);
View
14 wordpress-plugin/behaviors/masonry-isotope.js
@@ -12,10 +12,10 @@
*/
-$.extend($.infinitescroll.prototype,{
-
- _callback_masonry: function infscr_callback_masonry (newElements) {
- $(this).masonry('appended',$(newElements));
- }
-
-});
+(function($, undefined) {
+ $.extend($.infinitescroll.prototype,{
+ _callback_masonry: function infscr_callback_masonry (newElements) {
+ $(this).masonry('appended',$(newElements));
+ }
+ });
+})(jQuery);
View
10 wordpress-plugin/behaviors/sausage.js
@@ -12,8 +12,8 @@
*/
-$.extend($.infinitescroll.prototype,{
-
-
-
-});
+(function($, undefined) {
+ $.extend($.infinitescroll.prototype,{
+ // TODO: Implement
+ });
+})(jQuery);
View
17 wordpress-plugin/infinite-scroll.php
@@ -117,11 +117,26 @@ function enqueue_js() {
$suffix = ( WP_DEBUG ) ? '.dev' : '';
$file = "/js/front-end/jquery.infinitescroll{$suffix}.js";
-
wp_enqueue_script( $this->slug, plugins_url( $file, __FILE__ ), array( 'jquery' ), $this->version, true );
$options = apply_filters( $this->prefix . 'js_options', $this->options->get_options() );
wp_localize_script( $this->slug, $this->slug_, $options );
+
+ // Output a behavior script if needed
+ if ($options["behavior"]) {
+ $scripts["twitter"] = "manual-trigger.js";
+ $scripts["local"] = "local.js";
+ $scripts["cufon"] = "cufon.js";
+ $scripts["masonry"] = "masonry-isotope.js";
+
+ $behaviorFile = $scripts[$options["behavior"]];
+
+ if ($behaviorFile) {
+ $behaviorFile = "/behaviors/" . $behaviorFile;
+ wp_enqueue_script($this->slug . "-behavior", plugins_url($behaviorFile, __FILE__),
+ array("jquery", $this->slug), $this->version, true);
+ }
+ }
}
/**
View
6 wordpress-plugin/languages/infinite-scroll.pot
@@ -150,7 +150,11 @@ msgstr ""
msgid "URL of existing or uploaded image to display as new posts are retrieved"
msgstr ""
-#:templates/options.php
+#: templates/options.php
+mgsid "Behavior"
+msgstr ""
+
+#: templates/options.php
mgsid "Debug"
msgstr ""
View
26 wordpress-plugin/templates/options.php
@@ -99,6 +99,32 @@
</tr>
<tr valign="top">
<th scope="row">
+ <?php _e("Behavior", "infinite-scroll") ?>
+ </th>
+ <td>
+
+<?php
+$behavior = $this->parent->options->behavior;
+
+function isBehavior($value, $behavior) {
+ if ($value === $behavior) {
+ print("selected=\"selected\"");
+ }
+}
+
+?>
+
+ <select id="infinite_scroll[behavior]" name="infinite_scroll[behavior]">
+ <option <?php isBehavior("", $behavior); ?> value="">Default</option>
+ <option <?php isBehavior("twitter", $behavior); ?> value="twitter">Manual Trigger</option>
+ <option <?php isBehavior("local", $behavior); ?> value="local">Local</option>
+ <option <?php isBehavior("cufon", $behavior); ?> value="cufon">Cufon</option>
+ <option <?php isBehavior("masonry", $behavior); ?> value="masonry">Masonry/Isotope</option>
+ </select>
+ </td>
+ </tr>
+ <tr valign="top">
+ <th scope="row">
<?php _e("Debug", "infinite-scroll") ?>
</th>
<td>

0 comments on commit c950fb6

Please sign in to comment.