forked from aumcode/nfx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
776 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Array functions | ||
|
||
##### arrayClear(array) | ||
Delete all elements from `array`. | ||
|
||
##### arrayDelete(array, object element): bool | ||
Delete `element` from `array` and return true if `element` was found. | ||
|
||
##### arrayShallowCopy(source_array): object | ||
Return new array - copy of `source_array`. | ||
|
||
##### arrayWalkable(array) | ||
Provides walking (see WAVE.Walkable) capability for array. | ||
|
||
##### groupWalkable(array) | ||
Converts array with {k : {}, v: []} structure to Walkable group operation result (inverse method to Walkable.wGroupToArray). | ||
|
||
##### inArray(array, object element): bool | ||
Returns true when `array` contains `element`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# WAVE.EventManager | ||
Mixin that implements the event-handler mechanism and can be added to any class. | ||
|
||
##### eventInvocationSuspendCount: 0 | ||
Increase to disable event firing for all events, decrease to enable, events are enabled again when value is <=0. This property is useful for batch updates to suppress many event firings that are not needed. | ||
|
||
##### eventBind(evtName, func) | ||
Binds a function to the named event handler. | ||
|
||
##### eventUnbind(evtName, func) | ||
Un-Binds a function from the named event handler. | ||
|
||
##### eventClear(evtName) | ||
Clears all functions from the named event handler. | ||
|
||
##### eventInvoke(evtName) | ||
Invokes all functions bound to the named event handler. | ||
|
||
##### eventSinkBind(sink) | ||
Binds a sink instance (an object) that will receive all events dispatched by this manager. The `sink` must have a function called `eventNotify(evtName, sender, args)` that will be invoked. | ||
|
||
##### eventSinkUnbind(sink) | ||
Un-Binds an object that received all events from this manager. | ||
|
||
##### eventSinkClear() | ||
Clears all objects that cat as event sinks bound to this instance. | ||
|
||
##### eventSinks() | ||
Returns a list of sink object that receive event notifications from this manager. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# Field Class | ||
Record consists of fields and Field represents a FieldDef from server-side NFX.DataAccess.CRUD.Schema on the client side along with view model/controller. | ||
|
||
## Field() | ||
Constructor. Initializes a new instance using string field definition and value. | ||
```js | ||
new rec.Field(object fieldDef) | ||
``` | ||
### Examples | ||
```js | ||
var rec = new WAVE.RecordModel.Record("ID-123456", function(){ | ||
new this.Field({Name: "FirstName", Type: "string", Required: true}); | ||
new this.Field({Name: "LastName", Type: "string"}); | ||
new this.Field({Name: "Age", Type: "int"}); | ||
}); | ||
``` | ||
```js | ||
var rec = new WAVE.RecordModel.Record("ID-123456"); | ||
new rec.Field({Name: "FirstName", Type: "string"}); | ||
new rec.Field({Name: "LastName", Type: "string"}); | ||
new rec.Field({Name: "Age", Type: "int", Stored: false}); | ||
``` | ||
|
||
|
||
## drop() | ||
Deletes this field from the record. | ||
|
||
|
||
## deferValidation() | ||
Defer or NOT validation event while changing of field’s value. | ||
```js | ||
deferValidation(bool flag) | ||
``` | ||
### Examples | ||
```js | ||
var rec = ... | ||
var elog = ""; | ||
rec.fldLastName.deferValidation(true); | ||
rec.fldLastName.eventBind(WAVE.EventManager.ANY_EVENT, function(evtType, field, phase){ | ||
elog += "|"+evtType + field.name() + phase + field.value(); | ||
}); | ||
rec.fldLastName.value("Brown"); | ||
// elog = "|data-changeLastNamebeforeSmith|data-changeLastNameafterBrown" | ||
``` | ||
```js | ||
var rec = ... | ||
var elog = ""; | ||
rec.fldLastName.deferValidation(false); | ||
rec.fldLastName.eventBind(WAVE.EventManager.ANY_EVENT, function(evtType, field, phase){ | ||
elog += "|"+evtType + field.name() + phase + field.value(); | ||
}); | ||
rec.fldLastName.value("Brown"); | ||
// elog = "|data-changeLastNamebeforeSmith|validateLastNameundefinedBrown|validatedLastNameundefinedBrown|data-changeLastNameafterBrown" | ||
``` | ||
|
||
|
||
## eventBind() | ||
Binds a function to the named event handler on field. | ||
```js | ||
eventBind(string evtName, function handler) | ||
``` | ||
| Parameter | Requirement | Description | | ||
| --------- |:-----------:| --------------------------------------------- | | ||
| evtName | required | name of event from WAVE.RecordModel namespace | | ||
| handler | required | callback-function which fires on event | | ||
### Examples | ||
```js | ||
var rec = ... | ||
var elog = ""; | ||
rec.eventBind(WAVE.RecordModel.EVT_FIELD_DROP, function(field, phase){ | ||
elog += "|" + field.name() + phase; | ||
}); | ||
rec.fldLastName.drop(); | ||
// elog = |LastNamebefore|LastNameafter | ||
``` | ||
|
||
|
||
## isGUIModified() | ||
Returns true when this field was modified from an attached control. | ||
|
||
|
||
## isModified() | ||
Returns true when this field has been modified. | ||
|
||
|
||
## loaded() | ||
Returns true when this field has finished loading. | ||
|
||
|
||
## toString() | ||
Returns string like `[fieldType]Field(fieldName = 'fieldValue')`. | ||
|
||
|
||
## stored() | ||
Returns true if field must be stored back in the server (db). | ||
|
||
|
||
## Validation functions | ||
* valid() - returns true if field has not validation error. | ||
* validate() - validates field and returns true if it is valid. | ||
* validated() - returns true if field has been validated. | ||
* validationError() - returns error thrown during validation. | ||
### Examples | ||
```js | ||
var rec = new WAVE.RecordModel.Record("1", function(){ | ||
new this.Field({Name: "A", Type: "string"}); | ||
new this.Field({Name: "B", Type: "string", Required: true}); | ||
}); | ||
|
||
rec.fldB.validated(); // false | ||
rec.fldB.validate(); | ||
rec.fldB.validated(); //true | ||
rec.fldB.valid(); // false | ||
var err = rec.fldB.validationError(); // contains: 'B' must have a value | ||
rec.fldB.value("aaaaa"); | ||
rec.fldB.valid(); // true | ||
``` | ||
|
||
|
||
## value() | ||
`value()` - then returns field’s value. | ||
`value(object value, bool fromGUI)` - Sets value and modified, validated flags if new value is different from an existing one. `fromGUI` indicates that field is being altered from an attached control. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Operations with objects and functions | ||
|
||
##### clone(object obj): object | ||
Deep clones data object (not functions). | ||
|
||
##### extend(object obj, object ext, bool keepExisting): object | ||
Mixin behavior - extends `obj` with properties of `ext`. | ||
If flag `keepExisting=true` then existing object key is preserved, even if it is null. | ||
|
||
##### isArray(object obj): bool | ||
Returns true when the passed parameter is an array, not a map or function. | ||
|
||
##### isFunction(object obj): bool | ||
Returns true when the passed parameter is a function, not a map object or an array. | ||
|
||
##### isMapOrArray(obj): bool | ||
Returns true when the passed parameter is an array, or map but not a function. | ||
|
||
##### isObject(object obj): bool | ||
Returns true when the passed parameter is a map, not an array or function. | ||
|
||
##### isSame(object obj1, object obj2): bool | ||
Returns true if both objects represent the same scalar value or complex structure/map that is keys/values of maps/arrays. Nulls are considered equivalent. | ||
|
||
##### overrideFunction(function original, function fn): function | ||
Overrides existing function by wrapping in new one. May call base like so: | ||
```js | ||
object.about = WAVE.overrideFun(object.about, function(){ return this.baseFunction() + "overridden" }); | ||
``` | ||
|
||
##### propStrAsObject(object obj, string prop) | ||
Checks object property for string value and if it is then converts it to object (map). | ||
Does nothing if prop does not exist, is null or not a string value. | ||
```js | ||
var o1 = {a: 1, b: '{"c": "yes", "d": "no"}'}; | ||
// WAVE.isObject(o1.b)) = false | ||
|
||
WAVE.propStrAsObject(o1, "b"); | ||
// WAVE.isObject(o1.b)) = true | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# NFX Wave.js | ||
Java Script Client Library | ||
|
||
## General-Purpose Functions | ||
|
||
#### [Array functions](ArrayFunctions.md) | ||
#### [Operations with objects and functions](OperObjFunc.md) | ||
#### [String functions](StringFunctions.md) | ||
|
||
## Sub-libraries and mixins | ||
#### [Geometry](geometry.md) | ||
Contains a large number of functions to work with geometry tasks. | ||
|
||
#### [EventManager](EventManager.md) | ||
Mixin that implements the event-handler mechanism and can be added to any class. | ||
|
||
#### SVG | ||
Provides working with SVG objects. | ||
|
||
#### [UTest](UTest.md) | ||
Implementation of unit testing concept. | ||
|
||
#### [Walkable](walkable.md) | ||
Mixin that enables function chaining that facilitates lazy evaluation via lambda-functions. | ||
|
||
|
||
## Record Model | ||
Record model is in the WAVE.RecordModel namespace. | ||
|
||
### Classes | ||
##### [Record](Record.md) | ||
##### [Field](Field.md) | ||
##### [RecordView](RecordView.md) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.