1
0

The navigation buttons are now working on the test client (first, prev, next, last and up).

This commit is contained in:
Tim Almdal 2009-12-16 20:11:15 -08:00
parent fc71b2341a
commit 575bcbd22e
5 changed files with 121 additions and 38 deletions

View File

@ -5,22 +5,22 @@
<div id="center">
<div class="wc-toolbar ui-widget-header ui-corner-all ui-helper-clearfix">
<div class="wc-buttonset ui-helper-clearfix">
<a href="#" class="wc-button ui-state-default ui-state-disabled wc-button-icon-solo ui-corner-all" title="First"><span class="ui-icon ui-icon-seek-first"></span>First</a>
<a href="#" class="wc-button ui-state-default ui-state-disabled wc-button-icon-solo ui-corner-all" title="Previous"><span class="ui-icon ui-icon-seek-prev"></span>Previous</a>
<a href="#" class="wc-button ui-state-default ui-state-disabled wc-button-icon-solo ui-corner-all" title="Next"><span class="ui-icon ui-icon-seek-next"></span>Next</a>
<a href="#" class="wc-button ui-state-default ui-state-disabled wc-button-icon-solo ui-corner-all" title="Last"><span class="ui-icon ui-icon-seek-end"></span>Last</a>
<a href="#" ref="first" class="wc-button ui-state-default ui-state-disabled wc-button-icon-solo ui-corner-all" title="First"><span class="ui-icon ui-icon-seek-first"></span>First</a>
<a href="#" ref="previous" class="wc-button ui-state-default ui-state-disabled wc-button-icon-solo ui-corner-all" title="Previous"><span class="ui-icon ui-icon-seek-prev"></span>Previous</a>
<a href="#" ref="next" class="wc-button ui-state-default ui-state-disabled wc-button-icon-solo ui-corner-all" title="Next"><span class="ui-icon ui-icon-seek-next"></span>Next</a>
<a href="#" ref="last" class="wc-button ui-state-default ui-state-disabled wc-button-icon-solo ui-corner-all" title="Last"><span class="ui-icon ui-icon-seek-end"></span>Last</a>
</div>
<div class="wc-buttonset ui-helper-clearfix">
<a href="#" class="wc-button ui-state-default ui-state-disabled wc-button-icon-solo ui-corner-all" title="Parent"><span class="ui-icon ui-icon-eject"></span>Parent</a>
<a href="#" ref="parent" class="wc-button ui-state-default ui-state-disabled wc-button-icon-solo ui-corner-all" title="Parent"><span class="ui-icon ui-icon-eject"></span>Parent</a>
</div>
<div class="wc-buttonset ui-helper-clearfix">
<a href="#" class="wc-button ui-state-default ui-state-disabled wc-button-icon-solo ui-corner-all" title="Edit"><span class="ui-icon ui-icon-pencil"></span>Edit</a>
<a href="#" class="wc-button ui-state-default ui-state-disabled wc-button-icon-solo ui-corner-all" title="Delete"><span class="ui-icon ui-icon-trash"></span>Delete</a>
<a href="#" ref="edit" class="wc-button ui-state-default wc-button-icon-solo ui-corner-all" title="Edit"><span class="ui-icon ui-icon-pencil"></span>Edit</a>
<a href="#" ref="delete" class="wc-button ui-state-default ui-state-disabled wc-button-icon-solo ui-corner-all" title="Delete"><span class="ui-icon ui-icon-trash"></span>Delete</a>
</div>
<div class="wc-buttonset wc-buttonset-single ui-helper-clearfix">
<a href="#" class="wc-button ui-state-default wc-button-icon-solo ui-corner-all" title="Add Resource"><span class="ui-icon ui-icon-transferthick-e-w"></span>Add Resource</a>
<a href="#" ref="add" class="wc-button ui-state-default wc-button-icon-solo ui-corner-all" title="Add Resource"><span class="ui-icon ui-icon-transferthick-e-w"></span>Add Resource</a>
</div>
</div>
<div id="wc-detail">

View File

@ -1,5 +1,5 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="movie">
<div id="movie" ref="<?= $resource->path ?>">
<a id="movie-link" href="<?= $resource->url ?>" title="<?= $resource->title ?>"
style="display: block; height: <?= $resource->size->height ?>px; width: <?= $resource->size->width ?>px;" />
</div>

View File

@ -1,5 +1,5 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="photo">
<div id="photo" ref="<?= $resource->path ?>">
<img src="<?= $resource->resize_url ?>" title="<?= $resource->title ?>" />
</div>
<div id="photo-info">

View File

@ -103,29 +103,33 @@ span.error {
border: 2px inset;
bottom: 20px;
left: 225px;
overflow: auto;
padding: 10px;
position: absolute;
right: 20px;
top: 11px;
}
#wc-body #wc-detail {
bottom: 0;
left: 10px;
overflow-y: auto;
position: absolute;
right: 10px;
top: 60px;
}
.tree-title {
cursor: pointer;
}
#wc-body #center .thumb-grid-cell {
border: 1px solid transparent;
float: left;
height: 200px;
line-height: 220px;
margin: 10px;
text-align: center;
width: 200px;
}
#wc-body #center .thumb-grid-cell.ui-selected {
margin: 2px;
padding: 7px;
text-align: center;
width: 200px;
}
#wc-body #center .thumb-grid-cell img,
@ -145,8 +149,7 @@ span.error {
.ui-selected {
background: #F6F6F6 url(images/ui-bg_glass_100_f6f6f6_1x400png) repeat-x scroll 50% 50%;
border: 1px solid #CCCCCC;
//background-color: #E8E8E8;
border: 1px solid #CCCCCC !important;
color: #FF9933;
padding: 0 5px;
}

View File

@ -1,6 +1,5 @@
(function($) {
var _paths = [];
var _current_path = "";
$.fn.gallery3_client = function() {
return this.each(function(i) {
@ -23,7 +22,7 @@
$(obj).html(data.content);
if (data.status == "ok") {
initializeDetail(obj);
save_paths(".tree-title.ui-selected");
save_paths($(".tree-title.ui-selected").parents("li:first").attr("ref"));
} else {
ajaxifyLoginForm(obj);
}
@ -70,7 +69,7 @@
get_detail(path, function(path) {
var album = $("#album_tree [ref='" + path + "']");
if (album.length > 0) {
$(".ui-selected").removeClass("ui-selected");
$(".tree-title.ui-selected").removeClass("ui-selected");
$(".tree-title", album).addClass("ui-selected");
}
});
@ -80,6 +79,7 @@
$("#center a.child-link").live("click", function(event) {
$(".thumb-grid-cell.ui-selected").removeClass("ui-selected");
$(this).parents("li:first").addClass("ui-selected");
_set_navigation_buttons($(".thumb-grid-cell.ui-selected").attr("ref"));
return false;
});
@ -87,8 +87,41 @@
if ($(this).parent("a").hasClass("ui-state-disabled")) {
return false;
}
if ($("span", this).hasClass("ui-icon-eject")) {
var selected = $(".thumb-grid-cell.ui-selected");
switch ($(this).attr("ref")) {
case "parent":
get_detail($("span", this).attr("ref"));
break;
case "first":
case "previous":
case "next":
case "last":
if (selected.length == 0) {
get_detail($("span", this).attr("ref"));
} else {
selected.removeClass("ui-selected");
switch ($(this).attr("ref")) {
case "first":
$(".thumb-grid-cell:first").addClass("ui-selected");
break;
case "previous":
selected.prev().addClass("ui-selected");
break;
case "next":
selected.next().addClass("ui-selected");
break;
case "last":
$(".thumb-grid-cell:last").addClass("ui-selected");
_set_navigation_buttons();
break;
}
_set_navigation_buttons();
}
break;
default:
console.group("process toolbar button click: " + $(this).attr("ref"));
console.log(($("span", this).attr("ref")));
console.groupEnd();
}
return false;
});
@ -96,9 +129,9 @@
$(".tree-title", obj).live("click", function (event) {
get_detail($(this).parents("li:first").attr("ref"));
$(".ui-selected").removeClass("ui-selected");
$(this).addClass("ui-selected");
return false;
});
$(this).addClass("ui-selected");
return false;
});
$("#album_tree [ref=''] .tree-title:first").addClass("ui-selected");
set_selected_thumb();
@ -116,10 +149,9 @@
$("#wc-detail").html(data);
set_selected_thumb();
save_paths(path);
if (callback != undefined) {
if (callback) {
callback(path);
}
_current_path = path;
console.groupEnd();
});
}
@ -127,9 +159,7 @@
function save_paths(path) {
_paths[path] = [];
$(".thumb-grid-cell").each(function(i) {
var item_path = $(this).attr("ref");
var idx = item_path.lastIndexOf("/");
_paths[path][i] = idx != -1 ? item_path.substr(idx + 1) : item_path;
_paths[path][i] = $(this).attr("ref");
});
console.dir(_paths);
@ -137,17 +167,67 @@
}
function enable_toolbar_buttons(path) {
var idx = path.lastIndexOf("/");
var parent_path = "";
if (idx != -1) {
parent_path = path.substring (0, idx);
}
console.log("path: " + path + "; parent_path: " + parent_path);
if (path != "") {
$(".wc-toolbar .ui-icon-eject").parent("a").removeClass("ui-state-disabled");
$(".wc-toolbar .ui-icon-trash").parent("a").removeClass("ui-state-disabled");
} else {
$(".wc-toolbar .ui-icon-eject").parent("a").addClass("ui-state-disabled");
$(".wc-toolbar .ui-icon-trash").parent("a").addClass("ui-state-disabled");
}
$(".wc-toolbar .ui-icon-eject").attr("ref", parent_path);
$(".wc-toolbar .ui-icon-eject").attr("ref", _get_parent_path(path));
$(".wc-toolbar .ui-icon-pencil").attr("ref", path);
_set_navigation_buttons();
}
function _get_parent_path(path) {
var idx = path.lastIndexOf("/");
return idx != -1 ? path.substring(0, idx) : "";
}
function _set_navigation_buttons() {
var selected_path = $(".thumb-grid-cell.ui-selected").attr("ref");
if (selected_path == undefined) { // not found must be photo or movie
selected_path = $("#wc-detail div:first").attr("ref");
}
var parent_path = _get_parent_path(selected_path);
console.log("path: " + selected_path + "; parent_path: " + parent_path);
var paths = _paths[parent_path];
console.group("parent path");
console.dir(paths);
console.groupEnd();
if (paths.length > 0) {
$(".wc-toolbar .ui-icon-seek-first").parent("a").removeClass("ui-state-disabled");
$(".wc-toolbar .ui-icon-seek-end").parent("a").removeClass("ui-state-disabled");
$(".wc-toolbar .ui-icon-seek-first").attr("ref", paths[0]);
$(".wc-toolbar .ui-icon-seek-end").attr("ref", paths[paths.length - 1]);
} else {
$(".wc-toolbar .ui-icon-seek-first").parent("a").addClass("ui-state-disabled");
$(".wc-toolbar .ui-icon-seek-end").parent("a").addClass("ui-state-disabled");
}
var i = 0;
for (; i < paths.length; i++) {
if (paths[i] == selected_path) {
break;
}
}
if (i > 0) {
$(".wc-toolbar .ui-icon-seek-prev").parent("a").removeClass("ui-state-disabled");
$(".wc-toolbar .ui-icon-seek-prev").attr("ref", paths[i - 1]);
} else {
$(".wc-toolbar .ui-icon-seek-first").parent("a").addClass("ui-state-disabled");
$(".wc-toolbar .ui-icon-seek-prev").parent("a").addClass("ui-state-disabled");
}
if (i < paths.length - 1) {
$(".wc-toolbar .ui-icon-seek-next").parent("a").removeClass("ui-state-disabled");
$(".wc-toolbar .ui-icon-seek-next").attr("ref", paths[i + 1]);
} else {
$(".wc-toolbar .ui-icon-seek-next").parent("a").addClass("ui-state-disabled");
$(".wc-toolbar .ui-icon-seek-end").parent("a").addClass("ui-state-disabled");
}
console.log("found path: " + paths[i]);
}
})(jQuery);