Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/projects/WorkboardDropEffect.js
/** | /** | ||||
* @provides javelin-workboard-drop-effect | * @provides javelin-workboard-drop-effect | ||||
* @requires javelin-install | * @requires javelin-install | ||||
* javelin-dom | * javelin-dom | ||||
* @javelin | * @javelin | ||||
*/ | */ | ||||
JX.install('WorkboardDropEffect', { | JX.install('WorkboardDropEffect', { | ||||
properties: { | properties: { | ||||
icon: null, | icon: null, | ||||
color: null, | color: null, | ||||
content: null | content: null, | ||||
conditions: [] | |||||
}, | }, | ||||
statics: { | statics: { | ||||
newFromDictionary: function(map) { | newFromDictionary: function(map) { | ||||
return new JX.WorkboardDropEffect() | return new JX.WorkboardDropEffect() | ||||
.setIcon(map.icon) | .setIcon(map.icon) | ||||
.setColor(map.color) | .setColor(map.color) | ||||
.setContent(JX.$H(map.content)); | .setContent(JX.$H(map.content)) | ||||
.setConditions(map.conditions || []); | |||||
} | } | ||||
}, | }, | ||||
members: { | members: { | ||||
newNode: function() { | newNode: function() { | ||||
var icon = new JX.PHUIXIconView() | var icon = new JX.PHUIXIconView() | ||||
.setIcon(this.getIcon()) | .setIcon(this.getIcon()) | ||||
.setColor(this.getColor()) | .setColor(this.getColor()) | ||||
.getNode(); | .getNode(); | ||||
return JX.$N('li', {}, [icon, this.getContent()]); | return JX.$N('li', {}, [icon, this.getContent()]); | ||||
}, | |||||
isEffectVisibleForCard: function(card) { | |||||
var conditions = this.getConditions(); | |||||
var properties = card.getProperties(); | |||||
for (var ii = 0; ii < conditions.length; ii++) { | |||||
var condition = conditions[ii]; | |||||
var field = properties[condition.field]; | |||||
var value = condition.value; | |||||
var result = true; | |||||
switch (condition.operator) { | |||||
case '!=': | |||||
result = (field !== value); | |||||
break; | |||||
} | } | ||||
if (!result) { | |||||
return false; | |||||
} | |||||
} | |||||
return true; | |||||
} | |||||
} | } | ||||
}); | }); |