Socket
Socket
Sign inDemoInstall

umbrellajs

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

umbrellajs - npm Package Compare versions

Comparing version 2.10.1 to 2.10.2

2

bower.json
{
"name": "umbrella",
"version": "2.8.0",
"version": "2.10.2",
"homepage": "http://umbrellajs.com/",

@@ -5,0 +5,0 @@ "authors": [

# Porting from jQuery
Umbrella offers some advantages over jQuery:
UmbrellaJS offers some advantages over jQuery:
- Speed: using native methods makes it faster.
- Size: umbrella.js is 3kb in total.
- Size: UmbrellaJS is 3kb in total.
- Clean: making new plugins and reading the code base is easy.

@@ -18,11 +18,12 @@

## Before porting to UmbrellaJS
zepto.js, umbreallyJS does not support jQuery extensions! if your scripts make heavy use of extensions you should stop reading here.
zepto.js and UmbreallyJS does not support jQuery extensions! if your scripts make heavy use of extensions you should stop reading here.
before porting an existing script to a jQuery alternative I strongly recommend to check your jQuery code to be correct.
Before porting an existing script to a jQuery alternative I strongly recommend to check your jQuery code to be correct.
**Check for usage of `$('.subclass', $('.myclass'))`**
Even if `$('.subclass', $('.myclass'))` and `$('.myclass').find('.subclass')` are equivalent, you should use the latter. it's more readable and easier to port.
Even `$('.subclass', $('.myclass'))` and `$('.myclass').find('.subclass')` are equivalent, you should use the latter. it's more readable and easier to port.

@@ -35,22 +36,29 @@ **Check for correct `$(element)` selection**

`$('#myID')` always returns one element, more exactly the first matching element. all other selectors return ALL elements. if you want to select the first element of `$('.myclass')` you must use `$('.myclass').first()` or `$('.myclass').eq(0)`. avoid using of `$('.myclass')[0]`
`$('#myID')` always returns one element, more exactly the first matching element. all other selectors return ALL elements. if you want to select ONE element of `$('.myclass')` you must use `$('.myclass').first()`, `$('.myclass').last()` or `$('.myclass').eq(n)`. You must not use of `$('.myclass')[0]`
**Avoid the usage of `:not()` in selectors**
Instead of `$('.myclass:not(div, a)')` I strongly suggest to use `$('.myclass').not('div, a')` instead. it's more readable, faster and works with all CSS standard selectors.
jQuery **extends the `:not()` selector** such that you can pass any selector to it, no matter how complex it may be. the `:not()` pseudo-class in CSS only accepts a _single simple selector_ as an argument to `:not()`.
for more Information [see explanation on Stackoverflow](https://stackoverflow.com/questions/10711730/why-is-my-jquery-not-selector-not-working-in-css#answer-10711731)
### First steps
UmbrellaJS can be used in parallel with jQuery, so you can start porting to umbrellaJs step by step. simply include `<script src="https://unpkg.com/umbrellajs"></script>` in your HMTL file or `// @require https://unpkg.com/umbrellajs` in your script, if you are writing a userscript.
UmbrellaJS can be used in parallel with jQuery, so you can start porting to UmbrellaJs step by step. simply include `<script src="https://unpkg.com/umbrellajs"></script>` in your HMTL file or `// @require https://unpkg.com/umbrellajs` in your script, if you are writing a userscript.
Now start with changing a simple function or statement from jQuery to umbrella by replacing `$(...)` with `u(...)`, it so simple!
Now start with changing a simple function or statement from jQuery to UmbrellaJS by replacing `$(...)` with `u(...)`, it so simple!
## Porting tips
while porting my [enstlyer script](https://greasyfork.org/de/scripts/24244-enstyler-develop/code) from jQuery (more precise from zepto.js) to UmbrellaJS I discoverd some pitfalls I want to share with you. nevertheless it was easy and its always helpfull to have the excellent [UmbrellaJS documentation](https://umbrellajs.com/documentation) in a browser tab.
While porting [my](https://github.com/gnadelwartz) [enstlyer script](https://greasyfork.org/de/scripts/24244-enstyler-develop/code) from jQuery (more precise from zepto.js) to UmbrellaJS I discoverd some pitfalls I want to share with you. nevertheless it was easy and its always helpfull to have the excellent [UmbrellaJS documentation](https://umbrellajs.com/documentation) in a browser tab.
**Why does `.replaceWith()` not exist in umbrella?**
This should be very simple, use the umbrella `.replace()` method instead. It has nothing to do with the native javascript .replace() method for arrays though, so make sure not to mix them up.
#### Why does `.replaceWith()` not exist in UmbrellaJS?
If someone wants to stay with` .replaceWith` like in jquery and does not care about an extra function call, adding this to your script may help:
This should be very simple, use the UmbrellaJS `.replace()` method instead. It has nothing to do with the native javascript .replace() method for arrays though, so make sure not to mix them up.
If you wants to stay with` .replaceWith` like in jQuery and does not care about an extra function call, adding this to your script may help:
```

@@ -63,8 +71,8 @@ u.prototype.replaceWith = function(replace){

**Why does `.css()` not exist in umbrella?**
#### Why does `.css()` not exist in UmbrellaJS?
I general I avoid using `.css()` to set CSS properties because it's better and faster handled by CSS rules. To do something similar with UmbrellaJS use this `getStyle()` function:
I generaly avoid to set CSS properties with JavaScript, because it's better and faster handled by CSS rules. To do something similar as jQuery `.css()` get method with UmbrellaJS you can use this `getStyle()` function:
```js
// alternative for jquery .css() get method
// alternative for jQuery .css() get method
function getStyle(oElm, css3Prop){

@@ -88,6 +96,6 @@ // FF, Chrome etc.

// usage examples
// umbrella
// umbrella: use use one node
getStyle(u('.myClass').nodes[n], "border-radius");
// native DOM
// use one native DOM node
getStyle(getElementsByClassName('myClass')[n], "border-radius");

@@ -101,10 +109,10 @@ getStyle(getElementById('myID'), "border-radius");

**`u(this)` works different like in jquery**
#### `u(this)` works not like in jQuery
Umbrella follows the native Javascript array structure, so it won't change the scope of the javascript `this` property in `each().` But its easy to fix it.
UmbrellaJS follows the native Javascript array structure, so it won't change the scope of the javascript `this` property in `.each()` But it's easy to fix it.
Your jquery `.each()` loops might look like this now:
Your jQuery `.each()` loops might look like this now:
```js
$('.myremove').each(function () {
$('.myclass').each(function () {
...

@@ -115,5 +123,4 @@ $(this).dosomething();

```
You should change them to look like this:
Then change them to something like this:
```js

@@ -127,5 +134,7 @@ u('.myclass').each(function (el) {

**Note:** Search for occurences of `u(this)` while/after porting, in almost all cases it's not correct!
UmbrellaJS provides the actually processed node as first argument to the called function, [see the documentation for .each()](https://umbrellajs.com/documentation#each).
As a bonus you get the node count as second argument, so you don't have count it yourself in case you need to know:
As a bonus you get the node count as second argument, so you don't have count it yourself in case you need it:

@@ -156,14 +165,18 @@ ```js

**umbrella `.first()` returns native DOM element**
#### using UmbrellaJS `.first()/.last()/.eq()` give strange results or errors
in jquery `.first()` returns a jquery object, but umbrella it returns a native DOM object. this has pro and con:
in jQuery `.first()/.last()/.eq()` returns a jQuery object, but UmbrellaJS returns a native DOM element. this has pro and con:
- pro: you can use faster native javascript DOM manipulation
- con: you can't chain an other umbrella method like in jquery
- con: you can't chain an other UmbrellaJS method like in jQuery
- con: be careful to select the correct DOM property/method!
**example:** how to get inner html:
**Wait,** there is no `.eq()` in UmbrellaJS, but you can use `.nodes[n]` as a functional replacment.
**power tip from UmbrellaJS creator:** You can wrap the whole thing into another `u(...)` and use UmbrellaJS functions conveniently.
**example:** how to get inner html of first element:
```js
// jquery:
// jQuery:
$('.myclass').first().html();

@@ -174,48 +187,101 @@

// umbrella: wrapping it again
u(u('.myclass').first()).html();
// umbrella: wrapping it in u(...) again
u( u('.myclass').first() ).html();
```
**power tip from umbrealla creator:** For the .first() example you can just wrap the whole thing into another u() and use .before() conveniently.
**example:** how to add html before last element:
**example:** how to add html before element:
```js
// jquery:
$('.myclass').first().before('<div>this is inserted before</div>');
// jQuery:
$('.myclass').last().before('<div>this is inserted before</div>');
// umbrella: use of .insertAdjacentHTML() method, DOM method .before() requires DOM node!
u(u('.myclass').first()).before('<div>this is inserted before</div>');
u('.myclass').first().insertAdjacentHTML('beforebegin', '<div>this is inserted before</div>');
// umbrella: direct use of .insertAdjacentHTML() method
u('.myclass').last().insertAdjacentHTML('beforebegin', '<div>this is inserted before</div>');
// wrong: works not as you may expect!
// umbrella wrapping it in u(...) again
u( u('.myclass').last() ).before('<div>this is inserted before</div>');
// wrong: do not mix it up with DOM method .before()!
// insert TEXT => "&lt;div&gt,this is inserted before&lt;/div&gt,"
$('.myclass').first().before('<div>this is inserted before</div>');
$('.myclass').last().before('<div>this is inserted before</div>');
```
For more information see [.insertAdjacentHTML() ](https://developer.mozilla.org/docs/Web/API/Element/insertAdjacentHTML)
See also documentation of [.insertAdjacentHTML() ](https://developer.mozilla.org/docs/Web/API/Element/insertAdjacentHTML)
**example:** how to add DOM before element:
**example:** add a DOM node after n'th element:
```js
// correct use of .first().before(): create native DOM element
var enMenuButton = document.createElement('input');
enMenuButton.type = 'button';
enMenuButton.setAttribute(enID, 'myID');
enMenuButton.onclick = showmyConfig;
enMenuButton.value = 'Config ';
// append native DOM
u('.subNavMenu').first().before(enMenuButton);
// create a native DOM node
var myBbutton = document.createElement('input');
myButton.type = 'button';
myButton.setAttribute(enID, 'myID');
myButton.onclick = showConfig;
myButton.value = 'Config ';
// append native DOM node befre n'th element
u('.subNavMenu').nodes[n].after(enMenuButton);
```
**`return false`; does not stop iterations in umbrella `.each()` loop**
If you want to have an UmbrellaJS `.eq()` method and don't care about an extra function call, adding this to your script may help:
In jquery you can `return false;` to stop the iteration of an `.each()` loop
this seems to work different in umbrella, the remaining iterations are done instead of skipped
```
// get the nth of the nodes
u.prototype.eq = function (index) {
return this.nodes[index||0] || false;
}
```
#### How to break out of UmbrellaJS `.each()` loop?
In jQuery you can use `return false;` to stop the iteration of an `.each()` loop.
this is diffrent in UmbrellaJS, the loop always processes all given elememnts!
Depending on your use case you can mimic the jQuery logic in different ways:
**example**: stop after 5'th iterration
```js
u('article').each(function (that,i) {
dosometing(that);
if (i==5) return false;
u('article').each(function (el,i) {
if (i>5) return;
dosometing(el);
})
```
**example**: abort after something failed
```js
var abort=false;
u('article').each(function (el,i) {
if(abort) return;
if (! dosometing_ok(el)) abort=true; ;
})
```
#### You miss some jQuery features in UmbrellaJS?
A good source of inspiration is [You Might Not Need jQuery](http://youmightnotneedjquery.com/).
You can also search on [stackoverflow](https://stackoverflow.com/search?q=jquery%20pure%20javascript) for jQuery alternatives in pure JavaScript
You can apply most tips from there to single UmbrellaJS node directly:
```js
// jQuery
$(#hide).hide();
$(.myclass).hide();
// umbrella: apply "You Might Not Need jQuery" tips to one umbrella nodes[n]
$(#hide).nodes[0].style.display = 'none';
$(.myclass).nodes[n].style.display = 'none';
```
If you have to apply to all nodes returned from UmbrellaJS, you can use an `.each()` loop to apply to every node
```js
// jQuery
$(.myclass).empty();
// umbrella: apply "You Might Not Need jQuery" tips to all umbrella nodes
$(.myclass).each(el) {
el.innerHTML = '';
}
```
{
"name": "umbrellajs",
"version": "2.10.1",
"version": "2.10.2",
"homepage": "http://umbrellajs.com/",

@@ -25,2 +25,3 @@ "authors": [

"scripts": {
"build": "grunt build",
"start": "node app.js",

@@ -27,0 +28,0 @@ "test": "grunt test",

# Umbrella JS [![Circle CI](https://circleci.com/gh/franciscop/umbrella/tree/master.svg?style=shield)](https://circleci.com/gh/franciscop/umbrella/tree/master) [![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg)](https://github.com/Flet/semistandard) [![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/franciscop/umbrella/blob/master/LICENSE)
> [**Library Documentation**](http://umbrellajs.com/documentation) [**Migrating from jQuery guide**](https://github.com/franciscop/umbrella/blob/master/jquery.md)
> [**Library Documentation**](http://umbrellajs.com/documentation) | [**Migrating from jQuery guide**](https://github.com/franciscop/umbrella/blob/master/jquery.md)

@@ -43,15 +43,18 @@ Covers your javascript needs for those rainy days. A <3kb performant jquery-like library born from the question: [You might not need jquery](http://youmightnotneedjquery.com/), then what do you need?

JSDelivr is an awesome service that hosts many open source projects so you don't need to even download the code:
unpkg.com is an awesome service that hosts many open source projects so you don't need to even download the code:
[**JSDelivr CDN**](http://www.jsdelivr.com/projects/umbrella)
```js
<script src="https://unpkg.com/umbrellajs"></script>
```
### Use bower
### Install with `npm`
Bower is a front-end package manager that makes it super-easy to add a new package:
Using npm is a front-end package manager that makes it super-easy to add a new package:
```
bower install umbrella
npm install umbrellajs
```
### Module support

@@ -58,0 +61,0 @@

@@ -78,3 +78,5 @@ // Testing the main file

it("can append a table row", function() {
u('table.tbl').append('<tr><td>Hi</td></tr>');
var table = u('table.tbl').append('<tr><td>Hi</td></tr>');
var result = '<table class="tbl"><tr><td>Hi</td></tr></table>';
expect(table.nodes[0].outerHTML).to.equal(result);
});

@@ -81,0 +83,0 @@

@@ -6,3 +6,4 @@ // [INTERNAL USE ONLY]

if (/^\s*<t(h|r|d)/.test(html)) {
return u(document.createElement('table')).html(html).children().nodes;
var table = document.createElement('table');
return u(table).html(html).children().children().nodes;
} else if (/^\s*</.test(html)) {

@@ -9,0 +10,0 @@ return u(document.createElement('div')).html(html).children().nodes;

@@ -454,3 +454,4 @@ // Umbrella JS http://umbrellajs.com/

if (/^\s*<t(h|r|d)/.test(html)) {
return u(document.createElement('table')).html(html).children().nodes;
var table = document.createElement('table');
return u(table).html(html).children().children().nodes;
} else if (/^\s*</.test(html)) {

@@ -457,0 +458,0 @@ return u(document.createElement('div')).html(html).children().nodes;

@@ -1,2 +0,2 @@

/* Umbrella JS 2.10.0 umbrellajs.com */
function ajax(a,b,c,d){c=c||function(){},b=b||{},b.body=b.body||{},b.method=(b.method||"GET").toUpperCase(),b.headers=b.headers||{},b.headers["X-Requested-With"]=b.headers["X-Requested-With"]||"XMLHttpRequest","undefined"!=typeof window.FormData&&b.body instanceof window.FormData||(b.headers["Content-Type"]=b.headers["Content-Type"]||"application/x-www-form-urlencoded"),/json/.test(b.headers["Content-Type"])&&(b.body=JSON.stringify(b.body)),"object"!=typeof b.body||b.body instanceof window.FormData||(b.body=u().param(b.body));var e=new window.XMLHttpRequest;u(e).on("error timeout abort",function(){c(new Error,null,e)}).on("load",function(){var a=/^(4|5)/.test(e.status)?new Error(e.status):null,b=parseJson(e.response)||e.response;return c(a,b,e)}),e.open(b.method,a),e.withCredentials=!0;for(var f in b.headers)e.setRequestHeader(f,b.headers[f]);return d&&d(e),e.send(b.body),e}function parseJson(a){try{var b=JSON.parse(a);if(b&&"object"==typeof b)return b}catch(c){}return!1}var u=function(a,b){return this instanceof u?a instanceof u?a:("string"==typeof a&&(a=this.select(a,b)),a&&a.nodeName&&(a=[a]),void(this.nodes=this.slice(a))):new u(a,b)};u.prototype={get length(){return this.nodes.length}},u.prototype.nodes=[],u.prototype.addClass=function(){return this.eacharg(arguments,function(a,b){a.classList.add(b)})},u.prototype.adjacent=function(a,b,c){return"number"==typeof b&&(b=0===b?[]:new Array(b).join().split(",").map(Number.call,Number)),this.each(function(d,e){var f=document.createDocumentFragment();u(b||{}).map(function(b,c){var f="function"==typeof a?a.call(this,b,c,d,e):a;return"string"==typeof f?this.generate(f):u(f)}).each(function(a){this.isInPage(a)?f.appendChild(u(a).clone().first()):f.appendChild(a)}),c.call(this,d,f)})},u.prototype.after=function(a,b){return this.adjacent(a,b,function(a,b){a.parentNode.insertBefore(b,a.nextSibling)})},u.prototype.ajax=function(a,b){return this.handle("submit",function(c){ajax(u(this).attr("action"),{body:u(this).serialize(),method:u(this).attr("method")},a&&a.bind(this),b&&b.bind(this))})},u.prototype.append=function(a,b){return this.adjacent(a,b,function(a,b){a.appendChild(b)})},u.prototype.args=function(a,b,c){return"function"==typeof a&&(a=a(b,c)),"string"!=typeof a&&(a=this.slice(a).map(this.str(b,c))),a.toString().split(/[\s,]+/).filter(function(a){return a.length})},u.prototype.array=function(a){a=a;var b=this;return this.nodes.reduce(function(c,d,e){var f;return a?(f=a.call(b,d,e),f||(f=!1),"string"==typeof f&&(f=u(f)),f instanceof u&&(f=f.nodes)):f=d.innerHTML,c.concat(f!==!1?f:[])},[])},u.prototype.attr=function(a,b,c){return c=c?"data-":"",this.pairs(a,b,function(a,b){return a.getAttribute(c+b)},function(a,b,d){a.setAttribute(c+b,d)})},u.prototype.before=function(a,b){return this.adjacent(a,b,function(a,b){a.parentNode.insertBefore(b,a)})},u.prototype.children=function(a){return this.map(function(a){return this.slice(a.children)}).filter(a)},u.prototype.clone=function(){return this.map(function(a,b){var c=a.cloneNode(!0),d=this.getAll(c);return this.getAll(a).each(function(a,b){for(var c in this.mirror)this.mirror[c](a,d.nodes[b])}),c})},u.prototype.getAll=function(a){return u([a].concat(u("*",a).nodes))},u.prototype.mirror={},u.prototype.mirror.events=function(a,b){if(a._e)for(var c in a._e)a._e[c].forEach(function(a){u(b).on(c,a)})},u.prototype.mirror.select=function(a,b){u(a).is("select")&&(b.value=a.value)},u.prototype.mirror.textarea=function(a,b){u(a).is("textarea")&&(b.value=a.value)},u.prototype.closest=function(a){return this.map(function(b){do if(u(b).is(a))return b;while((b=b.parentNode)&&b!==document)})},u.prototype.data=function(a,b){return this.attr(a,b,!0)},u.prototype.each=function(a){return this.nodes.forEach(a.bind(this)),this},u.prototype.eacharg=function(a,b){return this.each(function(c,d){this.args(a,c,d).forEach(function(a){b.call(this,c,a)},this)})},u.prototype.empty=function(){return this.each(function(a){for(;a.firstChild;)a.removeChild(a.firstChild)})},u.prototype.filter=function(a){var b=function(b){return b.matches=b.matches||b.msMatchesSelector||b.webkitMatchesSelector,b.matches(a||"*")};return"function"==typeof a&&(b=a),a instanceof u&&(b=function(b){return a.nodes.indexOf(b)!==-1}),u(this.nodes.filter(b))},u.prototype.find=function(a){return this.map(function(b){return u(a||"*",b)})},u.prototype.first=function(){return this.nodes[0]||!1},u.prototype.generate=function(a){return/^\s*<t(h|r|d)/.test(a)?u(document.createElement("table")).html(a).children().nodes:/^\s*</.test(a)?u(document.createElement("div")).html(a).children().nodes:document.createTextNode(a)},u.prototype.handle=function(){var a=this.slice(arguments).map(function(a){return"function"==typeof a?function(b){b.preventDefault(),a.apply(this,arguments)}:a},this);return this.on.apply(this,a)},u.prototype.hasClass=function(){return this.is("."+this.args(arguments).join("."))},u.prototype.html=function(a){return void 0===a?this.first().innerHTML||"":this.each(function(b){b.innerHTML=a})},u.prototype.is=function(a){return this.filter(a).length>0},u.prototype.isInPage=function(a){return a!==document.body&&document.body.contains(a)},u.prototype.last=function(){return this.nodes[this.length-1]||!1},u.prototype.map=function(a){return a?u(this.array(a)).unique():this},u.prototype.not=function(a){return this.filter(function(b){return!u(b).is(a||!0)})},u.prototype.off=function(a){return this.eacharg(a,function(a,b){u(a._e?a._e[b]:[]).each(function(c){a.removeEventListener(b,c)})})},u.prototype.on=function(a,b,c){if("string"==typeof b){var d=b;b=function(a){var b=arguments;u(a.currentTarget).find(d).each(function(d){if(d===a.target||d.contains(a.target)){try{Object.defineProperty(a,"currentTarget",{get:function(){return d}})}catch(e){}c.apply(d,b)}})}}var e=function(a){return b.apply(this,[a].concat(a.detail||[]))};return this.eacharg(a,function(a,b){a.addEventListener(b,e),a._e=a._e||{},a._e[b]=a._e[b]||[],a._e[b].push(e)})},u.prototype.pairs=function(a,b,c,d){if("undefined"!=typeof b){var e=a;a={},a[e]=b}return"object"==typeof a?this.each(function(b){for(var c in a)d(b,c,a[c])}):this.length?c(this.first(),a):""},u.prototype.param=function(a){return Object.keys(a).map(function(b){return this.uri(b)+"="+this.uri(a[b])}.bind(this)).join("&")},u.prototype.parent=function(a){return this.map(function(a){return a.parentNode}).filter(a)},u.prototype.prepend=function(a,b){return this.adjacent(a,b,function(a,b){a.insertBefore(b,a.firstChild)})},u.prototype.remove=function(){return this.each(function(a){a.parentNode&&a.parentNode.removeChild(a)})},u.prototype.removeClass=function(){return this.eacharg(arguments,function(a,b){a.classList.remove(b)})},u.prototype.replace=function(a,b){var c=[];return this.adjacent(a,b,function(a,b){c=c.concat(this.slice(b.children)),a.parentNode.replaceChild(b,a)}),u(c)},u.prototype.scroll=function(){return this.first().scrollIntoView({behavior:"smooth"}),this},u.prototype.select=function(a,b){if(a=a.replace(/^\s*/,"").replace(/\s*$/,""),b)return this.select.byCss(a,b);for(var c in this.selectors)if(b=c.split("/"),new RegExp(b[1],b[2]).test(a))return this.selectors[c](a);return this.select.byCss(a)},u.prototype.select.byCss=function(a,b){return(b||document).querySelectorAll(a)},u.prototype.selectors={},u.prototype.selectors[/^\.[\w\-]+$/]=function(a){return document.getElementsByClassName(a.substring(1))},u.prototype.selectors[/^\w+$/]=function(a){return document.getElementsByTagName(a)},u.prototype.selectors[/^\#[\w\-]+$/]=function(a){return document.getElementById(a.substring(1))},u.prototype.selectors[/^</]=function(a){return u().generate(a)},u.prototype.serialize=function(){var a=this;return this.slice(this.first().elements).reduce(function(b,c){return!c.name||c.disabled||"file"===c.type?b:/(checkbox|radio)/.test(c.type)&&!c.checked?b:"select-multiple"===c.type?(u(c.options).each(function(d){d.selected&&(b+="&"+a.uri(c.name)+"="+a.uri(d.value))}),b):b+"&"+a.uri(c.name)+"="+a.uri(c.value)},"").slice(1)},u.prototype.siblings=function(a){return this.parent().children(a).not(this)},u.prototype.size=function(){return this.first().getBoundingClientRect()},u.prototype.slice=function(a){return a&&0!==a.length&&"string"!=typeof a&&"[object Function]"!==a.toString()?a.length?[].slice.call(a.nodes||a):[a]:[]},u.prototype.str=function(a,b){return function(c){return"function"==typeof c?c.call(this,a,b):c.toString()}},u.prototype.text=function(a){return void 0===a?this.first().textContent||"":this.each(function(b){b.textContent=a})},u.prototype.toggleClass=function(a,b){return!!b===b?this[b?"addClass":"removeClass"](a):this.eacharg(a,function(a,b){a.classList.toggle(b)})},u.prototype.trigger=function(a){var b=this.slice(arguments).slice(1);return this.eacharg(a,function(a,c){var d,e={bubbles:!0,cancelable:!0,detail:b};try{d=new window.CustomEvent(c,e)}catch(f){d=document.createEvent("CustomEvent"),d.initCustomEvent(c,!0,!0,b)}a.dispatchEvent(d)})},u.prototype.unique=function(){return u(this.nodes.reduce(function(a,b){var c=null!==b&&void 0!==b&&b!==!1;return c&&a.indexOf(b)===-1?a.concat(b):a},[]))},u.prototype.uri=function(a){return encodeURIComponent(a).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")},u.prototype.wrap=function(a){function b(a){for(;a.firstElementChild;)a=a.firstElementChild;return u(a)}return this.map(function(c){return u(a).each(function(a){b(a).append(c.cloneNode(!0)),c.parentNode.replaceChild(a,c)})})},"object"==typeof module&&module.exports&&(module.exports={u:u,ajax:ajax});
/* Umbrella JS 2.10.2 umbrellajs.com */
function ajax(a,b,c,d){c=c||function(){},b=b||{},b.body=b.body||{},b.method=(b.method||"GET").toUpperCase(),b.headers=b.headers||{},b.headers["X-Requested-With"]=b.headers["X-Requested-With"]||"XMLHttpRequest","undefined"!=typeof window.FormData&&b.body instanceof window.FormData||(b.headers["Content-Type"]=b.headers["Content-Type"]||"application/x-www-form-urlencoded"),/json/.test(b.headers["Content-Type"])&&(b.body=JSON.stringify(b.body)),"object"!=typeof b.body||b.body instanceof window.FormData||(b.body=u().param(b.body));var e=new window.XMLHttpRequest;u(e).on("error timeout abort",function(){c(new Error,null,e)}).on("load",function(){var a=/^(4|5)/.test(e.status)?new Error(e.status):null,b=parseJson(e.response)||e.response;return c(a,b,e)}),e.open(b.method,a),e.withCredentials=!0;for(var f in b.headers)e.setRequestHeader(f,b.headers[f]);return d&&d(e),e.send(b.body),e}function parseJson(a){try{var b=JSON.parse(a);if(b&&"object"==typeof b)return b}catch(c){}return!1}var u=function(a,b){return this instanceof u?a instanceof u?a:("string"==typeof a&&(a=this.select(a,b)),a&&a.nodeName&&(a=[a]),void(this.nodes=this.slice(a))):new u(a,b)};u.prototype={get length(){return this.nodes.length}},u.prototype.nodes=[],u.prototype.addClass=function(){return this.eacharg(arguments,function(a,b){a.classList.add(b)})},u.prototype.adjacent=function(a,b,c){return"number"==typeof b&&(b=0===b?[]:new Array(b).join().split(",").map(Number.call,Number)),this.each(function(d,e){var f=document.createDocumentFragment();u(b||{}).map(function(b,c){var f="function"==typeof a?a.call(this,b,c,d,e):a;return"string"==typeof f?this.generate(f):u(f)}).each(function(a){this.isInPage(a)?f.appendChild(u(a).clone().first()):f.appendChild(a)}),c.call(this,d,f)})},u.prototype.after=function(a,b){return this.adjacent(a,b,function(a,b){a.parentNode.insertBefore(b,a.nextSibling)})},u.prototype.ajax=function(a,b){return this.handle("submit",function(c){ajax(u(this).attr("action"),{body:u(this).serialize(),method:u(this).attr("method")},a&&a.bind(this),b&&b.bind(this))})},u.prototype.append=function(a,b){return this.adjacent(a,b,function(a,b){a.appendChild(b)})},u.prototype.args=function(a,b,c){return"function"==typeof a&&(a=a(b,c)),"string"!=typeof a&&(a=this.slice(a).map(this.str(b,c))),a.toString().split(/[\s,]+/).filter(function(a){return a.length})},u.prototype.array=function(a){a=a;var b=this;return this.nodes.reduce(function(c,d,e){var f;return a?(f=a.call(b,d,e),f||(f=!1),"string"==typeof f&&(f=u(f)),f instanceof u&&(f=f.nodes)):f=d.innerHTML,c.concat(f!==!1?f:[])},[])},u.prototype.attr=function(a,b,c){return c=c?"data-":"",this.pairs(a,b,function(a,b){return a.getAttribute(c+b)},function(a,b,d){a.setAttribute(c+b,d)})},u.prototype.before=function(a,b){return this.adjacent(a,b,function(a,b){a.parentNode.insertBefore(b,a)})},u.prototype.children=function(a){return this.map(function(a){return this.slice(a.children)}).filter(a)},u.prototype.clone=function(){return this.map(function(a,b){var c=a.cloneNode(!0),d=this.getAll(c);return this.getAll(a).each(function(a,b){for(var c in this.mirror)this.mirror[c](a,d.nodes[b])}),c})},u.prototype.getAll=function(a){return u([a].concat(u("*",a).nodes))},u.prototype.mirror={},u.prototype.mirror.events=function(a,b){if(a._e)for(var c in a._e)a._e[c].forEach(function(a){u(b).on(c,a)})},u.prototype.mirror.select=function(a,b){u(a).is("select")&&(b.value=a.value)},u.prototype.mirror.textarea=function(a,b){u(a).is("textarea")&&(b.value=a.value)},u.prototype.closest=function(a){return this.map(function(b){do if(u(b).is(a))return b;while((b=b.parentNode)&&b!==document)})},u.prototype.data=function(a,b){return this.attr(a,b,!0)},u.prototype.each=function(a){return this.nodes.forEach(a.bind(this)),this},u.prototype.eacharg=function(a,b){return this.each(function(c,d){this.args(a,c,d).forEach(function(a){b.call(this,c,a)},this)})},u.prototype.empty=function(){return this.each(function(a){for(;a.firstChild;)a.removeChild(a.firstChild)})},u.prototype.filter=function(a){var b=function(b){return b.matches=b.matches||b.msMatchesSelector||b.webkitMatchesSelector,b.matches(a||"*")};return"function"==typeof a&&(b=a),a instanceof u&&(b=function(b){return a.nodes.indexOf(b)!==-1}),u(this.nodes.filter(b))},u.prototype.find=function(a){return this.map(function(b){return u(a||"*",b)})},u.prototype.first=function(){return this.nodes[0]||!1},u.prototype.generate=function(a){if(/^\s*<t(h|r|d)/.test(a)){var b=document.createElement("table");return u(b).html(a).children().children().nodes}return/^\s*</.test(a)?u(document.createElement("div")).html(a).children().nodes:document.createTextNode(a)},u.prototype.handle=function(){var a=this.slice(arguments).map(function(a){return"function"==typeof a?function(b){b.preventDefault(),a.apply(this,arguments)}:a},this);return this.on.apply(this,a)},u.prototype.hasClass=function(){return this.is("."+this.args(arguments).join("."))},u.prototype.html=function(a){return void 0===a?this.first().innerHTML||"":this.each(function(b){b.innerHTML=a})},u.prototype.is=function(a){return this.filter(a).length>0},u.prototype.isInPage=function(a){return a!==document.body&&document.body.contains(a)},u.prototype.last=function(){return this.nodes[this.length-1]||!1},u.prototype.map=function(a){return a?u(this.array(a)).unique():this},u.prototype.not=function(a){return this.filter(function(b){return!u(b).is(a||!0)})},u.prototype.off=function(a){return this.eacharg(a,function(a,b){u(a._e?a._e[b]:[]).each(function(c){a.removeEventListener(b,c)})})},u.prototype.on=function(a,b,c){if("string"==typeof b){var d=b;b=function(a){var b=arguments;u(a.currentTarget).find(d).each(function(d){if(d===a.target||d.contains(a.target)){try{Object.defineProperty(a,"currentTarget",{get:function(){return d}})}catch(e){}c.apply(d,b)}})}}var e=function(a){return b.apply(this,[a].concat(a.detail||[]))};return this.eacharg(a,function(a,b){a.addEventListener(b,e),a._e=a._e||{},a._e[b]=a._e[b]||[],a._e[b].push(e)})},u.prototype.pairs=function(a,b,c,d){if("undefined"!=typeof b){var e=a;a={},a[e]=b}return"object"==typeof a?this.each(function(b){for(var c in a)d(b,c,a[c])}):this.length?c(this.first(),a):""},u.prototype.param=function(a){return Object.keys(a).map(function(b){return this.uri(b)+"="+this.uri(a[b])}.bind(this)).join("&")},u.prototype.parent=function(a){return this.map(function(a){return a.parentNode}).filter(a)},u.prototype.prepend=function(a,b){return this.adjacent(a,b,function(a,b){a.insertBefore(b,a.firstChild)})},u.prototype.remove=function(){return this.each(function(a){a.parentNode&&a.parentNode.removeChild(a)})},u.prototype.removeClass=function(){return this.eacharg(arguments,function(a,b){a.classList.remove(b)})},u.prototype.replace=function(a,b){var c=[];return this.adjacent(a,b,function(a,b){c=c.concat(this.slice(b.children)),a.parentNode.replaceChild(b,a)}),u(c)},u.prototype.scroll=function(){return this.first().scrollIntoView({behavior:"smooth"}),this},u.prototype.select=function(a,b){if(a=a.replace(/^\s*/,"").replace(/\s*$/,""),b)return this.select.byCss(a,b);for(var c in this.selectors)if(b=c.split("/"),new RegExp(b[1],b[2]).test(a))return this.selectors[c](a);return this.select.byCss(a)},u.prototype.select.byCss=function(a,b){return(b||document).querySelectorAll(a)},u.prototype.selectors={},u.prototype.selectors[/^\.[\w\-]+$/]=function(a){return document.getElementsByClassName(a.substring(1))},u.prototype.selectors[/^\w+$/]=function(a){return document.getElementsByTagName(a)},u.prototype.selectors[/^\#[\w\-]+$/]=function(a){return document.getElementById(a.substring(1))},u.prototype.selectors[/^</]=function(a){return u().generate(a)},u.prototype.serialize=function(){var a=this;return this.slice(this.first().elements).reduce(function(b,c){return!c.name||c.disabled||"file"===c.type?b:/(checkbox|radio)/.test(c.type)&&!c.checked?b:"select-multiple"===c.type?(u(c.options).each(function(d){d.selected&&(b+="&"+a.uri(c.name)+"="+a.uri(d.value))}),b):b+"&"+a.uri(c.name)+"="+a.uri(c.value)},"").slice(1)},u.prototype.siblings=function(a){return this.parent().children(a).not(this)},u.prototype.size=function(){return this.first().getBoundingClientRect()},u.prototype.slice=function(a){return a&&0!==a.length&&"string"!=typeof a&&"[object Function]"!==a.toString()?a.length?[].slice.call(a.nodes||a):[a]:[]},u.prototype.str=function(a,b){return function(c){return"function"==typeof c?c.call(this,a,b):c.toString()}},u.prototype.text=function(a){return void 0===a?this.first().textContent||"":this.each(function(b){b.textContent=a})},u.prototype.toggleClass=function(a,b){return!!b===b?this[b?"addClass":"removeClass"](a):this.eacharg(a,function(a,b){a.classList.toggle(b)})},u.prototype.trigger=function(a){var b=this.slice(arguments).slice(1);return this.eacharg(a,function(a,c){var d,e={bubbles:!0,cancelable:!0,detail:b};try{d=new window.CustomEvent(c,e)}catch(f){d=document.createEvent("CustomEvent"),d.initCustomEvent(c,!0,!0,b)}a.dispatchEvent(d)})},u.prototype.unique=function(){return u(this.nodes.reduce(function(a,b){var c=null!==b&&void 0!==b&&b!==!1;return c&&a.indexOf(b)===-1?a.concat(b):a},[]))},u.prototype.uri=function(a){return encodeURIComponent(a).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")},u.prototype.wrap=function(a){function b(a){for(;a.firstElementChild;)a=a.firstElementChild;return u(a)}return this.map(function(c){return u(a).each(function(a){b(a).append(c.cloneNode(!0)),c.parentNode.replaceChild(a,c)})})},"object"==typeof module&&module.exports&&(module.exports={u:u,ajax:ajax});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc