shipfi

add all

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