Skip to content

Commit

Permalink
增加了dataType
Browse files Browse the repository at this point in the history
  • Loading branch information
joleye committed Nov 19, 2018
1 parent 7432e31 commit 667361e
Show file tree
Hide file tree
Showing 15 changed files with 9,608 additions and 145 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.settings/
.project
.idea
.idea/*
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ ye.check({
```js
ye.verify('#form1').do_post({
method : 'ajax',//默认 ajax模式提交
dataType : 'json',//可选
contentType : 'application/json;charset=UTF-8',//可选
msg : {
right : 'dright',
error : 'derr'
Expand Down
6 changes: 3 additions & 3 deletions compositebox.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>compositebox</title>
<link rel="stylesheet" type="text/css" href="css/ye.check.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/ye.check.js"></script>
<script type="text/javascript" src="js/jquery.compositebox.js"></script>
<script type="text/javascript" src="src/jquery.js"></script>
<script type="text/javascript" src="src/ye.check.js"></script>
<script type="text/javascript" src="src/jquery.compositebox.js"></script>
<style type="text/css">
#form1 li {
height: 45px;
Expand Down
4 changes: 2 additions & 2 deletions demo-2verify.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>demo-verify</title>
<link rel="stylesheet" type="text/css" href="css/ye.check.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/ye.check.js"></script>
<script type="text/javascript" src="src/jquery.js"></script>
<script type="text/javascript" src="src/ye.check.js"></script>
<style type="text/css">
#form1 li {
height: 45px;
Expand Down
4 changes: 2 additions & 2 deletions demo-verify.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>demo-verify</title>
<link rel="stylesheet" type="text/css" href="css/ye.check.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/ye.check.js"></script>
<script type="text/javascript" src="src/jquery.js"></script>
<script type="text/javascript" src="src/ye.check.js"></script>
<style type="text/css">
#form1 li {
height: 45px;
Expand Down
4 changes: 2 additions & 2 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>demo</title>
<link rel="stylesheet" type="text/css" href="css/ye.check.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/ye.check.js"></script>
<script type="text/javascript" src="src/jquery.js"></script>
<script type="text/javascript" src="src/ye.check.js"></script>
<style type="text/css">
#form1 li {
height: 45px;
Expand Down
4 changes: 2 additions & 2 deletions demo2.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>demo</title>
<link rel="stylesheet" type="text/css" href="css/ye.check.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/ye.check.js"></script>
<script type="text/javascript" src="src/jquery.js"></script>
<script type="text/javascript" src="src/ye.check.js"></script>
<style type="text/css">
#form1 li {
height: 45px;
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions js/jquery.js

This file was deleted.

2 changes: 1 addition & 1 deletion make.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

yuicompressor --type js --charset UTF-8 -v js/ye.check.js > js/ye.check.min.js
yuicompressor --type js --charset UTF-8 -v src/ye.check.js > dist/ye.check.min.js
90 changes: 45 additions & 45 deletions js/jquery.action.js → src/jquery.action.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
/**
* jquery.action 插件,支持事件操作
* @author joleye
*/
;
$.fn.action = function(){
this.click(function(){
var attr = $(this).attr('act-conf');
var conf;
eval('conf = {'+attr+'}');

var func = 'act_'+conf.act;

act_func[func] && act_func[func](conf,this);
});
};

var act_func = {
act_link : function(conf){
location.href = conf.url;
},
act_post : function(conf,dthis){
var ext = conf.extend?conf.extend:{};

ye.verify(conf.form,ext).do_post({
method : 'ajax',
msg : {
right : 'dright',
error : 'derr'
},
btn : {
name : dthis,
text : 'load...'
},
success : function(env){
if(env.result){
$.messager.alert("系统提示",env.msg);
}else{
$.messager.alert("错误提示",env.msg);
}
}
});
}
};
/**
* jquery.action 插件,支持事件操作
* @author joleye
*/
;
$.fn.action = function(){
this.click(function(){
var attr = $(this).attr('act-conf');
var conf;
eval('conf = {'+attr+'}');

var func = 'act_'+conf.act;

act_func[func] && act_func[func](conf,this);
});
};

var act_func = {
act_link : function(conf){
location.href = conf.url;
},
act_post : function(conf,dthis){
var ext = conf.extend?conf.extend:{};

ye.verify(conf.form,ext).do_post({
method : 'ajax',
msg : {
right : 'dright',
error : 'derr'
},
btn : {
name : dthis,
text : 'load...'
},
success : function(env){
if(env.result){
$.messager.alert("系统提示",env.msg);
}else{
$.messager.alert("错误提示",env.msg);
}
}
});
}
};

146 changes: 73 additions & 73 deletions js/jquery.compositebox.js → src/jquery.compositebox.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
/**
* 复合复选框 - ye.check
*/

(function($){

function init(name,target,onSelect){
var item = $(target);

item.hide();

var ops = $.data(target);

$('<span class="comp-box"><input class="icon-compositebox '+ops.status[0]+'" type="button" value=" "/></span>').insertBefore(item).click(function(){
var inp = $(this).find('input');
var cls = inp.attr('class').match(/\s+\w+$/)[0].replace(/\s+/g,'');

var newcls = ye.array(ops.status).next(cls);

inp.removeClass(cls).addClass(newcls);

var index = 0;
$('input[name='+name+']').each(function(){

if($(this).val()==ops.map[newcls]){
$(this).attr('checked',true);
if(onSelect){
onSelect.call(this,index,true);
}
}else{
$(this).attr('checked',false);
}

if(onSelect && ops.map[newcls]==''){
onSelect.call(this,index,false);
}

index++;
});
});

};

$.fn.compositebox = function(option){
var options = $.extend({
status : ['none','checked','del']
},option);

var nodes = {};
this.each(function(){
nodes[this.name] = this.parentNode.parentNode;
$(nodes[this.name]).hide();
});

$.each(nodes,function(k,val){
var new_option = ['none'];
options.map = {'none':''};
$('input[name='+k+']').each(function(){
var b = $(this).attr('composite-box');
if(b){
new_option.push(b);
options.map[b] = $(this).val();
}
});

options.status = $.extend(options.status,new_option);

$.data(val,options);

init(k,val,options.onSelect);
});
};
})($);
/**
* 复合复选框 - ye.check
*/

(function($){

function init(name,target,onSelect){
var item = $(target);

item.hide();

var ops = $.data(target);

$('<span class="comp-box"><input class="icon-compositebox '+ops.status[0]+'" type="button" value=" "/></span>').insertBefore(item).click(function(){
var inp = $(this).find('input');
var cls = inp.attr('class').match(/\s+\w+$/)[0].replace(/\s+/g,'');

var newcls = ye.array(ops.status).next(cls);

inp.removeClass(cls).addClass(newcls);

var index = 0;
$('input[name='+name+']').each(function(){

if($(this).val()==ops.map[newcls]){
$(this).attr('checked',true);
if(onSelect){
onSelect.call(this,index,true);
}
}else{
$(this).attr('checked',false);
}

if(onSelect && ops.map[newcls]==''){
onSelect.call(this,index,false);
}

index++;
});
});

};

$.fn.compositebox = function(option){
var options = $.extend({
status : ['none','checked','del']
},option);

var nodes = {};
this.each(function(){
nodes[this.name] = this.parentNode.parentNode;
$(nodes[this.name]).hide();
});

$.each(nodes,function(k,val){
var new_option = ['none'];
options.map = {'none':''};
$('input[name='+k+']').each(function(){
var b = $(this).attr('composite-box');
if(b){
new_option.push(b);
options.map[b] = $(this).val();
}
});

options.status = $.extend(options.status,new_option);

$.data(val,options);

init(k,val,options.onSelect);
});
};
})($);
Loading

0 comments on commit 667361e

Please sign in to comment.