Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tower1229 committed Jan 17, 2018
1 parent 12bf57d commit 9899d94
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 42 deletions.
83 changes: 46 additions & 37 deletions sdk/modules/input-number.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* name: input-number.js
* version: v0.1.5
* update: 默认使用input初始值
* date: 2018-01-16
* version: v0.2.0
* update: 输出inputNumber方法
* date: 2018-01-17
*/
define("input-number", function(require, exports, module) {
"use strict";
Expand All @@ -20,6 +20,7 @@ define("input-number", function(require, exports, module) {
require('input');
var $ = window.$ || require('jquery'),
def = {
el: null,
val: null,
countstep: 1,
min: 0,
Expand Down Expand Up @@ -128,43 +129,51 @@ define("input-number", function(require, exports, module) {
}, 0);
}
syncButtonStatus(_val, _opt, _reduce, _plus);
},
inputNumber = function(config) {
var opt = $.extend({}, def, config || {}),
template,
inputObject,
$this = $(opt.el);
if (!$this.length) {
return null;
}
$.extend(opt, $.isPlainObject($this.data('options')) ? $this.data('options') : {});
switch ($.trim(opt.style)) {
case "inline":
template = '<${wrapTag} data-input-init="true" class="counter_wrap counter_inline input-group${color}<!-- if: ${className} --> ${className}<!-- /if -->"<!-- if: ${width} --> style="width:${width}px"<!-- /if -->>\
<div class="pro_counter_btn pro_counter_reduce input-group-addon">-</div>\
<input type="${type}" id="${id}" placeholder="${holder}" value="${val}" class="form-control pro_counter_val"<!-- if: ${disable} --> disabled<!-- /if --><!-- if: ${readonly} --> readonly<!-- /if -->><div class="pro_counter_btn pro_counter_add input-group-addon">+</div>\
</${wrapTag}>';
break;
default:
template = '<${wrapTag} data-input-init="true" class="counter_wrap counter_default${color}<!-- if: ${className} --> ${className}<!-- /if -->"<!-- if: ${width} --> style="width:${width}px"<!-- /if -->>\
<div class="pro_counter_btn pro_counter_reduce">-</div>\
<input type="${type}" id="${id}" placeholder="${holder}" value="${val}" class="form-control pro_counter_val"<!-- if: ${disable} --> disabled<!-- /if --><!-- if: ${readonly} --> readonly<!-- /if -->><div class="pro_counter_btn pro_counter_add">+</div>\
</${wrapTag}>';
}
opt.template = template;

inputObject = $this.input(opt);
setTimeout(function() {
$.each(inputObject.renderDom, function(i, e) {
$(e).on('click', catchClickEvent);

});
$.each(inputObject.shadowInput, function(i, e) {
$(e).on('blur', catchBlurEvent);
});
}, 0);
return inputObject;
};

$.fn.inputNumber = function(config) {
var $this = $(this),
opt = $.extend({}, def, config || {}, $.isPlainObject($this.data('options')) ? $this.data('options') : {}),
template,
inputObject;
if (!$this.length) {
return null;
}
switch ($.trim(opt.style)) {
case "inline":
template = '<${wrapTag} data-input-init="true" class="counter_wrap counter_inline input-group${color}<!-- if: ${className} --> ${className}<!-- /if -->"<!-- if: ${width} --> style="width:${width}px"<!-- /if -->>\
<div class="pro_counter_btn pro_counter_reduce input-group-addon">-</div>\
<input type="${type}" id="${id}" placeholder="${holder}" value="${val}" class="form-control pro_counter_val"<!-- if: ${disable} --> disabled<!-- /if --><!-- if: ${readonly} --> readonly<!-- /if -->><div class="pro_counter_btn pro_counter_add input-group-addon">+</div>\
</${wrapTag}>';
break;
default:
template = '<${wrapTag} data-input-init="true" class="counter_wrap counter_default${color}<!-- if: ${className} --> ${className}<!-- /if -->"<!-- if: ${width} --> style="width:${width}px"<!-- /if -->>\
<div class="pro_counter_btn pro_counter_reduce">-</div>\
<input type="${type}" id="${id}" placeholder="${holder}" value="${val}" class="form-control pro_counter_val"<!-- if: ${disable} --> disabled<!-- /if --><!-- if: ${readonly} --> readonly<!-- /if -->><div class="pro_counter_btn pro_counter_add">+</div>\
</${wrapTag}>';
}
opt.template = template;

inputObject = $this.input(opt);
setTimeout(function() {
$.each(inputObject.renderDom, function(i, e) {
$(e).on('click', catchClickEvent);
return inputNumber($.extend({
el: this
}, config || {}));
};

});
$.each(inputObject.shadowInput, function(i, e) {
$(e).on('blur', catchBlurEvent);
});
}, 0);
return inputObject;
};
//自动初始化
return $('.flow-ui-input-number').inputNumber();
$('.flow-ui-input-number').inputNumber();
module.exports = inputNumber;
});
10 changes: 5 additions & 5 deletions sdk/modules/input.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* name: input.js
* version: v0.1.5
* update: 默认使用原始值
* date: 2018-01-16
* version: v0.1.6
* update: bug fix
* date: 2018-01-18
*/
define('input', function(require, exports, module) {
"use strict";
Expand Down Expand Up @@ -172,9 +172,9 @@ define('input', function(require, exports, module) {
}
//默认使用原始值
if(opt.val===null){
opt.val = $this.val();
opt.val = $this.val() || 0;
}
//沿用
//沿用禁用状态
if(opt.disable===null){
opt.disable = $this.prop('disabled');
}
Expand Down

0 comments on commit 9899d94

Please sign in to comment.