shipfi

add all

Showing 149 changed files with 4292 additions and 101 deletions
## PHP总体规范 v1.0
PHP平台编写应用,公司需要强调的规则定义。
### 1. 整体环境
所有项目的整体环境说明:
> 对于PHP的项目,公司以Linux为部署操作系统,php-fpm+Nginx+Redis为程序环境,GIT作为版本的代码管理,GitLab作为项目管理,禅道作为项目控制和BUG管理,邮件作为团队之间联络渠道。
### 2. 程序的环境
对于开发主机,安装的环境以列表说明
* PHP版本 >= 5.6.0
* Nigix版本 >= 1.8.0
* composer版本 (保持最新)
* GIT版本 >= 2.10
* nodejs >= 6.10
各开发环境下载 :
PHP+NGINX工具参考下载 : [PHP_NGINX下载链接](http://resource.qingger.com/PHP_NIGIX.zip)
composer下载和使用参考(注意,composer使用国内源) :[composer主页](http://www.phpcomposer.com/)
git下载 : [下链链接](https://git-scm.com/downloads)
nodejs下载 : [下载链接](http://nodejs.cn/)
### 3. 开发工具
对于PHP开发工具,统一使用phpstorm。
对于WEB开发,统一使用webstorm
对于命令行工具,统一使用GIT中的bash工具。
windows的cms工具,可以使用ConEmu或者cmder工具
开发工具下载:
phpstorm : [下载链接](https://www.jetbrains.com/phpstorm/download/#section=windows) 注:phpstorm64位版本依赖于JRE
phpstorm的注册激活 : [参考](http://idea.lanyus.com/)
Conemu下载 [下载链接](http://conemu.github.io/en/Downloads.html)
### 4. 环境规范
* 4.1 [环境开发测试生产规范 v1.0](product.md)
### 5. 关于PHP默认编码规范
* [5.1 PHP语言编码规范 v1.0](php_rule.md)
* [5.2 LUMEN+API应用的编码规范 v1.0](lumen_rule.md)
### 6. 数据库规范
* 6.1 [数据库规范](database.md)
### 7. GIT代码管理规范
* 7.1 [GIT Flow规范](git_flow.md)
### 8. 项目开发流程规范
* 8.1 [文档规范]()
* 8.2 [项目开发规范]()
* 8.3 [测试规范]()
* 8.4 [生产部署规范]()
### 青鸽
\ No newline at end of file
## PHP总体规范 v1.0
PHP平台编写应用,公司需要强调的规则定义。
### 1. 整体环境
所有项目的整体环境说明:
> 对于PHP的项目,公司以Linux为部署操作系统,php-fpm+Nginx+Redis为程序环境,GIT作为版本的代码管理,GitLab作为项目管理,禅道作为项目控制和BUG管理,邮件作为团队之间联络渠道。
### 2. 程序的环境
对于开发主机,安装的环境以列表说明
* PHP版本 >= 5.6.0
* Nigix版本 >= 1.8.0
* composer版本 (保持最新)
* GIT版本 >= 2.10
* nodejs >= 6.10
各开发环境下载 :
PHP+NGINX工具参考下载 : [PHP_NGINX下载链接](http://resource.qingger.com/PHP_NIGIX.zip)
composer下载和使用参考(注意,composer使用国内源) :[composer主页](http://www.phpcomposer.com/)
git下载 : [下链链接](https://git-scm.com/downloads)
nodejs下载 : [下载链接](http://nodejs.cn/)
### 3. 开发工具
对于PHP开发工具,统一使用phpstorm。
对于WEB开发,统一使用webstorm
对于命令行工具,统一使用GIT中的bash工具。
windows的cms工具,可以使用ConEmu或者cmder工具
开发工具下载:
phpstorm : [下载链接](https://www.jetbrains.com/phpstorm/download/#section=windows) 注:phpstorm64位版本依赖于JRE
phpstorm的注册激活 : [参考](http://idea.lanyus.com/)
Conemu下载 [下载链接](http://conemu.github.io/en/Downloads.html)
### 4. 环境规范
* 4.1 [环境开发测试生产规范 v1.0](product.md)
### 5. 关于PHP默认编码规范
* [5.1 PHP语言编码规范 v1.0](php_rule.md)
* [5.2 LUMEN+API应用的编码规范 v1.0](lumen_rule.md)
### 6. 数据库规范
* 6.1 [数据库规范](database.md)
### 7. GIT代码管理规范
* 7.1 [GIT Flow规范](git_flow.md)
### 8. 项目开发流程规范
* 8.1 [文档规范]()
* 8.2 [项目开发规范]()
* 8.3 [测试规范]()
* 8.4 [生产部署规范]()
......
{
"plugins": ["js-sequence-diagram","sequence-diagram-lastest"]
}
\ No newline at end of file
## LUMEN+API Controller 规范
### 1. 第三方依赖库规范
在使用LUMEN实现API接口时,以下库必须需要包含在composer包依赖中,以实现代码编写的一些规范
* dingo/api : 实现API接口库
* vlucas/phpdotenv : 实现了配置文件读取的函数,包括env()函数等
* marc-mabe/php-enum : 实现php的ENUM功能
* barryvdh/laravel-ide-helper : IDE帮助,_ide_helper.php文件提供
### 2. Controller规范
* 所有Controller的基类以编写定义的BasicController为准。BasicController实现了一些基本的HTTP请求和应答功能。如$requestHander变量处理请求,respond函数处理应答。Trait类UtilToolMethod实现了通用功能函数。
* 所有的Controller不再使用Request对象,而使用BasicController中的$requestHandler变量。
* $requestHandler变量使用不再推荐使用数组形式结构获得参数变量,而使用使用其暴露的方法
```php
$this->requestHandler->input('key1','');
$this->requestHandler->all();
$this->requestHandler->only(['key1','key2']);
$this->requestHandler->file('file');
$this->requestHandler->header('Authorization');
$this->requestHandler->url();
$this->requestHandler->path();
```
* 对于请求参数的验证,统一使用validate方法
```php
$this->validate($this->requestHandler,[
'key1' => 'required'
]);
```
* 对于自己业务有特殊需求的,在BasicController基础上,扩展Controller的功能和方法。 然后再让其它的Controller类继承这个定义的Controller
```php
/**
* 应用授权用户基类,提供用户数据及用户操作方法
*/
class UserAuthBasicControll extends BaiscController
{
/**
* @var GuiderEmpUser
*/
private $_empUser = null;
public function __construct(Request $request,GuiderEmpUser $guiderEmpUser) {
parent::__construct($reuqest);
$this->_empUser = $guiderEmpUser;
}
/**
* @return GuiderEmpUser
*/
public function getEmpUser() { return $this->_empUser; }
public function userSiteAccess($pointSiteId) { /* 实现权限验证.. */ }
}
```
* Controller层函数使用对象的自动注入依赖。
```php
class CustomerController
{
private $_crmService = null;
public function __construct(CRMService $crmService) {
$this->_crmService = $crmService; // 自动注入依赖
}
public function customerEnterIn($userInfo) {
$this->_crmService->registerCustomer($userInfo);
}
}
```
* Controller层不能直接操作SQL,不能直接操作Model对象实现SQL功能。要实现数据库**增删改**,必须通过Model封装起来。以下方法在Controller中直接操作DB表都是被禁止的
```php
class SomeController
{
public function doSomeErrorThing() {
DB::table('t1')->insert([...]);
UserModel::where('user'=>'my')->update([...]);
DB::table('users')->truncate();
}
/* 对于查询来说,简单的查询可以在Controller直接完成,复杂的查询需要通过Model层添加方法来完成 */
public function userOperator() {
$id = 100;
$userInstance1 = User::find($id);
$userInstance2 = (new User())->getUserInstanceById($id);
$userAccesseList = (new User())->getUserAccesses($id);
}
}
```
* Controller通过调用Model层,自定义Service层,Event, Queue来完成自身的业务逻辑。但是在Controller层,尽量做到对于底层服务的底耦合,为了能够更好的测度,也尽量使用对象的依赖注入。
* Controller层与其它层的一般关系如下
```sequence
Router ->> Controller : 数据请求
Controller ->> Controller : 处理用户请求
Controller ->> Model : 数据业务处理
Model -> Model : 数据查询更新
Model -> Service : 业务逻辑处理
Controller ->> Service : 业务逻辑处理
Service --> ClientAPI : 服务请求处理
ClientAPI --> Service : 服务应答
Service --> Controller : 业务处理结果
Controller --> Router : 数据应答
```
* 如果要实现程序异步机制,请使用Lumen提供的Queue功能。异步机制的使用可以提高API的应答效率,以下场景比如事件机制的接收处理,对于延时的任务机制,也需要通过Queue功能完成
```sequence
Router -> Controller : 数据请求
Controller -> Controller : 处理请求
Controller --> QueueJob : 任务添加Dispatcher
Controller --> Router : 数据应答
QueueJob -> QueueJob : 任务调度
QueueJob -> JobProcedure : JOB处理
JobProcedure -> Model : 数据应务处理
```
* 如果编写与业务无关的类库、服务等应用,需要与上层的Controller/Model解耦,当需要有数据或者事件通知到上层应用,并让上层应用决定做出处理时,那么可以利用Event事件机制。
```sequence
Controller -> EventListener : 订阅事件
MyService -> MyService : 业务处理
MyService -> Event : 派发事件
Event --> EventListener : 事件触发
EventListener -> EventListener : 事件处理
```
* Controller层的处理只作出正常的返回处理,而不对异常情况进行返回,遇到异常情况时,通过Exception的机制进行数据的返回。
```php
public function dosth() {
dosth1();
dosth2();
if($error) {
throw new MYException('Error Message',SOMECODE);
}
$this->respond([..]);
}
```
* BasicController,BaseModel有UtilToolMethods的相关方法,实现了以下的基本功能
| 索引 | 方法名 | 备注 |
| ---- | --------------- | ---------------------------------- |
| 1 | arrValidate | 实现以数组字典数据的验证 |
| 2 | dispatchJob | 派发事件 |
| 3 | utilToArray | 将对象转换为数组 |
| 4 | getConfigValue | 获得配置文件中的值 |
| 5 | arrayEncode | 将字典Hash成一个字符串,一般用来实现CacheKey |
| 6 | getEnv | 获得环境变量名称: 有dev/testing/production/ |
| 7 | envIsTesting | 判断环境是否测试环境 |
| 8 | envIsDemo | 判断环境是否环境 |
| 9 | envIsProduction | 判断环境是否生产环境 |
?
\ No newline at end of file
## LUMEN+API Model规范
### 1. Model规范
* 使用Model实现数据业务处理,包括数据表和数据关联表的增删改查。
* 对于各个表的Model, 继承自定义的BaseModel类,而不是Model类
* 如果表和表之间有一定的关系,1vs1, 1vsN,那在Model中使用hasOne,belongsTo进行映射,通过这样的映射,可以对Model对象实现很清晰的操作逻辑:
```php
class GroupModel extends BaseModel {
/**
* @return GroupModel
*/
public function getInstanceByGroupCode($code) {
return $this->where('group_code',$code)->first();
}
public function weixinGroupInfo() {
return $this->hasOne(WeixinGroupInfo::class,'group_id','group_id');
}
/**
* @return WeixinGroupInfo
*/
public function myWeixinGroupInfo() {
return $this->weixinGroupInfo()->first();
}
public funciton groupSites() {
return $this->hasMany(GroupSite::class,'group_id','group_id');
}
/**
* @return Collection
*/
public function myGroupSites() {
return $this->groupSites->get();
}
public function getMyGroupName() {
return isset($this->group_name) ? $this->group_name : null;
}
}
$groupInstance = (new GroupModel())->getInstanceByGroupCode('Foo');
$groupWeixinInfoInstance = $groupInstance->myWeixinGroupInfo();
$groupSites = $groupInstance->myGroupSites()->filter( function($site) {/**/ });
```
* Model必须实现数据表的增删改操作,不能让这些操作暴露在Controller或者Service中
```php
class UserModel extends BasicModel
{
public function insertUser(array $userInfo) { /**/ }
public function updateUser(array $userInfo) { /**/ }
/* 如有必要,更新字段的操作颗粒度可以降底到每一项 */
public function updateUserLoginName ($userId,$userName) {/**/}
public function deleteUserById($userId) {/**/}
}
```
* Model层函数的返回,都要写明注释(尤其是参数和返回值类型),以便Controller调用时,可以智能感知和减少错误发生的机率。
```php
/**
* 增加一个新的用户,成功的情况下,返回用户对象
* @param array userInfo
* ['userName','userSex','userDesc']
* @result App\Models\User
*/
public function insertUser(array $userInfo) {
$this->arrValidation($userInfo, [
'userName' => 'required|string|min:6'
]);
$newUser = new User();
$newUser->user_name = userInfo['userName'];
$newUser->user_sex = isset($userInof['userSex']) ? $userInfo['userSex'] : GlobalSystem::MALE;
$newUser->user_desc = isset($userInof['userDesc']) ? $userInfo['userDesc'] : '';
$newUser->save();
return $newUser;
}
```
* 不要使用scope类型的函数。
* 在函数上区分并辩明属于Model的方法和属于Instance的方法。
> 所谓Model方法,是指new一个Model实例即可调用的方法,对于操作库,可以使用Model方法
>
> 所谓Instance方法,是指对应的数据表中的一个实例,例如,通过User::find(1)即可获得一个Instance方法。
>
> Instance方法一般用来获得属性,实现实例的业务逻辑,操作与此实例关联的其它数据模型的实例。
>
> 一般来说,在Instance方法上,加一个My修饰词进行表示。
```php
public function insertUser(array $userInfo); // Model方法
public function getMyUserName() { return $this->user_name; } // Instance方法
public function checkMyRoles() { /**/ }
```
* 在Model层所实现的业务逻辑上,要把业务边界分清楚,比如对于Group/Site这样的业务来说,Group可以代理Site的一些操作,但是具体涉及到Site数据操作,需要交给Site模型进行。
```php
class Group extends BaseModel
{
/* 假设groupInfo中涵盖了site的信息 */
public function receiveGroupInfoEvent($groupInfo) {
$this->updateGroup($groupInfo);
if(isset($groupInfo['sites'])) {
$this->updateGroupSites($groupInfo['sites']);
}
}
public function updateGroup($groupInfo) {
// do group update
}
public function updateGroupSites($siteList) {
foreach($siteList as $siteInfo)
(new Site())->updateSite($siteInfo);
}
}
```
* BaseModel的一些基本操作
| 索引 | 函数方法 | 备注 |
| ---- | ----------------------- | ---------------------------------------- |
| 1 | getInstanceById | Model方法,根据关键字获得Instance对象 |
| 2 | getMyId | Instance方法,获得主ID |
| 3 | getTable | Model方法,获得数据表名称 |
| 4 | toSql | Model方法,查询时可以将其转换为SQL语句 |
| 5 | getQueryByConditions | Model方法,基础的条件查询,一些场合下可以代替where语句 |
| 6 | checkValidItem | Model方法,查询符合条件的数据有多少项 |
| 7 | updateItemsByPrimaryId | Model方法,根据ID更新数据表项 |
| 8 | updateItemsByConditions | Model方法,根据条件更新数据表项 |
| 9 | checkObjectIdExist | Instance方法,检查调用实例是否Instance对象,如果不是,则抛出异常 |
?
## LUMEN+API 其它说明
### 1. Exception
* 在应用中,所有的错误或者异常情况,都是通过抛出异常来进行应答,而不是通过respondError.所以需要改造Exception, 以当异常抛出时,返回需要的接口值。
```php
/* 自定义实现ExceptionHandler */
class ECExceptionHandler extends ExceptionHandler
{
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
$response['code'] = $e->getCode();
$response['message'] = $e->getMessage();
/**
* 记录异常
*/
$this->logToDatabaseAndLogger($request,$e);
$httpStsCode = IlluminateResponse::HTTP_NOT_ACCEPTABLE;
if($e instanceof ECException) {
$response['message'] = $e->getECErrorMessage();
if($e->getHttpStatus()) {
$httpStsCode = $e->getHttpStatus();
}
}
if ($this->isDebugMode()) {
$response['debug'] = [
'exception' => get_class($e),
'trace' => $e->getTraceAsString()
];
}
// 错误时的应答
return response()->json(
$response,
$httpStsCode
);
}
}
```
* 异常可以自定义具体的HTTP返回码,当碰到什么样的错误时,HTTP码为什么值。默认的错误HTTP返回码是406(Not Accept).
```php
/**
* 错误代码的行为定义
* Class GlobalErrCodeLang
* @package App\Library\VariDefines\ErrorCodes
*/
class GlobalErrCodeLang
{
/* 定义错误码的中文说明 */
private static $errLang = array(
/* 函数或接口错误 (6xxxx) */
GlobalErrCode::ERR_PARAM_QUERY_ERROR => '参数错误',
GlobalErrCode::ERR_ATTRIBUTE_SET_ERROR => '数据设定错误',
GlobalErrCode::ERR_PARAM_NOT_SET => '函数调用参数没有设定',
/* 用户错误 */
GlobalErrCode::ERR_EMP_NOT_FIND => '找不到此用户',
GlobalErrCode::ERR_EMP_HAS_NO_GUIDER => '站点中没有配置此导购',
GlobalErrCode::ERR_EMP_HAS_NO_COMPANY => '此雇员没有设定相应的集团和公司',
/* 系统错误 (9xxxx) */
GlobalErrCode::ERR_SYSTEM_ERROR => '系统未知错误',
);
/* 定义错误码的HTTP返回Code */
private static $errHttpStatus = array(
/* 认证请求错误:401 */
GlobalErrCode::ERR_AUTH_BAD_REQUEST => IlluminateResponse::HTTP_UNAUTHORIZED,
GlobalErrCode::ERR_AUTH_USER_NOT_EXIST => IlluminateResponse::HTTP_UNAUTHORIZED,
GlobalErrCode::ERR_AUTH_INTERNAL_SERVER_ERROR => IlluminateResponse::HTTP_INTERNAL_SERVER_ERROR,
GlobalErrCode::ERR_AUTH_PARAM_ERROR => IlluminateResponse::HTTP_UNAUTHORIZED,
GlobalErrCode::ERR_AUTH_GET_ACCESS_TOKEN_ERROR => IlluminateResponse::HTTP_UNAUTHORIZED,
GlobalErrCode::ERR_AUTH_TOKEN_ABSENT => IlluminateResponse::HTTP_UNAUTHORIZED,
GlobalErrCode::ERR_AUTH_TOKEN_INVALID => IlluminateResponse::HTTP_UNAUTHORIZED,
GlobalErrCode::ERR_AUTH_TOKEN_EXPIRED => IlluminateResponse::HTTP_UNAUTHORIZED,
GlobalErrCode::ERR_AUTH_FORBIDDEN => IlluminateResponse::HTTP_UNAUTHORIZED,
);
}
```
?
### 2. IDE
通过PHPStorm工具,实现良好的编码规范后,可以避免很多的语法错误,包括变量未定义,语法的错误、重复定义等。
所以在写代码时,要确保代码在IDE中极少存在右侧的警告信息。(有些警告不可避免,但是这样的警告很少)
对于Model层,因为where, find,update这些方法IDE不认识,所以这些报告警告可以忽略,大部分警告需要我们去确认。
![](http://of2xnjf2g.bkt.clouddn.com/QQ%E5%9B%BE%E7%89%8720170330141303.png)
### 3. 环境
## LUMEN+API Service规范
### 1. Service规范
* 在应用中,除了数据操作的业务交给Model实现,额外的业务全部交给Service进行封装实现
* Service一般实现包括以下几个方面:
* 封装用户的权限验证
* 封装一些基本操作,如通过curl实现HttpGet,HttpPost、通过Cache实现CacheManager、通过Log实现LogService等。
* 封装了与其它系统交互的细节,如CRMService, PortalService, SCService等。
* 一般简单的工具类,文件存放在app\Libraray中。
* 其它具体的提供服务类,文件存放在app\Service中。
* 服务不依赖于上层Controller/Model类,按照约定,服务可以在不同项目中复用。
* 在应用中,服务的日志需要独立。
* 服务被Controller/Model对象所调用,实现业务逻辑,服务一般在这些类中配置成依赖注入的。或者通过Factory方式,生成服务对象。
```php
/**
* weixin服务工厂类
* Class WeixinServiceFactory
* @package App\Services\WeixinFunc
*/
class WeixinServiceFactory
{
/**
* @return WeixinMPTicketService
*/
public function mpTicketService() {
return App::make(WeixinMPTicketService::class);
}
/**
* @return WeixinMPOpenTPService
*/
public function mpOpenTpService() {
return App::make(WeixinMPOpenTPService::class);
}
/**
* @return WeixinQyCorpService
*/
public function qyCorpService() {
return App::make(WeixinQyCorpService::class);
}
}
// 在具体实现的Controller中
public function qyAgentMenuCreate($suiteName) {
$corpId = $this->requestHandler->input('corpId');
$this->wxServiceFactory->qyCorpService()->wxQySetAgentMenu(
$agentInstance->getMyAgentId(),
$this->getCorpAccessToken($suiteName,$corpId),
$this->requestHandler->input('menus')
);
}
```
* 对于依赖注入,有时创建服务时,需要根据Request参数不同,而创建不同的服务实例,那么,可以在bootstrap/app.php中去动态绑定依赖注入时参数的依赖
```php
/**
* CorpInstance注入
*/
$reqCorpId = $request->input($reqCorp);
$app->bind(\App\Services\CorpInstance::class,function($app) use($reqCorpId){
if(empty($reqCorpId)) {
$reqCorpId = 'UNKNOWN_CORP';
}
$corpIns = new \App\Services\CorpInstance(reqCorpId);
return $corpIns;
});
```
?
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules
JS Sequence Diagram Plugin
==============
Install the JS Sequence Diagram plugin via **NPM**, which should be installed globally using the `-g` option:
```
$ npm install gitbook-plugin-js-sequence-diagram -g
```
> As you are installing globally, you may need to put `sudo` in front of the command, `sudo npm install gitbook-plugin-js-sequence-diagram -g`
To use the plugin in your Gitbook project, add the plugin to the `book.json` file.
```
{
"plugins": ["js-sequence-diagram"]
}
```
Then, to include a sequence diagram, just wrap your definition in a "sequence" code block. For example:
``` sequence
Title: Here is a title
A->B: Normal line
B-->C: Dashed line
C->>D: Open arrow
D-->>A: Dashed open arrow
```
Please reference the [js-sequence-diagrams](http://bramp.github.io/js-sequence-diagrams/) documentation for details on syntax.
require(["gitbook"], function(gitbook) {
gitbook.events.bind("page.change", function() {
$('code.lang-sequence').each(function(index, element) {
var $element = $(element);
$element.sequenceDiagram({theme: 'simple'});
var wrapper = $("<div class='scroll'></div>");
wrapper.html($element.html());
$element.parent().replaceWith(wrapper);
});
});
});
svg text {
font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
}
.scroll {
width: 100%;
overflow-x: scroll;
}
module.exports = {
book: {
assets: "./book",
js: [
"jquery-2.1.1.min.js",
"underscore-min.js",
"sequence-diagram-min.js",
"plugin.js"
],
css: [
"styles.css"
],
html: {
"head:end": function() {
// Required to including this way because raphael is non-AMD compliant
return "<script src='//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js'></script>";
}
}
}
};
{
"_args": [
[
{
"name": "gitbook-plugin-js-sequence-diagram",
"raw": "gitbook-plugin-js-sequence-diagram@0.0.8",
"rawSpec": "0.0.8",
"scope": null,
"spec": "0.0.8",
"type": "version"
},
"E:\\SouceCode\\ProjectGit\\allProject\\Docs\\Rules"
]
],
"_from": "gitbook-plugin-js-sequence-diagram@0.0.8",
"_id": "gitbook-plugin-js-sequence-diagram@0.0.8",
"_inCache": true,
"_installable": true,
"_location": "/gitbook-plugin-js-sequence-diagram",
"_npmUser": {
"email": "gmassanek@gmail.com",
"name": "gmassanek"
},
"_npmVersion": "1.4.7",
"_phantomChildren": {},
"_requested": {
"name": "gitbook-plugin-js-sequence-diagram",
"raw": "gitbook-plugin-js-sequence-diagram@0.0.8",
"rawSpec": "0.0.8",
"scope": null,
"spec": "0.0.8",
"type": "version"
},
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/gitbook-plugin-js-sequence-diagram/-/gitbook-plugin-js-sequence-diagram-0.0.8.tgz",
"_shasum": "5bb7d4ebd578258b308e5322df9af2729d40ddc2",
"_shrinkwrap": null,
"_spec": "gitbook-plugin-js-sequence-diagram@0.0.8",
"_where": "E:\\SouceCode\\ProjectGit\\allProject\\Docs\\Rules",
"bugs": {
"url": "https://github.com/gmassanek/gitbook-plugin-js-sequence-diagram/issues"
},
"dependencies": {
"jquery": "*"
},
"description": "JS Sequence Diagram plugin for GitBook",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "5bb7d4ebd578258b308e5322df9af2729d40ddc2",
"tarball": "https://registry.npmjs.org/gitbook-plugin-js-sequence-diagram/-/gitbook-plugin-js-sequence-diagram-0.0.8.tgz"
},
"engines": {
"gitbook": "*"
},
"homepage": "https://github.com/gmassanek/gitbook-plugin-js-sequence-diagram",
"license": "Apache 2",
"main": "index.js",
"maintainers": [
{
"email": "gmassanek@gmail.com",
"name": "gmassanek"
}
],
"name": "gitbook-plugin-js-sequence-diagram",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/gmassanek/gitbook-plugin-js-sequence-diagram.git"
},
"version": "0.0.8"
}
Sequence Diagram Plugin for Gitbook
==============
Install the Sequence Diagram plugin via **NPM**
```
$ npm install gitbook-plugin-sequence-diagram-lastest
```
> if you are installing globally, you may need to put `sudo` in front of the command, `sudo npm install gitbook-plugin-sequence-diagram-lastest -g`
To use the plugin in your Gitbook project, add the plugin to the `book.json` file.
```
{
"plugins": ["sequence-diagram-lastest"]
}
```
Then, to include a sequence diagram, just wrap your definition in a "sequence" code block. For example:
``` sequence
Title: Here is a title
A->B: Normal line
B-->C: Dashed line
C->>D: Open arrow
D-->>A: Dashed open arrow
```
Please reference the [js-sequence-diagrams](https://bramp.github.io/js-sequence-diagrams/) documentation for details on syntax.
require(["gitbook"], function(gitbook) {
gitbook.events.bind("page.change", function() {
$('code.lang-sequence').sequenceDiagram({theme: 'simple'});
});
});
svg text {
font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
}
.scroll {
width: 100%;
overflow-x: auto;
}
module.exports = {
book: {
assets: "./book",
js: [
"jquery-2.1.1.min.js",
"underscore-min.js",
"snap.svg-min.js",
"webfont.js",
"sequence-diagram-min.js",
"plugin.js"
],
css: [
"styles.css"
],
html: {
"head:end": function() {
// Required to including this way because raphael is non-AMD compliant
return "<script src='//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js'></script>";
}
}
}
};
{
"_args": [
[
{
"name": "gitbook-plugin-sequence-diagram-lastest",
"raw": "gitbook-plugin-sequence-diagram-lastest@0.1.0",
"rawSpec": "0.1.0",
"scope": null,
"spec": "0.1.0",
"type": "version"
},
"E:\\SouceCode\\ProjectGit\\allProject\\Docs\\Rules"
]
],
"_from": "gitbook-plugin-sequence-diagram-lastest@0.1.0",
"_id": "gitbook-plugin-sequence-diagram-lastest@0.1.0",
"_inCache": true,
"_installable": true,
"_location": "/gitbook-plugin-sequence-diagram-lastest",
"_nodeVersion": "6.8.0",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/gitbook-plugin-sequence-diagram-lastest-0.1.0.tgz_1488511423008_0.9737237677909434"
},
"_npmUser": {
"email": "wangshiweilove@gmail.com",
"name": "webkong"
},
"_npmVersion": "3.10.8",
"_phantomChildren": {},
"_requested": {
"name": "gitbook-plugin-sequence-diagram-lastest",
"raw": "gitbook-plugin-sequence-diagram-lastest@0.1.0",
"rawSpec": "0.1.0",
"scope": null,
"spec": "0.1.0",
"type": "version"
},
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/gitbook-plugin-sequence-diagram-lastest/-/gitbook-plugin-sequence-diagram-lastest-0.1.0.tgz",
"_shasum": "02c1009254b69d9f741088a1daef0192bbc652f0",
"_shrinkwrap": null,
"_spec": "gitbook-plugin-sequence-diagram-lastest@0.1.0",
"_where": "E:\\SouceCode\\ProjectGit\\allProject\\Docs\\Rules",
"author": {
"email": "772930508@qq.com",
"name": "webkong"
},
"bugs": {
"url": "https://github.com/gmassanek/gitbook-plugin-sequence-diagram-lastest/issues"
},
"dependencies": {
"jquery": ">2.0.0"
},
"description": "Sequence Diagram plugin for GitBook",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "02c1009254b69d9f741088a1daef0192bbc652f0",
"tarball": "https://registry.npmjs.org/gitbook-plugin-sequence-diagram-lastest/-/gitbook-plugin-sequence-diagram-lastest-0.1.0.tgz"
},
"engines": {
"gitbook": "3.2.2"
},
"homepage": "https://github.com/gmassanek/gitbook-plugin-sequence-diagram-lastest",
"license": "Apache 2",
"main": "index.js",
"maintainers": [
{
"email": "wangshiweilove@gmail.com",
"name": "webkong"
}
],
"name": "gitbook-plugin-sequence-diagram-lastest",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/gmassanek/gitbook-plugin-sequence-diagram-lastest.git"
},
"scripts": {},
"version": "0.1.0"
}
This diff is collapsed. Click to expand it.
Copyright JS Foundation and other contributors, https://js.foundation/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.
# jQuery
> jQuery is a fast, small, and feature-rich JavaScript library.
For information on how to get started and how to use jQuery, please see [jQuery's documentation](http://api.jquery.com/).
For source files and issues, please visit the [jQuery repo](https://github.com/jquery/jquery).
If upgrading, please see the [blog post for 3.2.1](https://blog.jquery.com/2017/03/20/jquery-3-2-1-now-available/). This includes notable differences from the previous version and a more readable changelog.
## Including jQuery
Below are some of the most common ways to include jQuery.
### Browser
#### Script tag
```html
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
```
#### Babel
[Babel](http://babeljs.io/) is a next generation JavaScript compiler. One of the features is the ability to use ES6/ES2015 modules now, even though browsers do not yet support this feature natively.
```js
import $ from "jquery";
```
#### Browserify/Webpack
There are several ways to use [Browserify](http://browserify.org/) and [Webpack](https://webpack.github.io/). For more information on using these tools, please refer to the corresponding project's documention. In the script, including jQuery will usually look like this...
```js
var $ = require("jquery");
```
#### AMD (Asynchronous Module Definition)
AMD is a module format built for the browser. For more information, we recommend [require.js' documentation](http://requirejs.org/docs/whyamd.html).
```js
define(["jquery"], function($) {
});
```
### Node
To include jQuery in [Node](nodejs.org), first install with npm.
```sh
npm install jquery
```
For jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/tmpvar/jsdom). This can be useful for testing purposes.
```js
require("jsdom").env("", function(err, window) {
if (err) {
console.error(err);
return;
}
var $ = require("jquery")(window);
});
```
{
"name": "jquery",
"main": "dist/jquery.js",
"license": "MIT",
"ignore": [
"package.json"
],
"keywords": [
"jquery",
"javascript",
"browser",
"library"
]
}
\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/sizzle
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.
This diff is collapsed. Click to expand it.
{
"_args": [
[
{
"name": "jquery",
"raw": "jquery@*",
"rawSpec": "*",
"scope": null,
"spec": "*",
"type": "range"
},
"E:\\SouceCode\\ProjectGit\\allProject\\Docs\\Rules\\node_modules\\gitbook-plugin-js-sequence-diagram"
]
],
"_from": "jquery@*",
"_id": "jquery@3.2.1",
"_inCache": true,
"_installable": true,
"_location": "/jquery",
"_nodeVersion": "7.7.3",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/jquery-3.2.1.tgz_1490036530067_0.19497186387889087"
},
"_npmUser": {
"email": "4timmywil@gmail.com",
"name": "timmywil"
},
"_npmVersion": "4.4.4",
"_phantomChildren": {},
"_requested": {
"name": "jquery",
"raw": "jquery@*",
"rawSpec": "*",
"scope": null,
"spec": "*",
"type": "range"
},
"_requiredBy": [
"/gitbook-plugin-js-sequence-diagram"
],
"_resolved": "https://registry.npmjs.org/jquery/-/jquery-3.2.1.tgz",
"_shasum": "5c4d9de652af6cd0a770154a631bba12b015c787",
"_shrinkwrap": null,
"_spec": "jquery@*",
"_where": "E:\\SouceCode\\ProjectGit\\allProject\\Docs\\Rules\\node_modules\\gitbook-plugin-js-sequence-diagram",
"author": {
"name": "JS Foundation and other contributors",
"url": "https://github.com/jquery/jquery/blob/3.2.1/AUTHORS.txt"
},
"bugs": {
"url": "https://github.com/jquery/jquery/issues"
},
"commitplease": {
"components": [
"Docs",
"Tests",
"Build",
"Support",
"Release",
"Core",
"Ajax",
"Attributes",
"Callbacks",
"CSS",
"Data",
"Deferred",
"Deprecated",
"Dimensions",
"Effects",
"Event",
"Manipulation",
"Offset",
"Queue",
"Selector",
"Serialize",
"Traversing",
"Wrap"
],
"markerPattern": "^((clos|fix|resolv)(e[sd]|ing))|^(refs?)",
"nohook": true,
"ticketPattern": "^((Closes|Fixes) ([a-zA-Z]{2,}-)[0-9]+)|^(Refs? [^#])"
},
"dependencies": {},
"description": "JavaScript library for DOM operations",
"devDependencies": {
"babel-preset-es2015": "6.6.0",
"commitplease": "2.6.1",
"core-js": "2.2.2",
"cross-spawn": "2.2.3",
"eslint-config-jquery": "1.0.0",
"grunt": "1.0.1",
"grunt-babel": "6.0.0",
"grunt-cli": "1.2.0",
"grunt-compare-size": "0.4.2",
"grunt-contrib-uglify": "1.0.1",
"grunt-contrib-watch": "1.0.0",
"grunt-eslint": "19.0.0",
"grunt-git-authors": "3.2.0",
"grunt-jsonlint": "1.0.7",
"grunt-newer": "1.2.0",
"grunt-npmcopy": "0.1.0",
"gzip-js": "0.3.2",
"husky": "0.11.4",
"insight": "0.8.1",
"jsdom": "5.6.1",
"load-grunt-tasks": "3.5.0",
"native-promise-only": "0.8.1",
"promises-aplus-tests": "2.1.2",
"q": "1.4.1",
"qunit-assert-step": "1.0.3",
"qunitjs": "1.23.1",
"requirejs": "2.2.0",
"sinon": "1.17.3",
"sizzle": "2.3.3",
"strip-json-comments": "2.0.1",
"testswarm": "1.1.0"
},
"directories": {},
"dist": {
"shasum": "5c4d9de652af6cd0a770154a631bba12b015c787",
"tarball": "https://registry.npmjs.org/jquery/-/jquery-3.2.1.tgz"
},
"gitHead": "77d2a51d0520d2ee44173afdf4e40a9201f5964e",
"homepage": "https://jquery.com",
"keywords": [
"jquery",
"javascript",
"browser",
"library"
],
"license": "MIT",
"main": "dist/jquery.js",
"maintainers": [
{
"email": "dave.methvin@gmail.com",
"name": "dmethvin"
},
{
"email": "m.goleb@gmail.com",
"name": "mgol"
},
{
"email": "scott.gonzalez@gmail.com",
"name": "scott.gonzalez"
},
{
"email": "4timmywil@gmail.com",
"name": "timmywil"
}
],
"name": "jquery",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/jquery/jquery.git"
},
"scripts": {
"build": "npm install && grunt",
"commitmsg": "node node_modules/commitplease",
"precommit": "grunt lint:newer",
"start": "grunt watch",
"test": "grunt && grunt test:slow"
},
"title": "jQuery",
"version": "3.2.1"
}
{
"root": true,
"extends": "../.eslintrc-browser.json"
}
This diff is collapsed. Click to expand it.
define( [
"../core",
"./var/nonce",
"./var/rquery",
"../ajax"
], function( jQuery, nonce, rquery ) {
"use strict";
var oldCallbacks = [],
rjsonp = /(=)\?(?=&|$)|\?\?/;
// Default jsonp settings
jQuery.ajaxSetup( {
jsonp: "callback",
jsonpCallback: function() {
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
this[ callback ] = true;
return callback;
}
} );
// Detect, normalize options and install callbacks for jsonp requests
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
var callbackName, overwritten, responseContainer,
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
"url" :
typeof s.data === "string" &&
( s.contentType || "" )
.indexOf( "application/x-www-form-urlencoded" ) === 0 &&
rjsonp.test( s.data ) && "data"
);
// Handle iff the expected data type is "jsonp" or we have a parameter to set
if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
// Get callback name, remembering preexisting value associated with it
callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
s.jsonpCallback() :
s.jsonpCallback;
// Insert callback into url or form data
if ( jsonProp ) {
s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
} else if ( s.jsonp !== false ) {
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
}
// Use data converter to retrieve json after script execution
s.converters[ "script json" ] = function() {
if ( !responseContainer ) {
jQuery.error( callbackName + " was not called" );
}
return responseContainer[ 0 ];
};
// Force json dataType
s.dataTypes[ 0 ] = "json";
// Install callback
overwritten = window[ callbackName ];
window[ callbackName ] = function() {
responseContainer = arguments;
};
// Clean-up function (fires after converters)
jqXHR.always( function() {
// If previous value didn't exist - remove it
if ( overwritten === undefined ) {
jQuery( window ).removeProp( callbackName );
// Otherwise restore preexisting value
} else {
window[ callbackName ] = overwritten;
}
// Save back as free
if ( s[ callbackName ] ) {
// Make sure that re-using the options doesn't screw things around
s.jsonpCallback = originalSettings.jsonpCallback;
// Save the callback name for future use
oldCallbacks.push( callbackName );
}
// Call if it was a function and we have a response
if ( responseContainer && jQuery.isFunction( overwritten ) ) {
overwritten( responseContainer[ 0 ] );
}
responseContainer = overwritten = undefined;
} );
// Delegate to script
return "script";
}
} );
} );
define( [
"../core",
"../core/stripAndCollapse",
"../core/parseHTML",
"../ajax",
"../traversing",
"../manipulation",
"../selector"
], function( jQuery, stripAndCollapse ) {
"use strict";
/**
* Load a url into a page
*/
jQuery.fn.load = function( url, params, callback ) {
var selector, type, response,
self = this,
off = url.indexOf( " " );
if ( off > -1 ) {
selector = stripAndCollapse( url.slice( off ) );
url = url.slice( 0, off );
}
// If it's a function
if ( jQuery.isFunction( params ) ) {
// We assume that it's the callback
callback = params;
params = undefined;
// Otherwise, build a param string
} else if ( params && typeof params === "object" ) {
type = "POST";
}
// If we have elements to modify, make the request
if ( self.length > 0 ) {
jQuery.ajax( {
url: url,
// If "type" variable is undefined, then "GET" method will be used.
// Make value of this field explicit since
// user can override it through ajaxSetup method
type: type || "GET",
dataType: "html",
data: params
} ).done( function( responseText ) {
// Save response for use in complete callback
response = arguments;
self.html( selector ?
// If a selector was specified, locate the right elements in a dummy div
// Exclude scripts to avoid IE 'Permission Denied' errors
jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
// Otherwise use the full result
responseText );
// If the request succeeds, this function gets "data", "status", "jqXHR"
// but they are ignored because response was set above.
// If it fails, this function gets "jqXHR", "status", "error"
} ).always( callback && function( jqXHR, status ) {
self.each( function() {
callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
} );
} );
}
return this;
};
} );
define( [
"../core"
], function( jQuery ) {
"use strict";
// Cross-browser xml parsing
jQuery.parseXML = function( data ) {
var xml;
if ( !data || typeof data !== "string" ) {
return null;
}
// Support: IE 9 - 11 only
// IE throws on parseFromString with invalid input.
try {
xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
} catch ( e ) {
xml = undefined;
}
if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
jQuery.error( "Invalid XML: " + data );
}
return xml;
};
return jQuery.parseXML;
} );
define( [
"../core",
"../var/document",
"../ajax"
], function( jQuery, document ) {
"use strict";
// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
jQuery.ajaxPrefilter( function( s ) {
if ( s.crossDomain ) {
s.contents.script = false;
}
} );
// Install script dataType
jQuery.ajaxSetup( {
accepts: {
script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript"
},
contents: {
script: /\b(?:java|ecma)script\b/
},
converters: {
"text script": function( text ) {
jQuery.globalEval( text );
return text;
}
}
} );
// Handle cache's special case and crossDomain
jQuery.ajaxPrefilter( "script", function( s ) {
if ( s.cache === undefined ) {
s.cache = false;
}
if ( s.crossDomain ) {
s.type = "GET";
}
} );
// Bind script tag hack transport
jQuery.ajaxTransport( "script", function( s ) {
// This transport only deals with cross domain requests
if ( s.crossDomain ) {
var script, callback;
return {
send: function( _, complete ) {
script = jQuery( "<script>" ).prop( {
charset: s.scriptCharset,
src: s.url
} ).on(
"load error",
callback = function( evt ) {
script.remove();
callback = null;
if ( evt ) {
complete( evt.type === "error" ? 404 : 200, evt.type );
}
}
);
// Use native DOM manipulation to avoid our domManip AJAX trickery
document.head.appendChild( script[ 0 ] );
},
abort: function() {
if ( callback ) {
callback();
}
}
};
}
} );
} );
define( function() {
"use strict";
return window.location;
} );
define( [
"../../core"
], function( jQuery ) {
"use strict";
return jQuery.now();
} );
define( function() {
"use strict";
return ( /\?/ );
} );
define( [
"../core",
"../var/support",
"../ajax"
], function( jQuery, support ) {
"use strict";
jQuery.ajaxSettings.xhr = function() {
try {
return new window.XMLHttpRequest();
} catch ( e ) {}
};
var xhrSuccessStatus = {
// File protocol always yields status code 0, assume 200
0: 200,
// Support: IE <=9 only
// #1450: sometimes IE returns 1223 when it should be 204
1223: 204
},
xhrSupported = jQuery.ajaxSettings.xhr();
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
support.ajax = xhrSupported = !!xhrSupported;
jQuery.ajaxTransport( function( options ) {
var callback, errorCallback;
// Cross domain only allowed if supported through XMLHttpRequest
if ( support.cors || xhrSupported && !options.crossDomain ) {
return {
send: function( headers, complete ) {
var i,
xhr = options.xhr();
xhr.open(
options.type,
options.url,
options.async,
options.username,
options.password
);
// Apply custom fields if provided
if ( options.xhrFields ) {
for ( i in options.xhrFields ) {
xhr[ i ] = options.xhrFields[ i ];
}
}
// Override mime type if needed
if ( options.mimeType && xhr.overrideMimeType ) {
xhr.overrideMimeType( options.mimeType );
}
// X-Requested-With header
// For cross-domain requests, seeing as conditions for a preflight are
// akin to a jigsaw puzzle, we simply never set it to be sure.
// (it can always be set on a per-request basis or even using ajaxSetup)
// For same-domain requests, won't change header if already provided.
if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
headers[ "X-Requested-With" ] = "XMLHttpRequest";
}
// Set headers
for ( i in headers ) {
xhr.setRequestHeader( i, headers[ i ] );
}
// Callback
callback = function( type ) {
return function() {
if ( callback ) {
callback = errorCallback = xhr.onload =
xhr.onerror = xhr.onabort = xhr.onreadystatechange = null;
if ( type === "abort" ) {
xhr.abort();
} else if ( type === "error" ) {
// Support: IE <=9 only
// On a manual native abort, IE9 throws
// errors on any property access that is not readyState
if ( typeof xhr.status !== "number" ) {
complete( 0, "error" );
} else {
complete(
// File: protocol always yields status 0; see #8605, #14207
xhr.status,
xhr.statusText
);
}
} else {
complete(
xhrSuccessStatus[ xhr.status ] || xhr.status,
xhr.statusText,
// Support: IE <=9 only
// IE9 has no XHR2 but throws on binary (trac-11426)
// For XHR2 non-text, let the caller handle it (gh-2498)
( xhr.responseType || "text" ) !== "text" ||
typeof xhr.responseText !== "string" ?
{ binary: xhr.response } :
{ text: xhr.responseText },
xhr.getAllResponseHeaders()
);
}
}
};
};
// Listen to events
xhr.onload = callback();
errorCallback = xhr.onerror = callback( "error" );
// Support: IE 9 only
// Use onreadystatechange to replace onabort
// to handle uncaught aborts
if ( xhr.onabort !== undefined ) {
xhr.onabort = errorCallback;
} else {
xhr.onreadystatechange = function() {
// Check readyState before timeout as it changes
if ( xhr.readyState === 4 ) {
// Allow onerror to be called first,
// but that will not handle a native abort
// Also, save errorCallback to a variable
// as xhr.onerror cannot be accessed
window.setTimeout( function() {
if ( callback ) {
errorCallback();
}
} );
}
};
}
// Create the abort callback
callback = callback( "abort" );
try {
// Do send the request (this may raise an exception)
xhr.send( options.hasContent && options.data || null );
} catch ( e ) {
// #14683: Only rethrow if this hasn't been notified as an error yet
if ( callback ) {
throw e;
}
}
},
abort: function() {
if ( callback ) {
callback();
}
}
};
}
} );
} );
define( [
"./core",
"./attributes/attr",
"./attributes/prop",
"./attributes/classes",
"./attributes/val"
], function( jQuery ) {
"use strict";
// Return jQuery for attributes-only inclusion
return jQuery;
} );
define( [
"../core",
"../core/access",
"../core/nodeName",
"./support",
"../var/rnothtmlwhite",
"../selector"
], function( jQuery, access, nodeName, support, rnothtmlwhite ) {
"use strict";
var boolHook,
attrHandle = jQuery.expr.attrHandle;
jQuery.fn.extend( {
attr: function( name, value ) {
return access( this, jQuery.attr, name, value, arguments.length > 1 );
},
removeAttr: function( name ) {
return this.each( function() {
jQuery.removeAttr( this, name );
} );
}
} );
jQuery.extend( {
attr: function( elem, name, value ) {
var ret, hooks,
nType = elem.nodeType;
// Don't get/set attributes on text, comment and attribute nodes
if ( nType === 3 || nType === 8 || nType === 2 ) {
return;
}
// Fallback to prop when attributes are not supported
if ( typeof elem.getAttribute === "undefined" ) {
return jQuery.prop( elem, name, value );
}
// Attribute hooks are determined by the lowercase version
// Grab necessary hook if one is defined
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
}
if ( value !== undefined ) {
if ( value === null ) {
jQuery.removeAttr( elem, name );
return;
}
if ( hooks && "set" in hooks &&
( ret = hooks.set( elem, value, name ) ) !== undefined ) {
return ret;
}
elem.setAttribute( name, value + "" );
return value;
}
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
return ret;
}
ret = jQuery.find.attr( elem, name );
// Non-existent attributes return null, we normalize to undefined
return ret == null ? undefined : ret;
},
attrHooks: {
type: {
set: function( elem, value ) {
if ( !support.radioValue && value === "radio" &&
nodeName( elem, "input" ) ) {
var val = elem.value;
elem.setAttribute( "type", value );
if ( val ) {
elem.value = val;
}
return value;
}
}
}
},
removeAttr: function( elem, value ) {
var name,
i = 0,
// Attribute names can contain non-HTML whitespace characters
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
attrNames = value && value.match( rnothtmlwhite );
if ( attrNames && elem.nodeType === 1 ) {
while ( ( name = attrNames[ i++ ] ) ) {
elem.removeAttribute( name );
}
}
}
} );
// Hooks for boolean attributes
boolHook = {
set: function( elem, value, name ) {
if ( value === false ) {
// Remove boolean attributes when set to false
jQuery.removeAttr( elem, name );
} else {
elem.setAttribute( name, name );
}
return name;
}
};
jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
var getter = attrHandle[ name ] || jQuery.find.attr;
attrHandle[ name ] = function( elem, name, isXML ) {
var ret, handle,
lowercaseName = name.toLowerCase();
if ( !isXML ) {
// Avoid an infinite loop by temporarily removing this function from the getter
handle = attrHandle[ lowercaseName ];
attrHandle[ lowercaseName ] = ret;
ret = getter( elem, name, isXML ) != null ?
lowercaseName :
null;
attrHandle[ lowercaseName ] = handle;
}
return ret;
};
} );
} );
define( [
"../core",
"../core/stripAndCollapse",
"../var/rnothtmlwhite",
"../data/var/dataPriv",
"../core/init"
], function( jQuery, stripAndCollapse, rnothtmlwhite, dataPriv ) {
"use strict";
function getClass( elem ) {
return elem.getAttribute && elem.getAttribute( "class" ) || "";
}
jQuery.fn.extend( {
addClass: function( value ) {
var classes, elem, cur, curValue, clazz, j, finalValue,
i = 0;
if ( jQuery.isFunction( value ) ) {
return this.each( function( j ) {
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
} );
}
if ( typeof value === "string" && value ) {
classes = value.match( rnothtmlwhite ) || [];
while ( ( elem = this[ i++ ] ) ) {
curValue = getClass( elem );
cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
if ( cur ) {
j = 0;
while ( ( clazz = classes[ j++ ] ) ) {
if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
cur += clazz + " ";
}
}
// Only assign if different to avoid unneeded rendering.
finalValue = stripAndCollapse( cur );
if ( curValue !== finalValue ) {
elem.setAttribute( "class", finalValue );
}
}
}
}
return this;
},
removeClass: function( value ) {
var classes, elem, cur, curValue, clazz, j, finalValue,
i = 0;
if ( jQuery.isFunction( value ) ) {
return this.each( function( j ) {
jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
} );
}
if ( !arguments.length ) {
return this.attr( "class", "" );
}
if ( typeof value === "string" && value ) {
classes = value.match( rnothtmlwhite ) || [];
while ( ( elem = this[ i++ ] ) ) {
curValue = getClass( elem );
// This expression is here for better compressibility (see addClass)
cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
if ( cur ) {
j = 0;
while ( ( clazz = classes[ j++ ] ) ) {
// Remove *all* instances
while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
cur = cur.replace( " " + clazz + " ", " " );
}
}
// Only assign if different to avoid unneeded rendering.
finalValue = stripAndCollapse( cur );
if ( curValue !== finalValue ) {
elem.setAttribute( "class", finalValue );
}
}
}
}
return this;
},
toggleClass: function( value, stateVal ) {
var type = typeof value;
if ( typeof stateVal === "boolean" && type === "string" ) {
return stateVal ? this.addClass( value ) : this.removeClass( value );
}
if ( jQuery.isFunction( value ) ) {
return this.each( function( i ) {
jQuery( this ).toggleClass(
value.call( this, i, getClass( this ), stateVal ),
stateVal
);
} );
}
return this.each( function() {
var className, i, self, classNames;
if ( type === "string" ) {
// Toggle individual class names
i = 0;
self = jQuery( this );
classNames = value.match( rnothtmlwhite ) || [];
while ( ( className = classNames[ i++ ] ) ) {
// Check each className given, space separated list
if ( self.hasClass( className ) ) {
self.removeClass( className );
} else {
self.addClass( className );
}
}
// Toggle whole class name
} else if ( value === undefined || type === "boolean" ) {
className = getClass( this );
if ( className ) {
// Store className if set
dataPriv.set( this, "__className__", className );
}
// If the element has a class name or if we're passed `false`,
// then remove the whole classname (if there was one, the above saved it).
// Otherwise bring back whatever was previously saved (if anything),
// falling back to the empty string if nothing was stored.
if ( this.setAttribute ) {
this.setAttribute( "class",
className || value === false ?
"" :
dataPriv.get( this, "__className__" ) || ""
);
}
}
} );
},
hasClass: function( selector ) {
var className, elem,
i = 0;
className = " " + selector + " ";
while ( ( elem = this[ i++ ] ) ) {
if ( elem.nodeType === 1 &&
( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
return true;
}
}
return false;
}
} );
} );
define( [
"../core",
"../core/access",
"./support",
"../selector"
], function( jQuery, access, support ) {
"use strict";
var rfocusable = /^(?:input|select|textarea|button)$/i,
rclickable = /^(?:a|area)$/i;
jQuery.fn.extend( {
prop: function( name, value ) {
return access( this, jQuery.prop, name, value, arguments.length > 1 );
},
removeProp: function( name ) {
return this.each( function() {
delete this[ jQuery.propFix[ name ] || name ];
} );
}
} );
jQuery.extend( {
prop: function( elem, name, value ) {
var ret, hooks,
nType = elem.nodeType;
// Don't get/set properties on text, comment and attribute nodes
if ( nType === 3 || nType === 8 || nType === 2 ) {
return;
}
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
// Fix name and attach hooks
name = jQuery.propFix[ name ] || name;
hooks = jQuery.propHooks[ name ];
}
if ( value !== undefined ) {
if ( hooks && "set" in hooks &&
( ret = hooks.set( elem, value, name ) ) !== undefined ) {
return ret;
}
return ( elem[ name ] = value );
}
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
return ret;
}
return elem[ name ];
},
propHooks: {
tabIndex: {
get: function( elem ) {
// Support: IE <=9 - 11 only
// elem.tabIndex doesn't always return the
// correct value when it hasn't been explicitly set
// https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
// Use proper attribute retrieval(#12072)
var tabindex = jQuery.find.attr( elem, "tabindex" );
if ( tabindex ) {
return parseInt( tabindex, 10 );
}
if (
rfocusable.test( elem.nodeName ) ||
rclickable.test( elem.nodeName ) &&
elem.href
) {
return 0;
}
return -1;
}
}
},
propFix: {
"for": "htmlFor",
"class": "className"
}
} );
// Support: IE <=11 only
// Accessing the selectedIndex property
// forces the browser to respect setting selected
// on the option
// The getter ensures a default option is selected
// when in an optgroup
// eslint rule "no-unused-expressions" is disabled for this code
// since it considers such accessions noop
if ( !support.optSelected ) {
jQuery.propHooks.selected = {
get: function( elem ) {
/* eslint no-unused-expressions: "off" */
var parent = elem.parentNode;
if ( parent && parent.parentNode ) {
parent.parentNode.selectedIndex;
}
return null;
},
set: function( elem ) {
/* eslint no-unused-expressions: "off" */
var parent = elem.parentNode;
if ( parent ) {
parent.selectedIndex;
if ( parent.parentNode ) {
parent.parentNode.selectedIndex;
}
}
}
};
}
jQuery.each( [
"tabIndex",
"readOnly",
"maxLength",
"cellSpacing",
"cellPadding",
"rowSpan",
"colSpan",
"useMap",
"frameBorder",
"contentEditable"
], function() {
jQuery.propFix[ this.toLowerCase() ] = this;
} );
} );
define( [
"../var/document",
"../var/support"
], function( document, support ) {
"use strict";
( function() {
var input = document.createElement( "input" ),
select = document.createElement( "select" ),
opt = select.appendChild( document.createElement( "option" ) );
input.type = "checkbox";
// Support: Android <=4.3 only
// Default value for a checkbox should be "on"
support.checkOn = input.value !== "";
// Support: IE <=11 only
// Must access selectedIndex to make default options select
support.optSelected = opt.selected;
// Support: IE <=11 only
// An input loses its value after becoming a radio
input = document.createElement( "input" );
input.value = "t";
input.type = "radio";
support.radioValue = input.value === "t";
} )();
return support;
} );
define( [
"../core",
"../core/stripAndCollapse",
"./support",
"../core/nodeName",
"../core/init"
], function( jQuery, stripAndCollapse, support, nodeName ) {
"use strict";
var rreturn = /\r/g;
jQuery.fn.extend( {
val: function( value ) {
var hooks, ret, isFunction,
elem = this[ 0 ];
if ( !arguments.length ) {
if ( elem ) {
hooks = jQuery.valHooks[ elem.type ] ||
jQuery.valHooks[ elem.nodeName.toLowerCase() ];
if ( hooks &&
"get" in hooks &&
( ret = hooks.get( elem, "value" ) ) !== undefined
) {
return ret;
}
ret = elem.value;
// Handle most common string cases
if ( typeof ret === "string" ) {
return ret.replace( rreturn, "" );
}
// Handle cases where value is null/undef or number
return ret == null ? "" : ret;
}
return;
}
isFunction = jQuery.isFunction( value );
return this.each( function( i ) {
var val;
if ( this.nodeType !== 1 ) {
return;
}
if ( isFunction ) {
val = value.call( this, i, jQuery( this ).val() );
} else {
val = value;
}
// Treat null/undefined as ""; convert numbers to string
if ( val == null ) {
val = "";
} else if ( typeof val === "number" ) {
val += "";
} else if ( Array.isArray( val ) ) {
val = jQuery.map( val, function( value ) {
return value == null ? "" : value + "";
} );
}
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
// If set returns undefined, fall back to normal setting
if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
this.value = val;
}
} );
}
} );
jQuery.extend( {
valHooks: {
option: {
get: function( elem ) {
var val = jQuery.find.attr( elem, "value" );
return val != null ?
val :
// Support: IE <=10 - 11 only
// option.text throws exceptions (#14686, #14858)
// Strip and collapse whitespace
// https://html.spec.whatwg.org/#strip-and-collapse-whitespace
stripAndCollapse( jQuery.text( elem ) );
}
},
select: {
get: function( elem ) {
var value, option, i,
options = elem.options,
index = elem.selectedIndex,
one = elem.type === "select-one",
values = one ? null : [],
max = one ? index + 1 : options.length;
if ( index < 0 ) {
i = max;
} else {
i = one ? index : 0;
}
// Loop through all the selected options
for ( ; i < max; i++ ) {
option = options[ i ];
// Support: IE <=9 only
// IE8-9 doesn't update selected after form reset (#2551)
if ( ( option.selected || i === index ) &&
// Don't return options that are disabled or in a disabled optgroup
!option.disabled &&
( !option.parentNode.disabled ||
!nodeName( option.parentNode, "optgroup" ) ) ) {
// Get the specific value for the option
value = jQuery( option ).val();
// We don't need an array for one selects
if ( one ) {
return value;
}
// Multi-Selects return an array
values.push( value );
}
}
return values;
},
set: function( elem, value ) {
var optionSet, option,
options = elem.options,
values = jQuery.makeArray( value ),
i = options.length;
while ( i-- ) {
option = options[ i ];
/* eslint-disable no-cond-assign */
if ( option.selected =
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
) {
optionSet = true;
}
/* eslint-enable no-cond-assign */
}
// Force browsers to behave consistently when non-matching value is set
if ( !optionSet ) {
elem.selectedIndex = -1;
}
return values;
}
}
}
} );
// Radios and checkboxes getter/setter
jQuery.each( [ "radio", "checkbox" ], function() {
jQuery.valHooks[ this ] = {
set: function( elem, value ) {
if ( Array.isArray( value ) ) {
return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
}
}
};
if ( !support.checkOn ) {
jQuery.valHooks[ this ].get = function( elem ) {
return elem.getAttribute( "value" ) === null ? "on" : elem.value;
};
}
} );
} );
define( [
"./core",
"./var/rnothtmlwhite"
], function( jQuery, rnothtmlwhite ) {
"use strict";
// Convert String-formatted options into Object-formatted ones
function createOptions( options ) {
var object = {};
jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
object[ flag ] = true;
} );
return object;
}
/*
* Create a callback list using the following parameters:
*
* options: an optional list of space-separated options that will change how
* the callback list behaves or a more traditional option object
*
* By default a callback list will act like an event callback list and can be
* "fired" multiple times.
*
* Possible options:
*
* once: will ensure the callback list can only be fired once (like a Deferred)
*
* memory: will keep track of previous values and will call any callback added
* after the list has been fired right away with the latest "memorized"
* values (like a Deferred)
*
* unique: will ensure a callback can only be added once (no duplicate in the list)
*
* stopOnFalse: interrupt callings when a callback returns false
*
*/
jQuery.Callbacks = function( options ) {
// Convert options from String-formatted to Object-formatted if needed
// (we check in cache first)
options = typeof options === "string" ?
createOptions( options ) :
jQuery.extend( {}, options );
var // Flag to know if list is currently firing
firing,
// Last fire value for non-forgettable lists
memory,
// Flag to know if list was already fired
fired,
// Flag to prevent firing
locked,
// Actual callback list
list = [],
// Queue of execution data for repeatable lists
queue = [],
// Index of currently firing callback (modified by add/remove as needed)
firingIndex = -1,
// Fire callbacks
fire = function() {
// Enforce single-firing
locked = locked || options.once;
// Execute callbacks for all pending executions,
// respecting firingIndex overrides and runtime changes
fired = firing = true;
for ( ; queue.length; firingIndex = -1 ) {
memory = queue.shift();
while ( ++firingIndex < list.length ) {
// Run callback and check for early termination
if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
options.stopOnFalse ) {
// Jump to end and forget the data so .add doesn't re-fire
firingIndex = list.length;
memory = false;
}
}
}
// Forget the data if we're done with it
if ( !options.memory ) {
memory = false;
}
firing = false;
// Clean up if we're done firing for good
if ( locked ) {
// Keep an empty list if we have data for future add calls
if ( memory ) {
list = [];
// Otherwise, this object is spent
} else {
list = "";
}
}
},
// Actual Callbacks object
self = {
// Add a callback or a collection of callbacks to the list
add: function() {
if ( list ) {
// If we have memory from a past run, we should fire after adding
if ( memory && !firing ) {
firingIndex = list.length - 1;
queue.push( memory );
}
( function add( args ) {
jQuery.each( args, function( _, arg ) {
if ( jQuery.isFunction( arg ) ) {
if ( !options.unique || !self.has( arg ) ) {
list.push( arg );
}
} else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
// Inspect recursively
add( arg );
}
} );
} )( arguments );
if ( memory && !firing ) {
fire();
}
}
return this;
},
// Remove a callback from the list
remove: function() {
jQuery.each( arguments, function( _, arg ) {
var index;
while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
list.splice( index, 1 );
// Handle firing indexes
if ( index <= firingIndex ) {
firingIndex--;
}
}
} );
return this;
},
// Check if a given callback is in the list.
// If no argument is given, return whether or not list has callbacks attached.
has: function( fn ) {
return fn ?
jQuery.inArray( fn, list ) > -1 :
list.length > 0;
},
// Remove all callbacks from the list
empty: function() {
if ( list ) {
list = [];
}
return this;
},
// Disable .fire and .add
// Abort any current/pending executions
// Clear all callbacks and values
disable: function() {
locked = queue = [];
list = memory = "";
return this;
},
disabled: function() {
return !list;
},
// Disable .fire
// Also disable .add unless we have memory (since it would have no effect)
// Abort any pending executions
lock: function() {
locked = queue = [];
if ( !memory && !firing ) {
list = memory = "";
}
return this;
},
locked: function() {
return !!locked;
},
// Call all callbacks with the given context and arguments
fireWith: function( context, args ) {
if ( !locked ) {
args = args || [];
args = [ context, args.slice ? args.slice() : args ];
queue.push( args );
if ( !firing ) {
fire();
}
}
return this;
},
// Call all the callbacks with the given arguments
fire: function() {
self.fireWith( this, arguments );
return this;
},
// To know if the callbacks have already been called at least once
fired: function() {
return !!fired;
}
};
return self;
};
return jQuery;
} );
This diff is collapsed. Click to expand it.
define( [
"../var/document"
], function( document ) {
"use strict";
function DOMEval( code, doc ) {
doc = doc || document;
var script = doc.createElement( "script" );
script.text = code;
doc.head.appendChild( script ).parentNode.removeChild( script );
}
return DOMEval;
} );
define( [
"../core"
], function( jQuery ) {
"use strict";
// Multifunctional method to get and set values of a collection
// The value/s can optionally be executed if it's a function
var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
var i = 0,
len = elems.length,
bulk = key == null;
// Sets many values
if ( jQuery.type( key ) === "object" ) {
chainable = true;
for ( i in key ) {
access( elems, fn, i, key[ i ], true, emptyGet, raw );
}
// Sets one value
} else if ( value !== undefined ) {
chainable = true;
if ( !jQuery.isFunction( value ) ) {
raw = true;
}
if ( bulk ) {
// Bulk operations run against the entire set
if ( raw ) {
fn.call( elems, value );
fn = null;
// ...except when executing function values
} else {
bulk = fn;
fn = function( elem, key, value ) {
return bulk.call( jQuery( elem ), value );
};
}
}
if ( fn ) {
for ( ; i < len; i++ ) {
fn(
elems[ i ], key, raw ?
value :
value.call( elems[ i ], i, fn( elems[ i ], key ) )
);
}
}
}
if ( chainable ) {
return elems;
}
// Gets
if ( bulk ) {
return fn.call( elems );
}
return len ? fn( elems[ 0 ], key ) : emptyGet;
};
return access;
} );
// Initialize a jQuery object
define( [
"../core",
"../var/document",
"./var/rsingleTag",
"../traversing/findFilter"
], function( jQuery, document, rsingleTag ) {
"use strict";
// A central reference to the root jQuery(document)
var rootjQuery,
// A simple way to check for HTML strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
// Strict HTML recognition (#11290: must start with <)
// Shortcut simple #id case for speed
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
init = jQuery.fn.init = function( selector, context, root ) {
var match, elem;
// HANDLE: $(""), $(null), $(undefined), $(false)
if ( !selector ) {
return this;
}
// Method init() accepts an alternate rootjQuery
// so migrate can support jQuery.sub (gh-2101)
root = root || rootjQuery;
// Handle HTML strings
if ( typeof selector === "string" ) {
if ( selector[ 0 ] === "<" &&
selector[ selector.length - 1 ] === ">" &&
selector.length >= 3 ) {
// Assume that strings that start and end with <> are HTML and skip the regex check
match = [ null, selector, null ];
} else {
match = rquickExpr.exec( selector );
}
// Match html or make sure no context is specified for #id
if ( match && ( match[ 1 ] || !context ) ) {
// HANDLE: $(html) -> $(array)
if ( match[ 1 ] ) {
context = context instanceof jQuery ? context[ 0 ] : context;
// Option to run scripts is true for back-compat
// Intentionally let the error be thrown if parseHTML is not present
jQuery.merge( this, jQuery.parseHTML(
match[ 1 ],
context && context.nodeType ? context.ownerDocument || context : document,
true
) );
// HANDLE: $(html, props)
if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
for ( match in context ) {
// Properties of context are called as methods if possible
if ( jQuery.isFunction( this[ match ] ) ) {
this[ match ]( context[ match ] );
// ...and otherwise set as attributes
} else {
this.attr( match, context[ match ] );
}
}
}
return this;
// HANDLE: $(#id)
} else {
elem = document.getElementById( match[ 2 ] );
if ( elem ) {
// Inject the element directly into the jQuery object
this[ 0 ] = elem;
this.length = 1;
}
return this;
}
// HANDLE: $(expr, $(...))
} else if ( !context || context.jquery ) {
return ( context || root ).find( selector );
// HANDLE: $(expr, context)
// (which is just equivalent to: $(context).find(expr)
} else {
return this.constructor( context ).find( selector );
}
// HANDLE: $(DOMElement)
} else if ( selector.nodeType ) {
this[ 0 ] = selector;
this.length = 1;
return this;
// HANDLE: $(function)
// Shortcut for document ready
} else if ( jQuery.isFunction( selector ) ) {
return root.ready !== undefined ?
root.ready( selector ) :
// Execute immediately if ready is not present
selector( jQuery );
}
return jQuery.makeArray( selector, this );
};
// Give the init function the jQuery prototype for later instantiation
init.prototype = jQuery.fn;
// Initialize central reference
rootjQuery = jQuery( document );
return init;
} );
define( function() {
"use strict";
function nodeName( elem, name ) {
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
};
return nodeName;
} );
define( [
"../core",
"../var/document",
"./var/rsingleTag",
"../manipulation/buildFragment",
// This is the only module that needs core/support
"./support"
], function( jQuery, document, rsingleTag, buildFragment, support ) {
"use strict";
// Argument "data" should be string of html
// context (optional): If specified, the fragment will be created in this context,
// defaults to document
// keepScripts (optional): If true, will include scripts passed in the html string
jQuery.parseHTML = function( data, context, keepScripts ) {
if ( typeof data !== "string" ) {
return [];
}
if ( typeof context === "boolean" ) {
keepScripts = context;
context = false;
}
var base, parsed, scripts;
if ( !context ) {
// Stop scripts or inline event handlers from being executed immediately
// by using document.implementation
if ( support.createHTMLDocument ) {
context = document.implementation.createHTMLDocument( "" );
// Set the base href for the created document
// so any parsed elements with URLs
// are based on the document's URL (gh-2965)
base = context.createElement( "base" );
base.href = document.location.href;
context.head.appendChild( base );
} else {
context = document;
}
}
parsed = rsingleTag.exec( data );
scripts = !keepScripts && [];
// Single tag
if ( parsed ) {
return [ context.createElement( parsed[ 1 ] ) ];
}
parsed = buildFragment( [ data ], context, scripts );
if ( scripts && scripts.length ) {
jQuery( scripts ).remove();
}
return jQuery.merge( [], parsed.childNodes );
};
return jQuery.parseHTML;
} );
define( [
"../core",
"../var/document"
], function( jQuery, document ) {
"use strict";
var readyCallbacks = [],
whenReady = function( fn ) {
readyCallbacks.push( fn );
},
executeReady = function( fn ) {
// Prevent errors from freezing future callback execution (gh-1823)
// Not backwards-compatible as this does not execute sync
window.setTimeout( function() {
fn.call( document, jQuery );
} );
};
jQuery.fn.ready = function( fn ) {
whenReady( fn );
return this;
};
jQuery.extend( {
// Is the DOM ready to be used? Set to true once it occurs.
isReady: false,
// A counter to track how many items to wait for before
// the ready event fires. See #6781
readyWait: 1,
ready: function( wait ) {
// Abort if there are pending holds or we're already ready
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
return;
}
// Remember that the DOM is ready
jQuery.isReady = true;
// If a normal DOM Ready event fired, decrement, and wait if need be
if ( wait !== true && --jQuery.readyWait > 0 ) {
return;
}
whenReady = function( fn ) {
readyCallbacks.push( fn );
while ( readyCallbacks.length ) {
fn = readyCallbacks.shift();
if ( jQuery.isFunction( fn ) ) {
executeReady( fn );
}
}
};
whenReady();
}
} );
// Make jQuery.ready Promise consumable (gh-1778)
jQuery.ready.then = jQuery.fn.ready;
/**
* The ready event handler and self cleanup method
*/
function completed() {
document.removeEventListener( "DOMContentLoaded", completed );
window.removeEventListener( "load", completed );
jQuery.ready();
}
// Catch cases where $(document).ready() is called
// after the browser event has already occurred.
// Support: IE9-10 only
// Older IE sometimes signals "interactive" too soon
if ( document.readyState === "complete" ||
( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready
window.setTimeout( jQuery.ready );
} else {
// Use the handy event callback
document.addEventListener( "DOMContentLoaded", completed );
// A fallback to window.onload, that will always work
window.addEventListener( "load", completed );
}
} );
define( [
"../core",
"../var/document",
"../core/readyException",
"../deferred"
], function( jQuery, document ) {
"use strict";
// The deferred used on DOM ready
var readyList = jQuery.Deferred();
jQuery.fn.ready = function( fn ) {
readyList
.then( fn )
// Wrap jQuery.readyException in a function so that the lookup
// happens at the time of error handling instead of callback
// registration.
.catch( function( error ) {
jQuery.readyException( error );
} );
return this;
};
jQuery.extend( {
// Is the DOM ready to be used? Set to true once it occurs.
isReady: false,
// A counter to track how many items to wait for before
// the ready event fires. See #6781
readyWait: 1,
// Handle when the DOM is ready
ready: function( wait ) {
// Abort if there are pending holds or we're already ready
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
return;
}
// Remember that the DOM is ready
jQuery.isReady = true;
// If a normal DOM Ready event fired, decrement, and wait if need be
if ( wait !== true && --jQuery.readyWait > 0 ) {
return;
}
// If there are functions bound, to execute
readyList.resolveWith( document, [ jQuery ] );
}
} );
jQuery.ready.then = readyList.then;
// The ready event handler and self cleanup method
function completed() {
document.removeEventListener( "DOMContentLoaded", completed );
window.removeEventListener( "load", completed );
jQuery.ready();
}
// Catch cases where $(document).ready() is called
// after the browser event has already occurred.
// Support: IE <=9 - 10 only
// Older IE sometimes signals "interactive" too soon
if ( document.readyState === "complete" ||
( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready
window.setTimeout( jQuery.ready );
} else {
// Use the handy event callback
document.addEventListener( "DOMContentLoaded", completed );
// A fallback to window.onload, that will always work
window.addEventListener( "load", completed );
}
} );
define( [
"../core"
], function( jQuery ) {
"use strict";
jQuery.readyException = function( error ) {
window.setTimeout( function() {
throw error;
} );
};
} );
define( [
"../var/rnothtmlwhite"
], function( rnothtmlwhite ) {
"use strict";
// Strip and collapse whitespace according to HTML spec
// https://html.spec.whatwg.org/multipage/infrastructure.html#strip-and-collapse-whitespace
function stripAndCollapse( value ) {
var tokens = value.match( rnothtmlwhite ) || [];
return tokens.join( " " );
}
return stripAndCollapse;
} );
define( [
"../var/document",
"../var/support"
], function( document, support ) {
"use strict";
// Support: Safari 8 only
// In Safari 8 documents created via document.implementation.createHTMLDocument
// collapse sibling forms: the second one becomes a child of the first one.
// Because of that, this security measure has to be disabled in Safari 8.
// https://bugs.webkit.org/show_bug.cgi?id=137337
support.createHTMLDocument = ( function() {
var body = document.implementation.createHTMLDocument( "" ).body;
body.innerHTML = "<form></form><form></form>";
return body.childNodes.length === 2;
} )();
return support;
} );
define( function() {
"use strict";
// Match a standalone tag
return ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
} );
This diff is collapsed. Click to expand it.
define( function() {
"use strict";
function addGetHookIf( conditionFn, hookFn ) {
// Define the hook, we'll check on the first run if it's really needed.
return {
get: function() {
if ( conditionFn() ) {
// Hook not needed (or it's not possible to use it due
// to missing dependency), remove it.
delete this.get;
return;
}
// Hook needed; redefine it so that the support test is not executed again.
return ( this.get = hookFn ).apply( this, arguments );
}
};
}
return addGetHookIf;
} );
define( [
"../core",
"../var/rcssNum"
], function( jQuery, rcssNum ) {
"use strict";
function adjustCSS( elem, prop, valueParts, tween ) {
var adjusted,
scale = 1,
maxIterations = 20,
currentValue = tween ?
function() {
return tween.cur();
} :
function() {
return jQuery.css( elem, prop, "" );
},
initial = currentValue(),
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
// Starting value computation is required for potential unit mismatches
initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
rcssNum.exec( jQuery.css( elem, prop ) );
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
// Trust units reported by jQuery.css
unit = unit || initialInUnit[ 3 ];
// Make sure we update the tween properties later on
valueParts = valueParts || [];
// Iteratively approximate from a nonzero starting point
initialInUnit = +initial || 1;
do {
// If previous iteration zeroed out, double until we get *something*.
// Use string for doubling so we don't accidentally see scale as unchanged below
scale = scale || ".5";
// Adjust and apply
initialInUnit = initialInUnit / scale;
jQuery.style( elem, prop, initialInUnit + unit );
// Update scale, tolerating zero or NaN from tween.cur()
// Break the loop if scale is unchanged or perfect, or if we've just had enough.
} while (
scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
);
}
if ( valueParts ) {
initialInUnit = +initialInUnit || +initial || 0;
// Apply relative offset (+=/-=) if specified
adjusted = valueParts[ 1 ] ?
initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
+valueParts[ 2 ];
if ( tween ) {
tween.unit = unit;
tween.start = initialInUnit;
tween.end = adjusted;
}
}
return adjusted;
}
return adjustCSS;
} );
define( [
"../core",
"./var/rnumnonpx",
"./var/rmargin",
"./var/getStyles",
"./support",
"../selector" // Get jQuery.contains
], function( jQuery, rnumnonpx, rmargin, getStyles, support ) {
"use strict";
function curCSS( elem, name, computed ) {
var width, minWidth, maxWidth, ret,
// Support: Firefox 51+
// Retrieving style before computed somehow
// fixes an issue with getting wrong values
// on detached elements
style = elem.style;
computed = computed || getStyles( elem );
// getPropertyValue is needed for:
// .css('filter') (IE 9 only, #12537)
// .css('--customProperty) (#3144)
if ( computed ) {
ret = computed.getPropertyValue( name ) || computed[ name ];
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
ret = jQuery.style( elem, name );
}
// A tribute to the "awesome hack by Dean Edwards"
// Android Browser returns percentage for some values,
// but width seems to be reliably pixels.
// This is against the CSSOM draft spec:
// https://drafts.csswg.org/cssom/#resolved-values
if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
// Remember the original values
width = style.width;
minWidth = style.minWidth;
maxWidth = style.maxWidth;
// Put in the new values to get a computed value out
style.minWidth = style.maxWidth = style.width = ret;
ret = computed.width;
// Revert the changed values
style.width = width;
style.minWidth = minWidth;
style.maxWidth = maxWidth;
}
}
return ret !== undefined ?
// Support: IE <=9 - 11 only
// IE returns zIndex value as an integer.
ret + "" :
ret;
}
return curCSS;
} );
define( [
"../core",
"../selector"
], function( jQuery ) {
"use strict";
jQuery.expr.pseudos.hidden = function( elem ) {
return !jQuery.expr.pseudos.visible( elem );
};
jQuery.expr.pseudos.visible = function( elem ) {
return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
};
} );
define( [
"../core",
"../data/var/dataPriv",
"../css/var/isHiddenWithinTree"
], function( jQuery, dataPriv, isHiddenWithinTree ) {
"use strict";
var defaultDisplayMap = {};
function getDefaultDisplay( elem ) {
var temp,
doc = elem.ownerDocument,
nodeName = elem.nodeName,
display = defaultDisplayMap[ nodeName ];
if ( display ) {
return display;
}
temp = doc.body.appendChild( doc.createElement( nodeName ) );
display = jQuery.css( temp, "display" );
temp.parentNode.removeChild( temp );
if ( display === "none" ) {
display = "block";
}
defaultDisplayMap[ nodeName ] = display;
return display;
}
function showHide( elements, show ) {
var display, elem,
values = [],
index = 0,
length = elements.length;
// Determine new display value for elements that need to change
for ( ; index < length; index++ ) {
elem = elements[ index ];
if ( !elem.style ) {
continue;
}
display = elem.style.display;
if ( show ) {
// Since we force visibility upon cascade-hidden elements, an immediate (and slow)
// check is required in this first loop unless we have a nonempty display value (either
// inline or about-to-be-restored)
if ( display === "none" ) {
values[ index ] = dataPriv.get( elem, "display" ) || null;
if ( !values[ index ] ) {
elem.style.display = "";
}
}
if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
values[ index ] = getDefaultDisplay( elem );
}
} else {
if ( display !== "none" ) {
values[ index ] = "none";
// Remember what we're overwriting
dataPriv.set( elem, "display", display );
}
}
}
// Set the display of the elements in a second loop to avoid constant reflow
for ( index = 0; index < length; index++ ) {
if ( values[ index ] != null ) {
elements[ index ].style.display = values[ index ];
}
}
return elements;
}
jQuery.fn.extend( {
show: function() {
return showHide( this, true );
},
hide: function() {
return showHide( this );
},
toggle: function( state ) {
if ( typeof state === "boolean" ) {
return state ? this.show() : this.hide();
}
return this.each( function() {
if ( isHiddenWithinTree( this ) ) {
jQuery( this ).show();
} else {
jQuery( this ).hide();
}
} );
}
} );
return showHide;
} );
define( [
"../core",
"../var/document",
"../var/documentElement",
"../var/support"
], function( jQuery, document, documentElement, support ) {
"use strict";
( function() {
// Executing both pixelPosition & boxSizingReliable tests require only one layout
// so they're executed at the same time to save the second computation.
function computeStyleTests() {
// This is a singleton, we need to execute it only once
if ( !div ) {
return;
}
div.style.cssText =
"box-sizing:border-box;" +
"position:relative;display:block;" +
"margin:auto;border:1px;padding:1px;" +
"top:1%;width:50%";
div.innerHTML = "";
documentElement.appendChild( container );
var divStyle = window.getComputedStyle( div );
pixelPositionVal = divStyle.top !== "1%";
// Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
reliableMarginLeftVal = divStyle.marginLeft === "2px";
boxSizingReliableVal = divStyle.width === "4px";
// Support: Android 4.0 - 4.3 only
// Some styles come back with percentage values, even though they shouldn't
div.style.marginRight = "50%";
pixelMarginRightVal = divStyle.marginRight === "4px";
documentElement.removeChild( container );
// Nullify the div so it wouldn't be stored in the memory and
// it will also be a sign that checks already performed
div = null;
}
var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal,
container = document.createElement( "div" ),
div = document.createElement( "div" );
// Finish early in limited (non-browser) environments
if ( !div.style ) {
return;
}
// Support: IE <=9 - 11 only
// Style of cloned element affects source element cloned (#8908)
div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = "";
support.clearCloneStyle = div.style.backgroundClip === "content-box";
container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
"padding:0;margin-top:1px;position:absolute";
container.appendChild( div );
jQuery.extend( support, {
pixelPosition: function() {
computeStyleTests();
return pixelPositionVal;
},
boxSizingReliable: function() {
computeStyleTests();
return boxSizingReliableVal;
},
pixelMarginRight: function() {
computeStyleTests();
return pixelMarginRightVal;
},
reliableMarginLeft: function() {
computeStyleTests();
return reliableMarginLeftVal;
}
} );
} )();
return support;
} );
define( function() {
"use strict";
return [ "Top", "Right", "Bottom", "Left" ];
} );
define( function() {
"use strict";
return function( elem ) {
// Support: IE <=11 only, Firefox <=30 (#15098, #14150)
// IE throws on elements created in popups
// FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
var view = elem.ownerDocument.defaultView;
if ( !view || !view.opener ) {
view = window;
}
return view.getComputedStyle( elem );
};
} );
define( [
"../../core",
"../../selector"
// css is assumed
], function( jQuery ) {
"use strict";
// isHiddenWithinTree reports if an element has a non-"none" display style (inline and/or
// through the CSS cascade), which is useful in deciding whether or not to make it visible.
// It differs from the :hidden selector (jQuery.expr.pseudos.hidden) in two important ways:
// * A hidden ancestor does not force an element to be classified as hidden.
// * Being disconnected from the document does not force an element to be classified as hidden.
// These differences improve the behavior of .toggle() et al. when applied to elements that are
// detached or contained within hidden ancestors (gh-2404, gh-2863).
return function( elem, el ) {
// isHiddenWithinTree might be called from jQuery#filter function;
// in that case, element will be second argument
elem = el || elem;
// Inline style trumps all
return elem.style.display === "none" ||
elem.style.display === "" &&
// Otherwise, check computed style
// Support: Firefox <=43 - 45
// Disconnected elements can have computed display: none, so first confirm that elem is
// in the document.
jQuery.contains( elem.ownerDocument, elem ) &&
jQuery.css( elem, "display" ) === "none";
};
} );
define( function() {
"use strict";
return ( /^margin/ );
} );
define( [
"../../var/pnum"
], function( pnum ) {
"use strict";
return new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
} );
define( function() {
"use strict";
// A method for quickly swapping in/out CSS properties to get correct calculations.
return function( elem, options, callback, args ) {
var ret, name,
old = {};
// Remember the old values, and insert the new ones
for ( name in options ) {
old[ name ] = elem.style[ name ];
elem.style[ name ] = options[ name ];
}
ret = callback.apply( elem, args || [] );
// Revert the old values
for ( name in options ) {
elem.style[ name ] = old[ name ];
}
return ret;
};
} );
define( [
"./core",
"./core/access",
"./data/var/dataPriv",
"./data/var/dataUser"
], function( jQuery, access, dataPriv, dataUser ) {
"use strict";
// Implementation Summary
//
// 1. Enforce API surface and semantic compatibility with 1.9.x branch
// 2. Improve the module's maintainability by reducing the storage
// paths to a single mechanism.
// 3. Use the same single mechanism to support "private" and "user" data.
// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
// 5. Avoid exposing implementation details on user objects (eg. expando properties)
// 6. Provide a clear path for implementation upgrade to WeakMap in 2014
var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
rmultiDash = /[A-Z]/g;
function getData( data ) {
if ( data === "true" ) {
return true;
}
if ( data === "false" ) {
return false;
}
if ( data === "null" ) {
return null;
}
// Only convert to a number if it doesn't change the string
if ( data === +data + "" ) {
return +data;
}
if ( rbrace.test( data ) ) {
return JSON.parse( data );
}
return data;
}
function dataAttr( elem, key, data ) {
var name;
// If nothing was found internally, try to fetch any
// data from the HTML5 data-* attribute
if ( data === undefined && elem.nodeType === 1 ) {
name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
data = elem.getAttribute( name );
if ( typeof data === "string" ) {
try {
data = getData( data );
} catch ( e ) {}
// Make sure we set the data so it isn't changed later
dataUser.set( elem, key, data );
} else {
data = undefined;
}
}
return data;
}
jQuery.extend( {
hasData: function( elem ) {
return dataUser.hasData( elem ) || dataPriv.hasData( elem );
},
data: function( elem, name, data ) {
return dataUser.access( elem, name, data );
},
removeData: function( elem, name ) {
dataUser.remove( elem, name );
},
// TODO: Now that all calls to _data and _removeData have been replaced
// with direct calls to dataPriv methods, these can be deprecated.
_data: function( elem, name, data ) {
return dataPriv.access( elem, name, data );
},
_removeData: function( elem, name ) {
dataPriv.remove( elem, name );
}
} );
jQuery.fn.extend( {
data: function( key, value ) {
var i, name, data,
elem = this[ 0 ],
attrs = elem && elem.attributes;
// Gets all values
if ( key === undefined ) {
if ( this.length ) {
data = dataUser.get( elem );
if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
i = attrs.length;
while ( i-- ) {
// Support: IE 11 only
// The attrs elements can be null (#14894)
if ( attrs[ i ] ) {
name = attrs[ i ].name;
if ( name.indexOf( "data-" ) === 0 ) {
name = jQuery.camelCase( name.slice( 5 ) );
dataAttr( elem, name, data[ name ] );
}
}
}
dataPriv.set( elem, "hasDataAttrs", true );
}
}
return data;
}
// Sets multiple values
if ( typeof key === "object" ) {
return this.each( function() {
dataUser.set( this, key );
} );
}
return access( this, function( value ) {
var data;
// The calling jQuery object (element matches) is not empty
// (and therefore has an element appears at this[ 0 ]) and the
// `value` parameter was not undefined. An empty jQuery object
// will result in `undefined` for elem = this[ 0 ] which will
// throw an exception if an attempt to read a data cache is made.
if ( elem && value === undefined ) {
// Attempt to get data from the cache
// The key will always be camelCased in Data
data = dataUser.get( elem, key );
if ( data !== undefined ) {
return data;
}
// Attempt to "discover" the data in
// HTML5 custom data-* attrs
data = dataAttr( elem, key );
if ( data !== undefined ) {
return data;
}
// We tried really hard, but the data doesn't exist.
return;
}
// Set the data...
this.each( function() {
// We always store the camelCased key
dataUser.set( this, key, value );
} );
}, null, value, arguments.length > 1, null, true );
},
removeData: function( key ) {
return this.each( function() {
dataUser.remove( this, key );
} );
}
} );
return jQuery;
} );
define( [
"../core",
"../var/rnothtmlwhite",
"./var/acceptData"
], function( jQuery, rnothtmlwhite, acceptData ) {
"use strict";
function Data() {
this.expando = jQuery.expando + Data.uid++;
}
Data.uid = 1;
Data.prototype = {
cache: function( owner ) {
// Check if the owner object already has a cache
var value = owner[ this.expando ];
// If not, create one
if ( !value ) {
value = {};
// We can accept data for non-element nodes in modern browsers,
// but we should not, see #8335.
// Always return an empty object.
if ( acceptData( owner ) ) {
// If it is a node unlikely to be stringify-ed or looped over
// use plain assignment
if ( owner.nodeType ) {
owner[ this.expando ] = value;
// Otherwise secure it in a non-enumerable property
// configurable must be true to allow the property to be
// deleted when data is removed
} else {
Object.defineProperty( owner, this.expando, {
value: value,
configurable: true
} );
}
}
}
return value;
},
set: function( owner, data, value ) {
var prop,
cache = this.cache( owner );
// Handle: [ owner, key, value ] args
// Always use camelCase key (gh-2257)
if ( typeof data === "string" ) {
cache[ jQuery.camelCase( data ) ] = value;
// Handle: [ owner, { properties } ] args
} else {
// Copy the properties one-by-one to the cache object
for ( prop in data ) {
cache[ jQuery.camelCase( prop ) ] = data[ prop ];
}
}
return cache;
},
get: function( owner, key ) {
return key === undefined ?
this.cache( owner ) :
// Always use camelCase key (gh-2257)
owner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ];
},
access: function( owner, key, value ) {
// In cases where either:
//
// 1. No key was specified
// 2. A string key was specified, but no value provided
//
// Take the "read" path and allow the get method to determine
// which value to return, respectively either:
//
// 1. The entire cache object
// 2. The data stored at the key
//
if ( key === undefined ||
( ( key && typeof key === "string" ) && value === undefined ) ) {
return this.get( owner, key );
}
// When the key is not a string, or both a key and value
// are specified, set or extend (existing objects) with either:
//
// 1. An object of properties
// 2. A key and value
//
this.set( owner, key, value );
// Since the "set" path can have two possible entry points
// return the expected data based on which path was taken[*]
return value !== undefined ? value : key;
},
remove: function( owner, key ) {
var i,
cache = owner[ this.expando ];
if ( cache === undefined ) {
return;
}
if ( key !== undefined ) {
// Support array or space separated string of keys
if ( Array.isArray( key ) ) {
// If key is an array of keys...
// We always set camelCase keys, so remove that.
key = key.map( jQuery.camelCase );
} else {
key = jQuery.camelCase( key );
// If a key with the spaces exists, use it.
// Otherwise, create an array by matching non-whitespace
key = key in cache ?
[ key ] :
( key.match( rnothtmlwhite ) || [] );
}
i = key.length;
while ( i-- ) {
delete cache[ key[ i ] ];
}
}
// Remove the expando if there's no more data
if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
// Support: Chrome <=35 - 45
// Webkit & Blink performance suffers when deleting properties
// from DOM nodes, so set to undefined instead
// https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
if ( owner.nodeType ) {
owner[ this.expando ] = undefined;
} else {
delete owner[ this.expando ];
}
}
},
hasData: function( owner ) {
var cache = owner[ this.expando ];
return cache !== undefined && !jQuery.isEmptyObject( cache );
}
};
return Data;
} );
define( function() {
"use strict";
/**
* Determines whether an object can have data
*/
return function( owner ) {
// Accepts only:
// - Node
// - Node.ELEMENT_NODE
// - Node.DOCUMENT_NODE
// - Object
// - Any
return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
};
} );
define( [
"../Data"
], function( Data ) {
"use strict";
return new Data();
} );
define( [
"../Data"
], function( Data ) {
"use strict";
return new Data();
} );
This diff is collapsed. Click to expand it.
define( [
"../core",
"../deferred"
], function( jQuery ) {
"use strict";
// These usually indicate a programmer mistake during development,
// warn about them ASAP rather than swallowing them by default.
var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
jQuery.Deferred.exceptionHook = function( error, stack ) {
// Support: IE 8 - 9 only
// Console exists when dev tools are open, which can happen at any time
if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
}
};
} );
define( [
"./core",
"./core/nodeName"
], function( jQuery, nodeName ) {
"use strict";
jQuery.fn.extend( {
bind: function( types, data, fn ) {
return this.on( types, null, data, fn );
},
unbind: function( types, fn ) {
return this.off( types, null, fn );
},
delegate: function( selector, types, data, fn ) {
return this.on( types, selector, data, fn );
},
undelegate: function( selector, types, fn ) {
// ( namespace ) or ( selector, types [, fn] )
return arguments.length === 1 ?
this.off( selector, "**" ) :
this.off( types, selector || "**", fn );
}
} );
jQuery.holdReady = function( hold ) {
if ( hold ) {
jQuery.readyWait++;
} else {
jQuery.ready( true );
}
};
jQuery.isArray = Array.isArray;
jQuery.parseJSON = JSON.parse;
jQuery.nodeName = nodeName;
} );
define( [
"./core",
"./core/access",
"./css"
], function( jQuery, access ) {
"use strict";
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
function( defaultExtra, funcName ) {
// Margin is only for outerHeight, outerWidth
jQuery.fn[ funcName ] = function( margin, value ) {
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
return access( this, function( elem, type, value ) {
var doc;
if ( jQuery.isWindow( elem ) ) {
// $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
return funcName.indexOf( "outer" ) === 0 ?
elem[ "inner" + name ] :
elem.document.documentElement[ "client" + name ];
}
// Get document width or height
if ( elem.nodeType === 9 ) {
doc = elem.documentElement;
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
// whichever is greatest
return Math.max(
elem.body[ "scroll" + name ], doc[ "scroll" + name ],
elem.body[ "offset" + name ], doc[ "offset" + name ],
doc[ "client" + name ]
);
}
return value === undefined ?
// Get width or height on the element, requesting but not forcing parseFloat
jQuery.css( elem, type, extra ) :
// Set width or height on the element
jQuery.style( elem, type, value, extra );
}, type, chainable ? margin : undefined, chainable );
};
} );
} );
return jQuery;
} );
This diff is collapsed. Click to expand it.
define( [
"../core",
"../css"
], function( jQuery ) {
"use strict";
function Tween( elem, options, prop, end, easing ) {
return new Tween.prototype.init( elem, options, prop, end, easing );
}
jQuery.Tween = Tween;
Tween.prototype = {
constructor: Tween,
init: function( elem, options, prop, end, easing, unit ) {
this.elem = elem;
this.prop = prop;
this.easing = easing || jQuery.easing._default;
this.options = options;
this.start = this.now = this.cur();
this.end = end;
this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
},
cur: function() {
var hooks = Tween.propHooks[ this.prop ];
return hooks && hooks.get ?
hooks.get( this ) :
Tween.propHooks._default.get( this );
},
run: function( percent ) {
var eased,
hooks = Tween.propHooks[ this.prop ];
if ( this.options.duration ) {
this.pos = eased = jQuery.easing[ this.easing ](
percent, this.options.duration * percent, 0, 1, this.options.duration
);
} else {
this.pos = eased = percent;
}
this.now = ( this.end - this.start ) * eased + this.start;
if ( this.options.step ) {
this.options.step.call( this.elem, this.now, this );
}
if ( hooks && hooks.set ) {
hooks.set( this );
} else {
Tween.propHooks._default.set( this );
}
return this;
}
};
Tween.prototype.init.prototype = Tween.prototype;
Tween.propHooks = {
_default: {
get: function( tween ) {
var result;
// Use a property on the element directly when it is not a DOM element,
// or when there is no matching style property that exists.
if ( tween.elem.nodeType !== 1 ||
tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
return tween.elem[ tween.prop ];
}
// Passing an empty string as a 3rd parameter to .css will automatically
// attempt a parseFloat and fallback to a string if the parse fails.
// Simple values such as "10px" are parsed to Float;
// complex values such as "rotate(1rad)" are returned as-is.
result = jQuery.css( tween.elem, tween.prop, "" );
// Empty strings, null, undefined and "auto" are converted to 0.
return !result || result === "auto" ? 0 : result;
},
set: function( tween ) {
// Use step hook for back compat.
// Use cssHook if its there.
// Use .style if available and use plain properties where available.
if ( jQuery.fx.step[ tween.prop ] ) {
jQuery.fx.step[ tween.prop ]( tween );
} else if ( tween.elem.nodeType === 1 &&
( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
jQuery.cssHooks[ tween.prop ] ) ) {
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
} else {
tween.elem[ tween.prop ] = tween.now;
}
}
}
};
// Support: IE <=9 only
// Panic based approach to setting things on disconnected nodes
Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
set: function( tween ) {
if ( tween.elem.nodeType && tween.elem.parentNode ) {
tween.elem[ tween.prop ] = tween.now;
}
}
};
jQuery.easing = {
linear: function( p ) {
return p;
},
swing: function( p ) {
return 0.5 - Math.cos( p * Math.PI ) / 2;
},
_default: "swing"
};
jQuery.fx = Tween.prototype.init;
// Back compat <1.8 extension point
jQuery.fx.step = {};
} );
define( [
"../core",
"../selector",
"../effects"
], function( jQuery ) {
"use strict";
jQuery.expr.pseudos.animated = function( elem ) {
return jQuery.grep( jQuery.timers, function( fn ) {
return elem === fn.elem;
} ).length;
};
} );
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.