修复用户中心的几个小bug
把之前疏忽的一些文件更新上来
@@ -791,9 +791,9 @@ function execute_action($rules = false, $action_id = null, $user_id = null) {
|
||||
function avatar($uid, $size = 'middle') {
|
||||
$size = in_array($size, array('big', 'middle', 'small', 'real')) ? $size : 'middle';
|
||||
$dir = setavatardir($uid);
|
||||
$file = BASE_PATH . '/uploads/avatar/' . $dir . 'avatar_' . $size . '.png';
|
||||
$file = BASE_PATH . '/static/avatar/' . $dir . 'avatar_' . $size . '.png';
|
||||
if (!file_exists('.' . $file)) {
|
||||
$file = BASE_PATH . '/public/images/default_avatar_' . $size . '.jpg';
|
||||
$file = BASE_PATH . '/static/images/default_avatar_' . $size . '.jpg';
|
||||
}
|
||||
return $file;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,46 @@ class Member extends Base {
|
||||
'reg_time' => 'integer'
|
||||
);
|
||||
|
||||
public $editfield = array(
|
||||
array('name'=>'uid','type'=>'hidden'),
|
||||
array('name'=>'username','title'=>'用户名','type'=>'readonly','help'=>''),
|
||||
array('name'=>'nickname','title'=>'昵称','type'=>'text','help'=>''),
|
||||
array('name'=>'password','title'=>'密码','type'=>'password','help'=>'为空时则不修改'),
|
||||
array('name'=>'sex','title'=>'性别','type'=>'select','option'=>array('0'=>'保密','1'=>'男','2'=>'女'),'help'=>''),
|
||||
array('name'=>'email','title'=>'邮箱','type'=>'text','help'=>'用户邮箱,用于找回密码等安全操作'),
|
||||
array('name'=>'qq','title'=>'QQ','type'=>'text','help'=>''),
|
||||
array('name'=>'score','title'=>'用户积分','type'=>'text','help'=>''),
|
||||
array('name'=>'signature','title'=>'用户签名','type'=>'textarea','help'=>''),
|
||||
array('name'=>'status','title'=>'状态','type'=>'select','option'=>array('0'=>'禁用','1'=>'启用'),'help'=>''),
|
||||
);
|
||||
|
||||
public $addfield = array(
|
||||
array('name'=>'username','title'=>'用户名','type'=>'text','help'=>'用户名会作为默认的昵称'),
|
||||
array('name'=>'password','title'=>'密码','type'=>'password','help'=>'用户密码不能少于6位'),
|
||||
array('name'=>'repassword','title'=>'确认密码','type'=>'password','help'=>'确认密码'),
|
||||
array('name'=>'email','title'=>'邮箱','type'=>'text','help'=>'用户邮箱,用于找回密码等安全操作'),
|
||||
);
|
||||
|
||||
public $useredit = array(
|
||||
array('name'=>'uid','type'=>'hidden'),
|
||||
array('name'=>'nickname','title'=>'昵称','type'=>'text','help'=>''),
|
||||
array('name'=>'sex','title'=>'性别','type'=>'select','option'=>array('0'=>'保密','1'=>'男','2'=>'女'),'help'=>''),
|
||||
array('name'=>'email','title'=>'邮箱','type'=>'text','help'=>'用户邮箱,用于找回密码等安全操作'),
|
||||
array('name'=>'mobile','title'=>'联系电话','type'=>'text','help'=>''),
|
||||
array('name'=>'qq','title'=>'QQ','type'=>'text','help'=>''),
|
||||
array('name'=>'signature','title'=>'用户签名','type'=>'textarea','help'=>''),
|
||||
);
|
||||
|
||||
public $userextend = array(
|
||||
array('name'=>'company','title'=>'单位名称','type'=>'text','help'=>''),
|
||||
array('name'=>'company_addr','title'=>'单位地址','type'=>'text','help'=>''),
|
||||
array('name'=>'company_contact','title'=>'单位联系人','type'=>'text','help'=>''),
|
||||
array('name'=>'company_zip','title'=>'单位邮编','type'=>'text','help'=>''),
|
||||
array('name'=>'company_depart','title'=>'所属部门','type'=>'text','help'=>''),
|
||||
array('name'=>'company_post','title'=>'所属职务','type'=>'text','help'=>''),
|
||||
array('name'=>'company_type','title'=>'单位类型','type'=>'select', 'option'=>'', 'help'=>''),
|
||||
);
|
||||
|
||||
protected function getGroupListAttr($value, $data){
|
||||
$sql = db('AuthGroupAccess')->where('uid', $data['uid'])->fetchSql(true)->column('group_id');
|
||||
return db('AuthGroup')->where('id in ('.$sql.')')->column('title', 'id');
|
||||
|
||||
823
web/static/plugs/avatar/css/style.css
Normal file
@@ -0,0 +1,823 @@
|
||||
@charset "utf-8";
|
||||
|
||||
/*缓冲效果开始 2.3加入的*/
|
||||
|
||||
#shearphoto_main {
|
||||
visibility: hidden;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#shearphoto_loading {
|
||||
width: 100px;
|
||||
text-align: center;
|
||||
line-height: 130px;
|
||||
color: #999;
|
||||
margin: 0 auto;
|
||||
background: url(../images/loading.gif) no-repeat
|
||||
}
|
||||
|
||||
|
||||
/*缓冲效果结束*/
|
||||
|
||||
/*预览开始*/
|
||||
|
||||
#shearphoto_main #preview {
|
||||
float: left;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#shearphoto_main #preview a {
|
||||
display: inline;
|
||||
float: left;
|
||||
-moz-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
-moz-box-shadow: 1px 1px 3px 1px #999;
|
||||
box-shadow: 1px 1px 3px 1px #999;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#shearphoto_main #preview a img {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
|
||||
/*预览结束*/
|
||||
|
||||
.bottom a:hover {
|
||||
color: #39F;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
/*旋转开始*/
|
||||
|
||||
#Shearbar #LeftRotate {
|
||||
margin: 0 10px;
|
||||
}
|
||||
|
||||
#Shearbar #LeftRotate em,
|
||||
#Shearbar #RightRotate em {
|
||||
display: inline-block;
|
||||
height: 21px;
|
||||
vertical-align: middle;
|
||||
width: 15px;
|
||||
margin: 1px 3px 0 0;
|
||||
background: url(../images/bch.jpg) no-repeat;
|
||||
}
|
||||
|
||||
#Shearbar #LeftRotate,
|
||||
#Shearbar #RightRotate {
|
||||
-moz-border-radius: 5px;
|
||||
border: 1px solid #CCC;
|
||||
border-radius: 5px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
float: left;
|
||||
font-size: 12px;
|
||||
margin-top: -5px;
|
||||
text-align: center;
|
||||
width: 80px;
|
||||
padding: 5px 0;
|
||||
}
|
||||
|
||||
#Shearbar #LeftRotate:hover,
|
||||
#Shearbar #RightRotate:hover {
|
||||
border: 1px solid #919191;
|
||||
color: #414141
|
||||
}
|
||||
|
||||
#Shearbar #RightRotate {
|
||||
margin-left: 10px
|
||||
}
|
||||
|
||||
#Shearbar #RightRotate em {
|
||||
background-position: -91px 0;
|
||||
margin: 1px 0 0 3px;
|
||||
}
|
||||
|
||||
#Shearbar .hint {
|
||||
color: #333;
|
||||
display: block;
|
||||
float: left;
|
||||
font-size: 12px;
|
||||
font-style: normal;
|
||||
height: 19px;
|
||||
line-height: 15px;
|
||||
width: 19px
|
||||
}
|
||||
|
||||
#Shearbar .hint.L,
|
||||
#Shearbar .hint.R {
|
||||
background: url(../images/zoom.png) no-repeat -2px -1px
|
||||
}
|
||||
|
||||
#Shearbar .hint.R {
|
||||
background-position: -43px -1px
|
||||
}
|
||||
|
||||
|
||||
/*旋转结束*/
|
||||
|
||||
|
||||
/*选择图片方式开始*/
|
||||
|
||||
#shearphoto_main #SelectBox {
|
||||
background: url(../images/bg.png);
|
||||
position: absolute;
|
||||
z-index: 180
|
||||
}
|
||||
|
||||
#SelectBox #selectImage input {
|
||||
height: 74px;
|
||||
width: 224px;
|
||||
background-color: #FFF;
|
||||
filter: alpha(opacity=0);
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
float: left;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.displayNone {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#SelectBox #selectImage,
|
||||
#SelectBox #PhotoLoading,
|
||||
#SelectBox #camerasImage {
|
||||
-moz-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
-moz-box-shadow: 2px 2px 7px 1px #3e4044;
|
||||
box-shadow: 2px 2px 7px 1px #3e4044;
|
||||
display: block;
|
||||
height: 74px;
|
||||
outline: 0 none;
|
||||
position: absolute;
|
||||
width: 223px;
|
||||
overflow: hidden;
|
||||
margin: -37px 0 0 -112px;
|
||||
background: url(../images/Select.jpg) no-repeat;
|
||||
}
|
||||
|
||||
#SelectBox #PhotoLoading {
|
||||
background-position: 0 -148px;
|
||||
left: 50%;
|
||||
top: 52%
|
||||
}
|
||||
|
||||
#SelectBox #selectImage {
|
||||
left: 50%;
|
||||
top: 25%
|
||||
}
|
||||
|
||||
#SelectBox #camerasImage {
|
||||
background-position: 0 -74px;
|
||||
left: 50%;
|
||||
top: 79%
|
||||
}
|
||||
|
||||
#SelectBox #selectImage:hover,
|
||||
#SelectBox #PhotoLoading:hover,
|
||||
#SelectBox #camerasImage:hover {
|
||||
border: 3px solid #666;
|
||||
margin: -40px 0 0 -115px;
|
||||
}
|
||||
|
||||
|
||||
/*选择图片方式结束*/
|
||||
|
||||
|
||||
/*工具条开始*/
|
||||
|
||||
#shearphoto_main #Shearbar {
|
||||
padding-top: 10px;
|
||||
width: 442px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#Shearbar .Psava {
|
||||
clear: both;
|
||||
height: 40px;
|
||||
padding: 20px 0 0 110px
|
||||
}
|
||||
|
||||
#Shearbar .Psava #againIMG,
|
||||
#Shearbar .Psava #saveShear {
|
||||
background: url(../images/btn5.jpg) no-repeat;
|
||||
color: #666;
|
||||
float: left;
|
||||
line-height: 31px;
|
||||
margin-right: 20px;
|
||||
text-align: center;
|
||||
width: 79px;
|
||||
height: 31px;
|
||||
}
|
||||
|
||||
#Shearbar .Psava #againIMG:hover {
|
||||
background-position: 0px -31px;
|
||||
}
|
||||
|
||||
#Shearbar .Psava #saveShear {
|
||||
background-position: -79px 0px;
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
#Shearbar .Psava #saveShear:hover {
|
||||
background-position: -79px -31px
|
||||
}
|
||||
|
||||
#Shearbar #ZoomDist {
|
||||
float: left;
|
||||
height: 20px;
|
||||
position: relative;
|
||||
width: 200px
|
||||
}
|
||||
|
||||
#Shearbar #ZoomDist #ZoomBar {
|
||||
background: url(../images/ZoomBar.gif) no-repeat;
|
||||
filter: alpha(opacity=80);
|
||||
opacity: 0.8;
|
||||
height: 20px;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
width: 15px
|
||||
}
|
||||
|
||||
#ZoomDist #Zoomcentre {
|
||||
filter: alpha(opacity=100);
|
||||
height: 9px;
|
||||
left: 50%;
|
||||
top: 25px;
|
||||
position: absolute;
|
||||
width: 10px;
|
||||
margin-left: -4px;
|
||||
background: url(../images/Zoomcentre.jpg) no-repeat
|
||||
}
|
||||
|
||||
#ZoomDist .progress {
|
||||
-moz-border-radius: 15px;
|
||||
border-radius: 15px;
|
||||
background: #999;
|
||||
display: block;
|
||||
float: left;
|
||||
height: 8px;
|
||||
margin-top: 4px;
|
||||
overflow: hidden;
|
||||
width: 100%
|
||||
}
|
||||
|
||||
|
||||
/*工具条结束*/
|
||||
|
||||
|
||||
/*主功能界面开始*/
|
||||
|
||||
#shearphoto_main #black {
|
||||
position: absolute;
|
||||
z-index: 99
|
||||
}
|
||||
|
||||
#shearphoto_main .primary {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#shearphoto_main #main {
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
background: url(../images/bg.png);
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
z-index: 50;
|
||||
border: 1px solid #CCC;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#main .BigImg {
|
||||
float: left;
|
||||
position: relative;
|
||||
z-index: 51
|
||||
}
|
||||
|
||||
#main .MoveImg {
|
||||
position: relative;
|
||||
z-index: 98
|
||||
}
|
||||
|
||||
#main #imgID {
|
||||
display: block;
|
||||
z-index: 51
|
||||
}
|
||||
|
||||
#main #movebox {
|
||||
position: absolute;
|
||||
z-index: 100;
|
||||
float: left;
|
||||
}
|
||||
|
||||
|
||||
/*动态边框开始*/
|
||||
|
||||
#movebox #borderTop,
|
||||
#movebox #borderLeft,
|
||||
#movebox #borderRight,
|
||||
#movebox #borderBottom {
|
||||
background: url(../images/border.gif) #FFF;
|
||||
display: inline-block;
|
||||
filter: alpha(opacity=50);
|
||||
opacity: 0.5;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
z-index: 104;
|
||||
}
|
||||
|
||||
#movebox #borderTop {
|
||||
height: 1px;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#movebox #borderLeft {
|
||||
height: 100%;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
#movebox #borderRight {
|
||||
height: 100%;
|
||||
right: 0;
|
||||
top: 0;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
#movebox #borderBottom {
|
||||
bottom: 0;
|
||||
height: 1px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
/*动态边框结束*/
|
||||
|
||||
|
||||
/*拉伸截框的八个点开始*/
|
||||
|
||||
#main #movebox #BottomRight,
|
||||
#main #movebox #TopRight,
|
||||
#main #movebox #Topleft,
|
||||
#main #movebox #Bottomleft,
|
||||
#main #movebox #Topmiddle,
|
||||
#main #movebox #leftmiddle,
|
||||
#main #movebox #Rightmiddle,
|
||||
#main #movebox #Bottommiddle {
|
||||
background: #000;
|
||||
border: 1px solid #FFF;
|
||||
bottom: -5px;
|
||||
cursor: nw-resize;
|
||||
display: block;
|
||||
filter: alpha(opacity=50);
|
||||
height: 8px;
|
||||
opacity: 0.5;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
right: -5px;
|
||||
width: 8px;
|
||||
z-index: 105;
|
||||
}
|
||||
|
||||
#main #movebox #Bottomleft {
|
||||
bottom: -5px;
|
||||
cursor: ne-resize;
|
||||
left: -5px
|
||||
}
|
||||
|
||||
#main #movebox #Bottommiddle {
|
||||
bottom: -5px;
|
||||
cursor: n-resize;
|
||||
left: 50%;
|
||||
margin-left: -5px
|
||||
}
|
||||
|
||||
#main #movebox #Rightmiddle {
|
||||
cursor: e-resize;
|
||||
margin-top: -5px;
|
||||
right: -5px;
|
||||
top: 50%
|
||||
}
|
||||
|
||||
#main #movebox #TopRight {
|
||||
cursor: ne-resize;
|
||||
right: -5px;
|
||||
top: -5px
|
||||
}
|
||||
|
||||
#main #movebox #Topleft {
|
||||
cursor: nw-resize;
|
||||
left: -5px;
|
||||
top: -5px
|
||||
}
|
||||
|
||||
#main #movebox #Topmiddle {
|
||||
cursor: n-resize;
|
||||
left: 50%;
|
||||
margin-left: -5px;
|
||||
top: -5px
|
||||
}
|
||||
|
||||
#main #movebox #leftmiddle {
|
||||
cursor: e-resize;
|
||||
left: -5px;
|
||||
margin-top: -5px;
|
||||
top: 50%
|
||||
}
|
||||
|
||||
|
||||
/*拉伸截框的八个点结束*/
|
||||
|
||||
#main #relat {
|
||||
position: relative;
|
||||
z-index: 60
|
||||
}
|
||||
|
||||
#main #smallbox {
|
||||
background: url();
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
z-index: 100
|
||||
}
|
||||
|
||||
|
||||
/*主功能界面结束*/
|
||||
|
||||
|
||||
/*上滚下滚提示的CSS*/
|
||||
|
||||
#main .point {
|
||||
width: 100%;
|
||||
line-height: 35px;
|
||||
font-size: 12px;
|
||||
position: absolute;
|
||||
z-index: 200;
|
||||
filter: alpha(opacity=70);
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.point i {
|
||||
display: inline-block;
|
||||
height: 16px;
|
||||
width: 15px;
|
||||
float: left;
|
||||
margin: 10px 10px 0 20px;
|
||||
background: url(../images/bg_repno.png) no-repeat;
|
||||
}
|
||||
|
||||
|
||||
/*上滚下滚提示的CSS结束*/
|
||||
|
||||
|
||||
/*截图完成后的CSS开始*/
|
||||
|
||||
#shearphoto_main .complete {
|
||||
float: left;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
z-index: 250;
|
||||
padding: 10px 0 0 5px;
|
||||
background: url(../images/bg.jpg) #CCC;
|
||||
}
|
||||
|
||||
.complete .completeTxt {
|
||||
-moz-border-radius: 10px;
|
||||
-moz-box-shadow: 0 0 15px 0 #666;
|
||||
border-radius: 10px;
|
||||
bottom: 30px;
|
||||
box-shadow: 0 0 15px 0 #666;
|
||||
position: absolute;
|
||||
right: 30px;
|
||||
text-align: center;
|
||||
width: 280px;
|
||||
padding: 30px 0;
|
||||
background: #FBFDFF;
|
||||
}
|
||||
|
||||
.complete .completeTxt a {
|
||||
color: #FFF;
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
line-height: 40px;
|
||||
width: 128px;
|
||||
margin: 0 auto;
|
||||
background: url(../images/bg_index.gif) no-repeat 0 -2px;
|
||||
}
|
||||
|
||||
.complete .completeTxt a:hover {
|
||||
background-position: -137px -2px
|
||||
}
|
||||
|
||||
.complete .completeTxt p {
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.complete .completeTxt strong {
|
||||
font-size: 14px
|
||||
}
|
||||
|
||||
.complete img {
|
||||
border: 1px solid #CCC;
|
||||
display: inline-block;
|
||||
float: left;
|
||||
margin: 5px 5px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.complete .completeTxt strong i {
|
||||
display: inline-block;
|
||||
height: 16px;
|
||||
width: 15px;
|
||||
vertical-align: middle;
|
||||
margin: -3px 5px 0 0;
|
||||
background: url(../images/bg_repno.png) no-repeat;
|
||||
}
|
||||
|
||||
|
||||
/*截图完成后的CSS结束*/
|
||||
|
||||
|
||||
/*弹出相册开始*/
|
||||
|
||||
#photoalbum {
|
||||
-moz-border-radius: 10px;
|
||||
-moz-box-shadow: 3px 3px 10px 0 #000;
|
||||
border: 8px solid #999;
|
||||
border-radius: 10px;
|
||||
box-shadow: 3px 3px 10px 0 #000;
|
||||
display: none;
|
||||
height: 340px;
|
||||
left: 50%;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 465px;
|
||||
z-index: 210;
|
||||
margin: -178px 0 0 -240.5px;
|
||||
background: #DFEFFF;
|
||||
}
|
||||
|
||||
#photoalbum h1 {
|
||||
background: #999;
|
||||
color: #FFF;
|
||||
font-size: 15px;
|
||||
height: 40px;
|
||||
line-height: 30px;
|
||||
padding-left: 10px;
|
||||
width: 455px
|
||||
}
|
||||
|
||||
#photoalbum i {
|
||||
background: url(../images/fancybox_sprite.png) no-repeat;
|
||||
display: block;
|
||||
float: left;
|
||||
height: 37px;
|
||||
left: 429px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
cursor: pointer;
|
||||
width: 36px
|
||||
}
|
||||
|
||||
#photoalbum ul {
|
||||
height: auto;
|
||||
width: 100%
|
||||
}
|
||||
|
||||
#photoalbum ul li {
|
||||
border: 1px solid #CCC;
|
||||
cursor: pointer;
|
||||
display: inline;
|
||||
float: left;
|
||||
height: 133px;
|
||||
margin: 5px;
|
||||
padding: 2px;
|
||||
width: 100px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#photoalbum ul li img {
|
||||
width: 100%
|
||||
}
|
||||
|
||||
#photoalbum ul li:hover {
|
||||
border: 1px solid #09F
|
||||
}
|
||||
|
||||
|
||||
/*弹出相册结束*/
|
||||
|
||||
|
||||
/*弹出拍照开始*/
|
||||
|
||||
#CamBox {
|
||||
-moz-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
left: 50%;
|
||||
position: absolute;
|
||||
-moz-box-shadow: 5px 5px 10px 0 #3b3b3f;
|
||||
box-shadow: 5px 5px 10px 0 #3b3b3f;
|
||||
width: 550px;
|
||||
z-index: 250;
|
||||
display: none;
|
||||
top: 50%;
|
||||
margin: -285px 0 0 -276px;
|
||||
background: url(../images/cam_bg.jpg) #d5d5d5;
|
||||
}
|
||||
|
||||
#CamBox #CamFlash {
|
||||
height: 450px;
|
||||
width: 450px;
|
||||
margin: 0 auto;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
#CamBox #timing {
|
||||
color: #F60;
|
||||
display: none;
|
||||
font-size: 36px;
|
||||
font-weight: 700;
|
||||
height: 200px;
|
||||
left: 50%;
|
||||
line-height: 200px;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
top: 50%;
|
||||
width: 200px;
|
||||
margin: -100px 0 0 -100px;
|
||||
}
|
||||
|
||||
#CamBox .cambar {
|
||||
height: 50px;
|
||||
padding-top: 20px;
|
||||
width: 300px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#CamBox .cambar a {
|
||||
background: url(../images/btn5.jpg) no-repeat;
|
||||
float: left;
|
||||
height: 31px;
|
||||
line-height: 31px;
|
||||
text-align: center;
|
||||
width: 79px
|
||||
}
|
||||
|
||||
#CamBox .lens {
|
||||
background: url(../images/cam.png) no-repeat 50%;
|
||||
height: 50px;
|
||||
width: 100%
|
||||
}
|
||||
|
||||
#CamBox .cambar #camClose,
|
||||
#CamBox .cambar #setCam {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
#CamBox .cambar #setCam {
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
#CamBox .cambar #camClose:hover,
|
||||
#CamBox .cambar #setCam:hover {
|
||||
background-position: 0 -31px;
|
||||
}
|
||||
|
||||
#CamBox .cambar #CamOk {
|
||||
background-position: -79px 0;
|
||||
color: #fff;
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
#CamBox .cambar #CamOk:hover {
|
||||
background-position: -79px -31px;
|
||||
}
|
||||
|
||||
|
||||
/*弹出拍照结束*/
|
||||
|
||||
|
||||
/*图片特效*/
|
||||
|
||||
#shearphoto_main .Effects {
|
||||
color: #FFF;
|
||||
overflow-x: hidden;
|
||||
width: 155px;
|
||||
display: none;
|
||||
float: left;
|
||||
border-color: #CCC;
|
||||
border-style: solid none;
|
||||
border-width: 1px;
|
||||
background: url(../images/Effects/cardboard.png);
|
||||
}
|
||||
|
||||
#shearphoto_main .Effects .EffectsStrong {
|
||||
border-bottom: solid 1px #676767;
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
text-align: center;
|
||||
width: 100%
|
||||
}
|
||||
|
||||
#shearphoto_main .Effects a {
|
||||
border-bottom: solid 1px #676767;
|
||||
color: #FFF;
|
||||
display: block;
|
||||
vertical-align: middle;
|
||||
text-shadow: #000 0 2px 0;
|
||||
width: 100%;
|
||||
padding: 5px 0 7px;
|
||||
}
|
||||
|
||||
#shearphoto_main .Effects a:hover,
|
||||
#shearphoto_main .Effects .Aclick {
|
||||
background-color: #A7A7A7;
|
||||
}
|
||||
|
||||
#shearphoto_main .Effects a img {
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
display: inline-block;
|
||||
height: 42px;
|
||||
vertical-align: middle;
|
||||
-moz-box-shadow: 0 0 5px 0 #000;
|
||||
box-shadow: 0 0 5px 0 #000;
|
||||
width: 70px;
|
||||
margin: 2px 7px 0;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
height: 13px;
|
||||
width: 13px
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: padding-box #c2c2c2;
|
||||
border: 1px solid #979797;
|
||||
min-height: 28px
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #929292;
|
||||
border: 1px solid #636363
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track-piece {
|
||||
background: #f5f5f5;
|
||||
border-left: 1px solid #d2d2d2
|
||||
}
|
||||
|
||||
|
||||
/*图片特效结束*/
|
||||
|
||||
|
||||
/*底部开始*/
|
||||
|
||||
.bottom {
|
||||
width: 1000px;
|
||||
left: 2px;
|
||||
color: #666;
|
||||
clear: both;
|
||||
text-align: center;
|
||||
margin: 0 auto;
|
||||
padding: 0 0 10px 5px
|
||||
}
|
||||
|
||||
.bottom span {
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
margin: 0 5px 0 2px
|
||||
}
|
||||
|
||||
.bottom a {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.header h1 a {
|
||||
font-size: 14px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.bottom span img {
|
||||
border-radius: 30px;
|
||||
-moz-border-radius: 30px;
|
||||
}
|
||||
|
||||
|
||||
/*底部结束*/
|
||||
BIN
web/static/plugs/avatar/images/Author.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
web/static/plugs/avatar/images/Effects/cardboard.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
web/static/plugs/avatar/images/Effects/e0.jpg
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
web/static/plugs/avatar/images/Effects/e1.jpg
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
web/static/plugs/avatar/images/Effects/e10.jpg
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
web/static/plugs/avatar/images/Effects/e11.jpg
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
web/static/plugs/avatar/images/Effects/e12.jpg
Normal file
|
After Width: | Height: | Size: 6.4 KiB |
BIN
web/static/plugs/avatar/images/Effects/e13.jpg
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
BIN
web/static/plugs/avatar/images/Effects/e14.jpg
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
web/static/plugs/avatar/images/Effects/e2.jpg
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
web/static/plugs/avatar/images/Effects/e3.jpg
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
web/static/plugs/avatar/images/Effects/e4.jpg
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
web/static/plugs/avatar/images/Effects/e5.jpg
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
web/static/plugs/avatar/images/Effects/e6.jpg
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
web/static/plugs/avatar/images/Effects/e7.jpg
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
web/static/plugs/avatar/images/Effects/e8.jpg
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
web/static/plugs/avatar/images/Effects/e9.jpg
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
web/static/plugs/avatar/images/Select.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
web/static/plugs/avatar/images/ZoomBar.gif
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
web/static/plugs/avatar/images/Zoomcentre.jpg
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
web/static/plugs/avatar/images/bch.jpg
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
web/static/plugs/avatar/images/bg.jpg
Normal file
|
After Width: | Height: | Size: 462 B |
BIN
web/static/plugs/avatar/images/bg.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
web/static/plugs/avatar/images/bg_headLine1.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
web/static/plugs/avatar/images/bg_index.gif
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
web/static/plugs/avatar/images/bg_repno.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
web/static/plugs/avatar/images/border.gif
Normal file
|
After Width: | Height: | Size: 329 B |
BIN
web/static/plugs/avatar/images/btn5.jpg
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
web/static/plugs/avatar/images/cam.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
web/static/plugs/avatar/images/cam_bg.jpg
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
web/static/plugs/avatar/images/default.gif
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
web/static/plugs/avatar/images/fancybox_sprite.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
web/static/plugs/avatar/images/loading.gif
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
web/static/plugs/avatar/images/logo.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
web/static/plugs/avatar/images/logo2.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
web/static/plugs/avatar/images/photo/1.jpg
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
web/static/plugs/avatar/images/photo/2.jpg
Normal file
|
After Width: | Height: | Size: 117 KiB |
BIN
web/static/plugs/avatar/images/photo/3.jpg
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
web/static/plugs/avatar/images/photo/4.jpg
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
web/static/plugs/avatar/images/photo/5.jpg
Normal file
|
After Width: | Height: | Size: 148 KiB |
BIN
web/static/plugs/avatar/images/photo/6.jpg
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
web/static/plugs/avatar/images/photo/7.jpg
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
web/static/plugs/avatar/images/photo/8.jpg
Normal file
|
After Width: | Height: | Size: 88 KiB |
1
web/static/plugs/avatar/images/photo/ShearPhoto作者.txt
Normal file
@@ -0,0 +1 @@
|
||||
ShearPhoto作者肖像相册8张,只供测试所用
|
||||
BIN
web/static/plugs/avatar/images/shutter.mp3
Normal file
BIN
web/static/plugs/avatar/images/waterimg.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
web/static/plugs/avatar/images/waterimg2.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
web/static/plugs/avatar/images/webcam.swf
Normal file
BIN
web/static/plugs/avatar/images/zoom.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
2139
web/static/plugs/avatar/js/ShearPhoto.js
Normal file
811
web/static/plugs/avatar/js/alloyimage.js
Normal file
@@ -0,0 +1,811 @@
|
||||
try {
|
||||
Array.prototype.del = function(a) {
|
||||
a.sort();
|
||||
for (var b = this.concat([]), c = a.length - 1; c >= 0; c--) b = b.slice(0, a[c]).concat(b.slice(a[c] + 1));
|
||||
return b;
|
||||
},
|
||||
|
||||
HTMLImageElement.prototype.loadOnce = function(a) {
|
||||
var b = 0;
|
||||
this.onload = function() {
|
||||
b || a.call(this, null), b++;
|
||||
};
|
||||
},
|
||||
function(a) {
|
||||
var b = {
|
||||
lib: [],
|
||||
init: function() {
|
||||
this.require("config");
|
||||
},
|
||||
module: function(a, b) {
|
||||
this.lib[a] = b.call(null, this);
|
||||
},
|
||||
require: function(a) {
|
||||
var b = this,
|
||||
c = document.createElement("script");
|
||||
document.body.appendChild(c), c.src = "./js/module/" + a + ".js", c.onload = c.onerror = function(a) {
|
||||
b.handlerror(a);
|
||||
};
|
||||
},
|
||||
handlerror: function() {},
|
||||
destroySelf: function(b) {
|
||||
throw delete ShearPhoto[a], Error(b);
|
||||
},
|
||||
reflect: function(a, b, c) {
|
||||
return a = this.lib.config.getModuleName(a), this.lib[a].process(b, c);
|
||||
},
|
||||
reflectEasy: function(a) {
|
||||
return a = this.lib.config.getEasyFun(a), this.lib.easy.getFun(a);
|
||||
},
|
||||
add: function(a, b, c, d, e, f, g, h) {
|
||||
return this.lib.addLayer.add(a, b, c, d, e, f, g, h);
|
||||
},
|
||||
applyMatrix: function() {}
|
||||
};
|
||||
ShearPhoto[a] = function(b, c, d) {
|
||||
if (!(this instanceof ShearPhoto[a])) return new ShearPhoto[a](b, c, d);
|
||||
this.startTime = +new Date();
|
||||
var e = document.createElement("canvas"),
|
||||
f = e.getContext("2d"),
|
||||
imgWidth, imgHeight;
|
||||
isNaN(b) ? (e.width = parseInt(b.width), e.height = parseInt(b.height), c = getComputedStyle(b),
|
||||
imgWidth = parseInt(c.getPropertyValue("width")), imgHeight = parseInt(c.getPropertyValue("height")),
|
||||
isNaN(imgWidth) ? f.drawImage(b, 0, 0) : f.drawImage(b, 0, 0, imgWidth, imgHeight)) : (e.width = b,
|
||||
e.height = c, f.fillStyle = d || "#fff", f.fillRect(0, 0, b, c)), this.canvas = e,
|
||||
this.context = f, this.imgData = f.getImageData(0, 0, e.width, e.height), this.name = a + "_" + Math.random(),
|
||||
this.canvas.id = this.name, this.layers = [], b = document.createElement("canvas"),
|
||||
b.width = e.width, b.height = e.height;
|
||||
}, ShearPhoto[a].module = function(a, c) {
|
||||
b.module(a, c);
|
||||
}, ShearPhoto[a].dorsyMath = function() {
|
||||
return b.lib.dorsyMath;
|
||||
}, ShearPhoto[a].prototype = {
|
||||
act: function(a) {
|
||||
var c = [],
|
||||
c = Array.prototype.slice.call(arguments, 1);
|
||||
return b.reflect(a, this.imgData, c), this;
|
||||
},
|
||||
view: function(a, b, c, d, e) {
|
||||
var f = this.clone();
|
||||
return f.type = 1, this.addLayer(f, "正常", 0, 0), f.act(a, b, c, d, e), this;
|
||||
},
|
||||
excute: function() {
|
||||
var a = this.layers,
|
||||
b = a.length;
|
||||
a[b - 1] && 1 == a[b - 1][0].type && (this.imgData = a[b - 1][0].imgData, delete a[b - 1]);
|
||||
},
|
||||
cancel: function() {
|
||||
var a = this.layers,
|
||||
b = a.length;
|
||||
a[b - 1] && 1 == a[b - 1][0].type && delete a[b - 1];
|
||||
},
|
||||
show: function(b, c) {
|
||||
var d, e, f, g, h = new ShearPhoto[a](this.canvas.width, this.canvas.height);
|
||||
for (h.add(this, "正常", 0, 0, c), this.tempPsLib = h, d = 0; d < this.layers.length; d++) e = this.layers[d],
|
||||
f = e[0].layers, g = e[0], f[f.length - 1] && 1 == f[f.length - 1][0].type && (g = f[f.length - 1][0]),
|
||||
h.add(g, e[1], e[2], e[3], c);
|
||||
return this.context.clearRect(0, 0, this.canvas.width, this.canvas.height), this.context.putImageData(h.imgData, 0, 0),
|
||||
b ? document.querySelector(b).appendChild(this.canvas) : document.body.appendChild(this.canvas),
|
||||
this;
|
||||
},
|
||||
replace: function(a) {
|
||||
return a && (a.onload = function() {}, a.src = this.save()), this;
|
||||
},
|
||||
add: function() {
|
||||
var a, c, d, e, f, g = [];
|
||||
for (d = 0; d < arguments.length; d++)
|
||||
if (d) switch (typeof arguments[d]) {
|
||||
case "string":
|
||||
/\d+%/.test(arguments[d]) ? c = arguments[d].replace("%", "") : /[RGB]+/.test(arguments[d]) ? f = arguments[d] : a = arguments[d];
|
||||
break;
|
||||
|
||||
case "number":
|
||||
g.push(arguments[d]);
|
||||
break;
|
||||
|
||||
case "boolean":
|
||||
e = arguments[d];
|
||||
}
|
||||
return d = g[0] || 0, g = g[1] || 0, this.imgData = b.add(this.imgData, arguments[0].imgData, a || "正常", c / 100 || 1, d, g, e || !1, f || "RGB"),
|
||||
this;
|
||||
},
|
||||
addLayer: function(a, b, c, d) {
|
||||
return this.layers.push([a, b, c, d]), this;
|
||||
},
|
||||
clone: function() {
|
||||
var b = new ShearPhoto[a](this.canvas.width, this.canvas.height);
|
||||
return b.context.putImageData(this.imgData, 0, 0), b.imgData = b.context.getImageData(0, 0, this.canvas.width, this.canvas.height),
|
||||
b;
|
||||
},
|
||||
swap: function(a, b) {
|
||||
var c = this.layers[a];
|
||||
return this.layers[a] = this.layers[b], this.layers[b] = c, this;
|
||||
},
|
||||
deleteLayers: function(a) {
|
||||
this.layers = this.layers.del(a);
|
||||
},
|
||||
save: function(b, c) {
|
||||
var d, e, f, g, h;
|
||||
if (!this.layers.length) return c ? (this.context.putImageData(this.imgData, 0, 0),
|
||||
this.canvas.toDataURL(c, .9)) : (this.context.putImageData(this.imgData, 0, 0), this.canvas.toDataURL());
|
||||
for (d = new ShearPhoto[a](this.canvas.width, this.canvas.height), d.add(this, "正常", 0, 0, b),
|
||||
this.tempPsLib = d, e = 0; e < this.layers.length; e++) f = this.layers[e], g = f[0].layers,
|
||||
h = f[0], g[g.length - 1] && 1 == g[g.length - 1][0].type && (h = g[g.length - 1][0]),
|
||||
d.add(h, f[1], f[2], f[3], b);
|
||||
return this.context.clearRect(0, 0, this.canvas.width, this.canvas.height), this.context.putImageData(d.imgData, 0, 0),
|
||||
c ? this.canvas.toDataURL(c, .9) : this.canvas.toDataURL();
|
||||
},
|
||||
drawRect: function() {
|
||||
var a, b, c, d, e, f;
|
||||
for ((a = document.getElementById("imgRect")) || (a = document.createElement("canvas"),
|
||||
a.id = "imgRect", document.body.appendChild(a), a.width = parseInt(this.canvas.width),
|
||||
a.height = parseInt(this.canvas.height)), b = a.getContext("2d"), b.clearRect(0, 0, a.width, a.height),
|
||||
c = [], d = this.tempPsLib.imgData.data, e = 0, f = d.length; f > e; e++) c[d[e]] ? c[d[e]]++ : c[d[e]] = 1;
|
||||
for (b.beginPath(), b.moveTo(0, a.height), e = d = 0; 255 > e; e++) c[e] > d && (d = c[e]);
|
||||
for (e = 0; 255 > e; e++) f = c[e] || 0, f = a.height - .8 * (f / d) * a.height,
|
||||
b.lineTo(e / 256 * a.width, f, 1, 1);
|
||||
b.lineTo(a.width + 10, a.height), b.fill();
|
||||
},
|
||||
ps: function(a) {
|
||||
var c;
|
||||
return c = b.reflectEasy(a).call(this), this.logTime("组合效果" + a), c;
|
||||
},
|
||||
logTime: function(a) {
|
||||
console.log(a + ": " + (+new Date() - this.startTime) / 1e3 + "s");
|
||||
},
|
||||
ctx: function(a) {
|
||||
var b = this.ctxContext;
|
||||
return b.putImageData(this.imgData, 0, 0), a.call(b), this.imgData = b.getImageData(0, 0, this.canvas.width, this.canvas.height),
|
||||
this;
|
||||
}
|
||||
};
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("ImageEnhance", function() {
|
||||
return {
|
||||
process: function(a) {
|
||||
for (var b = a.data, c = 0, d = b.length; d > c; c += 4);
|
||||
return a.data = b, a;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("addLayer", function() {
|
||||
return {
|
||||
add: function(a, b, c, d, e, f, g, h) {
|
||||
var i, j, k, l, m, n, o, p;
|
||||
for (g = a.data, i = b.data, e = e || 0, f = f || 0, d = d || 1, h = h || "RGB",
|
||||
/[RGB]+/.test(h) || (h = "RGB"), k = h.replace("R", "0").replace("G", "1").replace("B", "2"),
|
||||
h = a.width, l = i.length, b = b.width, k = [-1 < k.indexOf("0"), -1 < k.indexOf("1"), -1 < k.indexOf("2")],
|
||||
o = 0, p = g.length; p > o; o += 4)
|
||||
if (m = o / 4, n = parseInt(m / h), m %= h,
|
||||
n -= f, m -= e, n = n * b + m, n *= 4, n >= 0 && l - 4 > n && b > m && m >= 0)
|
||||
for (m = 0; 3 > m && 0 != i[n + 3]; m++) switch (g[o + 3] = i[n + 3],
|
||||
c) {
|
||||
case "颜色减淡":
|
||||
k[m] && (j = g[o + m] + g[o + m] * i[n + m] / (255 - i[n + m]), g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "变暗":
|
||||
k[m] && (j = g[o + m] < i[n + m] ? g[o + m] : i[n + m], g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "变亮":
|
||||
k[m] && (j = g[o + m] > i[n + m] ? g[o + m] : i[n + m], g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "正片叠底":
|
||||
k[m] && (j = parseInt(g[o + m] * i[n + m] / 255), g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "滤色":
|
||||
k[m] && (j = parseInt(255 - (255 - g[o + m]) * (255 - i[n + m]) / 255), g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "叠加":
|
||||
k[m] && (j = 127.5 >= g[o + m] ? g[o + m] * i[n + m] / 127.5 : 255 - (255 - g[o + m]) * (255 - i[n + m]) / 127.5,
|
||||
g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "强光":
|
||||
k[m] && (j = 127.5 >= i[n + m] ? g[o + m] * i[n + m] / 127.5 : g[o + m] + (255 - g[o + m]) * (i[n + m] - 127.5) / 127.5,
|
||||
g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "差值":
|
||||
k[m] && (j = g[o + m] > i[n + m] ? g[o + m] - i[n + m] : i[n + m] - g[o + m], g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "排除":
|
||||
k[m] && (j = g[o + m] + i[n + m] - g[o + m] * i[n + m] / 127.5, g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "点光":
|
||||
k[m] && (j = g[o + m] < 2 * i[n + m] - 255 ? 2 * i[n + m] - 255 : g[o + m] < 2 * i[n + m] ? g[o + m] : 2 * i[n + m],
|
||||
g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "颜色加深":
|
||||
k[m] && (j = 255 - 255 * (255 - g[o + m]) / i[n + m], g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "线性加深":
|
||||
k[m] && (j = g[o + m] + i[n + m], j = j > 255 ? j - 255 : 0, g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "线性减淡":
|
||||
k[m] && (j = g[o + m] + i[n + m], j = j > 255 ? 255 : j, g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "柔光":
|
||||
k[m] && (j = 127.5 > i[n + m] ? ((2 * i[n + m] - 255) * (255 - g[o + m]) / 65025 + 1) * g[o + m] : (2 * i[n + m] - 255) * (Math.sqrt(g[o + m] / 255) - g[o + m] / 255) + g[o + m],
|
||||
g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "亮光":
|
||||
k[m] && (j = 127.5 > i[n + m] ? 255 * (1 - (255 - g[o + m]) / (2 * i[n + m])) : g[o + m] / (2 * (1 - i[n + m] / 255)),
|
||||
g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "线性光":
|
||||
k[m] && (j = g[o + m] + 2 * i[n + m] - 255, j = j > 255 ? 255 : j, g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
case "实色混合":
|
||||
k[m] && (j = i[n + m] < 255 - g[o + m] ? 0 : 255, g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
break;
|
||||
|
||||
default:
|
||||
k[m] && (j = i[n + m], g[o + m] = (1 - d) * g[o + m] + d * j);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("brightness", function() {
|
||||
return {
|
||||
process: function(a, b) {
|
||||
var c, d, e, f, g, h;
|
||||
for (c = a.data, d = b[0] / 50, e = Math.tan((45 + 44 * ((b[1] || 0) / 50)) * Math.PI / 180),
|
||||
f = 0, g = c.length; g > f; f += 4)
|
||||
for (h = 0; 3 > h; h++) c[f + h] = (c[f + h] - 127.5 * (1 - d)) * e + 127.5 * (1 + d);
|
||||
return a;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("applyMatrix", function(a) {
|
||||
return {
|
||||
process: function(b) {
|
||||
var c, d, e, f, g, h, i, j, k, l, m, n, o, p;
|
||||
for (c = b.data, d = b.width, e = new a.lib.dorsyMath.Matrix([-2, -4, -4, -4, -2, -4, 0, 8, 0, -4, -4, 8, 24, 8, -4, -4, 0, 8, 0, -4, -2, -4, -4, -4, -2], 25, 1),
|
||||
f = [], g = 0, h = c.length; h > g; g += 4)
|
||||
if (i = g / 4, j = parseInt(i / d),
|
||||
k = i % d, 0 != j && 0 != k) {
|
||||
for (l = [
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
], m = -2; 3 > m; m++)
|
||||
for (n = j + m, o = -2; 3 > o; o++)
|
||||
for (p = 4 * (n * d + (k + o)),
|
||||
i = 0; 3 > i; i++) l[i].push(c[p + i]);
|
||||
for (j = new a.lib.dorsyMath.Matrix(l, 3, matrixSize).mutiply(e), i = 0; 3 > i; i++) f[g + i] = j.data[i];
|
||||
f[g + 4] = c[g + 4];
|
||||
}
|
||||
for (g = 0, h = c.length; h > g; g++) c[g] = f[g] || c[g];
|
||||
return b;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("config", function() {
|
||||
var a = {
|
||||
"灰度处理": "toGray",
|
||||
"反色": "toReverse",
|
||||
"灰度阈值": "toThresh",
|
||||
"高斯模糊": "gaussBlur",
|
||||
"亮度": "brightness",
|
||||
"浮雕效果": "embossment",
|
||||
"查找边缘": "borderline",
|
||||
"色相/饱和度调节": "setHSI",
|
||||
"马赛克": "mosaic",
|
||||
"油画": "oilPainting",
|
||||
"腐蚀": "corrode",
|
||||
"锐化": "sharp",
|
||||
"添加杂色": "noise",
|
||||
"曲线": "curve",
|
||||
"暗角": "darkCorner",
|
||||
"喷点": "dotted"
|
||||
},
|
||||
b = {
|
||||
"美肤": "softenFace",
|
||||
"素描": "sketch",
|
||||
"自然增强": "softEnhancement",
|
||||
"紫调": "purpleStyle",
|
||||
"柔焦": "soften",
|
||||
"复古": "vintage",
|
||||
"黑白": "gray",
|
||||
"仿lomo": "lomo",
|
||||
"亮白增强": "strongEnhancement",
|
||||
"灰白": "strongGray",
|
||||
"灰色": "lightGray",
|
||||
"暖秋": "warmAutumn",
|
||||
"木雕": "carveStyle",
|
||||
"粗糙": "rough"
|
||||
};
|
||||
return {
|
||||
getModuleName: function(b) {
|
||||
return a[b] || b;
|
||||
},
|
||||
getEasyFun: function(a) {
|
||||
return b[a] || a;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("corrode", function() {
|
||||
return {
|
||||
process: function(a, b) {
|
||||
var c, d, e, f, g, h, i, j, k;
|
||||
for (c = parseInt(b[0]) || 3, d = a.data, e = a.width, f = a.height, g = 0; e > g; g++)
|
||||
for (h = 0; f > h; h++)
|
||||
for (i = parseInt(2 * Math.random() * c) - c,
|
||||
j = parseInt(2 * Math.random() * c) - c, k = h * e + g, i = (h + i) * e + g + j,
|
||||
j = 0; 3 > j; j++) d[4 * k + j] = d[4 * i + j];
|
||||
return a;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("curve", function(a) {
|
||||
return {
|
||||
process: function(b, c) {
|
||||
var d, e, f, g, h, i, j, k;
|
||||
for (d = a.lib.dorsyMath.lagrange(c[0], c[1]), e = b.data, f = b.width, g = b.height,
|
||||
h = 0; f > h; h++)
|
||||
for (i = 0; g > i; i++)
|
||||
for (j = i * f + h, k = 0; 3 > k; k++) e[4 * j + k] = d(e[4 * j + k]);
|
||||
return b;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("darkCorner", function(a) {
|
||||
return {
|
||||
process: function(b, c) {
|
||||
var d, e, f, g, h, i, j, k, l, m, n, o, p, q;
|
||||
for (d = parseInt(c[0]) || 3, e = c[1] || 30, f = b.data, g = b.width, h = b.height,
|
||||
i = 2 * g / 3, j = 1 * h / 2, k = a.lib.dorsyMath.distance([i, j]), d = k * (1 - d / 10),
|
||||
l = 0; g > l; l++)
|
||||
for (m = 0; h > m; m++)
|
||||
for (n = m * g + l, o = 0; 3 > o; o++) p = f[4 * n + o],
|
||||
q = (a.lib.dorsyMath.distance([l, m], [i, j]) - d) / (k - d), 0 > q && (q = 0),
|
||||
p = (0 * Math.pow(1 - q, 3) + .06 * q * Math.pow(1 - q, 2) + 3 * .3 * q * q * (1 - q) + 1 * Math.pow(q, 3)) * p * e / 255,
|
||||
f[4 * n + o] -= p;
|
||||
return b;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("dorsyMath", function(a) {
|
||||
var b = {
|
||||
FFT1: function(a) {
|
||||
function c() {
|
||||
var g, h, i, j, k, l, m, n, o, p, q;
|
||||
for (e++, g = d / Math.pow(2, e), h = d / g, i = 0; g > i; i++)
|
||||
for (j = i * h,
|
||||
k = (i + 1) * h - 1, l = e, m = Math.pow(2, l - 1), n = 0; k - m >= j; j++) o = j + m,
|
||||
p = n * d / Math.pow(2, l), q = p + d / 4, a[j] instanceof b.C || (a[j] = new b.C(a[j])),
|
||||
a[o] instanceof b.C || (a[o] = new b.C(a[o])), p = a[j].plus(a[o].mutiply(f[p])),
|
||||
q = a[j].plus(a[o].mutiply(f[q])), a[j] = p, a[o] = q, n++;
|
||||
g > 1 && c();
|
||||
}
|
||||
for (var d = a.length, e = 0, f = [], g = 0; d > g; g++) f[g] = this.exp(-2 * Math.PI * g / d);
|
||||
return c(), a;
|
||||
},
|
||||
DFT: function() {},
|
||||
Matrix: function(a, b, c) {
|
||||
var d, e, f = [];
|
||||
if (b) {
|
||||
if (isNaN(b) ? (d = /(\d+)\*/.exec(b)[1], b = /\*(\d+)/.exec(b)[1]) : (d = b, b = c),
|
||||
a[0] && a[0][0])
|
||||
for (c = 0; d > c; c++)
|
||||
for (f[c] = [], e = 0; b > e; e++) f[c][e] = a[c][e] || 0;
|
||||
else
|
||||
for (c = 0; d > c; c++)
|
||||
for (f[c] = [],
|
||||
e = 0; b > e; e++) f[c][e] = a[c * b + e] || 0;
|
||||
this.m = d, this.n = b;
|
||||
} else this.m = a.length, this.n = a[0].length;
|
||||
this.data = f;
|
||||
},
|
||||
C: function(a, b) {
|
||||
this.r = a || 0, this.i = b || 0;
|
||||
},
|
||||
exp: function(a, c) {
|
||||
a = a || 0, c = c || 1;
|
||||
var d = new b.C();
|
||||
return d.r = c * Math.cos(a), d.i = c * Math.sin(a), d;
|
||||
},
|
||||
lagrange: function(a, b) {
|
||||
var c = a.length;
|
||||
return function(d) {
|
||||
var e, f, g, h, i;
|
||||
for (e = 0, f = 0; c > f; f++) {
|
||||
for (g = 1, h = 1, i = 0; c > i; i++) i != f && (g *= a[f] - a[i], h *= d - a[i]);
|
||||
e += b[f] * (h / g);
|
||||
}
|
||||
return e;
|
||||
};
|
||||
},
|
||||
applyMatrix: function(c, d, e) {
|
||||
var f, g, h, i, j, k, l, m, n, o, p, q, r, s, t;
|
||||
for (e = e || 0, f = c.data, g = c.width, h = d.length, d = new b.Matrix(d, h, 1),
|
||||
i = [], j = -(Math.sqrt(h) - 1) / 2, k = 0, l = f.length; l > k; k += 4)
|
||||
if (m = k / 4,
|
||||
n = parseInt(m / g), o = m % g, 0 != n && 0 != o) {
|
||||
for (p = [
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
], q = j; - j >= q; q++)
|
||||
for (r = n + q, s = j; - j >= s; s++)
|
||||
for (t = 4 * (r * g + (o + s)),
|
||||
m = 0; 3 > m; m++) p[m].push(f[t + m]);
|
||||
for (n = new a.lib.dorsyMath.Matrix(p, 3, h).mutiply(d), m = 0; 3 > m; m++) i[k + m] = n.data[m];
|
||||
i[k + 4] = f[k + 4];
|
||||
}
|
||||
for (k = 0, l = f.length; l > k; k++) i[k] && (f[k] = i[k] < e ? i[k] : f[k]);
|
||||
return c;
|
||||
},
|
||||
RGBToHSI: function(a, b, c) {
|
||||
var d = (a - b + a - c) / 2 / Math.sqrt((a - b) * (a - b) + (a - c) * (b - c)) || 0,
|
||||
d = Math.acos(d),
|
||||
d = c > b ? 2 * Math.PI - d : d,
|
||||
e = 1 - 3 * Math.min(a, b, c) / (a + b + c);
|
||||
return d > 2 * Math.PI && (d = 2 * Math.PI), 0 > d && (d = 0), {
|
||||
H: d,
|
||||
S: e,
|
||||
I: (a + b + c) / 3
|
||||
};
|
||||
},
|
||||
HSIToRGB: function(a, b, c) {
|
||||
if (0 > a ? (a %= 2 * Math.PI, a += 2 * Math.PI) : a %= 2 * Math.PI, a <= 2 * Math.PI / 3) var d = c * (1 - b),
|
||||
e = c * (1 + b * Math.cos(a) / Math.cos(Math.PI / 3 - a)),
|
||||
f = 3 * c - (e + d);
|
||||
else a <= 4 * Math.PI / 3 ? (a -= 2 * Math.PI / 3,
|
||||
e = c * (1 - b), f = c * (1 + b * Math.cos(a) / Math.cos(Math.PI / 3 - a)), d = 3 * c - (f + e)) : (a -= 4 * Math.PI / 3,
|
||||
f = c * (1 - b), d = c * (1 + b * Math.cos(a) / Math.cos(Math.PI / 3 - a)), e = 3 * c - (f + d));
|
||||
return {
|
||||
R: e,
|
||||
G: f,
|
||||
B: d
|
||||
};
|
||||
},
|
||||
applyInHSI: function(a, b) {
|
||||
var c, d, e, f;
|
||||
for (c = a.data, d = 0, e = c.length; e > d; d += 4) f = this.RGBToHSI(c[d], c[d + 1], c[d + 2]),
|
||||
b(f), 1 < f.S && (f.S = 1), 0 > f.S && (f.S = 0), f = this.HSIToRGB(f.H, f.S, f.I),
|
||||
c[d] = f.R, c[d + 1] = f.G, c[d + 2] = f.B;
|
||||
},
|
||||
applyInCoordinate: function() {},
|
||||
distance: function(a, c) {
|
||||
return c = c || [0, 0], a = new b.C(a[0], a[1]), c = new b.C(c[0], c[1]), a.minus(c).distance();
|
||||
},
|
||||
xyToIFun: function(a) {
|
||||
return function(b, c, d) {
|
||||
return 4 * (c * a + b) + (d || 0);
|
||||
};
|
||||
},
|
||||
xyCal: function(a, b, c, d, e) {
|
||||
var f, g, h;
|
||||
for (f = this.xyToIFun(a.width), g = 0; 3 > g; g++) h = f(b, c, g), a[h] = d(a[h]);
|
||||
e && (a[h + 1] = e(a[h + 1]));
|
||||
}
|
||||
};
|
||||
return b.Matrix.prototype = {
|
||||
plus: function(a) {
|
||||
var c, d, e;
|
||||
if (this.m != a.m || this.n != a.n) throw Error("矩阵加法行列不匹配");
|
||||
for (c = new b.Matrix([], this.m, this.n), d = 0; d < this.m; d++)
|
||||
for (e = 0; e < this.n; e++) c.data[d][e] = this.data[d][e] + a.data[d][e];
|
||||
return c;
|
||||
},
|
||||
minus: function(a) {
|
||||
var c, d, e;
|
||||
if (this.m != a.m || this.n != a.n) throw Error("矩阵减法法行列不匹配");
|
||||
for (c = new b.Matrix([], this.m, this.n), d = 0; d < this.m; d++)
|
||||
for (e = 0; e < this.n; e++) c.data[d][e] = this.data[d][e] - a.data[d][e];
|
||||
return c;
|
||||
},
|
||||
mutiply: function(a) {
|
||||
var c, d, e, f, g;
|
||||
if (this.n != a.m) throw Error("矩阵乘法行列不匹配");
|
||||
for (c = new b.Matrix([], this.m, a.n), d = 0; d < this.m; d++)
|
||||
for (e = 0; e < a.n; e++) {
|
||||
for (f = 0, g = 0; g < this.n; g++) f += this.data[d][g] * a.data[g][e];
|
||||
c.data[d][e] = f;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}, b.C.prototype = {
|
||||
plus: function(a) {
|
||||
var c = new b.C();
|
||||
return c.r = this.r + a.r, c.i = this.i + a.i, c;
|
||||
},
|
||||
minus: function(a) {
|
||||
var c = new b.C();
|
||||
return c.r = this.r - a.r, c.i = this.i - a.i, c;
|
||||
},
|
||||
mutiply: function(a) {
|
||||
var c = new b.C();
|
||||
return c.r = this.r * a.r - this.i * a.i, c.i = this.r * a.i + this.i * a.r, c;
|
||||
},
|
||||
divide: function(a) {
|
||||
var c = new b.C(),
|
||||
d = a.mutiply(a.conjugated());
|
||||
return a = this.mutiply(a.conjugated()), c.r = a.r / d.r, c.i = a.i / d.r, c;
|
||||
},
|
||||
conjugated: function() {
|
||||
return new b.C(this.r, -this.i);
|
||||
},
|
||||
distance: function() {
|
||||
return Math.sqrt(this.r * this.r + this.i * this.i);
|
||||
}
|
||||
}, b;
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("dotted", function(a) {
|
||||
return {
|
||||
process: function(b, c) {
|
||||
var d, e, f, g, h, i, j, k, l, m, n, o, p, q;
|
||||
for (d = parseInt(c[0]) || 1, e = parseInt(c[1]) || 1, f = b.data, g = b.width,
|
||||
h = b.height, i = 2 * d + 1, j = [], k = e * e, e = -d; d > e; e++)
|
||||
for (l = -d; d > l; l++) e * e + l * l > k && j.push([e, l]);
|
||||
for (d = a.lib.dorsyMath.xyToIFun(g), e = 0, g = parseInt(g / i); g > e; e++)
|
||||
for (l = 0,
|
||||
k = parseInt(h / i); k > l; l++)
|
||||
for (m = parseInt((e + .5) * i), n = parseInt((l + .5) * i),
|
||||
o = 0; o < j.length; o++) p = m + j[o][0], q = n + j[o][1], f[d(p, q, 3)] = 225,
|
||||
f[d(p, q, 2)] = 225, f[d(p, q, 0)] = 225, f[d(p, q, 1)] = 225;
|
||||
return b;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("easy", function() {
|
||||
return {
|
||||
getFun: function(b) {
|
||||
return {
|
||||
softenFace: function() {
|
||||
return this.clone().add(this.act("高斯模糊", 10), "滤色").act("亮度", -10, 5);
|
||||
},
|
||||
sketch: function() {
|
||||
var a = this.act("灰度处理").clone();
|
||||
return this.add(a.act("反色").act("高斯模糊", 8), "颜色减淡").act("锐化", 1);
|
||||
},
|
||||
softEnhancement: function() {
|
||||
return this.act("曲线", [0, 190, 255], [0, 229, 255]);
|
||||
},
|
||||
purpleStyle: function() {
|
||||
var a = this.clone();
|
||||
return this.add(a.act("高斯模糊", 3), "正片叠底", "RG");
|
||||
},
|
||||
soften: function() {
|
||||
var a = this.clone();
|
||||
return this.add(a.act("高斯模糊", 6), "变暗");
|
||||
},
|
||||
vintage: function() {
|
||||
return this.clone(), this.act("灰度处理").add(ShearPhoto[a](this.canvas.width, this.canvas.height, "#808080").act("添加杂色").act("高斯模糊", 4).act("色相/饱和度调节", 32, 19, 0, !0), "叠加");
|
||||
},
|
||||
gray: function() {
|
||||
return this.act("灰度处理");
|
||||
},
|
||||
lomo: function() {
|
||||
return this.clone().add(this.clone(), "滤色").add(this.clone(), "柔光").add(this.clone().act("反色"), "正常", "20%", "B").act("暗角", 6, 200);
|
||||
},
|
||||
strongEnhancement: function() {
|
||||
return this.clone().add(this.clone().act("曲线", [0, 50, 255], [0, 234, 255]), "柔光");
|
||||
},
|
||||
strongGray: function() {
|
||||
return this.act("灰度处理").act("曲线", [0, 61, 69, 212, 255], [0, 111, 176, 237, 255]);
|
||||
},
|
||||
lightGray: function() {
|
||||
return this.act("灰度处理").act("曲线", [0, 60, 142, 194, 255], [0, 194, 240, 247, 255]);
|
||||
},
|
||||
warmAutumn: function() {
|
||||
var a = this.clone().act("色相/饱和度调节", 36, 47, 8, !0).act("暗角", 6, 150);
|
||||
return this.add(a, "叠加");
|
||||
},
|
||||
carveStyle: function() {
|
||||
var a = this.clone().act("马赛克").act("查找边缘").act("浮雕效果");
|
||||
return this.add(a, "线性光");
|
||||
},
|
||||
rough: function() {
|
||||
return this.add(ShearPhoto[a](this.canvas.width, this.canvas.height, "#000").act("喷点").act("反色").act("浮雕效果"), "叠加");
|
||||
}
|
||||
}[b];
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("embossment", function() {
|
||||
return {
|
||||
process: function(a) {
|
||||
var b, c, d, e, f, g, h, i, j;
|
||||
for (b = a.data, c = a.width, d = [], e = 0, f = b.length; f > e; e += 4)
|
||||
if (g = e / 4,
|
||||
h = parseInt(g / c), i = g % c, g = 4 * ((h - 1) * c + (i - 1)), j = 4 * (h + 1) * c + 4 * (i + 1),
|
||||
0 != h && 0 != i) {
|
||||
for (h = 0; 3 > h; h++) d[e + h] = b[g + h] - b[j + h] + 127.5;
|
||||
d[e + 4] = b[e + 4];
|
||||
}
|
||||
for (e = 0, f = b.length; f > e; e++) b[e] = d[e] || b[e];
|
||||
return a;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("gaussBlur", function() {
|
||||
return {
|
||||
process: function(a, b, c) {
|
||||
var d, e, f, g, h, i, j = a.data,
|
||||
k = a.width,
|
||||
l = a.height,
|
||||
m = [],
|
||||
n = 0;
|
||||
for (b = Math.floor(b) || 3, c = c || b / 3, d = 1 / (Math.sqrt(2 * Math.PI) * c),
|
||||
g = -1 / (2 * c * c), h = 0, c = -b; b >= c; c++, h++) f = d * Math.exp(g * c * c),
|
||||
m[h] = f, n += f;
|
||||
for (h = 0, c = m.length; c > h; h++) m[h] /= n;
|
||||
for (d = 0; l > d; d++)
|
||||
for (c = 0; k > c; c++) {
|
||||
for (n = e = f = g = 0, i = -b; b >= i; i++) h = c + i, h >= 0 && k > h && (h = 4 * (d * k + h),
|
||||
e += j[h] * m[i + b], f += j[h + 1] * m[i + b], g += j[h + 2] * m[i + b], n += m[i + b]);
|
||||
h = 4 * (d * k + c), j[h] = e / n, j[h + 1] = f / n, j[h + 2] = g / n;
|
||||
}
|
||||
for (c = 0; k > c; c++)
|
||||
for (d = 0; l > d; d++) {
|
||||
for (n = e = f = g = 0, i = -b; b >= i; i++) h = d + i, h >= 0 && l > h && (h = 4 * (h * k + c),
|
||||
e += j[h] * m[i + b], f += j[h + 1] * m[i + b], g += j[h + 2] * m[i + b], n += m[i + b]);
|
||||
h = 4 * (d * k + c), j[h] = e / n, j[h + 1] = f / n, j[h + 2] = g / n;
|
||||
}
|
||||
return a.data = j, a;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("borderline", function(a) {
|
||||
return {
|
||||
process: function(b) {
|
||||
return a.lib.dorsyMath.applyMatrix(b, [0, 1, 0, 1, -4, 1, 0, 1, 0], 250);
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("mosaic", function() {
|
||||
return {
|
||||
process: function(a, b) {
|
||||
var c, d, e, f, g, h, i, j, k, l, m, n, o;
|
||||
for (c = parseInt(b[0]) || 3, d = a.data, e = a.width, f = a.height, c = 2 * c + 1,
|
||||
g = 0, h = parseInt(e / c); h > g; g++)
|
||||
for (i = 0, j = parseInt(f / c); j > i; i++) {
|
||||
for (k = [], l = [0, 0, 0], m = 0; c > m; m++)
|
||||
for (n = 0; c > n; n++) o = (i * c + m) * e + g * c + n,
|
||||
l[0] += d[4 * o], l[1] += d[4 * o + 1], l[2] += d[4 * o + 2];
|
||||
for (k[0] = l[0] / (c * c), k[1] = l[1] / (c * c), k[2] = l[2] / (c * c), m = 0; c > m; m++)
|
||||
for (n = 0; c > n; n++) o = (i * c + m) * e + g * c + n,
|
||||
d[4 * o] = k[0], d[4 * o + 1] = k[1], d[4 * o + 2] = k[2];
|
||||
}
|
||||
return a;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("noise", function() {
|
||||
return {
|
||||
process: function(a, b) {
|
||||
var c, d, e, f, g, h, i, j, k;
|
||||
for (c = parseInt(b[0]) || 100, d = a.data, e = a.width, f = a.height, g = 0; e > g; g++)
|
||||
for (h = 0; f > h; h++)
|
||||
for (i = h * e + g,
|
||||
j = 0; 3 > j; j++) k = parseInt(2 * Math.random() * c) - c, d[4 * i + j] += k;
|
||||
return a;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("oilPainting", function() {
|
||||
return {
|
||||
process: function(a, b) {
|
||||
var c, d, e, f, g, h, i, j, k;
|
||||
for (c = parseInt(b[0]) || 16, d = a.data, e = a.width, f = a.height, g = 0; e > g; g++)
|
||||
for (h = 0; f > h; h++) {
|
||||
for (i = h * e + g, j = 0, k = 0; 3 > k; k++) j += d[4 * i + k];
|
||||
for (j /= 3, j = parseInt(j / c) * c, k = 0; 3 > k; k++) d[4 * i + k] = j;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("setHSI", function(a) {
|
||||
return {
|
||||
process: function(b, c) {
|
||||
return c[0] = c[0] / 180 * Math.PI, c[1] = c[1] / 100 || 0, c[2] = 255 * (c[2] / 100) || 0,
|
||||
c[3] = c[3] || !1, a.lib.dorsyMath.applyInHSI(b, function(a) {
|
||||
c[3] ? (a.H = c[0], a.S = c[1]) : (a.H += c[0], a.S += c[1]), a.I += c[2];
|
||||
}), b;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("sharp", function() {
|
||||
return {
|
||||
process: function(a, b) {
|
||||
var c, d, e, f, g, h, i, j, k;
|
||||
for (c = b[0] || .6, d = a.data, e = a.width, f = 0, g = d.length; g > f; f += 4)
|
||||
if (h = f / 4,
|
||||
i = parseInt(h / e), j = h % e, 0 != i && 0 != j)
|
||||
for (k = 4 * ((i - 1) * e + (j - 1)),
|
||||
i = 4 * ((i - 1) * e + j), h = 4 * (h - 1), j = 0; 3 > j; j++) d[f + j] += (d[f + j] - (d[i + j] + d[h + j] + d[k + j]) / 3) * c;
|
||||
return a;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("toGray", function() {
|
||||
return {
|
||||
process: function(a) {
|
||||
var b, c, d, e;
|
||||
for (b = a.data, c = 0, d = b.length; d > c; c += 4) e = parseInt((b[c] + b[c + 1] + b[c + 2]) / 3),
|
||||
b[c + 2] = b[c + 1] = b[c] = e;
|
||||
return a.data = b, a;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("toReverse", function() {
|
||||
return {
|
||||
process: function(a) {
|
||||
for (var b = a.data, c = 0, d = b.length; d > c; c += 4) b[c] = 255 - b[c], b[c + 1] = 255 - b[c + 1],
|
||||
b[c + 2] = 255 - b[c + 2];
|
||||
return a.data = b, a;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib"),
|
||||
function(a) {
|
||||
ShearPhoto[a].module("toThresh", function(a) {
|
||||
return {
|
||||
process: function(b, c) {
|
||||
var d, e, f;
|
||||
for (b = a.lib.toGray.process(b), d = b.data, c = c[0] || 128, e = 0, f = d.length; f > e; e++)(e + 1) % 4 && (d[e] = d[e] > c ? 255 : 0);
|
||||
return b.data = d, b;
|
||||
}
|
||||
};
|
||||
});
|
||||
}("psLib");
|
||||
} catch (e) {}
|
||||
222
web/static/plugs/avatar/js/handle.js
Normal file
@@ -0,0 +1,222 @@
|
||||
/*----------------------------注释结束--程序开始-----------------------------------------------------------*/
|
||||
window.ShearPhoto.MINGGE(function() {
|
||||
//██████████重要设置████████████████
|
||||
var relativeUrl = "/public/plugs/avatar"; //你不要在后面加斜杠,系统会自动给你加上斜杠,不信看下面! index.html的JS引用路径自己改,很简单的说
|
||||
|
||||
//█████████重要设置█████████████████
|
||||
relativeUrl = relativeUrl.replace(/(^\s*)|(\s*$)/g, ""); //去掉相对路径的所有空格
|
||||
relativeUrl === "" || (relativeUrl += "/"); //在相对地址后面加斜框,不需要用户自己加
|
||||
var publicRelat = document.getElementById("relat"); //"relat"对像
|
||||
var publicRelatImg = publicRelat.getElementsByTagName("img"); //"relat"下的两张图片对像
|
||||
var Shear = new ShearPhoto;
|
||||
Shear.config({
|
||||
/*---------------用户设置部份开始-----------------------------------------------------------------------*/
|
||||
relativeUrl: relativeUrl, //取回相对路径,不懂原理的话,你不要改动哦,否则你又鸡巴痛了
|
||||
|
||||
traverse: true, //可选 true,false 。 是否在拖动或拉伸时允许历遍全图(是否让大图动呢),
|
||||
|
||||
/*HTML5重点功能*/
|
||||
translate3d: false, //是否开启3D移动,CPU加速。可选true false。默认关闭的,作者认为PC端没必要!在PC端开启后,有部份浏览器页面走位的问题。主要是各大浏览器不统一所致,手机端效果会明显!PC端没什么感觉。 原来是采用left top进行定位的,那么3D移动就是CSS3的translate3d属性。去百度一下translate3D吧
|
||||
|
||||
/*HTML5重点功能*/
|
||||
HTML5: true, //可选 true,false 是否使用HTML5进行切图 ,支持HTML5浏览器会使用HTML5进行切图,没有HTML5浏览器则采用原始的方式(先上传大图再截取),SHEARPHOTO这个方案无可挑剔了吧!
|
||||
|
||||
/*HTML5重点功能*/
|
||||
HTML5MAX: 500, //默认请设0 (最大尺寸做事), HTML上传截图最大宽度, 宽度越大,HTML5截出来的图片容量越大,服务器压力就大,截图就更清淅! 设得越小 HTML5截出来的图片容量越小.但是造成一定程序的不清淅,请适量设置 当然开启HTML5切图,该设置才有效
|
||||
|
||||
/*HTML5重点功能*/
|
||||
HTML5Quality: 0.9, //截好的截图 0至1范围可选(可填小数) HTML5切图的质量 为1时 最高 ,当然开启HTML5切图,该设置才有效,设得越高,越清淅,但文件体积越大,同上!
|
||||
|
||||
/*HTML5重点功能*/
|
||||
HTML5FilesSize: 50, //如果是HTML5切图时,选择的图片不能超过多少,单位M,,你设大点都不怕, ------因为HTML5ZIP会对原图进行压缩处理
|
||||
|
||||
/*HTML5重点功能*/
|
||||
HTML5Effects: true, //是否开启图片特效功能给用户 可选true false, 提示:有HTML5浏览器才会开启的!当然开启HTML5切图,该设置才有效
|
||||
|
||||
/*HTML5重点功能*/
|
||||
HTML5ZIP: [900, 0.9], //HTML5截图前载入的大图 是否压缩图片(数组成员 是数字) ,如果不压缩的话填false,在处理特效时或者拉伸时会明显出卡顿,不流畅!官方强烈建意你进行设置 ,默认填写的是[900,0.9] ,代表宽和高都不能大于900,质量是0.9(最大是1)
|
||||
|
||||
/*记住 preview (预览图片功能) 尽量设false*/
|
||||
|
||||
preview: [150], // 开启动态预览图片 (数组成员整数型,禁止含小数点 可选false 和数组) 数组内是宽度设置,没有高度设!因为高度会按比例做事 ,此设置代表预览150 大小的预览图(你可以增加多个预览图,如[100,70,50]),设置越多预览图,shearphoto性能越差!官方不建意你开启这个功能,尽可能请设为preview:false
|
||||
|
||||
/*记住 preview 尽量设false*/
|
||||
|
||||
url: "/user/upload/avatar", //后端处理地址,保证正确哦,这是常识,连这个地址都能写错,你就是菜B,已经在本版本中帮你加入相对路径,你基本不用改这里了
|
||||
|
||||
scopeWidth: 500, //可拖动范围宽 也就是"main"对象的初始大小(整数型,禁止含小数点) 宽和高的值最好能一致
|
||||
|
||||
scopeHeight: 500, //可拖动范围高 也就是"main"对象的初始大小(整数型,禁止含小数点) 宽和高的值最好能一致
|
||||
|
||||
proportional: [1 / 1, <!--截框的宽高比例(宽除以高的比例值,这个设置其实就是1,对!你可以直接写1 如填3/4 那么就是0.75的比例,不设比例请设为0,注意更改比例后,后端也要进行相应设置,否则系统会给你抱出错误-->
|
||||
/*
|
||||
2.3版本加了一个新API ,动态修改比例!接口示例:Shear.SetProportional(3/4); 意思就是:动态修改比例为3/4;
|
||||
*/
|
||||
100, //必须整数!启动后的截框初始宽度(整数型,禁止含小数点)
|
||||
|
||||
133 //比例设置后,这个高度无效,由宽和比例来决定(整数型,禁止含小数点)
|
||||
],
|
||||
|
||||
Min: 50, //截框拉伸或拖拽不能少于多少PX(整数型,禁止含小数点)
|
||||
|
||||
Max: 500, //一开始启动时,图片的宽和高,有时候图片会很大的,必须要设置一下(整数型,禁止含小数点),尽可能和scopeWidth值 一致
|
||||
|
||||
backgroundColor: "#000", //遮层色
|
||||
|
||||
backgroundOpacity: 0.6, //遮层透明度-数字0-1 可选
|
||||
|
||||
Border: 0, //截框的边框大小 0代表动态边框。大于0表示静态边框,大于0时也代表静态边框的粗细值
|
||||
|
||||
BorderStyle: "solid", //只作用于静态边框,截框的边框类型,其实是引入CSS的border属性,和CSS2的border属性是一样的
|
||||
|
||||
BorderColor: "#09F", //只作用于静态边框,截框的边框色彩
|
||||
/*---------------用户设置截图功能部份..还没结束----------------------页面下面还有一些细节设置,去看一下-------------------------------------------------*/
|
||||
relat: publicRelat, //请查看 id:"relat"对象
|
||||
scope: document.getElementById("main"), //main范围对象
|
||||
ImgDom: publicRelatImg[0], //截图图片对象(小)
|
||||
ImgMain: publicRelatImg[1], //截图图片对象(大)
|
||||
black: document.getElementById("black"), //黑色遮层对象
|
||||
form: document.getElementById("smallbox"), //截框对象
|
||||
ZoomDist: document.getElementById("ZoomDist"), //放大工具条,可从HTML查看此对象,不作详细解释了
|
||||
ZoomBar: document.getElementById("ZoomBar"), //放大工具条,可从HTML查看此对象
|
||||
to: {
|
||||
BottomRight: document.getElementById("BottomRight"), //拉伸点中右
|
||||
TopRight: document.getElementById("TopRight"), //拉伸点上右,下面如此类推,一共8点进行拉伸,下面不再作解释
|
||||
Bottomleft: document.getElementById("Bottomleft"),
|
||||
Topleft: document.getElementById("Topleft"),
|
||||
Topmiddle: document.getElementById("Topmiddle"),
|
||||
leftmiddle: document.getElementById("leftmiddle"),
|
||||
Rightmiddle: document.getElementById("Rightmiddle"),
|
||||
Bottommiddle: document.getElementById("Bottommiddle")
|
||||
},
|
||||
Effects: document.getElementById("shearphoto_Effects") || false,
|
||||
DynamicBorder: [document.getElementById("borderTop"), document.getElementById("borderLeft"), document.getElementById("borderRight"), document.getElementById("borderBottom")],
|
||||
SelectBox: document.getElementById("SelectBox"), //选择图片方式的对象
|
||||
Shearbar: document.getElementById("Shearbar"), //截图工具条对象
|
||||
UpFun: function() { //鼠标健松开时执行函数
|
||||
Shear.MoveDiv.DivWHFun(); //把截框现时的宽高告诉JS
|
||||
}
|
||||
|
||||
});
|
||||
/*--------------------------------------------------------------截图成功后,返回来的callback-------------------------*/
|
||||
Shear.complete = function(serverdata) { //截图成功完成时,由shearphoto.php返回数据过来的成功包
|
||||
// alert(serverdata);//你可以调试一下这个返回包
|
||||
var point = this.arg.scope.childNodes[0];
|
||||
point.className === "point" && this.arg.scope.removeChild(point);
|
||||
var complete = document.createElement("div");
|
||||
complete.className = "complete";
|
||||
complete.style.height = this.arg.scopeHeight + "px";
|
||||
this.arg.scope.insertBefore(complete, this.arg.scope.childNodes[0]);
|
||||
var length = serverdata.length,
|
||||
creatImg;
|
||||
for (var i = 0; i < length; i++) {
|
||||
creatImg = document.createElement("img");
|
||||
complete.appendChild(creatImg);
|
||||
creatImg.src = serverdata[i]["ImgUrl"];
|
||||
}
|
||||
this.HTML5.EffectsReturn();
|
||||
this.HTML5.BOLBID && this.HTML5.URL.revokeObjectURL(this.HTML5.BOLBID);
|
||||
creatImg = document.createElement("DIV");
|
||||
creatImg.className = "completeTxt";
|
||||
creatImg.innerHTML = '<strong><i></i>恭喜你!截图成功</strong> <p>以上是你图片的' + length + '种尺寸</p><a href="javascript:;" id="completeA">完成</a>';
|
||||
complete.appendChild(creatImg);
|
||||
var completeA = document.getElementById("completeA");
|
||||
var this_ = this;
|
||||
this_.preview.close_();
|
||||
completeA.onclick || (completeA.onclick = function() {
|
||||
completeA.onclick = null;
|
||||
this_.arg.scope.removeChild(complete);
|
||||
this_.again();
|
||||
this_.pointhandle(3e3, 10, "截图完成!已返回!", 2, "#fbeb61", "#3a414c");
|
||||
});
|
||||
}
|
||||
/*--------------------------------------------------------------截图成功后,返回来的callback-------------------------*/
|
||||
|
||||
/*.................................................选择图片上传的设置...............................................................*/
|
||||
|
||||
var ShearPhotoForm = document.getElementById("ShearPhotoForm"); //FORM对象
|
||||
ShearPhotoForm.UpFile.onclick = function() {
|
||||
return false
|
||||
} //一开始时先不让用户点免得事件阻塞
|
||||
var up = new ShearPhoto.frameUpImg({
|
||||
|
||||
url: "/user/upload/avatar", //HTML5切图时,不会用到该文件,后端处理地址,保证正确哦,这是常识,连这个地址都能写错,你就是菜B,已经在本版本中帮你加入相对路径,你基本不用改这里了
|
||||
|
||||
FORM: ShearPhotoForm, //FORM对象传到设置
|
||||
|
||||
UpType: new Array("jpg", "jpeg", "png", "gif"), //图片类限制,上传的一定是图片,你就不要更改了
|
||||
|
||||
FilesSize: 2, //选择的图片不能超过 单位M(注意:是非HTML5时哦)
|
||||
|
||||
HTML5: Shear.HTML5, //切匆改动这句,不然你他妈又问为什么出错
|
||||
|
||||
HTML5FilesSize: Shear.arg.HTML5FilesSize, //切匆改动这句 如果是HTML5切图时,选择的图片不能超过 单位M,设太大话,如果客户端HTML5加截超大图片时,会卡爆的
|
||||
|
||||
HTML5ZIP: Shear.arg.HTML5ZIP, //切匆改动这句, 把压缩设置转移到这里
|
||||
|
||||
erro: function(msg) {
|
||||
Shear.pointhandle(3e3, 10, msg, 0, "#f82373", "#fff");
|
||||
},
|
||||
fileClick: function() { //先择图片被点击时,触发的事件
|
||||
Shear.pointhandle(-1); //关闭提示,防止线程阻塞事件冒泡
|
||||
},
|
||||
preced: function(fun) { //点击选择图,载入图片时的事件
|
||||
// try {
|
||||
// photoalbum.style.display = "none"; //什么情况下都关了相册
|
||||
// camClose.onclick(); //什么情况下都关了视频
|
||||
// } catch (e) {
|
||||
// console.log("在加载图片时,发现相册或拍照的对象检测不到,错误代码:" + e);
|
||||
// }
|
||||
Shear.pointhandle(0, 10, "正在为你加载图片,请你稍等哦......", 2, "#307ff6", "#fff", fun);
|
||||
}
|
||||
});
|
||||
|
||||
up.run(function(data, True) { //upload.php成功返回数据后
|
||||
//alert(data);你可以调试一下这个返回包
|
||||
True || (data = ShearPhoto.JsonString.StringToJson(data));
|
||||
if (data === false) {
|
||||
Shear.SendUserMsg("错误:请保证后端环境运行正常", 5e3, 0, "#f4102b", "#fff", true, true);
|
||||
return;
|
||||
}
|
||||
if (data["erro"]) {
|
||||
Shear.SendUserMsg("错误:" + data["erro"], 5e3, 0, "#f4102b", "#fff", true, true);
|
||||
return;
|
||||
}
|
||||
Shear.run(data["success"], true);
|
||||
});
|
||||
/*.................................................选择图片上传的设置结束...............................................................*/
|
||||
|
||||
/*............................截图,左旋,右旋,重新选择..................开始.........看好怎么调用截图,左旋,右旋,重新选择..........................................*/
|
||||
Shear.addEvent(document.getElementById("saveShear"), "click", function() { //按下截图事件,提交到后端的shearphoto.php接收
|
||||
Shear.SendPHP({
|
||||
shearphoto: "我要传参数到服端",
|
||||
mingge: "我要传第二个参数到服务器"
|
||||
}); //我们示例截图并且传参数,后端文件shearphoto.php用 示例:$_POST["shearphoto"] 接收参数,不需要传参数请清空Shear.SendPHP里面的参数示例 Shear.SendPHP();
|
||||
|
||||
});
|
||||
|
||||
Shear.addEvent(document.getElementById("LeftRotate"), "click", function() { //向左旋转事件
|
||||
Shear.Rotate("left");
|
||||
});
|
||||
|
||||
Shear.addEvent(document.getElementById("RightRotate"), "click", function() { //向右旋转事件
|
||||
Shear.Rotate("right");
|
||||
});
|
||||
|
||||
Shear.addEvent(document.getElementById("againIMG"), "click", function() { //重新选择事件
|
||||
Shear.preview.close_();
|
||||
Shear.again();
|
||||
Shear.HTML5.EffectsReturn();
|
||||
Shear.HTML5.BOLBID && Shear.HTML5.URL.revokeObjectURL(Shear.HTML5.BOLBID);
|
||||
Shear.pointhandle(3e3, 10, "已取消!重新选择", 2, "#fbeb61", "#3a414c");
|
||||
});
|
||||
|
||||
/*............................截图,左旋,右旋,重新选择.................................................结束....................*/
|
||||
|
||||
/*...........2.2加入的缓冲效果............................*/
|
||||
var shearphoto_loading = document.getElementById("shearphoto_loading");
|
||||
var shearphoto_main = document.getElementById("shearphoto_main");
|
||||
shearphoto_loading && shearphoto_loading.parentNode.removeChild(shearphoto_loading);
|
||||
shearphoto_main.style.visibility = "visible";
|
||||
/*................2.2加入的缓冲效果结束..................*/
|
||||
});
|
||||
6
web/static/plugs/board/board.min.css
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* ZUI - v1.3.1 - 2015-05-19
|
||||
* http://zui.sexy
|
||||
* GitHub: https://github.com/easysoft/zui.git
|
||||
* Copyright (c) 2015 cnezsoft.com; Licensed MIT
|
||||
*/.board-item{padding:6px 10px;margin-bottom:5px;background:#fff;border:1px solid #ddd;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.05);box-shadow:0 1px 0 rgba(0,0,0,.05);-webkit-transition:all .5s cubic-bezier(.175,.885,.32,1);-o-transition:all .5s cubic-bezier(.175,.885,.32,1);transition:all .5s cubic-bezier(.175,.885,.32,1)}.board-item:hover{-webkit-box-shadow:0 1px 1 rgba(0,0,0,.1);box-shadow:0 1px 1 rgba(0,0,0,.1)}.board-item.board-item-empty{display:none;color:gray;border-style:dashed}.board-item.board-item-shadow{display:none;padding:0;background:#ddd;border:none;border-color:#ddd;-webkit-box-shadow:inset 0 0 4px rgba(0,0,0,.1);box-shadow:inset 0 0 4px rgba(0,0,0,.1);-webkit-transition:all .5s cubic-bezier(.175,.885,.32,1);-o-transition:all .5s cubic-bezier(.175,.885,.32,1);transition:all .5s cubic-bezier(.175,.885,.32,1)}.board-item.drag-shadow{width:250px;cursor:move;background-color:#fff;border-color:#c4c4c4;-webkit-box-shadow:1px 1px 15px rgba(0,0,0,.25);box-shadow:1px 1px 15px rgba(0,0,0,.25);opacity:.9}.board-item.drag-from{background-color:#ebf2f9}.board-list .board-item:last-child{margin-bottom:0}.board{float:left;width:250px;margin-right:10px}.board.drop-in-empty .board-item-empty{height:0;padding:0;margin:0;overflow:hidden;border:transparent}.board:last-child{margin-right:0}.board>.panel-body{padding:5px;background:#f1f1f1}.boards:before,.boards:after{display:table;content:" "}.boards:after{clear:both}.boards.dragging .board.drop-in{border-color:#c4c4c4;-webkit-box-shadow:1px 1px 15px rgba(0,0,0,.25);box-shadow:1px 1px 15px rgba(0,0,0,.25)}.boards.dragging .board.drop-in .board-item-shadow{display:block}.boards.dragging .board .board-item.board-item-empty{display:block}.boards.dragging .board-item.disable-drop{display:none}.boards.drop-in .board-item.drag-from{height:0;padding:0;margin:0;overflow:hidden;border:transparent}
|
||||
8
web/static/plugs/board/board.min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*!
|
||||
* ZUI - v1.3.1 - 2015-05-19
|
||||
* http://zui.sexy
|
||||
* GitHub: https://github.com/easysoft/zui.git
|
||||
* Copyright (c) 2015 cnezsoft.com; Licensed MIT
|
||||
*/
|
||||
|
||||
!function(a){"use strict";if(!a.fn.droppable)throw new Error("droppable requires for boards");var b=function(b,c){this.$=a(b),this.options=this.getOptions(c),this.getLang(),this.init()};b.DEFAULTS={lang:"zh-cn",langs:{"zh-cn":{append2end:"移动到末尾"},"zh-tw":{append2end:"移动到末尾"},en:{append2end:"Move to the end."}}},b.prototype.getOptions=function(c){return c=a.extend({},b.DEFAULTS,this.$.data(),c)},b.prototype.getLang=function(){var c=window.config;if(!this.options.lang){if("undefined"!=typeof c&&c.clientLang)this.options.lang=c.clientLang;else{var d=a("html").attr("lang");this.options.lang=d?d:"en"}this.options.lang=this.options.lang.replace(/-/,"_").toLowerCase()}this.lang=this.options.langs[this.options.lang]||this.options.langs[b.DEFAULTS.lang]},b.prototype.init=function(){var b=1,c=this.lang;this.$.find('.board-item:not(".disable-drop"), .board:not(".disable-drop")').each(function(){var d=a(this);d.attr("id")?d.attr("data-id",d.attr("id")):d.attr("data-id")||d.attr("data-id","board"+b++),d.hasClass("board")&&d.find(".board-list").append('<div class="board-item board-item-empty"><i class="icon-plus"></i> {append2end}</div>'.format(c)).append('<div class="board-item board-item-shadow"></div>'.format(c))}),this.bind()},b.prototype.bind=function(b){var c=this.$,d=this.options;"undefined"==typeof b&&(b=c.find('.board-item:not(".disable-drop, .board-item-shadow")')),b.droppable({target:'.board-item:not(".disable-drop, .board-item-shadow")',flex:!0,start:function(a){c.addClass("dragging").find(".board-item-shadow").height(a.element.outerHeight())},drag:function(a){if(c.find(".board.drop-in-empty").removeClass("drop-in-empty"),a.isIn){var b=a.target.closest(".board").addClass("drop-in"),d=b.find(".board-item-shadow"),e=a.target;c.addClass("drop-in").find(".board.drop-in").not(b).removeClass("drop-in"),d.insertBefore(e),b.toggleClass("drop-in-empty",e.hasClass("board-item-empty"))}},drop:function(b){if(b.isNew){var c,e="drop";d.hasOwnProperty(e)&&a.isFunction(d[e])&&(c=d[e](b)),c!==!1&&b.element.insertBefore(b.target)}},finish:function(){c.removeClass("dragging").removeClass("drop-in").find(".board.drop-in").removeClass("drop-in")}})},a.fn.boards=function(c){return this.each(function(){var d=a(this),e=d.data("zui.boards"),f="object"==typeof c&&c;e||d.data("zui.boards",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.boards.Constructor=b,a(function(){a('[data-toggle="boards"]').boards()})}(jQuery);
|
||||
379
web/static/plugs/cropper/cropper.css
Normal file
@@ -0,0 +1,379 @@
|
||||
/*!
|
||||
* Cropper.js v0.5.6
|
||||
* https://github.com/fengyuanchen/cropperjs
|
||||
*
|
||||
* Copyright (c) 2015-2016 Fengyuan Chen
|
||||
* Released under the MIT license
|
||||
*
|
||||
* Date: 2016-01-18T05:33:19.322Z
|
||||
*/
|
||||
.cropper-container {
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
|
||||
position: relative;
|
||||
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
|
||||
direction: ltr !important;
|
||||
-ms-touch-action: none;
|
||||
touch-action: none;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
-webkit-touch-callout: none;
|
||||
}
|
||||
|
||||
.cropper-container img {
|
||||
display: block;
|
||||
|
||||
width: 100%;
|
||||
min-width: 0 !important;
|
||||
max-width: none !important;
|
||||
height: 100%;
|
||||
min-height: 0 !important;
|
||||
max-height: none !important;
|
||||
|
||||
image-orientation: 0deg !important;
|
||||
}
|
||||
|
||||
.cropper-wrap-box,
|
||||
.cropper-canvas,
|
||||
.cropper-drag-box,
|
||||
.cropper-crop-box,
|
||||
.cropper-modal {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.cropper-wrap-box {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.cropper-drag-box {
|
||||
opacity: 0;
|
||||
background-color: #fff;
|
||||
|
||||
filter: alpha(opacity=0);
|
||||
}
|
||||
|
||||
.cropper-modal {
|
||||
opacity: .5;
|
||||
background-color: #000;
|
||||
|
||||
filter: alpha(opacity=50);
|
||||
}
|
||||
|
||||
.cropper-view-box {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
outline: 1px solid #39f;
|
||||
outline-color: rgba(51, 153, 255, .75);
|
||||
}
|
||||
|
||||
.cropper-dashed {
|
||||
position: absolute;
|
||||
|
||||
display: block;
|
||||
|
||||
opacity: .5;
|
||||
border: 0 dashed #eee;
|
||||
|
||||
filter: alpha(opacity=50);
|
||||
}
|
||||
|
||||
.cropper-dashed.dashed-h {
|
||||
top: 33.33333%;
|
||||
left: 0;
|
||||
|
||||
width: 100%;
|
||||
height: 33.33333%;
|
||||
|
||||
border-top-width: 1px;
|
||||
border-bottom-width: 1px;
|
||||
}
|
||||
|
||||
.cropper-dashed.dashed-v {
|
||||
top: 0;
|
||||
left: 33.33333%;
|
||||
|
||||
width: 33.33333%;
|
||||
height: 100%;
|
||||
|
||||
border-right-width: 1px;
|
||||
border-left-width: 1px;
|
||||
}
|
||||
|
||||
.cropper-center {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
|
||||
display: block;
|
||||
|
||||
width: 0;
|
||||
height: 0;
|
||||
|
||||
opacity: .75;
|
||||
|
||||
filter: alpha(opacity=75);
|
||||
}
|
||||
|
||||
.cropper-center:before,
|
||||
.cropper-center:after {
|
||||
position: absolute;
|
||||
|
||||
display: block;
|
||||
|
||||
content: ' ';
|
||||
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.cropper-center:before {
|
||||
top: 0;
|
||||
left: -3px;
|
||||
|
||||
width: 7px;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
.cropper-center:after {
|
||||
top: -3px;
|
||||
left: 0;
|
||||
|
||||
width: 1px;
|
||||
height: 7px;
|
||||
}
|
||||
|
||||
.cropper-face,
|
||||
.cropper-line,
|
||||
.cropper-point {
|
||||
position: absolute;
|
||||
|
||||
display: block;
|
||||
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
opacity: .1;
|
||||
|
||||
filter: alpha(opacity=10);
|
||||
}
|
||||
|
||||
.cropper-face {
|
||||
top: 0;
|
||||
left: 0;
|
||||
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.cropper-line {
|
||||
background-color: #39f;
|
||||
}
|
||||
|
||||
.cropper-line.line-e {
|
||||
top: 0;
|
||||
right: -3px;
|
||||
|
||||
width: 5px;
|
||||
|
||||
cursor: e-resize;
|
||||
}
|
||||
|
||||
.cropper-line.line-n {
|
||||
top: -3px;
|
||||
left: 0;
|
||||
|
||||
height: 5px;
|
||||
|
||||
cursor: n-resize;
|
||||
}
|
||||
|
||||
.cropper-line.line-w {
|
||||
top: 0;
|
||||
left: -3px;
|
||||
|
||||
width: 5px;
|
||||
|
||||
cursor: w-resize;
|
||||
}
|
||||
|
||||
.cropper-line.line-s {
|
||||
bottom: -3px;
|
||||
left: 0;
|
||||
|
||||
height: 5px;
|
||||
|
||||
cursor: s-resize;
|
||||
}
|
||||
|
||||
.cropper-point {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
|
||||
opacity: .75;
|
||||
background-color: #39f;
|
||||
|
||||
filter: alpha(opacity=75);
|
||||
}
|
||||
|
||||
.cropper-point.point-e {
|
||||
top: 50%;
|
||||
right: -3px;
|
||||
|
||||
margin-top: -3px;
|
||||
|
||||
cursor: e-resize;
|
||||
}
|
||||
|
||||
.cropper-point.point-n {
|
||||
top: -3px;
|
||||
left: 50%;
|
||||
|
||||
margin-left: -3px;
|
||||
|
||||
cursor: n-resize;
|
||||
}
|
||||
|
||||
.cropper-point.point-w {
|
||||
top: 50%;
|
||||
left: -3px;
|
||||
|
||||
margin-top: -3px;
|
||||
|
||||
cursor: w-resize;
|
||||
}
|
||||
|
||||
.cropper-point.point-s {
|
||||
bottom: -3px;
|
||||
left: 50%;
|
||||
|
||||
margin-left: -3px;
|
||||
|
||||
cursor: s-resize;
|
||||
}
|
||||
|
||||
.cropper-point.point-ne {
|
||||
top: -3px;
|
||||
right: -3px;
|
||||
|
||||
cursor: ne-resize;
|
||||
}
|
||||
|
||||
.cropper-point.point-nw {
|
||||
top: -3px;
|
||||
left: -3px;
|
||||
|
||||
cursor: nw-resize;
|
||||
}
|
||||
|
||||
.cropper-point.point-sw {
|
||||
bottom: -3px;
|
||||
left: -3px;
|
||||
|
||||
cursor: sw-resize;
|
||||
}
|
||||
|
||||
.cropper-point.point-se {
|
||||
right: -3px;
|
||||
bottom: -3px;
|
||||
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
|
||||
cursor: se-resize;
|
||||
|
||||
opacity: 1;
|
||||
|
||||
filter: alpha(opacity=100);
|
||||
}
|
||||
|
||||
.cropper-point.point-se:before {
|
||||
position: absolute;
|
||||
right: -50%;
|
||||
bottom: -50%;
|
||||
|
||||
display: block;
|
||||
|
||||
width: 200%;
|
||||
height: 200%;
|
||||
|
||||
content: ' ';
|
||||
|
||||
opacity: 0;
|
||||
background-color: #39f;
|
||||
|
||||
filter: alpha(opacity=0);
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.cropper-point.point-se {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.cropper-point.point-se {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
.cropper-point.point-se {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
|
||||
opacity: .75;
|
||||
|
||||
filter: alpha(opacity=75);
|
||||
}
|
||||
}
|
||||
|
||||
.cropper-invisible {
|
||||
opacity: 0;
|
||||
|
||||
filter: alpha(opacity=0);
|
||||
}
|
||||
|
||||
.cropper-bg {
|
||||
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC');
|
||||
}
|
||||
|
||||
.cropper-hide {
|
||||
position: absolute;
|
||||
|
||||
display: block;
|
||||
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.cropper-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.cropper-move {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.cropper-crop {
|
||||
cursor: crosshair;
|
||||
}
|
||||
|
||||
.cropper-disabled .cropper-drag-box,
|
||||
.cropper-disabled .cropper-face,
|
||||
.cropper-disabled .cropper-line,
|
||||
.cropper-disabled .cropper-point {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
149
web/static/plugs/cropper/cropper.custom.js
Normal file
@@ -0,0 +1,149 @@
|
||||
window.onload = function() {
|
||||
'use strict';
|
||||
var Cropper = window.Cropper;
|
||||
var console = window.console || {
|
||||
log: function() {}
|
||||
};
|
||||
var container = document.querySelector('.img-container');
|
||||
var image = container.getElementsByTagName('img').item(0);
|
||||
var actions = document.getElementById('actions');
|
||||
var options = {
|
||||
aspectRatio: 1 / 1,
|
||||
preview: '.img-preview',
|
||||
build: function() {
|
||||
//console.log('build');
|
||||
},
|
||||
built: function() {
|
||||
//console.log('built');
|
||||
},
|
||||
cropstart: function(data) {
|
||||
//console.log('cropstart', data.action);
|
||||
},
|
||||
cropmove: function(data) {
|
||||
//console.log('cropmove', data.action);
|
||||
},
|
||||
cropend: function(data) {
|
||||
//console.log('cropend', data.action);
|
||||
},
|
||||
crop: function(data) {},
|
||||
zoom: function(data) {
|
||||
console.log('zoom', data.ratio);
|
||||
}
|
||||
};
|
||||
var cropper = new Cropper(image, options);
|
||||
|
||||
function isUndefined(obj) {
|
||||
return typeof obj === 'undefined';
|
||||
}
|
||||
|
||||
function preventDefault(e) {
|
||||
if (e) {
|
||||
if (e.preventDefault) {
|
||||
e.preventDefault();
|
||||
} else {
|
||||
e.returnValue = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Tooltip
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
// Buttons
|
||||
if (!document.createElement('canvas').getContext) {
|
||||
$('button[data-method="getCroppedCanvas"]').prop('disabled', true);
|
||||
}
|
||||
if (typeof document.createElement('cropper').style.transition === 'undefined') {
|
||||
$('button[data-method="rotate"]').prop('disabled', true);
|
||||
$('button[data-method="scale"]').prop('disabled', true);
|
||||
}
|
||||
|
||||
// Methods
|
||||
actions.querySelector('.docs-buttons').onclick = function(event) {
|
||||
var e = event || window.event;
|
||||
var target = e.target || e.srcElement;
|
||||
var result;
|
||||
var input;
|
||||
var data;
|
||||
if (!cropper) {
|
||||
return;
|
||||
}
|
||||
while (target !== this) {
|
||||
if (target.getAttribute('data-method')) {
|
||||
break;
|
||||
}
|
||||
target = target.parentNode;
|
||||
}
|
||||
if (target === this || target.disabled || target.className.indexOf('disabled') > -1) {
|
||||
return;
|
||||
}
|
||||
data = {
|
||||
method: target.getAttribute('data-method'),
|
||||
target: target.getAttribute('data-target'),
|
||||
option: target.getAttribute('data-option'),
|
||||
secondOption: target.getAttribute('data-second-option')
|
||||
};
|
||||
if (data.method) {
|
||||
if (typeof data.target !== 'undefined') {
|
||||
input = document.querySelector(data.target);
|
||||
if (!target.hasAttribute('data-option') && data.target && input) {
|
||||
try {
|
||||
data.option = JSON.parse(input.value);
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data.method === 'getCroppedCanvas') {
|
||||
data.option = JSON.parse(data.option);
|
||||
}
|
||||
result = cropper[data.method](data.option, data.secondOption);
|
||||
switch (data.method) {
|
||||
case 'scaleX':
|
||||
case 'scaleY':
|
||||
target.setAttribute('data-option', -data.option);
|
||||
break;
|
||||
case 'getCroppedCanvas':
|
||||
if (result) {
|
||||
// Bootstrap's Modal
|
||||
$('#getCroppedCanvasModal').modal().find('.modal-body').html(result);
|
||||
if (!download.disabled) {
|
||||
download.href = result.toDataURL();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'destroy':
|
||||
cropper = null;
|
||||
break;
|
||||
}
|
||||
if (typeof result === 'object' && result !== cropper && input) {
|
||||
try {
|
||||
input.value = JSON.stringify(result);
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
// Import image
|
||||
var inputImage = document.getElementById('inputImage');
|
||||
var URL = window.URL || window.webkitURL;
|
||||
var blobURL;
|
||||
if (URL) {
|
||||
inputImage.onchange = function() {
|
||||
var files = this.files;
|
||||
var file;
|
||||
if (cropper && files && files.length) {
|
||||
file = files[0];
|
||||
if (/^image\/\w+/.test(file.type)) {
|
||||
blobURL = URL.createObjectURL(file);
|
||||
cropper.reset().replace(blobURL);
|
||||
inputImage.value = null;
|
||||
} else {
|
||||
window.alert('Please choose an image file.');
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
inputImage.disabled = true;
|
||||
inputImage.parentNode.className += ' disabled';
|
||||
}
|
||||
};
|
||||
3417
web/static/plugs/cropper/cropper.js
Normal file
9
web/static/plugs/cropper/cropper.min.css
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* Cropper.js v0.5.6
|
||||
* https://github.com/fengyuanchen/cropperjs
|
||||
*
|
||||
* Copyright (c) 2015-2016 Fengyuan Chen
|
||||
* Released under the MIT license
|
||||
*
|
||||
* Date: 2016-01-18T05:33:19.322Z
|
||||
*/.cropper-container{font-size:0;line-height:0;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;direction:ltr!important;-ms-touch-action:none;touch-action:none;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none}.cropper-container img{display:block;width:100%;min-width:0!important;max-width:none!important;height:100%;min-height:0!important;max-height:none!important;image-orientation:0deg!important}.cropper-canvas,.cropper-crop-box,.cropper-drag-box,.cropper-modal,.cropper-wrap-box{position:absolute;top:0;right:0;bottom:0;left:0}.cropper-wrap-box{overflow:hidden}.cropper-drag-box{opacity:0;background-color:#fff;filter:alpha(opacity=0)}.cropper-dashed,.cropper-modal{opacity:.5;filter:alpha(opacity=50)}.cropper-modal{background-color:#000}.cropper-view-box{display:block;overflow:hidden;width:100%;height:100%;outline:#39f solid 1px;outline-color:rgba(51,153,255,.75)}.cropper-dashed{position:absolute;display:block;border:0 dashed #eee}.cropper-dashed.dashed-h{top:33.33333%;left:0;width:100%;height:33.33333%;border-top-width:1px;border-bottom-width:1px}.cropper-dashed.dashed-v{top:0;left:33.33333%;width:33.33333%;height:100%;border-right-width:1px;border-left-width:1px}.cropper-center{position:absolute;top:50%;left:50%;display:block;width:0;height:0;opacity:.75;filter:alpha(opacity=75)}.cropper-center:after,.cropper-center:before{position:absolute;display:block;content:' ';background-color:#eee}.cropper-center:before{top:0;left:-3px;width:7px;height:1px}.cropper-center:after{top:-3px;left:0;width:1px;height:7px}.cropper-face,.cropper-line,.cropper-point{position:absolute;display:block;width:100%;height:100%;opacity:.1;filter:alpha(opacity=10)}.cropper-face{top:0;left:0;background-color:#fff}.cropper-line,.cropper-point{background-color:#39f}.cropper-line.line-e{top:0;right:-3px;width:5px;cursor:e-resize}.cropper-line.line-n{top:-3px;left:0;height:5px;cursor:n-resize}.cropper-line.line-w{top:0;left:-3px;width:5px;cursor:w-resize}.cropper-line.line-s{bottom:-3px;left:0;height:5px;cursor:s-resize}.cropper-point{width:5px;height:5px;opacity:.75;filter:alpha(opacity=75)}.cropper-point.point-e{top:50%;right:-3px;margin-top:-3px;cursor:e-resize}.cropper-point.point-n{top:-3px;left:50%;margin-left:-3px;cursor:n-resize}.cropper-point.point-w{top:50%;left:-3px;margin-top:-3px;cursor:w-resize}.cropper-point.point-s{bottom:-3px;left:50%;margin-left:-3px;cursor:s-resize}.cropper-point.point-ne{top:-3px;right:-3px;cursor:ne-resize}.cropper-point.point-nw{top:-3px;left:-3px;cursor:nw-resize}.cropper-point.point-sw{bottom:-3px;left:-3px;cursor:sw-resize}.cropper-point.point-se{right:-3px;bottom:-3px;width:20px;height:20px;cursor:se-resize;opacity:1;filter:alpha(opacity=100)}.cropper-point.point-se:before{position:absolute;right:-50%;bottom:-50%;display:block;width:200%;height:200%;content:' ';opacity:0;background-color:#39f;filter:alpha(opacity=0)}@media (min-width:768px){.cropper-point.point-se{width:15px;height:15px}}@media (min-width:992px){.cropper-point.point-se{width:10px;height:10px}}@media (min-width:1200px){.cropper-point.point-se{width:5px;height:5px;opacity:.75;filter:alpha(opacity=75)}}.cropper-invisible{opacity:0;filter:alpha(opacity=0)}.cropper-bg{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC)}.cropper-hide{position:absolute;display:block;width:0;height:0}.cropper-hidden{display:none!important}.cropper-move{cursor:move}.cropper-crop{cursor:crosshair}.cropper-disabled .cropper-drag-box,.cropper-disabled .cropper-face,.cropper-disabled .cropper-line,.cropper-disabled .cropper-point{cursor:not-allowed}
|
||||
10
web/static/plugs/cropper/cropper.min.js
vendored
Normal file
1
web/static/plugs/datepicker/css/foundation-datepicker.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.datepicker{display:none;position:absolute;padding:4px;margin-top:1px;direction:ltr}.datepicker.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;float:left;display:none;min-width:160px;list-style:none;background-color:#fff;border:1px solid rgba(0,0,0,.2);-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;color:#333;font-size:13px;line-height:18px}.datepicker.dropdown-menu td,.datepicker.dropdown-menu th{padding:4px 5px}.datepicker table{border:0;margin:0;width:auto}.datepicker table tr td span{display:block;width:23%;height:54px;line-height:54px;float:left;margin:1%;cursor:pointer}.datepicker td,.datepicker th{text-align:center;width:20px;height:20px;border:0;font-size:12px;padding:4px 8px;cursor:pointer}.datepicker td{background:#fff}.datepicker td span.active,.datepicker td.active.day,.datepicker td.active.year{background:#2ba6cb}.datepicker td.new,.datepicker td.old{color:#999}.datepicker td.day.disabled{color:#eee}.datepicker th{background:#fff}.datepicker th span.active,.datepicker th.active.day,.datepicker th.active.year{background:#2ba6cb}.datepicker th.date-switch{width:145px}.datepicker .cw{font-size:10px;width:12px;padding:0 2px 0 5px;vertical-align:middle}.datepicker.days div.datepicker-days,.datepicker.months div.datepicker-months,.datepicker.years div.datepicker-years{display:block}.datepicker-dropdown:after,.datepicker-dropdown:before{content:'';display:inline-block;position:absolute}.datepicker thead tr:first-child th{cursor:pointer}.datepicker thead tr:first-child th.cw{cursor:default;background-color:transparent}.datepicker tfoot tr:first-child th{cursor:pointer}.datepicker-inline{width:220px}.datepicker-rtl{direction:rtl}.datepicker-rtl table tr td span{float:right}.datepicker-dropdown{top:0;left:0}.datepicker-dropdown:before{border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-bottom-color:1px solid rgba(0,0,0,.2);top:-7px;left:6px}.datepicker-dropdown:after{border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #fff;top:-6px;left:7px}.datepicker-dropdown::after,.datepicker-dropdown::before,.datepicker>div{display:none}.datepicker-close{position:absolute;top:-30px;right:0;width:15px;height:30px;padding:0;display:none}.table-striped .datepicker table tr td,.table-striped .datepicker table tr th{background-color:transparent}
|
||||
1325
web/static/plugs/datepicker/js/foundation-datepicker.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Simplified Chinese translation for foundation-datepicker
|
||||
* Yuan Cheung <advanimal@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.fdatepicker.dates['zh-CN'] = {
|
||||
days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
|
||||
daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
|
||||
daysMin: ["日", "一", "二", "三", "四", "五", "六"],
|
||||
months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
|
||||
monthsShort: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"],
|
||||
today: '今天'
|
||||
};
|
||||
}(jQuery));
|
||||
39
web/static/plugs/flot/jquery.flot.axislabels.js
Normal file
@@ -0,0 +1,39 @@
|
||||
(function($){var options={axisLabels:{show:true}};function canvasSupported(){return!!document.createElement('canvas').getContext;}
|
||||
function canvasTextSupported(){if(!canvasSupported()){return false;}
|
||||
var dummy_canvas=document.createElement('canvas');var context=dummy_canvas.getContext('2d');return typeof context.fillText=='function';}
|
||||
function css3TransitionSupported(){var div=document.createElement('div');return typeof div.style.MozTransition!='undefined'||typeof div.style.OTransition!='undefined'||typeof div.style.webkitTransition!='undefined'||typeof div.style.transition!='undefined';}
|
||||
function AxisLabel(axisName,position,padding,plot,opts){this.axisName=axisName;this.position=position;this.padding=padding;this.plot=plot;this.opts=opts;this.width=0;this.height=0;}
|
||||
AxisLabel.prototype.cleanup=function(){};CanvasAxisLabel.prototype=new AxisLabel();CanvasAxisLabel.prototype.constructor=CanvasAxisLabel;function CanvasAxisLabel(axisName,position,padding,plot,opts){AxisLabel.prototype.constructor.call(this,axisName,position,padding,plot,opts);}
|
||||
CanvasAxisLabel.prototype.calculateSize=function(){if(!this.opts.axisLabelFontSizePixels)
|
||||
this.opts.axisLabelFontSizePixels=14;if(!this.opts.axisLabelFontFamily)
|
||||
this.opts.axisLabelFontFamily='sans-serif';var textWidth=this.opts.axisLabelFontSizePixels+ this.padding;var textHeight=this.opts.axisLabelFontSizePixels+ this.padding;if(this.position=='left'||this.position=='right'){this.width=this.opts.axisLabelFontSizePixels+ this.padding;this.height=0;}else{this.width=0;this.height=this.opts.axisLabelFontSizePixels+ this.padding;}};CanvasAxisLabel.prototype.draw=function(box){if(!this.opts.axisLabelColour)
|
||||
this.opts.axisLabelColour='black';var ctx=this.plot.getCanvas().getContext('2d');ctx.save();ctx.font=this.opts.axisLabelFontSizePixels+'px '+
|
||||
this.opts.axisLabelFontFamily;ctx.fillStyle=this.opts.axisLabelColour;var width=ctx.measureText(this.opts.axisLabel).width;var height=this.opts.axisLabelFontSizePixels;var x,y,angle=0;if(this.position=='top'){x=box.left+ box.width/2- width/2;y=box.top+ height*0.72;}else if(this.position=='bottom'){x=box.left+ box.width/2- width/2;y=box.top+ box.height- height*0.72;}else if(this.position=='left'){x=box.left+ height*0.72;y=box.height/2+ box.top+ width/2;angle=-Math.PI/2;}else if(this.position=='right'){x=box.left+ box.width- height*0.72;y=box.height/2+ box.top- width/2;angle=Math.PI/2;}
|
||||
ctx.translate(x,y);ctx.rotate(angle);ctx.fillText(this.opts.axisLabel,0,0);ctx.restore();};HtmlAxisLabel.prototype=new AxisLabel();HtmlAxisLabel.prototype.constructor=HtmlAxisLabel;function HtmlAxisLabel(axisName,position,padding,plot,opts){AxisLabel.prototype.constructor.call(this,axisName,position,padding,plot,opts);this.elem=null;}
|
||||
HtmlAxisLabel.prototype.calculateSize=function(){var elem=$('<div class="axisLabels" style="position:absolute;">'+
|
||||
this.opts.axisLabel+'</div>');this.plot.getPlaceholder().append(elem);this.labelWidth=elem.outerWidth(true);this.labelHeight=elem.outerHeight(true);elem.remove();this.width=this.height=0;if(this.position=='left'||this.position=='right'){this.width=this.labelWidth+ this.padding;}else{this.height=this.labelHeight+ this.padding;}};HtmlAxisLabel.prototype.cleanup=function(){if(this.elem){this.elem.remove();}};HtmlAxisLabel.prototype.draw=function(box){this.plot.getPlaceholder().find('#'+ this.axisName+'Label').remove();this.elem=$('<div id="'+ this.axisName+'Label" " class="axisLabels" style="position:absolute;">'
|
||||
+ this.opts.axisLabel+'</div>');this.plot.getPlaceholder().append(this.elem);if(this.position=='top'){this.elem.css('left',box.left+ box.width/2- this.labelWidth/2+'px');this.elem.css('top',box.top+'px');}else if(this.position=='bottom'){this.elem.css('left',box.left+ box.width/2- this.labelWidth/2+'px');this.elem.css('top',box.top+ box.height- this.labelHeight+'px');}else if(this.position=='left'){this.elem.css('top',box.top+ box.height/2- this.labelHeight/2+'px');this.elem.css('left',box.left+'px');}else if(this.position=='right'){this.elem.css('top',box.top+ box.height/2- this.labelHeight/2+'px');this.elem.css('left',box.left+ box.width- this.labelWidth+'px');}};CssTransformAxisLabel.prototype=new HtmlAxisLabel();CssTransformAxisLabel.prototype.constructor=CssTransformAxisLabel;function CssTransformAxisLabel(axisName,position,padding,plot,opts){HtmlAxisLabel.prototype.constructor.call(this,axisName,position,padding,plot,opts);}
|
||||
CssTransformAxisLabel.prototype.calculateSize=function(){HtmlAxisLabel.prototype.calculateSize.call(this);this.width=this.height=0;if(this.position=='left'||this.position=='right'){this.width=this.labelHeight+ this.padding;}else{this.height=this.labelHeight+ this.padding;}};CssTransformAxisLabel.prototype.transforms=function(degrees,x,y){var stransforms={'-moz-transform':'','-webkit-transform':'','-o-transform':'','-ms-transform':''};if(x!=0||y!=0){var stdTranslate=' translate('+ x+'px, '+ y+'px)';stransforms['-moz-transform']+=stdTranslate;stransforms['-webkit-transform']+=stdTranslate;stransforms['-o-transform']+=stdTranslate;stransforms['-ms-transform']+=stdTranslate;}
|
||||
if(degrees!=0){var rotation=degrees/90;var stdRotate=' rotate('+ degrees+'deg)';stransforms['-moz-transform']+=stdRotate;stransforms['-webkit-transform']+=stdRotate;stransforms['-o-transform']+=stdRotate;stransforms['-ms-transform']+=stdRotate;}
|
||||
var s='top: 0; left: 0; ';for(var prop in stransforms){if(stransforms[prop]){s+=prop+':'+ stransforms[prop]+';';}}
|
||||
s+=';';return s;};CssTransformAxisLabel.prototype.calculateOffsets=function(box){var offsets={x:0,y:0,degrees:0};if(this.position=='bottom'){offsets.x=box.left+ box.width/2- this.labelWidth/2;offsets.y=box.top+ box.height- this.labelHeight;}else if(this.position=='top'){offsets.x=box.left+ box.width/2- this.labelWidth/2;offsets.y=box.top;}else if(this.position=='left'){offsets.degrees=-90;offsets.x=box.left- this.labelWidth/2+ this.labelHeight/2;offsets.y=box.height/2+ box.top;}else if(this.position=='right'){offsets.degrees=90;offsets.x=box.left+ box.width- this.labelWidth/2
|
||||
- this.labelHeight/2;offsets.y=box.height/2+ box.top;}
|
||||
return offsets;};CssTransformAxisLabel.prototype.draw=function(box){this.plot.getPlaceholder().find("."+ this.axisName+"Label").remove();var offsets=this.calculateOffsets(box);this.elem=$('<div class="axisLabels '+ this.axisName+'Label" style="position:absolute; '+
|
||||
this.transforms(offsets.degrees,offsets.x,offsets.y)+'">'+ this.opts.axisLabel+'</div>');this.plot.getPlaceholder().append(this.elem);};IeTransformAxisLabel.prototype=new CssTransformAxisLabel();IeTransformAxisLabel.prototype.constructor=IeTransformAxisLabel;function IeTransformAxisLabel(axisName,position,padding,plot,opts){CssTransformAxisLabel.prototype.constructor.call(this,axisName,position,padding,plot,opts);this.requiresResize=false;}
|
||||
IeTransformAxisLabel.prototype.transforms=function(degrees,x,y){var s='';if(degrees!=0){var rotation=degrees/90;while(rotation<0){rotation+=4;}
|
||||
s+=' filter: progid:DXImageTransform.Microsoft.BasicImage(rotation='+ rotation+'); ';this.requiresResize=(this.position=='right');}
|
||||
if(x!=0){s+='left: '+ x+'px; ';}
|
||||
if(y!=0){s+='top: '+ y+'px; ';}
|
||||
return s;};IeTransformAxisLabel.prototype.calculateOffsets=function(box){var offsets=CssTransformAxisLabel.prototype.calculateOffsets.call(this,box);if(this.position=='top'){offsets.y=box.top+ 1;}else if(this.position=='left'){offsets.x=box.left;offsets.y=box.height/2+ box.top- this.labelWidth/2;}else if(this.position=='right'){offsets.x=box.left+ box.width- this.labelHeight;offsets.y=box.height/2+ box.top- this.labelWidth/2;}
|
||||
return offsets;};IeTransformAxisLabel.prototype.draw=function(box){CssTransformAxisLabel.prototype.draw.call(this,box);if(this.requiresResize){this.elem=this.plot.getPlaceholder().find("."+ this.axisName+"Label");this.elem.css('width',this.labelWidth);this.elem.css('height',this.labelHeight);}};function init(plot){plot.hooks.processOptions.push(function(plot,options){if(!options.axisLabels.show)
|
||||
return;var secondPass=false;var axisLabels={};var axisOffsetCounts={left:0,right:0,top:0,bottom:0};var defaultPadding=2;plot.hooks.draw.push(function(plot,ctx){var hasAxisLabels=false;if(!secondPass){$.each(plot.getAxes(),function(axisName,axis){var opts=axis.options||plot.getOptions()[axisName];if(axisName in axisLabels){axis.labelHeight=axis.labelHeight-
|
||||
axisLabels[axisName].height;axis.labelWidth=axis.labelWidth-
|
||||
axisLabels[axisName].width;opts.labelHeight=axis.labelHeight;opts.labelWidth=axis.labelWidth;axisLabels[axisName].cleanup();delete axisLabels[axisName];}
|
||||
if(!opts||!opts.axisLabel||!axis.show)
|
||||
return;hasAxisLabels=true;var renderer=null;if(!opts.axisLabelUseHtml&&navigator.appName=='Microsoft Internet Explorer'){var ua=navigator.userAgent;var re=new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");if(re.exec(ua)!=null){rv=parseFloat(RegExp.$1);}
|
||||
if(rv>=9&&!opts.axisLabelUseCanvas&&!opts.axisLabelUseHtml){renderer=CssTransformAxisLabel;}else if(!opts.axisLabelUseCanvas&&!opts.axisLabelUseHtml){renderer=IeTransformAxisLabel;}else if(opts.axisLabelUseCanvas){renderer=CanvasAxisLabel;}else{renderer=HtmlAxisLabel;}}else{if(opts.axisLabelUseHtml||(!css3TransitionSupported()&&!canvasTextSupported())&&!opts.axisLabelUseCanvas){renderer=HtmlAxisLabel;}else if(opts.axisLabelUseCanvas||!css3TransitionSupported()){renderer=CanvasAxisLabel;}else{renderer=CssTransformAxisLabel;}}
|
||||
var padding=opts.axisLabelPadding===undefined?defaultPadding:opts.axisLabelPadding;axisLabels[axisName]=new renderer(axisName,axis.position,padding,plot,opts);axisLabels[axisName].calculateSize();opts.labelHeight=axis.labelHeight+
|
||||
axisLabels[axisName].height;opts.labelWidth=axis.labelWidth+
|
||||
axisLabels[axisName].width;});if(hasAxisLabels){secondPass=true;plot.setupGrid();plot.draw();}}else{secondPass=false;$.each(plot.getAxes(),function(axisName,axis){var opts=axis.options||plot.getOptions()[axisName];if(!opts||!opts.axisLabel||!axis.show)
|
||||
return;axisLabels[axisName].draw(axis.box);});}});});}
|
||||
$.plot.plugins.push({init:init,options:options,name:'axisLabels',version:'2.0'});})(jQuery);
|
||||
427
web/static/plugs/flot/jquery.flot.js
Normal file
@@ -0,0 +1,427 @@
|
||||
(function(B){B.color={};B.color.make=function(F,E,C,D){var G={};G.r=F||0;G.g=E||0;G.b=C||0;G.a=D!=null?D:1;G.add=function(J,I){for(var H=0;H<J.length;++H){G[J.charAt(H)]+=I}return G.normalize()};G.scale=function(J,I){for(var H=0;H<J.length;++H){G[J.charAt(H)]*=I}return G.normalize()};G.toString=function(){if(G.a>=1){return"rgb("+[G.r,G.g,G.b].join(",")+")"}else{return"rgba("+[G.r,G.g,G.b,G.a].join(",")+")"}};G.normalize=function(){function H(J,K,I){return K<J?J:(K>I?I:K)}G.r=H(0,parseInt(G.r),255);G.g=H(0,parseInt(G.g),255);G.b=H(0,parseInt(G.b),255);G.a=H(0,G.a,1);return G};G.clone=function(){return B.color.make(G.r,G.b,G.g,G.a)};return G.normalize()};B.color.extract=function(D,C){var E;do{E=D.css(C).toLowerCase();if(E!=""&&E!="transparent"){break}D=D.parent()}while(!B.nodeName(D.get(0),"body"));if(E=="rgba(0, 0, 0, 0)"){E="transparent"}return B.color.parse(E)};B.color.parse=function(F){var E,C=B.color.make;if(E=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10))}if(E=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10),parseFloat(E[4]))}if(E=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55)}if(E=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55,parseFloat(E[4]))}if(E=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(F)){return C(parseInt(E[1],16),parseInt(E[2],16),parseInt(E[3],16))}if(E=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(F)){return C(parseInt(E[1]+E[1],16),parseInt(E[2]+E[2],16),parseInt(E[3]+E[3],16))}var D=B.trim(F).toLowerCase();if(D=="transparent"){return C(255,255,255,0)}else{E=A[D]||[0,0,0];return C(E[0],E[1],E[2])}};var A={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);(function($){var hasOwnProperty=Object.prototype.hasOwnProperty;function Canvas(cls,container){var element=container.children("."+ cls)[0];if(element==null){element=document.createElement("canvas");element.className=cls;$(element).css({direction:"ltr",position:"absolute",left:0,top:0}).appendTo(container);if(!element.getContext){if(window.G_vmlCanvasManager){element=window.G_vmlCanvasManager.initElement(element);}else{throw new Error("Canvas is not available. If you're using IE with a fall-back such as Excanvas, then there's either a mistake in your conditional include, or the page has no DOCTYPE and is rendering in Quirks Mode.");}}}
|
||||
this.element=element;var context=this.context=element.getContext("2d");var devicePixelRatio=window.devicePixelRatio||1,backingStoreRatio=context.webkitBackingStorePixelRatio||context.mozBackingStorePixelRatio||context.msBackingStorePixelRatio||context.oBackingStorePixelRatio||context.backingStorePixelRatio||1;this.pixelRatio=devicePixelRatio/backingStoreRatio;this.resize(container.width(),container.height());this.textContainer=null;this.text={};this._textCache={};}
|
||||
Canvas.prototype.resize=function(width,height){if(width<=0||height<=0){throw new Error("Invalid dimensions for plot, width = "+ width+", height = "+ height);}
|
||||
var element=this.element,context=this.context,pixelRatio=this.pixelRatio;if(this.width!=width){element.width=width*pixelRatio;element.style.width=width+"px";this.width=width;}
|
||||
if(this.height!=height){element.height=height*pixelRatio;element.style.height=height+"px";this.height=height;}
|
||||
context.restore();context.save();context.scale(pixelRatio,pixelRatio);};Canvas.prototype.clear=function(){this.context.clearRect(0,0,this.width,this.height);};Canvas.prototype.render=function(){var cache=this._textCache;for(var layerKey in cache){if(hasOwnProperty.call(cache,layerKey)){var layer=this.getTextLayer(layerKey),layerCache=cache[layerKey];layer.hide();for(var styleKey in layerCache){if(hasOwnProperty.call(layerCache,styleKey)){var styleCache=layerCache[styleKey];for(var key in styleCache){if(hasOwnProperty.call(styleCache,key)){var positions=styleCache[key].positions;for(var i=0,position;position=positions[i];i++){if(position.active){if(!position.rendered){layer.append(position.element);position.rendered=true;}}else{positions.splice(i--,1);if(position.rendered){position.element.detach();}}}
|
||||
if(positions.length==0){delete styleCache[key];}}}}}
|
||||
layer.show();}}};Canvas.prototype.getTextLayer=function(classes){var layer=this.text[classes];if(layer==null){if(this.textContainer==null){this.textContainer=$("<div class='flot-text'></div>").css({position:"absolute",top:0,left:0,bottom:0,right:0,'font-size':"smaller",color:"#545454"}).insertAfter(this.element);}
|
||||
layer=this.text[classes]=$("<div></div>").addClass(classes).css({position:"absolute",top:0,left:0,bottom:0,right:0}).appendTo(this.textContainer);}
|
||||
return layer;};Canvas.prototype.getTextInfo=function(layer,text,font,angle,width){var textStyle,layerCache,styleCache,info;text=""+ text;if(typeof font==="object"){textStyle=font.style+" "+ font.variant+" "+ font.weight+" "+ font.size+"px/"+ font.lineHeight+"px "+ font.family;}else{textStyle=font;}
|
||||
layerCache=this._textCache[layer];if(layerCache==null){layerCache=this._textCache[layer]={};}
|
||||
styleCache=layerCache[textStyle];if(styleCache==null){styleCache=layerCache[textStyle]={};}
|
||||
info=styleCache[text];if(info==null){var element=$("<div></div>").html(text).css({position:"absolute",'max-width':width,top:-9999}).appendTo(this.getTextLayer(layer));if(typeof font==="object"){element.css({font:textStyle,color:font.color});}else if(typeof font==="string"){element.addClass(font);}
|
||||
info=styleCache[text]={width:element.outerWidth(true),height:element.outerHeight(true),element:element,positions:[]};element.detach();}
|
||||
return info;};Canvas.prototype.addText=function(layer,x,y,text,font,angle,width,halign,valign){var info=this.getTextInfo(layer,text,font,angle,width),positions=info.positions;if(halign=="center"){x-=info.width/2;}else if(halign=="right"){x-=info.width;}
|
||||
if(valign=="middle"){y-=info.height/2;}else if(valign=="bottom"){y-=info.height;}
|
||||
for(var i=0,position;position=positions[i];i++){if(position.x==x&&position.y==y){position.active=true;return;}}
|
||||
position={active:true,rendered:false,element:positions.length?info.element.clone():info.element,x:x,y:y}
|
||||
positions.push(position);position.element.css({top:Math.round(y),left:Math.round(x),'text-align':halign});};Canvas.prototype.removeText=function(layer,x,y,text,font,angle){if(text==null){var layerCache=this._textCache[layer];if(layerCache!=null){for(var styleKey in layerCache){if(hasOwnProperty.call(layerCache,styleKey)){var styleCache=layerCache[styleKey];for(var key in styleCache){if(hasOwnProperty.call(styleCache,key)){var positions=styleCache[key].positions;for(var i=0,position;position=positions[i];i++){position.active=false;}}}}}}}else{var positions=this.getTextInfo(layer,text,font,angle).positions;for(var i=0,position;position=positions[i];i++){if(position.x==x&&position.y==y){position.active=false;}}}};function Plot(placeholder,data_,options_,plugins){var series=[],options={colors:["#edc240","#afd8f8","#cb4b4b","#4da74d","#9440ed"],legend:{show:true,noColumns:1,labelFormatter:null,labelBoxBorderColor:"#ccc",container:null,position:"ne",margin:5,backgroundColor:null,backgroundOpacity:0.85,sorted:null},xaxis:{show:null,position:"bottom",mode:null,font:null,color:null,tickColor:null,transform:null,inverseTransform:null,min:null,max:null,autoscaleMargin:null,ticks:null,tickFormatter:null,labelWidth:null,labelHeight:null,reserveSpace:null,tickLength:null,alignTicksWithAxis:null,tickDecimals:null,tickSize:null,minTickSize:null},yaxis:{autoscaleMargin:0.02,position:"left"},xaxes:[],yaxes:[],series:{points:{show:false,radius:3,lineWidth:2,fill:true,fillColor:"#ffffff",symbol:"circle"},lines:{lineWidth:2,fill:false,fillColor:null,steps:false},bars:{show:false,lineWidth:2,barWidth:1,fill:true,fillColor:null,align:"left",horizontal:false,zero:true},shadowSize:3,highlightColor:null},grid:{show:true,aboveData:false,color:"#545454",backgroundColor:null,borderColor:null,tickColor:null,margin:0,labelMargin:5,axisMargin:8,borderWidth:2,minBorderMargin:null,markings:null,markingsColor:"#f4f4f4",markingsLineWidth:2,clickable:false,hoverable:false,autoHighlight:true,mouseActiveRadius:10},interaction:{redrawOverlayInterval:1000/60},hooks:{}},surface=null,overlay=null,eventHolder=null,ctx=null,octx=null,xaxes=[],yaxes=[],plotOffset={left:0,right:0,top:0,bottom:0},plotWidth=0,plotHeight=0,hooks={processOptions:[],processRawData:[],processDatapoints:[],processOffset:[],drawBackground:[],drawSeries:[],draw:[],bindEvents:[],drawOverlay:[],shutdown:[]},plot=this;plot.setData=setData;plot.setupGrid=setupGrid;plot.draw=draw;plot.getPlaceholder=function(){return placeholder;};plot.getCanvas=function(){return surface.element;};plot.getPlotOffset=function(){return plotOffset;};plot.width=function(){return plotWidth;};plot.height=function(){return plotHeight;};plot.offset=function(){var o=eventHolder.offset();o.left+=plotOffset.left;o.top+=plotOffset.top;return o;};plot.getData=function(){return series;};plot.getAxes=function(){var res={},i;$.each(xaxes.concat(yaxes),function(_,axis){if(axis)
|
||||
res[axis.direction+(axis.n!=1?axis.n:"")+"axis"]=axis;});return res;};plot.getXAxes=function(){return xaxes;};plot.getYAxes=function(){return yaxes;};plot.c2p=canvasToAxisCoords;plot.p2c=axisToCanvasCoords;plot.getOptions=function(){return options;};plot.highlight=highlight;plot.unhighlight=unhighlight;plot.triggerRedrawOverlay=triggerRedrawOverlay;plot.pointOffset=function(point){return{left:parseInt(xaxes[axisNumber(point,"x")- 1].p2c(+point.x)+ plotOffset.left,10),top:parseInt(yaxes[axisNumber(point,"y")- 1].p2c(+point.y)+ plotOffset.top,10)};};plot.shutdown=shutdown;plot.resize=function(){var width=placeholder.width(),height=placeholder.height();surface.resize(width,height);overlay.resize(width,height);};plot.hooks=hooks;initPlugins(plot);parseOptions(options_);setupCanvases();setData(data_);setupGrid();draw();bindEvents();function executeHooks(hook,args){args=[plot].concat(args);for(var i=0;i<hook.length;++i)
|
||||
hook[i].apply(this,args);}
|
||||
function initPlugins(){var classes={Canvas:Canvas};for(var i=0;i<plugins.length;++i){var p=plugins[i];p.init(plot,classes);if(p.options)
|
||||
$.extend(true,options,p.options);}}
|
||||
function parseOptions(opts){$.extend(true,options,opts);if(opts&&opts.colors){options.colors=opts.colors;}
|
||||
if(options.xaxis.color==null)
|
||||
options.xaxis.color=$.color.parse(options.grid.color).scale('a',0.22).toString();if(options.yaxis.color==null)
|
||||
options.yaxis.color=$.color.parse(options.grid.color).scale('a',0.22).toString();if(options.xaxis.tickColor==null)
|
||||
options.xaxis.tickColor=options.grid.tickColor||options.xaxis.color;if(options.yaxis.tickColor==null)
|
||||
options.yaxis.tickColor=options.grid.tickColor||options.yaxis.color;if(options.grid.borderColor==null)
|
||||
options.grid.borderColor=options.grid.color;if(options.grid.tickColor==null)
|
||||
options.grid.tickColor=$.color.parse(options.grid.color).scale('a',0.22).toString();var i,axisOptions,axisCount,fontDefaults={style:placeholder.css("font-style"),size:Math.round(0.8*(+placeholder.css("font-size").replace("px","")||13)),variant:placeholder.css("font-variant"),weight:placeholder.css("font-weight"),family:placeholder.css("font-family")};fontDefaults.lineHeight=fontDefaults.size*1.15;axisCount=options.xaxes.length||1;for(i=0;i<axisCount;++i){axisOptions=options.xaxes[i];if(axisOptions&&!axisOptions.tickColor){axisOptions.tickColor=axisOptions.color;}
|
||||
axisOptions=$.extend(true,{},options.xaxis,axisOptions);options.xaxes[i]=axisOptions;if(axisOptions.font){axisOptions.font=$.extend({},fontDefaults,axisOptions.font);if(!axisOptions.font.color){axisOptions.font.color=axisOptions.color;}}}
|
||||
axisCount=options.yaxes.length||1;for(i=0;i<axisCount;++i){axisOptions=options.yaxes[i];if(axisOptions&&!axisOptions.tickColor){axisOptions.tickColor=axisOptions.color;}
|
||||
axisOptions=$.extend(true,{},options.yaxis,axisOptions);options.yaxes[i]=axisOptions;if(axisOptions.font){axisOptions.font=$.extend({},fontDefaults,axisOptions.font);if(!axisOptions.font.color){axisOptions.font.color=axisOptions.color;}}}
|
||||
if(options.xaxis.noTicks&&options.xaxis.ticks==null)
|
||||
options.xaxis.ticks=options.xaxis.noTicks;if(options.yaxis.noTicks&&options.yaxis.ticks==null)
|
||||
options.yaxis.ticks=options.yaxis.noTicks;if(options.x2axis){options.xaxes[1]=$.extend(true,{},options.xaxis,options.x2axis);options.xaxes[1].position="top";}
|
||||
if(options.y2axis){options.yaxes[1]=$.extend(true,{},options.yaxis,options.y2axis);options.yaxes[1].position="right";}
|
||||
if(options.grid.coloredAreas)
|
||||
options.grid.markings=options.grid.coloredAreas;if(options.grid.coloredAreasColor)
|
||||
options.grid.markingsColor=options.grid.coloredAreasColor;if(options.lines)
|
||||
$.extend(true,options.series.lines,options.lines);if(options.points)
|
||||
$.extend(true,options.series.points,options.points);if(options.bars)
|
||||
$.extend(true,options.series.bars,options.bars);if(options.shadowSize!=null)
|
||||
options.series.shadowSize=options.shadowSize;if(options.highlightColor!=null)
|
||||
options.series.highlightColor=options.highlightColor;for(i=0;i<options.xaxes.length;++i)
|
||||
getOrCreateAxis(xaxes,i+ 1).options=options.xaxes[i];for(i=0;i<options.yaxes.length;++i)
|
||||
getOrCreateAxis(yaxes,i+ 1).options=options.yaxes[i];for(var n in hooks)
|
||||
if(options.hooks[n]&&options.hooks[n].length)
|
||||
hooks[n]=hooks[n].concat(options.hooks[n]);executeHooks(hooks.processOptions,[options]);}
|
||||
function setData(d){series=parseData(d);fillInSeriesOptions();processData();}
|
||||
function parseData(d){var res=[];for(var i=0;i<d.length;++i){var s=$.extend(true,{},options.series);if(d[i].data!=null){s.data=d[i].data;delete d[i].data;$.extend(true,s,d[i]);d[i].data=s.data;}
|
||||
else
|
||||
s.data=d[i];res.push(s);}
|
||||
return res;}
|
||||
function axisNumber(obj,coord){var a=obj[coord+"axis"];if(typeof a=="object")
|
||||
a=a.n;if(typeof a!="number")
|
||||
a=1;return a;}
|
||||
function allAxes(){return $.grep(xaxes.concat(yaxes),function(a){return a;});}
|
||||
function canvasToAxisCoords(pos){var res={},i,axis;for(i=0;i<xaxes.length;++i){axis=xaxes[i];if(axis&&axis.used)
|
||||
res["x"+ axis.n]=axis.c2p(pos.left);}
|
||||
for(i=0;i<yaxes.length;++i){axis=yaxes[i];if(axis&&axis.used)
|
||||
res["y"+ axis.n]=axis.c2p(pos.top);}
|
||||
if(res.x1!==undefined)
|
||||
res.x=res.x1;if(res.y1!==undefined)
|
||||
res.y=res.y1;return res;}
|
||||
function axisToCanvasCoords(pos){var res={},i,axis,key;for(i=0;i<xaxes.length;++i){axis=xaxes[i];if(axis&&axis.used){key="x"+ axis.n;if(pos[key]==null&&axis.n==1)
|
||||
key="x";if(pos[key]!=null){res.left=axis.p2c(pos[key]);break;}}}
|
||||
for(i=0;i<yaxes.length;++i){axis=yaxes[i];if(axis&&axis.used){key="y"+ axis.n;if(pos[key]==null&&axis.n==1)
|
||||
key="y";if(pos[key]!=null){res.top=axis.p2c(pos[key]);break;}}}
|
||||
return res;}
|
||||
function getOrCreateAxis(axes,number){if(!axes[number- 1])
|
||||
axes[number- 1]={n:number,direction:axes==xaxes?"x":"y",options:$.extend(true,{},axes==xaxes?options.xaxis:options.yaxis)};return axes[number- 1];}
|
||||
function fillInSeriesOptions(){var neededColors=series.length,maxIndex=-1,i;for(i=0;i<series.length;++i){var sc=series[i].color;if(sc!=null){neededColors--;if(typeof sc=="number"&&sc>maxIndex){maxIndex=sc;}}}
|
||||
if(neededColors<=maxIndex){neededColors=maxIndex+ 1;}
|
||||
var c,colors=[],colorPool=options.colors,colorPoolSize=colorPool.length,variation=0;for(i=0;i<neededColors;i++){c=$.color.parse(colorPool[i%colorPoolSize]||"#666");if(i%colorPoolSize==0&&i){if(variation>=0){if(variation<0.5){variation=-variation- 0.2;}else variation=0;}else variation=-variation;}
|
||||
colors[i]=c.scale('rgb',1+ variation);}
|
||||
var colori=0,s;for(i=0;i<series.length;++i){s=series[i];if(s.color==null){s.color=colors[colori].toString();++colori;}
|
||||
else if(typeof s.color=="number")
|
||||
s.color=colors[s.color].toString();if(s.lines.show==null){var v,show=true;for(v in s)
|
||||
if(s[v]&&s[v].show){show=false;break;}
|
||||
if(show)
|
||||
s.lines.show=true;}
|
||||
if(s.lines.zero==null){s.lines.zero=!!s.lines.fill;}
|
||||
s.xaxis=getOrCreateAxis(xaxes,axisNumber(s,"x"));s.yaxis=getOrCreateAxis(yaxes,axisNumber(s,"y"));}}
|
||||
function processData(){var topSentry=Number.POSITIVE_INFINITY,bottomSentry=Number.NEGATIVE_INFINITY,fakeInfinity=Number.MAX_VALUE,i,j,k,m,length,s,points,ps,x,y,axis,val,f,p,data,format;function updateAxis(axis,min,max){if(min<axis.datamin&&min!=-fakeInfinity)
|
||||
axis.datamin=min;if(max>axis.datamax&&max!=fakeInfinity)
|
||||
axis.datamax=max;}
|
||||
$.each(allAxes(),function(_,axis){axis.datamin=topSentry;axis.datamax=bottomSentry;axis.used=false;});for(i=0;i<series.length;++i){s=series[i];s.datapoints={points:[]};executeHooks(hooks.processRawData,[s,s.data,s.datapoints]);}
|
||||
for(i=0;i<series.length;++i){s=series[i];data=s.data;format=s.datapoints.format;if(!format){format=[];format.push({x:true,number:true,required:true});format.push({y:true,number:true,required:true});if(s.bars.show||(s.lines.show&&s.lines.fill)){var autoscale=!!((s.bars.show&&s.bars.zero)||(s.lines.show&&s.lines.zero));format.push({y:true,number:true,required:false,defaultValue:0,autoscale:autoscale});if(s.bars.horizontal){delete format[format.length- 1].y;format[format.length- 1].x=true;}}
|
||||
s.datapoints.format=format;}
|
||||
if(s.datapoints.pointsize!=null)
|
||||
continue;s.datapoints.pointsize=format.length;ps=s.datapoints.pointsize;points=s.datapoints.points;var insertSteps=s.lines.show&&s.lines.steps;s.xaxis.used=s.yaxis.used=true;for(j=k=0;j<data.length;++j,k+=ps){p=data[j];var nullify=p==null;if(!nullify){for(m=0;m<ps;++m){val=p[m];f=format[m];if(f){if(f.number&&val!=null){val=+val;if(isNaN(val))
|
||||
val=null;else if(val==Infinity)
|
||||
val=fakeInfinity;else if(val==-Infinity)
|
||||
val=-fakeInfinity;}
|
||||
if(val==null){if(f.required)
|
||||
nullify=true;if(f.defaultValue!=null)
|
||||
val=f.defaultValue;}}
|
||||
points[k+ m]=val;}}
|
||||
if(nullify){for(m=0;m<ps;++m){val=points[k+ m];if(val!=null){f=format[m];if(f.autoscale){if(f.x){updateAxis(s.xaxis,val,val);}
|
||||
if(f.y){updateAxis(s.yaxis,val,val);}}}
|
||||
points[k+ m]=null;}}
|
||||
else{if(insertSteps&&k>0&&points[k- ps]!=null&&points[k- ps]!=points[k]&&points[k- ps+ 1]!=points[k+ 1]){for(m=0;m<ps;++m)
|
||||
points[k+ ps+ m]=points[k+ m];points[k+ 1]=points[k- ps+ 1];k+=ps;}}}}
|
||||
for(i=0;i<series.length;++i){s=series[i];executeHooks(hooks.processDatapoints,[s,s.datapoints]);}
|
||||
for(i=0;i<series.length;++i){s=series[i];points=s.datapoints.points;ps=s.datapoints.pointsize;format=s.datapoints.format;var xmin=topSentry,ymin=topSentry,xmax=bottomSentry,ymax=bottomSentry;for(j=0;j<points.length;j+=ps){if(points[j]==null)
|
||||
continue;for(m=0;m<ps;++m){val=points[j+ m];f=format[m];if(!f||f.autoscale===false||val==fakeInfinity||val==-fakeInfinity)
|
||||
continue;if(f.x){if(val<xmin)
|
||||
xmin=val;if(val>xmax)
|
||||
xmax=val;}
|
||||
if(f.y){if(val<ymin)
|
||||
ymin=val;if(val>ymax)
|
||||
ymax=val;}}}
|
||||
if(s.bars.show){var delta;switch(s.bars.align){case"left":delta=0;break;case"right":delta=-s.bars.barWidth;break;case"center":delta=-s.bars.barWidth/2;break;default:throw new Error("Invalid bar alignment: "+ s.bars.align);}
|
||||
if(s.bars.horizontal){ymin+=delta;ymax+=delta+ s.bars.barWidth;}
|
||||
else{xmin+=delta;xmax+=delta+ s.bars.barWidth;}}
|
||||
updateAxis(s.xaxis,xmin,xmax);updateAxis(s.yaxis,ymin,ymax);}
|
||||
$.each(allAxes(),function(_,axis){if(axis.datamin==topSentry)
|
||||
axis.datamin=null;if(axis.datamax==bottomSentry)
|
||||
axis.datamax=null;});}
|
||||
function setupCanvases(){placeholder.css("padding",0).children(":not(.flot-base,.flot-overlay)").remove();if(placeholder.css("position")=='static')
|
||||
placeholder.css("position","relative");surface=new Canvas("flot-base",placeholder);overlay=new Canvas("flot-overlay",placeholder);ctx=surface.context;octx=overlay.context;eventHolder=$(overlay.element).unbind();var existing=placeholder.data("plot");if(existing){existing.shutdown();overlay.clear();}
|
||||
placeholder.data("plot",plot);}
|
||||
function bindEvents(){if(options.grid.hoverable){eventHolder.mousemove(onMouseMove);eventHolder.bind("mouseleave",onMouseLeave);}
|
||||
if(options.grid.clickable)
|
||||
eventHolder.click(onClick);executeHooks(hooks.bindEvents,[eventHolder]);}
|
||||
function shutdown(){if(redrawTimeout)
|
||||
clearTimeout(redrawTimeout);eventHolder.unbind("mousemove",onMouseMove);eventHolder.unbind("mouseleave",onMouseLeave);eventHolder.unbind("click",onClick);executeHooks(hooks.shutdown,[eventHolder]);}
|
||||
function setTransformationHelpers(axis){function identity(x){return x;}
|
||||
var s,m,t=axis.options.transform||identity,it=axis.options.inverseTransform;if(axis.direction=="x"){s=axis.scale=plotWidth/Math.abs(t(axis.max)- t(axis.min));m=Math.min(t(axis.max),t(axis.min));}
|
||||
else{s=axis.scale=plotHeight/Math.abs(t(axis.max)- t(axis.min));s=-s;m=Math.max(t(axis.max),t(axis.min));}
|
||||
if(t==identity)
|
||||
axis.p2c=function(p){return(p- m)*s;};else
|
||||
axis.p2c=function(p){return(t(p)- m)*s;};if(!it)
|
||||
axis.c2p=function(c){return m+ c/s;};else
|
||||
axis.c2p=function(c){return it(m+ c/s);};}
|
||||
function measureTickLabels(axis){var opts=axis.options,ticks=axis.ticks||[],labelWidth=opts.labelWidth||0,labelHeight=opts.labelHeight||0,maxWidth=labelWidth||axis.direction=="x"?Math.floor(surface.width/(ticks.length||1)):null;legacyStyles=axis.direction+"Axis "+ axis.direction+ axis.n+"Axis",layer="flot-"+ axis.direction+"-axis flot-"+ axis.direction+ axis.n+"-axis "+ legacyStyles,font=opts.font||"flot-tick-label tickLabel";for(var i=0;i<ticks.length;++i){var t=ticks[i];if(!t.label)
|
||||
continue;var info=surface.getTextInfo(layer,t.label,font,null,maxWidth);labelWidth=Math.max(labelWidth,info.width);labelHeight=Math.max(labelHeight,info.height);}
|
||||
axis.labelWidth=opts.labelWidth||labelWidth;axis.labelHeight=opts.labelHeight||labelHeight;}
|
||||
function allocateAxisBoxFirstPhase(axis){var lw=axis.labelWidth,lh=axis.labelHeight,pos=axis.options.position,tickLength=axis.options.tickLength,axisMargin=options.grid.axisMargin,padding=options.grid.labelMargin,all=axis.direction=="x"?xaxes:yaxes,index,innermost;var samePosition=$.grep(all,function(a){return a&&a.options.position==pos&&a.reserveSpace;});if($.inArray(axis,samePosition)==samePosition.length- 1)
|
||||
axisMargin=0;if(tickLength==null){var sameDirection=$.grep(all,function(a){return a&&a.reserveSpace;});innermost=$.inArray(axis,sameDirection)==0;if(innermost)
|
||||
tickLength="full";else
|
||||
tickLength=5;}
|
||||
if(!isNaN(+tickLength))
|
||||
padding+=+tickLength;if(axis.direction=="x"){lh+=padding;if(pos=="bottom"){plotOffset.bottom+=lh+ axisMargin;axis.box={top:surface.height- plotOffset.bottom,height:lh};}
|
||||
else{axis.box={top:plotOffset.top+ axisMargin,height:lh};plotOffset.top+=lh+ axisMargin;}}
|
||||
else{lw+=padding;if(pos=="left"){axis.box={left:plotOffset.left+ axisMargin,width:lw};plotOffset.left+=lw+ axisMargin;}
|
||||
else{plotOffset.right+=lw+ axisMargin;axis.box={left:surface.width- plotOffset.right,width:lw};}}
|
||||
axis.position=pos;axis.tickLength=tickLength;axis.box.padding=padding;axis.innermost=innermost;}
|
||||
function allocateAxisBoxSecondPhase(axis){if(axis.direction=="x"){axis.box.left=plotOffset.left- axis.labelWidth/2;axis.box.width=surface.width- plotOffset.left- plotOffset.right+ axis.labelWidth;}
|
||||
else{axis.box.top=plotOffset.top- axis.labelHeight/2;axis.box.height=surface.height- plotOffset.bottom- plotOffset.top+ axis.labelHeight;}}
|
||||
function adjustLayoutForThingsStickingOut(){var minMargin=options.grid.minBorderMargin,margins={x:0,y:0},i,axis;if(minMargin==null){minMargin=0;for(i=0;i<series.length;++i)
|
||||
minMargin=Math.max(minMargin,2*(series[i].points.radius+ series[i].points.lineWidth/2));}
|
||||
margins.x=margins.y=Math.ceil(minMargin);$.each(allAxes(),function(_,axis){var dir=axis.direction;if(axis.reserveSpace)
|
||||
margins[dir]=Math.ceil(Math.max(margins[dir],(dir=="x"?axis.labelWidth:axis.labelHeight)/ 2));
|
||||
});plotOffset.left=Math.max(margins.x,plotOffset.left);plotOffset.right=Math.max(margins.x,plotOffset.right);plotOffset.top=Math.max(margins.y,plotOffset.top);plotOffset.bottom=Math.max(margins.y,plotOffset.bottom);}
|
||||
function setupGrid(){var i,axes=allAxes(),showGrid=options.grid.show;for(var a in plotOffset){var margin=options.grid.margin||0;plotOffset[a]=typeof margin=="number"?margin:margin[a]||0;}
|
||||
executeHooks(hooks.processOffset,[plotOffset]);for(var a in plotOffset){if(typeof(options.grid.borderWidth)=="object"){plotOffset[a]+=showGrid?options.grid.borderWidth[a]:0;}
|
||||
else{plotOffset[a]+=showGrid?options.grid.borderWidth:0;}}
|
||||
$.each(axes,function(_,axis){axis.show=axis.options.show;if(axis.show==null)
|
||||
axis.show=axis.used;axis.reserveSpace=axis.show||axis.options.reserveSpace;setRange(axis);});if(showGrid){var allocatedAxes=$.grep(axes,function(axis){return axis.reserveSpace;});$.each(allocatedAxes,function(_,axis){setupTickGeneration(axis);setTicks(axis);snapRangeToTicks(axis,axis.ticks);measureTickLabels(axis);});for(i=allocatedAxes.length- 1;i>=0;--i)
|
||||
allocateAxisBoxFirstPhase(allocatedAxes[i]);adjustLayoutForThingsStickingOut();$.each(allocatedAxes,function(_,axis){allocateAxisBoxSecondPhase(axis);});}
|
||||
plotWidth=surface.width- plotOffset.left- plotOffset.right;plotHeight=surface.height- plotOffset.bottom- plotOffset.top;$.each(axes,function(_,axis){setTransformationHelpers(axis);});if(showGrid){drawAxisLabels();}
|
||||
insertLegend();}
|
||||
function setRange(axis){var opts=axis.options,min=+(opts.min!=null?opts.min:axis.datamin),max=+(opts.max!=null?opts.max:axis.datamax),delta=max- min;if(delta==0.0){var widen=max==0?1:0.01;if(opts.min==null)
|
||||
min-=widen;if(opts.max==null||opts.min!=null)
|
||||
max+=widen;}
|
||||
else{var margin=opts.autoscaleMargin;if(margin!=null){if(opts.min==null){min-=delta*margin;if(min<0&&axis.datamin!=null&&axis.datamin>=0)
|
||||
min=0;}
|
||||
if(opts.max==null){max+=delta*margin;if(max>0&&axis.datamax!=null&&axis.datamax<=0)
|
||||
max=0;}}}
|
||||
axis.min=min;axis.max=max;}
|
||||
function setupTickGeneration(axis){var opts=axis.options;var noTicks;if(typeof opts.ticks=="number"&&opts.ticks>0)
|
||||
noTicks=opts.ticks;else
|
||||
noTicks=0.3*Math.sqrt(axis.direction=="x"?surface.width:surface.height);var delta=(axis.max- axis.min)/ noTicks,
|
||||
dec=-Math.floor(Math.log(delta)/ Math.LN10),
|
||||
maxDec=opts.tickDecimals;if(maxDec!=null&&dec>maxDec){dec=maxDec;}
|
||||
var magn=Math.pow(10,-dec),norm=delta/magn,size;if(norm<1.5){size=1;}else if(norm<3){size=2;if(norm>2.25&&(maxDec==null||dec+ 1<=maxDec)){size=2.5;++dec;}}else if(norm<7.5){size=5;}else{size=10;}
|
||||
size*=magn;if(opts.minTickSize!=null&&size<opts.minTickSize){size=opts.minTickSize;}
|
||||
axis.delta=delta;axis.tickDecimals=Math.max(0,maxDec!=null?maxDec:dec);axis.tickSize=opts.tickSize||size;if(opts.mode=="time"&&!axis.tickGenerator){throw new Error("Time mode requires the flot.time plugin.");}
|
||||
if(!axis.tickGenerator){axis.tickGenerator=function(axis){var ticks=[],start=floorInBase(axis.min,axis.tickSize),i=0,v=Number.NaN,prev;do{prev=v;v=start+ i*axis.tickSize;ticks.push(v);++i;}while(v<axis.max&&v!=prev);return ticks;};axis.tickFormatter=function(value,axis){var factor=axis.tickDecimals?Math.pow(10,axis.tickDecimals):1;var formatted=""+ Math.round(value*factor)/ factor;
|
||||
if(axis.tickDecimals!=null){var decimal=formatted.indexOf(".");var precision=decimal==-1?0:formatted.length- decimal- 1;if(precision<axis.tickDecimals){return(precision?formatted:formatted+".")+(""+ factor).substr(1,axis.tickDecimals- precision);}}
|
||||
return formatted;};}
|
||||
if($.isFunction(opts.tickFormatter))
|
||||
axis.tickFormatter=function(v,axis){return""+ opts.tickFormatter(v,axis);};if(opts.alignTicksWithAxis!=null){var otherAxis=(axis.direction=="x"?xaxes:yaxes)[opts.alignTicksWithAxis- 1];if(otherAxis&&otherAxis.used&&otherAxis!=axis){var niceTicks=axis.tickGenerator(axis);if(niceTicks.length>0){if(opts.min==null)
|
||||
axis.min=Math.min(axis.min,niceTicks[0]);if(opts.max==null&&niceTicks.length>1)
|
||||
axis.max=Math.max(axis.max,niceTicks[niceTicks.length- 1]);}
|
||||
axis.tickGenerator=function(axis){var ticks=[],v,i;for(i=0;i<otherAxis.ticks.length;++i){v=(otherAxis.ticks[i].v- otherAxis.min)/ (otherAxis.max - otherAxis.min);
|
||||
v=axis.min+ v*(axis.max- axis.min);ticks.push(v);}
|
||||
return ticks;};if(!axis.mode&&opts.tickDecimals==null){var extraDec=Math.max(0,-Math.floor(Math.log(axis.delta)/ Math.LN10) + 1),
|
||||
ts=axis.tickGenerator(axis);if(!(ts.length>1&&/\..*0$/.test((ts[1]- ts[0]).toFixed(extraDec))))
|
||||
axis.tickDecimals=extraDec;}}}}
|
||||
function setTicks(axis){var oticks=axis.options.ticks,ticks=[];if(oticks==null||(typeof oticks=="number"&&oticks>0))
|
||||
ticks=axis.tickGenerator(axis);else if(oticks){if($.isFunction(oticks))
|
||||
ticks=oticks(axis);else
|
||||
ticks=oticks;}
|
||||
var i,v;axis.ticks=[];for(i=0;i<ticks.length;++i){var label=null;var t=ticks[i];if(typeof t=="object"){v=+t[0];if(t.length>1)
|
||||
label=t[1];}
|
||||
else
|
||||
v=+t;if(label==null)
|
||||
label=axis.tickFormatter(v,axis);if(!isNaN(v))
|
||||
axis.ticks.push({v:v,label:label});}}
|
||||
function snapRangeToTicks(axis,ticks){if(axis.options.autoscaleMargin&&ticks.length>0){if(axis.options.min==null)
|
||||
axis.min=Math.min(axis.min,ticks[0].v);if(axis.options.max==null&&ticks.length>1)
|
||||
axis.max=Math.max(axis.max,ticks[ticks.length- 1].v);}}
|
||||
function draw(){surface.clear();executeHooks(hooks.drawBackground,[ctx]);var grid=options.grid;if(grid.show&&grid.backgroundColor)
|
||||
drawBackground();if(grid.show&&!grid.aboveData){drawGrid();}
|
||||
for(var i=0;i<series.length;++i){executeHooks(hooks.drawSeries,[ctx,series[i]]);drawSeries(series[i]);}
|
||||
executeHooks(hooks.draw,[ctx]);if(grid.show&&grid.aboveData){drawGrid();}
|
||||
surface.render();triggerRedrawOverlay();}
|
||||
function extractRange(ranges,coord){var axis,from,to,key,axes=allAxes();for(var i=0;i<axes.length;++i){axis=axes[i];if(axis.direction==coord){key=coord+ axis.n+"axis";if(!ranges[key]&&axis.n==1)
|
||||
key=coord+"axis";if(ranges[key]){from=ranges[key].from;to=ranges[key].to;break;}}}
|
||||
if(!ranges[key]){axis=coord=="x"?xaxes[0]:yaxes[0];from=ranges[coord+"1"];to=ranges[coord+"2"];}
|
||||
if(from!=null&&to!=null&&from>to){var tmp=from;from=to;to=tmp;}
|
||||
return{from:from,to:to,axis:axis};}
|
||||
function drawBackground(){ctx.save();ctx.translate(plotOffset.left,plotOffset.top);ctx.fillStyle=getColorOrGradient(options.grid.backgroundColor,plotHeight,0,"rgba(255, 255, 255, 0)");ctx.fillRect(0,0,plotWidth,plotHeight);ctx.restore();}
|
||||
function drawGrid(){var i,axes,bw,bc;ctx.save();ctx.translate(plotOffset.left,plotOffset.top);var markings=options.grid.markings;if(markings){if($.isFunction(markings)){axes=plot.getAxes();axes.xmin=axes.xaxis.min;axes.xmax=axes.xaxis.max;axes.ymin=axes.yaxis.min;axes.ymax=axes.yaxis.max;markings=markings(axes);}
|
||||
for(i=0;i<markings.length;++i){var m=markings[i],xrange=extractRange(m,"x"),yrange=extractRange(m,"y");if(xrange.from==null)
|
||||
xrange.from=xrange.axis.min;if(xrange.to==null)
|
||||
xrange.to=xrange.axis.max;if(yrange.from==null)
|
||||
yrange.from=yrange.axis.min;if(yrange.to==null)
|
||||
yrange.to=yrange.axis.max;if(xrange.to<xrange.axis.min||xrange.from>xrange.axis.max||yrange.to<yrange.axis.min||yrange.from>yrange.axis.max)
|
||||
continue;xrange.from=Math.max(xrange.from,xrange.axis.min);xrange.to=Math.min(xrange.to,xrange.axis.max);yrange.from=Math.max(yrange.from,yrange.axis.min);yrange.to=Math.min(yrange.to,yrange.axis.max);if(xrange.from==xrange.to&&yrange.from==yrange.to)
|
||||
continue;xrange.from=xrange.axis.p2c(xrange.from);xrange.to=xrange.axis.p2c(xrange.to);yrange.from=yrange.axis.p2c(yrange.from);yrange.to=yrange.axis.p2c(yrange.to);if(xrange.from==xrange.to||yrange.from==yrange.to){ctx.beginPath();ctx.strokeStyle=m.color||options.grid.markingsColor;ctx.lineWidth=m.lineWidth||options.grid.markingsLineWidth;ctx.moveTo(xrange.from,yrange.from);ctx.lineTo(xrange.to,yrange.to);ctx.stroke();}
|
||||
else{ctx.fillStyle=m.color||options.grid.markingsColor;ctx.fillRect(xrange.from,yrange.to,xrange.to- xrange.from,yrange.from- yrange.to);}}}
|
||||
axes=allAxes();bw=options.grid.borderWidth;for(var j=0;j<axes.length;++j){var axis=axes[j],box=axis.box,t=axis.tickLength,x,y,xoff,yoff;if(!axis.show||axis.ticks.length==0)
|
||||
continue;ctx.lineWidth=1;if(axis.direction=="x"){x=0;if(t=="full")
|
||||
y=(axis.position=="top"?0:plotHeight);else
|
||||
y=box.top- plotOffset.top+(axis.position=="top"?box.height:0);}
|
||||
else{y=0;if(t=="full")
|
||||
x=(axis.position=="left"?0:plotWidth);else
|
||||
x=box.left- plotOffset.left+(axis.position=="left"?box.width:0);}
|
||||
if(!axis.innermost){ctx.strokeStyle=axis.options.color;ctx.beginPath();xoff=yoff=0;if(axis.direction=="x")
|
||||
xoff=plotWidth+ 1;else
|
||||
yoff=plotHeight+ 1;if(ctx.lineWidth==1){if(axis.direction=="x"){y=Math.floor(y)+ 0.5;}else{x=Math.floor(x)+ 0.5;}}
|
||||
ctx.moveTo(x,y);ctx.lineTo(x+ xoff,y+ yoff);ctx.stroke();}
|
||||
ctx.strokeStyle=axis.options.tickColor;ctx.beginPath();for(i=0;i<axis.ticks.length;++i){var v=axis.ticks[i].v;xoff=yoff=0;if(isNaN(v)||v<axis.min||v>axis.max||(t=="full"&&((typeof bw=="object"&&bw[axis.position]>0)||bw>0)&&(v==axis.min||v==axis.max)))
|
||||
continue;if(axis.direction=="x"){x=axis.p2c(v);yoff=t=="full"?-plotHeight:t;if(axis.position=="top")
|
||||
yoff=-yoff;}
|
||||
else{y=axis.p2c(v);xoff=t=="full"?-plotWidth:t;if(axis.position=="left")
|
||||
xoff=-xoff;}
|
||||
if(ctx.lineWidth==1){if(axis.direction=="x")
|
||||
x=Math.floor(x)+ 0.5;else
|
||||
y=Math.floor(y)+ 0.5;}
|
||||
ctx.moveTo(x,y);ctx.lineTo(x+ xoff,y+ yoff);}
|
||||
ctx.stroke();}
|
||||
if(bw){bc=options.grid.borderColor;if(typeof bw=="object"||typeof bc=="object"){if(typeof bw!=="object"){bw={top:bw,right:bw,bottom:bw,left:bw};}
|
||||
if(typeof bc!=="object"){bc={top:bc,right:bc,bottom:bc,left:bc};}
|
||||
if(bw.top>0){ctx.strokeStyle=bc.top;ctx.lineWidth=bw.top;ctx.beginPath();ctx.moveTo(0- bw.left,0- bw.top/2);ctx.lineTo(plotWidth,0- bw.top/2);ctx.stroke();}
|
||||
if(bw.right>0){ctx.strokeStyle=bc.right;ctx.lineWidth=bw.right;ctx.beginPath();ctx.moveTo(plotWidth+ bw.right/2,0- bw.top);ctx.lineTo(plotWidth+ bw.right/2,plotHeight);ctx.stroke();}
|
||||
if(bw.bottom>0){ctx.strokeStyle=bc.bottom;ctx.lineWidth=bw.bottom;ctx.beginPath();ctx.moveTo(plotWidth+ bw.right,plotHeight+ bw.bottom/2);ctx.lineTo(0,plotHeight+ bw.bottom/2);ctx.stroke();}
|
||||
if(bw.left>0){ctx.strokeStyle=bc.left;ctx.lineWidth=bw.left;ctx.beginPath();ctx.moveTo(0- bw.left/2,plotHeight+ bw.bottom);ctx.lineTo(0- bw.left/2,0);ctx.stroke();}}
|
||||
else{ctx.lineWidth=bw;ctx.strokeStyle=options.grid.borderColor;ctx.strokeRect(-bw/2,-bw/2,plotWidth+ bw,plotHeight+ bw);}}
|
||||
ctx.restore();}
|
||||
function drawAxisLabels(){$.each(allAxes(),function(_,axis){if(!axis.show||axis.ticks.length==0)
|
||||
return;var box=axis.box,legacyStyles=axis.direction+"Axis "+ axis.direction+ axis.n+"Axis",layer="flot-"+ axis.direction+"-axis flot-"+ axis.direction+ axis.n+"-axis "+ legacyStyles,font=axis.options.font||"flot-tick-label tickLabel",tick,x,y,halign,valign;surface.removeText(layer);for(var i=0;i<axis.ticks.length;++i){tick=axis.ticks[i];if(!tick.label||tick.v<axis.min||tick.v>axis.max)
|
||||
continue;if(axis.direction=="x"){halign="center";x=plotOffset.left+ axis.p2c(tick.v);if(axis.position=="bottom"){y=box.top+ box.padding;}else{y=box.top+ box.height- box.padding;valign="bottom";}}else{valign="middle";y=plotOffset.top+ axis.p2c(tick.v);if(axis.position=="left"){x=box.left+ box.width- box.padding;halign="right";}else{x=box.left+ box.padding;}}
|
||||
surface.addText(layer,x,y,tick.label,font,null,null,halign,valign);}});}
|
||||
function drawSeries(series){if(series.lines.show)
|
||||
drawSeriesLines(series);if(series.bars.show)
|
||||
drawSeriesBars(series);if(series.points.show)
|
||||
drawSeriesPoints(series);}
|
||||
function drawSeriesLines(series){function plotLine(datapoints,xoffset,yoffset,axisx,axisy){var points=datapoints.points,ps=datapoints.pointsize,prevx=null,prevy=null;ctx.beginPath();for(var i=ps;i<points.length;i+=ps){var x1=points[i- ps],y1=points[i- ps+ 1],x2=points[i],y2=points[i+ 1];if(x1==null||x2==null)
|
||||
continue;if(y1<=y2&&y1<axisy.min){if(y2<axisy.min)
|
||||
continue;x1=(axisy.min- y1)/ (y2 - y1) * (x2 - x1) + x1;
|
||||
y1=axisy.min;}
|
||||
else if(y2<=y1&&y2<axisy.min){if(y1<axisy.min)
|
||||
continue;x2=(axisy.min- y1)/ (y2 - y1) * (x2 - x1) + x1;
|
||||
y2=axisy.min;}
|
||||
if(y1>=y2&&y1>axisy.max){if(y2>axisy.max)
|
||||
continue;x1=(axisy.max- y1)/ (y2 - y1) * (x2 - x1) + x1;
|
||||
y1=axisy.max;}
|
||||
else if(y2>=y1&&y2>axisy.max){if(y1>axisy.max)
|
||||
continue;x2=(axisy.max- y1)/ (y2 - y1) * (x2 - x1) + x1;
|
||||
y2=axisy.max;}
|
||||
if(x1<=x2&&x1<axisx.min){if(x2<axisx.min)
|
||||
continue;y1=(axisx.min- x1)/ (x2 - x1) * (y2 - y1) + y1;
|
||||
x1=axisx.min;}
|
||||
else if(x2<=x1&&x2<axisx.min){if(x1<axisx.min)
|
||||
continue;y2=(axisx.min- x1)/ (x2 - x1) * (y2 - y1) + y1;
|
||||
x2=axisx.min;}
|
||||
if(x1>=x2&&x1>axisx.max){if(x2>axisx.max)
|
||||
continue;y1=(axisx.max- x1)/ (x2 - x1) * (y2 - y1) + y1;
|
||||
x1=axisx.max;}
|
||||
else if(x2>=x1&&x2>axisx.max){if(x1>axisx.max)
|
||||
continue;y2=(axisx.max- x1)/ (x2 - x1) * (y2 - y1) + y1;
|
||||
x2=axisx.max;}
|
||||
if(x1!=prevx||y1!=prevy)
|
||||
ctx.moveTo(axisx.p2c(x1)+ xoffset,axisy.p2c(y1)+ yoffset);prevx=x2;prevy=y2;ctx.lineTo(axisx.p2c(x2)+ xoffset,axisy.p2c(y2)+ yoffset);}
|
||||
ctx.stroke();}
|
||||
function plotLineArea(datapoints,axisx,axisy){var points=datapoints.points,ps=datapoints.pointsize,bottom=Math.min(Math.max(0,axisy.min),axisy.max),i=0,top,areaOpen=false,ypos=1,segmentStart=0,segmentEnd=0;while(true){if(ps>0&&i>points.length+ ps)
|
||||
break;i+=ps;var x1=points[i- ps],y1=points[i- ps+ ypos],x2=points[i],y2=points[i+ ypos];if(areaOpen){if(ps>0&&x1!=null&&x2==null){segmentEnd=i;ps=-ps;ypos=2;continue;}
|
||||
if(ps<0&&i==segmentStart+ ps){ctx.fill();areaOpen=false;ps=-ps;ypos=1;i=segmentStart=segmentEnd+ ps;continue;}}
|
||||
if(x1==null||x2==null)
|
||||
continue;if(x1<=x2&&x1<axisx.min){if(x2<axisx.min)
|
||||
continue;y1=(axisx.min- x1)/ (x2 - x1) * (y2 - y1) + y1;
|
||||
x1=axisx.min;}
|
||||
else if(x2<=x1&&x2<axisx.min){if(x1<axisx.min)
|
||||
continue;y2=(axisx.min- x1)/ (x2 - x1) * (y2 - y1) + y1;
|
||||
x2=axisx.min;}
|
||||
if(x1>=x2&&x1>axisx.max){if(x2>axisx.max)
|
||||
continue;y1=(axisx.max- x1)/ (x2 - x1) * (y2 - y1) + y1;
|
||||
x1=axisx.max;}
|
||||
else if(x2>=x1&&x2>axisx.max){if(x1>axisx.max)
|
||||
continue;y2=(axisx.max- x1)/ (x2 - x1) * (y2 - y1) + y1;
|
||||
x2=axisx.max;}
|
||||
if(!areaOpen){ctx.beginPath();ctx.moveTo(axisx.p2c(x1),axisy.p2c(bottom));areaOpen=true;}
|
||||
if(y1>=axisy.max&&y2>=axisy.max){ctx.lineTo(axisx.p2c(x1),axisy.p2c(axisy.max));ctx.lineTo(axisx.p2c(x2),axisy.p2c(axisy.max));continue;}
|
||||
else if(y1<=axisy.min&&y2<=axisy.min){ctx.lineTo(axisx.p2c(x1),axisy.p2c(axisy.min));ctx.lineTo(axisx.p2c(x2),axisy.p2c(axisy.min));continue;}
|
||||
var x1old=x1,x2old=x2;if(y1<=y2&&y1<axisy.min&&y2>=axisy.min){x1=(axisy.min- y1)/ (y2 - y1) * (x2 - x1) + x1;
|
||||
y1=axisy.min;}
|
||||
else if(y2<=y1&&y2<axisy.min&&y1>=axisy.min){x2=(axisy.min- y1)/ (y2 - y1) * (x2 - x1) + x1;
|
||||
y2=axisy.min;}
|
||||
if(y1>=y2&&y1>axisy.max&&y2<=axisy.max){x1=(axisy.max- y1)/ (y2 - y1) * (x2 - x1) + x1;
|
||||
y1=axisy.max;}
|
||||
else if(y2>=y1&&y2>axisy.max&&y1<=axisy.max){x2=(axisy.max- y1)/ (y2 - y1) * (x2 - x1) + x1;
|
||||
y2=axisy.max;}
|
||||
if(x1!=x1old){ctx.lineTo(axisx.p2c(x1old),axisy.p2c(y1));}
|
||||
ctx.lineTo(axisx.p2c(x1),axisy.p2c(y1));ctx.lineTo(axisx.p2c(x2),axisy.p2c(y2));if(x2!=x2old){ctx.lineTo(axisx.p2c(x2),axisy.p2c(y2));ctx.lineTo(axisx.p2c(x2old),axisy.p2c(y2));}}}
|
||||
ctx.save();ctx.translate(plotOffset.left,plotOffset.top);ctx.lineJoin="round";var lw=series.lines.lineWidth,sw=series.shadowSize;if(lw>0&&sw>0){ctx.lineWidth=sw;ctx.strokeStyle="rgba(0,0,0,0.1)";var angle=Math.PI/18;plotLine(series.datapoints,Math.sin(angle)*(lw/2+ sw/2),Math.cos(angle)*(lw/2+ sw/2),series.xaxis,series.yaxis);ctx.lineWidth=sw/2;plotLine(series.datapoints,Math.sin(angle)*(lw/2+ sw/4),Math.cos(angle)*(lw/2+ sw/4),series.xaxis,series.yaxis);}
|
||||
ctx.lineWidth=lw;ctx.strokeStyle=series.color;var fillStyle=getFillStyle(series.lines,series.color,0,plotHeight);if(fillStyle){ctx.fillStyle=fillStyle;plotLineArea(series.datapoints,series.xaxis,series.yaxis);}
|
||||
if(lw>0)
|
||||
plotLine(series.datapoints,0,0,series.xaxis,series.yaxis);ctx.restore();}
|
||||
function drawSeriesPoints(series){function plotPoints(datapoints,radius,fillStyle,offset,shadow,axisx,axisy,symbol){var points=datapoints.points,ps=datapoints.pointsize;for(var i=0;i<points.length;i+=ps){var x=points[i],y=points[i+ 1];if(x==null||x<axisx.min||x>axisx.max||y<axisy.min||y>axisy.max)
|
||||
continue;ctx.beginPath();x=axisx.p2c(x);y=axisy.p2c(y)+ offset;if(symbol=="circle")
|
||||
ctx.arc(x,y,radius,0,shadow?Math.PI:Math.PI*2,false);else
|
||||
symbol(ctx,x,y,radius,shadow);ctx.closePath();if(fillStyle){ctx.fillStyle=fillStyle;ctx.fill();}
|
||||
ctx.stroke();}}
|
||||
ctx.save();ctx.translate(plotOffset.left,plotOffset.top);var lw=series.points.lineWidth,sw=series.shadowSize,radius=series.points.radius,symbol=series.points.symbol;if(lw==0)
|
||||
lw=0.0001;if(lw>0&&sw>0){var w=sw/2;ctx.lineWidth=w;ctx.strokeStyle="rgba(0,0,0,0.1)";plotPoints(series.datapoints,radius,null,w+ w/2,true,series.xaxis,series.yaxis,symbol);ctx.strokeStyle="rgba(0,0,0,0.2)";plotPoints(series.datapoints,radius,null,w/2,true,series.xaxis,series.yaxis,symbol);}
|
||||
ctx.lineWidth=lw;ctx.strokeStyle=series.color;plotPoints(series.datapoints,radius,getFillStyle(series.points,series.color),0,false,series.xaxis,series.yaxis,symbol);ctx.restore();}
|
||||
function drawBar(x,y,b,barLeft,barRight,offset,fillStyleCallback,axisx,axisy,c,horizontal,lineWidth){var left,right,bottom,top,drawLeft,drawRight,drawTop,drawBottom,tmp;if(horizontal){drawBottom=drawRight=drawTop=true;drawLeft=false;left=b;right=x;top=y+ barLeft;bottom=y+ barRight;if(right<left){tmp=right;right=left;left=tmp;drawLeft=true;drawRight=false;}}
|
||||
else{drawLeft=drawRight=drawTop=true;drawBottom=false;left=x+ barLeft;right=x+ barRight;bottom=b;top=y;if(top<bottom){tmp=top;top=bottom;bottom=tmp;drawBottom=true;drawTop=false;}}
|
||||
if(right<axisx.min||left>axisx.max||top<axisy.min||bottom>axisy.max)
|
||||
return;if(left<axisx.min){left=axisx.min;drawLeft=false;}
|
||||
if(right>axisx.max){right=axisx.max;drawRight=false;}
|
||||
if(bottom<axisy.min){bottom=axisy.min;drawBottom=false;}
|
||||
if(top>axisy.max){top=axisy.max;drawTop=false;}
|
||||
left=axisx.p2c(left);bottom=axisy.p2c(bottom);right=axisx.p2c(right);top=axisy.p2c(top);if(fillStyleCallback){c.beginPath();c.moveTo(left,bottom);c.lineTo(left,top);c.lineTo(right,top);c.lineTo(right,bottom);c.fillStyle=fillStyleCallback(bottom,top);c.fill();}
|
||||
if(lineWidth>0&&(drawLeft||drawRight||drawTop||drawBottom)){c.beginPath();c.moveTo(left,bottom+ offset);if(drawLeft)
|
||||
c.lineTo(left,top+ offset);else
|
||||
c.moveTo(left,top+ offset);if(drawTop)
|
||||
c.lineTo(right,top+ offset);else
|
||||
c.moveTo(right,top+ offset);if(drawRight)
|
||||
c.lineTo(right,bottom+ offset);else
|
||||
c.moveTo(right,bottom+ offset);if(drawBottom)
|
||||
c.lineTo(left,bottom+ offset);else
|
||||
c.moveTo(left,bottom+ offset);c.stroke();}}
|
||||
function drawSeriesBars(series){function plotBars(datapoints,barLeft,barRight,offset,fillStyleCallback,axisx,axisy){var points=datapoints.points,ps=datapoints.pointsize;for(var i=0;i<points.length;i+=ps){if(points[i]==null)
|
||||
continue;drawBar(points[i],points[i+ 1],points[i+ 2],barLeft,barRight,offset,fillStyleCallback,axisx,axisy,ctx,series.bars.horizontal,series.bars.lineWidth);}}
|
||||
ctx.save();ctx.translate(plotOffset.left,plotOffset.top);ctx.lineWidth=series.bars.lineWidth;ctx.strokeStyle=series.color;var barLeft;switch(series.bars.align){case"left":barLeft=0;break;case"right":barLeft=-series.bars.barWidth;break;case"center":barLeft=-series.bars.barWidth/2;break;default:throw new Error("Invalid bar alignment: "+ series.bars.align);}
|
||||
var fillStyleCallback=series.bars.fill?function(bottom,top){return getFillStyle(series.bars,series.color,bottom,top);}:null;plotBars(series.datapoints,barLeft,barLeft+ series.bars.barWidth,0,fillStyleCallback,series.xaxis,series.yaxis);ctx.restore();}
|
||||
function getFillStyle(filloptions,seriesColor,bottom,top){var fill=filloptions.fill;if(!fill)
|
||||
return null;if(filloptions.fillColor)
|
||||
return getColorOrGradient(filloptions.fillColor,bottom,top,seriesColor);var c=$.color.parse(seriesColor);c.a=typeof fill=="number"?fill:0.4;c.normalize();return c.toString();}
|
||||
function insertLegend(){placeholder.find(".legend").remove();if(!options.legend.show)
|
||||
return;var fragments=[],entries=[],rowStarted=false,lf=options.legend.labelFormatter,s,label;for(var i=0;i<series.length;++i){s=series[i];if(s.label){label=lf?lf(s.label,s):s.label;if(label){entries.push({label:label,color:s.color});}}}
|
||||
if(options.legend.sorted){if($.isFunction(options.legend.sorted)){entries.sort(options.legend.sorted);}else if(options.legend.sorted=="reverse"){entries.reverse();}else{var ascending=options.legend.sorted!="descending";entries.sort(function(a,b){return a.label==b.label?0:((a.label<b.label)!=ascending?1:-1);});}}
|
||||
for(var i=0;i<entries.length;++i){var entry=entries[i];if(i%options.legend.noColumns==0){if(rowStarted)
|
||||
fragments.push('</tr>');fragments.push('<tr>');rowStarted=true;}
|
||||
fragments.push('<td class="legendColorBox"><div style="border:1px solid '+ options.legend.labelBoxBorderColor+';padding:1px"><div style="width:4px;height:0;border:5px solid '+ entry.color+';overflow:hidden"></div></div></td>'+'<td class="legendLabel">'+ entry.label+'</td>');}
|
||||
if(rowStarted)
|
||||
fragments.push('</tr>');if(fragments.length==0)
|
||||
return;var table='<table style="font-size:smaller;color:'+ options.grid.color+'">'+ fragments.join("")+'</table>';if(options.legend.container!=null)
|
||||
$(options.legend.container).html(table);else{var pos="",p=options.legend.position,m=options.legend.margin;if(m[0]==null)
|
||||
m=[m,m];if(p.charAt(0)=="n")
|
||||
pos+='top:'+(m[1]+ plotOffset.top)+'px;';else if(p.charAt(0)=="s")
|
||||
pos+='bottom:'+(m[1]+ plotOffset.bottom)+'px;';if(p.charAt(1)=="e")
|
||||
pos+='right:'+(m[0]+ plotOffset.right)+'px;';else if(p.charAt(1)=="w")
|
||||
pos+='left:'+(m[0]+ plotOffset.left)+'px;';var legend=$('<div class="legend">'+ table.replace('style="','style="position:absolute;'+ pos+';')+'</div>').appendTo(placeholder);if(options.legend.backgroundOpacity!=0.0){var c=options.legend.backgroundColor;if(c==null){c=options.grid.backgroundColor;if(c&&typeof c=="string")
|
||||
c=$.color.parse(c);else
|
||||
c=$.color.extract(legend,'background-color');c.a=1;c=c.toString();}
|
||||
var div=legend.children();$('<div style="position:absolute;width:'+ div.width()+'px;height:'+ div.height()+'px;'+ pos+'background-color:'+ c+';"> </div>').prependTo(legend).css('opacity',options.legend.backgroundOpacity);}}}
|
||||
var highlights=[],redrawTimeout=null;function findNearbyItem(mouseX,mouseY,seriesFilter){var maxDistance=options.grid.mouseActiveRadius,smallestDistance=maxDistance*maxDistance+ 1,item=null,foundPoint=false,i,j,ps;for(i=series.length- 1;i>=0;--i){if(!seriesFilter(series[i]))
|
||||
continue;var s=series[i],axisx=s.xaxis,axisy=s.yaxis,points=s.datapoints.points,mx=axisx.c2p(mouseX),my=axisy.c2p(mouseY),maxx=maxDistance/axisx.scale,maxy=maxDistance/axisy.scale;ps=s.datapoints.pointsize;if(axisx.options.inverseTransform)
|
||||
maxx=Number.MAX_VALUE;if(axisy.options.inverseTransform)
|
||||
maxy=Number.MAX_VALUE;if(s.lines.show||s.points.show){for(j=0;j<points.length;j+=ps){var x=points[j],y=points[j+ 1];if(x==null)
|
||||
continue;if(x- mx>maxx||x- mx<-maxx||y- my>maxy||y- my<-maxy)
|
||||
continue;var dx=Math.abs(axisx.p2c(x)- mouseX),dy=Math.abs(axisy.p2c(y)- mouseY),dist=dx*dx+ dy*dy;if(dist<smallestDistance){smallestDistance=dist;item=[i,j/ps];}}}
|
||||
if(s.bars.show&&!item){var barLeft=s.bars.align=="left"?0:-s.bars.barWidth/2,barRight=barLeft+ s.bars.barWidth;for(j=0;j<points.length;j+=ps){var x=points[j],y=points[j+ 1],b=points[j+ 2];if(x==null)
|
||||
continue;if(series[i].bars.horizontal?(mx<=Math.max(b,x)&&mx>=Math.min(b,x)&&my>=y+ barLeft&&my<=y+ barRight):(mx>=x+ barLeft&&mx<=x+ barRight&&my>=Math.min(b,y)&&my<=Math.max(b,y)))
|
||||
item=[i,j/ps];}}}
|
||||
if(item){i=item[0];j=item[1];ps=series[i].datapoints.pointsize;return{datapoint:series[i].datapoints.points.slice(j*ps,(j+ 1)*ps),dataIndex:j,series:series[i],seriesIndex:i};}
|
||||
return null;}
|
||||
function onMouseMove(e){if(options.grid.hoverable)
|
||||
triggerClickHoverEvent("plothover",e,function(s){return s["hoverable"]!=false;});}
|
||||
function onMouseLeave(e){if(options.grid.hoverable)
|
||||
triggerClickHoverEvent("plothover",e,function(s){return false;});}
|
||||
function onClick(e){triggerClickHoverEvent("plotclick",e,function(s){return s["clickable"]!=false;});}
|
||||
function triggerClickHoverEvent(eventname,event,seriesFilter){var offset=eventHolder.offset(),canvasX=event.pageX- offset.left- plotOffset.left,canvasY=event.pageY- offset.top- plotOffset.top,pos=canvasToAxisCoords({left:canvasX,top:canvasY});pos.pageX=event.pageX;pos.pageY=event.pageY;var item=findNearbyItem(canvasX,canvasY,seriesFilter);if(item){item.pageX=parseInt(item.series.xaxis.p2c(item.datapoint[0])+ offset.left+ plotOffset.left,10);item.pageY=parseInt(item.series.yaxis.p2c(item.datapoint[1])+ offset.top+ plotOffset.top,10);}
|
||||
if(options.grid.autoHighlight){for(var i=0;i<highlights.length;++i){var h=highlights[i];if(h.auto==eventname&&!(item&&h.series==item.series&&h.point[0]==item.datapoint[0]&&h.point[1]==item.datapoint[1]))
|
||||
unhighlight(h.series,h.point);}
|
||||
if(item)
|
||||
highlight(item.series,item.datapoint,eventname);}
|
||||
placeholder.trigger(eventname,[pos,item]);}
|
||||
function triggerRedrawOverlay(){var t=options.interaction.redrawOverlayInterval;if(t==-1){drawOverlay();return;}
|
||||
if(!redrawTimeout)
|
||||
redrawTimeout=setTimeout(drawOverlay,t);}
|
||||
function drawOverlay(){redrawTimeout=null;octx.save();overlay.clear();octx.translate(plotOffset.left,plotOffset.top);var i,hi;for(i=0;i<highlights.length;++i){hi=highlights[i];if(hi.series.bars.show)
|
||||
drawBarHighlight(hi.series,hi.point);else
|
||||
drawPointHighlight(hi.series,hi.point);}
|
||||
octx.restore();executeHooks(hooks.drawOverlay,[octx]);}
|
||||
function highlight(s,point,auto){if(typeof s=="number")
|
||||
s=series[s];if(typeof point=="number"){var ps=s.datapoints.pointsize;point=s.datapoints.points.slice(ps*point,ps*(point+ 1));}
|
||||
var i=indexOfHighlight(s,point);if(i==-1){highlights.push({series:s,point:point,auto:auto});triggerRedrawOverlay();}
|
||||
else if(!auto)
|
||||
highlights[i].auto=false;}
|
||||
function unhighlight(s,point){if(s==null&&point==null){highlights=[];triggerRedrawOverlay();return;}
|
||||
if(typeof s=="number")
|
||||
s=series[s];if(typeof point=="number"){var ps=s.datapoints.pointsize;point=s.datapoints.points.slice(ps*point,ps*(point+ 1));}
|
||||
var i=indexOfHighlight(s,point);if(i!=-1){highlights.splice(i,1);triggerRedrawOverlay();}}
|
||||
function indexOfHighlight(s,p){for(var i=0;i<highlights.length;++i){var h=highlights[i];if(h.series==s&&h.point[0]==p[0]&&h.point[1]==p[1])
|
||||
return i;}
|
||||
return-1;}
|
||||
function drawPointHighlight(series,point){var x=point[0],y=point[1],axisx=series.xaxis,axisy=series.yaxis,highlightColor=(typeof series.highlightColor==="string")?series.highlightColor:$.color.parse(series.color).scale('a',0.5).toString();if(x<axisx.min||x>axisx.max||y<axisy.min||y>axisy.max)
|
||||
return;var pointRadius=series.points.radius+ series.points.lineWidth/2;octx.lineWidth=pointRadius;octx.strokeStyle=highlightColor;var radius=1.5*pointRadius;x=axisx.p2c(x);y=axisy.p2c(y);octx.beginPath();if(series.points.symbol=="circle")
|
||||
octx.arc(x,y,radius,0,2*Math.PI,false);else
|
||||
series.points.symbol(octx,x,y,radius,false);octx.closePath();octx.stroke();}
|
||||
function drawBarHighlight(series,point){var highlightColor=(typeof series.highlightColor==="string")?series.highlightColor:$.color.parse(series.color).scale('a',0.5).toString(),fillStyle=highlightColor,barLeft=series.bars.align=="left"?0:-series.bars.barWidth/2;octx.lineWidth=series.bars.lineWidth;octx.strokeStyle=highlightColor;drawBar(point[0],point[1],point[2]||0,barLeft,barLeft+ series.bars.barWidth,0,function(){return fillStyle;},series.xaxis,series.yaxis,octx,series.bars.horizontal,series.bars.lineWidth);}
|
||||
function getColorOrGradient(spec,bottom,top,defaultColor){if(typeof spec=="string")
|
||||
return spec;else{var gradient=ctx.createLinearGradient(0,top,0,bottom);for(var i=0,l=spec.colors.length;i<l;++i){var c=spec.colors[i];if(typeof c!="string"){var co=$.color.parse(defaultColor);if(c.brightness!=null)
|
||||
co=co.scale('rgb',c.brightness);if(c.opacity!=null)
|
||||
co.a*=c.opacity;c=co.toString();}
|
||||
gradient.addColorStop(i/(l- 1),c);}
|
||||
return gradient;}}}
|
||||
$.plot=function(placeholder,data,options){var plot=new Plot($(placeholder),data,options,$.plot.plugins);return plot;};$.plot.version="0.8.1";$.plot.plugins=[];$.fn.plot=function(data,options){return this.each(function(){$.plot(this,data,options);});};function floorInBase(n,base){return base*Math.floor(n/base);}})(jQuery);
|
||||
29
web/static/plugs/flot/jquery.flot.min.js
vendored
Normal file
26
web/static/plugs/flot/jquery.flot.orderBars.js
Normal file
@@ -0,0 +1,26 @@
|
||||
(function($){function init(plot){var orderedBarSeries;var nbOfBarsToOrder;var borderWidth;var borderWidthInXabsWidth;var pixelInXWidthEquivalent=1;var isHorizontal=false;function reOrderBars(plot,serie,datapoints){var shiftedPoints=null;if(serieNeedToBeReordered(serie)){checkIfGraphIsHorizontal(serie);calculPixel2XWidthConvert(plot);retrieveBarSeries(plot);calculBorderAndBarWidth(serie);if(nbOfBarsToOrder>=2){var position=findPosition(serie);var decallage=0;var centerBarShift=calculCenterBarShift();if(isBarAtLeftOfCenter(position)){decallage=-1*(sumWidth(orderedBarSeries,position-1,Math.floor(nbOfBarsToOrder/2)-1))- centerBarShift;}else{decallage=sumWidth(orderedBarSeries,Math.ceil(nbOfBarsToOrder/2),position-2)+ centerBarShift+ borderWidthInXabsWidth*2;}
|
||||
shiftedPoints=shiftPoints(datapoints,serie,decallage);datapoints.points=shiftedPoints;}}
|
||||
return shiftedPoints;}
|
||||
function serieNeedToBeReordered(serie){return serie.bars!=null&&serie.bars.show&&serie.bars.order!=null;}
|
||||
function calculPixel2XWidthConvert(plot){var gridDimSize=isHorizontal?plot.getPlaceholder().innerHeight():plot.getPlaceholder().innerWidth();var minMaxValues=isHorizontal?getAxeMinMaxValues(plot.getData(),1):getAxeMinMaxValues(plot.getData(),0);var AxeSize=minMaxValues[1]- minMaxValues[0];pixelInXWidthEquivalent=AxeSize/gridDimSize;}
|
||||
function getAxeMinMaxValues(series,AxeIdx){var minMaxValues=new Array();for(var i=0;i<series.length;i++){minMaxValues[0]=series[i].data[0][AxeIdx];minMaxValues[1]=series[i].data[series[i].data.length- 1][AxeIdx];}
|
||||
return minMaxValues;}
|
||||
function retrieveBarSeries(plot){orderedBarSeries=findOthersBarsToReOrders(plot.getData());nbOfBarsToOrder=orderedBarSeries.length;}
|
||||
function findOthersBarsToReOrders(series){var retSeries=new Array();for(var i=0;i<series.length;i++){if(series[i].bars.order!=null&&series[i].bars.show){retSeries.push(series[i]);}}
|
||||
return retSeries.sort(sortByOrder);}
|
||||
function sortByOrder(serie1,serie2){var x=serie1.bars.order;var y=serie2.bars.order;return((x<y)?-1:((x>y)?1:0));}
|
||||
function calculBorderAndBarWidth(serie){borderWidth=serie.bars.lineWidth?serie.bars.lineWidth:2;borderWidthInXabsWidth=borderWidth*pixelInXWidthEquivalent;}
|
||||
function checkIfGraphIsHorizontal(serie){if(serie.bars.horizontal){isHorizontal=true;}}
|
||||
function findPosition(serie){var pos=0
|
||||
for(var i=0;i<orderedBarSeries.length;++i){if(serie==orderedBarSeries[i]){pos=i;break;}}
|
||||
return pos+1;}
|
||||
function calculCenterBarShift(){var width=0;if(nbOfBarsToOrder%2!=0)
|
||||
width=(orderedBarSeries[Math.ceil(nbOfBarsToOrder/2)].bars.barWidth)/2;
|
||||
return width;}
|
||||
function isBarAtLeftOfCenter(position){return position<=Math.ceil(nbOfBarsToOrder/2);}
|
||||
function sumWidth(series,start,end){var totalWidth=0;for(var i=start;i<=end;i++){totalWidth+=series[i].bars.barWidth+borderWidthInXabsWidth*2;}
|
||||
return totalWidth;}
|
||||
function shiftPoints(datapoints,serie,dx){var ps=datapoints.pointsize;var points=datapoints.points;var j=0;for(var i=isHorizontal?1:0;i<points.length;i+=ps){points[i]+=dx;serie.data[j][3]=points[i];j++;}
|
||||
return points;}
|
||||
plot.hooks.processDatapoints.push(reOrderBars);}
|
||||
var options={series:{bars:{order:null}}};$.plot.plugins.push({init:init,options:options,name:"orderBars",version:"0.2"});})(jQuery);
|
||||
56
web/static/plugs/flot/jquery.flot.pie.min.js
vendored
Normal file
19
web/static/plugs/flot/jquery.flot.resize.min.js
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/* Flot plugin for automatically redrawing plots as the placeholder resizes.
|
||||
|
||||
Copyright (c) 2007-2013 IOLA and Ole Laursen.
|
||||
Licensed under the MIT license.
|
||||
|
||||
It works by listening for changes on the placeholder div (through the jQuery
|
||||
resize event plugin) - if the size changes, it will redraw the plot.
|
||||
|
||||
There are no options. If you need to disable the plugin for some plots, you
|
||||
can just fix the size of their placeholders.
|
||||
|
||||
*//* Inline dependency:
|
||||
* jQuery resize event - v1.1 - 3/14/2010
|
||||
* http://benalman.com/projects/jquery-resize-plugin/
|
||||
*
|
||||
* Copyright (c) 2010 "Cowboy" Ben Alman
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* http://benalman.com/about/license/
|
||||
*/(function(e,t,n){function c(){s=t[o](function(){r.each(function(){var t=e(this),n=t.width(),r=t.height(),i=e.data(this,a);(n!==i.w||r!==i.h)&&t.trigger(u,[i.w=n,i.h=r])}),c()},i[f])}var r=e([]),i=e.resize=e.extend(e.resize,{}),s,o="setTimeout",u="resize",a=u+"-special-event",f="delay",l="throttleWindow";i[f]=250,i[l]=!0,e.event.special[u]={setup:function(){if(!i[l]&&this[o])return!1;var t=e(this);r=r.add(t),e.data(this,a,{w:t.width(),h:t.height()}),r.length===1&&c()},teardown:function(){if(!i[l]&&this[o])return!1;var t=e(this);r=r.not(t),t.removeData(a),r.length||clearTimeout(s)},add:function(t){function s(t,i,s){var o=e(this),u=e.data(this,a);u.w=i!==n?i:o.width(),u.h=s!==n?s:o.height(),r.apply(this,arguments)}if(!i[l]&&this[o])return!1;var r;if(e.isFunction(t))return r=t,s;r=t.handler,t.handler=s}}})(jQuery,this),function(e){function n(e){function t(){var t=e.getPlaceholder();if(t.width()==0||t.height()==0)return;e.resize(),e.setupGrid(),e.draw()}function n(e,n){e.getPlaceholder().resize(t)}function r(e,n){e.getPlaceholder().unbind("resize",t)}e.hooks.bindEvents.push(n),e.hooks.shutdown.push(r)}var t={};e.plot.plugins.push({init:n,options:t,name:"resize",version:"1.0"})}(jQuery);
|
||||
36
web/static/plugs/flot/jquery.flot.stack.min.js
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/* Flot plugin for stacking data sets rather than overlyaing them.
|
||||
|
||||
Copyright (c) 2007-2013 IOLA and Ole Laursen.
|
||||
Licensed under the MIT license.
|
||||
|
||||
The plugin assumes the data is sorted on x (or y if stacking horizontally).
|
||||
For line charts, it is assumed that if a line has an undefined gap (from a
|
||||
null point), then the line above it should have the same gap - insert zeros
|
||||
instead of "null" if you want another behaviour. This also holds for the start
|
||||
and end of the chart. Note that stacking a mix of positive and negative values
|
||||
in most instances doesn't make sense (so it looks weird).
|
||||
|
||||
Two or more series are stacked when their "stack" attribute is set to the same
|
||||
key (which can be any number or string or just "true"). To specify the default
|
||||
stack, you can set the stack option like this:
|
||||
|
||||
series: {
|
||||
stack: null/false, true, or a key (number/string)
|
||||
}
|
||||
|
||||
You can also specify it for a single series, like this:
|
||||
|
||||
$.plot( $("#placeholder"), [{
|
||||
data: [ ... ],
|
||||
stack: true
|
||||
}])
|
||||
|
||||
The stacking order is determined by the order of the data series in the array
|
||||
(later series end up on top of the previous).
|
||||
|
||||
Internally, the plugin modifies the datapoints in each series, adding an
|
||||
offset to the y value. For line series, extra data points are inserted through
|
||||
interpolation. If there's a second y value, it's also adjusted (e.g for bar
|
||||
charts or filled areas).
|
||||
|
||||
*/(function(e){function n(e){function t(e,t){var n=null;for(var r=0;r<t.length;++r){if(e==t[r])break;t[r].stack==e.stack&&(n=t[r])}return n}function n(e,n,r){if(n.stack==null||n.stack===!1)return;var i=t(n,e.getData());if(!i)return;var s=r.pointsize,o=r.points,u=i.datapoints.pointsize,a=i.datapoints.points,f=[],l,c,h,p,d,v,m=n.lines.show,g=n.bars.horizontal,y=s>2&&(g?r.format[2].x:r.format[2].y),b=m&&n.lines.steps,w=!0,E=g?1:0,S=g?0:1,x=0,T=0,N,C;for(;;){if(x>=o.length)break;N=f.length;if(o[x]==null){for(C=0;C<s;++C)f.push(o[x+C]);x+=s}else if(T>=a.length){if(!m)for(C=0;C<s;++C)f.push(o[x+C]);x+=s}else if(a[T]==null){for(C=0;C<s;++C)f.push(null);w=!0,T+=u}else{l=o[x+E],c=o[x+S],p=a[T+E],d=a[T+S],v=0;if(l==p){for(C=0;C<s;++C)f.push(o[x+C]);f[N+S]+=d,v=d,x+=s,T+=u}else if(l>p){if(m&&x>0&&o[x-s]!=null){h=c+(o[x-s+S]-c)*(p-l)/(o[x-s+E]-l),f.push(p),f.push(h+d);for(C=2;C<s;++C)f.push(o[x+C]);v=d}T+=u}else{if(w&&m){x+=s;continue}for(C=0;C<s;++C)f.push(o[x+C]);m&&T>0&&a[T-u]!=null&&(v=d+(a[T-u+S]-d)*(l-p)/(a[T-u+E]-p)),f[N+S]+=v,x+=s}w=!1,N!=f.length&&y&&(f[N+2]+=v)}if(b&&N!=f.length&&N>0&&f[N]!=null&&f[N]!=f[N-s]&&f[N+1]!=f[N-s+1]){for(C=0;C<s;++C)f[N+s+C]=f[N+C];f[N+1]=f[N-s+1]}}r.points=f}e.hooks.processDatapoints.push(n)}var t={series:{stack:null}};e.plot.plugins.push({init:n,options:t,name:"stack",version:"1.2"})})(jQuery);
|
||||
15
web/static/plugs/flot/jquery.flot.threshold.js
Normal file
@@ -0,0 +1,15 @@
|
||||
(function($){var options={series:{threshold:null}};function init(plot){function thresholdData(plot,s,datapoints,below,color){var ps=datapoints.pointsize,i,x,y,p,prevp,thresholded=$.extend({},s);thresholded.datapoints={points:[],pointsize:ps,format:datapoints.format};thresholded.label=null;thresholded.color=color;thresholded.threshold=null;thresholded.originSeries=s;thresholded.data=[];var origpoints=datapoints.points,addCrossingPoints=s.lines.show;var threspoints=[];var newpoints=[];var m;for(i=0;i<origpoints.length;i+=ps){x=origpoints[i];y=origpoints[i+ 1];prevp=p;if(y<below)
|
||||
p=threspoints;else
|
||||
p=newpoints;if(addCrossingPoints&&prevp!=p&&x!=null&&i>0&&origpoints[i- ps]!=null){var interx=x+(below- y)*(x- origpoints[i- ps])/ (y - origpoints[i - ps + 1]);
|
||||
prevp.push(interx);prevp.push(below);for(m=2;m<ps;++m)
|
||||
prevp.push(origpoints[i+ m]);p.push(null);p.push(null);for(m=2;m<ps;++m)
|
||||
p.push(origpoints[i+ m]);p.push(interx);p.push(below);for(m=2;m<ps;++m)
|
||||
p.push(origpoints[i+ m]);}
|
||||
p.push(x);p.push(y);for(m=2;m<ps;++m)
|
||||
p.push(origpoints[i+ m]);}
|
||||
datapoints.points=newpoints;thresholded.datapoints.points=threspoints;if(thresholded.datapoints.points.length>0){var origIndex=$.inArray(s,plot.getData());plot.getData().splice(origIndex+ 1,0,thresholded);}}
|
||||
function processThresholds(plot,s,datapoints){if(!s.threshold)
|
||||
return;if(s.threshold instanceof Array){s.threshold.sort(function(a,b){return a.below- b.below;});$(s.threshold).each(function(i,th){thresholdData(plot,s,datapoints,th.below,th.color);});}
|
||||
else{thresholdData(plot,s,datapoints,s.threshold.below,s.threshold.color);}}
|
||||
plot.hooks.processDatapoints.push(processThresholds);}
|
||||
$.plot.plugins.push({init:init,options:options,name:'threshold',version:'1.2'});})(jQuery);
|
||||
9
web/static/plugs/flot/jquery.flot.time.min.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/* Pretty handling of time axes.
|
||||
|
||||
Copyright (c) 2007-2013 IOLA and Ole Laursen.
|
||||
Licensed under the MIT license.
|
||||
|
||||
Set axis.mode to "time" to enable. See the section "Time series data" in
|
||||
API.txt for details.
|
||||
|
||||
*/(function(e){function n(e,t){return t*Math.floor(e/t)}function r(e,t,n,r){if(typeof e.strftime=="function")return e.strftime(t);var i=function(e,t){return e=""+e,t=""+(t==null?"0":t),e.length==1?t+e:e},s=[],o=!1,u=e.getHours(),a=u<12;n==null&&(n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),r==null&&(r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]);var f;u>12?f=u-12:u==0?f=12:f=u;for(var l=0;l<t.length;++l){var c=t.charAt(l);if(o){switch(c){case"a":c=""+r[e.getDay()];break;case"b":c=""+n[e.getMonth()];break;case"d":c=i(e.getDate());break;case"e":c=i(e.getDate()," ");break;case"h":case"H":c=i(u);break;case"I":c=i(f);break;case"l":c=i(f," ");break;case"m":c=i(e.getMonth()+1);break;case"M":c=i(e.getMinutes());break;case"q":c=""+(Math.floor(e.getMonth()/3)+1);break;case"S":c=i(e.getSeconds());break;case"y":c=i(e.getFullYear()%100);break;case"Y":c=""+e.getFullYear();break;case"p":c=a?"am":"pm";break;case"P":c=a?"AM":"PM";break;case"w":c=""+e.getDay()}s.push(c),o=!1}else c=="%"?o=!0:s.push(c)}return s.join("")}function i(e){function t(e,t,n,r){e[t]=function(){return n[r].apply(n,arguments)}}var n={date:e};e.strftime!=undefined&&t(n,"strftime",e,"strftime"),t(n,"getTime",e,"getTime"),t(n,"setTime",e,"setTime");var r=["Date","Day","FullYear","Hours","Milliseconds","Minutes","Month","Seconds"];for(var i=0;i<r.length;i++)t(n,"get"+r[i],e,"getUTC"+r[i]),t(n,"set"+r[i],e,"setUTC"+r[i]);return n}function s(e,t){if(t.timezone=="browser")return new Date(e);if(!t.timezone||t.timezone=="utc")return i(new Date(e));if(typeof timezoneJS!="undefined"&&typeof timezoneJS.Date!="undefined"){var n=new timezoneJS.Date;return n.setTimezone(t.timezone),n.setTime(e),n}return i(new Date(e))}function l(t){t.hooks.processOptions.push(function(t,i){e.each(t.getAxes(),function(e,t){var i=t.options;i.mode=="time"&&(t.tickGenerator=function(e){var t=[],r=s(e.min,i),u=0,l=i.tickSize&&i.tickSize[1]==="quarter"||i.minTickSize&&i.minTickSize[1]==="quarter"?f:a;i.minTickSize!=null&&(typeof i.tickSize=="number"?u=i.tickSize:u=i.minTickSize[0]*o[i.minTickSize[1]]);for(var c=0;c<l.length-1;++c)if(e.delta<(l[c][0]*o[l[c][1]]+l[c+1][0]*o[l[c+1][1]])/2&&l[c][0]*o[l[c][1]]>=u)break;var h=l[c][0],p=l[c][1];if(p=="year"){if(i.minTickSize!=null&&i.minTickSize[1]=="year")h=Math.floor(i.minTickSize[0]);else{var d=Math.pow(10,Math.floor(Math.log(e.delta/o.year)/Math.LN10)),v=e.delta/o.year/d;v<1.5?h=1:v<3?h=2:v<7.5?h=5:h=10,h*=d}h<1&&(h=1)}e.tickSize=i.tickSize||[h,p];var m=e.tickSize[0];p=e.tickSize[1];var g=m*o[p];p=="second"?r.setSeconds(n(r.getSeconds(),m)):p=="minute"?r.setMinutes(n(r.getMinutes(),m)):p=="hour"?r.setHours(n(r.getHours(),m)):p=="month"?r.setMonth(n(r.getMonth(),m)):p=="quarter"?r.setMonth(3*n(r.getMonth()/3,m)):p=="year"&&r.setFullYear(n(r.getFullYear(),m)),r.setMilliseconds(0),g>=o.minute&&r.setSeconds(0),g>=o.hour&&r.setMinutes(0),g>=o.day&&r.setHours(0),g>=o.day*4&&r.setDate(1),g>=o.month*2&&r.setMonth(n(r.getMonth(),3)),g>=o.quarter*2&&r.setMonth(n(r.getMonth(),6)),g>=o.year&&r.setMonth(0);var y=0,b=Number.NaN,w;do{w=b,b=r.getTime(),t.push(b);if(p=="month"||p=="quarter")if(m<1){r.setDate(1);var E=r.getTime();r.setMonth(r.getMonth()+(p=="quarter"?3:1));var S=r.getTime();r.setTime(b+y*o.hour+(S-E)*m),y=r.getHours(),r.setHours(0)}else r.setMonth(r.getMonth()+m*(p=="quarter"?3:1));else p=="year"?r.setFullYear(r.getFullYear()+m):r.setTime(b+g)}while(b<e.max&&b!=w);return t},t.tickFormatter=function(e,t){var n=s(e,t.options);if(i.timeformat!=null)return r(n,i.timeformat,i.monthNames,i.dayNames);var u=t.options.tickSize&&t.options.tickSize[1]=="quarter"||t.options.minTickSize&&t.options.minTickSize[1]=="quarter",a=t.tickSize[0]*o[t.tickSize[1]],f=t.max-t.min,l=i.twelveHourClock?" %p":"",c=i.twelveHourClock?"%I":"%H",h;a<o.minute?h=c+":%M:%S"+l:a<o.day?f<2*o.day?h=c+":%M"+l:h="%b %d "+c+":%M"+l:a<o.month?h="%b %d":u&&a<o.quarter||!u&&a<o.year?f<o.year?h="%b":h="%b %Y":u&&a<o.year?f<o.year?h="Q%q":h="Q%q %Y":h="%Y";var p=r(n,h,i.monthNames,i.dayNames);return p})})})}var t={xaxis:{timezone:null,timeformat:null,twelveHourClock:!1,monthNames:null}},o={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,quarter:7776e6,year:525949.2*60*1e3},u=[[1,"second"],[2,"second"],[5,"second"],[10,"second"],[30,"second"],[1,"minute"],[2,"minute"],[5,"minute"],[10,"minute"],[30,"minute"],[1,"hour"],[2,"hour"],[4,"hour"],[8,"hour"],[12,"hour"],[1,"day"],[2,"day"],[3,"day"],[.25,"month"],[.5,"month"],[1,"month"],[2,"month"]],a=u.concat([[3,"month"],[6,"month"],[1,"year"]]),f=u.concat([[1,"quarter"],[2,"quarter"],[1,"year"]]);e.plot.plugins.push({init:l,options:t,name:"time",version:"1.0"}),e.plot.formatDate=r})(jQuery);
|
||||
2
web/static/plugs/layer/layer.js
Normal file
2
web/static/plugs/layer/mobile/layer.js
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! layer mobile-v2.0 弹层组件移动版 License LGPL http://layer.layui.com/mobile By 贤心 */
|
||||
;!function(a){"use strict";var b=document,c="querySelectorAll",d="getElementsByClassName",e=function(a){return b[c](a)},f={type:0,shade:!0,shadeClose:!0,fixed:!0,anim:"scale"},g={extend:function(a){var b=JSON.parse(JSON.stringify(f));for(var c in a)b[c]=a[c];return b},timer:{},end:{}};g.touch=function(a,b){a.addEventListener("click",function(a){b.call(this,a)},!1)};var h=0,i=["layui-m-layer"],j=function(a){var b=this;b.config=g.extend(a),b.view()};j.prototype.view=function(){var a=this,c=a.config,f=b.createElement("div");a.id=f.id=i[0]+h,f.setAttribute("class",i[0]+" "+i[0]+(c.type||0)),f.setAttribute("index",h);var g=function(){var a="object"==typeof c.title;return c.title?'<h3 style="'+(a?c.title[1]:"")+'">'+(a?c.title[0]:c.title)+"</h3>":""}(),j=function(){"string"==typeof c.btn&&(c.btn=[c.btn]);var a,b=(c.btn||[]).length;return 0!==b&&c.btn?(a='<span yes type="1">'+c.btn[0]+"</span>",2===b&&(a='<span no type="0">'+c.btn[1]+"</span>"+a),'<div class="layui-m-layerbtn">'+a+"</div>"):""}();if(c.fixed||(c.top=c.hasOwnProperty("top")?c.top:100,c.style=c.style||"",c.style+=" top:"+(b.body.scrollTop+c.top)+"px"),2===c.type&&(c.content='<i></i><i class="layui-m-layerload"></i><i></i><p>'+(c.content||"")+"</p>"),c.skin&&(c.anim="up"),"msg"===c.skin&&(c.shade=!1),f.innerHTML=(c.shade?"<div "+("string"==typeof c.shade?'style="'+c.shade+'"':"")+' class="layui-m-layershade"></div>':"")+'<div class="layui-m-layermain" '+(c.fixed?"":'style="position:static;"')+'><div class="layui-m-layersection"><div class="layui-m-layerchild '+(c.skin?"layui-m-layer-"+c.skin+" ":"")+(c.className?c.className:"")+" "+(c.anim?"layui-m-anim-"+c.anim:"")+'" '+(c.style?'style="'+c.style+'"':"")+">"+g+'<div class="layui-m-layercont">'+c.content+"</div>"+j+"</div></div></div>",!c.type||2===c.type){var k=b[d](i[0]+c.type),l=k.length;l>=1&&layer.close(k[0].getAttribute("index"))}document.body.appendChild(f);var m=a.elem=e("#"+a.id)[0];c.success&&c.success(m),a.index=h++,a.action(c,m)},j.prototype.action=function(a,b){var c=this;a.time&&(g.timer[c.index]=setTimeout(function(){layer.close(c.index)},1e3*a.time));var e=function(){var b=this.getAttribute("type");0==b?(a.no&&a.no(),layer.close(c.index)):a.yes?a.yes(c.index):layer.close(c.index)};if(a.btn)for(var f=b[d]("layui-m-layerbtn")[0].children,h=f.length,i=0;h>i;i++)g.touch(f[i],e);if(a.shade&&a.shadeClose){var j=b[d]("layui-m-layershade")[0];g.touch(j,function(){layer.close(c.index,a.end)})}a.end&&(g.end[c.index]=a.end)},a.layer={v:"2.0",index:h,open:function(a){var b=new j(a||{});return b.index},close:function(a){var c=e("#"+i[0]+a)[0];c&&(c.innerHTML="",b.body.removeChild(c),clearTimeout(g.timer[a]),delete g.timer[a],"function"==typeof g.end[a]&&g.end[a](),delete g.end[a])},closeAll:function(){for(var a=b[d](i[0]),c=0,e=a.length;e>c;c++)layer.close(0|a[0].getAttribute("index"))}},"function"==typeof define?define(function(){return layer}):function(){var a=document.scripts,c=a[a.length-1],d=c.src,e=d.substring(0,d.lastIndexOf("/")+1);c.getAttribute("merge")||document.head.appendChild(function(){var a=b.createElement("link");return a.href=e+"need/layer.css?2.0",a.type="text/css",a.rel="styleSheet",a.id="layermcss",a}())}()}(window);
|
||||
1
web/static/plugs/layer/mobile/need/layer.css
Normal file
BIN
web/static/plugs/layer/skin/default/icon-ext.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
web/static/plugs/layer/skin/default/icon.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
web/static/plugs/layer/skin/default/loading-0.gif
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
web/static/plugs/layer/skin/default/loading-1.gif
Normal file
|
After Width: | Height: | Size: 701 B |
BIN
web/static/plugs/layer/skin/default/loading-2.gif
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
7
web/static/plugs/layer/skin/layer.css
Normal file
55
web/static/plugs/tagsinput/bootstrap-tagsinput.css
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
.bootstrap-tagsinput {
|
||||
background-color: #fff;
|
||||
border: 1px solid #ccc;
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
display: inline-block;
|
||||
padding: 4px 6px;
|
||||
color: #555;
|
||||
vertical-align: middle;
|
||||
border-radius: 4px;
|
||||
max-width: 100%;
|
||||
line-height: 22px;
|
||||
cursor: text;
|
||||
}
|
||||
.bootstrap-tagsinput input {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
outline: none;
|
||||
background-color: transparent;
|
||||
padding: 0 6px;
|
||||
margin: 0;
|
||||
width: auto;
|
||||
max-width: inherit;
|
||||
}
|
||||
.bootstrap-tagsinput.form-control input::-moz-placeholder {
|
||||
color: #777;
|
||||
opacity: 1;
|
||||
}
|
||||
.bootstrap-tagsinput.form-control input:-ms-input-placeholder {
|
||||
color: #777;
|
||||
}
|
||||
.bootstrap-tagsinput.form-control input::-webkit-input-placeholder {
|
||||
color: #777;
|
||||
}
|
||||
.bootstrap-tagsinput input:focus {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.bootstrap-tagsinput .tag {
|
||||
margin-right: 2px;
|
||||
color: white;
|
||||
}
|
||||
.bootstrap-tagsinput .tag [data-role="remove"] {
|
||||
margin-left: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.bootstrap-tagsinput .tag [data-role="remove"]:after {
|
||||
content: "x";
|
||||
padding: 0px 2px;
|
||||
}
|
||||
.bootstrap-tagsinput .tag [data-role="remove"]:hover {
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
.bootstrap-tagsinput .tag [data-role="remove"]:hover:active {
|
||||
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
|
||||
}
|
||||
673
web/static/plugs/tagsinput/bootstrap-tagsinput.js
vendored
Normal file
@@ -0,0 +1,673 @@
|
||||
(function ($) {
|
||||
"use strict";
|
||||
|
||||
var defaultOptions = {
|
||||
tagClass: function(item) {
|
||||
return 'label label-info';
|
||||
},
|
||||
focusClass: 'focus',
|
||||
itemValue: function(item) {
|
||||
return item ? item.toString() : item;
|
||||
},
|
||||
itemText: function(item) {
|
||||
return this.itemValue(item);
|
||||
},
|
||||
itemTitle: function(item) {
|
||||
return null;
|
||||
},
|
||||
freeInput: true,
|
||||
addOnBlur: true,
|
||||
maxTags: undefined,
|
||||
maxChars: undefined,
|
||||
confirmKeys: [13, 44],
|
||||
delimiter: ',',
|
||||
delimiterRegex: null,
|
||||
cancelConfirmKeysOnEmpty: false,
|
||||
onTagExists: function(item, $tag) {
|
||||
$tag.hide().fadeIn();
|
||||
},
|
||||
trimValue: false,
|
||||
allowDuplicates: false
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor function
|
||||
*/
|
||||
function TagsInput(element, options) {
|
||||
this.isInit = true;
|
||||
this.itemsArray = [];
|
||||
|
||||
this.$element = $(element);
|
||||
this.$element.hide();
|
||||
|
||||
this.isSelect = (element.tagName === 'SELECT');
|
||||
this.multiple = (this.isSelect && element.hasAttribute('multiple'));
|
||||
this.objectItems = options && options.itemValue;
|
||||
this.placeholderText = element.hasAttribute('placeholder') ? this.$element.attr('placeholder') : '';
|
||||
this.inputSize = Math.max(1, this.placeholderText.length);
|
||||
|
||||
this.$container = $('<div class="bootstrap-tagsinput"></div>');
|
||||
this.$input = $('<input type="text" placeholder="' + this.placeholderText + '"/>').appendTo(this.$container);
|
||||
|
||||
this.$element.before(this.$container);
|
||||
|
||||
this.build(options);
|
||||
this.isInit = false;
|
||||
}
|
||||
|
||||
TagsInput.prototype = {
|
||||
constructor: TagsInput,
|
||||
|
||||
/**
|
||||
* Adds the given item as a new tag. Pass true to dontPushVal to prevent
|
||||
* updating the elements val()
|
||||
*/
|
||||
add: function(item, dontPushVal, options) {
|
||||
var self = this;
|
||||
|
||||
if (self.options.maxTags && self.itemsArray.length >= self.options.maxTags)
|
||||
return;
|
||||
|
||||
// Ignore falsey values, except false
|
||||
if (item !== false && !item)
|
||||
return;
|
||||
|
||||
// Trim value
|
||||
if (typeof item === "string" && self.options.trimValue) {
|
||||
item = $.trim(item);
|
||||
}
|
||||
|
||||
// Throw an error when trying to add an object while the itemValue option was not set
|
||||
if (typeof item === "object" && !self.objectItems)
|
||||
throw("Can't add objects when itemValue option is not set");
|
||||
|
||||
// Ignore strings only containg whitespace
|
||||
if (item.toString().match(/^\s*$/))
|
||||
return;
|
||||
|
||||
// If SELECT but not multiple, remove current tag
|
||||
if (self.isSelect && !self.multiple && self.itemsArray.length > 0)
|
||||
self.remove(self.itemsArray[0]);
|
||||
|
||||
if (typeof item === "string" && this.$element[0].tagName === 'INPUT') {
|
||||
var delimiter = (self.options.delimiterRegex) ? self.options.delimiterRegex : self.options.delimiter;
|
||||
var items = item.split(delimiter);
|
||||
if (items.length > 1) {
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
this.add(items[i], true);
|
||||
}
|
||||
|
||||
if (!dontPushVal)
|
||||
self.pushVal();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var itemValue = self.options.itemValue(item),
|
||||
itemText = self.options.itemText(item),
|
||||
tagClass = self.options.tagClass(item),
|
||||
itemTitle = self.options.itemTitle(item);
|
||||
|
||||
// Ignore items allready added
|
||||
var existing = $.grep(self.itemsArray, function(item) { return self.options.itemValue(item) === itemValue; } )[0];
|
||||
if (existing && !self.options.allowDuplicates) {
|
||||
// Invoke onTagExists
|
||||
if (self.options.onTagExists) {
|
||||
var $existingTag = $(".tag", self.$container).filter(function() { return $(this).data("item") === existing; });
|
||||
self.options.onTagExists(item, $existingTag);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// if length greater than limit
|
||||
if (self.items().toString().length + item.length + 1 > self.options.maxInputLength)
|
||||
return;
|
||||
|
||||
// raise beforeItemAdd arg
|
||||
var beforeItemAddEvent = $.Event('beforeItemAdd', { item: item, cancel: false, options: options});
|
||||
self.$element.trigger(beforeItemAddEvent);
|
||||
if (beforeItemAddEvent.cancel)
|
||||
return;
|
||||
|
||||
// register item in internal array and map
|
||||
self.itemsArray.push(item);
|
||||
|
||||
// add a tag element
|
||||
|
||||
var $tag = $('<span class="tag ' + htmlEncode(tagClass) + (itemTitle !== null ? ('" title="' + itemTitle) : '') + '">' + htmlEncode(itemText) + '<span data-role="remove"></span></span>');
|
||||
$tag.data('item', item);
|
||||
self.findInputWrapper().before($tag);
|
||||
$tag.after(' ');
|
||||
|
||||
// Check to see if the tag exists in its raw or uri-encoded form
|
||||
var optionExists = (
|
||||
$('option[value="' + encodeURIComponent(itemValue) + '"]', self.$element).length ||
|
||||
$('option[value="' + htmlEncode(itemValue) + '"]', self.$element).length
|
||||
);
|
||||
|
||||
// add <option /> if item represents a value not present in one of the <select />'s options
|
||||
if (self.isSelect && !optionExists) {
|
||||
var $option = $('<option selected>' + htmlEncode(itemText) + '</option>');
|
||||
$option.data('item', item);
|
||||
$option.attr('value', itemValue);
|
||||
self.$element.append($option);
|
||||
}
|
||||
|
||||
if (!dontPushVal)
|
||||
self.pushVal();
|
||||
|
||||
// Add class when reached maxTags
|
||||
if (self.options.maxTags === self.itemsArray.length || self.items().toString().length === self.options.maxInputLength)
|
||||
self.$container.addClass('bootstrap-tagsinput-max');
|
||||
|
||||
// If using typeahead, once the tag has been added, clear the typeahead value so it does not stick around in the input.
|
||||
if ($('.typeahead, .twitter-typeahead', self.$container).length) {
|
||||
self.$input.typeahead('val', '');
|
||||
}
|
||||
|
||||
if (this.isInit) {
|
||||
self.$element.trigger($.Event('itemAddedOnInit', { item: item, options: options }));
|
||||
} else {
|
||||
self.$element.trigger($.Event('itemAdded', { item: item, options: options }));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the given item. Pass true to dontPushVal to prevent updating the
|
||||
* elements val()
|
||||
*/
|
||||
remove: function(item, dontPushVal, options) {
|
||||
var self = this;
|
||||
|
||||
if (self.objectItems) {
|
||||
if (typeof item === "object")
|
||||
item = $.grep(self.itemsArray, function(other) { return self.options.itemValue(other) == self.options.itemValue(item); } );
|
||||
else
|
||||
item = $.grep(self.itemsArray, function(other) { return self.options.itemValue(other) == item; } );
|
||||
|
||||
item = item[item.length-1];
|
||||
}
|
||||
|
||||
if (item) {
|
||||
var beforeItemRemoveEvent = $.Event('beforeItemRemove', { item: item, cancel: false, options: options });
|
||||
self.$element.trigger(beforeItemRemoveEvent);
|
||||
if (beforeItemRemoveEvent.cancel)
|
||||
return;
|
||||
|
||||
$('.tag', self.$container).filter(function() { return $(this).data('item') === item; }).remove();
|
||||
$('option', self.$element).filter(function() { return $(this).data('item') === item; }).remove();
|
||||
if($.inArray(item, self.itemsArray) !== -1)
|
||||
self.itemsArray.splice($.inArray(item, self.itemsArray), 1);
|
||||
}
|
||||
|
||||
if (!dontPushVal)
|
||||
self.pushVal();
|
||||
|
||||
// Remove class when reached maxTags
|
||||
if (self.options.maxTags > self.itemsArray.length)
|
||||
self.$container.removeClass('bootstrap-tagsinput-max');
|
||||
|
||||
self.$element.trigger($.Event('itemRemoved', { item: item, options: options }));
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes all items
|
||||
*/
|
||||
removeAll: function() {
|
||||
var self = this;
|
||||
|
||||
$('.tag', self.$container).remove();
|
||||
$('option', self.$element).remove();
|
||||
|
||||
while(self.itemsArray.length > 0)
|
||||
self.itemsArray.pop();
|
||||
|
||||
self.pushVal();
|
||||
},
|
||||
|
||||
/**
|
||||
* Refreshes the tags so they match the text/value of their corresponding
|
||||
* item.
|
||||
*/
|
||||
refresh: function() {
|
||||
var self = this;
|
||||
$('.tag', self.$container).each(function() {
|
||||
var $tag = $(this),
|
||||
item = $tag.data('item'),
|
||||
itemValue = self.options.itemValue(item),
|
||||
itemText = self.options.itemText(item),
|
||||
tagClass = self.options.tagClass(item);
|
||||
|
||||
// Update tag's class and inner text
|
||||
$tag.attr('class', null);
|
||||
$tag.addClass('tag ' + htmlEncode(tagClass));
|
||||
$tag.contents().filter(function() {
|
||||
return this.nodeType == 3;
|
||||
})[0].nodeValue = htmlEncode(itemText);
|
||||
|
||||
if (self.isSelect) {
|
||||
var option = $('option', self.$element).filter(function() { return $(this).data('item') === item; });
|
||||
option.attr('value', itemValue);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the items added as tags
|
||||
*/
|
||||
items: function() {
|
||||
return this.itemsArray;
|
||||
},
|
||||
|
||||
/**
|
||||
* Assembly value by retrieving the value of each item, and set it on the
|
||||
* element.
|
||||
*/
|
||||
pushVal: function() {
|
||||
var self = this,
|
||||
val = $.map(self.items(), function(item) {
|
||||
return self.options.itemValue(item).toString();
|
||||
});
|
||||
|
||||
self.$element.val(val, true).trigger('change');
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the tags input behaviour on the element
|
||||
*/
|
||||
build: function(options) {
|
||||
var self = this;
|
||||
|
||||
self.options = $.extend({}, defaultOptions, options);
|
||||
// When itemValue is set, freeInput should always be false
|
||||
if (self.objectItems)
|
||||
self.options.freeInput = false;
|
||||
|
||||
makeOptionItemFunction(self.options, 'itemValue');
|
||||
makeOptionItemFunction(self.options, 'itemText');
|
||||
makeOptionFunction(self.options, 'tagClass');
|
||||
|
||||
// Typeahead Bootstrap version 2.3.2
|
||||
if (self.options.typeahead) {
|
||||
var typeahead = self.options.typeahead || {};
|
||||
|
||||
makeOptionFunction(typeahead, 'source');
|
||||
|
||||
self.$input.typeahead($.extend({}, typeahead, {
|
||||
source: function (query, process) {
|
||||
function processItems(items) {
|
||||
var texts = [];
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var text = self.options.itemText(items[i]);
|
||||
map[text] = items[i];
|
||||
texts.push(text);
|
||||
}
|
||||
process(texts);
|
||||
}
|
||||
|
||||
this.map = {};
|
||||
var map = this.map,
|
||||
data = typeahead.source(query);
|
||||
|
||||
if ($.isFunction(data.success)) {
|
||||
// support for Angular callbacks
|
||||
data.success(processItems);
|
||||
} else if ($.isFunction(data.then)) {
|
||||
// support for Angular promises
|
||||
data.then(processItems);
|
||||
} else {
|
||||
// support for functions and jquery promises
|
||||
$.when(data)
|
||||
.then(processItems);
|
||||
}
|
||||
},
|
||||
updater: function (text) {
|
||||
self.add(this.map[text]);
|
||||
return this.map[text];
|
||||
},
|
||||
matcher: function (text) {
|
||||
return (text.toLowerCase().indexOf(this.query.trim().toLowerCase()) !== -1);
|
||||
},
|
||||
sorter: function (texts) {
|
||||
return texts.sort();
|
||||
},
|
||||
highlighter: function (text) {
|
||||
var regex = new RegExp( '(' + this.query + ')', 'gi' );
|
||||
return text.replace( regex, "<strong>$1</strong>" );
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
// typeahead.js
|
||||
if (self.options.typeaheadjs) {
|
||||
var typeaheadConfig = null;
|
||||
var typeaheadDatasets = {};
|
||||
|
||||
// Determine if main configurations were passed or simply a dataset
|
||||
var typeaheadjs = self.options.typeaheadjs;
|
||||
if ($.isArray(typeaheadjs)) {
|
||||
typeaheadConfig = typeaheadjs[0];
|
||||
typeaheadDatasets = typeaheadjs[1];
|
||||
} else {
|
||||
typeaheadDatasets = typeaheadjs;
|
||||
}
|
||||
|
||||
self.$input.typeahead(typeaheadConfig, typeaheadDatasets).on('typeahead:selected', $.proxy(function (obj, datum) {
|
||||
if (typeaheadDatasets.valueKey)
|
||||
self.add(datum[typeaheadDatasets.valueKey]);
|
||||
else
|
||||
self.add(datum);
|
||||
self.$input.typeahead('val', '');
|
||||
}, self));
|
||||
}
|
||||
|
||||
self.$container.on('click', $.proxy(function(event) {
|
||||
if (! self.$element.attr('disabled')) {
|
||||
self.$input.removeAttr('disabled');
|
||||
}
|
||||
self.$input.focus();
|
||||
}, self));
|
||||
|
||||
if (self.options.addOnBlur && self.options.freeInput) {
|
||||
self.$input.on('focusout', $.proxy(function(event) {
|
||||
// HACK: only process on focusout when no typeahead opened, to
|
||||
// avoid adding the typeahead text as tag
|
||||
if ($('.typeahead, .twitter-typeahead', self.$container).length === 0) {
|
||||
self.add(self.$input.val());
|
||||
self.$input.val('');
|
||||
}
|
||||
}, self));
|
||||
}
|
||||
|
||||
// Toggle the 'focus' css class on the container when it has focus
|
||||
self.$container.on({
|
||||
focusin: function() {
|
||||
self.$container.addClass(self.options.focusClass);
|
||||
},
|
||||
focusout: function() {
|
||||
self.$container.removeClass(self.options.focusClass);
|
||||
},
|
||||
});
|
||||
|
||||
self.$container.on('keydown', 'input', $.proxy(function(event) {
|
||||
var $input = $(event.target),
|
||||
$inputWrapper = self.findInputWrapper();
|
||||
|
||||
if (self.$element.attr('disabled')) {
|
||||
self.$input.attr('disabled', 'disabled');
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event.which) {
|
||||
// BACKSPACE
|
||||
case 8:
|
||||
if (doGetCaretPosition($input[0]) === 0) {
|
||||
var prev = $inputWrapper.prev();
|
||||
if (prev.length) {
|
||||
self.remove(prev.data('item'));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// DELETE
|
||||
case 46:
|
||||
if (doGetCaretPosition($input[0]) === 0) {
|
||||
var next = $inputWrapper.next();
|
||||
if (next.length) {
|
||||
self.remove(next.data('item'));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// LEFT ARROW
|
||||
case 37:
|
||||
// Try to move the input before the previous tag
|
||||
var $prevTag = $inputWrapper.prev();
|
||||
if ($input.val().length === 0 && $prevTag[0]) {
|
||||
$prevTag.before($inputWrapper);
|
||||
$input.focus();
|
||||
}
|
||||
break;
|
||||
// RIGHT ARROW
|
||||
case 39:
|
||||
// Try to move the input after the next tag
|
||||
var $nextTag = $inputWrapper.next();
|
||||
if ($input.val().length === 0 && $nextTag[0]) {
|
||||
$nextTag.after($inputWrapper);
|
||||
$input.focus();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// ignore
|
||||
}
|
||||
|
||||
// Reset internal input's size
|
||||
var textLength = $input.val().length,
|
||||
wordSpace = Math.ceil(textLength / 5),
|
||||
size = textLength + wordSpace + 1;
|
||||
$input.attr('size', Math.max(this.inputSize, $input.val().length));
|
||||
}, self));
|
||||
|
||||
self.$container.on('keypress', 'input', $.proxy(function(event) {
|
||||
var $input = $(event.target);
|
||||
|
||||
if (self.$element.attr('disabled')) {
|
||||
self.$input.attr('disabled', 'disabled');
|
||||
return;
|
||||
}
|
||||
|
||||
var text = $input.val(),
|
||||
maxLengthReached = self.options.maxChars && text.length >= self.options.maxChars;
|
||||
if (self.options.freeInput && (keyCombinationInList(event, self.options.confirmKeys) || maxLengthReached)) {
|
||||
// Only attempt to add a tag if there is data in the field
|
||||
if (text.length !== 0) {
|
||||
self.add(maxLengthReached ? text.substr(0, self.options.maxChars) : text);
|
||||
$input.val('');
|
||||
}
|
||||
|
||||
// If the field is empty, let the event triggered fire as usual
|
||||
if (self.options.cancelConfirmKeysOnEmpty === false) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
// Reset internal input's size
|
||||
var textLength = $input.val().length,
|
||||
wordSpace = Math.ceil(textLength / 5),
|
||||
size = textLength + wordSpace + 1;
|
||||
$input.attr('size', Math.max(this.inputSize, $input.val().length));
|
||||
}, self));
|
||||
|
||||
// Remove icon clicked
|
||||
self.$container.on('click', '[data-role=remove]', $.proxy(function(event) {
|
||||
if (self.$element.attr('disabled')) {
|
||||
return;
|
||||
}
|
||||
self.remove($(event.target).closest('.tag').data('item'));
|
||||
}, self));
|
||||
|
||||
// Only add existing value as tags when using strings as tags
|
||||
if (self.options.itemValue === defaultOptions.itemValue) {
|
||||
if (self.$element[0].tagName === 'INPUT') {
|
||||
self.add(self.$element.val());
|
||||
} else {
|
||||
$('option', self.$element).each(function() {
|
||||
self.add($(this).attr('value'), true);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes all tagsinput behaviour and unregsiter all event handlers
|
||||
*/
|
||||
destroy: function() {
|
||||
var self = this;
|
||||
|
||||
// Unbind events
|
||||
self.$container.off('keypress', 'input');
|
||||
self.$container.off('click', '[role=remove]');
|
||||
|
||||
self.$container.remove();
|
||||
self.$element.removeData('tagsinput');
|
||||
self.$element.show();
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets focus on the tagsinput
|
||||
*/
|
||||
focus: function() {
|
||||
this.$input.focus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the internal input element
|
||||
*/
|
||||
input: function() {
|
||||
return this.$input;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the element which is wrapped around the internal input. This
|
||||
* is normally the $container, but typeahead.js moves the $input element.
|
||||
*/
|
||||
findInputWrapper: function() {
|
||||
var elt = this.$input[0],
|
||||
container = this.$container[0];
|
||||
while(elt && elt.parentNode !== container)
|
||||
elt = elt.parentNode;
|
||||
|
||||
return $(elt);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Register JQuery plugin
|
||||
*/
|
||||
$.fn.tagsinput = function(arg1, arg2, arg3) {
|
||||
var results = [];
|
||||
|
||||
this.each(function() {
|
||||
var tagsinput = $(this).data('tagsinput');
|
||||
// Initialize a new tags input
|
||||
if (!tagsinput) {
|
||||
tagsinput = new TagsInput(this, arg1);
|
||||
$(this).data('tagsinput', tagsinput);
|
||||
results.push(tagsinput);
|
||||
|
||||
if (this.tagName === 'SELECT') {
|
||||
$('option', $(this)).attr('selected', 'selected');
|
||||
}
|
||||
|
||||
// Init tags from $(this).val()
|
||||
$(this).val($(this).val());
|
||||
} else if (!arg1 && !arg2) {
|
||||
// tagsinput already exists
|
||||
// no function, trying to init
|
||||
results.push(tagsinput);
|
||||
} else if(tagsinput[arg1] !== undefined) {
|
||||
// Invoke function on existing tags input
|
||||
if(tagsinput[arg1].length === 3 && arg3 !== undefined){
|
||||
var retVal = tagsinput[arg1](arg2, null, arg3);
|
||||
}else{
|
||||
var retVal = tagsinput[arg1](arg2);
|
||||
}
|
||||
if (retVal !== undefined)
|
||||
results.push(retVal);
|
||||
}
|
||||
});
|
||||
|
||||
if ( typeof arg1 == 'string') {
|
||||
// Return the results from the invoked function calls
|
||||
return results.length > 1 ? results : results[0];
|
||||
} else {
|
||||
return results;
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.tagsinput.Constructor = TagsInput;
|
||||
|
||||
/**
|
||||
* Most options support both a string or number as well as a function as
|
||||
* option value. This function makes sure that the option with the given
|
||||
* key in the given options is wrapped in a function
|
||||
*/
|
||||
function makeOptionItemFunction(options, key) {
|
||||
if (typeof options[key] !== 'function') {
|
||||
var propertyName = options[key];
|
||||
options[key] = function(item) { return item[propertyName]; };
|
||||
}
|
||||
}
|
||||
function makeOptionFunction(options, key) {
|
||||
if (typeof options[key] !== 'function') {
|
||||
var value = options[key];
|
||||
options[key] = function() { return value; };
|
||||
}
|
||||
}
|
||||
/**
|
||||
* HtmlEncodes the given value
|
||||
*/
|
||||
var htmlEncodeContainer = $('<div />');
|
||||
function htmlEncode(value) {
|
||||
if (value) {
|
||||
return htmlEncodeContainer.text(value).html();
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the position of the caret in the given input field
|
||||
* http://flightschool.acylt.com/devnotes/caret-position-woes/
|
||||
*/
|
||||
function doGetCaretPosition(oField) {
|
||||
var iCaretPos = 0;
|
||||
if (document.selection) {
|
||||
oField.focus ();
|
||||
var oSel = document.selection.createRange();
|
||||
oSel.moveStart ('character', -oField.value.length);
|
||||
iCaretPos = oSel.text.length;
|
||||
} else if (oField.selectionStart || oField.selectionStart == '0') {
|
||||
iCaretPos = oField.selectionStart;
|
||||
}
|
||||
return (iCaretPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns boolean indicates whether user has pressed an expected key combination.
|
||||
* @param object keyPressEvent: JavaScript event object, refer
|
||||
* http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
||||
* @param object lookupList: expected key combinations, as in:
|
||||
* [13, {which: 188, shiftKey: true}]
|
||||
*/
|
||||
function keyCombinationInList(keyPressEvent, lookupList) {
|
||||
var found = false;
|
||||
$.each(lookupList, function (index, keyCombination) {
|
||||
if (typeof (keyCombination) === 'number' && keyPressEvent.which === keyCombination) {
|
||||
found = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (keyPressEvent.which === keyCombination.which) {
|
||||
var alt = !keyCombination.hasOwnProperty('altKey') || keyPressEvent.altKey === keyCombination.altKey,
|
||||
shift = !keyCombination.hasOwnProperty('shiftKey') || keyPressEvent.shiftKey === keyCombination.shiftKey,
|
||||
ctrl = !keyCombination.hasOwnProperty('ctrlKey') || keyPressEvent.ctrlKey === keyCombination.ctrlKey;
|
||||
if (alt && shift && ctrl) {
|
||||
found = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize tagsinput behaviour on inputs and selects which have
|
||||
* data-role=tagsinput
|
||||
*/
|
||||
$(function() {
|
||||
$("input[data-role=tagsinput], select[multiple][data-role=tagsinput]").tagsinput();
|
||||
});
|
||||
})(window.jQuery);
|
||||
40
web/static/plugs/ueditor/dialogs/anchor/anchor.html
Normal file
@@ -0,0 +1,40 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<title></title>
|
||||
<style type="text/css">
|
||||
*{color: #838383;margin: 0;padding: 0}
|
||||
html,body {font-size: 12px;overflow: hidden; }
|
||||
.content{padding:5px 0 0 15px;}
|
||||
input{width:210px;height:21px;line-height:21px;margin-left: 4px;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<span><var id="lang_input_anchorName"></var></span><input id="anchorName" value="" />
|
||||
</div>
|
||||
<script type="text/javascript" src="../internal.js"></script>
|
||||
<script type="text/javascript">
|
||||
var anchorInput = $G('anchorName'),
|
||||
node = editor.selection.getRange().getClosedNode();
|
||||
if(node && node.tagName == 'IMG' && (node = node.getAttribute('anchorname'))){
|
||||
anchorInput.value = node;
|
||||
}
|
||||
anchorInput.onkeydown = function(evt){
|
||||
evt = evt || window.event;
|
||||
if(evt.keyCode == 13){
|
||||
editor.execCommand('anchor', anchorInput.value);
|
||||
dialog.close();
|
||||
domUtils.preventDefault(evt)
|
||||
}
|
||||
};
|
||||
dialog.onok = function (){
|
||||
editor.execCommand('anchor', anchorInput.value);
|
||||
dialog.close();
|
||||
};
|
||||
$focus(anchorInput);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
681
web/static/plugs/ueditor/dialogs/attachment/attachment.css
Normal file
@@ -0,0 +1,681 @@
|
||||
@charset "utf-8";
|
||||
/* dialog样式 */
|
||||
.wrapper {
|
||||
zoom: 1;
|
||||
width: 630px;
|
||||
*width: 626px;
|
||||
height: 380px;
|
||||
margin: 0 auto;
|
||||
padding: 10px;
|
||||
position: relative;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
/*tab样式框大小*/
|
||||
.tabhead {
|
||||
float:left;
|
||||
}
|
||||
.tabbody {
|
||||
width: 100%;
|
||||
height: 346px;
|
||||
position: relative;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.tabbody .panel {
|
||||
position: absolute;
|
||||
width: 0;
|
||||
height: 0;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tabbody .panel.focus {
|
||||
width: 100%;
|
||||
height: 346px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* 上传附件 */
|
||||
.tabbody #upload.panel {
|
||||
width: 0;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
position: absolute !important;
|
||||
clip: rect(1px, 1px, 1px, 1px);
|
||||
background: #fff;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.tabbody #upload.panel.focus {
|
||||
width: 100%;
|
||||
height: 346px;
|
||||
display: block;
|
||||
clip: auto;
|
||||
}
|
||||
|
||||
#upload .queueList {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#upload p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.element-invisible {
|
||||
width: 0 !important;
|
||||
height: 0 !important;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
position: absolute !important;
|
||||
clip: rect(1px, 1px, 1px, 1px);
|
||||
}
|
||||
|
||||
#upload .placeholder {
|
||||
margin: 10px;
|
||||
border: 2px dashed #e6e6e6;
|
||||
*border: 0px dashed #e6e6e6;
|
||||
height: 172px;
|
||||
padding-top: 150px;
|
||||
text-align: center;
|
||||
background: url(./images/image.png) center 70px no-repeat;
|
||||
color: #cccccc;
|
||||
font-size: 18px;
|
||||
position: relative;
|
||||
top:0;
|
||||
*top: 10px;
|
||||
}
|
||||
|
||||
#upload .placeholder .webuploader-pick {
|
||||
font-size: 18px;
|
||||
background: #00b7ee;
|
||||
border-radius: 3px;
|
||||
line-height: 44px;
|
||||
padding: 0 30px;
|
||||
*width: 120px;
|
||||
color: #fff;
|
||||
display: inline-block;
|
||||
margin: 0 auto 20px auto;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
#upload .placeholder .webuploader-pick-hover {
|
||||
background: #00a2d4;
|
||||
}
|
||||
|
||||
|
||||
#filePickerContainer {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#upload .placeholder .flashTip {
|
||||
color: #666666;
|
||||
font-size: 12px;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
bottom: 20px;
|
||||
}
|
||||
|
||||
#upload .placeholder .flashTip a {
|
||||
color: #0785d1;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#upload .placeholder .flashTip a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#upload .placeholder.webuploader-dnd-over {
|
||||
border-color: #999999;
|
||||
}
|
||||
|
||||
#upload .filelist {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
position: relative;
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
#upload .filelist:after {
|
||||
content: '';
|
||||
display: block;
|
||||
width: 0;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
#upload .filelist li {
|
||||
width: 113px;
|
||||
height: 113px;
|
||||
background: url(./images/bg.png);
|
||||
text-align: center;
|
||||
margin: 9px 0 0 9px;
|
||||
*margin: 6px 0 0 6px;
|
||||
position: relative;
|
||||
display: block;
|
||||
float: left;
|
||||
overflow: hidden;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
#upload .filelist li p.log {
|
||||
position: relative;
|
||||
top: -45px;
|
||||
}
|
||||
|
||||
#upload .filelist li p.title {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
top: 5px;
|
||||
text-indent: 5px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#upload .filelist li p.progress {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
height: 8px;
|
||||
overflow: hidden;
|
||||
z-index: 50;
|
||||
margin: 0;
|
||||
border-radius: 0;
|
||||
background: none;
|
||||
-webkit-box-shadow: 0 0 0;
|
||||
}
|
||||
|
||||
#upload .filelist li p.progress span {
|
||||
display: none;
|
||||
overflow: hidden;
|
||||
width: 0;
|
||||
height: 100%;
|
||||
background: #1483d8 url(./images/progress.png) repeat-x;
|
||||
|
||||
-webit-transition: width 200ms linear;
|
||||
-moz-transition: width 200ms linear;
|
||||
-o-transition: width 200ms linear;
|
||||
-ms-transition: width 200ms linear;
|
||||
transition: width 200ms linear;
|
||||
|
||||
-webkit-animation: progressmove 2s linear infinite;
|
||||
-moz-animation: progressmove 2s linear infinite;
|
||||
-o-animation: progressmove 2s linear infinite;
|
||||
-ms-animation: progressmove 2s linear infinite;
|
||||
animation: progressmove 2s linear infinite;
|
||||
|
||||
-webkit-transform: translateZ(0);
|
||||
}
|
||||
|
||||
@-webkit-keyframes progressmove {
|
||||
0% {
|
||||
background-position: 0 0;
|
||||
}
|
||||
100% {
|
||||
background-position: 17px 0;
|
||||
}
|
||||
}
|
||||
|
||||
@-moz-keyframes progressmove {
|
||||
0% {
|
||||
background-position: 0 0;
|
||||
}
|
||||
100% {
|
||||
background-position: 17px 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes progressmove {
|
||||
0% {
|
||||
background-position: 0 0;
|
||||
}
|
||||
100% {
|
||||
background-position: 17px 0;
|
||||
}
|
||||
}
|
||||
|
||||
#upload .filelist li p.imgWrap {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
line-height: 113px;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
width: 113px;
|
||||
height: 113px;
|
||||
|
||||
-webkit-transform-origin: 50% 50%;
|
||||
-moz-transform-origin: 50% 50%;
|
||||
-o-transform-origin: 50% 50%;
|
||||
-ms-transform-origin: 50% 50%;
|
||||
transform-origin: 50% 50%;
|
||||
|
||||
-webit-transition: 200ms ease-out;
|
||||
-moz-transition: 200ms ease-out;
|
||||
-o-transition: 200ms ease-out;
|
||||
-ms-transition: 200ms ease-out;
|
||||
transition: 200ms ease-out;
|
||||
}
|
||||
#upload .filelist li p.imgWrap.notimage {
|
||||
margin-top: 0;
|
||||
width: 111px;
|
||||
height: 111px;
|
||||
border: 1px #eeeeee solid;
|
||||
}
|
||||
#upload .filelist li p.imgWrap.notimage i.file-preview {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
#upload .filelist li img {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#upload .filelist li p.error {
|
||||
background: #f43838;
|
||||
color: #fff;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
width: 100%;
|
||||
z-index: 100;
|
||||
display:none;
|
||||
}
|
||||
|
||||
#upload .filelist li .success {
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
height: 40px;
|
||||
width: 100%;
|
||||
z-index: 200;
|
||||
background: url(./images/success.png) no-repeat right bottom;
|
||||
background-image: url(./images/success.gif) \9;
|
||||
}
|
||||
|
||||
#upload .filelist li.filePickerBlock {
|
||||
width: 113px;
|
||||
height: 113px;
|
||||
background: url(./images/image.png) no-repeat center 12px;
|
||||
border: 1px solid #eeeeee;
|
||||
border-radius: 0;
|
||||
}
|
||||
#upload .filelist li.filePickerBlock div.webuploader-pick {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
opacity: 0;
|
||||
background: none;
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
#upload .filelist div.file-panel {
|
||||
position: absolute;
|
||||
height: 0;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#80000000', endColorstr='#80000000') \0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
width: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
overflow: hidden;
|
||||
z-index: 300;
|
||||
}
|
||||
|
||||
#upload .filelist div.file-panel span {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: inline;
|
||||
float: right;
|
||||
text-indent: -9999px;
|
||||
overflow: hidden;
|
||||
background: url(./images/icons.png) no-repeat;
|
||||
background: url(./images/icons.gif) no-repeat \9;
|
||||
margin: 5px 1px 1px;
|
||||
cursor: pointer;
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
#upload .filelist div.file-panel span.rotateLeft {
|
||||
display:none;
|
||||
background-position: 0 -24px;
|
||||
}
|
||||
|
||||
#upload .filelist div.file-panel span.rotateLeft:hover {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
#upload .filelist div.file-panel span.rotateRight {
|
||||
display:none;
|
||||
background-position: -24px -24px;
|
||||
}
|
||||
|
||||
#upload .filelist div.file-panel span.rotateRight:hover {
|
||||
background-position: -24px 0;
|
||||
}
|
||||
|
||||
#upload .filelist div.file-panel span.cancel {
|
||||
background-position: -48px -24px;
|
||||
}
|
||||
|
||||
#upload .filelist div.file-panel span.cancel:hover {
|
||||
background-position: -48px 0;
|
||||
}
|
||||
|
||||
#upload .statusBar {
|
||||
height: 45px;
|
||||
border-bottom: 1px solid #dadada;
|
||||
margin: 0 10px;
|
||||
padding: 0;
|
||||
line-height: 45px;
|
||||
vertical-align: middle;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#upload .statusBar .progress {
|
||||
border: 1px solid #1483d8;
|
||||
width: 198px;
|
||||
background: #fff;
|
||||
height: 18px;
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
display: none;
|
||||
text-align: center;
|
||||
line-height: 18px;
|
||||
color: #6dbfff;
|
||||
margin: 0 10px 0 0;
|
||||
}
|
||||
#upload .statusBar .progress span.percentage {
|
||||
width: 0;
|
||||
height: 100%;
|
||||
left: 0;
|
||||
top: 0;
|
||||
background: #1483d8;
|
||||
position: absolute;
|
||||
}
|
||||
#upload .statusBar .progress span.text {
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
#upload .statusBar .info {
|
||||
display: inline-block;
|
||||
font-size: 14px;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
#upload .statusBar .btns {
|
||||
position: absolute;
|
||||
top: 7px;
|
||||
right: 0;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
#filePickerBtn {
|
||||
display: inline-block;
|
||||
float: left;
|
||||
}
|
||||
#upload .statusBar .btns .webuploader-pick,
|
||||
#upload .statusBar .btns .uploadBtn,
|
||||
#upload .statusBar .btns .uploadBtn.state-uploading,
|
||||
#upload .statusBar .btns .uploadBtn.state-paused {
|
||||
background: #ffffff;
|
||||
border: 1px solid #cfcfcf;
|
||||
color: #565656;
|
||||
padding: 0 18px;
|
||||
display: inline-block;
|
||||
border-radius: 3px;
|
||||
margin-left: 10px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
float: left;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
#upload .statusBar .btns .webuploader-pick-hover,
|
||||
#upload .statusBar .btns .uploadBtn:hover,
|
||||
#upload .statusBar .btns .uploadBtn.state-uploading:hover,
|
||||
#upload .statusBar .btns .uploadBtn.state-paused:hover {
|
||||
background: #f0f0f0;
|
||||
}
|
||||
|
||||
#upload .statusBar .btns .uploadBtn,
|
||||
#upload .statusBar .btns .uploadBtn.state-paused{
|
||||
background: #00b7ee;
|
||||
color: #fff;
|
||||
border-color: transparent;
|
||||
}
|
||||
#upload .statusBar .btns .uploadBtn:hover,
|
||||
#upload .statusBar .btns .uploadBtn.state-paused:hover{
|
||||
background: #00a2d4;
|
||||
}
|
||||
|
||||
#upload .statusBar .btns .uploadBtn.disabled {
|
||||
pointer-events: none;
|
||||
filter:alpha(opacity=60);
|
||||
-moz-opacity:0.6;
|
||||
-khtml-opacity: 0.6;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 图片管理样式 */
|
||||
#online {
|
||||
width: 100%;
|
||||
height: 336px;
|
||||
padding: 10px 0 0 0;
|
||||
}
|
||||
#online #fileList{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
position: relative;
|
||||
}
|
||||
#online ul {
|
||||
display: block;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#online li {
|
||||
float: left;
|
||||
display: block;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
width: 113px;
|
||||
height: 113px;
|
||||
margin: 0 0 9px 9px;
|
||||
*margin: 0 0 6px 6px;
|
||||
background-color: #eee;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
}
|
||||
#online li.clearFloat {
|
||||
float: none;
|
||||
clear: both;
|
||||
display: block;
|
||||
width:0;
|
||||
height:0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#online li img {
|
||||
cursor: pointer;
|
||||
}
|
||||
#online li div.file-wrapper {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
display: block;
|
||||
width: 111px;
|
||||
height: 111px;
|
||||
border: 1px solid #eee;
|
||||
background: url("./images/bg.png") repeat;
|
||||
}
|
||||
#online li div span.file-title{
|
||||
display: block;
|
||||
padding: 0 3px;
|
||||
margin: 3px 0 0 0;
|
||||
font-size: 12px;
|
||||
height: 13px;
|
||||
color: #555555;
|
||||
text-align: center;
|
||||
width: 107px;
|
||||
white-space: nowrap;
|
||||
word-break: break-all;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
#online li .icon {
|
||||
cursor: pointer;
|
||||
width: 113px;
|
||||
height: 113px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 2;
|
||||
border: 0;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
#online li .icon:hover {
|
||||
width: 107px;
|
||||
height: 107px;
|
||||
border: 3px solid #1094fa;
|
||||
}
|
||||
#online li.selected .icon {
|
||||
background-image: url(images/success.png);
|
||||
background-image: url(images/success.gif) \9;
|
||||
background-position: 75px 75px;
|
||||
}
|
||||
#online li.selected .icon:hover {
|
||||
width: 107px;
|
||||
height: 107px;
|
||||
border: 3px solid #1094fa;
|
||||
background-position: 72px 72px;
|
||||
}
|
||||
|
||||
|
||||
/* 在线文件的文件预览图标 */
|
||||
i.file-preview {
|
||||
display: block;
|
||||
margin: 10px auto;
|
||||
width: 70px;
|
||||
height: 70px;
|
||||
background-image: url("./images/file-icons.png");
|
||||
background-image: url("./images/file-icons.gif") \9;
|
||||
background-position: -140px center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
i.file-preview.file-type-dir{
|
||||
background-position: 0 center;
|
||||
}
|
||||
i.file-preview.file-type-file{
|
||||
background-position: -140px center;
|
||||
}
|
||||
i.file-preview.file-type-filelist{
|
||||
background-position: -210px center;
|
||||
}
|
||||
i.file-preview.file-type-zip,
|
||||
i.file-preview.file-type-rar,
|
||||
i.file-preview.file-type-7z,
|
||||
i.file-preview.file-type-tar,
|
||||
i.file-preview.file-type-gz,
|
||||
i.file-preview.file-type-bz2{
|
||||
background-position: -280px center;
|
||||
}
|
||||
i.file-preview.file-type-xls,
|
||||
i.file-preview.file-type-xlsx{
|
||||
background-position: -350px center;
|
||||
}
|
||||
i.file-preview.file-type-doc,
|
||||
i.file-preview.file-type-docx{
|
||||
background-position: -420px center;
|
||||
}
|
||||
i.file-preview.file-type-ppt,
|
||||
i.file-preview.file-type-pptx{
|
||||
background-position: -490px center;
|
||||
}
|
||||
i.file-preview.file-type-vsd{
|
||||
background-position: -560px center;
|
||||
}
|
||||
i.file-preview.file-type-pdf{
|
||||
background-position: -630px center;
|
||||
}
|
||||
i.file-preview.file-type-txt,
|
||||
i.file-preview.file-type-md,
|
||||
i.file-preview.file-type-json,
|
||||
i.file-preview.file-type-htm,
|
||||
i.file-preview.file-type-xml,
|
||||
i.file-preview.file-type-html,
|
||||
i.file-preview.file-type-js,
|
||||
i.file-preview.file-type-css,
|
||||
i.file-preview.file-type-php,
|
||||
i.file-preview.file-type-jsp,
|
||||
i.file-preview.file-type-asp{
|
||||
background-position: -700px center;
|
||||
}
|
||||
i.file-preview.file-type-apk{
|
||||
background-position: -770px center;
|
||||
}
|
||||
i.file-preview.file-type-exe{
|
||||
background-position: -840px center;
|
||||
}
|
||||
i.file-preview.file-type-ipa{
|
||||
background-position: -910px center;
|
||||
}
|
||||
i.file-preview.file-type-mp4,
|
||||
i.file-preview.file-type-swf,
|
||||
i.file-preview.file-type-mkv,
|
||||
i.file-preview.file-type-avi,
|
||||
i.file-preview.file-type-flv,
|
||||
i.file-preview.file-type-mov,
|
||||
i.file-preview.file-type-mpg,
|
||||
i.file-preview.file-type-mpeg,
|
||||
i.file-preview.file-type-ogv,
|
||||
i.file-preview.file-type-webm,
|
||||
i.file-preview.file-type-rm,
|
||||
i.file-preview.file-type-rmvb{
|
||||
background-position: -980px center;
|
||||
}
|
||||
i.file-preview.file-type-ogg,
|
||||
i.file-preview.file-type-wav,
|
||||
i.file-preview.file-type-wmv,
|
||||
i.file-preview.file-type-mid,
|
||||
i.file-preview.file-type-mp3{
|
||||
background-position: -1050px center;
|
||||
}
|
||||
i.file-preview.file-type-jpg,
|
||||
i.file-preview.file-type-jpeg,
|
||||
i.file-preview.file-type-gif,
|
||||
i.file-preview.file-type-bmp,
|
||||
i.file-preview.file-type-png,
|
||||
i.file-preview.file-type-psd{
|
||||
background-position: -140px center;
|
||||
}
|
||||
60
web/static/plugs/ueditor/dialogs/attachment/attachment.html
Normal file
@@ -0,0 +1,60 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>ueditor图片对话框</title>
|
||||
<script type="text/javascript" src="../internal.js"></script>
|
||||
|
||||
<!-- jquery -->
|
||||
<script type="text/javascript" src="../../third-party/jquery-1.10.2.min.js"></script>
|
||||
|
||||
<!-- webuploader -->
|
||||
<script src="../../third-party/webuploader/webuploader.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../third-party/webuploader/webuploader.css">
|
||||
|
||||
<!-- attachment dialog -->
|
||||
<link rel="stylesheet" href="attachment.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="wrapper">
|
||||
<div id="tabhead" class="tabhead">
|
||||
<span class="tab focus" data-content-id="upload"><var id="lang_tab_upload"></var></span>
|
||||
<span class="tab" data-content-id="online"><var id="lang_tab_online"></var></span>
|
||||
</div>
|
||||
<div id="tabbody" class="tabbody">
|
||||
<!-- 上传图片 -->
|
||||
<div id="upload" class="panel focus">
|
||||
<div id="queueList" class="queueList">
|
||||
<div class="statusBar element-invisible">
|
||||
<div class="progress">
|
||||
<span class="text">0%</span>
|
||||
<span class="percentage"></span>
|
||||
</div><div class="info"></div>
|
||||
<div class="btns">
|
||||
<div id="filePickerBtn"></div>
|
||||
<div class="uploadBtn"><var id="lang_start_upload"></var></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="dndArea" class="placeholder">
|
||||
<div class="filePickerContainer">
|
||||
<div id="filePickerReady"></div>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="filelist element-invisible">
|
||||
<li id="filePickerBlock" class="filePickerBlock"></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 在线图片 -->
|
||||
<div id="online" class="panel">
|
||||
<div id="fileList"><var id="lang_imgLoading"></var></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="attachment.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
754
web/static/plugs/ueditor/dialogs/attachment/attachment.js
Normal file
@@ -0,0 +1,754 @@
|
||||
/**
|
||||
* User: Jinqn
|
||||
* Date: 14-04-08
|
||||
* Time: 下午16:34
|
||||
* 上传图片对话框逻辑代码,包括tab: 远程图片/上传图片/在线图片/搜索图片
|
||||
*/
|
||||
|
||||
(function () {
|
||||
|
||||
var uploadFile,
|
||||
onlineFile;
|
||||
|
||||
window.onload = function () {
|
||||
initTabs();
|
||||
initButtons();
|
||||
};
|
||||
|
||||
/* 初始化tab标签 */
|
||||
function initTabs() {
|
||||
var tabs = $G('tabhead').children;
|
||||
for (var i = 0; i < tabs.length; i++) {
|
||||
domUtils.on(tabs[i], "click", function (e) {
|
||||
var target = e.target || e.srcElement;
|
||||
setTabFocus(target.getAttribute('data-content-id'));
|
||||
});
|
||||
}
|
||||
|
||||
setTabFocus('upload');
|
||||
}
|
||||
|
||||
/* 初始化tabbody */
|
||||
function setTabFocus(id) {
|
||||
if(!id) return;
|
||||
var i, bodyId, tabs = $G('tabhead').children;
|
||||
for (i = 0; i < tabs.length; i++) {
|
||||
bodyId = tabs[i].getAttribute('data-content-id')
|
||||
if (bodyId == id) {
|
||||
domUtils.addClass(tabs[i], 'focus');
|
||||
domUtils.addClass($G(bodyId), 'focus');
|
||||
} else {
|
||||
domUtils.removeClasses(tabs[i], 'focus');
|
||||
domUtils.removeClasses($G(bodyId), 'focus');
|
||||
}
|
||||
}
|
||||
switch (id) {
|
||||
case 'upload':
|
||||
uploadFile = uploadFile || new UploadFile('queueList');
|
||||
break;
|
||||
case 'online':
|
||||
onlineFile = onlineFile || new OnlineFile('fileList');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* 初始化onok事件 */
|
||||
function initButtons() {
|
||||
|
||||
dialog.onok = function () {
|
||||
var list = [], id, tabs = $G('tabhead').children;
|
||||
for (var i = 0; i < tabs.length; i++) {
|
||||
if (domUtils.hasClass(tabs[i], 'focus')) {
|
||||
id = tabs[i].getAttribute('data-content-id');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (id) {
|
||||
case 'upload':
|
||||
list = uploadFile.getInsertList();
|
||||
var count = uploadFile.getQueueCount();
|
||||
if (count) {
|
||||
$('.info', '#queueList').html('<span style="color:red;">' + '还有2个未上传文件'.replace(/[\d]/, count) + '</span>');
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'online':
|
||||
list = onlineFile.getInsertList();
|
||||
break;
|
||||
}
|
||||
|
||||
editor.execCommand('insertfile', list);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/* 上传附件 */
|
||||
function UploadFile(target) {
|
||||
this.$wrap = target.constructor == String ? $('#' + target) : $(target);
|
||||
this.init();
|
||||
}
|
||||
UploadFile.prototype = {
|
||||
init: function () {
|
||||
this.fileList = [];
|
||||
this.initContainer();
|
||||
this.initUploader();
|
||||
},
|
||||
initContainer: function () {
|
||||
this.$queue = this.$wrap.find('.filelist');
|
||||
},
|
||||
/* 初始化容器 */
|
||||
initUploader: function () {
|
||||
var _this = this,
|
||||
$ = jQuery, // just in case. Make sure it's not an other libaray.
|
||||
$wrap = _this.$wrap,
|
||||
// 图片容器
|
||||
$queue = $wrap.find('.filelist'),
|
||||
// 状态栏,包括进度和控制按钮
|
||||
$statusBar = $wrap.find('.statusBar'),
|
||||
// 文件总体选择信息。
|
||||
$info = $statusBar.find('.info'),
|
||||
// 上传按钮
|
||||
$upload = $wrap.find('.uploadBtn'),
|
||||
// 上传按钮
|
||||
$filePickerBtn = $wrap.find('.filePickerBtn'),
|
||||
// 上传按钮
|
||||
$filePickerBlock = $wrap.find('.filePickerBlock'),
|
||||
// 没选择文件之前的内容。
|
||||
$placeHolder = $wrap.find('.placeholder'),
|
||||
// 总体进度条
|
||||
$progress = $statusBar.find('.progress').hide(),
|
||||
// 添加的文件数量
|
||||
fileCount = 0,
|
||||
// 添加的文件总大小
|
||||
fileSize = 0,
|
||||
// 优化retina, 在retina下这个值是2
|
||||
ratio = window.devicePixelRatio || 1,
|
||||
// 缩略图大小
|
||||
thumbnailWidth = 113 * ratio,
|
||||
thumbnailHeight = 113 * ratio,
|
||||
// 可能有pedding, ready, uploading, confirm, done.
|
||||
state = '',
|
||||
// 所有文件的进度信息,key为file id
|
||||
percentages = {},
|
||||
supportTransition = (function () {
|
||||
var s = document.createElement('p').style,
|
||||
r = 'transition' in s ||
|
||||
'WebkitTransition' in s ||
|
||||
'MozTransition' in s ||
|
||||
'msTransition' in s ||
|
||||
'OTransition' in s;
|
||||
s = null;
|
||||
return r;
|
||||
})(),
|
||||
// WebUploader实例
|
||||
uploader,
|
||||
actionUrl = editor.getActionUrl(editor.getOpt('fileActionName')),
|
||||
fileMaxSize = editor.getOpt('fileMaxSize'),
|
||||
acceptExtensions = (editor.getOpt('fileAllowFiles') || []).join('').replace(/\./g, ',').replace(/^[,]/, '');;
|
||||
|
||||
if (!WebUploader.Uploader.support()) {
|
||||
$('#filePickerReady').after($('<div>').html(lang.errorNotSupport)).hide();
|
||||
return;
|
||||
} else if (!editor.getOpt('fileActionName')) {
|
||||
$('#filePickerReady').after($('<div>').html(lang.errorLoadConfig)).hide();
|
||||
return;
|
||||
}
|
||||
|
||||
uploader = _this.uploader = WebUploader.create({
|
||||
pick: {
|
||||
id: '#filePickerReady',
|
||||
label: lang.uploadSelectFile
|
||||
},
|
||||
swf: '../../third-party/webuploader/Uploader.swf',
|
||||
server: actionUrl,
|
||||
fileVal: editor.getOpt('fileFieldName'),
|
||||
duplicate: true,
|
||||
fileSingleSizeLimit: fileMaxSize,
|
||||
compress: false
|
||||
});
|
||||
uploader.addButton({
|
||||
id: '#filePickerBlock'
|
||||
});
|
||||
uploader.addButton({
|
||||
id: '#filePickerBtn',
|
||||
label: lang.uploadAddFile
|
||||
});
|
||||
|
||||
setState('pedding');
|
||||
|
||||
// 当有文件添加进来时执行,负责view的创建
|
||||
function addFile(file) {
|
||||
var $li = $('<li id="' + file.id + '">' +
|
||||
'<p class="title">' + file.name + '</p>' +
|
||||
'<p class="imgWrap"></p>' +
|
||||
'<p class="progress"><span></span></p>' +
|
||||
'</li>'),
|
||||
|
||||
$btns = $('<div class="file-panel">' +
|
||||
'<span class="cancel">' + lang.uploadDelete + '</span>' +
|
||||
'<span class="rotateRight">' + lang.uploadTurnRight + '</span>' +
|
||||
'<span class="rotateLeft">' + lang.uploadTurnLeft + '</span></div>').appendTo($li),
|
||||
$prgress = $li.find('p.progress span'),
|
||||
$wrap = $li.find('p.imgWrap'),
|
||||
$info = $('<p class="error"></p>').hide().appendTo($li),
|
||||
|
||||
showError = function (code) {
|
||||
switch (code) {
|
||||
case 'exceed_size':
|
||||
text = lang.errorExceedSize;
|
||||
break;
|
||||
case 'interrupt':
|
||||
text = lang.errorInterrupt;
|
||||
break;
|
||||
case 'http':
|
||||
text = lang.errorHttp;
|
||||
break;
|
||||
case 'not_allow_type':
|
||||
text = lang.errorFileType;
|
||||
break;
|
||||
default:
|
||||
text = lang.errorUploadRetry;
|
||||
break;
|
||||
}
|
||||
$info.text(text).show();
|
||||
};
|
||||
|
||||
if (file.getStatus() === 'invalid') {
|
||||
showError(file.statusText);
|
||||
} else {
|
||||
$wrap.text(lang.uploadPreview);
|
||||
if ('|png|jpg|jpeg|bmp|gif|'.indexOf('|'+file.ext.toLowerCase()+'|') == -1) {
|
||||
$wrap.empty().addClass('notimage').append('<i class="file-preview file-type-' + file.ext.toLowerCase() + '"></i>' +
|
||||
'<span class="file-title" title="' + file.name + '">' + file.name + '</span>');
|
||||
} else {
|
||||
if (browser.ie && browser.version <= 7) {
|
||||
$wrap.text(lang.uploadNoPreview);
|
||||
} else {
|
||||
uploader.makeThumb(file, function (error, src) {
|
||||
if (error || !src) {
|
||||
$wrap.text(lang.uploadNoPreview);
|
||||
} else {
|
||||
var $img = $('<img src="' + src + '">');
|
||||
$wrap.empty().append($img);
|
||||
$img.on('error', function () {
|
||||
$wrap.text(lang.uploadNoPreview);
|
||||
});
|
||||
}
|
||||
}, thumbnailWidth, thumbnailHeight);
|
||||
}
|
||||
}
|
||||
percentages[ file.id ] = [ file.size, 0 ];
|
||||
file.rotation = 0;
|
||||
|
||||
/* 检查文件格式 */
|
||||
if (!file.ext || acceptExtensions.indexOf(file.ext.toLowerCase()) == -1) {
|
||||
showError('not_allow_type');
|
||||
uploader.removeFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
file.on('statuschange', function (cur, prev) {
|
||||
if (prev === 'progress') {
|
||||
$prgress.hide().width(0);
|
||||
} else if (prev === 'queued') {
|
||||
$li.off('mouseenter mouseleave');
|
||||
$btns.remove();
|
||||
}
|
||||
// 成功
|
||||
if (cur === 'error' || cur === 'invalid') {
|
||||
showError(file.statusText);
|
||||
percentages[ file.id ][ 1 ] = 1;
|
||||
} else if (cur === 'interrupt') {
|
||||
showError('interrupt');
|
||||
} else if (cur === 'queued') {
|
||||
percentages[ file.id ][ 1 ] = 0;
|
||||
} else if (cur === 'progress') {
|
||||
$info.hide();
|
||||
$prgress.css('display', 'block');
|
||||
} else if (cur === 'complete') {
|
||||
}
|
||||
|
||||
$li.removeClass('state-' + prev).addClass('state-' + cur);
|
||||
});
|
||||
|
||||
$li.on('mouseenter', function () {
|
||||
$btns.stop().animate({height: 30});
|
||||
});
|
||||
$li.on('mouseleave', function () {
|
||||
$btns.stop().animate({height: 0});
|
||||
});
|
||||
|
||||
$btns.on('click', 'span', function () {
|
||||
var index = $(this).index(),
|
||||
deg;
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
uploader.removeFile(file);
|
||||
return;
|
||||
case 1:
|
||||
file.rotation += 90;
|
||||
break;
|
||||
case 2:
|
||||
file.rotation -= 90;
|
||||
break;
|
||||
}
|
||||
|
||||
if (supportTransition) {
|
||||
deg = 'rotate(' + file.rotation + 'deg)';
|
||||
$wrap.css({
|
||||
'-webkit-transform': deg,
|
||||
'-mos-transform': deg,
|
||||
'-o-transform': deg,
|
||||
'transform': deg
|
||||
});
|
||||
} else {
|
||||
$wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$li.insertBefore($filePickerBlock);
|
||||
}
|
||||
|
||||
// 负责view的销毁
|
||||
function removeFile(file) {
|
||||
var $li = $('#' + file.id);
|
||||
delete percentages[ file.id ];
|
||||
updateTotalProgress();
|
||||
$li.off().find('.file-panel').off().end().remove();
|
||||
}
|
||||
|
||||
function updateTotalProgress() {
|
||||
var loaded = 0,
|
||||
total = 0,
|
||||
spans = $progress.children(),
|
||||
percent;
|
||||
|
||||
$.each(percentages, function (k, v) {
|
||||
total += v[ 0 ];
|
||||
loaded += v[ 0 ] * v[ 1 ];
|
||||
});
|
||||
|
||||
percent = total ? loaded / total : 0;
|
||||
|
||||
spans.eq(0).text(Math.round(percent * 100) + '%');
|
||||
spans.eq(1).css('width', Math.round(percent * 100) + '%');
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
function setState(val, files) {
|
||||
|
||||
if (val != state) {
|
||||
|
||||
var stats = uploader.getStats();
|
||||
|
||||
$upload.removeClass('state-' + state);
|
||||
$upload.addClass('state-' + val);
|
||||
|
||||
switch (val) {
|
||||
|
||||
/* 未选择文件 */
|
||||
case 'pedding':
|
||||
$queue.addClass('element-invisible');
|
||||
$statusBar.addClass('element-invisible');
|
||||
$placeHolder.removeClass('element-invisible');
|
||||
$progress.hide(); $info.hide();
|
||||
uploader.refresh();
|
||||
break;
|
||||
|
||||
/* 可以开始上传 */
|
||||
case 'ready':
|
||||
$placeHolder.addClass('element-invisible');
|
||||
$queue.removeClass('element-invisible');
|
||||
$statusBar.removeClass('element-invisible');
|
||||
$progress.hide(); $info.show();
|
||||
$upload.text(lang.uploadStart);
|
||||
uploader.refresh();
|
||||
break;
|
||||
|
||||
/* 上传中 */
|
||||
case 'uploading':
|
||||
$progress.show(); $info.hide();
|
||||
$upload.text(lang.uploadPause);
|
||||
break;
|
||||
|
||||
/* 暂停上传 */
|
||||
case 'paused':
|
||||
$progress.show(); $info.hide();
|
||||
$upload.text(lang.uploadContinue);
|
||||
break;
|
||||
|
||||
case 'confirm':
|
||||
$progress.show(); $info.hide();
|
||||
$upload.text(lang.uploadStart);
|
||||
|
||||
stats = uploader.getStats();
|
||||
if (stats.successNum && !stats.uploadFailNum) {
|
||||
setState('finish');
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'finish':
|
||||
$progress.hide(); $info.show();
|
||||
if (stats.uploadFailNum) {
|
||||
$upload.text(lang.uploadRetry);
|
||||
} else {
|
||||
$upload.text(lang.uploadStart);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
state = val;
|
||||
updateStatus();
|
||||
|
||||
}
|
||||
|
||||
if (!_this.getQueueCount()) {
|
||||
$upload.addClass('disabled')
|
||||
} else {
|
||||
$upload.removeClass('disabled')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function updateStatus() {
|
||||
var text = '', stats;
|
||||
|
||||
if (state === 'ready') {
|
||||
text = lang.updateStatusReady.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize));
|
||||
} else if (state === 'confirm') {
|
||||
stats = uploader.getStats();
|
||||
if (stats.uploadFailNum) {
|
||||
text = lang.updateStatusConfirm.replace('_', stats.successNum).replace('_', stats.successNum);
|
||||
}
|
||||
} else {
|
||||
stats = uploader.getStats();
|
||||
text = lang.updateStatusFinish.replace('_', fileCount).
|
||||
replace('_KB', WebUploader.formatSize(fileSize)).
|
||||
replace('_', stats.successNum);
|
||||
|
||||
if (stats.uploadFailNum) {
|
||||
text += lang.updateStatusError.replace('_', stats.uploadFailNum);
|
||||
}
|
||||
}
|
||||
|
||||
$info.html(text);
|
||||
}
|
||||
|
||||
uploader.on('fileQueued', function (file) {
|
||||
fileCount++;
|
||||
fileSize += file.size;
|
||||
|
||||
if (fileCount === 1) {
|
||||
$placeHolder.addClass('element-invisible');
|
||||
$statusBar.show();
|
||||
}
|
||||
|
||||
addFile(file);
|
||||
});
|
||||
|
||||
uploader.on('fileDequeued', function (file) {
|
||||
fileCount--;
|
||||
fileSize -= file.size;
|
||||
|
||||
removeFile(file);
|
||||
updateTotalProgress();
|
||||
});
|
||||
|
||||
uploader.on('filesQueued', function (file) {
|
||||
if (!uploader.isInProgress() && (state == 'pedding' || state == 'finish' || state == 'confirm' || state == 'ready')) {
|
||||
setState('ready');
|
||||
}
|
||||
updateTotalProgress();
|
||||
});
|
||||
|
||||
uploader.on('all', function (type, files) {
|
||||
switch (type) {
|
||||
case 'uploadFinished':
|
||||
setState('confirm', files);
|
||||
break;
|
||||
case 'startUpload':
|
||||
/* 添加额外的GET参数 */
|
||||
var params = utils.serializeParam(editor.queryCommandValue('serverparam')) || '',
|
||||
url = utils.formatUrl(actionUrl + (actionUrl.indexOf('?') == -1 ? '?':'&') + 'encode=utf-8&' + params);
|
||||
uploader.option('server', url);
|
||||
setState('uploading', files);
|
||||
break;
|
||||
case 'stopUpload':
|
||||
setState('paused', files);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
uploader.on('uploadBeforeSend', function (file, data, header) {
|
||||
//这里可以通过data对象添加POST参数
|
||||
header['X_Requested_With'] = 'XMLHttpRequest';
|
||||
});
|
||||
|
||||
uploader.on('uploadProgress', function (file, percentage) {
|
||||
var $li = $('#' + file.id),
|
||||
$percent = $li.find('.progress span');
|
||||
|
||||
$percent.css('width', percentage * 100 + '%');
|
||||
percentages[ file.id ][ 1 ] = percentage;
|
||||
updateTotalProgress();
|
||||
});
|
||||
|
||||
uploader.on('uploadSuccess', function (file, ret) {
|
||||
var $file = $('#' + file.id);
|
||||
try {
|
||||
var responseText = (ret._raw || ret),
|
||||
json = utils.str2json(responseText);
|
||||
if (json.state == 'SUCCESS') {
|
||||
_this.fileList.push(json);
|
||||
$file.append('<span class="success"></span>');
|
||||
} else {
|
||||
$file.find('.error').text(json.state).show();
|
||||
}
|
||||
} catch (e) {
|
||||
$file.find('.error').text(lang.errorServerUpload).show();
|
||||
}
|
||||
});
|
||||
|
||||
uploader.on('uploadError', function (file, code) {
|
||||
});
|
||||
uploader.on('error', function (code, file) {
|
||||
if (code == 'Q_TYPE_DENIED' || code == 'F_EXCEED_SIZE') {
|
||||
addFile(file);
|
||||
}
|
||||
});
|
||||
uploader.on('uploadComplete', function (file, ret) {
|
||||
});
|
||||
|
||||
$upload.on('click', function () {
|
||||
if ($(this).hasClass('disabled')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (state === 'ready') {
|
||||
uploader.upload();
|
||||
} else if (state === 'paused') {
|
||||
uploader.upload();
|
||||
} else if (state === 'uploading') {
|
||||
uploader.stop();
|
||||
}
|
||||
});
|
||||
|
||||
$upload.addClass('state-' + state);
|
||||
updateTotalProgress();
|
||||
},
|
||||
getQueueCount: function () {
|
||||
var file, i, status, readyFile = 0, files = this.uploader.getFiles();
|
||||
for (i = 0; file = files[i++]; ) {
|
||||
status = file.getStatus();
|
||||
if (status == 'queued' || status == 'uploading' || status == 'progress') readyFile++;
|
||||
}
|
||||
return readyFile;
|
||||
},
|
||||
getInsertList: function () {
|
||||
var i, link, data, list = [],
|
||||
prefix = editor.getOpt('fileUrlPrefix');
|
||||
for (i = 0; i < this.fileList.length; i++) {
|
||||
data = this.fileList[i];
|
||||
link = data.url;
|
||||
list.push({
|
||||
title: data.original || link.substr(link.lastIndexOf('/') + 1),
|
||||
url: prefix + link
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* 在线附件 */
|
||||
function OnlineFile(target) {
|
||||
this.container = utils.isString(target) ? document.getElementById(target) : target;
|
||||
this.init();
|
||||
}
|
||||
OnlineFile.prototype = {
|
||||
init: function () {
|
||||
this.initContainer();
|
||||
this.initEvents();
|
||||
this.initData();
|
||||
},
|
||||
/* 初始化容器 */
|
||||
initContainer: function () {
|
||||
this.container.innerHTML = '';
|
||||
this.list = document.createElement('ul');
|
||||
this.clearFloat = document.createElement('li');
|
||||
|
||||
domUtils.addClass(this.list, 'list');
|
||||
domUtils.addClass(this.clearFloat, 'clearFloat');
|
||||
|
||||
this.list.appendChild(this.clearFloat);
|
||||
this.container.appendChild(this.list);
|
||||
},
|
||||
/* 初始化滚动事件,滚动到地步自动拉取数据 */
|
||||
initEvents: function () {
|
||||
var _this = this;
|
||||
|
||||
/* 滚动拉取图片 */
|
||||
domUtils.on($G('fileList'), 'scroll', function(e){
|
||||
var panel = this;
|
||||
if (panel.scrollHeight - (panel.offsetHeight + panel.scrollTop) < 10) {
|
||||
_this.getFileData();
|
||||
}
|
||||
});
|
||||
/* 选中图片 */
|
||||
domUtils.on(this.list, 'click', function (e) {
|
||||
var target = e.target || e.srcElement,
|
||||
li = target.parentNode;
|
||||
|
||||
if (li.tagName.toLowerCase() == 'li') {
|
||||
if (domUtils.hasClass(li, 'selected')) {
|
||||
domUtils.removeClasses(li, 'selected');
|
||||
} else {
|
||||
domUtils.addClass(li, 'selected');
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/* 初始化第一次的数据 */
|
||||
initData: function () {
|
||||
|
||||
/* 拉取数据需要使用的值 */
|
||||
this.state = 0;
|
||||
this.listSize = editor.getOpt('fileManagerListSize');
|
||||
this.listIndex = 0;
|
||||
this.listEnd = false;
|
||||
|
||||
/* 第一次拉取数据 */
|
||||
this.getFileData();
|
||||
},
|
||||
/* 向后台拉取图片列表数据 */
|
||||
getFileData: function () {
|
||||
var _this = this;
|
||||
|
||||
if(!_this.listEnd && !this.isLoadingData) {
|
||||
this.isLoadingData = true;
|
||||
ajax.request(editor.getActionUrl(editor.getOpt('fileManagerActionName')), {
|
||||
timeout: 100000,
|
||||
data: utils.extend({
|
||||
start: this.listIndex,
|
||||
size: this.listSize
|
||||
}, editor.queryCommandValue('serverparam')),
|
||||
method: 'get',
|
||||
onsuccess: function (r) {
|
||||
try {
|
||||
var json = eval('(' + r.responseText + ')');
|
||||
if (json.state == 'SUCCESS') {
|
||||
_this.pushData(json.list);
|
||||
_this.listIndex = parseInt(json.start) + parseInt(json.list.length);
|
||||
if(_this.listIndex >= json.total) {
|
||||
_this.listEnd = true;
|
||||
}
|
||||
_this.isLoadingData = false;
|
||||
}
|
||||
} catch (e) {
|
||||
if(r.responseText.indexOf('ue_separate_ue') != -1) {
|
||||
var list = r.responseText.split(r.responseText);
|
||||
_this.pushData(list);
|
||||
_this.listIndex = parseInt(list.length);
|
||||
_this.listEnd = true;
|
||||
_this.isLoadingData = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
onerror: function () {
|
||||
_this.isLoadingData = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
/* 添加图片到列表界面上 */
|
||||
pushData: function (list) {
|
||||
var i, item, img, filetype, preview, icon, _this = this,
|
||||
urlPrefix = editor.getOpt('fileManagerUrlPrefix');
|
||||
for (i = 0; i < list.length; i++) {
|
||||
if(list[i] && list[i].url) {
|
||||
item = document.createElement('li');
|
||||
icon = document.createElement('span');
|
||||
filetype = list[i].url.substr(list[i].url.lastIndexOf('.') + 1);
|
||||
|
||||
if ( "png|jpg|jpeg|gif|bmp".indexOf(filetype) != -1 ) {
|
||||
preview = document.createElement('img');
|
||||
domUtils.on(preview, 'load', (function(image){
|
||||
return function(){
|
||||
_this.scale(image, image.parentNode.offsetWidth, image.parentNode.offsetHeight);
|
||||
};
|
||||
})(preview));
|
||||
preview.width = 113;
|
||||
preview.setAttribute('src', urlPrefix + list[i].url + (list[i].url.indexOf('?') == -1 ? '?noCache=':'&noCache=') + (+new Date()).toString(36) );
|
||||
} else {
|
||||
var ic = document.createElement('i'),
|
||||
textSpan = document.createElement('span');
|
||||
textSpan.innerHTML = list[i].url.substr(list[i].url.lastIndexOf('/') + 1);
|
||||
preview = document.createElement('div');
|
||||
preview.appendChild(ic);
|
||||
preview.appendChild(textSpan);
|
||||
domUtils.addClass(preview, 'file-wrapper');
|
||||
domUtils.addClass(textSpan, 'file-title');
|
||||
domUtils.addClass(ic, 'file-type-' + filetype);
|
||||
domUtils.addClass(ic, 'file-preview');
|
||||
}
|
||||
domUtils.addClass(icon, 'icon');
|
||||
item.setAttribute('data-url', urlPrefix + list[i].url);
|
||||
if (list[i].original) {
|
||||
item.setAttribute('data-title', list[i].original);
|
||||
}
|
||||
|
||||
item.appendChild(preview);
|
||||
item.appendChild(icon);
|
||||
this.list.insertBefore(item, this.clearFloat);
|
||||
}
|
||||
}
|
||||
},
|
||||
/* 改变图片大小 */
|
||||
scale: function (img, w, h, type) {
|
||||
var ow = img.width,
|
||||
oh = img.height;
|
||||
|
||||
if (type == 'justify') {
|
||||
if (ow >= oh) {
|
||||
img.width = w;
|
||||
img.height = h * oh / ow;
|
||||
img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
|
||||
} else {
|
||||
img.width = w * ow / oh;
|
||||
img.height = h;
|
||||
img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
|
||||
}
|
||||
} else {
|
||||
if (ow >= oh) {
|
||||
img.width = w * ow / oh;
|
||||
img.height = h;
|
||||
img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
|
||||
} else {
|
||||
img.width = w;
|
||||
img.height = h * oh / ow;
|
||||
img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
|
||||
}
|
||||
}
|
||||
},
|
||||
getInsertList: function () {
|
||||
var i, lis = this.list.children, list = [];
|
||||
for (i = 0; i < lis.length; i++) {
|
||||
if (domUtils.hasClass(lis[i], 'selected')) {
|
||||
var url = lis[i].getAttribute('data-url');
|
||||
var title = lis[i].getAttribute('data-title') || url.substr(url.lastIndexOf('/') + 1);
|
||||
list.push({
|
||||
title: title,
|
||||
url: url
|
||||
});
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
})();
|
||||
|
After Width: | Height: | Size: 923 B |
|
After Width: | Height: | Size: 841 B |
|
After Width: | Height: | Size: 1012 B |
|
After Width: | Height: | Size: 949 B |
|
After Width: | Height: | Size: 950 B |
|
After Width: | Height: | Size: 986 B |
|
After Width: | Height: | Size: 1001 B |
|
After Width: | Height: | Size: 996 B |
|
After Width: | Height: | Size: 1001 B |
|
After Width: | Height: | Size: 1009 B |
|
After Width: | Height: | Size: 1007 B |