1
0
mirror of https://github.com/nolanlawson/pinafore synced 2025-02-02 22:57:36 +01:00

27 lines
912 B
JavaScript
Raw Normal View History

2018-03-03 14:15:50 -08:00
export function timelineMixins (Store) {
2018-01-28 13:09:39 -08:00
Store.prototype.setForTimeline = function (instanceName, timelineName, obj) {
let valuesToSet = {}
for (let key of Object.keys(obj)) {
let rootKey = `timelineData_${key}`
let root = this.get(rootKey) || {}
let instanceData = root[instanceName] = root[instanceName] || {}
instanceData[timelineName] = obj[key]
valuesToSet[rootKey] = root
}
this.set(valuesToSet)
2018-01-28 13:09:39 -08:00
}
Store.prototype.getForTimeline = function (instanceName, timelineName, key) {
let rootKey = `timelineData_${key}`
let root = this.get(rootKey)
return root && root[instanceName] && root[instanceName][timelineName]
2018-01-28 13:09:39 -08:00
}
Store.prototype.setForCurrentTimeline = function (obj) {
let instanceName = this.get('currentInstance')
let timelineName = this.get('currentTimeline')
this.setForTimeline(instanceName, timelineName, obj)
}
2018-01-28 13:09:39 -08:00
}