New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zepto-browserify

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zepto-browserify - npm Package Compare versions

Comparing version 1.0.0 to 1.1.3-0

2

package.json
{
"name": "zepto-browserify",
"version": "1.0.0",
"version": "1.1.3-0",
"description": "Shim repository for the Zepto.js JavaScript library for Browserify",

@@ -5,0 +5,0 @@ "main": "zepto.js",

Zepto-browserify
`zepto-browserify`
------

@@ -7,2 +7,10 @@

Version of Zepto in this repo is `1.1.3`, while I use `1.1.3-x` in module.
Goto Zepto's home page for docs: http://zeptojs.com/
Read more about it in official repo: https://github.com/madrobby/zepto
### Usage
```

@@ -15,29 +23,16 @@ npm install --save zepto-browserify

Zepto = require('zepto-browserify').Zepto
$ === Zepto // true
$ === Zepto // => true
```
How I made this:
### Differece from Zepto
How I modified this based on code of `1.1.3`:
```js
window.Zepto = Zepto
window.$ === undefined && (window.$ = Zepto)
```
git rm *json zepto.min.js Makefile
npm init
subl zepto.js
subl README.md
git diff zepto.js
```
```diff
-
-window.Zepto = Zepto
-'$' in window || (window.$ = Zepto)
-
-
-
+// @@ original loader
+// window.Zepto = Zepto
+// '$' in window || (window.$ = Zepto)
+// @@ modified by jiyinyiyong
+module.exports.$ = Zepto;
+module.exports.Zepto = Zepto;
+// @@ modifications end
```js
exports.$ = exports.Zepto = Zepto;
```

@@ -1,40 +0,4 @@

/* Zepto v1.0 - polyfill zepto detect event ajax form fx - zeptojs.com/license */
/* Zepto v1.1.3 - zepto event ajax form ie - zeptojs.com/license */
;(function(undefined){
if (String.prototype.trim === undefined) // fix for iOS 3.2
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g, '') }
// For iOS 3.x
// from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduce
if (Array.prototype.reduce === undefined)
Array.prototype.reduce = function(fun){
if(this === void 0 || this === null) throw new TypeError()
var t = Object(this), len = t.length >>> 0, k = 0, accumulator
if(typeof fun != 'function') throw new TypeError()
if(len == 0 && arguments.length == 1) throw new TypeError()
if(arguments.length >= 2)
accumulator = arguments[1]
else
do{
if(k in t){
accumulator = t[k++]
break
}
if(++k >= len) throw new TypeError()
} while (true)
while (k < len){
if(k in t) accumulator = fun.call(undefined, accumulator, t[k], k, t)
k++
}
return accumulator
}
})()
var Zepto = (function() {

@@ -44,7 +8,8 @@ var undefined, key, $, classList, emptyArray = [], slice = emptyArray.slice, filter = emptyArray.filter,

elementDisplay = {}, classCache = {},
getComputedStyle = document.defaultView.getComputedStyle,
cssNumber = { 'column-count': 1, 'columns': 1, 'font-weight': 1, 'line-height': 1,'opacity': 1, 'z-index': 1, 'zoom': 1 },
fragmentRE = /^\s*<(\w+|!)[^>]*>/,
singleTagRE = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
tagExpanderRE = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
rootNodeRE = /^(?:body|html)$/i,
capitalRE = /([A-Z])/g,

@@ -64,5 +29,3 @@ // special attributes that should be get/set via method calls

readyRE = /complete|loaded|interactive/,
classSelectorRE = /^\.([\w-]+)$/,
idSelectorRE = /^#([\w-]*)$/,
tagSelectorRE = /^[\w-]+$/,
simpleSelectorRE = /^[\w-]*$/,
class2type = {},

@@ -72,6 +35,22 @@ toString = class2type.toString,

camelize, uniq,
tempParent = document.createElement('div')
tempParent = document.createElement('div'),
propMap = {
'tabindex': 'tabIndex',
'readonly': 'readOnly',
'for': 'htmlFor',
'class': 'className',
'maxlength': 'maxLength',
'cellspacing': 'cellSpacing',
'cellpadding': 'cellPadding',
'rowspan': 'rowSpan',
'colspan': 'colSpan',
'usemap': 'useMap',
'frameborder': 'frameBorder',
'contenteditable': 'contentEditable'
},
isArray = Array.isArray ||
function(object){ return object instanceof Array }
zepto.matches = function(element, selector) {
if (!element || element.nodeType !== 1) return false
if (!selector || !element || element.nodeType !== 1) return false
var matchesSelector = element.webkitMatchesSelector || element.mozMatchesSelector ||

@@ -98,5 +77,4 @@ element.oMatchesSelector || element.matchesSelector

function isPlainObject(obj) {
return isObject(obj) && !isWindow(obj) && obj.__proto__ == Object.prototype
return isObject(obj) && !isWindow(obj) && Object.getPrototypeOf(obj) == Object.prototype
}
function isArray(value) { return value instanceof Array }
function likeArray(obj) { return typeof obj.length == 'number' }

@@ -150,11 +128,19 @@

zepto.fragment = function(html, name, properties) {
if (html.replace) html = html.replace(tagExpanderRE, "<$1></$2>")
if (name === undefined) name = fragmentRE.test(html) && RegExp.$1
if (!(name in containers)) name = '*'
var dom, nodes, container
var nodes, dom, container = containers[name]
container.innerHTML = '' + html
dom = $.each(slice.call(container.childNodes), function(){
container.removeChild(this)
})
// A special case optimization for a single tag
if (singleTagRE.test(html)) dom = $(document.createElement(RegExp.$1))
if (!dom) {
if (html.replace) html = html.replace(tagExpanderRE, "<$1></$2>")
if (name === undefined) name = fragmentRE.test(html) && RegExp.$1
if (!(name in containers)) name = '*'
container = containers[name]
container.innerHTML = '' + html
dom = $.each(slice.call(container.childNodes), function(){
container.removeChild(this)
})
}
if (isPlainObject(properties)) {

@@ -167,2 +153,3 @@ nodes = $(dom)

}
return dom

@@ -193,15 +180,29 @@ }

zepto.init = function(selector, context) {
var dom
// If nothing given, return an empty Zepto collection
if (!selector) return zepto.Z()
// Optimize for string selectors
else if (typeof selector == 'string') {
selector = selector.trim()
// If it's a html fragment, create nodes from it
// Note: In both Chrome 21 and Firefox 15, DOM error 12
// is thrown if the fragment doesn't begin with <
if (selector[0] == '<' && fragmentRE.test(selector))
dom = zepto.fragment(selector, RegExp.$1, context), selector = null
// If there's a context, create a collection on that context first, and select
// nodes from there
else if (context !== undefined) return $(context).find(selector)
// If it's a CSS selector, use it to select nodes.
else dom = zepto.qsa(document, selector)
}
// If a function is given, call it when the DOM is ready
else if (isFunction(selector)) return $(document).ready(selector)
// If a Zepto collection is given, juts return it
// If a Zepto collection is given, just return it
else if (zepto.isZ(selector)) return selector
else {
var dom
// normalize array if an array of nodes is given
if (isArray(selector)) dom = compact(selector)
// Wrap DOM nodes. If a plain object is given, duplicate it.
// Wrap DOM nodes.
else if (isObject(selector))
dom = [isPlainObject(selector) ? $.extend({}, selector) : selector], selector = null
dom = [selector], selector = null
// If it's a html fragment, create nodes from it

@@ -215,5 +216,5 @@ else if (fragmentRE.test(selector))

else dom = zepto.qsa(document, selector)
// create a new Zepto collection from the nodes found
return zepto.Z(dom, selector)
}
// create a new Zepto collection from the nodes found
return zepto.Z(dom, selector)
}

@@ -257,10 +258,15 @@

zepto.qsa = function(element, selector){
var found
return (isDocument(element) && idSelectorRE.test(selector)) ?
( (found = element.getElementById(RegExp.$1)) ? [found] : [] ) :
var found,
maybeID = selector[0] == '#',
maybeClass = !maybeID && selector[0] == '.',
nameOnly = maybeID || maybeClass ? selector.slice(1) : selector, // Ensure that a 1 char tag name still gets checked
isSimple = simpleSelectorRE.test(nameOnly)
return (isDocument(element) && isSimple && maybeID) ?
( (found = element.getElementById(nameOnly)) ? [found] : [] ) :
(element.nodeType !== 1 && element.nodeType !== 9) ? [] :
slice.call(
classSelectorRE.test(selector) ? element.getElementsByClassName(RegExp.$1) :
tagSelectorRE.test(selector) ? element.getElementsByTagName(selector) :
element.querySelectorAll(selector)
isSimple && !maybeID ?
maybeClass ? element.getElementsByClassName(nameOnly) : // If it's simple, it could be a class
element.getElementsByTagName(selector) : // Or a tag
element.querySelectorAll(selector) // Or it's not simple, and we need to query all
)

@@ -270,3 +276,3 @@ }

function filtered(nodes, selector) {
return selector === undefined ? $(nodes) : $(nodes).filter(selector)
return selector == null ? $(nodes) : $(nodes).filter(selector)
}

@@ -300,2 +306,3 @@

// "42.5" => 42.5
// "08" => "08"
// JSON => parse if valid

@@ -310,3 +317,3 @@ // String => self

value == "null" ? null :
!isNaN(num = Number(value)) ? num :
!/^0/.test(value) && !isNaN(num = Number(value)) ? num :
/^[\[\{]/.test(value) ? $.parseJSON(value) :

@@ -337,3 +344,5 @@ value )

$.camelCase = camelize
$.trim = function(str) { return str.trim() }
$.trim = function(str) {
return str == null ? "" : String.prototype.trim.call(str)
}

@@ -406,3 +415,5 @@ // plugin compatibility

ready: function(callback){
if (readyRE.test(document.readyState)) callback($)
// need to check if document.body exists for IE as that browser reports
// document ready when it hasn't yet created the body element
if (readyRE.test(document.readyState) && document.body) callback($)
else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false)

@@ -529,3 +540,3 @@ return this

return this.each(function(){
this.style.display == "none" && (this.style.display = null)
this.style.display == "none" && (this.style.display = '')
if (getComputedStyle(this, '').getPropertyValue("display") == "none")

@@ -590,3 +601,3 @@ this.style.display = defaultDisplay(this.nodeName)

html: function(html){
return html === undefined ?
return arguments.length === 0 ?
(this.length > 0 ? this[0].innerHTML : null) :

@@ -599,5 +610,5 @@ this.each(function(idx){

text: function(text){
return text === undefined ?
return arguments.length === 0 ?
(this.length > 0 ? this[0].textContent : null) :
this.each(function(){ this.textContent = text })
this.each(function(){ this.textContent = (text === undefined) ? '' : ''+text })
},

@@ -621,2 +632,3 @@ attr: function(name, value){

prop: function(name, value){
name = propMap[name] || name
return (value === undefined) ?

@@ -629,9 +641,9 @@ (this[0] && this[0][name]) :

data: function(name, value){
var data = this.attr('data-' + dasherize(name), value)
var data = this.attr('data-' + name.replace(capitalRE, '-$1').toLowerCase(), value)
return data !== null ? deserializeValue(data) : undefined
},
val: function(value){
return (value === undefined) ?
return arguments.length === 0 ?
(this[0] && (this[0].multiple ?
$(this[0]).find('option').filter(function(o){ return this.selected }).pluck('value') :
$(this[0]).find('option').filter(function(){ return this.selected }).pluck('value') :
this[0].value)

@@ -666,4 +678,15 @@ ) :

css: function(property, value){
if (arguments.length < 2 && typeof property == 'string')
return this[0] && (this[0].style[camelize(property)] || getComputedStyle(this[0], '').getPropertyValue(property))
if (arguments.length < 2) {
var element = this[0], computedStyle = getComputedStyle(element, '')
if(!element) return
if (typeof property == 'string')
return element.style[camelize(property)] || computedStyle.getPropertyValue(property)
else if (isArray(property)) {
var props = {}
$.each(isArray(property) ? property: [property], function(_, prop){
props[prop] = (element.style[camelize(prop)] || computedStyle.getPropertyValue(prop))
})
return props
}
}

@@ -690,2 +713,3 @@ var css = ''

hasClass: function(name){
if (!name) return false
return emptyArray.some.call(this, function(el){

@@ -696,2 +720,3 @@ return this.test(className(el))

addClass: function(name){
if (!name) return this
return this.each(function(idx){

@@ -717,2 +742,3 @@ classList = []

toggleClass: function(name, when){
if (!name) return this
return this.each(function(idx){

@@ -726,6 +752,18 @@ var $this = $(this), names = funcArg(this, name, idx, className(this))

},
scrollTop: function(){
scrollTop: function(value){
if (!this.length) return
return ('scrollTop' in this[0]) ? this[0].scrollTop : this[0].scrollY
var hasScrollTop = 'scrollTop' in this[0]
if (value === undefined) return hasScrollTop ? this[0].scrollTop : this[0].pageYOffset
return this.each(hasScrollTop ?
function(){ this.scrollTop = value } :
function(){ this.scrollTo(this.scrollX, value) })
},
scrollLeft: function(value){
if (!this.length) return
var hasScrollLeft = 'scrollLeft' in this[0]
if (value === undefined) return hasScrollLeft ? this[0].scrollLeft : this[0].pageXOffset
return this.each(hasScrollLeft ?
function(){ this.scrollLeft = value } :
function(){ this.scrollTo(value, this.scrollY) })
},
position: function() {

@@ -772,7 +810,9 @@ if (!this.length) return

;['width', 'height'].forEach(function(dimension){
var dimensionProperty =
dimension.replace(/./, function(m){ return m[0].toUpperCase() })
$.fn[dimension] = function(value){
var offset, el = this[0],
Dimension = dimension.replace(/./, function(m){ return m[0].toUpperCase() })
if (value === undefined) return isWindow(el) ? el['inner' + Dimension] :
isDocument(el) ? el.documentElement['offset' + Dimension] :
var offset, el = this[0]
if (value === undefined) return isWindow(el) ? el['inner' + dimensionProperty] :
isDocument(el) ? el.documentElement['scroll' + dimensionProperty] :
(offset = this.offset()) && offset[dimension]

@@ -848,69 +888,13 @@ else return this.each(function(idx){

// @@ original loader
// window.Zepto = Zepto
// '$' in window || (window.$ = Zepto)
// @@ modified by jiyinyiyong
module.exports.$ = Zepto;
module.exports.Zepto = Zepto;
// @@ modifications end
exports.$ = exports.Zepto = Zepto;
;(function($){
function detect(ua){
var os = this.os = {}, browser = this.browser = {},
webkit = ua.match(/WebKit\/([\d.]+)/),
android = ua.match(/(Android)\s+([\d.]+)/),
ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),
webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),
touchpad = webos && ua.match(/TouchPad/),
kindle = ua.match(/Kindle\/([\d.]+)/),
silk = ua.match(/Silk\/([\d._]+)/),
blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/),
bb10 = ua.match(/(BB10).*Version\/([\d.]+)/),
rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/),
playbook = ua.match(/PlayBook/),
chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/),
firefox = ua.match(/Firefox\/([\d.]+)/)
// Todo: clean this up with a better OS/browser seperation:
// - discern (more) between multiple browsers on android
// - decide if kindle fire in silk mode is android or not
// - Firefox on Android doesn't specify the Android version
// - possibly devide in os, device and browser hashes
if (browser.webkit = !!webkit) browser.version = webkit[1]
if (android) os.android = true, os.version = android[2]
if (iphone) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.')
if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.')
if (webos) os.webos = true, os.version = webos[2]
if (touchpad) os.touchpad = true
if (blackberry) os.blackberry = true, os.version = blackberry[2]
if (bb10) os.bb10 = true, os.version = bb10[2]
if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2]
if (playbook) browser.playbook = true
if (kindle) os.kindle = true, os.version = kindle[1]
if (silk) browser.silk = true, browser.version = silk[1]
if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true
if (chrome) browser.chrome = true, browser.version = chrome[1]
if (firefox) browser.firefox = true, browser.version = firefox[1]
os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) || (firefox && ua.match(/Tablet/)))
os.phone = !!(!os.tablet && (android || iphone || webos || blackberry || bb10 ||
(chrome && ua.match(/Android/)) || (chrome && ua.match(/CriOS\/([\d.]+)/)) || (firefox && ua.match(/Mobile/))))
}
detect.call($, navigator.userAgent)
// make available to unit tests
$.__detect = detect
})(Zepto)
;(function($){
var $$ = $.zepto.qsa, handlers = {}, _zid = 1, specialEvents={},
var _zid = 1, undefined,
slice = Array.prototype.slice,
isFunction = $.isFunction,
isString = function(obj){ return typeof obj == 'string' },
handlers = {},
specialEvents={},
focusinSupported = 'onfocusin' in window,
focus = { focus: 'focusin', blur: 'focusout' },
hover = { mouseenter: 'mouseover', mouseleave: 'mouseout' }

@@ -942,10 +926,5 @@

function eachEvent(events, fn, iterator){
if ($.type(events) != "string") $.each(events, iterator)
else events.split(/\s/).forEach(function(type){ iterator(type, fn) })
}
function eventCapture(handler, captureSetting) {
return handler.del &&
(handler.e == 'focus' || handler.e == 'blur') ||
(!focusinSupported && (handler.e in focus)) ||
!!captureSetting

@@ -955,8 +934,9 @@ }

function realEvent(type) {
return hover[type] || type
return hover[type] || (focusinSupported && focus[type]) || type
}
function add(element, events, fn, selector, getDelegate, capture){
function add(element, events, fn, data, selector, delegator, capture){
var id = zid(element), set = (handlers[id] || (handlers[id] = []))
eachEvent(events, fn, function(event, fn){
events.split(/\s/).forEach(function(event){
if (event == 'ready') return $(document).ready(fn)
var handler = parse(event)

@@ -971,6 +951,9 @@ handler.fn = fn

}
handler.del = getDelegate && getDelegate(fn, event)
var callback = handler.del || fn
handler.proxy = function (e) {
var result = callback.apply(element, [e].concat(e.data))
handler.del = delegator
var callback = delegator || fn
handler.proxy = function(e){
e = compatible(e)
if (e.isImmediatePropagationStopped()) return
e.data = data
var result = callback.apply(element, e._args == undefined ? [e] : [e].concat(e._args))
if (result === false) e.preventDefault(), e.stopPropagation()

@@ -981,3 +964,4 @@ return result

set.push(handler)
element.addEventListener(realEvent(handler.e), handler.proxy, eventCapture(handler, capture))
if ('addEventListener' in element)
element.addEventListener(realEvent(handler.e), handler.proxy, eventCapture(handler, capture))
})

@@ -987,5 +971,6 @@ }

var id = zid(element)
eachEvent(events || '', fn, function(event, fn){
;(events || '').split(/\s/).forEach(function(event){
findHandlers(element, event, fn, selector).forEach(function(handler){
delete handlers[id][handler.i]
if ('removeEventListener' in element)
element.removeEventListener(realEvent(handler.e), handler.proxy, eventCapture(handler, capture))

@@ -999,7 +984,7 @@ })

$.proxy = function(fn, context) {
if ($.isFunction(fn)) {
if (isFunction(fn)) {
var proxyFn = function(){ return fn.apply(context, arguments) }
proxyFn._zid = zid(fn)
return proxyFn
} else if (typeof context == 'string') {
} else if (isString(context)) {
return $.proxy(fn[context], fn)

@@ -1011,22 +996,10 @@ } else {

$.fn.bind = function(event, callback){
return this.each(function(){
add(this, event, callback)
})
$.fn.bind = function(event, data, callback){
return this.on(event, data, callback)
}
$.fn.unbind = function(event, callback){
return this.each(function(){
remove(this, event, callback)
})
return this.off(event, callback)
}
$.fn.one = function(event, callback){
return this.each(function(i, element){
add(this, event, callback, null, function(fn, type){
return function(){
var result = fn.apply(element, arguments)
remove(element, type, fn)
return result
}
})
})
$.fn.one = function(event, selector, data, callback){
return this.on(event, selector, data, callback, 1)
}

@@ -1036,3 +1009,3 @@

returnFalse = function(){return false},
ignoreProperties = /^([A-Z]|layer[XY]$)/,
ignoreProperties = /^([A-Z]|returnValue$|layer[XY]$)/,
eventMethods = {

@@ -1043,2 +1016,24 @@ preventDefault: 'isDefaultPrevented',

}
function compatible(event, source) {
if (source || !event.isDefaultPrevented) {
source || (source = event)
$.each(eventMethods, function(name, predicate) {
var sourceMethod = source[name]
event[name] = function(){
this[predicate] = returnTrue
return sourceMethod && sourceMethod.apply(source, arguments)
}
event[predicate] = returnFalse
})
if (source.defaultPrevented !== undefined ? source.defaultPrevented :
'returnValue' in source ? source.returnValue === false :
source.getPreventDefault && source.getPreventDefault())
event.isDefaultPrevented = returnTrue
}
return event
}
function createProxy(event) {

@@ -1049,41 +1044,10 @@ var key, proxy = { originalEvent: event }

$.each(eventMethods, function(name, predicate) {
proxy[name] = function(){
this[predicate] = returnTrue
return event[name].apply(event, arguments)
}
proxy[predicate] = returnFalse
})
return proxy
return compatible(proxy, event)
}
// emulates the 'defaultPrevented' property for browsers that have none
function fix(event) {
if (!('defaultPrevented' in event)) {
event.defaultPrevented = false
var prevent = event.preventDefault
event.preventDefault = function() {
this.defaultPrevented = true
prevent.call(this)
}
}
}
$.fn.delegate = function(selector, event, callback){
return this.each(function(i, element){
add(element, event, callback, selector, function(fn){
return function(e){
var evt, match = $(e.target).closest(selector, element).get(0)
if (match) {
evt = $.extend(createProxy(e), {currentTarget: match, liveFired: element})
return fn.apply(match, [evt].concat([].slice.call(arguments, 1)))
}
}
})
})
return this.on(event, selector, callback)
}
$.fn.undelegate = function(selector, event, callback){
return this.each(function(){
remove(this, event, callback, selector)
})
return this.off(event, selector, callback)
}

@@ -1100,19 +1064,61 @@

$.fn.on = function(event, selector, callback){
return !selector || $.isFunction(selector) ?
this.bind(event, selector || callback) : this.delegate(selector, event, callback)
$.fn.on = function(event, selector, data, callback, one){
var autoRemove, delegator, $this = this
if (event && !isString(event)) {
$.each(event, function(type, fn){
$this.on(type, selector, data, fn, one)
})
return $this
}
if (!isString(selector) && !isFunction(callback) && callback !== false)
callback = data, data = selector, selector = undefined
if (isFunction(data) || data === false)
callback = data, data = undefined
if (callback === false) callback = returnFalse
return $this.each(function(_, element){
if (one) autoRemove = function(e){
remove(element, e.type, callback)
return callback.apply(this, arguments)
}
if (selector) delegator = function(e){
var evt, match = $(e.target).closest(selector, element).get(0)
if (match && match !== element) {
evt = $.extend(createProxy(e), {currentTarget: match, liveFired: element})
return (autoRemove || callback).apply(match, [evt].concat(slice.call(arguments, 1)))
}
}
add(element, event, callback, data, selector, delegator || autoRemove)
})
}
$.fn.off = function(event, selector, callback){
return !selector || $.isFunction(selector) ?
this.unbind(event, selector || callback) : this.undelegate(selector, event, callback)
var $this = this
if (event && !isString(event)) {
$.each(event, function(type, fn){
$this.off(type, selector, fn)
})
return $this
}
if (!isString(selector) && !isFunction(callback) && callback !== false)
callback = selector, selector = undefined
if (callback === false) callback = returnFalse
return $this.each(function(){
remove(this, event, callback, selector)
})
}
$.fn.trigger = function(event, data){
if (typeof event == 'string' || $.isPlainObject(event)) event = $.Event(event)
fix(event)
event.data = data
$.fn.trigger = function(event, args){
event = (isString(event) || $.isPlainObject(event)) ? $.Event(event) : compatible(event)
event._args = args
return this.each(function(){
// items in the collection might not be DOM elements
// (todo: possibly support events on plain old objects)
if('dispatchEvent' in this) this.dispatchEvent(event)
else $(this).triggerHandler(event, args)
})

@@ -1123,7 +1129,7 @@ }

// doesn't trigger an actual event, doesn't bubble
$.fn.triggerHandler = function(event, data){
$.fn.triggerHandler = function(event, args){
var e, result
this.each(function(i, element){
e = createProxy(typeof event == 'string' ? $.Event(event) : event)
e.data = data
e = createProxy(isString(event) ? $.Event(event) : event)
e._args = args
e.target = element

@@ -1161,8 +1167,7 @@ $.each(findHandlers(element, event.type || event), function(i, handler){

$.Event = function(type, props) {
if (typeof type != 'string') props = type, type = props.type
if (!isString(type)) props = type, type = props.type
var event = document.createEvent(specialEvents[type] || 'Events'), bubbles = true
if (props) for (var name in props) (name == 'bubbles') ? (bubbles = !!props[name]) : (event[name] = props[name])
event.initEvent(type, bubbles, true, null, null, null, null, null, null, null, null, null, null, null, null)
event.isDefaultPrevented = function(){ return this.defaultPrevented }
return event
event.initEvent(type, bubbles, true)
return compatible(event)
}

@@ -1172,6 +1177,2 @@

;(function($){

@@ -1193,3 +1194,3 @@ var jsonpID = 0,

$(context).trigger(event, data)
return !event.defaultPrevented
return !event.isDefaultPrevented()
}

@@ -1221,5 +1222,6 @@

}
function ajaxSuccess(data, xhr, settings) {
function ajaxSuccess(data, xhr, settings, deferred) {
var context = settings.context, status = 'success'
settings.success.call(context, data, status, xhr)
if (deferred) deferred.resolveWith(context, [data, status, xhr])
triggerGlobal(settings, context, 'ajaxSuccess', [xhr, settings, data])

@@ -1229,6 +1231,7 @@ ajaxComplete(status, xhr, settings)

// type: "timeout", "error", "abort", "parsererror"
function ajaxError(error, type, xhr, settings) {
function ajaxError(error, type, xhr, settings, deferred) {
var context = settings.context
settings.error.call(context, xhr, type, error)
triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error])
if (deferred) deferred.rejectWith(context, [xhr, type, error])
triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error || type])
ajaxComplete(type, xhr, settings)

@@ -1247,36 +1250,47 @@ }

$.ajaxJSONP = function(options){
$.ajaxJSONP = function(options, deferred){
if (!('type' in options)) return $.ajax(options)
var callbackName = 'jsonp' + (++jsonpID),
var _callbackName = options.jsonpCallback,
callbackName = ($.isFunction(_callbackName) ?
_callbackName() : _callbackName) || ('jsonp' + (++jsonpID)),
script = document.createElement('script'),
cleanup = function() {
clearTimeout(abortTimeout)
$(script).remove()
delete window[callbackName]
originalCallback = window[callbackName],
responseData,
abort = function(errorType) {
$(script).triggerHandler('error', errorType || 'abort')
},
abort = function(type){
cleanup()
// In case of manual abort or timeout, keep an empty function as callback
// so that the SCRIPT tag that eventually loads won't result in an error.
if (!type || type == 'timeout') window[callbackName] = empty
ajaxError(null, type || 'abort', xhr, options)
},
xhr = { abort: abort }, abortTimeout
if (deferred) deferred.promise(xhr)
$(script).on('load error', function(e, errorType){
clearTimeout(abortTimeout)
$(script).off().remove()
if (e.type == 'error' || !responseData) {
ajaxError(null, errorType || 'error', xhr, options, deferred)
} else {
ajaxSuccess(responseData[0], xhr, options, deferred)
}
window[callbackName] = originalCallback
if (responseData && $.isFunction(originalCallback))
originalCallback(responseData[0])
originalCallback = responseData = undefined
})
if (ajaxBeforeSend(xhr, options) === false) {
abort('abort')
return false
return xhr
}
window[callbackName] = function(data){
cleanup()
ajaxSuccess(data, xhr, options)
window[callbackName] = function(){
responseData = arguments
}
script.onerror = function() { abort('error') }
script.src = options.url.replace(/\?(.+)=\?/, '?$1=' + callbackName)
document.head.appendChild(script)
script.src = options.url.replace(/=\?/, '=' + callbackName)
$('head').append(script)
if (options.timeout > 0) abortTimeout = setTimeout(function(){

@@ -1309,4 +1323,5 @@ abort('timeout')

// MIME types mapping
// IIS returns Javascript as "application/x-javascript"
accepts: {
script: 'text/javascript, application/javascript',
script: 'text/javascript, application/javascript, application/x-javascript',
json: jsonType,

@@ -1324,3 +1339,3 @@ xml: 'application/xml, text/xml',

// Whether the browser should be allowed to cache GET responses
cache: true,
cache: true
}

@@ -1337,2 +1352,3 @@

function appendQuery(url, query) {
if (query == '') return url
return (url + '&' + query).replace(/[&?]{1,2}/, '?')

@@ -1346,7 +1362,8 @@ }

if (options.data && (!options.type || options.type.toUpperCase() == 'GET'))
options.url = appendQuery(options.url, options.data)
options.url = appendQuery(options.url, options.data), options.data = undefined
}
$.ajax = function(options){
var settings = $.extend({}, options || {})
var settings = $.extend({}, options || {}),
deferred = $.Deferred && $.Deferred()
for (key in $.ajaxSettings) if (settings[key] === undefined) settings[key] = $.ajaxSettings[key]

@@ -1363,16 +1380,23 @@

var dataType = settings.dataType, hasPlaceholder = /=\?/.test(settings.url)
var dataType = settings.dataType, hasPlaceholder = /\?.+=\?/.test(settings.url)
if (dataType == 'jsonp' || hasPlaceholder) {
if (!hasPlaceholder) settings.url = appendQuery(settings.url, 'callback=?')
return $.ajaxJSONP(settings)
if (!hasPlaceholder)
settings.url = appendQuery(settings.url,
settings.jsonp ? (settings.jsonp + '=?') : settings.jsonp === false ? '' : 'callback=?')
return $.ajaxJSONP(settings, deferred)
}
var mime = settings.accepts[dataType],
baseHeaders = { },
headers = { },
setHeader = function(name, value) { headers[name.toLowerCase()] = [name, value] },
protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol,
xhr = settings.xhr(), abortTimeout
xhr = settings.xhr(),
nativeSetHeader = xhr.setRequestHeader,
abortTimeout
if (!settings.crossDomain) baseHeaders['X-Requested-With'] = 'XMLHttpRequest'
if (mime) {
baseHeaders['Accept'] = mime
if (deferred) deferred.promise(xhr)
if (!settings.crossDomain) setHeader('X-Requested-With', 'XMLHttpRequest')
setHeader('Accept', mime || '*/*')
if (mime = settings.mimeType || mime) {
if (mime.indexOf(',') > -1) mime = mime.split(',', 2)[0]

@@ -1382,12 +1406,14 @@ xhr.overrideMimeType && xhr.overrideMimeType(mime)

if (settings.contentType || (settings.contentType !== false && settings.data && settings.type.toUpperCase() != 'GET'))
baseHeaders['Content-Type'] = (settings.contentType || 'application/x-www-form-urlencoded')
settings.headers = $.extend(baseHeaders, settings.headers || {})
setHeader('Content-Type', settings.contentType || 'application/x-www-form-urlencoded')
if (settings.headers) for (name in settings.headers) setHeader(name, settings.headers[name])
xhr.setRequestHeader = setHeader
xhr.onreadystatechange = function(){
if (xhr.readyState == 4) {
xhr.onreadystatechange = empty;
xhr.onreadystatechange = empty
clearTimeout(abortTimeout)
var result, error = false
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) {
dataType = dataType || mimeToDataType(xhr.getResponseHeader('content-type'))
dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type'))
result = xhr.responseText

@@ -1402,6 +1428,6 @@

if (error) ajaxError(error, 'parsererror', xhr, settings)
else ajaxSuccess(result, xhr, settings)
if (error) ajaxError(error, 'parsererror', xhr, settings, deferred)
else ajaxSuccess(result, xhr, settings, deferred)
} else {
ajaxError(null, xhr.status ? 'error' : 'abort', xhr, settings)
ajaxError(xhr.statusText || null, xhr.status ? 'error' : 'abort', xhr, settings, deferred)
}

@@ -1411,16 +1437,19 @@ }

var async = 'async' in settings ? settings.async : true
xhr.open(settings.type, settings.url, async)
for (name in settings.headers) xhr.setRequestHeader(name, settings.headers[name])
if (ajaxBeforeSend(xhr, settings) === false) {
xhr.abort()
return false
ajaxError(null, 'abort', xhr, settings, deferred)
return xhr
}
if (settings.xhrFields) for (name in settings.xhrFields) xhr[name] = settings.xhrFields[name]
var async = 'async' in settings ? settings.async : true
xhr.open(settings.type, settings.url, async, settings.username, settings.password)
for (name in headers) nativeSetHeader.apply(xhr, headers[name])
if (settings.timeout > 0) abortTimeout = setTimeout(function(){
xhr.onreadystatechange = empty
xhr.abort()
ajaxError(null, 'timeout', xhr, settings)
ajaxError(null, 'timeout', xhr, settings, deferred)
}, settings.timeout)

@@ -1435,16 +1464,17 @@

function parseArguments(url, data, success, dataType) {
var hasData = !$.isFunction(data)
if ($.isFunction(data)) dataType = success, success = data, data = undefined
if (!$.isFunction(success)) dataType = success, success = undefined
return {
url: url,
data: hasData ? data : undefined,
success: !hasData ? data : $.isFunction(success) ? success : undefined,
dataType: hasData ? dataType || success : success
url: url
, data: data
, success: success
, dataType: dataType
}
}
$.get = function(url, data, success, dataType){
$.get = function(/* url, data, success, dataType */){
return $.ajax(parseArguments.apply(null, arguments))
}
$.post = function(url, data, success, dataType){
$.post = function(/* url, data, success, dataType */){
var options = parseArguments.apply(null, arguments)

@@ -1455,3 +1485,3 @@ options.type = 'POST'

$.getJSON = function(url, data, success){
$.getJSON = function(/* url, data, success */){
var options = parseArguments.apply(null, arguments)

@@ -1481,6 +1511,7 @@ options.dataType = 'json'

function serialize(params, obj, traditional, scope){
var type, array = $.isArray(obj)
var type, array = $.isArray(obj), hash = $.isPlainObject(obj)
$.each(obj, function(key, value) {
type = $.type(value)
if (scope) key = traditional ? scope : scope + '[' + (array ? '' : key) + ']'
if (scope) key = traditional ? scope :
scope + '[' + (hash || type == 'object' || type == 'array' ? key : '') + ']'
// handle data in serializeArray() format

@@ -1503,10 +1534,6 @@ if (!scope && array) params.add(value.name, value.value)

;(function ($) {
$.fn.serializeArray = function () {
;(function($){
$.fn.serializeArray = function() {
var result = [], el
$( Array.prototype.slice.call(this.get(0).elements) ).each(function () {
$([].slice.call(this.get(0).elements)).each(function(){
el = $(this)

@@ -1525,6 +1552,6 @@ var type = el.attr('type')

$.fn.serialize = function () {
$.fn.serialize = function(){
var result = []
this.serializeArray().forEach(function (elm) {
result.push( encodeURIComponent(elm.name) + '=' + encodeURIComponent(elm.value) )
this.serializeArray().forEach(function(elm){
result.push(encodeURIComponent(elm.name) + '=' + encodeURIComponent(elm.value))
})

@@ -1534,3 +1561,3 @@ return result.join('&')

$.fn.submit = function (callback) {
$.fn.submit = function(callback) {
if (callback) this.bind('submit', callback)

@@ -1540,3 +1567,3 @@ else if (this.length) {

this.eq(0).trigger(event)
if (!event.defaultPrevented) this.get(0).submit()
if (!event.isDefaultPrevented()) this.get(0).submit()
}

@@ -1548,103 +1575,35 @@ return this

;(function($, undefined){
var prefix = '', eventPrefix, endEventName, endAnimationName,
vendors = { Webkit: 'webkit', Moz: '', O: 'o', ms: 'MS' },
document = window.document, testEl = document.createElement('div'),
supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,
transform,
transitionProperty, transitionDuration, transitionTiming,
animationName, animationDuration, animationTiming,
cssReset = {}
function dasherize(str) { return downcase(str.replace(/([a-z])([A-Z])/, '$1-$2')) }
function downcase(str) { return str.toLowerCase() }
function normalizeEvent(name) { return eventPrefix ? eventPrefix + name : downcase(name) }
$.each(vendors, function(vendor, event){
if (testEl.style[vendor + 'TransitionProperty'] !== undefined) {
prefix = '-' + downcase(vendor) + '-'
eventPrefix = event
return false
}
})
transform = prefix + 'transform'
cssReset[transitionProperty = prefix + 'transition-property'] =
cssReset[transitionDuration = prefix + 'transition-duration'] =
cssReset[transitionTiming = prefix + 'transition-timing-function'] =
cssReset[animationName = prefix + 'animation-name'] =
cssReset[animationDuration = prefix + 'animation-duration'] =
cssReset[animationTiming = prefix + 'animation-timing-function'] = ''
$.fx = {
off: (eventPrefix === undefined && testEl.style.transitionProperty === undefined),
speeds: { _default: 400, fast: 200, slow: 600 },
cssPrefix: prefix,
transitionEnd: normalizeEvent('TransitionEnd'),
animationEnd: normalizeEvent('AnimationEnd')
;(function($){
// __proto__ doesn't exist on IE<11, so redefine
// the Z function to use object extension instead
if (!('__proto__' in {})) {
$.extend($.zepto, {
Z: function(dom, selector){
dom = dom || []
$.extend(dom, $.fn)
dom.selector = selector || ''
dom.__Z = true
return dom
},
// this is a kludge but works
isZ: function(object){
return $.type(object) === 'array' && '__Z' in object
}
})
}
$.fn.animate = function(properties, duration, ease, callback){
if ($.isPlainObject(duration))
ease = duration.easing, callback = duration.complete, duration = duration.duration
if (duration) duration = (typeof duration == 'number' ? duration :
($.fx.speeds[duration] || $.fx.speeds._default)) / 1000
return this.anim(properties, duration, ease, callback)
}
$.fn.anim = function(properties, duration, ease, callback){
var key, cssValues = {}, cssProperties, transforms = '',
that = this, wrappedCallback, endEvent = $.fx.transitionEnd
if (duration === undefined) duration = 0.4
if ($.fx.off) duration = 0
if (typeof properties == 'string') {
// keyframe animation
cssValues[animationName] = properties
cssValues[animationDuration] = duration + 's'
cssValues[animationTiming] = (ease || 'linear')
endEvent = $.fx.animationEnd
} else {
cssProperties = []
// CSS transitions
for (key in properties)
if (supportedTransforms.test(key)) transforms += key + '(' + properties[key] + ') '
else cssValues[key] = properties[key], cssProperties.push(dasherize(key))
if (transforms) cssValues[transform] = transforms, cssProperties.push(transform)
if (duration > 0 && typeof properties === 'object') {
cssValues[transitionProperty] = cssProperties.join(', ')
cssValues[transitionDuration] = duration + 's'
cssValues[transitionTiming] = (ease || 'linear')
// getComputedStyle shouldn't freak out when called
// without a valid element as argument
try {
getComputedStyle(undefined)
} catch(e) {
var nativeGetComputedStyle = getComputedStyle;
window.getComputedStyle = function(element){
try {
return nativeGetComputedStyle(element)
} catch(e) {
return null
}
}
wrappedCallback = function(event){
if (typeof event !== 'undefined') {
if (event.target !== event.currentTarget) return // makes sure the event didn't bubble from "below"
$(event.target).unbind(endEvent, wrappedCallback)
}
$(this).css(cssReset)
callback && callback.call(this)
}
if (duration > 0) this.bind(endEvent, wrappedCallback)
// trigger page reflow so new elements can animate
this.size() && this.get(0).clientLeft
this.css(cssValues)
if (duration <= 0) setTimeout(function() {
that.each(function(){ wrappedCallback.call(this) })
}, 0)
return this
}
testEl = null
})(Zepto)
})(Zepto)
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