Skip to content

Commit

Permalink
update js and button html
Browse files Browse the repository at this point in the history
  • Loading branch information
switer committed Jun 27, 2013
1 parent c2acad6 commit 4247894
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
16 changes: 16 additions & 0 deletions button.html
Expand Up @@ -23,6 +23,8 @@
</select>
</div>
</div>
<div class='sui-btn-check sui-mg-top sui-on' id='checkbox'></div>
<div class='sui-btn-switch sui-mg-top' id="switch"></div>
<input id="test" class="sui-btn sui-btn-primary sui-mg-top" data-toggle="2000" type="button" value="toggle">
<input class="sui-btn sui-btn-pure sui-mg-top" data-toggle="2000" type="button" value="toggle">
<input class="sui-btn sui-btn-silver sui-mg-top" data-feedback="sui-feedback" type="button" value="修改密码">
Expand All @@ -43,6 +45,20 @@
$('#test').on('click', function () {
console.log('hello');
})
$('#checkbox').on('click', function (e) {
var $this = $(this);
if ($this.isOn())
$this.suiOff();
else $this.suiOn();

})
$('#switch').on('click', function (e) {
var $this = $(this);
if ($this.isOn())
$this.suiOff();
else $this.suiOn();

})
</script>
</body>
</html>
7 changes: 6 additions & 1 deletion js/component/ui.base.js
@@ -1,9 +1,10 @@


!function ($) {

var conf = {
'hide_class' : 'sui-disp-none',
'on_class' : 'sui-on',
'on_class' : 'sui-on',
'popbox_class' : 'sui-popbox',
"delay_time" : 100
}
Expand Down Expand Up @@ -36,6 +37,7 @@
**/
$.fn.suiShow = function () {
var $this = $(this);

if ($this.hasClass(conf.popbox_class)) {
$this.showPopbox();
} else {
Expand All @@ -54,4 +56,7 @@
$.fn.suiOff = function () {
$(this).removeClass(conf.on_class);
}
$.fn.isOn = function () {
return $(this).hasClass(conf.on_class);
}
}(window.$);
5 changes: 3 additions & 2 deletions js/component/ui.button.js
@@ -1,4 +1,5 @@


!function ($) {

var conf = {
Expand Down Expand Up @@ -67,8 +68,7 @@
/**
* Button Event
**/
$(document).on('click.sui-btn', function (e) {

$(document).on('click .sui-btn,.sui-btn-check,.sui-btn-switch', function (e) {
var $btn = $(e.target);
$btn.feed();

Expand Down Expand Up @@ -100,3 +100,4 @@
}
})
}(window.$);

2 changes: 2 additions & 0 deletions js/component/ui.input.js
@@ -1,4 +1,5 @@


!function ($) {

var conf = {};
Expand All @@ -20,3 +21,4 @@
return (val === undefined || val === null || val.length === 0);
}
}(window.$);

16 changes: 12 additions & 4 deletions js/component/ui.popbox.js
@@ -1,4 +1,5 @@


!function ($) {

var conf = {
Expand All @@ -8,6 +9,9 @@
"delay_time" : 100
}
var _timer, _this =this;
function _suiShow () {
this.removeClass(conf.hide_class);
}
/**
* 定时检验矫正弹框的位置
**/
Expand All @@ -23,11 +27,11 @@
$(this).css('webkitTransition', 'top 1s');
}
/**
* 弹框的位置居中
**/
* 设定弹框位置居中
*/
$.fn.center = function () {
var diffHeight = document.height - $(this).height();
$(this).css('marginTop', diffHeight / 2);
var diffHeight = document.height - parseInt($(this).height());
$(this).css('marginTop', (diffHeight / 2) + 'px');
}
/**
* 显示弹框,并设置高度
Expand All @@ -40,11 +44,14 @@
//定高
var height = document.body.scrollHeight;
$popbox.height(height);
//显示
_suiShow.call($popbox);
//定时校验机制, 一次延时校验
function _fixedHeight() {
height = document.body.scrollHeight;
if ( height !== $popbox.height() ) $popbox.height(height);
}
//延时100ms,检验高度
setTimeout(_fixedHeight, 100);
/*根据data配置数据*/
if ( $popbox.data('position') === 'fixed' && $popbox.data('setPosition') !== 'fixed' ) {
Expand Down Expand Up @@ -99,3 +106,4 @@
}
}
}(window.$);

0 comments on commit 4247894

Please sign in to comment.