Repository: VIPJoey/doe Branch: master Commit: b37e58184bb1 Files: 154 Total size: 1.0 MB Directory structure: gitextract_eeqj_19b/ ├── .gitattributes ├── .gitignore ├── README.md ├── UPGRADE.md ├── deploy/ │ ├── SimpleHttpServer.py │ ├── deploy.sh │ ├── pom.xml │ └── pom.xml.backup ├── mmc-dubbo-api/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── com/ │ └── mmc/ │ └── dubbo/ │ └── api/ │ └── user/ │ ├── GenericReq.java │ ├── GenericResp.java │ ├── UserFact.java │ └── UserService.java ├── mmc-dubbo-doe/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── mmc/ │ │ │ └── dubbo/ │ │ │ └── doe/ │ │ │ ├── DubboDoeApplication.java │ │ │ ├── auth/ │ │ │ │ ├── MenuNode.java │ │ │ │ └── MenuTree.java │ │ │ ├── cache/ │ │ │ │ ├── CuratorCaches.java │ │ │ │ ├── DoeRedisResolver.java │ │ │ │ ├── MethodCaches.java │ │ │ │ ├── RedisConfiguration.java │ │ │ │ ├── RedisResolver.java │ │ │ │ └── UrlCaches.java │ │ │ ├── channel/ │ │ │ │ └── NettyChannel.java │ │ │ ├── client/ │ │ │ │ ├── DoeClient.java │ │ │ │ ├── ProcessClient.java │ │ │ │ └── TransportClient.java │ │ │ ├── context/ │ │ │ │ ├── ApplicationReadyEventListener.java │ │ │ │ ├── Const.java │ │ │ │ ├── DoeClassLoader.java │ │ │ │ ├── ResponseDispatcher.java │ │ │ │ └── TaskContainer.java │ │ │ ├── crontroller/ │ │ │ │ ├── CaseController.java │ │ │ │ ├── DubboController.java │ │ │ │ ├── HomeController.java │ │ │ │ ├── PomController.java │ │ │ │ ├── RegistryController.java │ │ │ │ └── SysConfController.java │ │ │ ├── dao/ │ │ │ │ └── CaseDAO.java │ │ │ ├── dto/ │ │ │ │ ├── BaseDTO.java │ │ │ │ ├── CaseModelDTO.java │ │ │ │ ├── ConnectDTO.java │ │ │ │ ├── MethodModelDTO.java │ │ │ │ ├── PomDTO.java │ │ │ │ ├── ResultDTO.java │ │ │ │ └── UrlModelDTO.java │ │ │ ├── exception/ │ │ │ │ └── DoeException.java │ │ │ ├── handler/ │ │ │ │ ├── CuratorHandler.java │ │ │ │ ├── SendReceiveHandler.java │ │ │ │ └── StreamHandler.java │ │ │ ├── model/ │ │ │ │ ├── CaseModel.java │ │ │ │ ├── MethodModel.java │ │ │ │ ├── PointModel.java │ │ │ │ ├── PomModel.java │ │ │ │ ├── RegistryModel.java │ │ │ │ ├── ServiceModel.java │ │ │ │ └── UrlModel.java │ │ │ ├── service/ │ │ │ │ ├── CaseService.java │ │ │ │ ├── ClassService.java │ │ │ │ ├── ConfigService.java │ │ │ │ ├── ConnectService.java │ │ │ │ ├── MenuService.java │ │ │ │ ├── PomService.java │ │ │ │ ├── TelnetService.java │ │ │ │ └── impl/ │ │ │ │ ├── CaseServiceImpl.java │ │ │ │ ├── ClassServiceImpl.java │ │ │ │ ├── ConfigServiceImpl.java │ │ │ │ ├── ConnectServiceImpl.java │ │ │ │ ├── MenuServiceImpl.java │ │ │ │ ├── PomServiceImpl.java │ │ │ │ └── TelnetServiceImpl.java │ │ │ └── util/ │ │ │ ├── DOMUtil.java │ │ │ ├── FileUtil.java │ │ │ ├── JsonFileUtil.java │ │ │ ├── MD5Util.java │ │ │ ├── ParamUtil.java │ │ │ └── StringUtil.java │ │ └── resources/ │ │ ├── application-dev.yml │ │ ├── application-prd.yml │ │ ├── application.yml │ │ ├── logback-spring.xml │ │ ├── menu.json │ │ ├── registry.json │ │ ├── static/ │ │ │ └── v3/ │ │ │ ├── assets/ │ │ │ │ ├── css/ │ │ │ │ │ ├── bootstrap-editable.css │ │ │ │ │ ├── bootstrap-timepicker.css │ │ │ │ │ ├── chosen.css │ │ │ │ │ ├── colorbox.css │ │ │ │ │ ├── colorpicker.css │ │ │ │ │ ├── datepicker.css │ │ │ │ │ ├── daterangepicker.css │ │ │ │ │ ├── dropzone.css │ │ │ │ │ ├── fullcalendar.css │ │ │ │ │ ├── jquery.gritter.css │ │ │ │ │ ├── multiple-select.css │ │ │ │ │ ├── select2.css │ │ │ │ │ └── ui.jqgrid.css │ │ │ │ ├── font/ │ │ │ │ │ └── fonts.googleapis.com.css │ │ │ │ └── js/ │ │ │ │ ├── fuelux/ │ │ │ │ │ └── data/ │ │ │ │ │ └── fuelux.tree-sampledata.js │ │ │ │ ├── html5shiv.js │ │ │ │ ├── jqGrid/ │ │ │ │ │ ├── i18n/ │ │ │ │ │ │ └── grid.locale-en.js │ │ │ │ │ └── jquery.jqGrid.src.js │ │ │ │ ├── jquery.colorbox-min.js │ │ │ │ ├── jquery.dataTables.bootstrap.js │ │ │ │ ├── jquery.form.js │ │ │ │ └── multiple-select.js │ │ │ └── js/ │ │ │ ├── JGridUtils.js │ │ │ ├── Nora.js │ │ │ ├── core.js │ │ │ ├── echartUtils.js │ │ │ ├── jquery.jsonEdit.js │ │ │ └── pom.js │ │ └── templates/ │ │ ├── index.html │ │ └── pages/ │ │ ├── tpl/ │ │ │ ├── bread.html │ │ │ ├── foot.html │ │ │ ├── head.html │ │ │ ├── left.html │ │ │ └── top.html │ │ └── v3/ │ │ ├── addJar.html │ │ ├── caseCnt.html │ │ ├── easyCnt.html │ │ ├── editPom.html │ │ ├── listJar.html │ │ ├── listZk.html │ │ ├── normalCnt.html │ │ └── sys.html │ └── test/ │ ├── java/ │ │ └── com/ │ │ └── mmc/ │ │ └── dubbo/ │ │ └── doe/ │ │ ├── DubboDoeApplicationTests.java │ │ └── test/ │ │ ├── TestCaseService.java │ │ ├── TestClassService.java │ │ ├── TestConfigService.java │ │ ├── TestConnectService.java │ │ ├── TestCuratorHandler.java │ │ ├── TestDemo.java │ │ ├── TestDoeClassLoader.java │ │ ├── TestDoeClient.java │ │ ├── TestFuture.java │ │ ├── TestLogback.java │ │ ├── TestNumber.java │ │ ├── TestParam.java │ │ ├── TestPomService.java │ │ ├── TestProcessClient.java │ │ ├── TestRedisResolver.java │ │ ├── TestRedisTemplate.java │ │ ├── TestTelnetService.java │ │ └── TestTime.java │ └── resources/ │ ├── logback-spring.xml │ └── test-pom.xml └── mmc-dubbo-provider/ ├── .gitignore ├── pom.xml └── src/ └── main/ ├── java/ │ └── com/ │ └── mmc/ │ └── dubbo/ │ └── provider/ │ ├── DubboProviderApplication.java │ └── user/ │ ├── UserFeedbackServiceImpl.java │ └── UserMemberServiceImpl.java └── resources/ └── application.yml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes ================================================ *.js linguist-language=Java ================================================ FILE: .gitignore ================================================ ##ignore this file## .idea/ target target/ *.iml ================================================ FILE: README.md ================================================ # Doe 发布 [V1.3.0] 前段时间排查某问题的时候,想要快速知道某些dubbo接口(三无)的响应结果,但不想启动项目(因为这些项目不是你负责的,不会部署而且超级笨重),也不想新建一个dubbo客户端项目(占地方),也不想开telnet客户端连接口(麻烦而且有限制)。所以扣了dubbo的netty模块源码,封装了个收发客户端集成一个工具,可以快速调试dubbo接口。 ![极简模式](https://github.com/VIPJoey/doe/blob/master/deploy/easy.png) ![普通模式](https://github.com/VIPJoey/doe/blob/master/deploy/normal.png) ## 目录结构 - mmc-dubbo-api 接口项目,主要用于测试。 - mmc-dubbo-provider dubbo提供者项目,主要用于测试。 - mmc-dubbo-doe 主项目,实现dubbo接口调试。 - deploy 部署文档 ## 功能特性 - 极简模式:通过dubbo提供的telnet协议收发数据。 - 普通模式:通过封装netty客户端收发数据。 - 用例模式:通过缓存数据,方便下一次操作,依赖普通模式。 - 增加依赖:通过调用maven命令,下载jar包和热加载到系统,主要用来分析接口方法参数,主要作用在普通模式(已过时,请使用【依赖编辑】模块)。 - 依赖列表:通过分析pom文件,展示已经加载的jar包。 - 依赖编辑:可以直接编辑pom文件,新增修改依赖jar。 - 注册中心:可以添加或删除zookeeper注册中心。 - 系统配置:可以清空jar或者重新加载jar。 ## 其它特性 - springboot 整合 redis,支持spring el 表达式。 - springboot 整合 thymeleaf。 - springboot 整合 logback。 - netty rpc 实现原理。 - 热加载和沙箱隔离原理。 ## 开发环境 - jdk 1.8 - maven 3.5.3 - dubbo 2.6.1 - lombok 1.16.20 - idea 2018 - windows 7 ## 启动方式 * IDEA 启动 - 安装JDK、并设置环境变量 - 安装MAVEN,并设置好环境变量,仓库目录 - 安装REDIS,设置相关配置 - 安装IDEA,设置IDEA环境 - 导入项目到IDEA,设置为maven工程,勾选profile环境 - 根据各自需要,修改application-dev.yml或application-prd.yml配置文件,除了redis配置项,其它建议保持默认配置 - 在当前IDEA的workspace所在根目录,创建/app/doe目录 - 例如:application-*.yml为默认配置,且当前IDEA的workspace为F:\idea-workspaces\mmc-workspace\,则在F盘创建F:\app\doe - 进入mmc-dubbo-api目录,执行mvn clean install命令,生成api的jar包。 - 进入mmc-dubbo-doe目录,执行mvn clean install 命令,在target目录生成dubbo-doe.jar - 打开mmc-dubbo-doe工程,找到DubboDoeApplication.java类,右键点击运行即可。 - 默认日志目录:/app/applogs/doe - 打开浏览器,访问地址:http://localhost:9876/doe/home/index * LINUX 启动 - 安装JDK、并设置环境变量 - 安装MAVEN,并设置好环境变量,仓库目录 - 安装REDIS,设置相关配置 - 安装PYTHON(可选) - 执行mkdir -p /app/doe,创建/app/doe目录,注意权限问题 - 把deploy目录中的所有文件上传到/app/doe - 参考IDEA方式,下载DOE源码,并编译生成dubbo-doe.jar,并上传到/app/doe 目录 - 进入/app/doe 目录,执行chmod +x deploy.sh - 进入/app/doe 目录,执行 ./deploy.sh start 启动项目,支持(start/stop)参数,详细参数用途请阅读deploy.sh源码 - 默认日志目录:/app/applogs/doe - 打开浏览器,访问地址:http://ip:9876/doe/home/index ## 项目介绍 - https://blog.csdn.net/hanyi_?t=1 - https://blog.csdn.net/hanyi_/article/details/113945026 ## 发布记录 * [发布记录](https://github.com/VIPJoey/doe/blob/feature/doe_v1.3.0/UPGRADE.md) ## 特别说明 - 由于平时比较忙,仓促写下的代码未免有BUG,请见谅 - 如遇到问题,可以github上留言,或贡献您的代码 ## 关于内推
关注公众号即可获得大厂内推机会,优质简历可以全程帮忙跟踪进度,欢迎投递。
================================================ FILE: UPGRADE.md ================================================ 版本发布记录 # Doe 发布 [V1.0.0] ## 版本特性 一、连接发送 * 极简模式 * 普通模式 * 用例模式 二、依赖管理 * 增加依赖 * 依赖列表 > 基础功能基本实现 # Doe 发布 [V1.1.0] ## 版本特性 ##### 一、新功能 * 增加注册中心管理模块 * 增加编辑依赖模块 * 增加守护程序,停止、重启、重新发布 ##### 二. 优化功能 * provider 修改为starter方式 * 增加接口version和group支持 ##### 三. 缺陷修复 * 修复grid序号问题 * 修复spring 版本过低问题 * 优化菜单栏展示方式 # Doe 发布 [V1.2.0] ## 版本特性 ##### 一、新功能 * 增加独立加载JAR功能 * 增加清空lib目录功能 ##### 二. 优化功能 * 增加mac系统判断(commited by Lutong ) * 增加泛型接口测试 * 修改dubbo依赖为starter方式 * 修改类加载方式,增加沙箱隔离 * 移除python模块 ##### 三. 缺陷修复 * 无 # Doe 发布 [V1.3.0] ## 功能特性 ##### 一、新功能 * 无 ##### 二. 优化功能 * 无 ##### 三. 缺陷修复 * 修复【依赖编辑】模块未清空原目录残存jar包问题 * 修复【重新加载】模块未清空缓存classMap问题 ================================================ FILE: deploy/SimpleHttpServer.py ================================================ #!/usr/bin/env python2 # --coding:utf-8-- import os import time from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer from os import path import urlparse curdir = path.dirname(path.realpath(__file__)) sep = '/' # MIME-TYPE mimedic = [ ('.html', 'text/html'), ('.htm', 'text/html'), ('.js', 'application/javascript'), ('.css', 'text/css'), ('.json', 'application/json'), ('.png', 'image/png'), ('.jpg', 'image/jpeg'), ('.gif', 'image/gif'), ('.txt', 'text/plain'), ('.avi', 'video/x-msvideo'), ] class SimpleHttpServerHandler(BaseHTTPRequestHandler): def log(self, msg): timstr = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) print("[%s] %s" % (timstr, msg)) # GET def do_GET(self): querypath = urlparse.urlparse(self.path) filepath, query = querypath.path, querypath.query filename, fileext = path.splitext(filepath) self.log(filename + " --- " + fileext) # 支持命令集合 urlSet = set(("/start", "/stop", "/reload", "/republish")) sendReply = filename in urlSet if sendReply == True: try: param = filename[1:] self.log("/app/doe/deploy.sh " + param) os.system("/app/doe/deploy.sh " + param) content = ("{'success': true, 'msg': 'success.'}").encode("utf-8") self.send_response(200) self.send_header('Content-type', 'application/json') self.end_headers() self.wfile.write(content) except IOError: self.log('File Not Found: %s' % self.path) self.send_error(404, 'File Not Found: %s' % self.path) else: try: content = ("{'success': false, 'msg': 'no match url.'}").encode("utf-8") self.send_response(200) self.send_header('Content-type', 'application/json') self.end_headers() self.wfile.write(content) except IOError: self.log('File Not Found: %s' % self.path) self.send_error(404, 'File Not Found: %s' % self.path) def run(): port = 8000 print('starting server, port', port) # Server settings server_address = ('', port) httpd = HTTPServer(server_address, SimpleHttpServerHandler) print('running server...') httpd.serve_forever() if __name__ == '__main__': run() ================================================ FILE: deploy/deploy.sh ================================================ #!/bin/bash source /etc/profile function log() { echo `date '+%Y-%m-%d %H:%M:%S'` "$1" } function doStop() { log "bein to stop doe." count=`ps aux|grep "java -jar dubbo-doe" |grep -v grep|wc -l` if [ $count -gt 0 ] then log "bein to shutdown doe." pid=`ps aux|grep "java -jar dubbo-doe" |grep -v grep|awk '{ print $2 }'` kill $pid sleep 3s fi count=`ps aux|grep "java -jar dubbo-doe" |grep -v grep|wc -l` if [ $count -gt 0 ] then log "bein to force to kill doe." pid=`ps aux|grep "java -jar dubbo-doe" |grep -v grep|awk '{ print $2 }'` kill -9 $pid sleep 3s fi log "finish stop doe." } function doStart() { log "bein to install doe." java -jar dubbo-doe.jar --spring.profiles.active=prd & log "finish install doe." } function main() { log "welcome to doe." option="$1" if [ "$option" = "start" ] then doStart elif [ "$option" = "stop" ] then doStop elif [ "$option" = "reload" ] then doStop sleep 3s doStart elif [ "$option" = "republish" ] then doStop cp pom.xml.backup pom.xml rm -rf ./lib/* sleep 3s doStart else log "input option error (start/stop/reload/republish)" fi log "done." } main "$1" ================================================ FILE: deploy/pom.xml ================================================ 4.0.0 mmc-dubbo doe 1.0-SNAPSHOT compile maven-dependency-plugin process-sources copy-dependencies /app/doe/lib ================================================ FILE: deploy/pom.xml.backup ================================================ 4.0.0 mmc-dubbo doe 1.0-SNAPSHOT compile maven-dependency-plugin process-sources copy-dependencies /app/doe/lib ================================================ FILE: mmc-dubbo-api/.gitignore ================================================ ##ignore this file## .idea/ target target/ *.iml ================================================ FILE: mmc-dubbo-api/pom.xml ================================================ 4.0.0 mmc-dubbo api 1.3-RELEASE mmc-dubbo-api 1.8 1.8 org.apache.maven.plugins maven-compiler-plugin 3.1 1.8 1.8 ================================================ FILE: mmc-dubbo-api/src/main/java/com/mmc/dubbo/api/user/GenericReq.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.api.user; import java.io.Serializable; /** * @author Joey * @date 2019/5/10 16:10 */ public class GenericReq implements Serializable { private static final long serialVersionUID = 3998577120137245599L; private String name; private T data; public String getName() { return name; } public void setName(String name) { this.name = name; } public T getData() { return data; } public void setData(T data) { this.data = data; } } ================================================ FILE: mmc-dubbo-api/src/main/java/com/mmc/dubbo/api/user/GenericResp.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.api.user; import java.io.Serializable; /** * @author Joey * @date 2019/5/10 16:11 */ public class GenericResp implements Serializable { private static final long serialVersionUID = 6753766666093779059L; private T data; private String name; public T getData() { return data; } public void setData(T data) { this.data = data; } public String getName() { return name; } public void setName(String name) { this.name = name; } } ================================================ FILE: mmc-dubbo-api/src/main/java/com/mmc/dubbo/api/user/UserFact.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.api.user; import java.io.Serializable; /** * @author Joey * @date 2018/5/8 20:26 */ public class UserFact implements Serializable { private static final long serialVersionUID = 2798561567572955369L; private long id; private String name; private int sex; private int height; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getSex() { return sex; } public void setSex(int sex) { this.sex = sex; } public int getHeight() { return height; } public void setHeight(int height) { this.height = height; } } ================================================ FILE: mmc-dubbo-api/src/main/java/com/mmc/dubbo/api/user/UserService.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.api.user; /** * @author Joey * @date 2018/5/8 20:25 */ public interface UserService { /** * 测试方法一(单个参数). * @param id * @return */ UserFact getCurrentById(long id); /** * 测试方法二(多个参数). * @param u * @param name * @param sex * @return */ UserFact insert(UserFact u, String name, int sex); /** * 泛型测试. * @param user * @return */ GenericResp echo(GenericReq user); } ================================================ FILE: mmc-dubbo-doe/.gitignore ================================================ /target/ !.mvn/wrapper/maven-wrapper.jar ### STS ### .apt_generated .classpath .factorypath .project .settings .springBeans .sts4-cache ### IntelliJ IDEA ### .idea *.iws *.iml *.ipr ### NetBeans ### /nbproject/private/ /build/ /nbbuild/ /dist/ /nbdist/ /.nb-gradle/ ================================================ FILE: mmc-dubbo-doe/pom.xml ================================================ 4.0.0 com.mmc dubbo-doe 1.3.0-RELEASE jar mmc-dubbo-doe Demo project for Spring Boot org.springframework.boot spring-boot-starter-parent 2.0.2.RELEASE UTF-8 UTF-8 1.8 0.2.0 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-thymeleaf org.springframework.boot spring-boot-starter-data-redis org.springframework.boot spring-boot-starter-test test com.alibaba.boot dubbo-spring-boot-starter ${version.starter.dubbo} com.alibaba fastjson 1.2.46 org.projectlombok lombok true ru.dmerkushov xml-helper 1.5.0 org.apache.commons commons-pool2 2.5.0 org.apache.commons commons-text 1.3 commons-net commons-net 3.6 mmc-dubbo api 1.0-RELEASE dubbo-doe org.springframework.boot spring-boot-maven-plugin dev true dev prd prd ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/DubboDoeApplication.java ================================================ package com.mmc.dubbo.doe; import com.mmc.dubbo.doe.context.ApplicationReadyEventListener; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class DubboDoeApplication { public static void main(String[] args) { SpringApplication springApplication = new SpringApplication(DubboDoeApplication.class); springApplication.addListeners(new ApplicationReadyEventListener()); // load jars when startup springApplication.run(args); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/auth/MenuNode.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ /** * */ package com.mmc.dubbo.doe.auth; import java.util.ArrayList; import java.util.List; /** * 菜单节点. * @author Joey * 2016年6月24日 下午4:50:47 */ public class MenuNode extends MenuTree{ /** * */ private static final long serialVersionUID = 1456456456L; private List children = new ArrayList(); public List getChildren() { return children; } public void setChildren(List children) { this.children = children; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/auth/MenuTree.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ /** * */ package com.mmc.dubbo.doe.auth; import java.io.Serializable; /** * 菜单树实体类. * @author Joey * 2016年5月26日 下午1:20:34 */ public class MenuTree implements Serializable{ /** * */ private static final long serialVersionUID = 1485485452L; private Integer uId; private Integer roleId; private Integer menuId; private Integer pmenuId; private String menuName; private String menuUrl; private String menuStyle; private Integer mlevel; private Integer mleft; private Integer mright; public Integer getuId() { return uId; } public void setuId(Integer uId) { this.uId = uId; } public Integer getMenuId() { return menuId; } public void setMenuId(Integer menuId) { this.menuId = menuId; } public Integer getPmenuId() { return pmenuId; } public void setPmenuId(Integer pmenuId) { this.pmenuId = pmenuId; } public String getMenuName() { return menuName; } public void setMenuName(String menuName) { this.menuName = menuName; } public String getMenuUrl() { return menuUrl; } public void setMenuUrl(String menuUrl) { this.menuUrl = menuUrl; } public String getMenuStyle() { return menuStyle; } public void setMenuStyle(String menuStyle) { this.menuStyle = menuStyle; } public Integer getMlevel() { return mlevel; } public void setMlevel(Integer mlevel) { this.mlevel = mlevel; } public Integer getMleft() { return mleft; } public void setMleft(Integer mleft) { this.mleft = mleft; } public Integer getMright() { return mright; } public void setMright(Integer mright) { this.mright = mright; } public Integer getRoleId() { return roleId; } public void setRoleId(Integer roleId) { this.roleId = roleId; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/cache/CuratorCaches.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.cache; import com.mmc.dubbo.doe.exception.DoeException; import com.mmc.dubbo.doe.handler.CuratorHandler; import com.mmc.dubbo.doe.model.PointModel; import com.mmc.dubbo.doe.util.ParamUtil; import com.mmc.dubbo.doe.util.StringUtil; import javax.validation.constraints.NotNull; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** * cache all zk connection. * * @author Joey * @date 2018/6/18 20:12 */ public class CuratorCaches { private final static Map map = new ConcurrentHashMap<>(); public static CuratorHandler getHandler(@NotNull String conn) throws NoSuchFieldException, IllegalAccessException { CuratorHandler client = map.get(conn); if (null == client) { try { // split host and port PointModel model = ParamUtil.parsePointModel(conn); client = new CuratorHandler("zookeeper", model.getIp(), model.getPort()); // connect to zk client.doConnect(); // async connecting, so we should wait a few second. Thread.sleep(1000); if (client.isAvailable()) { // cache client for reuse map.putIfAbsent(conn, client); } else { client.close(); } } catch(Exception e) { throw new DoeException(StringUtil.format("can't connect to {}, {}", conn, e.getMessage())); } } return client; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/cache/DoeRedisResolver.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.cache; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; /** * @author Joey * @date 2018/6/17 18:00 */ @Service("redisResolver") @Slf4j public class DoeRedisResolver implements RedisResolver { @Autowired private RedisTemplate redisTemplate; public RedisTemplate getRedisTemplate() { return redisTemplate; } //=============================common============================ @Override public boolean expire(String key, long time) { try { if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } return true; } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override public long getExpire(String key) { return redisTemplate.getExpire(key, TimeUnit.SECONDS); } @Override public boolean hasKey(String key) { try { return redisTemplate.hasKey(key); } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override @SuppressWarnings("unchecked") public void del(String... key) { if (key != null && key.length > 0) { if (key.length == 1) { redisTemplate.delete(key[0]); } else { redisTemplate.delete(CollectionUtils.arrayToList(key)); } } } //============================String============================= @Override public Object get(String key) { return key == null ? null : redisTemplate.opsForValue().get(key); } @Override public boolean set(String key, Object value) { try { redisTemplate.opsForValue().set(key, value); return true; } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override public boolean set(String key, Object value, long time) { return set(key, value, time, TimeUnit.SECONDS); } @Override public boolean set(String key, Object value, long time, TimeUnit unit) { try { if (time > 0) { redisTemplate.opsForValue().set(key, value, time, unit); } else { set(key, value); } return true; } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override public long incr(String key, long delta) { if (delta < 0) { throw new RuntimeException("递增因子必须大于0"); } return redisTemplate.opsForValue().increment(key, delta); } @Override public long decr(String key, long delta) { if (delta < 0) { throw new RuntimeException("递减因子必须大于0"); } return redisTemplate.opsForValue().increment(key, -delta); } //================================Map================================= @Override public Object hget(String key, String item) { return redisTemplate.opsForHash().get(key, item); } @Override public Map hmget(String key) { return redisTemplate.opsForHash().entries(key); } @Override public boolean hmset(String key, Map map) { try { redisTemplate.opsForHash().putAll(key, map); return true; } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override public boolean hmset(String key, Map map, long time) { try { redisTemplate.opsForHash().putAll(key, map); if (time > 0) { expire(key, time); } return true; } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override public boolean hset(String key, String item, Object value) { try { redisTemplate.opsForHash().put(key, item, value); return true; } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override public boolean hset(String key, String item, Object value, long time) { try { redisTemplate.opsForHash().put(key, item, value); if (time > 0) { expire(key, time); } return true; } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override public void hdel(String key, Object... item) { redisTemplate.opsForHash().delete(key, item); } @Override public boolean hHasKey(String key, String item) { return redisTemplate.opsForHash().hasKey(key, item); } @Override public double hincr(String key, String item, double by) { return redisTemplate.opsForHash().increment(key, item, by); } @Override public double hdecr(String key, String item, double by) { return redisTemplate.opsForHash().increment(key, item, -by); } //============================set============================= @Override public Set sMembers(String key) { try { return redisTemplate.opsForSet().members(key); } catch (Exception e) { log.error(e.getMessage(), e); return null; } } @Override public boolean sHasKey(String key, Object value) { try { return redisTemplate.opsForSet().isMember(key, value); } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override public long sAdd(String key, Object... values) { try { return redisTemplate.opsForSet().add(key, values); } catch (Exception e) { log.error(e.getMessage(), e); return 0; } } @Override public long sSetAndTime(String key, long time, Object... values) { try { Long count = redisTemplate.opsForSet().add(key, values); if (time > 0) expire(key, time); return count; } catch (Exception e) { log.error(e.getMessage(), e); return 0; } } @Override public long sGetSetSize(String key) { try { return redisTemplate.opsForSet().size(key); } catch (Exception e) { log.error(e.getMessage(), e); return 0; } } @Override public long sRem(String key, Object... values) { try { Long count = redisTemplate.opsForSet().remove(key, values); return count; } catch (Exception e) { log.error(e.getMessage(), e); return 0; } } //===============================list================================= @Override public List lGet(String key, long start, long end) { try { return redisTemplate.opsForList().range(key, start, end); } catch (Exception e) { log.error(e.getMessage(), e); return null; } } @Override public long lGetListSize(String key) { try { return redisTemplate.opsForList().size(key); } catch (Exception e) { log.error(e.getMessage(), e); return 0; } } @Override public Object lGetIndex(String key, long index) { try { return redisTemplate.opsForList().index(key, index); } catch (Exception e) { log.error(e.getMessage(), e); return null; } } @Override public boolean lSet(String key, Object value) { try { redisTemplate.opsForList().rightPush(key, value); return true; } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override public boolean lSet(String key, Object value, long time) { try { redisTemplate.opsForList().rightPush(key, value); if (time > 0) expire(key, time); return true; } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override public boolean lSet(String key, List value) { try { redisTemplate.opsForList().rightPushAll(key, value); return true; } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override public boolean lSet(String key, List value, long time) { try { redisTemplate.opsForList().rightPushAll(key, value); if (time > 0) expire(key, time); return true; } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override public boolean lUpdateIndex(String key, long index, Object value) { try { redisTemplate.opsForList().set(key, index, value); return true; } catch (Exception e) { log.error(e.getMessage(), e); return false; } } @Override public long lRemove(String key, long count, Object value) { try { Long remove = redisTemplate.opsForList().remove(key, count, value); return remove; } catch (Exception e) { log.error(e.getMessage(), e); return 0; } } @Override public boolean rPush(String key, Object value) { try { return redisTemplate.opsForList().rightPush(key, value) > 0; } catch(Exception e) { log.error(e.getMessage(), e); return false; } } @Override public Object lPop(String key) { try { return redisTemplate.opsForList().leftPop(key); } catch(Exception e) { log.error(e.getMessage(), e); return null; } } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/cache/MethodCaches.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.cache; import com.mmc.dubbo.doe.model.MethodModel; import com.mmc.dubbo.doe.dto.MethodModelDTO; import com.mmc.dubbo.doe.util.MD5Util; import com.mmc.dubbo.doe.util.StringUtil; import javax.validation.constraints.NotNull; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; /** * @author Joey * @date 2018/6/15 14:55 */ public class MethodCaches { private final static Map map = new ConcurrentHashMap<>(); /** * cache the method object so we can get them next time quickly. * * @param interfaceName * @param methods * @return */ public static List cache(final String interfaceName, Method[] methods) { List ret = new ArrayList<>(); Arrays.stream(methods).forEach(m -> { String key = generateMethodKey(m, interfaceName); MethodModel model = new MethodModel(key, m); ret.add(new MethodModelDTO(model)); map.putIfAbsent(key, model); // add to cache }); return ret; } private static String generateMethodKey(Method method, String interfaceName) { return StringUtil.format("{}#{}", interfaceName, MD5Util.encrypt(method.toGenericString())); } public static MethodModel get(@NotNull String key) { return map.get(key); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/cache/RedisConfiguration.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.cache; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.databind.ObjectMapper; import com.mmc.dubbo.doe.context.Const; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.*; import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.cache.RedisCacheConfiguration; import org.springframework.data.redis.cache.RedisCacheManager; import org.springframework.data.redis.cache.RedisCacheWriter; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.RedisSerializationContext; import org.springframework.data.redis.serializer.StringRedisSerializer; import java.lang.reflect.Method; import java.time.Duration; import java.util.HashMap; import java.util.Map; /** * redis cache configuration. * * @author Joey * @date 2018/6/17 11:20 */ @Configuration @EnableAutoConfiguration @EnableCaching public class RedisConfiguration extends CachingConfigurerSupport { @Bean public RedisTemplate getRedisTemplate(RedisConnectionFactory connectionFactory) { RedisTemplate template = new StringRedisTemplate(connectionFactory); template.setKeySerializer(new StringRedisSerializer()); Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class); ObjectMapper om = new ObjectMapper(); om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); jackson2JsonRedisSerializer.setObjectMapper(om); template.setValueSerializer(jackson2JsonRedisSerializer); template.setHashValueSerializer(jackson2JsonRedisSerializer); return template; } // 缓存管理器 @Bean public CacheManager cacheManager(RedisConnectionFactory connectionFactory) { // 生成一个默认配置,通过config对象即可对缓存进行自定义配置 RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofMinutes(1)) // 设置缓存的默认过期时间,也是使用Duration设置 .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())) .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(createJacksonRedisSerializer())) .disableCachingNullValues(); // 不缓存空值 // 对每个缓存空间应用不同的配置 Map redisCacheConfigurationMap = new HashMap<>(); redisCacheConfigurationMap.put(Const.DOE_CACHE_PREFIX, config); // 初始化一个RedisCacheWriter RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory); // 初始化RedisCacheManager RedisCacheManager cacheManager = new RedisCacheManager(redisCacheWriter, config, redisCacheConfigurationMap); return cacheManager; // RedisCacheManager cacheManager = RedisCacheManager.builder(redisConnectionFactory) // 使用自定义的缓存配置初始化一个cacheManager // .initialCacheNames(cacheNames) // 注意这两句的调用顺序,一定要先调用该方法设置初始化的缓存名,再初始化相关的配置 // .withInitialCacheConfigurations(configMap) // .build(); } private Jackson2JsonRedisSerializer createJacksonRedisSerializer() { Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class); ObjectMapper om = new ObjectMapper(); om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); jackson2JsonRedisSerializer.setObjectMapper(om); return jackson2JsonRedisSerializer; } @Bean public KeyGenerator keyGenerator() { return new KeyGenerator() { @Override public Object generate(Object target, Method method, Object... params) { StringBuilder sb = new StringBuilder(); String[] value = new String[1]; Cacheable cacheable = method.getAnnotation(Cacheable.class); if (cacheable != null) { value = cacheable.value(); } CachePut cachePut = method.getAnnotation(CachePut.class); if (cachePut != null) { value = cachePut.value(); } CacheEvict cacheEvict = method.getAnnotation(CacheEvict.class); if (cacheEvict != null) { value = cacheEvict.value(); } sb.append(value[0]); for (Object obj : params) { sb.append(":") .append(obj.toString()); } return sb.toString(); } }; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/cache/RedisResolver.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.cache; import org.springframework.data.redis.core.RedisTemplate; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; /** * @author Joey * @date 2018/6/17 18:13 */ public interface RedisResolver { /** * 获取模板. * * @return */ RedisTemplate getRedisTemplate(); /** * 指定缓存失效时间 * * @param key 键 * @param time 时间(秒) * @return */ boolean expire(String key, long time); /** * 根据key 获取过期时间 * * @param key 键 不能为null * @return 时间(秒) 返回0代表为永久有效 */ long getExpire(String key); /** * 判断key是否存在 * * @param key 键 * @return true 存在 false不存在 */ boolean hasKey(String key); /** * 删除缓存 * * @param key 可以传一个值 或多个 */ @SuppressWarnings("unchecked") void del(String... key); /** * 普通缓存获取 * * @param key 键 * @return 值 */ Object get(String key); /** * 普通缓存放入 * * @param key 键 * @param value 值 * @return true成功 false失败 */ boolean set(String key, Object value); /** * 普通缓存放入并设置时间. * * @param key 键 * @param value 值 * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 * @return true成功 false 失败 */ boolean set(String key, Object value, long time); /** * 普通缓存放入并设置时间. * @param key * @param value * @param time * @param unit * @return */ boolean set(String key, Object value, long time, TimeUnit unit); /** * 递增 * @param key 键 * @param delta 要增加几(大于0) * @return */ long incr(String key, long delta); /** * 递减 * @param key 键 * @param delta 要减少几(大于0) * @return */ long decr(String key, long delta); /** * HashGet * * @param key 键 不能为null * @param item 项 不能为null * @return 值 */ Object hget(String key, String item); /** * 获取hashKey对应的所有键值 * * @param key 键 * @return 对应的多个键值 */ Map hmget(String key); /** * HashSet * * @param key 键 * @param map 对应多个键值 * @return true 成功 false 失败 */ boolean hmset(String key, Map map); /** * HashSet 并设置时间 * * @param key 键 * @param map 对应多个键值 * @param time 时间(秒) * @return true成功 false失败 */ boolean hmset(String key, Map map, long time); /** * 向一张hash表中放入数据,如果不存在将创建 * * @param key 键 * @param item 项 * @param value 值 * @return true 成功 false失败 */ boolean hset(String key, String item, Object value); /** * 向一张hash表中放入数据,如果不存在将创建 * * @param key 键 * @param item 项 * @param value 值 * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 * @return true 成功 false失败 */ boolean hset(String key, String item, Object value, long time); /** * 删除hash表中的值 * * @param key 键 不能为null * @param item 项 可以使多个 不能为null */ void hdel(String key, Object... item); /** * 判断hash表中是否有该项的值 * * @param key 键 不能为null * @param item 项 不能为null * @return true 存在 false不存在 */ boolean hHasKey(String key, String item); /** * hash递增 如果不存在,就会创建一个 并把新增后的值返回 * * @param key 键 * @param item 项 * @param by 要增加几(大于0) * @return */ double hincr(String key, String item, double by); /** * hash递减 * * @param key 键 * @param item 项 * @param by 要减少记(小于0) * @return */ double hdecr(String key, String item, double by); /** * 根据key获取Set中的所有值 * * @param key 键 * @return */ Set sMembers(String key); /** * 根据value从一个set中查询,是否存在 * * @param key 键 * @param value 值 * @return true 存在 false不存在 */ boolean sHasKey(String key, Object value); /** * 将数据放入set缓存 * * @param key 键 * @param values 值 可以是多个 * @return 成功个数 */ long sAdd(String key, Object... values); /** * 将set数据放入缓存 * * @param key 键 * @param time 时间(秒) * @param values 值 可以是多个 * @return 成功个数 */ long sSetAndTime(String key, long time, Object... values); /** * 获取set缓存的长度 * * @param key 键 * @return */ long sGetSetSize(String key); /** * 移除值为value的 * * @param key 键 * @param values 值 可以是多个 * @return 移除的个数 */ long sRem(String key, Object... values); /** * 获取list缓存的内容 * * @param key 键 * @param start 开始 * @param end 结束 0 到 -1代表所有值 * @return */ List lGet(String key, long start, long end); /** * 获取list缓存的长度 * * @param key 键 * @return */ long lGetListSize(String key); /** * 通过索引 获取list中的值 * * @param key 键 * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 * @return */ Object lGetIndex(String key, long index); /** * 将list放入缓存. * @param key * @param value * @return */ boolean lSet(String key, Object value); /** * 将list放入缓存 * * @param key 键 * @param value 值 * @param time 时间(秒) * @return */ boolean lSet(String key, Object value, long time); /** * 将list放入缓存. * @param key * @param value * @return */ boolean lSet(String key, List value); /** * 将list放入缓存 * * @param key 键 * @param value 值 * @param time 时间(秒) * @return */ boolean lSet(String key, List value, long time); /** * 根据索引修改list中的某条数据 * * @param key 键 * @param index 索引 * @param value 值 * @return */ boolean lUpdateIndex(String key, long index, Object value); /** * 移除N个值为value * * @param key 键 * @param count 移除多少个 * @param value 值 * @return 移除的个数 */ long lRemove(String key, long count, Object value); /** * 从右边加入队列. * @param key * @param value * @return */ boolean rPush(String key, Object value); /** * 从左边出队. * @param key * @return */ Object lPop(String key); } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/cache/UrlCaches.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.cache; import com.alibaba.dubbo.common.URL; import com.mmc.dubbo.doe.model.UrlModel; import com.mmc.dubbo.doe.util.StringUtil; import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; /** * @author Joey * @date 2018/6/15 17:59 */ public class UrlCaches { private final static Map map = new ConcurrentHashMap<>(); /** * cache all providers by unique key. * * @param interfaceName * @param urls * @return */ public static List cache(String interfaceName, List urls) { List ret = new ArrayList<>(); for (int i = 0; i < urls.size(); i++) { URL url = urls.get(i); String key = generateUrlKey(interfaceName, url.getHost(), url.getPort()); UrlModel model = new UrlModel(key, url); ret.add(model); map.put(model.getKey(), model); // 存入缓存 } return ret; } private static String generateUrlKey(String interfaceName, String host, int port) { return StringUtil.format("{}#{}#{}#", interfaceName, host, port); } public static UrlModel get(@NotNull String key) { return map.get(key); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/channel/NettyChannel.java ================================================ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.mmc.dubbo.doe.channel; import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; import com.alibaba.dubbo.common.logger.Logger; import com.alibaba.dubbo.common.logger.LoggerFactory; import com.alibaba.dubbo.remoting.ChannelHandler; import com.alibaba.dubbo.remoting.RemotingException; import com.alibaba.dubbo.remoting.transport.AbstractChannel; import org.jboss.netty.channel.ChannelFuture; import java.net.InetSocketAddress; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; /** * NettyChannel. */ public class NettyChannel extends AbstractChannel { private static final Logger logger = LoggerFactory.getLogger(NettyChannel.class); private static final ConcurrentMap channelMap = new ConcurrentHashMap(); private final org.jboss.netty.channel.Channel channel; private final Map attributes = new ConcurrentHashMap(); private NettyChannel(org.jboss.netty.channel.Channel channel, URL url, ChannelHandler handler) { super(url, handler); if (channel == null) { throw new IllegalArgumentException("netty channel == null;"); } this.channel = channel; } public static NettyChannel getOrAddChannel(org.jboss.netty.channel.Channel ch, URL url, ChannelHandler handler) { if (ch == null) { return null; } NettyChannel ret = channelMap.get(ch); if (ret == null) { NettyChannel nc = new NettyChannel(ch, url, handler); if (ch.isConnected()) { ret = channelMap.putIfAbsent(ch, nc); } if (ret == null) { ret = nc; } } return ret; } public static void removeChannelIfDisconnected(org.jboss.netty.channel.Channel ch) { if (ch != null && !ch.isConnected()) { channelMap.remove(ch); } } public InetSocketAddress getLocalAddress() { return (InetSocketAddress) channel.getLocalAddress(); } public InetSocketAddress getRemoteAddress() { return (InetSocketAddress) channel.getRemoteAddress(); } public boolean isConnected() { return channel.isConnected(); } public void send(Object message, boolean sent) throws RemotingException { super.send(message, sent); boolean success = true; int timeout = 0; try { ChannelFuture future = channel.write(message); if (sent) { timeout = getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); success = future.await(timeout); } Throwable cause = future.getCause(); if (cause != null) { throw cause; } } catch (Throwable e) { throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + ", cause: " + e.getMessage(), e); } if (!success) { throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + "in timeout(" + timeout + "ms) limit"); } } public void close() { try { super.close(); } catch (Exception e) { logger.warn(e.getMessage(), e); } try { removeChannelIfDisconnected(channel); } catch (Exception e) { logger.warn(e.getMessage(), e); } try { attributes.clear(); } catch (Exception e) { logger.warn(e.getMessage(), e); } try { if (logger.isInfoEnabled()) { logger.info("Close netty channel " + channel); } channel.close(); } catch (Exception e) { logger.warn(e.getMessage(), e); } } public boolean hasAttribute(String key) { return attributes.containsKey(key); } public Object getAttribute(String key) { return attributes.get(key); } public void setAttribute(String key, Object value) { if (value == null) { // The null value unallowed in the ConcurrentHashMap. attributes.remove(key); } else { attributes.put(key, value); } } public void removeAttribute(String key) { attributes.remove(key); } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((channel == null) ? 0 : channel.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; NettyChannel other = (NettyChannel) obj; if (channel == null) { if (other.channel != null) return false; } else if (!channel.equals(other.channel)) return false; return true; } @Override public String toString() { return "com.mmc.dubbo.test.NettyChannel [channel=" + channel + "]"; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/client/DoeClient.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.client; import com.alibaba.dubbo.common.URL; import com.alibaba.dubbo.remoting.RemotingException; import com.alibaba.dubbo.remoting.exchange.Request; import com.mmc.dubbo.doe.channel.NettyChannel; import com.mmc.dubbo.doe.handler.SendReceiveHandler; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelFuture; import java.util.concurrent.TimeUnit; /** * @author Joey * @date 2018/6/7 10:42 */ public class DoeClient extends TransportClient { public DoeClient(URL url) { super(url, new SendReceiveHandler()); } public void doConnect() { ChannelFuture future = bootstrap.connect(getConnectAddress()); boolean ret = future.awaitUninterruptibly(timeout, TimeUnit.MILLISECONDS); if (ret && future.isSuccess()) { Channel newChannel = future.getChannel(); newChannel.setInterestOps(Channel.OP_READ_WRITE); DoeClient.this.channel = future.getChannel(); } else { throw new RuntimeException("can't not connect to server."); } } public void send(Request req) throws RemotingException { NettyChannel ch = NettyChannel.getOrAddChannel(this.channel, url, handler); ch.send(req); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/client/ProcessClient.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.client; import com.mmc.dubbo.doe.cache.RedisResolver; import com.mmc.dubbo.doe.context.Const; import com.mmc.dubbo.doe.context.TaskContainer; import com.mmc.dubbo.doe.dto.PomDTO; import com.mmc.dubbo.doe.handler.StreamHandler; import com.mmc.dubbo.doe.util.StringUtil; import lombok.extern.slf4j.Slf4j; import java.io.IOException; import java.util.Properties; import java.util.concurrent.TimeUnit; /** * @author Joey * @date 2018/6/17 23:43 */ @Slf4j public class ProcessClient extends Thread { private final String libPath; private final RedisResolver redisResolver; private final PomDTO dto; private final String pomXml; private long timeout = 20; private volatile boolean done; public ProcessClient(PomDTO dto, RedisResolver redisResolver, String pomXml, String libPath) { this.dto = dto; this.redisResolver = redisResolver; this.pomXml = pomXml; this.libPath = libPath; } @Override public void run() { log.info("begin to download the jars."); // set running flag this.putFlag(); // make the command depends on the OS. String command = makeCommand(pomXml); log.info("begin to exec the command {}", command); Process ps = null; try { ps = Runtime.getRuntime().exec(command); } catch (IOException e) { log.error(StringUtil.format("can't execute the command {}", command), e); return; } // 再开线程执行 TaskContainer.getTaskContainer().execute(new StreamHandler(ps, redisResolver, dto.getRequestId(), libPath)); // no longer than default 20 minutes. try { ps.waitFor(timeout, TimeUnit.MINUTES); } catch (InterruptedException e) { log.error("waiting too long...", e); } // remove the key this.removeFlag(); // set complete normally flag this.done = true; } private void putFlag() { // set the key mark as the running flag and the longest lifetime of task was one hour. log.info("set the key to mark as the running flag and the longest lifetime of task was one hour"); redisResolver.set(Const.DOE_DOWNLOAD_JAR_TASK, Const.RUNNING_FlAG, 1, TimeUnit.HOURS); } /** * remove the running flag. */ private void removeFlag() { log.info("remove the running flag."); redisResolver.del(Const.DOE_DOWNLOAD_JAR_TASK); } /** * get the cmd code. * * @param pomXml * @return */ private String makeCommand(String pomXml) { if (isOSLinux()) { return StringUtil.format("/bin/bash -c mvn dependency:copy-dependencies -DoutputDirectory={} -DincludeScope=compile -f {}", libPath, pomXml); } else if (isOSMac()){ return StringUtil.format("mvn dependency:copy-dependencies -DoutputDirectory={} -DincludeScope=compile -f {}", libPath, pomXml); }else { return StringUtil.format("cmd /c mvn dependency:copy-dependencies -DoutputDirectory=lib -DincludeScope=compile -f {}", pomXml); } } /** * judge if linux os. * * @return */ public static boolean isOSLinux() { Properties prop = System.getProperties(); String os = prop.getProperty("os.name"); if (os != null && os.toLowerCase().contains("linux")) { return true; } else { return false; } } /** * judge if mac os. * * @return */ public static boolean isOSMac() { Properties prop = System.getProperties(); String os = prop.getProperty("os.name"); if (os != null && os.toLowerCase().contains("mac")) { return true; } else { return false; } } public boolean isDone() { return done; } public boolean isRunning() { if (redisResolver.hasKey(Const.DOE_DOWNLOAD_JAR_TASK)) { log.warn("some task was already running at background, please try again for a few minutes later."); return true; } return false; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/client/TransportClient.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.client; import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; import com.alibaba.dubbo.common.extension.ExtensionLoader; import com.alibaba.dubbo.common.utils.NamedThreadFactory; import com.alibaba.dubbo.common.utils.NetUtils; import com.alibaba.dubbo.remoting.Codec2; import com.alibaba.dubbo.remoting.buffer.DynamicChannelBuffer; import com.alibaba.dubbo.remoting.transport.netty.NettyHandler; import com.mmc.dubbo.doe.channel.NettyChannel; import org.jboss.netty.bootstrap.ClientBootstrap; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.*; import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; import java.io.IOException; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.util.concurrent.Executors; /** * @author Joey * @date 2018/6/15 11:26 */ public class TransportClient { protected static final ChannelFactory channelFactory = new NioClientSocketChannelFactory( Executors.newCachedThreadPool(new NamedThreadFactory("NettyClientBoss", true)), Executors.newCachedThreadPool(new NamedThreadFactory("NettyClientWorker", true)), Constants.DEFAULT_IO_THREADS); protected ClientBootstrap bootstrap = new ClientBootstrap(channelFactory); protected int bufferSize = Constants.DEFAULT_BUFFER_SIZE; protected int timeout = Constants.DEFAULT_TIMEOUT; protected final Codec2 codec; protected final URL url; protected volatile Channel channel; // volatile, please copy reference to use protected com.alibaba.dubbo.remoting.ChannelHandler handler; public TransportClient(URL url, com.alibaba.dubbo.remoting.ChannelHandler handler) { this.url = url; this.handler = handler; this.codec = getChannelCodec(url); bootstrap.setOption("keepAlive", true); bootstrap.setOption("tcpNoDelay", true); bootstrap.setOption("connectTimeoutMillis", timeout); final NettyHandler nettyHandler = new NettyHandler(url, handler); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { public ChannelPipeline getPipeline() { ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("decoder", getDecoder()); pipeline.addLast("encoder", getEncoder()); pipeline.addLast("handler", nettyHandler); return pipeline; } }); } protected static Codec2 getChannelCodec(URL url) { String codecName = url.getParameter(Constants.CODEC_KEY, "telnet"); return ExtensionLoader.getExtensionLoader(Codec2.class).getExtension(codecName); } protected SocketAddress getConnectAddress() { return new InetSocketAddress(NetUtils.filterLocalHost(url.getHost()), url.getPort()); } private org.jboss.netty.channel.ChannelHandler getEncoder() { return new InternalEncoder(); } private org.jboss.netty.channel.ChannelHandler getDecoder() { return new InternalDecoder(); } private class InternalEncoder extends OneToOneEncoder { @Override protected Object encode(ChannelHandlerContext ctx, Channel ch, Object msg) throws Exception { com.alibaba.dubbo.remoting.buffer.ChannelBuffer buffer = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.dynamicBuffer(1024); NettyChannel channel = NettyChannel.getOrAddChannel(ch, url, handler); try { codec.encode(channel, buffer, msg); } finally { NettyChannel.removeChannelIfDisconnected(ch); } return ChannelBuffers.wrappedBuffer(buffer.toByteBuffer()); } } private class InternalDecoder extends SimpleChannelUpstreamHandler { private com.alibaba.dubbo.remoting.buffer.ChannelBuffer buffer = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.EMPTY_BUFFER; @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent event) throws Exception { Object o = event.getMessage(); if (!(o instanceof ChannelBuffer)) { ctx.sendUpstream(event); return; } ChannelBuffer input = (ChannelBuffer) o; int readable = input.readableBytes(); if (readable <= 0) { return; } com.alibaba.dubbo.remoting.buffer.ChannelBuffer message; if (buffer.readable()) { if (buffer instanceof DynamicChannelBuffer) { buffer.writeBytes(input.toByteBuffer()); message = buffer; } else { int size = buffer.readableBytes() + input.readableBytes(); message = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.dynamicBuffer( size > bufferSize ? size : bufferSize); message.writeBytes(buffer, buffer.readableBytes()); message.writeBytes(input.toByteBuffer()); } } else { message = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.wrappedBuffer( input.toByteBuffer()); } NettyChannel channel = NettyChannel.getOrAddChannel(ctx.getChannel(), url, handler); Object msg; int saveReaderIndex; try { // decode object. do { saveReaderIndex = message.readerIndex(); try { msg = codec.decode(channel, message); } catch (IOException e) { buffer = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.EMPTY_BUFFER; throw e; } if (msg == Codec2.DecodeResult.NEED_MORE_INPUT) { message.readerIndex(saveReaderIndex); break; } else { if (saveReaderIndex == message.readerIndex()) { buffer = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.EMPTY_BUFFER; throw new IOException("Decode without read data."); } if (msg != null) { Channels.fireMessageReceived(ctx, msg, event.getRemoteAddress()); } } } while (message.readable()); } finally { if (message.readable()) { message.discardReadBytes(); buffer = message; } else { buffer = com.alibaba.dubbo.remoting.buffer.ChannelBuffers.EMPTY_BUFFER; } NettyChannel.removeChannelIfDisconnected(ctx.getChannel()); } } @Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { ctx.sendUpstream(e); } } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/context/ApplicationReadyEventListener.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.context; import com.mmc.dubbo.doe.service.PomService; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; import org.springframework.context.ConfigurableApplicationContext; import java.net.MalformedURLException; /** * @author Joey * @date 2018/6/22 13:55 */ @Slf4j public class ApplicationReadyEventListener implements ApplicationListener { /** * Handle an application event. * * @param event the event to respond to */ @Override public void onApplicationEvent(ApplicationReadyEvent event) { log.info("ApplicationReadyEventListener.onApplicationEvent()"); ConfigurableApplicationContext applicationContext = event.getApplicationContext(); PomService pomService = applicationContext.getBean("pomService", PomService.class); try { log.info("begin auto to load jars."); pomService.loadJars(""); log.info("finished load jars."); } catch (NoSuchMethodException | MalformedURLException e) { log.error("fail to load jars.", e); } } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/context/Const.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.context; /** * @author Joey * @date 2018/6/17 18:38 */ public class Const { /** * download task key. */ public static final String DOE_DOWNLOAD_JAR_TASK = "doe:download:jar:task"; /** * when the task was running. */ public static final int RUNNING_FlAG = 1; /** * when the task has completed. */ public static final int COMPLETE_FLAG = 2; /** * download task real time message key. */ public static final String DOE_DOWNLOAD_JAR_MESSAGE = "doe:download:jar:msg:{}"; /** * the project cache namespace. */ public static final String DOE_CACHE_PREFIX = "doe:cache"; /** * use case key. */ public static final String DOE_CASE_KEY = "doe:case"; /** * all config of zk address key. */ public static final String DOE_REGISTRY_KEY = "doe:registry:list"; } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/context/DoeClassLoader.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.context; import com.alibaba.dubbo.common.utils.StringUtils; import com.mmc.dubbo.doe.exception.DoeException; import com.mmc.dubbo.doe.util.StringUtil; import lombok.extern.slf4j.Slf4j; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Enumeration; import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.jar.JarEntry; import java.util.jar.JarFile; /** * 自定义类加载器,做沙箱隔离. * * @author Joey * @date 2019/6/28 14:20 */ @Slf4j public class DoeClassLoader extends ClassLoader { private final String path; private static Map classMap = new ConcurrentHashMap<>(); /** * destroy the Parental Entrustment. */ public DoeClassLoader(String path) { super(null); this.path = path; } private void scanJarFile(File file) throws Exception { JarFile jar = new JarFile(file); Enumeration en = jar.entries(); while (en.hasMoreElements()) { JarEntry je = en.nextElement(); je.getName(); String name = je.getName(); if (name.endsWith(".class")) { String className = makeClassName(name); try (InputStream input = jar.getInputStream(je); ByteArrayOutputStream baos = new ByteArrayOutputStream()) { int bufferSize = 1024; byte[] buffer = new byte[bufferSize]; int bytesNumRead; while ((bytesNumRead = input.read(buffer)) != -1) { baos.write(buffer, 0, bytesNumRead); } addClass(className, baos.toByteArray()); } } } jar.close(); } private String makeClassName(String name) { String ret = name.replace("\\", ".") .replace("/", ".") .replace(".class", ""); return ret; } /** * load jars from the Specified path. */ public void loadJars() throws Exception { if (StringUtils.isEmpty(path)) { throw new DoeException(StringUtil.format("can't found the path {}", path)); } File libPath = new File(path); if (!libPath.exists()) { throw new DoeException(StringUtil.format("the path[{}] is not exists.", path)); } File[] files = libPath.listFiles((dir, name) -> name.endsWith(".jar") || name.endsWith(".zip")); if (files != null) { for (File file : files) { scanJarFile(file); } } } /** * Add one class dynamically. */ public static boolean addClass(String className, byte[] byteCode) { if (!classMap.containsKey(className)) { classMap.put(className, byteCode); return true; } return false; } @Override protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { name = makeClassName(name); byte[] stream = get(name); if (null != stream) { return defineClass(name, stream, 0, stream.length); } return super.loadClass(name, resolve); } /** * Get class in our classloader rather than system classloader. */ public static Class getClass(String name) throws ClassNotFoundException { return new DoeClassLoader("").loadClass(name, false); } private static byte[] get(String className) { return classMap.getOrDefault(className, null); } private void scanClassFile(File file) { if (file.exists()) { if (file.isFile() && file.getName().endsWith(".class")) { try { byte[] byteCode = Files.readAllBytes(Paths.get(file.getAbsolutePath())); String className = file.getAbsolutePath().replace(this.path, "") .replace(File.separator, "."); className = makeClassName(className); addClass(className, byteCode); } catch (IOException e) { e.printStackTrace(); } } else if (file.isDirectory()) { for (File f : Objects.requireNonNull(file.listFiles())) { scanClassFile(f); } } } } /** * load classes from the Specified path. */ public void loadClassFile() { File[] files = new File(path).listFiles(); if (files != null) { for (File file : files) { scanClassFile(file); } } } /** * clear the class cache. */ public void clearCache() { classMap.clear(); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/context/ResponseDispatcher.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.context; import com.alibaba.dubbo.remoting.exchange.Request; import com.alibaba.dubbo.remoting.exchange.Response; import com.alibaba.dubbo.rpc.RpcResult; import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; /** * @author Joey * @date 2018/6/11 12:33 */ public class ResponseDispatcher { private Map futures = new ConcurrentHashMap<>(); private ResponseDispatcher() { } @SuppressWarnings("uncheck") public CompletableFuture getFuture(Request req) { return futures.get(req.getId()); } public void register(Request req) { CompletableFuture future = new CompletableFuture(); futures.put(req.getId(), future); } public void dispatch(Response res) { CompletableFuture future = futures.get(res.getId()); if (null == future) { throw new RuntimeException(); } future.complete(res.getResult()); } public CompletableFuture removeFuture(Request req) { return futures.remove(req.getId()); } static class ResponseDispatcherHolder { static final ResponseDispatcher instance = new ResponseDispatcher(); } public static ResponseDispatcher getDispatcher() { return ResponseDispatcherHolder.instance; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/context/TaskContainer.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.context; import lombok.extern.slf4j.Slf4j; import java.util.concurrent.*; /** * @author Joey * @date 2018/6/29 20:00 */ @Slf4j public class TaskContainer { // 获取当前的cpu核心数 private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors(); // 线程池最大容量 public static final int MAXIMUM_POOL_SIZE = CPU_COUNT; // 线程池核心容量 private static final int CORE_POOL_SIZE = CPU_COUNT; // 线程池 private final ThreadPoolExecutor poolExecutor; // 判断是否关闭 protected volatile boolean isShutdown; // 任务计数器 protected CountDownLatch watch; private TaskContainer() { // 创建任务池 poolExecutor = new ThreadPoolExecutor(2, MAXIMUM_POOL_SIZE, 1, TimeUnit.HOURS, new ArrayBlockingQueue(CORE_POOL_SIZE), new RejectedExecutionHandler() { @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { try { // 核心改造点,由blocking queue的offer改成put阻塞方法 executor.getQueue().put(r); } catch (InterruptedException e) { log.error("任务进入队列出错:", e); } } }); } public static TaskContainer getTaskContainer() { return TaskContainerHolder.instance; } /** * execute task. * * @param task */ public void execute(Runnable task) { poolExecutor.execute(task); } static class TaskContainerHolder { static final TaskContainer instance = new TaskContainer(); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/crontroller/CaseController.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.crontroller; import com.alibaba.fastjson.JSON; import com.mmc.dubbo.doe.dto.CaseModelDTO; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.model.CaseModel; import com.mmc.dubbo.doe.service.CaseService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * @author Joey * @date 2018/6/29 15:57 */ @RestController @RequestMapping("/doe/case") @Slf4j public class CaseController { @Autowired private CaseService caseService; @RequestMapping("/doSave") public ResultDTO doSave(@NotNull CaseModelDTO dto) { log.info("CaseController.doSave({})", JSON.toJSONString(dto)); ResultDTO resultDTO; try { CaseModel model = new CaseModel(); BeanUtils.copyProperties(dto, model); resultDTO = caseService.save(model); } catch(Exception e) { resultDTO = ResultDTO.createExceptionResult(e, CaseModel.class); } return resultDTO; } @RequestMapping("/doList") public String doList(CaseModelDTO dto) { log.info("CaseController.doList({})", JSON.toJSONString(dto)); try { List list = caseService.listAll(); List ret = list.stream().map(l -> { CaseModel model = new CaseModel(); BeanUtils.copyProperties(l, model); return model; }).collect(Collectors.toList()); return JSON.toJSONString(ret); } catch(Exception e) { return "[]"; } } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/crontroller/DubboController.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.crontroller; import com.alibaba.fastjson.JSON; import com.mmc.dubbo.doe.dto.ConnectDTO; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.dto.MethodModelDTO; import com.mmc.dubbo.doe.dto.UrlModelDTO; import com.mmc.dubbo.doe.model.ServiceModel; import com.mmc.dubbo.doe.service.ClassService; import com.mmc.dubbo.doe.service.ConnectService; import com.mmc.dubbo.doe.service.TelnetService; import com.mmc.dubbo.doe.util.StringUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.validation.constraints.NotNull; import java.util.List; /** * @author Joey * @date 2018/6/18 17:07 */ @RestController @RequestMapping("/doe/dubbo") @Slf4j public class DubboController { @Autowired private ConnectService connectService; @Autowired private ClassService classService; @Autowired private TelnetService telnetService; @RequestMapping("/doSendWithTelnet") public ResultDTO doSendWithTelnet(@NotNull ConnectDTO dto) { log.info("DubboController.doSendWithTelnet({})", JSON.toJSONString(dto)); ResultDTO resultDTO; try { resultDTO = telnetService.send(dto); } catch(Exception e) { resultDTO = ResultDTO.createExceptionResult(e, String.class); } return resultDTO; } @RequestMapping("/doSend") public ResultDTO doSend(@NotNull ConnectDTO dto) { log.info("DubboController.doSend({})", JSON.toJSONString(dto)); ResultDTO resultDTO; try { resultDTO = connectService.send(dto); } catch(Exception e) { resultDTO = ResultDTO.createExceptionResult(e, String.class); } return resultDTO; } @RequestMapping("/doListParams") public ResultDTO doListParams(@NotNull MethodModelDTO dto) { log.info("DubboController.doListParams({})", JSON.toJSONString(dto)); ResultDTO resultDTO; try { resultDTO = classService.generateMethodParamsJsonString(dto); } catch(Exception e) { resultDTO = ResultDTO.createExceptionResult(e, String.class); } return resultDTO; } @RequestMapping("/doListMethods") public ResultDTO doListMethods(@NotNull ConnectDTO dto) { log.info("DubboController.doListMethods({})", dto.getProviderKey()); ResultDTO resultDTO = new ResultDTO<>(); try { List models = classService.listMethods(dto); if (CollectionUtils.isEmpty(models)) { resultDTO = ResultDTO.createErrorResult(StringUtil.format("no methods for {}.", dto.getServiceName()), Object.class); } else { log.info("methods: {}", JSON.toJSONString(models)); resultDTO.setData(models); resultDTO.setSuccess(true); } } catch(Exception e) { resultDTO = ResultDTO.createExceptionResult(e, Object.class); resultDTO.setMsg("occur an error when get methods : " + resultDTO.getMsg()); } return resultDTO; } @RequestMapping("/doListProviders") public ResultDTO doListProviders(@NotNull ConnectDTO dto) { log.info("DubboController.doListProviders({} {} {})", dto.getServiceName(), dto.getVersion(), dto.getGroup()); ResultDTO resultDTO = new ResultDTO<>(); try { List models = connectService.listProviders(dto); if (CollectionUtils.isEmpty(models)) { resultDTO = ResultDTO.createErrorResult(StringUtil.format("no provider for {} in this zookeeper registry.", dto.getServiceName()), Object.class); } else { log.info("providers: {}", JSON.toJSONString(models)); resultDTO.setData(models); resultDTO.setSuccess(true); } } catch(Exception e) { resultDTO = ResultDTO.createExceptionResult(e, Object.class); resultDTO.setMsg("occur an error when get provider : " + resultDTO.getMsg()); } return resultDTO; } @RequestMapping("/doConnect") public ResultDTO doConnect(@NotNull String conn) { log.debug("DubboController.doConnect({})", conn); ResultDTO resultDTO = new ResultDTO<>(); try { List models = connectService.connect(conn); if (CollectionUtils.isEmpty(models)) { resultDTO = ResultDTO.createErrorResult("no provider for this this zookeeper registry.", Object.class); } else { resultDTO.setData(models); resultDTO.setSuccess(true); } } catch(Exception e) { resultDTO = ResultDTO.createExceptionResult(e, Object.class); } return resultDTO; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/crontroller/HomeController.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.crontroller; import com.mmc.dubbo.doe.service.MenuService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; /** * @author Joey * @date 2018/6/16 11:57 */ @Controller @RequestMapping("/doe/home") public class HomeController { @Autowired private MenuService menuService; @RequestMapping("/index") public String index(Model model) { // open easyCnt page defaultly. return index("f16001100", model); } @RequestMapping("/main") public String index(String mid, Model model) { // you can do something here, such as auth validation,,, Integer menuId = Integer.valueOf(mid.substring(1)); String path = menuService.getUrl(menuId); String menuHtml = menuService.getHtml(); model.addAttribute("mid", mid); model.addAttribute("menuHtml", menuHtml); return path; } @RequestMapping("/normalCnt") public String openNormalPage() { return "/pages/v3/normalCnt.html"; } @RequestMapping("/caseCnt") public String openCasePage() { return "/pages/v3/caseCnt.html"; } @RequestMapping("/easyCnt") public String openEasyPage() { return "/pages/v3/easyCnt.html"; } @RequestMapping("/addJar") public String openAddJarPage() { return "/pages/v3/addJar.html"; } @RequestMapping("/listJar") public String openListJarPage() { return "/pages/v3/listJar.html"; } @RequestMapping("/editPom") public String openEditPomPage() { return "/pages/v3/editPom.html"; } @RequestMapping("/listZk") public String openListZkPage() { return "/pages/v3/listZk.html"; } @RequestMapping("/sys") public String openSysPage() { return "/pages/v3/sys.html"; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/crontroller/PomController.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.crontroller; import com.alibaba.dubbo.common.utils.StringUtils; import com.alibaba.fastjson.JSON; import com.mmc.dubbo.doe.dto.PomDTO; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.exception.DoeException; import com.mmc.dubbo.doe.model.PomModel; import com.mmc.dubbo.doe.service.PomService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * Dependency controller. * @author Joey * @date 2018/6/17 8:53 */ @RestController @RequestMapping("/doe/pom") @Slf4j public class PomController { @Autowired private PomService pomService; /** * load jars. * * @return */ @RequestMapping("/doLoad") public ResultDTO doLoad() { log.info("PomController.doLoad"); ResultDTO resultDTO = null; try { resultDTO = pomService.loadJars(""); } catch(Exception e) { resultDTO = ResultDTO.createExceptionResult(e, String.class); } return resultDTO; } /** * parse the upload content to pom model and fork another process to invoke cmd/shell command to download the jars at background. * * @param pom * @return */ @RequestMapping("/doParse") public ResultDTO doParse(String pom) { log.info("PomController.doParse({})", pom); ResultDTO resultDTO; try { if (StringUtils.isEmpty(pom)) { throw new DoeException("the pom content can't be blank."); } // convert the pom pom = org.apache.commons.text.StringEscapeUtils.unescapeXml(pom); log.debug("pom after escape was {}", pom); PomDTO dto = new PomDTO(); dto.setPom(pom); resultDTO = pomService.invoke(dto); } catch(Exception e) { resultDTO = ResultDTO.createExceptionResult(e, PomDTO.class); } return resultDTO; } /** * invoke the mvn command to download the jars again. * * @return */ @RequestMapping("/doReparse") public ResultDTO doReparse() { log.info("PomController.doReparse({})"); ResultDTO resultDTO; try { resultDTO = pomService.invoke(); } catch(Exception e) { resultDTO = ResultDTO.createExceptionResult(e, PomDTO.class); } return resultDTO; } @RequestMapping("/doMsg") public ResultDTO getRealTimeMsg(String requestId) { log.info("PomController.getRealTimeMsg({})", requestId); ResultDTO resultDTO; try { if (StringUtils.isEmpty(requestId)) { resultDTO = ResultDTO.createErrorResult("ERROR", String.class); } else { resultDTO = pomService.getRealTimeMsg(requestId); } } catch(Exception e) { resultDTO = ResultDTO.createExceptionResult(e, String.class); } return resultDTO; } @RequestMapping("/doListJars") public String doListJars(PomDTO dto) { log.info("PomController.doListJars({})", JSON.toJSONString(dto)); String result; try { List models = pomService.listJars(dto); result = JSON.toJSONString(models); } catch(Exception e) { result = "[]"; } return result; } @RequestMapping("/doLoadPomFile") public ResultDTO doLoadPomFile() { log.info("PomController.doLoadPomFile"); ResultDTO resultDTO; try { String content = pomService.loadPomFile(null); resultDTO = ResultDTO.handleSuccess("SUCCESS", content); } catch(Exception e) { resultDTO = ResultDTO.createExceptionResult(e, String.class); } return resultDTO; } @RequestMapping("/doOverridePomFile") public ResultDTO doOverridePomFile(String content) { log.info("PomController.doOverridePomFile"); ResultDTO resultDTO; try { Boolean flag = pomService.overridePomFile("", content); resultDTO = ResultDTO.handleSuccess("SUCCESS", flag); } catch(Exception e) { resultDTO = ResultDTO.createExceptionResult(e, Boolean.class); } return resultDTO; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/crontroller/RegistryController.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.crontroller; import com.alibaba.fastjson.JSON; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.model.RegistryModel; import com.mmc.dubbo.doe.service.ConfigService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.validation.constraints.NotNull; import java.util.List; /** * @author Joey * @date 2018/7/9 19:39 */ @RestController @RequestMapping("/doe/zk") @Slf4j public class RegistryController { @Autowired private ConfigService configService; @RequestMapping("/doListZk") public String doListZk() { log.info("RegistryController.doListZk()"); String result; try { List models = configService.listRegistry(); result = JSON.toJSONString(models); } catch (Exception e) { result = "[]"; } return result; } @RequestMapping("/doListRegistry") public ResultDTO doListRegistry() { log.info("RegistryController.doListRegistry()"); ResultDTO resultDTO = new ResultDTO<>(); try { List models = configService.listRegistry(); resultDTO.setData(models); resultDTO.setSuccess(true); } catch (Exception e) { resultDTO = ResultDTO.createExceptionResult("occur an error when list registry address : ", e, Object.class); } return resultDTO; } @RequestMapping("/addRegistry") public ResultDTO addRegistry(@NotNull RegistryModel dto) { log.info("RegistryController.addRegistry({})", JSON.toJSONString(dto)); ResultDTO resultDTO; try { resultDTO = configService.addRegistry(dto); } catch (Exception e) { resultDTO = ResultDTO.createExceptionResult(e, RegistryModel.class); } return resultDTO; } @RequestMapping("/delRegistry") public ResultDTO delRegistry(@NotNull RegistryModel dto) { log.info("RegistryController.delRegistry({})", JSON.toJSONString(dto)); ResultDTO resultDTO; try { resultDTO = configService.delRegistry(dto); } catch (Exception e) { resultDTO = ResultDTO.createExceptionResult(e, RegistryModel.class); } return resultDTO; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/crontroller/SysConfController.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.crontroller; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.service.PomService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.net.MalformedURLException; /** * @author Joey * @date 2018/10/30 16:28 */ @Slf4j @RestController @RequestMapping("/doe/sys") public class SysConfController { @Value("${doe.watchdog.url}") private String url; @Resource private PomService pomService; @RequestMapping("/doReload") public ResultDTO doReload(HttpServletResponse response) { log.info("SysConfController.doReload"); try { return pomService.loadJars(""); } catch (NoSuchMethodException | MalformedURLException e) { return ResultDTO.handleException(null, null, e); } } @RequestMapping("/doRepublish") public ResultDTO doRepublish(HttpServletResponse response) { log.info("SysConfController.doRepublish"); return pomService.deleteJars(""); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/dao/CaseDAO.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.dao; import com.mmc.dubbo.doe.model.CaseModel; import java.util.List; /** * @author Joey * @date 2018/6/29 15:36 */ public interface CaseDAO { /** * save the case. * * @param model * @return */ int save(CaseModel model); /** * list all model. * @return */ List listAll(); } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/dto/BaseDTO.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.dto; import java.util.concurrent.atomic.AtomicLong; /** * @author Joey * @date 2018/6/17 10:11 */ public class BaseDTO { private static final AtomicLong counter = new AtomicLong(); private final String requestId; public BaseDTO() { this.requestId = String.valueOf(counter.getAndAdd(1)); } public String getRequestId() { return requestId; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/dto/CaseModelDTO.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.dto; import com.mmc.dubbo.doe.model.CaseModel; /** * @author Joey * @date 2018/6/29 15:58 */ public class CaseModelDTO extends CaseModel { } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/dto/ConnectDTO.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.dto; import lombok.Data; /** * @author Joey * @date 2018/6/18 19:10 */ @Data public class ConnectDTO extends BaseDTO { /** * ip and port. */ private String conn; /** * interface name; */ private String serviceName; /** * the provider cache key. */ private String providerKey; /** * method key. */ private String methodKey; /** * method name. */ private String methodName; /** * method params. */ private String json; /** * timeout of waiting for result. */ private int timeout; /** * interface version number, eg: 1.0.0 */ private String version; /** * the group of interface, eg: mmcgroup */ private String group; } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/dto/MethodModelDTO.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.dto; import com.mmc.dubbo.doe.model.MethodModel; import lombok.Data; /** * @author Joey * @date 2018/6/18 21:49 */ @Data public class MethodModelDTO { /** * the name of interface which the method belong to. */ private String interfaceName; /** * the cache key. */ private String methodKey; /** * just only the method name. */ private String methodName; /** * show on the web. */ private String methodText; public MethodModelDTO() { } public MethodModelDTO(MethodModel model) { this.methodKey = model.getKey(); this.methodName = model.getMethod().getName(); this.methodText = model.getMethodText(); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/dto/PomDTO.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.dto; import lombok.Data; /** * @author Joey * @date 2018/6/17 10:03 */ @Data public class PomDTO extends BaseDTO { /** * the pom xml content. */ private String pom; /** * the path of pom file. */ private String path; } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/dto/ResultDTO.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.dto; import com.alibaba.dubbo.common.utils.StringUtils; import lombok.Data; /** * common result. * * @author Joey * @date 2018/6/17 9:30 */ @Data public class ResultDTO { private static final long serialVersionUID = 1789151585L; private static final int DEFAULT_EXCEPTION_CODE = -1; // 默认异常码 private static final int DEFAULT_SUCCESS_CODE = 1; // 默认成功吗 private static final int DEFAULT_ERROR_CODE = 0; // 默认错误吗 private int code; // 响应码 private boolean success; // 执行结果标识 private String msg; // 消息 private String remark; // 备注 private T data; // 附带数据 private Throwable exception; // 异常 public static ResultDTO handleSuccess(String msg, T data) { ResultDTO ret = new ResultDTO<>(); ret.setCode(DEFAULT_SUCCESS_CODE); ret.setSuccess(true); ret.setMsg(msg); ret.setRemark("success"); ret.setData(data); ret.setException(null); return ret; } public static ResultDTO handleError(String msg, T data) { ResultDTO ret = new ResultDTO<>(); ret.setCode(DEFAULT_ERROR_CODE); ret.setMsg(msg); ret.setSuccess(false); ret.setRemark("occur an error"); ret.setData(data); ret.setException(null); return ret; } public static ResultDTO handleException(String msg, T data, Throwable e) { ResultDTO ret = new ResultDTO<>(); ret.setCode(DEFAULT_EXCEPTION_CODE); ret.setSuccess(false); ret.setMsg(null == msg ? e.getMessage() : msg); ret.setRemark("occur an exception"); ret.setData(data); ret.setException(e); return ret; } public static ResultDTO createExceptionResult(Throwable e, Class clazz) { return createExceptionResult("", e, clazz); } public static ResultDTO createExceptionResult(String msg, Throwable e, Class clazz) { ResultDTO ret = new ResultDTO<>(); ret.setCode(DEFAULT_EXCEPTION_CODE); ret.setSuccess(false); ret.setMsg(StringUtils.isEmpty(msg) ? e.getMessage() : msg); ret.setRemark("occur an exception"); ret.setData(null); ret.setException(e); return ret; } public static ResultDTO createErrorResult(String msg, Class clazz) { ResultDTO ret = new ResultDTO<>(); ret.setCode(DEFAULT_ERROR_CODE); ret.setMsg(msg); ret.setSuccess(false); ret.setRemark("occur an error"); ret.setData(null); ret.setException(null); return ret; } public static ResultDTO createSuccessResult(String msg, Class clazz) { return createSuccessResult(msg, null, clazz); } public static ResultDTO createSuccessResult(String msg, T data, Class clazz) { ResultDTO ret = new ResultDTO<>(); ret.setCode(DEFAULT_SUCCESS_CODE); ret.setSuccess(true); ret.setMsg(msg); ret.setRemark("success"); ret.setData(data); ret.setException(null); return ret; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/dto/UrlModelDTO.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.dto; import lombok.Data; /** * @author Joey * @date 2018/6/18 21:19 */ @Data public class UrlModelDTO { private String key; private String host; private Integer port; } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/exception/DoeException.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.exception; /** * @author Joey * @date 2018/6/13 19:29 */ public class DoeException extends RuntimeException { public DoeException(String message) { super(message); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/handler/CuratorHandler.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.handler; import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; import com.alibaba.dubbo.common.utils.StringUtils; import com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry; import com.alibaba.dubbo.remoting.zookeeper.ZookeeperClient; import com.alibaba.dubbo.remoting.zookeeper.curator.CuratorZookeeperTransporter; import com.mmc.dubbo.doe.cache.MethodCaches; import com.mmc.dubbo.doe.cache.UrlCaches; import com.mmc.dubbo.doe.dto.ConnectDTO; import com.mmc.dubbo.doe.dto.MethodModelDTO; import com.mmc.dubbo.doe.exception.DoeException; import com.mmc.dubbo.doe.model.ServiceModel; import com.mmc.dubbo.doe.model.UrlModel; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author Joey * @date 2018/6/15 10:21 */ public class CuratorHandler { private final String protocol; private final String host; private final int port; private ZookeeperClient zkClient; private ZookeeperRegistry registry; private String root = "/dubbo"; public CuratorHandler(String protocol, String host, int port) { this.protocol = protocol; this.host = host; this.port = port; } public void doConnect() throws NoSuchFieldException, IllegalAccessException { CuratorZookeeperTransporter zookeeperTransporter = new CuratorZookeeperTransporter(); URL url = new URL(protocol, host, port); registry = new ZookeeperRegistry(url, zookeeperTransporter); Field field = registry.getClass().getDeclaredField("zkClient"); field.setAccessible(true); zkClient = (ZookeeperClient) field.get(registry); } public List getInterfaces() { List ret = new ArrayList<>(); List list = zkClient.getChildren(root); for (int i = 0; i < list.size(); i++) { ServiceModel model = new ServiceModel(); model.setServiceName(list.get(i)); ret.add(model); } return ret; } public List getProviders(ConnectDTO dto) { if (null == dto) { throw new DoeException("dto can't be null."); } if (StringUtils.isEmpty(dto.getServiceName())) { throw new DoeException("service name can't be null."); } Map map = new HashMap<>(); map.put(Constants.INTERFACE_KEY, dto.getServiceName()); if (StringUtils.isNotEmpty(dto.getVersion())) { map.put(Constants.VERSION_KEY, dto.getVersion()); } if (StringUtils.isNotEmpty(dto.getGroup())) { map.put(Constants.GROUP_KEY, dto.getGroup()); } URL url = new URL(protocol, host, port, map); List list = registry.lookup(url); return UrlCaches.cache(dto.getServiceName(), list); } public List getMethods(String interfaceName) throws ClassNotFoundException { Class clazz = Class.forName(interfaceName); Method[] methods = clazz.getMethods(); return MethodCaches.cache(interfaceName, methods); // 缓存一份,方便下次调用 } public void close() { registry.destroy(); } public boolean isAvailable() { return registry.isAvailable(); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/handler/SendReceiveHandler.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.handler; import com.alibaba.dubbo.remoting.Channel; import com.alibaba.dubbo.remoting.ChannelHandler; import com.alibaba.dubbo.remoting.RemotingException; import com.alibaba.dubbo.remoting.TimeoutException; import com.alibaba.dubbo.remoting.exchange.Request; import com.alibaba.dubbo.remoting.exchange.Response; import com.alibaba.dubbo.rpc.RpcResult; import com.alibaba.fastjson.JSON; import com.mmc.dubbo.doe.context.ResponseDispatcher; import lombok.extern.slf4j.Slf4j; /** * nio event listener. * @author Joey * @date 2018/6/7 10:55 */ @Slf4j public class SendReceiveHandler implements ChannelHandler { @Override public void connected(Channel channel) throws RemotingException { log.info("SendReceiveHandler.connected"); } @Override public void disconnected(Channel channel) throws RemotingException { log.info("SendReceiveHandler.disconnected"); } @Override public void sent(Channel channel, Object message) throws RemotingException { log.info("SendReceiveHandler.sent"); if (message instanceof Request) { Request req = (Request) message; ResponseDispatcher.getDispatcher().register(req); } } @Override public void received(Channel channel, Object message) { log.info("SendReceiveHandler.received({})", JSON.toJSONString(message)); if (message instanceof Response) { Response res = (Response) message; if (res.getStatus() == Response.OK) { try { if (res.getResult() instanceof RpcResult) { ResponseDispatcher.getDispatcher().dispatch(res); } } catch (Exception e) { log.error("callback invoke error .result:" + res.getResult() + ",url:" + channel.getUrl(), e); } } else if (res.getStatus() == Response.CLIENT_TIMEOUT || res.getStatus() == Response.SERVER_TIMEOUT) { try { TimeoutException te = new TimeoutException(res.getStatus() == Response.SERVER_TIMEOUT, channel, res.getErrorMessage()); // callbackCopy.caught(te); } catch (Exception e) { log.error("callback invoke error ,url:" + channel.getUrl(), e); } } else { try { RuntimeException re = new RuntimeException(res.getErrorMessage()); // callbackCopy.caught(re); } catch (Exception e) { log.error("callback invoke error ,url:" + channel.getUrl(), e); } } } } @Override public void caught(Channel channel, Throwable exception) throws RemotingException { log.error("SendReceiveHandler.caught", exception); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/handler/StreamHandler.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.handler; import com.alibaba.dubbo.common.utils.StringUtils; import com.mmc.dubbo.doe.cache.RedisResolver; import com.mmc.dubbo.doe.context.Const; import com.mmc.dubbo.doe.dto.PomDTO; import com.mmc.dubbo.doe.util.StringUtil; import lombok.extern.slf4j.Slf4j; import java.io.BufferedReader; import java.io.InputStreamReader; /** * @author Joey * @date 2018/6/29 20:20 */ @Slf4j public class StreamHandler implements Runnable { private final String libPath; private final RedisResolver redisResolver; private final String requestId; private final Process ps; public StreamHandler(Process ps, RedisResolver redisResolver, String requestId, String libPath) { this.ps = ps; this.redisResolver = redisResolver; this.requestId = requestId; this.libPath = libPath; } /** * When an object implementing interface Runnable is used * to create a thread, starting the thread causes the object's * run method to be called in that separately executing * thread. *

* The general contract of the method run is that it may * take any action whatsoever. * * @see Thread#run() */ @Override public void run() { log.info("begin to put the message into redis."); // 获取标准输出 BufferedReader readStdout = new BufferedReader(new InputStreamReader(ps.getInputStream())); // 获取错误输出 BufferedReader readStderr = new BufferedReader(new InputStreamReader(ps.getErrorStream())); try { // auto expire String key = StringUtil.format(Const.DOE_DOWNLOAD_JAR_MESSAGE, requestId); redisResolver.rPush(key, ""); redisResolver.expire(key, 15 * 60); // ten minute String successLine; String errorLine = null; while (null != (successLine = readStdout.readLine()) || (errorLine = readStderr.readLine()) != null) { if (StringUtils.isNotEmpty(successLine)) { putToRedis(requestId, successLine); } if (StringUtils.isNotEmpty(errorLine)) { putToRedis(requestId, errorLine); } } log.info("finish download the jars to the path {}.", libPath); } catch (Exception e) { log.error("occur something wrong when download the jars.", e); } finally { try { readStdout.close(); readStderr.close(); } catch (Exception e) { log.error("occur something wrong when close resources", e); } } } private void putToRedis(String requestId, String message) { log.info("{}|{}", requestId, message); String key = StringUtil.format(Const.DOE_DOWNLOAD_JAR_MESSAGE, requestId); redisResolver.rPush(key, message); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/model/CaseModel.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.model; import lombok.Data; import java.util.Date; import java.util.Map; /** * @author Joey * @date 2018/6/28 10:42 */ @Data public class CaseModel { /** * case Id. */ private long caseId; /** * case group. */ private String caseGroup; private String caseName; private String caseDesc; private String insertTime; /** * provider address. */ private String address; private String interfaceName; /** * the method name with parameters. */ private String methodText; private String providerKey; private String methodKey; /** * parameters. */ private String json; /** * assert condition. */ private String condition; /** * expected result. */ private String expect; } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/model/MethodModel.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.model; import com.alibaba.dubbo.common.utils.StringUtils; import com.mmc.dubbo.doe.util.StringUtil; import java.lang.reflect.Method; import java.lang.reflect.Parameter; /** * @author Joey * @date 2018/6/15 14:54 */ public class MethodModel { private final Method method; private final String key; public String getKey() { return key; } public Method getMethod() { return method; } public MethodModel(String key, Method method) { this.key = key; this.method = method; } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(method.getName()); sb.append("("); for (Parameter param : method.getParameters()) { sb.append(param.getType().getName()); sb.append(" "); sb.append(param.getName()); sb.append(", "); } sb.delete(sb.length() - 2, sb.length()); sb.append(")"); return sb.toString(); } public String getMethodText() { StringBuilder sb = new StringBuilder(); sb.append(method.getName()); sb.append("("); for (Parameter param : method.getParameters()) { sb.append(getShortType(param.getType().getName())); sb.append(" "); sb.append(param.getName()); sb.append(", "); } sb.delete(sb.length() - 2, sb.length()); sb.append(")"); return sb.toString(); } private String getShortType(String name) { if (StringUtils.isEmpty(name)) { return name; } int index = name.lastIndexOf("."); if (index > 0 && index < name.length()) { name = name.substring(index + 1); } return name; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/model/PointModel.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.model; import lombok.Data; /** * ip and port. * * @author Joey * @date 2018/7/18 10:17 */ @Data public class PointModel { private String ip; private int port; public PointModel(String host, Integer port) { this.ip = host; this.port = port; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/model/PomModel.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.model; import com.alibaba.dubbo.common.utils.StringUtils; /** * @author Joey * @date 2018/6/16 9:55 */ public class PomModel { private String groupId; private String artifactId; private String version; private String scope; public String getGroupId() { return groupId; } public void setGroupId(String groupId) { this.groupId = groupId; } public String getArtifactId() { return artifactId; } public void setArtifactId(String artifactId) { this.artifactId = artifactId; } public String getVersion() { return version; } public void setVersion(String version) { this.version = version; } public String getScope() { return scope; } public void setScope(String scope) { this.scope = scope; } public boolean isBroken() { return StringUtils.isEmpty(groupId) || StringUtils.isEmpty(artifactId) || StringUtils.isEmpty(version); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/model/RegistryModel.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.model; import lombok.Data; /** * @author Joey * @date 2018/7/9 19:42 */ @Data public class RegistryModel { private String registryKey; private String registryDesc; } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/model/ServiceModel.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.model; import lombok.Data; /** * interface wrapper. * * @author Joey * @date 2018/6/18 17:51 */ @Data public class ServiceModel { private String serviceName; } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/model/UrlModel.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.model; import com.alibaba.dubbo.common.URL; /** * @author Joey * @date 2018/6/15 17:56 */ public class UrlModel { private final String key; private final URL url; public UrlModel(String key, URL url) { this.key = key; this.url = url; } public String getKey() { return key; } public URL getUrl() { return url; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/CaseService.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.model.CaseModel; import java.util.List; /** * @author Joey * @date 2018/6/29 15:21 */ public interface CaseService { /** * save the case. * * @param model * @return */ ResultDTO save(CaseModel model); /** * list all case. * * @return */ List listAll(); } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/ClassService.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service; import com.mmc.dubbo.doe.dto.ConnectDTO; import com.mmc.dubbo.doe.dto.MethodModelDTO; import com.mmc.dubbo.doe.dto.ResultDTO; import javax.validation.constraints.NotNull; import java.util.List; /** * @author Joey * @date 2018/6/28 11:28 */ public interface ClassService { /** * generate the simple json string of the method parameters. * * @param dto * @return */ ResultDTO generateMethodParamsJsonString(@NotNull MethodModelDTO dto) throws ClassNotFoundException, InstantiationException, IllegalAccessException; /** * get all methods from the given interface. * * @param dto * @return */ List listMethods(ConnectDTO dto); } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/ConfigService.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.model.RegistryModel; import java.util.List; /** * @author Joey * @date 2018/7/9 19:40 */ public interface ConfigService { /** * list all registry. * * @return */ List listRegistry(); /** * add registry. * * @return */ ResultDTO addRegistry(RegistryModel model); /** * load zk config. */ void loadZkConfigFromResource(); /** * delete registry. * * @param model * @return */ ResultDTO delRegistry(RegistryModel model); } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/ConnectService.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service; import com.mmc.dubbo.doe.dto.ConnectDTO; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.dto.MethodModelDTO; import com.mmc.dubbo.doe.dto.UrlModelDTO; import com.mmc.dubbo.doe.model.ServiceModel; import javax.validation.constraints.NotNull; import java.util.List; /** * @author Joey * @date 2018/6/18 17:10 */ public interface ConnectService { /** * connect to zk and get all providers. * * @param conn * @return */ List connect(@NotNull String conn) throws NoSuchFieldException, IllegalAccessException; /** * list providers of service. * * @param connect * @return */ List listProviders(@NotNull ConnectDTO connect) throws NoSuchFieldException, IllegalAccessException; /** * send request to the real dubbo server. * * @param dto * @return */ ResultDTO send(ConnectDTO dto) throws Exception; } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/MenuService.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service; /** * @author Joey * @date 2018/11/26 16:20 */ public interface MenuService { /** * get url map to the mid. * * @param mid menuId * @return the menu mrl */ String getUrl(Integer mid); /** * get the menu text. * @return */ String getHtml(); } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/PomService.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service; import com.mmc.dubbo.doe.dto.PomDTO; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.model.PomModel; import org.xml.sax.SAXException; import javax.validation.constraints.NotNull; import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.net.MalformedURLException; import java.util.List; /** * @author Joey * @date 2018/6/17 9:41 */ public interface PomService { /** * download jar, push message to redis. *
* it's a backdoor. * * @return */ ResultDTO invoke() throws Exception; /** * parse pom, download jar, push message to redis. * * @param dto * @return */ ResultDTO invoke(PomDTO dto) throws Exception; /** * do parse pom. * * @param xml * @return * @throws IOException * @throws SAXException */ List parsePom(@NotNull String xml) throws IOException, SAXException; /** * do append content to the end of pom.xml. * * @param models * @param pomXml * @throws Exception */ void appendPom(List models, @NotNull String pomXml) throws Exception; /** * get the real time message from redis. * * @param requestId * @return */ ResultDTO getRealTimeMsg(@NotNull String requestId); /** * load jars. * * @param libPath the lib full path. * @return */ ResultDTO loadJars(String libPath) throws NoSuchMethodException, MalformedURLException; /** * list all dependency. * * @param dto * @return */ List listJars(PomDTO dto) throws ParserConfigurationException, IOException, SAXException; /** * read the content from pom xml. * * @param pomXmlPath the path of pom xml file * @return the pom content */ String loadPomFile(String pomXmlPath); /** * override the content of pom xml. * * @param pomXmlPath the path of pom xml file * @param content text */ Boolean overridePomFile(String pomXmlPath, String content); /** * delete all jars in the specifiy path. */ ResultDTO deleteJars(String path); } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/TelnetService.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service; import com.mmc.dubbo.doe.dto.ConnectDTO; import com.mmc.dubbo.doe.dto.ResultDTO; import javax.validation.constraints.NotNull; /** * @author Joey * @date 2018/7/17 15:10 */ public interface TelnetService { /** * send message with telnet client. * @param dto * @return */ ResultDTO send(@NotNull ConnectDTO dto); } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/impl/CaseServiceImpl.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service.impl; import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.utils.StringUtils; import com.mmc.dubbo.doe.cache.MethodCaches; import com.mmc.dubbo.doe.cache.RedisResolver; import com.mmc.dubbo.doe.cache.UrlCaches; import com.mmc.dubbo.doe.context.Const; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.exception.DoeException; import com.mmc.dubbo.doe.model.CaseModel; import com.mmc.dubbo.doe.service.CaseService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.validation.constraints.NotNull; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.List; import java.util.concurrent.atomic.AtomicLong; /** * @author Joey * @date 2018/6/29 15:20 */ @Service("caseService") public class CaseServiceImpl implements CaseService { @Autowired private RedisResolver redisResolver; private static final AtomicLong counter = new AtomicLong(); /** * save the case. * * @param model * @return */ @Override public ResultDTO save(@NotNull CaseModel model) { if (StringUtils.isEmpty(model.getProviderKey())) { throw new DoeException("获取不到提供者!"); } if (StringUtils.isEmpty(model.getMethodKey())) { throw new DoeException("获取不到方法!"); } model.setAddress(UrlCaches.get(model.getProviderKey()).getUrl().getAddress()); model.setInterfaceName(UrlCaches.get(model.getProviderKey()).getUrl().getParameter(Constants.INTERFACE_KEY )); model.setMethodText(MethodCaches.get(model.getMethodKey()).getMethodText()); model.setCaseId(counter.getAndAdd(1)); model.setInsertTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); redisResolver.rPush(Const.DOE_CASE_KEY, model); // TODO // save to db. return ResultDTO.createSuccessResult("SUCCESS", model, CaseModel.class); } /** * list all case. * * @return */ @Override public List listAll() { List list = redisResolver.lGet(Const.DOE_CASE_KEY, 0, -1); if (CollectionUtils.isEmpty(list)) { // TODO // get from db and put them to cache. } return list; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/impl/ClassServiceImpl.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service.impl; import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.utils.StringUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; import com.mmc.dubbo.doe.cache.MethodCaches; import com.mmc.dubbo.doe.cache.UrlCaches; import com.mmc.dubbo.doe.context.Const; import com.mmc.dubbo.doe.context.DoeClassLoader; import com.mmc.dubbo.doe.dto.ConnectDTO; import com.mmc.dubbo.doe.dto.MethodModelDTO; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.exception.DoeException; import com.mmc.dubbo.doe.model.MethodModel; import com.mmc.dubbo.doe.model.UrlModel; import com.mmc.dubbo.doe.service.ClassService; import com.mmc.dubbo.doe.util.StringUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.RandomUtils; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.util.ReflectionUtils; import javax.validation.constraints.NotNull; import java.lang.reflect.*; import java.util.*; /** * @author Joey * @date 2018/6/28 11:32 */ @Service("classService") @Slf4j public class ClassServiceImpl implements ClassService { @Override @Cacheable(value = Const.DOE_CACHE_PREFIX, key = "#dto.serviceName") public List listMethods(ConnectDTO dto) { log.info("begin to invoke listMethods({})", JSON.toJSONString(dto)); String interfaceName = dto.getServiceName(); if (StringUtils.isEmpty(interfaceName)) { // get provider UrlModel provider = UrlCaches.get(dto.getProviderKey()); if (null == provider) { throw new DoeException(StringUtil.format("can't found the provider key {}.", dto.getProviderKey())); } interfaceName = provider.getUrl().getParameter(Constants.INTERFACE_KEY); } if (StringUtils.isEmpty(interfaceName)) { throw new DoeException("interface name and provider cache key can't both be blank."); } try { // show only public method // Class clazz = Class.forName(interfaceName); // load classes without affect system class since v1.2.0 Class clazz = DoeClassLoader.getClass(interfaceName); Method[] methods = clazz.getMethods(); // convert and cache method object associate witch the unique key return MethodCaches.cache(interfaceName, methods); } catch (ClassNotFoundException e) { throw new DoeException("can't found the interface from classpath, please add the dependency first."); } } /** * generate the simple json string of the method parameters. * * @param dto * @return */ @Override public ResultDTO generateMethodParamsJsonString(@NotNull MethodModelDTO dto) throws ClassNotFoundException, InstantiationException, IllegalAccessException { Method method = null; // get method from cache if (StringUtils.isNotEmpty(dto.getMethodKey())) { MethodModel model = MethodCaches.get(dto.getMethodKey()); method = (null == model) ? null : model.getMethod(); } // search from classpath if (null == method && StringUtils.isNotEmpty(dto.getInterfaceName()) && StringUtils.isNotEmpty(dto.getMethodName())) { method = getMethodByName(dto.getInterfaceName(), dto.getMethodName()); } if (null == method) { return ResultDTO.createErrorResult( StringUtil.format("can't find the method[{}] in the interface[{}]", dto.getInterfaceName(), dto.getMethodName()), String.class); } List objects = new ArrayList<>(); for (Parameter param : method.getParameters()) { objects.add(initObject(param.getType(), param.getParameterizedType())); } String json = JSON.toJSONString(objects, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteDateUseDateFormat); return ResultDTO.createSuccessResult("SUCCESS", json, String.class); } /** * we must to make sure we have one no parameter constructor in our class. * * @param clazz * @param type * @return */ private Object initObject(Class clazz, Type type) throws IllegalAccessException, InstantiationException { log.debug("begin to init {}", clazz.getTypeName()); if (clazz == Integer.class || clazz == int.class) { return RandomUtils.nextInt(0, 1000); } else if (clazz == String.class) { String base = UUID.randomUUID().toString(); return base.substring(RandomUtils.nextInt(1, base.length())); } else if (clazz == Long.class || clazz == long.class) { return RandomUtils.nextLong(0, 1000); } else if (clazz == Short.class || clazz == short.class) { return RandomUtils.nextInt(0, 100); } else if (clazz == Date.class) { return new Date(); } else if (clazz == List.class) { if (null != type) { return initArrayList(type); } } else if (clazz == Map.class) { return new HashMap<>(); } else if (clazz == Set.class) { return new HashSet<>(); } Object ret; try { ret = clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { log.debug("you should define one no parameter constructor.", e); return new Object(); } List fields = new ArrayList<>(); ReflectionUtils.doWithFields(clazz, fields::add); for (Field field : fields) { field.setAccessible(true); boolean isStatic = Modifier.isStatic(field.getModifiers()); if(isStatic) { continue; } try { field.set(ret, initObject(field.getType(), field.getGenericType())); } catch (Exception e) { log.debug("can't set value for the field, you should complete the method initObject(Class clazz, Type type) later.", e); } } return ret; } private List initArrayList(Type genericType) throws InstantiationException, IllegalAccessException { List list = new ArrayList<>(); if (genericType == null) { return list; } // 如果是泛型参数的类型 if (genericType instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType) genericType; // 得到泛型里的class类型对象 Class genericClazz = (Class) pt.getActualTypeArguments()[0]; list.add(initObject(genericClazz, null)); // too deep... } return list; } /** * we will get wrong result if there are overload method in the interface. * * @param interfaceName * @param methodName * @return * @throws ClassNotFoundException */ private Method getMethodByName(String interfaceName, String methodName) throws ClassNotFoundException { Class clazz = Class.forName(interfaceName); for (Method method : clazz.getDeclaredMethods()) { if (methodName.equals(method.getName())) { return method; } } return null; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/impl/ConfigServiceImpl.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service.impl; import com.alibaba.dubbo.common.utils.CollectionUtils; import com.alibaba.dubbo.common.utils.StringUtils; import com.alibaba.fastjson.JSON; import com.mmc.dubbo.doe.cache.RedisResolver; import com.mmc.dubbo.doe.context.Const; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.exception.DoeException; import com.mmc.dubbo.doe.model.RegistryModel; import com.mmc.dubbo.doe.service.ConfigService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resource; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.stream.Collectors; /** * @author Joey * @date 2018/7/9 19:41 */ @Service("configService") @Slf4j public class ConfigServiceImpl implements ConfigService { @Autowired private RedisResolver redisResolver; @Value("classpath:registry.json") private Resource resource; /** * list all registry. * * @return */ @Override public List listRegistry() { List ret = new ArrayList<>(); Set list = redisResolver.sMembers(Const.DOE_REGISTRY_KEY); if (CollectionUtils.isNotEmpty(list)) { ret = list.stream().map(l -> { RegistryModel model = new RegistryModel(); BeanUtils.copyProperties(l, model); return model; }).collect(Collectors.toList()); } return ret; } /** * add registry. * * @param model * @return */ @Override public ResultDTO addRegistry(RegistryModel model) { if (null == model) { throw new DoeException("the paramter can't be null."); } if (StringUtils.isEmpty(model.getRegistryKey())) { throw new DoeException("the registryKey can not be null."); } if (StringUtils.isEmpty(model.getRegistryDesc())) { throw new DoeException("the registryDesc can not be null."); } boolean flag = redisResolver.sAdd(Const.DOE_REGISTRY_KEY, model) > 0; if (flag) { return ResultDTO.createSuccessResult("success to add registry.", RegistryModel.class); } else { return ResultDTO.createErrorResult("fail to add registry, check whether if duplicate configuration or not.", RegistryModel.class); } } @Override public ResultDTO delRegistry(RegistryModel model) { if (null == model) { throw new DoeException("the paramter can't be null."); } if (StringUtils.isEmpty(model.getRegistryKey())) { throw new DoeException("the registryKey can not be null."); } if (StringUtils.isEmpty(model.getRegistryDesc())) { throw new DoeException("the registryDesc can not be null."); } boolean flag = redisResolver.sRem(Const.DOE_REGISTRY_KEY, model) > 0; if (flag) { return ResultDTO.createSuccessResult("success to delete registry.", RegistryModel.class); } else { return ResultDTO.createErrorResult("fail to delete registry, check whether if the configuration exists or not.", RegistryModel.class); } } @PostConstruct public void loadConfig() { log.info("ConfigServiceImpl.loadConfig()"); loadZkConfigFromResource(); } @Override public void loadZkConfigFromResource() { try { BufferedReader tBufferedReader = new BufferedReader(new InputStreamReader(resource.getInputStream())); StringBuilder sb = new StringBuilder(); String sTempOneLine; while ((sTempOneLine = tBufferedReader.readLine()) != null) { sb.append(sTempOneLine); } List list = JSON.parseArray(sb.toString(), RegistryModel.class); redisResolver.sAdd(Const.DOE_REGISTRY_KEY,list.toArray()); } catch (Exception e) { log.error("occur an error when reading zk address configuration.", e); } } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/impl/ConnectServiceImpl.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service.impl; import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; import com.alibaba.dubbo.remoting.exchange.Request; import com.alibaba.dubbo.rpc.RpcInvocation; import com.alibaba.dubbo.rpc.RpcResult; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; import com.mmc.dubbo.doe.cache.CuratorCaches; import com.mmc.dubbo.doe.cache.MethodCaches; import com.mmc.dubbo.doe.cache.UrlCaches; import com.mmc.dubbo.doe.client.DoeClient; import com.mmc.dubbo.doe.context.ResponseDispatcher; import com.mmc.dubbo.doe.dto.ConnectDTO; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.dto.UrlModelDTO; import com.mmc.dubbo.doe.exception.DoeException; import com.mmc.dubbo.doe.handler.CuratorHandler; import com.mmc.dubbo.doe.model.MethodModel; import com.mmc.dubbo.doe.model.ServiceModel; import com.mmc.dubbo.doe.model.UrlModel; import com.mmc.dubbo.doe.service.ConnectService; import com.mmc.dubbo.doe.util.ParamUtil; import com.mmc.dubbo.doe.util.StringUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; /** * @author Joey * @date 2018/6/18 17:10 */ @Service("connectService") @Slf4j public class ConnectServiceImpl implements ConnectService { @Override public ResultDTO send(@NotNull ConnectDTO dto) throws Exception { log.info("begin to send {} .", JSON.toJSONString(dto)); // get provider url URL url = UrlCaches.get(dto.getProviderKey()).getUrl(); // get method MethodModel methodModel = MethodCaches.get(dto.getMethodKey()); // parse parameter Object[] params = ParamUtil.parseJson(dto.getJson(), methodModel.getMethod()); url = url.addParameter(Constants.CODEC_KEY, "dubbo"); // 非常重要,必须要设置编码器协议类型 DoeClient client = new DoeClient(url); client.doConnect(); // set the path variables Map map = ParamUtil.getAttachmentFromUrl(url); // create request. Request req = new Request(); req.setVersion("2.0.0"); req.setTwoWay(true); req.setData(new RpcInvocation(methodModel.getMethod(), params, map)); client.send(req); int timeout = (0 == dto.getTimeout()) ? 10 : dto.getTimeout(); // send timeout CompletableFuture future = ResponseDispatcher.getDispatcher().getFuture(req); RpcResult result = future.get(timeout, TimeUnit.SECONDS); ResponseDispatcher.getDispatcher().removeFuture(req); return ResultDTO.createSuccessResult("SUCCESS", JSON.toJSONString(result.getValue(), SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteDateUseDateFormat), String.class); } @Override public List listProviders(@NotNull ConnectDTO connect) throws NoSuchFieldException, IllegalAccessException { // get client CuratorHandler client = CuratorCaches.getHandler(connect.getConn()); if (null == client) { throw new DoeException("the cache is validate, please reconnect to zk againt."); } List providers = client.getProviders(connect); // throw fast json error if you don't convert simple pojo // I have no idea why the UrlModel object will throw stack over flow exception. List ret = new ArrayList<>(); providers.forEach(p -> { UrlModelDTO m = new UrlModelDTO(); m.setKey(p.getKey()); m.setHost(p.getUrl().getHost()); m.setPort(p.getUrl().getPort()); ret.add(m); }); return ret; } /** * connect to zk and get all providers. * * @param conn * @return */ @Override public List connect(@NotNull String conn) throws NoSuchFieldException, IllegalAccessException { // get client CuratorHandler client = CuratorCaches.getHandler(conn); if (!client.isAvailable()) { throw new DoeException(StringUtil.format("can't connect to {}", conn)); } // get providers List list = client.getInterfaces(); return list; } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/impl/MenuServiceImpl.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service.impl; import com.mmc.dubbo.doe.auth.MenuNode; import com.mmc.dubbo.doe.auth.MenuTree; import com.mmc.dubbo.doe.service.MenuService; import com.mmc.dubbo.doe.util.JsonFileUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resource; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.annotation.PostConstruct; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; import java.text.MessageFormat; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @author Joey * @date 2018/11/26 16:21 */ @Service("menuService") @Slf4j public class MenuServiceImpl implements MenuService { /** * 用户静态资源文件路径. */ private static final String STATIC_MENU_PATH = "templates/pages/v3/"; @Value("classpath:menu.json") private Resource resource; /** * cache urls. */ private Map cacheMap; /** * the html text. */ private String html; @Override public String getHtml() { return html; } @Override public String getUrl(Integer mid) { return cacheMap.get(mid); } private void cacheMenu(List tree) { if (CollectionUtils.isEmpty(tree)) { return; } cacheMap = tree.stream().collect(Collectors.toMap(MenuNode::getMenuId, MenuTree::getMenuUrl)); } /** * 真正生成文件方法. */ @PostConstruct private void createFile() throws IOException { List tree = JsonFileUtil.readList(resource.getInputStream(), MenuNode.class); MenuNode root = null; cacheMenu(tree); try { root = buildTree(tree, -1); } catch (Exception e) { log.error("fail to build the menu tree:", e); return; } String html = toHtml("", root); String projectRealPath = getProjectRealPath(); try { createFile(projectRealPath, html); } catch (Exception e) { log.error("fail to create the menu file:", e); } } private String getProjectRealPath() throws FileNotFoundException { // useless when you run doe in the jar way, so comment these code. // String path = ResourceUtils.getURL("classpath:").getPath(); String path = "/app/doe/"; path = path + STATIC_MENU_PATH; return path; } private void createFile(String projectRealPath, String html) throws Exception { // 创建目录 File path = new File(projectRealPath); if (!path.exists()) { path.mkdirs(); } // 删除旧文件 File file = new File(path, "menu.html"); if (file.exists()) { file.delete(); } // 写入权限菜单 PrintWriter out = new PrintWriter(file); String content = "" // + "
" + "\n
\n" + "\n \n" + "\n
\n" + html + "\n
\n" + "\n \n" + "\n
\n" + "\n \n" + "\n
\n" + "\n \n" + "\n \n" // + "\n
" + "
"; this.html = content; out.append(content); out.flush(); out.close(); } private MenuNode buildTree(List menuList, int pMenuId) { MenuNode result = new MenuNode(); MenuNode temp = new MenuNode(); for (int i = 0; i < menuList.size(); i++) { if (menuList.get(i).getPmenuId() == pMenuId) { result.getChildren().add(menuList.get(i)); temp = buildTree(menuList, menuList.get(i).getMenuId()); if (temp.getChildren().size() > 0) { menuList.get(i).setChildren(temp.getChildren()); } } } return result; } private String toHtml(String elementId, MenuNode root) { StringBuilder sb = new StringBuilder(); boolean useCache = true; // 判断是否使用缓存 for (MenuNode item : root.getChildren()) { if (null != item && item.getChildren().size() > 0) { if (item.getPmenuId() == -1) { String html = "\n
    \n"; html = MessageFormat.format(html, item.getMenuId().toString()); sb.append(html); sb.append(toHtml(null, item)); sb.append("
"); } else { String html = "\n" + "
  • \n" + " \n" + " \n" + " {2} \n" + " \n" + " \n" + "
      \n" + "\n"; html = MessageFormat.format(html, item.getMenuId().toString(), item.getMenuStyle(), item.getMenuName()); sb.append(html); sb.append(toHtml(null, item)); sb.append("
  • "); } } else { String html = "\n" + "
  • \n" + " \n" + " \n" + "{3} \n" + " \n" + "
  • \n" + "\n"; if (useCache) { html = MessageFormat.format(html, item.getMenuId().toString(), item.getMenuUrl(), item.getMenuStyle(), item.getMenuName(), "main"); } else { html = MessageFormat.format(html, item.getMenuId().toString(), item.getMenuUrl(), item.getMenuStyle(), item.getMenuName(), item.getMenuUrl()); } sb.append(html); } } return sb.toString(); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/impl/PomServiceImpl.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service.impl; import com.alibaba.dubbo.common.utils.StringUtils; import com.alibaba.fastjson.JSON; import com.mmc.dubbo.doe.cache.RedisResolver; import com.mmc.dubbo.doe.client.ProcessClient; import com.mmc.dubbo.doe.context.Const; import com.mmc.dubbo.doe.context.DoeClassLoader; import com.mmc.dubbo.doe.context.TaskContainer; import com.mmc.dubbo.doe.dto.PomDTO; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.exception.DoeException; import com.mmc.dubbo.doe.model.PomModel; import com.mmc.dubbo.doe.service.PomService; import com.mmc.dubbo.doe.util.DOMUtil; import com.mmc.dubbo.doe.util.FileUtil; import com.mmc.dubbo.doe.util.StringUtil; import lombok.extern.slf4j.Slf4j; import org.apache.tomcat.util.http.fileupload.FileUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import javax.validation.constraints.NotNull; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import java.io.*; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; /** * dependency service. * * @author Joey * @date 2018/6/17 9:42 */ @Service("pomService") @Slf4j public class PomServiceImpl implements PomService { private Lock locker = new ReentrantLock(); @Value("${doe.dependency.pom}") private String pomXml; @Value("${doe.dependency.lib}") private String libPath = null; @Autowired private RedisResolver redisResolver; @Override public ResultDTO invoke() { PomDTO dto = new PomDTO(); ProcessClient processClient = new ProcessClient(dto, redisResolver, pomXml, libPath); // just can only invoke one task to downloaded the jars. // we can invoke more task after we have finished all code actually. if (processClient.isRunning()) { return ResultDTO.createErrorResult("some task was already running at background, please try again for a few minutes later.", PomDTO.class); } try { locker.lock(); // clear old directory deleteJars(libPath); // download jars asynchronously log.info("fork another thread to download jars."); TaskContainer.getTaskContainer().execute(processClient); log.info("success fork another thread to download jars."); } catch (Exception e) { throw e; } finally { locker.unlock(); } // return the success signal and redirect another url to get real time information. return ResultDTO.createSuccessResult("the download task is running at background, please wait...", dto, PomDTO.class); } @Override public ResultDTO invoke(@NotNull PomDTO dto) throws Exception { ProcessClient processClient = new ProcessClient(dto, redisResolver, pomXml, libPath); // just can only invoke one task to downloaded the jars. // we can invoke more task after we have finished all code actually. if (processClient.isRunning()) { return ResultDTO.createErrorResult("some task was already running at background, please try again for a few minutes later.", PomDTO.class); } // parse the pom log.info("begin to parse the pom."); List models = parsePom(dto.getPom()); // check the model is good or not checkModels(models); // check maven configuration checkMaven(models); try { locker.lock(); // append the parse content to the end of real pom.xml. log.info("begin to append the parse content to the end of {}.", pomXml); appendPom(models, pomXml); // download jars asynchronously log.info("fork another thread to download jars."); TaskContainer.getTaskContainer().execute(processClient); log.info("success fork another thread to download jars."); } catch (Exception e) { throw e; } finally { locker.unlock(); } // return the success signal and redirect another url to get real time information. return ResultDTO.createSuccessResult("the download task is running at background, please wait...", dto, PomDTO.class); } // the mvn environment variable must be set. private void checkMaven(List models) { } @Override public void appendPom(List models, @NotNull String pomXml) throws Exception { File file = new File(pomXml); // 1.得到DOM解析器的工厂实例 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); // 2.从DOM工厂里获取DOM解析器 DocumentBuilder db = dbf.newDocumentBuilder(); // 3.解析XML文档,得到document,即DOM树 Document doc = db.parse(file); // root Element rootDependency = (Element) doc.getElementsByTagName("dependencies").item(0); for (PomModel model : models) { // 创建节点 Element dependencyElement = doc.createElement("dependency"); // 创建group节点 Element groupElement = doc.createElement("groupId"); groupElement.appendChild(doc.createTextNode(model.getGroupId())); // 创建artifactId节点 Element artifactIdElement = doc.createElement("artifactId"); artifactIdElement.appendChild(doc.createTextNode(model.getArtifactId())); // 创建version节点 Element versionElement = doc.createElement("version"); versionElement.appendChild(doc.createTextNode(model.getVersion())); // 添加父子关系 dependencyElement.appendChild(groupElement); dependencyElement.appendChild(artifactIdElement); dependencyElement.appendChild(versionElement); // 追加节点 rootDependency.appendChild(dependencyElement); } // 保存xml文件 TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); // 格式化 transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); // 设置编码类型 transformer.setOutputProperty(OutputKeys.ENCODING, "GB2312"); DOMSource domSource = new DOMSource(doc); StreamResult result = new StreamResult(new FileOutputStream(file)); // 把DOM树转换为xml文件 transformer.transform(domSource, result); } private void checkModels(List models) { if (CollectionUtils.isEmpty(models)) { throw new DoeException("Can't parse any dependency, please check your pom before you execute the do parse request."); } models.forEach(m -> { if (m.isBroken()) { throw new DoeException(StringUtil.format("The content of pom is Incomplete.[{}]", JSON.toJSONString(m))); } }); } @Override public List parsePom(@NotNull String xml) throws IOException, SAXException { List models = new ArrayList<>(); xml = "" + xml + ""; Document document = DOMUtil.parse(xml); Node root = document.getElementsByTagName("root").item(0); for (int i = 0; i < root.getChildNodes().getLength(); i++) { Node dependencyNode = root.getChildNodes().item(i); String nodeName = dependencyNode.getNodeName(); if ("dependency".equals(nodeName)) { PomModel model = new PomModel(); for (int j = 0; j < dependencyNode.getChildNodes().getLength(); j++) { Node childNode = dependencyNode.getChildNodes().item(j); if (childNode.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) childNode; if ("groupId".equals(element.getNodeName())) { model.setGroupId(element.getFirstChild().getNodeValue()); } else if ("artifactId".equals(element.getNodeName())) { model.setArtifactId(element.getFirstChild().getNodeValue()); } else if ("version".equals(element.getNodeName())) { model.setVersion(element.getFirstChild().getNodeValue()); } } } models.add(model); } } return models; } @Override public ResultDTO getRealTimeMsg(@NotNull String requestId) { String key = StringUtil.format(Const.DOE_DOWNLOAD_JAR_MESSAGE, requestId); ResultDTO ret = ResultDTO.createSuccessResult("SUCCESS", String.class); boolean isRunning = redisResolver.hasKey(Const.DOE_DOWNLOAD_JAR_TASK); if (!isRunning) { // if the task was done, get all message prevent the task running too fast. List list = redisResolver.lGet(key, 0, -1); String data = list.stream().map(l -> l.toString()).collect(Collectors.joining("\r\n")); ret.setMsg("download completed!"); ret.setData(data); ret.setCode(Const.COMPLETE_FLAG); } else { // loop time of queue length long size = redisResolver.lGetListSize(key); StringBuilder sb = new StringBuilder(); while (--size > 0) { String value = (String) redisResolver.lPop(key); sb.append("\r\n"); sb.append(value); } ret.setData(sb.toString()); ret.setCode(Const.RUNNING_FlAG); // tell the jquery continue to ask message. } return ret; } @Override public ResultDTO loadJars(String path) { String realPath = (StringUtils.isEmpty(path)) ? this.libPath : path; DoeClassLoader classLoader = new DoeClassLoader(realPath); try { classLoader.clearCache(); classLoader.loadJars(); return ResultDTO.createSuccessResult("load jars completely and successfully", String.class); } catch (Exception e) { return ResultDTO.handleException("occur an error when load jars", null, e); } } @Deprecated // since v1.1.0 public ResultDTO loadJars$$(String path) throws NoSuchMethodException, MalformedURLException { String fullLibPath = StringUtils.isEmpty(path) ? this.libPath : path; if (StringUtils.isEmpty(fullLibPath)) { return ResultDTO.createErrorResult(StringUtil.format("can't found the path {}", fullLibPath), String.class); } if (!new File(fullLibPath).exists()) { throw new DoeException(StringUtil.format("the path[{}] is not exists.", fullLibPath)); } log.info("begin to load jars from {}.", fullLibPath); // check for changes prevent to do useless job. checkForChanges(); // 系统类库路径 File libPath = new File(fullLibPath); // 获取所有的.jar和.zip文件 File[] jarFiles = libPath.listFiles((dir, name) -> name.endsWith(".jar") || name.endsWith(".zip")); if (jarFiles != null) { // 从URLClassLoader类中获取类所在文件夹的方法 // 对于jar文件,可以理解为一个存放class文件的文件夹 Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); boolean accessible = method.isAccessible(); // 获取方法的访问权限 try { if (!accessible) { method.setAccessible(true); // 设置方法的访问权限 } // 获取系统类加载器 URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); for (File file : jarFiles) { URL url = file.toURI().toURL(); try { method.invoke(classLoader, url); log.debug("读取jar文件[name={}]", file.getName()); } catch (Exception e) { log.error("读取jar文件[name={}]失败", file.getName()); } } return ResultDTO.createSuccessResult("load jars completely and successfully", String.class); } finally { method.setAccessible(accessible); } } else { return ResultDTO.createErrorResult(StringUtil.format("Can't found any jars from {}.", fullLibPath), String.class); } } /** * list all dependency. * * @param dto * @return */ @Override public List listJars(PomDTO dto) throws ParserConfigurationException, IOException, SAXException { List result = new ArrayList<>(); String pomPath = (StringUtils.isEmpty(dto.getPath())) ? pomXml : dto.getPath(); File file = new File(pomPath); // 1.得到DOM解析器的工厂实例 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); // 2.从DOM工厂里获取DOM解析器 DocumentBuilder db = dbf.newDocumentBuilder(); // 3.解析XML文档,得到document,即DOM树 Document doc = db.parse(file); // list NodeList list = doc.getElementsByTagName("dependency"); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; PomModel model = new PomModel(); model.setGroupId(element.getElementsByTagName("groupId").item(0).getTextContent()); model.setArtifactId(element.getElementsByTagName("artifactId").item(0).getTextContent()); model.setVersion(element.getElementsByTagName("version").item(0).getTextContent()); result.add(model); } } return result; } private void checkForChanges() { // TODO // check if any changes } @Override public String loadPomFile(String pomXmlPath) { String pomPath = StringUtils.isEmpty(pomXmlPath) ? pomXml : pomXmlPath; return FileUtil.readToString(pomPath); } @Override public Boolean overridePomFile(String pomXmlPath, String content) { String pomPath = StringUtils.isEmpty(pomXmlPath) ? pomXml : pomXmlPath; FileUtil.WriteStringToFile(pomPath, content); return true; } @Override public ResultDTO deleteJars(String path) { String realPath = (StringUtils.isEmpty(path)) ? this.libPath : path; if (StringUtils.isEmpty(realPath)) { throw new DoeException(StringUtil.format("can't found the path {}", path)); } File libPath = new File(realPath); if (!libPath.exists()) { throw new DoeException(StringUtil.format("the path[{}] is not exists.", path)); } File[] jarFiles = libPath.listFiles((dir, name) -> name.endsWith(".jar") || name.endsWith(".zip")); if (jarFiles != null) { for (File file : jarFiles) { log.info("begin to delete file {}.", file.getAbsolutePath()); boolean ret = file.delete(); if (!ret) { try { log.info("begin to force to delete file {}.", file.getAbsolutePath()); FileUtils.forceDelete(file); } catch (IOException e) { e.printStackTrace(); } } } } return ResultDTO.handleSuccess("delete sucess!", path); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/service/impl/TelnetServiceImpl.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.service.impl; import com.alibaba.dubbo.common.utils.StringUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; import com.mmc.dubbo.doe.dto.ConnectDTO; import com.mmc.dubbo.doe.dto.ResultDTO; import com.mmc.dubbo.doe.model.PointModel; import com.mmc.dubbo.doe.service.TelnetService; import com.mmc.dubbo.doe.util.ParamUtil; import com.mmc.dubbo.doe.util.StringUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.net.telnet.TelnetClient; import org.springframework.stereotype.Service; import javax.validation.constraints.NotNull; import java.io.BufferedInputStream; import java.io.InputStream; import java.io.PrintStream; /** * @author Joey * @date 2018/7/17 19:43 */ @Slf4j @Service("telnetService") public class TelnetServiceImpl implements TelnetService { /** * send message with telnet client. * * @param dto * @return */ @Override public ResultDTO send(@NotNull ConnectDTO dto) { PointModel model = ParamUtil.parsePointModel(dto.getConn()); TelnetClient telnetClient = null; try { telnetClient = new TelnetClient("VT220"); // 指明Telnet终端类型,否则会返回来的数据中文会乱码 telnetClient.setDefaultTimeout(dto.getTimeout() <= 0 ? 5000 : dto.getTimeout()); // socket延迟时间:5000ms telnetClient.connect(model.getIp(), model.getPort()); // 建立一个连接,默认端口是23 InputStream in = telnetClient.getInputStream(); // 读取命令的流 PrintStream out = new PrintStream(telnetClient.getOutputStream()); // 写命令的流 String command = makeCommand(dto.getServiceName(), dto.getMethodName(), dto.getJson()); log.info("send: {}", command); out.println("\r\n"); out.println(command); out.println("\r\n"); out.flush(); // handle inputStream StringBuilder sb = new StringBuilder(); BufferedInputStream bi = new BufferedInputStream(in); while (true) { byte[] buffer = new byte[1024]; int len = bi.read(buffer); if (len <= -1) { break; } String msg = new String(buffer, 0, len, "GBK"); sb.append(msg); if (msg.endsWith("dubbo>")) { break; } } out.println("exit"); // 写命令 out.flush(); // 将命令发送到telnet Server telnetClient.disconnect(); String ret = sb.toString(); String lineSeparator = System.getProperty("line.separator", "\n"); if (StringUtils.isNotEmpty(ret)) { ret = ret.split(lineSeparator)[0]; } log.info("receive: {}", ret); // format the json string String result = JSON.toJSONString(JSON.parse(ret), SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteDateUseDateFormat); return ResultDTO.createSuccessResult("SUCCESS", result, String.class); } catch (Exception e) { log.error("occur an error when sending message with telnet client.", e); return ResultDTO.createExceptionResult(e, String.class); } finally { try { if (null != telnetClient) { telnetClient.disconnect(); } } catch (Exception e) { e.printStackTrace(); } } } private String makeCommand(String serviceName, String methodName, String json) { return StringUtil.format("invoke {}.{}({})", serviceName, methodName, json); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/util/DOMUtil.java ================================================ package com.mmc.dubbo.doe.util; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; import java.util.Vector; import javax.naming.ConfigurationException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; /** * DOM utility * * Thanks to Tom Fennelly from Jboss Group * */ public class DOMUtil { /** * Create a new W3C Document. *

    * Handles exceptions etc. * @return The new Document instance. * @throws ConfigurationException */ public static Document createDocument() throws ConfigurationException { Document doc = null; try { doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { throw new ConfigurationException("Failed to create ESB Configuration Document instance."); } return doc; } /** * Parse the supplied XML String and return the associated W3C Document object. * * @param xml XML String. * @return The W3C Document object associated with the input stream. */ public static Document parse(String xml) throws SAXException, IOException { return parseStream(new ByteArrayInputStream(xml.getBytes()), false, false); } /** * Parse the XML stream and return the associated W3C Document object. *

    * Performs a namespace unaware parse. * * @param stream * The stream to be parsed. * @param validate * True if the document is to be validated, otherwise false. * @param expandEntityRefs * Expand entity References as per * {@link DocumentBuilderFactory#setExpandEntityReferences(boolean)}. * @return The W3C Document object associated with the input stream. */ public static Document parseStream(InputStream stream, boolean validate, boolean expandEntityRefs) throws SAXException, IOException { return parseStream(stream, validate, expandEntityRefs, false); } /** * Parse the XML stream and return the associated W3C Document object. * * @param stream * The stream to be parsed. * @param validate * True if the document is to be validated, otherwise false. * @param expandEntityRefs * Expand entity References as per * {@link DocumentBuilderFactory#setExpandEntityReferences(boolean)}. * @param namespaceAware * True if the document parse is to be namespace aware, * otherwise false. * @return The W3C Document object associated with the input stream. */ public static Document parseStream(InputStream stream, boolean validate, boolean expandEntityRefs, boolean namespaceAware) throws SAXException, IOException { if (stream == null) { throw new IllegalArgumentException( "null 'stream' arg in method call."); } try { DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance(); DocumentBuilder docBuilder = null; factory.setValidating(validate); factory.setExpandEntityReferences(expandEntityRefs); factory.setNamespaceAware(namespaceAware); docBuilder = factory.newDocumentBuilder(); return docBuilder.parse(stream); } catch (ParserConfigurationException e) { IllegalStateException state = new IllegalStateException( "Unable to parse XML stream - XML Parser not configured correctly."); state.initCause(e); throw state; } catch (FactoryConfigurationError e) { IllegalStateException state = new IllegalStateException( "Unable to parse XML stream - DocumentBuilderFactory not configured correctly."); state.initCause(e); throw state; } } public static String getAttribute(Element element, String name, String defaultVal) { if(element.hasAttribute(name)) { return element.getAttribute(name); } else { return defaultVal; } } /** * Add an Element node to the supplied parent name. * @param parent The parent to to which the new Element node is to be added. * @param elementName The name of the Element to be added. * @return The new Element. */ public static Element addElement(Node parent, String elementName) { Element element = null; if(parent instanceof Document) { element = ((Document)parent).createElement(elementName); } else { element = parent.getOwnerDocument().createElement(elementName); } parent.appendChild(element); return element; } /** * Remove all attributes having an empty value. * @param element The element to be processed. */ public static void removeEmptyAttributes(Element element) { NamedNodeMap attributes = element.getAttributes(); int attribCount = attributes.getLength(); for(int i = attribCount - 1; i >= 0; i--) { Attr attribute = (Attr) attributes.item(i); // Note - doesn't account for namespaces. Not needed here ! if(attribute.getValue().equals("")) { attributes.removeNamedItem(attribute.getName()); } } } /** * Serialize the supplied DOM node to the specified file in the specified output directory. * @param node The DOM node to be serialised. * @param outdir The directory into which the file is to be serialised. * @param fileName The name of the file. * @throws ConfigurationException Unable to serialise the node. */ public static void serialize(Node node, File outdir, String fileName) throws ConfigurationException { serialize(node, new StreamResult(new File(outdir, fileName))); } public static void serialize(Node node, OutputStream out) throws ConfigurationException { serialize(node, new StreamResult(out)); } /** * Serialize the supplied DOM node to the supplied DOM StreamResult instance. * @param node The DOM node to be serialised. * @param streamRes The StreamResult into which the node is to be serialised. * @throws ConfigurationException Unable to serialise the node. */ public static void serialize(Node node, StreamResult streamRes) throws ConfigurationException { serialize(node, streamRes, false); } /** * Serialize the supplied DOM node to the supplied DOM StreamResult instance. * @param node The DOM node to be serialised. * @param streamRes The StreamResult into which the node is to be serialised. * @param omitXmlDecl Omit the XML declaration. * @throws ConfigurationException Unable to serialise the node. */ public static void serialize(Node node, StreamResult streamRes, boolean omitXmlDecl) throws ConfigurationException { DOMSource domSource = new DOMSource(node); try { Transformer transformer = TransformerFactory.newInstance().newTransformer(); // There's a bug in Java 5 re this code (formatting). // See http://forum.java.sun.com/thread.jspa?threadID=562510&start=0 and it explains the // whys of the following code. // transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "4"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, (omitXmlDecl?"yes":"no")); transformer.transform(domSource, streamRes); } catch (Exception e) { throw new ConfigurationException("Failed to serialize ESB Configuration Document instance."); } } /** * Count the DOM element nodes before the supplied node, having the specified * tag name, not including the node itself. *

    * Counts the sibling nodes. * * @param node Node whose element siblings are to be counted. * @param tagName The tag name of the sibling elements to be counted. * @return The number of siblings elements before the supplied node with the * specified tag name. */ public static int countElementsBefore(Node node, String tagName) { Node parent = node.getParentNode(); NodeList siblings = parent.getChildNodes(); int count = 0; int siblingCount = siblings.getLength(); for (int i = 0; i < siblingCount; i++) { Node sibling = siblings.item(i); if (sibling == node) { break; } if (sibling.getNodeType() == Node.ELEMENT_NODE && ((Element) sibling).getTagName().equals(tagName)) { count++; } } return count; } /** * Copy the nodes of a NodeList into the supplied list. *

    * This is not a cloneCollectionTemplateElement. It's just a copy of the node references. *

    * Allows iteration over the Nodelist using the copy in the knowledge that * the list will remain the same length, even if we modify the underlying NodeList. * Using the NodeList can result in problems because elements can get removed from * the list while we're iterating over it. *

    * This code was acquired donated by the Milyn Smooks project. * * @param nodeList Nodelist to copy. * @return List copy. */ public static List copyNodeList(NodeList nodeList) { List copy = new Vector(); if (nodeList != null) { int nodeCount = nodeList.getLength(); for (int i = 0; i < nodeCount; i++) { copy.add(nodeList.item(i)); } } return copy; } public static Element getNextSiblingElement(Node node) { Node nextSibling = node.getNextSibling(); while (nextSibling != null) { if (nextSibling.getNodeType() == Node.ELEMENT_NODE) { return (Element) nextSibling; } nextSibling = nextSibling.getNextSibling(); } return null; } public static Node getFirstChildByType(Element element, int nodeType) { NodeList children = element.getChildNodes(); int childCount = children.getLength(); for(int i = 0; i < childCount; i++) { Node child = children.item(i); if (child.getNodeType() == nodeType) { return child; } } return null; } private static String ELEMENT_NAME_FUNC = "/name()"; private static XPathFactory xPathFactory = XPathFactory.newInstance(); /** * Get the W3C NodeList instance associated with the XPath selection * supplied. *

    * NOTE: Taken from Milyn Commons. * * @param node The document node to be searched. * @param xpath The XPath String to be used in the selection. * @return The W3C NodeList instance at the specified location in the * document, or null. */ public static NodeList getNodeList(Node node, String xpath) { if (node == null) { throw new IllegalArgumentException( "null 'document' arg in method call."); } else if (xpath == null) { throw new IllegalArgumentException( "null 'xpath' arg in method call."); } try { XPath xpathEvaluater = xPathFactory.newXPath(); if (xpath.endsWith(ELEMENT_NAME_FUNC)) { return (NodeList) xpathEvaluater.evaluate(xpath.substring(0, xpath.length() - ELEMENT_NAME_FUNC.length()), node, XPathConstants.NODESET); } else { return (NodeList) xpathEvaluater.evaluate(xpath, node, XPathConstants.NODESET); } } catch (XPathExpressionException e) { throw new IllegalArgumentException("bad 'xpath' expression [" + xpath + "]."); } } /** * Get the W3C Node instance associated with the XPath selection supplied. *

    * NOTE: Taken from Milyn Commons. * * @param node The document node to be searched. * @param xpath The XPath String to be used in the selection. * @return The W3C Node instance at the specified location in the document, * or null. */ public static Node getNode(Node node, String xpath) { NodeList nodeList = getNodeList(node, xpath); if (nodeList == null || nodeList.getLength() == 0) { return null; } else { return nodeList.item(0); } } /** * Get the name from the supplied element. *

    * Returns the {@link Node#getLocalName() localName} of the element * if set (namespaced element), otherwise the * element's {@link Element#getTagName() tagName} is returned. *

    * NOTE: Taken from Milyn Smooks. * * @param element The element. * @return The element name. */ public static String getName(Element element) { String name = element.getLocalName(); if(name != null) { return name; } else { return element.getTagName(); } } /** * Copy child node references from source to target. * @param source Source Node. * @param target Target Node. */ public static void copyChildNodes(Node source, Node target) { List nodeList = copyNodeList(source.getChildNodes()); int childCount = nodeList.size(); for(int i = 0; i < childCount; i++) { target.appendChild((Node)nodeList.get(i)); } } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/util/FileUtil.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.util; import com.mmc.dubbo.doe.exception.DoeException; import lombok.extern.slf4j.Slf4j; import java.io.*; /** * @author Joey * @date 2018/11/23 17:28 */ @Slf4j public class FileUtil { public static String readToString(String fileName) throws DoeException { String encoding = "UTF-8"; File file = new File(fileName); Long filelength = file.length(); byte[] filecontent = new byte[filelength.intValue()]; try { FileInputStream in = new FileInputStream(file); int read = in.read(filecontent); in.close(); log.info("read:{} filelength:{}", read, filelength); } catch (IOException e) { throw new DoeException(StringUtil.format("can't load the file content, because {}.", e.getMessage())); } try { return new String(filecontent, encoding); } catch (UnsupportedEncodingException e) { throw new DoeException(StringUtil.format("can't load the file content, because {}.", e.getMessage())); } } public static void WriteStringToFile(String fileName, String text) { try { try (PrintWriter out = new PrintWriter(new File(fileName).getAbsoluteFile())) { out.print(text); } } catch (IOException e) { throw new RuntimeException(e); } } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/util/JsonFileUtil.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.util; import com.alibaba.fastjson.JSON; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; /** * Json文件处理类. * @author Joey * @date 2018/11/14 9:23 */ public class JsonFileUtil { /** * 从JSON文件流中读取列表. */ public static List readList(InputStream inputStream, Class clazz) throws IOException { BufferedReader tBufferedReader = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder sb = new StringBuilder(); String sTempOneLine; while ((sTempOneLine = tBufferedReader.readLine()) != null) { sb.append(sTempOneLine); } return JSON.parseArray(sb.toString(), clazz); } /** * 从JSON文件流中读取对象. */ public static T readObject(InputStream inputStream, Class clazz) throws IOException { BufferedReader tBufferedReader = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder sb = new StringBuilder(); String sTempOneLine; while ((sTempOneLine = tBufferedReader.readLine()) != null) { sb.append(sTempOneLine); } return JSON.parseObject(sb.toString(), clazz); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/util/MD5Util.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.util; import lombok.extern.slf4j.Slf4j; import java.security.MessageDigest; /** * MD5加密工具类. * @author Joey * @date 2018/6/24 16:40 */ @Slf4j public class MD5Util { public final static String encrypt(String pwd) { //用于加密的字符 char md5String[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; try { //使用平台的默认字符集将此 String 编码为 byte序列,并将结果存储到一个新的 byte数组中 byte[] btInput = pwd.getBytes(); //信息摘要是安全的单向哈希函数,它接收任意大小的数据,并输出固定长度的哈希值。 MessageDigest mdInst = MessageDigest.getInstance("MD5"); //MessageDigest对象通过使用 update方法处理数据, 使用指定的byte数组更新摘要 mdInst.update(btInput); // 摘要更新之后,通过调用digest()执行哈希计算,获得密文 byte[] md = mdInst.digest(); // 把密文转换成十六进制的字符串形式 int j = md.length; char str[] = new char[j * 2]; int k = 0; for (int i = 0; i < j; i++) { // i = 0 byte byte0 = md[i]; //95 str[k++] = md5String[byte0 >>> 4 & 0xf]; // 5 str[k++] = md5String[byte0 & 0xf]; // F } //返回经过加密后的字符串 return new String(str); } catch (Exception e) { log.error("encrypt error: ", e); return null; } } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/util/ParamUtil.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.util; import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; import com.alibaba.dubbo.common.utils.PojoUtils; import com.alibaba.dubbo.common.utils.StringUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.mmc.dubbo.doe.exception.DoeException; import com.mmc.dubbo.doe.model.PointModel; import javax.validation.constraints.NotNull; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * @author Joey * @date 2018/6/13 19:22 */ public class ParamUtil { public static HashMap getAttachmentFromUrl(URL url) throws Exception { String interfaceName = url.getParameter(Constants.INTERFACE_KEY, ""); if (StringUtils.isEmpty(interfaceName)) { throw new DoeException("找不到接口名称!"); } HashMap map = new HashMap(); map.put(Constants.PATH_KEY, interfaceName); map.put(Constants.VERSION_KEY, url.getParameter(Constants.VERSION_KEY)); map.put(Constants.GROUP_KEY, url.getParameter(Constants.GROUP_KEY)); /** * doesn't necessary to set these params. * map.put(Constants.SIDE_KEY, Constants.CONSUMER_SIDE); map.put(Constants.DUBBO_VERSION_KEY, Version.getVersion()); map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis())); map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid())); map.put(Constants.METHODS_KEY, methodNames); map.put(Constants.INTERFACE_KEY, interfaceName); map.put(Constants.VERSION_KEY, "1.0"); // 不能设置这个,不然服务端找不到invoker */ return map; } /** * prepare method parameters. * * @param jsonStr * @param invokeMethod * @return */ public static Object[] parseJson(String jsonStr, Method invokeMethod) { jsonStr = jsonStr.trim(); // we should convert to array model if more the one parameter prevent someone forgetting about it. String json; if (invokeMethod.getParameters().length > 0) { if (StringUtils.isEmpty(jsonStr)) { throw new DoeException("json parameter can't be blank."); } if (jsonStr.startsWith("[") && jsonStr.endsWith("]")) { json = jsonStr; } else { json = "[" + jsonStr + "]"; } } else { json = jsonStr; } List list = JSON.parseArray(json, Object.class); Object[] array = PojoUtils.realize(list.toArray(), invokeMethod.getParameterTypes(), invokeMethod.getGenericParameterTypes()); return array; } /** * parse ip and port from the conn. * * @param conn * @return */ public static PointModel parsePointModel(@NotNull String conn) { // split host and port String[] pairs = conn.replace(":", ":").split(":"); String host = pairs[0]; String port = pairs[1]; return new PointModel(host, Integer.valueOf(port)); } } ================================================ FILE: mmc-dubbo-doe/src/main/java/com/mmc/dubbo/doe/util/StringUtil.java ================================================ /* * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Founder. You shall not disclose such Confidential Information * and shall use it only in accordance with the terms of the agreements * you entered into with Founder. * */ package com.mmc.dubbo.doe.util; /** * 字符串工具类. * @author Joey * 2016年10月17日 下午4:08:55 */ public class StringUtil { /** * 简单格式化{}样式的字符串.
    * String str = "aaa{} bbb{} ccc{}";
    * System.out.println(StringUtil.format(str, "1", "2", "3")); * @param src 源字符串 * @param param 跟源字符串{}匹配的个数字符串 * @return */ public static String format(String src, Object... param) { int i = 0; int index = 0; StringBuffer sb = new StringBuffer(src); while (-1 != (index = sb.indexOf("{}"))) { sb.replace(index, index + 2, String.valueOf(param[i++])); } return sb.toString(); } public static void main(String[] args) { String str = "aaa{} bbb{} ccc{}"; System.out.println(StringUtil.format(str, "1", "2", "3")); } } ================================================ FILE: mmc-dubbo-doe/src/main/resources/application-dev.yml ================================================ # ====================server==================== server: port: 9876 spring: thymeleaf: # 开发环境禁用页面缓存 cache: false encoding: utf-8 mode: HTML5 redis: # 数据库索引 database: 0 host: 127.0.0.1 port: 6379 jedis: pool: # 最大连接数 max-active: 8 # 最大空闲 max-idle: 8 # 最小空闲 min-idle: 4 # 连接超时时间 timeout: 10000 # ====================doe==================== doe: dependency: # 用于下载依赖的pom文件 pom: /app/doe/pom.xml # 用于存放下载的jar的目录 lib: /app/doe/lib/ # 用于执行mvn命令超时时间(秒) timeout: 20 watchdog: url: http://localhost:8000 ================================================ FILE: mmc-dubbo-doe/src/main/resources/application-prd.yml ================================================ # ====================server==================== server: port: 9876 spring: thymeleaf: # 开发环境禁用页面缓存 cache: true encoding: utf-8 mode: HTML5 prefix: classpath:/templates suffix: .html redis: # 数据库索引 database: 0 host: 127.0.0.1 port: 6379 jedis: pool: # 最大连接数 max-active: 8 # 最大空闲 max-idle: 8 # 最小空闲 min-idle: 4 # 连接超时时间 timeout: 10000 # ====================doe==================== doe: dependency: # 用于下载依赖的pom文件 pom: /app/doe/pom.xml # 用于存放下载的jar的目录 lib: /app/doe/lib/ # 用于执行mvn命令超时时间(秒) timeout: 20 watchdog: url: http://localhost:8000 ================================================ FILE: mmc-dubbo-doe/src/main/resources/application.yml ================================================ spring: profiles: active: @spring.profiles.active@ ================================================ FILE: mmc-dubbo-doe/src/main/resources/logback-spring.xml ================================================ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n ${LOG_PATH}/info.log ${LOG_PATH}/info.%d{yyyy-MM-dd}.%i.log.zip 60 30GB 128MB %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n INFO ACCEPT DENY ${LOG_PATH}/warn.log ${LOG_PATH}/warn.%d{yyyy-MM-dd}.%i.log.zip 60 30GB 128MB %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n WARN ACCEPT DENY ${LOG_PATH}/error.log ${LOG_PATH}/error.%d{yyyy-MM-dd}.%i.log.zip 60 30GB 128MB %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n ERROR ACCEPT DENY 0 512 ================================================ FILE: mmc-dubbo-doe/src/main/resources/menu.json ================================================ [ { "autoId":"1", "menuId":"16000000", "pmenuId":"-1", "menuName":"Doe", "menuUrl":"#", "menuStyle":"#", "mlevel":"0", "mleft":"0", "mright":"0", "isUse":"1", "seq":"1000", "cTime":"2018/5/26 11:23", "uTime":"2018/5/26 11:23", "sysId":"1605" }, { "autoId":"2", "menuId":"16001000", "pmenuId":"16000000", "menuName":"连接发送", "menuUrl":"#", "menuStyle":"icon-list", "mlevel":"1", "mleft":"0", "mright":"0", "isUse":"1", "seq":"1001", "cTime":"2018/5/26 11:23", "uTime":"2018/5/25 20:56", "sysId":"1605" }, { "autoId":"3", "menuId":"16001100", "pmenuId":"16001000", "menuName":"极简模式", "menuUrl":"/pages/v3/easyCnt.html", "menuStyle":"icon-double-angle-right", "mlevel":"2", "mleft":"0", "mright":"0", "isUse":"1", "seq":"1002", "cTime":"2018/5/26 11:23", "uTime":"2018/5/26 11:23", "sysId":"1605" }, { "autoId":"4", "menuId":"16001200", "pmenuId":"16001000", "menuName":"普通模式", "menuUrl":"/pages/v3/normalCnt.html", "menuStyle":"icon-double-angle-right", "mlevel":"2", "mleft":"0", "mright":"0", "isUse":"1", "seq":"1003", "cTime":"2018/5/26 11:23", "uTime":"2018/5/26 11:23", "sysId":"1605" }, { "autoId":"5", "menuId":"16001300", "pmenuId":"16001000", "menuName":"用例模式", "menuUrl":"/pages/v3/caseCnt.html", "menuStyle":"icon-double-angle-right", "mlevel":"2", "mleft":"0", "mright":"0", "isUse":"1", "seq":"1004", "cTime":"2018/5/26 11:23", "uTime":"2018/5/26 11:23", "sysId":"1605" }, { "autoId":"6", "menuId":"16002000", "pmenuId":"16000000", "menuName":"依赖管理", "menuUrl":"#", "menuStyle":"icon-exchange", "mlevel":"1", "mleft":"0", "mright":"0", "isUse":"1", "seq":"1005", "cTime":"2018/5/26 11:23", "uTime":"2018/5/26 11:23", "sysId":"1605" }, { "autoId":"7", "menuId":"16002100", "pmenuId":"16002000", "menuName":"增加依赖", "menuUrl":"/pages/v3/addJar.html", "menuStyle":"icon-double-angle-right", "mlevel":"2", "mleft":"0", "mright":"0", "isUse":"1", "seq":"1006", "cTime":"2018/5/26 11:23", "uTime":"2018/5/26 11:23", "sysId":"1605" }, { "autoId":"8", "menuId":"16002200", "pmenuId":"16002000", "menuName":"依赖列表", "menuUrl":"/pages/v3/listJar.html", "menuStyle":"icon-double-angle-right", "mlevel":"2", "mleft":"0", "mright":"0", "isUse":"1", "seq":"1007", "cTime":"2018/5/26 11:23", "uTime":"2018/5/26 11:23", "sysId":"1605" }, { "autoId":"9", "menuId":"16002300", "pmenuId":"16002000", "menuName":"依赖编辑", "menuUrl":"/pages/v3/editPom.html", "menuStyle":"icon-double-angle-right", "mlevel":"2", "mleft":"0", "mright":"0", "isUse":"1", "seq":"1008", "cTime":"2018/5/26 11:23", "uTime":"2018/5/26 11:23", "sysId":"1605" }, { "autoId":"10", "menuId":"16003000", "pmenuId":"16000000", "menuName":"系统管理", "menuUrl":"#", "menuStyle":"icon-cogs", "mlevel":"1", "mleft":"0", "mright":"0", "isUse":"1", "seq":"1009", "cTime":"2018/5/26 11:23", "uTime":"2018/5/26 11:23", "sysId":"1605" }, { "autoId":"11", "menuId":"16003100", "pmenuId":"16003000", "menuName":"注册中心", "menuUrl":"/pages/v3/listZk.html", "menuStyle":"icon-double-angle-right", "mlevel":"0", "mleft":"0", "mright":"0", "isUse":"1", "seq":"1010", "cTime":"2018/5/26 11:23", "uTime":"2018/5/26 11:23", "sysId":"1605" }, { "autoId":"12", "menuId":"16003200", "pmenuId":"16003000", "menuName":"系统配置", "menuUrl":"/pages/v3/sys.html", "menuStyle":"icon-double-angle-right", "mlevel":"0", "mleft":"0", "mright":"0", "isUse":"1", "seq":"1011", "cTime":"2018/5/26 11:23", "uTime":"2018/5/26 11:23", "sysId":"1605" } ] ================================================ FILE: mmc-dubbo-doe/src/main/resources/registry.json ================================================ [ { "registryKey": "127.0.0.1:2181", "registryDesc": "localhost -- 127.0.0.1:2181" } ] ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/css/bootstrap-editable.css ================================================ /*! X-editable - v1.4.6 * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * http://github.com/vitalets/x-editable * Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */ .editableform { margin-bottom: 0; /* overwrites bootstrap margin */ } .editableform .control-group { margin-bottom: 0; /* overwrites bootstrap margin */ white-space: nowrap; /* prevent wrapping buttons on new line */ line-height: 20px; /* overwriting bootstrap line-height. See #133 */ } .editable-buttons { display: inline-block; /* should be inline to take effect of parent's white-space: nowrap */ vertical-align: top; margin-left: 7px; /* inline-block emulation for IE7*/ zoom: 1; *display: inline; } .editable-buttons.editable-buttons-bottom { display: block; margin-top: 7px; margin-left: 0; } .editable-input { vertical-align: top; display: inline-block; /* should be inline to take effect of parent's white-space: nowrap */ width: auto; /* bootstrap-responsive has width: 100% that breakes layout */ white-space: normal; /* reset white-space decalred in parent*/ /* display-inline emulation for IE7*/ zoom: 1; *display: inline; } .editable-buttons .editable-cancel { margin-left: 7px; } /*for jquery-ui buttons need set height to look more pretty*/ .editable-buttons button.ui-button-icon-only { height: 24px; width: 30px; } .editableform-loading { background: url('../img/loading.gif') center center no-repeat; height: 25px; width: auto; min-width: 25px; } .editable-inline .editableform-loading { background-position: left 5px; } .editable-error-block { max-width: 300px; margin: 5px 0 0 0; width: auto; white-space: normal; } /*add padding for jquery ui*/ .editable-error-block.ui-state-error { padding: 3px; } .editable-error { color: red; } /* ---- For specific types ---- */ .editableform .editable-date { padding: 0; margin: 0; float: left; } /* move datepicker icon to center of add-on button. See https://github.com/vitalets/x-editable/issues/183 */ .editable-inline .add-on .icon-th { margin-top: 3px; margin-left: 1px; } /* checklist vertical alignment */ .editable-checklist label input[type="checkbox"], .editable-checklist label span { vertical-align: middle; margin: 0; } .editable-checklist label { white-space: nowrap; } /* set exact width of textarea to fit buttons toolbar */ .editable-wysihtml5 { width: 566px; height: 250px; } /* clear button shown as link in date inputs */ .editable-clear { clear: both; font-size: 0.9em; text-decoration: none; text-align: right; } /* IOS-style clear button for text inputs */ .editable-clear-x { background: url('../img/clear.png') center center no-repeat; display: block; width: 13px; height: 13px; position: absolute; opacity: 0.6; z-index: 100; top: 50%; right: 6px; margin-top: -6px; } .editable-clear-x:hover { opacity: 1; } .editable-pre-wrapped { white-space: pre-wrap; } .editable-container.editable-popup { max-width: none !important; /* without this rule poshytip/tooltip does not stretch */ } .editable-container.popover { width: auto; /* without this rule popover does not stretch */ } .editable-container.editable-inline { display: inline-block; vertical-align: middle; width: auto; /* inline-block emulation for IE7*/ zoom: 1; *display: inline; } .editable-container.ui-widget { font-size: inherit; /* jqueryui widget font 1.1em too big, overwrite it */ z-index: 9990; /* should be less than select2 dropdown z-index to close dropdown first when click */ } .editable-click, a.editable-click, a.editable-click:hover { text-decoration: none; border-bottom: dashed 1px #0088cc; } .editable-click.editable-disabled, a.editable-click.editable-disabled, a.editable-click.editable-disabled:hover { color: #585858; cursor: default; border-bottom: none; } .editable-empty, .editable-empty:hover, .editable-empty:focus{ font-style: italic; color: #DD1144; /* border-bottom: none; */ text-decoration: none; } .editable-unsaved { font-weight: bold; } .editable-unsaved:after { /* content: '*'*/ } .editable-bg-transition { -webkit-transition: background-color 1400ms ease-out; -moz-transition: background-color 1400ms ease-out; -o-transition: background-color 1400ms ease-out; -ms-transition: background-color 1400ms ease-out; transition: background-color 1400ms ease-out; } /*see https://github.com/vitalets/x-editable/issues/139 */ .form-horizontal .editable { padding-top: 5px; display:inline-block; } /*! * Datepicker for Bootstrap * * Copyright 2012 Stefan Petre * Improvements by Andrew Rowls * Licensed under the Apache License v2.0 * http://www.apache.org/licenses/LICENSE-2.0 * */ .datepicker { padding: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; direction: ltr; /*.dow { border-top: 1px solid #ddd !important; }*/ } .datepicker-inline { width: 220px; } .datepicker.datepicker-rtl { direction: rtl; } .datepicker.datepicker-rtl table tr td span { float: right; } .datepicker-dropdown { top: 0; left: 0; } .datepicker-dropdown:before { content: ''; display: inline-block; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 7px solid #ccc; border-bottom-color: rgba(0, 0, 0, 0.2); position: absolute; top: -7px; left: 6px; } .datepicker-dropdown:after { content: ''; display: inline-block; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 6px solid #ffffff; position: absolute; top: -6px; left: 7px; } .datepicker > div { display: none; } .datepicker.days div.datepicker-days { display: block; } .datepicker.months div.datepicker-months { display: block; } .datepicker.years div.datepicker-years { display: block; } .datepicker table { margin: 0; } .datepicker td, .datepicker th { text-align: center; width: 20px; height: 20px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; border: none; } .table-striped .datepicker table tr td, .table-striped .datepicker table tr th { background-color: transparent; } .datepicker table tr td.day:hover { background: #eeeeee; cursor: pointer; } .datepicker table tr td.old, .datepicker table tr td.new { color: #999999; } .datepicker table tr td.disabled, .datepicker table tr td.disabled:hover { background: none; color: #999999; cursor: default; } .datepicker table tr td.today, .datepicker table tr td.today:hover, .datepicker table tr td.today.disabled, .datepicker table tr td.today.disabled:hover { background-color: #fde19a; background-image: -moz-linear-gradient(top, #fdd49a, #fdf59a); background-image: -ms-linear-gradient(top, #fdd49a, #fdf59a); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fdd49a), to(#fdf59a)); background-image: -webkit-linear-gradient(top, #fdd49a, #fdf59a); background-image: -o-linear-gradient(top, #fdd49a, #fdf59a); background-image: linear-gradient(top, #fdd49a, #fdf59a); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdd49a', endColorstr='#fdf59a', GradientType=0); border-color: #fdf59a #fdf59a #fbed50; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); color: #000; } .datepicker table tr td.today:hover, .datepicker table tr td.today:hover:hover, .datepicker table tr td.today.disabled:hover, .datepicker table tr td.today.disabled:hover:hover, .datepicker table tr td.today:active, .datepicker table tr td.today:hover:active, .datepicker table tr td.today.disabled:active, .datepicker table tr td.today.disabled:hover:active, .datepicker table tr td.today.active, .datepicker table tr td.today:hover.active, .datepicker table tr td.today.disabled.active, .datepicker table tr td.today.disabled:hover.active, .datepicker table tr td.today.disabled, .datepicker table tr td.today:hover.disabled, .datepicker table tr td.today.disabled.disabled, .datepicker table tr td.today.disabled:hover.disabled, .datepicker table tr td.today[disabled], .datepicker table tr td.today:hover[disabled], .datepicker table tr td.today.disabled[disabled], .datepicker table tr td.today.disabled:hover[disabled] { background-color: #fdf59a; } .datepicker table tr td.today:active, .datepicker table tr td.today:hover:active, .datepicker table tr td.today.disabled:active, .datepicker table tr td.today.disabled:hover:active, .datepicker table tr td.today.active, .datepicker table tr td.today:hover.active, .datepicker table tr td.today.disabled.active, .datepicker table tr td.today.disabled:hover.active { background-color: #fbf069 \9; } .datepicker table tr td.today:hover:hover { color: #000; } .datepicker table tr td.today.active:hover { color: #fff; } .datepicker table tr td.range, .datepicker table tr td.range:hover, .datepicker table tr td.range.disabled, .datepicker table tr td.range.disabled:hover { background: #eeeeee; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; } .datepicker table tr td.range.today, .datepicker table tr td.range.today:hover, .datepicker table tr td.range.today.disabled, .datepicker table tr td.range.today.disabled:hover { background-color: #f3d17a; background-image: -moz-linear-gradient(top, #f3c17a, #f3e97a); background-image: -ms-linear-gradient(top, #f3c17a, #f3e97a); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f3c17a), to(#f3e97a)); background-image: -webkit-linear-gradient(top, #f3c17a, #f3e97a); background-image: -o-linear-gradient(top, #f3c17a, #f3e97a); background-image: linear-gradient(top, #f3c17a, #f3e97a); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f3c17a', endColorstr='#f3e97a', GradientType=0); border-color: #f3e97a #f3e97a #edde34; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; } .datepicker table tr td.range.today:hover, .datepicker table tr td.range.today:hover:hover, .datepicker table tr td.range.today.disabled:hover, .datepicker table tr td.range.today.disabled:hover:hover, .datepicker table tr td.range.today:active, .datepicker table tr td.range.today:hover:active, .datepicker table tr td.range.today.disabled:active, .datepicker table tr td.range.today.disabled:hover:active, .datepicker table tr td.range.today.active, .datepicker table tr td.range.today:hover.active, .datepicker table tr td.range.today.disabled.active, .datepicker table tr td.range.today.disabled:hover.active, .datepicker table tr td.range.today.disabled, .datepicker table tr td.range.today:hover.disabled, .datepicker table tr td.range.today.disabled.disabled, .datepicker table tr td.range.today.disabled:hover.disabled, .datepicker table tr td.range.today[disabled], .datepicker table tr td.range.today:hover[disabled], .datepicker table tr td.range.today.disabled[disabled], .datepicker table tr td.range.today.disabled:hover[disabled] { background-color: #f3e97a; } .datepicker table tr td.range.today:active, .datepicker table tr td.range.today:hover:active, .datepicker table tr td.range.today.disabled:active, .datepicker table tr td.range.today.disabled:hover:active, .datepicker table tr td.range.today.active, .datepicker table tr td.range.today:hover.active, .datepicker table tr td.range.today.disabled.active, .datepicker table tr td.range.today.disabled:hover.active { background-color: #efe24b \9; } .datepicker table tr td.selected, .datepicker table tr td.selected:hover, .datepicker table tr td.selected.disabled, .datepicker table tr td.selected.disabled:hover { background-color: #9e9e9e; background-image: -moz-linear-gradient(top, #b3b3b3, #808080); background-image: -ms-linear-gradient(top, #b3b3b3, #808080); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#b3b3b3), to(#808080)); background-image: -webkit-linear-gradient(top, #b3b3b3, #808080); background-image: -o-linear-gradient(top, #b3b3b3, #808080); background-image: linear-gradient(top, #b3b3b3, #808080); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#b3b3b3', endColorstr='#808080', GradientType=0); border-color: #808080 #808080 #595959; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); color: #fff; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); } .datepicker table tr td.selected:hover, .datepicker table tr td.selected:hover:hover, .datepicker table tr td.selected.disabled:hover, .datepicker table tr td.selected.disabled:hover:hover, .datepicker table tr td.selected:active, .datepicker table tr td.selected:hover:active, .datepicker table tr td.selected.disabled:active, .datepicker table tr td.selected.disabled:hover:active, .datepicker table tr td.selected.active, .datepicker table tr td.selected:hover.active, .datepicker table tr td.selected.disabled.active, .datepicker table tr td.selected.disabled:hover.active, .datepicker table tr td.selected.disabled, .datepicker table tr td.selected:hover.disabled, .datepicker table tr td.selected.disabled.disabled, .datepicker table tr td.selected.disabled:hover.disabled, .datepicker table tr td.selected[disabled], .datepicker table tr td.selected:hover[disabled], .datepicker table tr td.selected.disabled[disabled], .datepicker table tr td.selected.disabled:hover[disabled] { background-color: #808080; } .datepicker table tr td.selected:active, .datepicker table tr td.selected:hover:active, .datepicker table tr td.selected.disabled:active, .datepicker table tr td.selected.disabled:hover:active, .datepicker table tr td.selected.active, .datepicker table tr td.selected:hover.active, .datepicker table tr td.selected.disabled.active, .datepicker table tr td.selected.disabled:hover.active { background-color: #666666 \9; } .datepicker table tr td.active, .datepicker table tr td.active:hover, .datepicker table tr td.active.disabled, .datepicker table tr td.active.disabled:hover { background-color: #006dcc; background-image: -moz-linear-gradient(top, #0088cc, #0044cc); background-image: -ms-linear-gradient(top, #0088cc, #0044cc); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); background-image: -webkit-linear-gradient(top, #0088cc, #0044cc); background-image: -o-linear-gradient(top, #0088cc, #0044cc); background-image: linear-gradient(top, #0088cc, #0044cc); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0); border-color: #0044cc #0044cc #002a80; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); color: #fff; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); } .datepicker table tr td.active:hover, .datepicker table tr td.active:hover:hover, .datepicker table tr td.active.disabled:hover, .datepicker table tr td.active.disabled:hover:hover, .datepicker table tr td.active:active, .datepicker table tr td.active:hover:active, .datepicker table tr td.active.disabled:active, .datepicker table tr td.active.disabled:hover:active, .datepicker table tr td.active.active, .datepicker table tr td.active:hover.active, .datepicker table tr td.active.disabled.active, .datepicker table tr td.active.disabled:hover.active, .datepicker table tr td.active.disabled, .datepicker table tr td.active:hover.disabled, .datepicker table tr td.active.disabled.disabled, .datepicker table tr td.active.disabled:hover.disabled, .datepicker table tr td.active[disabled], .datepicker table tr td.active:hover[disabled], .datepicker table tr td.active.disabled[disabled], .datepicker table tr td.active.disabled:hover[disabled] { background-color: #0044cc; } .datepicker table tr td.active:active, .datepicker table tr td.active:hover:active, .datepicker table tr td.active.disabled:active, .datepicker table tr td.active.disabled:hover:active, .datepicker table tr td.active.active, .datepicker table tr td.active:hover.active, .datepicker table tr td.active.disabled.active, .datepicker table tr td.active.disabled:hover.active { background-color: #003399 \9; } .datepicker table tr td span { display: block; width: 23%; height: 54px; line-height: 54px; float: left; margin: 1%; cursor: pointer; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; } .datepicker table tr td span:hover { background: #eeeeee; } .datepicker table tr td span.disabled, .datepicker table tr td span.disabled:hover { background: none; color: #999999; cursor: default; } .datepicker table tr td span.active, .datepicker table tr td span.active:hover, .datepicker table tr td span.active.disabled, .datepicker table tr td span.active.disabled:hover { background-color: #006dcc; background-image: -moz-linear-gradient(top, #0088cc, #0044cc); background-image: -ms-linear-gradient(top, #0088cc, #0044cc); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); background-image: -webkit-linear-gradient(top, #0088cc, #0044cc); background-image: -o-linear-gradient(top, #0088cc, #0044cc); background-image: linear-gradient(top, #0088cc, #0044cc); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0); border-color: #0044cc #0044cc #002a80; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); color: #fff; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); } .datepicker table tr td span.active:hover, .datepicker table tr td span.active:hover:hover, .datepicker table tr td span.active.disabled:hover, .datepicker table tr td span.active.disabled:hover:hover, .datepicker table tr td span.active:active, .datepicker table tr td span.active:hover:active, .datepicker table tr td span.active.disabled:active, .datepicker table tr td span.active.disabled:hover:active, .datepicker table tr td span.active.active, .datepicker table tr td span.active:hover.active, .datepicker table tr td span.active.disabled.active, .datepicker table tr td span.active.disabled:hover.active, .datepicker table tr td span.active.disabled, .datepicker table tr td span.active:hover.disabled, .datepicker table tr td span.active.disabled.disabled, .datepicker table tr td span.active.disabled:hover.disabled, .datepicker table tr td span.active[disabled], .datepicker table tr td span.active:hover[disabled], .datepicker table tr td span.active.disabled[disabled], .datepicker table tr td span.active.disabled:hover[disabled] { background-color: #0044cc; } .datepicker table tr td span.active:active, .datepicker table tr td span.active:hover:active, .datepicker table tr td span.active.disabled:active, .datepicker table tr td span.active.disabled:hover:active, .datepicker table tr td span.active.active, .datepicker table tr td span.active:hover.active, .datepicker table tr td span.active.disabled.active, .datepicker table tr td span.active.disabled:hover.active { background-color: #003399 \9; } .datepicker table tr td span.old, .datepicker table tr td span.new { color: #999999; } .datepicker th.datepicker-switch { width: 145px; } .datepicker thead tr:first-child th, .datepicker tfoot tr th { cursor: pointer; } .datepicker thead tr:first-child th:hover, .datepicker tfoot tr th:hover { background: #eeeeee; } .datepicker .cw { font-size: 10px; width: 12px; padding: 0 2px 0 5px; vertical-align: middle; } .datepicker thead tr:first-child th.cw { cursor: default; background-color: transparent; } .input-append.date .add-on i, .input-prepend.date .add-on i { display: block; cursor: pointer; width: 16px; height: 16px; } .input-daterange input { text-align: center; } .input-daterange input:first-child { -webkit-border-radius: 3px 0 0 3px; -moz-border-radius: 3px 0 0 3px; border-radius: 3px 0 0 3px; } .input-daterange input:last-child { -webkit-border-radius: 0 3px 3px 0; -moz-border-radius: 0 3px 3px 0; border-radius: 0 3px 3px 0; } .input-daterange .add-on { display: inline-block; width: auto; min-width: 16px; height: 18px; padding: 4px 5px; font-weight: normal; line-height: 18px; text-align: center; text-shadow: 0 1px 0 #ffffff; vertical-align: middle; background-color: #eeeeee; border: 1px solid #ccc; margin-left: -5px; margin-right: -5px; } ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/css/bootstrap-timepicker.css ================================================ /*! * Timepicker Component for Twitter Bootstrap * * Copyright 2013 Joris de Wit * * Contributors https://github.com/jdewit/bootstrap-timepicker/graphs/contributors * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ .bootstrap-timepicker { position: relative; } .bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu { left: auto; right: 0; } .bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu:before { left: auto; right: 12px; } .bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu:after { left: auto; right: 13px; } .bootstrap-timepicker .add-on { cursor: pointer; } .bootstrap-timepicker .add-on i { display: inline-block; width: 16px; height: 16px; } .bootstrap-timepicker-widget.dropdown-menu { padding: 2px 3px 2px 2px; } .bootstrap-timepicker-widget.dropdown-menu.open { display: inline-block; } .bootstrap-timepicker-widget.dropdown-menu:before { border-bottom: 7px solid rgba(0, 0, 0, 0.2); border-left: 7px solid transparent; border-right: 7px solid transparent; content: ""; display: inline-block; left: 9px; position: absolute; top: -7px; } .bootstrap-timepicker-widget.dropdown-menu:after { border-bottom: 6px solid #FFFFFF; border-left: 6px solid transparent; border-right: 6px solid transparent; content: ""; display: inline-block; left: 10px; position: absolute; top: -6px; } .bootstrap-timepicker-widget a.btn, .bootstrap-timepicker-widget input { border-radius: 4px; } .bootstrap-timepicker-widget table { width: 100%; margin: 0; } .bootstrap-timepicker-widget table td { text-align: center; height: 30px; margin: 0; padding: 2px; } .bootstrap-timepicker-widget table td:not(.separator) { min-width: 30px; } .bootstrap-timepicker-widget table td span { width: 100%; } .bootstrap-timepicker-widget table td a { border: 1px transparent solid; width: 100%; display: inline-block; margin: 0; padding: 8px 0; outline: 0; color: #333; } .bootstrap-timepicker-widget table td a:hover { text-decoration: none; background-color: #eee; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; border-color: #ddd; } .bootstrap-timepicker-widget table td a i { margin-top: 2px; } .bootstrap-timepicker-widget table td input { width: 25px; margin: 0; text-align: center; } .bootstrap-timepicker-widget .modal-content { padding: 4px; } @media (min-width: 767px) { .bootstrap-timepicker-widget.modal { width: 200px; margin-left: -100px; } } @media (max-width: 767px) { .bootstrap-timepicker { width: 100%; } .bootstrap-timepicker .dropdown-menu { width: 100%; } } ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/css/chosen.css ================================================ /* @group Base */ .chosen-container { position: relative; display: inline-block; vertical-align: middle; font-size: 13px; zoom: 1; *display: inline; -webkit-user-select: none; -moz-user-select: none; user-select: none; } .chosen-container .chosen-drop { position: absolute; top: 100%; left: -9999px; z-index: 1010; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; width: 100%; border: 1px solid #aaa; border-top: 0; background: #fff; box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15); } .chosen-container.chosen-with-drop .chosen-drop { left: 0; } .chosen-container a { cursor: pointer; } /* @end */ /* @group Single Chosen */ .chosen-container-single .chosen-single { position: relative; display: block; overflow: hidden; padding: 0 0 0 8px; height: 23px; border: 1px solid #aaa; border-radius: 5px; background-color: #fff; background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #ffffff), color-stop(50%, #f6f6f6), color-stop(52%, #eeeeee), color-stop(100%, #f4f4f4)); background: -webkit-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%); background: -moz-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%); background: -o-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%); background: linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%); background-clip: padding-box; box-shadow: 0 0 3px white inset, 0 1px 1px rgba(0, 0, 0, 0.1); color: #444; text-decoration: none; white-space: nowrap; line-height: 24px; } .chosen-container-single .chosen-default { color: #999; } .chosen-container-single .chosen-single span { display: block; overflow: hidden; margin-right: 26px; text-overflow: ellipsis; white-space: nowrap; } .chosen-container-single .chosen-single-with-deselect span { margin-right: 38px; } .chosen-container-single .chosen-single abbr { position: absolute; top: 6px; right: 26px; display: block; width: 12px; height: 12px; background: url('chosen-sprite.png') -42px 1px no-repeat; font-size: 1px; } .chosen-container-single .chosen-single abbr:hover { background-position: -42px -10px; } .chosen-container-single.chosen-disabled .chosen-single abbr:hover { background-position: -42px -10px; } .chosen-container-single .chosen-single div { position: absolute; top: 0; right: 0; display: block; width: 18px; height: 100%; } .chosen-container-single .chosen-single div b { display: block; width: 100%; height: 100%; background: url('chosen-sprite.png') no-repeat 0px 2px; } .chosen-container-single .chosen-search { position: relative; z-index: 1010; margin: 0; padding: 3px 4px; white-space: nowrap; } .chosen-container-single .chosen-search input[type="text"] { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; margin: 1px 0; padding: 4px 20px 4px 5px; width: 100%; height: auto; outline: 0; border: 1px solid #aaa; background: white url('chosen-sprite.png') no-repeat 100% -20px; background: url('chosen-sprite.png') no-repeat 100% -20px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff)); background: url('chosen-sprite.png') no-repeat 100% -20px, -webkit-linear-gradient(#eeeeee 1%, #ffffff 15%); background: url('chosen-sprite.png') no-repeat 100% -20px, -moz-linear-gradient(#eeeeee 1%, #ffffff 15%); background: url('chosen-sprite.png') no-repeat 100% -20px, -o-linear-gradient(#eeeeee 1%, #ffffff 15%); background: url('chosen-sprite.png') no-repeat 100% -20px, linear-gradient(#eeeeee 1%, #ffffff 15%); font-size: 1em; font-family: sans-serif; line-height: normal; border-radius: 0; } .chosen-container-single .chosen-drop { margin-top: -1px; border-radius: 0 0 4px 4px; background-clip: padding-box; } .chosen-container-single.chosen-container-single-nosearch .chosen-search { position: absolute; left: -9999px; } /* @end */ /* @group Results */ .chosen-container .chosen-results { position: relative; overflow-x: hidden; overflow-y: auto; margin: 0 4px 4px 0; padding: 0 0 0 4px; max-height: 240px; -webkit-overflow-scrolling: touch; } .chosen-container .chosen-results li { display: none; margin: 0; padding: 5px 6px; list-style: none; line-height: 15px; } .chosen-container .chosen-results li.active-result { display: list-item; cursor: pointer; } .chosen-container .chosen-results li.disabled-result { display: list-item; color: #ccc; cursor: default; } .chosen-container .chosen-results li.highlighted { background-color: #3875d7; background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #3875d7), color-stop(90%, #2a62bc)); background-image: -webkit-linear-gradient(#3875d7 20%, #2a62bc 90%); background-image: -moz-linear-gradient(#3875d7 20%, #2a62bc 90%); background-image: -o-linear-gradient(#3875d7 20%, #2a62bc 90%); background-image: linear-gradient(#3875d7 20%, #2a62bc 90%); color: #fff; } .chosen-container .chosen-results li.no-results { display: list-item; background: #f4f4f4; } .chosen-container .chosen-results li.group-result { display: list-item; font-weight: bold; cursor: default; } .chosen-container .chosen-results li.group-option { padding-left: 15px; } .chosen-container .chosen-results li em { font-style: normal; text-decoration: underline; } /* @end */ /* @group Multi Chosen */ .chosen-container-multi .chosen-choices { position: relative; overflow: hidden; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; margin: 0; padding: 0; width: 100%; height: auto !important; height: 1%; border: 1px solid #aaa; background-color: #fff; background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff)); background-image: -webkit-linear-gradient(#eeeeee 1%, #ffffff 15%); background-image: -moz-linear-gradient(#eeeeee 1%, #ffffff 15%); background-image: -o-linear-gradient(#eeeeee 1%, #ffffff 15%); background-image: linear-gradient(#eeeeee 1%, #ffffff 15%); cursor: text; } .chosen-container-multi .chosen-choices li { float: left; list-style: none; } .chosen-container-multi .chosen-choices li.search-field { margin: 0; padding: 0; white-space: nowrap; } .chosen-container-multi .chosen-choices li.search-field input[type="text"] { margin: 1px 0; padding: 5px; height: 15px; outline: 0; border: 0 !important; background: transparent !important; box-shadow: none; color: #666; font-size: 100%; font-family: sans-serif; line-height: normal; border-radius: 0; } .chosen-container-multi .chosen-choices li.search-field .default { color: #999; } .chosen-container-multi .chosen-choices li.search-choice { position: relative; margin: 3px 0 3px 5px; padding: 3px 20px 3px 5px; border: 1px solid #aaa; border-radius: 3px; background-color: #e4e4e4; background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee)); background-image: -webkit-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); background-image: -moz-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); background-image: -o-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); background-clip: padding-box; box-shadow: 0 0 2px white inset, 0 1px 0 rgba(0, 0, 0, 0.05); color: #333; line-height: 13px; cursor: default; } .chosen-container-multi .chosen-choices li.search-choice .search-choice-close { position: absolute; top: 4px; right: 3px; display: block; width: 12px; height: 12px; background: url('chosen-sprite.png') -42px 1px no-repeat; font-size: 1px; } .chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover { background-position: -42px -10px; } .chosen-container-multi .chosen-choices li.search-choice-disabled { padding-right: 5px; border: 1px solid #ccc; background-color: #e4e4e4; background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee)); background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%); color: #666; } .chosen-container-multi .chosen-choices li.search-choice-focus { background: #d4d4d4; } .chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close { background-position: -42px -10px; } .chosen-container-multi .chosen-results { margin: 0; padding: 0; } .chosen-container-multi .chosen-drop .result-selected { display: list-item; color: #ccc; cursor: default; } /* @end */ /* @group Active */ .chosen-container-active .chosen-single { border: 1px solid #5897fb; box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); } .chosen-container-active.chosen-with-drop .chosen-single { border: 1px solid #aaa; -moz-border-radius-bottomright: 0; border-bottom-right-radius: 0; -moz-border-radius-bottomleft: 0; border-bottom-left-radius: 0; background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #eeeeee), color-stop(80%, #ffffff)); background-image: -webkit-linear-gradient(#eeeeee 20%, #ffffff 80%); background-image: -moz-linear-gradient(#eeeeee 20%, #ffffff 80%); background-image: -o-linear-gradient(#eeeeee 20%, #ffffff 80%); background-image: linear-gradient(#eeeeee 20%, #ffffff 80%); box-shadow: 0 1px 0 #fff inset; } .chosen-container-active.chosen-with-drop .chosen-single div { border-left: none; background: transparent; } .chosen-container-active.chosen-with-drop .chosen-single div b { background-position: -18px 2px; } .chosen-container-active .chosen-choices { border: 1px solid #5897fb; box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); } .chosen-container-active .chosen-choices li.search-field input[type="text"] { color: #111 !important; } /* @end */ /* @group Disabled Support */ .chosen-disabled { opacity: 0.5 !important; cursor: default; } .chosen-disabled .chosen-single { cursor: default; } .chosen-disabled .chosen-choices .search-choice .search-choice-close { cursor: default; } /* @end */ /* @group Right to Left */ .chosen-rtl { text-align: right; } .chosen-rtl .chosen-single { overflow: visible; padding: 0 8px 0 0; } .chosen-rtl .chosen-single span { margin-right: 0; margin-left: 26px; direction: rtl; } .chosen-rtl .chosen-single-with-deselect span { margin-left: 38px; } .chosen-rtl .chosen-single div { right: auto; left: 3px; } .chosen-rtl .chosen-single abbr { right: auto; left: 26px; } .chosen-rtl .chosen-choices li { float: right; } .chosen-rtl .chosen-choices li.search-field input[type="text"] { direction: rtl; } .chosen-rtl .chosen-choices li.search-choice { margin: 3px 5px 3px 0; padding: 3px 5px 3px 19px; } .chosen-rtl .chosen-choices li.search-choice .search-choice-close { right: auto; left: 4px; } .chosen-rtl.chosen-container-single-nosearch .chosen-search, .chosen-rtl .chosen-drop { left: 9999px; } .chosen-rtl.chosen-container-single .chosen-results { margin: 0 0 4px 4px; padding: 0 4px 0 0; } .chosen-rtl .chosen-results li.group-option { padding-right: 15px; padding-left: 0; } .chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div { border-right: none; } .chosen-rtl .chosen-search input[type="text"] { padding: 4px 5px 4px 20px; background: white url('chosen-sprite.png') no-repeat -30px -20px; background: url('chosen-sprite.png') no-repeat -30px -20px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff)); background: url('chosen-sprite.png') no-repeat -30px -20px, -webkit-linear-gradient(#eeeeee 1%, #ffffff 15%); background: url('chosen-sprite.png') no-repeat -30px -20px, -moz-linear-gradient(#eeeeee 1%, #ffffff 15%); background: url('chosen-sprite.png') no-repeat -30px -20px, -o-linear-gradient(#eeeeee 1%, #ffffff 15%); background: url('chosen-sprite.png') no-repeat -30px -20px, linear-gradient(#eeeeee 1%, #ffffff 15%); direction: rtl; } .chosen-rtl.chosen-container-single .chosen-single div b { background-position: 6px 2px; } .chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b { background-position: -12px 2px; } /* @end */ /* @group Retina compatibility */ @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 144dpi) { .chosen-rtl .chosen-search input[type="text"], .chosen-container-single .chosen-single abbr, .chosen-container-single .chosen-single div b, .chosen-container-single .chosen-search input[type="text"], .chosen-container-multi .chosen-choices .search-choice .search-choice-close, .chosen-container .chosen-results-scroll-down span, .chosen-container .chosen-results-scroll-up span { background-image: url('chosen-sprite@2x.png') !important; background-size: 52px 37px !important; background-repeat: no-repeat !important; } } /* @end */ ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/css/colorbox.css ================================================ /* Colorbox Core Style: The following CSS is consistent between example themes and should not be altered. */ #colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden;} #cboxOverlay{position:fixed; width:100%; height:100%;} #cboxMiddleLeft, #cboxBottomLeft{clear:left;} #cboxContent{position:relative;} #cboxLoadedContent{overflow:auto; -webkit-overflow-scrolling: touch;} #cboxTitle{margin:0;} #cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;} #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;} .cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;} .cboxIframe{width:100%; height:100%; display:block; border:0;} #colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;} /* User Style: Change the following styles to modify the appearance of Colorbox. They are ordered & tabbed in a way that represents the nesting of the generated HTML. */ #cboxOverlay{background:url(images/overlay.png) repeat 0 0;} #colorbox{outline:0;} #cboxTopLeft{width:21px; height:21px; background:url(images/controls.png) no-repeat -101px 0;} #cboxTopRight{width:21px; height:21px; background:url(images/controls.png) no-repeat -130px 0;} #cboxBottomLeft{width:21px; height:21px; background:url(images/controls.png) no-repeat -101px -29px;} #cboxBottomRight{width:21px; height:21px; background:url(images/controls.png) no-repeat -130px -29px;} #cboxMiddleLeft{width:21px; background:url(images/controls.png) left top repeat-y;} #cboxMiddleRight{width:21px; background:url(images/controls.png) right top repeat-y;} #cboxTopCenter{height:21px; background:url(images/border.png) 0 0 repeat-x;} #cboxBottomCenter{height:21px; background:url(images/border.png) 0 -29px repeat-x;} #cboxContent{background:#fff; overflow:hidden;} .cboxIframe{background:#fff;} #cboxError{padding:50px; border:1px solid #ccc;} #cboxLoadedContent{margin-bottom:28px;} #cboxTitle{position:absolute; bottom:4px; left:0; text-align:center; width:100%; color:#949494;} #cboxCurrent{position:absolute; bottom:4px; left:58px; color:#949494;} #cboxLoadingOverlay{background:url(images/loading_background.png) no-repeat center center;} #cboxLoadingGraphic{background:url(images/loading.gif) no-repeat center center;} /* these elements are buttons, and may need to have additional styles reset to avoid unwanted base styles */ #cboxPrevious, #cboxNext, #cboxSlideshow, #cboxClose {border:0; padding:0; margin:0; overflow:visible; width:auto; background:none; } /* avoid outlines on :active (mouseclick), but preserve outlines on :focus (tabbed navigating) */ #cboxPrevious:active, #cboxNext:active, #cboxSlideshow:active, #cboxClose:active {outline:0;} #cboxSlideshow{position:absolute; bottom:4px; right:30px; color:#0092ef;} #cboxPrevious{position:absolute; bottom:0; left:0; background:url(images/controls.png) no-repeat -75px 0; width:25px; height:25px; text-indent:-9999px;} #cboxPrevious:hover{background-position:-75px -25px;} #cboxNext{position:absolute; bottom:0; left:27px; background:url(images/controls.png) no-repeat -50px 0; width:25px; height:25px; text-indent:-9999px;} #cboxNext:hover{background-position:-50px -25px;} #cboxClose{position:absolute; bottom:0; right:0; background:url(images/controls.png) no-repeat -25px 0; width:25px; height:25px; text-indent:-9999px;} #cboxClose:hover{background-position:-25px -25px;} /* The following fixes a problem where IE7 and IE8 replace a PNG's alpha transparency with a black fill when an alpha filter (opacity change) is set on the element or ancestor element. This style is not applied to or needed in IE9. See: http://jacklmoore.com/notes/ie-transparency-problems/ */ .cboxIE #cboxTopLeft, .cboxIE #cboxTopCenter, .cboxIE #cboxTopRight, .cboxIE #cboxBottomLeft, .cboxIE #cboxBottomCenter, .cboxIE #cboxBottomRight, .cboxIE #cboxMiddleLeft, .cboxIE #cboxMiddleRight { filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF); } ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/css/colorpicker.css ================================================ /*! * Colorpicker for Bootstrap * * Copyright 2012 Stefan Petre * Licensed under the Apache License v2.0 * http://www.apache.org/licenses/LICENSE-2.0 * */ .colorpicker-saturation { width: 100px; height: 100px; background-image: url(img/saturation.png); cursor: crosshair; float: left; } .colorpicker-saturation i { display: block; height: 5px; width: 5px; border: 1px solid #000; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; position: absolute; top: 0; left: 0; margin: -4px 0 0 -4px; } .colorpicker-saturation i b { display: block; height: 5px; width: 5px; border: 1px solid #fff; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; } .colorpicker-hue, .colorpicker-alpha { width: 15px; height: 100px; float: left; cursor: row-resize; margin-left: 4px; margin-bottom: 4px; } .colorpicker-hue i, .colorpicker-alpha i { display: block; height: 1px; background: #000; border-top: 1px solid #fff; position: absolute; top: 0; left: 0; width: 100%; margin-top: -1px; } .colorpicker-hue { background-image: url(img/hue.png); } .colorpicker-alpha { background-image: url(img/alpha.png); display: none; } .colorpicker { *zoom: 1; top: 0; left: 0; padding: 4px; min-width: 120px; margin-top: 1px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; } .colorpicker:before, .colorpicker:after { display: table; content: ""; } .colorpicker:after { clear: both; } .colorpicker:before { content: ''; display: inline-block; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 7px solid #ccc; border-bottom-color: rgba(0, 0, 0, 0.2); position: absolute; top: -7px; left: 6px; } .colorpicker:after { content: ''; display: inline-block; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 6px solid #ffffff; position: absolute; top: -6px; left: 7px; } .colorpicker div { position: relative; } .colorpicker.alpha { min-width: 140px; } .colorpicker.alpha .colorpicker-alpha { display: block; } .colorpicker-color { height: 10px; margin-top: 5px; clear: both; background-image: url(img/alpha.png); background-position: 0 100%; } .colorpicker-color div { height: 10px; } .input-append.color .add-on i, .input-prepend.color .add-on i { display: block; cursor: pointer; width: 16px; height: 16px; } ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/css/datepicker.css ================================================ /*! * Datepicker for Bootstrap * * Copyright 2012 Stefan Petre * Improvements by Andrew Rowls * Licensed under the Apache License v2.0 * http://www.apache.org/licenses/LICENSE-2.0 * */ .datepicker { padding: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; direction: ltr; /*.dow { border-top: 1px solid #ddd !important; }*/ } .datepicker-inline { width: 220px; } .datepicker.datepicker-rtl { direction: rtl; } .datepicker.datepicker-rtl table tr td span { float: right; } .datepicker-dropdown { top: 0; left: 0; } .datepicker-dropdown:before { content: ''; display: inline-block; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 7px solid #ccc; border-bottom-color: rgba(0, 0, 0, 0.2); position: absolute; top: -7px; left: 6px; } .datepicker-dropdown:after { content: ''; display: inline-block; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 6px solid #ffffff; position: absolute; top: -6px; left: 7px; } .datepicker > div { display: none; } .datepicker.days div.datepicker-days { display: block; } .datepicker.months div.datepicker-months { display: block; } .datepicker.years div.datepicker-years { display: block; } .datepicker table { margin: 0; } .datepicker td, .datepicker th { text-align: center; width: 20px; height: 20px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; border: none; } .table-striped .datepicker table tr td, .table-striped .datepicker table tr th { background-color: transparent; } .datepicker table tr td.day:hover { background: #eeeeee; cursor: pointer; } .datepicker table tr td.old, .datepicker table tr td.new { color: #999999; } .datepicker table tr td.disabled, .datepicker table tr td.disabled:hover { background: none; color: #999999; cursor: default; } .datepicker table tr td.today, .datepicker table tr td.today:hover, .datepicker table tr td.today.disabled, .datepicker table tr td.today.disabled:hover { background-color: #fde19a; background-image: -moz-linear-gradient(top, #fdd49a, #fdf59a); background-image: -ms-linear-gradient(top, #fdd49a, #fdf59a); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fdd49a), to(#fdf59a)); background-image: -webkit-linear-gradient(top, #fdd49a, #fdf59a); background-image: -o-linear-gradient(top, #fdd49a, #fdf59a); background-image: linear-gradient(top, #fdd49a, #fdf59a); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdd49a', endColorstr='#fdf59a', GradientType=0); border-color: #fdf59a #fdf59a #fbed50; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); color: #000 !important; } .datepicker table tr td.today:hover, .datepicker table tr td.today:hover:hover, .datepicker table tr td.today.disabled:hover, .datepicker table tr td.today.disabled:hover:hover, .datepicker table tr td.today:active, .datepicker table tr td.today:hover:active, .datepicker table tr td.today.disabled:active, .datepicker table tr td.today.disabled:hover:active, .datepicker table tr td.today.active, .datepicker table tr td.today:hover.active, .datepicker table tr td.today.disabled.active, .datepicker table tr td.today.disabled:hover.active, .datepicker table tr td.today.disabled, .datepicker table tr td.today:hover.disabled, .datepicker table tr td.today.disabled.disabled, .datepicker table tr td.today.disabled:hover.disabled, .datepicker table tr td.today[disabled], .datepicker table tr td.today:hover[disabled], .datepicker table tr td.today.disabled[disabled], .datepicker table tr td.today.disabled:hover[disabled] { background-color: #fdf59a; } .datepicker table tr td.today:active, .datepicker table tr td.today:hover:active, .datepicker table tr td.today.disabled:active, .datepicker table tr td.today.disabled:hover:active, .datepicker table tr td.today.active, .datepicker table tr td.today:hover.active, .datepicker table tr td.today.disabled.active, .datepicker table tr td.today.disabled:hover.active { background-color: #fbf069 \9; } .datepicker table tr td.active, .datepicker table tr td.active:hover, .datepicker table tr td.active.disabled, .datepicker table tr td.active.disabled:hover { background-color: #006dcc; background-image: -moz-linear-gradient(top, #0088cc, #0044cc); background-image: -ms-linear-gradient(top, #0088cc, #0044cc); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); background-image: -webkit-linear-gradient(top, #0088cc, #0044cc); background-image: -o-linear-gradient(top, #0088cc, #0044cc); background-image: linear-gradient(top, #0088cc, #0044cc); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0); border-color: #0044cc #0044cc #002a80; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); color: #fff; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); } .datepicker table tr td.active:hover, .datepicker table tr td.active:hover:hover, .datepicker table tr td.active.disabled:hover, .datepicker table tr td.active.disabled:hover:hover, .datepicker table tr td.active:active, .datepicker table tr td.active:hover:active, .datepicker table tr td.active.disabled:active, .datepicker table tr td.active.disabled:hover:active, .datepicker table tr td.active.active, .datepicker table tr td.active:hover.active, .datepicker table tr td.active.disabled.active, .datepicker table tr td.active.disabled:hover.active, .datepicker table tr td.active.disabled, .datepicker table tr td.active:hover.disabled, .datepicker table tr td.active.disabled.disabled, .datepicker table tr td.active.disabled:hover.disabled, .datepicker table tr td.active[disabled], .datepicker table tr td.active:hover[disabled], .datepicker table tr td.active.disabled[disabled], .datepicker table tr td.active.disabled:hover[disabled] { background-color: #0044cc; } .datepicker table tr td.active:active, .datepicker table tr td.active:hover:active, .datepicker table tr td.active.disabled:active, .datepicker table tr td.active.disabled:hover:active, .datepicker table tr td.active.active, .datepicker table tr td.active:hover.active, .datepicker table tr td.active.disabled.active, .datepicker table tr td.active.disabled:hover.active { background-color: #003399 \9; } .datepicker table tr td span { display: block; width: 23%; height: 54px; line-height: 54px; float: left; margin: 1%; cursor: pointer; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; } .datepicker table tr td span:hover { background: #eeeeee; } .datepicker table tr td span.disabled, .datepicker table tr td span.disabled:hover { background: none; color: #999999; cursor: default; } .datepicker table tr td span.active, .datepicker table tr td span.active:hover, .datepicker table tr td span.active.disabled, .datepicker table tr td span.active.disabled:hover { background-color: #006dcc; background-image: -moz-linear-gradient(top, #0088cc, #0044cc); background-image: -ms-linear-gradient(top, #0088cc, #0044cc); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); background-image: -webkit-linear-gradient(top, #0088cc, #0044cc); background-image: -o-linear-gradient(top, #0088cc, #0044cc); background-image: linear-gradient(top, #0088cc, #0044cc); background-repeat: repeat-x; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0); border-color: #0044cc #0044cc #002a80; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); color: #fff; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); } .datepicker table tr td span.active:hover, .datepicker table tr td span.active:hover:hover, .datepicker table tr td span.active.disabled:hover, .datepicker table tr td span.active.disabled:hover:hover, .datepicker table tr td span.active:active, .datepicker table tr td span.active:hover:active, .datepicker table tr td span.active.disabled:active, .datepicker table tr td span.active.disabled:hover:active, .datepicker table tr td span.active.active, .datepicker table tr td span.active:hover.active, .datepicker table tr td span.active.disabled.active, .datepicker table tr td span.active.disabled:hover.active, .datepicker table tr td span.active.disabled, .datepicker table tr td span.active:hover.disabled, .datepicker table tr td span.active.disabled.disabled, .datepicker table tr td span.active.disabled:hover.disabled, .datepicker table tr td span.active[disabled], .datepicker table tr td span.active:hover[disabled], .datepicker table tr td span.active.disabled[disabled], .datepicker table tr td span.active.disabled:hover[disabled] { background-color: #0044cc; } .datepicker table tr td span.active:active, .datepicker table tr td span.active:hover:active, .datepicker table tr td span.active.disabled:active, .datepicker table tr td span.active.disabled:hover:active, .datepicker table tr td span.active.active, .datepicker table tr td span.active:hover.active, .datepicker table tr td span.active.disabled.active, .datepicker table tr td span.active.disabled:hover.active { background-color: #003399 \9; } .datepicker table tr td span.old { color: #999999; } .datepicker th.switch { width: 145px; } .datepicker thead tr:first-child th, .datepicker tfoot tr:first-child th { cursor: pointer; } .datepicker thead tr:first-child th:hover, .datepicker tfoot tr:first-child th:hover { background: #eeeeee; } .datepicker .cw { font-size: 10px; width: 12px; padding: 0 2px 0 5px; vertical-align: middle; } .datepicker thead tr:first-child th.cw { cursor: default; background-color: transparent; } .input-append.date .add-on i, .input-prepend.date .add-on i { display: block; cursor: pointer; width: 16px; height: 16px; } ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/css/daterangepicker.css ================================================ /*! * Stylesheet for the Date Range Picker, for use with Bootstrap 3.x * * Copyright 2013 Dan Grossman ( http://www.dangrossman.info ) * Licensed under the Apache License v2.0 * http://www.apache.org/licenses/LICENSE-2.0 * * Built for http://www.improvely.com */ .daterangepicker.dropdown-menu { max-width: none; } .daterangepicker.opensleft .ranges, .daterangepicker.opensleft .calendar { float: left; margin: 4px; } .daterangepicker.opensright .ranges, .daterangepicker.opensright .calendar { float: right; margin: 4px; } .daterangepicker .ranges { width: 160px; text-align: left; } .daterangepicker .ranges .range_inputs>div { float: left; } .daterangepicker .ranges .range_inputs>div:nth-child(2) { padding-left: 11px; } .daterangepicker .calendar { display: none; max-width: 270px; } .daterangepicker .calendar th, .daterangepicker .calendar td { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; white-space: nowrap; text-align: center; min-width: 32px; } .daterangepicker .ranges label { color: #333; display: block; font-size: 11px; font-weight: normal; height: 20px; line-height: 20px; margin-bottom: 2px; text-shadow: #fff 1px 1px 0px; text-transform: uppercase; width: 74px; } .daterangepicker .ranges input { font-size: 11px; } .daterangepicker .ranges .input-mini { background-color: #eee; border: 1px solid #ccc; border-radius: 4px; color: #555; display: block; font-size: 11px; height: 30px; line-height: 30px; vertical-align: middle; margin: 0 0 10px 0; padding: 0 6px; width: 74px; } .daterangepicker .ranges ul { list-style: none; margin: 0; padding: 0; } .daterangepicker .ranges li { font-size: 13px; background: #f5f5f5; border: 1px solid #f5f5f5; color: #08c; padding: 3px 12px; margin-bottom: 8px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; cursor: pointer; } .daterangepicker .ranges li.active, .daterangepicker .ranges li:hover { background: #08c; border: 1px solid #08c; color: #fff; } .daterangepicker .calendar-date { border: 1px solid #ddd; padding: 4px; border-radius: 4px; background: #fff; } .daterangepicker .calendar-time { text-align: center; margin: 8px auto 0 auto; line-height: 30px; } .daterangepicker { position: absolute; background: #fff; top: 100px; left: 20px; padding: 4px; margin-top: 1px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; } .daterangepicker.opensleft:before { position: absolute; top: -7px; right: 9px; display: inline-block; border-right: 7px solid transparent; border-bottom: 7px solid #ccc; border-left: 7px solid transparent; border-bottom-color: rgba(0, 0, 0, 0.2); content: ''; } .daterangepicker.opensleft:after { position: absolute; top: -6px; right: 10px; display: inline-block; border-right: 6px solid transparent; border-bottom: 6px solid #fff; border-left: 6px solid transparent; content: ''; } .daterangepicker.opensright:before { position: absolute; top: -7px; left: 9px; display: inline-block; border-right: 7px solid transparent; border-bottom: 7px solid #ccc; border-left: 7px solid transparent; border-bottom-color: rgba(0, 0, 0, 0.2); content: ''; } .daterangepicker.opensright:after { position: absolute; top: -6px; left: 10px; display: inline-block; border-right: 6px solid transparent; border-bottom: 6px solid #fff; border-left: 6px solid transparent; content: ''; } .daterangepicker table { width: 100%; margin: 0; } .daterangepicker td, .daterangepicker th { text-align: center; width: 20px; height: 20px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; cursor: pointer; white-space: nowrap; } .daterangepicker td.off { color: #999; } .daterangepicker td.disabled { color: #999; } .daterangepicker td.available:hover, .daterangepicker th.available:hover { background: #eee; } .daterangepicker td.in-range { background: #ebf4f8; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; } .daterangepicker td.active, .daterangepicker td.active:hover { background-color: #357ebd; border-color: #3071a9; color: #fff; } .daterangepicker td.week, .daterangepicker th.week { font-size: 80%; color: #ccc; } .daterangepicker select.monthselect, .daterangepicker select.yearselect { font-size: 12px; padding: 1px; height: auto; margin: 0; cursor: default; } .daterangepicker select.monthselect { margin-right: 2%; width: 56%; } .daterangepicker select.yearselect { width: 40%; } .daterangepicker select.hourselect, .daterangepicker select.minuteselect, .daterangepicker select.ampmselect { width: 50px; margin-bottom: 0; } ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/css/dropzone.css ================================================ /* The MIT License */ .dropzone, .dropzone *, .dropzone-previews, .dropzone-previews * { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .dropzone { position: relative; border: 1px solid rgba(0,0,0,0.08); background: rgba(0,0,0,0.02); padding: 1em; } .dropzone.dz-clickable { cursor: pointer; } .dropzone-excel { background: url("/nora.web/ico/excel_ico.png") center top no-repeat; } .dropzone.dz-clickable .dz-message, .dropzone.dz-clickable .dz-message span { cursor: pointer; } .dropzone.dz-clickable * { cursor: default; } .dropzone .dz-message { opacity: 1; -ms-filter: none; filter: none; } .dropzone.dz-drag-hover { border-color: rgba(0,0,0,0.15); background: rgba(0,0,0,0.04); } .dropzone.dz-started .dz-message { display: none; } .dropzone .dz-preview, .dropzone-previews .dz-preview { background: rgba(255,255,255,0.8); position: relative; display: inline-block; margin: 17px; vertical-align: top; border: 1px solid #acacac; padding: 6px 6px 6px 6px; } .dropzone .dz-preview.dz-file-preview [data-dz-thumbnail], .dropzone-previews .dz-preview.dz-file-preview [data-dz-thumbnail] { display: none; } .dropzone .dz-preview .dz-details, .dropzone-previews .dz-preview .dz-details { width: 100px; height: 100px; position: relative; background: #ebebeb; padding: 5px; margin-bottom: 22px; } .dropzone .dz-preview .dz-details .dz-filename, .dropzone-previews .dz-preview .dz-details .dz-filename { overflow: hidden; height: 100%; } .dropzone .dz-preview .dz-details img, .dropzone-previews .dz-preview .dz-details img { position: absolute; top: 0; left: 0; width: 100px; height: 100px; } .dropzone .dz-preview .dz-details .dz-size, .dropzone-previews .dz-preview .dz-details .dz-size { position: absolute; bottom: -28px; left: 3px; height: 28px; line-height: 28px; } .dropzone .dz-preview.dz-error .dz-error-mark, .dropzone-previews .dz-preview.dz-error .dz-error-mark { display: block; } .dropzone .dz-preview.dz-success .dz-success-mark, .dropzone-previews .dz-preview.dz-success .dz-success-mark { display: block; } .dropzone .dz-preview:hover .dz-details img, .dropzone-previews .dz-preview:hover .dz-details img { display: none; } .dropzone .dz-preview .dz-success-mark, .dropzone-previews .dz-preview .dz-success-mark, .dropzone .dz-preview .dz-error-mark, .dropzone-previews .dz-preview .dz-error-mark { display: none; position: absolute; width: 40px; height: 40px; font-size: 30px; text-align: center; right: -10px; top: -10px; } .dropzone .dz-preview .dz-success-mark, .dropzone-previews .dz-preview .dz-success-mark { color: #8cc657; } .dropzone .dz-preview .dz-error-mark, .dropzone-previews .dz-preview .dz-error-mark { color: #ee162d; } .dropzone .dz-preview .dz-progress, .dropzone-previews .dz-preview .dz-progress { position: absolute; top: 100px; left: 6px; right: 6px; height: 6px; background: #d7d7d7; display: none; } .dropzone .dz-preview .dz-progress .dz-upload, .dropzone-previews .dz-preview .dz-progress .dz-upload { position: absolute; top: 0; bottom: 0; left: 0; width: 0%; background-color: #8cc657; } .dropzone .dz-preview.dz-processing .dz-progress, .dropzone-previews .dz-preview.dz-processing .dz-progress { display: block; } .dropzone .dz-preview .dz-error-message, .dropzone-previews .dz-preview .dz-error-message { display: none; position: absolute; top: -5px; left: -20px; background: rgba(245,245,245,0.8); padding: 8px 10px; color: #800; min-width: 140px; max-width: 500px; z-index: 500; } .dropzone .dz-preview:hover.dz-error .dz-error-message, .dropzone-previews .dz-preview:hover.dz-error .dz-error-message { display: block; } .dropzone { border: 1px solid rgba(0,0,0,0.03); min-height: 360px; -webkit-border-radius: 3px; border-radius: 3px; background: rgba(0,0,0,0.03); padding: 23px; } .dropzone .dz-default.dz-message { opacity: 1; -ms-filter: none; filter: none; -webkit-transition: opacity 0.3s ease-in-out; -moz-transition: opacity 0.3s ease-in-out; -o-transition: opacity 0.3s ease-in-out; -ms-transition: opacity 0.3s ease-in-out; transition: opacity 0.3s ease-in-out; background-image: url("../images/spritemap.png"); background-repeat: no-repeat; background-position: 0 0; position: absolute; width: 428px; height: 123px; margin-left: -214px; margin-top: -61.5px; top: 50%; left: 50%; } @media all and (-webkit-min-device-pixel-ratio:1.5),(min--moz-device-pixel-ratio:1.5),(-o-min-device-pixel-ratio:1.5/1),(min-device-pixel-ratio:1.5),(min-resolution:138dpi),(min-resolution:1.5dppx) { .dropzone .dz-default.dz-message { background-image: url("../images/spritemap@2x.png"); -webkit-background-size: 428px 406px; -moz-background-size: 428px 406px; background-size: 428px 406px; } } .dropzone .dz-default.dz-message span { display: none; } .dropzone.dz-square .dz-default.dz-message { background-position: 0 -123px; width: 268px; margin-left: -134px; height: 174px; margin-top: -87px; } .dropzone.dz-drag-hover .dz-message { opacity: 0.15; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=15)"; filter: alpha(opacity=15); } .dropzone.dz-started .dz-message { display: block; opacity: 0; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter: alpha(opacity=0); } .dropzone .dz-preview, .dropzone-previews .dz-preview { -webkit-box-shadow: 1px 1px 4px rgba(0,0,0,0.16); box-shadow: 1px 1px 4px rgba(0,0,0,0.16); font-size: 14px; } .dropzone .dz-preview.dz-image-preview:hover .dz-details img, .dropzone-previews .dz-preview.dz-image-preview:hover .dz-details img { display: block; opacity: 0.1; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=10)"; filter: alpha(opacity=10); } .dropzone .dz-preview.dz-success .dz-success-mark, .dropzone-previews .dz-preview.dz-success .dz-success-mark { opacity: 1; -ms-filter: none; filter: none; } .dropzone .dz-preview.dz-error .dz-error-mark, .dropzone-previews .dz-preview.dz-error .dz-error-mark { opacity: 1; -ms-filter: none; filter: none; } .dropzone .dz-preview.dz-error .dz-progress .dz-upload, .dropzone-previews .dz-preview.dz-error .dz-progress .dz-upload { background: #ee1e2d; } .dropzone .dz-preview .dz-error-mark, .dropzone-previews .dz-preview .dz-error-mark, .dropzone .dz-preview .dz-success-mark, .dropzone-previews .dz-preview .dz-success-mark { display: block; opacity: 0; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter: alpha(opacity=0); -webkit-transition: opacity 0.4s ease-in-out; -moz-transition: opacity 0.4s ease-in-out; -o-transition: opacity 0.4s ease-in-out; -ms-transition: opacity 0.4s ease-in-out; transition: opacity 0.4s ease-in-out; background-image: url("../images/spritemap.png"); background-repeat: no-repeat; } @media all and (-webkit-min-device-pixel-ratio:1.5),(min--moz-device-pixel-ratio:1.5),(-o-min-device-pixel-ratio:1.5/1),(min-device-pixel-ratio:1.5),(min-resolution:138dpi),(min-resolution:1.5dppx) { .dropzone .dz-preview .dz-error-mark, .dropzone-previews .dz-preview .dz-error-mark, .dropzone .dz-preview .dz-success-mark, .dropzone-previews .dz-preview .dz-success-mark { background-image: url("../images/spritemap@2x.png"); -webkit-background-size: 428px 406px; -moz-background-size: 428px 406px; background-size: 428px 406px; } } .dropzone .dz-preview .dz-error-mark span, .dropzone-previews .dz-preview .dz-error-mark span, .dropzone .dz-preview .dz-success-mark span, .dropzone-previews .dz-preview .dz-success-mark span { display: none; } .dropzone .dz-preview .dz-error-mark, .dropzone-previews .dz-preview .dz-error-mark { background-position: -268px -123px; } .dropzone .dz-preview .dz-success-mark, .dropzone-previews .dz-preview .dz-success-mark { background-position: -268px -163px; } .dropzone .dz-preview .dz-progress .dz-upload, .dropzone-previews .dz-preview .dz-progress .dz-upload { -webkit-animation: loading 0.4s linear infinite; -moz-animation: loading 0.4s linear infinite; -o-animation: loading 0.4s linear infinite; -ms-animation: loading 0.4s linear infinite; animation: loading 0.4s linear infinite; -webkit-transition: width 0.3s ease-in-out; -moz-transition: width 0.3s ease-in-out; -o-transition: width 0.3s ease-in-out; -ms-transition: width 0.3s ease-in-out; transition: width 0.3s ease-in-out; -webkit-border-radius: 2px; border-radius: 2px; position: absolute; top: 0; left: 0; width: 0%; height: 100%; background-image: url("../images/spritemap.png"); background-repeat: repeat-x; background-position: 0px -400px; } @media all and (-webkit-min-device-pixel-ratio:1.5),(min--moz-device-pixel-ratio:1.5),(-o-min-device-pixel-ratio:1.5/1),(min-device-pixel-ratio:1.5),(min-resolution:138dpi),(min-resolution:1.5dppx) { .dropzone .dz-preview .dz-progress .dz-upload, .dropzone-previews .dz-preview .dz-progress .dz-upload { background-image: url("../images/spritemap@2x.png"); -webkit-background-size: 428px 406px; -moz-background-size: 428px 406px; background-size: 428px 406px; } } .dropzone .dz-preview.dz-success .dz-progress, .dropzone-previews .dz-preview.dz-success .dz-progress { display: block; opacity: 0; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter: alpha(opacity=0); -webkit-transition: opacity 0.4s ease-in-out; -moz-transition: opacity 0.4s ease-in-out; -o-transition: opacity 0.4s ease-in-out; -ms-transition: opacity 0.4s ease-in-out; transition: opacity 0.4s ease-in-out; } .dropzone .dz-preview .dz-error-message, .dropzone-previews .dz-preview .dz-error-message { display: block; opacity: 0; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter: alpha(opacity=0); -webkit-transition: opacity 0.3s ease-in-out; -moz-transition: opacity 0.3s ease-in-out; -o-transition: opacity 0.3s ease-in-out; -ms-transition: opacity 0.3s ease-in-out; transition: opacity 0.3s ease-in-out; } .dropzone .dz-preview:hover.dz-error .dz-error-message, .dropzone-previews .dz-preview:hover.dz-error .dz-error-message { opacity: 1; -ms-filter: none; filter: none; } .dropzone a.dz-remove, .dropzone-previews a.dz-remove { background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fafafa), color-stop(1, #eee)); background-image: -webkit-linear-gradient(top, #fafafa 0, #eee 100%); background-image: -moz-linear-gradient(top, #fafafa 0, #eee 100%); background-image: -o-linear-gradient(top, #fafafa 0, #eee 100%); background-image: -ms-linear-gradient(top, #fafafa 0, #eee 100%); background-image: linear-gradient(top, #fafafa 0, #eee 100%); -webkit-border-radius: 2px; border-radius: 2px; border: 1px solid #eee; text-decoration: none; display: block; padding: 4px 5px; text-align: center; color: #aaa; margin-top: 26px; } .dropzone a.dz-remove:hover, .dropzone-previews a.dz-remove:hover { color: #666; } @-moz-keyframes loading { 0% { background-position: 0 -400px; } 100% { background-position: -7px -400px; } } @-webkit-keyframes loading { 0% { background-position: 0 -400px; } 100% { background-position: -7px -400px; } } @-o-keyframes loading { 0% { background-position: 0 -400px; } 100% { background-position: -7px -400px; } } @-ms-keyframes loading { 0% { background-position: 0 -400px; } 100% { background-position: -7px -400px; } } @keyframes loading { 0% { background-position: 0 -400px; } 100% { background-position: -7px -400px; } } ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/css/fullcalendar.css ================================================ /*! * FullCalendar v1.6.4 Stylesheet * Docs & License: http://arshaw.com/fullcalendar/ * (c) 2013 Adam Shaw */ .fc { direction: ltr; text-align: left; } .fc table { border-collapse: collapse; border-spacing: 0; } html .fc, .fc table { font-size: 1em; } .fc td, .fc th { padding: 0; vertical-align: top; } /* Header ------------------------------------------------------------------------*/ .fc-header td { white-space: nowrap; } .fc-header-left { width: 25%; text-align: left; } .fc-header-center { text-align: center; } .fc-header-right { width: 25%; text-align: right; } .fc-header-title { display: inline-block; vertical-align: top; } .fc-header-title h2 { margin-top: 0; white-space: nowrap; } .fc .fc-header-space { padding-left: 10px; } .fc-header .fc-button { margin-bottom: 1em; vertical-align: top; } /* buttons edges butting together */ .fc-header .fc-button { margin-right: -1px; } .fc-header .fc-corner-right, /* non-theme */ .fc-header .ui-corner-right { /* theme */ margin-right: 0; /* back to normal */ } /* button layering (for border precedence) */ .fc-header .fc-state-hover, .fc-header .ui-state-hover { z-index: 2; } .fc-header .fc-state-down { z-index: 3; } .fc-header .fc-state-active, .fc-header .ui-state-active { z-index: 4; } /* Content ------------------------------------------------------------------------*/ .fc-content { clear: both; zoom: 1; /* for IE7, gives accurate coordinates for [un]freezeContentHeight */ } .fc-view { width: 100%; overflow: hidden; } /* Cell Styles ------------------------------------------------------------------------*/ .fc-widget-header, /* , usually */ .fc-widget-content { /* , usually */ border: 1px solid #ddd; } .fc-state-highlight { /* today cell */ /* TODO: add .fc-today to */ background: #fcf8e3; } .fc-cell-overlay { /* semi-transparent rectangle while dragging */ background: #bce8f1; opacity: .3; filter: alpha(opacity=30); /* for IE */ } /* Buttons ------------------------------------------------------------------------*/ .fc-button { position: relative; display: inline-block; padding: 0 .6em; overflow: hidden; height: 1.9em; line-height: 1.9em; white-space: nowrap; cursor: pointer; } .fc-state-default { /* non-theme */ border: 1px solid; } .fc-state-default.fc-corner-left { /* non-theme */ border-top-left-radius: 4px; border-bottom-left-radius: 4px; } .fc-state-default.fc-corner-right { /* non-theme */ border-top-right-radius: 4px; border-bottom-right-radius: 4px; } /* Our default prev/next buttons use HTML entities like ‹ › « » and we'll try to make them look good cross-browser. */ .fc-text-arrow { margin: 0 .1em; font-size: 2em; font-family: "Courier New", Courier, monospace; vertical-align: baseline; /* for IE7 */ } .fc-button-prev .fc-text-arrow, .fc-button-next .fc-text-arrow { /* for ‹ › */ font-weight: bold; } /* icon (for jquery ui) */ .fc-button .fc-icon-wrap { position: relative; float: left; top: 50%; } .fc-button .ui-icon { position: relative; float: left; margin-top: -50%; *margin-top: 0; *top: -50%; } /* button states borrowed from twitter bootstrap (http://twitter.github.com/bootstrap/) */ .fc-state-default { background-color: #f5f5f5; background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6)); background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6); background-image: -o-linear-gradient(top, #ffffff, #e6e6e6); background-image: linear-gradient(to bottom, #ffffff, #e6e6e6); background-repeat: repeat-x; border-color: #e6e6e6 #e6e6e6 #bfbfbf; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); color: #333; text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); } .fc-state-hover, .fc-state-down, .fc-state-active, .fc-state-disabled { color: #333333; background-color: #e6e6e6; } .fc-state-hover { color: #333333; text-decoration: none; background-position: 0 -15px; -webkit-transition: background-position 0.1s linear; -moz-transition: background-position 0.1s linear; -o-transition: background-position 0.1s linear; transition: background-position 0.1s linear; } .fc-state-down, .fc-state-active { background-color: #cccccc; background-image: none; outline: 0; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); } .fc-state-disabled { cursor: default; background-image: none; opacity: 0.65; filter: alpha(opacity=65); box-shadow: none; } /* Global Event Styles ------------------------------------------------------------------------*/ .fc-event-container > * { z-index: 8; } .fc-event-container > .ui-draggable-dragging, .fc-event-container > .ui-resizable-resizing { z-index: 9; } .fc-event { border: 1px solid #3a87ad; /* default BORDER color */ background-color: #3a87ad; /* default BACKGROUND color */ color: #fff; /* default TEXT color */ font-size: .85em; cursor: default; } a.fc-event { text-decoration: none; } a.fc-event, .fc-event-draggable { cursor: pointer; } .fc-rtl .fc-event { text-align: right; } .fc-event-inner { width: 100%; height: 100%; overflow: hidden; } .fc-event-time, .fc-event-title { padding: 0 1px; } .fc .ui-resizable-handle { display: block; position: absolute; z-index: 99999; overflow: hidden; /* hacky spaces (IE6/7) */ font-size: 300%; /* */ line-height: 50%; /* */ } /* Horizontal Events ------------------------------------------------------------------------*/ .fc-event-hori { border-width: 1px 0; margin-bottom: 1px; } .fc-ltr .fc-event-hori.fc-event-start, .fc-rtl .fc-event-hori.fc-event-end { border-left-width: 1px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; } .fc-ltr .fc-event-hori.fc-event-end, .fc-rtl .fc-event-hori.fc-event-start { border-right-width: 1px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; } /* resizable */ .fc-event-hori .ui-resizable-e { top: 0 !important; /* importants override pre jquery ui 1.7 styles */ right: -3px !important; width: 7px !important; height: 100% !important; cursor: e-resize; } .fc-event-hori .ui-resizable-w { top: 0 !important; left: -3px !important; width: 7px !important; height: 100% !important; cursor: w-resize; } .fc-event-hori .ui-resizable-handle { _padding-bottom: 14px; /* IE6 had 0 height */ } /* Reusable Separate-border Table ------------------------------------------------------------*/ table.fc-border-separate { border-collapse: separate; } .fc-border-separate th, .fc-border-separate td { border-width: 1px 0 0 1px; } .fc-border-separate th.fc-last, .fc-border-separate td.fc-last { border-right-width: 1px; } .fc-border-separate tr.fc-last th, .fc-border-separate tr.fc-last td { border-bottom-width: 1px; } .fc-border-separate tbody tr.fc-first td, .fc-border-separate tbody tr.fc-first th { border-top-width: 0; } /* Month View, Basic Week View, Basic Day View ------------------------------------------------------------------------*/ .fc-grid th { text-align: center; } .fc .fc-week-number { width: 22px; text-align: center; } .fc .fc-week-number div { padding: 0 2px; } .fc-grid .fc-day-number { float: right; padding: 0 2px; } .fc-grid .fc-other-month .fc-day-number { opacity: 0.3; filter: alpha(opacity=30); /* for IE */ /* opacity with small font can sometimes look too faded might want to set the 'color' property instead making day-numbers bold also fixes the problem */ } .fc-grid .fc-day-content { clear: both; padding: 2px 2px 1px; /* distance between events and day edges */ } /* event styles */ .fc-grid .fc-event-time { font-weight: bold; } /* right-to-left */ .fc-rtl .fc-grid .fc-day-number { float: left; } .fc-rtl .fc-grid .fc-event-time { float: right; } /* Agenda Week View, Agenda Day View ------------------------------------------------------------------------*/ .fc-agenda table { border-collapse: separate; } .fc-agenda-days th { text-align: center; } .fc-agenda .fc-agenda-axis { width: 50px; padding: 0 4px; vertical-align: middle; text-align: right; white-space: nowrap; font-weight: normal; } .fc-agenda .fc-week-number { font-weight: bold; } .fc-agenda .fc-day-content { padding: 2px 2px 1px; } /* make axis border take precedence */ .fc-agenda-days .fc-agenda-axis { border-right-width: 1px; } .fc-agenda-days .fc-col0 { border-left-width: 0; } /* all-day area */ .fc-agenda-allday th { border-width: 0 1px; } .fc-agenda-allday .fc-day-content { min-height: 34px; /* TODO: doesnt work well in quirksmode */ _height: 34px; } /* divider (between all-day and slots) */ .fc-agenda-divider-inner { height: 2px; overflow: hidden; } .fc-widget-header .fc-agenda-divider-inner { background: #eee; } /* slot rows */ .fc-agenda-slots th { border-width: 1px 1px 0; } .fc-agenda-slots td { border-width: 1px 0 0; background: none; } .fc-agenda-slots td div { height: 20px; } .fc-agenda-slots tr.fc-slot0 th, .fc-agenda-slots tr.fc-slot0 td { border-top-width: 0; } .fc-agenda-slots tr.fc-minor th, .fc-agenda-slots tr.fc-minor td { border-top-style: dotted; } .fc-agenda-slots tr.fc-minor th.ui-widget-header { *border-top-style: solid; /* doesn't work with background in IE6/7 */ } /* Vertical Events ------------------------------------------------------------------------*/ .fc-event-vert { border-width: 0 1px; } .fc-event-vert.fc-event-start { border-top-width: 1px; border-top-left-radius: 3px; border-top-right-radius: 3px; } .fc-event-vert.fc-event-end { border-bottom-width: 1px; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; } .fc-event-vert .fc-event-time { white-space: nowrap; font-size: 10px; } .fc-event-vert .fc-event-inner { position: relative; z-index: 2; } .fc-event-vert .fc-event-bg { /* makes the event lighter w/ a semi-transparent overlay */ position: absolute; z-index: 1; top: 0; left: 0; width: 100%; height: 100%; background: #fff; opacity: .25; filter: alpha(opacity=25); } .fc .ui-draggable-dragging .fc-event-bg, /* TODO: something nicer like .fc-opacity */ .fc-select-helper .fc-event-bg { display: none\9; /* for IE6/7/8. nested opacity filters while dragging don't work */ } /* resizable */ .fc-event-vert .ui-resizable-s { bottom: 0 !important; /* importants override pre jquery ui 1.7 styles */ width: 100% !important; height: 8px !important; overflow: hidden !important; line-height: 8px !important; font-size: 11px !important; font-family: monospace; text-align: center; cursor: s-resize; } .fc-agenda .ui-resizable-resizing { /* TODO: better selector */ _overflow: hidden; } ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/css/jquery.gritter.css ================================================ /* the norm */ #gritter-notice-wrapper { position:fixed; top:20px; right:20px; width:301px; z-index:9999; } #gritter-notice-wrapper.top-left { left: 20px; right: auto; } #gritter-notice-wrapper.bottom-right { top: auto; left: auto; bottom: 20px; right: 20px; } #gritter-notice-wrapper.bottom-left { top: auto; right: auto; bottom: 20px; left: 20px; } .gritter-item-wrapper { position:relative; margin:0 0 10px 0; background:url('../images/ie-spacer.gif'); /* ie7/8 fix */ } .gritter-top { background:url(../images/gritter.png) no-repeat left -30px; height:10px; } .hover .gritter-top { background-position:right -30px; } .gritter-bottom { background:url(../images/gritter.png) no-repeat left bottom; height:8px; margin:0; } .hover .gritter-bottom { background-position: bottom right; } .gritter-item { display:block; background:url(../images/gritter.png) no-repeat left -40px; color:#eee; padding:2px 11px 8px 11px; font-size: 11px; font-family:verdana; } .hover .gritter-item { background-position:right -40px; } .gritter-item p { padding:0; margin:0; word-wrap:break-word; } .gritter-close { display:none; position:absolute; top:5px; left:3px; background:url(../images/gritter.png) no-repeat left top; cursor:pointer; width:30px; height:30px; } .gritter-title { font-size:14px; font-weight:bold; padding:0 0 7px 0; display:block; text-shadow:1px 1px 0 #000; /* Not supported by IE :( */ } .gritter-image { width:48px; height:48px; float:left; } .gritter-with-image, .gritter-without-image { padding:0; } .gritter-with-image { width:220px; float:right; } /* for the light (white) version of the gritter notice */ .gritter-light .gritter-item, .gritter-light .gritter-bottom, .gritter-light .gritter-top, .gritter-light .gritter-close { background-image: url(../images/gritter-light.png); color: #222; } .gritter-light .gritter-title { text-shadow: none; } ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/css/multiple-select.css ================================================ /** * @author zhixin wen */ .ms-parent { display: inline-block; position: relative; vertical-align: middle; } .ms-choice { display: block; width: 100%; height: 26px; padding: 0; overflow: hidden; cursor: pointer; border: 1px solid #aaa; text-align: left; white-space: nowrap; line-height: 26px; color: #444; text-decoration: none; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; background-color: #fff; } .ms-choice.disabled { background-color: #f4f4f4; background-image: none; border: 1px solid #ddd; cursor: default; } .ms-choice > span { position: absolute; top: 0; left: 0; right: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; padding-left: 8px; } .ms-choice > span.placeholder { color: #999; } .ms-choice > div { position: absolute; top: 0; right: 0; width: 20px; height: 25px; background: url('multiple-select.png') left top no-repeat; } .ms-choice > div.open { background: url('multiple-select.png') right top no-repeat; } .ms-drop { width: 100%; overflow: hidden; display: none; margin-top: -1px; padding: 0; position: absolute; z-index: 1000; background: #fff; color: #000; border: 1px solid #aaa; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; } .ms-drop.bottom { top: 100%; -webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15); -moz-box-shadow: 0 4px 5px rgba(0, 0, 0, .15); box-shadow: 0 4px 5px rgba(0, 0, 0, .15); } .ms-drop.top { bottom: 100%; -webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15); -moz-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15); box-shadow: 0 -4px 5px rgba(0, 0, 0, .15); } .ms-search { display: inline-block; margin: 0; min-height: 26px; padding: 4px; position: relative; white-space: nowrap; width: 100%; z-index: 10000; } .ms-search input { width: 100%; height: auto !important; min-height: 24px; padding: 0 20px 0 5px; margin: 0; outline: 0; font-family: sans-serif; font-size: 1em; border: 1px solid #aaa; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; background: #fff url('multiple-select.png') no-repeat 100% -22px; background: url('multiple-select.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee)); background: url('multiple-select.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%); background: url('multiple-select.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%); background: url('multiple-select.png') no-repeat 100% -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%); background: url('multiple-select.png') no-repeat 100% -22px, -ms-linear-gradient(top, #ffffff 85%, #eeeeee 99%); background: url('multiple-select.png') no-repeat 100% -22px, linear-gradient(top, #ffffff 85%, #eeeeee 99%); } .ms-search, .ms-search input { -webkit-box-sizing: border-box; -khtml-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; } .ms-drop ul { overflow: auto; margin: 0; padding: 5px 8px; } .ms-drop ul > li { list-style: none; display: list-item; background-image: none; position: static; } .ms-drop ul > li .disabled { opacity: .35; filter: Alpha(Opacity=35); } .ms-drop ul > li.multiple { display: block; float: left; } .ms-drop ul > li.group { clear: both; } .ms-drop ul > li.multiple label { width: 100%; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .ms-drop ul > li label { font-weight: normal; display: block; white-space: nowrap; } .ms-drop ul > li label.optgroup { font-weight: bold; } .ms-drop input[type="checkbox"] { vertical-align: middle; } .ms-drop .ms-no-results { display: none; } ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/css/select2.css ================================================ /* Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013 */ .select2-container { margin: 0; position: relative; display: inline-block; /* inline-block for ie7 */ zoom: 1; *display: inline; vertical-align: middle; } .select2-container, .select2-drop, .select2-search, .select2-search input { /* Force border-box so that % widths fit the parent container without overlap because of margin/padding. More Info : http://www.quirksmode.org/css/box.html */ -webkit-box-sizing: border-box; /* webkit */ -moz-box-sizing: border-box; /* firefox */ box-sizing: border-box; /* css3 */ } .select2-container .select2-choice { display: block; height: 26px; padding: 0 0 0 8px; overflow: hidden; position: relative; border: 1px solid #aaa; white-space: nowrap; line-height: 26px; color: #444; text-decoration: none; border-radius: 4px; background-clip: padding-box; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; background-color: #fff; background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff)); background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%); background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%); background-image: -o-linear-gradient(bottom, #eee 0%, #fff 50%); background-image: -ms-linear-gradient(top, #fff 0%, #eee 50%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0); background-image: linear-gradient(top, #fff 0%, #eee 50%); } .select2-container.select2-drop-above .select2-choice { border-bottom-color: #aaa; border-radius: 0 0 4px 4px; background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff)); background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%); background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%); background-image: -o-linear-gradient(bottom, #eee 0%, #fff 90%); background-image: -ms-linear-gradient(top, #eee 0%, #fff 90%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0); background-image: linear-gradient(top, #eee 0%, #fff 90%); } .select2-container.select2-allowclear .select2-choice .select2-chosen { margin-right: 42px; } .select2-container .select2-choice > .select2-chosen { margin-right: 26px; display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .select2-container .select2-choice abbr { display: none; width: 12px; height: 12px; position: absolute; right: 24px; top: 8px; font-size: 1px; text-decoration: none; border: 0; background: url('select2.png') right top no-repeat; cursor: pointer; outline: 0; } .select2-container.select2-allowclear .select2-choice abbr { display: inline-block; } .select2-container .select2-choice abbr:hover { background-position: right -11px; cursor: pointer; } .select2-drop-mask { border: 0; margin: 0; padding: 0; position: fixed; left: 0; top: 0; min-height: 100%; min-width: 100%; height: auto; width: auto; opacity: 0; z-index: 9998; /* styles required for IE to work */ background-color: #fff; opacity: 0; filter: alpha(opacity=0); } .select2-drop { width: 100%; margin-top: -1px; position: absolute; z-index: 9999; top: 100%; background: #fff; color: #000; border: 1px solid #aaa; border-top: 0; border-radius: 0 0 4px 4px; -webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15); box-shadow: 0 4px 5px rgba(0, 0, 0, .15); } .select2-drop-auto-width { border-top: 1px solid #aaa; width: auto; } .select2-drop-auto-width .select2-search { padding-top: 4px; } .select2-drop.select2-drop-above { margin-top: 1px; border-top: 1px solid #aaa; border-bottom: 0; border-radius: 4px 4px 0 0; -webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15); box-shadow: 0 -4px 5px rgba(0, 0, 0, .15); } .select2-drop-active { border: 1px solid #5897fb; border-top: none; } .select2-drop.select2-drop-above.select2-drop-active { border-top: 1px solid #5897fb; } .select2-container .select2-choice .select2-arrow { display: inline-block; width: 18px; height: 100%; position: absolute; right: 0; top: 0; border-left: 1px solid #aaa; border-radius: 0 4px 4px 0; background-clip: padding-box; background: #ccc; background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee)); background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%); background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%); background-image: -o-linear-gradient(bottom, #ccc 0%, #eee 60%); background-image: -ms-linear-gradient(top, #ccc 0%, #eee 60%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0); background-image: linear-gradient(top, #ccc 0%, #eee 60%); } .select2-container .select2-choice .select2-arrow b { display: block; width: 100%; height: 100%; background: url('select2.png') no-repeat 0 1px; } .select2-search { display: inline-block; width: 100%; min-height: 26px; margin: 0; padding-left: 4px; padding-right: 4px; position: relative; z-index: 10000; white-space: nowrap; } .select2-search input { width: 100%; height: auto !important; min-height: 26px; padding: 4px 20px 4px 5px; margin: 0; outline: 0; font-family: sans-serif; font-size: 1em; border: 1px solid #aaa; border-radius: 0; -webkit-box-shadow: none; box-shadow: none; background: #fff url('select2.png') no-repeat 100% -22px; background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); background: url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); background: url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); background: url('select2.png') no-repeat 100% -22px, -o-linear-gradient(bottom, #fff 85%, #eee 99%); background: url('select2.png') no-repeat 100% -22px, -ms-linear-gradient(top, #fff 85%, #eee 99%); background: url('select2.png') no-repeat 100% -22px, linear-gradient(top, #fff 85%, #eee 99%); } .select2-drop.select2-drop-above .select2-search input { margin-top: 4px; } .select2-search input.select2-active { background: #fff url('select2-spinner.gif') no-repeat 100%; background: url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); background: url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); background: url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); background: url('select2-spinner.gif') no-repeat 100%, -o-linear-gradient(bottom, #fff 85%, #eee 99%); background: url('select2-spinner.gif') no-repeat 100%, -ms-linear-gradient(top, #fff 85%, #eee 99%); background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(top, #fff 85%, #eee 99%); } .select2-container-active .select2-choice, .select2-container-active .select2-choices { border: 1px solid #5897fb; outline: none; -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3); box-shadow: 0 0 5px rgba(0, 0, 0, .3); } .select2-dropdown-open .select2-choice { border-bottom-color: transparent; -webkit-box-shadow: 0 1px 0 #fff inset; box-shadow: 0 1px 0 #fff inset; border-bottom-left-radius: 0; border-bottom-right-radius: 0; background-color: #eee; background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee)); background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%); background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%); background-image: -o-linear-gradient(bottom, #fff 0%, #eee 50%); background-image: -ms-linear-gradient(top, #fff 0%, #eee 50%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0); background-image: linear-gradient(top, #fff 0%, #eee 50%); } .select2-dropdown-open.select2-drop-above .select2-choice, .select2-dropdown-open.select2-drop-above .select2-choices { border: 1px solid #5897fb; border-top-color: transparent; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee)); background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%); background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%); background-image: -o-linear-gradient(top, #fff 0%, #eee 50%); background-image: -ms-linear-gradient(bottom, #fff 0%, #eee 50%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0); background-image: linear-gradient(bottom, #fff 0%, #eee 50%); } .select2-dropdown-open .select2-choice .select2-arrow { background: transparent; border-left: none; filter: none; } .select2-dropdown-open .select2-choice .select2-arrow b { background-position: -18px 1px; } /* results */ .select2-results { max-height: 200px; padding: 0 0 0 4px; margin: 4px 4px 4px 0; position: relative; overflow-x: hidden; overflow-y: auto; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } .select2-results ul.select2-result-sub { margin: 0; padding-left: 0; } .select2-results ul.select2-result-sub > li .select2-result-label { padding-left: 20px } .select2-results ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 40px } .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 60px } .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 80px } .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 100px } .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 110px } .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 120px } .select2-results li { list-style: none; display: list-item; background-image: none; } .select2-results li.select2-result-with-children > .select2-result-label { font-weight: bold; } .select2-results .select2-result-label { padding: 3px 7px 4px; margin: 0; cursor: pointer; min-height: 1em; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .select2-results .select2-highlighted { background: #3875d7; color: #fff; } .select2-results li em { background: #feffde; font-style: normal; } .select2-results .select2-highlighted em { background: transparent; } .select2-results .select2-highlighted ul { background: #fff; color: #000; } .select2-results .select2-no-results, .select2-results .select2-searching, .select2-results .select2-selection-limit { background: #f4f4f4; display: list-item; } /* disabled look for disabled choices in the results dropdown */ .select2-results .select2-disabled.select2-highlighted { color: #666; background: #f4f4f4; display: list-item; cursor: default; } .select2-results .select2-disabled { background: #f4f4f4; display: list-item; cursor: default; } .select2-results .select2-selected { display: none; } .select2-more-results.select2-active { background: #f4f4f4 url('select2-spinner.gif') no-repeat 100%; } .select2-more-results { background: #f4f4f4; display: list-item; } /* disabled styles */ .select2-container.select2-container-disabled .select2-choice { background-color: #f4f4f4; background-image: none; border: 1px solid #ddd; cursor: default; } .select2-container.select2-container-disabled .select2-choice .select2-arrow { background-color: #f4f4f4; background-image: none; border-left: 0; } .select2-container.select2-container-disabled .select2-choice abbr { display: none; } /* multiselect */ .select2-container-multi .select2-choices { height: auto !important; height: 1%; margin: 0; padding: 0; position: relative; border: 1px solid #aaa; cursor: text; overflow: hidden; background-color: #fff; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff)); background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%); background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%); background-image: -o-linear-gradient(top, #eee 1%, #fff 15%); background-image: -ms-linear-gradient(top, #eee 1%, #fff 15%); background-image: linear-gradient(top, #eee 1%, #fff 15%); } .select2-locked { padding: 3px 5px 3px 5px !important; } .select2-container-multi .select2-choices { min-height: 26px; } .select2-container-multi.select2-container-active .select2-choices { border: 1px solid #5897fb; outline: none; -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3); box-shadow: 0 0 5px rgba(0, 0, 0, .3); } .select2-container-multi .select2-choices li { float: left; list-style: none; } .select2-container-multi .select2-choices .select2-search-field { margin: 0; padding: 0; white-space: nowrap; } .select2-container-multi .select2-choices .select2-search-field input { padding: 5px; margin: 1px 0; font-family: sans-serif; font-size: 100%; color: #666; outline: 0; border: 0; -webkit-box-shadow: none; box-shadow: none; background: transparent !important; } .select2-container-multi .select2-choices .select2-search-field input.select2-active { background: #fff url('select2-spinner.gif') no-repeat 100% !important; } .select2-default { color: #999 !important; } .select2-container-multi .select2-choices .select2-search-choice { padding: 3px 5px 3px 18px; margin: 3px 0 3px 5px; position: relative; line-height: 13px; color: #333; cursor: default; border: 1px solid #aaaaaa; border-radius: 3px; -webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05); box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05); background-clip: padding-box; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; background-color: #e4e4e4; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee)); background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); background-image: -ms-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); } .select2-container-multi .select2-choices .select2-search-choice .select2-chosen { cursor: default; } .select2-container-multi .select2-choices .select2-search-choice-focus { background: #d4d4d4; } .select2-search-choice-close { display: block; width: 12px; height: 13px; position: absolute; right: 3px; top: 4px; font-size: 1px; outline: none; background: url('select2.png') right top no-repeat; } .select2-container-multi .select2-search-choice-close { left: 3px; } .select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover { background-position: right -11px; } .select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close { background-position: right -11px; } /* disabled styles */ .select2-container-multi.select2-container-disabled .select2-choices { background-color: #f4f4f4; background-image: none; border: 1px solid #ddd; cursor: default; } .select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice { padding: 3px 5px 3px 5px; border: 1px solid #ddd; background-image: none; background-color: #f4f4f4; } .select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close { display: none; background: none; } /* end multiselect */ .select2-result-selectable .select2-match, .select2-result-unselectable .select2-match { text-decoration: underline; } .select2-offscreen, .select2-offscreen:focus { clip: rect(0 0 0 0) !important; width: 1px !important; height: 1px !important; border: 0 !important; margin: 0 !important; padding: 0 !important; overflow: hidden !important; position: absolute !important; outline: 0 !important; left: 0px !important; top: 0px !important; } .select2-display-none { display: none; } .select2-measure-scrollbar { position: absolute; top: -10000px; left: -10000px; width: 100px; height: 100px; overflow: scroll; } /* Retina-ize icons */ @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { .select2-search input, .select2-search-choice-close, .select2-container .select2-choice abbr, .select2-container .select2-choice .select2-arrow b { background-image: url('select2x2.png') !important; background-repeat: no-repeat !important; background-size: 60px 40px !important; } .select2-search input { background-position: 100% -21px !important; } } ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/css/ui.jqgrid.css ================================================ /*Grid*/ .ui-jqgrid {position: relative;} .ui-jqgrid .ui-jqgrid-view {position: relative;left:0; top: 0; padding: 0; font-size:11px;} /* caption*/ .ui-jqgrid .ui-jqgrid-titlebar {padding: .3em .2em .2em .3em; position: relative; border-left: 0 none;border-right: 0 none; border-top: 0 none;} .ui-jqgrid .ui-jqgrid-title { float: left; margin: .1em 0 .2em; } .ui-jqgrid .ui-jqgrid-titlebar-close { position: absolute;top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height:18px;}.ui-jqgrid .ui-jqgrid-titlebar-close span { display: block; margin: 1px; } .ui-jqgrid .ui-jqgrid-titlebar-close:hover { padding: 0; } /* header*/ .ui-jqgrid .ui-jqgrid-hdiv {position: relative; margin: 0;padding: 0; overflow-x: hidden; border-left: 0 none !important; border-top : 0 none !important; border-right : 0 none !important;} .ui-jqgrid .ui-jqgrid-hbox {float: left; padding-right: 20px;} .ui-jqgrid .ui-jqgrid-htable {table-layout:fixed;margin:0;} .ui-jqgrid .ui-jqgrid-htable th {height:22px;padding: 0 2px 0 2px;} .ui-jqgrid .ui-jqgrid-htable th div {overflow: hidden; position:relative; height:17px;} .ui-th-column, .ui-jqgrid .ui-jqgrid-htable th.ui-th-column {overflow: hidden;white-space: nowrap;text-align:center;border-top : 0 none;border-bottom : 0 none;} .ui-th-ltr, .ui-jqgrid .ui-jqgrid-htable th.ui-th-ltr {border-left : 0 none;} .ui-th-rtl, .ui-jqgrid .ui-jqgrid-htable th.ui-th-rtl {border-right : 0 none;} .ui-first-th-ltr {border-right: 1px solid; } .ui-first-th-rtl {border-left: 1px solid; } .ui-jqgrid .ui-th-div-ie {white-space: nowrap; zoom :1; height:17px;} .ui-jqgrid .ui-jqgrid-resize {height:20px !important;position: relative; cursor :e-resize;display: inline;overflow: hidden;} .ui-jqgrid .ui-grid-ico-sort {overflow:hidden;position:absolute;display:inline; cursor: pointer !important;} .ui-jqgrid .ui-icon-asc {margin-top:-3px; height:12px;} .ui-jqgrid .ui-icon-desc {margin-top:3px;height:12px;} .ui-jqgrid .ui-i-asc {margin-top:0;height:16px;} .ui-jqgrid .ui-i-desc {margin-top:0;margin-left:13px;height:16px;} .ui-jqgrid .ui-jqgrid-sortable {cursor:pointer;} .ui-jqgrid tr.ui-search-toolbar th { border-top-width: 1px !important; border-top-color: inherit !important; border-top-style: ridge !important } tr.ui-search-toolbar input {margin: 1px 0 0 0} tr.ui-search-toolbar select {margin: 1px 0 0 0} /* body */ .ui-jqgrid .ui-jqgrid-bdiv {position: relative; margin: 0; padding:0; overflow: auto; text-align:left;} .ui-jqgrid .ui-jqgrid-btable {table-layout:fixed; margin:0; outline-style: none; } .ui-jqgrid tr.jqgrow { outline-style: none; } .ui-jqgrid tr.jqgroup { outline-style: none; } .ui-jqgrid tr.jqgrow td {font-weight: normal; overflow: hidden; white-space: pre; height: 22px;padding: 0 2px 0 2px;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;} .ui-jqgrid tr.jqgfirstrow td {padding: 0 2px 0 2px;border-right-width: 1px; border-right-style: solid;} .ui-jqgrid tr.jqgroup td {font-weight: normal; overflow: hidden; white-space: pre; height: 22px;padding: 0 2px 0 2px;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;} .ui-jqgrid tr.jqfoot td {font-weight: bold; overflow: hidden; white-space: pre; height: 22px;padding: 0 2px 0 2px;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;} .ui-jqgrid tr.ui-row-ltr td {text-align:left;border-right-width: 1px; border-right-color: inherit; border-right-style: solid;} .ui-jqgrid tr.ui-row-rtl td {text-align:right;border-left-width: 1px; border-left-color: inherit; border-left-style: solid;} .ui-jqgrid td.jqgrid-rownum { padding: 0 2px 0 2px; margin: 0; border: 0 none;} .ui-jqgrid .ui-jqgrid-resize-mark { width:2px; left:0; background-color:#777; cursor: e-resize; cursor: col-resize; position:absolute; top:0; height:100px; overflow:hidden; display:none; border:0 none; z-index: 99999;} /* footer */ .ui-jqgrid .ui-jqgrid-sdiv {position: relative; margin: 0;padding: 0; overflow: hidden; border-left: 0 none !important; border-top : 0 none !important; border-right : 0 none !important;} .ui-jqgrid .ui-jqgrid-ftable {table-layout:fixed; margin-bottom:0;} .ui-jqgrid tr.footrow td {font-weight: bold; overflow: hidden; white-space:nowrap; height: 21px;padding: 0 2px 0 2px;border-top-width: 1px; border-top-color: inherit; border-top-style: solid;} .ui-jqgrid tr.footrow-ltr td {text-align:left;border-right-width: 1px; border-right-color: inherit; border-right-style: solid;} .ui-jqgrid tr.footrow-rtl td {text-align:right;border-left-width: 1px; border-left-color: inherit; border-left-style: solid;} /* Pager*/ .ui-jqgrid .ui-jqgrid-pager { border-left: 0 none !important;border-right: 0 none !important; border-bottom: 0 none !important; margin: 0 !important; padding: 0 !important; position: relative; height: 25px;white-space: nowrap;overflow: hidden;font-size:11px;} .ui-jqgrid .ui-pager-control {position: relative;} .ui-jqgrid .ui-pg-table {position: relative; padding-bottom:2px; width:auto; margin: 0;} .ui-jqgrid .ui-pg-table td {font-weight:normal; vertical-align:middle; padding:1px;} .ui-jqgrid .ui-pg-button { height:19px !important;} .ui-jqgrid .ui-pg-button span { display: block; margin: 1px; float:left;} .ui-jqgrid .ui-pg-button:hover { padding: 0; } .ui-jqgrid .ui-state-disabled:hover {padding:1px;} .ui-jqgrid .ui-pg-input { height:13px;font-size:.8em; margin: 0;} .ui-jqgrid .ui-pg-selbox {font-size:.8em; line-height:18px; display:block; height:18px; margin: 0;} .ui-jqgrid .ui-separator {height: 18px; border-left: 1px solid #ccc ; border-right: 1px solid #ccc ; margin: 1px; float: right;} .ui-jqgrid .ui-paging-info {font-weight: normal;height:19px; margin-top:3px;margin-right:4px;} .ui-jqgrid .ui-jqgrid-pager .ui-pg-div {padding:1px 0;float:left;position:relative;} .ui-jqgrid .ui-jqgrid-pager .ui-pg-button { cursor:pointer; } .ui-jqgrid .ui-jqgrid-pager .ui-pg-div span.ui-icon {float:left;margin:0 2px;} .ui-jqgrid td input, .ui-jqgrid td select .ui-jqgrid td textarea { margin: 0;} .ui-jqgrid td textarea {width:auto;height:auto;} .ui-jqgrid .ui-jqgrid-toppager {border-left: 0 none !important;border-right: 0 none !important; border-top: 0 none !important; margin: 0 !important; padding: 0 !important; position: relative; height: 25px !important;white-space: nowrap;overflow: hidden;} .ui-jqgrid .ui-jqgrid-toppager .ui-pg-div {padding:1px 0;float:left;position:relative;} .ui-jqgrid .ui-jqgrid-toppager .ui-pg-button { cursor:pointer; } .ui-jqgrid .ui-jqgrid-toppager .ui-pg-div span.ui-icon {float:left;margin:0 2px;} /*subgrid*/ .ui-jqgrid .ui-jqgrid-btable .ui-sgcollapsed span {display: block;} .ui-jqgrid .ui-subgrid {margin:0;padding:0; width:100%;} .ui-jqgrid .ui-subgrid table {table-layout: fixed;} .ui-jqgrid .ui-subgrid tr.ui-subtblcell td {height:18px;border-right-width: 1px; border-right-color: inherit; border-right-style: solid;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;} .ui-jqgrid .ui-subgrid td.subgrid-data {border-top: 0 none !important;} .ui-jqgrid .ui-subgrid td.subgrid-cell {border-width: 0 0 1px 0;} .ui-jqgrid .ui-th-subgrid {height:20px;} /* loading */ .ui-jqgrid .loading {position: absolute; top: 45%;left: 45%;width: auto;z-index:101;padding: 6px; margin: 5px;text-align: center;font-weight: bold;display: none;border-width: 2px !important; font-size:11px;} .ui-jqgrid .jqgrid-overlay {display:none;z-index:100;} * html .jqgrid-overlay {width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');} * .jqgrid-overlay iframe {position:absolute;top:0;left:0;z-index:-1;width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');} /* end loading div */ /* toolbar */ .ui-jqgrid .ui-userdata {border-left: 0 none; border-right: 0 none; height : 21px;overflow: hidden; } /*Modal Window */ .ui-jqdialog { display: none; width: 300px; position: absolute; padding: .2em; font-size:11px; overflow:visible;} .ui-jqdialog .ui-jqdialog-titlebar { padding: .3em .2em; position: relative; } .ui-jqdialog .ui-jqdialog-title { margin: .1em 0 .2em; } .ui-jqdialog .ui-jqdialog-titlebar-close { position: absolute; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; } .ui-jqdialog .ui-jqdialog-titlebar-close span { display: block; margin: 1px; } .ui-jqdialog .ui-jqdialog-titlebar-close:hover, .ui-jqdialog .ui-jqdialog-titlebar-close:focus { padding: 0; } .ui-jqdialog-content, .ui-jqdialog .ui-jqdialog-content { border: 0; padding: .3em .2em; background: none; height:auto;} .ui-jqdialog .ui-jqconfirm {padding: .4em 1em; border-width:3px;position:absolute;bottom:10px;right:10px;overflow:visible;display:none;height:80px;width:220px;text-align:center;} .ui-jqdialog>.ui-resizable-se { bottom: -3px; right: -3px} /* end Modal window*/ /* Form edit */ .ui-jqdialog-content .FormGrid {margin: 0;} .ui-jqdialog-content .EditTable { width: 100%; margin-bottom:0;} .ui-jqdialog-content .DelTable { width: 100%; margin-bottom:0;} .EditTable td input, .EditTable td select, .EditTable td textarea {margin: 0;} .EditTable td textarea { width:auto; height:auto;} .ui-jqdialog-content td.EditButton {text-align: right;border-top: 0 none;border-left: 0 none;border-right: 0 none; padding-bottom:5px; padding-top:5px;} .ui-jqdialog-content td.navButton {text-align: center; border-left: 0 none;border-top: 0 none;border-right: 0 none; padding-bottom:5px; padding-top:5px;} .ui-jqdialog-content input.FormElement {padding:.3em} .ui-jqdialog-content select.FormElement {padding:.3em} .ui-jqdialog-content .data-line {padding-top:.1em;border: 0 none;} .ui-jqdialog-content .CaptionTD {vertical-align: middle;border: 0 none; padding: 2px;white-space: nowrap;} .ui-jqdialog-content .DataTD {padding: 2px; border: 0 none; vertical-align: top;} .ui-jqdialog-content .form-view-data {white-space:pre} .fm-button { display: inline-block; margin:0 4px 0 0; padding: .4em .5em; text-decoration:none !important; cursor:pointer; position: relative; text-align: center; zoom: 1; } .fm-button-icon-left { padding-left: 1.9em; } .fm-button-icon-right { padding-right: 1.9em; } .fm-button-icon-left .ui-icon { right: auto; left: .2em; margin-left: 0; position: absolute; top: 50%; margin-top: -8px; } .fm-button-icon-right .ui-icon { left: auto; right: .2em; margin-left: 0; position: absolute; top: 50%; margin-top: -8px;} #nData, #pData { float: left; margin:3px;padding: 0; width: 15px; } /* End Eorm edit */ /*.ui-jqgrid .edit-cell {}*/ .ui-jqgrid .selected-row, div.ui-jqgrid .selected-row td {font-style : normal;border-left: 0 none;} /* inline edit actions button*/ .ui-inline-del.ui-state-hover span, .ui-inline-edit.ui-state-hover span, .ui-inline-save.ui-state-hover span, .ui-inline-cancel.ui-state-hover span { margin: -1px; } /* Tree Grid */ .ui-jqgrid .tree-wrap {float: left; position: relative;height: 18px;white-space: nowrap;overflow: hidden;} .ui-jqgrid .tree-minus {position: absolute; height: 18px; width: 18px; overflow: hidden;} .ui-jqgrid .tree-plus {position: absolute; height: 18px; width: 18px; overflow: hidden;} .ui-jqgrid .tree-leaf {position: absolute; height: 18px; width: 18px;overflow: hidden;} .ui-jqgrid .treeclick {cursor: pointer;} /* moda dialog */ * iframe.jqm {position:absolute;top:0;left:0;z-index:-1;width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');} .ui-jqgrid-dnd tr td {border-right-width: 1px; border-right-color: inherit; border-right-style: solid; height:20px} /* RTL Support */ .ui-jqgrid .ui-jqgrid-title-rtl {float:right;margin: .1em 0 .2em; } .ui-jqgrid .ui-jqgrid-hbox-rtl {float: right; padding-left: 20px;} .ui-jqgrid .ui-jqgrid-resize-ltr {float: right;margin: -2px -2px -2px 0;} .ui-jqgrid .ui-jqgrid-resize-rtl {float: left;margin: -2px 0 -1px -3px;} .ui-jqgrid .ui-sort-rtl {left:0;} .ui-jqgrid .tree-wrap-ltr {float: left;} .ui-jqgrid .tree-wrap-rtl {float: right;} .ui-jqgrid .ui-ellipsis {text-overflow:ellipsis;} /* Toolbar Search Menu */ .ui-search-menu { position: absolute; padding: 2px 5px;} .ui-jqgrid .ui-search-table { padding: 0px 0px; border: 0px none; height:20px; width:100%;} .ui-jqgrid .ui-search-table .ui-search-oper { width:20px; } ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/font/fonts.googleapis.com.css ================================================ @font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 300; src: local('Open Sans Light'), local('OpenSans-Light'), url(DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff) format('woff'); } @font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 400; src: local('Open Sans'), local('OpenSans'), url(cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff) format('woff'); } ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/js/fuelux/data/fuelux.tree-sampledata.js ================================================ var DataSourceTree = function(options) { this._data = options.data; this._delay = options.delay; } DataSourceTree.prototype.data = function(options, callback) { var self = this; var $data = null; if(!("name" in options) && !("type" in options)){ $data = this._data;//the root tree callback({ data: $data }); return; } else if("type" in options && options.type == "folder") { if("additionalParameters" in options && "children" in options.additionalParameters) $data = options.additionalParameters.children; else $data = {}//no data } if($data != null)//this setTimeout is only for mimicking some random delay setTimeout(function(){callback({ data: $data });} , parseInt(Math.random() * 500) + 200); //we have used static data here //but you can retrieve your data dynamically from a server using ajax call //checkout examples/treeview.html and examples/treeview.js for more info }; var tree_data = { 'for-sale' : {name: 'For Sale', type: 'folder'} , 'vehicles' : {name: 'Vehicles', type: 'folder'} , 'rentals' : {name: 'Rentals', type: 'folder'} , 'real-estate' : {name: 'Real Estate', type: 'folder'} , 'pets' : {name: 'Pets', type: 'folder'} , 'tickets' : {name: 'Tickets', type: 'item'} , 'services' : {name: 'Services', type: 'item'} , 'personals' : {name: 'Personals', type: 'item'} } tree_data['for-sale']['additionalParameters'] = { 'children' : { 'appliances' : {name: 'Appliances', type: 'item'}, 'arts-crafts' : {name: 'Arts & Crafts', type: 'item'}, 'clothing' : {name: 'Clothing', type: 'item'}, 'computers' : {name: 'Computers', type: 'item'}, 'jewelry' : {name: 'Jewelry', type: 'item'}, 'office-business' : {name: 'Office & Business', type: 'item'}, 'sports-fitness' : {name: 'Sports & Fitness', type: 'item'} } } tree_data['vehicles']['additionalParameters'] = { 'children' : { 'cars' : {name: 'Cars', type: 'folder'}, 'motorcycles' : {name: 'Motorcycles', type: 'item'}, 'boats' : {name: 'Boats', type: 'item'} } } tree_data['vehicles']['additionalParameters']['children']['cars']['additionalParameters'] = { 'children' : { 'classics' : {name: 'Classics', type: 'item'}, 'convertibles' : {name: 'Convertibles', type: 'item'}, 'coupes' : {name: 'Coupes', type: 'item'}, 'hatchbacks' : {name: 'Hatchbacks', type: 'item'}, 'hybrids' : {name: 'Hybrids', type: 'item'}, 'suvs' : {name: 'SUVs', type: 'item'}, 'sedans' : {name: 'Sedans', type: 'item'}, 'trucks' : {name: 'Trucks', type: 'item'} } } tree_data['rentals']['additionalParameters'] = { 'children' : { 'apartments-rentals' : {name: 'Apartments', type: 'item'}, 'office-space-rentals' : {name: 'Office Space', type: 'item'}, 'vacation-rentals' : {name: 'Vacation Rentals', type: 'item'} } } tree_data['real-estate']['additionalParameters'] = { 'children' : { 'apartments' : {name: 'Apartments', type: 'item'}, 'villas' : {name: 'Villas', type: 'item'}, 'plots' : {name: 'Plots', type: 'item'} } } tree_data['pets']['additionalParameters'] = { 'children' : { 'cats' : {name: 'Cats', type: 'item'}, 'dogs' : {name: 'Dogs', type: 'item'}, 'horses' : {name: 'Horses', type: 'item'}, 'reptiles' : {name: 'Reptiles', type: 'item'} } } var treeDataSource = new DataSourceTree({data: tree_data}); var tree_data_2 = { 'pictures' : {name: 'Pictures', type: 'folder', 'icon-class':'red'} , 'music' : {name: 'Music', type: 'folder', 'icon-class':'orange'} , 'video' : {name: 'Video', type: 'folder', 'icon-class':'blue'} , 'documents' : {name: 'Documents', type: 'folder', 'icon-class':'green'} , 'backup' : {name: 'Backup', type: 'folder'} , 'readme' : {name: ' ReadMe.txt', type: 'item'}, 'manual' : {name: ' Manual.html', type: 'item'} } tree_data_2['music']['additionalParameters'] = { 'children' : [ {name: ' song1.ogg', type: 'item'}, {name: ' song2.ogg', type: 'item'}, {name: ' song3.ogg', type: 'item'}, {name: ' song4.ogg', type: 'item'}, {name: ' song5.ogg', type: 'item'} ] } tree_data_2['video']['additionalParameters'] = { 'children' : [ {name: ' movie1.avi', type: 'item'}, {name: ' movie2.avi', type: 'item'}, {name: ' movie3.avi', type: 'item'}, {name: ' movie4.avi', type: 'item'}, {name: ' movie5.avi', type: 'item'} ] } tree_data_2['pictures']['additionalParameters'] = { 'children' : { 'wallpapers' : {name: 'Wallpapers', type: 'folder', 'icon-class':'pink'}, 'camera' : {name: 'Camera', type: 'folder', 'icon-class':'pink'} } } tree_data_2['pictures']['additionalParameters']['children']['wallpapers']['additionalParameters'] = { 'children' : [ {name: ' wallpaper1.jpg', type: 'item'}, {name: ' wallpaper2.jpg', type: 'item'}, {name: ' wallpaper3.jpg', type: 'item'}, {name: ' wallpaper4.jpg', type: 'item'} ] } tree_data_2['pictures']['additionalParameters']['children']['camera']['additionalParameters'] = { 'children' : [ {name: ' photo1.jpg', type: 'item'}, {name: ' photo2.jpg', type: 'item'}, {name: ' photo3.jpg', type: 'item'}, {name: ' photo4.jpg', type: 'item'}, {name: ' photo5.jpg', type: 'item'}, {name: ' photo6.jpg', type: 'item'} ] } tree_data_2['documents']['additionalParameters'] = { 'children' : [ {name: ' document1.pdf', type: 'item'}, {name: ' document2.doc', type: 'item'}, {name: ' document3.doc', type: 'item'}, {name: ' document4.pdf', type: 'item'}, {name: ' document5.doc', type: 'item'} ] } tree_data_2['backup']['additionalParameters'] = { 'children' : [ {name: ' backup1.zip', type: 'item'}, {name: ' backup2.zip', type: 'item'}, {name: ' backup3.zip', type: 'item'}, {name: ' backup4.zip', type: 'item'} ] } var treeDataSource2 = new DataSourceTree({data: tree_data_2}); ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/js/html5shiv.js ================================================ /** * @preserve HTML5 Shiv tpl.6.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed */ ;(function(window, document) { /*jshint evil:true */ /** version */ var version = '3.6.2'; /** Preset options */ var options = window.html5 || {}; /** Used to skip problem elements */ var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i; /** Not all elements can be cloned in IE **/ var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i; /** Detect whether the browser supports default html5 styles */ var supportsHtml5Styles; /** Name of the expando, to work with multiple documents or to re-shiv one document */ var expando = '_html5shiv'; /** The id for the the documents expando */ var expanID = 0; /** Cached data for each document */ var expandoData = {}; /** Detect whether the browser supports unknown elements */ var supportsUnknownElements; (function() { try { var a = document.createElement('a'); a.innerHTML = ''; //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles supportsHtml5Styles = ('hidden' in a); supportsUnknownElements = a.childNodes.length == 1 || (function() { // assign a false positive if unable to shiv (document.createElement)('a'); var frag = document.createDocumentFragment(); return ( typeof frag.cloneNode == 'undefined' || typeof frag.createDocumentFragment == 'undefined' || typeof frag.createElement == 'undefined' ); }()); } catch(e) { // assign a false positive if detection fails => unable to shiv supportsHtml5Styles = true; supportsUnknownElements = true; } }()); /*--------------------------------------------------------------------------*/ /** * Creates a style sheet with the given CSS text and adds it to the document. * @private * @param {Document} ownerDocument The document. * @param {String} cssText The CSS text. * @returns {StyleSheet} The style element. */ function addStyleSheet(ownerDocument, cssText) { var p = ownerDocument.createElement('p'), parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement; p.innerHTML = 'x'; return parent.insertBefore(p.lastChild, parent.firstChild); } /** * Returns the value of `html5.elements` as an array. * @private * @returns {Array} An array of shived element node names. */ function getElements() { var elements = html5.elements; return typeof elements == 'string' ? elements.split(' ') : elements; } /** * Returns the data associated to the given document * @private * @param {Document} ownerDocument The document. * @returns {Object} An object of data. */ function getExpandoData(ownerDocument) { var data = expandoData[ownerDocument[expando]]; if (!data) { data = {}; expanID++; ownerDocument[expando] = expanID; expandoData[expanID] = data; } return data; } /** * returns a shived element for the given nodeName and document * @memberOf html5 * @param {String} nodeName name of the element * @param {Document} ownerDocument The context document. * @returns {Object} The shived element. */ function createElement(nodeName, ownerDocument, data){ if (!ownerDocument) { ownerDocument = document; } if(supportsUnknownElements){ return ownerDocument.createElement(nodeName); } if (!data) { data = getExpandoData(ownerDocument); } var node; if (data.cache[nodeName]) { node = data.cache[nodeName].cloneNode(); } else if (saveClones.test(nodeName)) { node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode(); } else { node = data.createElem(nodeName); } // Avoid adding some elements to fragments in IE < 9 because // * Attributes like `name` or `type` cannot be set/changed once an element // is inserted into a document/fragment // * Link elements with `src` attributes that are inaccessible, as with // a 403 response, will cause the tab/window to crash // * Script elements appended to fragments will execute when their `src` // or `text` property is set return node.canHaveChildren && !reSkip.test(nodeName) ? data.frag.appendChild(node) : node; } /** * returns a shived DocumentFragment for the given document * @memberOf html5 * @param {Document} ownerDocument The context document. * @returns {Object} The shived DocumentFragment. */ function createDocumentFragment(ownerDocument, data){ if (!ownerDocument) { ownerDocument = document; } if(supportsUnknownElements){ return ownerDocument.createDocumentFragment(); } data = data || getExpandoData(ownerDocument); var clone = data.frag.cloneNode(), i = 0, elems = getElements(), l = elems.length; for(;i colModel!" }, formatter : { integer : {thousandsSeparator: ",", defaultValue: '0'}, number : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, defaultValue: '0.00'}, currency : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'}, date : { dayNames: [ "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], AmPm : ["am","pm","AM","PM"], S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th';}, srcformat: 'Y-m-d', newformat: 'n/j/Y', parseRe : /[Tt\\\/:_;.,\t\s-]/, masks : { // see http://php.net/manual/en/function.date.php for PHP format used in jqGrid // and see http://docs.jquery.com/UI/Datepicker/formatDate // and https://github.com/jquery/globalize#dates for alternative formats used frequently // one can find on https://github.com/jquery/globalize/tree/master/lib/cultures many // information about date, time, numbers and currency formats used in different countries // one should just convert the information in PHP format ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", // short date: // n - Numeric representation of a month, without leading zeros // j - Day of the month without leading zeros // Y - A full numeric representation of a year, 4 digits // example: 3/1/2012 which means 1 March 2012 ShortDate: "n/j/Y", // in jQuery UI Datepicker: "M/d/yyyy" // long date: // l - A full textual representation of the day of the week // F - A full textual representation of a month // d - Day of the month, 2 digits with leading zeros // Y - A full numeric representation of a year, 4 digits LongDate: "l, F d, Y", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy" // long date with long time: // l - A full textual representation of the day of the week // F - A full textual representation of a month // d - Day of the month, 2 digits with leading zeros // Y - A full numeric representation of a year, 4 digits // g - 12-hour format of an hour without leading zeros // i - Minutes with leading zeros // s - Seconds, with leading zeros // A - Uppercase Ante meridiem and Post meridiem (AM or PM) FullDateTime: "l, F d, Y g:i:s A", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy h:mm:ss tt" // month day: // F - A full textual representation of a month // d - Day of the month, 2 digits with leading zeros MonthDay: "F d", // in jQuery UI Datepicker: "MMMM dd" // short time (without seconds) // g - 12-hour format of an hour without leading zeros // i - Minutes with leading zeros // A - Uppercase Ante meridiem and Post meridiem (AM or PM) ShortTime: "g:i A", // in jQuery UI Datepicker: "h:mm tt" // long time (with seconds) // g - 12-hour format of an hour without leading zeros // i - Minutes with leading zeros // s - Seconds, with leading zeros // A - Uppercase Ante meridiem and Post meridiem (AM or PM) LongTime: "g:i:s A", // in jQuery UI Datepicker: "h:mm:ss tt" SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", // month with year // Y - A full numeric representation of a year, 4 digits // F - A full textual representation of a month YearMonth: "F, Y" // in jQuery UI Datepicker: "MMMM, yyyy" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: '', target: '', checkbox : {disabled:true}, idName : 'id' } }); })(jQuery); ================================================ FILE: mmc-dubbo-doe/src/main/resources/static/v3/assets/js/jqGrid/jquery.jqGrid.src.js ================================================ // ==ClosureCompiler== // @compilation_level SIMPLE_OPTIMIZATIONS /** * @license jqGrid 4.5.2 - jQuery Grid * Copyright (c) 2008, Tony Tomov, tony@trirand.com * Dual licensed under the MIT and GPL licenses * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl-2.0.html * Date: 2013-05-21 */ //jsHint options /*jshint evil:true, eqeqeq:false, eqnull:true, devel:true */ /*global jQuery */ (function ($) { "use strict"; $.jgrid = $.jgrid || {}; $.extend($.jgrid,{ version : "4.5.2", htmlDecode : function(value){ if(value && (value===' ' || value===' ' || (value.length===1 && value.charCodeAt(0)===160))) { return "";} return !value ? value : String(value).replace(/>/g, ">").replace(/</g, "<").replace(/"/g, '"').replace(/&/g, "&"); }, htmlEncode : function (value){ return !value ? value : String(value).replace(/&/g, "&").replace(/\"/g, """).replace(//g, ">"); }, format : function(format){ //jqgformat var args = $.makeArray(arguments).slice(1); if(format==null) { format = ""; } return format.replace(/\{(\d+)\}/g, function(m, i){ return args[i]; }); }, msie : navigator.appName === 'Microsoft Internet Explorer', msiever : function () { var rv = -1; var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (re.exec(ua) != null) { rv = parseFloat( RegExp.$1 ); } return rv; }, getCellIndex : function (cell) { var c = $(cell); if (c.is('tr')) { return -1; } c = (!c.is('td') && !c.is('th') ? c.closest("td,th") : c)[0]; if ($.jgrid.msie) { return $.inArray(c, c.parentNode.cells); } return c.cellIndex; }, stripHtml : function(v) { v = String(v); var regexp = /<("[^"]*"|'[^']*'|[^'">])*>/gi; if (v) { v = v.replace(regexp,""); return (v && v !== ' ' && v !== ' ') ? v.replace(/\"/g,"'") : ""; } return v; }, stripPref : function (pref, id) { var obj = $.type( pref ); if( obj === "string" || obj === "number") { pref = String(pref); id = pref !== "" ? String(id).replace(String(pref), "") : id; } return id; }, parse : function(jsonString) { var js = jsonString; if (js.substr(0,9) === "while(1);") { js = js.substr(9); } if (js.substr(0,2) === "/*") { js = js.substr(2,js.length-4); } if(!js) { js = "{}"; } return ($.jgrid.useJSON===true && typeof JSON === 'object' && typeof JSON.parse === 'function') ? JSON.parse(js) : eval('(' + js + ')'); }, parseDate : function(format, date, newformat, opts) { var token = /\\.|[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g, timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, timezoneClip = /[^-+\dA-Z]/g, msDateRegExp = new RegExp("^\/Date\\((([-+])?[0-9]+)(([-+])([0-9]{2})([0-9]{2}))?\\)\/$"), msMatch = ((typeof date === 'string') ? date.match(msDateRegExp): null), pad = function (value, length) { value = String(value); length = parseInt(length,10) || 2; while (value.length < length) { value = '0' + value; } return value; }, ts = {m : 1, d : 1, y : 1970, h : 0, i : 0, s : 0, u:0}, timestamp=0, dM, k,hl, h12to24 = function(ampm, h){ if (ampm === 0){ if (h === 12) { h = 0;} } else { if (h !== 12) { h += 12; } } return h; }; if(opts === undefined) { opts = $.jgrid.formatter.date; } // old lang files if(opts.parseRe === undefined ) { opts.parseRe = /[Tt\\\/:_;.,\t\s-]/; } if( opts.masks.hasOwnProperty(format) ) { format = opts.masks[format]; } if(date && date != null) { if( !isNaN( date - 0 ) && String(format).toLowerCase() === "u") { //Unix timestamp timestamp = new Date( parseFloat(date)*1000 ); } else if(date.constructor === Date) { timestamp = date; // Microsoft date format support } else if( msMatch !== null ) { timestamp = new Date(parseInt(msMatch[1], 10)); if (msMatch[3]) { var offset = Number(msMatch[5]) * 60 + Number(msMatch[6]); offset *= ((msMatch[4] === '-') ? 1 : -1); offset -= timestamp.getTimezoneOffset(); timestamp.setTime(Number(Number(timestamp) + (offset * 60 * 1000))); } } else { date = String(date).replace(/\\T/g,"T").replace(/\\t/,"t").split(opts.parseRe); format = format.replace(/\\T/g,"T").replace(/\\t/,"t").split(opts.parseRe); // parsing for month names for(k=0,hl=format.length;k 11){date[k] = dM+1-12; ts.m = date[k];} } if(format[k] === 'a') { dM = $.inArray(date[k],opts.AmPm); if(dM !== -1 && dM < 2 && date[k] === opts.AmPm[dM]){ date[k] = dM; ts.h = h12to24(date[k], ts.h); } } if(format[k] === 'A') { dM = $.inArray(date[k],opts.AmPm); if(dM !== -1 && dM > 1 && date[k] === opts.AmPm[dM]){ date[k] = dM-2; ts.h = h12to24(date[k], ts.h); } } if (format[k] === 'g') { ts.h = parseInt(date[k], 10); } if(date[k] !== undefined) { ts[format[k].toLowerCase()] = parseInt(date[k],10); } } if(ts.f) {ts.m = ts.f;} if( ts.m === 0 && ts.y === 0 && ts.d === 0) { return " " ; } ts.m = parseInt(ts.m,10)-1; var ty = ts.y; if (ty >= 70 && ty <= 99) {ts.y = 1900+ts.y;} else if (ty >=0 && ty <=69) {ts.y= 2000+ts.y;} timestamp = new Date(ts.y, ts.m, ts.d, ts.h, ts.i, ts.s, ts.u); } } else { timestamp = new Date(ts.y, ts.m, ts.d, ts.h, ts.i, ts.s, ts.u); } if( newformat === undefined ) { return timestamp; } if( opts.masks.hasOwnProperty(newformat) ) { newformat = opts.masks[newformat]; } else if ( !newformat ) { newformat = 'Y-m-d'; } var G = timestamp.getHours(), i = timestamp.getMinutes(), j = timestamp.getDate(), n = timestamp.getMonth() + 1, o = timestamp.getTimezoneOffset(), s = timestamp.getSeconds(), u = timestamp.getMilliseconds(), w = timestamp.getDay(), Y = timestamp.getFullYear(), N = (w + 6) % 7 + 1, z = (new Date(Y, n - 1, j) - new Date(Y, 0, 1)) / 86400000, flags = { // Day d: pad(j), D: opts.dayNames[w], j: j, l: opts.dayNames[w + 7], N: N, S: opts.S(j), //j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th', w: w, z: z, // Week W: N < 5 ? Math.floor((z + N - 1) / 7) + 1 : Math.floor((z + N - 1) / 7) || ((new Date(Y - 1, 0, 1).getDay() + 6) % 7 < 4 ? 53 : 52), // Month F: opts.monthNames[n - 1 + 12], m: pad(n), M: opts.monthNames[n - 1], n: n, t: '?', // Year L: '?', o: '?', Y: Y, y: String(Y).substring(2), // Time a: G < 12 ? opts.AmPm[0] : opts.AmPm[1], A: G < 12 ? opts.AmPm[2] : opts.AmPm[3], B: '?', g: G % 12 || 12, G: G, h: pad(G % 12 || 12), H: pad(G), i: pad(i), s: pad(s), u: u, // Timezone e: '?', I: '?', O: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), P: '?', T: (String(timestamp).match(timezone) || [""]).pop().replace(timezoneClip, ""), Z: '?', // Full Date/Time c: '?', r: '?', U: Math.floor(timestamp / 1000) }; return newformat.replace(token, function ($0) { return flags.hasOwnProperty($0) ? flags[$0] : $0.substring(1); }); }, jqID : function(sid){ return String(sid).replace(/[!"#$%&'()*+,.\/:; <=>?@\[\\\]\^`{|}~]/g,"\\$&"); }, guid : 1, uidPref: 'jqg', randId : function( prefix ) { return (prefix || $.jgrid.uidPref) + ($.jgrid.guid++); }, getAccessor : function(obj, expr) { var ret,p,prm = [], i; if( typeof expr === 'function') { return expr(obj); } ret = obj[expr]; if(ret===undefined) { try { if ( typeof expr === 'string' ) { prm = expr.split('.'); } i = prm.length; if( i ) { ret = obj; while (ret && i--) { p = prm.shift(); ret = ret[p]; } } } catch (e) {} } return ret; }, getXmlData: function (obj, expr, returnObj) { var ret, m = typeof expr === 'string' ? expr.match(/^(.*)\[(\w+)\]$/) : null; if (typeof expr === 'function') { return expr(obj); } if (m && m[2]) { // m[2] is the attribute selector // m[1] is an optional element selector // examples: "[id]", "rows[page]" return m[1] ? $(m[1], obj).attr(m[2]) : $(obj).attr(m[2]); } ret = $(expr, obj); if (returnObj) { return ret; } //$(expr, obj).filter(':last'); // we use ':last' to be more compatible with old version of jqGrid return ret.length > 0 ? $(ret).text() : undefined; }, cellWidth : function () { var $testDiv = $("
    "), testCell = $testDiv.appendTo("body") .find("td") .width(); $testDiv.remove(); return testCell !== 5; }, cell_width : true, ajaxOptions: {}, from : function(source){ // Original Author Hugo Bonacci // License MIT http://jlinq.codeplex.com/license var QueryObject=function(d,q){ if(typeof d==="string"){ d=$.data(d); } var self=this, _data=d, _usecase=true, _trim=false, _query=q, _stripNum = /[\$,%]/g, _lastCommand=null, _lastField=null, _orDepth=0, _negate=false, _queuedOperator="", _sorting=[], _useProperties=true; if(typeof d==="object"&&d.push) { if(d.length>0){ if(typeof d[0]!=="object"){ _useProperties=false; }else{ _useProperties=true; } } }else{ throw "data provides is not an array"; } this._hasData=function(){ return _data===null?false:_data.length===0?false:true; }; this._getStr=function(s){ var phrase=[]; if(_trim){ phrase.push("jQuery.trim("); } phrase.push("String("+s+")"); if(_trim){ phrase.push(")"); } if(!_usecase){ phrase.push(".toLowerCase()"); } return phrase.join(""); }; this._strComp=function(val){ if(typeof val==="string"){ return".toString()"; } return""; }; this._group=function(f,u){ return({field:f.toString(),unique:u,items:[]}); }; this._toStr=function(phrase){ if(_trim){ phrase=$.trim(phrase); } phrase=phrase.toString().replace(/\\/g,'\\\\').replace(/\"/g,'\\"'); return _usecase ? phrase : phrase.toLowerCase(); }; this._funcLoop=function(func){ var results=[]; $.each(_data,function(i,v){ results.push(func(v)); }); return results; }; this._append=function(s){ var i; if(_query===null){ _query=""; } else { _query+=_queuedOperator === "" ? " && " :_queuedOperator; } for (i=0;i<_orDepth;i++){ _query+="("; } if(_negate){ _query+="!"; } _query+="("+s+")"; _negate=false; _queuedOperator=""; _orDepth=0; }; this._setCommand=function(f,c){ _lastCommand=f; _lastField=c; }; this._resetNegate=function(){ _negate=false; }; this._repeatCommand=function(f,v){ if(_lastCommand===null){ return self; } if(f!==null&&v!==null){ return _lastCommand(f,v); } if(_lastField===null){ return _lastCommand(f); } if(!_useProperties){ return _lastCommand(f); } return _lastCommand(_lastField,f); }; this._equals=function(a,b){ return(self._compare(a,b,1)===0); }; this._compare=function(a,b,d){ var toString = Object.prototype.toString; if( d === undefined) { d = 1; } if(a===undefined) { a = null; } if(b===undefined) { b = null; } if(a===null && b===null){ return 0; } if(a===null&&b!==null){ return 1; } if(a!==null&&b===null){ return -1; } if (toString.call(a) === '[object Date]' && toString.call(b) === '[object Date]') { if (a < b) { return -d; } if (a > b) { return d; } return 0; } if(!_usecase && typeof a !== "number" && typeof b !== "number" ) { a=String(a); b=String(b); } if(ab){return d;} return 0; }; this._performSort=function(){ if(_sorting.length===0){return;} _data=self._doSort(_data,0); }; this._doSort=function(d,q){ var by=_sorting[q].by, dir=_sorting[q].dir, type = _sorting[q].type, dfmt = _sorting[q].datefmt; if(q===_sorting.length-1){ return self._getOrder(d, by, dir, type, dfmt); } q++; var values=self._getGroup(d,by,dir,type,dfmt), results=[], i, j, sorted; for(i=0;i0; }; this.andNot=function(f,v,x){ _negate=!_negate; return self.and(f,v,x); }; this.orNot=function(f,v,x){ _negate=!_negate; return self.or(f,v,x); }; this.not=function(f,v,x){ return self.andNot(f,v,x); }; this.and=function(f,v,x){ _queuedOperator=" && "; if(f===undefined){ return self; } return self._repeatCommand(f,v,x); }; this.or=function(f,v,x){ _queuedOperator=" || "; if(f===undefined) { return self; } return self._repeatCommand(f,v,x); }; this.orBegin=function(){ _orDepth++; return self; }; this.orEnd=function(){ if (_query !== null){ _query+=")"; } return self; }; this.isNot=function(f){ _negate=!_negate; return self.is(f); }; this.is=function(f){ self._append('this.'+f); self._resetNegate(); return self; }; this._compareValues=function(func,f,v,how,t){ var fld; if(_useProperties){ fld='jQuery.jgrid.getAccessor(this,\''+f+'\')'; }else{ fld='this'; } if(v===undefined) { v = null; } //var val=v===null?f:v, var val =v, swst = t.stype === undefined ? "text" : t.stype; if(v !== null) { switch(swst) { case 'int': case 'integer': val = (isNaN(Number(val)) || val==="") ? '0' : val; // To be fixed with more inteligent code fld = 'parseInt('+fld+',10)'; val = 'parseInt('+val+',10)'; break; case 'float': case 'number': case 'numeric': val = String(val).replace(_stripNum, ''); val = (isNaN(Number(val)) || val==="") ? '0' : val; // To be fixed with more inteligent code fld = 'parseFloat('+fld+')'; val = 'parseFloat('+val+')'; break; case 'date': case 'datetime': val = String($.jgrid.parseDate(t.newfmt || 'Y-m-d',val).getTime()); fld = 'jQuery.jgrid.parseDate("'+t.srcfmt+'",'+fld+').getTime()'; break; default : fld=self._getStr(fld); val=self._getStr('"'+self._toStr(val)+'"'); } } self._append(fld+' '+how+' '+val); self._setCommand(func,f); self._resetNegate(); return self; }; this.equals=function(f,v,t){ return self._compareValues(self.equals,f,v,"==",t); }; this.notEquals=function(f,v,t){ return self._compareValues(self.equals,f,v,"!==",t); }; this.isNull = function(f,v,t){ return self._compareValues(self.equals,f,null,"===",t); }; this.greater=function(f,v,t){ return self._compareValues(self.greater,f,v,">",t); }; this.less=function(f,v,t){ return self._compareValues(self.less,f,v,"<",t); }; this.greaterOrEquals=function(f,v,t){ return self._compareValues(self.greaterOrEquals,f,v,">=",t); }; this.lessOrEquals=function(f,v,t){ return self._compareValues(self.lessOrEquals,f,v,"<=",t); }; this.startsWith=function(f,v){ var val = (v==null) ? f: v, length=_trim ? $.trim(val.toString()).length : val.toString().length; if(_useProperties){ self._append(self._getStr('jQuery.jgrid.getAccessor(this,\''+f+'\')')+'.substr(0,'+length+') == '+self._getStr('"'+self._toStr(v)+'"')); }else{ length=_trim?$.trim(v.toString()).length:v.toString().length; self._append(self._getStr('this')+'.substr(0,'+length+') == '+self._getStr('"'+self._toStr(f)+'"')); } self._setCommand(self.startsWith,f); self._resetNegate(); return self; }; this.endsWith=function(f,v){ var val = (v==null) ? f: v, length=_trim ? $.trim(val.toString()).length:val.toString().length; if(_useProperties){ self._append(self._getStr('jQuery.jgrid.getAccessor(this,\''+f+'\')')+'.substr('+self._getStr('jQuery.jgrid.getAccessor(this,\''+f+'\')')+'.length-'+length+','+length+') == "'+self._toStr(v)+'"'); } else { self._append(self._getStr('this')+'.substr('+self._getStr('this')+'.length-"'+self._toStr(f)+'".length,"'+self._toStr(f)+'".length) == "'+self._toStr(f)+'"'); } self._setCommand(self.endsWith,f);self._resetNegate(); return self; }; this.contains=function(f,v){ if(_useProperties){ self._append(self._getStr('jQuery.jgrid.getAccessor(this,\''+f+'\')')+'.indexOf("'+self._toStr(v)+'",0) > -1'); }else{ self._append(self._getStr('this')+'.indexOf("'+self._toStr(f)+'",0) > -1'); } self._setCommand(self.contains,f); self._resetNegate(); return self; }; this.groupBy=function(by,dir,type, datefmt){ if(!self._hasData()){ return null; } return self._getGroup(_data,by,dir,type, datefmt); }; this.orderBy=function(by,dir,stype, dfmt){ dir = dir == null ? "a" :$.trim(dir.toString().toLowerCase()); if(stype == null) { stype = "text"; } if(dfmt == null) { dfmt = "Y-m-d"; } if(dir==="desc"||dir==="descending"){dir="d";} if(dir==="asc"||dir==="ascending"){dir="a";} _sorting.push({by:by,dir:dir,type:stype, datefmt: dfmt}); return self; }; return self; }; return new QueryObject(source,null); }, getMethod: function (name) { return this.getAccessor($.fn.jqGrid, name); }, extend : function(methods) { $.extend($.fn.jqGrid,methods); if (!this.no_legacy_api) { $.fn.extend(methods); } } }); $.fn.jqGrid = function( pin ) { if (typeof pin === 'string') { var fn = $.jgrid.getMethod(pin); if (!fn) { throw ("jqGrid - No such method: " + pin); } var args = $.makeArray(arguments).slice(1); return fn.apply(this,args); } return this.each( function() { if(this.grid) {return;} var p = $.extend(true,{ url: "", height: 150, page: 1, rowNum: 20, rowTotal : null, records: 0, pager: "", pgbuttons: true, pginput: true, colModel: [], rowList: [], colNames: [], sortorder: "asc", sortname: "", datatype: "xml", mtype: "GET", altRows: false, selarrrow: [], savedRow: [], shrinkToFit: true, xmlReader: {}, jsonReader: {}, subGrid: false, subGridModel :[], reccount: 0, lastpage: 0, lastsort: 0, selrow: null, beforeSelectRow: null, onSelectRow: null, onSortCol: null, ondblClickRow: null, onRightClickRow: null, onPaging: null, onSelectAll: null, onInitGrid : null, loadComplete: null, gridComplete: null, loadError: null, loadBeforeSend: null, afterInsertRow: null, beforeRequest: null, beforeProcessing : null, onHeaderClick: null, viewrecords: false, loadonce: false, multiselect: false, multikey: false, editurl: null, search: false, caption: "", hidegrid: true, hiddengrid: false, postData: {}, userData: {}, treeGrid : false, treeGridModel : 'nested', treeReader : {}, treeANode : -1, ExpandColumn: null, tree_root_level : 0, prmNames: {page:"page",rows:"rows", sort: "sidx",order: "sord", search:"_search", nd:"nd", id:"id",oper:"oper",editoper:"edit",addoper:"add",deloper:"del", subgridid:"id", npage: null, totalrows:"totalrows"}, forceFit : false, gridstate : "visible", cellEdit: false, cellsubmit: "remote", nv:0, loadui: "enable", toolbar: [false,""], scroll: false, multiboxonly : false, deselectAfterSort : true, scrollrows : false, autowidth: false, scrollOffset :18, cellLayout: 5, subGridWidth: 20, multiselectWidth: 20, gridview: false, rownumWidth: 25, rownumbers : false, pagerpos: 'center', recordpos: 'right', footerrow : false, userDataOnFooter : false, hoverrows : true, altclass : 'ui-priority-secondary', viewsortcols : [false,'vertical',true], resizeclass : '', autoencode : false, remapColumns : [], ajaxGridOptions :{}, direction : "ltr", toppager: false, headertitles: false, scrollTimeout: 40, data : [], _index : {}, grouping : false, groupingView : {groupField:[],groupOrder:[], groupText:[],groupColumnShow:[],groupSummary:[], showSummaryOnHide: false, sortitems:[], sortnames:[], summary:[],summaryval:[], plusicon: 'ui-icon-circlesmall-plus', minusicon: 'ui-icon-circlesmall-minus', displayField: []}, ignoreCase : false, cmTemplate : {}, idPrefix : "", multiSort : false }, $.jgrid.defaults, pin || {}); var ts= this, grid={ headers:[], cols:[], footers: [], dragStart: function(i,x,y) { this.resizing = { idx: i, startX: x.clientX, sOL : y[0]}; this.hDiv.style.cursor = "col-resize"; this.curGbox = $("#rs_m"+$.jgrid.jqID(p.id),"#gbox_"+$.jgrid.jqID(p.id)); this.curGbox.css({display:"block",left:y[0],top:y[1],height:y[2]}); $(ts).triggerHandler("jqGridResizeStart", [x, i]); if($.isFunction(p.resizeStart)) { p.resizeStart.call(ts,x,i); } document.onselectstart=function(){return false;}; }, dragMove: function(x) { if(this.resizing) { var diff = x.clientX-this.resizing.startX, h = this.headers[this.resizing.idx], newWidth = p.direction === "ltr" ? h.width + diff : h.width - diff, hn, nWn; if(newWidth > 33) { this.curGbox.css({left:this.resizing.sOL+diff}); if(p.forceFit===true ){ hn = this.headers[this.resizing.idx+p.nv]; nWn = p.direction === "ltr" ? hn.width - diff : hn.width + diff; if(nWn >33) { h.newWidth = newWidth; hn.newWidth = nWn; } } else { this.newWidth = p.direction === "ltr" ? p.tblwidth+diff : p.tblwidth-diff; h.newWidth = newWidth; } } } }, dragEnd: function() { this.hDiv.style.cursor = "default"; if(this.resizing) { var idx = this.resizing.idx, nw = this.headers[idx].newWidth || this.headers[idx].width; nw = parseInt(nw,10); this.resizing = false; $("#rs_m"+$.jgrid.jqID(p.id)).css("display","none"); p.colModel[idx].width = nw; this.headers[idx].width = nw; this.headers[idx].el.style.width = nw + "px"; this.cols[idx].style.width = nw+"px"; if(this.footers.length>0) {this.footers[idx].style.width = nw+"px";} if(p.forceFit===true){ nw = this.headers[idx+p.nv].newWidth || this.headers[idx+p.nv].width; this.headers[idx+p.nv].width = nw; this.headers[idx+p.nv].el.style.width = nw + "px"; this.cols[idx+p.nv].style.width = nw+"px"; if(this.footers.length>0) {this.footers[idx+p.nv].style.width = nw+"px";} p.colModel[idx+p.nv].width = nw; } else { p.tblwidth = this.newWidth || p.tblwidth; $('table:first',this.bDiv).css("width",p.tblwidth+"px"); $('table:first',this.hDiv).css("width",p.tblwidth+"px"); this.hDiv.scrollLeft = this.bDiv.scrollLeft; if(p.footerrow) { $('table:first',this.sDiv).css("width",p.tblwidth+"px"); this.sDiv.scrollLeft = this.bDiv.scrollLeft; } } $(ts).triggerHandler("jqGridResizeStop", [nw, idx]); if($.isFunction(p.resizeStop)) { p.resizeStop.call(ts,nw,idx); } } this.curGbox = null; document.onselectstart=function(){return true;}; }, populateVisible: function() { if (grid.timer) { clearTimeout(grid.timer); } grid.timer = null; var dh = $(grid.bDiv).height(); if (!dh) { return; } var table = $("table:first", grid.bDiv); var rows, rh; if(table[0].rows.length) { try { rows = table[0].rows[1]; rh = rows ? $(rows).outerHeight() || grid.prevRowHeight : grid.prevRowHeight; } catch (pv) { rh = grid.prevRowHeight; } } if (!rh) { return; } grid.prevRowHeight = rh; var rn = p.rowNum; var scrollTop = grid.scrollTop = grid.bDiv.scrollTop; var ttop = Math.round(table.position().top) - scrollTop; var tbot = ttop + table.height(); var div = rh * rn; var page, npage, empty; if ( tbot < dh && ttop <= 0 && (p.lastpage===undefined||parseInt((tbot + scrollTop + div - 1) / div,10) <= p.lastpage)) { npage = parseInt((dh - tbot + div - 1) / div,10); if (tbot >= 0 || npage < 2 || p.scroll === true) { page = Math.round((tbot + scrollTop) / div) + 1; ttop = -1; } else { ttop = 1; } } if (ttop > 0) { page = parseInt(scrollTop / div,10) + 1; npage = parseInt((scrollTop + dh) / div,10) + 2 - page; empty = true; } if (npage) { if (p.lastpage && (page > p.lastpage || p.lastpage===1 || (page === p.page && page===p.lastpage)) ) { return; } if (grid.hDiv.loading) { grid.timer = setTimeout(grid.populateVisible, p.scrollTimeout); } else { p.page = page; if (empty) { grid.selectionPreserver(table[0]); grid.emptyRows.call(table[0], false, false); } grid.populate(npage); } } }, scrollGrid: function( e ) { if(p.scroll) { var scrollTop = grid.bDiv.scrollTop; if(grid.scrollTop === undefined) { grid.scrollTop = 0; } if (scrollTop !== grid.scrollTop) { grid.scrollTop = scrollTop; if (grid.timer) { clearTimeout(grid.timer); } grid.timer = setTimeout(grid.populateVisible, p.scrollTimeout); } } grid.hDiv.scrollLeft = grid.bDiv.scrollLeft; if(p.footerrow) { grid.sDiv.scrollLeft = grid.bDiv.scrollLeft; } if( e ) { e.stopPropagation(); } }, selectionPreserver : function(ts) { var p = ts.p, sr = p.selrow, sra = p.selarrrow ? $.makeArray(p.selarrrow) : null, left = ts.grid.bDiv.scrollLeft, restoreSelection = function() { var i; p.selrow = null; p.selarrrow = []; if(p.multiselect && sra && sra.length>0) { for(i=0;i"), isMSIE = $.jgrid.msie; ts.p.direction = $.trim(ts.p.direction.toLowerCase()); if($.inArray(ts.p.direction,["ltr","rtl"]) === -1) { ts.p.direction = "ltr"; } dir = ts.p.direction; $(gv).insertBefore(this); $(this).removeClass("scroll").appendTo(gv); var eg = $("
    "); $(eg).attr({"id" : "gbox_"+this.id,"dir":dir}).insertBefore(gv); $(gv).attr("id","gview_"+this.id).appendTo(eg); $("
    ").insertBefore(gv); $("
    "+this.p.loadtext+"
    ").insertBefore(gv); $(this).attr({cellspacing:"0",cellpadding:"0",border:"0","role":"grid","aria-multiselectable":!!this.p.multiselect,"aria-labelledby":"gbox_"+this.id}); var sortkeys = ["shiftKey","altKey","ctrlKey"], intNum = function(val,defval) { val = parseInt(val,10); if (isNaN(val)) { return defval || 0;} return val; }, formatCol = function (pos, rowInd, tv, rawObject, rowId, rdata){ var cm = ts.p.colModel[pos], ral = cm.align, result="style=\"", clas = cm.classes, nm = cm.name, celp, acp=[]; if(ral) { result += "text-align:"+ral+";"; } if(cm.hidden===true) { result += "display:none;"; } if(rowInd===0) { result += "width: "+grid.headers[pos].width+"px;"; } else if (cm.cellattr && $.isFunction(cm.cellattr)) { celp = cm.cellattr.call(ts, rowId, tv, rawObject, cm, rdata); if(celp && typeof celp === "string") { celp = celp.replace(/style/i,'style').replace(/title/i,'title'); if(celp.indexOf('title') > -1) { cm.title=false;} if(celp.indexOf('class') > -1) { clas = undefined;} acp = celp.split(/[^-]style/); if(acp.length === 2 ) { acp[1] = $.trim(acp[1].replace("=","")); if(acp[1].indexOf("'") === 0 || acp[1].indexOf('"') === 0) { acp[1] = acp[1].substring(1); } result += acp[1].replace(/'/gi,'"'); } else { result += "\""; } } } if(!acp.length) { acp[0] = ""; result += "\"";} result += (clas !== undefined ? (" class=\""+clas+"\"") :"") + ((cm.title && tv) ? (" title=\""+$.jgrid.stripHtml(tv)+"\"") :""); result += " aria-describedby=\""+ts.p.id+"_"+nm+"\""; return result + acp[0]; }, cellVal = function (val) { return val == null || val === "" ? " " : (ts.p.autoencode ? $.jgrid.htmlEncode(val) : String(val)); }, formatter = function (rowId, cellval , colpos, rwdat, _act){ var cm = ts.p.colModel[colpos],v; if(cm.formatter !== undefined) { rowId = String(ts.p.idPrefix) !== "" ? $.jgrid.stripPref(ts.p.idPrefix, rowId) : rowId; var opts= {rowId: rowId, colModel:cm, gid:ts.p.id, pos:colpos }; if($.isFunction( cm.formatter ) ) { v = cm.formatter.call(ts,cellval,opts,rwdat,_act); } else if($.fmatter){ v = $.fn.fmatter.call(ts,cm.formatter,cellval,opts,rwdat,_act); } else { v = cellVal(cellval); } } else { v = cellVal(cellval); } return v; }, addCell = function(rowId,cell,pos,irow, srvr, rdata) { var v,prp; v = formatter(rowId,cell,pos,srvr,'add'); prp = formatCol( pos,irow, v, srvr, rowId, rdata); return ""+v+""; }, addMulti = function(rowid,pos,irow,checked){ var v = "", prp = formatCol( pos,irow,'',null, rowid, true); return ""+v+""; }, addRowNum = function (pos,irow,pG,rN) { var v = (parseInt(pG,10)-1)*parseInt(rN,10)+1+irow, prp = formatCol( pos,irow,v, null, irow, true); return ""+v+""; }, reader = function (datatype) { var field, f=[], j=0, i; for(i =0; i 0 ? this.rows[0] : null; $(this.firstChild).empty().append(firstrow); } if (scroll && this.p.scroll) { $(this.grid.bDiv.firstChild).css({height: "auto"}); $(this.grid.bDiv.firstChild.firstChild).css({height: 0, display: "none"}); if (this.grid.bDiv.scrollTop !== 0) { this.grid.bDiv.scrollTop = 0; } } if(locdata === true && this.p.treeGrid) { this.p.data = []; this.p._index = {}; } }, refreshIndex = function() { var datalen = ts.p.data.length, idname, i, val, ni = ts.p.rownumbers===true ? 1 :0, gi = ts.p.multiselect ===true ? 1 :0, si = ts.p.subGrid===true ? 1 :0; if(ts.p.keyIndex === false || ts.p.loadonce === true) { idname = ts.p.localReader.id; } else { idname = ts.p.colModel[ts.p.keyIndex+gi+si+ni].name; } for(i =0;i < datalen; i++) { val = $.jgrid.getAccessor(ts.p.data[i],idname); if (val === undefined) { val=String(i+1); } ts.p._index[val] = i; } }, constructTr = function(id, hide, altClass, rd, cur, selected) { var tabindex = '-1', restAttr = '', attrName, style = hide ? 'display:none;' : '', classes = 'ui-widget-content jqgrow ui-row-' + ts.p.direction + (altClass ? ' ' + altClass : '') + (selected ? ' ui-state-highlight' : ''), rowAttrObj = $(ts).triggerHandler("jqGridRowAttr", [rd, cur, id]); if( typeof rowAttrObj !== "object" ) { rowAttrObj = $.isFunction(ts.p.rowattr) ? ts.p.rowattr.call(ts, rd, cur, id) :{}; } if(!$.isEmptyObject( rowAttrObj )) { if (rowAttrObj.hasOwnProperty("id")) { id = rowAttrObj.id; delete rowAttrObj.id; } if (rowAttrObj.hasOwnProperty("tabindex")) { tabindex = rowAttrObj.tabindex; delete rowAttrObj.tabindex; } if (rowAttrObj.hasOwnProperty("style")) { style += rowAttrObj.style; delete rowAttrObj.style; } if (rowAttrObj.hasOwnProperty("class")) { classes += ' ' + rowAttrObj['class']; delete rowAttrObj['class']; } // dot't allow to change role attribute try { delete rowAttrObj.role; } catch(ra){} for (attrName in rowAttrObj) { if (rowAttrObj.hasOwnProperty(attrName)) { restAttr += ' ' + attrName + '=' + rowAttrObj[attrName]; } } } return ''; }, addXmlData = function (xml,t, rcnt, more, adjust) { var startReq = new Date(), locdata = (ts.p.datatype !== "local" && ts.p.loadonce) || ts.p.datatype === "xmlstring", xmlid = "_id_", xmlRd = ts.p.xmlReader, frd = ts.p.datatype === "local" ? "local" : "xml"; if(locdata) { ts.p.data = []; ts.p._index = {}; ts.p.localReader.id = xmlid; } ts.p.reccount = 0; if($.isXMLDoc(xml)) { if(ts.p.treeANode===-1 && !ts.p.scroll) { emptyRows.call(ts, false, true); rcnt=1; } else { rcnt = rcnt > 1 ? rcnt :1; } } else { return; } var self= $(ts), i,fpos,ir=0,v,gi=ts.p.multiselect===true?1:0,si=0,addSubGridCell,ni=ts.p.rownumbers===true?1:0,idn, getId,f=[],F,rd ={}, xmlr,rid, rowData=[], cn=(ts.p.altRows === true) ? ts.p.altclass:"",cn1; if(ts.p.subGrid===true) { si = 1; addSubGridCell = $.jgrid.getMethod("addSubGridCell"); } if(!xmlRd.repeatitems) {f = reader(frd);} if( ts.p.keyIndex===false) { idn = $.isFunction( xmlRd.id ) ? xmlRd.id.call(ts, xml) : xmlRd.id; } else { idn = ts.p.keyIndex; } if(f.length>0 && !isNaN(idn)) { if (ts.p.remapColumns && ts.p.remapColumns.length) { idn = $.inArray(idn, ts.p.remapColumns); } idn=f[idn]; } if( String(idn).indexOf("[") === -1 ) { if (f.length) { getId = function( trow, k) {return $(idn,trow).text() || k;}; } else { getId = function( trow, k) {return $(xmlRd.cell,trow).eq(idn).text() || k;}; } } else { getId = function( trow, k) {return trow.getAttribute(idn.replace(/[\[\]]/g,"")) || k;}; } ts.p.userData = {}; ts.p.page = $.jgrid.getXmlData( xml,xmlRd.page ) || ts.p.page || 0; ts.p.lastpage = $.jgrid.getXmlData( xml,xmlRd.total ); if(ts.p.lastpage===undefined) { ts.p.lastpage=1; } ts.p.records = $.jgrid.getXmlData( xml,xmlRd.records ) || 0; if($.isFunction(xmlRd.userdata)) { ts.p.userData = xmlRd.userdata.call(ts, xml) || {}; } else { $.jgrid.getXmlData(xml, xmlRd.userdata, true).each(function() {ts.p.userData[this.getAttribute("name")]= $(this).text();}); } var gxml = $.jgrid.getXmlData( xml, xmlRd.root, true); gxml = $.jgrid.getXmlData( gxml, xmlRd.row, true); if (!gxml) { gxml = []; } var gl = gxml.length, j=0, grpdata=[], rn = parseInt(ts.p.rowNum,10), br=ts.p.scroll?$.jgrid.randId():1, altr; if (gl > 0 && ts.p.page <= 0) { ts.p.page = 1; } if(gxml && gl){ if (adjust) { rn *= adjust+1; } var afterInsRow = $.isFunction(ts.p.afterInsertRow), hiderow=false, groupingPrepare; if(ts.p.grouping) { hiderow = ts.p.groupingView.groupCollapse === true; groupingPrepare = $.jgrid.getMethod("groupingPrepare"); } while (j"); if(ts.p.grouping) { grpdata = groupingPrepare.call(self,rowData, grpdata, rd, j); rowData = []; } if(locdata || ts.p.treeGrid === true) { rd[xmlid] = $.jgrid.stripPref(ts.p.idPrefix, rid); ts.p.data.push(rd); ts.p._index[rd[xmlid]] = ts.p.data.length-1; } if(ts.p.gridview === false ) { $("tbody:first",t).append(rowData.join('')); self.triggerHandler("jqGridAfterInsertRow", [rid, rd, xmlr]); if(afterInsRow) {ts.p.afterInsertRow.call(ts,rid,rd,xmlr);} rowData=[]; } rd={}; ir++; j++; if(ir===rn) {break;} } } if(ts.p.gridview === true) { fpos = ts.p.treeANode > -1 ? ts.p.treeANode: 0; if(ts.p.grouping) { self.jqGrid('groupingRender',grpdata,ts.p.colModel.length); grpdata = null; } else if(ts.p.treeGrid === true && fpos > 0) { $(ts.rows[fpos]).after(rowData.join('')); } else { $("tbody:first",t).append(rowData.join('')); } } if(ts.p.subGrid === true ) { try {self.jqGrid("addSubGrid",gi+ni);} catch (_){} } ts.p.totaltime = new Date() - startReq; if(ir>0) { if(ts.p.records===0) { ts.p.records=gl;} } rowData =null; if( ts.p.treeGrid === true) { try {self.jqGrid("setTreeNode", fpos+1, ir+fpos+1);} catch (e) {} } if(!ts.p.treeGrid && !ts.p.scroll) {ts.grid.bDiv.scrollTop = 0;} ts.p.reccount=ir; ts.p.treeANode = -1; if(ts.p.userDataOnFooter) { self.jqGrid("footerData","set",ts.p.userData,true); } if(locdata) { ts.p.records = gl; ts.p.lastpage = Math.ceil(gl/ rn); } if (!more) { ts.updatepager(false,true); } if(locdata) { while (ir 1 ? rcnt :1; } } else { return; } var dReader, locid = "_id_", frd, locdata = (ts.p.datatype !== "local" && ts.p.loadonce) || ts.p.datatype === "jsonstring"; if(locdata) { ts.p.data = []; ts.p._index = {}; ts.p.localReader.id = locid;} ts.p.reccount = 0; if(ts.p.datatype === "local") { dReader = ts.p.localReader; frd= 'local'; } else { dReader = ts.p.jsonReader; frd='json'; } var self = $(ts), ir=0,v,i,j,f=[],cur,gi=ts.p.multiselect?1:0,si=ts.p.subGrid===true?1:0,addSubGridCell,ni=ts.p.rownumbers===true?1:0,arrayReader=orderedCols(gi+si+ni),objectReader=reader(frd),rowReader,len,drows,idn,rd={}, fpos, idr,rowData=[],cn=(ts.p.altRows === true) ? ts.p.altclass:"",cn1,lp; ts.p.page = $.jgrid.getAccessor(data,dReader.page) || ts.p.page || 0; lp = $.jgrid.getAccessor(data,dReader.total); if(si) { addSubGridCell = $.jgrid.getMethod("addSubGridCell"); } ts.p.lastpage = lp === undefined ? 1 : lp; ts.p.records = $.jgrid.getAccessor(data,dReader.records) || 0; ts.p.userData = $.jgrid.getAccessor(data,dReader.userdata) || {}; if( ts.p.keyIndex===false ) { idn = $.isFunction(dReader.id) ? dReader.id.call(ts, data) : dReader.id; } else { idn = ts.p.keyIndex; } if(!dReader.repeatitems) { f = objectReader; if(f.length>0 && !isNaN(idn)) { if (ts.p.remapColumns && ts.p.remapColumns.length) { idn = $.inArray(idn, ts.p.remapColumns); } idn=f[idn]; } } drows = $.jgrid.getAccessor(data,dReader.root); if (drows == null && $.isArray(data)) { drows = data; } if (!drows) { drows = []; } len = drows.length; i=0; if (len > 0 && ts.p.page <= 0) { ts.p.page = 1; } var rn = parseInt(ts.p.rowNum,10),br=ts.p.scroll?$.jgrid.randId():1, altr, selected=false, selr; if (adjust) { rn *= adjust+1; } if(ts.p.datatype === "local" && !ts.p.deselectAfterSort) { selected = true; } var afterInsRow = $.isFunction(ts.p.afterInsertRow), grpdata=[],hiderow=false, groupingPrepare; if(ts.p.grouping) { hiderow = ts.p.groupingView.groupCollapse === true; groupingPrepare = $.jgrid.getMethod("groupingPrepare"); } while (i" ); if(ts.p.grouping) { grpdata = groupingPrepare.call(self,rowData, grpdata, rd, i); rowData = []; } if(locdata || ts.p.treeGrid===true) { rd[locid] = $.jgrid.stripPref(ts.p.idPrefix, idr); ts.p.data.push(rd); ts.p._index[rd[locid]] = ts.p.data.length-1; } if(ts.p.gridview === false ) { $("#"+$.jgrid.jqID(ts.p.id)+" tbody:first").append(rowData.join('')); self.triggerHandler("jqGridAfterInsertRow", [idr, rd, cur]); if(afterInsRow) {ts.p.afterInsertRow.call(ts,idr,rd,cur);} rowData=[];//ari=0; } rd={}; ir++; i++; if(ir===rn) { break; } } if(ts.p.gridview === true ) { fpos = ts.p.treeANode > -1 ? ts.p.treeANode: 0; if(ts.p.grouping) { self.jqGrid('groupingRender',grpdata,ts.p.colModel.length); grpdata = null; } else if(ts.p.treeGrid === true && fpos > 0) { $(ts.rows[fpos]).after(rowData.join('')); } else { $("#"+$.jgrid.jqID(ts.p.id)+" tbody:first").append(rowData.join('')); } } if(ts.p.subGrid === true ) { try { self.jqGrid("addSubGrid",gi+ni);} catch (_){} } ts.p.totaltime = new Date() - startReq; if(ir>0) { if(ts.p.records===0) { ts.p.records=len; } } rowData = null; if( ts.p.treeGrid === true) { try {self.jqGrid("setTreeNode", fpos+1, ir+fpos+1);} catch (e) {} } if(!ts.p.treeGrid && !ts.p.scroll) {ts.grid.bDiv.scrollTop = 0;} ts.p.reccount=ir; ts.p.treeANode = -1; if(ts.p.userDataOnFooter) { self.jqGrid("footerData","set",ts.p.userData,true); } if(locdata) { ts.p.records = len; ts.p.lastpage = Math.ceil(len/ rn); } if (!more) { ts.updatepager(false,true); } if(locdata) { while (ir 0 && gor) { query.or(); } try { tojLinq(group.groups[index]); } catch (e) {alert(e);} s++; } if (gor) { query.orEnd(); } } if (group.rules != null) { //if(s>0) { // var result = query.select(); // query = $.jgrid.from( result); // if (ts.p.ignoreCase) { query = query.ignoreCase(); } //} try{ ror = group.rules.length && group.groupOp.toString().toUpperCase() === "OR"; if (ror) { query.orBegin(); } for (index = 0; index < group.rules.length; index++) { rule = group.rules[index]; opr = group.groupOp.toString().toUpperCase(); if (compareFnMap[rule.op] && rule.field ) { if(s > 0 && opr && opr === "OR") { query = query.or(); } query = compareFnMap[rule.op](query, opr)(rule.field, rule.data, cmtypes[rule.field]); } s++; } if (ror) { query.orEnd(); } } catch (g) {alert(g);} } } if (ts.p.search === true) { var srules = ts.p.postData.filters; if(srules) { if(typeof srules === "string") { srules = $.jgrid.parse(srules);} tojLinq( srules ); } else { try { query = compareFnMap[ts.p.postData.searchOper](query)(ts.p.postData.searchField, ts.p.postData.searchString,cmtypes[ts.p.postData.searchField]); } catch (se){} } } if(ts.p.grouping) { for(gin=0; gin tr:gt(0)", ts.grid.bDiv); base = to - rows.length; ts.p.reccount = rows.length; var rh = rows.outerHeight() || ts.grid.prevRowHeight; if (rh) { var top = base * rh; var height = parseInt(ts.p.records,10) * rh; $(">div:first",ts.grid.bDiv).css({height : height}).children("div:first").css({height:top,display:top?"":"none"}); if (ts.grid.bDiv.scrollTop == 0 && ts.p.page > 1) { ts.grid.bDiv.scrollTop = ts.p.rowNum * (ts.p.page - 1) * rh; } } ts.grid.bDiv.scrollLeft = ts.grid.hDiv.scrollLeft; } pgboxes = ts.p.pager || ""; pgboxes += ts.p.toppager ? (pgboxes ? "," + ts.p.toppager : ts.p.toppager) : ""; if(pgboxes) { fmt = $.jgrid.formatter.integer || {}; cp = intNum(ts.p.page); last = intNum(ts.p.lastpage); $(".selbox",pgboxes)[ this.p.useProp ? 'prop' : 'attr' ]("disabled",false); if(ts.p.pginput===true) { $('.ui-pg-input',pgboxes).val(ts.p.page); sppg = ts.p.toppager ? '#sp_1'+tspg+",#sp_1"+tspg_t : '#sp_1'+tspg; $(sppg).html($.fmatter ? $.fmatter.util.NumberFormat(ts.p.lastpage,fmt):ts.p.lastpage); } if (ts.p.viewrecords){ if(ts.p.reccount === 0) { $(".ui-paging-info",pgboxes).html(ts.p.emptyrecords); } else { from = base+1; tot=ts.p.records; if($.fmatter) { from = $.fmatter.util.NumberFormat(from,fmt); to = $.fmatter.util.NumberFormat(to,fmt); tot = $.fmatter.util.NumberFormat(tot,fmt); } $(".ui-paging-info",pgboxes).html($.jgrid.format(ts.p.recordtext,from,to,tot)); } } if(ts.p.pgbuttons===true) { if(cp<=0) {cp = last = 0;} if(cp===1 || cp === 0) { $("#first"+tspg+", #prev"+tspg).addClass('ui-state-disabled').removeClass('ui-state-hover'); if(ts.p.toppager) { $("#first_t"+tspg_t+", #prev_t"+tspg_t).addClass('ui-state-disabled').removeClass('ui-state-hover'); } } else { $("#first"+tspg+", #prev"+tspg).removeClass('ui-state-disabled'); if(ts.p.toppager) { $("#first_t"+tspg_t+", #prev_t"+tspg_t).removeClass('ui-state-disabled'); } } if(cp===last || cp === 0) { $("#next"+tspg+", #last"+tspg).addClass('ui-state-disabled').removeClass('ui-state-hover'); if(ts.p.toppager) { $("#next_t"+tspg_t+", #last_t"+tspg_t).addClass('ui-state-disabled').removeClass('ui-state-hover'); } } else { $("#next"+tspg+", #last"+tspg).removeClass('ui-state-disabled'); if(ts.p.toppager) { $("#next_t"+tspg_t+", #last_t"+tspg_t).removeClass('ui-state-disabled'); } } } } if(rn===true && ts.p.rownumbers === true) { $(">td.jqgrid-rownum",ts.rows).each(function(i){ $(this).html(base+1+i); }); } if(dnd && ts.p.jqgdnd) { $(ts).jqGrid('gridDnD','updateDnD');} $(ts).triggerHandler("jqGridGridComplete"); if($.isFunction(ts.p.gridComplete)) {ts.p.gridComplete.call(ts);} $(ts).triggerHandler("jqGridAfterGridComplete"); }, beginReq = function() { ts.grid.hDiv.loading = true; if(ts.p.hiddengrid) { return;} switch(ts.p.loadui) { case "disable": break; case "enable": $("#load_"+$.jgrid.jqID(ts.p.id)).show(); break; case "block": $("#lui_"+$.jgrid.jqID(ts.p.id)).show(); $("#load_"+$.jgrid.jqID(ts.p.id)).show(); break; } }, endReq = function() { ts.grid.hDiv.loading = false; switch(ts.p.loadui) { case "disable": break; case "enable": $("#load_"+$.jgrid.jqID(ts.p.id)).hide(); break; case "block": $("#lui_"+$.jgrid.jqID(ts.p.id)).hide(); $("#load_"+$.jgrid.jqID(ts.p.id)).hide(); break; } }, populate = function (npage) { if(!ts.grid.hDiv.loading) { var pvis = ts.p.scroll && npage === false, prm = {}, dt, dstr, pN=ts.p.prmNames; if(ts.p.page <=0) { ts.p.page = 1; } if(pN.search !== null) {prm[pN.search] = ts.p.search;} if(pN.nd !== null) {prm[pN.nd] = new Date().getTime();} if(pN.rows !== null) {prm[pN.rows]= ts.p.rowNum;} if(pN.page !== null) {prm[pN.page]= ts.p.page;} if(pN.sort !== null) {prm[pN.sort]= ts.p.sortname;} if(pN.order !== null) {prm[pN.order]= ts.p.sortorder;} if(ts.p.rowTotal !== null && pN.totalrows !== null) { prm[pN.totalrows]= ts.p.rowTotal; } var lcf = $.isFunction(ts.p.loadComplete), lc = lcf ? ts.p.loadComplete : null; var adjust = 0; npage = npage || 1; if (npage > 1) { if(pN.npage !== null) { prm[pN.npage] = npage; adjust = npage - 1; npage = 1; } else { lc = function(req) { ts.p.page++; ts.grid.hDiv.loading = false; if (lcf) { ts.p.loadComplete.call(ts,req); } populate(npage-1); }; } } else if (pN.npage !== null) { delete ts.p.postData[pN.npage]; } if(ts.p.grouping) { $(ts).jqGrid('groupingSetup'); var grp = ts.p.groupingView, gi, gs=""; for(gi=0;gi1,adjust); } else { addJSONData(data,ts.grid.bDiv,rcnt,npage>1,adjust); } $(ts).triggerHandler("jqGridLoadComplete", [data]); if(lc) { lc.call(ts,data); } $(ts).triggerHandler("jqGridAfterLoadComplete", [data]); if (pvis) { ts.grid.populateVisible(); } if( ts.p.loadonce || ts.p.treeGrid) {ts.p.datatype = "local";} data=null; if (npage === 1) { endReq(); } }, error:function(xhr,st,err){ if($.isFunction(ts.p.loadError)) { ts.p.loadError.call(ts,xhr,st,err); } if (npage === 1) { endReq(); } xhr=null; }, beforeSend: function(xhr, settings ){ var gotoreq = true; if($.isFunction(ts.p.loadBeforeSend)) { gotoreq = ts.p.loadBeforeSend.call(ts,xhr, settings); } if(gotoreq === undefined) { gotoreq = true; } if(gotoreq === false) { return false; } beginReq(); } },$.jgrid.ajaxOptions, ts.p.ajaxGridOptions)); break; case "xmlstring": beginReq(); dstr = typeof ts.p.datastr !== 'string' ? ts.p.datastr : $.parseXML(ts.p.datastr); addXmlData(dstr,ts.grid.bDiv); $(ts).triggerHandler("jqGridLoadComplete", [dstr]); if(lcf) {ts.p.loadComplete.call(ts,dstr);} $(ts).triggerHandler("jqGridAfterLoadComplete", [dstr]); ts.p.datatype = "local"; ts.p.datastr = null; endReq(); break; case "jsonstring": beginReq(); if(typeof ts.p.datastr === 'string') { dstr = $.jgrid.parse(ts.p.datastr); } else { dstr = ts.p.datastr; } addJSONData(dstr,ts.grid.bDiv); $(ts).triggerHandler("jqGridLoadComplete", [dstr]); if(lcf) {ts.p.loadComplete.call(ts,dstr);} $(ts).triggerHandler("jqGridAfterLoadComplete", [dstr]); ts.p.datatype = "local"; ts.p.datastr = null; endReq(); break; case "local": case "clientside": beginReq(); ts.p.datatype = "local"; var req = addLocalData(); addJSONData(req,ts.grid.bDiv,rcnt,npage>1,adjust); $(ts).triggerHandler("jqGridLoadComplete", [req]); if(lc) { lc.call(ts,req); } $(ts).triggerHandler("jqGridAfterLoadComplete", [req]); if (pvis) { ts.grid.populateVisible(); } endReq(); break; } } }, setHeadCheckBox = function ( checked ) { $('#cb_'+$.jgrid.jqID(ts.p.id),ts.grid.hDiv)[ts.p.useProp ? 'prop': 'attr']("checked", checked); var fid = ts.p.frozenColumns ? ts.p.id+"_frozen" : ""; if(fid) { $('#cb_'+$.jgrid.jqID(ts.p.id),ts.grid.fhDiv)[ts.p.useProp ? 'prop': 'attr']("checked", checked); } }, setPager = function (pgid, tp){ // TBD - consider escaping pgid with pgid = $.jgrid.jqID(pgid); var sep = "", pginp = "", pgl="", str="", pgcnt, lft, cent, rgt, twd, tdw, i, clearVals = function(onpaging){ var ret; if ($.isFunction(ts.p.onPaging) ) { ret = ts.p.onPaging.call(ts,onpaging); } ts.p.selrow = null; if(ts.p.multiselect) {ts.p.selarrrow =[]; setHeadCheckBox( false );} ts.p.savedRow = []; if(ret==='stop') {return false;} return true; }; pgid = pgid.substr(1); tp += "_" + pgid; pgcnt = "pg_"+pgid; lft = pgid+"_left"; cent = pgid+"_center"; rgt = pgid+"_right"; $("#"+$.jgrid.jqID(pgid) ) .append("
    ") .attr("dir","ltr"); //explicit setting if(ts.p.rowList.length >0){ str = ""; str +=""; } if(dir==="rtl") { pgl += str; } if(ts.p.pginput===true) { pginp= ""+$.jgrid.format(ts.p.pgtext || "","","")+"";} if(ts.p.pgbuttons===true) { var po=["first"+tp,"prev"+tp, "next"+tp,"last"+tp]; if(dir==="rtl") { po.reverse(); } pgl += ""; pgl += ""; pgl += pginp !== "" ? sep+pginp+sep:""; pgl += ""; pgl += ""; } else if (pginp !== "") { pgl += pginp; } if(dir==="ltr") { pgl += str; } pgl += ""; if(ts.p.viewrecords===true) {$("td#"+pgid+"_"+ts.p.recordpos,"#"+pgcnt).append("
    ");} $("td#"+pgid+"_"+ts.p.pagerpos,"#"+pgcnt).append(pgl); tdw = $(".ui-jqgrid").css("font-size") || "11px"; $(document.body).append(""); twd = $(pgl).clone().appendTo("#testpg").width(); $("#testpg").remove(); if(twd > 0) { if(pginp !== "") { twd += 50; } //should be param $("td#"+pgid+"_"+ts.p.pagerpos,"#"+pgcnt).width(twd); } ts.p._nvtd = []; ts.p._nvtd[0] = twd ? Math.floor((ts.p.width - twd)/2) : Math.floor(ts.p.width/3); ts.p._nvtd[1] = 0; pgl=null; $('.ui-pg-selbox',"#"+pgcnt).bind('change',function() { if(!clearVals('records')) { return false; } ts.p.page = Math.round(ts.p.rowNum*(ts.p.page-1)/this.value-0.5)+1; ts.p.rowNum = this.value; if(ts.p.pager) { $('.ui-pg-selbox',ts.p.pager).val(this.value); } if(ts.p.toppager) { $('.ui-pg-selbox',ts.p.toppager).val(this.value); } populate(); return false; }); if(ts.p.pgbuttons===true) { $(".ui-pg-button","#"+pgcnt).hover(function(){ if($(this).hasClass('ui-state-disabled')) { this.style.cursor='default'; } else { $(this).addClass('ui-state-hover'); this.style.cursor='pointer'; } },function() { if(!$(this).hasClass('ui-state-disabled')) { $(this).removeClass('ui-state-hover'); this.style.cursor= "default"; } }); $("#first"+$.jgrid.jqID(tp)+", #prev"+$.jgrid.jqID(tp)+", #next"+$.jgrid.jqID(tp)+", #last"+$.jgrid.jqID(tp)).click( function() { var cp = intNum(ts.p.page,1), last = intNum(ts.p.lastpage,1), selclick = false, fp=true, pp=true, np=true,lp=true; if(last ===0 || last===1) {fp=false;pp=false;np=false;lp=false; } else if( last>1 && cp >=1) { if( cp === 1) { fp=false; pp=false; } //else if( cp>1 && cp 1 && cp===0 ) { np=false;lp=false; cp=last-1;} if(!clearVals(this.id)) { return false; } if( this.id === 'first'+tp && fp ) { ts.p.page=1; selclick=true;} if( this.id === 'prev'+tp && pp) { ts.p.page=(cp-1); selclick=true;} if( this.id === 'next'+tp && np) { ts.p.page=(cp+1); selclick=true;} if( this.id === 'last'+tp && lp) { ts.p.page=last; selclick=true;} if(selclick) { populate(); } return false; }); } if(ts.p.pginput===true) { $('input.ui-pg-input',"#"+pgcnt).keypress( function(e) { var key = e.charCode || e.keyCode || 0; if(key === 13) { if(!clearVals('user')) { return false; } $(this).val( intNum( $(this).val(), 1)); ts.p.page = ($(this).val()>0) ? $(this).val():ts.p.page; populate(); return false; } return this; }); } }, multiSort = function(iCol, obj ) { var splas, sort="", cm = ts.p.colModel, fs=false, ls, selTh = ts.p.frozenColumns ? obj : ts.grid.headers[iCol].el, so=""; $("span.ui-grid-ico-sort",selTh).addClass('ui-state-disabled'); $(selTh).attr("aria-selected","false"); if(cm[iCol].lso) { if(cm[iCol].lso==="asc") { cm[iCol].lso += "-desc"; so = "desc"; } else if(cm[iCol].lso==="desc") { cm[iCol].lso += "-asc"; so = "asc"; } else if(cm[iCol].lso==="asc-desc" || cm[iCol].lso==="desc-asc") { cm[iCol].lso=""; } } else { cm[iCol].lso = so = cm.firstsortorder || 'asc'; } if( so ) { $("span.s-ico",selTh).show(); $("span.ui-icon-"+so,selTh).removeClass('ui-state-disabled'); $(selTh).attr("aria-selected","true"); } else { if(!ts.p.viewsortcols[0]) { $("span.s-ico",selTh).hide(); } } ts.p.sortorder = ""; $.each(cm, function(i){ if(this.lso) { if(i>0 && fs) { sort += ", "; } splas = this.lso.split("-"); sort += cm[i].index || cm[i].name; sort += " "+splas[splas.length-1]; fs = true; ts.p.sortorder = splas[splas.length-1]; } }); ls = sort.lastIndexOf(ts.p.sortorder); sort = sort.substring(0, ls); ts.p.sortname = sort; }, sortData = function (index, idxcol,reload,sor, obj){ if(!ts.p.colModel[idxcol].sortable) { return; } var so; if(ts.p.savedRow.length > 0) {return;} if(!reload) { if( ts.p.lastsort === idxcol ) { if( ts.p.sortorder === 'asc') { ts.p.sortorder = 'desc'; } else if(ts.p.sortorder === 'desc') { ts.p.sortorder = 'asc';} } else { ts.p.sortorder = ts.p.colModel[idxcol].firstsortorder || 'asc'; } ts.p.page = 1; } if(ts.p.multiSort) { multiSort( idxcol, obj); } else { if(sor) { if(ts.p.lastsort === idxcol && ts.p.sortorder === sor && !reload) { return; } ts.p.sortorder = sor; } var previousSelectedTh = ts.grid.headers[ts.p.lastsort].el, newSelectedTh = ts.p.frozenColumns ? obj : ts.grid.headers[idxcol].el; $("span.ui-grid-ico-sort",previousSelectedTh).addClass('ui-state-disabled'); $(previousSelectedTh).attr("aria-selected","false"); if(ts.p.frozenColumns) { ts.grid.fhDiv.find("span.ui-grid-ico-sort").addClass('ui-state-disabled'); ts.grid.fhDiv.find("th").attr("aria-selected","false"); } $("span.ui-icon-"+ts.p.sortorder,newSelectedTh).removeClass('ui-state-disabled'); $(newSelectedTh).attr("aria-selected","true"); if(!ts.p.viewsortcols[0]) { if(ts.p.lastsort !== idxcol) { if(ts.p.frozenColumns){ ts.grid.fhDiv.find("span.s-ico").hide(); } $("span.s-ico",previousSelectedTh).hide(); $("span.s-ico",newSelectedTh).show(); } } index = index.substring(5 + ts.p.id.length + 1); // bad to be changed!?! ts.p.sortname = ts.p.colModel[idxcol].index || index; so = ts.p.sortorder; } if ($(ts).triggerHandler("jqGridSortCol", [index, idxcol, so]) === 'stop') { ts.p.lastsort = idxcol; return; } if($.isFunction(ts.p.onSortCol)) {if (ts.p.onSortCol.call(ts,index,idxcol,so)==='stop') {ts.p.lastsort = idxcol; return;}} if(ts.p.datatype === "local") { if(ts.p.deselectAfterSort) {$(ts).jqGrid("resetSelection");} } else { ts.p.selrow = null; if(ts.p.multiselect){setHeadCheckBox( false );} ts.p.selarrrow =[]; ts.p.savedRow =[]; } if(ts.p.scroll) { var sscroll = ts.grid.bDiv.scrollLeft; emptyRows.call(ts, true, false); ts.grid.hDiv.scrollLeft = sscroll; } if(ts.p.subGrid && ts.p.datatype === 'local') { $("td.sgexpanded","#"+$.jgrid.jqID(ts.p.id)).each(function(){ $(this).trigger("click"); }); } populate(); ts.p.lastsort = idxcol; if(ts.p.sortname !== index && idxcol) {ts.p.lastsort = idxcol;} }, setColWidth = function () { var initwidth = 0, brd=$.jgrid.cell_width? 0: intNum(ts.p.cellLayout,0), vc=0, lvc, scw=intNum(ts.p.scrollOffset,0),cw,hs=false,aw,gw=0,cr; $.each(ts.p.colModel, function() { if(this.hidden === undefined) {this.hidden=false;} if(ts.p.grouping && ts.p.autowidth) { var ind = $.inArray(this.name, ts.p.groupingView.groupField); if(ind >= 0 && ts.p.groupingView.groupColumnShow.length > ind) { this.hidden = !ts.p.groupingView.groupColumnShow[ind]; } } this.widthOrg = cw = intNum(this.width,0); if(this.hidden===false){ initwidth += cw+brd; if(this.fixed) { gw += cw+brd; } else { vc++; } } }); if(isNaN(ts.p.width)) { ts.p.width = initwidth + ((ts.p.shrinkToFit ===false && !isNaN(ts.p.height)) ? scw : 0); } grid.width = ts.p.width; ts.p.tblwidth = initwidth; if(ts.p.shrinkToFit ===false && ts.p.forceFit === true) {ts.p.forceFit=false;} if(ts.p.shrinkToFit===true && vc > 0) { aw = grid.width-brd*vc-gw; if(!isNaN(ts.p.height)) { aw -= scw; hs = true; } initwidth =0; $.each(ts.p.colModel, function(i) { if(this.hidden === false && !this.fixed){ cw = Math.round(aw*this.width/(ts.p.tblwidth-brd*vc-gw)); this.width =cw; initwidth += cw; lvc = i; } }); cr =0; if (hs) { if(grid.width-gw-(initwidth+brd*vc) !== scw){ cr = grid.width-gw-(initwidth+brd*vc)-scw; } } else if(!hs && Math.abs(grid.width-gw-(initwidth+brd*vc)) !== 1) { cr = grid.width-gw-(initwidth+brd*vc); } ts.p.colModel[lvc].width += cr; ts.p.tblwidth = initwidth+cr+brd*vc+gw; if(ts.p.tblwidth > ts.p.width) { ts.p.colModel[lvc].width -= (ts.p.tblwidth - parseInt(ts.p.width,10)); ts.p.tblwidth = ts.p.width; } } }, nextVisible= function(iCol) { var ret = iCol, j=iCol, i; for (i = iCol+1;i"); this.p.colModel.unshift({name:'cb',width:$.jgrid.cell_width ? ts.p.multiselectWidth+ts.p.cellLayout : ts.p.multiselectWidth,sortable:false,resizable:false,hidedlg:true,search:false,align:'center',fixed:true}); } if(this.p.rownumbers) { this.p.colNames.unshift(""); this.p.colModel.unshift({name:'rn',width:ts.p.rownumWidth,sortable:false,resizable:false,hidedlg:true,search:false,align:'center',fixed:true}); } ts.p.xmlReader = $.extend(true,{ root: "rows", row: "row", page: "rows>page", total: "rows>total", records : "rows>records", repeatitems: true, cell: "cell", id: "[id]", userdata: "userdata", subgrid: {root:"rows", row: "row", repeatitems: true, cell:"cell"} }, ts.p.xmlReader); ts.p.jsonReader = $.extend(true,{ root: "rows", page: "page", total: "total", records: "records", repeatitems: true, cell: "cell", id: "id", userdata: "userdata", subgrid: {root:"rows", repeatitems: true, cell:"cell"} },ts.p.jsonReader); ts.p.localReader = $.extend(true,{ root: "rows", page: "page", total: "total", records: "records", repeatitems: false, cell: "cell", id: "id", userdata: "userdata", subgrid: {root:"rows", repeatitems: true, cell:"cell"} },ts.p.localReader); if(ts.p.scroll){ ts.p.pgbuttons = false; ts.p.pginput=false; ts.p.rowList=[]; } if(ts.p.data.length) { refreshIndex(); } var thead = "", tdc, idn, w, res, sort, td, ptr, tbody, imgs,iac="",idc="",sortarr=[], sortord=[], sotmp=[]; if(ts.p.shrinkToFit===true && ts.p.forceFit===true) { for (i=ts.p.colModel.length-1;i>=0;i--){ if(!ts.p.colModel[i].hidden) { ts.p.colModel[i].resizable=false; break; } } } if(ts.p.viewsortcols[1] === 'horizontal') {iac=" ui-i-asc";idc=" ui-i-desc";} tdc = isMSIE ? "class='ui-th-div-ie'" :""; imgs = ""; if(ts.p.multiSort) { sortarr = ts.p.sortname.split(","); for (i=0; i"; idn = ts.p.colModel[i].index || ts.p.colModel[i].name; thead += "
    "+ts.p.colNames[i]; if(!ts.p.colModel[i].width) { ts.p.colModel[i].width = 150; } else { ts.p.colModel[i].width = parseInt(ts.p.colModel[i].width,10); } if(typeof ts.p.colModel[i].title !== "boolean") { ts.p.colModel[i].title = true; } ts.p.colModel[i].lso = ""; if (idn === ts.p.sortname) { ts.p.lastsort = i; } if(ts.p.multiSort) { sotmp = $.inArray(idn,sortarr); if( sotmp !== -1 ) { ts.p.colModel[i].lso = sortord[sotmp]; } } thead += imgs+"
    "; } thead += ""; imgs = null; $(this).append(thead); $("thead tr:first th",this).hover(function(){$(this).addClass('ui-state-hover');},function(){$(this).removeClass('ui-state-hover');}); if(this.p.multiselect) { var emp=[], chk; $('#cb_'+$.jgrid.jqID(ts.p.id),this).bind('click',function(){ ts.p.selarrrow = []; var froz = ts.p.frozenColumns === true ? ts.p.id + "_frozen" : ""; if (this.checked) { $(ts.rows).each(function(i) { if (i>0) { if(!$(this).hasClass("ui-subgrid") && !$(this).hasClass("jqgroup") && !$(this).hasClass('ui-state-disabled')){ $("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+$.jgrid.jqID(this.id) )[ts.p.useProp ? 'prop': 'attr']("checked",true); $(this).addClass("ui-state-highlight").attr("aria-selected","true"); ts.p.selarrrow.push(this.id); ts.p.selrow = this.id; if(froz) { $("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+$.jgrid.jqID(this.id), ts.grid.fbDiv )[ts.p.useProp ? 'prop': 'attr']("checked",true); $("#"+$.jgrid.jqID(this.id), ts.grid.fbDiv).addClass("ui-state-highlight"); } } } }); chk=true; emp=[]; } else { $(ts.rows).each(function(i) { if(i>0) { if(!$(this).hasClass("ui-subgrid") && !$(this).hasClass('ui-state-disabled')){ $("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+$.jgrid.jqID(this.id) )[ts.p.useProp ? 'prop': 'attr']("checked", false); $(this).removeClass("ui-state-highlight").attr("aria-selected","false"); emp.push(this.id); if(froz) { $("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+$.jgrid.jqID(this.id), ts.grid.fbDiv )[ts.p.useProp ? 'prop': 'attr']("checked",false); $("#"+$.jgrid.jqID(this.id), ts.grid.fbDiv).removeClass("ui-state-highlight"); } } } }); ts.p.selrow = null; chk=false; } $(ts).triggerHandler("jqGridSelectAll", [chk ? ts.p.selarrrow : emp, chk]); if($.isFunction(ts.p.onSelectAll)) {ts.p.onSelectAll.call(ts, chk ? ts.p.selarrrow : emp,chk);} }); } if(ts.p.autowidth===true) { var pw = $(eg).innerWidth(); ts.p.width = pw > 0? pw: 'nw'; } setColWidth(); $(eg).css("width",grid.width+"px").append("
     
    "); $(gv).css("width",grid.width+"px"); thead = $("thead:first",ts).get(0); var tfoot = ""; if(ts.p.footerrow) { tfoot += ""; } var thr = $("tr:first",thead), firstr = ""; ts.p.disableClick=false; $("th",thr).each(function ( j ) { w = ts.p.colModel[j].width; if(ts.p.colModel[j].resizable === undefined) {ts.p.colModel[j].resizable = true;} if(ts.p.colModel[j].resizable){ res = document.createElement("span"); $(res).html(" ").addClass('ui-jqgrid-resize ui-jqgrid-resize-'+dir) .css("cursor","col-resize"); $(this).addClass(ts.p.resizeclass); } else { res = ""; } $(this).css("width",w+"px").prepend(res); var hdcol = ""; if( ts.p.colModel[j].hidden ) { $(this).css("display","none"); hdcol = "display:none;"; } firstr += ""; grid.headers[j] = { width: w, el: this }; sort = ts.p.colModel[j].sortable; if( typeof sort !== 'boolean') {ts.p.colModel[j].sortable = true; sort=true;} var nm = ts.p.colModel[j].name; if( !(nm === 'cb' || nm==='subgrid' || nm==='rn') ) { if(ts.p.viewsortcols[2]){ $(">div",this).addClass('ui-jqgrid-sortable'); } } if(sort) { if(ts.p.multiSort) { if(ts.p.viewsortcols[0]) { $("div span.s-ico",this).show(); if(ts.p.colModel[j].lso){ $("div span.ui-icon-"+ts.p.colModel[j].lso,this).removeClass("ui-state-disabled"); } } else if( ts.p.colModel[j].lso) { $("div span.s-ico",this).show(); $("div span.ui-icon-"+ts.p.colModel[j].lso,this).removeClass("ui-state-disabled"); } } else { if(ts.p.viewsortcols[0]) {$("div span.s-ico",this).show(); if(j===ts.p.lastsort){ $("div span.ui-icon-"+ts.p.sortorder,this).removeClass("ui-state-disabled");}} else if( j === ts.p.lastsort) {$("div span.s-ico",this).show();$("div span.ui-icon-"+ts.p.sortorder,this).removeClass("ui-state-disabled");} } } if(ts.p.footerrow) { tfoot += ""; } }).mousedown(function(e) { if ($(e.target).closest("th>span.ui-jqgrid-resize").length !== 1) { return; } var ci = getColumnHeaderIndex(this); if(ts.p.forceFit===true) {ts.p.nv= nextVisible(ci);} grid.dragStart(ci, e, getOffset(ci)); return false; }).click(function(e) { if (ts.p.disableClick) { ts.p.disableClick = false; return false; } var s = "th>div.ui-jqgrid-sortable",r,d; if (!ts.p.viewsortcols[2]) { s = "th>div>span>span.ui-grid-ico-sort"; } var t = $(e.target).closest(s); if (t.length !== 1) { return; } var ci; if(ts.p.frozenColumns) { var tid = $(this)[0].id.substring(5); $(ts.p.colModel).each(function(i){ if (this.name === tid) { ci = i;return false; } }); } else { ci = getColumnHeaderIndex(this); } if (!ts.p.viewsortcols[2]) { r=true;d=t.attr("sort"); } if(ci != null){ sortData( $('div',this)[0].id, ci, r, d, this); } return false; }); if (ts.p.sortable && $.fn.sortable) { try { $(ts).jqGrid("sortableColumns", thr); } catch (e){} } if(ts.p.footerrow) { tfoot += "
     
    "; } firstr += ""; tbody = document.createElement("tbody"); this.appendChild(tbody); $(this).addClass('ui-jqgrid-btable').append(firstr); firstr = null; var hTable = $("
    ").append(thead), hg = (ts.p.caption && ts.p.hiddengrid===true) ? true : false, hb = $("
    "); thead = null; grid.hDiv = document.createElement("div"); $(grid.hDiv) .css({ width: grid.width+"px"}) .addClass("ui-state-default ui-jqgrid-hdiv") .append(hb); $(hb).append(hTable); hTable = null; if(hg) { $(grid.hDiv).hide(); } if(ts.p.pager){ // TBD -- escape ts.p.pager here? if(typeof ts.p.pager === "string") {if(ts.p.pager.substr(0,1) !== "#") { ts.p.pager = "#"+ts.p.pager;} } else { ts.p.pager = "#"+ $(ts.p.pager).attr("id");} $(ts.p.pager).css({width: grid.width+"px"}).addClass('ui-state-default ui-jqgrid-pager ui-corner-bottom').appendTo(eg); if(hg) {$(ts.p.pager).hide();} setPager(ts.p.pager,''); } if( ts.p.cellEdit === false && ts.p.hoverrows === true) { $(ts).bind('mouseover',function(e) { ptr = $(e.target).closest("tr.jqgrow"); if($(ptr).attr("class") !== "ui-subgrid") { $(ptr).addClass("ui-state-hover"); } }).bind('mouseout',function(e) { ptr = $(e.target).closest("tr.jqgrow"); $(ptr).removeClass("ui-state-hover"); }); } var ri,ci, tdHtml; $(ts).before(grid.hDiv).click(function(e) { td = e.target; ptr = $(td,ts.rows).closest("tr.jqgrow"); if($(ptr).length === 0 || ptr[0].className.indexOf( 'ui-state-disabled' ) > -1 || ($(td,ts).closest("table.ui-jqgrid-btable").attr('id') || '').replace("_frozen","") !== ts.id ) { return this; } var scb = $(td).hasClass("cbox"), cSel = $(ts).triggerHandler("jqGridBeforeSelectRow", [ptr[0].id, e]); cSel = (cSel === false || cSel === 'stop') ? false : true; if(cSel && $.isFunction(ts.p.beforeSelectRow)) { cSel = ts.p.beforeSelectRow.call(ts,ptr[0].id, e); } if (td.tagName === 'A' || ((td.tagName === 'INPUT' || td.tagName === 'TEXTAREA' || td.tagName === 'OPTION' || td.tagName === 'SELECT' ) && !scb) ) { return; } if(cSel === true) { ri = ptr[0].id; ci = $.jgrid.getCellIndex(td); tdHtml = $(td).closest("td,th").html(); $(ts).triggerHandler("jqGridCellSelect", [ri,ci,tdHtml,e]); if($.isFunction(ts.p.onCellSelect)) { ts.p.onCellSelect.call(ts,ri,ci,tdHtml,e); } if(ts.p.cellEdit === true) { if(ts.p.multiselect && scb){ $(ts).jqGrid("setSelection", ri ,true,e); } else { ri = ptr[0].rowIndex; try {$(ts).jqGrid("editCell",ri,ci,true);} catch (_) {} } } else if ( !ts.p.multikey ) { if(ts.p.multiselect && ts.p.multiboxonly) { if(scb){$(ts).jqGrid("setSelection",ri,true,e);} else { var frz = ts.p.frozenColumns ? ts.p.id+"_frozen" : ""; $(ts.p.selarrrow).each(function(i,n){ var ind = ts.rows.namedItem(n); $(ind).removeClass("ui-state-highlight"); $("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+$.jgrid.jqID(n))[ts.p.useProp ? 'prop': 'attr']("checked", false); if(frz) { $("#"+$.jgrid.jqID(n), "#"+$.jgrid.jqID(frz)).removeClass("ui-state-highlight"); $("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+$.jgrid.jqID(n), "#"+$.jgrid.jqID(frz))[ts.p.useProp ? 'prop': 'attr']("checked", false); } }); ts.p.selarrrow = []; $(ts).jqGrid("setSelection",ri,true,e); } } else { $(ts).jqGrid("setSelection",ri,true,e); } } else { if(e[ts.p.multikey]) { $(ts).jqGrid("setSelection",ri,true,e); } else if(ts.p.multiselect && scb) { scb = $("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+ri).is(":checked"); $("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+ri)[ts.p.useProp ? 'prop' : 'attr']("checked", scb); } } } }).bind('reloadGrid', function(e,opts) { if(ts.p.treeGrid ===true) { ts.p.datatype = ts.p.treedatatype;} if (opts && opts.current) { ts.grid.selectionPreserver(ts); } if(ts.p.datatype==="local"){ $(ts).jqGrid("resetSelection"); if(ts.p.data.length) { refreshIndex();} } else if(!ts.p.treeGrid) { ts.p.selrow=null; if(ts.p.multiselect) {ts.p.selarrrow =[];setHeadCheckBox(false);} ts.p.savedRow = []; } if(ts.p.scroll) {emptyRows.call(ts, true, false);} if (opts && opts.page) { var page = opts.page; if (page > ts.p.lastpage) { page = ts.p.lastpage; } if (page < 1) { page = 1; } ts.p.page = page; if (ts.grid.prevRowHeight) { ts.grid.bDiv.scrollTop = (page - 1) * ts.grid.prevRowHeight * ts.p.rowNum; } else { ts.grid.bDiv.scrollTop = 0; } } if (ts.grid.prevRowHeight && ts.p.scroll) { delete ts.p.lastpage; ts.grid.populateVisible(); } else { ts.grid.populate(); } if(ts.p._inlinenav===true) {$(ts).jqGrid('showAddEditButtons');} return false; }) .dblclick(function(e) { td = e.target; ptr = $(td,ts.rows).closest("tr.jqgrow"); if($(ptr).length === 0 ){return;} ri = ptr[0].rowIndex; ci = $.jgrid.getCellIndex(td); $(ts).triggerHandler("jqGridDblClickRow", [$(ptr).attr("id"),ri,ci,e]); if ($.isFunction(ts.p.ondblClickRow)) { ts.p.ondblClickRow.call(ts,$(ptr).attr("id"),ri,ci, e); } }) .bind('contextmenu', function(e) { td = e.target; ptr = $(td,ts.rows).closest("tr.jqgrow"); if($(ptr).length === 0 ){return;} if(!ts.p.multiselect) { $(ts).jqGrid("setSelection",ptr[0].id,true,e); } ri = ptr[0].rowIndex; ci = $.jgrid.getCellIndex(td); $(ts).triggerHandler("jqGridRightClickRow", [$(ptr).attr("id"),ri,ci,e]); if ($.isFunction(ts.p.onRightClickRow)) { ts.p.onRightClickRow.call(ts,$(ptr).attr("id"),ri,ci, e); } }); grid.bDiv = document.createElement("div"); if(isMSIE) { if(String(ts.p.height).toLowerCase() === "auto") { ts.p.height = "100%"; } } $(grid.bDiv) .append($('
    ').append('
    ').append(this)) .addClass("ui-jqgrid-bdiv") .css({ height: ts.p.height+(isNaN(ts.p.height)?"":"px"), width: (grid.width)+"px"}) .scroll(grid.scrollGrid); $("table:first",grid.bDiv).css({width:ts.p.tblwidth+"px"}); if( !$.support.tbody ) { //IE if( $("tbody",this).length === 2 ) { $("tbody:gt(0)",this).remove();} } if(ts.p.multikey){ if( $.jgrid.msie) { $(grid.bDiv).bind("selectstart",function(){return false;}); } else { $(grid.bDiv).bind("mousedown",function(){return false;}); } } if(hg) {$(grid.bDiv).hide();} grid.cDiv = document.createElement("div"); var arf = ts.p.hidegrid===true ? $("").addClass('ui-jqgrid-titlebar-close HeaderButton').hover( function(){ arf.addClass('ui-state-hover');}, function() {arf.removeClass('ui-state-hover');}) .append("").css((dir==="rtl"?"left":"right"),"0px") : ""; $(grid.cDiv).append(arf).append(""+ts.p.caption+"") .addClass("ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix"); $(grid.cDiv).insertBefore(grid.hDiv); if( ts.p.toolbar[0] ) { grid.uDiv = document.createElement("div"); if(ts.p.toolbar[1] === "top") {$(grid.uDiv).insertBefore(grid.hDiv);} else if (ts.p.toolbar[1]==="bottom" ) {$(grid.uDiv).insertAfter(grid.hDiv);} if(ts.p.toolbar[1]==="both") { grid.ubDiv = document.createElement("div"); $(grid.uDiv).addClass("ui-userdata ui-state-default").attr("id","t_"+this.id).insertBefore(grid.hDiv); $(grid.ubDiv).addClass("ui-userdata ui-state-default").attr("id","tb_"+this.id).insertAfter(grid.hDiv); if(hg) {$(grid.ubDiv).hide();} } else { $(grid.uDiv).width(grid.width).addClass("ui-userdata ui-state-default").attr("id","t_"+this.id); } if(hg) {$(grid.uDiv).hide();} } if(ts.p.toppager) { ts.p.toppager = $.jgrid.jqID(ts.p.id)+"_toppager"; grid.topDiv = $("
    ")[0]; ts.p.toppager = "#"+ts.p.toppager; $(grid.topDiv).addClass('ui-state-default ui-jqgrid-toppager').width(grid.width).insertBefore(grid.hDiv); setPager(ts.p.toppager,'_t'); } if(ts.p.footerrow) { grid.sDiv = $("
    ")[0]; hb = $("
    "); $(grid.sDiv).append(hb).width(grid.width).insertAfter(grid.hDiv); $(hb).append(tfoot); grid.footers = $(".ui-jqgrid-ftable",grid.sDiv)[0].rows[0].cells; if(ts.p.rownumbers) { grid.footers[0].className = 'ui-state-default jqgrid-rownum'; } if(hg) {$(grid.sDiv).hide();} } hb = null; if(ts.p.caption) { var tdt = ts.p.datatype; if(ts.p.hidegrid===true) { $(".ui-jqgrid-titlebar-close",grid.cDiv).click( function(e){ var onHdCl = $.isFunction(ts.p.onHeaderClick), elems = ".ui-jqgrid-bdiv, .ui-jqgrid-hdiv, .ui-jqgrid-pager, .ui-jqgrid-sdiv", counter, self = this; if(ts.p.toolbar[0]===true) { if( ts.p.toolbar[1]==='both') { elems += ', #' + $(grid.ubDiv).attr('id'); } elems += ', #' + $(grid.uDiv).attr('id'); } counter = $(elems,"#gview_"+$.jgrid.jqID(ts.p.id)).length; if(ts.p.gridstate === 'visible') { $(elems,"#gbox_"+$.jgrid.jqID(ts.p.id)).slideUp("fast", function() { counter--; if (counter === 0) { $("span",self).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s"); ts.p.gridstate = 'hidden'; if($("#gbox_"+$.jgrid.jqID(ts.p.id)).hasClass("ui-resizable")) { $(".ui-resizable-handle","#gbox_"+$.jgrid.jqID(ts.p.id)).hide(); } $(ts).triggerHandler("jqGridHeaderClick", [ts.p.gridstate,e]); if(onHdCl) {if(!hg) {ts.p.onHeaderClick.call(ts,ts.p.gridstate,e);}} } }); } else if(ts.p.gridstate === 'hidden'){ $(elems,"#gbox_"+$.jgrid.jqID(ts.p.id)).slideDown("fast", function() { counter--; if (counter === 0) { $("span",self).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n"); if(hg) {ts.p.datatype = tdt;populate();hg=false;} ts.p.gridstate = 'visible'; if($("#gbox_"+$.jgrid.jqID(ts.p.id)).hasClass("ui-resizable")) { $(".ui-resizable-handle","#gbox_"+$.jgrid.jqID(ts.p.id)).show(); } $(ts).triggerHandler("jqGridHeaderClick", [ts.p.gridstate,e]); if(onHdCl) {if(!hg) {ts.p.onHeaderClick.call(ts,ts.p.gridstate,e);}} } }); } return false; }); if(hg) {ts.p.datatype="local"; $(".ui-jqgrid-titlebar-close",grid.cDiv).trigger("click");} } } else {$(grid.cDiv).hide();} $(grid.hDiv).after(grid.bDiv) .mousemove(function (e) { if(grid.resizing){grid.dragMove(e);return false;} }); $(".ui-jqgrid-labels",grid.hDiv).bind("selectstart", function () { return false; }); $(document).mouseup(function () { if(grid.resizing) { grid.dragEnd(); return false;} return true; }); ts.formatCol = formatCol; ts.sortData = sortData; ts.updatepager = updatepager; ts.refreshIndex = refreshIndex; ts.setHeadCheckBox = setHeadCheckBox; ts.constructTr = constructTr; ts.formatter = function ( rowId, cellval , colpos, rwdat, act){return formatter(rowId, cellval , colpos, rwdat, act);}; $.extend(grid,{populate : populate, emptyRows: emptyRows}); this.grid = grid; ts.addXmlData = function(d) {addXmlData(d,ts.grid.bDiv);}; ts.addJSONData = function(d) {addJSONData(d,ts.grid.bDiv);}; this.grid.cols = this.rows[0].cells; $(ts).triggerHandler("jqGridInitGrid"); if ($.isFunction( ts.p.onInitGrid )) { ts.p.onInitGrid.call(ts); } populate();ts.p.hiddengrid=false; }); }; $.jgrid.extend({ getGridParam : function(pName) { var $t = this[0]; if (!$t || !$t.grid) {return;} if (!pName) { return $t.p; } return $t.p[pName] !== undefined ? $t.p[pName] : null; }, setGridParam : function (newParams){ return this.each(function(){ if (this.grid && typeof newParams === 'object') {$.extend(true,this.p,newParams);} }); }, getDataIDs : function () { var ids=[], i=0, len, j=0; this.each(function(){ len = this.rows.length; if(len && len>0){ while(i -1 ) { return; } function scrGrid(iR){ var ch = $($t.grid.bDiv)[0].clientHeight, st = $($t.grid.bDiv)[0].scrollTop, rpos = $($t.rows[iR]).position().top, rh = $t.rows[iR].clientHeight; if(rpos+rh >= ch+st) { $($t.grid.bDiv)[0].scrollTop = rpos-(ch+st)+rh+st; } else if(rpos < ch+st) { if(rpos < st) { $($t.grid.bDiv)[0].scrollTop = rpos; } } } if($t.p.scrollrows===true) { ner = $t.rows.namedItem(selection).rowIndex; if(ner >=0 ){ scrGrid(ner); } } if($t.p.frozenColumns === true ) { fid = $t.p.id+"_frozen"; } if(!$t.p.multiselect) { if(pt.className !== "ui-subgrid") { if( $t.p.selrow !== pt.id) { $($t.rows.namedItem($t.p.selrow)).removeClass("ui-state-highlight").attr({"aria-selected":"false", "tabindex" : "-1"}); $(pt).addClass("ui-state-highlight").attr({"aria-selected":"true", "tabindex" : "0"});//.focus(); if(fid) { $("#"+$.jgrid.jqID($t.p.selrow), "#"+$.jgrid.jqID(fid)).removeClass("ui-state-highlight"); $("#"+$.jgrid.jqID(selection), "#"+$.jgrid.jqID(fid)).addClass("ui-state-highlight"); } stat = true; } else { stat = false; } $t.p.selrow = pt.id; if( onsr ) { $($t).triggerHandler("jqGridSelectRow", [pt.id, stat, e]); if( $t.p.onSelectRow) { $t.p.onSelectRow.call($t, pt.id, stat, e); } } } } else { //unselect selectall checkbox when deselecting a specific row $t.setHeadCheckBox( false ); $t.p.selrow = pt.id; ia = $.inArray($t.p.selrow,$t.p.selarrrow); if ( ia === -1 ){ if(pt.className !== "ui-subgrid") { $(pt).addClass("ui-state-highlight").attr("aria-selected","true");} stat = true; $t.p.selarrrow.push($t.p.selrow); } else { if(pt.className !== "ui-subgrid") { $(pt).removeClass("ui-state-highlight").attr("aria-selected","false");} stat = false; $t.p.selarrrow.splice(ia,1); tpsr = $t.p.selarrrow[0]; $t.p.selrow = (tpsr === undefined) ? null : tpsr; } $("#jqg_"+$.jgrid.jqID($t.p.id)+"_"+$.jgrid.jqID(pt.id))[$t.p.useProp ? 'prop': 'attr']("checked",stat); if(fid) { if(ia === -1) { $("#"+$.jgrid.jqID(selection), "#"+$.jgrid.jqID(fid)).addClass("ui-state-highlight"); } else { $("#"+$.jgrid.jqID(selection), "#"+$.jgrid.jqID(fid)).removeClass("ui-state-highlight"); } $("#jqg_"+$.jgrid.jqID($t.p.id)+"_"+$.jgrid.jqID(selection), "#"+$.jgrid.jqID(fid))[$t.p.useProp ? 'prop': 'attr']("checked",stat); } if( onsr ) { $($t).triggerHandler("jqGridSelectRow", [pt.id, stat, e]); if( $t.p.onSelectRow) { $t.p.onSelectRow.call($t, pt.id , stat, e); } } } }); }, resetSelection : function( rowid ){ return this.each(function(){ var t = this, ind, sr, fid; if( t.p.frozenColumns === true ) { fid = t.p.id+"_frozen"; } if(rowid !== undefined ) { sr = rowid === t.p.selrow ? t.p.selrow : rowid; $("#"+$.jgrid.jqID(t.p.id)+" tbody:first tr#"+$.jgrid.jqID(sr)).removeClass("ui-state-highlight").attr("aria-selected","false"); if (fid) { $("#"+$.jgrid.jqID(sr), "#"+$.jgrid.jqID(fid)).removeClass("ui-state-highlight"); } if(t.p.multiselect) { $("#jqg_"+$.jgrid.jqID(t.p.id)+"_"+$.jgrid.jqID(sr), "#"+$.jgrid.jqID(t.p.id))[t.p.useProp ? 'prop': 'attr']("checked",false); if(fid) { $("#jqg_"+$.jgrid.jqID(t.p.id)+"_"+$.jgrid.jqID(sr), "#"+$.jgrid.jqID(fid))[t.p.useProp ? 'prop': 'attr']("checked",false); } t.setHeadCheckBox( false); } sr = null; } else if(!t.p.multiselect) { if(t.p.selrow) { $("#"+$.jgrid.jqID(t.p.id)+" tbody:first tr#"+$.jgrid.jqID(t.p.selrow)).removeClass("ui-state-highlight").attr("aria-selected","false"); if(fid) { $("#"+$.jgrid.jqID(t.p.selrow), "#"+$.jgrid.jqID(fid)).removeClass("ui-state-highlight"); } t.p.selrow = null; } } else { $(t.p.selarrrow).each(function(i,n){ ind = t.rows.namedItem(n); $(ind).removeClass("ui-state-highlight").attr("aria-selected","false"); $("#jqg_"+$.jgrid.jqID(t.p.id)+"_"+$.jgrid.jqID(n))[t.p.useProp ? 'prop': 'attr']("checked",false); if(fid) { $("#"+$.jgrid.jqID(n), "#"+$.jgrid.jqID(fid)).removeClass("ui-state-highlight"); $("#jqg_"+$.jgrid.jqID(t.p.id)+"_"+$.jgrid.jqID(n), "#"+$.jgrid.jqID(fid))[t.p.useProp ? 'prop': 'attr']("checked",false); } }); t.setHeadCheckBox( false ); t.p.selarrrow = []; } if(t.p.cellEdit === true) { if(parseInt(t.p.iCol,10)>=0 && parseInt(t.p.iRow,10)>=0) { $("td:eq("+t.p.iCol+")",t.rows[t.p.iRow]).removeClass("edit-cell ui-state-highlight"); $(t.rows[t.p.iRow]).removeClass("selected-row ui-state-hover"); } } t.p.savedRow = []; }); }, getRowData : function( rowid ) { var res = {}, resall, getall=false, len, j=0; this.each(function(){ var $t = this,nm,ind; if(rowid === undefined) { getall = true; resall = []; len = $t.rows.length; } else { ind = $t.rows.namedItem(rowid); if(!ind) { return res; } len = 2; } while(j 0) { $t.p.selrow = $t.p.selarrrow[$t.p.selarrrow.length-1]; } else { $t.p.selrow = null; } if($t.p.datatype === 'local') { var id = $.jgrid.stripPref($t.p.idPrefix, rowid), pos = $t.p._index[id]; if(pos !== undefined) { $t.p.data.splice(pos,1); $t.refreshIndex(); } } if( $t.p.altRows === true && success ) { var cn = $t.p.altclass; $($t.rows).each(function(i){ if(i % 2 === 1) { $(this).addClass(cn); } else { $(this).removeClass(cn); } }); } }); return success; }, setRowData : function(rowid, data, cssp) { var nm, success=true, title; this.each(function(){ if(!this.grid) {return false;} var t = this, vl, ind, cp = typeof cssp, lcdata={}; ind = t.rows.namedItem(rowid); if(!ind) { return false; } if( data ) { try { $(this.p.colModel).each(function(i){ nm = this.name; var dval =$.jgrid.getAccessor(data,nm); if( dval !== undefined) { lcdata[nm] = this.formatter && typeof this.formatter === 'string' && this.formatter === 'date' ? $.unformat.date.call(t,dval,this) : dval; vl = t.formatter( rowid, dval, i, data, 'edit'); title = this.title ? {"title":$.jgrid.stripHtml(vl)} : {}; if(t.p.treeGrid===true && nm === t.p.ExpandColumn) { $("td[role='gridcell']:eq("+i+") > span:first",ind).html(vl).attr(title); } else { $("td[role='gridcell']:eq("+i+")",ind).html(vl).attr(title); } } }); if(t.p.datatype === 'local') { var id = $.jgrid.stripPref(t.p.idPrefix, rowid), pos = t.p._index[id], key; if(t.p.treeGrid) { for(key in t.p.treeReader){ if(t.p.treeReader.hasOwnProperty(key)) { delete lcdata[t.p.treeReader[key]]; } } } if(pos !== undefined) { t.p.data[pos] = $.extend(true, t.p.data[pos], lcdata); } lcdata = null; } } catch (e) { success = false; } } if(success) { if(cp === 'string') {$(ind).addClass(cssp);} else if(cp === 'object') {$(ind).css(cssp);} $(t).triggerHandler("jqGridAfterGridComplete"); } }); return success; }, addRowData : function(rowid,rdata,pos,src) { if(!pos) {pos = "last";} var success = false, nm, row, gi, si, ni,sind, i, v, prp="", aradd, cnm, cn, data, cm, id; if(rdata) { if($.isArray(rdata)) { aradd=true; pos = "last"; cnm = rowid; } else { rdata = [rdata]; aradd = false; } this.each(function() { var t = this, datalen = rdata.length; ni = t.p.rownumbers===true ? 1 :0; gi = t.p.multiselect ===true ? 1 :0; si = t.p.subGrid===true ? 1 :0; if(!aradd) { if(rowid !== undefined) { rowid = String(rowid);} else { rowid = $.jgrid.randId(); if(t.p.keyIndex !== false) { cnm = t.p.colModel[t.p.keyIndex+gi+si+ni].name; if(rdata[0][cnm] !== undefined) { rowid = rdata[0][cnm]; } } } } cn = t.p.altclass; var k = 0, cna ="", lcdata = {}, air = $.isFunction(t.p.afterInsertRow) ? true : false; while(k < datalen) { data = rdata[k]; row=[]; if(aradd) { try { rowid = data[cnm]; if(rowid===undefined) { rowid = $.jgrid.randId(); } } catch (e) {rowid = $.jgrid.randId();} cna = t.p.altRows === true ? (t.rows.length-1)%2 === 0 ? cn : "" : ""; } id = rowid; rowid = t.p.idPrefix + rowid; if(ni){ prp = t.formatCol(0,1,'',null,rowid, true); row[row.length] = "0"; } if(gi) { v = ""; prp = t.formatCol(ni,1,'', null, rowid, true); row[row.length] = ""+v+""; } if(si) { row[row.length] = $(t).jqGrid("addSubGridCell",gi+ni,1); } for(i = gi+si+ni; i < t.p.colModel.length;i++){ cm = t.p.colModel[i]; nm = cm.name; lcdata[nm] = data[nm]; v = t.formatter( rowid, $.jgrid.getAccessor(data,nm), i, data ); prp = t.formatCol(i,1,v, data, rowid, lcdata); row[row.length] = ""+v+""; } row.unshift( t.constructTr(rowid, false, cna, lcdata, data, false ) ); row[row.length] = ""; if(t.rows.length === 0){ $("table:first",t.grid.bDiv).append(row.join('')); } else { switch (pos) { case 'last': $(t.rows[t.rows.length-1]).after(row.join('')); sind = t.rows.length-1; break; case 'first': $(t.rows[0]).after(row.join('')); sind = 1; break; case 'after': sind = t.rows.namedItem(src); if (sind) { if($(t.rows[sind.rowIndex+1]).hasClass("ui-subgrid")) { $(t.rows[sind.rowIndex+1]).after(row); } else { $(sind).after(row.join('')); } } sind++; break; case 'before': sind = t.rows.namedItem(src); if(sind) {$(sind).before(row.join(''));sind=sind.rowIndex;} sind--; break; } } if(t.p.subGrid===true) { $(t).jqGrid("addSubGrid",gi+ni, sind); } t.p.records++; t.p.reccount++; $(t).triggerHandler("jqGridAfterInsertRow", [rowid,data,data]); if(air) { t.p.afterInsertRow.call(t,rowid,data,data); } k++; if(t.p.datatype === 'local') { lcdata[t.p.localReader.id] = id; t.p._index[id] = t.p.data.length; t.p.data.push(lcdata); lcdata = {}; } } if( t.p.altRows === true && !aradd) { if (pos === "last") { if ((t.rows.length-1)%2 === 1) {$(t.rows[t.rows.length-1]).addClass(cn);} } else { $(t.rows).each(function(i){ if(i % 2 ===1) { $(this).addClass(cn); } else { $(this).removeClass(cn); } }); } } t.updatepager(true,true); success = true; }); } return success; }, footerData : function(action,data, format) { var nm, success=false, res={}, title; function isEmpty(obj) { var i; for(i in obj) { if (obj.hasOwnProperty(i)) { return false; } } return true; } if(action === undefined) { action = "get"; } if(typeof format !== "boolean") { format = true; } action = action.toLowerCase(); this.each(function(){ var t = this, vl; if(!t.grid || !t.p.footerrow) {return false;} if(action === "set") { if(isEmpty(data)) { return false; } } success=true; $(this.p.colModel).each(function(i){ nm = this.name; if(action === "set") { if( data[nm] !== undefined) { vl = format ? t.formatter( "", data[nm], i, data, 'edit') : data[nm]; title = this.title ? {"title":$.jgrid.stripHtml(vl)} : {}; $("tr.footrow td:eq("+i+")",t.grid.sDiv).html(vl).attr(title); success = true; } } else if(action === "get") { res[nm] = $("tr.footrow td:eq("+i+")",t.grid.sDiv).html(); } }); }); return action === "get" ? res : success; }, showHideCol : function(colname,show) { return this.each(function() { var $t = this, fndh=false, brd=$.jgrid.cell_width ? 0: $t.p.cellLayout, cw; if (!$t.grid ) {return;} if( typeof colname === 'string') {colname=[colname];} show = show !== "none" ? "" : "none"; var sw = show === "" ? true :false, gh = $t.p.groupHeader && (typeof $t.p.groupHeader === 'object' || $.isFunction($t.p.groupHeader) ); if(gh) { $($t).jqGrid('destroyGroupHeader', false); } $(this.p.colModel).each(function(i) { if ($.inArray(this.name,colname) !== -1 && this.hidden === sw) { if($t.p.frozenColumns === true && this.frozen === true) { return true; } $("tr",$t.grid.hDiv).each(function(){ $(this.cells[i]).css("display", show); }); $($t.rows).each(function(){ if (!$(this).hasClass("jqgroup")) { $(this.cells[i]).css("display", show); } }); if($t.p.footerrow) { $("tr.footrow td:eq("+i+")", $t.grid.sDiv).css("display", show); } cw = parseInt(this.width,10); if(show === "none") { $t.p.tblwidth -= cw+brd; } else { $t.p.tblwidth += cw+brd; } this.hidden = !sw; fndh=true; $($t).triggerHandler("jqGridShowHideCol", [sw,this.name,i]); } }); if(fndh===true) { if($t.p.shrinkToFit === true && !isNaN($t.p.height)) { $t.p.tblwidth += parseInt($t.p.scrollOffset,10);} $($t).jqGrid("setGridWidth",$t.p.shrinkToFit === true ? $t.p.tblwidth : $t.p.width ); } if( gh ) { $($t).jqGrid('setGroupHeaders',$t.p.groupHeader); } }); }, hideCol : function (colname) { return this.each(function(){$(this).jqGrid("showHideCol",colname,"none");}); }, showCol : function(colname) { return this.each(function(){$(this).jqGrid("showHideCol",colname,"");}); }, remapColumns : function(permutation, updateCells, keepHeader) { function resortArray(a) { var ac; if (a.length) { ac = $.makeArray(a); } else { ac = $.extend({}, a); } $.each(permutation, function(i) { a[i] = ac[this]; }); } var ts = this.get(0); function resortRows(parent, clobj) { $(">tr"+(clobj||""), parent).each(function() { var row = this; var elems = $.makeArray(row.cells); $.each(permutation, function() { var e = elems[this]; if (e) { row.appendChild(e); } }); }); } resortArray(ts.p.colModel); resortArray(ts.p.colNames); resortArray(ts.grid.headers); resortRows($("thead:first", ts.grid.hDiv), keepHeader && ":not(.ui-jqgrid-labels)"); if (updateCells) { resortRows($("#"+$.jgrid.jqID(ts.p.id)+" tbody:first"), ".jqgfirstrow, tr.jqgrow, tr.jqfoot"); } if (ts.p.footerrow) { resortRows($("tbody:first", ts.grid.sDiv)); } if (ts.p.remapColumns) { if (!ts.p.remapColumns.length){ ts.p.remapColumns = $.makeArray(permutation); } else { resortArray(ts.p.remapColumns); } } ts.p.lastsort = $.inArray(ts.p.lastsort, permutation); if(ts.p.treeGrid) { ts.p.expColInd = $.inArray(ts.p.expColInd, permutation); } $(ts).triggerHandler("jqGridRemapColumns", [permutation, updateCells, keepHeader]); }, setGridWidth : function(nwidth, shrink) { return this.each(function(){ if (!this.grid ) {return;} var $t = this, cw, initwidth = 0, brd=$.jgrid.cell_width ? 0: $t.p.cellLayout, lvc, vc=0, hs=false, scw=$t.p.scrollOffset, aw, gw=0, cr; if(typeof shrink !== 'boolean') { shrink=$t.p.shrinkToFit; } if(isNaN(nwidth)) {return;} nwidth = parseInt(nwidth,10); $t.grid.width = $t.p.width = nwidth; $("#gbox_"+$.jgrid.jqID($t.p.id)).css("width",nwidth+"px"); $("#gview_"+$.jgrid.jqID($t.p.id)).css("width",nwidth+"px"); $($t.grid.bDiv).css("width",nwidth+"px"); $($t.grid.hDiv).css("width",nwidth+"px"); if($t.p.pager ) {$($t.p.pager).css("width",nwidth+"px");} if($t.p.toppager ) {$($t.p.toppager).css("width",nwidth+"px");} if($t.p.toolbar[0] === true){ $($t.grid.uDiv).css("width",nwidth+"px"); if($t.p.toolbar[1]==="both") {$($t.grid.ubDiv).css("width",nwidth+"px");} } if($t.p.footerrow) { $($t.grid.sDiv).css("width",nwidth+"px"); } if(shrink ===false && $t.p.forceFit === true) {$t.p.forceFit=false;} if(shrink===true) { $.each($t.p.colModel, function() { if(this.hidden===false){ cw = this.widthOrg; initwidth += cw+brd; if(this.fixed) { gw += cw+brd; } else { vc++; } } }); if(vc === 0) { return; } $t.p.tblwidth = initwidth; aw = nwidth-brd*vc-gw; if(!isNaN($t.p.height)) { if($($t.grid.bDiv)[0].clientHeight < $($t.grid.bDiv)[0].scrollHeight || $t.rows.length === 1){ hs = true; aw -= scw; } } initwidth =0; var cle = $t.grid.cols.length >0; $.each($t.p.colModel, function(i) { if(this.hidden === false && !this.fixed){ cw = this.widthOrg; cw = Math.round(aw*cw/($t.p.tblwidth-brd*vc-gw)); if (cw < 0) { return; } this.width =cw; initwidth += cw; $t.grid.headers[i].width=cw; $t.grid.headers[i].el.style.width=cw+"px"; if($t.p.footerrow) { $t.grid.footers[i].style.width = cw+"px"; } if(cle) { $t.grid.cols[i].style.width = cw+"px"; } lvc = i; } }); if (!lvc) { return; } cr =0; if (hs) { if(nwidth-gw-(initwidth+brd*vc) !== scw){ cr = nwidth-gw-(initwidth+brd*vc)-scw; } } else if( Math.abs(nwidth-gw-(initwidth+brd*vc)) !== 1) { cr = nwidth-gw-(initwidth+brd*vc); } $t.p.colModel[lvc].width += cr; $t.p.tblwidth = initwidth+cr+brd*vc+gw; if($t.p.tblwidth > nwidth) { var delta = $t.p.tblwidth - parseInt(nwidth,10); $t.p.tblwidth = nwidth; cw = $t.p.colModel[lvc].width = $t.p.colModel[lvc].width-delta; } else { cw= $t.p.colModel[lvc].width; } $t.grid.headers[lvc].width = cw; $t.grid.headers[lvc].el.style.width=cw+"px"; if(cle) { $t.grid.cols[lvc].style.width = cw+"px"; } if($t.p.footerrow) { $t.grid.footers[lvc].style.width = cw+"px"; } } if($t.p.tblwidth) { $('table:first',$t.grid.bDiv).css("width",$t.p.tblwidth+"px"); $('table:first',$t.grid.hDiv).css("width",$t.p.tblwidth+"px"); $t.grid.hDiv.scrollLeft = $t.grid.bDiv.scrollLeft; if($t.p.footerrow) { $('table:first',$t.grid.sDiv).css("width",$t.p.tblwidth+"px"); } } }); }, setGridHeight : function (nh) { return this.each(function (){ var $t = this; if(!$t.grid) {return;} var bDiv = $($t.grid.bDiv); bDiv.css({height: nh+(isNaN(nh)?"":"px")}); if($t.p.frozenColumns === true){ //follow the original set height to use 16, better scrollbar width detection $('#'+$.jgrid.jqID($t.p.id)+"_frozen").parent().height(bDiv.height() - 16); } $t.p.height = nh; if ($t.p.scroll) { $t.grid.populateVisible(); } }); }, setCaption : function (newcap){ return this.each(function(){ this.p.caption=newcap; $("span.ui-jqgrid-title, span.ui-jqgrid-title-rtl",this.grid.cDiv).html(newcap); $(this.grid.cDiv).show(); }); }, setLabel : function(colname, nData, prop, attrp ){ return this.each(function(){ var $t = this, pos=-1; if(!$t.grid) {return;} if(colname !== undefined) { $($t.p.colModel).each(function(i){ if (this.name === colname) { pos = i;return false; } }); } else { return; } if(pos>=0) { var thecol = $("tr.ui-jqgrid-labels th:eq("+pos+")",$t.grid.hDiv); if (nData){ var ico = $(".s-ico",thecol); $("[id^=jqgh_]",thecol).empty().html(nData).append(ico); $t.p.colNames[pos] = nData; } if (prop) { if(typeof prop === 'string') {$(thecol).addClass(prop);} else {$(thecol).css(prop);} } if(typeof attrp === 'object') {$(thecol).attr(attrp);} } }); }, setCell : function(rowid,colname,nData,cssp,attrp, forceupd) { return this.each(function(){ var $t = this, pos =-1,v, title; if(!$t.grid) {return;} if(isNaN(colname)) { $($t.p.colModel).each(function(i){ if (this.name === colname) { pos = i;return false; } }); } else {pos = parseInt(colname,10);} if(pos>=0) { var ind = $t.rows.namedItem(rowid); if (ind){ var tcell = $("td:eq("+pos+")",ind); if(nData !== "" || forceupd === true) { v = $t.formatter(rowid, nData, pos,ind,'edit'); title = $t.p.colModel[pos].title ? {"title":$.jgrid.stripHtml(v)} : {}; if($t.p.treeGrid && $(".tree-wrap",$(tcell)).length>0) { $("span",$(tcell)).html(v).attr(title); } else { $(tcell).html(v).attr(title); } if($t.p.datatype === "local") { var cm = $t.p.colModel[pos], index; nData = cm.formatter && typeof cm.formatter === 'string' && cm.formatter === 'date' ? $.unformat.date.call($t,nData,cm) : nData; index = $t.p._index[$.jgrid.stripPref($t.p.idPrefix, rowid)]; if(index !== undefined) { $t.p.data[index][cm.name] = nData; } } } if(typeof cssp === 'string'){ $(tcell).addClass(cssp); } else if(cssp) { $(tcell).css(cssp); } if(typeof attrp === 'object') {$(tcell).attr(attrp);} } } }); }, getCell : function(rowid,col) { var ret = false; this.each(function(){ var $t=this, pos=-1; if(!$t.grid) {return;} if(isNaN(col)) { $($t.p.colModel).each(function(i){ if (this.name === col) { pos = i;return false; } }); } else {pos = parseInt(col,10);} if(pos>=0) { var ind = $t.rows.namedItem(rowid); if(ind) { try { ret = $.unformat.call($t,$("td:eq("+pos+")",ind),{rowId:ind.id, colModel:$t.p.colModel[pos]},pos); } catch (e){ ret = $.jgrid.htmlDecode($("td:eq("+pos+")",ind).html()); } } } }); return ret; }, getCol : function (col, obj, mathopr) { var ret = [], val, sum=0, min, max, v; obj = typeof obj !== 'boolean' ? false : obj; if(mathopr === undefined) { mathopr = false; } this.each(function(){ var $t=this, pos=-1; if(!$t.grid) {return;} if(isNaN(col)) { $($t.p.colModel).each(function(i){ if (this.name === col) { pos = i;return false; } }); } else {pos = parseInt(col,10);} if(pos>=0) { var ln = $t.rows.length, i =0; if (ln && ln>0){ while(i= 0 ) { ret = this.p.data[ind]; } } }); return ret; } }); })(jQuery); /*jshint eqeqeq:false */ /*global jQuery */ (function($){ /** * jqGrid extension for custom methods * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * * Wildraid wildraid@mail.ru * Oleg Kiriljuk oleg.kiriljuk@ok-soft-gmbh.com * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl-2.0.html **/ "use strict"; $.jgrid.extend({ getColProp : function(colname){ var ret ={}, $t = this[0]; if ( !$t.grid ) { return false; } var cM = $t.p.colModel, i; for ( i=0;i","ge":">=","bw":"^","bn":"!^","in":"=","ni":"!=","ew":"|","en":"!@","cn":"~","nc":"!~","nu":"#","nn":"!#"} }, $.jgrid.search , p || {}); return this.each(function(){ var $t = this; if(this.ftoolbar) { return; } var triggerToolbar = function() { var sdata={}, j=0, v, nm, sopt={},so; $.each($t.p.colModel,function(){ var $elem = $("#gs_"+$.jgrid.jqID(this.name), (this.frozen===true && $t.p.frozenColumns === true) ? $t.grid.fhDiv : $t.grid.hDiv); nm = this.index || this.name; if(p.searchOperators ) { so = $elem.parent().prev().children("a").attr("soper") || p.defaultSearch; } else { so = (this.searchoptions && this.searchoptions.sopt) ? this.searchoptions.sopt[0] : this.stype==='select'? 'eq' : p.defaultSearch; } v = this.stype === "custom" && $.isFunction(this.searchoptions.custom_value) && $elem.length > 0 && $elem[0].nodeName.toUpperCase() === "SPAN" ? this.searchoptions.custom_value.call($t, $elem.children(".customelement:first"), "get") : $elem.val(); if(v || so==="nu" || so==="nn") { sdata[nm] = v; sopt[nm] = so; j++; } else { try { delete $t.p.postData[nm]; } catch (z) {} } }); var sd = j>0 ? true : false; if(p.stringResult === true || $t.p.datatype === "local") { var ruleGroup = "{\"groupOp\":\"" + p.groupOp + "\",\"rules\":["; var gi=0; $.each(sdata,function(i,n){ if (gi > 0) {ruleGroup += ",";} ruleGroup += "{\"field\":\"" + i + "\","; ruleGroup += "\"op\":\"" + sopt[i] + "\","; n+=""; ruleGroup += "\"data\":\"" + n.replace(/\\/g,'\\\\').replace(/\"/g,'\\"') + "\"}"; gi++; }); ruleGroup += "]}"; $.extend($t.p.postData,{filters:ruleGroup}); $.each(['searchField', 'searchString', 'searchOper'], function(i, n){ if($t.p.postData.hasOwnProperty(n)) { delete $t.p.postData[n];} }); } else { $.extend($t.p.postData,sdata); } var saveurl; if($t.p.searchurl) { saveurl = $t.p.url; $($t).jqGrid("setGridParam",{url:$t.p.searchurl}); } var bsr = $($t).triggerHandler("jqGridToolbarBeforeSearch") === 'stop' ? true : false; if(!bsr && $.isFunction(p.beforeSearch)){bsr = p.beforeSearch.call($t);} if(!bsr) { $($t).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]); } if(saveurl) {$($t).jqGrid("setGridParam",{url:saveurl});} $($t).triggerHandler("jqGridToolbarAfterSearch"); if($.isFunction(p.afterSearch)){p.afterSearch.call($t);} }, clearToolbar = function(trigger){ var sdata={}, j=0, nm; trigger = (typeof trigger !== 'boolean') ? true : trigger; $.each($t.p.colModel,function(){ var v, $elem = $("#gs_"+$.jgrid.jqID(this.name),(this.frozen===true && $t.p.frozenColumns === true) ? $t.grid.fhDiv : $t.grid.hDiv); if(this.searchoptions && this.searchoptions.defaultValue !== undefined) { v = this.searchoptions.defaultValue; } nm = this.index || this.name; switch (this.stype) { case 'select' : $elem.find("option").each(function (i){ if(i===0) { this.selected = true; } if ($(this).val() === v) { this.selected = true; return false; } }); if ( v !== undefined ) { // post the key and not the text sdata[nm] = v; j++; } else { try { delete $t.p.postData[nm]; } catch(e) {} } break; case 'text': $elem.val(v); if(v !== undefined) { sdata[nm] = v; j++; } else { try { delete $t.p.postData[nm]; } catch (y){} } break; case 'custom': if ($.isFunction(this.searchoptions.custom_value) && $elem.length > 0 && $elem[0].nodeName.toUpperCase() === "SPAN") { this.searchoptions.custom_value.call($t, $elem.children(".customelement:first"), "set", v); } break; } }); var sd = j>0 ? true : false; if(p.stringResult === true || $t.p.datatype === "local") { var ruleGroup = "{\"groupOp\":\"" + p.groupOp + "\",\"rules\":["; var gi=0; $.each(sdata,function(i,n){ if (gi > 0) {ruleGroup += ",";} ruleGroup += "{\"field\":\"" + i + "\","; ruleGroup += "\"op\":\"" + "eq" + "\","; n+=""; ruleGroup += "\"data\":\"" + n.replace(/\\/g,'\\\\').replace(/\"/g,'\\"') + "\"}"; gi++; }); ruleGroup += "]}"; $.extend($t.p.postData,{filters:ruleGroup}); $.each(['searchField', 'searchString', 'searchOper'], function(i, n){ if($t.p.postData.hasOwnProperty(n)) { delete $t.p.postData[n];} }); } else { $.extend($t.p.postData,sdata); } var saveurl; if($t.p.searchurl) { saveurl = $t.p.url; $($t).jqGrid("setGridParam",{url:$t.p.searchurl}); } var bcv = $($t).triggerHandler("jqGridToolbarBeforeClear") === 'stop' ? true : false; if(!bcv && $.isFunction(p.beforeClear)){bcv = p.beforeClear.call($t);} if(!bcv) { if(trigger) { $($t).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]); } } if(saveurl) {$($t).jqGrid("setGridParam",{url:saveurl});} $($t).triggerHandler("jqGridToolbarAfterClear"); if($.isFunction(p.afterClear)){p.afterClear();} }, toggleToolbar = function(){ var trow = $("tr.ui-search-toolbar",$t.grid.hDiv), trow2 = $t.p.frozenColumns === true ? $("tr.ui-search-toolbar",$t.grid.fhDiv) : false; if(trow.css("display") === 'none') { trow.show(); if(trow2) { trow2.show(); } } else { trow.hide(); if(trow2) { trow2.hide(); } } }, buildRuleMenu = function( elem, left, top ){ $("#sopt_menu").remove(); left=parseInt(left,10); top=parseInt(top,10) + 18; var fs = $('.ui-jqgrid-view').css('font-size') || '11px'; var str = '
    "; $('body').append(str); $("#sopt_menu").addClass("ui-menu ui-widget ui-widget-content ui-corner-all"); $("#sopt_menu > li > a").hover( function(){ $(this).addClass("ui-state-hover"); }, function(){ $(this).removeClass("ui-state-hover"); } ).click(function( e ){ var v = $(this).attr("value"), oper = $(this).attr("oper"); $($t).triggerHandler("jqGridToolbarSelectOper", [v, oper, elem]); $("#sopt_menu").hide(); $(elem).text(oper).attr("soper",v); if(p.autosearch===true){ var inpelm = $(elem).parent().next().children()[0]; if( $(inpelm).val() || v==="nu" || v ==="nn") { triggerToolbar(); } } }); }; // create the row var tr = $(""); var timeoutHnd; $.each($t.p.colModel,function(){ var cm=this, soptions, surl, self, select = "", sot="=", so, i, th = $(""), thd = $("
    "), stbl = $("
    "); if(this.hidden===true) { $(th).css("display","none");} this.search = this.search === false ? false : true; if(this.stype === undefined) {this.stype='text';} soptions = $.extend({},this.searchoptions || {}); if(this.search){ if(p.searchOperators) { so = (soptions.sopt) ? soptions.sopt[0] : cm.stype==='select' ? 'eq' : p.defaultSearch; for(i = 0;i"+sot+""; } $("td:eq(0)",stbl).append(select); switch (this.stype) { case "select": surl = this.surl || soptions.dataUrl; if(surl) { // data returned should have already constructed html select // primitive jQuery load self = thd; $.ajax($.extend({ url: surl, dataType: "html", success: function(res) { if(soptions.buildSelect !== undefined) { var d = soptions.buildSelect(res); if (d) { $("td:eq(1)",stbl).append(d); $(self).append(stbl); } } else { $("td:eq(1)",stbl).append(res); $(self).append(stbl); } if(soptions.defaultValue !== undefined) { $("select",self).val(soptions.defaultValue); } $("select",self).attr({name:cm.index || cm.name, id: "gs_"+cm.name}); if(soptions.attr) {$("select",self).attr(soptions.attr);} $("select",self).css({width: "100%"}); // preserve autoserch $.jgrid.bindEv.call($t, $("select",self)[0], soptions); if(p.autosearch===true){ $("select",self).change(function(){ triggerToolbar(); return false; }); } res=null; } }, $.jgrid.ajaxOptions, $t.p.ajaxSelectOptions || {} )); } else { var oSv, sep, delim; if(cm.searchoptions) { oSv = cm.searchoptions.value === undefined ? "" : cm.searchoptions.value; sep = cm.searchoptions.separator === undefined ? ":" : cm.searchoptions.separator; delim = cm.searchoptions.delimiter === undefined ? ";" : cm.searchoptions.delimiter; } else if(cm.editoptions) { oSv = cm.editoptions.value === undefined ? "" : cm.editoptions.value; sep = cm.editoptions.separator === undefined ? ":" : cm.editoptions.separator; delim = cm.editoptions.delimiter === undefined ? ";" : cm.editoptions.delimiter; } if (oSv) { var elem = document.createElement("select"); elem.style.width = "100%"; $(elem).attr({name:cm.index || cm.name, id: "gs_"+cm.name}); var sv, ov, key, k; if(typeof oSv === "string") { so = oSv.split(delim); for(k=0; k"); $(thd).append(stbl); if(soptions.attr) {$("input",thd).attr(soptions.attr);} $.jgrid.bindEv.call($t, $("input",thd)[0], soptions); if(p.autosearch===true){ if(p.searchOnEnter) { $("input",thd).keypress(function(e){ var key = e.charCode || e.keyCode || 0; if(key === 13){ triggerToolbar(); return false; } return this; }); } else { $("input",thd).keydown(function(e){ var key = e.which; switch (key) { case 13: return false; case 9 : case 16: case 37: case 38: case 39: case 40: case 27: break; default : if(timeoutHnd) { clearTimeout(timeoutHnd); } timeoutHnd = setTimeout(function(){triggerToolbar();},500); } }); } } break; case "custom": $("td:eq(1)",stbl).append(""); $(thd).append(stbl); try { if($.isFunction(soptions.custom_element)) { var celm = soptions.custom_element.call($t,soptions.defaultValue !== undefined ? soptions.defaultValue: "",soptions); if(celm) { celm = $(celm).addClass("customelement"); $(thd).find(">span").append(celm); } else { throw "e2"; } } else { throw "e1"; } } catch (e) { if (e === "e1") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_element' "+$.jgrid.edit.msg.nodefined,$.jgrid.edit.bClose);} if (e === "e2") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_element' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose);} else { $.jgrid.info_dialog($.jgrid.errors.errcap,typeof e==="string"?e:e.message,$.jgrid.edit.bClose); } } break; } } $(th).append(thd); $(tr).append(th); if(!p.searchOperators) { $("td:eq(0)",stbl).hide(); } }); $("table thead",$t.grid.hDiv).append(tr); if(p.searchOperators) { $(".soptclass").click(function(e){ var offset = $(this).offset(), left = ( offset.left ), top = ( offset.top); buildRuleMenu(this, left, top ); e.stopPropagation(); }); $("body").on('click', function(e){ if(e.target.className !== "soptclass") { $("#sopt_menu").hide(); } }); } this.ftoolbar = true; this.triggerToolbar = triggerToolbar; this.clearToolbar = clearToolbar; this.toggleToolbar = toggleToolbar; }); }, destroyFilterToolbar: function () { return this.each(function () { if (!this.ftoolbar) { return; } this.triggerToolbar = null; this.clearToolbar = null; this.toggleToolbar = null; this.ftoolbar = false; $(this.grid.hDiv).find("table thead tr.ui-search-toolbar").remove(); }); }, destroyGroupHeader : function(nullHeader) { if(nullHeader === undefined) { nullHeader = true; } return this.each(function() { var $t = this, $tr, i, l, headers, $th, $resizing, grid = $t.grid, thead = $("table.ui-jqgrid-htable thead", grid.hDiv), cm = $t.p.colModel, hc; if(!grid) { return; } $(this).unbind('.setGroupHeaders'); $tr = $("", {role: "rowheader"}).addClass("ui-jqgrid-labels"); headers = grid.headers; for (i = 0, l = headers.length; i < l; i++) { hc = cm[i].hidden ? "none" : ""; $th = $(headers[i].el) .width(headers[i].width) .css('display',hc); try { $th.removeAttr("rowSpan"); } catch (rs) { //IE 6/7 $th.attr("rowSpan",1); } $tr.append($th); $resizing = $th.children("span.ui-jqgrid-resize"); if ($resizing.length>0) {// resizable column $resizing[0].style.height = ""; } $th.children("div")[0].style.top = ""; } $(thead).children('tr.ui-jqgrid-labels').remove(); $(thead).prepend($tr); if(nullHeader === true) { $($t).jqGrid('setGridParam',{ 'groupHeader': null}); } }); }, setGroupHeaders : function ( o ) { o = $.extend({ useColSpanStyle : false, groupHeaders: [] },o || {}); return this.each(function(){ this.p.groupHeader = o; var ts = this, i, cmi, skip = 0, $tr, $colHeader, th, $th, thStyle, iCol, cghi, //startColumnName, numberOfColumns, titleText, cVisibleColumns, colModel = ts.p.colModel, cml = colModel.length, ths = ts.grid.headers, $htable = $("table.ui-jqgrid-htable", ts.grid.hDiv), $trLabels = $htable.children("thead").children("tr.ui-jqgrid-labels:last").addClass("jqg-second-row-header"), $thead = $htable.children("thead"), $theadInTable, $firstHeaderRow = $htable.find(".jqg-first-row-header"); if($firstHeaderRow[0] === undefined) { $firstHeaderRow = $('', {role: "row", "aria-hidden": "true"}).addClass("jqg-first-row-header").css("height", "auto"); } else { $firstHeaderRow.empty(); } var $firstRow, inColumnHeader = function (text, columnHeaders) { var length = columnHeaders.length, i; for (i = 0; i < length; i++) { if (columnHeaders[i].startColumnName === text) { return i; } } return -1; }; $(ts).prepend($thead); $tr = $('', {role: "rowheader"}).addClass("ui-jqgrid-labels jqg-third-row-header"); for (i = 0; i < cml; i++) { th = ths[i].el; $th = $(th); cmi = colModel[i]; // build the next cell for the first header row thStyle = { height: '0px', width: ths[i].width + 'px', display: (cmi.hidden ? 'none' : '')}; $("", {role: 'gridcell'}).css(thStyle).addClass("ui-first-th-"+ts.p.direction).appendTo($firstHeaderRow); th.style.width = ""; // remove unneeded style iCol = inColumnHeader(cmi.name, o.groupHeaders); if (iCol >= 0) { cghi = o.groupHeaders[iCol]; numberOfColumns = cghi.numberOfColumns; titleText = cghi.titleText; // caclulate the number of visible columns from the next numberOfColumns columns for (cVisibleColumns = 0, iCol = 0; iCol < numberOfColumns && (i + iCol < cml); iCol++) { if (!colModel[i + iCol].hidden) { cVisibleColumns++; } } // The next numberOfColumns headers will be moved in the next row // in the current row will be placed the new column header with the titleText. // The text will be over the cVisibleColumns columns $colHeader = $('').attr({role: "columnheader"}) .addClass("ui-state-default ui-th-column-header ui-th-"+ts.p.direction) .css({'height':'22px', 'border-top': '0px none'}) .html(titleText); if(cVisibleColumns > 0) { $colHeader.attr("colspan", String(cVisibleColumns)); } if (ts.p.headertitles) { $colHeader.attr("title", $colHeader.text()); } // hide if not a visible cols if( cVisibleColumns === 0) { $colHeader.hide(); } $th.before($colHeader); // insert new column header before the current $tr.append(th); // move the current header in the next row // set the coumter of headers which will be moved in the next row skip = numberOfColumns - 1; } else { if (skip === 0) { if (o.useColSpanStyle) { // expand the header height to two rows $th.attr("rowspan", "2"); } else { $('', {role: "columnheader"}) .addClass("ui-state-default ui-th-column-header ui-th-"+ts.p.direction) .css({"display": cmi.hidden ? 'none' : '', 'border-top': '0px none'}) .insertBefore($th); $tr.append(th); } } else { // move the header to the next row //$th.css({"padding-top": "2px", height: "19px"}); $tr.append(th); skip--; } } } $theadInTable = $(ts).children("thead"); $theadInTable.prepend($firstHeaderRow); $tr.insertAfter($trLabels); $htable.append($theadInTable); if (o.useColSpanStyle) { // Increase the height of resizing span of visible headers $htable.find("span.ui-jqgrid-resize").each(function () { var $parent = $(this).parent(); if ($parent.is(":visible")) { this.style.cssText = 'height: ' + $parent.height() + 'px !important; cursor: col-resize;'; } }); // Set position of the sortable div (the main lable) // with the column header text to the middle of the cell. // One should not do this for hidden headers. $htable.find("div.ui-jqgrid-sortable").each(function () { var $ts = $(this), $parent = $ts.parent(); if ($parent.is(":visible") && $parent.is(":has(span.ui-jqgrid-resize)")) { $ts.css('top', ($parent.height() - $ts.outerHeight()) / 2 + 'px'); } }); } $firstRow = $theadInTable.find("tr.jqg-first-row-header"); $(ts).bind('jqGridResizeStop.setGroupHeaders', function (e, nw, idx) { $firstRow.find('th').eq(idx).width(nw); }); }); }, setFrozenColumns : function () { return this.each(function() { if ( !this.grid ) {return;} var $t = this, cm = $t.p.colModel,i=0, len = cm.length, maxfrozen = -1, frozen= false; // TODO treeGrid and grouping Support if($t.p.subGrid === true || $t.p.treeGrid === true || $t.p.cellEdit === true || $t.p.sortable || $t.p.scroll || $t.p.grouping ) { return; } if($t.p.rownumbers) { i++; } if($t.p.multiselect) { i++; } // get the max index of frozen col while(i=0 && frozen) { var top = $t.p.caption ? $($t.grid.cDiv).outerHeight() : 0, hth = $(".ui-jqgrid-htable","#gview_"+$.jgrid.jqID($t.p.id)).height(); //headers if($t.p.toppager) { top = top + $($t.grid.topDiv).outerHeight(); } if($t.p.toolbar[0] === true) { if($t.p.toolbar[1] !== "bottom") { top = top + $($t.grid.uDiv).outerHeight(); } } $t.grid.fhDiv = $('
    '); $t.grid.fbDiv = $('
    '); $("#gview_"+$.jgrid.jqID($t.p.id)).append($t.grid.fhDiv); var htbl = $(".ui-jqgrid-htable","#gview_"+$.jgrid.jqID($t.p.id)).clone(true); // groupheader support - only if useColSpanstyle is false if($t.p.groupHeader) { $("tr.jqg-first-row-header, tr.jqg-third-row-header", htbl).each(function(){ $("th:gt("+maxfrozen+")",this).remove(); }); var swapfroz = -1, fdel = -1, cs, rs; $("tr.jqg-second-row-header th", htbl).each(function(){ cs= parseInt($(this).attr("colspan"),10); rs= parseInt($(this).attr("rowspan"),10); if(rs) { swapfroz++; fdel++; } if(cs) { swapfroz = swapfroz+cs; fdel++; } if(swapfroz === maxfrozen) { return false; } }); if(swapfroz !== maxfrozen) { fdel = maxfrozen; } $("tr.jqg-second-row-header", htbl).each(function(){ $("th:gt("+fdel+")",this).remove(); }); } else { $("tr",htbl).each(function(){ $("th:gt("+maxfrozen+")",this).remove(); }); } $(htbl).width(1); // resizing stuff $($t.grid.fhDiv).append(htbl) .mousemove(function (e) { if($t.grid.resizing){ $t.grid.dragMove(e);return false; } }); $($t).bind('jqGridResizeStop.setFrozenColumns', function (e, w, index) { var rhth = $(".ui-jqgrid-htable",$t.grid.fhDiv); $("th:eq("+index+")",rhth).width( w ); var btd = $(".ui-jqgrid-btable",$t.grid.fbDiv); $("tr:first td:eq("+index+")",btd).width( w ); }); // sorting stuff $($t).bind('jqGridOnSortCol.setFrozenColumns', function (e, index, idxcol) { var previousSelectedTh = $("tr.ui-jqgrid-labels:last th:eq("+$t.p.lastsort+")",$t.grid.fhDiv), newSelectedTh = $("tr.ui-jqgrid-labels:last th:eq("+idxcol+")",$t.grid.fhDiv); $("span.ui-grid-ico-sort",previousSelectedTh).addClass('ui-state-disabled'); $(previousSelectedTh).attr("aria-selected","false"); $("span.ui-icon-"+$t.p.sortorder,newSelectedTh).removeClass('ui-state-disabled'); $(newSelectedTh).attr("aria-selected","true"); if(!$t.p.viewsortcols[0]) { if($t.p.lastsort !== idxcol) { $("span.s-ico",previousSelectedTh).hide(); $("span.s-ico",newSelectedTh).show(); } } }); // data stuff //TODO support for setRowData $("#gview_"+$.jgrid.jqID($t.p.id)).append($t.grid.fbDiv); $($t.grid.bDiv).scroll(function () { $($t.grid.fbDiv).scrollTop($(this).scrollTop()); }); if($t.p.hoverrows === true) { $("#"+$.jgrid.jqID($t.p.id)).unbind('mouseover').unbind('mouseout'); } $($t).bind('jqGridAfterGridComplete.setFrozenColumns', function () { $("#"+$.jgrid.jqID($t.p.id)+"_frozen").remove(); $($t.grid.fbDiv).height($($t.grid.bDiv).height()-16); var btbl = $("#"+$.jgrid.jqID($t.p.id)).clone(true); $("tr",btbl).each(function(){ $("td:gt("+maxfrozen+")",this).remove(); }); $(btbl).width(1).attr("id",$t.p.id+"_frozen"); $($t.grid.fbDiv).append(btbl); if($t.p.hoverrows === true) { $("tr.jqgrow", btbl).hover( function(){ $(this).addClass("ui-state-hover"); $("#"+$.jgrid.jqID(this.id), "#"+$.jgrid.jqID($t.p.id)).addClass("ui-state-hover"); }, function(){ $(this).removeClass("ui-state-hover"); $("#"+$.jgrid.jqID(this.id), "#"+$.jgrid.jqID($t.p.id)).removeClass("ui-state-hover"); } ); $("tr.jqgrow", "#"+$.jgrid.jqID($t.p.id)).hover( function(){ $(this).addClass("ui-state-hover"); $("#"+$.jgrid.jqID(this.id), "#"+$.jgrid.jqID($t.p.id)+"_frozen").addClass("ui-state-hover");}, function(){ $(this).removeClass("ui-state-hover"); $("#"+$.jgrid.jqID(this.id), "#"+$.jgrid.jqID($t.p.id)+"_frozen").removeClass("ui-state-hover"); } ); } btbl=null; }); $t.p.frozenColumns = true; } }); }, destroyFrozenColumns : function() { return this.each(function() { if ( !this.grid ) {return;} if(this.p.frozenColumns === true) { var $t = this; $($t.grid.fhDiv).remove(); $($t.grid.fbDiv).remove(); $t.grid.fhDiv = null; $t.grid.fbDiv=null; $(this).unbind('.setFrozenColumns'); if($t.p.hoverrows === true) { var ptr; $("#"+$.jgrid.jqID($t.p.id)).bind('mouseover',function(e) { ptr = $(e.target).closest("tr.jqgrow"); if($(ptr).attr("class") !== "ui-subgrid") { $(ptr).addClass("ui-state-hover"); } }).bind('mouseout',function(e) { ptr = $(e.target).closest("tr.jqgrow"); $(ptr).removeClass("ui-state-hover"); }); } this.p.frozenColumns = false; } }); } }); })(jQuery); /* * jqModal - Minimalist Modaling with jQuery * (http://dev.iceburg.net/jquery/jqmodal/) * * Copyright (c) 2007,2008 Brice Burgess * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * $Version: 07/06/2008 +r13 */ (function($) { $.fn.jqm=function(o){ var p={ overlay: 50, closeoverlay : true, overlayClass: 'jqmOverlay', closeClass: 'jqmClose', trigger: '.jqModal', ajax: F, ajaxText: '', target: F, modal: F, toTop: F, onShow: F, onHide: F, onLoad: F }; return this.each(function(){if(this._jqm)return H[this._jqm].c=$.extend({},H[this._jqm].c,o);s++;this._jqm=s; H[s]={c:$.extend(p,$.jqm.params,o),a:F,w:$(this).addClass('jqmID'+s),s:s}; if(p.trigger)$(this).jqmAddTrigger(p.trigger); });}; $.fn.jqmAddClose=function(e){return hs(this,e,'jqmHide');}; $.fn.jqmAddTrigger=function(e){return hs(this,e,'jqmShow');}; $.fn.jqmShow=function(t){return this.each(function(){$.jqm.open(this._jqm,t);});}; $.fn.jqmHide=function(t){return this.each(function(){$.jqm.close(this._jqm,t)});}; $.jqm = { hash:{}, open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(parseInt(h.w.css('z-index')));z=(z>0)?z:3000;var o=$('
    ').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});if(h.a)return F;h.t=t;h.a=true;h.w.css('z-index',z); if(c.modal) {if(!A[0])setTimeout(function(){L('bind');},1);A.push(s);} else if(c.overlay > 0) {if(c.closeoverlay) h.w.jqmAddClose(o);} else o=F; h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):F; if(c.ajax) {var r=c.target||h.w,u=c.ajax;r=(typeof r == 'string')?$(r,h.w):$(r);u=(u.substr(0,1) == '@')?$(t).attr(u.substring(1)):u; r.html(c.ajaxText).load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});} else if(cc)h.w.jqmAddClose($(cc,h.w)); if(c.toTop&&h.o)h.w.before('').insertAfter(h.o); (c.onShow)?c.onShow(h):h.w.show();e(h);return F; }, close:function(s){var h=H[s];if(!h.a)return F;h.a=F; if(A[0]){A.pop();if(!A[0])L('unbind');} if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove(); if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();} return F; }, params:{}}; var s=0,H=$.jqm.hash,A=[],F=false, e=function(h){f(h);}, f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(_){}}, L=function(t){$(document)[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);}, m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r){$('.jqmID'+h.s).each(function(){var $self=$(this),offset=$self.offset();if(offset.top<=e.pageY && e.pageY<=offset.top+$self.height() && offset.left<=e.pageX && e.pageX<=offset.left+$self.width()){r=false;return false;}});f(h);}return !r;}, hs=function(w,t,c){return w.each(function(){var s=this._jqm;$(t).each(function() { if(!this[c]){this[c]=[];$(this).click(function(){for(var i in {jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return F;});}this[c].push(s);});});}; })(jQuery);/* * jqDnR - Minimalistic Drag'n'Resize for jQuery. * * Copyright (c) 2007 Brice Burgess , http://www.iceburg.net * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php * * $Version: 2007.08.19 +r2 */ (function($){ $.fn.jqDrag=function(h){return i(this,h,'d');}; $.fn.jqResize=function(h,ar){return i(this,h,'r',ar);}; $.jqDnR={ dnr:{}, e:0, drag:function(v){ if(M.k == 'd'){E.css({left:M.X+v.pageX-M.pX,top:M.Y+v.pageY-M.pY});} else { E.css({width:Math.max(v.pageX-M.pX+M.W,0),height:Math.max(v.pageY-M.pY+M.H,0)}); if(M1){E1.css({width:Math.max(v.pageX-M1.pX+M1.W,0),height:Math.max(v.pageY-M1.pY+M1.H,0)});} } return false; }, stop:function(){ //E.css('opacity',M.o); $(document).unbind('mousemove',J.drag).unbind('mouseup',J.stop); } }; var J=$.jqDnR,M=J.dnr,E=J.e,E1,M1, i=function(e,h,k,aR){ return e.each(function(){ h=(h)?$(h,e):e; h.bind('mousedown',{e:e,k:k},function(v){ var d=v.data,p={};E=d.e;E1 = aR ? $(aR) : false; // attempt utilization of dimensions plugin to fix IE issues if(E.css('position') != 'relative'){try{E.position(p);}catch(e){}} M={ X:p.left||f('left')||0, Y:p.top||f('top')||0, W:f('width')||E[0].scrollWidth||0, H:f('height')||E[0].scrollHeight||0, pX:v.pageX, pY:v.pageY, k:d.k //o:E.css('opacity') }; // also resize if(E1 && d.k != 'd'){ M1={ X:p.left||f1('left')||0, Y:p.top||f1('top')||0, W:E1[0].offsetWidth||f1('width')||0, H:E1[0].offsetHeight||f1('height')||0, pX:v.pageX, pY:v.pageY, k:d.k }; } else {M1 = false;} //E.css({opacity:0.8}); if($("input.hasDatepicker",E[0])[0]) { try {$("input.hasDatepicker",E[0]).datepicker('hide');}catch (dpe){} } $(document).mousemove($.jqDnR.drag).mouseup($.jqDnR.stop); return false; }); }); }, f=function(k){return parseInt(E.css(k),10)||false;}, f1=function(k){return parseInt(E1.css(k),10)||false;}; })(jQuery);/* The below work is licensed under Creative Commons GNU LGPL License. Original work: License: http://creativecommons.org/licenses/LGPL/2.1/ Author: Stefan Goessner/2006 Web: http://goessner.net/ Modifications made: Version: 0.9-p5 Description: Restructured code, JSLint validated (no strict whitespaces), added handling of empty arrays, empty strings, and int/floats values. Author: Michael Schøler/2008-01-29 Web: http://michael.hinnerup.net/blog/2008/01/26/converting-json-to-xml-and-xml-to-json/ Description: json2xml added support to convert functions as CDATA so it will be easy to write characters that cause some problems when convert Author: Tony Tomov */ /*global alert */ var xmlJsonClass = { // Param "xml": Element or document DOM node. // Param "tab": Tab or indent string for pretty output formatting omit or use empty string "" to supress. // Returns: JSON string xml2json: function(xml, tab) { if (xml.nodeType === 9) { // document node xml = xml.documentElement; } var nws = this.removeWhite(xml); var obj = this.toObj(nws); var json = this.toJson(obj, xml.nodeName, "\t"); return "{\n" + tab + (tab ? json.replace(/\t/g, tab) : json.replace(/\t|\n/g, "")) + "\n}"; }, // Param "o": JavaScript object // Param "tab": tab or indent string for pretty output formatting omit or use empty string "" to supress. // Returns: XML string json2xml: function(o, tab) { var toXml = function(v, name, ind) { var xml = ""; var i, n; if (v instanceof Array) { if (v.length === 0) { xml += ind + "<"+name+">__EMPTY_ARRAY_\n"; } else { for (i = 0, n = v.length; i < n; i += 1) { var sXml = ind + toXml(v[i], name, ind+"\t") + "\n"; xml += sXml; } } } else if (typeof(v) === "object") { var hasChild = false; xml += ind + "<" + name; var m; for (m in v) if (v.hasOwnProperty(m)) { if (m.charAt(0) === "@") { xml += " " + m.substr(1) + "=\"" + v[m].toString() + "\""; } else { hasChild = true; } } xml += hasChild ? ">" : "/>"; if (hasChild) { for (m in v) if (v.hasOwnProperty(m)) { if (m === "#text") { xml += v[m]; } else if (m === "#cdata") { xml += ""; } else if (m.charAt(0) !== "@") { xml += toXml(v[m], m, ind+"\t"); } } xml += (xml.charAt(xml.length - 1) === "\n" ? ind : "") + ""; } } else if (typeof(v) === "function") { xml += ind + "<" + name + ">" + "" + ""; } else { if (v === undefined ) { v = ""; } if (v.toString() === "\"\"" || v.toString().length === 0) { xml += ind + "<" + name + ">__EMPTY_STRING_"; } else { xml += ind + "<" + name + ">" + v.toString() + ""; } } return xml; }; var xml = ""; var m; for (m in o) if (o.hasOwnProperty(m)) { xml += toXml(o[m], m, ""); } return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, ""); }, // Internal methods toObj: function(xml) { var o = {}; var FuncTest = /function/i; if (xml.nodeType === 1) { // element node .. if (xml.attributes.length) { // element with attributes .. var i; for (i = 0; i < xml.attributes.length; i += 1) { o["@" + xml.attributes[i].nodeName] = (xml.attributes[i].nodeValue || "").toString(); } } if (xml.firstChild) { // element has child nodes .. var textChild = 0, cdataChild = 0, hasElementChild = false; var n; for (n = xml.firstChild; n; n = n.nextSibling) { if (n.nodeType === 1) { hasElementChild = true; } else if (n.nodeType === 3 && n.nodeValue.match(/[^ \f\n\r\t\v]/)) { // non-whitespace text textChild += 1; } else if (n.nodeType === 4) { // cdata section node cdataChild += 1; } } if (hasElementChild) { if (textChild < 2 && cdataChild < 2) { // structured element with evtl. a single text or/and cdata node .. this.removeWhite(xml); for (n = xml.firstChild; n; n = n.nextSibling) { if (n.nodeType === 3) { // text node o["#text"] = this.escape(n.nodeValue); } else if (n.nodeType === 4) { // cdata node if (FuncTest.test(n.nodeValue)) { o[n.nodeName] = [o[n.nodeName], n.nodeValue]; } else { o["#cdata"] = this.escape(n.nodeValue); } } else if (o[n.nodeName]) { // multiple occurence of element .. if (o[n.nodeName] instanceof Array) { o[n.nodeName][o[n.nodeName].length] = this.toObj(n); } else { o[n.nodeName] = [o[n.nodeName], this.toObj(n)]; } } else { // first occurence of element .. o[n.nodeName] = this.toObj(n); } } } else { // mixed content if (!xml.attributes.length) { o = this.escape(this.innerXml(xml)); } else { o["#text"] = this.escape(this.innerXml(xml)); } } } else if (textChild) { // pure text if (!xml.attributes.length) { o = this.escape(this.innerXml(xml)); if (o === "__EMPTY_ARRAY_") { o = "[]"; } else if (o === "__EMPTY_STRING_") { o = ""; } } else { o["#text"] = this.escape(this.innerXml(xml)); } } else if (cdataChild) { // cdata if (cdataChild > 1) { o = this.escape(this.innerXml(xml)); } else { for (n = xml.firstChild; n; n = n.nextSibling) { if(FuncTest.test(xml.firstChild.nodeValue)) { o = xml.firstChild.nodeValue; break; } else { o["#cdata"] = this.escape(n.nodeValue); } } } } } if (!xml.attributes.length && !xml.firstChild) { o = null; } } else if (xml.nodeType === 9) { // document.node o = this.toObj(xml.documentElement); } else { alert("unhandled node type: " + xml.nodeType); } return o; }, toJson: function(o, name, ind, wellform) { if(wellform === undefined) wellform = true; var json = name ? ("\"" + name + "\"") : "", tab = "\t", newline = "\n"; if(!wellform) { tab= ""; newline= ""; } if (o === "[]") { json += (name ? ":[]" : "[]"); } else if (o instanceof Array) { var n, i, ar=[]; for (i = 0, n = o.length; i < n; i += 1) { ar[i] = this.toJson(o[i], "", ind + tab, wellform); } json += (name ? ":[" : "[") + (ar.length > 1 ? (newline + ind + tab + ar.join(","+newline + ind + tab) + newline + ind) : ar.join("")) + "]"; } else if (o === null) { json += (name && ":") + "null"; } else if (typeof(o) === "object") { var arr = [], m; for (m in o) { if (o.hasOwnProperty(m)) { arr[arr.length] = this.toJson(o[m], m, ind + tab, wellform); } } json += (name ? ":{" : "{") + (arr.length > 1 ? (newline + ind + tab + arr.join(","+newline + ind + tab) + newline + ind) : arr.join("")) + "}"; } else if (typeof(o) === "string") { /* var objRegExp = /(^-?\d+\.?\d*$)/; var FuncTest = /function/i; var os = o.toString(); if (objRegExp.test(os) || FuncTest.test(os) || os==="false" || os==="true") { // int or float json += (name && ":") + "\"" +os + "\""; } else { */ json += (name && ":") + "\"" + o.replace(/\\/g,'\\\\').replace(/\"/g,'\\"') + "\""; //} } else { json += (name && ":") + o.toString(); } return json; }, innerXml: function(node) { var s = ""; if ("innerHTML" in node) { s = node.innerHTML; } else { var asXml = function(n) { var s = "", i; if (n.nodeType === 1) { s += "<" + n.nodeName; for (i = 0; i < n.attributes.length; i += 1) { s += " " + n.attributes[i].nodeName + "=\"" + (n.attributes[i].nodeValue || "").toString() + "\""; } if (n.firstChild) { s += ">"; for (var c = n.firstChild; c; c = c.nextSibling) { s += asXml(c); } s += ""; } else { s += "/>"; } } else if (n.nodeType === 3) { s += n.nodeValue; } else if (n.nodeType === 4) { s += ""; } return s; }; for (var c = node.firstChild; c; c = c.nextSibling) { s += asXml(c); } } return s; }, escape: function(txt) { return txt.replace(/[\\]/g, "\\\\").replace(/[\"]/g, '\\"').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r'); }, removeWhite: function(e) { e.normalize(); var n; for (n = e.firstChild; n; ) { if (n.nodeType === 3) { // text node if (!n.nodeValue.match(/[^ \f\n\r\t\v]/)) { // pure whitespace text node var nxt = n.nextSibling; e.removeChild(n); n = nxt; } else { n = n.nextSibling; } } else if (n.nodeType === 1) { // element node this.removeWhite(n); n = n.nextSibling; } else { // any other node n = n.nextSibling; } } return e; } };/* ** * formatter for values but most of the values if for jqGrid * Some of this was inspired and based on how YUI does the table datagrid but in jQuery fashion * we are trying to keep it as light as possible * Joshua Burnett josh@9ci.com * http://www.greenbill.com * * Changes from Tony Tomov tony@trirand.com * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl-2.0.html * **/ /*jshint eqeqeq:false */ /*global jQuery */ (function($) { "use strict"; $.fmatter = {}; //opts can be id:row id for the row, rowdata:the data for the row, colmodel:the column model for this column //example {id:1234,} $.extend($.fmatter,{ isBoolean : function(o) { return typeof o === 'boolean'; }, isObject : function(o) { return (o && (typeof o === 'object' || $.isFunction(o))) || false; }, isString : function(o) { return typeof o === 'string'; }, isNumber : function(o) { return typeof o === 'number' && isFinite(o); }, isValue : function (o) { return (this.isObject(o) || this.isString(o) || this.isNumber(o) || this.isBoolean(o)); }, isEmpty : function(o) { if(!this.isString(o) && this.isValue(o)) { return false; } if (!this.isValue(o)){ return true; } o = $.trim(o).replace(/\ \;/ig,'').replace(/\ \;/ig,''); return o===""; } }); $.fn.fmatter = function(formatType, cellval, opts, rwd, act) { // build main options before element iteration var v=cellval; opts = $.extend({}, $.jgrid.formatter, opts); try { v = $.fn.fmatter[formatType].call(this, cellval, opts, rwd, act); } catch(fe){} return v; }; $.fmatter.util = { // Taken from YAHOO utils NumberFormat : function(nData,opts) { if(!$.fmatter.isNumber(nData)) { nData *= 1; } if($.fmatter.isNumber(nData)) { var bNegative = (nData < 0); var sOutput = String(nData); var sDecimalSeparator = opts.decimalSeparator || "."; var nDotIndex; if($.fmatter.isNumber(opts.decimalPlaces)) { // Round to the correct decimal place var nDecimalPlaces = opts.decimalPlaces; var nDecimal = Math.pow(10, nDecimalPlaces); sOutput = String(Math.round(nData*nDecimal)/nDecimal); nDotIndex = sOutput.lastIndexOf("."); if(nDecimalPlaces > 0) { // Add the decimal separator if(nDotIndex < 0) { sOutput += sDecimalSeparator; nDotIndex = sOutput.length-1; } // Replace the "." else if(sDecimalSeparator !== "."){ sOutput = sOutput.replace(".",sDecimalSeparator); } // Add missing zeros while((sOutput.length - 1 - nDotIndex) < nDecimalPlaces) { sOutput += "0"; } } } if(opts.thousandsSeparator) { var sThousandsSeparator = opts.thousandsSeparator; nDotIndex = sOutput.lastIndexOf(sDecimalSeparator); nDotIndex = (nDotIndex > -1) ? nDotIndex : sOutput.length; var sNewOutput = sOutput.substring(nDotIndex); var nCount = -1, i; for (i=nDotIndex; i>0; i--) { nCount++; if ((nCount%3 === 0) && (i !== nDotIndex) && (!bNegative || (i > 1))) { sNewOutput = sThousandsSeparator + sNewOutput; } sNewOutput = sOutput.charAt(i-1) + sNewOutput; } sOutput = sNewOutput; } // Prepend prefix sOutput = (opts.prefix) ? opts.prefix + sOutput : sOutput; // Append suffix sOutput = (opts.suffix) ? sOutput + opts.suffix : sOutput; return sOutput; } return nData; } }; $.fn.fmatter.defaultFormat = function(cellval, opts) { return ($.fmatter.isValue(cellval) && cellval!=="" ) ? cellval : opts.defaultValue || " "; }; $.fn.fmatter.email = function(cellval, opts) { if(!$.fmatter.isEmpty(cellval)) { return "" + cellval + ""; } return $.fn.fmatter.defaultFormat(cellval,opts ); }; $.fn.fmatter.checkbox =function(cval, opts) { var op = $.extend({},opts.checkbox), ds; if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) { op = $.extend({},op,opts.colModel.formatoptions); } if(op.disabled===true) {ds = "disabled=\"disabled\"";} else {ds="";} if($.fmatter.isEmpty(cval) || cval === undefined ) {cval = $.fn.fmatter.defaultFormat(cval,op);} cval=String(cval); cval=cval.toLowerCase(); var bchk = cval.search(/(false|f|0|no|n|off|undefined)/i)<0 ? " checked='checked' " : ""; return ""; }; $.fn.fmatter.link = function(cellval, opts) { var op = {target:opts.target}; var target = ""; if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) { op = $.extend({},op,opts.colModel.formatoptions); } if(op.target) {target = 'target=' + op.target;} if(!$.fmatter.isEmpty(cellval)) { return "" + cellval + ""; } return $.fn.fmatter.defaultFormat(cellval,opts); }; $.fn.fmatter.showlink = function(cellval, opts) { var op = {baseLinkUrl: opts.baseLinkUrl,showAction:opts.showAction, addParam: opts.addParam || "", target: opts.target, idName: opts.idName}, target = "", idUrl; if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) { op = $.extend({},op,opts.colModel.formatoptions); } if(op.target) {target = 'target=' + op.target;} idUrl = op.baseLinkUrl+op.showAction + '?'+ op.idName+'='+opts.rowId+op.addParam; if($.fmatter.isString(cellval) || $.fmatter.isNumber(cellval)) { //add this one even if its blank string return "" + cellval + ""; } return $.fn.fmatter.defaultFormat(cellval,opts); }; $.fn.fmatter.integer = function(cellval, opts) { var op = $.extend({},opts.integer); if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) { op = $.extend({},op,opts.colModel.formatoptions); } if($.fmatter.isEmpty(cellval)) { return op.defaultValue; } return $.fmatter.util.NumberFormat(cellval,op); }; $.fn.fmatter.number = function (cellval, opts) { var op = $.extend({},opts.number); if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) { op = $.extend({},op,opts.colModel.formatoptions); } if($.fmatter.isEmpty(cellval)) { return op.defaultValue; } return $.fmatter.util.NumberFormat(cellval,op); }; $.fn.fmatter.currency = function (cellval, opts) { var op = $.extend({},opts.currency); if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) { op = $.extend({},op,opts.colModel.formatoptions); } if($.fmatter.isEmpty(cellval)) { return op.defaultValue; } return $.fmatter.util.NumberFormat(cellval,op); }; $.fn.fmatter.date = function (cellval, opts, rwd, act) { var op = $.extend({},opts.date); if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) { op = $.extend({},op,opts.colModel.formatoptions); } if(!op.reformatAfterEdit && act === 'edit'){ return $.fn.fmatter.defaultFormat(cellval, opts); } if(!$.fmatter.isEmpty(cellval)) { return $.jgrid.parseDate(op.srcformat,cellval,op.newformat,op); } return $.fn.fmatter.defaultFormat(cellval, opts); }; $.fn.fmatter.select = function (cellval,opts) { // jqGrid specific cellval = String(cellval); var oSelect = false, ret=[], sep, delim; if(opts.colModel.formatoptions !== undefined){ oSelect= opts.colModel.formatoptions.value; sep = opts.colModel.formatoptions.separator === undefined ? ":" : opts.colModel.formatoptions.separator; delim = opts.colModel.formatoptions.delimiter === undefined ? ";" : opts.colModel.formatoptions.delimiter; } else if(opts.colModel.editoptions !== undefined){ oSelect= opts.colModel.editoptions.value; sep = opts.colModel.editoptions.separator === undefined ? ":" : opts.colModel.editoptions.separator; delim = opts.colModel.editoptions.delimiter === undefined ? ";" : opts.colModel.editoptions.delimiter; } if (oSelect) { var msl = opts.colModel.editoptions.multiple === true ? true : false, scell = [], sv; if(msl) {scell = cellval.split(",");scell = $.map(scell,function(n){return $.trim(n);});} if ($.fmatter.isString(oSelect)) { // mybe here we can use some caching with care ???? var so = oSelect.split(delim), j=0, i; for(i=0; i 2 ) { sv[1] = $.map(sv,function(n,i){if(i>0) {return n;}}).join(sep); } if(msl) { if($.inArray(sv[0],scell)>-1) { ret[j] = sv[1]; j++; } } else if($.trim(sv[0]) === $.trim(cellval)) { ret[0] = sv[1]; break; } } } else if($.fmatter.isObject(oSelect)) { // this is quicker if(msl) { ret = $.map(scell, function(n){ return oSelect[n]; }); } else { ret[0] = oSelect[cellval] || ""; } } } cellval = ret.join(", "); return cellval === "" ? $.fn.fmatter.defaultFormat(cellval,opts) : cellval; }; $.fn.fmatter.rowactions = function(act) { var $tr = $(this).closest("tr.jqgrow"), rid = $tr.attr("id"), $id = $(this).closest("table.ui-jqgrid-btable").attr('id').replace(/_frozen([^_]*)$/,'$1'), $grid = $("#"+$id), $t = $grid[0], p = $t.p, cm = p.colModel[$.jgrid.getCellIndex(this)], $actionsDiv = cm.frozen ? $("tr#"+rid+" td:eq("+$.jgrid.getCellIndex(this)+") > div",$grid) :$(this).parent(), op = { keys: false, onEdit: null, onSuccess: null, afterSave: null, onError: null, afterRestore: null, extraparam: {}, url: null, restoreAfterError: true, mtype: "POST", delOptions: {}, editOptions: {} }, saverow = function(rowid, res) { if($.isFunction(op.afterSave)) { op.afterSave.call($t, rowid, res); } $actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").show(); $actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").hide(); }, restorerow = function(rowid) { if($.isFunction(op.afterRestore)) { op.afterRestore.call($t, rowid); } $actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").show(); $actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").hide(); }; if (cm.formatoptions !== undefined) { op = $.extend(op,cm.formatoptions); } if (p.editOptions !== undefined) { op.editOptions = p.editOptions; } if (p.delOptions !== undefined) { op.delOptions = p.delOptions; } if ($tr.hasClass("jqgrid-new-row")){ op.extraparam[p.prmNames.oper] = p.prmNames.addoper; } var actop = { keys: op.keys, oneditfunc: op.onEdit, successfunc: op.onSuccess, beforeSubmit: op.beforeSubmit, url: op.url, extraparam: op.extraparam, aftersavefunc: saverow, errorfunc: op.onError, afterrestorefunc: restorerow, restoreAfterError: op.restoreAfterError, mtype: op.mtype }; switch(act) { case 'edit': $grid.jqGrid('editRow', rid, actop); $actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").hide(); $actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").show(); $grid.triggerHandler("jqGridAfterGridComplete"); break; case 'save': // show dialog to ask if you want to save changes before submit if ($.isFunction(actop.beforeSubmit)) { if (!actop.beforeSubmit(rid)) { $grid.jqGrid('restoreRow', rid, restorerow); $actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").show(); $actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").hide(); $grid.triggerHandler("jqGridAfterGridComplete"); break; } } if ($grid.jqGrid('saveRow', rid, actop)) { $actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").show(); $actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").hide(); $grid.triggerHandler("jqGridAfterGridComplete"); } break; case 'cancel' : $grid.jqGrid('restoreRow', rid, restorerow); $actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").show(); $actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").hide(); $grid.triggerHandler("jqGridAfterGridComplete"); break; case 'del': $grid.jqGrid('delGridRow', rid, op.delOptions); break; case 'formedit': $grid.jqGrid('setSelection', rid); $grid.jqGrid('editGridRow', rid, op.editOptions); break; } }; $.fn.fmatter.actions = function(cellval,opts) { var op={keys:false, editbutton:true, delbutton:true, editformbutton: false}, rowid=opts.rowId, str="",ocl; if(opts.colModel.formatoptions !== undefined) { op = $.extend(op,opts.colModel.formatoptions); } if(rowid === undefined || $.fmatter.isEmpty(rowid)) {return "";} if(op.editformbutton){ ocl = "id='jEditButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'formedit'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); "; str += "
    "; } else if(op.editbutton){ ocl = "id='jEditButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'edit'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover') "; str += "
    "; } if(op.delbutton) { ocl = "id='jDeleteButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'del'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); "; str += "
    "; } ocl = "id='jSaveButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'save'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); "; str += ""; ocl = "id='jCancelButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'cancel'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); "; str += ""; return "
    " + str + "
    "; }; $.unformat = function (cellval,options,pos,cnt) { // specific for jqGrid only var ret, formatType = options.colModel.formatter, op =options.colModel.formatoptions || {}, sep, re = /([\.\*\_\'\(\)\{\}\+\?\\])/g, unformatFunc = options.colModel.unformat||($.fn.fmatter[formatType] && $.fn.fmatter[formatType].unformat); if(unformatFunc !== undefined && $.isFunction(unformatFunc) ) { ret = unformatFunc.call(this, $(cellval).text(), options, cellval); } else if(formatType !== undefined && $.fmatter.isString(formatType) ) { var opts = $.jgrid.formatter || {}, stripTag; switch(formatType) { case 'integer' : op = $.extend({},opts.integer,op); sep = op.thousandsSeparator.replace(re,"\\$1"); stripTag = new RegExp(sep, "g"); ret = $(cellval).text().replace(stripTag,''); break; case 'number' : op = $.extend({},opts.number,op); sep = op.thousandsSeparator.replace(re,"\\$1"); stripTag = new RegExp(sep, "g"); ret = $(cellval).text().replace(stripTag,"").replace(op.decimalSeparator,'.'); break; case 'currency': op = $.extend({},opts.currency,op); sep = op.thousandsSeparator.replace(re,"\\$1"); stripTag = new RegExp(sep, "g"); ret = $(cellval).text(); if (op.prefix && op.prefix.length) { ret = ret.substr(op.prefix.length); } if (op.suffix && op.suffix.length) { ret = ret.substr(0, ret.length - op.suffix.length); } ret = ret.replace(stripTag,'').replace(op.decimalSeparator,'.'); break; case 'checkbox': var cbv = (options.colModel.editoptions) ? options.colModel.editoptions.value.split(":") : ["Yes","No"]; ret = $('input',cellval).is(":checked") ? cbv[0] : cbv[1]; break; case 'select' : ret = $.unformat.select(cellval,options,pos,cnt); break; case 'actions': return ""; default: ret= $(cellval).text(); } } return ret !== undefined ? ret : cnt===true ? $(cellval).text() : $.jgrid.htmlDecode($(cellval).html()); }; $.unformat.select = function (cellval,options,pos,cnt) { // Spacial case when we have local data and perform a sort // cnt is set to true only in sortDataArray var ret = []; var cell = $(cellval).text(); if(cnt===true) {return cell;} var op = $.extend({}, options.colModel.formatoptions !== undefined ? options.colModel.formatoptions: options.colModel.editoptions), sep = op.separator === undefined ? ":" : op.separator, delim = op.delimiter === undefined ? ";" : op.delimiter; if(op.value){ var oSelect = op.value, msl = op.multiple === true ? true : false, scell = [], sv; if(msl) {scell = cell.split(",");scell = $.map(scell,function(n){return $.trim(n);});} if ($.fmatter.isString(oSelect)) { var so = oSelect.split(delim), j=0, i; for(i=0; i 2 ) { sv[1] = $.map(sv,function(n,i){if(i>0) {return n;}}).join(sep); } if(msl) { if($.inArray(sv[1],scell)>-1) { ret[j] = sv[0]; j++; } } else if($.trim(sv[1]) === $.trim(cell)) { ret[0] = sv[0]; break; } } } else if($.fmatter.isObject(oSelect) || $.isArray(oSelect) ){ if(!msl) {scell[0] = cell;} ret = $.map(scell, function(n){ var rv; $.each(oSelect, function(i,val){ if (val === n) { rv = i; return false; } }); if( rv !== undefined ) {return rv;} }); } return ret.join(", "); } return cell || ""; }; $.unformat.date = function (cellval, opts) { var op = $.jgrid.formatter.date || {}; if(opts.formatoptions !== undefined) { op = $.extend({},op,opts.formatoptions); } if(!$.fmatter.isEmpty(cellval)) { return $.jgrid.parseDate(op.newformat,cellval,op.srcformat,op); } return $.fn.fmatter.defaultFormat(cellval, opts); }; })(jQuery); /*jshint eqeqeq:false */ /*global jQuery */ (function($){ /* * jqGrid common function * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl-2.0.html */ "use strict"; $.extend($.jgrid,{ // Modal functions showModal : function(h) { h.w.show(); }, closeModal : function(h) { h.w.hide().attr("aria-hidden","true"); if(h.o) {h.o.remove();} }, hideModal : function (selector,o) { o = $.extend({jqm : true, gb :''}, o || {}); if(o.onClose) { var oncret = o.gb && typeof o.gb === "string" && o.gb.substr(0,6) === "#gbox_" ? o.onClose.call($("#" + o.gb.substr(6))[0], selector) : o.onClose(selector); if (typeof oncret === 'boolean' && !oncret ) { return; } } if ($.fn.jqm && o.jqm === true) { $(selector).attr("aria-hidden","true").jqmHide(); } else { if(o.gb !== '') { try {$(".jqgrid-overlay:first",o.gb).hide();} catch (e){} } $(selector).hide().attr("aria-hidden","true"); } }, //Helper functions findPos : function(obj) { var curleft = 0, curtop = 0; if (obj.offsetParent) { do { curleft += obj.offsetLeft; curtop += obj.offsetTop; } while (obj = obj.offsetParent); //do not change obj == obj.offsetParent } return [curleft,curtop]; }, createModal : function(aIDs, content, p, insertSelector, posSelector, appendsel, css) { p = $.extend(true, {}, $.jgrid.jqModal || {}, p); var mw = document.createElement('div'), rtlsup, self = this; css = $.extend({}, css || {}); rtlsup = $(p.gbox).attr("dir") === "rtl" ? true : false; mw.className= "ui-widget ui-widget-content ui-corner-all ui-jqdialog"; mw.id = aIDs.themodal; var mh = document.createElement('div'); mh.className = "ui-jqdialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"; mh.id = aIDs.modalhead; $(mh).append(""+p.caption+""); var ahr= $("") .hover(function(){ahr.addClass('ui-state-hover');}, function(){ahr.removeClass('ui-state-hover');}) .append(""); $(mh).append(ahr); if(rtlsup) { mw.dir = "rtl"; $(".ui-jqdialog-title",mh).css("float","right"); $(".ui-jqdialog-titlebar-close",mh).css("left",0.3+"em"); } else { mw.dir = "ltr"; $(".ui-jqdialog-title",mh).css("float","left"); $(".ui-jqdialog-titlebar-close",mh).css("right",0.3+"em"); } var mc = document.createElement('div'); $(mc).addClass("ui-jqdialog-content ui-widget-content").attr("id",aIDs.modalcontent); $(mc).append(content); mw.appendChild(mc); $(mw).prepend(mh); if(appendsel===true) { $('body').append(mw); } //append as first child in body -for alert dialog else if (typeof appendsel === "string") { $(appendsel).append(mw); } else {$(mw).insertBefore(insertSelector);} $(mw).css(css); if(p.jqModal === undefined) {p.jqModal = true;} // internal use var coord = {}; if ( $.fn.jqm && p.jqModal === true) { if(p.left ===0 && p.top===0 && p.overlay) { var pos = []; pos = $.jgrid.findPos(posSelector); p.left = pos[0] + 4; p.top = pos[1] + 4; } coord.top = p.top+"px"; coord.left = p.left; } else if(p.left !==0 || p.top!==0) { coord.left = p.left; coord.top = p.top+"px"; } $("a.ui-jqdialog-titlebar-close",mh).click(function(){ var oncm = $("#"+$.jgrid.jqID(aIDs.themodal)).data("onClose") || p.onClose; var gboxclose = $("#"+$.jgrid.jqID(aIDs.themodal)).data("gbox") || p.gbox; self.hideModal("#"+$.jgrid.jqID(aIDs.themodal),{gb:gboxclose,jqm:p.jqModal,onClose:oncm}); return false; }); if (p.width === 0 || !p.width) {p.width = 300;} if(p.height === 0 || !p.height) {p.height =200;} if(!p.zIndex) { var parentZ = $(insertSelector).parents("*[role=dialog]").filter(':first').css("z-index"); if(parentZ) { p.zIndex = parseInt(parentZ,10)+2; } else { p.zIndex = 950; } } var rtlt = 0; if( rtlsup && coord.left && !appendsel) { rtlt = $(p.gbox).width()- (!isNaN(p.width) ? parseInt(p.width,10) :0) - 8; // to do // just in case coord.left = parseInt(coord.left,10) + parseInt(rtlt,10); } if(coord.left) { coord.left += "px"; } $(mw).css($.extend({ width: isNaN(p.width) ? "auto": p.width+"px", height:isNaN(p.height) ? "auto" : p.height + "px", zIndex:p.zIndex, overflow: 'hidden' },coord)) .attr({tabIndex: "-1","role":"dialog","aria-labelledby":aIDs.modalhead,"aria-hidden":"true"}); if(p.drag === undefined) { p.drag=true;} if(p.resize === undefined) {p.resize=true;} if (p.drag) { $(mh).css('cursor','move'); if($.fn.jqDrag) { $(mw).jqDrag(mh); } else { try { $(mw).draggable({handle: $("#"+$.jgrid.jqID(mh.id))}); } catch (e) {} } } if(p.resize) { if($.fn.jqResize) { $(mw).append("
    "); $("#"+$.jgrid.jqID(aIDs.themodal)).jqResize(".jqResize",aIDs.scrollelm ? "#"+$.jgrid.jqID(aIDs.scrollelm) : false); } else { try { $(mw).resizable({handles: 'se, sw',alsoResize: aIDs.scrollelm ? "#"+$.jgrid.jqID(aIDs.scrollelm) : false}); } catch (r) {} } } if(p.closeOnEscape === true){ $(mw).keydown( function( e ) { if( e.which == 27 ) { var cone = $("#"+$.jgrid.jqID(aIDs.themodal)).data("onClose") || p.onClose; self.hideModal("#"+$.jgrid.jqID(aIDs.themodal),{gb:p.gbox,jqm:p.jqModal,onClose: cone}); } }); } }, viewModal : function (selector,o){ o = $.extend({ toTop: true, overlay: 10, modal: false, overlayClass : 'ui-widget-overlay', onShow: $.jgrid.showModal, onHide: $.jgrid.closeModal, gbox: '', jqm : true, jqM : true }, o || {}); if ($.fn.jqm && o.jqm === true) { if(o.jqM) { $(selector).attr("aria-hidden","false").jqm(o).jqmShow(); } else {$(selector).attr("aria-hidden","false").jqmShow();} } else { if(o.gbox !== '') { $(".jqgrid-overlay:first",o.gbox).show(); $(selector).data("gbox",o.gbox); } $(selector).show().attr("aria-hidden","false"); try{$(':input:visible',selector)[0].focus();}catch(_){} } }, info_dialog : function(caption, content,c_b, modalopt) { var mopt = { width:290, height:'auto', dataheight: 'auto', drag: true, resize: false, left:250, top:170, zIndex : 1000, jqModal : true, modal : false, closeOnEscape : true, align: 'center', buttonalign : 'center', buttons : [] // {text:'textbutt', id:"buttid", onClick : function(){...}} // if the id is not provided we set it like info_button_+ the index in the array - i.e info_button_0,info_button_1... }; $.extend(true, mopt, $.jgrid.jqModal || {}, {caption:""+caption+""}, modalopt || {}); var jm = mopt.jqModal, self = this; if($.fn.jqm && !jm) { jm = false; } // in case there is no jqModal var buttstr ="", i; if(mopt.buttons.length > 0) { for(i=0;i"+mopt.buttons[i].text+""; } } var dh = isNaN(mopt.dataheight) ? mopt.dataheight : mopt.dataheight+"px", cn = "text-align:"+mopt.align+";"; var cnt = "
    "; cnt += "
    "+content+"
    "; cnt += c_b ? "
    "+c_b+""+buttstr+"
    " : buttstr !== "" ? "
    "+buttstr+"
    " : ""; cnt += "
    "; try { if($("#info_dialog").attr("aria-hidden") === "false") { $.jgrid.hideModal("#info_dialog",{jqm:jm}); } $("#info_dialog").remove(); } catch (e){} $.jgrid.createModal({ themodal:'info_dialog', modalhead:'info_head', modalcontent:'info_content', scrollelm: 'infocnt'}, cnt, mopt, '','',true ); // attach onclick after inserting into the dom if(buttstr) { $.each(mopt.buttons,function(i){ $("#"+$.jgrid.jqID(this.id),"#info_id").bind('click',function(){mopt.buttons[i].onClick.call($("#info_dialog")); return false;}); }); } $("#closedialog", "#info_id").click(function(){ self.hideModal("#info_dialog",{ jqm:jm, onClose: $("#info_dialog").data("onClose") || mopt.onClose, gb: $("#info_dialog").data("gbox") || mopt.gbox }); return false; }); $(".fm-button","#info_dialog").hover( function(){$(this).addClass('ui-state-hover');}, function(){$(this).removeClass('ui-state-hover');} ); if($.isFunction(mopt.beforeOpen) ) { mopt.beforeOpen(); } $.jgrid.viewModal("#info_dialog",{ onHide: function(h) { h.w.hide().remove(); if(h.o) { h.o.remove(); } }, modal :mopt.modal, jqm:jm }); if($.isFunction(mopt.afterOpen) ) { mopt.afterOpen(); } try{ $("#info_dialog").focus();} catch (m){} }, bindEv: function (el, opt) { var $t = this; if($.isFunction(opt.dataInit)) { opt.dataInit.call($t,el); } if(opt.dataEvents) { $.each(opt.dataEvents, function() { if (this.data !== undefined) { $(el).bind(this.type, this.data, this.fn); } else { $(el).bind(this.type, this.fn); } }); } }, // Form Functions createEl : function(eltype,options,vl,autowidth, ajaxso) { var elem = "", $t = this; function setAttributes(elm, atr, exl ) { var exclude = ['dataInit','dataEvents','dataUrl', 'buildSelect','sopt', 'searchhidden', 'defaultValue', 'attr', 'custom_element', 'custom_value']; if(exl !== undefined && $.isArray(exl)) { $.merge(exclude, exl); } $.each(atr, function(key, value){ if($.inArray(key, exclude) === -1) { $(elm).attr(key,value); } }); if(!atr.hasOwnProperty('id')) { $(elm).attr('id', $.jgrid.randId()); } } switch (eltype) { case "textarea" : elem = document.createElement("textarea"); if(autowidth) { if(!options.cols) { $(elem).css({width:"98%"});} } else if (!options.cols) { options.cols = 20; } if(!options.rows) { options.rows = 2; } if(vl===' ' || vl===' ' || (vl.length===1 && vl.charCodeAt(0)===160)) {vl="";} elem.value = vl; setAttributes(elem, options); $(elem).attr({"role":"textbox","multiline":"true"}); break; case "checkbox" : //what code for simple checkbox elem = document.createElement("input"); elem.type = "checkbox"; if( !options.value ) { var vl1 = vl.toLowerCase(); if(vl1.search(/(false|f|0|no|n|off|undefined)/i)<0 && vl1!=="") { elem.checked=true; elem.defaultChecked=true; elem.value = vl; } else { elem.value = "on"; } $(elem).attr("offval","off"); } else { var cbval = options.value.split(":"); if(vl === cbval[0]) { elem.checked=true; elem.defaultChecked=true; } elem.value = cbval[0]; $(elem).attr("offval",cbval[1]); } setAttributes(elem, options, ['value']); $(elem).attr("role","checkbox"); break; case "select" : elem = document.createElement("select"); elem.setAttribute("role","select"); var msl, ovm = []; if(options.multiple===true) { msl = true; elem.multiple="multiple"; $(elem).attr("aria-multiselectable","true"); } else { msl = false; } if(options.dataUrl !== undefined) { var rowid = options.name ? String(options.id).substring(0, String(options.id).length - String(options.name).length - 1) : String(options.id), postData = options.postData || ajaxso.postData; if ($t.p && $t.p.idPrefix) { rowid = $.jgrid.stripPref($t.p.idPrefix, rowid); } else { postData = undefined; // don't use postData for searching from jqFilter. One can implement the feature in the future if required. } $.ajax($.extend({ url: options.dataUrl, type : "GET", dataType: "html", data: $.isFunction(postData) ? postData.call($t, rowid, vl, String(options.name)) : postData, context: {elem:elem, options:options, vl:vl}, success: function(data){ var ovm = [], elem = this.elem, vl = this.vl, options = $.extend({},this.options), msl = options.multiple===true, a = $.isFunction(options.buildSelect) ? options.buildSelect.call($t,data) : data; if(typeof a === 'string') { a = $( $.trim( a ) ).html(); } if(a) { $(elem).append(a); setAttributes(elem, options); if(options.size === undefined) { options.size = msl ? 3 : 1;} if(msl) { ovm = vl.split(","); ovm = $.map(ovm,function(n){return $.trim(n);}); } else { ovm[0] = $.trim(vl); } //$(elem).attr(options); setTimeout(function(){ $("option",elem).each(function(i){ //if(i===0) { this.selected = ""; } // fix IE8/IE7 problem with selecting of the first item on multiple=true if (i === 0 && elem.multiple) { this.selected = false; } $(this).attr("role","option"); if($.inArray($.trim($(this).text()),ovm) > -1 || $.inArray($.trim($(this).val()),ovm) > -1 ) { this.selected= "selected"; } }); },0); } } },ajaxso || {})); } else if(options.value) { var i; if(options.size === undefined) { options.size = msl ? 3 : 1; } if(msl) { ovm = vl.split(","); ovm = $.map(ovm,function(n){return $.trim(n);}); } if(typeof options.value === 'function') { options.value = options.value(); } var so,sv, ov, sep = options.separator === undefined ? ":" : options.separator, delim = options.delimiter === undefined ? ";" : options.delimiter; if(typeof options.value === 'string') { so = options.value.split(delim); for(i=0; i 2 ) { sv[1] = $.map(sv,function(n,ii){if(ii>0) { return n;} }).join(sep); } ov = document.createElement("option"); ov.setAttribute("role","option"); ov.value = sv[0]; ov.innerHTML = sv[1]; elem.appendChild(ov); if (!msl && ($.trim(sv[0]) === $.trim(vl) || $.trim(sv[1]) === $.trim(vl))) { ov.selected ="selected"; } if (msl && ($.inArray($.trim(sv[1]), ovm)>-1 || $.inArray($.trim(sv[0]), ovm)>-1)) {ov.selected ="selected";} } } else if (typeof options.value === 'object') { var oSv = options.value, key; for (key in oSv) { if (oSv.hasOwnProperty(key ) ){ ov = document.createElement("option"); ov.setAttribute("role","option"); ov.value = key; ov.innerHTML = oSv[key]; elem.appendChild(ov); if (!msl && ( $.trim(key) === $.trim(vl) || $.trim(oSv[key]) === $.trim(vl)) ) { ov.selected ="selected"; } if (msl && ($.inArray($.trim(oSv[key]),ovm)>-1 || $.inArray($.trim(key),ovm)>-1)) { ov.selected ="selected"; } } } } setAttributes(elem, options, ['value']); } break; case "text" : case "password" : case "button" : var role; if(eltype==="button") { role = "button"; } else { role = "textbox"; } elem = document.createElement("input"); elem.type = eltype; elem.value = vl; setAttributes(elem, options); if(eltype !== "button"){ if(autowidth) { if(!options.size) { $(elem).css({width:"98%"}); } } else if (!options.size) { options.size = 20; } } $(elem).attr("role",role); break; case "image" : case "file" : elem = document.createElement("input"); elem.type = eltype; setAttributes(elem, options); break; case "custom" : elem = document.createElement("span"); try { if($.isFunction(options.custom_element)) { var celm = options.custom_element.call($t,vl,options); if(celm) { celm = $(celm).addClass("customelement").attr({id:options.id,name:options.name}); $(elem).empty().append(celm); } else { throw "e2"; } } else { throw "e1"; } } catch (e) { if (e==="e1") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_element' "+$.jgrid.edit.msg.nodefined, $.jgrid.edit.bClose);} if (e==="e2") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_element' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose);} else { $.jgrid.info_dialog($.jgrid.errors.errcap,typeof e==="string"?e:e.message,$.jgrid.edit.bClose); } } break; } return elem; }, // Date Validation Javascript checkDate : function (format, date) { var daysInFebruary = function(year){ // February has 29 days in any year evenly divisible by four, // EXCEPT for centurial years which are not also divisible by 400. return (((year % 4 === 0) && ( year % 100 !== 0 || (year % 400 === 0))) ? 29 : 28 ); }, tsp = {}, sep; format = format.toLowerCase(); //we search for /,-,. for the date separator if(format.indexOf("/") !== -1) { sep = "/"; } else if(format.indexOf("-") !== -1) { sep = "-"; } else if(format.indexOf(".") !== -1) { sep = "."; } else { sep = "/"; } format = format.split(sep); date = date.split(sep); if (date.length !== 3) { return false; } var j=-1,yln, dln=-1, mln=-1, i; for(i=0;i12){ return false; } if(dln === -1) { return false; } strDate = tsp[format[dln]].toString(); if (strDate.length<1 || tsp[format[dln]]<1 || tsp[format[dln]]>31 || (tsp[format[mln]]===2 && tsp[format[dln]]>daysInFebruary(tsp[format[j]])) || tsp[format[dln]] > daysInMonth[tsp[format[mln]]]){ return false; } return true; }, isEmpty : function(val) { if (val.match(/^\s+$/) || val === "") { return true; } return false; }, checkTime : function(time){ // checks only hh:ss (and optional am/pm) var re = /^(\d{1,2}):(\d{2})([apAP][Mm])?$/,regs; if(!$.jgrid.isEmpty(time)) { regs = time.match(re); if(regs) { if(regs[3]) { if(regs[1] < 1 || regs[1] > 12) { return false; } } else { if(regs[1] > 23) { return false; } } if(regs[2] > 59) { return false; } } else { return false; } } return true; }, checkValues : function(val, valref, customobject, nam) { var edtrul,i, nm, dft, len, g = this, cm = g.p.colModel; if(customobject === undefined) { if(typeof valref==='string'){ for( i =0, len=cm.length;i=0) { edtrul = cm[valref].editrules; } } else { edtrul = customobject; nm = nam===undefined ? "_" : nam; } if(edtrul) { if(!nm) { nm = g.p.colNames != null ? g.p.colNames[valref] : cm[valref].label; } if(edtrul.required === true) { if( $.jgrid.isEmpty(val) ) { return [false,nm+": "+$.jgrid.edit.msg.required,""]; } } // force required var rqfield = edtrul.required === false ? false : true; if(edtrul.number === true) { if( !(rqfield === false && $.jgrid.isEmpty(val)) ) { if(isNaN(val)) { return [false,nm+": "+$.jgrid.edit.msg.number,""]; } } } if(edtrul.minValue !== undefined && !isNaN(edtrul.minValue)) { if (parseFloat(val) < parseFloat(edtrul.minValue) ) { return [false,nm+": "+$.jgrid.edit.msg.minValue+" "+edtrul.minValue,""];} } if(edtrul.maxValue !== undefined && !isNaN(edtrul.maxValue)) { if (parseFloat(val) > parseFloat(edtrul.maxValue) ) { return [false,nm+": "+$.jgrid.edit.msg.maxValue+" "+edtrul.maxValue,""];} } var filter; if(edtrul.email === true) { if( !(rqfield === false && $.jgrid.isEmpty(val)) ) { // taken from $ Validate plugin filter = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i; if(!filter.test(val)) {return [false,nm+": "+$.jgrid.edit.msg.email,""];} } } if(edtrul.integer === true) { if( !(rqfield === false && $.jgrid.isEmpty(val)) ) { if(isNaN(val)) { return [false,nm+": "+$.jgrid.edit.msg.integer,""]; } if ((val % 1 !== 0) || (val.indexOf('.') !== -1)) { return [false,nm+": "+$.jgrid.edit.msg.integer,""];} } } if(edtrul.date === true) { if( !(rqfield === false && $.jgrid.isEmpty(val)) ) { if(cm[valref].formatoptions && cm[valref].formatoptions.newformat) { dft = cm[valref].formatoptions.newformat; if( $.jgrid.formatter.date.masks.hasOwnProperty(dft) ) { dft = $.jgrid.formatter.date.masks[dft]; } } else { dft = cm[valref].datefmt || "Y-m-d"; } if(!$.jgrid.checkDate (dft, val)) { return [false,nm+": "+$.jgrid.edit.msg.date+" - "+dft,""]; } } } if(edtrul.time === true) { if( !(rqfield === false && $.jgrid.isEmpty(val)) ) { if(!$.jgrid.checkTime (val)) { return [false,nm+": "+$.jgrid.edit.msg.date+" - hh:mm (am/pm)",""]; } } } if(edtrul.url === true) { if( !(rqfield === false && $.jgrid.isEmpty(val)) ) { filter = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i; if(!filter.test(val)) {return [false,nm+": "+$.jgrid.edit.msg.url,""];} } } if(edtrul.custom === true) { if( !(rqfield === false && $.jgrid.isEmpty(val)) ) { if($.isFunction(edtrul.custom_func)) { var ret = edtrul.custom_func.call(g,val,nm,valref); return $.isArray(ret) ? ret : [false,$.jgrid.edit.msg.customarray,""]; } return [false,$.jgrid.edit.msg.customfcheck,""]; } } } return [true,"",""]; } }); })(jQuery); /* * jqFilter jQuery jqGrid filter addon. * Copyright (c) 2011, Tony Tomov, tony@trirand.com * Dual licensed under the MIT and GPL licenses * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl-2.0.html * * The work is inspired from this Stefan Pirvu * http://www.codeproject.com/KB/scripting/json-filtering.aspx * * The filter uses JSON entities to hold filter rules and groups. Here is an example of a filter: { "groupOp": "AND", "groups" : [ { "groupOp": "OR", "rules": [ { "field": "name", "op": "eq", "data": "England" }, { "field": "id", "op": "le", "data": "5"} ] } ], "rules": [ { "field": "name", "op": "eq", "data": "Romania" }, { "field": "id", "op": "le", "data": "1"} ] } */ /*jshint eqeqeq:false, eqnull:true, devel:true */ /*global jQuery */ (function ($) { "use strict"; $.fn.jqFilter = function( arg ) { if (typeof arg === 'string') { var fn = $.fn.jqFilter[arg]; if (!fn) { throw ("jqFilter - No such method: " + arg); } var args = $.makeArray(arguments).slice(1); return fn.apply(this,args); } var p = $.extend(true,{ filter: null, columns: [], onChange : null, afterRedraw : null, checkValues : null, error: false, errmsg : "", errorcheck : true, showQuery : true, sopt : null, ops : [], operands : null, numopts : ['eq','ne', 'lt', 'le', 'gt', 'ge', 'nu', 'nn', 'in', 'ni'], stropts : ['eq', 'ne', 'bw', 'bn', 'ew', 'en', 'cn', 'nc', 'nu', 'nn', 'in', 'ni'], strarr : ['text', 'string', 'blob'], groupOps : [{ op: "AND", text: "AND" }, { op: "OR", text: "OR" }], groupButton : true, ruleButtons : true, direction : "ltr" }, $.jgrid.filter, arg || {}); return this.each( function() { if (this.filter) {return;} this.p = p; // setup filter in case if they is not defined if (this.p.filter === null || this.p.filter === undefined) { this.p.filter = { groupOp: this.p.groupOps[0].op, rules: [], groups: [] }; } var i, len = this.p.columns.length, cl, isIE = /msie/i.test(navigator.userAgent) && !window.opera; // translating the options this.p.initFilter = $.extend(true,{},this.p.filter); // set default values for the columns if they are not set if( !len ) {return;} for(i=0; i < len; i++) { cl = this.p.columns[i]; if( cl.stype ) { // grid compatibility cl.inputtype = cl.stype; } else if(!cl.inputtype) { cl.inputtype = 'text'; } if( cl.sorttype ) { // grid compatibility cl.searchtype = cl.sorttype; } else if (!cl.searchtype) { cl.searchtype = 'string'; } if(cl.hidden === undefined) { // jqGrid compatibility cl.hidden = false; } if(!cl.label) { cl.label = cl.name; } if(cl.index) { cl.name = cl.index; } if(!cl.hasOwnProperty('searchoptions')) { cl.searchoptions = {}; } if(!cl.hasOwnProperty('searchrules')) { cl.searchrules = {}; } } if(this.p.showQuery) { $(this).append("
    "); } var getGrid = function () { return $("#" + $.jgrid.jqID(p.id))[0] || null; }; /* *Perform checking. * */ var checkData = function(val, colModelItem) { var ret = [true,""], $t = getGrid(); if($.isFunction(colModelItem.searchrules)) { ret = colModelItem.searchrules.call($t, val, colModelItem); } else if($.jgrid && $.jgrid.checkValues) { try { ret = $.jgrid.checkValues.call($t, val, -1, colModelItem.searchrules, colModelItem.label); } catch (e) {} } if(ret && ret.length && ret[0] === false) { p.error = !ret[0]; p.errmsg = ret[1]; } }; /* moving to common randId = function() { return Math.floor(Math.random()*10000).toString(); }; */ this.onchange = function ( ){ // clear any error this.p.error = false; this.p.errmsg=""; return $.isFunction(this.p.onChange) ? this.p.onChange.call( this, this.p ) : false; }; /* * Redraw the filter every time when new field is added/deleted * and field is changed */ this.reDraw = function() { $("table.group:first",this).remove(); var t = this.createTableForGroup(p.filter, null); $(this).append(t); if($.isFunction(this.p.afterRedraw) ) { this.p.afterRedraw.call(this, this.p); } }; /* * Creates a grouping data for the filter * @param group - object * @param parentgroup - object */ this.createTableForGroup = function(group, parentgroup) { var that = this, i; // this table will hold all the group (tables) and rules (rows) var table = $("
    "), // create error message row align = "left"; if(this.p.direction === "rtl") { align = "right"; table.attr("dir","rtl"); } if(parentgroup === null) { table.append(""); } var tr = $(""); table.append(tr); // this header will hold the group operator type and group action buttons for // creating subgroup "+ {}", creating rule "+" or deleting the group "-" var th = $(""); tr.append(th); if(this.p.ruleButtons === true) { // dropdown for: choosing group operator type var groupOpSelect = $(""); th.append(groupOpSelect); // populate dropdown with all posible group operators: or, and var str= "", selected; for (i = 0; i < p.groupOps.length; i++) { selected = group.groupOp === that.p.groupOps[i].op ? " selected='selected'" :""; str += ""; } groupOpSelect .append(str) .bind('change',function() { group.groupOp = $(groupOpSelect).val(); that.onchange(); // signals that the filter has changed }); } // button for adding a new subgroup var inputAddSubgroup =""; if(this.p.groupButton) { inputAddSubgroup = $(""); inputAddSubgroup.bind('click',function() { if (group.groups === undefined ) { group.groups = []; } group.groups.push({ groupOp: p.groupOps[0].op, rules: [], groups: [] }); // adding a new group that.reDraw(); // the html has changed, force reDraw that.onchange(); // signals that the filter has changed return false; }); } th.append(inputAddSubgroup); if(this.p.ruleButtons === true) { // button for adding a new rule var inputAddRule = $(""), cm; inputAddRule.bind('click',function() { //if(!group) { group = {};} if (group.rules === undefined) { group.rules = []; } for (i = 0; i < that.p.columns.length; i++) { // but show only serchable and serchhidden = true fields var searchable = (that.p.columns[i].search === undefined) ? true: that.p.columns[i].search, hidden = (that.p.columns[i].hidden === true), ignoreHiding = (that.p.columns[i].searchoptions.searchhidden === true); if ((ignoreHiding && searchable) || (searchable && !hidden)) { cm = that.p.columns[i]; break; } } var opr; if( cm.searchoptions.sopt ) {opr = cm.searchoptions.sopt;} else if(that.p.sopt) { opr= that.p.sopt; } else if ( $.inArray(cm.searchtype, that.p.strarr) !== -1 ) {opr = that.p.stropts;} else {opr = that.p.numopts;} group.rules.push({ field: cm.name, op: opr[0], data: "" }); // adding a new rule that.reDraw(); // the html has changed, force reDraw // for the moment no change have been made to the rule, so // this will not trigger onchange event return false; }); th.append(inputAddRule); } // button for delete the group if (parentgroup !== null) { // ignore the first group var inputDeleteGroup = $(""); th.append(inputDeleteGroup); inputDeleteGroup.bind('click',function() { // remove group from parent for (i = 0; i < parentgroup.groups.length; i++) { if (parentgroup.groups[i] === group) { parentgroup.groups.splice(i, 1); break; } } that.reDraw(); // the html has changed, force reDraw that.onchange(); // signals that the filter has changed return false; }); } // append subgroup rows if (group.groups !== undefined) { for (i = 0; i < group.groups.length; i++) { var trHolderForSubgroup = $(""); table.append(trHolderForSubgroup); var tdFirstHolderForSubgroup = $(""); trHolderForSubgroup.append(tdFirstHolderForSubgroup); var tdMainHolderForSubgroup = $(""); tdMainHolderForSubgroup.append(this.createTableForGroup(group.groups[i], group)); trHolderForSubgroup.append(tdMainHolderForSubgroup); } } if(group.groupOp === undefined) { group.groupOp = that.p.groupOps[0].op; } // append rules rows if (group.rules !== undefined) { for (i = 0; i < group.rules.length; i++) { table.append( this.createTableRowForRule(group.rules[i], group) ); } } return table; }; /* * Create the rule data for the filter */ this.createTableRowForRule = function(rule, group ) { // save current entity in a variable so that it could // be referenced in anonimous method calls var that=this, $t = getGrid(), tr = $(""), //document.createElement("tr"), // first column used for padding //tdFirstHolderForRule = document.createElement("td"), i, op, trpar, cm, str="", selected; //tdFirstHolderForRule.setAttribute("class", "first"); tr.append(""); // create field container var ruleFieldTd = $(""); tr.append(ruleFieldTd); // dropdown for: choosing field var ruleFieldSelect = $(""), ina, aoprs = []; ruleFieldTd.append(ruleFieldSelect); ruleFieldSelect.bind('change',function() { rule.field = $(ruleFieldSelect).val(); trpar = $(this).parents("tr:first"); for (i=0;i"+that.p.ops[ina].text+""; so++; } } $(".selectopts",trpar).empty().append( s ); $(".selectopts",trpar)[0].selectedIndex = 0; if( $.jgrid.msie && $.jgrid.msiever() < 9) { var sw = parseInt($("select.selectopts",trpar)[0].offsetWidth, 10) + 1; $(".selectopts",trpar).width( sw ); $(".selectopts",trpar).css("width","auto"); } // data $(".data",trpar).empty().append( elm ); $.jgrid.bindEv.call($t, elm, cm.searchoptions); $(".input-elm",trpar).bind('change',function( e ) { var tmo = $(this).hasClass("ui-autocomplete-input") ? 200 :0; setTimeout(function(){ var elem = e.target; rule.data = elem.nodeName.toUpperCase() === "SPAN" && cm.searchoptions && $.isFunction(cm.searchoptions.custom_value) ? cm.searchoptions.custom_value.call($t, $(elem).children(".customelement:first"), 'get') : elem.value; that.onchange(); // signals that the filter has changed }, tmo); }); setTimeout(function(){ //IE, Opera, Chrome rule.data = $(elm).val(); that.onchange(); // signals that the filter has changed }, 0); }); // populate drop down with user provided column definitions var j=0; for (i = 0; i < that.p.columns.length; i++) { // but show only serchable and serchhidden = true fields var searchable = (that.p.columns[i].search === undefined) ? true: that.p.columns[i].search, hidden = (that.p.columns[i].hidden === true), ignoreHiding = (that.p.columns[i].searchoptions.searchhidden === true); if ((ignoreHiding && searchable) || (searchable && !hidden)) { selected = ""; if(rule.field === that.p.columns[i].name) { selected = " selected='selected'"; j=i; } str += ""; } } ruleFieldSelect.append( str ); // create operator container var ruleOperatorTd = $(""); tr.append(ruleOperatorTd); cm = p.columns[j]; // create it here so it can be referentiated in the onchange event //var RD = that.createElement(rule, rule.data); cm.searchoptions.id = $.jgrid.randId(); if(isIE && cm.inputtype === "text") { if(!cm.searchoptions.size) { cm.searchoptions.size = 10; } } var ruleDataInput = $.jgrid.createEl.call($t, cm.inputtype,cm.searchoptions, rule.data, true, that.p.ajaxSelectOptions, true); if(rule.op === 'nu' || rule.op === 'nn') { $(ruleDataInput).attr('readonly','true'); $(ruleDataInput).attr('disabled','true'); } //retain the state of disabled text fields in case of null ops // dropdown for: choosing operator var ruleOperatorSelect = $(""); ruleOperatorTd.append(ruleOperatorSelect); ruleOperatorSelect.bind('change',function() { rule.op = $(ruleOperatorSelect).val(); trpar = $(this).parents("tr:first"); var rd = $(".input-elm",trpar)[0]; if (rule.op === "nu" || rule.op === "nn") { // disable for operator "is null" and "is not null" rule.data = ""; rd.value = ""; rd.setAttribute("readonly", "true"); rd.setAttribute("disabled", "true"); } else { rd.removeAttribute("readonly"); rd.removeAttribute("disabled"); } that.onchange(); // signals that the filter has changed }); // populate drop down with all available operators if( cm.searchoptions.sopt ) {op = cm.searchoptions.sopt;} else if(that.p.sopt) { op= that.p.sopt; } else if ($.inArray(cm.searchtype, that.p.strarr) !== -1) {op = that.p.stropts;} else {op = that.p.numopts;} str=""; $.each(that.p.ops, function() { aoprs.push(this.oper); }); for ( i = 0; i < op.length; i++) { ina = $.inArray(op[i],aoprs); if(ina !== -1) { selected = rule.op === that.p.ops[ina].oper ? " selected='selected'" : ""; str += ""; } } ruleOperatorSelect.append( str ); // create data container var ruleDataTd = $(""); tr.append(ruleDataTd); // textbox for: data // is created previously //ruleDataInput.setAttribute("type", "text"); ruleDataTd.append(ruleDataInput); $.jgrid.bindEv.call($t, ruleDataInput, cm.searchoptions); $(ruleDataInput) .addClass("input-elm") .bind('change', function() { rule.data = cm.inputtype === 'custom' ? cm.searchoptions.custom_value.call($t, $(this).children(".customelement:first"),'get') : $(this).val(); that.onchange(); // signals that the filter has changed }); // create action container var ruleDeleteTd = $(""); tr.append(ruleDeleteTd); // create button for: delete rule if(this.p.ruleButtons === true) { var ruleDeleteInput = $(""); ruleDeleteTd.append(ruleDeleteInput); //$(ruleDeleteInput).html("").height(20).width(30).button({icons: { primary: "ui-icon-minus", text:false}}); ruleDeleteInput.bind('click',function() { // remove rule from group for (i = 0; i < group.rules.length; i++) { if (group.rules[i] === rule) { group.rules.splice(i, 1); break; } } that.reDraw(); // the html has changed, force reDraw that.onchange(); // signals that the filter has changed return false; }); } return tr; }; this.getStringForGroup = function(group) { var s = "(", index; if (group.groups !== undefined) { for (index = 0; index < group.groups.length; index++) { if (s.length > 1) { s += " " + group.groupOp + " "; } try { s += this.getStringForGroup(group.groups[index]); } catch (eg) {alert(eg);} } } if (group.rules !== undefined) { try{ for (index = 0; index < group.rules.length; index++) { if (s.length > 1) { s += " " + group.groupOp + " "; } s += this.getStringForRule(group.rules[index]); } } catch (e) {alert(e);} } s += ")"; if (s === "()") { return ""; // ignore groups that don't have rules } return s; }; this.getStringForRule = function(rule) { var opUF = "",opC="", i, cm, ret, val, numtypes = ['int', 'integer', 'float', 'number', 'currency']; // jqGrid for (i = 0; i < this.p.ops.length; i++) { if (this.p.ops[i].oper === rule.op) { opUF = this.p.operands.hasOwnProperty(rule.op) ? this.p.operands[rule.op] : ""; opC = this.p.ops[i].oper; break; } } for (i=0; i 1) { if (group.groupOp === "OR") { s += " || "; } else { s += " && "; } } s += getStringForGroup(group.groups[index]); } } if (group.rules !== undefined) { for (index = 0; index < group.rules.length; index++) { if (s.length > 1) { if (group.groupOp === "OR") { s += " || "; } else { s += " && "; } } s += getStringRule(group.rules[index]); } } s += ")"; if (s === "()") { return ""; // ignore groups that don't have rules } return s; } return getStringForGroup(this.p.filter); }; // Here we init the filter this.reDraw(); if(this.p.showQuery) { this.onchange(); } // mark is as created so that it will not be created twice on this element this.filter = true; }); }; $.extend($.fn.jqFilter,{ /* * Return SQL like string. Can be used directly */ toSQLString : function() { var s =""; this.each(function(){ s = this.toUserFriendlyString(); }); return s; }, /* * Return filter data as object. */ filterData : function() { var s; this.each(function(){ s = this.p.filter; }); return s; }, getParameter : function (param) { if(param !== undefined) { if (this.p.hasOwnProperty(param) ) { return this.p[param]; } } return this.p; }, resetFilter: function() { return this.each(function(){ this.resetFilter(); }); }, addFilter: function (pfilter) { if (typeof pfilter === "string") { pfilter = $.jgrid.parse( pfilter ); } this.each(function(){ this.p.filter = pfilter; this.reDraw(); this.onchange(); }); } }); })(jQuery); /*jshint eqeqeq:false, eqnull:true, devel:true */ /*global xmlJsonClass, jQuery */ (function($){ /** * jqGrid extension for form editing Grid Data * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl-2.0.html **/ "use strict"; var rp_ge = {}; $.jgrid.extend({ searchGrid : function (p) { p = $.extend(true, { recreateFilter: false, drag: true, sField:'searchField', sValue:'searchString', sOper: 'searchOper', sFilter: 'filters', loadDefaults: true, // this options activates loading of default filters from grid's postData for Multipe Search only. beforeShowSearch: null, afterShowSearch : null, onInitializeSearch: null, afterRedraw : null, afterChange: null, closeAfterSearch : false, closeAfterReset: false, closeOnEscape : false, searchOnEnter : false, multipleSearch : false, multipleGroup : false, //cloneSearchRowOnAdd: true, top : 0, left: 0, jqModal : true, modal: false, resize : true, width: 450, height: 'auto', dataheight: 'auto', showQuery: false, errorcheck : true, sopt: null, stringResult: undefined, onClose : null, onSearch : null, onReset : null, toTop : true, overlay : 30, columns : [], tmplNames : null, tmplFilters : null, tmplLabel : ' Template: ', showOnLoad: false, layer: null, operands : { "eq" :"=", "ne":"<>","lt":"<","le":"<=","gt":">","ge":">=","bw":"LIKE","bn":"NOT LIKE","in":"IN","ni":"NOT IN","ew":"LIKE","en":"NOT LIKE","cn":"LIKE","nc":"NOT LIKE","nu":"IS NULL","nn":"ISNOT NULL"} }, $.jgrid.search, p || {}); return this.each(function() { var $t = this; if(!$t.grid) {return;} var fid = "fbox_"+$t.p.id, showFrm = true, IDs = {themodal:'searchmod'+fid,modalhead:'searchhd'+fid,modalcontent:'searchcnt'+fid, scrollelm : fid}, defaultFilters = $t.p.postData[p.sFilter]; if(typeof defaultFilters === "string") { defaultFilters = $.jgrid.parse( defaultFilters ); } if(p.recreateFilter === true) { $("#"+$.jgrid.jqID(IDs.themodal)).remove(); } function showFilter(_filter) { showFrm = $($t).triggerHandler("jqGridFilterBeforeShow", [_filter]); if(showFrm === undefined) { showFrm = true; } if(showFrm && $.isFunction(p.beforeShowSearch)) { showFrm = p.beforeShowSearch.call($t,_filter); } if(showFrm) { $.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(fid),jqm:p.jqModal, modal:p.modal, overlay: p.overlay, toTop: p.toTop}); $($t).triggerHandler("jqGridFilterAfterShow", [_filter]); if($.isFunction(p.afterShowSearch)) { p.afterShowSearch.call($t, _filter); } } } if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) { showFilter($("#fbox_"+$.jgrid.jqID(+$t.p.id))); } else { var fil = $("
    ").insertBefore("#gview_"+$.jgrid.jqID($t.p.id)), align = "left", butleft =""; if($t.p.direction === "rtl") { align = "right"; butleft = " style='text-align:left'"; fil.attr("dir","rtl"); } var columns = $.extend([],$t.p.colModel), bS =""+p.Find+"", bC =""+p.Reset+"", bQ = "", tmpl="", colnm, found = false, bt, cmi=-1; if(p.showQuery) { bQ ="Query"; } if(!p.columns.length) { $.each(columns, function(i,n){ if(!n.label) { n.label = $t.p.colNames[i]; } // find first searchable column and set it if no default filter if(!found) { var searchable = (n.search === undefined) ? true: n.search , hidden = (n.hidden === true), ignoreHiding = (n.searchoptions && n.searchoptions.searchhidden === true); if ((ignoreHiding && searchable) || (searchable && !hidden)) { found = true; colnm = n.index || n.name; cmi =i; } } }); } else { columns = p.columns; cmi = 0; colnm = columns[0].index || columns[0].name; } // old behaviour if( (!defaultFilters && colnm) || p.multipleSearch === false ) { var cmop = "eq"; if(cmi >=0 && columns[cmi].searchoptions && columns[cmi].searchoptions.sopt) { cmop = columns[cmi].searchoptions.sopt[0]; } else if(p.sopt && p.sopt.length) { cmop = p.sopt[0]; } defaultFilters = {groupOp: "AND", rules: [{field: colnm, op: cmop, data: ""}]}; } found = false; if(p.tmplNames && p.tmplNames.length) { found = true; tmpl = p.tmplLabel; tmpl += ""; } bt = "

    "+bC+tmpl+""+bQ+bS+"
    "; fid = $.jgrid.jqID( fid); $("#"+fid).jqFilter({ columns : columns, filter: p.loadDefaults ? defaultFilters : null, showQuery: p.showQuery, errorcheck : p.errorcheck, sopt: p.sopt, groupButton : p.multipleGroup, ruleButtons : p.multipleSearch, afterRedraw : p.afterRedraw, ops : p.odata, operands : p.operands, ajaxSelectOptions: $t.p.ajaxSelectOptions, groupOps: p.groupOps, onChange : function() { if(this.p.showQuery) { $('.query',this).html(this.toUserFriendlyString()); } if ($.isFunction(p.afterChange)) { p.afterChange.call($t, $("#"+fid), p); } }, direction : $t.p.direction, id: $t.p.id }); fil.append( bt ); if(found && p.tmplFilters && p.tmplFilters.length) { $(".ui-tpl", fil).bind('change', function(){ var curtempl = $(this).val(); if(curtempl==="default") { $("#"+fid).jqFilter('addFilter', defaultFilters); } else { $("#"+fid).jqFilter('addFilter', p.tmplFilters[parseInt(curtempl,10)]); } return false; }); } if(p.multipleGroup === true) {p.multipleSearch = true;} $($t).triggerHandler("jqGridFilterInitialize", [$("#"+fid)]); if($.isFunction(p.onInitializeSearch) ) { p.onInitializeSearch.call($t, $("#"+fid)); } p.gbox = "#gbox_"+fid; if (p.layer) { $.jgrid.createModal(IDs ,fil,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gbox_"+$.jgrid.jqID($t.p.id))[0], "#"+$.jgrid.jqID(p.layer), {position: "relative"}); } else { $.jgrid.createModal(IDs ,fil,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gbox_"+$.jgrid.jqID($t.p.id))[0]); } if (p.searchOnEnter || p.closeOnEscape) { $("#"+$.jgrid.jqID(IDs.themodal)).keydown(function (e) { var $target = $(e.target); if (p.searchOnEnter && e.which === 13 && // 13 === $.ui.keyCode.ENTER !$target.hasClass('add-group') && !$target.hasClass('add-rule') && !$target.hasClass('delete-group') && !$target.hasClass('delete-rule') && (!$target.hasClass("fm-button") || !$target.is("[id$=_query]"))) { $("#"+fid+"_search").focus().click(); return false; } if (p.closeOnEscape && e.which === 27) { // 27 === $.ui.keyCode.ESCAPE $("#"+$.jgrid.jqID(IDs.modalhead)).find(".ui-jqdialog-titlebar-close").focus().click(); return false; } }); } if(bQ) { $("#"+fid+"_query").bind('click', function(){ $(".queryresult", fil).toggle(); return false; }); } if (p.stringResult===undefined) { // to provide backward compatibility, inferring stringResult value from multipleSearch p.stringResult = p.multipleSearch; } $("#"+fid+"_search").bind('click', function(){ var fl = $("#"+fid), sdata={}, res, filters = fl.jqFilter('filterData'); if(p.errorcheck) { fl[0].hideError(); if(!p.showQuery) {fl.jqFilter('toSQLString');} if(fl[0].p.error) { fl[0].showError(); return false; } } if(p.stringResult) { try { // xmlJsonClass or JSON.stringify res = xmlJsonClass.toJson(filters, '', '', false); } catch (e) { try { res = JSON.stringify(filters); } catch (e2) { } } if(typeof res==="string") { sdata[p.sFilter] = res; $.each([p.sField,p.sValue, p.sOper], function() {sdata[this] = "";}); } } else { if(p.multipleSearch) { sdata[p.sFilter] = filters; $.each([p.sField,p.sValue, p.sOper], function() {sdata[this] = "";}); } else { sdata[p.sField] = filters.rules[0].field; sdata[p.sValue] = filters.rules[0].data; sdata[p.sOper] = filters.rules[0].op; sdata[p.sFilter] = ""; } } $t.p.search = true; $.extend($t.p.postData,sdata); $($t).triggerHandler("jqGridFilterSearch"); if($.isFunction(p.onSearch) ) { p.onSearch.call($t); } $($t).trigger("reloadGrid",[{page:1}]); if(p.closeAfterSearch) { $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID($t.p.id),jqm:p.jqModal,onClose: p.onClose}); } return false; }); $("#"+fid+"_reset").bind('click', function(){ var sdata={}, fl = $("#"+fid); $t.p.search = false; if(p.multipleSearch===false) { sdata[p.sField] = sdata[p.sValue] = sdata[p.sOper] = ""; } else { sdata[p.sFilter] = ""; } fl[0].resetFilter(); if(found) { $(".ui-tpl", fil).val("default"); } $.extend($t.p.postData,sdata); $($t).triggerHandler("jqGridFilterReset"); if($.isFunction(p.onReset) ) { p.onReset.call($t); } $($t).trigger("reloadGrid",[{page:1}]); return false; }); showFilter($("#"+fid)); $(".fm-button:not(.ui-state-disabled)",fil).hover( function(){$(this).addClass('ui-state-hover');}, function(){$(this).removeClass('ui-state-hover');} ); } }); }, editGridRow : function(rowid, p){ p = $.extend(true, { top : 0, left: 0, width: 300, datawidth: 'auto', height: 'auto', dataheight: 'auto', modal: false, overlay : 30, drag: true, resize: true, url: null, mtype : "POST", clearAfterAdd :true, closeAfterEdit : false, reloadAfterSubmit : true, onInitializeForm: null, beforeInitData: null, beforeShowForm: null, afterShowForm: null, beforeSubmit: null, afterSubmit: null, onclickSubmit: null, afterComplete: null, onclickPgButtons : null, afterclickPgButtons: null, editData : {}, recreateForm : false, jqModal : true, closeOnEscape : false, addedrow : "first", topinfo : '', bottominfo: '', saveicon : [], closeicon : [], savekey: [false,13], navkeys: [false,38,40], checkOnSubmit : false, checkOnUpdate : false, _savedData : {}, processing : false, onClose : null, ajaxEditOptions : {}, serializeEditData : null, viewPagerButtons : true, overlayClass : 'ui-widget-overlay' }, $.jgrid.edit, p || {}); rp_ge[$(this)[0].p.id] = p; return this.each(function(){ var $t = this; if (!$t.grid || !rowid) {return;} var gID = $t.p.id, frmgr = "FrmGrid_"+gID, frmtborg = "TblGrid_"+gID, frmtb = "#"+$.jgrid.jqID(frmtborg), IDs = {themodal:'editmod'+gID,modalhead:'edithd'+gID,modalcontent:'editcnt'+gID, scrollelm : frmgr}, onBeforeShow = $.isFunction(rp_ge[$t.p.id].beforeShowForm) ? rp_ge[$t.p.id].beforeShowForm : false, onAfterShow = $.isFunction(rp_ge[$t.p.id].afterShowForm) ? rp_ge[$t.p.id].afterShowForm : false, onBeforeInit = $.isFunction(rp_ge[$t.p.id].beforeInitData) ? rp_ge[$t.p.id].beforeInitData : false, onInitializeForm = $.isFunction(rp_ge[$t.p.id].onInitializeForm) ? rp_ge[$t.p.id].onInitializeForm : false, showFrm = true, maxCols = 1, maxRows=0, postdata, diff, frmoper; frmgr = $.jgrid.jqID(frmgr); if (rowid === "new") { rowid = "_empty"; frmoper = "add"; p.caption=rp_ge[$t.p.id].addCaption; } else { p.caption=rp_ge[$t.p.id].editCaption; frmoper = "edit"; } if(p.recreateForm===true && $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined) { $("#"+$.jgrid.jqID(IDs.themodal)).remove(); } var closeovrl = true; if(p.checkOnUpdate && p.jqModal && !p.modal) { closeovrl = false; } function getFormData(){ $(frmtb+" > tbody > tr > td > .FormElement").each(function() { var celm = $(".customelement", this); if (celm.length) { var elem = celm[0], nm = $(elem).attr('name'); $.each($t.p.colModel, function(){ if(this.name === nm && this.editoptions && $.isFunction(this.editoptions.custom_value)) { try { postdata[nm] = this.editoptions.custom_value.call($t, $("#"+$.jgrid.jqID(nm),frmtb),'get'); if (postdata[nm] === undefined) {throw "e1";} } catch (e) { if (e==="e1") {$.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose);} else {$.jgrid.info_dialog($.jgrid.errors.errcap,e.message,$.jgrid.edit.bClose);} } return true; } }); } else { switch ($(this).get(0).type) { case "checkbox": if($(this).is(":checked")) { postdata[this.name]= $(this).val(); }else { var ofv = $(this).attr("offval"); postdata[this.name]= ofv; } break; case "select-one": postdata[this.name]= $("option:selected",this).val(); break; case "select-multiple": postdata[this.name]= $(this).val(); if(postdata[this.name]) {postdata[this.name] = postdata[this.name].join(",");} else {postdata[this.name] ="";} var selectedText = []; $("option:selected",this).each( function(i,selected){ selectedText[i] = $(selected).text(); } ); break; case "password": case "text": case "textarea": case "button": postdata[this.name] = $(this).val(); break; } if($t.p.autoencode) {postdata[this.name] = $.jgrid.htmlEncode(postdata[this.name]);} } }); return true; } function createData(rowid,obj,tb,maxcols){ var nm, hc,trdata, cnt=0,tmp, dc,elc, retpos=[], ind=false, tdtmpl = "  ", tmpl="", i; //*2 for (i =1; i<=maxcols;i++) { tmpl += tdtmpl; } if(rowid !== '_empty') { ind = $(obj).jqGrid("getInd",rowid); } $(obj.p.colModel).each( function(i) { nm = this.name; // hidden fields are included in the form if(this.editrules && this.editrules.edithidden === true) { hc = false; } else { hc = this.hidden === true ? true : false; } dc = hc ? "style='display:none'" : ""; if ( nm !== 'cb' && nm !== 'subgrid' && this.editable===true && nm !== 'rn') { if(ind === false) { tmp = ""; } else { if(nm === obj.p.ExpandColumn && obj.p.treeGrid === true) { tmp = $("td[role='gridcell']:eq("+i+")",obj.rows[ind]).text(); } else { try { tmp = $.unformat.call(obj, $("td[role='gridcell']:eq("+i+")",obj.rows[ind]),{rowId:rowid, colModel:this},i); } catch (_) { tmp = (this.edittype && this.edittype === "textarea") ? $("td[role='gridcell']:eq("+i+")",obj.rows[ind]).text() : $("td[role='gridcell']:eq("+i+")",obj.rows[ind]).html(); } if(!tmp || tmp === " " || tmp === " " || (tmp.length===1 && tmp.charCodeAt(0)===160) ) {tmp='';} } } var opt = $.extend({}, this.editoptions || {} ,{id:nm,name:nm}), frmopt = $.extend({}, {elmprefix:'',elmsuffix:'',rowabove:false,rowcontent:''}, this.formoptions || {}), rp = parseInt(frmopt.rowpos,10) || cnt+1, cp = parseInt((parseInt(frmopt.colpos,10) || 1)*2,10); if(rowid === "_empty" && opt.defaultValue ) { tmp = $.isFunction(opt.defaultValue) ? opt.defaultValue.call($t) : opt.defaultValue; } if(!this.edittype) {this.edittype = "text";} if($t.p.autoencode) {tmp = $.jgrid.htmlDecode(tmp);} elc = $.jgrid.createEl.call($t,this.edittype,opt,tmp,false,$.extend({},$.jgrid.ajaxOptions,obj.p.ajaxSelectOptions || {})); //if(tmp === "" && this.edittype == "checkbox") {tmp = $(elc).attr("offval");} //if(tmp === "" && this.edittype == "select") {tmp = $("option:eq(0)",elc).text();} if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData[nm] = tmp;} $(elc).addClass("FormElement"); if( $.inArray(this.edittype, ['text','textarea','password','select']) > -1) { $(elc).addClass("ui-widget-content ui-corner-all"); } trdata = $(tb).find("tr[rowpos="+rp+"]"); if(frmopt.rowabove) { var newdata = $(""+frmopt.rowcontent+""); $(tb).append(newdata); newdata[0].rp = rp; } if ( trdata.length===0 ) { trdata = $("").addClass("FormData").attr("id","tr_"+nm); $(trdata).append(tmpl); $(tb).append(trdata); trdata[0].rp = rp; } $("td:eq("+(cp-2)+")",trdata[0]).html(frmopt.label === undefined ? obj.p.colNames[i]: frmopt.label); $("td:eq("+(cp-1)+")",trdata[0]).append(frmopt.elmprefix).append(elc).append(frmopt.elmsuffix); if($.isFunction(opt.custom_value) && rowid !== "_empty" ) { opt.custom_value.call($t, $("#"+nm,"#"+frmgr),'set',tmp); } $.jgrid.bindEv.call($t, elc, opt); retpos[cnt] = i; cnt++; } }); if( cnt > 0) { var idrow = $(""); idrow[0].rp = cnt+999; $(tb).append(idrow); if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData[obj.p.id+"_id"] = rowid;} } return retpos; } function fillData(rowid,obj,fmid){ var nm,cnt=0,tmp, fld,opt,vl,vlc; if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData = {};rp_ge[$t.p.id]._savedData[obj.p.id+"_id"]=rowid;} var cm = obj.p.colModel; if(rowid === '_empty') { $(cm).each(function(){ nm = this.name; opt = $.extend({}, this.editoptions || {} ); fld = $("#"+$.jgrid.jqID(nm),"#"+fmid); if(fld && fld.length && fld[0] !== null) { vl = ""; if(opt.defaultValue ) { vl = $.isFunction(opt.defaultValue) ? opt.defaultValue.call($t) : opt.defaultValue; if(fld[0].type==='checkbox') { vlc = vl.toLowerCase(); if(vlc.search(/(false|f|0|no|n|off|undefined)/i)<0 && vlc!=="") { fld[0].checked = true; fld[0].defaultChecked = true; fld[0].value = vl; } else { fld[0].checked = false; fld[0].defaultChecked = false; } } else {fld.val(vl);} } else { if( fld[0].type==='checkbox' ) { fld[0].checked = false; fld[0].defaultChecked = false; vl = $(fld).attr("offval"); } else if (fld[0].type && fld[0].type.substr(0,6)==='select') { fld[0].selectedIndex = 0; } else { fld.val(vl); } } if(rp_ge[$t.p.id].checkOnSubmit===true || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData[nm] = vl;} } }); $("#id_g","#"+fmid).val(rowid); return; } var tre = $(obj).jqGrid("getInd",rowid,true); if(!tre) {return;} $('td[role="gridcell"]',tre).each( function(i) { nm = cm[i].name; // hidden fields are included in the form if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn' && cm[i].editable===true) { if(nm === obj.p.ExpandColumn && obj.p.treeGrid === true) { tmp = $(this).text(); } else { try { tmp = $.unformat.call(obj, $(this),{rowId:rowid, colModel:cm[i]},i); } catch (_) { tmp = cm[i].edittype==="textarea" ? $(this).text() : $(this).html(); } } if($t.p.autoencode) {tmp = $.jgrid.htmlDecode(tmp);} if(rp_ge[$t.p.id].checkOnSubmit===true || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData[nm] = tmp;} nm = $.jgrid.jqID(nm); switch (cm[i].edittype) { case "password": case "text": case "button" : case "image": case "textarea": if(tmp === " " || tmp === " " || (tmp.length===1 && tmp.charCodeAt(0)===160) ) {tmp='';} $("#"+nm,"#"+fmid).val(tmp); break; case "select": var opv = tmp.split(","); opv = $.map(opv,function(n){return $.trim(n);}); $("#"+nm+" option","#"+fmid).each(function(){ if (!cm[i].editoptions.multiple && ($.trim(tmp) === $.trim($(this).text()) || opv[0] === $.trim($(this).text()) || opv[0] === $.trim($(this).val())) ){ this.selected= true; } else if (cm[i].editoptions.multiple){ if( $.inArray($.trim($(this).text()), opv ) > -1 || $.inArray($.trim($(this).val()), opv ) > -1 ){ this.selected = true; }else{ this.selected = false; } } else { this.selected = false; } }); break; case "checkbox": tmp = String(tmp); if(cm[i].editoptions && cm[i].editoptions.value) { var cb = cm[i].editoptions.value.split(":"); if(cb[0] === tmp) { $("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']({"checked":true, "defaultChecked" : true}); } else { $("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']({"checked":false, "defaultChecked" : false}); } } else { tmp = tmp.toLowerCase(); if(tmp.search(/(false|f|0|no|n|off|undefined)/i)<0 && tmp!=="") { $("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("checked",true); $("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("defaultChecked",true); //ie } else { $("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("checked", false); $("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("defaultChecked", false); //ie } } break; case 'custom' : try { if(cm[i].editoptions && $.isFunction(cm[i].editoptions.custom_value)) { cm[i].editoptions.custom_value.call($t, $("#"+nm,"#"+fmid),'set',tmp); } else {throw "e1";} } catch (e) { if (e==="e1") {$.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.nodefined,$.jgrid.edit.bClose);} else {$.jgrid.info_dialog($.jgrid.errors.errcap,e.message,$.jgrid.edit.bClose);} } break; } cnt++; } }); if(cnt>0) {$("#id_g",frmtb).val(rowid);} } function setNulls() { $.each($t.p.colModel, function(i,n){ if(n.editoptions && n.editoptions.NullIfEmpty === true) { if(postdata.hasOwnProperty(n.name) && postdata[n.name] === "") { postdata[n.name] = 'null'; } } }); } function postIt() { var copydata, ret=[true,"",""], onCS = {}, opers = $t.p.prmNames, idname, oper, key, selr, i; var retvals = $($t).triggerHandler("jqGridAddEditBeforeCheckValues", [$("#"+frmgr), frmoper]); if(retvals && typeof retvals === 'object') {postdata = retvals;} if($.isFunction(rp_ge[$t.p.id].beforeCheckValues)) { retvals = rp_ge[$t.p.id].beforeCheckValues.call($t, postdata,$("#"+frmgr),frmoper); if(retvals && typeof retvals === 'object') {postdata = retvals;} } for( key in postdata ){ if(postdata.hasOwnProperty(key)) { ret = $.jgrid.checkValues.call($t,postdata[key],key); if(ret[0] === false) {break;} } } setNulls(); if(ret[0]) { onCS = $($t).triggerHandler("jqGridAddEditClickSubmit", [rp_ge[$t.p.id], postdata, frmoper]); if( onCS === undefined && $.isFunction( rp_ge[$t.p.id].onclickSubmit)) { onCS = rp_ge[$t.p.id].onclickSubmit.call($t, rp_ge[$t.p.id], postdata, frmoper) || {}; } ret = $($t).triggerHandler("jqGridAddEditBeforeSubmit", [postdata, $("#"+frmgr), frmoper]); if(ret === undefined) { ret = [true,"",""]; } if( ret[0] && $.isFunction(rp_ge[$t.p.id].beforeSubmit)) { ret = rp_ge[$t.p.id].beforeSubmit.call($t,postdata,$("#"+frmgr), frmoper); } } if(ret[0] && !rp_ge[$t.p.id].processing) { rp_ge[$t.p.id].processing = true; $("#sData", frmtb+"_2").addClass('ui-state-active'); oper = opers.oper; idname = opers.id; // we add to pos data array the action - the name is oper postdata[oper] = ($.trim(postdata[$t.p.id+"_id"]) === "_empty") ? opers.addoper : opers.editoper; if(postdata[oper] !== opers.addoper) { postdata[idname] = postdata[$t.p.id+"_id"]; } else { // check to see if we have allredy this field in the form and if yes lieve it if( postdata[idname] === undefined ) {postdata[idname] = postdata[$t.p.id+"_id"];} } delete postdata[$t.p.id+"_id"]; postdata = $.extend(postdata,rp_ge[$t.p.id].editData,onCS); if($t.p.treeGrid === true) { if(postdata[oper] === opers.addoper) { selr = $($t).jqGrid("getGridParam", 'selrow'); var tr_par_id = $t.p.treeGridModel === 'adjacency' ? $t.p.treeReader.parent_id_field : 'parent_id'; postdata[tr_par_id] = selr; } for(i in $t.p.treeReader){ if($t.p.treeReader.hasOwnProperty(i)) { var itm = $t.p.treeReader[i]; if(postdata.hasOwnProperty(itm)) { if(postdata[oper] === opers.addoper && i === 'parent_id_field') {continue;} delete postdata[itm]; } } } } postdata[idname] = $.jgrid.stripPref($t.p.idPrefix, postdata[idname]); var ajaxOptions = $.extend({ url: rp_ge[$t.p.id].url || $($t).jqGrid('getGridParam','editurl'), type: rp_ge[$t.p.id].mtype, data: $.isFunction(rp_ge[$t.p.id].serializeEditData) ? rp_ge[$t.p.id].serializeEditData.call($t,postdata) : postdata, complete:function(data,status){ var key; postdata[idname] = $t.p.idPrefix + postdata[idname]; if(data.status >= 300 && data.status !== 304) { ret[0] = false; ret[1] = $($t).triggerHandler("jqGridAddEditErrorTextFormat", [data, frmoper]); if ($.isFunction(rp_ge[$t.p.id].errorTextFormat)) { ret[1] = rp_ge[$t.p.id].errorTextFormat.call($t, data, frmoper); } else { ret[1] = status + " Status: '" + data.statusText + "'. Error code: " + data.status; } } else { // data is posted successful // execute aftersubmit with the returned data from server ret = $($t).triggerHandler("jqGridAddEditAfterSubmit", [data, postdata, frmoper]); if(ret === undefined) { ret = [true,"",""]; } if( ret[0] && $.isFunction(rp_ge[$t.p.id].afterSubmit) ) { ret = rp_ge[$t.p.id].afterSubmit.call($t, data,postdata, frmoper); } } if(ret[0] === false) { $("#FormError>td",frmtb).html(ret[1]); $("#FormError",frmtb).show(); } else { if($t.p.autoencode) { $.each(postdata,function(n,v){ postdata[n] = $.jgrid.htmlDecode(v); }); } //rp_ge[$t.p.id].reloadAfterSubmit = rp_ge[$t.p.id].reloadAfterSubmit && $t.p.datatype != "local"; // the action is add if(postdata[oper] === opers.addoper ) { //id processing // user not set the id ret[2] if(!ret[2]) {ret[2] = $.jgrid.randId();} postdata[idname] = ret[2]; if(rp_ge[$t.p.id].reloadAfterSubmit) { $($t).trigger("reloadGrid"); } else { if($t.p.treeGrid === true){ $($t).jqGrid("addChildNode",ret[2],selr,postdata ); } else { $($t).jqGrid("addRowData",ret[2],postdata,p.addedrow); } } if(rp_ge[$t.p.id].closeAfterAdd) { if($t.p.treeGrid !== true){ $($t).jqGrid("setSelection",ret[2]); } $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose}); } else if (rp_ge[$t.p.id].clearAfterAdd) { fillData("_empty",$t,frmgr); } } else { // the action is update if(rp_ge[$t.p.id].reloadAfterSubmit) { $($t).trigger("reloadGrid"); if( !rp_ge[$t.p.id].closeAfterEdit ) {setTimeout(function(){$($t).jqGrid("setSelection",postdata[idname]);},1000);} } else { if($t.p.treeGrid === true) { $($t).jqGrid("setTreeRow", postdata[idname],postdata); } else { $($t).jqGrid("setRowData", postdata[idname],postdata); } } if(rp_ge[$t.p.id].closeAfterEdit) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});} } if($.isFunction(rp_ge[$t.p.id].afterComplete)) { copydata = data; setTimeout(function(){ $($t).triggerHandler("jqGridAddEditAfterComplete", [copydata, postdata, $("#"+frmgr), frmoper]); rp_ge[$t.p.id].afterComplete.call($t, copydata, postdata, $("#"+frmgr), frmoper); copydata=null; },500); } if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) { $("#"+frmgr).data("disabled",false); if(rp_ge[$t.p.id]._savedData[$t.p.id+"_id"] !== "_empty"){ for(key in rp_ge[$t.p.id]._savedData) { if(rp_ge[$t.p.id]._savedData.hasOwnProperty(key) && postdata[key]) { rp_ge[$t.p.id]._savedData[key] = postdata[key]; } } } } } rp_ge[$t.p.id].processing=false; $("#sData", frmtb+"_2").removeClass('ui-state-active'); try{$(':input:visible',"#"+frmgr)[0].focus();} catch (e){} } }, $.jgrid.ajaxOptions, rp_ge[$t.p.id].ajaxEditOptions ); if (!ajaxOptions.url && !rp_ge[$t.p.id].useDataProxy) { if ($.isFunction($t.p.dataProxy)) { rp_ge[$t.p.id].useDataProxy = true; } else { ret[0]=false;ret[1] += " "+$.jgrid.errors.nourl; } } if (ret[0]) { if (rp_ge[$t.p.id].useDataProxy) { var dpret = $t.p.dataProxy.call($t, ajaxOptions, "set_"+$t.p.id); if(dpret === undefined) { dpret = [true, ""]; } if(dpret[0] === false ) { ret[0] = false; ret[1] = dpret[1] || "Error deleting the selected row!" ; } else { if(ajaxOptions.data.oper === opers.addoper && rp_ge[$t.p.id].closeAfterAdd ) { $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose}); } if(ajaxOptions.data.oper === opers.editoper && rp_ge[$t.p.id].closeAfterEdit ) { $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose}); } } } else { $.ajax(ajaxOptions); } } } if(ret[0] === false) { $("#FormError>td",frmtb).html(ret[1]); $("#FormError",frmtb).show(); // return; } } function compareData(nObj, oObj ) { var ret = false,key; for (key in nObj) { if(nObj.hasOwnProperty(key) && nObj[key] != oObj[key]) { ret = true; break; } } return ret; } function checkUpdates () { var stat = true; $("#FormError",frmtb).hide(); if(rp_ge[$t.p.id].checkOnUpdate) { postdata = {}; getFormData(); diff = compareData(postdata,rp_ge[$t.p.id]._savedData); if(diff) { $("#"+frmgr).data("disabled",true); $(".confirm","#"+IDs.themodal).show(); stat = false; } } return stat; } function restoreInline() { var i; if (rowid !== "_empty" && $t.p.savedRow !== undefined && $t.p.savedRow.length > 0 && $.isFunction($.fn.jqGrid.restoreRow)) { for (i=0;i<$t.p.savedRow.length;i++) { if ($t.p.savedRow[i].id == rowid) { $($t).jqGrid('restoreRow',rowid); break; } } } } function updateNav(cr, posarr){ var totr = posarr[1].length-1; if (cr===0) { $("#pData",frmtb+"_2").addClass('ui-state-disabled'); } else if( posarr[1][cr-1] !== undefined && $("#"+$.jgrid.jqID(posarr[1][cr-1])).hasClass('ui-state-disabled')) { $("#pData",frmtb+"_2").addClass('ui-state-disabled'); } else { $("#pData",frmtb+"_2").removeClass('ui-state-disabled'); } if (cr===totr) { $("#nData",frmtb+"_2").addClass('ui-state-disabled'); } else if( posarr[1][cr+1] !== undefined && $("#"+$.jgrid.jqID(posarr[1][cr+1])).hasClass('ui-state-disabled')) { $("#nData",frmtb+"_2").addClass('ui-state-disabled'); } else { $("#nData",frmtb+"_2").removeClass('ui-state-disabled'); } } function getCurrPos() { var rowsInGrid = $($t).jqGrid("getDataIDs"), selrow = $("#id_g",frmtb).val(), pos = $.inArray(selrow,rowsInGrid); return [pos,rowsInGrid]; } if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) { showFrm = $($t).triggerHandler("jqGridAddEditBeforeInitData", [$("#"+$.jgrid.jqID(frmgr)), frmoper]); if(showFrm === undefined) { showFrm = true; } if(showFrm && onBeforeInit) { showFrm = onBeforeInit.call($t,$("#"+frmgr), frmoper); } if(showFrm === false) {return;} restoreInline(); $(".ui-jqdialog-title","#"+$.jgrid.jqID(IDs.modalhead)).html(p.caption); $("#FormError",frmtb).hide(); if(rp_ge[$t.p.id].topinfo) { $(".topinfo",frmtb).html(rp_ge[$t.p.id].topinfo); $(".tinfo",frmtb).show(); } else { $(".tinfo",frmtb).hide(); } if(rp_ge[$t.p.id].bottominfo) { $(".bottominfo",frmtb+"_2").html(rp_ge[$t.p.id].bottominfo); $(".binfo",frmtb+"_2").show(); } else { $(".binfo",frmtb+"_2").hide(); } // filldata fillData(rowid,$t,frmgr); /// if(rowid==="_empty" || !rp_ge[$t.p.id].viewPagerButtons) { $("#pData, #nData",frmtb+"_2").hide(); } else { $("#pData, #nData",frmtb+"_2").show(); } if(rp_ge[$t.p.id].processing===true) { rp_ge[$t.p.id].processing=false; $("#sData", frmtb+"_2").removeClass('ui-state-active'); } if($("#"+frmgr).data("disabled")===true) { $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide(); $("#"+frmgr).data("disabled",false); } $($t).triggerHandler("jqGridAddEditBeforeShowForm", [$("#"+frmgr), frmoper]); if(onBeforeShow) { onBeforeShow.call($t, $("#"+frmgr), frmoper); } $("#"+$.jgrid.jqID(IDs.themodal)).data("onClose",rp_ge[$t.p.id].onClose); $.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, jqM: false, overlay: p.overlay, modal:p.modal, overlayClass : p.overlayClass}); if(!closeovrl) { $("." + $.jgrid.jqID(p.overlayClass)).click(function(){ if(!checkUpdates()) {return false;} $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose}); return false; }); } $($t).triggerHandler("jqGridAddEditAfterShowForm", [$("#"+frmgr), frmoper]); if(onAfterShow) { onAfterShow.call($t, $("#"+frmgr), frmoper); } } else { var dh = isNaN(p.dataheight) ? p.dataheight : p.dataheight+"px", dw = isNaN(p.datawidth) ? p.datawidth : p.datawidth+"px", frm = $("
    ").data("disabled",false), tbl = $("
    "); showFrm = $($t).triggerHandler("jqGridAddEditBeforeInitData", [$("#"+frmgr), frmoper]); if(showFrm === undefined) { showFrm = true; } if(showFrm && onBeforeInit) { showFrm = onBeforeInit.call($t,$("#"+frmgr,frmoper)); } if(showFrm === false) {return;} restoreInline(); $($t.p.colModel).each( function() { var fmto = this.formoptions; maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0 ); maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0 ); }); $(frm).append(tbl); var flr = $(""); flr[0].rp = 0; $(tbl).append(flr); //topinfo flr = $(""+rp_ge[$t.p.id].topinfo+""); flr[0].rp = 0; $(tbl).append(flr); // set the id. // use carefull only to change here colproperties. // create data var rtlb = $t.p.direction === "rtl" ? true :false, bp = rtlb ? "nData" : "pData", bn = rtlb ? "pData" : "nData"; createData(rowid,$t,tbl,maxCols); // buttons at footer var bP = "", bN = "", bS =""+p.bSubmit+"", bC =""+p.bCancel+""; var bt = ""; bt += ""; bt += "

    "+bS+bC+"
    "; if(maxRows > 0) { var sd=[]; $.each($(tbl)[0].rows,function(i,r){ sd[i] = r; }); sd.sort(function(a,b){ if(a.rp > b.rp) {return 1;} if(a.rp < b.rp) {return -1;} return 0; }); $.each(sd, function(index, row) { $('tbody',tbl).append(row); }); } p.gbox = "#gbox_"+$.jgrid.jqID(gID); var cle = false; if(p.closeOnEscape===true){ p.closeOnEscape = false; cle = true; } var tms = $("
    ").append(frm).append(bt); $.jgrid.createModal(IDs,tms,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gbox_"+$.jgrid.jqID($t.p.id))[0]); if(rtlb) { $("#pData, #nData",frmtb+"_2").css("float","right"); $(".EditButton",frmtb+"_2").css("text-align","left"); } if(rp_ge[$t.p.id].topinfo) {$(".tinfo",frmtb).show();} if(rp_ge[$t.p.id].bottominfo) {$(".binfo",frmtb+"_2").show();} tms = null;bt=null; $("#"+$.jgrid.jqID(IDs.themodal)).keydown( function( e ) { var wkey = e.target; if ($("#"+frmgr).data("disabled")===true ) {return false;}//?? if(rp_ge[$t.p.id].savekey[0] === true && e.which === rp_ge[$t.p.id].savekey[1]) { // save if(wkey.tagName !== "TEXTAREA") { $("#sData", frmtb+"_2").trigger("click"); return false; } } if(e.which === 27) { if(!checkUpdates()) {return false;} if(cle) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:p.gbox,jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});} return false; } if(rp_ge[$t.p.id].navkeys[0]===true) { if($("#id_g",frmtb).val() === "_empty") {return true;} if(e.which === rp_ge[$t.p.id].navkeys[1]){ //up $("#pData", frmtb+"_2").trigger("click"); return false; } if(e.which === rp_ge[$t.p.id].navkeys[2]){ //down $("#nData", frmtb+"_2").trigger("click"); return false; } } }); if(p.checkOnUpdate) { $("a.ui-jqdialog-titlebar-close span","#"+$.jgrid.jqID(IDs.themodal)).removeClass("jqmClose"); $("a.ui-jqdialog-titlebar-close","#"+$.jgrid.jqID(IDs.themodal)).unbind("click") .click(function(){ if(!checkUpdates()) {return false;} $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose}); return false; }); } p.saveicon = $.extend([true,"left","ui-icon-disk"],p.saveicon); p.closeicon = $.extend([true,"left","ui-icon-close"],p.closeicon); // beforeinitdata after creation of the form if(p.saveicon[0]===true) { $("#sData",frmtb+"_2").addClass(p.saveicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left') .append(""); } if(p.closeicon[0]===true) { $("#cData",frmtb+"_2").addClass(p.closeicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left') .append(""); } if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) { bS =""+p.bYes+""; bN =""+p.bNo+""; bC =""+p.bExit+""; var zI = p.zIndex || 999;zI ++; $("
    "+p.saveData+"

    "+bS+bN+bC+"
    ").insertAfter("#"+frmgr); $("#sNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){ postIt(); $("#"+frmgr).data("disabled",false); $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide(); return false; }); $("#nNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){ $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide(); $("#"+frmgr).data("disabled",false); setTimeout(function(){$(":input:visible","#"+frmgr)[0].focus();},0); return false; }); $("#cNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){ $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide(); $("#"+frmgr).data("disabled",false); $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose}); return false; }); } // here initform - only once $($t).triggerHandler("jqGridAddEditInitializeForm", [$("#"+frmgr), frmoper]); if(onInitializeForm) {onInitializeForm.call($t,$("#"+frmgr), frmoper);} if(rowid==="_empty" || !rp_ge[$t.p.id].viewPagerButtons) {$("#pData,#nData",frmtb+"_2").hide();} else {$("#pData,#nData",frmtb+"_2").show();} $($t).triggerHandler("jqGridAddEditBeforeShowForm", [$("#"+frmgr), frmoper]); if(onBeforeShow) { onBeforeShow.call($t, $("#"+frmgr), frmoper);} $("#"+$.jgrid.jqID(IDs.themodal)).data("onClose",rp_ge[$t.p.id].onClose); $.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, overlay: p.overlay,modal:p.modal, overlayClass: p.overlayClass}); if(!closeovrl) { $("." + $.jgrid.jqID(p.overlayClass)).click(function(){ if(!checkUpdates()) {return false;} $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose}); return false; }); } $($t).triggerHandler("jqGridAddEditAfterShowForm", [$("#"+frmgr), frmoper]); if(onAfterShow) { onAfterShow.call($t, $("#"+frmgr), frmoper); } $(".fm-button","#"+$.jgrid.jqID(IDs.themodal)).hover( function(){$(this).addClass('ui-state-hover');}, function(){$(this).removeClass('ui-state-hover');} ); $("#sData", frmtb+"_2").click(function(){ postdata = {}; $("#FormError",frmtb).hide(); // all depend on ret array //ret[0] - succes //ret[1] - msg if not succes //ret[2] - the id that will be set if reload after submit false getFormData(); if(postdata[$t.p.id+"_id"] === "_empty") {postIt();} else if(p.checkOnSubmit===true ) { diff = compareData(postdata,rp_ge[$t.p.id]._savedData); if(diff) { $("#"+frmgr).data("disabled",true); $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).show(); } else { postIt(); } } else { postIt(); } return false; }); $("#cData", frmtb+"_2").click(function(){ if(!checkUpdates()) {return false;} $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose}); return false; }); $("#nData", frmtb+"_2").click(function(){ if(!checkUpdates()) {return false;} $("#FormError",frmtb).hide(); var npos = getCurrPos(); npos[0] = parseInt(npos[0],10); if(npos[0] !== -1 && npos[1][npos[0]+1]) { $($t).triggerHandler("jqGridAddEditClickPgButtons", ['next',$("#"+frmgr),npos[1][npos[0]]]); var nposret; if($.isFunction(p.onclickPgButtons)) { nposret = p.onclickPgButtons.call($t, 'next',$("#"+frmgr),npos[1][npos[0]]); if( nposret !== undefined && nposret === false ) {return false;} } if( $("#"+$.jgrid.jqID(npos[1][npos[0]+1])).hasClass('ui-state-disabled')) {return false;} fillData(npos[1][npos[0]+1],$t,frmgr); $($t).jqGrid("setSelection",npos[1][npos[0]+1]); $($t).triggerHandler("jqGridAddEditAfterClickPgButtons", ['next',$("#"+frmgr),npos[1][npos[0]]]); if($.isFunction(p.afterclickPgButtons)) { p.afterclickPgButtons.call($t, 'next',$("#"+frmgr),npos[1][npos[0]+1]); } updateNav(npos[0]+1,npos); } return false; }); $("#pData", frmtb+"_2").click(function(){ if(!checkUpdates()) {return false;} $("#FormError",frmtb).hide(); var ppos = getCurrPos(); if(ppos[0] !== -1 && ppos[1][ppos[0]-1]) { $($t).triggerHandler("jqGridAddEditClickPgButtons", ['prev',$("#"+frmgr),ppos[1][ppos[0]]]); var pposret; if($.isFunction(p.onclickPgButtons)) { pposret = p.onclickPgButtons.call($t, 'prev',$("#"+frmgr),ppos[1][ppos[0]]); if( pposret !== undefined && pposret === false ) {return false;} } if( $("#"+$.jgrid.jqID(ppos[1][ppos[0]-1])).hasClass('ui-state-disabled')) {return false;} fillData(ppos[1][ppos[0]-1],$t,frmgr); $($t).jqGrid("setSelection",ppos[1][ppos[0]-1]); $($t).triggerHandler("jqGridAddEditAfterClickPgButtons", ['prev',$("#"+frmgr),ppos[1][ppos[0]]]); if($.isFunction(p.afterclickPgButtons)) { p.afterclickPgButtons.call($t, 'prev',$("#"+frmgr),ppos[1][ppos[0]-1]); } updateNav(ppos[0]-1,ppos); } return false; }); } var posInit =getCurrPos(); updateNav(posInit[0],posInit); }); }, viewGridRow : function(rowid, p){ p = $.extend(true, { top : 0, left: 0, width: 0, datawidth: 'auto', height: 'auto', dataheight: 'auto', modal: false, overlay: 30, drag: true, resize: true, jqModal: true, closeOnEscape : false, labelswidth: '30%', closeicon: [], navkeys: [false,38,40], onClose: null, beforeShowForm : null, beforeInitData : null, viewPagerButtons : true, recreateForm : false }, $.jgrid.view, p || {}); rp_ge[$(this)[0].p.id] = p; return this.each(function(){ var $t = this; if (!$t.grid || !rowid) {return;} var gID = $t.p.id, frmgr = "ViewGrid_"+$.jgrid.jqID( gID ), frmtb = "ViewTbl_" + $.jgrid.jqID( gID ), frmgr_id = "ViewGrid_"+gID, frmtb_id = "ViewTbl_"+gID, IDs = {themodal:'viewmod'+gID,modalhead:'viewhd'+gID,modalcontent:'viewcnt'+gID, scrollelm : frmgr}, onBeforeInit = $.isFunction(rp_ge[$t.p.id].beforeInitData) ? rp_ge[$t.p.id].beforeInitData : false, showFrm = true, maxCols = 1, maxRows=0; if(p.recreateForm===true && $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined) { $("#"+$.jgrid.jqID(IDs.themodal)).remove(); } function focusaref(){ //Sfari 3 issues if(rp_ge[$t.p.id].closeOnEscape===true || rp_ge[$t.p.id].navkeys[0]===true) { setTimeout(function(){$(".ui-jqdialog-titlebar-close","#"+$.jgrid.jqID(IDs.modalhead)).focus();},0); } } function createData(rowid,obj,tb,maxcols){ var nm, hc,trdata, cnt=0,tmp, dc, retpos=[], ind=false, i, tdtmpl = "  ", tmpl="", tdtmpl2 = "  ", fmtnum = ['integer','number','currency'],max1 =0, max2=0 ,maxw,setme, viewfld; for (i=1;i<=maxcols;i++) { tmpl += i === 1 ? tdtmpl : tdtmpl2; } // find max number align rigth with property formatter $(obj.p.colModel).each( function() { if(this.editrules && this.editrules.edithidden === true) { hc = false; } else { hc = this.hidden === true ? true : false; } if(!hc && this.align==='right') { if(this.formatter && $.inArray(this.formatter,fmtnum) !== -1 ) { max1 = Math.max(max1,parseInt(this.width,10)); } else { max2 = Math.max(max2,parseInt(this.width,10)); } } }); maxw = max1 !==0 ? max1 : max2 !==0 ? max2 : 0; ind = $(obj).jqGrid("getInd",rowid); $(obj.p.colModel).each( function(i) { nm = this.name; setme = false; // hidden fields are included in the form if(this.editrules && this.editrules.edithidden === true) { hc = false; } else { hc = this.hidden === true ? true : false; } dc = hc ? "style='display:none'" : ""; viewfld = (typeof this.viewable !== 'boolean') ? true : this.viewable; if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn' && viewfld) { if(ind === false) { tmp = ""; } else { if(nm === obj.p.ExpandColumn && obj.p.treeGrid === true) { tmp = $("td:eq("+i+")",obj.rows[ind]).text(); } else { tmp = $("td:eq("+i+")",obj.rows[ind]).html(); } } setme = this.align === 'right' && maxw !==0 ? true : false; var frmopt = $.extend({},{rowabove:false,rowcontent:''}, this.formoptions || {}), rp = parseInt(frmopt.rowpos,10) || cnt+1, cp = parseInt((parseInt(frmopt.colpos,10) || 1)*2,10); if(frmopt.rowabove) { var newdata = $(""+frmopt.rowcontent+""); $(tb).append(newdata); newdata[0].rp = rp; } trdata = $(tb).find("tr[rowpos="+rp+"]"); if ( trdata.length===0 ) { trdata = $("").addClass("FormData").attr("id","trv_"+nm); $(trdata).append(tmpl); $(tb).append(trdata); trdata[0].rp = rp; } $("td:eq("+(cp-2)+")",trdata[0]).html(''+ (frmopt.label === undefined ? obj.p.colNames[i]: frmopt.label)+''); $("td:eq("+(cp-1)+")",trdata[0]).append(""+tmp+"").attr("id","v_"+nm); if(setme){ $("td:eq("+(cp-1)+") span",trdata[0]).css({'text-align':'right',width:maxw+"px"}); } retpos[cnt] = i; cnt++; } }); if( cnt > 0) { var idrow = $(""); idrow[0].rp = cnt+99; $(tb).append(idrow); } return retpos; } function fillData(rowid,obj){ var nm, hc,cnt=0,tmp,trv; trv = $(obj).jqGrid("getInd",rowid,true); if(!trv) {return;} $('td',trv).each( function(i) { nm = obj.p.colModel[i].name; // hidden fields are included in the form if(obj.p.colModel[i].editrules && obj.p.colModel[i].editrules.edithidden === true) { hc = false; } else { hc = obj.p.colModel[i].hidden === true ? true : false; } if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn') { if(nm === obj.p.ExpandColumn && obj.p.treeGrid === true) { tmp = $(this).text(); } else { tmp = $(this).html(); } nm = $.jgrid.jqID("v_"+nm); $("#"+nm+" span","#"+frmtb).html(tmp); if (hc) {$("#"+nm,"#"+frmtb).parents("tr:first").hide();} cnt++; } }); if(cnt>0) {$("#id_g","#"+frmtb).val(rowid);} } function updateNav(cr,posarr){ var totr = posarr[1].length-1; if (cr===0) { $("#pData","#"+frmtb+"_2").addClass('ui-state-disabled'); } else if( posarr[1][cr-1] !== undefined && $("#"+$.jgrid.jqID(posarr[1][cr-1])).hasClass('ui-state-disabled')) { $("#pData",frmtb+"_2").addClass('ui-state-disabled'); } else { $("#pData","#"+frmtb+"_2").removeClass('ui-state-disabled'); } if (cr===totr) { $("#nData","#"+frmtb+"_2").addClass('ui-state-disabled'); } else if( posarr[1][cr+1] !== undefined && $("#"+$.jgrid.jqID(posarr[1][cr+1])).hasClass('ui-state-disabled')) { $("#nData",frmtb+"_2").addClass('ui-state-disabled'); } else { $("#nData","#"+frmtb+"_2").removeClass('ui-state-disabled'); } } function getCurrPos() { var rowsInGrid = $($t).jqGrid("getDataIDs"), selrow = $("#id_g","#"+frmtb).val(), pos = $.inArray(selrow,rowsInGrid); return [pos,rowsInGrid]; } if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) { if(onBeforeInit) { showFrm = onBeforeInit.call($t,$("#"+frmgr)); if(showFrm === undefined) { showFrm = true; } } if(showFrm === false) {return;} $(".ui-jqdialog-title","#"+$.jgrid.jqID(IDs.modalhead)).html(p.caption); $("#FormError","#"+frmtb).hide(); fillData(rowid,$t); if($.isFunction(rp_ge[$t.p.id].beforeShowForm)) {rp_ge[$t.p.id].beforeShowForm.call($t,$("#"+frmgr));} $.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, jqM: false, overlay: p.overlay, modal:p.modal}); focusaref(); } else { var dh = isNaN(p.dataheight) ? p.dataheight : p.dataheight+"px", dw = isNaN(p.datawidth) ? p.datawidth : p.datawidth+"px", frm = $("
    "), tbl =$("
    "); if(onBeforeInit) { showFrm = onBeforeInit.call($t,$("#"+frmgr)); if(showFrm === undefined) { showFrm = true; } } if(showFrm === false) {return;} $($t.p.colModel).each( function() { var fmto = this.formoptions; maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0 ); maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0 ); }); // set the id. $(frm).append(tbl); createData(rowid, $t, tbl, maxCols); var rtlb = $t.p.direction === "rtl" ? true :false, bp = rtlb ? "nData" : "pData", bn = rtlb ? "pData" : "nData", // buttons at footer bP = "", bN = "", bC =""+p.bClose+""; if(maxRows > 0) { var sd=[]; $.each($(tbl)[0].rows,function(i,r){ sd[i] = r; }); sd.sort(function(a,b){ if(a.rp > b.rp) {return 1;} if(a.rp < b.rp) {return -1;} return 0; }); $.each(sd, function(index, row) { $('tbody',tbl).append(row); }); } p.gbox = "#gbox_"+$.jgrid.jqID(gID); var bt = $("
    ").append(frm).append("
    "+bC+"
    "); $.jgrid.createModal(IDs,bt,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gview_"+$.jgrid.jqID($t.p.id))[0]); if(rtlb) { $("#pData, #nData","#"+frmtb+"_2").css("float","right"); $(".EditButton","#"+frmtb+"_2").css("text-align","left"); } if(!p.viewPagerButtons) {$("#pData, #nData","#"+frmtb+"_2").hide();} bt = null; $("#"+IDs.themodal).keydown( function( e ) { if(e.which === 27) { if(rp_ge[$t.p.id].closeOnEscape) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:p.gbox,jqm:p.jqModal, onClose: p.onClose});} return false; } if(p.navkeys[0]===true) { if(e.which === p.navkeys[1]){ //up $("#pData", "#"+frmtb+"_2").trigger("click"); return false; } if(e.which === p.navkeys[2]){ //down $("#nData", "#"+frmtb+"_2").trigger("click"); return false; } } }); p.closeicon = $.extend([true,"left","ui-icon-close"],p.closeicon); if(p.closeicon[0]===true) { $("#cData","#"+frmtb+"_2").addClass(p.closeicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left') .append(""); } if($.isFunction(p.beforeShowForm)) {p.beforeShowForm.call($t,$("#"+frmgr));} $.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,overlay: p.overlay, modal:p.modal}); $(".fm-button:not(.ui-state-disabled)","#"+frmtb+"_2").hover( function(){$(this).addClass('ui-state-hover');}, function(){$(this).removeClass('ui-state-hover');} ); focusaref(); $("#cData", "#"+frmtb+"_2").click(function(){ $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: p.onClose}); return false; }); $("#nData", "#"+frmtb+"_2").click(function(){ $("#FormError","#"+frmtb).hide(); var npos = getCurrPos(); npos[0] = parseInt(npos[0],10); if(npos[0] !== -1 && npos[1][npos[0]+1]) { if($.isFunction(p.onclickPgButtons)) { p.onclickPgButtons.call($t,'next',$("#"+frmgr),npos[1][npos[0]]); } fillData(npos[1][npos[0]+1],$t); $($t).jqGrid("setSelection",npos[1][npos[0]+1]); if($.isFunction(p.afterclickPgButtons)) { p.afterclickPgButtons.call($t,'next',$("#"+frmgr),npos[1][npos[0]+1]); } updateNav(npos[0]+1,npos); } focusaref(); return false; }); $("#pData", "#"+frmtb+"_2").click(function(){ $("#FormError","#"+frmtb).hide(); var ppos = getCurrPos(); if(ppos[0] !== -1 && ppos[1][ppos[0]-1]) { if($.isFunction(p.onclickPgButtons)) { p.onclickPgButtons.call($t,'prev',$("#"+frmgr),ppos[1][ppos[0]]); } fillData(ppos[1][ppos[0]-1],$t); $($t).jqGrid("setSelection",ppos[1][ppos[0]-1]); if($.isFunction(p.afterclickPgButtons)) { p.afterclickPgButtons.call($t,'prev',$("#"+frmgr),ppos[1][ppos[0]-1]); } updateNav(ppos[0]-1,ppos); } focusaref(); return false; }); } var posInit =getCurrPos(); updateNav(posInit[0],posInit); }); }, delGridRow : function(rowids,p) { p = $.extend(true, { top : 0, left: 0, width: 240, height: 'auto', dataheight : 'auto', modal: false, overlay: 30, drag: true, resize: true, url : '', mtype : "POST", reloadAfterSubmit: true, beforeShowForm: null, beforeInitData : null, afterShowForm: null, beforeSubmit: null, onclickSubmit: null, afterSubmit: null, jqModal : true, closeOnEscape : false, delData: {}, delicon : [], cancelicon : [], onClose : null, ajaxDelOptions : {}, processing : false, serializeDelData : null, useDataProxy : false }, $.jgrid.del, p ||{}); rp_ge[$(this)[0].p.id] = p; return this.each(function(){ var $t = this; if (!$t.grid ) {return;} if(!rowids) {return;} var onBeforeShow = $.isFunction( rp_ge[$t.p.id].beforeShowForm ), onAfterShow = $.isFunction( rp_ge[$t.p.id].afterShowForm ), onBeforeInit = $.isFunction(rp_ge[$t.p.id].beforeInitData) ? rp_ge[$t.p.id].beforeInitData : false, gID = $t.p.id, onCS = {}, showFrm = true, dtbl = "DelTbl_"+$.jgrid.jqID(gID),postd, idname, opers, oper, dtbl_id = "DelTbl_" + gID, IDs = {themodal:'delmod'+gID,modalhead:'delhd'+gID,modalcontent:'delcnt'+gID, scrollelm: dtbl}; if ($.isArray(rowids)) {rowids = rowids.join();} if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) { if(onBeforeInit) { showFrm = onBeforeInit.call($t,$("#"+dtbl)); if(showFrm === undefined) { showFrm = true; } } if(showFrm === false) {return;} $("#DelData>td","#"+dtbl).text(rowids); $("#DelError","#"+dtbl).hide(); if( rp_ge[$t.p.id].processing === true) { rp_ge[$t.p.id].processing=false; $("#dData", "#"+dtbl).removeClass('ui-state-active'); } if(onBeforeShow) {rp_ge[$t.p.id].beforeShowForm.call($t,$("#"+dtbl));} $.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:rp_ge[$t.p.id].jqModal,jqM: false, overlay: rp_ge[$t.p.id].overlay, modal:rp_ge[$t.p.id].modal}); if(onAfterShow) {rp_ge[$t.p.id].afterShowForm.call($t,$("#"+dtbl));} } else { var dh = isNaN(rp_ge[$t.p.id].dataheight) ? rp_ge[$t.p.id].dataheight : rp_ge[$t.p.id].dataheight+"px", dw = isNaN(p.datawidth) ? p.datawidth : p.datawidth+"px", tbl = "
    "; tbl += ""; // error data tbl += ""; tbl += ""; tbl += ""; // buttons at footer tbl += "
    "+rp_ge[$t.p.id].msg+"
     
    "; var bS = ""+p.bSubmit+"", bC = ""+p.bCancel+""; tbl += "

    "+bS+" "+bC+"
    "; p.gbox = "#gbox_"+$.jgrid.jqID(gID); $.jgrid.createModal(IDs,tbl,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gview_"+$.jgrid.jqID($t.p.id))[0]); if(onBeforeInit) { showFrm = onBeforeInit.call($t,$("#"+dtbl)); if(showFrm === undefined) { showFrm = true; } } if(showFrm === false) {return;} $(".fm-button","#"+dtbl+"_2").hover( function(){$(this).addClass('ui-state-hover');}, function(){$(this).removeClass('ui-state-hover');} ); p.delicon = $.extend([true,"left","ui-icon-scissors"],rp_ge[$t.p.id].delicon); p.cancelicon = $.extend([true,"left","ui-icon-cancel"],rp_ge[$t.p.id].cancelicon); if(p.delicon[0]===true) { $("#dData","#"+dtbl+"_2").addClass(p.delicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left') .append(""); } if(p.cancelicon[0]===true) { $("#eData","#"+dtbl+"_2").addClass(p.cancelicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left') .append(""); } $("#dData","#"+dtbl+"_2").click(function(){ var ret=[true,""], pk, postdata = $("#DelData>td","#"+dtbl).text(); //the pair is name=val1,val2,... onCS = {}; if( $.isFunction( rp_ge[$t.p.id].onclickSubmit ) ) {onCS = rp_ge[$t.p.id].onclickSubmit.call($t,rp_ge[$t.p.id], postdata) || {};} if( $.isFunction( rp_ge[$t.p.id].beforeSubmit ) ) {ret = rp_ge[$t.p.id].beforeSubmit.call($t,postdata);} if(ret[0] && !rp_ge[$t.p.id].processing) { rp_ge[$t.p.id].processing = true; opers = $t.p.prmNames; postd = $.extend({},rp_ge[$t.p.id].delData, onCS); oper = opers.oper; postd[oper] = opers.deloper; idname = opers.id; postdata = String(postdata).split(","); if(!postdata.length) { return false; } for(pk in postdata) { if(postdata.hasOwnProperty(pk)) { postdata[pk] = $.jgrid.stripPref($t.p.idPrefix, postdata[pk]); } } postd[idname] = postdata.join(); $(this).addClass('ui-state-active'); var ajaxOptions = $.extend({ url: rp_ge[$t.p.id].url || $($t).jqGrid('getGridParam','editurl'), type: rp_ge[$t.p.id].mtype, data: $.isFunction(rp_ge[$t.p.id].serializeDelData) ? rp_ge[$t.p.id].serializeDelData.call($t,postd) : postd, complete:function(data,status){ var i; if(data.status >= 300 && data.status !== 304) { ret[0] = false; if ($.isFunction(rp_ge[$t.p.id].errorTextFormat)) { ret[1] = rp_ge[$t.p.id].errorTextFormat.call($t,data); } else { ret[1] = status + " Status: '" + data.statusText + "'. Error code: " + data.status; } } else { // data is posted successful // execute aftersubmit with the returned data from server if( $.isFunction( rp_ge[$t.p.id].afterSubmit ) ) { ret = rp_ge[$t.p.id].afterSubmit.call($t,data,postd); } } if(ret[0] === false) { $("#DelError>td","#"+dtbl).html(ret[1]); $("#DelError","#"+dtbl).show(); } else { if(rp_ge[$t.p.id].reloadAfterSubmit && $t.p.datatype !== "local") { $($t).trigger("reloadGrid"); } else { if($t.p.treeGrid===true){ try {$($t).jqGrid("delTreeNode",$t.p.idPrefix+postdata[0]);} catch(e){} } else { for(i=0;itd","#"+dtbl).html(ret[1]); $("#DelError","#"+dtbl).show(); } return false; }); $("#eData", "#"+dtbl+"_2").click(function(){ $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:rp_ge[$t.p.id].jqModal, onClose: rp_ge[$t.p.id].onClose}); return false; }); if(onBeforeShow) {rp_ge[$t.p.id].beforeShowForm.call($t,$("#"+dtbl));} $.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:rp_ge[$t.p.id].jqModal, overlay: rp_ge[$t.p.id].overlay, modal:rp_ge[$t.p.id].modal}); if(onAfterShow) {rp_ge[$t.p.id].afterShowForm.call($t,$("#"+dtbl));} } if(rp_ge[$t.p.id].closeOnEscape===true) { setTimeout(function(){$(".ui-jqdialog-titlebar-close","#"+$.jgrid.jqID(IDs.modalhead)).focus();},0); } }); }, navGrid : function (elem, o, pEdit,pAdd,pDel,pSearch, pView) { o = $.extend({ edit: true, editicon: "ui-icon-pencil", add: true, addicon:"ui-icon-plus", del: true, delicon:"ui-icon-trash", search: true, searchicon:"ui-icon-search", refresh: true, refreshicon:"ui-icon-refresh", refreshstate: 'firstpage', view: false, viewicon : "ui-icon-document", position : "left", closeOnEscape : true, beforeRefresh : null, afterRefresh : null, cloneToTop : false, alertwidth : 200, alertheight : 'auto', alerttop: null, alertleft: null, alertzIndex : null }, $.jgrid.nav, o ||{}); return this.each(function() { if(this.nav) {return;} var alertIDs = {themodal: 'alertmod_' + this.p.id, modalhead: 'alerthd_' + this.p.id,modalcontent: 'alertcnt_' + this.p.id}, $t = this, twd, tdw; if(!$t.grid || typeof elem !== 'string') {return;} if ($("#"+alertIDs.themodal)[0] === undefined) { if(!o.alerttop && !o.alertleft) { if (window.innerWidth !== undefined) { o.alertleft = window.innerWidth; o.alerttop = window.innerHeight; } else if (document.documentElement !== undefined && document.documentElement.clientWidth !== undefined && document.documentElement.clientWidth !== 0) { o.alertleft = document.documentElement.clientWidth; o.alerttop = document.documentElement.clientHeight; } else { o.alertleft=1024; o.alerttop=768; } o.alertleft = o.alertleft/2 - parseInt(o.alertwidth,10)/2; o.alerttop = o.alerttop/2-25; } $.jgrid.createModal(alertIDs, "
    "+o.alerttext+"
    ", { gbox:"#gbox_"+$.jgrid.jqID($t.p.id), jqModal:true, drag:true, resize:true, caption:o.alertcap, top:o.alerttop, left:o.alertleft, width:o.alertwidth, height: o.alertheight, closeOnEscape:o.closeOnEscape, zIndex: o.alertzIndex }, "#gview_"+$.jgrid.jqID($t.p.id), $("#gbox_"+$.jgrid.jqID($t.p.id))[0], true ); } var clone = 1, i, onHoverIn = function () { if (!$(this).hasClass('ui-state-disabled')) { $(this).addClass("ui-state-hover"); } }, onHoverOut = function () { $(this).removeClass("ui-state-hover"); }; if(o.cloneToTop && $t.p.toppager) {clone = 2;} for(i = 0; i"), sep = "", pgid, elemids; if(i===0) { pgid = elem; elemids = $t.p.id; if(pgid === $t.p.toppager) { elemids += "_top"; clone = 1; } } else { pgid = $t.p.toppager; elemids = $t.p.id+"_top"; } if($t.p.direction === "rtl") {$(navtbl).attr("dir","rtl").css("float","right");} if (o.add) { pAdd = pAdd || {}; tbd = $(""); $(tbd).append("
    "+o.addtext+"
    "); $("tr",navtbl).append(tbd); $(tbd,navtbl) .attr({"title":o.addtitle || "",id : pAdd.id || "add_"+elemids}) .click(function(){ if (!$(this).hasClass('ui-state-disabled')) { if ($.isFunction( o.addfunc )) { o.addfunc.call($t); } else { $($t).jqGrid("editGridRow","new",pAdd); } } return false; }).hover(onHoverIn, onHoverOut); tbd = null; } if (o.edit) { tbd = $(""); pEdit = pEdit || {}; $(tbd).append("
    "+o.edittext+"
    "); $("tr",navtbl).append(tbd); $(tbd,navtbl) .attr({"title":o.edittitle || "",id: pEdit.id || "edit_"+elemids}) .click(function(){ if (!$(this).hasClass('ui-state-disabled')) { var sr = $t.p.selrow; if (sr) { if($.isFunction( o.editfunc ) ) { o.editfunc.call($t, sr); } else { $($t).jqGrid("editGridRow",sr,pEdit); } } else { $.jgrid.viewModal("#"+alertIDs.themodal,{gbox:"#gbox_"+$.jgrid.jqID($t.p.id),jqm:true}); $("#jqg_alrt").focus(); } } return false; }).hover(onHoverIn, onHoverOut); tbd = null; } if (o.view) { tbd = $(""); pView = pView || {}; $(tbd).append("
    "+o.viewtext+"
    "); $("tr",navtbl).append(tbd); $(tbd,navtbl) .attr({"title":o.viewtitle || "",id: pView.id || "view_"+elemids}) .click(function(){ if (!$(this).hasClass('ui-state-disabled')) { var sr = $t.p.selrow; if (sr) { if($.isFunction( o.viewfunc ) ) { o.viewfunc.call($t, sr); } else { $($t).jqGrid("viewGridRow",sr,pView); } } else { $.jgrid.viewModal("#"+alertIDs.themodal,{gbox:"#gbox_"+$.jgrid.jqID($t.p.id),jqm:true}); $("#jqg_alrt").focus(); } } return false; }).hover(onHoverIn, onHoverOut); tbd = null; } if (o.del) { tbd = $(""); pDel = pDel || {}; $(tbd).append("
    "+o.deltext+"
    "); $("tr",navtbl).append(tbd); $(tbd,navtbl) .attr({"title":o.deltitle || "",id: pDel.id || "del_"+elemids}) .click(function(){ if (!$(this).hasClass('ui-state-disabled')) { var dr; if($t.p.multiselect) { dr = $t.p.selarrrow; if(dr.length===0) {dr = null;} } else { dr = $t.p.selrow; } if(dr){ if($.isFunction( o.delfunc )){ o.delfunc.call($t, dr); }else{ $($t).jqGrid("delGridRow",dr,pDel); } } else { $.jgrid.viewModal("#"+alertIDs.themodal,{gbox:"#gbox_"+$.jgrid.jqID($t.p.id),jqm:true});$("#jqg_alrt").focus(); } } return false; }).hover(onHoverIn, onHoverOut); tbd = null; } if(o.add || o.edit || o.del || o.view) {$("tr",navtbl).append(sep);} if (o.search) { tbd = $(""); pSearch = pSearch || {}; $(tbd).append("
    "+o.searchtext+"
    "); $("tr",navtbl).append(tbd); $(tbd,navtbl) .attr({"title":o.searchtitle || "",id:pSearch.id || "search_"+elemids}) .click(function(){ if (!$(this).hasClass('ui-state-disabled')) { if($.isFunction( o.searchfunc )) { o.searchfunc.call($t, pSearch); } else { $($t).jqGrid("searchGrid",pSearch); } } return false; }).hover(onHoverIn, onHoverOut); if (pSearch.showOnLoad && pSearch.showOnLoad === true) { $(tbd,navtbl).click(); } tbd = null; } if (o.refresh) { tbd = $(""); $(tbd).append("
    "+o.refreshtext+"
    "); $("tr",navtbl).append(tbd); $(tbd,navtbl) .attr({"title":o.refreshtitle || "",id: "refresh_"+elemids}) .click(function(){ if (!$(this).hasClass('ui-state-disabled')) { if($.isFunction(o.beforeRefresh)) {o.beforeRefresh.call($t);} $t.p.search = false; try { var gID = $t.p.id; $t.p.postData.filters =""; try { $("#fbox_"+$.jgrid.jqID(gID)).jqFilter('resetFilter'); } catch(ef) {} if($.isFunction($t.clearToolbar)) {$t.clearToolbar.call($t,false);} } catch (e) {} switch (o.refreshstate) { case 'firstpage': $($t).trigger("reloadGrid", [{page:1}]); break; case 'current': $($t).trigger("reloadGrid", [{current:true}]); break; } if($.isFunction(o.afterRefresh)) {o.afterRefresh.call($t);} } return false; }).hover(onHoverIn, onHoverOut); tbd = null; } tdw = $(".ui-jqgrid").css("font-size") || "11px"; $('body').append(""); twd = $(navtbl).clone().appendTo("#testpg2").width(); $("#testpg2").remove(); $(pgid+"_"+o.position,pgid).append(navtbl); if($t.p._nvtd) { if(twd > $t.p._nvtd[0] ) { $(pgid+"_"+o.position,pgid).width(twd); $t.p._nvtd[0] = twd; } $t.p._nvtd[1] = twd; } tdw =null;twd=null;navtbl =null; this.nav = true; } }); }, navButtonAdd : function (elem, p) { p = $.extend({ caption : "newButton", title: '', buttonicon : 'ui-icon-newwin', onClickButton: null, position : "last", cursor : 'pointer' }, p ||{}); return this.each(function() { if( !this.grid) {return;} if( typeof elem === "string" && elem.indexOf("#") !== 0) {elem = "#"+$.jgrid.jqID(elem);} var findnav = $(".navtable",elem)[0], $t = this; if (findnav) { if( p.id && $("#"+$.jgrid.jqID(p.id), findnav)[0] !== undefined ) {return;} var tbd = $(""); if(p.buttonicon.toString().toUpperCase() === "NONE") { $(tbd).addClass('ui-pg-button ui-corner-all').append("
    "+p.caption+"
    "); } else { $(tbd).addClass('ui-pg-button ui-corner-all').append("
    "+p.caption+"
    "); } if(p.id) {$(tbd).attr("id",p.id);} if(p.position==='first'){ if(findnav.rows[0].cells.length ===0 ) { $("tr",findnav).append(tbd); } else { $("tr td:eq(0)",findnav).before(tbd); } } else { $("tr",findnav).append(tbd); } $(tbd,findnav) .attr("title",p.title || "") .click(function(e){ if (!$(this).hasClass('ui-state-disabled')) { if ($.isFunction(p.onClickButton) ) {p.onClickButton.call($t,e);} } return false; }) .hover( function () { if (!$(this).hasClass('ui-state-disabled')) { $(this).addClass('ui-state-hover'); } }, function () {$(this).removeClass("ui-state-hover");} ); } }); }, navSeparatorAdd:function (elem,p) { p = $.extend({ sepclass : "ui-separator", sepcontent: '', position : "last" }, p ||{}); return this.each(function() { if( !this.grid) {return;} if( typeof elem === "string" && elem.indexOf("#") !== 0) {elem = "#"+$.jgrid.jqID(elem);} var findnav = $(".navtable",elem)[0]; if(findnav) { var sep = ""+p.sepcontent+""; if (p.position === 'first') { if (findnav.rows[0].cells.length === 0) { $("tr", findnav).append(sep); } else { $("tr td:eq(0)", findnav).before(sep); } } else { $("tr", findnav).append(sep); } } }); }, GridToForm : function( rowid, formid ) { return this.each(function(){ var $t = this, i; if (!$t.grid) {return;} var rowdata = $($t).jqGrid("getRowData",rowid); if (rowdata) { for(i in rowdata) { if(rowdata.hasOwnProperty(i)) { if ( $("[name="+$.jgrid.jqID(i)+"]",formid).is("input:radio") || $("[name="+$.jgrid.jqID(i)+"]",formid).is("input:checkbox")) { $("[name="+$.jgrid.jqID(i)+"]",formid).each( function() { if( $(this).val() == rowdata[i] ) { $(this)[$t.p.useProp ? 'prop': 'attr']("checked",true); } else { $(this)[$t.p.useProp ? 'prop': 'attr']("checked", false); } }); } else { // this is very slow on big table and form. $("[name="+$.jgrid.jqID(i)+"]",formid).val(rowdata[i]); } } } } }); }, FormToGrid : function(rowid, formid, mode, position){ return this.each(function() { var $t = this; if(!$t.grid) {return;} if(!mode) {mode = 'set';} if(!position) {position = 'first';} var fields = $(formid).serializeArray(); var griddata = {}; $.each(fields, function(i, field){ griddata[field.name] = field.value; }); if(mode==='add') {$($t).jqGrid("addRowData",rowid,griddata, position);} else if(mode==='set') {$($t).jqGrid("setRowData",rowid,griddata);} }); } }); })(jQuery); /*jshint eqeqeq:false, eqnull:true, devel:true */ /*global jQuery */ (function($){ /** * jqGrid extension for manipulating Grid Data * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl-2.0.html **/ "use strict"; $.jgrid.inlineEdit = $.jgrid.inlineEdit || {}; $.jgrid.extend({ //Editing editRow : function(rowid,keys,oneditfunc,successfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc) { // Compatible mode old versions var o={}, args = $.makeArray(arguments).slice(1); if( $.type(args[0]) === "object" ) { o = args[0]; } else { if (keys !== undefined) { o.keys = keys; } if ($.isFunction(oneditfunc)) { o.oneditfunc = oneditfunc; } if ($.isFunction(successfunc)) { o.successfunc = successfunc; } if (url !== undefined) { o.url = url; } if (extraparam !== undefined) { o.extraparam = extraparam; } if ($.isFunction(aftersavefunc)) { o.aftersavefunc = aftersavefunc; } if ($.isFunction(errorfunc)) { o.errorfunc = errorfunc; } if ($.isFunction(afterrestorefunc)) { o.afterrestorefunc = afterrestorefunc; } // last two not as param, but as object (sorry) //if (restoreAfterError !== undefined) { o.restoreAfterError = restoreAfterError; } //if (mtype !== undefined) { o.mtype = mtype || "POST"; } } o = $.extend(true, { keys : false, oneditfunc: null, successfunc: null, url: null, extraparam: {}, aftersavefunc: null, errorfunc: null, afterrestorefunc: null, restoreAfterError: true, mtype: "POST" }, $.jgrid.inlineEdit, o ); // End compatible return this.each(function(){ var $t = this, nm, tmp, editable, cnt=0, focus=null, svr={}, ind,cm; if (!$t.grid ) { return; } ind = $($t).jqGrid("getInd",rowid,true); if( ind === false ) {return;} editable = $(ind).attr("editable") || "0"; if (editable === "0" && !$(ind).hasClass("not-editable-row")) { cm = $t.p.colModel; $('td[role="gridcell"]',ind).each( function(i) { nm = cm[i].name; var treeg = $t.p.treeGrid===true && nm === $t.p.ExpandColumn; if(treeg) { tmp = $("span:first",this).html();} else { try { tmp = $.unformat.call($t,this,{rowId:rowid, colModel:cm[i]},i); } catch (_) { tmp = ( cm[i].edittype && cm[i].edittype === 'textarea' ) ? $(this).text() : $(this).html(); } } if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn') { if($t.p.autoencode) { tmp = $.jgrid.htmlDecode(tmp); } svr[nm]=tmp; if(cm[i].editable===true) { if(focus===null) { focus = i; } if (treeg) { $("span:first",this).html(""); } else { $(this).html(""); } var opt = $.extend({},cm[i].editoptions || {},{id:rowid+"_"+nm,name:nm}); if(!cm[i].edittype) { cm[i].edittype = "text"; } if(tmp === " " || tmp === " " || (tmp.length===1 && tmp.charCodeAt(0)===160) ) {tmp='';} var elc = $.jgrid.createEl.call($t,cm[i].edittype,opt,tmp,true,$.extend({},$.jgrid.ajaxOptions,$t.p.ajaxSelectOptions || {})); $(elc).addClass("editable"); if(treeg) { $("span:first",this).append(elc); } else { $(this).append(elc); } $.jgrid.bindEv.call($t, elc, opt); //Again IE if(cm[i].edittype === "select" && cm[i].editoptions!==undefined && cm[i].editoptions.multiple===true && cm[i].editoptions.dataUrl===undefined && $.jgrid.msie) { $(elc).width($(elc).width()); } cnt++; } } }); if(cnt > 0) { svr.id = rowid; $t.p.savedRow.push(svr); $(ind).attr("editable","1"); $("td:eq("+focus+") input",ind).focus(); if(o.keys===true) { $(ind).bind("keydown",function(e) { if (e.keyCode === 27) { $($t).jqGrid("restoreRow",rowid, o.afterrestorefunc); if($t.p._inlinenav) { try { $($t).jqGrid('showAddEditButtons'); } catch (eer1) {} } return false; } if (e.keyCode === 13) { var ta = e.target; if(ta.tagName === 'TEXTAREA') { return true; } if( $($t).jqGrid("saveRow", rowid, o ) ) { if($t.p._inlinenav) { try { $($t).jqGrid('showAddEditButtons'); } catch (eer2) {} } } return false; } }); } $($t).triggerHandler("jqGridInlineEditRow", [rowid, o]); if( $.isFunction(o.oneditfunc)) { o.oneditfunc.call($t, rowid); } } } }); }, saveRow : function(rowid, successfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc) { // Compatible mode old versions var args = $.makeArray(arguments).slice(1), o = {}; if( $.type(args[0]) === "object" ) { o = args[0]; } else { if ($.isFunction(successfunc)) { o.successfunc = successfunc; } if (url !== undefined) { o.url = url; } if (extraparam !== undefined) { o.extraparam = extraparam; } if ($.isFunction(aftersavefunc)) { o.aftersavefunc = aftersavefunc; } if ($.isFunction(errorfunc)) { o.errorfunc = errorfunc; } if ($.isFunction(afterrestorefunc)) { o.afterrestorefunc = afterrestorefunc; } } o = $.extend(true, { successfunc: null, url: null, extraparam: {}, aftersavefunc: null, errorfunc: null, afterrestorefunc: null, restoreAfterError: true, mtype: "POST" }, $.jgrid.inlineEdit, o ); // End compatible var success = false; var $t = this[0], nm, tmp={}, tmp2={}, tmp3= {}, editable, fr, cv, ind; if (!$t.grid ) { return success; } ind = $($t).jqGrid("getInd",rowid,true); if(ind === false) {return success;} editable = $(ind).attr("editable"); o.url = o.url || $t.p.editurl; if (editable==="1") { var cm; $('td[role="gridcell"]',ind).each(function(i) { cm = $t.p.colModel[i]; nm = cm.name; if ( nm !== 'cb' && nm !== 'subgrid' && cm.editable===true && nm !== 'rn' && !$(this).hasClass('not-editable-cell')) { switch (cm.edittype) { case "checkbox": var cbv = ["Yes","No"]; if(cm.editoptions ) { cbv = cm.editoptions.value.split(":"); } tmp[nm]= $("input",this).is(":checked") ? cbv[0] : cbv[1]; break; case 'text': case 'password': case 'textarea': case "button" : tmp[nm]=$("input, textarea",this).val(); break; case 'select': if(!cm.editoptions.multiple) { tmp[nm] = $("select option:selected",this).val(); tmp2[nm] = $("select option:selected", this).text(); } else { var sel = $("select",this), selectedText = []; tmp[nm] = $(sel).val(); if(tmp[nm]) { tmp[nm]= tmp[nm].join(","); } else { tmp[nm] =""; } $("select option:selected",this).each( function(i,selected){ selectedText[i] = $(selected).text(); } ); tmp2[nm] = selectedText.join(","); } if(cm.formatter && cm.formatter === 'select') { tmp2={}; } break; case 'custom' : try { if(cm.editoptions && $.isFunction(cm.editoptions.custom_value)) { tmp[nm] = cm.editoptions.custom_value.call($t, $(".customelement",this),'get'); if (tmp[nm] === undefined) { throw "e2"; } } else { throw "e1"; } } catch (e) { if (e==="e1") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.nodefined,$.jgrid.edit.bClose); } if (e==="e2") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose); } else { $.jgrid.info_dialog($.jgrid.errors.errcap,e.message,$.jgrid.edit.bClose); } } break; } cv = $.jgrid.checkValues.call($t,tmp[nm],i); if(cv[0] === false) { cv[1] = tmp[nm] + " " + cv[1]; return false; } if($t.p.autoencode) { tmp[nm] = $.jgrid.htmlEncode(tmp[nm]); } if(o.url !== 'clientArray' && cm.editoptions && cm.editoptions.NullIfEmpty === true) { if(tmp[nm] === "") { tmp3[nm] = 'null'; } } } }); if (cv[0] === false){ try { var tr = $t.rows.namedItem(rowid), positions = $.jgrid.findPos(tr); $.jgrid.info_dialog($.jgrid.errors.errcap,cv[1],$.jgrid.edit.bClose,{left:positions[0],top:positions[1]+$(tr).outerHeight()}); } catch (e) { alert(cv[1]); } return success; } var idname, opers = $t.p.prmNames, oldRowId = rowid; if ($t.p.keyIndex === false) { idname = opers.id; } else { idname = $t.p.colModel[$t.p.keyIndex + ($t.p.rownumbers === true ? 1 : 0) + ($t.p.multiselect === true ? 1 : 0) + ($t.p.subGrid === true ? 1 : 0)].name; } if(tmp) { tmp[opers.oper] = opers.editoper; if (tmp[idname] === undefined || tmp[idname]==="") { tmp[idname] = rowid; } else if (ind.id !== $t.p.idPrefix + tmp[idname]) { // rename rowid var oldid = $.jgrid.stripPref($t.p.idPrefix, rowid); if ($t.p._index[oldid] !== undefined) { $t.p._index[tmp[idname]] = $t.p._index[oldid]; delete $t.p._index[oldid]; } rowid = $t.p.idPrefix + tmp[idname]; $(ind).attr("id", rowid); if ($t.p.selrow === oldRowId) { $t.p.selrow = rowid; } if ($.isArray($t.p.selarrrow)) { var i = $.inArray(oldRowId, $t.p.selarrrow); if (i>=0) { $t.p.selarrrow[i] = rowid; } } if ($t.p.multiselect) { var newCboxId = "jqg_" + $t.p.id + "_" + rowid; $("input.cbox",ind) .attr("id", newCboxId) .attr("name", newCboxId); } // TODO: to test the case of frozen columns } if($t.p.inlineData === undefined) { $t.p.inlineData ={}; } tmp = $.extend({},tmp,$t.p.inlineData,o.extraparam); } if (o.url === 'clientArray') { tmp = $.extend({},tmp, tmp2); if($t.p.autoencode) { $.each(tmp,function(n,v){ tmp[n] = $.jgrid.htmlDecode(v); }); } var k, resp = $($t).jqGrid("setRowData",rowid,tmp); $(ind).attr("editable","0"); for(k=0;k<$t.p.savedRow.length;k++) { if( String($t.p.savedRow[k].id) === String(oldRowId)) {fr = k; break;} } if(fr >= 0) { $t.p.savedRow.splice(fr,1); } $($t).triggerHandler("jqGridInlineAfterSaveRow", [rowid, resp, tmp, o]); if( $.isFunction(o.aftersavefunc) ) { o.aftersavefunc.call($t, rowid,resp, o); } success = true; $(ind).removeClass("jqgrid-new-row").unbind("keydown"); } else { $("#lui_"+$.jgrid.jqID($t.p.id)).show(); tmp3 = $.extend({},tmp,tmp3); tmp3[idname] = $.jgrid.stripPref($t.p.idPrefix, tmp3[idname]); $.ajax($.extend({ url:o.url, data: $.isFunction($t.p.serializeRowData) ? $t.p.serializeRowData.call($t, tmp3) : tmp3, type: o.mtype, async : true, //?!? complete: function(res,stat){ $("#lui_"+$.jgrid.jqID($t.p.id)).hide(); if (stat === "success"){ var ret = true, sucret, k; sucret = $($t).triggerHandler("jqGridInlineSuccessSaveRow", [res, rowid, o]); if (!$.isArray(sucret)) {sucret = [true, tmp];} if (sucret[0] && $.isFunction(o.successfunc)) {sucret = o.successfunc.call($t, res);} if($.isArray(sucret)) { // expect array - status, data, rowid ret = sucret[0]; tmp = sucret[1] || tmp; } else { ret = sucret; } if (ret===true) { if($t.p.autoencode) { $.each(tmp,function(n,v){ tmp[n] = $.jgrid.htmlDecode(v); }); } tmp = $.extend({},tmp, tmp2); $($t).jqGrid("setRowData",rowid,tmp); $(ind).attr("editable","0"); for(k=0;k<$t.p.savedRow.length;k++) { if( String($t.p.savedRow[k].id) === String(rowid)) {fr = k; break;} } if(fr >= 0) { $t.p.savedRow.splice(fr,1); } $($t).triggerHandler("jqGridInlineAfterSaveRow", [rowid, res, tmp, o]); if( $.isFunction(o.aftersavefunc) ) { o.aftersavefunc.call($t, rowid,res); } success = true; $(ind).removeClass("jqgrid-new-row").unbind("keydown"); } else { $($t).triggerHandler("jqGridInlineErrorSaveRow", [rowid, res, stat, null, o]); if($.isFunction(o.errorfunc) ) { o.errorfunc.call($t, rowid, res, stat, null); } if(o.restoreAfterError === true) { $($t).jqGrid("restoreRow",rowid, o.afterrestorefunc); } } } }, error:function(res,stat,err){ $("#lui_"+$.jgrid.jqID($t.p.id)).hide(); $($t).triggerHandler("jqGridInlineErrorSaveRow", [rowid, res, stat, err, o]); if($.isFunction(o.errorfunc) ) { o.errorfunc.call($t, rowid, res, stat, err); } else { var rT = res.responseText || res.statusText; try { $.jgrid.info_dialog($.jgrid.errors.errcap,'
    '+ rT +'
    ', $.jgrid.edit.bClose,{buttonalign:'right'}); } catch(e) { alert(rT); } } if(o.restoreAfterError === true) { $($t).jqGrid("restoreRow",rowid, o.afterrestorefunc); } } }, $.jgrid.ajaxOptions, $t.p.ajaxRowOptions || {})); } } return success; }, restoreRow : function(rowid, afterrestorefunc) { // Compatible mode old versions var args = $.makeArray(arguments).slice(1), o={}; if( $.type(args[0]) === "object" ) { o = args[0]; } else { if ($.isFunction(afterrestorefunc)) { o.afterrestorefunc = afterrestorefunc; } } o = $.extend(true, {}, $.jgrid.inlineEdit, o ); // End compatible return this.each(function(){ var $t= this, fr, ind, ares={}, k; if (!$t.grid ) { return; } ind = $($t).jqGrid("getInd",rowid,true); if(ind === false) {return;} for(k=0;k<$t.p.savedRow.length;k++) { if( String($t.p.savedRow[k].id) === String(rowid)) {fr = k; break;} } if(fr >= 0) { if($.isFunction($.fn.datepicker)) { try { $("input.hasDatepicker","#"+$.jgrid.jqID(ind.id)).datepicker('hide'); } catch (e) {} } $.each($t.p.colModel, function(){ if(this.editable === true && $t.p.savedRow[fr].hasOwnProperty(this.name)) { ares[this.name] = $t.p.savedRow[fr][this.name]; } }); $($t).jqGrid("setRowData",rowid,ares); $(ind).attr("editable","0").unbind("keydown"); $t.p.savedRow.splice(fr,1); if($("#"+$.jgrid.jqID(rowid), "#"+$.jgrid.jqID($t.p.id)).hasClass("jqgrid-new-row")){ setTimeout(function(){ $($t).jqGrid("delRowData",rowid); $($t).jqGrid('showAddEditButtons'); },0); } } $($t).triggerHandler("jqGridInlineAfterRestoreRow", [rowid]); if ($.isFunction(o.afterrestorefunc)) { o.afterrestorefunc.call($t, rowid); } }); }, addRow : function ( p ) { p = $.extend(true, { rowID : null, initdata : {}, position :"first", useDefValues : true, useFormatter : false, addRowParams : {extraparam:{}} },p || {}); return this.each(function(){ if (!this.grid ) { return; } var $t = this; p.rowID = $.isFunction(p.rowID) ? p.rowID.call($t, p) : ( (p.rowID != null) ? p.rowID : $.jgrid.randId()); if(p.useDefValues === true) { $($t.p.colModel).each(function(){ if( this.editoptions && this.editoptions.defaultValue ) { var opt = this.editoptions.defaultValue, tmp = $.isFunction(opt) ? opt.call($t) : opt; p.initdata[this.name] = tmp; } }); } $($t).jqGrid('addRowData', p.rowID, p.initdata, p.position); p.rowID = $t.p.idPrefix + p.rowID; $("#"+$.jgrid.jqID(p.rowID), "#"+$.jgrid.jqID($t.p.id)).addClass("jqgrid-new-row"); if(p.useFormatter) { $("#"+$.jgrid.jqID(p.rowID)+" .ui-inline-edit", "#"+$.jgrid.jqID($t.p.id)).click(); } else { var opers = $t.p.prmNames, oper = opers.oper; p.addRowParams.extraparam[oper] = opers.addoper; $($t).jqGrid('editRow', p.rowID, p.addRowParams); $($t).jqGrid('setSelection', p.rowID); } }); }, inlineNav : function (elem, o) { o = $.extend(true,{ edit: true, editicon: "ui-icon-pencil", add: true, addicon:"ui-icon-plus", save: true, saveicon:"ui-icon-disk", cancel: true, cancelicon:"ui-icon-cancel", addParams : {addRowParams: {extraparam: {}}}, editParams : {}, restoreAfterSelect : true }, $.jgrid.nav, o ||{}); return this.each(function(){ if (!this.grid ) { return; } var $t = this, onSelect, gID = $.jgrid.jqID($t.p.id); $t.p._inlinenav = true; // detect the formatactions column if(o.addParams.useFormatter === true) { var cm = $t.p.colModel,i; for (i = 0; i 0 && $t.p._inlinenav===true && ( id !== $t.p.selrow && $t.p.selrow !==null) ) { if($t.p.selrow === o.addParams.rowID ) { $($t).jqGrid('delRowData', $t.p.selrow); } else { $($t).jqGrid('restoreRow', $t.p.selrow, o.editParams); } $($t).jqGrid('showAddEditButtons'); } if(onSelect) { ret = onSelect.call($t, id, stat); } return ret; }; } }); }, showAddEditButtons : function() { return this.each(function(){ if (!this.grid ) { return; } var gID = $.jgrid.jqID(this.p.id); $("#"+gID+"_ilsave").addClass('ui-state-disabled'); $("#"+gID+"_ilcancel").addClass('ui-state-disabled'); $("#"+gID+"_iladd").removeClass('ui-state-disabled'); $("#"+gID+"_iledit").removeClass('ui-state-disabled'); }); } //end inline edit }); })(jQuery); /*jshint eqeqeq:false */ /*global jQuery */ (function($){ /* ** * jqGrid extension for cellediting Grid Data * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl-2.0.html **/ /** * all events and options here are aded anonynous and not in the base grid * since the array is to big. Here is the order of execution. * From this point we use jQuery isFunction * formatCell * beforeEditCell, * onSelectCell (used only for noneditable cels) * afterEditCell, * beforeSaveCell, (called before validation of values if any) * beforeSubmitCell (if cellsubmit remote (ajax)) * afterSubmitCell(if cellsubmit remote (ajax)), * afterSaveCell, * errorCell, * serializeCellData - new * Options * cellsubmit (remote,clientArray) (added in grid options) * cellurl * ajaxCellOptions * */ "use strict"; $.jgrid.extend({ editCell : function (iRow,iCol, ed){ return this.each(function (){ var $t = this, nm, tmp,cc, cm; if (!$t.grid || $t.p.cellEdit !== true) {return;} iCol = parseInt(iCol,10); // select the row that can be used for other methods $t.p.selrow = $t.rows[iRow].id; if (!$t.p.knv) {$($t).jqGrid("GridNav");} // check to see if we have already edited cell if ($t.p.savedRow.length>0) { // prevent second click on that field and enable selects if (ed===true ) { if(iRow == $t.p.iRow && iCol == $t.p.iCol){ return; } } // save the cell $($t).jqGrid("saveCell",$t.p.savedRow[0].id,$t.p.savedRow[0].ic); } else { window.setTimeout(function () { $("#"+$.jgrid.jqID($t.p.knv)).attr("tabindex","-1").focus();},0); } cm = $t.p.colModel[iCol]; nm = cm.name; if (nm==='subgrid' || nm==='cb' || nm==='rn') {return;} cc = $("td:eq("+iCol+")",$t.rows[iRow]); if (cm.editable===true && ed===true && !cc.hasClass("not-editable-cell")) { if(parseInt($t.p.iCol,10)>=0 && parseInt($t.p.iRow,10)>=0) { $("td:eq("+$t.p.iCol+")",$t.rows[$t.p.iRow]).removeClass("edit-cell ui-state-highlight"); $($t.rows[$t.p.iRow]).removeClass("selected-row ui-state-hover"); } $(cc).addClass("edit-cell ui-state-highlight"); $($t.rows[iRow]).addClass("selected-row ui-state-hover"); try { tmp = $.unformat.call($t,cc,{rowId: $t.rows[iRow].id, colModel:cm},iCol); } catch (_) { tmp = ( cm.edittype && cm.edittype === 'textarea' ) ? $(cc).text() : $(cc).html(); } if($t.p.autoencode) { tmp = $.jgrid.htmlDecode(tmp); } if (!cm.edittype) {cm.edittype = "text";} $t.p.savedRow.push({id:iRow,ic:iCol,name:nm,v:tmp}); if(tmp === " " || tmp === " " || (tmp.length===1 && tmp.charCodeAt(0)===160) ) {tmp='';} if($.isFunction($t.p.formatCell)) { var tmp2 = $t.p.formatCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol); if(tmp2 !== undefined ) {tmp = tmp2;} } var opt = $.extend({}, cm.editoptions || {} ,{id:iRow+"_"+nm,name:nm}); var elc = $.jgrid.createEl.call($t,cm.edittype,opt,tmp,true,$.extend({},$.jgrid.ajaxOptions,$t.p.ajaxSelectOptions || {})); $($t).triggerHandler("jqGridBeforeEditCell", [$t.rows[iRow].id, nm, tmp, iRow, iCol]); if ($.isFunction($t.p.beforeEditCell)) { $t.p.beforeEditCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol); } $(cc).html("").append(elc).attr("tabindex","0"); $.jgrid.bindEv.call($t, elc, opt); window.setTimeout(function () { $(elc).focus();},0); $("input, select, textarea",cc).bind("keydown",function(e) { if (e.keyCode === 27) { if($("input.hasDatepicker",cc).length >0) { if( $(".ui-datepicker").is(":hidden") ) { $($t).jqGrid("restoreCell",iRow,iCol); } else { $("input.hasDatepicker",cc).datepicker('hide'); } } else { $($t).jqGrid("restoreCell",iRow,iCol); } } //ESC if (e.keyCode === 13) { $($t).jqGrid("saveCell",iRow,iCol); // Prevent default action return false; } //Enter if (e.keyCode === 9) { if(!$t.grid.hDiv.loading ) { if (e.shiftKey) {$($t).jqGrid("prevCell",iRow,iCol);} //Shift TAb else {$($t).jqGrid("nextCell",iRow,iCol);} //Tab } else { return false; } } e.stopPropagation(); }); $($t).triggerHandler("jqGridAfterEditCell", [$t.rows[iRow].id, nm, tmp, iRow, iCol]); if ($.isFunction($t.p.afterEditCell)) { $t.p.afterEditCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol); } } else { if (parseInt($t.p.iCol,10)>=0 && parseInt($t.p.iRow,10)>=0) { $("td:eq("+$t.p.iCol+")",$t.rows[$t.p.iRow]).removeClass("edit-cell ui-state-highlight"); $($t.rows[$t.p.iRow]).removeClass("selected-row ui-state-hover"); } cc.addClass("edit-cell ui-state-highlight"); $($t.rows[iRow]).addClass("selected-row ui-state-hover"); tmp = cc.html().replace(/\ \;/ig,''); $($t).triggerHandler("jqGridSelectCell", [$t.rows[iRow].id, nm, tmp, iRow, iCol]); if ($.isFunction($t.p.onSelectCell)) { $t.p.onSelectCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol); } } $t.p.iCol = iCol; $t.p.iRow = iRow; }); }, saveCell : function (iRow, iCol){ return this.each(function(){ var $t= this, fr; if (!$t.grid || $t.p.cellEdit !== true) {return;} if ( $t.p.savedRow.length >= 1) {fr = 0;} else {fr=null;} if(fr !== null) { var cc = $("td:eq("+iCol+")",$t.rows[iRow]),v,v2, cm = $t.p.colModel[iCol], nm = cm.name, nmjq = $.jgrid.jqID(nm) ; switch (cm.edittype) { case "select": if(!cm.editoptions.multiple) { v = $("#"+iRow+"_"+nmjq+" option:selected",$t.rows[iRow]).val(); v2 = $("#"+iRow+"_"+nmjq+" option:selected",$t.rows[iRow]).text(); } else { var sel = $("#"+iRow+"_"+nmjq,$t.rows[iRow]), selectedText = []; v = $(sel).val(); if(v) { v.join(",");} else { v=""; } $("option:selected",sel).each( function(i,selected){ selectedText[i] = $(selected).text(); } ); v2 = selectedText.join(","); } if(cm.formatter) { v2 = v; } break; case "checkbox": var cbv = ["Yes","No"]; if(cm.editoptions){ cbv = cm.editoptions.value.split(":"); } v = $("#"+iRow+"_"+nmjq,$t.rows[iRow]).is(":checked") ? cbv[0] : cbv[1]; v2=v; break; case "password": case "text": case "textarea": case "button" : v = $("#"+iRow+"_"+nmjq,$t.rows[iRow]).val(); v2=v; break; case 'custom' : try { if(cm.editoptions && $.isFunction(cm.editoptions.custom_value)) { v = cm.editoptions.custom_value.call($t, $(".customelement",cc),'get'); if (v===undefined) { throw "e2";} else { v2=v; } } else { throw "e1"; } } catch (e) { if (e==="e1") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.nodefined,$.jgrid.edit.bClose); } if (e==="e2") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose); } else {$.jgrid.info_dialog($.jgrid.errors.errcap,e.message,$.jgrid.edit.bClose); } } break; } // The common approach is if nothing changed do not do anything if (v2 !== $t.p.savedRow[fr].v){ var vvv = $($t).triggerHandler("jqGridBeforeSaveCell", [$t.rows[iRow].id, nm, v, iRow, iCol]); if (vvv) {v = vvv; v2=vvv;} if ($.isFunction($t.p.beforeSaveCell)) { var vv = $t.p.beforeSaveCell.call($t, $t.rows[iRow].id,nm, v, iRow,iCol); if (vv) {v = vv; v2=vv;} } var cv = $.jgrid.checkValues.call($t,v,iCol); if(cv[0] === true) { var addpost = $($t).triggerHandler("jqGridBeforeSubmitCell", [$t.rows[iRow].id, nm, v, iRow, iCol]) || {}; if ($.isFunction($t.p.beforeSubmitCell)) { addpost = $t.p.beforeSubmitCell.call($t, $t.rows[iRow].id,nm, v, iRow,iCol); if (!addpost) {addpost={};} } if( $("input.hasDatepicker",cc).length >0) { $("input.hasDatepicker",cc).datepicker('hide'); } if ($t.p.cellsubmit === 'remote') { if ($t.p.cellurl) { var postdata = {}; if($t.p.autoencode) { v = $.jgrid.htmlEncode(v); } postdata[nm] = v; var idname,oper, opers; opers = $t.p.prmNames; idname = opers.id; oper = opers.oper; postdata[idname] = $.jgrid.stripPref($t.p.idPrefix, $t.rows[iRow].id); postdata[oper] = opers.editoper; postdata = $.extend(addpost,postdata); $("#lui_"+$.jgrid.jqID($t.p.id)).show(); $t.grid.hDiv.loading = true; $.ajax( $.extend( { url: $t.p.cellurl, data :$.isFunction($t.p.serializeCellData) ? $t.p.serializeCellData.call($t, postdata) : postdata, type: "POST", complete: function (result, stat) { $("#lui_"+$t.p.id).hide(); $t.grid.hDiv.loading = false; if (stat === 'success') { var ret = $($t).triggerHandler("jqGridAfterSubmitCell", [$t, result, postdata.id, nm, v, iRow, iCol]) || [true, '']; if (ret[0] === true && $.isFunction($t.p.afterSubmitCell)) { ret = $t.p.afterSubmitCell.call($t, result,postdata.id,nm,v,iRow,iCol); } if(ret[0] === true){ $(cc).empty(); $($t).jqGrid("setCell",$t.rows[iRow].id, iCol, v2, false, false, true); $(cc).addClass("dirty-cell"); $($t.rows[iRow]).addClass("edited"); $($t).triggerHandler("jqGridAfterSaveCell", [$t.rows[iRow].id, nm, v, iRow, iCol]); if ($.isFunction($t.p.afterSaveCell)) { $t.p.afterSaveCell.call($t, $t.rows[iRow].id,nm, v, iRow,iCol); } $t.p.savedRow.splice(0,1); } else { $.jgrid.info_dialog($.jgrid.errors.errcap,ret[1],$.jgrid.edit.bClose); $($t).jqGrid("restoreCell",iRow,iCol); } } }, error:function(res,stat,err) { $("#lui_"+$.jgrid.jqID($t.p.id)).hide(); $t.grid.hDiv.loading = false; $($t).triggerHandler("jqGridErrorCell", [res, stat, err]); if ($.isFunction($t.p.errorCell)) { $t.p.errorCell.call($t, res,stat,err); $($t).jqGrid("restoreCell",iRow,iCol); } else { $.jgrid.info_dialog($.jgrid.errors.errcap,res.status+" : "+res.statusText+"
    "+stat,$.jgrid.edit.bClose); $($t).jqGrid("restoreCell",iRow,iCol); } } }, $.jgrid.ajaxOptions, $t.p.ajaxCellOptions || {})); } else { try { $.jgrid.info_dialog($.jgrid.errors.errcap,$.jgrid.errors.nourl,$.jgrid.edit.bClose); $($t).jqGrid("restoreCell",iRow,iCol); } catch (e) {} } } if ($t.p.cellsubmit === 'clientArray') { $(cc).empty(); $($t).jqGrid("setCell",$t.rows[iRow].id,iCol, v2, false, false, true); $(cc).addClass("dirty-cell"); $($t.rows[iRow]).addClass("edited"); $($t).triggerHandler("jqGridAfterSaveCell", [$t.rows[iRow].id, nm, v, iRow, iCol]); if ($.isFunction($t.p.afterSaveCell)) { $t.p.afterSaveCell.call($t, $t.rows[iRow].id,nm, v, iRow,iCol); } $t.p.savedRow.splice(0,1); } } else { try { window.setTimeout(function(){$.jgrid.info_dialog($.jgrid.errors.errcap,v+" "+cv[1],$.jgrid.edit.bClose);},100); $($t).jqGrid("restoreCell",iRow,iCol); } catch (e) {} } } else { $($t).jqGrid("restoreCell",iRow,iCol); } } window.setTimeout(function () { $("#"+$.jgrid.jqID($t.p.knv)).attr("tabindex","-1").focus();},0); }); }, restoreCell : function(iRow, iCol) { return this.each(function(){ var $t= this, fr; if (!$t.grid || $t.p.cellEdit !== true ) {return;} if ( $t.p.savedRow.length >= 1) {fr = 0;} else {fr=null;} if(fr !== null) { var cc = $("td:eq("+iCol+")",$t.rows[iRow]); // datepicker fix if($.isFunction($.fn.datepicker)) { try { $("input.hasDatepicker",cc).datepicker('hide'); } catch (e) {} } $(cc).empty().attr("tabindex","-1"); $($t).jqGrid("setCell",$t.rows[iRow].id, iCol, $t.p.savedRow[fr].v, false, false, true); $($t).triggerHandler("jqGridAfterRestoreCell", [$t.rows[iRow].id, $t.p.savedRow[fr].v, iRow, iCol]); if ($.isFunction($t.p.afterRestoreCell)) { $t.p.afterRestoreCell.call($t, $t.rows[iRow].id, $t.p.savedRow[fr].v, iRow, iCol); } $t.p.savedRow.splice(0,1); } window.setTimeout(function () { $("#"+$t.p.knv).attr("tabindex","-1").focus();},0); }); }, nextCell : function (iRow,iCol) { return this.each(function (){ var $t = this, nCol=false, i; if (!$t.grid || $t.p.cellEdit !== true) {return;} // try to find next editable cell for (i=iCol+1; i<$t.p.colModel.length; i++) { if ( $t.p.colModel[i].editable ===true) { nCol = i; break; } } if(nCol !== false) { $($t).jqGrid("editCell",iRow,nCol,true); } else { if ($t.p.savedRow.length >0) { $($t).jqGrid("saveCell",iRow,iCol); } } }); }, prevCell : function (iRow,iCol) { return this.each(function (){ var $t = this, nCol=false, i; if (!$t.grid || $t.p.cellEdit !== true) {return;} // try to find next editable cell for (i=iCol-1; i>=0; i--) { if ( $t.p.colModel[i].editable ===true) { nCol = i; break; } } if(nCol !== false) { $($t).jqGrid("editCell",iRow,nCol,true); } else { if ($t.p.savedRow.length >0) { $($t).jqGrid("saveCell",iRow,iCol); } } }); }, GridNav : function() { return this.each(function () { var $t = this; if (!$t.grid || $t.p.cellEdit !== true ) {return;} // trick to process keydown on non input elements $t.p.knv = $t.p.id + "_kn"; var selection = $("
    "), i, kdir; function scrollGrid(iR, iC, tp){ if (tp.substr(0,1)==='v') { var ch = $($t.grid.bDiv)[0].clientHeight, st = $($t.grid.bDiv)[0].scrollTop, nROT = $t.rows[iR].offsetTop+$t.rows[iR].clientHeight, pROT = $t.rows[iR].offsetTop; if(tp === 'vd') { if(nROT >= ch) { $($t.grid.bDiv)[0].scrollTop = $($t.grid.bDiv)[0].scrollTop + $t.rows[iR].clientHeight; } } if(tp === 'vu'){ if (pROT < st ) { $($t.grid.bDiv)[0].scrollTop = $($t.grid.bDiv)[0].scrollTop - $t.rows[iR].clientHeight; } } } if(tp==='h') { var cw = $($t.grid.bDiv)[0].clientWidth, sl = $($t.grid.bDiv)[0].scrollLeft, nCOL = $t.rows[iR].cells[iC].offsetLeft+$t.rows[iR].cells[iC].clientWidth, pCOL = $t.rows[iR].cells[iC].offsetLeft; if(nCOL >= cw+parseInt(sl,10)) { $($t.grid.bDiv)[0].scrollLeft = $($t.grid.bDiv)[0].scrollLeft + $t.rows[iR].cells[iC].clientWidth; } else if (pCOL < sl) { $($t.grid.bDiv)[0].scrollLeft = $($t.grid.bDiv)[0].scrollLeft - $t.rows[iR].cells[iC].clientWidth; } } } function findNextVisible(iC,act){ var ind, i; if(act === 'lft') { ind = iC+1; for (i=iC;i>=0;i--){ if ($t.p.colModel[i].hidden !== true) { ind = i; break; } } } if(act === 'rgt') { ind = iC-1; for (i=iC; i<$t.p.colModel.length;i++){ if ($t.p.colModel[i].hidden !== true) { ind = i; break; } } } return ind; } $(selection).insertBefore($t.grid.cDiv); $("#"+$t.p.knv) .focus() .keydown(function (e){ kdir = e.keyCode; if($t.p.direction === "rtl") { if(kdir===37) { kdir = 39;} else if (kdir===39) { kdir = 37; } } switch (kdir) { case 38: if ($t.p.iRow-1 >0 ) { scrollGrid($t.p.iRow-1,$t.p.iCol,'vu'); $($t).jqGrid("editCell",$t.p.iRow-1,$t.p.iCol,false); } break; case 40 : if ($t.p.iRow+1 <= $t.rows.length-1) { scrollGrid($t.p.iRow+1,$t.p.iCol,'vd'); $($t).jqGrid("editCell",$t.p.iRow+1,$t.p.iCol,false); } break; case 37 : if ($t.p.iCol -1 >= 0) { i = findNextVisible($t.p.iCol-1,'lft'); scrollGrid($t.p.iRow, i,'h'); $($t).jqGrid("editCell",$t.p.iRow, i,false); } break; case 39 : if ($t.p.iCol +1 <= $t.p.colModel.length-1) { i = findNextVisible($t.p.iCol+1,'rgt'); scrollGrid($t.p.iRow,i,'h'); $($t).jqGrid("editCell",$t.p.iRow,i,false); } break; case 13: if (parseInt($t.p.iCol,10)>=0 && parseInt($t.p.iRow,10)>=0) { $($t).jqGrid("editCell",$t.p.iRow,$t.p.iCol,true); } break; default : return true; } return false; }); }); }, getChangedCells : function (mthd) { var ret=[]; if (!mthd) {mthd='all';} this.each(function(){ var $t= this,nm; if (!$t.grid || $t.p.cellEdit !== true ) {return;} $($t.rows).each(function(j){ var res = {}; if ($(this).hasClass("edited")) { $('td',this).each( function(i) { nm = $t.p.colModel[i].name; if ( nm !== 'cb' && nm !== 'subgrid') { if (mthd==='dirty') { if ($(this).hasClass('dirty-cell')) { try { res[nm] = $.unformat.call($t,this,{rowId:$t.rows[j].id, colModel:$t.p.colModel[i]},i); } catch (e){ res[nm] = $.jgrid.htmlDecode($(this).html()); } } } else { try { res[nm] = $.unformat.call($t,this,{rowId:$t.rows[j].id,colModel:$t.p.colModel[i]},i); } catch (e) { res[nm] = $.jgrid.htmlDecode($(this).html()); } } } }); res.id = this.id; ret.push(res); } }); }); return ret; } /// end cell editing }); })(jQuery); /*jshint eqeqeq:false */ /*global jQuery */ (function($){ /** * jqGrid extension for SubGrid Data * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl-2.0.html **/ "use strict"; $.jgrid.extend({ setSubGrid : function () { return this.each(function (){ var $t = this, cm, i, suboptions = { plusicon : "ui-icon-plus", minusicon : "ui-icon-minus", openicon: "ui-icon-carat-1-sw", expandOnLoad: false, delayOnLoad : 50, selectOnExpand : false, reloadOnExpand : true }; $t.p.subGridOptions = $.extend(suboptions, $t.p.subGridOptions || {}); $t.p.colNames.unshift(""); $t.p.colModel.unshift({name:'subgrid',width: $.jgrid.cell_width ? $t.p.subGridWidth+$t.p.cellLayout : $t.p.subGridWidth,sortable: false,resizable:false,hidedlg:true,search:false,fixed:true}); cm = $t.p.subGridModel; if(cm[0]) { cm[0].align = $.extend([],cm[0].align || []); for(i=0;i"; }, addSubGrid : function( pos, sind ) { return this.each(function(){ var ts = this; if (!ts.grid ) { return; } //------------------------- var subGridCell = function(trdiv,cell,pos) { var tddiv = $("").html(cell); $(trdiv).append(tddiv); }; var subGridXml = function(sjxml, sbid){ var tddiv, i, sgmap, dummy = $("
    "), trdiv = $(""); for (i = 0; i"); $(tddiv).html(ts.p.subGridModel[0].name[i]); $(tddiv).width( ts.p.subGridModel[0].width[i]); $(trdiv).append(tddiv); } $(dummy).append(trdiv); if (sjxml){ sgmap = ts.p.xmlReader.subgrid; $(sgmap.root+" "+sgmap.row, sjxml).each( function(){ trdiv = $(""); if(sgmap.repeatitems === true) { $(sgmap.cell,this).each( function(i) { subGridCell(trdiv, $(this).text() || ' ',i); }); } else { var f = ts.p.subGridModel[0].mapping || ts.p.subGridModel[0].name; if (f) { for (i=0;i"), trdiv = $(""); for (i = 0; i"); $(tddiv).html(ts.p.subGridModel[0].name[i]); $(tddiv).width( ts.p.subGridModel[0].width[i]); $(trdiv).append(tddiv); } $(dummy).append(trdiv); if (sjxml){ sgmap = ts.p.jsonReader.subgrid; result = $.jgrid.getAccessor(sjxml, sgmap.root); if ( result !== undefined ) { for (i=0;i"); if(sgmap.repeatitems === true) { if(sgmap.cell) { cur=cur[sgmap.cell]; } for (j=0;j 0) { i = sind; len = sind+1; } while(i < len) { if($(ts.rows[i]).hasClass('jqgrow')) { $(ts.rows[i].cells[pos]).bind('click', function() { var tr = $(this).parent("tr")[0]; r = tr.nextSibling; if($(this).hasClass("sgcollapsed")) { pID = ts.p.id; _id = tr.id; if(ts.p.subGridOptions.reloadOnExpand === true || ( ts.p.subGridOptions.reloadOnExpand === false && !$(r).hasClass('ui-subgrid') ) ) { atd = pos >=1 ? " ":""; bfsc = $(ts).triggerHandler("jqGridSubGridBeforeExpand", [pID + "_" + _id, _id]); bfsc = (bfsc === false || bfsc === 'stop') ? false : true; if(bfsc && $.isFunction(ts.p.subGridBeforeExpand)) { bfsc = ts.p.subGridBeforeExpand.call(ts, pID+"_"+_id,_id); } if(bfsc === false) {return false;} $(tr).after( ""+atd+"
    " ); $(ts).triggerHandler("jqGridSubGridRowExpanded", [pID + "_" + _id, _id]); if( $.isFunction(ts.p.subGridRowExpanded)) { ts.p.subGridRowExpanded.call(ts, pID+"_"+ _id,_id); } else { populatesubgrid(tr); } } else { $(r).show(); } $(this).html("").removeClass("sgcollapsed").addClass("sgexpanded"); if(ts.p.subGridOptions.selectOnExpand) { $(ts).jqGrid('setSelection',_id); } } else if($(this).hasClass("sgexpanded")) { bfsc = $(ts).triggerHandler("jqGridSubGridRowColapsed", [pID + "_" + _id, _id]); bfsc = (bfsc === false || bfsc === 'stop') ? false : true; if( bfsc && $.isFunction(ts.p.subGridRowColapsed)) { _id = tr.id; bfsc = ts.p.subGridRowColapsed.call(ts, pID+"_"+_id,_id ); } if(bfsc===false) {return false;} if(ts.p.subGridOptions.reloadOnExpand === true) { $(r).remove(".ui-subgrid"); } else if($(r).hasClass('ui-subgrid')) { // incase of dynamic deleting $(r).hide(); } $(this).html("").removeClass("sgexpanded").addClass("sgcollapsed"); } return false; }); } i++; } if(ts.p.subGridOptions.expandOnLoad === true) { $(ts.rows).filter('.jqgrow').each(function(index,row){ $(row.cells[0]).click(); }); } ts.subGridXml = function(xml,sid) {subGridXml(xml,sid);}; ts.subGridJson = function(json,sid) {subGridJson(json,sid);}; }); }, expandSubGridRow : function(rowid) { return this.each(function () { var $t = this; if(!$t.grid && !rowid) {return;} if($t.p.subGrid===true) { var rc = $(this).jqGrid("getInd",rowid,true); if(rc) { var sgc = $("td.sgcollapsed",rc)[0]; if(sgc) { $(sgc).trigger("click"); } } } }); }, collapseSubGridRow : function(rowid) { return this.each(function () { var $t = this; if(!$t.grid && !rowid) {return;} if($t.p.subGrid===true) { var rc = $(this).jqGrid("getInd",rowid,true); if(rc) { var sgc = $("td.sgexpanded",rc)[0]; if(sgc) { $(sgc).trigger("click"); } } } }); }, toggleSubGridRow : function(rowid) { return this.each(function () { var $t = this; if(!$t.grid && !rowid) {return;} if($t.p.subGrid===true) { var rc = $(this).jqGrid("getInd",rowid,true); if(rc) { var sgc = $("td.sgcollapsed",rc)[0]; if(sgc) { $(sgc).trigger("click"); } else { sgc = $("td.sgexpanded",rc)[0]; if(sgc) { $(sgc).trigger("click"); } } } } }); } }); })(jQuery); /** * jqGrid extension - Tree Grid * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ /*jshint eqeqeq:false */ /*global jQuery */ (function($) { "use strict"; $.jgrid.extend({ setTreeNode : function(i, len){ return this.each(function(){ var $t = this; if( !$t.grid || !$t.p.treeGrid ) {return;} var expCol = $t.p.expColInd, expanded = $t.p.treeReader.expanded_field, isLeaf = $t.p.treeReader.leaf_field, level = $t.p.treeReader.level_field, icon = $t.p.treeReader.icon_field, loaded = $t.p.treeReader.loaded, lft, rgt, curLevel, ident,lftpos, twrap, ldat, lf; while(i"; twrap += "
    ").prepend(twrap); if(curLevel !== parseInt($t.p.tree_root_level,10)) { var pn = $($t).jqGrid('getNodeParent',ldat); expan = pn && pn.hasOwnProperty(expanded) ? pn[expanded] : true; if( !expan ){ $($t.rows[i]).css("display","none"); } } $($t.rows[i].cells[expCol]) .find("div.treeclick") .bind("click",function(e){ var target = e.target || e.srcElement, ind2 =$.jgrid.stripPref($t.p.idPrefix,$(target,$t.rows).closest("tr.jqgrow")[0].id), pos = $t.p._index[ind2]; if(!$t.p.data[pos][isLeaf]){ if($t.p.data[pos][expanded]){ $($t).jqGrid("collapseRow",$t.p.data[pos]); $($t).jqGrid("collapseNode",$t.p.data[pos]); } else { $($t).jqGrid("expandRow",$t.p.data[pos]); $($t).jqGrid("expandNode",$t.p.data[pos]); } } return false; }); if($t.p.ExpandColClick === true) { $($t.rows[i].cells[expCol]) .find("span.cell-wrapper") .css("cursor","pointer") .bind("click",function(e) { var target = e.target || e.srcElement, ind2 =$.jgrid.stripPref($t.p.idPrefix,$(target,$t.rows).closest("tr.jqgrow")[0].id), pos = $t.p._index[ind2]; if(!$t.p.data[pos][isLeaf]){ if($t.p.data[pos][expanded]){ $($t).jqGrid("collapseRow",$t.p.data[pos]); $($t).jqGrid("collapseNode",$t.p.data[pos]); } else { $($t).jqGrid("expandRow",$t.p.data[pos]); $($t).jqGrid("expandNode",$t.p.data[pos]); } } $($t).jqGrid("setSelection",ind2); return false; }); } i++; } }); }, setTreeGrid : function() { return this.each(function (){ var $t = this, i=0, pico, ecol = false, nm, key, tkey, dupcols=[]; if(!$t.p.treeGrid) {return;} if(!$t.p.treedatatype ) {$.extend($t.p,{treedatatype: $t.p.datatype});} $t.p.subGrid = false;$t.p.altRows =false; $t.p.pgbuttons = false;$t.p.pginput = false; $t.p.gridview = true; if($t.p.rowTotal === null ) { $t.p.rowNum = 10000; } $t.p.multiselect = false;$t.p.rowList = []; $t.p.expColInd = 0; pico = 'ui-icon-triangle-1-' + ($t.p.direction==="rtl" ? 'w' : 'e'); $t.p.treeIcons = $.extend({plus:pico,minus:'ui-icon-triangle-1-s',leaf:'ui-icon-radio-off'},$t.p.treeIcons || {}); if($t.p.treeGridModel === 'nested') { $t.p.treeReader = $.extend({ level_field: "level", left_field:"lft", right_field: "rgt", leaf_field: "isLeaf", expanded_field: "expanded", loaded: "loaded", icon_field: "icon" },$t.p.treeReader); } else if($t.p.treeGridModel === 'adjacency') { $t.p.treeReader = $.extend({ level_field: "level", parent_id_field: "parent", leaf_field: "isLeaf", expanded_field: "expanded", loaded: "loaded", icon_field: "icon" },$t.p.treeReader ); } for ( key in $t.p.colModel){ if($t.p.colModel.hasOwnProperty(key)) { nm = $t.p.colModel[key].name; if( nm === $t.p.ExpandColumn && !ecol ) { ecol = true; $t.p.expColInd = i; } i++; // for(tkey in $t.p.treeReader) { if($t.p.treeReader.hasOwnProperty(tkey) && $t.p.treeReader[tkey] === nm) { dupcols.push(nm); } } } } $.each($t.p.treeReader,function(j,n){ if(n && $.inArray(n, dupcols) === -1){ if(j==='leaf_field') { $t.p._treeleafpos= i; } i++; $t.p.colNames.push(n); $t.p.colModel.push({name:n,width:1,hidden:true,sortable:false,resizable:false,hidedlg:true,editable:true,search:false}); } }); }); }, expandRow: function (record){ this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) {return;} var childern = $($t).jqGrid("getNodeChildren",record), //if ($($t).jqGrid("isVisibleNode",record)) { expanded = $t.p.treeReader.expanded_field, rows = $t.rows; $(childern).each(function(){ var id = $t.p.idPrefix + $.jgrid.getAccessor(this,$t.p.localReader.id); $(rows.namedItem(id)).css("display",""); if(this[expanded]) { $($t).jqGrid("expandRow",this); } }); //} }); }, collapseRow : function (record) { this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) {return;} var childern = $($t).jqGrid("getNodeChildren",record), expanded = $t.p.treeReader.expanded_field, rows = $t.rows; $(childern).each(function(){ var id = $t.p.idPrefix + $.jgrid.getAccessor(this,$t.p.localReader.id); $(rows.namedItem(id)).css("display","none"); if(this[expanded]){ $($t).jqGrid("collapseRow",this); } }); }); }, // NS ,adjacency models getRootNodes : function() { var result = []; this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) {return;} switch ($t.p.treeGridModel) { case 'nested' : var level = $t.p.treeReader.level_field; $($t.p.data).each(function(){ if(parseInt(this[level],10) === parseInt($t.p.tree_root_level,10)) { result.push(this); } }); break; case 'adjacency' : var parent_id = $t.p.treeReader.parent_id_field; $($t.p.data).each(function(){ if(this[parent_id] === null || String(this[parent_id]).toLowerCase() === "null") { result.push(this); } }); break; } }); return result; }, getNodeDepth : function(rc) { var ret = null; this.each(function(){ if(!this.grid || !this.p.treeGrid) {return;} var $t = this; switch ($t.p.treeGridModel) { case 'nested' : var level = $t.p.treeReader.level_field; ret = parseInt(rc[level],10) - parseInt($t.p.tree_root_level,10); break; case 'adjacency' : ret = $($t).jqGrid("getNodeAncestors",rc).length; break; } }); return ret; }, getNodeParent : function(rc) { var result = null; this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) {return;} switch ($t.p.treeGridModel) { case 'nested' : var lftc = $t.p.treeReader.left_field, rgtc = $t.p.treeReader.right_field, levelc = $t.p.treeReader.level_field, lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10); $(this.p.data).each(function(){ if(parseInt(this[levelc],10) === level-1 && parseInt(this[lftc],10) < lft && parseInt(this[rgtc],10) > rgt) { result = this; return false; } }); break; case 'adjacency' : var parent_id = $t.p.treeReader.parent_id_field, dtid = $t.p.localReader.id; $(this.p.data).each(function(){ if(this[dtid] === $.jgrid.stripPref($t.p.idPrefix, rc[parent_id]) ) { result = this; return false; } }); break; } }); return result; }, getNodeChildren : function(rc) { var result = []; this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) {return;} switch ($t.p.treeGridModel) { case 'nested' : var lftc = $t.p.treeReader.left_field, rgtc = $t.p.treeReader.right_field, levelc = $t.p.treeReader.level_field, lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10); $(this.p.data).each(function(){ if(parseInt(this[levelc],10) === level+1 && parseInt(this[lftc],10) > lft && parseInt(this[rgtc],10) < rgt) { result.push(this); } }); break; case 'adjacency' : var parent_id = $t.p.treeReader.parent_id_field, dtid = $t.p.localReader.id; $(this.p.data).each(function(){ if(this[parent_id] == $.jgrid.stripPref($t.p.idPrefix, rc[dtid])) { result.push(this); } }); break; } }); return result; }, getFullTreeNode : function(rc) { var result = []; this.each(function(){ var $t = this, len; if(!$t.grid || !$t.p.treeGrid) {return;} switch ($t.p.treeGridModel) { case 'nested' : var lftc = $t.p.treeReader.left_field, rgtc = $t.p.treeReader.right_field, levelc = $t.p.treeReader.level_field, lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10); $(this.p.data).each(function(){ if(parseInt(this[levelc],10) >= level && parseInt(this[lftc],10) >= lft && parseInt(this[lftc],10) <= rgt) { result.push(this); } }); break; case 'adjacency' : if(rc) { result.push(rc); var parent_id = $t.p.treeReader.parent_id_field, dtid = $t.p.localReader.id; $(this.p.data).each(function(i){ len = result.length; for (i = 0; i < len; i++) { if ($.jgrid.stripPref($t.p.idPrefix, result[i][dtid]) === this[parent_id]) { result.push(this); break; } } }); } break; } }); return result; }, // End NS, adjacency Model getNodeAncestors : function(rc) { var ancestors = []; this.each(function(){ if(!this.grid || !this.p.treeGrid) {return;} var parent = $(this).jqGrid("getNodeParent",rc); while (parent) { ancestors.push(parent); parent = $(this).jqGrid("getNodeParent",parent); } }); return ancestors; }, isVisibleNode : function(rc) { var result = true; this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) {return;} var ancestors = $($t).jqGrid("getNodeAncestors",rc), expanded = $t.p.treeReader.expanded_field; $(ancestors).each(function(){ result = result && this[expanded]; if(!result) {return false;} }); }); return result; }, isNodeLoaded : function(rc) { var result; this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) {return;} var isLeaf = $t.p.treeReader.leaf_field; if(rc !== undefined ) { if(rc.loaded !== undefined) { result = rc.loaded; } else if( rc[isLeaf] || $($t).jqGrid("getNodeChildren",rc).length > 0){ result = true; } else { result = false; } } else { result = false; } }); return result; }, expandNode : function(rc) { return this.each(function(){ if(!this.grid || !this.p.treeGrid) {return;} var expanded = this.p.treeReader.expanded_field, parent = this.p.treeReader.parent_id_field, loaded = this.p.treeReader.loaded, level = this.p.treeReader.level_field, lft = this.p.treeReader.left_field, rgt = this.p.treeReader.right_field; if(!rc[expanded]) { var id = $.jgrid.getAccessor(rc,this.p.localReader.id); var rc1 = $("#" + this.p.idPrefix + $.jgrid.jqID(id),this.grid.bDiv)[0]; var position = this.p._index[id]; if( $(this).jqGrid("isNodeLoaded",this.p.data[position]) ) { rc[expanded] = true; $("div.treeclick",rc1).removeClass(this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.minus+" tree-minus"); } else if (!this.grid.hDiv.loading) { rc[expanded] = true; $("div.treeclick",rc1).removeClass(this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.minus+" tree-minus"); this.p.treeANode = rc1.rowIndex; this.p.datatype = this.p.treedatatype; if(this.p.treeGridModel === 'nested') { $(this).jqGrid("setGridParam",{postData:{nodeid:id,n_left:rc[lft],n_right:rc[rgt],n_level:rc[level]}}); } else { $(this).jqGrid("setGridParam",{postData:{nodeid:id,parentid:rc[parent],n_level:rc[level]}} ); } $(this).trigger("reloadGrid"); rc[loaded] = true; if(this.p.treeGridModel === 'nested') { $(this).jqGrid("setGridParam",{postData:{nodeid:'',n_left:'',n_right:'',n_level:''}}); } else { $(this).jqGrid("setGridParam",{postData:{nodeid:'',parentid:'',n_level:''}}); } } } }); }, collapseNode : function(rc) { return this.each(function(){ if(!this.grid || !this.p.treeGrid) {return;} var expanded = this.p.treeReader.expanded_field; if(rc[expanded]) { rc[expanded] = false; var id = $.jgrid.getAccessor(rc,this.p.localReader.id); var rc1 = $("#" + this.p.idPrefix + $.jgrid.jqID(id),this.grid.bDiv)[0]; $("div.treeclick",rc1).removeClass(this.p.treeIcons.minus+" tree-minus").addClass(this.p.treeIcons.plus+" tree-plus"); } }); }, SortTree : function( sortname, newDir, st, datefmt) { return this.each(function(){ if(!this.grid || !this.p.treeGrid) {return;} var i, len, rec, records = [], $t = this, query, roots, rt = $(this).jqGrid("getRootNodes"); // Sorting roots query = $.jgrid.from(rt); query.orderBy(sortname,newDir,st, datefmt); roots = query.select(); // Sorting children for (i = 0, len = roots.length; i < len; i++) { rec = roots[i]; records.push(rec); $(this).jqGrid("collectChildrenSortTree",records, rec, sortname, newDir,st, datefmt); } $.each(records, function(index) { var id = $.jgrid.getAccessor(this,$t.p.localReader.id); $('#'+$.jgrid.jqID($t.p.id)+ ' tbody tr:eq('+index+')').after($('tr#'+$.jgrid.jqID(id),$t.grid.bDiv)); }); query = null;roots=null;records=null; }); }, collectChildrenSortTree : function(records, rec, sortname, newDir,st, datefmt) { return this.each(function(){ if(!this.grid || !this.p.treeGrid) {return;} var i, len, child, ch, query, children; ch = $(this).jqGrid("getNodeChildren",rec); query = $.jgrid.from(ch); query.orderBy(sortname, newDir, st, datefmt); children = query.select(); for (i = 0, len = children.length; i < len; i++) { child = children[i]; records.push(child); $(this).jqGrid("collectChildrenSortTree",records, child, sortname, newDir, st, datefmt); } }); }, // experimental setTreeRow : function(rowid, data) { var success=false; this.each(function(){ var t = this; if(!t.grid || !t.p.treeGrid) {return;} success = $(t).jqGrid("setRowData",rowid,data); }); return success; }, delTreeNode : function (rowid) { return this.each(function () { var $t = this, rid = $t.p.localReader.id, i, left = $t.p.treeReader.left_field, right = $t.p.treeReader.right_field, myright, width, res, key; if(!$t.grid || !$t.p.treeGrid) {return;} var rc = $t.p._index[rowid]; if (rc !== undefined) { // nested myright = parseInt($t.p.data[rc][right],10); width = myright - parseInt($t.p.data[rc][left],10) + 1; var dr = $($t).jqGrid("getFullTreeNode",$t.p.data[rc]); if(dr.length>0){ for (i=0;i= 0 ) { while(i>=0){max = Math.max(max, parseInt($t.p.data[i][$t.p.localReader.id],10)); i--;} } nodeid = max+1; } var prow = $($t).jqGrid('getInd', parentid); leaf = false; // if not a parent we assume root if ( parentid === undefined || parentid === null || parentid==="") { parentid = null; rowind = null; method = 'last'; parentlevel = $t.p.tree_root_level; i = $t.p.data.length+1; } else { method = 'after'; parentindex = $t.p._index[parentid]; parentdata = $t.p.data[parentindex]; parentid = parentdata[$t.p.localReader.id]; parentlevel = parseInt(parentdata[level],10)+1; var childs = $($t).jqGrid('getFullTreeNode', parentdata); // if there are child nodes get the last index of it if(childs.length) { i = childs[childs.length-1][$t.p.localReader.id]; rowind = i; i = $($t).jqGrid('getInd',rowind)+1; } else { i = $($t).jqGrid('getInd', parentid)+1; } // if the node is leaf if(parentdata[isLeaf]) { leaf = true; parentdata[expanded] = true; //var prow = $($t).jqGrid('getInd', parentid); $($t.rows[prow]) .find("span.cell-wrapperleaf").removeClass("cell-wrapperleaf").addClass("cell-wrapper") .end() .find("div.tree-leaf").removeClass($t.p.treeIcons.leaf+" tree-leaf").addClass($t.p.treeIcons.minus+" tree-minus"); $t.p.data[parentindex][isLeaf] = false; parentdata[loaded] = true; } } len = i+1; if( data[expanded]===undefined) {data[expanded]= false;} if( data[loaded]===undefined ) { data[loaded] = false;} data[level] = parentlevel; if( data[isLeaf]===undefined) {data[isLeaf]= true;} if( $t.p.treeGridModel === "adjacency") { data[parent] = parentid; } if( $t.p.treeGridModel === "nested") { // this method requiere more attention var query, res, key; //maxright = parseInt(maxright,10); // ToDo - update grid data if(parentid !== null) { maxright = parseInt(parentdata[right],10); query = $.jgrid.from($t.p.data); query = query.greaterOrEquals(right,maxright,{stype:'integer'}); res = query.select(); if(res.length) { for( key in res) { if(res.hasOwnProperty(key)) { res[key][left] = res[key][left] > maxright ? parseInt(res[key][left],10) +2 : res[key][left]; res[key][right] = res[key][right] >= maxright ? parseInt(res[key][right],10) +2 : res[key][right]; } } } data[left] = maxright; data[right]= maxright+1; } else { maxright = parseInt( $($t).jqGrid('getCol', right, false, 'max'), 10); res = $.jgrid.from($t.p.data) .greater(left,maxright,{stype:'integer'}) .select(); if(res.length) { for( key in res) { if(res.hasOwnProperty(key)) { res[key][left] = parseInt(res[key][left],10) +2 ; } } } res = $.jgrid.from($t.p.data) .greater(right,maxright,{stype:'integer'}) .select(); if(res.length) { for( key in res) { if(res.hasOwnProperty(key)) { res[key][right] = parseInt(res[key][right],10) +2 ; } } } data[left] = maxright+1; data[right] = maxright + 2; } } if( parentid === null || $($t).jqGrid("isNodeLoaded",parentdata) || leaf ) { $($t).jqGrid('addRowData', nodeid, data, method, rowind); $($t).jqGrid('setTreeNode', i, len); } if(parentdata && !parentdata[expanded] && expandData) { $($t.rows[prow]) .find("div.treeclick") .click(); } } //}); } }); })(jQuery); /*jshint eqeqeq:false, eqnull:true */ /*global jQuery */ // Grouping module (function($){ "use strict"; $.extend($.jgrid,{ template : function(format){ //jqgformat var args = $.makeArray(arguments).slice(1), j, al = args.length; if(format==null) { format = ""; } return format.replace(/\{([\w\-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g, function(m,i){ if(!isNaN(parseInt(i,10))) { return args[parseInt(i,10)]; } for(j=0; j < al;j++) { if($.isArray(args[j])) { var nmarr = args[ j ], k = nmarr.length; while(k--) { if(i===nmarr[k].nm) { return nmarr[k].v; } } } } }); } }); $.jgrid.extend({ groupingSetup : function () { return this.each(function (){ var $t = this, i, j, cml, cm = $t.p.colModel, grp = $t.p.groupingView; if(grp !== null && ( (typeof grp === 'object') || $.isFunction(grp) ) ) { if(!grp.groupField.length) { $t.p.grouping = false; } else { if (grp.visibiltyOnNextGrouping === undefined) { grp.visibiltyOnNextGrouping = []; } grp.lastvalues=[]; grp.groups =[]; grp.counters =[]; for(i=0;i= 0; i--) { if(grp[i].idx === id-offset) { ret = grp[i]; break; } } } } return ret; } var sumreverse = $.makeArray(grp.groupSummary); sumreverse.reverse(); $.each(grp.groups,function(i,n){ toEnd++; clid = $t.p.id+"ghead_"+n.idx; hid = clid+"_"+i; icon = ""; try { if ($.isArray(grp.formatDisplayField) && $.isFunction(grp.formatDisplayField[n.idx])) { n.displayValue = grp.formatDisplayField[n.idx].call($t, n.displayValue, n.value, $t.p.colModel[cp[n.idx]], n.idx, grp); } gv = $t.formatter(hid, n.displayValue, cp[n.idx], n.value ); } catch (egv) { gv = n.displayValue; } str += ""+icon+$.jgrid.template(grp.groupText[n.idx], gv, n.cnt, n.summary)+""; var leaf = len-1 === n.idx; if( leaf ) { var gg = grp.groups[i+1], k, kk, ik; var end = gg !== undefined ? grp.groups[i+1].startRow : grdata.length; for(kk=n.startRow;kk"; var fdata = findGroupIdx(i, ik, grp.groups), cm = $t.p.colModel, vv, grlen = fdata.cnt; for(k=0; k ", tplfld = "{0}"; $.each(fdata.summary,function(){ if(this.nm === cm[k].name) { if(cm[k].summaryTpl) { tplfld = cm[k].summaryTpl; } if(typeof this.st === 'string' && this.st.toLowerCase() === 'avg') { if(this.v && grlen > 0) { this.v = (this.v/grlen); } } try { vv = $t.formatter('', this.v, k, this); } catch (ef) { vv = this.v; } tmpdata= ""+$.jgrid.format(tplfld,vv)+ ""; return false; } }); str += tmpdata; } str += ""; } toEnd = jj; } }); $("#"+$.jgrid.jqID($t.p.id)+" tbody:first").append(str); // free up memory str = null; }); }, groupingGroupBy : function (name, options ) { return this.each(function(){ var $t = this; if(typeof name === "string") { name = [name]; } var grp = $t.p.groupingView; $t.p.grouping = true; //Set default, in case visibilityOnNextGrouping is undefined if (grp.visibiltyOnNextGrouping === undefined) { grp.visibiltyOnNextGrouping = []; } var i; // show previous hidden groups if they are hidden and weren't removed yet for(i=0;i