Skip to content

Commit

Permalink
update for slider bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jguang committed Oct 9, 2014
1 parent a5ee73e commit db15d1d
Show file tree
Hide file tree
Showing 9 changed files with 208 additions and 246 deletions.
316 changes: 152 additions & 164 deletions dist/BlendHybridUI-0.0.4.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/BlendHybridUI-0.0.4.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/BlendHybridUI.min.js

Large diffs are not rendered by default.

26 changes: 9 additions & 17 deletions src/hybrid/api/component/footbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,27 @@ define(
*/
var config = require('../config');
var event = require('../event');
var util = require('../util');
var footbar = {};
var devPR = config.DEVICE_PR;

var apiFn = function( handler, args){
try{
var api = window.nuwa_widget||window.lc_bridge;
return api[handler].apply(api,args);
}catch(e){
console.log("BlendUI_Api_Error:"+handler+"======");
console.log(e);
}
};
var filterOption = util.filterPositionOption;
var apiFn = util.apiFn;

/**
* 增加slider
*/
footbar.add = function(id, options){
var _options = {
"left":0,
"top":(window.innerHeight-45)*devPR,
"width":window.innerWidth*devPR,
"height":45 * devPR,
"top":window.innerHeight-45,
"width":window.innerWidth,
"height":45,
"fixed":true
};
['left','top','width','height'].forEach(function(n,i){
if(options&&options[n]!==undefined){
_options[n] = options[n]*devPR;
}
});

_options = filterOption(options,false,_options);

apiFn("addComponent",[id, 'UIBase', 'com.baidu.lightui.component.toolbar.Toolbar', JSON.stringify(_options)]);

return footbar;
Expand Down
34 changes: 11 additions & 23 deletions src/hybrid/api/component/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,14 @@ define(
*/
var config = require('../config');
var event = require('../event');
var util = require('../util');

var slider = {};
var devPR = config.DEVICE_PR;
/*var widgetApi = function(){
return window.nuwa_widget||window.lc_bridge;
};*/
// native api回调
var apiFn = function( handler, args){
try{
var api = window.nuwa_widget||window.lc_bridge;
return api[handler].apply(api,args);
}catch(e){
console.log("BlendUI_Api_Error:"+handler+"======");
console.log(e);
}
};


var filterOption = util.filterPositionOption;
var apiFn = util.apiFn;

/**
* 增加slider
Expand All @@ -31,18 +24,13 @@ define(
var _options = {
"left":0,
"top":0,
"width":window.innerWidth*devPR,
"height":window.innerHeight*devPR,
"width":window.innerWidth,
"height":window.innerHeight,
"fixed":false
};
['left','top','width','height'].forEach(function(n,i){
if(options&&options[n]!==undefined){
_options[n] = options[n]*devPR;
}
});
if(options.fixed){
_options.fixed = true;
}

_options = filterOption(options,false,_options);

_options.top += window.pageYOffset*devPR;
apiFn("addComponent",[id, 'UIBase', 'com.baidu.lightui.component.slider.Slider', JSON.stringify(_options)]);

Expand Down
20 changes: 3 additions & 17 deletions src/hybrid/api/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,13 @@ define(
* @blendui native核心接口层
* @private
*/
var util = require('./util');
var apiFn = util.apiFn;

var core = {};

var keyboard;

var apiFn = function(handler, args) {
try {
var api = window.nuwa_core || window.nuwa_runtime;
var api2 = window.nuwa_widget || window.lc_bridge;
var fn;
if(api2&&(fn=api2[handler])){
api = api2;
}else{
fn = api[handler];
}
return fn.apply(api, args);
}catch (e) {
console.log('BlendUI_Api_Error:'+ handler + '======'+fn);
console.log(e);
}
};

/**
* 移除启动画面
* @method {Function} removeSplashScreen
Expand Down
28 changes: 20 additions & 8 deletions src/hybrid/api/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
define(
function(require) {

/**
* api通用函数
*/
var config = require('./config');
var devPR = config.DEVICE_PR;

Expand All @@ -20,9 +22,9 @@ define(
}
};

util.filterPositionOption = function(options,delKeys){
util.filterPositionOption = function(options,delKeys,defaultOptions){
var layerOut = ['left', 'top', 'width', 'height','right','bottom'];
var _options = {};
var _options = defaultOptions||{};
for(var n in options){
if(options[n] === undefined || (delKeys&&delKeys.indexOf(n)>=0)) continue;
_options[n] = layerOut.indexOf(n)>=0?options[n]*devPR:options[n];
Expand All @@ -32,19 +34,29 @@ define(

util.apiFn = function(handler, args) {
try {
var api = window.nuwa_frame || window.lc_bridge;
var value = api[handler].apply(api, args);
var api = window.nuwa_core || window.nuwa_runtime;
var api2 = window.nuwa_widget || window.lc_bridge;
var fn,value;
if(api2&&(fn=api2[handler])){
api = api2;
}else{
fn = api[handler];
}
value = fn.apply(api, args);
//android 4.4 true false返回为字符串
if(value==="ture"){
value=true;
value = true;
}else if(value==="false"){
value = false;
}
return value;
}catch (e) {
console.log('BlendUI_Api_Error:'+ handler + '======');
console.log(e.stack);
console.log('BlendUI_Api_Error:'+ handler + '======'+fn);
console.log(e);
}
};


return util;
}
);
13 changes: 7 additions & 6 deletions test/case/index_demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>layer功能测试</title>
<link rel="stylesheet" href="">
<script src="../../../third_party/zepto.js"></script>
<script src="../../../third_party/require.js"></script>
<script src=" http://weinre123.duapp.com/target/target-script-min.js"></script>
<script src="../../third_party/zepto.js"></script>
<script src="../../third_party/require.js"></script>
<!--
<script src=" http://weinre123.duapp.com/target/target-script-min.js"></script>-->
</head>
<body>
layer测试<br/><br/>
Expand All @@ -33,7 +34,7 @@
</body>
<script>
require.config({
baseUrl:"../../../"
baseUrl:"../../"
});
require(['src/hybrid/blend','src/hybrid/Layer'], function ( main,Layer) {
var _layer;
Expand All @@ -54,15 +55,15 @@
alert("baidu的回调"+data.ccc);
});

layerApi.fire('baidu',"top",{"aaa":"ddddd"},function(data){
/*layerApi.fire('baidu',"top",{"aaa":"ddddd"},function(data){
alert("baidu的回调1"+data.ccc);
});
layerApi.fire('book',"top",{"aaa":"ccccc"},function(data){
//alert(111);
alert("book的回调"+data.ccc);
});

*/
layerApi.fire('bbbb',"top");

}
Expand Down
13 changes: 4 additions & 9 deletions test/case/layer.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ <h2>layer功能测试</h2><br/><br/>
<input type="button" id="create" value="创建layer test"/>
<br/>
属性默认值
{"fx":"slide","reverse":false,"duration":"normal",pullToRefresh:"false"}
{"fx":"slide","reverse":false,"duration":200,pullToRefresh:"true"}
<br/>
<hr/>
<input type="button" id="create1" value="设置动画slide"/>
<br/>
动画设置为slide
{"fx":"slide","reverse":false,"duration":"normal"}
{"fx":"slide","reverse":true,"duration":"quick"}
<hr/>
<input type="button" id="create2" value="设置动画pop"/>
<br/>
Expand All @@ -43,7 +43,7 @@ <h2>layer功能测试</h2><br/><br/>
<br/>
<hr/>
<input type="button" id="reload" value="改变layer test的url"/><br/>
改变layer test的url
改变layer test的url -> 163.com
<br/>
<hr/>
<input type="button" id="showEvent" value="onshow事件回调"/><br/>
Expand Down Expand Up @@ -176,8 +176,6 @@ <h2>layer功能测试</h2><br/><br/>
'id':"test",
"url":"index_demo.html",
"active":true,
"autoStopLoading":false,
"maxLoadingTime": 1500,
"pullToRefresh":true,
"pullBgColor":"ff0000",
"pullText":"下拉",
Expand All @@ -192,7 +190,7 @@ <h2>layer功能测试</h2><br/><br/>
_layer.in()
},
reload:function(){
_layer.reload('index_demo.html');
_layer.reload('http://www.163.com');
_layer.in();
},
back :function(){
Expand Down Expand Up @@ -292,9 +290,6 @@ <h2>layer功能测试</h2><br/><br/>
},"test");
},
backKey:function(){
layerApi.on("layerGoBack",function(){
alert('test-layer keyBack');
},'test');

layerApi.on("layerGoBack",function(){
alert("0-layer keyBack");
Expand Down

0 comments on commit db15d1d

Please sign in to comment.