Skip to content

Commit f7a0e43

Browse files
author
zhangxinxu
committed
Merge remote-tracking branch 'origin/master' into develop
2 parents 1d20892 + c489b8e commit f7a0e43

File tree

5 files changed

+37
-32
lines changed

5 files changed

+37
-32
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"name": "mobilebone",
3+
<<<<<<< HEAD
4+
"version": "1.1.0",
5+
"description": "Bone main for mobile web APP with a sigle page mode.",
6+
=======
37
"version": "1.0.0",
48
"description": "Bone for mobile web APP with a sigle page mode.",
9+
>>>>>>> origin/develop
510
"main": "src/mobilebone.js",
611
"directories": {
712
"test": "test"

plugins/ppt/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
6-
<title>ajax请求HTML</title>
6+
<title>屁屁踢在线幻灯片插件演示</title>
77
<link rel="stylesheet" href="../../src/mobilebone.css">
88
<link rel="stylesheet" href="ppt.css">
99
</head>

src/mobilebone.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ html, body, .page {
4040
height: 100%; width: 100%;
4141
background-color: rgba(255,255,255,.35);
4242
position: absolute;
43+
z-index: 9;
4344
}
4445
.loading { /* more info: http://www.zhangxinxu.com/wordpress/?p=3357 */
4546
width: 3px; height:3px;

src/mobilebone.js

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,12 @@
3333

3434
if (supportHistory == false) return Mobilebone;
3535

36-
// similar to $().prop() method, but with a diff rule
37-
var prop = function(element, attribute) {
38-
var attr = element.getAttribute(attribute);
39-
if (attr == null || attr == "false" || attr == "0") return false;
40-
return true;
41-
};
42-
4336
/**
4437
* Current version of the library. Keep in sync with `package.json`.
4538
*
4639
* @type string
4740
**/
48-
Mobilebone.VERSION = '1.0.0';
41+
Mobilebone.VERSION = '1.1.0';
4942

5043
/**
5144
* Whether bind events when dom ready
@@ -60,7 +53,7 @@
6053
* If the value set to false, jump links in a refresh form(not slide)
6154
* In most cases, you do not need to care about this parameter.
6255
Except some special pages that should refresh all links, as test/index.html show.
63-
However, if your only want several links refesh, you can use data-ajax="false" or data-role="external"
56+
However, if your only want several links refesh, you can use data-ajax="false" or data-rel="external"
6457
*
6558
* @type boolean
6659
**/
@@ -113,9 +106,9 @@
113106
* @returns undefined
114107
* @example Mobilebone.transition(element);
115108
Mobilebone.transition(element1, element2);
116-
Mobilebone.transition(element1, element2, true);
117-
Mobilebone.transition(element1, element2, { id: "only" });
118-
Mobilebone.transition(element1, element2, true, { id: "only" });
109+
Mobilebone.transition(element1, element2, true);
110+
Mobilebone.transition(element1, element2, { id: "only" });
111+
Mobilebone.transition(element1, element2, true, { id: "only" });
119112
**/
120113
Mobilebone.transition = function(pageInto, pageOut, back, options) {
121114
if (arguments.length == 0) return;
@@ -153,7 +146,7 @@
153146
});
154147

155148
if (typeof _params.root == "string") {
156-
_params.root = root[_params.root];
149+
_params.root = Mobilebone.getFunction(_params.root);
157150
}
158151

159152
return _params;
@@ -261,9 +254,9 @@
261254
* @returns string
262255
* @example Mobilebone.getCleanUrl(elementOfA);
263256
Mobilebone.getCleanUrl(elementOfA, '', "a=1&b=2");
264-
Mobilebone.getCleanUrl(null, "xxx.html");
265-
Mobilebone.getCleanUrl(null, "xxx.html?a=1&b=2");
266-
Mobilebone.getCleanUrl(null, "xxx.html", "a=1&b=2");
257+
Mobilebone.getCleanUrl(null, "xxx.html");
258+
Mobilebone.getCleanUrl(null, "xxx.html?a=1&b=2");
259+
Mobilebone.getCleanUrl(null, "xxx.html", "a=1&b=2");
267260
**/
268261
Mobilebone.getCleanUrl = function(trigger, url, params) {
269262
var href = "", formdata = "", clean_url = "";
@@ -341,11 +334,11 @@
341334
* @returns undefined
342335
* @example Mobilebone.createPage(pageDom);
343336
Mobilebone.createPage(generalDom);
344-
Mobilebone.createPage('<div class="page out">xxx</div>');
345-
Mobilebone.createPage('<p>xxx</p>');
346-
Mobilebone.createPage(pageDom, triggerLink);
347-
Mobilebone.createPage(pageDom, { reponse: '<div...>' });
348-
Mobilebone.createPage(pageDom, triggerLink, { reponse: '<div...>' });
337+
Mobilebone.createPage('<div class="page out">xxx</div>');
338+
Mobilebone.createPage('<p>xxx</p>');
339+
Mobilebone.createPage(pageDom, triggerLink);
340+
Mobilebone.createPage(pageDom, { reponse: '<div...>' });
341+
Mobilebone.createPage(pageDom, triggerLink, { reponse: '<div...>' });
349342
*
350343
**/
351344
Mobilebone.createPage = function(dom_or_html, element_or_options, options) {
@@ -406,7 +399,7 @@
406399
* @returns function
407400
undefined keys is not string
408401
window keys unfinded
409-
* @example Mobilebone.createPage("a.b.c");
402+
* @example Mobilebone.getFunction("a.b.c");
410403
*
411404
**/
412405
Mobilebone.getFunction = function(keys) {
@@ -510,7 +503,7 @@
510503

511504
// ajax request
512505
var xhr = new XMLHttpRequest();
513-
xhr.open("GET", params.url + (/\?/.test(params.url)? "&" : "?") + "r=" + Date.now());
506+
xhr.open("GET", params.url + (/\?/.test(params.url)? "&" : "?") + "r=" + Date.now(), params.async, params.username, params.password);
514507
xhr.timeout = params.timeout;
515508

516509
xhr.onload = function() {
@@ -574,7 +567,7 @@
574567

575568

576569
/**
577-
* Sometime we don't know direction of transition. Such as browser history change, or data-role="auto".
570+
* Sometime we don't know direction of transition. Such as browser history change, or data-rel="auto".
578571
In this case, we ensure the direction(back or prev) by the sorts of two pages(into or out)
579572
580573
* @params page_in dom-object - Necessary
@@ -671,7 +664,10 @@
671664

672665
// if mask element exist and displaying, prevent double trigger
673666
var ele_mask = target.getElementsByClassName(Mobilebone.classMask)[0];
674-
if (ele_mask && ele_mask.style.visibility != "hidden") { return; }
667+
if (ele_mask && ele_mask.style.visibility != "hidden") {
668+
event.preventDefault();
669+
return false;
670+
}
675671

676672
// if captureLink
677673
var capture = (Mobilebone.captureLink == true);

test/callback/index.html

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h2>主页</h2>
3333
<a href="#pageHome" data-rel="back">&laquo;返回2</a>
3434
<p>该页面首次载入,按钮会被居中</p>
3535
</div>
36-
<div id="page3" class="page out" data-animationend="random_bgcolor">
36+
<div id="page3" class="page out" data-root="callback_page.test_obj" data-animationend="random_bgcolor">
3737
<a href="#pageHome" data-rel="back">&laquo;返回3</a>
3838
<p class="text-shadow">预期效果为每次动画载入随机灰度背景色</p>
3939
</div>
@@ -57,11 +57,6 @@ <h2>主页</h2>
5757
},
5858
end: function(page, into_or_out) {
5959
page.querySelector("p").innerHTML += "页面"+ this.status[into_or_out] +"动画完成,时间是:" + this.time() + "<br>";
60-
},
61-
random_bgcolor: function(page, into_or_out) {
62-
if (into_or_out == "into") {
63-
page.style.backgroundColor = "rgba(0,0,0,."+ Math.round(Math.random() * 10) +")";
64-
}
6560
}
6661
};
6762

@@ -70,6 +65,14 @@ <h2>主页</h2>
7065
page.style.textAlign = "center";
7166
};
7267

68+
callback_page.test_obj = {
69+
random_bgcolor: function(page, into_or_out) {
70+
if (into_or_out == "into") {
71+
page.style.backgroundColor = "rgba(0,0,0,."+ Math.round(Math.random() * 10) +")";
72+
}
73+
}
74+
};
75+
7376
Mobilebone.rootTransition = FUN;
7477
</script>
7578
</body>

0 commit comments

Comments
 (0)