mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-06-04 08:59:39 -04:00
Added icon view.
This commit is contained in:
parent
3576db818b
commit
1c9cb5def4
55 changed files with 110 additions and 11 deletions
68
h5ai/main.js
68
h5ai/main.js
|
@ -3,6 +3,7 @@
|
|||
var columnClasses = [ "icon", "name", "date", "size" ];
|
||||
var defaultSortOrder = "C=N;O=A"
|
||||
var h5aiPath = "/h5ai"
|
||||
var views = [ "details", "icons" ];
|
||||
|
||||
|
||||
$( function() {
|
||||
|
@ -19,9 +20,11 @@
|
|||
initTableRows();
|
||||
addSortOrderIcons();
|
||||
addTopAndBottom();
|
||||
initViews();
|
||||
checkView();
|
||||
};
|
||||
|
||||
|
||||
|
||||
function convertToHtml5() {
|
||||
|
||||
$( "td" ).removeAttr( "align" ).removeAttr( "valign" );
|
||||
|
@ -39,12 +42,11 @@
|
|||
var part = parts[idx];
|
||||
if ( part !== "" ) {
|
||||
path += part + "/";
|
||||
$ul.append( $( "<li><a href='" + path + "'><img src='" + h5aiPath + "/icons/crumb.png' alt='>' />" + part + "</a></li>" ) );
|
||||
$ul.append( $( "<li class=\"crumb\"><a href='" + path + "'><img src='" + h5aiPath + "/icons/crumb.png' alt='>' />" + part + "</a></li>" ) );
|
||||
}
|
||||
}
|
||||
|
||||
$( "nav li a" ).closest( "li" )
|
||||
.addClass( "crumb" )
|
||||
.click( function () {
|
||||
document.location.href = $( this ).find( "a" ).attr( "href" );
|
||||
} );
|
||||
|
@ -129,4 +131,64 @@
|
|||
} );
|
||||
};
|
||||
|
||||
|
||||
function checkView() {
|
||||
|
||||
if ( getView() === "icons" ) {
|
||||
$( "#content table" ).hide();
|
||||
$( "#content #empty" ).hide();
|
||||
$( "#content #box" ).show();
|
||||
} else {
|
||||
$( "#content table" ).show();
|
||||
$( "#content #box" ).hide();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function getView() {
|
||||
|
||||
var view = localStorage.getItem( "h5ai.view" );
|
||||
if ( $.inArray( view, views ) ) {
|
||||
return view;
|
||||
};
|
||||
return views[0];
|
||||
};
|
||||
|
||||
|
||||
function setView( view ) {
|
||||
|
||||
localStorage.setItem( "h5ai.view", view );
|
||||
checkView();
|
||||
};
|
||||
|
||||
|
||||
function initViews() {
|
||||
|
||||
var $box = $( "<div id=\"box\"></div>" );
|
||||
$( "td.name a" ).closest( "tr" ).each( function () {
|
||||
var $tr = $( this );
|
||||
var icon = $tr.find( "td.icon img" ).attr( "src" ).replace( "icon", "image" );
|
||||
var name = $tr.find( "td.name a" ).text();
|
||||
$( "<div class=\"entry\"></div>" )
|
||||
.append( $( "<img src=\"" + icon + "\" />" ) )
|
||||
.append( $( "<div class=\"label\">" + name + "</div>" ) )
|
||||
.click( function () {
|
||||
document.location.href = $tr.find( "td.name a" ).attr( "href" );
|
||||
} ).
|
||||
appendTo( $box );
|
||||
} );
|
||||
$box.append( $( "<div class=\"clearfix\"></div>" ) );
|
||||
$( "#content table" ).after( $box );
|
||||
|
||||
|
||||
$( "#details" ).closest( "li" )
|
||||
.click( function () {
|
||||
setView( "details" );
|
||||
} );
|
||||
$( "#icons" ).closest( "li" )
|
||||
.click( function () {
|
||||
setView( "icons" );
|
||||
} );
|
||||
};
|
||||
|
||||
} )( jQuery );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue