],
create: function() {
this.inherited(arguments);
- /*
- this.index = localStorage.getItem('hack.index');
- if (!this.index)
+ try {
+ this.index = parseInt(localStorage.getItem('hack.index'));
+ if (!this.index)
+ this.index = 0;
+ } catch(e) {
+ enyo.log("Could not load last hack index");
this.index = 0;
- */
- this.index = 0;
+ }
this.lastScrollPos = 0;
this.$.hacksCarousel.setCenterView(this.getHack(this.index));
},
});
}
this.$.hacksListSelector.setItems(displayList);
+ this.$.hacksListSelector.setValue(this.index);
this.startHack();
window.addEventListener('resize', this.resizeHack.bind(this), false);
+ this.$.info.addRemoveClass('dark', this.hacksList[this.index].dark);
this.setNotice('Swipe for more...');
},
setNotice: function(notice) {
}
},
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();
windowDeactivated: function() {
this.stopHack();
},
- selectHack: function(inSender, inValue, inOldValue) {
+ selectHack: function(inSender, inValue) {
this.stopHack();
this.index = inValue;
this.lastScrollPos = 0;
//enyo.log('starting view ' + view);
if (view)
view.start();
- //localStorage.setItem('hack.index', this.index);
+ try {
+ localStorage.setItem('hack.index', this.index);
+ } catch(e) {
+ enyo.log("Could not set hack index");
+ }
},
stopHack: function(direction) {
var view = this.$.hacksCarousel.fetchView(direction || 'center');