Commit 495a7bfb authored by Remon Georgy's avatar Remon Georgy

Add D7 modifications :D

parent 4c5afb8b
......@@ -7,7 +7,7 @@
*/
/**
* Implementation of hook_drush_command().
* Implements hook_drush_command().
*
* In this hook, you specify which commands your
* drush module makes available, what it does and
......@@ -32,7 +32,7 @@ function views_infinite_scroll_drush_command() {
}
/**
* Implementation of hook_drush_help().
* Implements hook_drush_help().
*
* This function is called whenever a drush user calls
* 'drush help <name-of-your-command>'
......@@ -62,7 +62,7 @@ function views_infinite_scroll_drush_help($section) {
*
*/
function views_infinite_scroll_drush_autopager_download() {
if(module_exists('libraries')) {
if (module_exists('libraries')) {
$path = 'sites/all/libraries/autopager';
// Create the path if it does not exist.
......
// $Id:
(function ($) {
var views_infinite_scroll_was_initialised = false;
Drupal.behaviors.views_infinite_scroll = function() {
// Make sure that autopager plugin is loaded
if($.autopager) {
if(!views_infinite_scroll_was_initialised) {
views_infinite_scroll_was_initialised = true;
// There should not be multiple Infinite Scroll Views on the same page
if(Drupal.settings.views_infinite_scroll.length == 1) {
var settings = Drupal.settings.views_infinite_scroll[0];
var use_ajax = false;
// Make sure that views ajax is disabled
if(Drupal.settings.views && Drupal.settings.views.ajaxViews) {
$.each(Drupal.settings.views.ajaxViews, function(key, value) {
if((value.view_name == settings.view_name) && (value.view_display_id == settings.display)) {
use_ajax = true;
}
});
Drupal.behaviors.views_infinite_scroll = {
attach:function() {
// Make sure that autopager plugin is loaded
if($.autopager) {
if(!views_infinite_scroll_was_initialised) {
views_infinite_scroll_was_initialised = true;
// There should not be multiple Infinite Scroll Views on the same page
if(Drupal.settings.views_infinite_scroll.length == 1) {
var settings = Drupal.settings.views_infinite_scroll[0];
var use_ajax = false;
// Make sure that views ajax is disabled
if(Drupal.settings.views && Drupal.settings.views.ajaxViews) {
$.each(Drupal.settings.views.ajaxViews, function(key, value) {
if((value.view_name == settings.view_name) && (value.view_display_id == settings.display)) {
use_ajax = true;
}
});
}
if(!use_ajax) {
var content_selector = 'div.view-id-' + settings.view_name + '.view-display-id-' + settings.display + ' ' + settings.content_selector;
var items_selector = content_selector + ' ' + settings.items_selector;
var next_selector = settings.next_selector;
var img_path = settings.img_path;
var img = '<div id="views_infinite_scroll-ajax-loader"><img src="' + img_path + '" alt="loading..."/></div>';
var img_location = 'div.view-id-' + settings.view_name + '.view-display-id-' + settings.display + ' div.view-content';
$(settings.pager_selector).hide();
$.autopager({
appendTo: content_selector,
content: items_selector,
link: next_selector,
page: 0,
start: function() {
$(img_location).after(img);
},
load: function() {
$('div#views_infinite_scroll-ajax-loader').remove();
Drupal.attachBehaviors();
}
});
}
else {
alert(Drupal.t('Views infinite scroll pager is not compatible with Ajax Views. Please disable "Use Ajax" option.'));
}
}
if(!use_ajax) {
var content_selector = 'div.view-id-' + settings.view_name + '.view-display-id-' + settings.display + ' ' + settings.content_selector;
var items_selector = content_selector + ' ' + settings.items_selector;
var next_selector = settings.next_selector;
var img_path = settings.img_path;
var img = '<div id="views_infinite_scroll-ajax-loader"><img src="' + img_path + '" alt="loading..."/></div>';
var img_location = 'div.view-id-' + settings.view_name + '.view-display-id-' + settings.display + ' div.view-content';
$(settings.pager_selector).hide();
$.autopager({
appendTo: content_selector,
content: items_selector,
link: next_selector,
page: 0,
start: function() {
$(img_location).after(img);
},
load: function() {
$('div#views_infinite_scroll-ajax-loader').remove();
Drupal.attachBehaviors();
}
});
else if(Drupal.settings.views_infinite_scroll.length > 1) {
alert(Drupal.t('Views Infinite Scroll module can\'t handle more than one infinite view in the same page.'));
}
else {
alert(Drupal.t('Views infinite scroll pager is not compatible with Ajax Views. Please disable "Use Ajax" option.'));
}
}
else if(Drupal.settings.views_infinite_scroll.length > 1) {
alert(Drupal.t('Views Infinite Scroll module can\'t handle more than one infinite view in the same page.'));
}
}
else {
alert(Drupal.t('Autopager jquery plugin in not loaded.'));
}
}
else {
alert(Drupal.t('Autopager jquery plugin in not loaded.'));
}
};
}
})(jQuery);
......@@ -4,7 +4,18 @@
* @file
* Theme infinite scroll page
*/
function theme_views_infinite_scroll_pager($tags = array(), $limit = 10, $view_name, $current_display, $content_selector = 'div.view-content', $items_selector = 'div.view-content .views-row', $img_path, $element = 0, $parameters = array(), $quantity = 9) {
function theme_views_infinite_scroll_pager($variables) {
$tags = $variables['tags'];
$limit = isset($variables['limit']) ? $variables['limit'] : 10;
$view_name = $variables['view_name'];
$element = isset($variables['element']) ? $variables['element'] : 0;
$current_display = $variables['current_display'];
$content_selector = isset($variables['content_selector']) ? $variables['content_selector'] : 'div.view-content';
$items_selector = isset($variables['items_selector']) ? $variables['items_selector'] : 'div.view-content .views-row';
$img_path = $variables['img_path'];
$parameters = $variables['parameters'];
$quantity = $variables['quantity'];
$PAGER_CLASS = 'pager';
global $pager_page_array, $pager_total;
......@@ -17,38 +28,47 @@ function theme_views_infinite_scroll_pager($tags = array(), $limit = 10, $view_n
$pager_max = $pager_total[$element];
// End of marker calculations.
$li_next = theme('pager_next', (isset($tags[3]) ? $tags[3] : t('››')), $limit, $element, 1, $parameters);
$li_next = theme('pager_next',
array(
'text' => (isset($tags[3]) ? $tags[3] : t('››')),
'limit' => $limit,
'element' => $element,
'interval' => 1,
'parameters' => $parameters,
)
);
if (empty($li_next)) {
$li_next = "&nbsp;";
}
if ($pager_total[$element] > 1) {
$items[] = array(
'class' => 'pager-current',
'class' => array('pager-current'),
'data' => t('@current of @max', array('@current' => $pager_current, '@max' => $pager_max)),
);
$items[] = array(
'class' => 'pager-next',
'class' => array('pager-next'),
'data' => $li_next,
);
$settings = array(
'views_infinite_scroll' => array(
array(
'view_name' => $view_name,
'display' => $current_display,
'display' => $current_display,
'pager_selector' => 'ul.' . $PAGER_CLASS,
'next_selector' => 'li.pager-next a:first',
'content_selector' => $content_selector,
'items_selector' => $items_selector,
'next_selector' => 'li.pager-next a:first',
'content_selector' => $content_selector,
'items_selector' => $items_selector,
'img_path' => $img_path,
),
),
);
drupal_add_css(drupal_get_path('module', 'views_infinite_scroll') . '/css/views_infinite_scroll.css');
drupal_add_js($settings, 'setting' );
drupal_add_js($settings, array('type' => 'setting', 'scope' => JS_DEFAULT));
$autopager_path = '';
if (module_exists('libraries')) {
$autopager_path = libraries_get_path('autopager');
......@@ -60,7 +80,7 @@ function theme_views_infinite_scroll_pager($tags = array(), $limit = 10, $view_n
drupal_add_js($autopager_path . '/jquery.autopager-1.0.0.js');
drupal_add_js(drupal_get_path('module', 'views_infinite_scroll') . '/js/views_infinite_scroll.js');
return theme('item_list', $items, NULL, 'ul', array('class' => $PAGER_CLASS));
return theme('item_list', array('items' => $items, 'title' => NULL, 'type' => 'ul', 'attributes' => array('class' => array($PAGER_CLASS))));
}
}
......@@ -2,5 +2,11 @@
name = Views Infinite Scroll
description = Provides an Infinite Scrolling pager for Views
package = Views
core = 6.x
core = 7.x
dependencies[] = views
files[] = views_infinite_scroll.module
files[] = views_infinite_scroll.views.inc
files[] = views_plugin_pager_infinite_scroll.inc
files[] = drush/views_infinite_scroll.drush.inc
files[] = theme/views_infinite_scroll_theme.inc
......@@ -5,14 +5,14 @@
*/
/**
* Implementation of hook_views_api().
* Implements hook_views_api().
*/
function views_infinite_scroll_views_api() {
return array('api' => '3.0-alpha1');
}
/**
* Implementation of hook_theme().
* Implements hook_theme().
*/
function views_infinite_scroll_theme() {
$path = drupal_get_path('module', 'views_infinite_scroll');
......@@ -25,7 +25,12 @@ function views_infinite_scroll_theme() {
// Our extra version of pager from pager.inc
$hooks['views_infinite_scroll_pager'] = $base + array(
'arguments' => array('tags' => array(), 'limit' => 10, 'element' => 0, 'parameters' => array()),
'variables' => array(
'tags' => array(),
'limit' => 10,
'element' => 0,
'parameters' => array(),
),
'pattern' => 'views_infinite_scroll_pager__',
);
return $hooks;
......
......@@ -6,8 +6,8 @@
*/
/**
* Implementation of hook_views_plugin().
*/
* Implements hook_views_plugin().
*/
function views_infinite_scroll_views_plugins() {
return array(
'module' => 'views_infinite_scroll',
......
......@@ -16,16 +16,16 @@ class views_plugin_pager_infinite_scroll extends views_plugin_pager_full {
if (!empty($this->options['offset'])) {
return format_plural($this->options['items_per_page'], 'Infinite scroll pager, @count item, skip @skip', 'Infinite scroll pager, @count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']));
}
return format_plural($this->options['items_per_page'], 'Infinite scroll pager, @count item', 'Infinite scroll pager, @count items', array('@count' => $this->options['items_per_page']));
return format_plural($this->options['items_per_page'], 'Infinite scroll pager, @count item', 'Infinite scroll pager, @count items', array('@count' => $this->options['items_per_page']));
}
function render($input) {
global $base_url;
$style_plugin = $this->view->display_handler->default_display->options['style_plugin'];
$style_plugin = $this->view->display_handler->default_display->options['style_plugin'];
$content_selector = '';
$items_selector = '';
$img_path = $base_url . '/' . drupal_get_path('module', 'views_infinite_scroll') . '/images/ajax-loader.gif';
switch($this->view->plugin_name){
switch ($this->view->plugin_name) {
case 'default':
$content_selector = 'div.view-content';
$items_selector = '.views-row';
......@@ -44,6 +44,6 @@ class views_plugin_pager_infinite_scroll extends views_plugin_pager_full {
break;
}
$pager_theme = views_theme_functions('views_infinite_scroll_pager', $this->view, $this->display);
return theme($pager_theme, $input, $this->options['items_per_page'], $this->view->name, $this->view->current_display, $content_selector, $items_selector, $img_path, $this->options['id']);
return theme($pager_theme, array('tags' => $input, 'quantity' => $this->options['items_per_page'], 'view_name' => $this->view->name, 'current_display' => $this->view->current_display, 'content_selector' => $content_selector, 'items_selector' => $items_selector, 'img_path' => $img_path, 'element' => $this->options['id']));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment