NPellet/visualizer — pull request #179 by targos (2014-09-04 12:25:43+00:00)
Title: Data trigger

## What's new ?
Added a change listener on the main data object.
Every time a change happens on some data, it will be triggered (thanks to bubbling) and all variables related to this change (= variables whose jpath includes the jpath the modified object) will in return trigger the module's update.

### Example
#### Main data
```json
{
"arr": [
{
"val1": {
"prop": "valABC"
},
"val2": {
"prop": "val123"
}
},
{
"val1": {
"prop": "valDEF"
},
"val2": {
"prop": "val456"
}
},
{
"val1": {
"prop": "valGHI"
},
"val2": {
"prop": "val789"
}
}
]
}
```
#### Variables defined in view
- arr as arr

#### Modules
- fast table
- Input: arr
- Output:
- element.val2.prop as myVal
- element.val2 as myObj
- One column showing element.val1.prop
- single value
- Input: myVal
- object editor
- Input: myObj

#### Result of data.setChild (depending on jpath)
- [ 'arr', 0, 'val1', 'prop' ] :
- As before: the corresponding line in the table will be updated (listener added in the module, event bubbling).
- [ 'arr', 0, 'val2', 'prop'] :
- As before : line is updated (same reason)
- New : if the last hovered element is 0, the single value and object editor modules will be updated (could eventually be handled in the module itself)
- [ 'arr', 0, 'val2' ] :
- Line is updated (same)
- Object editor is updated (same)
- Single value is updated (Could not be handled in the module, event is not triggered from the input object but from its parent !)

## Main changes
- listeners of the change event now receive an object as first argument which contains :
- target : reference to the changed object
- jpath : jpath (array form) from the current object (this) the modified object (target)
- variable.js and variable.js have been merged (variable wasn't used anywhere else and there was a circular dependency if I let it alone)

##TODO
- Trigger change when setValue is used ? (currently, it is not possible to change a string and have the change event on this string without calling triggerChange manually)
- Add a way to setValue of a child (if I change myObj.x by calling myObj.setChild(['x'], 4), the property x will be replaced and triggerChange is called on myObj)