UNPKG

@titanium/turbo

Version:

<p align="center"> <img src="https://cdn.secure-api.org/images/turbo-title_400.png" /><br> <a href="https://www.npmjs.com/package/@titanium/turbo"> <img src="https://img.shields.io/npm/v/@titanium/turbo.png" /> </a> </p>

31 lines (26 loc) 691 B
var moment = require('alloy/moment'); function doTransform(model) { var transform = model.toJSON(); transform.dateSince = moment(transform.dateCreated, 'YYYYMMDDHHmmss').fromNow(); switch (transform.mood) { case 'mad': transform.moodColor = '#a00'; break; case 'happy': transform.moodColor = '#0a0'; break; case 'neutral': default: transform.moodColor = '#88f'; break; } return transform; } function addEntry() { Alloy.createController('add').getView().open(); } Alloy.Collections.journal.comparator = function(entry1, entry2) { return entry1.get('dateCreated') > entry2.get('dateCreated') ? -1 : 1; }; Alloy.Collections.journal.fetch(); $.index.open();