@@ -588,7 +588,9 @@ function addEvents(model, Class, classId) {
588
588
*/
589
589
function addOn ( Class , classId ) {
590
590
var body = function ( state , handler , useCoreAPI ) {
591
- var result = '' ;
591
+ var behaviorId = '' ,
592
+ currentState = '' ;
593
+
592
594
if ( $workflow . checkParams ( {
593
595
"component" : this ,
594
596
"methodName" : "on" ,
@@ -606,16 +608,11 @@ function addOn(Class, classId) {
606
608
$log . behaviorNotUnique ( classId , state ) ;
607
609
} else {
608
610
if ( $worklow . validParamNumbers ( classId , state , handler ) ) {
609
- result = $behavior . add ( this . id ( ) , state , handler , useCoreAPI ) ;
610
-
611
- // experimental
612
- var currentState = $state . get ( this . id ( ) ) ;
611
+ behaviorId = $behavior . add ( this . id ( ) , state , handler , useCoreAPI ) ;
612
+
613
+ currentState = $state . get ( this . id ( ) ) ;
613
614
if ( currentState && state === currentState . name ) {
614
- $workflow . state ( {
615
- "component" : this . id ( ) ,
616
- "state" : state ,
617
- "data" : currentState . parameters . data
618
- } ) ;
615
+ $workflow . action ( behaviorId , behaviorId ) ;
619
616
}
620
617
621
618
} else {
@@ -626,7 +623,7 @@ function addOn(Class, classId) {
626
623
$log . invalidStateOn ( classId , state ) ;
627
624
}
628
625
}
629
- return result ;
626
+ return behaviorId ;
630
627
} ;
631
628
/* jshint -W054 */
632
629
Class . prototype . on = new Function ( "body" , "return function on (state,handler,useCoreAPI) { return body.call(this,state,handler,useCoreAPI) };" ) ( body ) ;
@@ -643,7 +640,9 @@ function addOn(Class, classId) {
643
640
*/
644
641
function addOnClass ( Class , classId ) {
645
642
var body = function ( state , handler , useCoreAPI ) {
646
- var result = '' ;
643
+ var behaviorId = '' ,
644
+ currentState = '' ;
645
+
647
646
if ( $workflow . checkParams ( {
648
647
"component" : this ,
649
648
"methodName" : "on" ,
@@ -661,16 +660,11 @@ function addOnClass(Class, classId) {
661
660
$log . behaviorNotUnique ( classId , state ) ;
662
661
} else {
663
662
if ( $worklow . validParamNumbers ( classId , state , handler ) ) {
664
- result = $behavior . add ( this . id ( ) , state , handler , useCoreAPI ) ;
665
-
666
- // experimental
667
- var currentState = $state . get ( this . id ( ) ) ;
663
+ behaviorId = $behavior . add ( this . id ( ) , state , handler , useCoreAPI ) ;
664
+
665
+ currentState = $state . get ( this . id ( ) ) ;
668
666
if ( currentState && state === currentState . name ) {
669
- $workflow . state ( {
670
- "component" : this . id ( ) ,
671
- "state" : state ,
672
- "data" : currentState . parameters . data
673
- } ) ;
667
+ $workflow . action ( behaviorId , behaviorId ) ;
674
668
}
675
669
676
670
} else {
@@ -681,7 +675,7 @@ function addOnClass(Class, classId) {
681
675
$log . invalidStateOn ( classId , state ) ;
682
676
}
683
677
}
684
- return result ;
678
+ return behaviorId ;
685
679
} ;
686
680
/* jshint -W054 */
687
681
Class . on = new Function ( "body" , "return function on (state,handler,useCoreAPI) { return body.call(this, state, handler, useCoreAPI) };" ) ( body ) ;
@@ -747,7 +741,6 @@ function addDestroyClass(Class) {
747
741
}
748
742
749
743
750
-
751
744
/*
752
745
* Add the addClassInfo method on a class.
753
746
* @method addClassInfoClass
@@ -827,10 +820,16 @@ function get(id) {
827
820
828
821
829
822
/*
830
- * Find components with a query.
823
+ * Find components with a query.
831
824
* @method find
832
- * @param {String } query query
825
+ * @param {String } Class class name of the component to search
826
+ * @param {Object|Array } query query
833
827
* @return {Array } components found
828
+ *
829
+ * @example
830
+ * $component.find("Student", {"name": "laure"}); <br>
831
+ * $component.find("Student", {"name": "laure", "age" : 24}); <br>
832
+ * $component.find("Student", [{"name": "rene"}, {"name": "robert"}]);
834
833
*/
835
834
function find ( Class , query ) {
836
835
var documents = [ ] ,
@@ -959,8 +958,14 @@ exports.get = get;
959
958
/**
960
959
* Find components with a query.
961
960
* @method find
962
- * @param {String } query query
961
+ * @param {String } Class class name of the component to search
962
+ * @param {Object|Array } query query
963
963
* @return {Array } components found
964
+ *
965
+ * @example
966
+ * $component.find("Student", {"name": "laure"}); <br>
967
+ * $component.find("Student", {"name": "laure", "age" : 24}); <br>
968
+ * $component.find("Student", [{"name": "rene"}, {"name": "robert"}]);
964
969
*/
965
970
exports . find = find ;
966
971
0 commit comments