|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright (c) 2011-present Mediasift Ltd |
|
5
|
|
|
* All rights reserved. |
|
6
|
|
|
* |
|
7
|
|
|
* Redistribution and use in source and binary forms, with or without |
|
8
|
|
|
* modification, are permitted provided that the following conditions |
|
9
|
|
|
* are met: |
|
10
|
|
|
* |
|
11
|
|
|
* * Redistributions of source code must retain the above copyright |
|
12
|
|
|
* notice, this list of conditions and the following disclaimer. |
|
13
|
|
|
* |
|
14
|
|
|
* * Redistributions in binary form must reproduce the above copyright |
|
15
|
|
|
* notice, this list of conditions and the following disclaimer in |
|
16
|
|
|
* the documentation and/or other materials provided with the |
|
17
|
|
|
* distribution. |
|
18
|
|
|
* |
|
19
|
|
|
* * Neither the names of the copyright holders nor the names of his |
|
20
|
|
|
* contributors may be used to endorse or promote products derived |
|
21
|
|
|
* from this software without specific prior written permission. |
|
22
|
|
|
* |
|
23
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
24
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
25
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
26
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
27
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
28
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
29
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
30
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
31
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
32
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
33
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
34
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
|
35
|
|
|
* |
|
36
|
|
|
* @category Libraries |
|
37
|
|
|
* @package Storyplayer/Browser |
|
38
|
|
|
* @author Stuart Herbert <[email protected]> |
|
39
|
|
|
* @copyright 2011-present Mediasift Ltd www.datasift.com |
|
40
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
41
|
|
|
* @link http://datasift.github.io/storyplayer |
|
42
|
|
|
*/ |
|
43
|
|
|
|
|
44
|
|
|
namespace Storyplayer\SPv2\Modules\Browser; |
|
45
|
|
|
|
|
46
|
|
|
use DataSift\Storyplayer\PlayerLib\StoryTeller; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Helper class that allows us to write Prose where the action comes before |
|
50
|
|
|
* we say what DOM element we want to act upon |
|
51
|
|
|
* |
|
52
|
|
|
* @method mixed boxWithId(string $id) |
|
53
|
|
|
* @method mixed boxWithLabel(string $label) |
|
54
|
|
|
* @method mixed boxLabelled(string $label) |
|
55
|
|
|
* @method mixed boxWithName(string $name) |
|
56
|
|
|
* @method mixed boxNamed(string $name) |
|
57
|
|
|
* @method mixed boxWithClass(string $class) |
|
58
|
|
|
* @method mixed boxWithPlaceholder(string $text) |
|
59
|
|
|
* @method mixed boxWithTitle(string $title) |
|
60
|
|
|
* @method mixed boxWithLabelTextOrId(string $labelTextOrId) |
|
61
|
|
|
* @method mixed boxesWithId(string $id) |
|
62
|
|
|
* @method mixed boxesWithLabel(string $label) |
|
63
|
|
|
* @method mixed boxesLabelled(string $label) |
|
64
|
|
|
* @method mixed boxesWithName(string $name) |
|
65
|
|
|
* @method mixed boxesNamed(string $name) |
|
66
|
|
|
* @method mixed boxesWithClass(string $class) |
|
67
|
|
|
* @method mixed boxesWithPlaceholder(string $text) |
|
68
|
|
|
* @method mixed boxesWithTitle(string $title) |
|
69
|
|
|
* @method mixed boxesWithLabelTextOrId(string $labelTextOrId) |
|
70
|
|
|
* @method mixed buttonWithId(string $id) |
|
71
|
|
|
* @method mixed buttonWithLabel(string $label) |
|
72
|
|
|
* @method mixed buttonLabelled(string $label) |
|
73
|
|
|
* @method mixed buttonWithName(string $name) |
|
74
|
|
|
* @method mixed buttonNamed(string $name) |
|
75
|
|
|
* @method mixed buttonWithClass(string $class) |
|
76
|
|
|
* @method mixed buttonWithPlaceholder(string $text) |
|
77
|
|
|
* @method mixed buttonWithTitle(string $title) |
|
78
|
|
|
* @method mixed buttonWithLabelTextOrId(string $labelTextOrId) |
|
79
|
|
|
* @method mixed buttonsWithId(string $id) |
|
80
|
|
|
* @method mixed buttonsWithLabel(string $label) |
|
81
|
|
|
* @method mixed buttonsLabelled(string $label) |
|
82
|
|
|
* @method mixed buttonsWithName(string $name) |
|
83
|
|
|
* @method mixed buttonsNamed(string $name) |
|
84
|
|
|
* @method mixed buttonsWithClass(string $class) |
|
85
|
|
|
* @method mixed buttonsWithPlaceholder(string $text) |
|
86
|
|
|
* @method mixed buttonsWithTitle(string $title) |
|
87
|
|
|
* @method mixed buttonsWithLabelTextOrId(string $labelTextOrId) |
|
88
|
|
|
* @method mixed cellWithId(string $id) |
|
89
|
|
|
* @method mixed cellWithLabel(string $label) |
|
90
|
|
|
* @method mixed cellLabelled(string $label) |
|
91
|
|
|
* @method mixed cellWithName(string $name) |
|
92
|
|
|
* @method mixed cellNamed(string $name) |
|
93
|
|
|
* @method mixed cellWithClass(string $class) |
|
94
|
|
|
* @method mixed cellWithPlaceholder(string $text) |
|
95
|
|
|
* @method mixed cellWithTitle(string $title) |
|
96
|
|
|
* @method mixed cellWithLabelTextOrId(string $labelTextOrId) |
|
97
|
|
|
* @method mixed cellsWithId(string $id) |
|
98
|
|
|
* @method mixed cellsWithLabel(string $label) |
|
99
|
|
|
* @method mixed cellsLabelled(string $label) |
|
100
|
|
|
* @method mixed cellsWithName(string $name) |
|
101
|
|
|
* @method mixed cellsNamed(string $name) |
|
102
|
|
|
* @method mixed cellsWithClass(string $class) |
|
103
|
|
|
* @method mixed cellsWithPlaceholder(string $text) |
|
104
|
|
|
* @method mixed cellsWithTitle(string $title) |
|
105
|
|
|
* @method mixed cellsWithLabelTextOrId(string $labelTextOrId) |
|
106
|
|
|
* @method mixed dropdownWithId(string $id) |
|
107
|
|
|
* @method mixed dropdownWithLabel(string $label) |
|
108
|
|
|
* @method mixed dropdownLabelled(string $label) |
|
109
|
|
|
* @method mixed dropdownWithName(string $name) |
|
110
|
|
|
* @method mixed dropdownNamed(string $name) |
|
111
|
|
|
* @method mixed dropdownWithClass(string $class) |
|
112
|
|
|
* @method mixed dropdownWithPlaceholder(string $text) |
|
113
|
|
|
* @method mixed dropdownWithTitle(string $title) |
|
114
|
|
|
* @method mixed dropdownWithLabelTextOrId(string $labelTextOrId) |
|
115
|
|
|
* @method mixed dropdownsWithId(string $id) |
|
116
|
|
|
* @method mixed dropdownsWithLabel(string $label) |
|
117
|
|
|
* @method mixed dropdownsLabelled(string $label) |
|
118
|
|
|
* @method mixed dropdownsWithName(string $name) |
|
119
|
|
|
* @method mixed dropdownsNamed(string $name) |
|
120
|
|
|
* @method mixed dropdownsWithClass(string $class) |
|
121
|
|
|
* @method mixed dropdownsWithPlaceholder(string $text) |
|
122
|
|
|
* @method mixed dropdownsWithTitle(string $title) |
|
123
|
|
|
* @method mixed dropdownsWithLabelTextOrId(string $labelTextOrId) |
|
124
|
|
|
* @method mixed elementById(string $id) |
|
125
|
|
|
* @method mixed elementWithId(string $id) |
|
126
|
|
|
* @method mixed elementWithLabel(string $label) |
|
127
|
|
|
* @method mixed elementLabelled(string $label) |
|
128
|
|
|
* @method mixed elementWithName(string $name) |
|
129
|
|
|
* @method mixed elementNamed(string $name) |
|
130
|
|
|
* @method mixed elementWithClass(string $class) |
|
131
|
|
|
* @method mixed elementWithPlaceholder(string $text) |
|
132
|
|
|
* @method mixed elementWithTitle(string $title) |
|
133
|
|
|
* @method mixed elementByLabelIdOrName(string $text) |
|
134
|
|
|
* @method mixed elementWithLabelTextOrId(string $labelTextOrId) |
|
135
|
|
|
* @method mixed elementByXpath(string $xpath) |
|
136
|
|
|
* @method mixed elementsWithId(string $id) |
|
137
|
|
|
* @method mixed elementsWithLabel(string $label) |
|
138
|
|
|
* @method mixed elementsLabelled(string $label) |
|
139
|
|
|
* @method mixed elementsWithName(string $name) |
|
140
|
|
|
* @method mixed elementsNamed(string $name) |
|
141
|
|
|
* @method mixed elementsWithClass(string $class) |
|
142
|
|
|
* @method mixed elementsWithPlaceholder(string $text) |
|
143
|
|
|
* @method mixed elementsWithTitle(string $title) |
|
144
|
|
|
* @method mixed elementsWithLabelTextOrId(string $labelTextOrId) |
|
145
|
|
|
* @method mixed fieldWithId(string $id) |
|
146
|
|
|
* @method mixed fieldWithLabel(string $label) |
|
147
|
|
|
* @method mixed fieldLabelled(string $label) |
|
148
|
|
|
* @method mixed fieldWithName(string $name) |
|
149
|
|
|
* @method mixed fieldNamed(string $name) |
|
150
|
|
|
* @method mixed fieldWithClass(string $class) |
|
151
|
|
|
* @method mixed fieldWithPlaceholder(string $text) |
|
152
|
|
|
* @method mixed fieldWithTitle(string $title) |
|
153
|
|
|
* @method mixed fieldWithLabelTextOrId(string $labelTextOrId) |
|
154
|
|
|
* @method mixed fieldsWithId(string $id) |
|
155
|
|
|
* @method mixed fieldsWithLabel(string $label) |
|
156
|
|
|
* @method mixed fieldsLabelled(string $label) |
|
157
|
|
|
* @method mixed fieldsWithName(string $name) |
|
158
|
|
|
* @method mixed fieldsNamed(string $name) |
|
159
|
|
|
* @method mixed fieldsWithClass(string $class) |
|
160
|
|
|
* @method mixed fieldsWithPlaceholder(string $text) |
|
161
|
|
|
* @method mixed fieldsWithTitle(string $title) |
|
162
|
|
|
* @method mixed fieldsWithLabelTextOrId(string $labelTextOrId) |
|
163
|
|
|
* @method mixed headingWithId(string $id) |
|
164
|
|
|
* @method mixed headingWithLabel(string $label) |
|
165
|
|
|
* @method mixed headingLabelled(string $label) |
|
166
|
|
|
* @method mixed headingWithName(string $name) |
|
167
|
|
|
* @method mixed headingNamed(string $name) |
|
168
|
|
|
* @method mixed headingWithClass(string $class) |
|
169
|
|
|
* @method mixed headingWithPlaceholder(string $text) |
|
170
|
|
|
* @method mixed headingWithTitle(string $title) |
|
171
|
|
|
* @method mixed headingWithLabelTextOrId(string $labelTextOrId) |
|
172
|
|
|
* @method mixed headingsWithId(string $id) |
|
173
|
|
|
* @method mixed headingsWithLabel(string $label) |
|
174
|
|
|
* @method mixed headingsLabelled(string $label) |
|
175
|
|
|
* @method mixed headingsWithName(string $name) |
|
176
|
|
|
* @method mixed headingsNamed(string $name) |
|
177
|
|
|
* @method mixed headingsWithClass(string $class) |
|
178
|
|
|
* @method mixed headingsWithPlaceholder(string $text) |
|
179
|
|
|
* @method mixed headingsWithTitle(string $title) |
|
180
|
|
|
* @method mixed headingsWithLabelTextOrId(string $labelTextOrId) |
|
181
|
|
|
* @method mixed linkWithId(string $id) |
|
182
|
|
|
* @method mixed linkWithLabel(string $label) |
|
183
|
|
|
* @method mixed linkLabelled(string $label) |
|
184
|
|
|
* @method mixed linkWithName(string $name) |
|
185
|
|
|
* @method mixed linkNamed(string $name) |
|
186
|
|
|
* @method mixed linkWithClass(string $class) |
|
187
|
|
|
* @method mixed linkWithPlaceholder(string $text) |
|
188
|
|
|
* @method mixed linkWithTitle(string $title) |
|
189
|
|
|
* @method mixed linkWithLabelTextOrId(string $labelTextOrId) |
|
190
|
|
|
* @method mixed linksWithId(string $id) |
|
191
|
|
|
* @method mixed linksWithLabel(string $label) |
|
192
|
|
|
* @method mixed linksLabelled(string $label) |
|
193
|
|
|
* @method mixed linksWithName(string $name) |
|
194
|
|
|
* @method mixed linksNamed(string $name) |
|
195
|
|
|
* @method mixed linksWithClass(string $class) |
|
196
|
|
|
* @method mixed linksWithPlaceholder(string $text) |
|
197
|
|
|
* @method mixed linksWithTitle(string $title) |
|
198
|
|
|
* @method mixed linksWithLabelTextOrId(string $labelTextOrId) |
|
199
|
|
|
* @method mixed orderedlistWithId(string $id) |
|
200
|
|
|
* @method mixed orderedlistWithLabel(string $label) |
|
201
|
|
|
* @method mixed orderedlistLabelled(string $label) |
|
202
|
|
|
* @method mixed orderedlistWithName(string $name) |
|
203
|
|
|
* @method mixed orderedlistNamed(string $name) |
|
204
|
|
|
* @method mixed orderedlistWithClass(string $class) |
|
205
|
|
|
* @method mixed orderedlistWithPlaceholder(string $text) |
|
206
|
|
|
* @method mixed orderedlistWithTitle(string $title) |
|
207
|
|
|
* @method mixed orderedlistWithLabelTextOrId(string $labelTextOrId) |
|
208
|
|
|
* @method mixed spanWithId(string $id) |
|
209
|
|
|
* @method mixed spanWithLabel(string $label) |
|
210
|
|
|
* @method mixed spanLabelled(string $label) |
|
211
|
|
|
* @method mixed spanWithName(string $name) |
|
212
|
|
|
* @method mixed spanNamed(string $name) |
|
213
|
|
|
* @method mixed spanWithClass(string $class) |
|
214
|
|
|
* @method mixed spanWithPlaceholder(string $text) |
|
215
|
|
|
* @method mixed spanWithTitle(string $title) |
|
216
|
|
|
* @method mixed spanWithLabelTextOrId(string $labelTextOrId) |
|
217
|
|
|
* @method mixed unorderedlistWithId(string $id) |
|
218
|
|
|
* @method mixed unorderedlistWithLabel(string $label) |
|
219
|
|
|
* @method mixed unorderedlistLabelled(string $label) |
|
220
|
|
|
* @method mixed unorderedlistWithName(string $name) |
|
221
|
|
|
* @method mixed unorderedlistNamed(string $name) |
|
222
|
|
|
* @method mixed unorderedlistWithClass(string $class) |
|
223
|
|
|
* @method mixed unorderedlistWithPlaceholder(string $text) |
|
224
|
|
|
* @method mixed unorderedlistWithTitle(string $title) |
|
225
|
|
|
* @method mixed unorderedlistWithLabelTextOrId(string $labelTextOrId) |
|
226
|
|
|
* @method mixed intoElement($element) |
|
227
|
|
|
* @method mixed fromElement($element) |
|
228
|
|
|
* |
|
229
|
|
|
* @method mixed theFieldLabelled(string $label) |
|
230
|
|
|
* @method mixed fromFieldWithId(string $id) |
|
231
|
|
|
* @method void intoFieldWithId(string $id) |
|
232
|
|
|
* |
|
233
|
|
|
* @category Libraries |
|
234
|
|
|
* @package Storyplayer/BrowserLib |
|
235
|
|
|
* @author Stuart Herbert <[email protected]> |
|
236
|
|
|
* @copyright 2011-present Mediasift Ltd www.datasift.com |
|
237
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
238
|
|
|
* @link http://datasift.github.io/storyplayer |
|
239
|
|
|
*/ |
|
240
|
|
|
class SingleElementAction extends BaseElementAction |
|
241
|
|
|
{ |
|
242
|
|
|
protected $action; |
|
243
|
|
|
protected $actionDesc; |
|
244
|
|
|
|
|
245
|
|
|
/** |
|
246
|
|
|
* @param \Closure $action |
|
247
|
|
|
* @param string $actionDesc |
|
248
|
|
|
*/ |
|
249
|
|
|
public function __construct($action, $actionDesc, $baseElement = null) |
|
250
|
|
|
{ |
|
251
|
|
|
parent::__construct($baseElement); |
|
252
|
|
|
|
|
253
|
|
|
$this->action = $action; |
|
254
|
|
|
$this->actionDesc = $actionDesc; |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
/** |
|
258
|
|
|
* @param string $methodName |
|
259
|
|
|
* @param array $methodArgs |
|
260
|
|
|
* @return mixed |
|
261
|
|
|
*/ |
|
262
|
|
|
public function __call($methodName, $methodArgs) |
|
263
|
|
|
{ |
|
264
|
|
|
// retrieve the element, using the fake method name to figure out |
|
265
|
|
|
// which element the caller is looking for |
|
266
|
|
|
$element = $this->retrieveElement($methodName, $methodArgs); |
|
267
|
|
|
|
|
268
|
|
|
// now that we have our element, let's apply the action to it |
|
269
|
|
|
$action = $this->action; |
|
270
|
|
|
$return = $action($element, $methodArgs[0], $methodName); |
|
271
|
|
|
|
|
272
|
|
|
// all done |
|
273
|
|
|
return $return; |
|
274
|
|
|
} |
|
275
|
|
|
} |
|
276
|
|
|
|