mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[jquery/findTestSubject] added docs
This commit is contained in:
parent
657697aa68
commit
870eb8a4a8
1 changed files with 39 additions and 5 deletions
44
src/ui/public/jquery/findTestSubject.js
vendored
44
src/ui/public/jquery/findTestSubject.js
vendored
|
@ -1,5 +1,44 @@
|
|||
module.exports = function bindToJquery($) {
|
||||
|
||||
/**
|
||||
* Find elements with the `data-test-subj` attribute by the terms in that attribute.
|
||||
*
|
||||
* Find all of the element inside $el with the "saveButton" subject.
|
||||
*
|
||||
* ```js
|
||||
* var $button = $el.findTestSubject('saveButton');
|
||||
* ```
|
||||
*
|
||||
* Find all of the elements with either "saveButton" or "cancelButton"
|
||||
*
|
||||
* ```js
|
||||
* var $buttons = $.findTestSubject('saveButton', 'cancelButton');
|
||||
* ```
|
||||
*
|
||||
* Find all of the elements with a subject that decent from another subject
|
||||
*
|
||||
* ```js
|
||||
* var $button = $.findTestSubject('savedObjectForm saveButton');
|
||||
* ```
|
||||
*
|
||||
* Find all of the elements which have both subjects
|
||||
*
|
||||
* ```js
|
||||
* var $input = $.findTestSubject('smallButton&saveButton');
|
||||
* ```
|
||||
*
|
||||
* @return {jQueryCollection}
|
||||
*/
|
||||
$.findTestSubject = function () {
|
||||
return findTestSubject.apply($(document.body), arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Just like $.findTestSubject, except only finds elements within another element.
|
||||
* @return {jQueryCollection}
|
||||
*/
|
||||
$.fn.findTestSubject = findTestSubject;
|
||||
|
||||
function findTestSubject(/* ...subjectSelectors */) {
|
||||
var subjectSelectors = [].slice.apply(arguments);
|
||||
var $els = $();
|
||||
|
@ -16,9 +55,4 @@ module.exports = function bindToJquery($) {
|
|||
return $els;
|
||||
};
|
||||
|
||||
$.fn.findTestSubject = findTestSubject;
|
||||
$.findTestSubject = function () {
|
||||
return findTestSubject.apply($(document.body), arguments);
|
||||
};
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue