X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=Main.js;h=35c3a6cd215cb55d5fbce617aafbc72d1206e3a2;hb=1c721a96d70dcffb50c33ee81c8df3d78ef0a28f;hp=9a0a2093ad4318168bd60dccb07f469e7a2b7ccc;hpb=98d8bc4d5f0bc0b315b54369a8f288d93e9b2c44;p=Hacks.git diff --git a/Main.js b/Main.js index 9a0a209..35c3a6c 100644 --- a/Main.js +++ b/Main.js @@ -12,6 +12,9 @@ enyo.kind({ {name: "hacksListSelector", kind: "ListSelector", popupAlign: "left", onChange: "selectHack", style: "width: 200px"}, {kind: "Spacer"}, {name: "notice", className: "notice"} + ]}, + {name: "noPrefsDialog", kind: "ModalDialog", caption: "No Preferences", components: [ + {kind: "Button", content: "Okay", onclick: "closeNoPrefsDialog"} ]} ]}, {name: "preferencesView", kind: "HackPreferences", onClose: "savePreferences"} @@ -68,23 +71,29 @@ enyo.kind({ }, openPreferences: function() { var view = this.$.hacksCarousel.fetchView('center'); - view.stop(); var meta = view.getPreferencesMetadata(); - if (meta) { + if (meta.length) { + view.stop(); var values = view.getPreferences(); this.$.preferencesView.load(this.hacksList[this.index].name, meta, values); this.selectView(this.$.preferencesView); } else { - alert("No prefs"); + this.$.noPrefsDialog.openAtCenter(); } }, savePreferences: function(inSender, prefs) { - enyo.log("Saving prefs: " + JSON.stringify(prefs)); - this.back(); var view = this.$.hacksCarousel.fetchView('center'); - view.setPreferences(prefs); - view.start(); + if (prefs == null) { + enyo.log("Clearing prefs"); + view.resetPreferences(prefs); + this.selectHack(this, this.index); + } else { + enyo.log("Saving prefs: " + JSON.stringify(prefs)); + view.setPreferences(prefs); + view.start(); + } + this.back(); }, windowActivated: function() { this.startHack(); @@ -92,7 +101,7 @@ enyo.kind({ windowDeactivated: function() { this.stopHack(); }, - selectHack: function(inSender, inValue, inOldValue) { + selectHack: function(inSender, inValue) { this.stopHack(); this.index = inValue; this.lastScrollPos = 0; @@ -172,5 +181,8 @@ enyo.kind({ stopScroll: function(inSender) { this.lastScrollPos = this.$.hacksCarousel.scrollLeft; this.startHack(); + }, + closeNoPrefsDialog: function() { + this.$.noPrefsDialog.close(); } });