require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o -1) { end = idx + className.length; if ((idx === 0 || rspace.test(clazz[idx-1])) && (end === clazz.length || rspace.test(clazz[end]))) { return true; } } } }); }; exports.addClass = function(value) { // Support functions if (typeof value === 'function') { return domEach(this, function(i, el) { var className = el.attribs['class'] || ''; exports.addClass.call([el], value.call(el, i, className)); }); } // Return if no value or not a string or function if (!value || typeof value !== 'string') return this; var classNames = value.split(rspace), numElements = this.length; for (var i = 0; i < numElements; i++) { // If selected element isn't a tag, move on if (!isTag(this[i])) continue; // If we don't already have classes var className = getAttr(this[i], 'class'), numClasses, setClass; if (!className) { setAttr(this[i], 'class', classNames.join(' ').trim()); } else { setClass = ' ' + className + ' '; numClasses = classNames.length; // Check if class already exists for (var j = 0; j < numClasses; j++) { var appendClass = classNames[j] + ' '; if (setClass.indexOf(' ' + appendClass) < 0) setClass += appendClass; } setAttr(this[i], 'class', setClass.trim()); } } return this; }; var splitClass = function(className) { return className ? className.trim().split(rspace) : []; }; exports.removeClass = function(value) { var classes, numClasses, removeAll; // Handle if value is a function if (typeof value === 'function') { return domEach(this, function(i, el) { exports.removeClass.call( [el], value.call(el, i, el.attribs['class'] || '') ); }); } classes = splitClass(value); numClasses = classes.length; removeAll = arguments.length === 0; return domEach(this, function(i, el) { if (!isTag(el)) return; if (removeAll) { // Short circuit the remove all case as this is the nice one el.attribs.class = ''; } else { var elClasses = splitClass(el.attribs.class), index, changed; for (var j = 0; j < numClasses; j++) { index = elClasses.indexOf(classes[j]); if (index >= 0) { elClasses.splice(index, 1); changed = true; // We have to do another pass to ensure that there are not duplicate // classes listed j--; } } if (changed) { el.attribs.class = elClasses.join(' '); } } }); }; exports.toggleClass = function(value, stateVal) { // Support functions if (typeof value === 'function') { return domEach(this, function(i, el) { exports.toggleClass.call( [el], value.call(el, i, el.attribs['class'] || '', stateVal), stateVal ); }); } // Return if no value or not a string or function if (!value || typeof value !== 'string') return this; var classNames = value.split(rspace), numClasses = classNames.length, state = typeof stateVal === 'boolean' ? stateVal ? 1 : -1 : 0, numElements = this.length, elementClasses, index; for (var i = 0; i < numElements; i++) { // If selected element isn't a tag, move on if (!isTag(this[i])) continue; elementClasses = splitClass(this[i].attribs.class); // Check if class already exists for (var j = 0; j < numClasses; j++) { // Check if the class name is currently defined index = elementClasses.indexOf(classNames[j]); // Add if stateValue === true or we are toggling and there is no value if (state >= 0 && index < 0) { elementClasses.push(classNames[j]); } else if (state <= 0 && index >= 0) { // Otherwise remove but only if the item exists elementClasses.splice(index, 1); } } this[i].attribs.class = elementClasses.join(' '); } return this; }; exports.is = function (selector) { if (selector) { return this.filter(selector).length > 0; } return false; }; },{"../utils":10,"lodash":110}],3:[function(require,module,exports){ var _ = require('lodash'), domEach = require('../utils').domEach; var toString = Object.prototype.toString; /** * Set / Get css. * * @param {String|Object} prop * @param {String} val * @return {self} * @api public */ exports.css = function(prop, val) { if (arguments.length === 2 || // When `prop` is a "plain" object (toString.call(prop) === '[object Object]')) { return domEach(this, function(idx, el) { setCss(el, prop, val, idx); }); } else { return getCss(this[0], prop); } }; /** * Set styles of all elements. * * @param {String|Object} prop * @param {String} val * @param {Number} idx - optional index within the selection * @return {self} * @api private */ function setCss(el, prop, val, idx) { if ('string' == typeof prop) { var styles = getCss(el); if (typeof val === 'function') { val = val.call(el, idx, styles[prop]); } if (val === '') { delete styles[prop]; } else if (val != null) { styles[prop] = val; } el.attribs.style = stringify(styles); } else if ('object' == typeof prop) { Object.keys(prop).forEach(function(k){ setCss(el, k, prop[k]); }); } } /** * Get parsed styles of the first element. * * @param {String} prop * @return {Object} * @api private */ function getCss(el, prop) { var styles = parse(el.attribs.style); if (typeof prop === 'string') { return styles[prop]; } else if (Array.isArray(prop)) { return _.pick(styles, prop); } else { return styles; } } /** * Stringify `obj` to styles. * * @param {Object} obj * @return {Object} * @api private */ function stringify(obj) { return Object.keys(obj || {}) .reduce(function(str, prop){ return str += '' + (str ? ' ' : '') + prop + ': ' + obj[prop] + ';'; }, ''); } /** * Parse `styles`. * * @param {String} styles * @return {Object} * @api private */ function parse(styles) { styles = (styles || '').trim(); if (!styles) return {}; return styles .split(';') .reduce(function(obj, str){ var n = str.indexOf(':'); // skip if there is no :, or if it is the first/last character if (n < 1 || n === str.length-1) return obj; obj[str.slice(0,n).trim()] = str.slice(n+1).trim(); return obj; }, {}); } },{"../utils":10,"lodash":110}],4:[function(require,module,exports){ // https://github.com/jquery/jquery/blob/2.1.3/src/manipulation/var/rcheckableType.js // https://github.com/jquery/jquery/blob/2.1.3/src/serialize.js var _ = require('lodash'), submittableSelector = 'input,select,textarea,keygen', rCRLF = /\r?\n/g, rcheckableType = /^(?:checkbox|radio)$/i, rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i; exports.serializeArray = function() { // Resolve all form elements from either forms or collections of form elements var Cheerio = this.constructor; return this.map(function() { var elem = this; var $elem = Cheerio(elem); if (elem.name === 'form') { return $elem.find(submittableSelector).toArray(); } else { return $elem.filter(submittableSelector).toArray(); } }).filter(function() { var $elem = Cheerio(this); var type = $elem.attr('type'); // Verify elements have a name (`attr.name`) and are not disabled (`:disabled`) return $elem.attr('name') && !$elem.is(':disabled') && // and cannot be clicked (`[type=submit]`) or are used in `x-www-form-urlencoded` (`[type=file]`) !rsubmitterTypes.test(type) && // and are either checked/don't have a checkable state ($elem.attr('checked') || !rcheckableType.test(type)); // Convert each of the elements to its value(s) }).map(function(i, elem) { var $elem = Cheerio(elem); var name = $elem.attr('name'); var val = $elem.val(); // If there is no value set (e.g. `undefined`, `null`), then return nothing if (val == null) { return null; } else { // If we have an array of values (e.g. `