[bugzilla-gnome-org-extensions] Allow programmatically switching pages
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bugzilla-gnome-org-extensions] Allow programmatically switching pages
- Date: Thu, 20 Nov 2014 22:22:18 +0000 (UTC)
commit 3379470cebb2ac05e8d918547dd0a9cd0d93cd27
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Sun Oct 4 17:01:52 2009 -0400
Allow programmatically switching pages
Set things up so showOverview() and showPatchFile() work when called
from code other than clicking on the navigation links and properly
update the navigation links.
js/splinter.js | 48 +++++++++++++++++++++++++++++++-----------------
1 files changed, 31 insertions(+), 17 deletions(-)
---
diff --git a/js/splinter.js b/js/splinter.js
index d4e3143..d34271b 100644
--- a/js/splinter.js
+++ b/js/splinter.js
@@ -14,6 +14,8 @@ var theReview;
var reviewers = {};
+var navigationLinks = {};
+
var updateHaveDraftTimeoutId;
var saveDraftTimeoutId;
var saveDraftNoticeTimeoutId;
@@ -611,21 +613,12 @@ function addPatchFile(file) {
}
}
-function showOverview() {
- $("#overview").show();
- $(".file").hide();
+function selectNavigationLink(identifier) {
+ $(".navigation-link").removeClass("navigation-link-selected");
+ $(navigationLinks[identifier]).addClass("navigation-link-selected");
}
-function showPatchFile(file) {
- $("#overview").hide();
- $(".file").hide();
- if (file.div)
- $(file.div).show();
- else
- addPatchFile(file);
-}
-
-function addNavigationLink(title, callback, selected) {
+function addNavigationLink(identifier, title, callback, selected) {
if ($("#navigation").children().size() > 0)
$("#navigation").append(" | ");
@@ -634,19 +627,40 @@ function addNavigationLink(title, callback, selected) {
.appendTo("#navigation")
.click(function() {
if (!$(this).hasClass("navigation-link-selected")) {
- $(".navigation-link").removeClass("navigation-link-selected");
- $(this).addClass("navigation-link-selected");
callback();
}
});
if (selected)
q.addClass("navigation-link-selected");
+
+ navigationLinks[identifier] = q.get(0);
+}
+
+function showOverview() {
+ selectNavigationLink('__OVERVIEW__');
+ $("#overview").show();
+ $(".file").hide();
+ updateMyPatchComments();
+}
+
+function addOverviewNavigationLink() {
+ addNavigationLink('__OVERVIEW__', "Overview", showOverview, true);
+}
+
+function showPatchFile(file) {
+ selectNavigationLink(file.filename);
+ $("#overview").hide();
+ $(".file").hide();
+ if (file.div)
+ $(file.div).show();
+ else
+ addPatchFile(file);
}
function addFileNavigationLink(file) {
var basename = file.filename.replace(/.*\//, "");
- addNavigationLink(basename, function() {
+ addNavigationLink(file.filename, basename, function() {
showPatchFile(file);
});
}
@@ -686,7 +700,7 @@ function start(xml) {
else
$("#patchIntro").hide();
- addNavigationLink("Overview", showOverview, true);
+ addOverviewNavigationLink();
for (i = 0; i < thePatch.files.length; i++)
addFileNavigationLink(thePatch.files[i]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]