Shindigのgadgets.tabsでは、選択したタブをUserPrefsに自動保存する、
という機能が効かないみたい。
(コードにそのような記述はない。)
Google gadgets APIでは、
- <?xml version="1.0" encoding="UTF-8" ?>
- <Module>
- <ModulePrefs title="tabsフィーチャー">
- <Require feature="setprefs" />
- <Require feature="tabs" />
- </ModulePrefs>
- <UserPref name="selectedTab" value="0" />
- <Content type="html" view="home,profile,canvas">
などと書いておくと、再表示したときに、前回表示したときに選択したタブが選択される
らしい。
これをShindigでもやってみた。
- --- tabs.js.old 2009-07-30 23:48:32.000000000 +0900
- +++ tabs.js 2009-07-31 09:28:01.000000000 +0900
- @@ -171,6 +171,9 @@
- 'text-decoration: none;',
- '}'
- ].join(''));
- + if (gadgets.util.hasFeature('setprefs')) {
- + this.prefs = new gadgets.Prefs();
- + }
- };
- /**
- @@ -230,6 +233,12 @@
- if (tabName == this.defaultTabName_ || (!this.defaultTabName_ && tabIndex === 0)) {
- this.selectTab_(tab);
- }
- + if (this.prefs) {
- + var selectedTab = this.prefs.getString("selectedTab");
- + if (selectedTab === tabName) {
- + this.selectTab_(tab);
- + }
- + }
- this.tabsAdded_++;
- this.displayTabs(true);
- @@ -602,7 +611,13 @@
- * @return {Function} Callback function to select the tab.
- */
- gadgets.TabSet.prototype.setSelectedTabGenerator_ = function(tab) {
- - return function() { tab.handle_.selectTab_(tab); };
- + var self = this;
- + return function() {
- + if (self.prefs) {
- + self.prefs.set("selectedTab", tab.getName());
- + }
- + tab.handle_.selectTab_(tab);
- + };
- };
- /**
と、features/tabs/tabs.jsを修正する。
すると、あら不思議。
前回選択したタブが選択された状態で表示できるじゃありませんか。
そんだけ。
.
0 コメント:
コメントを投稿