11/**
2- * Setup file for the Scenario.
2+ * Setup file for the Scenario.
33 * Must be first in the compilation/bootstrap list.
44 */
55
@@ -19,7 +19,7 @@ angular.scenario.ui = {};
1919 * functions.
2020 *
2121 * @param {String } The name of the statement
22- * @param {Function } Factory function(application), return a function for
22+ * @param {Function } Factory function(application), return a function for
2323 * the statement.
2424 */
2525angular . scenario . dsl = function ( name , fn ) {
@@ -50,7 +50,7 @@ angular.scenario.dsl = function(name, fn) {
5050
5151/**
5252 * Defines a new matcher for use with the expects() statement. The value
53- * this.actual (like in Jasmine) is available in your matcher to compare
53+ * this.actual (like in Jasmine) is available in your matcher to compare
5454 * against. Your function should return a boolean. The future is automatically
5555 * created for you.
5656 *
@@ -83,7 +83,7 @@ angular.scenario.matcher = function(name, fn) {
8383 *
8484 * @param {Array } list to iterate over
8585 * @param {Function } Callback function(value, continueFunction)
86- * @param {Function } Callback function(error, result) called when iteration
86+ * @param {Function } Callback function(error, result) called when iteration
8787 * finishes or an error occurs.
8888 */
8989function asyncForEach ( list , iterator , done ) {
@@ -101,3 +101,44 @@ function asyncForEach(list, iterator, done) {
101101 }
102102 loop ( ) ;
103103}
104+
105+
106+ function browserTrigger ( element , type ) {
107+ if ( ! element . nodeName ) element = element [ 0 ] ;
108+ if ( ! type ) {
109+ type = {
110+ 'text' : 'change' ,
111+ 'textarea' : 'change' ,
112+ 'hidden' : 'change' ,
113+ 'password' : 'change' ,
114+ 'button' : 'click' ,
115+ 'submit' : 'click' ,
116+ 'reset' : 'click' ,
117+ 'image' : 'click' ,
118+ 'checkbox' : 'click' ,
119+ 'radio' : 'click' ,
120+ 'select-one' : 'change' ,
121+ 'select-multiple' : 'change'
122+ } [ element . type ] || 'click' ;
123+ }
124+ if ( lowercase ( nodeName ( element ) ) == 'option' ) {
125+ element . parentNode . value = element . value ;
126+ element = element . parentNode ;
127+ type = 'change' ;
128+ }
129+ if ( msie ) {
130+ element . fireEvent ( 'on' + type ) ;
131+ } else {
132+ var evnt = document . createEvent ( 'MouseEvents' ) ;
133+ evnt . initMouseEvent ( type , true , true , window , 0 , 0 , 0 , 0 , 0 , false , false , false , false , 0 , element ) ;
134+ element . dispatchEvent ( evnt ) ;
135+ }
136+ }
137+
138+ _jQuery . fn . trigger = function ( type ) {
139+ return this . each ( function ( index , node ) {
140+ browserTrigger ( node , type ) ;
141+ } ) ;
142+ } ;
143+
144+
0 commit comments