Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_branch

Conflicts:
	themes/default/js/ui.init.js
This commit is contained in:
Bharat Mediratta
2009-08-07 12:37:25 -07:00
15 changed files with 311 additions and 296 deletions

View File

@@ -21,7 +21,8 @@
define("IN_PRODUCTION", true);
// Gallery requires PHP 5.2+
version_compare(PHP_VERSION, "5.2.3", "<") and exit("Gallery requires PHP 5.2.3 or newer.");
version_compare(PHP_VERSION, "5.2.3", "<") and
exit("Gallery requires PHP 5.2.3 or newer (you're using " . PHP_VERSION . ")");
// Gallery requires short_tags to be on
!ini_get("short_open_tag") and exit("Gallery requires short_open_tag to be on.");

View File

@@ -1,19 +1,13 @@
/**
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
(function () {
$.fn.showMessage = function(message) {
(function ($) {
$.fn.gallery_show_message = function(message) {
return this.each(function(i){
$(this).effect("highlight", {"color": "white"}, 3000);
$(this).animate({opacity: 1.0}, 6000);
});
};
})(jQuery);
// Vertically align a block element's content
(function () {
$.fn.vAlign = function(container) {
// Vertically align a block element's content
$.fn.gallery_valign = function(container) {
return this.each(function(i){
if (container == null) {
container = 'div';
@@ -26,11 +20,9 @@
$(el).css('margin-top', nh);
});
};
})(jQuery);
// Get the viewport size
(function () {
$.getViewportSize = function() {
// Get the viewport size
$.gallery_get_viewport_size = function() {
return {
width : function() {
return $(window).width();
@@ -40,4 +32,24 @@
}
};
};
/**
* Toggle the processing indicator, both large and small
* @param elementID Target ID, including #, to apply .gLoadingSize
*/
$.fn.gallery_show_loading = function() {
return this.each(function(i){
var size;
switch ($(this).attr("id")) {
case "#gDialog":
case "#gPanel":
size = "Large";
break;
default:
size = "Small";
break;
}
$(this).toggleClass("gLoading" + size);
});
};
})(jQuery);

View File

@@ -1,140 +1,136 @@
/**
* Fire openDialog() and prevent links from opening
* @see openDialog()
*/
function handleDialogEvent(event) {
var target = event.currentTarget;
if (!target) {
target = event.srcElement;
}
openDialog(target);
event.preventDefault();
}
(function($) {
$.widget("ui.gallery_dialog", {
_init: function() {
var self = this;
this.element.click(function(event){
event.preventDefault();
var element = event.currentTarget;
var sHref = $(element).attr("href");
var sTitle = $(element).attr("title");
var eDialog = '<div id="gDialog"></div>';
function ajaxify_dialog() {
$("#gDialog form").ajaxForm({
dataType: "json",
success: function(data) {
if (data.form) {
$("#gDialog form").replaceWith(data.form);
ajaxify_dialog();
on_form_loaded();
if (typeof data.reset == 'function') {
eval(data.reset + '()');
$("body").append(eDialog);
if (!self.options.close) {
self.options.close = self.close_dialog;
}
$("#gDialog").dialog(self.options);
$("#gDialog").gallery_show_loading();
$.get(sHref, function(data) {
$("#gDialog").html(data).gallery_show_loading();
if ($("#gDialog form").length) {
self._trigger("form_loaded", null, $("#gDialog form"));
}
self._layout();
$("#gDialog").dialog("open");
// Remove titlebar for progress dialogs or set title
if ($("#gDialog #gProgress").length) {
$(".ui-dialog-titlebar").remove();
} else if ($("#gDialog h1").length) {
$("#gDialog").dialog('option', 'title', $("#gDialog h1:eq(0)").html());
} else if ($("#gDialog fieldset legend").length) {
$("#gDialog").dialog('option', 'title', $("#gDialog fieldset legend:eq(0)").html());
}
if ($("#gDialog form").length) {
self._ajaxify_dialog();
}
});
$("#gDialog").dialog("option", "self", self);
return false;
});
},
destroy: function() {
if ($("#gDialog form").length) {
this._trigger("form_closing", null, $("#gDialog form"));
}
this._trigger("dialog_closing", null, $("#gDialog"));
$("#gDialog").dialog("destroy").remove();
},
_layout: function() {
var dialogWidth;
var dialogHeight = $("#gDialog").height();
var cssWidth = new String($("#gDialog form").css("width"));
var childWidth = cssWidth.replace(/[^0-9]/g,"");
if ($("#gDialog iframe").length) {
dialogWidth = $(window).width() - 100;
// Set the iframe width and height
$("#gDialog iframe").width("100%").height($(window).height() - 100);
} else if (childWidth == "" || childWidth > 300) {
dialogWidth = 500;
}
$("#gDialog").dialog('option', 'width', dialogWidth);
},
form_loaded: function event(event, ui) {
// Should be defined (and localized) in the theme
MSG_CANCEL = MSG_CANCEL || 'Cancel';
var eCancel = '<a href="#" class="gCancel">' + MSG_CANCEL + '</a>';
if ($("#gDialog .submit").length) {
$("#gDialog .submit").addClass("ui-state-default ui-corner-all");
$("#gDialog .submit").parent().append(eCancel);
$("#gDialog .gCancel").click(function(event) {
$("gDialog").dialog("close");
event.preventDefault();
});
}
}
if (data.result == "success") {
if (data.location) {
window.location = data.location;
} else {
window.location.reload();
}
}
}
});
};
$("#gDialog .ui-state-default").hover(
function() {
$(this).addClass("ui-state-hover");
},
function() {
$(this).removeClass("ui-state-hover");
}
);
},
/**
* Display modal dialogs, populate dialog with trigger link's href
* @requires ui.core
* @requires ui.draggable
* @requires ui.resizable
* @requires ui.dialog
* @see handleDialogEvent()
* @see showLoading()
*/
function openDialog(element) {
var sHref = $(element).attr("href");
var sTitle = $(element).attr("title");
var eDialog = '<div id="gDialog"></div>';
var dialogWidth;
close_dialog: function (event, ui) {
var self = $("#gDialog").dialog("option", "self");
self.destroy();
},
$("body").append(eDialog);
_ajaxify_dialog: function() {
var self = this;
$("#gDialog form").ajaxForm({
dataType: "json",
success: function(data) {
if (data.form) {
$("#gDialog form").replaceWith(data.form);
self._ajaxify_dialog();
self._trigger("form_loaded", null, $("#gDialog form"));
if (typeof data.reset == 'function') {
eval(data.reset + '()');
}
}
if (data.result == "success") {
if (data.location) {
window.location = data.location;
} else {
window.location.reload();
}
}
}
});
},
$("#gDialog").dialog({
autoOpen: false,
autoResize: true,
modal: true,
resizable: false,
close: closeDialog
});
form_closing: function(event, ui) {},
dialog_closing: function(event, ui) {}
});
showLoading("#gDialog");
$.get(sHref, function(data) {
showLoading("#gDialog");
$("#gDialog").html(data);
var dialogHeight = $("#gDialog").height();
var cssWidth = new String($("#gDialog form").css("width"));
var childWidth = cssWidth.replace(/[^0-9]/g,"");
if ($("#gDialog iframe").length) {
dialogWidth = $(window).width() - 100;
// Set the iframe width and height
$("#gDialog iframe").width("100%");
$("#gDialog iframe").height($(window).height() - 100);
} else if (childWidth == "" || childWidth > 300) {
dialogWidth = 500;
}
$("#gDialog").dialog('option', 'width', dialogWidth);
on_form_loaded();
$("#gDialog").dialog("open");
// Remove titlebar for progress dialogs or set title
if ($("#gDialog #gProgress").length) {
$(".ui-dialog-titlebar").remove();
} else if ($("#gDialog h1").length) {
$("#gDialog").dialog('option', 'title', $("#gDialog h1:eq(0)").html());
} else if ($("#gDialog fieldset legend").length) {
$("#gDialog").dialog('option', 'title', $("#gDialog fieldset legend:eq(0)").html());
}
ajaxify_dialog();
});
return false;
}
function on_form_loaded() {
// Should be defined (and localized) in the theme
MSG_CANCEL = MSG_CANCEL || 'Cancel';
var eCancel = '<a href="javascript: closeDialog()" class="gCancel">' + MSG_CANCEL + '</a>';
if ($("#gDialog .submit").length) {
$("#gDialog .submit").addClass("ui-state-default ui-corner-all");
$("#gDialog .submit").parent().append(eCancel);
}
$("#gDialog").dialog("option", "form", $("#gDialog form"));
$("#gDialog .ui-state-default").hover(
function() {
$(this).addClass("ui-state-hover");
},
function() {
$(this).removeClass("ui-state-hover");
}
);
}
function closeDialog() {
var form = $("#gDialog").dialog("option", "form");
if (form != null) {
$("#gDialog").dialog("option", "form").trigger("form_closing");
}
$("#gDialog").dialog("destroy").remove();
}
/**
* Toggle the processing indicator, both large and small
* @param elementID Target ID, including #, to apply .gLoadingSize
*/
function showLoading(elementID) {
var size;
switch (elementID) {
case "#gDialog":
case "#gPanel":
size = "Large";
break;
default:
size = "Small";
break;
}
$(elementID).toggleClass("gLoading" + size);
}
$.extend($.ui.gallery_dialog, {
defaults: {
autoOpen: false,
autoResize: true,
modal: true,
resizable: false,
position: "center"
}
});
})(jQuery);

View File

@@ -1,62 +1,58 @@
/**
* Fire togglePanel() and prevent links from opening
* @see togglePanel()
*/
function handlePanelEvent(event) {
togglePanel(event.currentTarget);
event.preventDefault();
}
(function($) {
$.widget("ui.gallery_panel", {
_init: function() {
var self = this;
this.element.click(function(event) {
event.preventDefault();
var element = event.currentTarget;
var parent = $(element).parent().parent();
var sHref = $(element).attr("href");
var parentClass = $(parent).attr("class");
var ePanel = "<tr id=\"gPanel\"><td colspan=\"6\"></td></tr>";
function togglePanel(element, on_success) {
var parent = $(element).parent().parent();
var sHref = $(element).attr("href");
var parentClass = $(parent).attr("class");
var ePanel = "<tr id=\"gPanel\"><td colspan=\"6\"></td></tr>";
if ($("#gPanel").length) {
$("#gPanel").slideUp("slow").remove();
if ($(element).attr("orig_text")) {
$(element).children(".gButtonText").text($(element).attr("orig_text"));
}
} else {
$(parent).after(ePanel);
$("#gPanel td").html(sHref);
$.get(sHref, function(data) {
$("#gPanel td").html(data);
self._ajaxify_panel();
if ($(element).attr("open_text")) {
$(element).attr("orig_text", $(element).children(".gButtonText").text());
$(element).children(".gButtonText").text($(element).attr("open_text"));
}
$("#gPanel").addClass(parentClass).show().slideDown("slow");
});
}
return false;
});
},
if ($("#gPanel").length) {
$("#gPanel").slideUp("slow");
$("#gPanel *").remove();
$("#gPanel").remove();
if ($(element).attr("orig_text")) {
$(element).children(".gButtonText").text($(element).attr("orig_text"));
}
//togglePanel(element, on_success);
} else {
$(parent).after(ePanel);
//showLoading("#here");
$("#gPanel td").html(sHref);
$("#gPanel").addClass(parentClass).show().slideDown("slow");
$.get(sHref, function(data) {
$("#gPanel td").html(data);
ajaxify_panel = function() {
$("#gPanel td form").ajaxForm({
dataType: "json",
success: function(data) {
if (data.form) {
$("#gPanel td form").replaceWith(data.form);
ajaxify_panel();
}
if (data.result == "success") {
if (on_success) {
on_success();
} else if (data.location) {
window.location = data.location;
} else {
window.location.reload();
}
}
}
});
if ($("#gPanel td").hasClass("gLoadingLarge")) {
showLoading("#gPanel td");
}
};
ajaxify_panel();
if ($(element).attr("open_text")) {
$(element).attr("orig_text", $(element).children(".gButtonText").text());
$(element).children(".gButtonText").text($(element).attr("open_text"));
}
});
}
return false;
}
_ajaxify_panel: function () {
var self = this;
$("#gPanel td form").ajaxForm({
dataType: "json",
success: function(data) {
if (data.form) {
$("#gPanel td form").replaceWith(data.form);
self._ajaxify_panel();
}
if (data.result == "success") {
self._trigger("success", null, {});
if (data.location) {
window.location = data.location;
} else {
window.location.reload();
}
}
}
});
},
success: function(event, ui) {}
});
})(jQuery);

View File

@@ -1,76 +1,78 @@
/**
* @todo Move inline CSS out to external style sheet (theme style sheet)
*/
var show_full_size = function(image_url, image_width, image_height) {
/*
* Calculate the size of the image panel based on the size of the image and the size of the
* window. Scale the image so the entire panel fits in the view port.
*/
function _auto_fit(imageWidth, imageHeight) {
// ui-dialog gives a padding of 2 pixels
var windowWidth = $(window).width() - 10;
var windowHeight = $(window).height() - 10;
(function($) {
/**
* @todo Move inline CSS out to external style sheet (theme style sheet)
*/
$.gallery_show_full_size = function(image_url, image_width, image_height) {
/*
* Calculate the size of the image panel based on the size of the image and the size of the
* window. Scale the image so the entire panel fits in the view port.
*/
function _auto_fit(imageWidth, imageHeight) {
// ui-dialog gives a padding of 2 pixels
var windowWidth = $(window).width() - 10;
var windowHeight = $(window).height() - 10;
/* If the width is greater then scale the image width first */
if (imageWidth > windowWidth) {
var ratio = windowWidth / imageWidth;
imageWidth *= ratio;
imageHeight *= ratio;
}
/* after scaling the width, check that the height fits */
if (imageHeight > windowHeight) {
var ratio = windowHeight / imageHeight;
imageWidth *= ratio;
imageHeight *= ratio;
}
/* If the width is greater then scale the image width first */
if (imageWidth > windowWidth) {
var ratio = windowWidth / imageWidth;
imageWidth *= ratio;
imageHeight *= ratio;
}
/* after scaling the width, check that the height fits */
if (imageHeight > windowHeight) {
var ratio = windowHeight / imageHeight;
imageWidth *= ratio;
imageHeight *= ratio;
}
// handle the case where the calculation is almost zero (2.14e-14)
return {
top: Number((windowHeight - imageHeight) / 2),
left: Number((windowWidth - imageWidth) / 2),
width: Number(imageWidth),
height: Number(imageHeight)
};
}
// handle the case where the calculation is almost zero (2.14e-14)
return {
top: Number((windowHeight - imageHeight) / 2),
left: Number((windowWidth - imageWidth) / 2),
width: Number(imageWidth),
height: Number(imageHeight)
};
}
var width = $(document).width();
var height = $(document).height();
var width = $(document).width();
var height = $(document).height();
$("body").append('<div id="gFullsizeOverlay" class="ui-dialog-overlay" ' +
'style="border: none; margin: 0; padding: 0; background-color: #000; ' +
'position: absolute; top: 0px; left: 0px; ' +
'width: ' + width + 'px; height: ' + height + 'px; opacity: 0.7; filter: alpha(opacity=70);' +
'-moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; ' +
'-moz-background-inline-policy: -moz-initial; z-index: 1001;"> </div>');
$("body").append('<div id="gFullsizeOverlay" class="ui-dialog-overlay" ' +
'style="border: none; margin: 0; padding: 0; background-color: #000; ' +
'position: absolute; top: 0px; left: 0px; ' +
'width: ' + width + 'px; height: ' + height + 'px; opacity: 0.7; filter: alpha(opacity=70);' +
'-moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; ' +
'-moz-background-inline-policy: -moz-initial; z-index: 1001;"> </div>');
var image_size = _auto_fit(image_width, image_height);
var image_size = _auto_fit(image_width, image_height);
$("body").append('<div id="gFullsize" class="ui-dialog ui-widget" ' +
'style="overflow: hidden; display: block; ' +
'position: absolute; z-index: 1002; outline-color: -moz-use-text-color; ' +
'outline-style: none; outline-width: 0px; ' +
'height: ' + image_size.height + 'px; ' +
'width: ' + image_size.width + 'px; ' +
'top: ' + image_size.top + 'px; left: ' + image_size.left + 'px;">' +
'<img id="gFullSizeImage" src="' + image_url + '"' +
'height="' + image_size.height + '" width="' + image_size.width + '"/></div>');
$("body").append('<div id="gFullsize" class="ui-dialog ui-widget" ' +
'style="overflow: hidden; display: block; ' +
'position: absolute; z-index: 1002; outline-color: -moz-use-text-color; ' +
'outline-style: none; outline-width: 0px; ' +
'height: ' + image_size.height + 'px; ' +
'width: ' + image_size.width + 'px; ' +
'top: ' + image_size.top + 'px; left: ' + image_size.left + 'px;">' +
'<img id="gFullSizeImage" src="' + image_url + '"' +
'height="' + image_size.height + '" width="' + image_size.width + '"/></div>');
$("#gFullsize").append('<span id="gFullsizeClose" class="fg-button ui-icon ui-state-default ' +
'ui-icon-closethick ui-corner-all" style="z-index: 1003; position: absolute; ' +
'right: 1em; top: 1em;"></span>');
$("#gFullsizeClose").click(function() {
$("#gFullsizeOverlay*").remove();
$("#gFullsize").remove();
});
$(window).resize(function() {
$("#gFullsizeOverlay").width($(document).width());
$("#gFullsizeOverlay").height($(document).height());
image_size = _auto_fit(image_width, image_height);
$("#gFullsize").height(image_size.height);
$("#gFullsize").width(image_size.width);
$("#gFullsize").css("top", image_size.top);
$("#gFullsize").css("left", image_size.left);
$("#gFullSizeImage").height(image_size.height);
$("#gFullSizeImage").width(image_size.width);
});
};
$("#gFullsize").append('<span id="gFullsizeClose" class="fg-button ui-icon ui-state-default ' +
'ui-icon-closethick ui-corner-all" style="z-index: 1003; position: absolute; ' +
'right: 1em; top: 1em;"></span>');
$("#gFullsizeClose").click(function() {
$("#gFullsizeOverlay*").remove();
$("#gFullsize").remove();
});
$(window).resize(function() {
$("#gFullsizeOverlay").width($(document).width())
.height($(document).height());
image_size = _auto_fit(image_width, image_height);
$("#gFullsize").height(image_size.height)
.width(image_size.width)
.css("top", image_size.top)
.css("left", image_size.left);
$("#gFullSizeImage").height(image_size.height)
.width(image_size.width);
});
};
})(jQuery);

View File

@@ -16,7 +16,7 @@
title="<?= t("Edit Your Profile") ?>"
id="gAfterInstallChangePasswordLink" class="gButtonLink ui-state-default ui-corners-all"><?= t("Change Password Now") ?></a>
<script>
$("#gAfterInstallChangePasswordLink").bind("click", handleDialogEvent);
$("#gAfterInstallChangePasswordLink").gallery_dialog();
</script>
</p>

View File

@@ -391,7 +391,7 @@ function organize_dialog_init() {
$(".gBranchText").droppable(treeDroppable);
$(".gBranchText").click(organizeOpenFolder);
retrieveMicroThumbs(item_id);
//showLoading("#gDialog");
//$.gallery_show_loading("#gDialog");
$("#gMicroThumbPanel").droppable(thumbDroppable);
$("#gMicroThumbPanel").selectable(selectable);

View File

@@ -17,7 +17,7 @@ $("document").ready(function() {
zIndex: 75
});
//showLoading("#gDialog");
//$.gallery_show_loading("#gDialog");
$.get(href, function(data) {
$("#gDialog").html(data);

View File

@@ -34,7 +34,7 @@
<?= t("Add") ?>
</button>
<button class="ui-state-default ui-corner-all" onclick="closeDialog(); window.location.reload();">
<button id="gServerCloseButton" class="ui-state-default ui-corner-all">
<?= t("Close") ?>
</button>
</span>
@@ -48,6 +48,9 @@
progressbar("value", 0);
$("#gProgress").slideDown("fast", function() { start_add() });
});
$("#gServerCloseButton").click(function(event) {
$("#gDialog").dialog("close");
});
});
</script>

View File

@@ -23,7 +23,7 @@ function closeEditInPlaceForms() {
$("#gRenameTagForm").parent().html($("#gRenameTagForm").parent().data("revert"));
li.height("");
$(".gEditable", li).bind("click", editInPlace);
$(".gDialogLink", li).bind("click", handleDialogEvent);
$(".gDialogLink", li).gallery_dialog();
}
}

View File

@@ -19,8 +19,10 @@
*/
class user_theme_Core {
static function header_top($theme) {
$view = new View("login.html");
$view->user = user::active();
return $view->render();
if ($theme->page_type != "login") {
$view = new View("login.html");
$view->user = user::active();
return $view->render();
}
}
}

View File

@@ -28,7 +28,7 @@
{},
function(data) {
$("#group-" + group_id).html(data);
$("#group-" + group_id + " .gDialogLink").bind("click", handleDialogEvent);
$("#group-" + group_id + " .gDialogLink").gallery_dialog();
});
}

View File

@@ -1,5 +1,4 @@
$(document).ready(function(){
// Initialize Superfish menus
$("#gSiteAdminMenu ul.gMenu").addClass("sf-menu");
$("ul.gMenu").addClass("sf-menu");
@@ -15,17 +14,17 @@ $(document).ready(function(){
$("#gSiteAdminMenu").css("display", "block");
// Initialize status message effects
$("#gMessage li").showMessage();
$("#gMessage li").gallery_show_message();
// Initialize modal dialogs
$(".gDialogLink").bind("click", handleDialogEvent);
$(".gDialogLink").gallery_dialog();
// Initialize panels
$(".gPanelLink").bind("click", handlePanelEvent);
$(".gPanelLink").gallery_panel();
if ($("#gPhotoStream").length) {
// Vertically align thumbs in photostream
$(".gItem").vAlign();
$(".gItem").gallery_valign();
}
// Apply jQuery UI button css to submit inputs

View File

@@ -1,3 +1,4 @@
#
/**
* Initialize jQuery UI and Plugin elements
*
@@ -29,11 +30,11 @@ $(document).ready(function() {
$("#gSiteMenu").css("display", "block");
// Initialize status message effects
$("#gMessage li").showMessage();
$("#gMessage li").gallery_show_message();
// Initialize dialogs
$("#gLoginLink").addClass("gDialogLink");
$(".gDialogLink").bind("click", handleDialogEvent);
$(".gDialogLink").gallery_dialog();
// Initialize view menu
if ($("#gViewMenu").length) {
@@ -52,7 +53,10 @@ $(document).ready(function() {
// Album view only
if ($("#gAlbumGrid").length) {
// Vertical align thumbnails/metadata in album grid
$(".gItem").vAlign();
$(".gItem").gallery_valign();
$(".gQuick").ajaxStop(function(){
$(".gItem").gallery_valign();
});
}
// Photo/Item item view only

View File

@@ -5,7 +5,7 @@
<script>
$(document).ready(function() {
$(".gFullSizeLink").click(function() {
show_full_size("<?= $theme->item()->file_url() ?>", "<?= $theme->item()->width ?>", "<?= $theme->item()->height ?>");
$.gallery_show_full_size("<?= $theme->item()->file_url() ?>", "<?= $theme->item()->width ?>", "<?= $theme->item()->height ?>");
return false;
});
});