From fd23166f43566058069497ea1a1030f5b0ea831b Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Thu, 14 Jan 2016 10:29:49 +0100 Subject: [PATCH] Phi: let plugins register additional properties --- Phi/lib/knockprops.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Phi/lib/knockprops.js b/Phi/lib/knockprops.js index 645d86b2e..4069d2a89 100644 --- a/Phi/lib/knockprops.js +++ b/Phi/lib/knockprops.js @@ -175,9 +175,23 @@ define(['knockout'], function(ko) { } } - self.makeObservablesForAllProperties = function(target) { - for( var p in self.aliases ) { + self.addAliases = function(arg) { + self.aliases = self.aliases || {}; + + for( var p in arg ) { if( self.aliases.hasOwnProperty(p) ) { + console.log(p + " is already a property alias. Skipping."); + continue; + } + self.aliases[p] = arg[p]; + } + } + + self.makeObservablesForAllProperties = function(target, aliases ) { + aliases = aliases || self.aliases; + + for( var p in aliases ) { + if( aliases.hasOwnProperty(p) ) { target[p] = ko.observable().extend({ fgprop : p });