1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-05 10:49:37 +02:00

Add Infinite Scroll in Browse

This commit is contained in:
Afterster 2014-01-12 01:55:14 +01:00
parent c3b3a8021e
commit cfb349178e
24 changed files with 494 additions and 85 deletions

View file

@ -81,6 +81,7 @@ Ampache includes some external modules that carry their own licensing.
* [Tag-it!] (http://aehlke.github.io/tag-it/): MIT
* [PHP Echo Nest API] (https://github.com/bshaffer/php-echonest-api): MIT
* [Noty] (http://ned.im/noty/): MIT
* [jScroll] (https://github.com/pklauzinski/jscroll): MIT
Translations

View file

@ -140,6 +140,9 @@ class Ajax
*/
public static function text($action, $text, $source, $post='', $class='')
{
// Avoid duplicate id
$source .= '_' . time();
// Format the string we wanna use
$ajax_string = self::action($action, $source, $post);
@ -148,7 +151,6 @@ class Ajax
$class = ' class="' . $class . '"';
}
// If we pass a source put it in the ID
$string = "<a href=\"javascript:void(0);\" id=\"$source\" $class>$text</a>\n";
$string .= self::observe($source, 'click', $ajax_string);

View file

@ -31,6 +31,17 @@
*/
class Browse extends Query
{
public function __construct($id = null, $cached = true)
{
parent::__construct($id, $cached);
if (!$id) {
$this->set_use_pages(true);
$this->set_use_alpha(false);
}
$this->show_header = true;
}
/**
* set_simple_browse
* This sets the current browse object to a 'simple' browse method
@ -123,108 +134,123 @@ class Browse extends Query
// Set the correct classes based on type
$class = "box browse_" . $type;
Ajax::start_container('browse_content_' . $type, 'browse_content');
// Switch on the type of browsing we're doing
switch ($type) {
case 'song':
UI::show_box_top(T_('Songs') . $match, $class);
$box_title = T_('Songs') . $match;
Song::build_cache($object_ids);
require_once AmpConfig::get('prefix') . '/templates/show_songs.inc.php';
UI::show_box_bottom();
$box_req = AmpConfig::get('prefix') . '/templates/show_songs.inc.php';
break;
case 'album':
UI::show_box_top(T_('Albums') . $match, $class);
$box_title = T_('Albums') . $match;
Album::build_cache($object_ids,'extra');
require_once AmpConfig::get('prefix') . '/templates/show_albums.inc.php';
UI::show_box_bottom();
$box_req = AmpConfig::get('prefix') . '/templates/show_albums.inc.php';
break;
case 'user':
UI::show_box_top(T_('Manage Users') . $match, $class);
require_once AmpConfig::get('prefix') . '/templates/show_users.inc.php';
UI::show_box_bottom();
$box_title = T_('Manage Users') . $match;
$box_req = AmpConfig::get('prefix') . '/templates/show_users.inc.php';
break;
case 'artist':
UI::show_box_top(T_('Artists') . $match, $class);
$box_title = T_('Artists') . $match;
Artist::build_cache($object_ids,'extra');
require_once AmpConfig::get('prefix') . '/templates/show_artists.inc.php';
UI::show_box_bottom();
$box_req = AmpConfig::get('prefix') . '/templates/show_artists.inc.php';
break;
case 'live_stream':
require_once AmpConfig::get('prefix') . '/templates/show_live_stream.inc.php';
UI::show_box_top(T_('Radio Stations') . $match, $class);
require_once AmpConfig::get('prefix') . '/templates/show_live_streams.inc.php';
UI::show_box_bottom();
$box_title = T_('Radio Stations') . $match;
$box_req = AmpConfig::get('prefix') . '/templates/show_live_streams.inc.php';
break;
case 'playlist':
Playlist::build_cache($object_ids);
UI::show_box_top(T_('Playlists') . $match, $class);
require_once AmpConfig::get('prefix') . '/templates/show_playlists.inc.php';
UI::show_box_bottom();
$box_title = T_('Playlists') . $match;
$box_req = AmpConfig::get('prefix') . '/templates/show_playlists.inc.php';
break;
case 'playlist_song':
UI::show_box_top(T_('Playlist Songs') . $match, $class);
require_once AmpConfig::get('prefix') . '/templates/show_playlist_songs.inc.php';
UI::show_box_bottom();
$box_title = T_('Playlist Songs') . $match;
$box_req = AmpConfig::get('prefix') . '/templates/show_playlist_songs.inc.php';
break;
case 'playlist_localplay':
UI::show_box_top(T_('Current Playlist'));
require_once AmpConfig::get('prefix') . '/templates/show_localplay_playlist.inc.php';
$box_title = T_('Current Playlist');
$box_req = AmpConfig::get('prefix') . '/templates/show_localplay_playlist.inc.php';
UI::show_box_bottom();
break;
case 'smartplaylist':
UI::show_box_top(T_('Smart Playlists') . $match, $class);
require_once AmpConfig::get('prefix') . '/templates/show_smartplaylists.inc.php';
UI::show_box_bottom();
$box_title = T_('Smart Playlists') . $match;
$box_req = AmpConfig::get('prefix') . '/templates/show_smartplaylists.inc.php';
break;
case 'catalog':
UI::show_box_top(T_('Catalogs'), $class);
require_once AmpConfig::get('prefix') . '/templates/show_catalogs.inc.php';
UI::show_box_bottom();
$box_title = T_('Catalogs');
$box_req = AmpConfig::get('prefix') . '/templates/show_catalogs.inc.php';
break;
case 'shoutbox':
UI::show_box_top(T_('Shoutbox Records'),$class);
require_once AmpConfig::get('prefix') . '/templates/show_manage_shoutbox.inc.php';
UI::show_box_bottom();
$box_title = T_('Shoutbox Records');
$box_req = AmpConfig::get('prefix') . '/templates/show_manage_shoutbox.inc.php';
break;
case 'tag':
Tag::build_cache($tags);
UI::show_box_top(T_('Tag Cloud'),$class);
require_once AmpConfig::get('prefix') . '/templates/show_tagcloud.inc.php';
UI::show_box_bottom();
$box_title = T_('Tag Cloud');
$box_req = AmpConfig::get('prefix') . '/templates/show_tagcloud.inc.php';
break;
case 'video':
Video::build_cache($object_ids);
UI::show_box_top(T_('Videos'),$class);
require_once AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
UI::show_box_bottom();
$box_title = T_('Videos');
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
break;
case 'democratic':
UI::show_box_top(T_('Democratic Playlist'),$class);
require_once AmpConfig::get('prefix') . '/templates/show_democratic_playlist.inc.php';
UI::show_box_bottom();
$box_title = T_('Democratic Playlist');
$box_req = AmpConfig::get('prefix') . '/templates/show_democratic_playlist.inc.php';
break;
case 'wanted':
UI::show_box_top(T_('Wanted Albums'),$class);
require_once AmpConfig::get('prefix') . '/templates/show_wanted_albums.inc.php';
UI::show_box_bottom();
$box_title = T_('Wanted Albums');
$box_req = AmpConfig::get('prefix') . '/templates/show_wanted_albums.inc.php';
break;
case 'song_preview':
UI::show_box_top(T_('Songs'),$class);
require_once AmpConfig::get('prefix') . '/templates/show_song_previews.inc.php';
UI::show_box_bottom();
$box_title = T_('Songs');
$box_req = AmpConfig::get('prefix') . '/templates/show_song_previews.inc.php';
break;
default:
// Rien a faire
break;
} // end switch on type
echo '<script type="text/javascript">';
echo Ajax::action('?page=browse&action=get_filters&browse_id=' . $this->id, '');
echo ';</script>';
Ajax::start_container('browse_content_' . $type, 'browse_content');
if ($this->get_show_header()) {
if ($box_req) {
UI::show_box_top($box_title, $class);
}
}
if ($box_req) {
require_once $box_req;
}
if ($this->get_show_header()) {
if ($box_req) {
UI::show_box_bottom();
}
echo '<script type="text/javascript">';
echo Ajax::action('?page=browse&action=get_filters&browse_id=' . $this->id, '');
echo ';</script>';
} else {
if (!$this->get_use_pages()) {
$this->show_next_link();
}
}
Ajax::end_container();
} // show_object
public function show_next_link()
{
$limit = $this->get_offset();
$start = $this->get_start();
$total = $this->get_total();
$next_offset = $start + $limit;
if ($next_offset <= $total) {
echo '<a class="jscroll-next" href="' . AmpConfig::get('ajax_url') . '?page=browse&action=page&browse_id=' . $this->id . '&start=' . $next_offset . '&xoutput=raw&xoutputnode=browse_content_' . $this->get_type() . '&show_header=false">' . T_('More') . '</a>';
}
}
/**
* set_filter_from_request
* //FIXME
@ -251,4 +277,34 @@ class Browse extends Query
}
} // set_filter_from_request
public function set_use_pages($use_pages)
{
$this->_state['use_pages'] = $use_pages;
}
public function get_use_pages()
{
return $this->_state['use_pages'];
}
public function set_use_alpha($use_alpha)
{
$this->_state['use_alpha'] = $use_alpha;
}
public function get_use_alpha()
{
return $this->_state['use_alpha'];
}
public function set_show_header($show_header)
{
$this->show_header = $show_header;
}
public function get_show_header()
{
return $this->show_header;
}
} // browse

View file

@ -366,6 +366,9 @@ function xoutput_from_array($array, $callback = false, $type = '')
$output = $_REQUEST['xoutput'] ?: 'xml';
if ($output == 'xml') {
return xml_from_array($array, $callback, $type);
} elseif ($output == 'raw') {
$outputnode = $_REQUEST['xoutputnode'];
return $array[$outputnode];
} else {
return json_from_array($array, $callback, $type);
}

View file

@ -0,0 +1,209 @@
/*!
* jScroll - jQuery Plugin for Infinite Scrolling / Auto-Paging - v2.2.4
* http://jscroll.com/
*
* Copyright 2011-2013, Philip Klauzinski
* http://klauzinski.com/
* Dual licensed under the MIT and GPL Version 2 licenses.
* http://jscroll.com/#license
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
*
* @author Philip Klauzinski
* @requires jQuery v1.4.3+
*/
(function($) {
// Define the jscroll namespace and default settings
$.jscroll = {
defaults: {
debug: false,
autoTrigger: true,
autoTriggerUntil: false,
loadingHtml: '<small>Loading...</small>',
padding: 0,
nextSelector: 'a:last',
contentSelector: '',
pagingSelector: '',
callback: false
}
};
// Constructor
var jScroll = function($e, options) {
// Private vars
var _data = $e.data('jscroll'),
_userOptions = (typeof options === 'function') ? { callback: options } : options,
_options = $.extend({}, $.jscroll.defaults, _userOptions, _data || {}),
_isWindow = ($e.css('overflow-y') === 'visible'),
_$next = $e.find(_options.nextSelector).first(),
_$window = $(window),
_$body = $('body'),
_$scroll = _isWindow ? _$window : $e,
_nextHref = $.trim(_$next.attr('href') + ' ' + _options.contentSelector);
// Initialization
$e.data('jscroll', $.extend({}, _data, {initialized: true, waiting: false, nextHref: _nextHref}));
_wrapInnerContent();
_preloadImage();
_setBindings();
// Private methods
// Check if a loading image is defined and preload
function _preloadImage() {
var src = $(_options.loadingHtml).filter('img').attr('src');
if (src) {
var image = new Image();
image.src = src;
}
}
// Wrapper inner content, if it isn't already
function _wrapInnerContent() {
if (!$e.find('.jscroll-inner').length) {
$e.contents().wrapAll('<div class="jscroll-inner" />');
}
}
// Find the next link's parent, or add one, and hide it
function _nextWrap($next) {
if (_options.pagingSelector) {
var $parent = $next.closest(_options.pagingSelector).hide();
} else {
var $parent = $next.parent().not('.jscroll-inner,.jscroll-added').addClass('jscroll-next-parent').hide();
if (!$parent.length) {
$next.wrap('<div class="jscroll-next-parent" />').parent().hide();
}
}
}
// Remove the jscroll behavior and data from an element
function _destroy() {
return _$scroll.unbind('.jscroll')
.removeData('jscroll')
.find('.jscroll-inner').children().unwrap()
.filter('.jscroll-added').children().unwrap();
}
// Observe the scroll event for when to trigger the next load
function _observe() {
_wrapInnerContent();
var $inner = $e.find('div.jscroll-inner').first(),
data = $e.data('jscroll'),
borderTopWidth = parseInt($e.css('borderTopWidth')),
borderTopWidthInt = isNaN(borderTopWidth) ? 0 : borderTopWidth,
iContainerTop = parseInt($e.css('paddingTop')) + borderTopWidthInt,
iTopHeight = _isWindow ? _$scroll.scrollTop() : $e.offset().top,
innerTop = $inner.length ? $inner.offset().top : 0,
iTotalHeight = Math.ceil(iTopHeight - innerTop + _$scroll.height() + iContainerTop);
if (!data.waiting && iTotalHeight + _options.padding >= $inner.outerHeight()) {
//data.nextHref = $.trim(data.nextHref + ' ' + _options.contentSelector);
_debug('info', 'jScroll:', $inner.outerHeight() - iTotalHeight, 'from bottom. Loading next request...');
return _load();
}
}
// Check if the href for the next set of content has been set
function _checkNextHref(data) {
data = data || $e.data('jscroll');
if (!data || !data.nextHref) {
_debug('warn', 'jScroll: nextSelector not found - destroying');
_destroy();
return false;
} else {
_setBindings();
return true;
}
}
function _setBindings() {
var $next = $e.find(_options.nextSelector).first();
if (_options.autoTrigger && (_options.autoTriggerUntil === false || _options.autoTriggerUntil > 0)) {
_nextWrap($next);
if (_$body.height() <= _$window.height()) {
_observe();
}
_$scroll.unbind('.jscroll').bind('scroll.jscroll', function() {
return _observe();
});
if (_options.autoTriggerUntil > 0) {
_options.autoTriggerUntil--;
}
} else {
_$scroll.unbind('.jscroll');
$next.bind('click.jscroll', function() {
_nextWrap($next);
_load();
return false;
});
}
}
// Load the next set of content, if available
function _load() {
var $inner = $e.find('div.jscroll-inner').first(),
data = $e.data('jscroll');
data.waiting = true;
$inner.append('<div class="jscroll-added" />')
.children('.jscroll-added').last()
.html('<div class="jscroll-loading">' + _options.loadingHtml + '</div>');
return $e.animate({scrollTop: $inner.outerHeight()}, 0, function() {
$inner.find('div.jscroll-added').last().load(data.nextHref, function(r, status, xhr) {
if (status === 'error') {
return _destroy();
}
var $next = $(this).find(_options.nextSelector).first();
data.waiting = false;
data.nextHref = $next.attr('href') ? $.trim($next.attr('href') + ' ' + _options.contentSelector) : false;
$('.jscroll-next-parent', $e).remove(); // Remove the previous next link now that we have a new one
_checkNextHref();
if (_options.callback) {
_options.callback.call(this);
}
_debug('dir', data);
});
});
}
// Safe console debug - http://klauzinski.com/javascript/safe-firebug-console-in-javascript
function _debug(m) {
if (_options.debug && typeof console === 'object' && (typeof m === 'object' || typeof console[m] === 'function')) {
if (typeof m === 'object') {
var args = [];
for (var sMethod in m) {
if (typeof console[sMethod] === 'function') {
args = (m[sMethod].length) ? m[sMethod] : [m[sMethod]];
console[sMethod].apply(console, args);
} else {
console.log.apply(console, args);
}
}
} else {
console[m].apply(console, Array.prototype.slice.call(arguments, 1));
}
}
}
// Expose API methods via the jQuery.jscroll namespace, e.g. $('sel').jscroll.method()
$.extend($e.jscroll, {
destroy: _destroy
});
return $e;
};
// Define the jscroll plugin method and loop
$.fn.jscroll = function(m) {
return this.each(function() {
var $this = $(this),
data = $this.data('jscroll');
// Instantiate jScroll on this element if it hasn't been already
if (data && data.initialized) return;
var jscroll = new jScroll($this, m);
});
};
})(jQuery);

15
modules/jscroll/jquery.jscroll.min.js vendored Normal file
View file

@ -0,0 +1,15 @@
/*!
* jScroll - jQuery Plugin for Infinite Scrolling / Auto-Paging - v2.2.4
* http://jscroll.com/
*
* Copyright 2011-2013, Philip Klauzinski
* http://klauzinski.com/
* Dual licensed under the MIT and GPL Version 2 licenses.
* http://jscroll.com/#license
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
*
* @author Philip Klauzinski
* @requires jQuery v1.4.3+
*/
(function(b){b.jscroll={defaults:{debug:false,autoTrigger:true,autoTriggerUntil:false,loadingHtml:"<small>Loading...</small>",padding:0,nextSelector:"a:last",contentSelector:"",pagingSelector:"",callback:false}};var a=function(e,g){var o=e.data("jscroll"),n=(typeof g==="function")?{callback:g}:g,p=b.extend({},b.jscroll.defaults,n,o||{}),c=(e.css("overflow-y")==="visible"),l=e.find(p.nextSelector).first(),v=b(window),h=b("body"),q=c?v:e,m=b.trim(l.attr("href")+" "+p.contentSelector);e.data("jscroll",b.extend({},o,{initialized:true,waiting:false,nextHref:m}));r();k();t();function k(){var x=b(p.loadingHtml).filter("img").attr("src");if(x){var w=new Image();w.src=x}}function r(){if(!e.find(".jscroll-inner").length){e.contents().wrapAll('<div class="jscroll-inner" />')}}function d(w){if(p.pagingSelector){var x=w.closest(p.pagingSelector).hide()}else{var x=w.parent().not(".jscroll-inner,.jscroll-added").addClass("jscroll-next-parent").hide();if(!x.length){w.wrap('<div class="jscroll-next-parent" />').parent().hide()}}}function j(){return q.unbind(".jscroll").removeData("jscroll").find(".jscroll-inner").children().unwrap().filter(".jscroll-added").children().unwrap()}function i(){r();var D=e.find("div.jscroll-inner").first(),B=e.data("jscroll"),C=parseInt(e.css("borderTopWidth")),y=isNaN(C)?0:C,x=parseInt(e.css("paddingTop"))+y,A=c?q.scrollTop():e.offset().top,z=D.length?D.offset().top:0,w=Math.ceil(A-z+q.height()+x);if(!B.waiting&&w+p.padding>=D.outerHeight()){f("info","jScroll:",D.outerHeight()-w,"from bottom. Loading next request...");return u()}}function s(w){w=w||e.data("jscroll");if(!w||!w.nextHref){f("warn","jScroll: nextSelector not found - destroying");j();return false}else{t();return true}}function t(){var w=e.find(p.nextSelector).first();if(p.autoTrigger&&(p.autoTriggerUntil===false||p.autoTriggerUntil>0)){d(w);if(h.height()<=v.height()){i()}q.unbind(".jscroll").bind("scroll.jscroll",function(){return i()});if(p.autoTriggerUntil>0){p.autoTriggerUntil--}}else{q.unbind(".jscroll");w.bind("click.jscroll",function(){d(w);u();return false})}}function u(){var x=e.find("div.jscroll-inner").first(),w=e.data("jscroll");w.waiting=true;x.append('<div class="jscroll-added" />').children(".jscroll-added").last().html('<div class="jscroll-loading">'+p.loadingHtml+"</div>");return e.animate({scrollTop:x.outerHeight()},0,function(){x.find("div.jscroll-added").last().load(w.nextHref,function(A,z,B){if(z==="error"){return j()}var y=b(this).find(p.nextSelector).first();w.waiting=false;w.nextHref=y.attr("href")?b.trim(y.attr("href")+" "+p.contentSelector):false;b(".jscroll-next-parent",e).remove();s();if(p.callback){p.callback.call(this)}f("dir",w)})})}function f(w){if(p.debug&&typeof console==="object"&&(typeof w==="object"||typeof console[w]==="function")){if(typeof w==="object"){var y=[];for(var x in w){if(typeof console[x]==="function"){y=(w[x].length)?w[x]:[w[x]];console[x].apply(console,y)}else{console.log.apply(console,y)}}}else{console[w].apply(console,Array.prototype.slice.call(arguments,1))}}}b.extend(e.jscroll,{destroy:j});return e};b.fn.jscroll=function(c){return this.each(function(){var f=b(this),e=f.data("jscroll");if(e&&e.initialized){return}var d=new a(f,c)})}})(jQuery);

View file

@ -0,0 +1,41 @@
{
"name": "jscroll",
"version": "2.2.4",
"title": "jScroll - jQuery Plugin for Infinite Scrolling / Auto-Paging",
"author": {
"name": "Philip KLauzinski",
"url": "http://klauzinski.com"
},
"licenses": [
{
"type": "MIT",
"url": "http://opensource.org/licenses/MIT"
},
{
"type": "GPL-2.0",
"url": "http://opensource.org/licenses/GPL-2.0"
}
],
"dependencies": {
"jquery": ">=1.4.3"
},
"description": "jScroll is a jQuery plugin allowing you to effortlessly implement infinite scrolling, lazy loading, or whatever catchy phrase you may know it as, within a web page or web/HTML5 application. jScroll allows you to initiate an auto-paged AJAX fetch triggered by scrolling within a fixed-height div, or from scrolling the window object. A real-world example of this behavior is your Facebook News Feed, which automatically loads content as you scroll down and reach the end of the page.",
"keywords": [
"infinite-scrolling",
"lazy-loading",
"auto-paging",
"infinite",
"scroll",
"scrolling",
"lazy",
"auto",
"loading",
"paging",
"ajax",
"html5"
],
"homepage": "http://jscroll.com",
"demo": "http://jscroll.com/#examples",
"docs": "http://jscroll.com",
"bugs": "https://github.com/pklauzinski/jscroll/issues"
}

View file

@ -28,11 +28,6 @@ if (!AmpConfig::get('subsonic_backend')) {
exit;
}
$ssid = $_GET['ssid'];
if (!empty($ssid)) {
print_r('test', 'found!', '5');
}
$action = strtolower($_GET['action']);
$f = $_GET['f'];
$callback = $_GET['callback'];

View file

@ -37,6 +37,10 @@ if (isset($_REQUEST['browse_id'])) {
$list_uid = scrub_in($_REQUEST['uid']);
$browse = new Browse($browse_id);
if ($_REQUEST['show_header']) {
$browse->set_show_header($_REQUEST['show_header'] == 'true');
}
debug_event('browse.ajax.php', 'Called for action: {'.$_REQUEST['action'].'}', '5');
switch ($_REQUEST['action']) {
@ -73,6 +77,10 @@ switch ($_REQUEST['action']) {
$browse->set_sort($_REQUEST['sort']);
}
if (!$browse->get_use_pages()) {
$browse->set_start(0);
}
ob_start();
$browse->show_objects();
$results['browse_content_' . $browse->get_type()] = ob_get_clean();
@ -130,6 +138,25 @@ switch ($_REQUEST['action']) {
ob_start();
require_once AmpConfig::get('prefix') . '/templates/browse_filters.inc.php';
$results['browse_filters'] = ob_get_clean();
break;
case 'options':
$option = $_REQUEST['option'];
$value = $_REQUEST['value'];
$browse->set_start(0);
switch ($option) {
case 'use_pages':
$browse->set_use_pages($value == 'true');
break;
case 'use_alpha':
$browse->set_use_alpha($value == 'true');
break;
}
ob_start();
$browse->show_objects();
$results['browse_content_' . $browse->get_type()] = ob_get_clean();
break;
default:
$results['rfc3514'] = '0x1';
break;

View file

@ -47,6 +47,7 @@ if (AmpConfig::get('use_rss')) { ?>
<script src="<?php echo $web_path; ?>/modules/prettyPhoto/js/jquery.prettyPhoto.js" language="javascript" type="text/javascript"></script>
<script src="<?php echo $web_path; ?>/modules/tag-it/tag-it.min.js" language="javascript" type="text/javascript"></script>
<script src="<?php echo $web_path; ?>/modules/noty/packaged/jquery.noty.packaged.min.js" language="javascript" type="text/javascript"></script>
<script src="<?php echo $web_path; ?>/modules/jscroll/jquery.jscroll.min.js" language="javascript" type="text/javascript"></script>
<script src="<?php echo $web_path; ?>/lib/javascript/base.js" language="javascript" type="text/javascript"></script>
<script src="<?php echo $web_path; ?>/lib/javascript/ajax.js" language="javascript" type="text/javascript"></script>
<script src="<?php echo $web_path; ?>/lib/javascript/edit-dialog.js" language="javascript" type="text/javascript"></script>

View file

@ -27,6 +27,12 @@
* to layout this page.
*/
if ($is_header) {
$is_header = false;
} else {
$is_header = true;
}
// Pull these variables out to allow shorthand (easier for lazy programmers)
$limit = $browse->get_offset();
$start = $browse->get_start();
@ -39,6 +45,21 @@ if (isset($_REQUEST['browse_uid'])) {
}
$sides = 5;
?>
<?php if (!$browse->get_use_pages() && !$is_header) { ?>
<?php $this->show_next_link(); ?>
</p>
</div>
<script type="text/javascript">
$('#browse_<?php echo $browse->id; ?>_scroll').jscroll({
autoTrigger: true,
nextSelector: 'a.jscroll-next:last',
autoTriggerUntil: 2,
});
</script>
<?php } ?>
<?php
// Next
$next_offset = $start + $limit;
if ($next_offset > $total) { $next_offset = $start; }
@ -53,9 +74,11 @@ if ($limit > 0 && $total > $limit) {
} else {
$pages = 0;
}
?>
<div class="list-header">
<?php
// are there enough items to even need this view?
if ($pages > 1) {
if ($pages > 1 && $start > -1) {
/* Calculate current page and how many we have on each side */
$page_data = array('up' => array(), 'down' => array());
@ -98,8 +121,7 @@ if ($pages > 1) {
ksort($page_data['up']);
ksort($page_data['down']);
?>
<div class="list-header">
<?php if ($browse->get_use_pages()) { ?>
<?php echo Ajax::text('?page=browse&action=page&browse_id=' . $browse->id . '&start=' . $prev_offset . '&browse_uid=' . $uid, T_('Prev'),'browse_' . $uid . 'prev','','prev'); ?>
<?php echo Ajax::text('?page=browse&action=page&browse_id=' . $browse->id . '&start=' . $next_offset . '&browse_uid=' . $uid, T_('Next'),'browse_' . $uid . 'next','','next'); ?>
<?php echo Ajax::text('?page=browse&action=page&browse_id=' . $browse->id . '&start=-1&browse_uid=' . $uid, T_('All'),'browse_' . $uid . 'all','','all'); ?>
@ -126,7 +148,19 @@ if ($pages > 1) {
} // end else
} // end foreach up
?>
</div>
<?php } else {?>
&nbsp;
<?php } ?>
<?php
} // if stuff
?>
<span class="browse-options">
<span><input type="checkbox" id="browse_<?php echo $browse->id; ?>_use_pages_<?php echo $is_header; ?>" value="true" <?php echo (($browse->get_use_pages()) ? 'checked' : ''); ?> onClick="javascript:<?php echo Ajax::action("?page=browse&action=options&browse_id=" . $browse->id . "&option=use_pages&value=' + $('#browse_" . $browse->id . "_use_pages_" . $is_header . "').is(':checked') + '", "browse_" . $browse->id . "_use_pages_" . $is_header); ?>">Pages</span>
<span><input type="checkbox" id="browse_<?php echo $browse->id; ?>_use_scroll_<?php echo $is_header; ?>" value="true" <?php echo ((!$browse->get_use_pages()) ? 'checked' : ''); ?> onClick="javascript:<?php echo Ajax::action("?page=browse&action=options&browse_id=" . $browse->id . "&option=use_pages&value=' + !($('#browse_" . $browse->id . "_use_scroll_" . $is_header . "').is(':checked')) + '", "browse_" . $browse->id . "_use_scroll_" . $is_header); ?>">Infinite Scroll</span>
<!--<span><input type="checkbox" id="browse_<?php echo $browse->id; ?>_use_alpha_<?php echo $is_header; ?>" value="true" <?php echo (($browse->get_use_alpha()) ? 'checked' : ''); ?>>Alphabet</span>-->
</span>
</div>
<?php if (!$browse->get_use_pages() && $is_header) { ?>
<div id="browse_<?php echo $browse->id; ?>_scroll">
<p>
<?php } ?>

View file

@ -24,7 +24,7 @@ $web_path = AmpConfig::get('web_path');
$tags_list = Tag::get_display(Tag::get_tags());
$thcount = 7;
?>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">
<?php if (AmpConfig::get('directplay')) { ++$thcount; ?>
@ -87,4 +87,4 @@ $thcount = 7;
<th class="cel_action"><?php echo T_('Actions'); ?></th>
</tr>
</table>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>

View file

@ -26,7 +26,7 @@ $web_path = AmpConfig::get('web_path');
$tags_list = Tag::get_display(Tag::get_tags());
$thcount = 7;
?>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">
<?php if (AmpConfig::get('directplay')) { ++$thcount; ?>
@ -84,4 +84,4 @@ $thcount = 7;
<th class="cel_action"> <?php echo T_('Action'); ?> </th>
</tr>
</table>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>

View file

@ -20,7 +20,7 @@
*
*/
?>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">
<th class="cel_catalog"><?php echo T_('Name'); ?></th>
@ -55,4 +55,4 @@
<th class="cel_action"><?php echo T_('Actions'); ?></th>
</tr>
</table>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>

View file

@ -22,7 +22,7 @@
$web_path = AmpConfig::get('web_path');
?>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<colgroup>
<col id="col_action" />
@ -107,4 +107,4 @@ foreach ($object_ids as $item) {
} // end else
?>
</table>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>

View file

@ -23,7 +23,7 @@
$web_path = AmpConfig::get('web_path');
$thcount = 5;
?>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">
<?php if (AmpConfig::get('directplay')) { ++$thcount; ?>
@ -60,4 +60,4 @@ $thcount = 5;
<th class="cel_action"><?php echo T_('Action'); ?> </th>
</tr>
</table>
<?php require AmpConfig::Get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::Get('prefix') . '/templates/list_header.inc.php'; ?>

View file

@ -24,7 +24,7 @@ $localplay = new Localplay(AmpConfig::get('localplay_controller'));
$localplay->connect();
$status = $localplay->status();
?>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">
<th class="cel_track"><?php echo T_('Track'); ?></th>
@ -58,4 +58,4 @@ $status = $localplay->status();
<th class="cel_action"><?php echo T_('Action'); ?></th>
</tr>
</table>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>

View file

@ -22,7 +22,7 @@
$web_path = AmpConfig::get('web_path');
?>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<form method="post" id="reorder_playlist_<?php echo $playlist->id; ?>">
<table id="reorder_playlist_table" class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">
@ -84,4 +84,4 @@ $web_path = AmpConfig::get('web_path');
</tr>
</table>
</form>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>

View file

@ -20,7 +20,7 @@
*
*/
?>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php' ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php' ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">
<?php if (AmpConfig::get('directplay')) { ?>
@ -60,4 +60,4 @@
<th class="cel_action"><?php echo T_('Actions'); ?></th>
</tr>
</table>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php' ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php' ?>

View file

@ -23,7 +23,7 @@
$tags_list = Tag::get_display(Tag::get_tags());
$thcount = 5;
?>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php' ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php' ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">
<?php if (AmpConfig::get('directplay')) { ++$thcount; ?>
@ -60,4 +60,4 @@ $thcount = 5;
<th class="cel_action"><?php echo T_('Actions'); ?></th>
</tr>
</table>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php' ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php' ?>

View file

@ -24,7 +24,7 @@ $web_path = AmpConfig::get('web_path');
$tags_list = Tag::get_display(Tag::get_tags());
$thcount = 8;
?>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<table id="reorder_songs_table" class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">
<?php if (AmpConfig::get('directplay')) { ++$thcount; ?>
@ -96,4 +96,4 @@ $thcount = 8;
<?php } ?>
</tr>
</table>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>

View file

@ -23,7 +23,7 @@
$web_path = AmpConfig::get('web_path');
?>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<colgroup>
<col id="col_username" />
@ -70,3 +70,4 @@ foreach ($object_ids as $user_id) {
<th class="cel_online"><?php echo T_('On-line'); ?></th>
</tr>
</table>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>

View file

@ -21,7 +21,7 @@
*/
$web_path = AmpConfig::get('web_path');
require AmpConfig::get('prefix') . '/templates/list_header.inc.php';
if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php';
$thcount = 7;
?>
<table class="tabledata" cellpadding="0" cellspacing="0">
@ -65,4 +65,4 @@ $thcount = 7;
<th class="cel_action"><?php echo T_('Action'); ?></th>
</tr>
</table>
<?php require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>

View file

@ -1602,3 +1602,27 @@ ol, ul, #rightbar ul {
color: #ffffff;
background-color: #222;
}
.browse-options {
float: right;
}
.jscroll-next {
width:50%;
display:block;
border:1px solid #ccc;
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius: 10px;
background-color:#eee;
color:#999;
font-weight:bold;
text-align:center;
padding:10px 0;
cursor:pointer;
margin: auto;
}
.jscroll-next:hover {
color:#666;
}