Skip to content

Commit 28030db

Browse files
committed
baidu.page.load修复
[bugfix]修复了xxx.js?v这种情况下不能获取扩展名的问题。 baidu/page/load.js
2 parents 06a4cf7 + f6f799f commit 28030db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1651
-206
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2009, Baidu Inc.
1+
Copyright (c) 2012, Baidu Inc.
22
All rights reserved.
33

44
Redistribution and use of this software in source and binary forms, with or

src/baidu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* @namespace T Tangram七巧板
2222
* @name T
23-
* @version 1.5.0
23+
* @version 1.6.0
2424
*/
2525

2626
/**
@@ -36,4 +36,4 @@ baidu.guid = "$BAIDU$";
3636

3737
//Tangram可能被放在闭包中
3838
//一些页面级别唯一的属性,需要挂载在window[baidu.guid]上
39-
window[baidu.guid] = window[baidu.guid] || {};
39+
baidu.$$ = window[baidu.guid] = window[baidu.guid] || {global:{}};

src/baidu/dom/ddManager.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
///import baidu.lang.createSingle;
1212
///import baidu.lang.Event;
13+
///import baidu.lang.Class.$removeEventListener;
1314
/**
1415
* 拖曳管理器
1516
* @function

src/baidu/dom/getComputedStyle.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
///import baidu.dom._g;
77
///import baidu.dom.getDocument;
8-
///import baidu.browser.ie;
98

109
/**
1110
* 获取目标元素的computed style值。如果元素的样式值不能被浏览器计算,则会返回空字符串(IE)
@@ -34,3 +33,5 @@ baidu.dom.getComputedStyle = function(element, key){
3433
}
3534
return '';
3635
};
36+
37+
// 20111204 meizz 去掉一个无用的import baidu.browser.ie

src/baidu/dom/getCurrentStyle.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Tangram
3+
* Copyright 2011 Baidu Inc. All rights reserved.
4+
*
5+
* author: meizz
6+
* create: 20111204
7+
*/
8+
9+
///import baidu.dom.g;
10+
///import baidu.dom.getComputedStyle;
11+
12+
/**
13+
* 获取目标元素的 currentStyle 值,兼容非IE浏览器
14+
* 某些样式名称或者值需要hack的话,需要别外处理!
15+
*
16+
* @author meizz
17+
* @name baidu.dom.getCurrentStyle
18+
* @function
19+
* @grammar baidu.dom.currentStyle(element, key)
20+
* @param {HTMLElement|string} element 目标元素或目标元素的id
21+
* @param {string} key 要获取的样式名
22+
*
23+
* @see baidu.dom.getStyle
24+
*
25+
* @returns {string} 目标元素的computed style值
26+
*/
27+
28+
baidu.dom.getCurrentStyle = function(element, key){
29+
element = baidu.dom.g(element);
30+
31+
return element.style[key] ||
32+
(element.currentStyle ? element.currentStyle[key] : "") ||
33+
baidu.dom.getComputedStyle(element, key);
34+
};

src/baidu/dom/hasClass.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
*/
3030
baidu.dom.hasClass = function (element, className) {
3131
element = baidu.dom.g(element);
32+
33+
// 对于 textNode 节点来说没有 className
34+
if(!element || !element.className) return false;
35+
3236
var classArray = baidu.string.trim(className).split(/\s+/),
3337
len = classArray.length;
3438

src/baidu/dom/opacity.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
///import baidu.dom.g;
2+
///import baidu.browser.ie;
3+
4+
/**
5+
* 设置HTML元素的不透明性,跨浏览器种类兼容处理
6+
*
7+
* @author: meizz
8+
* @version: 2011-07-11
9+
* @namespace: baidu.dom.opacity
10+
*
11+
* @param {String|HTMLElement} element 定位插入的HTML的目标DOM元素
12+
* @param {Number} opacity 不透明度
13+
*/
14+
baidu.dom.opacity = function(element, opacity){
15+
element = baidu.dom.g(element);
16+
17+
if (!baidu.browser.ie) {
18+
element.style.opacity = opacity;
19+
element.style.KHTMLOpacity = opacity;
20+
} else {
21+
element.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity:"+
22+
Math.floor(opacity * 100) +")";
23+
}
24+
};

src/baidu/dom/setPixel.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Tangram
3+
* Copyright 2011 Baidu Inc. All rights reserved.
4+
*
5+
* author: meizz
6+
* create: 2011-12-14
7+
*/
8+
9+
///import baidu.dom;
10+
///import baidu.dom.g;
11+
12+
/**
13+
* 给元素样式(比如width)赋值时,如果是数字则添加单位(px),如果是其它值直接赋
14+
*
15+
* @param {HTMLElement} el DOM元素
16+
* @param {String} style 样式属性名
17+
* @param {Number|String} n 被赋的值
18+
*/
19+
baidu.dom.setPixel = function (el, style, n) {
20+
typeof n != "undefined" &&
21+
(baidu.dom.g(el).style[style] = n +(!isNaN(n) ? "px" : ""));
22+
};

src/baidu/event/getEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* path: baidu/event/getEvent.js
66
* author: xiadengping
7-
* version: 1.1.0
7+
* version: 1.6.0
88
* date: 2011/12/08
99
*/
1010

src/baidu/form.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Tangram
3+
* Copyright 2009 Baidu Inc. All rights reserved.
4+
*
5+
* path: baidu/fn.js
6+
* author: qiaoyue
7+
* version: 1.0.0
8+
* date: 2011/12/23
9+
*/
10+
11+
///import baidu;
12+
/**
13+
* 对form的操作,解决表单数据问题
14+
* @namespace baidu.form
15+
*/
16+
baidu.form = baidu.form || {};

src/baidu/form/json.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Tangram
3+
* Copyright 2009 Baidu Inc. All rights reserved.
4+
*
5+
* path: baidu/form/json.js
6+
* author: qiaoyue
7+
* version: 1.1.0
8+
* date: 2011/12/23
9+
*/
10+
11+
///import baidu.form;
12+
///import baidu.url.escapeSymbol;
13+
14+
/**
15+
* josn化表单数据
16+
* @name baidu.form.json
17+
* @function
18+
* @grammar baidu.form.json(form[, replacer])
19+
* @param {HTMLFormElement} form 需要提交的表单元素
20+
* @param {Function} replacer 对参数值特殊处理的函数,replacer(string value, string key)
21+
22+
* @returns {data} 表单数据js对象
23+
*/
24+
baidu.form.json = function (form, replacer) {
25+
var elements = form.elements,
26+
replacer = replacer || function (value, name) {
27+
return value;
28+
},
29+
data = {},
30+
item, itemType, itemName, itemValue,
31+
opts, oi, oLen, oItem;
32+
33+
/**
34+
* 向缓冲区添加参数数据
35+
* @private
36+
*/
37+
function addData(name, value) {
38+
var val = data[name];
39+
if(val){
40+
val.push || ( data[name] = [val] );
41+
data[name].push(value);
42+
}else{
43+
data[name] = value;
44+
}
45+
}
46+
47+
for (var i = 0, len = elements.length; i < len; i++) {
48+
item = elements[i];
49+
itemName = item.name;
50+
51+
// 处理:可用并包含表单name的表单项
52+
if (!item.disabled && itemName) {
53+
itemType = item.type;
54+
itemValue = baidu.url.escapeSymbol(item.value);
55+
56+
switch (itemType) {
57+
// radio和checkbox被选中时,拼装queryString数据
58+
case 'radio':
59+
case 'checkbox':
60+
if (!item.checked) {
61+
break;
62+
}
63+
64+
// 默认类型,拼装queryString数据
65+
case 'textarea':
66+
case 'text':
67+
case 'password':
68+
case 'hidden':
69+
case 'file':
70+
case 'select-one':
71+
addData(itemName, replacer(itemValue, itemName));
72+
break;
73+
74+
// 多行选中select,拼装所有选中的数据
75+
case 'select-multiple':
76+
opts = item.options;
77+
oLen = opts.length;
78+
for (oi = 0; oi < oLen; oi++) {
79+
oItem = opts[oi];
80+
if (oItem.selected) {
81+
addData(itemName, replacer(oItem.value, itemName));
82+
}
83+
}
84+
break;
85+
}
86+
}
87+
}
88+
89+
return data;
90+
};

src/baidu/form/serialize.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Tangram
3+
* Copyright 2009 Baidu Inc. All rights reserved.
4+
*
5+
* path: baidu/form/serialize.js
6+
* author: qiaoyue
7+
* version: 1.1.0
8+
* date: 2011/12/23
9+
*/
10+
11+
///import baidu.form;
12+
///import baidu.url.escapeSymbol;
13+
14+
/**
15+
* 序列化表单数据
16+
* @name baidu.form.serialize
17+
* @function
18+
* @grammar baidu.form.serialize(form[, replacer])
19+
* @param {HTMLFormElement} form 需要提交的表单元素
20+
* @param {Function} replacer 对参数值特殊处理的函数,replacer(string value, string key)
21+
22+
* @returns {data} 表单数据数组
23+
*/
24+
baidu.form.serialize = function (form, replacer) {
25+
var elements = form.elements,
26+
replacer = replacer || function (value, name) {
27+
return value;
28+
},
29+
data = [],
30+
item, itemType, itemName, itemValue,
31+
opts, oi, oLen, oItem;
32+
33+
/**
34+
* 向缓冲区添加参数数据
35+
* @private
36+
*/
37+
function addData(name, value) {
38+
data.push(name + '=' + value);
39+
}
40+
41+
for (var i = 0, len = elements.length; i < len; i++) {
42+
item = elements[i];
43+
itemName = item.name;
44+
45+
// 处理:可用并包含表单name的表单项
46+
if (!item.disabled && itemName) {
47+
itemType = item.type;
48+
itemValue = baidu.url.escapeSymbol(item.value);
49+
50+
switch (itemType) {
51+
// radio和checkbox被选中时,拼装queryString数据
52+
case 'radio':
53+
case 'checkbox':
54+
if (!item.checked) {
55+
break;
56+
}
57+
58+
// 默认类型,拼装queryString数据
59+
case 'textarea':
60+
case 'text':
61+
case 'password':
62+
case 'hidden':
63+
case 'file':
64+
case 'select-one':
65+
addData(itemName, replacer(itemValue, itemName));
66+
break;
67+
68+
// 多行选中select,拼装所有选中的数据
69+
case 'select-multiple':
70+
opts = item.options;
71+
oLen = opts.length;
72+
for (oi = 0; oi < oLen; oi++) {
73+
oItem = opts[oi];
74+
if (oItem.selected) {
75+
addData(itemName, replacer(oItem.value, itemName));
76+
}
77+
}
78+
break;
79+
}
80+
}
81+
}
82+
83+
return data;
84+
};

src/baidu/global.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Tangram
3+
* Copyright 2009 Baidu Inc. All rights reserved.
4+
*
5+
* version: 1.4.0
6+
* date: 2011/07/05
7+
*/
8+
9+
///import baidu;
10+
11+
/**
12+
* @namespace baidu.global 操作global对象的方法。
13+
* @author meizz
14+
*/
15+
baidu.global = baidu.global || {};
16+
17+
// 将全局存放在的变量都集中到一个地方
18+
window[baidu.guid].global = window[baidu.guid].global || {};

src/baidu/global/get.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Tangram
3+
* Copyright 2009 Baidu Inc. All rights reserved.
4+
*
5+
* version: 1.4.0
6+
* date: 2011/07/05
7+
*/
8+
9+
///import baidu.global;
10+
11+
/**
12+
* @namespace baidu.global.get 取得global全局对象里存储的信息。
13+
* @author meizz
14+
*
15+
* @param {string} key 信息对应的 key 值
16+
* @return {object} 信息
17+
*/
18+
(function(){
19+
var global = window[baidu.guid].global;
20+
21+
baidu.global.get = function(key) {
22+
return global[key];
23+
};
24+
})();

0 commit comments

Comments
 (0)