code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
package cn.com.widemex.core.db; //package cn.com.myext.core.db; //import java.io.Serializable; //import java.util.Collection; //import java.util.List; // //import org.apache.commons.logging.Log; //import org.apache.commons.logging.LogFactory; //import org.springframework.jdbc.core.support.JdbcDaoSupport; // //import cn.com.myext.core.utils.GenericsUtils; //import cn.com.myext.core.vo.PageVO; // ///** // * JDBC支持 // * @author 张中原 // * @since 2010-6-26 // * @version ExtFw3.0 // * @param <T> // */ //public class JdbcSupport<T, ID extends Serializable> extends JdbcDaoSupport implements ExtDao<T, ID >{ //// protected static Log logger = LogFactory.getLog(JdbcSupport.class); //// protected Class<T> entityClass; //// public JdbcSupport() { //// //获得范型参数的类型 //// this.entityClass = GenericsUtils.getSuperClassGenricType(this.getClass()); //// } //// //// /** //// * 删除 //// */ //// public boolean remove(String sql, Object... params) { //// if(this.getJdbcTemplate().update(sql, params) > 0){ //// return true; //// } //// return false; //// } //// public boolean remove(String sql, Object[] params, int[] types) { //// if(this.getJdbcTemplate().update(sql, params, types) > 0){ //// return true; //// } //// return false; //// } //// //// /** //// * //// * @param hql //// * @param params //// * @return //// */ //// public int executeUpdate(String sql, Object... params){ //// return this.getJdbcTemplate().update(sql, params); //// } //// public int executeUpdate(String sql, Object[] params, int[] types){ //// return this.getJdbcTemplate().update(sql, params, types); //// } //// //// //待实现====================================== //// public List<T> find(String hql, Object... params) { //// // TODO Auto-generated method stub //// //SqlRowSet rs = jdbcTemplate.queryForRowSet(sql, params); //// return null; //// } //// //// public List<T> find(String hql, boolean isHql, Object... params) { //// // TODO Auto-generated method stub //// return null; //// } //// //// public List<T> findBy(String name, Object value) { //// // TODO Auto-generated method stub //// return null; //// } //// //// public List<T> findBy(String name, Object value, String sort, boolean isAsc) { //// // TODO Auto-generated method stub //// return null; //// } //// //// public T findUniqueBy(String name, Object value) { //// // TODO Auto-generated method stub //// return null; //// } //// //// public T get(Serializable id) { //// // TODO Auto-generated method stub //// return null; //// } //// //// public boolean isUnique(String hql, Object... params) { //// // TODO Auto-generated method stub //// return false; //// } //// //// public PageVO pagedQuery(int start, int limit, String where, //// Object... params) { //// // TODO Auto-generated method stub //// return null; //// } //// //// public boolean remove(T id) { //// // TODO Auto-generated method stub //// return false; //// } //// //// public boolean remove(Serializable id) { //// // TODO Auto-generated method stub //// return false; //// } //// //// public boolean removeAll(Collection<T> list) { //// // TODO Auto-generated method stub //// return false; //// } //// //// public boolean save(T entity) { //// // TODO Auto-generated method stub //// return false; //// } //// //// public boolean saveOrUpdate(T entity) { //// // TODO Auto-generated method stub //// return false; //// } //// //// public boolean saveOrUpdateAll(Collection<T> entities) { //// // TODO Auto-generated method stub //// return false; //// } //// //// public boolean update(T entity) { //// // TODO Auto-generated method stub //// return false; //// } // //}
zzyapps
trunk/JqFw/core/cn/com/widemex/core/db/JdbcDao.java
Java
asf20
3,871
package cn.com.widemex.core.json.serializer; import java.io.IOException; import java.sql.Timestamp; import org.codehaus.jackson.JsonGenerator; import org.codehaus.jackson.JsonProcessingException; import org.codehaus.jackson.map.JsonSerializer; import org.codehaus.jackson.map.SerializerProvider; import cn.com.widemex.core.utils.data.DateHelper; public class TimestampSerializer extends JsonSerializer<Timestamp>{ /**格式化*/ // private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @Override public void serialize(Timestamp value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { String formattedDate = DateHelper.TIMESTAMP_FORMAT.format(value); jgen.writeString(formattedDate); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/json/serializer/TimestampSerializer.java
Java
asf20
822
package cn.com.widemex.core.json.serializer; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import org.codehaus.jackson.JsonGenerator; import org.codehaus.jackson.JsonProcessingException; import org.codehaus.jackson.map.JsonSerializer; import org.codehaus.jackson.map.SerializerProvider; import cn.com.widemex.core.utils.data.DateHelper; public class DateSerializer extends JsonSerializer<Date>{ @Override public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { // SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String formattedDate = DateHelper.TIMESTAMP_FORMAT.format(value); jgen.writeString(formattedDate); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/json/serializer/DateSerializer.java
Java
asf20
824
package cn.com.widemex.core.json.hibernate; import org.codehaus.jackson.Version; import org.codehaus.jackson.map.*; public class HibernateModule extends Module { private final String NAME = "HibernateModule"; // Should externalize this somehow private final static Version VERSION = new Version(0, 1, 0, null); // 0.1.0 /** * Enumeration that defines all togglable features this module */ public enum Feature { /** * Whether lazy-loaded object should be forced to be loaded and then serialized * (true); or serialized as nulls (false). *<p> * Default value is false. */ FORCE_LAZY_LOADING(false), /** * Whether @Transient annotation should be checked or not; if true, will consider * @Transient to mean that property is to be ignored; if false annotation will * have no effect. *<p> * Default value is true. * * @since 0.7.0 */ USE_TRANSIENT_ANNOTATION(true) ; final boolean _defaultState; final int _mask; /** * Method that calculates bit set (flags) of all features that * are enabled by default. */ public static int collectDefaults() { int flags = 0; for (Feature f : values()) { if (f.enabledByDefault()) { flags |= f.getMask(); } } return flags; } private Feature(boolean defaultState) { _defaultState = defaultState; _mask = (1 << ordinal()); } public boolean enabledByDefault() { return _defaultState; } public int getMask() { return _mask; } } protected final static int DEFAULT_FEATURES = Feature.collectDefaults(); /** * Bit flag composed of bits that indicate which * {@link Feature}s * are enabled. */ protected int _moduleFeatures = DEFAULT_FEATURES; /* /********************************************************************** /* Life-cycle /********************************************************************** */ public HibernateModule() { } @Override public String getModuleName() { return NAME; } @Override public Version version() { return VERSION; } @Override public void setupModule(SetupContext context) { /* First, append annotation introspector (no need to override, esp. * as we just implement couple of methods) */ // Then add serializers we need AnnotationIntrospector ai = annotationIntrospector(); if (ai != null) { context.appendAnnotationIntrospector(ai); } context.addSerializers(new HibernateSerializers(_moduleFeatures)); } /** * Method called during {@link #setupModule}, to create {@link AnnotationIntrospector} * to register along with module. If null is returned, no introspector is added. */ protected AnnotationIntrospector annotationIntrospector() { HibernateAnnotationIntrospector ai = new HibernateAnnotationIntrospector(); ai.setUseTransient(isEnabled(Feature.USE_TRANSIENT_ANNOTATION)); return ai; } /* /********************************************************************** /* Extended API, configuration /********************************************************************** */ public HibernateModule enable(Feature f) { _moduleFeatures |= f.getMask(); return this; } public HibernateModule disable(Feature f) { _moduleFeatures &= ~f.getMask(); return this; } public final boolean isEnabled(Feature f) { return (_moduleFeatures & f.getMask()) != 0; } public HibernateModule configure(Feature f, boolean state) { if (state) { enable(f); } else { disable(f); } return this; } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/json/hibernate/HibernateModule.java
Java
asf20
4,079
package cn.com.widemex.core.json.hibernate; import java.util.*; import org.hibernate.collection.PersistentCollection; import org.hibernate.collection.PersistentMap; import org.hibernate.proxy.HibernateProxy; import org.codehaus.jackson.map.*; import org.codehaus.jackson.map.type.CollectionType; import org.codehaus.jackson.map.type.MapType; import org.codehaus.jackson.map.type.TypeFactory; import org.codehaus.jackson.type.JavaType; import cn.com.widemex.core.json.hibernate.HibernateModule.Feature; public class HibernateSerializers extends Serializers.None { protected final int _moduleFeatures; public HibernateSerializers(int features) { _moduleFeatures = features; } @Override public JsonSerializer<?> findSerializer( SerializationConfig config, JavaType type, BeanDescription beanDesc, BeanProperty beanProperty ) { Class<?> raw = type.getRawClass(); /* Note: PersistentCollection does not implement Collection, so we * may get some types here... */ if (PersistentCollection.class.isAssignableFrom(raw)) { // TODO: handle iterator types? Or PersistentArrayHolder? } if (HibernateProxy.class.isAssignableFrom(raw)) { return new HibernateProxySerializer(beanProperty, isEnabled(Feature.FORCE_LAZY_LOADING)); } return null; } @Override public JsonSerializer<?> findCollectionSerializer(SerializationConfig config, CollectionType type, BeanDescription beanDesc, BeanProperty property, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) { Class<?> raw = type.getRawClass(); // only handle PersistentCollection style collections... if (PersistentCollection.class.isAssignableFrom(raw)) { /* And for those, figure out "fallback type"; we MUST have some idea of * type to deserialize, aside from nominal PersistentXxx type. */ return new PersistentCollectionSerializer(property, _figureFallbackType(config, type), isEnabled(Feature.FORCE_LAZY_LOADING)); } return null; } @Override public JsonSerializer<?> findMapSerializer(SerializationConfig config, MapType type, BeanDescription beanDesc, BeanProperty property, JsonSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) { Class<?> raw = type.getRawClass(); if (PersistentMap.class.isAssignableFrom(raw)) { return new PersistentCollectionSerializer(property, _figureFallbackType(config, type), isEnabled(Feature.FORCE_LAZY_LOADING)); } return null; } public final boolean isEnabled(HibernateModule.Feature f) { return (_moduleFeatures & f.getMask()) != 0; } protected JavaType _figureFallbackType(SerializationConfig config, JavaType persistentType) { // Alas, PersistentTypes are NOT generics-aware... meaning can't specify parameterization Class<?> raw = persistentType.getRawClass(); TypeFactory tf = config.getTypeFactory(); if (Map.class.isAssignableFrom(raw)) { return tf.constructMapType(Map.class, Object.class, Object.class); } if (List.class.isAssignableFrom(raw)) { return tf.constructCollectionType(List.class, Object.class); } if (Set.class.isAssignableFrom(raw)) { return tf.constructCollectionType(Set.class, Object.class); } // ok, just Collection of some kind return tf.constructCollectionType(Collection.class, Object.class); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/json/hibernate/HibernateSerializers.java
Java
asf20
3,821
package cn.com.widemex.core.json.hibernate; import java.lang.annotation.Annotation; import javax.persistence.Transient; import org.codehaus.jackson.map.introspect.AnnotatedConstructor; import org.codehaus.jackson.map.introspect.AnnotatedField; import org.codehaus.jackson.map.introspect.AnnotatedMethod; import org.codehaus.jackson.map.introspect.NopAnnotationIntrospector; /** * Simple {@link org.codehaus.jackson.map.AnnotationIntrospector} that adds support for using * {@link Transient} to denote ignorable fields (alongside with Jackson * and/or JAXB annotations). */ public class HibernateAnnotationIntrospector extends NopAnnotationIntrospector { /** * Whether we should check for existence of @Transient or not. * Default value is 'true'. */ protected boolean _cfgCheckTransient; /* /********************************************************************** /* Construction, configuration /********************************************************************** */ public HibernateAnnotationIntrospector() { } /** * Method to call to specify whether @Transient annotation is to be * supported; if false, will be ignored, if true, will be used to * detect "ignorable" properties. */ public HibernateAnnotationIntrospector setUseTransient(boolean state) { _cfgCheckTransient = state; return this; } /* /********************************************************************** /* AnnotationIntrospector implementation/overrides /********************************************************************** */ @Override public boolean isHandled(Annotation a) { // We only care for one single type, for now: return (a.annotationType() == Transient.class); } public boolean isIgnorableConstructor(AnnotatedConstructor c) { return _cfgCheckTransient && c.hasAnnotation(Transient.class); } public boolean isIgnorableField(AnnotatedField f) { return _cfgCheckTransient && f.hasAnnotation(Transient.class); } public boolean isIgnorableMethod(AnnotatedMethod m) { return _cfgCheckTransient && m.hasAnnotation(Transient.class); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/json/hibernate/HibernateAnnotationIntrospector.java
Java
asf20
2,254
package cn.com.widemex.core.json.hibernate; import java.io.IOException; import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.LazyInitializer; import org.codehaus.jackson.JsonGenerator; import org.codehaus.jackson.JsonProcessingException; import org.codehaus.jackson.map.BeanProperty; import org.codehaus.jackson.map.JsonSerializer; import org.codehaus.jackson.map.SerializerProvider; import org.codehaus.jackson.map.TypeSerializer; import org.codehaus.jackson.map.ser.impl.PropertySerializerMap; /** * Serializer to use for values proxied using {@link HibernateProxy}. *<p> * TODO: should try to make this work more like Jackson * <code>BeanPropertyWriter</code>, possibly sub-classing * it -- it handles much of functionality we need, and has * access to more information than value serializers (like * this one) have. */ public class HibernateProxySerializer extends JsonSerializer<HibernateProxy> { /** * Property that has proxy value to handle */ protected final BeanProperty _property; protected final boolean _forceLazyLoading; /** * For efficient serializer lookup, let's use this; most * of the time, there's just one type and one serializer. */ protected PropertySerializerMap _dynamicSerializers; /* /********************************************************************** /* Life cycle /********************************************************************** */ public HibernateProxySerializer(BeanProperty property, boolean forceLazyLoading) { _property = property; _forceLazyLoading = forceLazyLoading; _dynamicSerializers = PropertySerializerMap.emptyMap(); } /* /********************************************************************** /* JsonSerializer impl /********************************************************************** */ @Override public void serialize(HibernateProxy value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { Object proxiedValue = findProxied(value); // TODO: figure out how to suppress nulls, if necessary? (too late for that here) if (proxiedValue == null) { provider.defaultSerializeNull(jgen); return; } findSerializer(provider, proxiedValue).serialize(proxiedValue, jgen, provider); } public void serializeWithType(HibernateProxy value, JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, JsonProcessingException { Object proxiedValue = findProxied(value); if (proxiedValue == null) { provider.defaultSerializeNull(jgen); return; } /* This isn't exactly right, since type serializer really refers to proxy * object, not value. And we really don't either know static type (necessary * to know how to apply additional type info) or other things; * so it's not going to work well. But... we'll do out best. */ findSerializer(provider, proxiedValue).serializeWithType(proxiedValue, jgen, provider, typeSer); } /* /********************************************************************** /* Helper methods /********************************************************************** */ protected JsonSerializer<Object> findSerializer(SerializerProvider provider, Object value) throws IOException, JsonProcessingException { /* TODO: if Hibernate did use generics, or we wanted to allow use of Jackson * annotations to indicate type, should take that into account. */ Class<?> type = value.getClass(); /* we will use a map to contain serializers found so far, keyed by type: * this avoids potentially costly lookup from global caches and/or construction * of new serializers */ PropertySerializerMap.SerializerAndMapResult result = _dynamicSerializers.findAndAddSerializer(type, provider, _property); if (_dynamicSerializers != result.map) { _dynamicSerializers = result.map; } return result.serializer; } /** * Helper method for finding value being proxied, if it is available * or if it is to be forced to be loaded. */ protected Object findProxied(HibernateProxy proxy) { LazyInitializer init = proxy.getHibernateLazyInitializer(); if (!_forceLazyLoading && init.isUninitialized()) { return null; } return init.getImplementation(); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/json/hibernate/HibernateProxySerializer.java
Java
asf20
4,704
package cn.com.widemex.core.json.hibernate; import java.io.IOException; import org.hibernate.collection.PersistentCollection; import org.codehaus.jackson.JsonGenerator; import org.codehaus.jackson.JsonProcessingException; import org.codehaus.jackson.map.*; import org.codehaus.jackson.type.JavaType; /** * Wrapper serializer used to handle aspects of lazy loading that can be used * for Hibernate collection datatypes. */ public class PersistentCollectionSerializer extends JsonSerializer<PersistentCollection> implements ContextualSerializer<PersistentCollection>, ResolvableSerializer { /** * Property that has collection value to handle */ protected final BeanProperty _property; protected final boolean _forceLazyLoading; /** * This is the nominal type used to locate actual serializer to use * for contents, if this collection is to be serialized. */ protected final JavaType _serializationType; /** * Serializer to which we delegate if serialization is not blocked. */ protected JsonSerializer<Object> _serializer; /* /********************************************************************** /* Life cycle /********************************************************************** */ public PersistentCollectionSerializer(BeanProperty property, JavaType type, boolean forceLazyLoading) { _property = property; _serializationType = type; _forceLazyLoading = forceLazyLoading; } /** * We need to resolve actual serializer once we know the context; specifically * must know type of property being serialized. * If not known */ public JsonSerializer<PersistentCollection> createContextual(SerializationConfig config, BeanProperty property) throws JsonMappingException { /* If we have property, should be able to get actual polymorphic type * information. * May need to refine in future, in case nested types are used, since * 'property' refers to field/method and main type, but contents of * that type may also be resolved... in which case this would fail. */ if (property != null) { return new PersistentCollectionSerializer(property, property.getType(), _forceLazyLoading); } return this; } public void resolve(SerializerProvider provider) throws JsonMappingException { _serializer = provider.findValueSerializer(_serializationType, _property); } /* /********************************************************************** /* JsonSerializer impl /********************************************************************** */ @Override public void serialize(PersistentCollection coll, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { // If lazy-loaded, not yet loaded, may serialize as null? if (!_forceLazyLoading && !coll.wasInitialized()) { jgen.writeNull(); return; } Object value = coll.getValue(); if (value == null) { provider.defaultSerializeNull(jgen); } else { if (_serializer == null) { // sanity check... // zzy+ jgen.writeNull(); throw new JsonMappingException("PersitentCollection does not have serializer set"); } _serializer.serialize(value, jgen, provider); } } public void serializeWithType(PersistentCollection coll, JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, JsonProcessingException { if (!_forceLazyLoading && !coll.wasInitialized()) { jgen.writeNull(); return; } Object value = coll.getValue(); if (value == null) { provider.defaultSerializeNull(jgen); } else { if (_serializer == null) { // sanity check... throw new JsonMappingException("PersitentCollection does not have serializer set"); } _serializer.serializeWithType(value, jgen, provider, typeSer); } } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/json/hibernate/PersistentCollectionSerializer.java
Java
asf20
4,356
package cn.com.widemex.core.vo; /** * 排序VO * @author 张中原 * */ public class SortVO { /**要排序的字段属性*/ private String property; /**排序形式:ASC ,DESC */ private String direction; public SortVO(){}; /** * 排序vo构造函数 * @param property 排序字段 * @param direction 排序方式:ASC,DESC */ public SortVO(String property, String direction){ this.property = property; this.direction = (direction==null || direction.equals("") ) ? "ASC" : direction; } public String getProperty() { return property; } public void setProperty(String property) { this.property = property; } public String getDirection() { return direction; } public void setDirection(String direction) { this.direction = direction; } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/vo/SortVO.java
Java
asf20
837
package cn.com.widemex.core.vo; import org.codehaus.jackson.annotate.JsonIgnoreProperties; /** * 参数VO * @author 查询参数类 * */ public class ParamsVO { /**参数名称*/ private String name; /**参数值*/ private Object value; public String getName() { return name; } public void setName(String name) { this.name = name; } public Object getValue() { return value; } public void setValue(Object value) { this.value = value; } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/vo/ParamsVO.java
Java
asf20
494
package cn.com.widemex.core.vo; import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.type.TypeFactory; import cn.com.widemex.core.data.MyHashMap; import cn.com.widemex.core.data.MyMap; import cn.com.widemex.core.utils.web.WebUtils; /** * 分页值对象 * 用于存放一页数据以及关于该页的相关信息 * @author 张中原 * */ @JsonIgnoreProperties(value={"where", "whereParams", "sortList"}) public class PageVO extends MsgVO{ /**树节点*/ // private String node; /**记录总数*/ private int total; /**行数*/ private int limit; /** 起始行 */ private int start; /** 查询条件 */ private String where = ""; /** 查询条件的参数 数组*/ private Object[] whereParams = new Object[]{}; /**排序的信息集合*/ private List<SortVO> sortList; // /**定制参数*/ // private MyMap myParams; /**构造函数:空*/ public PageVO(){} /** * 有参构造函数:请求对象转换成参数 * @param request 请求对象 */ public PageVO(HttpServletRequest request){ super(request); // super.setParams(WebUtils.getParamsMap(request)); } /** * 获取MsgVO对象 * @param request 请求对象 * @return */ public static PageVO valueOf(HttpServletRequest request){ PageVO vo = new PageVO( request ); // 参数map MyMap map = vo.getParams(); // 处理页面大小 if(map.get("limit") != null){ vo.setLimit(map.getInt("limit", 0)); map.remove("limit"); } // 处理页面 if(map.get("start") != null){ vo.setStart(map.getInt("start", 0)); map.remove("start"); } // 处理where语句 if(map.get("where") != null){ vo.setWhere(map.getString("where", "")); map.remove("where"); } // 处理排序信息 if(map.get("sort") != null){ List<SortVO> list = new ArrayList<SortVO>(); list.add(new SortVO(map.getString("sort"), map.getString("order", "ASC"))); vo.setSortList(list); map.remove("sort"); map.remove("order"); } // if(map.getString("sort") != null){ // ObjectMapper mapper = new ObjectMapper(); // try { // vo.setSortList((List<SortVO>) mapper.readValue(map.getString("sort"), TypeFactory.collectionType(ArrayList.class, SortVO.class))); // map.remove("sort"); // } catch (Exception e) { // System.err.println("排序参数转换成集合时报错:::" + e.toString()); // } // } // 获取定制参数信息 // if(map.getString("myParams") != null){ // ObjectMapper mapper = new ObjectMapper(); // try { // vo.setMyParams((MyMap) mapper.readValue(map.getString("myParams"), TypeFactory.mapType(MyHashMap.class, String.class, String.class))); // map.remove("myParams"); // } catch (Exception e) { // System.err.println("定制参数转换成Map时报错:::" + e.toString()); // } // } // // 获取树节点 // if(map.getString("node") != null){ // vo.setNode(map.getString("node")); // } return vo; } /** * 构造 * @param result * @param totalCount */ public PageVO(Object result, int totalCount) { this.setRows(result); this.total = totalCount; } /** * 构造 * @param start * @param limit * @param where */ public PageVO(int start, int limit, String where) { this.start = start; this.limit = limit; this.where = where; } /** * 构造 * @param start * @param limit * @param where * @param params */ public PageVO(int start, int limit, String where, Object... params) { this.start = start; this.limit = limit; this.where = where; } // // /** // * @return the totalCount // */ // public int getTotalCount() { // return totalCount; // } // // /** // * @param totalCount the totalCount to set // */ // public void setTotalCount(int totalCount) { // this.totalCount = totalCount; // } /** * @return the limit */ public int getLimit() { return limit; } /** * @param limit the limit to set */ public void setLimit(int limit) { this.limit = limit; } /** * @return the start */ public int getStart() { return start; } /** * @param start the start to set */ public void setStart(int start) { this.start = start; } /** * @return the where */ public String getWhere() { return where; } /** * @param where the where to set */ public void setWhere(String where) { this.where = where; } public List<SortVO> getSortList() { return sortList; } public void setSortList(List<SortVO> sortList) { this.sortList = sortList; } public Object[] getWhereParams() { return whereParams; } public void setWhereParams(Object[] whereParams) { this.whereParams = whereParams; } // public MyMap getMyParams() { // return myParams; // } // // public void setMyParams(MyMap myParams) { // this.myParams = myParams; // } // // public String getNode() { // return node; // } // // public void setNode(String node) { // this.node = node; // } public int getTotal() { return total; } public void setTotal(int total) { this.total = total; } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/vo/PageVO.java
Java
asf20
5,650
package cn.com.widemex.core.vo; import java.util.ArrayList; import java.util.Enumeration; import javax.servlet.http.HttpServletRequest; import cn.com.widemex.core.data.MyHashMap; import cn.com.widemex.core.data.MyMap; import cn.com.widemex.core.utils.web.WebUtils; /** * 消息返回对象 * Restful是用到 * @author 张中原 * */ public class MsgVO { /**日志实例化*/ // private static Logger logger = Logger.getLogger(MsgVO.class); /**是否执行成功*/ private boolean success = true; /**执行消息 */ private String message = ""; /**返回数据*/ private Object rows; /**前台传输的参数*/ private MyMap params; /**空构造函数*/ public MsgVO(){}; /** * 有参构造函数:请求对象转换成参数 * @param request 请求对象 */ public MsgVO(HttpServletRequest request){ this.params = new MyHashMap(); for (Enumeration<String> em = request.getParameterNames(); em.hasMoreElements();) { String key = em.nextElement(); this.params.put(key, request.getParameter(key)); } } /** * 获取MsgVO对象 * @param request 请求对象 * @return */ public static MsgVO valueOf(HttpServletRequest request){ MsgVO vo = new MsgVO( request ); return vo; } /** * 获取MsgVO对象 * @param success 是否成功 * @return */ public static MsgVO valueOf(Object results){ MsgVO vo = new MsgVO(); vo.setRows(results); return vo; } /** * 获取MsgVO对象 * @param success 是否成功 * @return */ public static MsgVO valueOf(boolean success){ MsgVO vo = new MsgVO(); vo.setSuccess(success); return vo; } /** * 获取MsgVO对象 * @param success 是否成功 * @param message 消息内容 * @return */ public static MsgVO valueOf(boolean success, String message){ MsgVO vo = new MsgVO(); vo.setSuccess(true); vo.setMessage(message); return vo; } /** * 获取MsgVO对象 * @param success 是否成功 * @param message 消息内容 * @param data 消息数据 * @return */ public static MsgVO valueOf(boolean success, String message, Object results){ MsgVO vo = new MsgVO(); vo.setSuccess(true); vo.setMessage(message); vo.setRows(results); return vo; } public boolean isSuccess() { return success; } public void setSuccess(boolean success) { this.success = success; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } // public Object getData() { // return data; // } // public void setData(Object data) { // this.data = data; // } public MyMap getParams() { return params; } public void setParams(MyMap params) { this.params = params; } public Object getRows() { return rows; } public void setRows(Object rows) { this.rows = rows; } // public Object getResults() { // return results; // } // // public void setResults(Object results) { // results = results==null ? new ArrayList() : results; // this.results = results; // } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/vo/MsgVO.java
Java
asf20
3,156
package cn.com.widemex.core.vo; /** * 树VO * easyui树展现的相关属性,主要用来被其他VO或者POJO继承用 * * @author 张中原 * */ public class TreeVO { /**节点样式*/ private String iconCls = "icon-tree-folder"; /**父节点key*/ private String parentId; /**节点状态,closed为关闭,open为打开*/ private String state = "closed"; /**其他信息*/ private Object otherInfo; /**是否选中当前行*/ private boolean checked=false; /**是否是叶子节点*/ private boolean leaf = false; /**是否已经加载*/ private boolean loaded = false; public boolean isLoaded() { return loaded; } public void setLoaded(boolean loaded) { this.loaded = loaded; } public boolean isLeaf() { return leaf; } public void setLeaf(boolean leaf) { // 如果是叶子节点,且节点样式为文件夹,则转换成文件样式形式 if(leaf && "icon-tree-folder".equals(iconCls)){ this.iconCls = "icon-tree-action"; } this.leaf = leaf; } public boolean isChecked() { return checked; } public void setChecked(boolean checked) { this.checked = checked; } public String getState() { return state; } public void setState(String state) { this.state = state; } public Object getOtherInfo() { return otherInfo; } public void setOtherInfo(Object otherInfo) { this.otherInfo = otherInfo; } public String getIconCls() { return iconCls; } public void setIconCls(String iconCls) { this.iconCls = iconCls; } public String getParentId() { return parentId; } public void setParentId(String parentId) { this.parentId = parentId; } // // public String get_parentId() { // return _parentId; // } // // public void set_parentId(String _parentId) { // this._parentId = _parentId; // } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/vo/TreeVO.java
Java
asf20
1,921
package cn.com.widemex.core.utils.data; /** * 字符串辅助类 * @author 张中原 * @since 2010-6-26 * @version ExtFw3.0 */ public class StrHelper { /** * 判断str中是否包含str2或者str3... * * @author davi * * @param str * @param str2 * @throws Exception * @return */ public static boolean like(Object str, Object... str2) throws Exception { return StrHelper.indexOf(str, str2) != -1; } /** * 返回匹配参数的序号 * * @author davi * * @param str * @param str2 * @throws Exception * @return */ public static Integer indexOf(Object str, Object... str2) throws Exception { if (str == null || str2 == null || str2.length == 0) { return -1; } else { for (int i = 0; i < str2.length; i++) { if (str2[i] == null) { return -1; } else if ((str + "").indexOf(str2[i] + "") >= 0) { return i + 1; } } return -1; } } /** * 字符串截取 * @param str * @param idx * @param str2[] * @return * @throws Exception */ public static String substring(String str, int idx, Object... str2) throws Exception{ if (str == null || str2 == null || str2.length == 0) { return str; } else { int i=StrHelper.indexOf(str, str2); if(i == -1){ return str.substring(idx); } else{ return StrHelper.substring(str.substring(0, str.indexOf(str2[i-1].toString())), idx, str2); } } } /** * 字符串替换 * @author davi * * @param source * @param oldString * @param newString * @return */ public static String replaceAll(String source, String oldString, String newString) { StringBuffer output = new StringBuffer(); int lengthOfSource = source.length(); int lengthOfOld = oldString.length(); int posStart = 0; int pos; // while ((pos = source.indexOf(oldString, posStart)) >= 0) { output.append(source.substring(posStart, pos)); output.append(newString); posStart = pos + lengthOfOld; } if (posStart < lengthOfSource) { output.append(source.substring(posStart)); } return output.toString(); } /** * 判断参数值是否为空 * @param s * @return */ public static boolean isEmpty(String s) { return s == null || s.equals("") || s.toUpperCase().equals("NULL") || s.equals("undefined"); } /** * 字符集转换 * @param s * @return */ public static String toUTF8(String s) { try { return new String(toISO(s), "UTF-8"); } catch (Exception e) { return null; } } private static byte[] toISO(String s) { try { return s.getBytes("ISO-8859-1"); } catch (Exception e) { return null; } } /** * */ public static void main(String[] argv) throws Exception { System.err.println(StrHelper.substring("机碎片湖南07年", 0, 0, 1, 2, 3)); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/data/StrHelper.java
Java
asf20
2,928
package cn.com.widemex.core.utils.data; import java.sql.Clob; import java.sql.SQLException; import java.sql.Time; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.lang.StringUtils; import cn.com.widemex.core.utils.reflection.ReflectionUtils; /** * <p>类名: TypeConverUtils</p> * <p>描述: 类型转换的相关静态方法</p> * @author 张中原 * @date Jul 7, 2010 */ public class ConverHelper { /** * <p>方法名: clob2String</p> * <p>描述:将Clob类型转换成String 类型 </p> * @param clob clob大文本对象 * @return */ public static String clob2String( Clob clob){ if(clob == null)return null; try { return clob.getSubString((long)1,(int)clob.length()); } catch (SQLException e) { e.printStackTrace(); } return null; } /** * <p>方法名: object2String</p> * <p>描述: 将对象转换成字符串</p> * @param obj 要转换的对象 * @return */ public static String object2String(Object obj){ if(obj == null) return null; //如果是Clob大文本对象 if(obj.getClass().getName().indexOf("CLOB") != -1){ return clob2String((Clob)(obj)); } return obj.toString(); } /** * <p>方法名: object2Long</p> * <p>描述: 将日期时间对象转换成long类型对象</p> * @param obj 要转换的对象 * @return */ public static Long dateTimeObject2Long(Object obj){ if(obj == null)return null; if(obj.getClass() == java.sql.Date.class){ return ((java.sql.Date)obj).getTime(); }else if(obj.getClass() == Time.class){ return ((Time)obj).getTime(); }else if( obj.getClass() == Date.class){ return ((Date)obj).getTime(); }else{ //if(obj.getClass() == Timestamp.class) try { return ((Timestamp)obj).getTime(); } catch (RuntimeException e) { throw new RuntimeException("时间日期类型转换错误,请确定你所获取的值是否是日期或者是时间类型"); } } } /** * <p>方法名: dateTimeObject2SqlDate</p> * <p>描述: 将日期时间对象转换成sql.Date对象</p> * @param obj 要转换的对象 * @return */ public static java.sql.Date dateTimeObject2SqlDate(Object obj){ if(obj == null)return null; if(obj.getClass() == java.sql.Date.class ) return (java.sql.Date)obj; return new java.sql.Date(dateTimeObject2Long(obj)); } /** * <p>方法名: dateTimeObject2UtilDate</p> * <p>描述: 将日期时间对象转换成util.Date对象</p> * @param obj 要转换的对象 * @return */ public static java.util.Date dateTimeObject2UtilDate(Object obj){ if(obj == null)return null; if(obj.getClass() == Date.class) return (Date)obj; return new Date(dateTimeObject2Long(obj)); } /** * <p>方法名: dateTimeObject2Time</p> * <p>描述: 将日期时间对象转换成Time对象</p> * @param obj 要转换的对象 * @return */ public static Time dateTimeObject2Time(Object obj){ if(obj == null)return null; if(obj.getClass() == Time.class) return (Time)obj; return new Time(dateTimeObject2Long(obj)); } /** * <p>方法名: dateTimeObject2Timestamp</p> * <p>描述: 将日期对象转换成Timestamp对象</p> * @param obj 要转换的对象 * @return */ public static Timestamp dateTimeObject2Timestamp(Object obj){ if(obj == null)return null; if(obj.getClass() == Timestamp.class)return (Timestamp)obj; return new Timestamp(dateTimeObject2Long(obj)); } /** * 提取集合中的对象的属性(通过getter函数), 组合成List. * * @param collection 来源集合. * @param propertyName 要提取的属性名. */ @SuppressWarnings("unchecked") public static List convertElementPropertyToList(final Collection collection, final String propertyName) { List list = new ArrayList(); try { for (Object obj : collection) { list.add(PropertyUtils.getProperty(obj, propertyName)); } } catch (Exception e) { throw ReflectionUtils.convertReflectionExceptionToUnchecked(e); } return list; } /** * 提取集合中的对象的属性(通过getter函数), 组合成由分割符分隔的字符串. * * @param collection 来源集合. * @param propertyName 要提取的属性名. * @param separator 分隔符. */ @SuppressWarnings("unchecked") public static String convertElementPropertyToString(final Collection collection, final String propertyName, final String separator) { List list = convertElementPropertyToList(collection, propertyName); return StringUtils.join(list, separator); } /** * 转换字符串到相应类型. * * @param value 待转换的字符串. * @param toType 转换目标类型. */ public static Object convertStringToObject(String value, Class<?> toType) { try { return org.apache.commons.beanutils.ConvertUtils.convert(value, toType); } catch (Exception e) { throw ReflectionUtils.convertReflectionExceptionToUnchecked(e); } } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/data/ConverHelper.java
Java
asf20
5,205
package cn.com.widemex.core.utils.data; import java.text.ParseException; import java.util.Date; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * 类型转换工具类 * @author 张中原 * @since 2010-6-26 * @version ExtFw3.0 * */ public class Type{ protected static Log logger = LogFactory.getLog(Type.class); /** * toString * @param s * @param defaultValue * @return */ public static String toString(Object s, String defaultValue) { if (StrHelper.isEmpty(s.toString())) return defaultValue; if(s.getClass().isArray()){ try{ String str = ""; Object[] arr = (Object[]) s; for(int i=0; i<arr.length; i++){ str += arr[i]; if(i < arr.length - 1){ str += ","; } } return str; } catch (Exception e) { logger.error(e.getMessage() + ", return " + (StrHelper.isEmpty(defaultValue) ? "\"\"" : defaultValue)); } } return s + ""; } /** * toString * @param s * @return */ public static String toString(Object s) { return toString(s, ""); } /** * toString * @param arr * @return */ public static String toString(String[] arr) { return toString(arr, ","); } /** * toString * @param arr * @param sep * @return */ public static String toString(String[] arr, String sep) { String s = ""; for(int i=0; i<arr.length; i++){ s += arr[i] + (i<arr.length-1 ? sep : ""); } return s; } /** * toLong * @param s * @param defaultValue * @return */ public static Long toLong(String s, Long defaultValue) { try { if (StrHelper.isEmpty(s)) return defaultValue; return Long.valueOf(s); } catch (Exception e) { logger.error(e.getMessage() + ", return " + defaultValue); return defaultValue; } } /** * toLong * @param s * @return */ public static Long toLong(String s) { return toLong(s, null); } /** * toDouble * @param s * @param defaultValue * @return */ public static Double toDouble(String s, Double defaultValue) { try { if (StrHelper.isEmpty(s)) return defaultValue; return Double.valueOf(s); } catch (Exception e) { logger.error(e.getMessage() + ", return " + defaultValue); return defaultValue; } } /** * toDouble * @param s * @return */ public static Double toDouble(String s) { return toDouble(s, null); } /** * toInteger * @param s * @param defaultValue * @return */ public static Integer toInteger(String s, Integer defaultValue) { try { if (StrHelper.isEmpty(s)) return defaultValue; return Integer.valueOf(s); } catch (Exception e) { logger.error(e.getMessage() + ", return " + defaultValue); return defaultValue; } } /** * toInteger * @param s * @return */ public static Integer toInteger(String s) { return toInteger(s, null); } /** * toFloat * @param value * @param defaultValue * @return */ public static Float toFloat(String value, Float defaultValue) { try { return Float.valueOf(value); } catch (Exception e) { logger.error(e.getMessage() + ", return " + defaultValue); return defaultValue; } } /** * toFloat * @param value * @return */ public static Float toFloat(String value) { return toFloat(value, null); } /** * toInt * @param value * @param defaultValue * @return */ public static int toInt(Object value, int defaultValue) { if (value instanceof Integer) { return ((Integer) value).intValue(); } else if (value instanceof Long) { return ((Long) value).intValue(); } else { return toInteger(value + "", defaultValue); } } /** * toInt * @param value * @return */ public static int toInt(Object value) { return toInt(value, 0); } /** * toShort * @param value * @param defaultValue * @return */ public static Short toShort(String value, Short defaultValue) { try { return Short.valueOf(value.split("\\.")[0]); } catch (Exception e) { logger.error(e.getMessage() + ", return " + defaultValue); return defaultValue; } } /** * toShort * @param value * @return */ public static Short toShort(String value) { return toShort(value, null); } /** * toDate * @param s * @param defaultValue * @return */ public static Date toDate(String s, Date defaultValue) { try { if (StrHelper.isEmpty(s)) return defaultValue; return DateHelper.stringToDate(s); } catch (ParseException e) { logger.error(e.getMessage() + ", return " + defaultValue); } return defaultValue; } /** * toDate * @param s * @return */ public static Date toDate(String s) { return toDate(s, null); } /** * nowDate * @return */ public static Date nowDate() { return DateHelper.nowDate(); } /** * toSqlDate * @param s * @param defaultValue * @return */ public static java.sql.Date toSqlDate(String s, java.sql.Date defaultValue) { return (java.sql.Date) toDate(s, defaultValue); } /** * toSqlDate * @param s * @return */ public static java.sql.Date toSqlDate(String s) { return (java.sql.Date) toDate(s, null); } /** * * @param args */ public static void main(String[] args){ System.err.println(toShort("10111.333")); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/data/Type.java
Java
asf20
6,001
package cn.com.widemex.core.utils.data; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; /** * MD5加密 * 工具类 * @author 张中原 * @since 2010-7-14 * @version ExtFw3.0 * */ public class MD5 { /** * The hex digits. */ private static final String[] hexDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R" }; /** * Transform the byte array to hex string. * * @param b * @return */ public static String byteArrayToHexString(byte[] b) { StringBuffer resultSb = new StringBuffer(); for (int i = 0; i < b.length; i++) { resultSb.append(byteToHexString(b[i])); } return resultSb.toString(); } /** * Transform a byte to hex string * * @param b * @return */ private static String byteToHexString(byte b) { int n = b; if (n < 0) n = 256 + n; // get the first four bit int d1 = n / 28; // get the second four bit int d2 = n % 28; return hexDigits[d1] + hexDigits[d2]; } /** * Get the MD5 encrypt hex string of the origin string. <br/> * The origin string won't validate here, so who use the API should validate * by himself * * @param origin * @return * @throws NoSuchAlgorithmException */ public static String encode(String origin) { MessageDigest md = null; try { md = MessageDigest.getInstance("MD5"); return byteArrayToHexString(md.digest(origin.getBytes())).toUpperCase(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return null; } } /** * * @param args */ public static void main(String[] args) { System.out.println(MD5.encode("a")); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/data/MD5.java
Java
asf20
2,146
package cn.com.widemex.core.utils.data; import java.util.Calendar; import java.util.Date; import java.text.SimpleDateFormat; import java.text.ParseException; /** * 日期处理工具类 * @author 张中原 * @since 2010-6-26 */ public class DateHelper { /**日期 :格式化'yyyy-MM-dd'Date*/ public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); /**时间戳:格式化'yyyy-MM-dd HH:mm:ss'Date*/ public static final SimpleDateFormat TIMESTAMP_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); /**年月 :格式化'yyyyMM'Date*/ public static final SimpleDateFormat MONTH_FORMAT = new SimpleDateFormat("yyyyMM"); /** * nowDate * @return */ public static Date nowDate() { Calendar calendar = Calendar.getInstance(); return calendar.getTime(); } /** * 获得某一日期的后N天字符串 * @param date * @param next * @param partten * @return */ public static String getNextDateString(Date date, int next, String partten) { return getDateString(getNextDate(date, next), partten); } /** * 获得某一日期的前N天字符串 * @param date * @param next * @param partten * @return */ public static String getPrevDateString(Date date, int Prev, String partten) { return getDateString(getPrevDate(date, Prev), partten); } /** * 获得某一日期的后N天 * @param date * @param next * @return */ public static Date getNextDate(Date date, int next) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int day = calendar.get(Calendar.DATE); calendar.set(Calendar.DATE, day + next); return calendar.getTime(); } /** * 获得某一日期的前N天 * @param date * @param Prev * @return */ public static Date getPrevDate(Date date, int Prev) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int day = calendar.get(Calendar.DATE); calendar.set(Calendar.DATE, day - Prev); return calendar.getTime(); } /** * 获得某年某月第一天的日期 * @param year * @param month * @return Date */ public static Date getFirstDayOfMonth(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DATE, 1); return calendar.getTime(); } /** * 获得某年某月最后一天的日期 * @param year * @param month * @return Date */ public static Date getLastDayOfMonth(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DATE, 1); return getPrevDate(calendar.getTime(), 1); } /** * 由年月日构建Date * @param year * @param month * @param day * @return */ public static Date buildDate(int year, int month, int day) { Calendar calendar = Calendar.getInstance(); calendar.set(year, month - 1, day); return calendar.getTime(); } /** * 取得某月的天数 * @param year * @param month * @return */ public static int getDayCountOfMonth(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DATE, 0); return calendar.get(Calendar.DATE); } /** * 获得某年某季度的最后一天的日期 * @param year * @param quarter * @return */ public static Date getLastDayOfQuarter(int year, int quarter) { int month = 0; if (quarter > 4) { return null; } else { month = quarter * 3; } return getLastDayOfMonth(year, month); } /** * 获得某年某季度的第一天的日期 * @param year * @param quarter * @return */ public static Date getFirstDayOfQuarter(int year, int quarter) { int month = 0; if (quarter > 4) { return null; } else { month = (quarter - 1) * 3 + 1; } return getFirstDayOfMonth(year, month); } /** * 获得某年的第一天的日期 * @param year * @return */ public static Date getFirstDayOfYear(int year) { return getFirstDayOfMonth(year, 1); } /** * 获得某年的最后一天的日期 * @param year * @return */ public static Date getLastDayOfYear(int year) { return getLastDayOfMonth(year, 12); } /** * String到Date的类型转换 * @param param * @return * @throws ParseException */ public static Date stringToDate(String param) throws ParseException { if(param == null || param == "" || param.indexOf("null") >=0) { return null; } else { if(param.length() > 11){ return new Date(Date.parse(param)); } Date date = null; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); param = param.replaceAll("年", "-").replaceAll("月", "-").replaceAll("日", "-").replaceAll("/", "-").replaceAll("\\.", "-"); date = sdf.parse(param); return new Date(date.getTime()); } } /** * 得到日期字符串 * @param date * @param partten * @return */ public static String getDateString(Date date, String partten) { if(date == null) date = nowDate(); String result = null; SimpleDateFormat formatter = new SimpleDateFormat(partten); result = formatter.format(date); return result; } /** * 得到日期字符串 * @param time * @param partten * @return */ public static String getDateString(Long time, String partten) { return getDateString(new Date(time), partten); } /** * 得到日期字符串 * @param partten * @return */ public static String getDateString(String partten) { return getDateString(nowDate(), partten); } /** * * @param argv * @throws ParseException */ public static void main(String[] argv) throws ParseException { System.out.println(getNextDate(new Date(), 1)); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/data/DateHelper.java
Java
asf20
6,916
package cn.com.widemex.core.utils.file; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.beans.XMLDecoder; import java.beans.XMLEncoder; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; /** * XML工具类 * 使用XML文件存取可序列化的对象的类 * @author 张中原 * @since 2010-6-26 * @version ExtFw3.0 * */ public class XmlHelper { private static Log logger = LogFactory.getLog(XmlHelper.class); /** * 把java的可序列化的对象(实现Serializable接口)序列化保存到XML文件里面,如果想一次保存多个可序列化对象请用集合进行封装 * 保存时将会用现在的对象原来的XML文件内容 * * @param obj 要序列化的可序列化的对象 * @param fileName 带完全的保存路径的文件名 * @throws FileNotFoundException 指定位置的文件不存在 * @throws IOException 输出时发生异常 * @throws Exception 其他运行时异常 */ public static void encoder(Object obj, String fileName) throws FileNotFoundException, IOException, Exception { //创建输出文件 File fo = new File(fileName); //文件不存在,就创建该文件 if (!fo.exists()) { // 先创建文件的目录 String path = fileName.substring(0, fileName.lastIndexOf('.')); File pFile = new File(path); pFile.mkdirs(); } //创建文件输出流 FileOutputStream fos = new FileOutputStream(fo); //创建XML文件对象输出类实例 XMLEncoder encoder = new XMLEncoder(fos); //对象序列化输出到XML文件 encoder.writeObject(obj); encoder.flush(); //关闭序列化工具 encoder.close(); //关闭输出流 fos.close(); } /** * XML TO OBJECT * * @param objSource 带全部文件路径的文件全名 * @return 由XML文件里面保存的对象 * @throws FileNotFoundException 指定的对象读取资源不存在 * @throws IOException 读取发生错误 * @throws Exception 其他运行时异常发生 */ public static Object decoder(String objSource) throws FileNotFoundException, IOException, Exception { // List objList = new ArrayList(); File fin = new File(objSource); FileInputStream fis = new FileInputStream(fin); XMLDecoder decoder = new XMLDecoder(fis); Object obj = null; try { obj = decoder.readObject(); // while ((obj = decoder.readObject()) != null) { // objList.add(obj); // } } catch (Exception e) { logger.error("XML TO OBJECT错误!" + e.getMessage()); } fis.close(); decoder.close(); return obj; } /** * * @param args * @throws Exception * @throws IOException * @throws FileNotFoundException */ public static void main(String[] args) throws FileNotFoundException, IOException, Exception{ // TemplateVo vo = new TemplateVo(); // List<String> l = new ArrayList(); // l.add("sss"); // l.add("ssaaa"); // vo.setGrid(l); // XmlHelper.encoder(vo, "D://test.xml"); // TemplateVo vo = (TemplateVo) XmlHelper.objectXmlDecoder("D://test.xml"); // System.err.println(vo.isHql()); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/file/XmlHelper.java
Java
asf20
3,254
package cn.com.widemex.core.utils.file; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.security.CodeSource; import java.security.ProtectionDomain; /** * 路径操作工具类 * 根据类的CLASS文件位置来定位 * @author 张中原 * @since 2010-6-26 * @version ExtFw3.0 * */ public class Path { /** * 返回某各类的绝对路径 * @param cls * @return * @throws IOException */ public static String getPathFromClass(Class cls) throws IOException { String path = null; if (cls == null) { throw new NullPointerException(); } URL url = getClassLocationURL(cls); if (url != null) { path = url.getPath(); if ("jar".equalsIgnoreCase(url.getProtocol())) { try { path = new URL(path).getPath(); } catch (MalformedURLException e) { } int location = path.indexOf("!/"); if (location != -1) { path = path.substring(0, location); } } File file = new File(path); path = file.getCanonicalPath(); } return path; } /** * 以Cls参数类为参照 * 返回其相对路径所对应的绝对路径 * @param relatedPath * @param cls * @return */ public static String getFullPathRelateClass(String relatedPath, Class cls){ String path = null; String clsPath; try { clsPath = getPathFromClass(cls); File clsFile = new File(clsPath); String tempPath = clsFile.getParent() + File.separator + relatedPath; File file = new File(tempPath); path = file.getCanonicalPath(); } catch (IOException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } return path; } /** * 以Path.class为参照 * 返回其相对路径所对应的绝对路径 * @param relatedPath * @return */ public static String getFullPath(String relatedPath){ String path = getFullPathRelateClass("../../" + relatedPath, Path.class); if(FileHelper.isDirectory(path, false) || FileHelper.isFile(path)){ // System.err.println(path); relatedPath = path; } else{ relatedPath = getFullPathRelateClass("../../../../../../../" + relatedPath, Path.class); } return relatedPath; } /** * 获取类的class的路径 * @param cls * @return */ private static URL getClassLocationURL(final Class cls) { if (cls == null) throw new IllegalArgumentException("null input: cls"); URL result = null; final String clsAsResource = cls.getName().replace('.', '/').concat(".class"); final ProtectionDomain pd = cls.getProtectionDomain(); if (pd != null) { final CodeSource cs = pd.getCodeSource(); if (cs != null) result = cs.getLocation(); if (result != null) { if ("file".equals(result.getProtocol())) { try { if (result.toExternalForm().endsWith(".jar") || result.toExternalForm().endsWith(".zip")){ result = new URL("jar:".concat(result.toExternalForm()).concat("!/").concat(clsAsResource)); } else if (new File(result.getFile()).isDirectory()){ result = new URL(result, clsAsResource); } } catch (MalformedURLException ignore) { } } } } if (result == null) { final ClassLoader clsLoader = cls.getClassLoader(); result = clsLoader != null ? clsLoader.getResource(clsAsResource) : ClassLoader.getSystemResource(clsAsResource); } return result; } /** * * @param args */ public static void main(String[] args) { try { // System.out.println(getPathFromClass(Path.class)); System.out.println(getFullPath("uploadFiles/tmp")); } catch (Exception e) { e.printStackTrace(); } } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/file/Path.java
Java
asf20
3,733
package cn.com.widemex.core.utils.file; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import cn.com.widemex.core.utils.data.StrHelper; import cn.com.widemex.core.utils.data.Type; /** * 文件操作工具类 * @author 何启伟 * @since 2010-6-26 * @version ExtFw3.0 * */ public class FileHelper{ protected static Log logger = LogFactory.getLog(FileHelper.class); /** * 写入文件 * @param filePath * @param fileName * @param content * @throws Exception */ public static void write(String filePath, String fileName, String content) throws Exception { OutputStreamWriter fw = null; PrintWriter out = null; try { FileHelper.isDirectory(filePath, true); fw = new OutputStreamWriter(new FileOutputStream(filePath + "/" + fileName), "UTF-8"); out = new PrintWriter(fw); out.print(content); } catch (Exception e) { logger.error("文件写入错误!\n" + e.getMessage()); } finally { if (out != null){ out.close(); } if (fw != null){ fw.close(); } } } /** * 根据size返回粘贴后的name */ public static String getPasteName(int size, String name) { if(StrHelper.isEmpty(name)) return ""; if(size <= 1){ name = "复件 " + name; } else{ String[] arr = name.split(" "); if(arr.length == 1){ return "复件 ("+size+") " + name; } else if(arr[0].equals("复件") && arr[1].substring(0, 1).equals("(") && arr[1].substring(arr[1].length() - 1).equals(")")){ arr[1] = "("+size+")"; } else{ arr[0] += " ("+size+")"; } name = Type.toString(arr, " "); } return name; } /** * 根据粘贴后的name获得原始name * @param name * @return */ public static String getPasteName(String name) { String[] arr = name.split(" "); if(arr.length == 1) return name; int index=0; if(arr[0].equals("复件") && arr[1].substring(0, 1).equals("(") && arr[1].substring(arr[1].length() - 1).equals(")")){ index = 2; } else{ index = 1; } name = ""; for(int ii=index; ii<arr.length; ii++){ name += arr[ii] + (ii<arr.length-1 ? " " : ""); } return name; } /** * 判断目录是否存在 * @param path * @param autoCreate */ public static boolean isDirectory(String path, boolean autoCreate){ File file = new File(path); if(file.isDirectory()){ return true; } else if(autoCreate){ file.mkdirs(); return true; } return false; } /** * 判断文件是否存在 * @param path * @param autoCreate */ public static boolean isFile(String file){ File f = new File(file); if(f.isFile()){ return true; } return false; } /** * 移动指定文件夹内的全部文件 * @param 要移动的文件目录 * @param 目标文件目录 * @throws Exception * @throws Exception */ public static void moveAll(String from, String to) throws Exception{ try { File dir = new File(from); //所有文件 File[] files = dir.listFiles(); if (files == null) return; //目标 File moveDir = new File(to); if (!moveDir.isDirectory()) { moveDir.mkdirs(); } //文件移动 for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { moveAll(files[i].getPath(), to + "\\" + files[i].getName()); // 成功,删除原文件 files[i].delete(); } File moveFile = new File(moveDir.getPath() + "\\" + files[i].getName()); // 目标文件夹下存在的话,删除 if (moveFile.exists()) { moveFile.delete(); } files[i].renameTo(moveFile); } dir.delete(); } catch (Exception e) { logger.error("移动文件夹[" + from + "]出错!"); throw e; } } /** * 删除文件夹 * @param dir * @return * @throws Exception */ public static void deleteFolder(String dir) throws Exception{ try { File file = new File(dir); if (!file.isDirectory()) { file.delete(); } else{ String[] filelist = file.list(); for (int i = 0; i < filelist.length; i++) { File delfile = new File(dir + "\\" + filelist[i]); if (!delfile.isDirectory()){ delfile.delete(); } else{ deleteFolder(dir + "\\" + filelist[i]); } } file.delete(); } } catch (Exception e) { logger.error("删除文件夹[" + dir + "]出错!"); throw e; } } /** * 复制整个文件夹内容 * * @param oldPath 原文件路径 如:c:/aaa * @param newPath 复制后路径 如:f:/bbb * @return boolean * @throws Exception */ public static void copyFolder(String oldPath, String newPath) throws Exception { try { (new File(newPath)).mkdirs(); // 如果文件夹不存在 则建立新文件夹 File a = new File(oldPath); String[] file = a.list(); File temp = null; for (int i = 0; i < file.length; i++) { if (oldPath.endsWith(File.separator)) { temp = new File(oldPath + file[i]); } else { temp = new File(oldPath + File.separator + file[i]); } if (temp.isFile()) { FileInputStream input = new FileInputStream(temp); FileOutputStream output = new FileOutputStream(newPath + "/" + (temp.getName()).toString()); byte[] b = new byte[1024 * 5]; int len; while ((len = input.read(b)) != -1) { output.write(b, 0, len); } output.flush(); output.close(); input.close(); } if (temp.isDirectory()) {// 如果是子文件夹 copyFolder(oldPath + "/" + file[i], newPath + "/" + file[i]); } } } catch (Exception e) { logger.error("复制文件夹[" + oldPath + "]出错!"); throw e; } } /** * 复制正式目录 * * @param 正式目录 * @return */ public static void copy(String copyDir, String dir){ copyDir = Path.getFullPath("uploadFiles/" + copyDir); dir = Path.getFullPath("uploadFiles/" + dir); try { copyFolder(copyDir, dir); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * 删除正式目录 * * @param 正式目录 * @return */ public static void delete(String dir){ dir = Path.getFullPath("uploadFiles/" + dir); try { deleteFolder(dir); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * 将临时目录中的文件移动到正式目录 * * @param 临时目录 * @param 正式目录 * @return */ public static void move(String tempDir, String dir){ tempDir = Path.getFullPath("uploadFiles/tmp/" + tempDir); dir = Path.getFullPath("uploadFiles/" + dir); if(isDirectory(tempDir, false)){ try { moveAll(tempDir, dir); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } /** * * @param args */ public static void main(String[] args){ for(int i=3;i<11; i++){ // String s = getPasteName(i, "复件 ("+i+") 测试测试测试"); // System.err.println(getPasteName(i, s)); } System.err.println(getPasteName(2, "复件 (33) 测试测")); // System.err.println(getPasteName("复件测试测试测试")); // System.err.println(getPasteName("复件 (33) 测试测试测试")); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/file/FileHelper.java
Java
asf20
7,674
/** * Copyright (c) 2005-2010 springside.org.cn * * Licensed under the Apache License, Version 2.0 (the "License"); * * $Id: ThreadUtils.java 1211 2010-09-10 16:20:45Z calvinxiu $ */ package cn.com.widemex.core.utils; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * 线程相关的Utils函数集合. * * @author calvin */ public class ThreadUtils { /** * sleep等待,单位毫秒,忽略InterruptedException. */ public static void sleep(long millis) { try { Thread.sleep(millis); } catch (InterruptedException e) { // Ignore. } } /** * 按照ExecutorService JavaDoc示例代码编写的Graceful Shutdown方法. * 先使用shutdown尝试执行所有任务. * 超时后调用shutdownNow取消在workQueue中Pending的任务,并中断所有阻塞函数. * 另对在shutdown时线程本身被调用中断做了处理. * @param shutdownNowTimeout TODO */ public static void gracefulShutdown(ExecutorService pool, int shutdownTimeout, int shutdownNowTimeout, TimeUnit timeUnit) { pool.shutdown(); // Disable new tasks from being submitted try { // Wait a while for existing tasks to terminate if (!pool.awaitTermination(shutdownTimeout, timeUnit)) { pool.shutdownNow(); // Cancel currently executing tasks // Wait a while for tasks to respond to being cancelled if (!pool.awaitTermination(shutdownNowTimeout, timeUnit)) { System.err.println("Pool did not terminate"); } } } catch (InterruptedException ie) { // (Re-)Cancel if current thread also interrupted pool.shutdownNow(); // Preserve interrupt status Thread.currentThread().interrupt(); } } /** * 直接调用shutdownNow的方法. */ public static void normalShutdown(ExecutorService pool, int timeout, TimeUnit timeUnit) { try { pool.shutdownNow(); if (!pool.awaitTermination(timeout, timeUnit)) { System.err.println("Pool did not terminate"); } } catch (InterruptedException ie) { Thread.currentThread().interrupt(); } } /** * 自定义ThreadFactory,可定制线程池的名称. */ public static class CustomizableThreadFactory implements ThreadFactory { private final String namePrefix; private final AtomicInteger threadNumber = new AtomicInteger(1); public CustomizableThreadFactory(String poolName) { namePrefix = poolName + "-"; } public Thread newThread(Runnable runable) { return new Thread(runable, namePrefix + threadNumber.getAndIncrement()); } } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/ThreadUtils.java
Java
asf20
2,696
package cn.com.widemex.core.utils.reflection; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * 处理范型参数的类型 * @author 何启伟 * @since 2010-6-26 * @version ExtFw3.0 */ public class GenericsUtils { private static final Log LOGGER = LogFactory.getLog(GenericsUtils.class); /** * 构造 */ protected GenericsUtils() { } /** * 通过反射,获得定义Class时声明的范型参数的类型 * @param clazz * @return */ public static Class getSuperClassGenricType(Class clazz) { return getSuperClassGenricType(clazz, 0); } /** * 通过反射,获得定义Class时声明的父类的范型参数的类型 * @param clazz * @param index * @return */ public static Class getSuperClassGenricType(Class clazz, int index) { Type genType = clazz.getGenericSuperclass(); if (!(genType instanceof ParameterizedType)) { LOGGER.warn(clazz.getSimpleName() + "'s superclass not ParameterizedType"); return Object.class; } Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); if (index >= params.length || index < 0) { LOGGER.warn("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " + params.length); return Object.class; } if (!(params[index] instanceof Class)) { LOGGER.warn(clazz.getSimpleName() + " not set the actual class on superclass generic parameter"); return Object.class; } return (Class) params[index]; } /** * 获取方法返回类型的泛型类型 * 如果:Set<User> ,返回User * @param method 有返回参数的方法 * @return */ public static Type[] getMethodGenericReturnType(Method method){ Type returnType = method.getGenericReturnType(); Type[] types = null; if (returnType instanceof ParameterizedType)/**//* 如果是泛型类型 */{ types = ((ParameterizedType) returnType).getActualTypeArguments();// 泛型类型列表 } return types; } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/reflection/GenericsUtils.java
Java
asf20
2,413
package cn.com.widemex.core.utils.reflection; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; import java.util.Enumeration; import java.util.Properties; import javax.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; import org.hibernate.Hibernate; import org.hibernate.id.Configurable; import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.UUIDHexGenerator; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.support.ClassPathXmlApplicationContext; import cn.com.widemex.core.json.hibernate.HibernateModule; import cn.com.widemex.core.utils.data.DateHelper; /** * 封装了Bean的获取、反射、GET、SET等 * @author 张中原 * @version JqFw * */ public class Bean{ protected static Log logger = LogFactory.getLog(Bean.class); public static BeanFactory beanFactory = null; /** * 获取getBeanFactory * @return */ private static BeanFactory getBeanFactory(){ if(beanFactory == null){ logger.info("获取不到WebApplicationContext,手工加载appContext"); beanFactory = new ClassPathXmlApplicationContext("classpath*:/config/spring/core/applicationContext.xml");; } return beanFactory; } /** * 根据beanName返回bean对象 * @param String beanName * @return Object */ public static Object get(String beanName){ return getBeanFactory().getBean(beanName); } /** * 根据class类获取bean对象 * @param <T> * @param cls * @return */ public static <T> T get(Class<T> cls){ return getBeanFactory().getBean(cls); } /** * 根据beanName和class类型获取bean对象 * @param <T> * @param beanName * @param cls * @return */ public static <T> T get(String beanName, Class<T> cls){ return getBeanFactory().getBean(beanName, cls); } /** * 打印request中的所有参数 * @param HttpServletRequest request */ public static void printReq(HttpServletRequest request) { logger.info("开始打印查询参数[" + DateHelper.getDateString("yyyy-MM-dd hh:mm:ss") + "]-------------------------------------"); for (Enumeration<String> em = request.getParameterNames(); em.hasMoreElements();) { String key = em.nextElement(); logger.info(key + ":" + request.getParameter(key)); } logger.info("-------------------------------------------------------------------------\n\n"); } /** * 执行某对象的方法(带参数) * @param Object 类 * @param String 方法名称 * @param Object[] 参数 * @return Object * @throws ExtFwException */ public static Object invokeMethod(Object owner, String methodName, Object[] args) throws Exception { Class<?> ownerClass = owner.getClass(); Class[] argsClass = new Class[args.length]; for (int i = 0, j = args.length; i < j; i++) { argsClass[i] = args[i].getClass(); if(("org.apache.catalina.connector.RequestFacade").equals(argsClass[i].getName())){ argsClass[i] = javax.servlet.http.HttpServletRequest.class; } } try { Method method = ownerClass.getMethod(methodName, argsClass); return method.invoke(owner, args); } catch (SecurityException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); throw new Exception(e); } catch (IllegalArgumentException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } catch (IllegalAccessException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); throw new Exception(e.getTargetException()); } return null; } /** * 执行静态对象的静态方法(带参数) * @param Object 类 * @param String 方法名称 * @param Object[] 参数 * @return Object */ public static Object invokeStaticMethod(String className, String methodName, Object[] args) throws Exception { // try { return invokeStaticMethod(Class.forName(className), methodName, args); // } catch (ClassNotFoundException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // return null; } public static Object invokeStaticMethod(Class<?> ownerClass, String methodName, Object[] args) throws Exception{ // try { Class[] argsClass = new Class[args.length]; for (int i = 0, j = args.length; i < j; i++) { argsClass[i] = args[i].getClass(); } Method method = ownerClass.getMethod(methodName, argsClass); return method.invoke(ownerClass, args); // } catch (SecurityException e) { // // TODO 自动生成 catch 块 // e.printStackTrace(); // } catch (NoSuchMethodException e) { // // TODO 自动生成 catch 块 // e.printStackTrace(); // } catch (IllegalArgumentException e) { // // TODO 自动生成 catch 块 // e.printStackTrace(); // } catch (IllegalAccessException e) { // // TODO 自动生成 catch 块 // e.printStackTrace(); // } catch (InvocationTargetException e) { // // TODO 自动生成 catch 块 // e.printStackTrace(); // } // return null; } /** * 执行某对象的方法(不带参数) * @param Object 类 * @param String 方法名称 * @return Object * @throws ExtFwException */ public static Object invokeMethod(Object owner, String methodName) throws Exception{ return invokeMethod(owner, methodName, new Object[0]); } /** * 得到对象某个属性 * @param Object 类 * @param String 属性名称 * @param boolean true: 返回属性值 false: 返回属性 * @return Object */ public static Object getProperty(Object owner, String propertyName, boolean f){ Class<?> ownerClass = owner.getClass(); try { Field field = ownerClass.getField(propertyName); if(!f) return field; Object property = field.get(owner); return property; } catch (SecurityException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO 自动生成 catch 块 //e.printStackTrace(); return null; } catch (IllegalArgumentException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } catch (IllegalAccessException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } return null; } /** * 返回对象某个属性的值 * @param Object 类 * @param String 属性名称 * @return Object */ public static Object getPropertyValue(Object owner, String propertyName) { return getProperty(owner, propertyName, true); } /** * 判断对象某个属性是否存在 * @param Object 类 * @param String 属性名称 * @return boolean */ public static boolean beingProperty(Object owner, String propertyName) { Object property = getProperty(owner, propertyName, false); return property != null; } /** * 打印po所有get方法的值 * @param po */ public static void printValues(Object po){ Class<?> ownerClass = po.getClass(); int j = 0; for (Method method : ownerClass.getMethods()) { String methodName = method.getName(); if (isGetter(method)) { try { System.err.println("["+(j++)+"]" + methodName + ":" + invokeMethod(po, methodName)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } /** * 将oldPo中不为null的值复制到newPo中 * @param oldPo * @param newPo */ public static void copy(Object oldPo, Object newPo){ copy(oldPo, newPo, false); } /** * 将oldPo中不为null的值复制到newPo中 * @param oldPo * @param newPo * @param print */ public static void copy(Object oldPo, Object newPo, boolean print) { Class<?> oldPoClass = oldPo.getClass(); Class<?> newPoClass = newPo.getClass(); for (Method method : oldPoClass.getMethods()) { if (method.getName().equals("getClass")) { continue; } if (isGetter(method)) { try { Object result = method.invoke(oldPo); if (result == null) { continue; } else if (result instanceof Collection<?>) { if (((Collection<?>) result).isEmpty()) { continue; } } else if (result.getClass().isArray()) { if (result instanceof Object[]) { if (((Object[]) result).length == 0) { continue; } } else if (result instanceof byte[]) { if (((byte[]) result).length == 0) { continue; } } else if (result instanceof short[]) { if (((short[]) result).length == 0) { continue; } } else if (result instanceof int[]) { if (((int[]) result).length == 0) { continue; } } else if (result instanceof long[]) { if (((long[]) result).length == 0) { continue; } } else if (result instanceof float[]) { if (((float[]) result).length == 0) { continue; } } else if (result instanceof double[]) { if (((double[]) result).length == 0) { continue; } } else if (result instanceof char[]) { if (((char[]) result).length == 0) { continue; } } else if (result instanceof boolean[]) { if (((boolean[]) result).length == 0) { continue; } } } // String methodName = getter2Setter(method.getName()); Class<?> methodParam = method.getReturnType(); try{ Method setter = newPoClass.getMethod(methodName, methodParam); if(print){ System.out.println("方法名称:" + methodName); System.out.println("参数类型:" + methodParam); System.out.println("set方法:" + setter); System.out.println(); } // setter.invoke(newPo, result); } catch(NoSuchMethodException e){ logger.warn("目标对象缺少" + e.getMessage() + "方法"); } } catch (Exception ex) { ex.printStackTrace(); } } } } /** * 返回是否为get方法 * @param method * @return boolean */ public static boolean isGetter(Method method) { String name = method.getName(); if (method.getParameterTypes().length == 0 && //方法没有参数 !name.equals("getClass") && //方法名称<>getClass name.startsWith("get") && //方法以get开头 name.length() > 3){ //方法名称3个字符以上 return true; } else { return false; } } /** * 根据get方法名称得到set方法名称 * @param methodName * @return */ public static String getter2Setter(String methodName) { if (methodName.startsWith("get")) { return methodName.replaceFirst("g", "s"); } else { return methodName; } } /** * 返回32位uuid * @return */ public static String uuid(){ Properties props = new Properties(); //props.setProperty("separator", "/"); IdentifierGenerator gen = new UUIDHexGenerator(); ((Configurable) gen).configure(Hibernate.STRING, props, null); return (String)gen.generate(null, null); } /** * JSON转换 * @return */ public static String toJson(Object bean){ ObjectMapper mapper = new ObjectMapper(); try { mapper.registerModule(new HibernateModule()); return mapper.writeValueAsString(bean); } catch (JsonGenerationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JsonMappingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } /** * * @param args */ public static void main(String[] args){ System.err.println(Bean.get("graphTypeService")); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/reflection/Bean.java
Java
asf20
14,136
/** * Copyright (c) 2005-2010 springside.org.cn * * Licensed under the Apache License, Version 2.0 (the "License"); * * $Id: ReflectionUtils.java 1211 2010-09-10 16:20:45Z calvinxiu $ */ package cn.com.widemex.core.utils.reflection; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.Assert; /** * 反射工具类. * * 提供访问私有变量,获取泛型类型Class, 提取集合中元素的属性, 转换字符串到对象等Util函数. * * @author calvin */ public class ReflectionUtils { private static Logger logger = LoggerFactory.getLogger(ReflectionUtils.class); /** * 调用Getter方法. */ public static Object invokeGetterMethod(Object obj, String propertyName) { String getterMethodName = "get" + StringUtils.capitalize(propertyName); return invokeMethod(obj, getterMethodName, new Class[] {}, new Object[] {}); } /** * 调用Setter方法.使用value的Class来查找Setter方法. */ public static void invokeSetterMethod(Object obj, String propertyName, Object value) { invokeSetterMethod(obj, propertyName, value, null); } /** * 调用Setter方法. * * @param propertyType 用于查找Setter方法,为空时使用value的Class替代. */ public static void invokeSetterMethod(Object obj, String propertyName, Object value, Class<?> propertyType) { Class<?> type = propertyType != null ? propertyType : value.getClass(); String setterMethodName = "set" + StringUtils.capitalize(propertyName); invokeMethod(obj, setterMethodName, new Class[] { type }, new Object[] { value }); } /** * 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数. */ public static Object getFieldValue(final Object obj, final String fieldName) { Field field = getAccessibleField(obj, fieldName); if (field == null) { throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]"); } Object result = null; try { result = field.get(obj); } catch (IllegalAccessException e) { logger.error("不可能抛出的异常{}", e.getMessage()); } return result; } /** * 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数. */ public static void setFieldValue(final Object obj, final String fieldName, final Object value) { Field field = getAccessibleField(obj, fieldName); if (field == null) { throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]"); } try { field.set(obj, value); } catch (IllegalAccessException e) { logger.error("不可能抛出的异常:{}", e.getMessage()); } } /** * 循环向上转型, 获取对象的DeclaredField, 并强制设置为可访问. * * 如向上转型到Object仍无法找到, 返回null. */ public static Field getAccessibleField(final Object obj, final String fieldName) { Assert.notNull(obj, "object不能为空"); Assert.hasText(fieldName, "fieldName"); for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) { try { Field field = superClass.getDeclaredField(fieldName); field.setAccessible(true); return field; } catch (NoSuchFieldException e) {//NOSONAR // Field不在当前类定义,继续向上转型 } } return null; } /** * 直接调用对象方法, 无视private/protected修饰符. * 用于一次性调用的情况. */ public static Object invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes, final Object[] args) { Method method = getAccessibleMethod(obj, methodName, parameterTypes); if (method == null) { throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]"); } try { return method.invoke(obj, args); } catch (Exception e) { throw convertReflectionExceptionToUnchecked(e); } } /** * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问. * 如向上转型到Object仍无法找到, 返回null. * * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) */ public static Method getAccessibleMethod(final Object obj, final String methodName, final Class<?>... parameterTypes) { Assert.notNull(obj, "object不能为空"); for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) { try { Method method = superClass.getDeclaredMethod(methodName, parameterTypes); method.setAccessible(true); return method; } catch (NoSuchMethodException e) {//NOSONAR // Method不在当前类定义,继续向上转型 } } return null; } /** * 通过反射, 获得Class定义中声明的父类的泛型参数的类型. * 如无法找到, 返回Object.class. * eg. * public UserDao extends HibernateDao<User> * * @param clazz The class to introspect * @return the first generic declaration, or Object.class if cannot be determined */ @SuppressWarnings("unchecked") public static <T> Class<T> getSuperClassGenricType(final Class clazz) { return getSuperClassGenricType(clazz, 0); } /** * 通过反射, 获得Class定义中声明的父类的泛型参数的类型. * 如无法找到, 返回Object.class. * * 如public UserDao extends HibernateDao<User,Long> * * @param clazz clazz The class to introspect * @param index the Index of the generic ddeclaration,start from 0. * @return the index generic declaration, or Object.class if cannot be determined */ @SuppressWarnings("unchecked") public static Class getSuperClassGenricType(final Class clazz, final int index) { Type genType = clazz.getGenericSuperclass(); if (!(genType instanceof ParameterizedType)) { logger.warn(clazz.getSimpleName() + "'s superclass not ParameterizedType"); return Object.class; } Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); if (index >= params.length || index < 0) { logger.warn("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " + params.length); return Object.class; } if (!(params[index] instanceof Class)) { logger.warn(clazz.getSimpleName() + " not set the actual class on superclass generic parameter"); return Object.class; } return (Class) params[index]; } /** * 将反射时的checked exception转换为unchecked exception. */ public static RuntimeException convertReflectionExceptionToUnchecked(Exception e) { if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException || e instanceof NoSuchMethodException) { return new IllegalArgumentException("Reflection Exception.", e); } else if (e instanceof InvocationTargetException) { return new RuntimeException("Reflection Exception.", ((InvocationTargetException) e).getTargetException()); } else if (e instanceof RuntimeException) { return (RuntimeException) e; } return new RuntimeException("Unexpected Checked Exception.", e); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/reflection/ReflectionUtils.java
Java
asf20
7,589
/** * Copyright (c) 2005-2010 springside.org.cn * * Licensed under the Apache License, Version 2.0 (the "License"); * * $Id: ServletUtils.java 1211 2010-09-10 16:20:45Z calvinxiu $ */ package cn.com.widemex.core.utils.web; import java.io.UnsupportedEncodingException; import java.util.Enumeration; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeMap; import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.util.Assert; /** * Http与Servlet工具类. * * @author 张中原 */ public class ServletUtils { //-- Content Type 定义 --// public static final String TEXT_TYPE = "text/plain"; public static final String JSON_TYPE = "application/json"; public static final String XML_TYPE = "text/xml"; public static final String HTML_TYPE = "text/html"; public static final String JS_TYPE = "text/javascript"; public static final String EXCEL_TYPE = "application/vnd.ms-excel"; //-- Header 定义 --// public static final String AUTHENTICATION_HEADER = "Authorization"; //-- 常用数值定义 --// public static final long ONE_YEAR_SECONDS = 60 * 60 * 24 * 365; /** * 设置客户端缓存过期时间 的Header. */ public static void setExpiresHeader(HttpServletResponse response, long expiresSeconds) { //Http 1.0 header response.setDateHeader("Expires", System.currentTimeMillis() + expiresSeconds * 1000); //Http 1.1 header response.setHeader("Cache-Control", "private, max-age=" + expiresSeconds); } /** * 设置禁止客户端缓存的Header. */ public static void setDisableCacheHeader(HttpServletResponse response) { //Http 1.0 header response.setDateHeader("Expires", 1L); response.addHeader("Pragma", "no-cache"); //Http 1.1 header response.setHeader("Cache-Control", "no-cache, no-store, max-age=0"); } /** * 设置LastModified Header. */ public static void setLastModifiedHeader(HttpServletResponse response, long lastModifiedDate) { response.setDateHeader("Last-Modified", lastModifiedDate); } /** * 设置Etag Header. */ public static void setEtag(HttpServletResponse response, String etag) { response.setHeader("ETag", etag); } /** * 根据浏览器If-Modified-Since Header, 计算文件是否已被修改. * * 如果无修改, checkIfModify返回false ,设置304 not modify status. * * @param lastModified 内容的最后修改时间. */ public static boolean checkIfModifiedSince(HttpServletRequest request, HttpServletResponse response, long lastModified) { long ifModifiedSince = request.getDateHeader("If-Modified-Since"); if ((ifModifiedSince != -1) && (lastModified < ifModifiedSince + 1000)) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return false; } return true; } /** * 根据浏览器 If-None-Match Header, 计算Etag是否已无效. * * 如果Etag有效, checkIfNoneMatch返回false, 设置304 not modify status. * * @param etag 内容的ETag. */ public static boolean checkIfNoneMatchEtag(HttpServletRequest request, HttpServletResponse response, String etag) { String headerValue = request.getHeader("If-None-Match"); if (headerValue != null) { boolean conditionSatisfied = false; if (!"*".equals(headerValue)) { StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ","); while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { String currentToken = commaTokenizer.nextToken(); if (currentToken.trim().equals(etag)) { conditionSatisfied = true; } } } else { conditionSatisfied = true; } if (conditionSatisfied) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); response.setHeader("ETag", etag); return false; } } return true; } /** * 设置让浏览器弹出下载对话框的Header. * * @param fileName 下载后的文件名. */ public static void setFileDownloadHeader(HttpServletResponse response, String fileName) { try { //中文文件名支持 String encodedfileName = new String(fileName.getBytes(), "ISO8859-1"); response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedfileName + "\""); } catch (UnsupportedEncodingException e) { } } /** * 取得带相同前缀的Request Parameters. * * 返回的结果的Parameter名已去除前缀. */ @SuppressWarnings("unchecked") public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) { Assert.notNull(request, "Request must not be null"); Enumeration paramNames = request.getParameterNames(); Map<String, Object> params = new TreeMap<String, Object>(); if (prefix == null) { prefix = ""; } while (paramNames != null && paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); if ("".equals(prefix) || paramName.startsWith(prefix)) { String unprefixed = paramName.substring(prefix.length()); String[] values = request.getParameterValues(paramName); if (values == null || values.length == 0) { // Do nothing, no values found at all. } else if (values.length > 1) { params.put(unprefixed, values); } else { params.put(unprefixed, values[0]); } } } return params; } /** * 对Http Basic验证的 Header进行编码. */ // public static String encodeHttpBasic(String userName, String password) { // String encode = userName + ":" + password; // return "Basic " + EncodeUtils.base64Encode(encode.getBytes()); // } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/web/ServletUtils.java
Java
asf20
5,761
package cn.com.widemex.core.utils.web; import java.util.Enumeration; import javax.servlet.http.HttpServletRequest; import cn.com.widemex.core.data.MyHashMap; import cn.com.widemex.core.data.MyMap; /** * WEB相关的工具 * (1)、存储session信息 * @author 张中原 * */ public class WebUtils { public final static String OPERATE_TYPE_ADD = "0"; public final static String OPERATE_TYPE_UPDATE = "1"; public final static String OPERATE_TYPE_DELETE = "2"; public final static String RESULT_FAILED = "0"; public final static String RESULT_SUCCESS = "1"; /** * 获取参数map对象 * @param request 请求对象 * @return */ public static MyMap getParamsMap(HttpServletRequest request){ MyMap map = new MyHashMap(); for (Enumeration<String> em = request.getParameterNames(); em.hasMoreElements();) { String key = em.nextElement(); map.put(key, request.getParameter(key)); } return map; } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/utils/web/WebUtils.java
Java
asf20
982
package cn.com.widemex.core.mvcExtends; import java.io.EOFException; import java.io.IOException; import java.nio.charset.Charset; import org.codehaus.jackson.JsonEncoding; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.JsonGenerator; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.Module; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.type.TypeFactory; import org.codehaus.jackson.type.JavaType; import org.joda.time.DateTime; import org.springframework.http.HttpInputMessage; import org.springframework.http.HttpOutputMessage; import org.springframework.http.MediaType; import org.springframework.http.converter.AbstractHttpMessageConverter; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.http.converter.HttpMessageNotWritableException; import org.springframework.util.Assert; import cn.com.widemex.core.json.hibernate.HibernateModule; import cn.com.widemex.core.utils.data.DateHelper; /** * 自定义json格式的http消息转换 * @author 张中原 * */ @SuppressWarnings("deprecation") public class MyMappingJacksonHttpMessageConverter extends AbstractHttpMessageConverter<Object> { public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); private ObjectMapper objectMapper = new ObjectMapper(); private Module module = new HibernateModule(); // 代码块:解决Hibernate延时加载、日期格式转换,JSON转换的问题 { objectMapper.registerModule(module); objectMapper.getSerializationConfig().setDateFormat(DateHelper.TIMESTAMP_FORMAT); objectMapper.getDeserializationConfig().setDateFormat(DateHelper.TIMESTAMP_FORMAT); } private boolean prefixJson = false; /** * Construct a new {@code BindingJacksonHttpMessageConverter}. */ public MyMappingJacksonHttpMessageConverter() { super(new MediaType("application", "json", DEFAULT_CHARSET)); } /** * Sets the {@code ObjectMapper} for this view. If not set, a default * {@link ObjectMapper#ObjectMapper() ObjectMapper} is used. * <p>Setting a custom-configured {@code ObjectMapper} is one way to take further control of the JSON serialization * process. For example, an extended {@link org.codehaus.jackson.map.SerializerFactory} can be configured that provides * custom serializers for specific types. The other option for refining the serialization process is to use Jackson's * provided annotations on the types to be serialized, in which case a custom-configured ObjectMapper is unnecessary. */ public void setObjectMapper(ObjectMapper objectMapper) { Assert.notNull(objectMapper, "'objectMapper' must not be null----objectMapper对象不能为空"); this.objectMapper = objectMapper; } /** * Indicates whether the JSON output by this view should be prefixed with "{} &&". Default is false. * <p> Prefixing the JSON string in this manner is used to help prevent JSON Hijacking. The prefix renders the string * syntactically invalid as a script so that it cannot be hijacked. This prefix does not affect the evaluation of JSON, * but if JSON validation is performed on the string, the prefix would need to be ignored. */ public void setPrefixJson(boolean prefixJson) { this.prefixJson = prefixJson; } @Override public boolean canRead(Class<?> clazz, MediaType mediaType) { JavaType javaType = getJavaType(clazz); return this.objectMapper.canDeserialize(javaType) && canRead(mediaType); } /** * Returns the Jackson {@link JavaType} for the specific class. * * <p>Default implementation returns {@link TypeFactory#type(java.lang.reflect.Type)}, but this can be overridden * in subclasses, to allow for custom generic collection handling. For instance: * <pre class="code"> * protected JavaType getJavaType(Class&lt;?&gt; clazz) { * if (List.class.isAssignableFrom(clazz)) { * return TypeFactory.collectionType(ArrayList.class, MyBean.class); * } else { * return super.getJavaType(clazz); * } * } * </pre> * * @param clazz the class to return the java type for * @return the java type */ protected JavaType getJavaType(Class<?> clazz) { return TypeFactory.type(clazz); } @Override public boolean canWrite(Class<?> clazz, MediaType mediaType) { return this.objectMapper.canSerialize(clazz) && canWrite(mediaType); } @Override protected boolean supports(Class<?> clazz) { // should not be called, since we override canRead/Write instead throw new UnsupportedOperationException(); } @Override protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { JavaType javaType = getJavaType(clazz); try { return this.objectMapper.readValue(inputMessage.getBody(), javaType); } catch (JsonParseException ex) { throw new HttpMessageNotReadableException("不能读JSON:Could not read JSON: " + ex.getMessage(), ex); } catch (EOFException ex) { throw new HttpMessageNotReadableException("不能读JSON:Could not read JSON: " + ex.getMessage(), ex); } } @Override protected void writeInternal(Object o, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { JsonEncoding encoding = getEncoding(outputMessage.getHeaders().getContentType()); JsonGenerator jsonGenerator = this.objectMapper.getJsonFactory().createJsonGenerator(outputMessage.getBody(), encoding); try { if (this.prefixJson) { jsonGenerator.writeRaw("{} && "); } this.objectMapper.writeValue(jsonGenerator, o); } catch (JsonGenerationException ex) { throw new HttpMessageNotWritableException("不能写JSON: Could not write JSON: " + ex.getMessage(), ex); } } private JsonEncoding getEncoding(MediaType contentType) { if (contentType != null && contentType.getCharSet() != null) { Charset charset = contentType.getCharSet(); for (JsonEncoding encoding : JsonEncoding.values()) { if (charset.name().equals(encoding.getJavaName())) { return encoding; } } } return JsonEncoding.UTF8; } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/mvcExtends/MyMappingJacksonHttpMessageConverter.java
Java
asf20
6,297
package cn.com.widemex.core.mvcExtends.editor; import java.beans.PropertyEditorSupport; import java.text.ParseException; import java.text.SimpleDateFormat; import org.apache.log4j.Logger; import org.springframework.util.StringUtils; import cn.com.widemex.core.utils.data.DateHelper; /** * 日期编辑器 * @author 张中原 * */ public class DateConvertEditor extends PropertyEditorSupport { /**日志实例化*/ private static Logger logger = Logger.getLogger(DateConvertEditor.class); // private static SimpleDateFormat datetimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); public void setAsText(String text) throws IllegalArgumentException { logger.info("DateConvertEditor被调用...."); if (StringUtils.hasText(text)) { try { if (text.indexOf(":") == -1 && text.length() == 10) { setValue(DateHelper.DATE_FORMAT.parse(text)); } else if (text.indexOf(":") > 0 && text.length() == 19) { setValue(DateHelper.TIMESTAMP_FORMAT.parse(text)); }else{ throw new IllegalArgumentException("Could not parse date, date format is error "); } } catch (ParseException ex) { IllegalArgumentException iae = new IllegalArgumentException("Could not parse date: " + ex.getMessage()); iae.initCause(ex); throw iae; } } else { setValue(null); } } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/mvcExtends/editor/DateConvertEditor.java
Java
asf20
1,452
package cn.com.widemex.core.mvcExtends.editor; import java.beans.PropertyEditorSupport; import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import org.apache.log4j.Logger; import org.springframework.util.StringUtils; /** * 日期编辑器 * @author 张中原 * */ public class TimestampConvertEditor extends PropertyEditorSupport { /**日志实例化*/ private static Logger logger = Logger.getLogger(TimestampConvertEditor.class); private static SimpleDateFormat datetimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); public void setAsText(String text) throws IllegalArgumentException { logger.info("TimestampConvertEditor被调用...."); if (StringUtils.hasText(text)) { try { if (text.indexOf(":") == -1 && text.length() == 10) { setValue(new Timestamp(this.dateFormat.parse(text).getTime())); } else if (text.indexOf(":") > 0 && text.length() == 19) { setValue(new Timestamp(this.datetimeFormat.parse(text).getTime())); }else{ throw new IllegalArgumentException("不能转换为Timestamp格式,当前字符串格式不准确。value::" + text); } } catch (ParseException ex) { IllegalArgumentException iae = new IllegalArgumentException("不能正常转换TimeStamp: " + ex.getMessage()); iae.initCause(ex); throw iae; } } else { setValue(null); } } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/mvcExtends/editor/TimestampConvertEditor.java
Java
asf20
1,521
package cn.com.widemex.core.mvcExtends; public class DataGridModel implements java.io.Serializable { private static final long serialVersionUID = 7232798260610351343L; private int page; //当前页,名字必须为page private int rows ; //每页大小,名字必须为rows private String sort; //排序字段 private String order; //排序规则 public int getPage() { return page; } public void setPage(int page) { this.page = page; } public int getRows() { return rows; } public void setRows(int rows) { this.rows = rows; } public String getSort() { return sort; } public void setSort(String sort) { this.sort = sort; } public String getOrder() { return order; } public void setOrder(String order) { this.order = order; } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/mvcExtends/DataGridModel.java
Java
asf20
807
package cn.com.widemex.core.mvcExtends; import java.sql.Timestamp; import java.util.Date; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.support.WebBindingInitializer; import org.springframework.web.context.request.WebRequest; import cn.com.widemex.core.mvcExtends.editor.DateConvertEditor; /** * 定制WEB绑定 * @author 张中原 * */ public class MyWebBinding implements WebBindingInitializer { public void initBinder(WebDataBinder binder, WebRequest request) { //1. 使用spring自带的CustomDateEditor //SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); //binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); // 注册Date编辑器 binder.registerCustomEditor(Date.class, new DateConvertEditor()); // 注册Timestamp编辑器 binder.registerCustomEditor(Timestamp.class, new DateConvertEditor()); } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/mvcExtends/MyWebBinding.java
Java
asf20
955
package cn.com.widemex.core.mvcExtends; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import cn.com.widemex.core.utils.reflection.Bean; /** * 定制拦截器,主要是权限管理及登录校验 * @author 张中原 * */ public class MyHandlerInterceptor extends HandlerInterceptorAdapter { /** * easyui标签的相关字符串 */ private static String jqFW = null; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { Bean.printReq(request); if(jqFW == null){ ServletContext sc = request.getServletContext(); String isDebug = sc.getInitParameter("isDebug"); String rootPath = sc.getContextPath(); String str = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + rootPath + "/resource/themes/default/easyui.css\" rel=\"stylesheet\" title='skinStyle'> </link>\n";//+ // "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + rootPath + "/resource/themes/gray/easyui.css\" rel=\"stylesheet\" title=\"gray\"> \n" + // "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + rootPath + "/resource/themes/green/easyui.css\" rel=\"stylesheet\" title=\"green\"> \n"+ // "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + rootPath + "/resource/themes/orange/easyui.css\" rel=\"stylesheet\" title=\"orange\"> \n"+ // "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + rootPath + "/resource/themes/pink/easyui.css\" rel=\"stylesheet\" title=\"pink\"> \n"; if("true".equals(isDebug)){ str += //" <link rel=\"stylesheet\" type=\"text/css\" href=\"" + rootPath + "/resource/themes/default/easyui.css" + "\" /> \n" + " <script type=\"text/javascript\" src=\"" + rootPath + "/resource/easyui/jquery-1.6.min.js" + "\"></script> \n" + " <script type=\"text/javascript\" src=\"" + rootPath + "/resource/easyui/easyloader.js" + "\"></script> \n" + " <link rel=\"stylesheet\" type=\"text/css\" href=\"" + rootPath + "/resource/themes/icon.css" + "\" /> \n"; }else{ str = //" <link rel=\"stylesheet\" type=\"text/css\" href=\"" + rootPath + "/resource/themes/default/easyui.css" + "\" /> \n" + " <link rel=\"stylesheet\" type=\"text/css\" href=\"" + rootPath + "/resource/themes/icon.css" + "\" /> \n" + " <script type=\"text/javascript\" src=\"" + rootPath + "/resource/easyui/jquery-1.6.min.js" + "\"></script> \n" + " <script type=\"text/javascript\" src=\"" + rootPath + "/resource/easyui/jquery.easyui.min.js" + "\"></script> \n" + " <script type=\"text/javascript\" src=\"" + rootPath + "/resource/easyui/locale/easyui-lang-zh_CN.js" + "\" />\"></script>\n"; } str += " <script type=\"text/javascript\" src=\"" + rootPath + "/resource/wide/Wide.js" + "\"></script>\n"; System.out.println("jqFW::::" + str); jqFW = str; // 设置application中 sc.setAttribute("jqFW", jqFW); sc.setAttribute("path", request.getContextPath()); } String url = request.getRequestURI(); System.out.println("url::::" + url); if(url.indexOf("/sys/checkLogin") != -1){ return true; }else if(request.getSession() != null && request.getSession().getAttribute("USER_INFO")==null){ response.sendRedirect(request.getContextPath()); return false; } return true; } }
zzyapps
trunk/JqFw/core/cn/com/widemex/core/mvcExtends/MyHandlerInterceptor.java
Java
asf20
3,576
package cn.com.widemex.service.demo; import org.springframework.stereotype.Service; import cn.com.widemex.core.vo.PageVO; import cn.com.widemex.dao.demo.DemoUserDao; import cn.com.widemex.domain.demo.DemoUser; /** * 用户维护 service * * @author 张中原 * */ @Service("demoUserService") public class DemoUserService { private DemoUserDao demoUserDao; /** * 查询 * @param page * @return */ public PageVO list(PageVO page){ return this.demoUserDao.findPage(page); } /** * 保存 * @param user * @return */ public DemoUser save(DemoUser user){ this.demoUserDao.save(user); return user; } /** * 删除 * @param user * @return */ public DemoUser remove(DemoUser user){ this.demoUserDao.remove(user); return user; } public DemoUserDao getDemoUserDao() { return demoUserDao; } public void setDemoUserDao(DemoUserDao demoUserDao) { this.demoUserDao = demoUserDao; } }
zzyapps
trunk/JqFw/demo/cn/com/widemex/service/demo/DemoUserService.java
Java
asf20
997
package cn.com.widemex.service.demo; import org.springframework.stereotype.Service; import cn.com.widemex.core.vo.PageVO; import cn.com.widemex.dao.demo.DemoTypeDao; /** * 类型维护 service * * @author 张中原 * */ @Service("demoTypeService") public class DemoTypeService { private DemoTypeDao demoTypeDao; /** * 查询 * @param page * @return */ public PageVO list(PageVO page){ return this.demoTypeDao.findPage(page); } public DemoTypeDao getDemoTypeDao() { return demoTypeDao; } public void setDemoTypeDao(DemoTypeDao demoTypeDao) { this.demoTypeDao = demoTypeDao; } }
zzyapps
trunk/JqFw/demo/cn/com/widemex/service/demo/DemoTypeService.java
Java
asf20
654
package cn.com.widemex.service.demo; import org.springframework.stereotype.Service; import cn.com.widemex.core.vo.PageVO; import cn.com.widemex.dao.demo.DemoDeptDao; import cn.com.widemex.domain.demo.DemoDept; /** * 部门维护 service * * @author 张中原 * */ @Service("demoDeptService") public class DemoDeptService { private DemoDeptDao demoDeptDao; /** * 查询结果 * @param page 页面信息 * @return */ public PageVO list(PageVO page){ String id = page.getParams()==null ? null : page.getParams().getString("id", null); // 如果为空,则是加载根节点 if(id == null){ return this.demoDeptDao.findPage(" where pDept.id is null"); }else{ return this.demoDeptDao.findPage(" where pDept.id='" + id + "'"); } } /** * 保存部门信息 * @param dept 部门信息 * @return */ public DemoDept save(DemoDept dept){ dept.setpDept(this.demoDeptDao.get(dept.getParentId())); this.demoDeptDao.saveOrUpdate(dept); return dept; } /** * 删除部门信息 * @param dept 部门信息 * @return */ public DemoDept delete(DemoDept dept){ this.demoDeptDao.remove(this.demoDeptDao.get(dept.getId())); return dept; } public DemoDeptDao getDemoDeptDao() { return demoDeptDao; } public void setDemoDeptDao(DemoDeptDao demoDeptDao) { this.demoDeptDao = demoDeptDao; } }
zzyapps
trunk/JqFw/demo/cn/com/widemex/service/demo/DemoDeptService.java
Java
asf20
1,444
package cn.com.widemex.dao.demo; import org.springframework.stereotype.Repository; import cn.com.widemex.core.db.HibernateDao; import cn.com.widemex.domain.demo.DemoUser; /** * 用户dao * @author 张中原 * */ @Repository("demoUserDao") public class DemoUserDao extends HibernateDao<DemoUser> { }
zzyapps
trunk/JqFw/demo/cn/com/widemex/dao/demo/DemoUserDao.java
Java
asf20
322
package cn.com.widemex.dao.demo; import org.springframework.stereotype.Repository; import cn.com.widemex.core.db.HibernateDao; import cn.com.widemex.domain.demo.DemoDept; /** * 部门DAO * @author 张中原 * */ @Repository("demoDeptDao") public class DemoDeptDao extends HibernateDao<DemoDept>{ }
zzyapps
trunk/JqFw/demo/cn/com/widemex/dao/demo/DemoDeptDao.java
Java
asf20
323
package cn.com.widemex.dao.demo; import org.springframework.stereotype.Repository; import cn.com.widemex.core.db.HibernateDao; import cn.com.widemex.domain.demo.DemoType; /** * 类型dao * @author 张中原 * */ @Repository("demoTypeDao") public class DemoTypeDao extends HibernateDao<DemoType> { }
zzyapps
trunk/JqFw/demo/cn/com/widemex/dao/demo/DemoTypeDao.java
Java
asf20
321
package cn.com.widemex.action.demo; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; /** * 范例 * @author 张中原 * */ @Controller @RequestMapping("demo") public class DemoController { /** * 初始化demo列表界面 * @return */ @RequestMapping public String initDemo(){ return "demo/demo"; } /** * 初始化treegrid * @return */ @RequestMapping("initTreeGrid") public String initTreeGrid(){ return "demo/treegrid/treegrid"; } /** * TreeGrid查询 * @param id key * @return */ @RequestMapping("listTreeGrid") public @ResponseBody Object listTreeGrid(){//@RequestParam String id String json = "{'total':7,'rows':[ "+ " {'id':1,'name':'All Tasks','begin':'3/4/2010','end':'3/20/2010','progress':60,'iconCls':'icon-ok'},"+ " {'id':2,'name':'Designing','begin':'3/4/2010','end':'3/10/2010','progress':100,'_parentId':1,'state':'closed'},"+ " {'id':21,'name':'Database','persons':2,'begin':'3/4/2010','end':'3/6/2010','progress':100,'_parentId':2},"+ " {'id':22,'name':'UML','persons':1,'begin':'3/7/2010','end':'3/8/2010','progress':100,'_parentId':2},"+ " {'id':23,'name':'Export Document','persons':1,'begin':'3/9/2010','end':'3/10/2010','progress':100,'_parentId':2},"+ " {'id':3,'name':'Coding','persons':2,'begin':'3/11/2010','end':'3/18/2010','progress':80},"+ " {'id':4,'name':'Testing','persons':1,'begin':'3/19/2010','end':'3/20/2010','progress':20}"+ " ],'footer':["+ " {'name':'Total Persons:','persons':7,'iconCls':'icon-sum'}"+ " ]} "; return json; } @RequestMapping("listTreeGrid2") public @ResponseBody Object listTreeGrid2(@RequestParam String id){ System.out.println("主键::" + id); String json = "{'total':7,'rows':[ "+ " {'id':1,'name':'All Tasks','begin':'3/4/2010','end':'3/20/2010','progress':60,'iconCls':'icon-ok' ,'state':'closed'},"+ " {'id':2,'name':'Designing','begin':'3/4/2010','end':'3/10/2010','progress':100,'state':'closed'}"+ " ]} "; // if("1".equals(id)) return json; } }
zzyapps
trunk/JqFw/demo/cn/com/widemex/action/demo/DemoController.java
Java
asf20
2,362
package cn.com.widemex.action.demo.jdbcCRUD; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; /** * DEMO:datagrid 通过JDBC方式对表格进行CRUD * @author 张中原 * */ @Controller @RequestMapping("demo/datagrid/jdbc") public class DemoJdbcDataGridController { /** * 初始化界面 */ public String init(){ return "demo/datagrid/datagrid"; } /** * 查询 * @return */ @RequestMapping("list") public @ResponseBody Object list(){ return null; } /** * 更新、保存 * @return */ @RequestMapping("save") public @ResponseBody Object save(){ return null; } /** * 删除 * @return */ @RequestMapping("delete") public @ResponseBody Object delete(){ return null; } }
zzyapps
trunk/JqFw/demo/cn/com/widemex/action/demo/jdbcCRUD/DemoJdbcDataGridController.java
Java
asf20
905
package cn.com.widemex.action.demo.pojoCRUD; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import cn.com.widemex.core.utils.reflection.Bean; import cn.com.widemex.core.vo.PageVO; import cn.com.widemex.domain.demo.DemoDept; import cn.com.widemex.service.demo.DemoDeptService; /** * DEMO:树表格 * @author 张中原 */ @Controller @RequestMapping("demo/pojo/treegrid/") public class DemoTreeGridController { /**部门维护serivce类*/ private DemoDeptService demoDeptService; /** * 初始化界面 */ @RequestMapping("init") public String initPojoTreeGrid(){ return "demo/treegrid/pojoCRUD/crud"; } /** * 初始化界面 */ @RequestMapping("initTree") public String initPojoTree(Model model){ // 初始化jsp界面 PageVO page = this.demoDeptService.list(new PageVO()); model.addAttribute("deptList", page.getRows()); return "demo/tree/tree"; } /** * 查询 * @return */ @RequestMapping("list") public @ResponseBody Object list(HttpServletRequest request){ PageVO page = PageVO.valueOf(request); return this.demoDeptService.list(page); // return "{total:2, rows:[{id:111, name:'22222222222', code:333333, status:1, createTime:'2011-11-14 23:24:25'}]}"; } /** * 更新、保存 * @return */ @RequestMapping("save") public @ResponseBody Object save( @RequestBody DemoDept dept){ // Bean.printValues(dept); // System.out.println("xxxxxxxxxxxxxxxxxxxxxxx"); this.demoDeptService.save(dept); return dept; } /** * 删除 * @return */ @RequestMapping("remove") public @ResponseBody Object delete( @RequestBody DemoDept dept){ return this.demoDeptService.delete(dept); } public DemoDeptService getDemoDeptService() { return demoDeptService; } public void setDemoDeptService(DemoDeptService demoDeptService) { this.demoDeptService = demoDeptService; } }
zzyapps
trunk/JqFw/demo/cn/com/widemex/action/demo/pojoCRUD/DemoTreeGridController.java
Java
asf20
2,257
package cn.com.widemex.action.demo.pojoCRUD; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import cn.com.widemex.core.vo.PageVO; import cn.com.widemex.service.demo.DemoTypeService; /** * 下拉框 * @author 张中原 * */ @Controller @RequestMapping("demo/combo/") public class DemoComboController { private DemoTypeService demoTypeService; /** * 初始化界面 * @return */ @RequestMapping("init") public String init(){ return "demo/form/combo"; } /** * 查询 * @param request * @return */ @RequestMapping("list") public @ResponseBody Object list(HttpServletRequest request){ return this.demoTypeService.list(PageVO.valueOf(request)); } public DemoTypeService getDemoTypeService() { return demoTypeService; } public void setDemoTypeService(DemoTypeService demoTypeService) { this.demoTypeService = demoTypeService; } }
zzyapps
trunk/JqFw/demo/cn/com/widemex/action/demo/pojoCRUD/DemoComboController.java
Java
asf20
1,102
package cn.com.widemex.action.demo.pojoCRUD; import java.util.Collection; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import cn.com.widemex.core.vo.PageVO; import cn.com.widemex.domain.demo.DemoDept; import cn.com.widemex.domain.demo.DemoUser; import cn.com.widemex.service.demo.DemoUserService; /** * DEMO:通过hibernate对datagrid进行CRUD * @author 张中原 * */ @Controller @RequestMapping("demo/pojo/datagrid") public class DemoDataGridController { private DemoUserService demoUserService; /** * 初始化界面 */ @RequestMapping("init") public String init(){ return "demo/datagrid/pojoCRUD/datagrid"; } /** * 查询 * @return */ @RequestMapping("list") public @ResponseBody Object list(HttpServletRequest request){ PageVO page = PageVO.valueOf(request); return this.demoUserService.list(page); } // public String toTree(Collection<DemoDept> deptList){ // for(DemoDept dept : deptList){ //// out.println("<li>"); //// out.println(" <span>" + dept.getName() + "</span>"); //// //// if(dept.getDemoDepts()!=null){ //// out.println(" <lu>"); //// toTree(dept.getDemoDepts()); //// out.println(" </lu>"); //// } //// //// out.println("</li>"); // // // // } // return null; // } /** * 更新、保存 * @return */ @RequestMapping("save") public @ResponseBody Object save(@RequestBody DemoUser user){ return this.demoUserService.save(user); } /** * 删除 * @return */ @RequestMapping("remove") public @ResponseBody Object remove(@RequestBody DemoUser user){ return this.demoUserService.remove(user); } public DemoUserService getDemoUserService() { return demoUserService; } public void setDemoUserService(DemoUserService demoUserService) { this.demoUserService = demoUserService; } }
zzyapps
trunk/JqFw/demo/cn/com/widemex/action/demo/pojoCRUD/DemoDataGridController.java
Java
asf20
2,141
/** * 辅助工具 */ Wide = function(){ return{ /** * 项目路径 **/ path: "/JqFw/",//easyloader.base.replace("resource/easyui/", "") /** * 父窗体 */ parentWindow: (window.parent && window.parent.$) ? window.parent : null, /** * 创建iframe */ iframe: function(url){ return '<iframe src="'+Wide.path + url +'" style="width:100%;height:100%;" frameborder="no" scrolling="auto"></iframe>'; }, /** * 当按下回车键的处理事件 */ onEnterKeyEvent: function(){}, /** * 切换皮肤 * @param skinName 皮肤名称 */ changeSkin: function(skinName) { skinName = skinName=='blue'?'default':skinName; var skinPath; $('link[rel=stylesheet][href*=/easyui.css][title]').each(function(i) { var arr = $(this).attr('href').split('themes/'); arr[1] = skinName +'/easyui.css'; skinPath = arr.join('themes/'); $(this).attr('href', skinPath); // if (this.getAttribute('title') == skinName){ // this.disabled = false; // }else{ // this.disabled = true; // } }); $("iframe").contents().find('link[rel=stylesheet][href*="/easyui.css"][title]').each(function(i) { $(this).attr('href', skinPath); }); $.cookie('skin', skinName, 365); }, /** * 主界面是否正在加载 */ mainPageIsLoading: false }; }(); /** * 列格式化 * @type */ Formatter={ /** * 状态 */ status: function(val){ if($.isEmpty(val))return''; return val==1 ? '<span class="blue">有效</span>' : '<span class="red">无效</span>'; }, /** * 显示函数 * @param {} prop * @return {} */ showFun: function(prop){ return function(v){ if(!v || $.isString(v))return v; return v[prop]; } }, /** * 角色类型 */ roleType: function(v){ if($.isEmpty(v))return ''; if(v == 'GR'){ return '<span class="blue">正常角色</span>' }else{ return '<span class="red">公共角色</span>' } } } Fmt = Formatter; /**扩展基础类**/ /** * @class Array */ $.extend(Array.prototype, { /** * Checks whether or not the specified object exists in the array. * @param {Object} o The object to check for * @param {Number} from (Optional) The index at which to begin the search * @return {Number} The index of o in the array (or -1 if it is not found) */ indexOf : function(o, from){ var len = this.length; from = from || 0; from += (from < 0) ? len : 0; for (; from < len; ++from){ if(this[from] === o){ return from; } } return -1; }, /** * 根据属性-值,获取索引 * @param {} o * @param {} from * @return {} */ indexOfByProp : function(prop, val){ var len = this.length; var index = -1; $.each(this, function(idx, bean){ if(bean[prop] == val){ index = idx; return false; } }); return index; }, /** * Removes the specified object from the array. If the object is not found nothing happens. * @param {Object} o The object to remove * @return {Array} this array */ remove : function(o){ var index = this.indexOf(o); if(index != -1){ this.splice(index, 1); } return this; }, /** * 根据属性-值,删除相关记录 * @param {} prop * @param {} val * @return {} */ removeByProp: function(prop, val){ var index = this.indexOfByProp(prop, val); if(index != -1){ this.splice(index, 1); } return this; } }); // 公共预处理 $(function(){ /** * 监听公共事件 */ $(document).keydown(function(event){ var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; if (keyCode == 13) { // 回车键 if(event.target.nodeName != 'TEXTAREA'){ Wide.onEnterKeyEvent(event); } } }); $('a[form*=]').each(function(){ var _this = this; var formId = $(_this).attr('form'); $('#' + formId).focus(function(){ Wide.onEnterKeyEvent = function(event){ $(_this).click(); } }); $(formId).blur(function(){ Wide.onEnterKeyEvent = function(event){} }); }); // 换肤 var skinName = null; if(Wide.parentWindow != null){ skinName = Wide.parentWindow.$.cookie('skin'); }else{ skinName = $.cookie('skin'); } Wide.changeSkin( skinName || 'blue'); // 监听主界面的iframe的渲染情况 if(Wide.parentWindow && Wide.parentWindow.Wide){ $.defer(function(){ Wide.parentWindow.Wide.mainPageIsLoading = false; }, 1000); } }); // //var s = { // winId: '', // 基本配置项--》弹出框 // formId: '', // 基本配置项--》表格 // id:'', // 基本配置项-树表格 // // winEl: '', // 生成属性项--》弹出框 // formEl: '', // 生成属性项--》表格 // el:'', // 生成属性项--》树表格 // // onBeforeAdd: function(){}, // onBeforeUpdate: function(){}, // onBeforeSave: function(){}, // onBeforeRemove: function(){}, // // onAdd: function(){}, // onUpdate: function(){}, // onSave: function(){}, // onRemove: function(){}, // // addAction: function(){}, // updateAction: function(){}, // removeAction: function(){}, // // add: function(){}, // update: function(){}, // remove: function(){} // //}; // // //Wide['TreeGrid'] = function(cfg){ // // 赋值配置项给当前对象 // $.extend(this, cfg); // // if(cfg){ // this.formEl =null; // } // //}; ////////////////////////////测试///////////////////////////////////// //var _arr = [0, 1, 2, 3,4]; //alert(_arr.slice(1,5)); //var _bean = {id:111, dept:{id:'sdf', name:'nnnnnn'}, name:'bbbbbbbb'}; //alert($.beanVal(_bean, "dept.id"));
zzyapps
trunk/JqFw/WebRoot/resource/wide/Wide.js
JavaScript
asf20
6,147
/** * easyloader - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * */ (function(){ var modules = { draggable:{ js:'jquery.draggable.js' }, droppable:{ js:'jquery.droppable.js' }, resizable:{ js:'jquery.resizable.js' }, linkbutton:{ js:'jquery.linkbutton.js'/*, css:'linkbutton.css'*/ }, pagination:{ js:'jquery.pagination.js', // css:'pagination.css', dependencies:['linkbutton'] }, datagrid:{ js:'jquery.datagrid.js', // css:'datagrid.css', dependencies:['panel','resizable','linkbutton','pagination'] }, treegrid:{ js:'jquery.treegrid.js', // css:'tree.css', dependencies:['datagrid', 'draggable','droppable'] }, panel: { js:'jquery.panel.js'/*, css:'panel.css'*/ }, window:{ js:'jquery.window.js', // css:'window.css', dependencies:['resizable','draggable','panel'] }, dialog:{ js:'jquery.dialog.js', // css:'dialog.css', dependencies:['linkbutton','window'] }, messager:{ js:'jquery.messager.js', // css:'messager.css', dependencies:['linkbutton','window'] }, layout:{ js:'jquery.layout.js', // css:'layout.css', dependencies:['resizable','panel'] }, form:{ js:'jquery.form.js' }, menu:{ js:'jquery.menu.js'//, // css:'menu.css' }, tabs:{ js:'jquery.tabs.js', // css:'tabs.css', dependencies:['panel','linkbutton'] }, splitbutton:{ js:'jquery.splitbutton.js', // css:'splitbutton.css', dependencies:['linkbutton','menu'] }, menubutton:{ js:'jquery.menubutton.js', // css:'menubutton.css', dependencies:['linkbutton','menu'] }, accordion:{ js:'jquery.accordion.js', // css:'accordion.css', dependencies:['panel'] }, calendar:{ js:'jquery.calendar.js', css:'calendar.css' }, combo:{ js:'jquery.combo.js', // css:'combo.css', dependencies:['panel','validatebox'] }, combobox:{ js:'jquery.combobox.js', // css:'combobox.css', dependencies:['combo'] }, combotree:{ js:'jquery.combotree.js', dependencies:['combo','tree'] }, combogrid:{ js:'jquery.combogrid.js', dependencies:['combo','datagrid'] }, validatebox:{ js:'jquery.validatebox.js'//, // css:'validatebox.css' }, numberbox:{ js:'jquery.numberbox.js', dependencies:['validatebox'] }, spinner:{ js:'jquery.spinner.js', // css:'spinner.css', dependencies:['validatebox'] }, numberspinner:{ js:'jquery.numberspinner.js', dependencies:['spinner','numberbox'] }, timespinner:{ js:'jquery.timespinner.js', dependencies:['spinner'] }, tree:{ js:'jquery.tree.js', // css:'tree.css', dependencies:['draggable','droppable'] }, datebox:{ js:'jquery.datebox.js', css:'datebox.css', dependencies:['combo', 'calendar','validatebox'] }, //zzy+ datetimebox:{ js:'jquery.datetimebox.js', // css:'datebox.css', dependencies:['datebox', 'timespinner', 'validatebox'] }, parser:{ js:'jquery.parser.js' } }; // zzy+ modules['msg'] = modules['messager']; modules['grid'] = modules['datagrid']; var locales = { 'zh_CN':'easyui-lang-zh_CN.js' }; var queues = {}; function loadJs(url, callback){ var done = false; var script = document.createElement('script'); script.type = 'text/javascript'; script.language = 'javascript'; script.src = url; script.onload = script.onreadystatechange = function(){ if (!done && (!script.readyState || script.readyState == 'loaded' || script.readyState == 'complete')){ done = true; script.onload = script.onreadystatechange = null; if (callback){ callback.call(script); } } } document.getElementsByTagName("head")[0].appendChild(script); } function runJs(url, callback){ loadJs(url, function(){ document.getElementsByTagName("head")[0].removeChild(this); if (callback){ callback(); } }); } function loadCss(url, callback){ var link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; link.media = 'screen'; link.href = url; document.getElementsByTagName('head')[0].appendChild(link); if (callback){ callback.call(link); } } function loadSingle(name, callback){ queues[name] = 'loading'; var module = modules[name]; var jsStatus = 'loading'; var cssStatus = (easyloader.css && module['css']) ? 'loading' : 'loaded'; if (easyloader.css && module['css']){ if (/^http/i.test(module['css'])){ var url = module['css']; } else { // zzy+ var url = easyloader.base.replace("easyui/", '') + 'themes/' + easyloader.theme + '/' + module['css']; } loadCss(url, function(){ cssStatus = 'loaded'; if (jsStatus == 'loaded' && cssStatus == 'loaded'){ finish(); } }); } if (/^http/i.test(module['js'])){ var url = module['js']; } else {// zzy+ 直接加载源码 var url = easyloader.base + (easyloader.isDebug?'src/':'plugins/') + module['js']; } loadJs(url, function(){ jsStatus = 'loaded'; if (jsStatus == 'loaded' && cssStatus == 'loaded'){ finish(); } }); function finish(){ queues[name] = 'loaded'; easyloader.onProgress(name); if (callback){ callback(); } } } function loadModule(name, callback){ var mm = []; var doLoad = false; if (typeof name == 'string'){ add(name); } else { for(var i=0; i<name.length; i++){ add(name[i]); } } function add(name){ if (!modules[name]) return; var d = modules[name]['dependencies']; if (d){ for(var i=0; i<d.length; i++){ add(d[i]); } } mm.push(name); } function finish(){ if (callback){ callback(); } easyloader.onLoad(name); } var time = 0; function loadMm(){ if (mm.length){ var m = mm[0]; // the first module if (!queues[m]){ doLoad = true; loadSingle(m, function(){ mm.shift(); loadMm(); }); } else if (queues[m] == 'loaded'){ mm.shift(); loadMm(); } else { if (time < easyloader.timeout){ time += 10; setTimeout(arguments.callee, 10); } } } else { if (easyloader.locale && doLoad == true && locales[easyloader.locale]){ var url = easyloader.base + 'locale/' + locales[easyloader.locale]; runJs(url, function(){ finish(); }); } else { finish(); } } } loadMm(); } easyloader = { modules:modules, locales:locales, base:'.', theme:'default', css:true, locale:"zh_CN", timeout:2000, isDebug: false, // 是否是debug load: function(name, callback){ if (/\.css$/i.test(name)){ if (/^http/i.test(name)){ loadCss(name, callback); } else { loadCss(easyloader.base + name, callback); } } else if (/\.js$/i.test(name)){ if (/^http/i.test(name)){ loadJs(name, callback); } else { loadJs(easyloader.base + name, callback); } } else { loadModule(name, callback); } }, onProgress: function(name){}, onLoad: function(name){} }; var scripts = document.getElementsByTagName('script'); for(var i=0; i<scripts.length; i++){ var src = scripts[i].src; if (!src) continue; var m = src.match(/easyloader\.js(\W|$)/i); if (m){ easyloader.base = src.substring(0, m.index); } } window.using = easyloader.load; if (window.jQuery){ jQuery(function(){ easyloader.load('parser', function(){ jQuery.parser.parse(); }); }); } })();
zzyapps
trunk/JqFw/WebRoot/resource/easyui/easyloader.js
JavaScript
asf20
7,917
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ $(_2).addClass("droppable"); $(_2).bind("_dragenter",function(e,_3){ $.data(_2,"droppable").options.onDragEnter.apply(_2,[e,_3]); }); $(_2).bind("_dragleave",function(e,_4){ $.data(_2,"droppable").options.onDragLeave.apply(_2,[e,_4]); }); $(_2).bind("_dragover",function(e,_5){ $.data(_2,"droppable").options.onDragOver.apply(_2,[e,_5]); }); $(_2).bind("_drop",function(e,_6){ $.data(_2,"droppable").options.onDrop.apply(_2,[e,_6]); }); }; $.fn.droppable=function(_7,_8){ if(typeof _7=="string"){ return $.fn.droppable.methods[_7](this,_8); } _7=_7||{}; return this.each(function(){ var _9=$.data(this,"droppable"); if(_9){ $.extend(_9.options,_7); }else{ _1(this); $.data(this,"droppable",{options:$.extend({},$.fn.droppable.defaults,_7)}); } }); }; $.fn.droppable.methods={}; $.fn.droppable.defaults={accept:null,onDragEnter:function(e,_a){ },onDragOver:function(e,_b){ },onDragLeave:function(e,_c){ },onDrop:function(e,_d){ }}; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.droppable.js
JavaScript
asf20
1,167
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ var _3=$.data(_2,"calendar").options; var t=$(_2); if(_3.fit==true){ var p=t.parent(); _3.width=p.width(); _3.height=p.height(); } var _4=t.find(".calendar-header"); if($.boxModel==true){ t.width(_3.width-(t.outerWidth()-t.width())); t.height(_3.height-(t.outerHeight()-t.height())); }else{ t.width(_3.width); t.height(_3.height); } var _5=t.find(".calendar-body"); var _6=t.height()-_4.outerHeight(); if($.boxModel==true){ _5.height(_6-(_5.outerHeight()-_5.height())); }else{ _5.height(_6); } }; function _7(_8){ $(_8).addClass("calendar").wrapInner("<div class=\"calendar-header\">"+"<div class=\"calendar-prevmonth\"></div>"+"<div class=\"calendar-nextmonth\"></div>"+"<div class=\"calendar-prevyear\"></div>"+"<div class=\"calendar-nextyear\"></div>"+"<div class=\"calendar-title\">"+"<span>Aprial 2010</span>"+"</div>"+"</div>"+"<div class=\"calendar-body\">"+"<div class=\"calendar-menu\">"+"<div class=\"calendar-menu-year-inner\">"+"<span class=\"calendar-menu-prev\"></span>"+"<span><input class=\"calendar-menu-year\" type=\"text\"></input></span>"+"<span class=\"calendar-menu-next\"></span>"+"</div>"+"<div class=\"calendar-menu-month-inner\">"+"</div>"+"</div>"+"</div>"); $(_8).find(".calendar-title span").hover(function(){ $(this).addClass("calendar-menu-hover"); },function(){ $(this).removeClass("calendar-menu-hover"); }).click(function(){ var _9=$(_8).find(".calendar-menu"); if(_9.is(":visible")){ _9.hide(); }else{ _16(_8); } }); $(".calendar-prevmonth,.calendar-nextmonth,.calendar-prevyear,.calendar-nextyear",_8).hover(function(){ $(this).addClass("calendar-nav-hover"); },function(){ $(this).removeClass("calendar-nav-hover"); }); $(_8).find(".calendar-nextmonth").click(function(){ _b(_8,1); }); $(_8).find(".calendar-prevmonth").click(function(){ _b(_8,-1); }); $(_8).find(".calendar-nextyear").click(function(){ _11(_8,1); }); $(_8).find(".calendar-prevyear").click(function(){ _11(_8,-1); }); $(_8).bind("_resize",function(){ var _a=$.data(_8,"calendar").options; if(_a.fit==true){ _1(_8); } return false; }); }; function _b(_c,_d){ var _e=$.data(_c,"calendar").options; _e.month+=_d; if(_e.month>12){ _e.year++; _e.month=1; }else{ if(_e.month<1){ _e.year--; _e.month=12; } } _f(_c); var _10=$(_c).find(".calendar-menu-month-inner"); _10.find("td.calendar-selected").removeClass("calendar-selected"); _10.find("td:eq("+(_e.month-1)+")").addClass("calendar-selected"); }; function _11(_12,_13){ var _14=$.data(_12,"calendar").options; _14.year+=_13; _f(_12); var _15=$(_12).find(".calendar-menu-year"); _15.val(_14.year); }; function _16(_17){ var _18=$.data(_17,"calendar").options; $(_17).find(".calendar-menu").show(); if($(_17).find(".calendar-menu-month-inner").is(":empty")){ $(_17).find(".calendar-menu-month-inner").empty(); var t=$("<table></table>").appendTo($(_17).find(".calendar-menu-month-inner")); var idx=0; for(var i=0;i<3;i++){ var tr=$("<tr></tr>").appendTo(t); for(var j=0;j<4;j++){ $("<td class=\"calendar-menu-month\"></td>").html(_18.months[idx++]).attr("abbr",idx).appendTo(tr); } } $(_17).find(".calendar-menu-prev,.calendar-menu-next").hover(function(){ $(this).addClass("calendar-menu-hover"); },function(){ $(this).removeClass("calendar-menu-hover"); }); $(_17).find(".calendar-menu-next").click(function(){ var y=$(_17).find(".calendar-menu-year"); if(!isNaN(y.val())){ y.val(parseInt(y.val())+1); } }); $(_17).find(".calendar-menu-prev").click(function(){ var y=$(_17).find(".calendar-menu-year"); if(!isNaN(y.val())){ y.val(parseInt(y.val()-1)); } }); $(_17).find(".calendar-menu-year").keypress(function(e){ if(e.keyCode==13){ _19(); } }); $(_17).find(".calendar-menu-month").hover(function(){ $(this).addClass("calendar-menu-hover"); },function(){ $(this).removeClass("calendar-menu-hover"); }).click(function(){ var _1a=$(_17).find(".calendar-menu"); _1a.find(".calendar-selected").removeClass("calendar-selected"); $(this).addClass("calendar-selected"); _19(); }); } function _19(){ var _1b=$(_17).find(".calendar-menu"); var _1c=_1b.find(".calendar-menu-year").val(); var _1d=_1b.find(".calendar-selected").attr("abbr"); if(!isNaN(_1c)){ _18.year=parseInt(_1c); _18.month=parseInt(_1d); _f(_17); } _1b.hide(); }; var _1e=$(_17).find(".calendar-body"); var _1f=$(_17).find(".calendar-menu"); var _20=_1f.find(".calendar-menu-year-inner"); var _21=_1f.find(".calendar-menu-month-inner"); _20.find("input").val(_18.year).focus(); _21.find("td.calendar-selected").removeClass("calendar-selected"); _21.find("td:eq("+(_18.month-1)+")").addClass("calendar-selected"); if($.boxModel==true){ _1f.width(_1e.outerWidth()-(_1f.outerWidth()-_1f.width())); _1f.height(_1e.outerHeight()-(_1f.outerHeight()-_1f.height())); _21.height(_1f.height()-(_21.outerHeight()-_21.height())-_20.outerHeight()); }else{ _1f.width(_1e.outerWidth()); _1f.height(_1e.outerHeight()); _21.height(_1f.height()-_20.outerHeight()); } }; function _22(_23,_24){ var _25=[]; var _26=new Date(_23,_24,0).getDate(); for(var i=1;i<=_26;i++){ _25.push([_23,_24,i]); } var _27=[],_28=[]; while(_25.length>0){ var _29=_25.shift(); _28.push(_29); if(new Date(_29[0],_29[1]-1,_29[2]).getDay()==6){ _27.push(_28); _28=[]; } } if(_28.length){ _27.push(_28); } var _2a=_27[0]; if(_2a.length<7){ while(_2a.length<7){ var _2b=_2a[0]; var _29=new Date(_2b[0],_2b[1]-1,_2b[2]-1); _2a.unshift([_29.getFullYear(),_29.getMonth()+1,_29.getDate()]); } }else{ var _2b=_2a[0]; var _28=[]; for(var i=1;i<=7;i++){ var _29=new Date(_2b[0],_2b[1]-1,_2b[2]-i); _28.unshift([_29.getFullYear(),_29.getMonth()+1,_29.getDate()]); } _27.unshift(_28); } var _2c=_27[_27.length-1]; while(_2c.length<7){ var _2d=_2c[_2c.length-1]; var _29=new Date(_2d[0],_2d[1]-1,_2d[2]+1); _2c.push([_29.getFullYear(),_29.getMonth()+1,_29.getDate()]); } if(_27.length<6){ var _2d=_2c[_2c.length-1]; var _28=[]; for(var i=1;i<=7;i++){ var _29=new Date(_2d[0],_2d[1]-1,_2d[2]+i); _28.push([_29.getFullYear(),_29.getMonth()+1,_29.getDate()]); } _27.push(_28); } return _27; }; function _f(_2e){ var _2f=$.data(_2e,"calendar").options; $(_2e).find(".calendar-title span").html(_2f.months[_2f.month-1]+" "+_2f.year); var _30=$(_2e).find("div.calendar-body"); _30.find(">table").remove(); var t=$("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><thead></thead><tbody></tbody></table>").prependTo(_30); var tr=$("<tr></tr>").appendTo(t.find("thead")); for(var i=0;i<_2f.weeks.length;i++){ tr.append("<th>"+_2f.weeks[i]+"</th>"); } var _31=_22(_2f.year,_2f.month); for(var i=0;i<_31.length;i++){ var _32=_31[i]; var tr=$("<tr></tr>").appendTo(t.find("tbody")); for(var j=0;j<_32.length;j++){ var day=_32[j]; $("<td class=\"calendar-day calendar-other-month\"></td>").attr("abbr",day[0]+","+day[1]+","+day[2]).html(day[2]).appendTo(tr); } } t.find("td[abbr^=\""+_2f.year+","+_2f.month+"\"]").removeClass("calendar-other-month"); var now=new Date(); var _33=now.getFullYear()+","+(now.getMonth()+1)+","+now.getDate(); t.find("td[abbr=\""+_33+"\"]").addClass("calendar-today"); if(_2f.current){ t.find(".calendar-selected").removeClass("calendar-selected"); var _34=_2f.current.getFullYear()+","+(_2f.current.getMonth()+1)+","+_2f.current.getDate(); t.find("td[abbr=\""+_34+"\"]").addClass("calendar-selected"); } t.find("tr").find("td:first").addClass("calendar-sunday"); t.find("tr").find("td:last").addClass("calendar-saturday"); t.find("td").hover(function(){ $(this).addClass("calendar-hover"); },function(){ $(this).removeClass("calendar-hover"); }).click(function(){ t.find(".calendar-selected").removeClass("calendar-selected"); $(this).addClass("calendar-selected"); var _35=$(this).attr("abbr").split(","); _2f.current=new Date(_35[0],parseInt(_35[1])-1,_35[2]); _2f.onSelect.call(_2e,_2f.current); }); }; $.fn.calendar=function(_36,_37){ if(typeof _36=="string"){ return $.fn.calendar.methods[_36](this,_37); } _36=_36||{}; return this.each(function(){ var _38=$.data(this,"calendar"); if(_38){ $.extend(_38.options,_36); }else{ _38=$.data(this,"calendar",{options:$.extend({},$.fn.calendar.defaults,$.fn.calendar.parseOptions(this),_36)}); _7(this); } if(_38.options.border==false){ $(this).addClass("calendar-noborder"); } _1(this); _f(this); $(this).find("div.calendar-menu").hide(); }); }; $.fn.calendar.methods={options:function(jq){ return $.data(jq[0],"calendar").options; },resize:function(jq){ return jq.each(function(){ _1(this); }); },moveTo:function(jq,_39){ return jq.each(function(){ $(this).calendar({year:_39.getFullYear(),month:_39.getMonth()+1,current:_39}); }); }}; $.fn.calendar.parseOptions=function(_3a){ var t=$(_3a); return {width:(parseInt(_3a.style.width)||undefined),height:(parseInt(_3a.style.height)||undefined),fit:(t.attr("fit")?t.attr("fit")=="true":undefined),border:(t.attr("border")?t.attr("border")=="true":undefined)}; }; $.fn.calendar.defaults={width:180,height:180,fit:false,border:true,weeks:["S","M","T","W","T","F","S"],months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],year:new Date().getFullYear(),month:new Date().getMonth()+1,current:new Date(),onSelect:function(_3b){ }}; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.calendar.js
JavaScript
asf20
9,271
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($) { function _1(_2, _3) { var _4 = $.data(_2, "combo").options; var _5 = $.data(_2, "combo").combo; var _6 = $.data(_2, "combo").panel; if (_3) { _4.width = _3; } _5.appendTo("body"); if (isNaN(_4.width)) { _4.width = _5.find("input.combo-text").outerWidth(); } var _7 = 0; if (_4.hasDownArrow) { _7 = _5.find(".combo-arrow").outerWidth(); } var _3 = _4.width - _7; if ($.boxModel == true) { _3 -= _5.outerWidth() - _5.width(); } _5.find("input.combo-text").width(_3); _6.panel("resize", { width : (_4.panelWidth ? _4.panelWidth : _5.outerWidth()), height : _4.panelHeight }); _5.insertAfter(_2); }; function _8(_9) { var _a = $.data(_9, "combo").options; var _b = $.data(_9, "combo").combo; if (_a.hasDownArrow) { _b.find(".combo-arrow").show(); } else { _b.find(".combo-arrow").hide(); } }; function _c(_d) { $(_d).addClass("combo-f").hide(); var _e = $("<span class=\"combo\"></span>").insertAfter(_d); var _f = $("<input type=\"text\" class=\"combo-text\">").appendTo(_e); $("<span><span class=\"combo-arrow\"></span></span>").appendTo(_e); $("<input type=\"hidden\" class=\"combo-value\">").appendTo(_e); var _10 = $("<div class=\"combo-panel\"></div>").appendTo("body"); _10.panel({ doSize : false, closed : true, style : { position : "absolute", zIndex : 10 }, onOpen : function() { $(this).panel("resize"); } }); var _11 = $(_d).attr("name"); if (_11) { _e.find("input.combo-value").attr("name", _11); $(_d).removeAttr("name").attr("comboName", _11); } _f.attr("autocomplete", "off"); return { combo : _e, panel : _10 }; }; function _12(_13) { var _14 = $.data(_13, "combo").combo.find("input.combo-text"); _14.validatebox("destroy"); $.data(_13, "combo").panel.panel("destroy"); $.data(_13, "combo").combo.remove(); $(_13).remove(); }; function _15(_16) { var _17 = $.data(_16, "combo"); var _18 = _17.options; var _19 = $.data(_16, "combo").combo; var _1a = $.data(_16, "combo").panel; var _1b = _19.find(".combo-text"); var _1c = _19.find(".combo-arrow"); $(document).unbind(".combo").bind("mousedown.combo", function(e) { $("div.combo-panel").panel("close"); }); _19.unbind(".combo"); _1a.unbind(".combo"); _1b.unbind(".combo"); _1c.unbind(".combo"); if (!_18.disabled) { _1a.bind("mousedown.combo", function(e) { return false; }); _1b.bind("mousedown.combo", function(e) { e.stopPropagation(); }).bind("keydown.combo", function(e) { switch (e.keyCode) { case 38 : _18.keyHandler.up.call(_16); break; case 40 : _18.keyHandler.down.call(_16); break; case 13 : e.preventDefault(); _18.keyHandler.enter.call(_16); return false; case 9 : case 27 : _25(_16); break; default : if (_18.editable) { if (_17.timer) { clearTimeout(_17.timer); } _17.timer = setTimeout(function() { var q = _1b.val(); if (_17.previousValue != q) { _17.previousValue = q; _1d(_16); _18.keyHandler.query.call(_16, _1b .val()); _29(_16, true); } }, _18.delay); } } }); _1c.bind("click.combo", function() { if (_1a.is(":visible")) { _25(_16); } else { $("div.combo-panel").panel("close"); _1d(_16); } _1b.focus(); }).bind("mouseenter.combo", function() { $(this).addClass("combo-arrow-hover"); }).bind("mouseleave.combo", function() { $(this).removeClass("combo-arrow-hover"); }).bind("mousedown.combo", function() { return false; }); } }; function _1d(_1e) { var _1f = $.data(_1e, "combo").options; var _20 = $.data(_1e, "combo").combo; var _21 = $.data(_1e, "combo").panel; if ($.fn.window) { _21.panel("panel").css("z-index", $.fn.window.defaults.zIndex++); } _21.panel("move", { left : _20.offset().left, top : _22() }); _21.panel("open"); _1f.onShowPanel.call(_1e); (function() { if (_21.is(":visible")) { _21.panel("move", { left : _23(), top : _22() }); setTimeout(arguments.callee, 200); } })(); function _23() { var _24 = _20.offset().left; if (_24 + _21.outerWidth() > $(window).width() + $(document).scrollLeft()) { _24 = $(window).width() + $(document).scrollLeft() - _21.outerWidth(); } if (_24 < 0) { _24 = 0; } return _24; }; function _22() { var top = _20.offset().top + _20.outerHeight(); if (top + _21.outerHeight() > $(window).height() + $(document).scrollTop()) { top = _20.offset().top - _21.outerHeight(); } if (top < $(document).scrollTop()) { top = _20.offset().top + _20.outerHeight(); } return top; }; }; function _25(_26) { var _27 = $.data(_26, "combo").options; var _28 = $.data(_26, "combo").panel; _28.panel("close"); _27.onHidePanel.call(_26); }; function _29(_2a, _2b) { var _2c = $.data(_2a, "combo").options; var _2d = $.data(_2a, "combo").combo.find("input.combo-text"); _2d.validatebox(_2c); if (_2b) { _2d.validatebox("validate"); _2d.trigger("mouseleave"); } }; function _2e(_2f, _30) { var _31 = $.data(_2f, "combo").options; var _32 = $.data(_2f, "combo").combo; if (_30) { _31.disabled = true; $(_2f).attr("disabled", true); _32.find(".combo-value").attr("disabled", true); _32.find(".combo-text").attr("disabled", true); } else { _31.disabled = false; $(_2f).removeAttr("disabled"); _32.find(".combo-value").removeAttr("disabled"); _32.find(".combo-text").removeAttr("disabled"); } }; function _33(_34) { var _35 = $.data(_34, "combo").options; var _36 = $.data(_34, "combo").combo; if (_35.multiple) { _36.find("input.combo-value").remove(); } else { _36.find("input.combo-value").val(""); } _36.find("input.combo-text").val(""); }; function _37(_38) { var _39 = $.data(_38, "combo").combo; return _39.find("input.combo-text").val(); }; function _3a(_3b, _3c) { var _3d = $.data(_3b, "combo").combo; _3d.find("input.combo-text").val(_3c); _29(_3b, true); $.data(_3b, "combo").previousValue = _3c; }; // /** // * 获取多个值 // */ // function getValues(_3f, isBeanValue) { // var opts = $.data(_3f, 'combo').options; // var data = $.data(_3f, 'combo').data; // // var _40 = []; // var _41 = $.data(_3f, "combo").combo; // _41.find("input.combo-value").each(function() { // _40.push($(this).val()); // }); // // return _40; // // //// // 是否是对象只 //// if(isBeanValue !== true){ //// return _40; //// } // //// var beanValues = []; //// ////// for (var valIndex = 0; valIndex < _40.length; valIndex++) { ////// var val = _40[valIndex]; ////// ////// for (var index = 0; index < data.length; index++) { ////// var bean = data[index]; ////// if(bean[opts['idField']] == val){ ////// beanValues.push(bean); ////// break; ////// } ////// } ////// } //// //// return beanValues; // }; // /** // * 获取缓存数据对象 // */ // function getDataObject(target, key){ // var val = null; // if((val=$.data(target, 'combotree')) && $.data(target, 'combotree')[key]){ // return val[key]; // }else if((val=$.data(target, 'combogrid')) && $.data(target, 'combogrid')[key]){ // return val[key]; // }else if((val=$.data(target, 'combobox')) && $.data(target, 'combobox')[key]){ // return val[key]; // }else if((val=$.data(target, 'combo')) && $.data(target, 'combo')[key]){ // return val[key]; // } // // return val ? val[key]; // }; /** * 获取值数组 */ function getValues(target, isBeanValue){ var opts = $.data(target, 'combo').options; var data = $.data(target, 'combo').data; switch (opts['xtype']){ case 'combobox': { data = $.data(target, 'combobox').data; break; } case 'combogrid': { var grid = $.data(target, 'combogrid').grid; if(grid){ data = grid.datagrid('getRows'); } break; } case 'combotree': { // 如果是下拉树 var tree = $.data(target, "combotree").tree; if(tree){ if (opts.multiple) { data = tree.tree("getChecked"); } else { data = [tree.tree("getSelected")]; } } break; } } var valueField = opts['valueField'] || opts['idField']; var valArr = []; var combo = $.data(target, "combo").combo; combo.find("input.combo-value").each(function() { valArr.push($(this).val()); }); if(!isBeanValue || $.isEmpty(valueField, false)){ return valArr; } if(opts['xtype'] == 'combotree'){ return data; } var beanArr = []; if(valArr.length>0 && $.isArray(valArr) && data.length>0){ for (var valArrIndex = 0; valArrIndex < valArr.length; valArrIndex++) { var key = valArr[valArrIndex]; for (var dataIndex = 0; dataIndex < data.length; dataIndex++) { var bean = data[dataIndex]; if(bean[valueField] == key){ beanArr.push(bean); } } } } return beanArr; } /** * 获取单个值 */ function getValue(target, isBeanValue){ var valArr = getValues(target, isBeanValue); return valArr ? valArr[0] : null; } function _42(_43, _44) { var _45 = $.data(_43, "combo").options; var _46 = getValues(_43); var _47 = $.data(_43, "combo").combo; _47.find("input.combo-value").remove(); var _48 = $(_43).attr("comboName"); for (var i = 0; i < _44.length; i++) { var _49 = $("<input type=\"hidden\" class=\"combo-value\">") .appendTo(_47); if (_48) { _49.attr("name", _48); } _49.val(_44[i]); } var tmp = []; for (var i = 0; i < _46.length; i++) { tmp[i] = _46[i]; } var aa = []; for (var i = 0; i < _44.length; i++) { for (var j = 0; j < tmp.length; j++) { if (_44[i] == tmp[j]) { aa.push(_44[i]); tmp.splice(j, 1); break; } } } if (aa.length != _44.length || _44.length != _46.length) { if (_45.multiple) { _45.onChange.call(_43, _44, _46); } else { _45.onChange.call(_43, _44[0], _46[0]); } } }; // /** // * 获取值 // */ // function _4a(_4b) { // var _4c = getValues(_4b); // return _4c[0]; // }; function _4d(_4e, _4f) { _42(_4e, [_4f]); }; function _50(_51) { var _52 = $.data(_51, "combo").options; var fn = _52.onChange; _52.onChange = function() { }; if (_52.multiple) { if (_52.value) { if (typeof _52.value == "object") { _42(_51, _52.value); } else { _4d(_51, _52.value); } } else { _42(_51, []); } } else { _4d(_51, _52.value); } _52.onChange = fn; }; $.fn.combo = function(_53, _54) { if (typeof _53 == "string") { return $.fn.combo.methods[_53](this, _54); } _53 = _53 || {}; return this.each(function() { var _55 = $.data(this, "combo"); if (_55) { $.extend(_55.options, _53); } else { var r = _c(this); _55 = $.data(this, "combo", { options : $.extend({}, $.fn.combo.defaults, $.fn.combo.parseOptions(this), _53), combo : r.combo, panel : r.panel, previousValue : null }); $(this).removeAttr("disabled"); } $("input.combo-text", _55.combo).attr("readonly", !_55.options.editable); _8(this); _2e(this, _55.options.disabled); _1(this); _15(this); _29(this); _50(this); }); }; $.fn.combo.methods = { options : function(jq) { return $.data(jq[0], "combo").options; }, panel : function(jq) { return $.data(jq[0], "combo").panel; }, textbox : function(jq) { return $.data(jq[0], "combo").combo.find("input.combo-text"); }, destroy : function(jq) { return jq.each(function() { _12(this); }); }, resize : function(jq, _56) { return jq.each(function() { _1(this, _56); }); }, showPanel : function(jq) { return jq.each(function() { _1d(this); }); }, hidePanel : function(jq) { return jq.each(function() { _25(this); }); }, disable : function(jq) { return jq.each(function() { _2e(this, true); _15(this); }); }, enable : function(jq) { return jq.each(function() { _2e(this, false); _15(this); }); }, validate : function(jq) { return jq.each(function() { _29(this, true); }); }, isValid : function(jq) { var _57 = $.data(jq[0], "combo").combo.find("input.combo-text"); return _57.validatebox("isValid"); }, clear : function(jq) { return jq.each(function() { _33(this); }); }, getText : function(jq) { return _37(jq[0]); }, setText : function(jq, _58) { return jq.each(function() { _3a(this, _58); }); }, // getValues : function(jq) { // return getValues(jq[0]); // }, /** * 获取多个值 */ setValues : function(jq, _59) { return jq.each(function() { _42(this, _59); }); }, // /** // * 获取值 // */ // getValue : function(jq) { // return _4a(jq[0]); // }, /** * 获取值数组 */ getValues: function(jq, isBeanValue){ var val = null; jq.each(function() { val = getValues(this, isBeanValue); }); return val; }, /** * 获取单个值 */ getValue: function(jq, isBeanValue){ var val = null; jq.each(function() { val = getValue(this, isBeanValue); }); return val; }, setValue : function(jq, _5a) { return jq.each(function() { _4d(this, _5a); }); } }; $.fn.combo.parseOptions = function(_5b) { var t = $(_5b); return $.extend({}, $.fn.validatebox.parseOptions(_5b), { width : (parseInt(_5b.style.width) || undefined), panelWidth : (parseInt(t.attr("panelWidth")) || undefined), panelHeight : (t.attr("panelHeight") == "auto" ? "auto" : parseInt(t.attr("panelHeight")) || undefined), separator : (t.attr("separator") || undefined), multiple : (t.attr("multiple") ? (t.attr("multiple") == "true" || t .attr("multiple") == true) : undefined), editable : (t.attr("editable") ? t.attr("editable") == "true" : undefined), disabled : (t.attr("disabled") ? true : undefined), hasDownArrow : (t.attr("hasDownArrow") ? t .attr("hasDownArrow") == "true" : undefined), value : (t.val() || undefined), delay : (t.attr("delay") ? parseInt(t.attr("delay")) : undefined) }); }; $.fn.combo.defaults = $.extend({}, $.fn.validatebox.defaults, { width : "auto", panelWidth : null, panelHeight : 200, multiple : false, separator : ",", editable : false, disabled : false, hasDownArrow : true, value : "", delay : 200, keyHandler : { up : function() { }, down : function() { }, enter : function() { }, query : function(q) { } }, onShowPanel : function() { }, onHidePanel : function() { }, onChange : function(_5c, _5d) { } }); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.combo.js
JavaScript
asf20
16,059
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ var t=$(_2); t.wrapInner("<div class=\"dialog-content\"></div>"); var _3=t.children("div.dialog-content"); _3.attr("style",t.attr("style")); t.removeAttr("style").css("overflow","hidden"); _3.panel({border:false,doSize:false}); return _3; }; function _4(_5){ var _6=$.data(_5,"dialog").options; var _7=$.data(_5,"dialog").contentPanel; if(_6.toolbar){ if(typeof _6.toolbar=="string"){ $(_6.toolbar).addClass("dialog-toolbar").prependTo(_5); $(_6.toolbar).show(); }else{ $(_5).find("div.dialog-toolbar").remove(); var _8=$("<div class=\"dialog-toolbar\"></div>").prependTo(_5); for(var i=0;i<_6.toolbar.length;i++){ var p=_6.toolbar[i]; if(p=="-"){ _8.append("<div class=\"dialog-tool-separator\"></div>"); }else{ var _9=$("<a href=\"javascript:void(0)\"></a>").appendTo(_8); _9.css("float","left"); _9[0].onclick=eval(p.handler||function(){ }); _9.linkbutton($.extend({},p,{plain:true})); } } _8.append("<div style=\"clear:both\"></div>"); } }else{ $(_5).find("div.dialog-toolbar").remove(); } if(_6.buttons){ if(typeof _6.buttons=="string"){ $(_6.buttons).addClass("dialog-button").appendTo(_5); $(_6.buttons).show(); }else{ $(_5).find("div.dialog-button").remove(); var _a=$("<div class=\"dialog-button\"></div>").appendTo(_5); for(var i=0;i<_6.buttons.length;i++){ var p=_6.buttons[i]; var _b=$("<a href=\"javascript:void(0)\"></a>").appendTo(_a); if(p.handler){ _b[0].onclick=p.handler; } _b.linkbutton(p); } } }else{ $(_5).find("div.dialog-button").remove(); } var _c=_6.href; var _d=_6.content; _6.href=null; _6.content=null; $(_5).window($.extend({},_6,{onOpen:function(){ _7.panel("open"); if(_6.onOpen){ _6.onOpen.call(_5); } },onResize:function(_e,_f){ var _10=$(_5).panel("panel").find(">div.panel-body"); _7.panel("resize",{width:_10.width(),height:(_f=="auto")?"auto":_10.height()-_10.find(">div.dialog-toolbar").outerHeight()-_10.find(">div.dialog-button").outerHeight()}); if(_6.onResize){ _6.onResize.call(_5,_e,_f); } }})); _7.panel({closed:_6.closed,href:_c,content:_d,onLoad:function(){ if(_6.height=="auto"){ $(_5).window("resize"); } _6.onLoad.apply(_5,arguments); }}); _6.href=_c; }; function _11(_12,_13){ var _14=$.data(_12,"dialog").contentPanel; _14.panel("refresh",_13); }; $.fn.dialog=function(_15,_16){ if(typeof _15=="string"){ var _17=$.fn.dialog.methods[_15]; if(_17){ return _17(this,_16); }else{ return this.window(_15,_16); } } _15=_15||{}; return this.each(function(){ var _18=$.data(this,"dialog"); if(_18){ $.extend(_18.options,_15); }else{ $.data(this,"dialog",{options:$.extend({},$.fn.dialog.defaults,$.fn.dialog.parseOptions(this),_15),contentPanel:_1(this)}); } _4(this); }); }; $.fn.dialog.methods={options:function(jq){ var _19=$.data(jq[0],"dialog").options; var _1a=jq.panel("options"); $.extend(_19,{closed:_1a.closed,collapsed:_1a.collapsed,minimized:_1a.minimized,maximized:_1a.maximized}); var _1b=$.data(jq[0],"dialog").contentPanel; return _19; },dialog:function(jq){ return jq.window("window"); },refresh:function(jq,_1c){ return jq.each(function(){ _11(this,_1c); }); }}; $.fn.dialog.parseOptions=function(_1d){ var t=$(_1d); return $.extend({},$.fn.window.parseOptions(_1d),{toolbar:t.attr("toolbar"),buttons:t.attr("buttons")}); }; $.fn.dialog.defaults=$.extend({},$.fn.window.defaults,{title:"New Dialog",collapsible:false,minimizable:false,maximizable:false,resizable:false,toolbar:null,buttons:null}); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.dialog.js
JavaScript
asf20
3,598
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ _2.each(function(){ $(this).remove(); if($.browser.msie){ this.outerHTML=""; } }); }; function _3(_4,_5){ var _6=$.data(_4,"panel").options; var _7=$.data(_4,"panel").panel; var _8=_7.children("div.panel-header"); var _9=_7.children("div.panel-body"); if(_5){ if(_5.width){ _6.width=_5.width; } if(_5.height){ _6.height=_5.height; } if(_5.left!=null){ _6.left=_5.left; } if(_5.top!=null){ _6.top=_5.top; } } if(_6.fit==true){ var p=_7.parent(); _6.width=p.width(); _6.height=p.height(); } _7.css({left:_6.left,top:_6.top}); if(!isNaN(_6.width)){ if($.boxModel==true){ _7.width(_6.width-(_7.outerWidth()-_7.width())); }else{ _7.width(_6.width); } }else{ _7.width("auto"); } if($.boxModel==true){ _8.width(_7.width()-(_8.outerWidth()-_8.width())); _9.width(_7.width()-(_9.outerWidth()-_9.width())); }else{ _8.width(_7.width()); _9.width(_7.width()); } if(!isNaN(_6.height)){ if($.boxModel==true){ _7.height(_6.height-(_7.outerHeight()-_7.height())); _9.height(_7.height()-_8.outerHeight()-(_9.outerHeight()-_9.height())); }else{ _7.height(_6.height); _9.height(_7.height()-_8.outerHeight()); } }else{ _9.height("auto"); } _7.css("height",""); _6.onResize.apply(_4,[_6.width,_6.height]); _7.find(">div.panel-body>div").triggerHandler("_resize"); }; function _a(_b,_c){ var _d=$.data(_b,"panel").options; var _e=$.data(_b,"panel").panel; if(_c){ if(_c.left!=null){ _d.left=_c.left; } if(_c.top!=null){ _d.top=_c.top; } } _e.css({left:_d.left,top:_d.top}); _d.onMove.apply(_b,[_d.left,_d.top]); }; function _f(_10){ var _11=$(_10).addClass("panel-body").wrap("<div class=\"panel\"></div>").parent(); _11.bind("_resize",function(){ var _12=$.data(_10,"panel").options; if(_12.fit==true){ _3(_10); } return false; }); return _11; }; function _13(_14){ var _15=$.data(_14,"panel").options; var _16=$.data(_14,"panel").panel; _1(_16.find(">div.panel-header")); if(_15.title&&!_15.noheader){ var _17=$("<div class=\"panel-header\"><div class=\"panel-title\">"+_15.title+"</div></div>").prependTo(_16); if(_15.iconCls){ _17.find(".panel-title").addClass("panel-with-icon"); $("<div class=\"panel-icon\"></div>").addClass(_15.iconCls).appendTo(_17); } var _18=$("<div class=\"panel-tool\"></div>").appendTo(_17); if(_15.closable){ $("<div class=\"panel-tool-close\"></div>").appendTo(_18).bind("click",_19); } if(_15.maximizable){ $("<div class=\"panel-tool-max\"></div>").appendTo(_18).bind("click",_1a); } if(_15.minimizable){ $("<div class=\"panel-tool-min\"></div>").appendTo(_18).bind("click",_1b); } if(_15.collapsible){ $("<div class=\"panel-tool-collapse\"></div>").appendTo(_18).bind("click",_1c); } if(_15.tools){ for(var i=_15.tools.length-1;i>=0;i--){ var t=$("<div></div>").addClass(_15.tools[i].iconCls).appendTo(_18); if(_15.tools[i].handler){ t.bind("click",eval(_15.tools[i].handler)); } } } _18.find("div").hover(function(){ $(this).addClass("panel-tool-over"); },function(){ $(this).removeClass("panel-tool-over"); }); _16.find(">div.panel-body").removeClass("panel-body-noheader"); }else{ _16.find(">div.panel-body").addClass("panel-body-noheader"); } function _1c(){ if(_15.collapsed==true){ _3b(_14,true); }else{ _2b(_14,true); } return false; }; function _1b(){ _46(_14); return false; }; function _1a(){ if(_15.maximized==true){ _4a(_14); }else{ _2a(_14); } return false; }; function _19(){ _1d(_14); return false; }; }; function _1e(_1f){ var _20=$.data(_1f,"panel"); if(_20.options.href&&(!_20.isLoaded||!_20.options.cache)){ _20.isLoaded=false; var _21=_20.panel.find(">div.panel-body"); if(_20.options.loadingMessage){ _21.html($("<div class=\"panel-loading\"></div>").html(_20.options.loadingMessage)); } $.ajax({url:_20.options.href,cache:false,success:function(_22){ _21.html(_20.options.extractor.call(_1f,_22)); if($.parser){ $.parser.parse(_21); } _20.options.onLoad.apply(_1f,arguments); _20.isLoaded=true; }}); } }; function _23(_24){ $(_24).find("div.panel:visible,div.accordion:visible,div.tabs-container:visible,div.layout:visible").each(function(){ $(this).triggerHandler("_resize",[true]); }); }; function _25(_26,_27){ var _28=$.data(_26,"panel").options; var _29=$.data(_26,"panel").panel; if(_27!=true){ if(_28.onBeforeOpen.call(_26)==false){ return; } } _29.show(); _28.closed=false; _28.minimized=false; _28.onOpen.call(_26); if(_28.maximized==true){ _28.maximized=false; _2a(_26); } if(_28.collapsed==true){ _28.collapsed=false; _2b(_26); } if(!_28.collapsed){ _1e(_26); _23(_26); } }; function _1d(_2c,_2d){ var _2e=$.data(_2c,"panel").options; var _2f=$.data(_2c,"panel").panel; if(_2d!=true){ if(_2e.onBeforeClose.call(_2c)==false){ return; } } _2f.hide(); _2e.closed=true; _2e.onClose.call(_2c); }; function _30(_31,_32){ var _33=$.data(_31,"panel").options; var _34=$.data(_31,"panel").panel; if(_32!=true){ if(_33.onBeforeDestroy.call(_31)==false){ return; } } _1(_34); _33.onDestroy.call(_31); }; function _2b(_35,_36){ var _37=$.data(_35,"panel").options; var _38=$.data(_35,"panel").panel; var _39=_38.children("div.panel-body"); var _3a=_38.children("div.panel-header").find("div.panel-tool-collapse"); if(_37.collapsed==true){ return; } _39.stop(true,true); if(_37.onBeforeCollapse.call(_35)==false){ return; } _3a.addClass("panel-tool-expand"); if(_36==true){ _39.slideUp("normal",function(){ _37.collapsed=true; _37.onCollapse.call(_35); }); }else{ _39.hide(); _37.collapsed=true; _37.onCollapse.call(_35); } }; function _3b(_3c,_3d){ var _3e=$.data(_3c,"panel").options; var _3f=$.data(_3c,"panel").panel; var _40=_3f.children("div.panel-body"); var _41=_3f.children("div.panel-header").find("div.panel-tool-collapse"); if(_3e.collapsed==false){ return; } _40.stop(true,true); if(_3e.onBeforeExpand.call(_3c)==false){ return; } _41.removeClass("panel-tool-expand"); if(_3d==true){ _40.slideDown("normal",function(){ _3e.collapsed=false; _3e.onExpand.call(_3c); _1e(_3c); _23(_3c); }); }else{ _40.show(); _3e.collapsed=false; _3e.onExpand.call(_3c); _1e(_3c); _23(_3c); } }; function _2a(_42){ var _43=$.data(_42,"panel").options; var _44=$.data(_42,"panel").panel; var _45=_44.children("div.panel-header").find("div.panel-tool-max"); if(_43.maximized==true){ return; } _45.addClass("panel-tool-restore"); if(!$.data(_42,"panel").original){ $.data(_42,"panel").original={width:_43.width,height:_43.height,left:_43.left,top:_43.top,fit:_43.fit}; } _43.left=0; _43.top=0; _43.fit=true; _3(_42); _43.minimized=false; _43.maximized=true; _43.onMaximize.call(_42); }; function _46(_47){ var _48=$.data(_47,"panel").options; var _49=$.data(_47,"panel").panel; _49.hide(); _48.minimized=true; _48.maximized=false; _48.onMinimize.call(_47); }; function _4a(_4b){ var _4c=$.data(_4b,"panel").options; var _4d=$.data(_4b,"panel").panel; var _4e=_4d.children("div.panel-header").find("div.panel-tool-max"); if(_4c.maximized==false){ return; } _4d.show(); _4e.removeClass("panel-tool-restore"); var _4f=$.data(_4b,"panel").original; _4c.width=_4f.width; _4c.height=_4f.height; _4c.left=_4f.left; _4c.top=_4f.top; _4c.fit=_4f.fit; _3(_4b); _4c.minimized=false; _4c.maximized=false; $.data(_4b,"panel").original=null; _4c.onRestore.call(_4b); }; function _50(_51){ var _52=$.data(_51,"panel").options; var _53=$.data(_51,"panel").panel; if(_52.border==true){ _53.children("div.panel-header").removeClass("panel-header-noborder"); _53.children("div.panel-body").removeClass("panel-body-noborder"); }else{ _53.children("div.panel-header").addClass("panel-header-noborder"); _53.children("div.panel-body").addClass("panel-body-noborder"); } _53.css(_52.style); _53.addClass(_52.cls); _53.children("div.panel-header").addClass(_52.headerCls); _53.children("div.panel-body").addClass(_52.bodyCls); }; function _54(_55,_56){ $.data(_55,"panel").options.title=_56; $(_55).panel("header").find("div.panel-title").html(_56); }; var TO=false; var _57=true; $(window).unbind(".panel").bind("resize.panel",function(){ if(!_57){ return; } if(TO!==false){ clearTimeout(TO); } TO=setTimeout(function(){ _57=false; var _58=$("body.layout"); if(_58.length){ _58.layout("resize"); }else{ $("body").children("div.panel,div.accordion,div.tabs-container,div.layout").triggerHandler("_resize"); } _57=true; TO=false; },200); }); $.fn.panel=function(_59,_5a){ if(typeof _59=="string"){ return $.fn.panel.methods[_59](this,_5a); } _59=_59||{}; return this.each(function(){ var _5b=$.data(this,"panel"); var _5c; if(_5b){ _5c=$.extend(_5b.options,_59); }else{ _5c=$.extend({},$.fn.panel.defaults,$.fn.panel.parseOptions(this),_59); $(this).attr("title",""); _5b=$.data(this,"panel",{options:_5c,panel:_f(this),isLoaded:false}); } if(_5c.content){ $(this).html(_5c.content); if($.parser){ $.parser.parse(this); } } _13(this); _50(this); if(_5c.doSize==true){ _5b.panel.css("display","block"); _3(this); } if(_5c.closed==true||_5c.minimized==true){ _5b.panel.hide(); }else{ _25(this); } }); }; $.fn.panel.methods={options:function(jq){ return $.data(jq[0],"panel").options; },panel:function(jq){ return $.data(jq[0],"panel").panel; },header:function(jq){ return $.data(jq[0],"panel").panel.find(">div.panel-header"); },body:function(jq){ return $.data(jq[0],"panel").panel.find(">div.panel-body"); },setTitle:function(jq,_5d){ return jq.each(function(){ _54(this,_5d); }); },open:function(jq,_5e){ return jq.each(function(){ _25(this,_5e); }); },close:function(jq,_5f){ return jq.each(function(){ _1d(this,_5f); }); },destroy:function(jq,_60){ return jq.each(function(){ _30(this,_60); }); },refresh:function(jq,_61){ return jq.each(function(){ $.data(this,"panel").isLoaded=false; if(_61){ $.data(this,"panel").options.href=_61; } _1e(this); }); },resize:function(jq,_62){ return jq.each(function(){ _3(this,_62); }); },move:function(jq,_63){ return jq.each(function(){ _a(this,_63); }); },maximize:function(jq){ return jq.each(function(){ _2a(this); }); },minimize:function(jq){ return jq.each(function(){ _46(this); }); },restore:function(jq){ return jq.each(function(){ _4a(this); }); },collapse:function(jq,_64){ return jq.each(function(){ _2b(this,_64); }); },expand:function(jq,_65){ return jq.each(function(){ _3b(this,_65); }); }}; $.fn.panel.parseOptions=function(_66){ var t=$(_66); return {width:(parseInt(_66.style.width)||undefined),height:(parseInt(_66.style.height)||undefined),left:(parseInt(_66.style.left)||undefined),top:(parseInt(_66.style.top)||undefined),title:(t.attr("title")||undefined),iconCls:(t.attr("iconCls")||t.attr("icon")),cls:t.attr("cls"),headerCls:t.attr("headerCls"),bodyCls:t.attr("bodyCls"),href:t.attr("href"),loadingMessage:(t.attr("loadingMessage")!=undefined?t.attr("loadingMessage"):undefined),cache:(t.attr("cache")?t.attr("cache")=="true":undefined),fit:(t.attr("fit")?t.attr("fit")=="true":undefined),border:(t.attr("border")?t.attr("border")=="true":undefined),noheader:(t.attr("noheader")?t.attr("noheader")=="true":undefined),collapsible:(t.attr("collapsible")?t.attr("collapsible")=="true":undefined),minimizable:(t.attr("minimizable")?t.attr("minimizable")=="true":undefined),maximizable:(t.attr("maximizable")?t.attr("maximizable")=="true":undefined),closable:(t.attr("closable")?t.attr("closable")=="true":undefined),collapsed:(t.attr("collapsed")?t.attr("collapsed")=="true":undefined),minimized:(t.attr("minimized")?t.attr("minimized")=="true":undefined),maximized:(t.attr("maximized")?t.attr("maximized")=="true":undefined),closed:(t.attr("closed")?t.attr("closed")=="true":undefined)}; }; $.fn.panel.defaults={title:null,iconCls:null,width:"auto",height:"auto",left:null,top:null,cls:null,headerCls:null,bodyCls:null,style:{},href:null,cache:true,fit:false,border:true,doSize:true,noheader:false,content:null,collapsible:false,minimizable:false,maximizable:false,closable:false,collapsed:false,minimized:false,maximized:false,closed:false,tools:[],href:null,loadingMessage:"Loading...",extractor:function(_67){ var _68=/<body[^>]*>((.|[\n\r])*)<\/body>/im; var _69=_68.exec(_67); if(_69){ return _69[1]; }else{ return _67; } },onLoad:function(){ },onBeforeOpen:function(){ },onOpen:function(){ },onBeforeClose:function(){ },onClose:function(){ },onBeforeDestroy:function(){ },onDestroy:function(){ },onResize:function(_6a,_6b){ },onMove:function(_6c,top){ },onMaximize:function(){ },onRestore:function(){ },onMinimize:function(){ },onBeforeCollapse:function(){ },onBeforeExpand:function(){ },onCollapse:function(){ },onExpand:function(){ }}; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.panel.js
JavaScript
asf20
12,544
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ var _3=$.data(_2,"numberspinner").options; $(_2).spinner(_3).numberbox(_3); }; function _4(_5,_6){ var _7=$.data(_5,"numberspinner").options; var v=parseFloat($(_5).numberbox("getValue")||_7.value)||0; if(_6==true){ v-=_7.increment; }else{ v+=_7.increment; } $(_5).numberbox("setValue",v); }; $.fn.numberspinner=function(_8,_9){ if(typeof _8=="string"){ var _a=$.fn.numberspinner.methods[_8]; if(_a){ return _a(this,_9); }else{ return this.spinner(_8,_9); } } _8=_8||{}; return this.each(function(){ var _b=$.data(this,"numberspinner"); if(_b){ $.extend(_b.options,_8); }else{ $.data(this,"numberspinner",{options:$.extend({},$.fn.numberspinner.defaults,$.fn.numberspinner.parseOptions(this),_8)}); } _1(this); }); }; $.fn.numberspinner.methods={options:function(jq){ var _c=$.data(jq[0],"numberspinner").options; return $.extend(_c,{value:jq.numberbox("getValue")}); },setValue:function(jq,_d){ return jq.each(function(){ $(this).numberbox("setValue",_d); }); },getValue:function(jq){ return jq.numberbox("getValue"); },clear:function(jq){ return jq.each(function(){ $(this).spinner("clear"); $(this).numberbox("clear"); }); }}; $.fn.numberspinner.parseOptions=function(_e){ return $.extend({},$.fn.spinner.parseOptions(_e),$.fn.numberbox.parseOptions(_e),{}); }; $.fn.numberspinner.defaults=$.extend({},$.fn.spinner.defaults,$.fn.numberbox.defaults,{spin:function(_f){ _4(this,_f); }}); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.numberspinner.js
JavaScript
asf20
1,625
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ var _3=$(_2).children("div.tabs-header"); var _4=0; $("ul.tabs li",_3).each(function(){ _4+=$(this).outerWidth(true); }); var _5=_3.children("div.tabs-wrap").width(); var _6=parseInt(_3.find("ul.tabs").css("padding-left")); return _4-_5+_6; }; function _7(_8){ var _9=$.data(_8,"tabs").options; var _a=$(_8).children("div.tabs-header"); var _b=_a.children("div.tabs-tool"); var _c=_a.children("div.tabs-scroller-left"); var _d=_a.children("div.tabs-scroller-right"); var _e=_a.children("div.tabs-wrap"); var _f=($.boxModel==true?(_a.outerHeight()-(_b.outerHeight()-_b.height())):_a.outerHeight()); if(_9.plain){ _f-=2; } _b.height(_f); var _10=0; $("ul.tabs li",_a).each(function(){ _10+=$(this).outerWidth(true); }); var _11=_a.width()-_b.outerWidth(); if(_10>_11){ _c.show(); _d.show(); _b.css("right",_d.outerWidth()); _e.css({marginLeft:_c.outerWidth(),marginRight:_d.outerWidth()+_b.outerWidth(),left:0,width:_11-_c.outerWidth()-_d.outerWidth()}); }else{ _c.hide(); _d.hide(); _b.css("right",0); _e.css({marginLeft:0,marginRight:_b.outerWidth(),left:0,width:_11}); _e.scrollLeft(0); } }; function _12(_13){ var _14=$.data(_13,"tabs").options; var _15=$(_13).children("div.tabs-header"); var _16=_15.children("div.tabs-tool"); _16.remove(); if(_14.tools){ _16=$("<div class=\"tabs-tool\"></div>").appendTo(_15); for(var i=0;i<_14.tools.length;i++){ var _17=$("<a href=\"javascript:void(0);\"></a>").appendTo(_16); _17[0].onclick=eval(_14.tools[i].handler||function(){ }); _17.linkbutton($.extend({},_14.tools[i],{plain:true})); } } }; function _18(_19){ var _1a=$.data(_19,"tabs").options; var cc=$(_19); if(_1a.fit==true){ var p=cc.parent(); _1a.width=p.width(); _1a.height=p.height(); } cc.width(_1a.width).height(_1a.height); var _1b=$(_19).children("div.tabs-header"); if($.boxModel==true){ _1b.width(_1a.width-(_1b.outerWidth()-_1b.width())); }else{ _1b.width(_1a.width); } _7(_19); var _1c=$(_19).children("div.tabs-panels"); var _1d=_1a.height; if(!isNaN(_1d)){ if($.boxModel==true){ var _1e=_1c.outerHeight()-_1c.height(); _1c.css("height",(_1d-_1b.outerHeight()-_1e)||"auto"); }else{ _1c.css("height",_1d-_1b.outerHeight()); } }else{ _1c.height("auto"); } var _1f=_1a.width; if(!isNaN(_1f)){ if($.boxModel==true){ _1c.width(_1f-(_1c.outerWidth()-_1c.width())); }else{ _1c.width(_1f); } }else{ _1c.width("auto"); } }; function _20(_21){ var _22=$.data(_21,"tabs").options; var tab=_23(_21); if(tab){ var _24=$(_21).children("div.tabs-panels"); var _25=_22.width=="auto"?"auto":_24.width(); var _26=_22.height=="auto"?"auto":_24.height(); tab.panel("resize",{width:_25,height:_26}); } }; function _27(_28){ var cc=$(_28); cc.addClass("tabs-container"); cc.wrapInner("<div class=\"tabs-panels\"/>"); $("<div class=\"tabs-header\">"+"<div class=\"tabs-scroller-left\"></div>"+"<div class=\"tabs-scroller-right\"></div>"+"<div class=\"tabs-wrap\">"+"<ul class=\"tabs\"></ul>"+"</div>"+"</div>").prependTo(_28); var _29=[]; var tp=cc.children("div.tabs-panels"); tp.children("div[selected]").attr("toselect","true"); tp.children("div").each(function(){ var pp=$(this); _29.push(pp); _37(_28,pp); }); cc.children("div.tabs-header").find(".tabs-scroller-left, .tabs-scroller-right").hover(function(){ $(this).addClass("tabs-scroller-over"); },function(){ $(this).removeClass("tabs-scroller-over"); }); cc.bind("_resize",function(e,_2a){ var _2b=$.data(_28,"tabs").options; if(_2b.fit==true||_2a){ _18(_28); _20(_28); } return false; }); return _29; }; function _2c(_2d){ var _2e=$.data(_2d,"tabs").options; var _2f=$(_2d).children("div.tabs-header"); var _30=$(_2d).children("div.tabs-panels"); if(_2e.plain==true){ _2f.addClass("tabs-header-plain"); }else{ _2f.removeClass("tabs-header-plain"); } if(_2e.border==true){ _2f.removeClass("tabs-header-noborder"); _30.removeClass("tabs-panels-noborder"); }else{ _2f.addClass("tabs-header-noborder"); _30.addClass("tabs-panels-noborder"); } $(".tabs-scroller-left",_2f).unbind(".tabs").bind("click.tabs",function(){ var _31=$(".tabs-wrap",_2f); var pos=_31.scrollLeft()-_2e.scrollIncrement; _31.animate({scrollLeft:pos},_2e.scrollDuration); }); $(".tabs-scroller-right",_2f).unbind(".tabs").bind("click.tabs",function(){ var _32=$(".tabs-wrap",_2f); var pos=Math.min(_32.scrollLeft()+_2e.scrollIncrement,_1(_2d)); _32.animate({scrollLeft:pos},_2e.scrollDuration); }); var _33=$.data(_2d,"tabs").tabs; for(var i=0,len=_33.length;i<len;i++){ var _34=_33[i]; var tab=_34.panel("options").tab; tab.unbind(".tabs").bind("click.tabs",{p:_34},function(e){ _45(_2d,_36(_2d,e.data.p)); }).bind("contextmenu.tabs",{p:_34},function(e){ _2e.onContextMenu.call(_2d,e,e.data.p.panel("options").title); }); tab.find("a.tabs-close").unbind(".tabs").bind("click.tabs",{p:_34},function(e){ _35(_2d,_36(_2d,e.data.p)); return false; }); } }; function _37(_38,pp,_39){ _39=_39||{}; pp.panel($.extend({},_39,{border:false,noheader:true,closed:true,doSize:false,iconCls:(_39.icon?_39.icon:undefined),onLoad:function(){ if(_39.onLoad){ _39.onLoad.call(this,arguments); } $.data(_38,"tabs").options.onLoad.call(_38,pp); }})); var _3a=pp.panel("options"); var _3b=$(_38).children("div.tabs-header"); var _3c=$("ul.tabs",_3b); var tab=$("<li></li>").appendTo(_3c); var _3d=$("<a href=\"javascript:void(0)\" class=\"tabs-inner\"></a>").appendTo(tab); var _3e=$("<span class=\"tabs-title\"></span>").html(_3a.title).appendTo(_3d); var _3f=$("<span class=\"tabs-icon\"></span>").appendTo(_3d); if(_3a.closable){ _3e.addClass("tabs-closable"); $("<a href=\"javascript:void(0)\" class=\"tabs-close\"></a>").appendTo(tab); } if(_3a.iconCls){ _3e.addClass("tabs-with-icon"); _3f.addClass(_3a.iconCls); } _3a.tab=tab; }; function _40(_41,_42){ var _43=$.data(_41,"tabs").options; var _44=$.data(_41,"tabs").tabs; var pp=$("<div></div>").appendTo($(_41).children("div.tabs-panels")); _44.push(pp); _37(_41,pp,_42); _43.onAdd.call(_41,_42.title); _7(_41); _2c(_41); _45(_41,_44.length-1); }; function _46(_47,_48){ var _49=$.data(_47,"tabs").selectHis; var pp=_48.tab; var _4a=pp.panel("options").title; pp.panel($.extend({},_48.options,{iconCls:(_48.options.icon?_48.options.icon:undefined)})); var _4b=pp.panel("options"); var tab=_4b.tab; tab.find("span.tabs-icon").attr("class","tabs-icon"); tab.find("a.tabs-close").remove(); tab.find("span.tabs-title").html(_4b.title); if(_4b.closable){ tab.find("span.tabs-title").addClass("tabs-closable"); $("<a href=\"javascript:void(0)\" class=\"tabs-close\"></a>").appendTo(tab); }else{ tab.find("span.tabs-title").removeClass("tabs-closable"); } if(_4b.iconCls){ tab.find("span.tabs-title").addClass("tabs-with-icon"); tab.find("span.tabs-icon").addClass(_4b.iconCls); }else{ tab.find("span.tabs-title").removeClass("tabs-with-icon"); } if(_4a!=_4b.title){ for(var i=0;i<_49.length;i++){ if(_49[i]==_4a){ _49[i]=_4b.title; } } } _2c(_47); $.data(_47,"tabs").options.onUpdate.call(_47,_4b.title); }; function _35(_4c,_4d){ var _4e=$.data(_4c,"tabs").options; var _4f=$.data(_4c,"tabs").tabs; var _50=$.data(_4c,"tabs").selectHis; if(!_51(_4c,_4d)){ return; } var tab=_52(_4c,_4d); var _53=tab.panel("options").title; if(_4e.onBeforeClose.call(_4c,_53)==false){ return; } var tab=_52(_4c,_4d,true); tab.panel("options").tab.remove(); tab.panel("destroy"); _4e.onClose.call(_4c,_53); _7(_4c); for(var i=0;i<_50.length;i++){ if(_50[i]==_53){ _50.splice(i,1); i--; } } var _54=_50.pop(); if(_54){ _45(_4c,_54); }else{ if(_4f.length){ _45(_4c,0); } } }; function _52(_55,_56,_57){ var _58=$.data(_55,"tabs").tabs; if(typeof _56=="number"){ if(_56<0||_56>=_58.length){ return null; }else{ var tab=_58[_56]; if(_57){ _58.splice(_56,1); } return tab; } } for(var i=0;i<_58.length;i++){ var tab=_58[i]; if(tab.panel("options").title==_56){ if(_57){ _58.splice(i,1); } return tab; } } return null; }; function _36(_59,tab){ var _5a=$.data(_59,"tabs").tabs; for(var i=0;i<_5a.length;i++){ if(_5a[i][0]==$(tab)[0]){ return i; } } return -1; }; function _23(_5b){ var _5c=$.data(_5b,"tabs").tabs; for(var i=0;i<_5c.length;i++){ var tab=_5c[i]; if(tab.panel("options").closed==false){ return tab; } } return null; }; function _5d(_5e){ var _5f=$.data(_5e,"tabs").tabs; for(var i=0;i<_5f.length;i++){ if(_5f[i].attr("toselect")=="true"){ _45(_5e,i); return; } } if(_5f.length){ _45(_5e,0); } }; function _45(_60,_61){ var _62=$.data(_60,"tabs").options; var _63=$.data(_60,"tabs").tabs; var _64=$.data(_60,"tabs").selectHis; if(_63.length==0){ return; } var _65=_52(_60,_61); if(!_65){ return; } var _66=_23(_60); if(_66){ _66.panel("close"); _66.panel("options").tab.removeClass("tabs-selected"); } _65.panel("open"); var _67=_65.panel("options").title; _64.push(_67); var tab=_65.panel("options").tab; tab.addClass("tabs-selected"); var _68=$(_60).find(">div.tabs-header div.tabs-wrap"); var _69=tab.position().left+_68.scrollLeft(); var _6a=_69-_68.scrollLeft(); var _6b=_6a+tab.outerWidth(); if(_6a<0||_6b>_68.innerWidth()){ var pos=Math.min(_69-(_68.width()-tab.width())/2,_1(_60)); _68.animate({scrollLeft:pos},_62.scrollDuration); }else{ var pos=Math.min(_68.scrollLeft(),_1(_60)); _68.animate({scrollLeft:pos},_62.scrollDuration); } _20(_60); _62.onSelect.call(_60,_67); }; function _51(_6c,_6d){ return _52(_6c,_6d)!=null; }; $.fn.tabs=function(_6e,_6f){ if(typeof _6e=="string"){ return $.fn.tabs.methods[_6e](this,_6f); } _6e=_6e||{}; return this.each(function(){ var _70=$.data(this,"tabs"); var _71; if(_70){ _71=$.extend(_70.options,_6e); _70.options=_71; }else{ $.data(this,"tabs",{options:$.extend({},$.fn.tabs.defaults,$.fn.tabs.parseOptions(this),_6e),tabs:_27(this),selectHis:[]}); } _12(this); _2c(this); _18(this); _5d(this); }); }; $.fn.tabs.methods={options:function(jq){ return $.data(jq[0],"tabs").options; },tabs:function(jq){ return $.data(jq[0],"tabs").tabs; },resize:function(jq){ return jq.each(function(){ _18(this); _20(this); }); },add:function(jq,_72){ return jq.each(function(){ _40(this,_72); }); },close:function(jq,_73){ return jq.each(function(){ _35(this,_73); }); },getTab:function(jq,_74){ return _52(jq[0],_74); },getTabIndex:function(jq,tab){ return _36(jq[0],tab); },getSelected:function(jq){ return _23(jq[0]); },select:function(jq,_75){ return jq.each(function(){ _45(this,_75); }); },exists:function(jq,_76){ return _51(jq[0],_76); },update:function(jq,_77){ return jq.each(function(){ _46(this,_77); }); }}; $.fn.tabs.parseOptions=function(_78){ var t=$(_78); return {width:(parseInt(_78.style.width)||undefined),height:(parseInt(_78.style.height)||undefined),fit:(t.attr("fit")?t.attr("fit")=="true":undefined),border:(t.attr("border")?t.attr("border")=="true":undefined),plain:(t.attr("plain")?t.attr("plain")=="true":undefined)}; }; $.fn.tabs.defaults={width:"auto",height:"auto",plain:false,fit:false,border:true,tools:null,scrollIncrement:100,scrollDuration:400,onLoad:function(_79){ },onSelect:function(_7a){ },onBeforeClose:function(_7b){ },onClose:function(_7c){ },onAdd:function(_7d){ },onUpdate:function(_7e){ },onContextMenu:function(e,_7f){ }}; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.tabs.js
JavaScript
asf20
11,188
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($) { function _1(_2, _3) { var _4 = $.data(_2, "window").options; if (_3) { if (_3.width) { _4.width = _3.width; } if (_3.height) { _4.height = _3.height; } if (_3.left != null) { _4.left = _3.left; } if (_3.top != null) { _4.top = _3.top; } } $(_2).panel("resize", _4); }; function _5(_6, _7) { var _8 = $.data(_6, "window"); if (_7) { if (_7.left != null) { _8.options.left = _7.left; } if (_7.top != null) { _8.options.top = _7.top; } } $(_6).panel("move", _8.options); if (_8.shadow) { _8.shadow.css({ left : _8.options.left, top : _8.options.top }); } }; function _9(_a) { var _b = $.data(_a, "window"); var _c = $(_a).panel($.extend({}, _b.options, { border : false, doSize : true, closed : true, cls : "window", headerCls : "window-header", bodyCls : "window-body " + (_b.options.noheader ? "window-body-noheader" : ""), onBeforeDestroy : function() { if (_b.options.onBeforeDestroy.call(_a) == false) { return false; } if (_b.shadow) { _b.shadow.remove(); } if (_b.mask) { _b.mask.remove(); } }, onClose : function() { if (_b.shadow) { _b.shadow.hide(); } if (_b.mask) { _b.mask.hide(); } _b.options.onClose.call(_a); }, onOpen : function() { if (_b.mask) { _b.mask.css({ display : "block", zIndex : $.fn.window.defaults.zIndex++ }); } if (_b.shadow) { _b.shadow.css({ display : "block", zIndex : $.fn.window.defaults.zIndex++, left : _b.options.left, top : _b.options.top, width : _b.window.outerWidth(), height : _b.window.outerHeight() }); } _b.window.css("z-index", $.fn.window.defaults.zIndex++); _b.options.onOpen.call(_a); }, onResize : function(_d, _e) { var _f = $(_a).panel("options"); _b.options.width = _f.width; _b.options.height = _f.height; _b.options.left = _f.left; _b.options.top = _f.top; if (_b.shadow) { _b.shadow.css({ left : _b.options.left, top : _b.options.top, width : _b.window.outerWidth(), height : _b.window.outerHeight() }); } _b.options.onResize.call(_a, _d, _e); }, onMinimize : function() { if (_b.shadow) { _b.shadow.hide(); } if (_b.mask) { _b.mask.hide(); } _b.options.onMinimize.call(_a); }, onBeforeCollapse : function() { if (_b.options.onBeforeCollapse.call(_a) == false) { return false; } if (_b.shadow) { _b.shadow.hide(); } }, onExpand : function() { if (_b.shadow) { _b.shadow.show(); } _b.options.onExpand.call(_a); } })); _b.window = _c.panel("panel"); if (_b.mask) { _b.mask.remove(); } if (_b.options.modal == true) { _b.mask = $("<div class=\"window-mask\"></div>") .insertAfter(_b.window); _b.mask.css({ width : (_b.options.inline ? _b.mask.parent().width() : _10().width), height : (_b.options.inline ? _b.mask.parent().height() : _10().height), display : "none" }); } if (_b.shadow) { _b.shadow.remove(); } if (_b.options.shadow == true) { _b.shadow = $("<div class=\"window-shadow\"></div>") .insertAfter(_b.window); _b.shadow.css({ display : "none" }); } if (_b.options.left == null) { var _11 = _b.options.width; if (isNaN(_11)) { _11 = _b.window.outerWidth(); } if (_b.options.inline) { var _12 = _b.window.parent(); _b.options.left = (_12.width() - _11) / 2 + _12.scrollLeft(); } else { _b.options.left = ($(window).width() - _11) / 2 + $(document).scrollLeft(); } } if (_b.options.top == null) { var _13 = _b.window.height; if (isNaN(_13)) { _13 = _b.window.outerHeight(); } if (_b.options.inline) { var _12 = _b.window.parent(); _b.options.top = (_12.height() - _13) / 2 + _12.scrollTop(); } else { _b.options.top = ($(window).height() - _13) / 2 + $(document).scrollTop(); } } _5(_a); if (_b.options.closed == false) { _c.window("open"); } }; function _14(_15) { var _16 = $.data(_15, "window"); _16.window.draggable({ handle : ">div.panel-header>div.panel-title", disabled : _16.options.draggable == false, onStartDrag : function(e) { if (_16.mask) { _16.mask.css("z-index", $.fn.window.defaults.zIndex++); } if (_16.shadow) { _16.shadow.css("z-index", $.fn.window.defaults.zIndex++); } _16.window.css("z-index", $.fn.window.defaults.zIndex++); if (!_16.proxy) { _16.proxy = $("<div class=\"window-proxy\"></div>") .insertAfter(_16.window); } _16.proxy.css({ display : "none", zIndex : $.fn.window.defaults.zIndex++, left : e.data.left, top : e.data.top, width : ($.boxModel == true ? (_16.window.outerWidth() - (_16.proxy .outerWidth() - _16.proxy.width())) : _16.window.outerWidth()), height : ($.boxModel == true ? (_16.window.outerHeight() - (_16.proxy .outerHeight() - _16.proxy.height())) : _16.window.outerHeight()) }); setTimeout(function() { if (_16.proxy) { _16.proxy.show(); } }, 500); }, onDrag : function(e) { try{ _16.proxy.css({ display : "block", left : e.data.left, top : e.data.top }); }catch(e){}; return false; }, onStopDrag : function(e) { _16.options.left = e.data.left; _16.options.top = e.data.top; $(_15).window("move"); _16.proxy.remove(); _16.proxy = null; } }); _16.window.resizable({ disabled : _16.options.resizable == false, onStartResize : function(e) { _16.pmask = $("<div class=\"window-proxy-mask\"></div>") .insertAfter(_16.window); _16.pmask.css({ zIndex : $.fn.window.defaults.zIndex++, left : e.data.left, top : e.data.top, width : _16.window.outerWidth(), height : _16.window.outerHeight() }); if (!_16.proxy) { _16.proxy = $("<div class=\"window-proxy\"></div>") .insertAfter(_16.window); } _16.proxy.css({ zIndex : $.fn.window.defaults.zIndex++, left : e.data.left, top : e.data.top, width : ($.boxModel == true ? (e.data.width - (_16.proxy .outerWidth() - _16.proxy.width())) : e.data.width), height : ($.boxModel == true ? (e.data.height - (_16.proxy.outerHeight() - _16.proxy .height())) : e.data.height) }); }, onResize : function(e) { _16.proxy.css({ left : e.data.left, top : e.data.top, width : ($.boxModel == true ? (e.data.width - (_16.proxy .outerWidth() - _16.proxy.width())) : e.data.width), height : ($.boxModel == true ? (e.data.height - (_16.proxy.outerHeight() - _16.proxy .height())) : e.data.height) }); return false; }, onStopResize : function(e) { _16.options.left = e.data.left; _16.options.top = e.data.top; _16.options.width = e.data.width; _16.options.height = e.data.height; _1(_15); _16.pmask.remove(); _16.pmask = null; _16.proxy.remove(); _16.proxy = null; } }); }; function _10() { if (document.compatMode == "BackCompat") { return { width : Math.max(document.body.scrollWidth, document.body.clientWidth), height : Math.max(document.body.scrollHeight, document.body.clientHeight) }; } else { return { width : Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth), height : Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) }; } }; $(window).resize(function() { $("body>div.window-mask").css({ width : $(window).width(), height : $(window).height() }); setTimeout(function() { $("body>div.window-mask").css({ width : _10().width, height : _10().height }); }, 50); }); $.fn.window = function(_17, _18) { if (typeof _17 == "string") { var _19 = $.fn.window.methods[_17]; if (_19) { return _19(this, _18); } else { return this.panel(_17, _18); } } _17 = _17 || {}; return this.each(function() { var _1a = $.data(this, "window"); if (_1a) { $.extend(_1a.options, _17); } else { _1a = $.data(this, "window", { options : $.extend({}, $.fn.window.defaults, $.fn.window .parseOptions(this), _17) }); if (!_1a.options.inline) { $(this).appendTo("body"); } } _9(this); _14(this); }); }; $.fn.window.methods = { options : function(jq) { var _1b = jq.panel("options"); var _1c = $.data(jq[0], "window").options; return $.extend(_1c, { closed : _1b.closed, collapsed : _1b.collapsed, minimized : _1b.minimized, maximized : _1b.maximized }); }, window : function(jq) { return $.data(jq[0], "window").window; }, resize : function(jq, _1d) { return jq.each(function() { _1(this, _1d); }); }, move : function(jq, _1e) { return jq.each(function() { _5(this, _1e); }); } }; $.fn.window.parseOptions = function(_1f) { var t = $(_1f); return $.extend({}, $.fn.panel.parseOptions(_1f), { draggable : (t.attr("draggable") ? t.attr("draggable") == "true" : undefined), resizable : (t.attr("resizable") ? t.attr("resizable") == "true" : undefined), shadow : (t.attr("shadow") ? t.attr("shadow") == "true" : undefined), modal : (t.attr("modal") ? t.attr("modal") == "true" : undefined), inline : (t.attr("inline") ? t.attr("inline") == "true" : undefined) }); }; $.fn.window.defaults = $.extend({}, $.fn.panel.defaults, { zIndex : 9000, draggable : true, resizable : false,//true, shadow : true, modal : true,//false, inline : false, title : "New Window", collapsible : true, minimizable : false,//true, maximizable : true, closable : true, closed : false }); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.window.js
JavaScript
asf20
11,071
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($) { function _1(_2, _3) { var _4 = $(_2).combo("panel"); var _5 = _4.find("div.combobox-item[value=" + _3 + "]"); if (_5.length) { if (_5.position().top <= 0) { var h = _4.scrollTop() + _5.position().top; _4.scrollTop(h); } else { if (_5.position().top + _5.outerHeight() > _4.height()) { var h = _4.scrollTop() + _5.position().top + _5.outerHeight() - _4.height(); _4.scrollTop(h); } } } }; function _6(_7) { var _8 = $(_7).combo("panel"); var _9 = $(_7).combo("getValues"); var _a = _8.find("div.combobox-item[value=" + _9.pop() + "]"); if (_a.length) { var _b = _a.prev(":visible"); if (_b.length) { _a = _b; } } else { _a = _8.find("div.combobox-item:visible:last"); } var _c = _a.attr("value"); _d(_7, _c); _1(_7, _c); }; function _e(_f) { var _10 = $(_f).combo("panel"); var _11 = $(_f).combo("getValues"); var _12 = _10.find("div.combobox-item[value=" + _11.pop() + "]"); if (_12.length) { var _13 = _12.next(":visible"); if (_13.length) { _12 = _13; } } else { _12 = _10.find("div.combobox-item:visible:first"); } var _14 = _12.attr("value"); _d(_f, _14); _1(_f, _14); }; function _d(_15, _16) { var _17 = $.data(_15, "combobox").options; var _18 = $.data(_15, "combobox").data; if (_17.multiple) { var _19 = $(_15).combo("getValues"); for (var i = 0; i < _19.length; i++) { if (_19[i] == _16) { return; } } _19.push(_16); _1a(_15, _19); } else { _1a(_15, [_16]); } for (var i = 0; i < _18.length; i++) { if (_18[i][_17.valueField] == _16) { _17.onSelect.call(_15, _18[i]); return; } } }; function _1b(_1c, _1d) { var _1e = $.data(_1c, "combobox").options; var _1f = $.data(_1c, "combobox").data; var _20 = $(_1c).combo("getValues"); for (var i = 0; i < _20.length; i++) { if (_20[i] == _1d) { _20.splice(i, 1); _1a(_1c, _20); break; } } for (var i = 0; i < _1f.length; i++) { if (_1f[i][_1e.valueField] == _1d) { _1e.onUnselect.call(_1c, _1f[i]); return; } } }; /** * 设置值 */ function _1a(_21, _22, _23) { var _24 = $.data(_21, "combobox").options; var _25 = $.data(_21, "combobox").data; var _26 = $(_21).combo("panel"); _26.find("div.combobox-item-selected") .removeClass("combobox-item-selected"); // 如果是对象数组,则转换成普通key数组 if($.isArray(_22) && $.isObject(_22[0])){ var keyArr = []; for (var index = 0; index < _22.length; index++) { var bean = _22[index]; if(bean[_24.valueField]){ keyArr.push(bean[_24.valueField]); } } _22 = keyArr; } var vv = [], ss = []; for (var i = 0; i < _22.length; i++) { var v = _22[i]; var s = v; for (var j = 0; j < _25.length; j++) { if (_25[j][_24.valueField] == v) { s = _25[j][_24.textField]; break; } } vv.push(v); ss.push(s); _26.find("div.combobox-item[value=" + v + "]") .addClass("combobox-item-selected"); } $(_21).combo("setValues", vv); if (!_23) { $(_21).combo("setText", ss.join(_24.separator)); } }; function _27(_28) { var _29 = $.data(_28, "combobox").options; var _2a = []; $(">option", _28).each(function() { var _2b = {}; _2b[_29.valueField] = $(this).attr("value") != undefined ? $(this) .attr("value") : $(this).html(); _2b[_29.textField] = $(this).html(); _2b["selected"] = $(this).attr("selected"); _2a.push(_2b); }); return _2a; }; function _2c(_2d, _2e, _2f) { var _30 = $.data(_2d, "combobox").options; var _31 = $(_2d).combo("panel"); $.data(_2d, "combobox").data = _2e; var _32 = $(_2d).combobox("getValues"); _31.empty(); for (var i = 0; i < _2e.length; i++) { var v = _2e[i][_30.valueField]; var s = _2e[i][_30.textField]; var _33 = $("<div class=\"combobox-item\"></div>").appendTo(_31); _33.attr("value", v); if (_30.formatter) { _33.html(_30.formatter.call(_2d, _2e[i])); } else { _33.html(s); } if (_2e[i]["selected"]) { (function() { for (var i = 0; i < _32.length; i++) { if (v == _32[i]) { return; } } _32.push(v); })(); } } if (_30.multiple) { _1a(_2d, _32, _2f); } else { if (_32.length) { _1a(_2d, [_32[_32.length - 1]], _2f); } else { _1a(_2d, [], _2f); } } _30.onLoadSuccess.call(_2d, _2e); $(".combobox-item", _31).hover(function() { $(this).addClass("combobox-item-hover"); }, function() { $(this).removeClass("combobox-item-hover"); }).click(function() { var _34 = $(this); if (_30.multiple) { if (_34.hasClass("combobox-item-selected")) { _1b(_2d, _34.attr("value")); } else { _d(_2d, _34.attr("value")); } } else { _d(_2d, _34.attr("value")); $(_2d).combo("hidePanel"); } }); }; function _35(_36, url, _37, _38) { var _39 = $.data(_36, "combobox").options; if (url) { _39.list = url; } if (!/*_39.url*/ _39.list) { return; } _37 = _37 || {}; _39.queryParams = _39.queryParams || {}; var param = $.isFunction(_39.queryParams) ? _39.queryParams() : _39.queryParams; // 合并参数 $.extend(_37, param); // zzy+ 用通用ajax $.query(_39['list'], _37, function(_3a) { if (!$.isEmpty(_3a)) { _3a = $.decode(_3a); } if (_3a['rows']) { _3a = _3a['rows']; } _2c(_36, _3a, _38); }, function() { _39.onLoadError.apply(this, arguments); }); // $.ajax({ // type : _39.method, // url : _39.url, // dataType : "json", // data : _37, // success : function(_3a) { // _2c(_36, _3a, _38); // }, // error : function() { // _39.onLoadError.apply(this, arguments); // } // }); }; function _3b(_3c, q) { var _3d = $.data(_3c, "combobox").options; if (_3d.multiple && !q) { _1a(_3c, [], true); } else { _1a(_3c, [q], true); } if (_3d.mode == "remote") { _35(_3c, null, { q : q }, true); } else { var _3e = $(_3c).combo("panel"); _3e.find("div.combobox-item").hide(); var _3f = $.data(_3c, "combobox").data; for (var i = 0; i < _3f.length; i++) { if (_3d.filter.call(_3c, q, _3f[i])) { var v = _3f[i][_3d.valueField]; var s = _3f[i][_3d.textField]; var _40 = _3e.find("div.combobox-item[value=" + v + "]"); _40.show(); if (s == q) { _1a(_3c, [v], true); _40.addClass("combobox-item-selected"); } } } } }; function _41(_42) { var _43 = $.data(_42, "combobox").options; $(_42).addClass("combobox-f"); $(_42).combo($.extend({}, _43, { onShowPanel : function() { $(_42).combo("panel").find("div.combobox-item").show(); _1(_42, $(_42).combobox("getValue")); _43.onShowPanel.call(_42); } })); }; $.fn.combobox = function(_44, _45) { if (typeof _44 == "string") { var _46 = $.fn.combobox.methods[_44]; if (_46) { return _46(this, _45); } else { return this.combo(_44, _45); } } _44 = _44 || {}; // 设置CRUD的相关url $.createURL(_44); // if (_44.url != null) { // if (_44.list == null) { // _44.list = _44.url + '/list' // }; // // if (_44.remove == null) { // _44.remove = _44.url + '/remove' // } // // if (_44.save == null) { // _44.save = _44.url + '/save' // } // } return this.each(function() { var _47 = $.data(this, "combobox"); if (_47) { $.extend(_47.options, _44); _41(this); } else { _47 = $.data(this, "combobox", { options : $.extend({}, $.fn.combobox.defaults, $.fn.combobox.parseOptions(this), _44) }); // 设置CRUD的相关url $.createURL(_47['options']); _41(this); _2c(this, _27(this)); } if (_47.options.data) { _2c(this, _47.options.data); } _35(this); }); }; $.fn.combobox.methods = { options : function(jq) { return $.data(jq[0], "combobox").options; }, getData : function(jq) { return $.data(jq[0], "combobox").data; }, setValues : function(jq, _48) { return jq.each(function() { _1a(this, _48); }); }, setValue : function(jq, _49) { return jq.each(function() { _1a(this, [_49]); }); }, // // /** // * 获取值数组 // */ // getValues: function(jq, isBeanValue){ // var val = null; // jq.each(function() { // val = getValues(this, isBeanValue); // }); // // return val; // }, // /** // * 获取单个值 // */ // getValue: function(jq, isBeanValue){ // var val = null; // jq.each(function() { // val = getValue(this, isBeanValue); // }); // return val; // }, clear : function(jq) { return jq.each(function() { $(this).combo("clear"); var _4a = $(this).combo("panel"); _4a.find("div.combobox-item-selected") .removeClass("combobox-item-selected"); }); }, loadData : function(jq, _4b) { return jq.each(function() { _2c(this, _4b); }); }, reload : function(jq, url) { return jq.each(function() { _35(this, url); }); }, select : function(jq, _4c) { return jq.each(function() { _d(this, _4c); }); }, unselect : function(jq, _4d) { return jq.each(function() { _1b(this, _4d); }); } }; $.fn.combobox.parseOptions = function(_4e) { var t = $(_4e); return $.extend({}, $.fn.combo.parseOptions(_4e), { valueField : t.attr("valueField"), textField : t.attr("textField"), mode : t.attr("mode"), method : (t.attr("method") ? t.attr("method") : undefined), url : t.attr("url"), list: t.attr('list') }); }; $.fn.combobox.defaults = $.extend({}, $.fn.combo.defaults, { xtype: 'combobox', // zzy+ valueField : "value", textField : "text", mode : "local", method : "post", url : null, data : null, keyHandler : { up : function() { _6(this); }, down : function() { _e(this); }, enter : function() { var _4f = $(this).combobox("getValues"); $(this).combobox("setValues", _4f); $(this).combobox("hidePanel"); }, query : function(q) { _3b(this, q); } }, filter : function(q, row) { var _50 = $(this).combobox("options"); return row[_50.textField].indexOf(q) == 0; }, formatter : function(row) { var _51 = $(this).combobox("options"); return row[_51.textField]; }, onLoadSuccess : function() { }, onLoadError : function() { }, onSelect : function(_52) { }, onUnselect : function(_53) { } }); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.combobox.js
JavaScript
asf20
11,376
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($) { function _1(_2) { var v = $("<input type=\"hidden\">").insertAfter(_2); var _3 = $(_2).attr("name"); if (_3) { v.attr("name", _3); $(_2).removeAttr("name").attr("numberboxName", _3); } return v; }; function _4(_5) { var _6 = $.data(_5, "numberbox").options; var fn = _6.onChange; _6.onChange = function() { }; _7(_5, _6.parser.call(_5, _6.value)); _6.onChange = fn; }; function _8(_9) { return $.data(_9, "numberbox").field.val(); }; function _7(_a, _b) { var _c = $.data(_a, "numberbox"); var _d = _c.options; var _e = _8(_a); _b = _d.parser.call(_a, _b); _d.value = _b; _c.field.val(_b); $(_a).val(_d.formatter.call(_a, _b)); if (_e != _b) { _d.onChange.call(_a, _b, _e); } }; function _f(_10) { var _11 = $.data(_10, "numberbox").options; $(_10).unbind(".numberbox").bind("keypress.numberbox", function(e) { if (e.which == 45) { return true; } if (e.which == 46) { return true; } else { if ((e.which >= 48 && e.which <= 57 && e.ctrlKey == false && e.shiftKey == false) || e.which == 0 || e.which == 8) { return true; } else { if (e.ctrlKey == true && (e.which == 99 || e.which == 118)) { return true; } else { return false; } } } }).bind("paste.numberbox", function() { if (window.clipboardData) { var s = clipboardData.getData("text"); if (!/\D/.test(s)) { return true; } else { return false; } } else { return false; } }).bind("dragenter.numberbox", function() { return false; }).bind("blur.numberbox", function() { _7(_10, $(this).val()); $(this).val(_11.formatter.call(_10, _8(_10))); }).bind("focus.numberbox", function() { var vv = _8(_10); if ($(this).val() != vv) { $(this).val(vv); } }); }; function _12(_13) { if ($.fn.validatebox) { var _14 = $.data(_13, "numberbox").options; $(_13).validatebox(_14); } }; function _15(_16, _17) { var _18 = $.data(_16, "numberbox").options; if (_17) { _18.disabled = true; $(_16).attr("disabled", true); } else { _18.disabled = false; $(_16).removeAttr("disabled"); } }; $.fn.numberbox = function(_19, _1a) { if (typeof _19 == "string") { var _1b = $.fn.numberbox.methods[_19]; if (_1b) { return _1b(this, _1a); } else { return this.validatebox(_19, _1a); } } _19 = _19 || {}; return this.each(function() { var _1c = $.data(this, "numberbox"); if (_1c) { $.extend(_1c.options, _19); } else { _1c = $.data(this, "numberbox", { options : $.extend({}, $.fn.numberbox.defaults, $.fn.numberbox.parseOptions(this), _19), field : _1(this) }); $(this).removeAttr("disabled"); $(this).css({ imeMode : "disabled" }); } _15(this, _1c.options.disabled); _f(this); _12(this); _4(this); }); }; $.fn.numberbox.methods = { options : function(jq) { return $.data(jq[0], "numberbox").options; }, destroy : function(jq) { return jq.each(function() { $.data(this, "numberbox").field.remove(); $(this).validatebox("destroy"); $(this).remove(); }); }, disable : function(jq) { return jq.each(function() { _15(this, true); }); }, enable : function(jq) { return jq.each(function() { _15(this, false); }); }, fix : function(jq) { return jq.each(function() { _7(this, $(this).val()); }); }, setValue : function(jq, _1d) { return jq.each(function() { _7(this, _1d); }); }, getValue : function(jq) { return _8(jq[0]); }, clear : function(jq) { return jq.each(function() { var _1e = $.data(this, "numberbox"); _1e.field.val(""); $(this).val(""); }); } }; $.fn.numberbox.parseOptions = function(_1f) { var t = $(_1f); return $.extend({}, $.fn.validatebox.parseOptions(_1f), { disabled : (t.attr("disabled") ? true : undefined), value : (t.val() || undefined), min : (t.attr("min") == "0" ? 0 : parseFloat(t.attr("min")) || undefined), max : (t.attr("max") == "0" ? 0 : parseFloat(t.attr("max")) || undefined), precision : (parseInt(t.attr("precision")) || undefined) }); }; $.fn.numberbox.defaults = $.extend({}, $.fn.validatebox.defaults, { disabled : false, value : "", min : null, max : null, precision : 0, formatter : function(_20) { return _20; }, parser : function(s) { var _21 = $(this).numberbox("options"); var val = parseFloat(s).toFixed(_21.precision); if (isNaN(val)) { val = ""; } else { if (typeof(_21.min) == "number" && val < _21.min) { val = _21.min.toFixed(_21.precision); } else { if (typeof(_21.max) == "number" && val > _21.max) { val = _21.max.toFixed(_21.precision); } } } return val; }, onChange : function(_22, _23) { } }); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.numberbox.js
JavaScript
asf20
5,483
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($) { var _1 = false; function _2(e) { //zzy+ if(!$.data(e.data.target, "draggable"))return; var _3 = $.data(e.data.target, "draggable").options; var _4 = e.data; var _5 = _4.startLeft + e.pageX - _4.startX; var _6 = _4.startTop + e.pageY - _4.startY; if (_3.deltaX != null && _3.deltaX != undefined) { _5 = e.pageX + _3.deltaX; } if (_3.deltaY != null && _3.deltaY != undefined) { _6 = e.pageY + _3.deltaY; } if (e.data.parnet != document.body) { if ($.boxModel == true) { _5 += $(e.data.parent).scrollLeft(); _6 += $(e.data.parent).scrollTop(); } } if (_3.axis == "h") { _4.left = _5; } else { if (_3.axis == "v") { _4.top = _6; } else { _4.left = _5; _4.top = _6; } } }; function _7(e) { var _8 = $.data(e.data.target, "draggable").options; var _9 = $.data(e.data.target, "draggable").proxy; if (_9) { _9.css("cursor", _8.cursor); } else { _9 = $(e.data.target); $.data(e.data.target, "draggable").handle.css("cursor", _8.cursor); } _9.css({ left : e.data.left, top : e.data.top }); }; function _a(e) { _1 = true; var _b = $.data(e.data.target, "draggable").options; var _c = $(".droppable").filter(function() { return e.data.target != this; }).filter(function() { var _d = $.data(this, "droppable").options.accept; if (_d) { $.msg.say($.isFunction(_d)); //zzy+ 自定义accept if($.isFunction(_d)){ return _d.call(this, e); } return $(_d).filter(function() { return this == e.data.target; }).length > 0; } else { return true; } }); $.data(e.data.target, "draggable").droppables = _c; var _e = $.data(e.data.target, "draggable").proxy; if (!_e) { if (_b.proxy) { if (_b.proxy == "clone") { _e = $(e.data.target).clone().insertAfter(e.data.target); } else { _e = _b.proxy.call(e.data.target, e.data.target); } $.data(e.data.target, "draggable").proxy = _e; } else { _e = $(e.data.target); } } _e.css("position", "absolute"); _2(e); _7(e); _b.onStartDrag.call(e.data.target, e); return false; }; function _f(e) { _2(e); if ($.data(e.data.target, "draggable") && $.data(e.data.target, "draggable").options.onDrag.call( e.data.target, e) != false) { _7(e); } var _10 = e.data.target; // zzy+ if($.data(e.data.target, "draggable")){ $.data(e.data.target, "draggable").droppables.each(function() { var _11 = $(this); var p2 = $(this).offset(); if (e.pageX > p2.left && e.pageX < p2.left + _11.outerWidth() && e.pageY > p2.top && e.pageY < p2.top + _11.outerHeight()) { if (!this.entered) { $(this).trigger("_dragenter", [_10]); this.entered = true; } $(this).trigger("_dragover", [_10]); } else { if (this.entered) { $(this).trigger("_dragleave", [_10]); this.entered = false; } } }); } return false; }; function _12(e) { _1 = false; _2(e); var _13 = $.data(e.data.target, "draggable").proxy; var _14 = $.data(e.data.target, "draggable").options; if (_14.revert) { if (_15() == true) { _16(); $(e.data.target).css({ position : e.data.startPosition, left : e.data.startLeft, top : e.data.startTop }); } else { if (_13) { _13.animate({ left : e.data.startLeft, top : e.data.startTop }, function() { _16(); }); } else { $(e.data.target).animate({ left : e.data.startLeft, top : e.data.startTop }, function() { $(e.data.target).css("position", e.data.startPosition); }); } } } else { $(e.data.target).css({ position : "absolute", left : e.data.left, top : e.data.top }); _16(); _15(); } _14.onStopDrag.call(e.data.target, e); setTimeout(function() { $(document).unbind(".draggable"); $("body").css("cursor", "auto"); }, 100); function _16() { if (_13) { _13.remove(); } $.data(e.data.target, "draggable").proxy = null; }; function _15() { var _17 = false; $.data(e.data.target, "draggable").droppables.each(function() { var _18 = $(this); var p2 = $(this).offset(); if (e.pageX > p2.left && e.pageX < p2.left + _18.outerWidth() && e.pageY > p2.top && e.pageY < p2.top + _18.outerHeight()) { if (_14.revert) { $(e.data.target).css({ position : e.data.startPosition, left : e.data.startLeft, top : e.data.startTop }); } $(this).trigger("_drop", [e.data.target]); _17 = true; this.entered = false; } }); return _17; }; return false; }; $.fn.draggable = function(_19, _1a) { if (typeof _19 == "string") { return $.fn.draggable.methods[_19](this, _1a); } return this.each(function() { var _1b; var _1c = $.data(this, "draggable"); if (_1c) { _1c.handle.unbind(".draggable"); _1b = $.extend(_1c.options, _19); } else { _1b = $.extend({}, $.fn.draggable.defaults, _19 || {}); } if (_1b.disabled == true) { $(this).css("cursor", "default"); return; } var _1d = null; if (typeof _1b.handle == "undefined" || _1b.handle == null) { _1d = $(this); } else { _1d = (typeof _1b.handle == "string" ? $(_1b.handle, this) : _1b.handle); } $.data(this, "draggable", { options : _1b, handle : _1d }); _1d.unbind(".draggable").bind("mousemove.draggable", { target : this }, function(e) { if (_1) { return; } var _1e = $.data(e.data.target, "draggable").options; if (_1f(e)) { $(this).css("cursor", _1e.cursor); } else { $(this).css("cursor", ""); } }).bind("mouseleave.draggable", { target : this }, function(e) { $(this).css("cursor", ""); }).bind("mousedown.draggable", { target : this }, function(e) { if (_1f(e) == false) { return; } var _20 = $(e.data.target).position(); var _21 = { startPosition : $(e.data.target) .css("position"), startLeft : _20.left, startTop : _20.top, left : _20.left, top : _20.top, startX : e.pageX, startY : e.pageY, target : e.data.target, parent : $(e.data.target).parent()[0] }; $.extend(e.data, _21); var _22 = $.data(e.data.target, "draggable").options; if (_22.onBeforeDrag.call(e.data.target, e) == false) { return; } $(document).bind("mousedown.draggable", e.data, _a); $(document).bind("mousemove.draggable", e.data, _f); $(document).bind("mouseup.draggable", e.data, _12); $("body").css("cursor", _22.cursor); }); function _1f(e) { var _23 = $.data(e.data.target, "draggable"); var _24 = _23.handle; var _25 = $(_24).offset(); var _26 = $(_24).outerWidth(); var _27 = $(_24).outerHeight(); var t = e.pageY - _25.top; var r = _25.left + _26 - e.pageX; var b = _25.top + _27 - e.pageY; var l = e.pageX - _25.left; return Math.min(t, r, b, l) > _23.options.edge; }; }); }; $.fn.draggable.methods = { options : function(jq) { return $.data(jq[0], "draggable").options; }, proxy : function(jq) { return $.data(jq[0], "draggable").proxy; }, enable : function(jq) { return jq.each(function() { $(this).draggable({ disabled : false }); }); }, disable : function(jq) { return jq.each(function() { $(this).draggable({ disabled : true }); }); } }; $.fn.draggable.defaults = { proxy : null, revert : false, cursor : "move", deltaX : null, deltaY : null, handle : null, disabled : false, edge : 0, axis : null, onBeforeDrag : function(e) { }, onStartDrag : function(e) { }, onDrag : function(e) { }, onStopDrag : function(e) { } }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.draggable.js
JavaScript
asf20
8,793
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ var _3=$.data(_2,"linkbutton").options; $(_2).empty(); $(_2).addClass("l-btn"); if(_3.id){ $(_2).attr("id",_3.id); }else{ $.fn.removeProp?$(_2).removeProp("id"):$(_2).removeAttr("id"); } if(_3.plain){ $(_2).addClass("l-btn-plain"); }else{ $(_2).removeClass("l-btn-plain"); } if(_3.text){ $(_2).html(_3.text).wrapInner("<span class=\"l-btn-left\">"+"<span class=\"l-btn-text\">"+"</span>"+"</span>"); if(_3.iconCls){ $(_2).find(".l-btn-text").addClass(_3.iconCls).css("padding-left","20px"); } }else{ $(_2).html("&nbsp;").wrapInner("<span class=\"l-btn-left\">"+"<span class=\"l-btn-text\">"+"<span class=\"l-btn-empty\"></span>"+"</span>"+"</span>"); if(_3.iconCls){ $(_2).find(".l-btn-empty").addClass(_3.iconCls); } } _4(_2,_3.disabled); }; function _4(_5,_6){ var _7=$.data(_5,"linkbutton"); if(_6){ _7.options.disabled=true; var _8=$(_5).attr("href"); if(_8){ _7.href=_8; $(_5).attr("href","javascript:void(0)"); } if(_5.onclick){ _7.onclick=_5.onclick; _5.onclick=null; } $(_5).addClass("l-btn-disabled"); }else{ _7.options.disabled=false; if(_7.href){ $(_5).attr("href",_7.href); } if(_7.onclick){ _5.onclick=_7.onclick; } $(_5).removeClass("l-btn-disabled"); } }; $.fn.linkbutton=function(_9,_a){ if(typeof _9=="string"){ return $.fn.linkbutton.methods[_9](this,_a); } _9=_9||{}; return this.each(function(){ var _b=$.data(this,"linkbutton"); if(_b){ $.extend(_b.options,_9); }else{ $.data(this,"linkbutton",{options:$.extend({},$.fn.linkbutton.defaults,$.fn.linkbutton.parseOptions(this),_9)}); $(this).removeAttr("disabled"); } _1(this); }); }; $.fn.linkbutton.methods={options:function(jq){ return $.data(jq[0],"linkbutton").options; },enable:function(jq){ return jq.each(function(){ _4(this,false); }); },disable:function(jq){ return jq.each(function(){ _4(this,true); }); }}; $.fn.linkbutton.parseOptions=function(_c){ var t=$(_c); return {id:t.attr("id"),disabled:(t.attr("disabled")?true:undefined),plain:(t.attr("plain")?t.attr("plain")=="true":undefined),text:$.trim(t.html()),iconCls:(t.attr("icon")||t.attr("iconCls"))}; }; $.fn.linkbutton.defaults={id:null,disabled:false,plain:false,text:"",iconCls:null}; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.linkbutton.js
JavaScript
asf20
2,362
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ $(_2).addClass("progressbar"); $(_2).html("<div class=\"progressbar-text\"></div><div class=\"progressbar-value\">&nbsp;</div>"); return $(_2); }; function _3(_4,_5){ var _6=$.data(_4,"progressbar").options; var _7=$.data(_4,"progressbar").bar; if(_5){ _6.width=_5; } if($.boxModel==true){ _7.width(_6.width-(_7.outerWidth()-_7.width())); }else{ _7.width(_6.width); } _7.find("div.progressbar-text").width(_7.width()); }; $.fn.progressbar=function(_8,_9){ if(typeof _8=="string"){ var _a=$.fn.progressbar.methods[_8]; if(_a){ return _a(this,_9); } } _8=_8||{}; return this.each(function(){ var _b=$.data(this,"progressbar"); if(_b){ $.extend(_b.options,_8); }else{ _b=$.data(this,"progressbar",{options:$.extend({},$.fn.progressbar.defaults,$.fn.progressbar.parseOptions(this),_8),bar:_1(this)}); } $(this).progressbar("setValue",_b.options.value); _3(this); }); }; $.fn.progressbar.methods={options:function(jq){ return $.data(jq[0],"progressbar").options; },resize:function(jq,_c){ return jq.each(function(){ _3(this,_c); }); },getValue:function(jq){ return $.data(jq[0],"progressbar").options.value; },setValue:function(jq,_d){ if(_d<0){ _d=0; } if(_d>100){ _d=100; } return jq.each(function(){ var _e=$.data(this,"progressbar").options; var _f=_e.text.replace(/{value}/,_d); var _10=_e.value; _e.value=_d; $(this).find("div.progressbar-value").width(_d+"%"); $(this).find("div.progressbar-text").html(_f); if(_10!=_d){ _e.onChange.call(this,_d,_10); } }); }}; $.fn.progressbar.parseOptions=function(_11){ var t=$(_11); return {width:(parseInt(_11.style.width)||undefined),value:(t.attr("value")?parseInt(t.attr("value")):undefined),text:t.attr("text")}; }; $.fn.progressbar.defaults={width:"auto",value:0,text:"{value}%",onChange:function(_12,_13){ }}; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.progressbar.js
JavaScript
asf20
1,993
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(el,_2,_3,_4){ var _5=$(el).window("window"); if(!_5){ return; } switch(_2){ case null: _5.show(); break; case "slide": _5.slideDown(_3); break; case "fade": _5.fadeIn(_3); break; case "show": _5.show(_3); break; } var _6=null; if(_4>0){ _6=setTimeout(function(){ _7(el,_2,_3); },_4); } _5.hover(function(){ if(_6){ clearTimeout(_6); } },function(){ if(_4>0){ _6=setTimeout(function(){ _7(el,_2,_3); },_4); } }); }; function _7(el,_8,_9){ if(el.locked==true){ return; } el.locked=true; var _a=$(el).window("window"); if(!_a){ return; } switch(_8){ case null: _a.hide(); break; case "slide": _a.slideUp(_9); break; case "fade": _a.fadeOut(_9); break; case "show": _a.hide(_9); break; } setTimeout(function(){ $(el).window("destroy"); },_9); }; function _b(_c,_d,_e){ var _f=$("<div class=\"messager-body\"></div>").appendTo("body"); _f.append(_d); if(_e){ var tb=$("<div class=\"messager-button\"></div>").appendTo(_f); // zzy+ 聚焦 OK 按钮 var okBtnEl = null; for(var _10 in _e){ var btnEl = $("<a></a>").attr("href","javascript:void(0)").text(_10).css("margin-left",10).bind("click",eval(_e[_10])).appendTo(tb).linkbutton(); if(_10=='ok' || _10=='OK' || _10=='确定'){ okBtnEl = btnEl; } } } _f.window({title:_c,noheader:(_c?false:true),width:300,height:"auto",modal:true,collapsible:false,minimizable:false,maximizable:false,resizable:false,onClose:function(){ setTimeout(function(){ _f.window("destroy"); },100); }}); _f.window("window").addClass("messager-window"); // 聚焦 ok按钮 zzy+ if(okBtnEl != null){ okBtnEl.focus(); } return _f; }; $.messager={show:function(_11){ var _12=$.extend({showType:"slide",showSpeed:600,width:250,height:100,msg:"",title:"",timeout:4000},_11||{}); var win=$("<div class=\"messager-body\"></div>").html(_12.msg).appendTo("body"); win.window({title:_12.title,width:_12.width,height:_12.height,collapsible:false,minimizable:false,maximizable:false,shadow:false,draggable:false,resizable:false,closed:true,onBeforeOpen:function(){ _1(this,_12.showType,_12.showSpeed,_12.timeout); return false; },onBeforeClose:function(){ _7(this,_12.showType,_12.showSpeed); return false; }}); win.window("window").css({left:"",top:"0",right:0,height:_12.height,zIndex:$.fn.window.defaults.zIndex++,bottom:0/*zzy+ -document.body.scrollTop-document.documentElement.scrollTop*/}); win.window("open"); },alert:function(_13,msg,_14,fn){ var _15="<div>"+msg+"</div>"; switch(_14){ case "error": _15="<div class=\"messager-icon messager-error\"></div>"+_15; break; case "info": _15="<div class=\"messager-icon messager-info\"></div>"+_15; break; case "question": _15="<div class=\"messager-icon messager-question\"></div>"+_15; break; case "warning": _15="<div class=\"messager-icon messager-warning\"></div>"+_15; break; } _15+="<div style=\"clear:both;\"/>"; var _16={}; _16[$.messager.defaults.ok]=function(){ win.dialog({closed:true}); if(fn){ fn(); return false; } }; _16[$.messager.defaults.ok]=function(){ win.window("close"); if(fn){ fn(); return false; } }; var win=_b(_13,_15,_16); },confirm:function(_17,msg,fn){ var _18 = "<div class=\"messager-icon messager-question\"></div>" + "<div>" + msg + "</div>" + "<div style=\"clear:both;\"/>"; var _19 = {}; _19[$.messager.defaults.ok] = function() { win.window("close"); if (fn) { fn(true); return false; } }; _19[$.messager.defaults.cancel] = function() { win.window("close"); if (fn) { fn(false); return false; } }; var win = _b(_17, _18, _19); },prompt:function(_1a,msg,fn){ var _1b="<div class=\"messager-icon messager-question\"></div>"+"<div>"+msg+"</div>"+"<br/>"+"<input class=\"messager-input\" type=\"text\"/>"+"<div style=\"clear:both;\"/>"; var _1c={}; _1c[$.messager.defaults.ok]=function(){ win.window("close"); if(fn){ fn($(".messager-input",win).val()); return false; } }; _1c[$.messager.defaults.cancel]=function(){ win.window("close"); if(fn){ fn(); return false; } }; var win=_b(_1a,_1b,_1c); },progress:function(_1d){ var _1e=$.extend({title:"",msg:"",text:undefined,interval:300},_1d||{}); var _1f={bar:function(){ return $("body>div.messager-window").find("div.messager-p-bar"); },close:function(){ var win=$("body>div.messager-window>div.messager-body"); if(win.length){ if(win[0].timer){ clearInterval(win[0].timer); } win.window("close"); } }}; if(typeof _1d=="string"){ var _20=_1f[_1d]; return _20(); } var _21="<div class=\"messager-progress\"><div class=\"messager-p-msg\"></div><div class=\"messager-p-bar\"></div></div>"; var win=_b(_1e.title,_21,null); win.find("div.messager-p-msg").html(_1e.msg); var bar=win.find("div.messager-p-bar"); bar.progressbar({text:_1e.text}); win.window({closable:false}); if(_1e.interval){ win[0].timer=setInterval(function(){ var v=bar.progressbar("getValue"); v+=10; if(v>100){ v=0; } bar.progressbar("setValue",v); },_1e.interval); } }}; $.messager.defaults={ok:"Ok",cancel:"Cancel"}; })(jQuery); //zzy+ $.msg = $.messager; /** * 提示 * @param {} msg */ $.extend($.msg,{ /** * 提示框 * @param {} msg */ say: function(msg){ $.msg.show({ title: '提示', msg: msg, timeout: 2500, showSpeed: 500/*, height:200*/ }); }, /** * 信息弹出框 */ info: function(msg){ $.msg.alert('提示信息', msg, 'info'); }, /** * 错误提示框 * @param {} msg */ err: function(msg){ $.msg.alert('提示信息', msg, 'error'); }, /** * 问题提示框 */ issue: function(msg){ $.msg.alert('提示信息', msg, 'question'); }, /** * 警告提示框 */ warn: function(msg){ $.msg.alert('提示信息', msg, 'warning'); }, /** * ajax错误处理解析 * @param {} r */ ajaxError: function(r){ var win = $('<div class="messager-body" style="overflow:auto;"></div>').appendTo('body'); win.append(r['responseText']); win.window({ title: "后台报错", width: 800, height: 500, modal: false, collapsible: true, maximizable: true, resizable: true, onClose: function(){ setTimeout(function(){ win.window('destroy'); }, 100); } }); }, /** * 确认 * @param {} msg * @param {} fn */ cfm: function(msg, fn){ $.msg.confirm("确认", msg, fn); } });
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.messager.js
JavaScript
asf20
6,516
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ var _1=false; function _2(_3){ var _4=$.data(_3,"layout").options; var _5=$.data(_3,"layout").panels; var cc=$(_3); if(_4.fit==true){ var p=cc.parent(); cc.width(p.width()).height(p.height()); } var _6={top:0,left:0,width:cc.width(),height:cc.height()}; function _7(pp){ if(pp.length==0){ return; } pp.panel("resize",{width:cc.width(),height:pp.panel("options").height,left:0,top:0}); _6.top+=pp.panel("options").height; _6.height-=pp.panel("options").height; }; if(_b(_5.expandNorth)){ _7(_5.expandNorth); }else{ _7(_5.north); } function _8(pp){ if(pp.length==0){ return; } pp.panel("resize",{width:cc.width(),height:pp.panel("options").height,left:0,top:cc.height()-pp.panel("options").height}); _6.height-=pp.panel("options").height; }; if(_b(_5.expandSouth)){ _8(_5.expandSouth); }else{ _8(_5.south); } function _9(pp){ if(pp.length==0){ return; } pp.panel("resize",{width:pp.panel("options").width,height:_6.height,left:cc.width()-pp.panel("options").width,top:_6.top}); _6.width-=pp.panel("options").width; }; if(_b(_5.expandEast)){ _9(_5.expandEast); }else{ _9(_5.east); } function _a(pp){ if(pp.length==0){ return; } pp.panel("resize",{width:pp.panel("options").width,height:_6.height,left:0,top:_6.top}); _6.left+=pp.panel("options").width; _6.width-=pp.panel("options").width; }; if(_b(_5.expandWest)){ _a(_5.expandWest); }else{ _a(_5.west); } _5.center.panel("resize",_6); }; function _c(_d){ var cc=$(_d); if(cc[0].tagName=="BODY"){ $("html").css({height:"100%",overflow:"hidden"}); $("body").css({height:"100%",overflow:"hidden",border:"none"}); } cc.addClass("layout"); cc.css({margin:0,padding:0}); function _e(_f){ var pp=$(">div[region="+_f+"]",_d).addClass("layout-body"); var _10=null; if(_f=="north"){ _10="layout-button-up"; }else{ if(_f=="south"){ _10="layout-button-down"; }else{ if(_f=="east"){ _10="layout-button-right"; }else{ if(_f=="west"){ _10="layout-button-left"; } } } } var cls="layout-panel layout-panel-"+_f; if(pp.attr("split")=="true"){ cls+=" layout-split-"+_f; } pp.panel({cls:cls,doSize:false,border:(pp.attr("border")=="false"?false:true),width:(pp.length?parseInt(pp[0].style.width)||pp.outerWidth():"auto"),height:(pp.length?parseInt(pp[0].style.height)||pp.outerHeight():"auto"),tools:[{iconCls:_10,handler:function(){ _1c(_d,_f); }}]}); if(pp.attr("split")=="true"){ var _11=pp.panel("panel"); var _12=""; if(_f=="north"){ _12="s"; } if(_f=="south"){ _12="n"; } if(_f=="east"){ _12="w"; } if(_f=="west"){ _12="e"; } _11.resizable({handles:_12,onStartResize:function(e){ _1=true; if(_f=="north"||_f=="south"){ var _13=$(">div.layout-split-proxy-v",_d); }else{ var _13=$(">div.layout-split-proxy-h",_d); } var top=0,_14=0,_15=0,_16=0; var pos={display:"block"}; if(_f=="north"){ pos.top=parseInt(_11.css("top"))+_11.outerHeight()-_13.height(); pos.left=parseInt(_11.css("left")); pos.width=_11.outerWidth(); pos.height=_13.height(); }else{ if(_f=="south"){ pos.top=parseInt(_11.css("top")); pos.left=parseInt(_11.css("left")); pos.width=_11.outerWidth(); pos.height=_13.height(); }else{ if(_f=="east"){ pos.top=parseInt(_11.css("top"))||0; pos.left=parseInt(_11.css("left"))||0; pos.width=_13.width(); pos.height=_11.outerHeight(); }else{ if(_f=="west"){ pos.top=parseInt(_11.css("top"))||0; pos.left=_11.outerWidth()-_13.width(); pos.width=_13.width(); pos.height=_11.outerHeight(); } } } } _13.css(pos); $("<div class=\"layout-mask\"></div>").css({left:0,top:0,width:cc.width(),height:cc.height()}).appendTo(cc); },onResize:function(e){ if(_f=="north"||_f=="south"){ var _17=$(">div.layout-split-proxy-v",_d); _17.css("top",e.pageY-$(_d).offset().top-_17.height()/2); }else{ var _17=$(">div.layout-split-proxy-h",_d); _17.css("left",e.pageX-$(_d).offset().left-_17.width()/2); } return false; },onStopResize:function(){ $(">div.layout-split-proxy-v",_d).css("display","none"); $(">div.layout-split-proxy-h",_d).css("display","none"); var _18=pp.panel("options"); _18.width=_11.outerWidth(); _18.height=_11.outerHeight(); _18.left=_11.css("left"); _18.top=_11.css("top"); pp.panel("resize"); _2(_d); _1=false; cc.find(">div.layout-mask").remove(); }}); } return pp; }; $("<div class=\"layout-split-proxy-h\"></div>").appendTo(cc); $("<div class=\"layout-split-proxy-v\"></div>").appendTo(cc); var _19={center:_e("center")}; _19.north=_e("north"); _19.south=_e("south"); _19.east=_e("east"); _19.west=_e("west"); $(_d).bind("_resize",function(e,_1a){ var _1b=$.data(_d,"layout").options; if(_1b.fit==true||_1a){ _2(_d); } return false; }); return _19; }; function _1c(_1d,_1e){ var _1f=$.data(_1d,"layout").panels; var cc=$(_1d); function _20(dir){ var _21; if(dir=="east"){ _21="layout-button-left"; }else{ if(dir=="west"){ _21="layout-button-right"; }else{ if(dir=="north"){ _21="layout-button-down"; }else{ if(dir=="south"){ _21="layout-button-up"; } } } } var p=$("<div></div>").appendTo(cc).panel({cls:"layout-expand",title:"&nbsp;",closed:true,doSize:false,tools:[{iconCls:_21,handler:function(){ _22(_1d,_1e); }}]}); p.panel("panel").hover(function(){ $(this).addClass("layout-expand-over"); },function(){ $(this).removeClass("layout-expand-over"); }); return p; }; if(_1e=="east"){ if(_1f.east.panel("options").onBeforeCollapse.call(_1f.east)==false){ return; } _1f.center.panel("resize",{width:_1f.center.panel("options").width+_1f.east.panel("options").width-28}); _1f.east.panel("panel").animate({left:cc.width()},function(){ _1f.east.panel("close"); _1f.expandEast.panel("open").panel("resize",{top:_1f.east.panel("options").top,left:cc.width()-28,width:28,height:_1f.east.panel("options").height}); _1f.east.panel("options").onCollapse.call(_1f.east); }); if(!_1f.expandEast){ _1f.expandEast=_20("east"); _1f.expandEast.panel("panel").click(function(){ _1f.east.panel("open").panel("resize",{left:cc.width()}); _1f.east.panel("panel").animate({left:cc.width()-_1f.east.panel("options").width}); return false; }); } }else{ if(_1e=="west"){ if(_1f.west.panel("options").onBeforeCollapse.call(_1f.west)==false){ return; } _1f.center.panel("resize",{width:_1f.center.panel("options").width+_1f.west.panel("options").width-28,left:28}); _1f.west.panel("panel").animate({left:-_1f.west.panel("options").width},function(){ _1f.west.panel("close"); _1f.expandWest.panel("open").panel("resize",{top:_1f.west.panel("options").top,left:0,width:28,height:_1f.west.panel("options").height}); _1f.west.panel("options").onCollapse.call(_1f.west); }); if(!_1f.expandWest){ _1f.expandWest=_20("west"); _1f.expandWest.panel("panel").click(function(){ _1f.west.panel("open").panel("resize",{left:-_1f.west.panel("options").width}); _1f.west.panel("panel").animate({left:0}); return false; }); } }else{ if(_1e=="north"){ if(_1f.north.panel("options").onBeforeCollapse.call(_1f.north)==false){ return; } var hh=cc.height()-28; if(_b(_1f.expandSouth)){ hh-=_1f.expandSouth.panel("options").height; }else{ if(_b(_1f.south)){ hh-=_1f.south.panel("options").height; } } _1f.center.panel("resize",{top:28,height:hh}); _1f.east.panel("resize",{top:28,height:hh}); _1f.west.panel("resize",{top:28,height:hh}); if(_b(_1f.expandEast)){ _1f.expandEast.panel("resize",{top:28,height:hh}); } if(_b(_1f.expandWest)){ _1f.expandWest.panel("resize",{top:28,height:hh}); } _1f.north.panel("panel").animate({top:-_1f.north.panel("options").height},function(){ _1f.north.panel("close"); _1f.expandNorth.panel("open").panel("resize",{top:0,left:0,width:cc.width(),height:28}); _1f.north.panel("options").onCollapse.call(_1f.north); }); if(!_1f.expandNorth){ _1f.expandNorth=_20("north"); _1f.expandNorth.panel("panel").click(function(){ _1f.north.panel("open").panel("resize",{top:-_1f.north.panel("options").height}); _1f.north.panel("panel").animate({top:0}); return false; }); } }else{ if(_1e=="south"){ if(_1f.south.panel("options").onBeforeCollapse.call(_1f.south)==false){ return; } var hh=cc.height()-28; if(_b(_1f.expandNorth)){ hh-=_1f.expandNorth.panel("options").height; }else{ if(_b(_1f.north)){ hh-=_1f.north.panel("options").height; } } _1f.center.panel("resize",{height:hh}); _1f.east.panel("resize",{height:hh}); _1f.west.panel("resize",{height:hh}); if(_b(_1f.expandEast)){ _1f.expandEast.panel("resize",{height:hh}); } if(_b(_1f.expandWest)){ _1f.expandWest.panel("resize",{height:hh}); } _1f.south.panel("panel").animate({top:cc.height()},function(){ _1f.south.panel("close"); _1f.expandSouth.panel("open").panel("resize",{top:cc.height()-28,left:0,width:cc.width(),height:28}); _1f.south.panel("options").onCollapse.call(_1f.south); }); if(!_1f.expandSouth){ _1f.expandSouth=_20("south"); _1f.expandSouth.panel("panel").click(function(){ _1f.south.panel("open").panel("resize",{top:cc.height()}); _1f.south.panel("panel").animate({top:cc.height()-_1f.south.panel("options").height}); return false; }); } } } } } }; function _22(_23,_24){ var _25=$.data(_23,"layout").panels; var cc=$(_23); if(_24=="east"&&_25.expandEast){ if(_25.east.panel("options").onBeforeExpand.call(_25.east)==false){ return; } _25.expandEast.panel("close"); _25.east.panel("panel").stop(true,true); _25.east.panel("open").panel("resize",{left:cc.width()}); _25.east.panel("panel").animate({left:cc.width()-_25.east.panel("options").width},function(){ _2(_23); _25.east.panel("options").onExpand.call(_25.east); }); }else{ if(_24=="west"&&_25.expandWest){ if(_25.west.panel("options").onBeforeExpand.call(_25.west)==false){ return; } _25.expandWest.panel("close"); _25.west.panel("panel").stop(true,true); _25.west.panel("open").panel("resize",{left:-_25.west.panel("options").width}); _25.west.panel("panel").animate({left:0},function(){ _2(_23); _25.west.panel("options").onExpand.call(_25.west); }); }else{ if(_24=="north"&&_25.expandNorth){ if(_25.north.panel("options").onBeforeExpand.call(_25.north)==false){ return; } _25.expandNorth.panel("close"); _25.north.panel("panel").stop(true,true); _25.north.panel("open").panel("resize",{top:-_25.north.panel("options").height}); _25.north.panel("panel").animate({top:0},function(){ _2(_23); _25.north.panel("options").onExpand.call(_25.north); }); }else{ if(_24=="south"&&_25.expandSouth){ if(_25.south.panel("options").onBeforeExpand.call(_25.south)==false){ return; } _25.expandSouth.panel("close"); _25.south.panel("panel").stop(true,true); _25.south.panel("open").panel("resize",{top:cc.height()}); _25.south.panel("panel").animate({top:cc.height()-_25.south.panel("options").height},function(){ _2(_23); _25.south.panel("options").onExpand.call(_25.south); }); } } } } }; function _26(_27){ var _28=$.data(_27,"layout").panels; var cc=$(_27); if(_28.east.length){ _28.east.panel("panel").bind("mouseover","east",_1c); } if(_28.west.length){ _28.west.panel("panel").bind("mouseover","west",_1c); } if(_28.north.length){ _28.north.panel("panel").bind("mouseover","north",_1c); } if(_28.south.length){ _28.south.panel("panel").bind("mouseover","south",_1c); } _28.center.panel("panel").bind("mouseover","center",_1c); function _1c(e){ if(_1==true){ return; } if(e.data!="east"&&_b(_28.east)&&_b(_28.expandEast)){ _28.east.panel("panel").animate({left:cc.width()},function(){ _28.east.panel("close"); }); } if(e.data!="west"&&_b(_28.west)&&_b(_28.expandWest)){ _28.west.panel("panel").animate({left:-_28.west.panel("options").width},function(){ _28.west.panel("close"); }); } if(e.data!="north"&&_b(_28.north)&&_b(_28.expandNorth)){ _28.north.panel("panel").animate({top:-_28.north.panel("options").height},function(){ _28.north.panel("close"); }); } if(e.data!="south"&&_b(_28.south)&&_b(_28.expandSouth)){ _28.south.panel("panel").animate({top:cc.height()},function(){ _28.south.panel("close"); }); } return false; }; }; function _b(pp){ if(!pp){ return false; } if(pp.length){ return pp.panel("panel").is(":visible"); }else{ return false; } }; $.fn.layout=function(_29,_2a){ if(typeof _29=="string"){ return $.fn.layout.methods[_29](this,_2a); } return this.each(function(){ var _2b=$.data(this,"layout"); if(!_2b){ var _2c=$.extend({},{fit:$(this).attr("fit")=="true"}); $.data(this,"layout",{options:_2c,panels:_c(this)}); _26(this); } _2(this); }); }; $.fn.layout.methods={resize:function(jq){ return jq.each(function(){ _2(this); }); },panel:function(jq,_2d){ return $.data(jq[0],"layout").panels[_2d]; },collapse:function(jq,_2e){ return jq.each(function(){ _1c(this,_2e); }); },expand:function(jq,_2f){ return jq.each(function(){ _22(this,_2f); }); }}; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.layout.js
JavaScript
asf20
12,543
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($) { function _1(_2) { $(_2).addClass("validatebox-text"); }; function _3(_4) { var _5 = $.data(_4, "validatebox"); _5.validating = false; var _6 = _5.tip; if (_6) { _6.remove(); } $(_4).unbind(); $(_4).remove(); }; function _7(_8) { var _9 = $(_8); var _a = $.data(_8, "validatebox"); _a.validating = false; _9.unbind(".validatebox").bind("focus.validatebox", function() { _a.validating = true; _a.value = undefined; (function () { if (_a.validating) { if (_a.value != _9.val()) { _a.value = _9.val(); _11(_8); } setTimeout(arguments.callee, 200); } })(); }).bind("blur.validatebox", function() { _a.validating = false; _b(_8); }).bind("mouseenter.validatebox", function() { if (_9.hasClass("validatebox-invalid")) { _c(_8); } }).bind("mouseleave.validatebox", function() { _b(_8); }); }; function _c(_d) { var _e = $(_d); var _f = $.data(_d, "validatebox").message; var tip = $.data(_d, "validatebox").tip; if (!tip) { tip = $("<div class=\"validatebox-tip\">" + "<span class=\"validatebox-tip-content\">" + "</span>" + "<span class=\"validatebox-tip-pointer\">" + "</span>" + "</div>").appendTo("body"); $.data(_d, "validatebox").tip = tip; } tip.find(".validatebox-tip-content").html(_f); tip.css({ display : "block", left : _e.offset().left + _e.outerWidth(), top : _e.offset().top }); }; function _b(_10) { var tip = $.data(_10, "validatebox").tip; if (tip) { tip.remove(); $.data(_10, "validatebox").tip = null; } }; function _11(_12) { var _13 = $.data(_12, "validatebox").options; var tip = $.data(_12, "validatebox").tip; var box = $(_12); var _14 = box.val(); function _15(msg) { $.data(_12, "validatebox").message = msg; }; var _16 = box.attr("disabled"); if (_16 == true || _16 == "true") { box.removeClass("validatebox-invalid"); _b(_12); return true; } if (_13.required) { if (_14 == "") { box.addClass("validatebox-invalid"); _15(_13.missingMessage); _c(_12); return false; } } if (_13.validType) { //zzy+ 解决多重验证的问题,如:length[1,3];email var validTypeArr = _13.validType.split(';'); for (var index = 0; index < validTypeArr.length; index++) { var validType = validTypeArr[index]; var _17 = /([a-zA-Z_]+)(.*)/.exec(validType); var _18 = _13.rules[_17[1]]; if (_14 && _18) { var _19 = eval(_17[2]); if (!_18["validator"](_14, _19)) { box.addClass("validatebox-invalid"); var _1a = _18["message"]; if (_19) { for (var i = 0; i < _19.length; i++) { _1a = _1a.replace( new RegExp("\\{" + i + "\\}", "g"), _19[i]); } } _15(_13.invalidMessage || _1a); _c(_12); return false; } } } } box.removeClass("validatebox-invalid"); _b(_12); return true; }; $.fn.validatebox = function(_1b, _1c) { if (typeof _1b == "string") { return $.fn.validatebox.methods[_1b](this, _1c); } _1b = _1b || {}; return this.each(function() { var _1d = $.data(this, "validatebox"); if (_1d) { $.extend(_1d.options, _1b); } else { _1(this); $.data(this, "validatebox", { options : $ .extend( {}, $.fn.validatebox.defaults, $.fn.validatebox .parseOptions(this), _1b) }); } _7(this); }); }; $.fn.validatebox.methods = { destroy : function(jq) { return jq.each(function() { _3(this); }); }, validate : function(jq) { return jq.each(function() { _11(this); }); }, isValid : function(jq) { return _11(jq[0]); }, /** * 清除验证 * @param jq */ clear: function(jq){ } }; $.fn.validatebox.parseOptions = function(_1e) { var t = $(_1e); return { required : (t.attr("required") ? (t.attr("required") == "required" || t.attr("required") == "true" || t .attr("required") == true) : undefined), validType : (t.attr("validType") || undefined), missingMessage : (t.attr("missingMessage") || undefined), invalidMessage : (t.attr("invalidMessage") || undefined) }; }; $.fn.validatebox.defaults = { required : false, validType : null, missingMessage : "This field is required.", invalidMessage : null, rules : { email : { validator : function(_1f) { return /^((([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 .test(_1f); }, message : "Please enter a valid email address." }, url : { validator : function(_20) { return /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([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])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i .test(_20); }, message : "Please enter a valid URL." }, length : { validator : function(_21, _22) { var len = $.trim(_21).length; return len >= _22[0] && len <= _22[1]; }, message : "Please enter a value between {0} and {1}." }, remote : { validator : function(_23, _24) { var _25 = {}; _25[_24[1]] = _23; var _26 = $.ajax({ url : _24[0], dataType : "json", data : _25, async : false, cache : false, type : "post" }).responseText; return _26 == "true"; }, message : "Please fix this field." }, /** * 第二次密码验证 */ pwdTow : { validator : function(val, params) { var val1 = $('#'+params[0]).val(); var val2 = $.trim(val); return val1 == val2; }, message : "第二次输入的密码与第一次不一致!" } } }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.validatebox.js
JavaScript
asf20
8,133
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ var _3=$.data(_2,"menubutton").options; var _4=$(_2); _4.removeClass("m-btn-active m-btn-plain-active"); _4.linkbutton($.extend({},_3,{text:_3.text+"<span class=\"m-btn-downarrow\">&nbsp;</span>"})); if(_3.menu){ $(_3.menu).menu({onShow:function(){ _4.addClass((_3.plain==true)?"m-btn-plain-active":"m-btn-active"); },onHide:function(){ _4.removeClass((_3.plain==true)?"m-btn-plain-active":"m-btn-active"); }}); } _5(_2,_3.disabled); }; function _5(_6,_7){ var _8=$.data(_6,"menubutton").options; _8.disabled=_7; var _9=$(_6); if(_7){ _9.linkbutton("disable"); _9.unbind(".menubutton"); }else{ _9.linkbutton("enable"); _9.unbind(".menubutton"); _9.bind("click.menubutton",function(){ _a(); return false; }); var _b=null; _9.bind("mouseenter.menubutton",function(){ _b=setTimeout(function(){ _a(); },_8.duration); return false; }).bind("mouseleave.menubutton",function(){ if(_b){ clearTimeout(_b); } }); } function _a(){ if(!_8.menu){ return; } var _c=_9.offset().left; if(_c+$(_8.menu).outerWidth()+5>$(window).width()){ _c=$(window).width()-$(_8.menu).outerWidth()-5; } $("body>div.menu-top").menu("hide"); $(_8.menu).menu("show",{left:_c,top:_9.offset().top+_9.outerHeight()}); _9.blur(); }; }; $.fn.menubutton=function(_d,_e){ if(typeof _d=="string"){ return $.fn.menubutton.methods[_d](this,_e); } _d=_d||{}; return this.each(function(){ var _f=$.data(this,"menubutton"); if(_f){ $.extend(_f.options,_d); }else{ $.data(this,"menubutton",{options:$.extend({},$.fn.menubutton.defaults,$.fn.menubutton.parseOptions(this),_d)}); $(this).removeAttr("disabled"); } _1(this); }); }; $.fn.menubutton.methods={options:function(jq){ return $.data(jq[0],"menubutton").options; },enable:function(jq){ return jq.each(function(){ _5(this,false); }); },disable:function(jq){ return jq.each(function(){ _5(this,true); }); }}; $.fn.menubutton.parseOptions=function(_10){ var t=$(_10); return $.extend({},$.fn.linkbutton.parseOptions(_10),{menu:t.attr("menu"),duration:t.attr("duration")}); }; $.fn.menubutton.defaults=$.extend({},$.fn.linkbutton.defaults,{plain:true,menu:null,duration:100}); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.menubutton.js
JavaScript
asf20
2,316
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ var _3=$.data(_2,"pagination").options; var _4=$(_2).addClass("pagination").empty(); var t=$("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr></tr></table>").appendTo(_4); var tr=$("tr",t); if(_3.showPageList){ var ps=$("<select class=\"pagination-page-list\"></select>"); for(var i=0;i<_3.pageList.length;i++){ var _5=$("<option></option>").text(_3.pageList[i]).appendTo(ps); if(_3.pageList[i]==_3.pageSize){ _5.attr("selected","selected"); } } $("<td></td>").append(ps).appendTo(tr); _3.pageSize=parseInt(ps.val()); $("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr); } $("<td><a href=\"javascript:void(0)\" icon=\"pagination-first\"></a></td>").appendTo(tr); $("<td><a href=\"javascript:void(0)\" icon=\"pagination-prev\"></a></td>").appendTo(tr); $("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr); $("<span style=\"padding-left:6px;\"></span>").html(_3.beforePageText).wrap("<td></td>").parent().appendTo(tr); $("<td><input class=\"pagination-num\" type=\"text\" value=\"1\" size=\"2\"></td>").appendTo(tr); $("<span style=\"padding-right:6px;\"></span>").wrap("<td></td>").parent().appendTo(tr); $("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr); $("<td><a href=\"javascript:void(0)\" icon=\"pagination-next\"></a></td>").appendTo(tr); $("<td><a href=\"javascript:void(0)\" icon=\"pagination-last\"></a></td>").appendTo(tr); if(_3.showRefresh){ $("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr); $("<td><a href=\"javascript:void(0)\" icon=\"pagination-load\"></a></td>").appendTo(tr); } if(_3.buttons){ $("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr); for(var i=0;i<_3.buttons.length;i++){ var _6=_3.buttons[i]; if(_6=="-"){ $("<td><div class=\"pagination-btn-separator\"></div></td>").appendTo(tr); }else{ var td=$("<td></td>").appendTo(tr); $("<a href=\"javascript:void(0)\"></a>").addClass("l-btn").css("float","left").text(_6.text||"").attr("icon",_6.iconCls||"").bind("click",eval(_6.handler||function(){ })).appendTo(td).linkbutton({plain:true}); } } } $("<div class=\"pagination-info\"></div>").appendTo(_4); $("<div style=\"clear:both;\"></div>").appendTo(_4); $("a[icon^=pagination]",_4).linkbutton({plain:true}); _4.find("a[icon=pagination-first]").unbind(".pagination").bind("click.pagination",function(){ if(_3.pageNumber>1){ _b(_2,1); } }); _4.find("a[icon=pagination-prev]").unbind(".pagination").bind("click.pagination",function(){ if(_3.pageNumber>1){ _b(_2,_3.pageNumber-1); } }); _4.find("a[icon=pagination-next]").unbind(".pagination").bind("click.pagination",function(){ var _7=Math.ceil(_3.total/_3.pageSize); if(_3.pageNumber<_7){ _b(_2,_3.pageNumber+1); } }); _4.find("a[icon=pagination-last]").unbind(".pagination").bind("click.pagination",function(){ var _8=Math.ceil(_3.total/_3.pageSize); if(_3.pageNumber<_8){ _b(_2,_8); } }); _4.find("a[icon=pagination-load]").unbind(".pagination").bind("click.pagination",function(){ if(_3.onBeforeRefresh.call(_2,_3.pageNumber,_3.pageSize)!=false){ _b(_2,_3.pageNumber); _3.onRefresh.call(_2,_3.pageNumber,_3.pageSize); } }); _4.find("input.pagination-num").unbind(".pagination").bind("keydown.pagination",function(e){ if(e.keyCode==13){ var _9=parseInt($(this).val())||1; _b(_2,_9); } }); _4.find(".pagination-page-list").unbind(".pagination").bind("change.pagination",function(){ _3.pageSize=$(this).val(); _3.onChangePageSize.call(_2,_3.pageSize); var _a=Math.ceil(_3.total/_3.pageSize); _b(_2,_3.pageNumber); }); }; function _b(_c,_d){ var _e=$.data(_c,"pagination").options; var _f=Math.ceil(_e.total/_e.pageSize)||1; var _10=_d; if(_d<1){ _10=1; } if(_d>_f){ _10=_f; } _e.pageNumber=_10; _e.onSelectPage.call(_c,_10,_e.pageSize); _11(_c); }; function _11(_12){ var _13=$.data(_12,"pagination").options; var _14=Math.ceil(_13.total/_13.pageSize)||1; var num=$(_12).find("input.pagination-num"); num.val(_13.pageNumber); num.parent().next().find("span").html(_13.afterPageText.replace(/{pages}/,_14)); var _15=_13.displayMsg; _15=_15.replace(/{from}/,_13.pageSize*(_13.pageNumber-1)+1); _15=_15.replace(/{to}/,Math.min(_13.pageSize*(_13.pageNumber),_13.total)); _15=_15.replace(/{total}/,_13.total); $(_12).find(".pagination-info").html(_15); $("a[icon=pagination-first],a[icon=pagination-prev]",_12).linkbutton({disabled:(_13.pageNumber==1)}); $("a[icon=pagination-next],a[icon=pagination-last]",_12).linkbutton({disabled:(_13.pageNumber==_14)}); if(_13.loading){ $(_12).find("a[icon=pagination-load]").find(".pagination-load").addClass("pagination-loading"); }else{ $(_12).find("a[icon=pagination-load]").find(".pagination-load").removeClass("pagination-loading"); } }; function _16(_17,_18){ var _19=$.data(_17,"pagination").options; _19.loading=_18; if(_19.loading){ $(_17).find("a[icon=pagination-load]").find(".pagination-load").addClass("pagination-loading"); }else{ $(_17).find("a[icon=pagination-load]").find(".pagination-load").removeClass("pagination-loading"); } }; $.fn.pagination=function(_1a,_1b){ if(typeof _1a=="string"){ return $.fn.pagination.methods[_1a](this,_1b); } _1a=_1a||{}; return this.each(function(){ var _1c; var _1d=$.data(this,"pagination"); if(_1d){ _1c=$.extend(_1d.options,_1a); }else{ _1c=$.extend({},$.fn.pagination.defaults,_1a); $.data(this,"pagination",{options:_1c}); } _1(this); _11(this); }); }; $.fn.pagination.methods={options:function(jq){ return $.data(jq[0],"pagination").options; },loading:function(jq){ return jq.each(function(){ _16(this,true); }); },loaded:function(jq){ return jq.each(function(){ _16(this,false); }); }}; $.fn.pagination.defaults={total:1,pageSize:10,pageNumber:1,pageList:[10,20,30,50],loading:false,buttons:null,showPageList:true,showRefresh:true,onSelectPage:function(_1e,_1f){ },onBeforeRefresh:function(_20,_21){ },onRefresh:function(_22,_23){ },onChangePageSize:function(_24){ },beforePageText:"Page",afterPageText:"of {pages}",displayMsg:"Displaying {from} to {to} of {total} items"}; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.pagination.js
JavaScript
asf20
6,205
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ var _3=$.data(_2,"timespinner").options; $(_2).spinner(_3); $(_2).unbind(".timespinner"); $(_2).bind("click.timespinner",function(){ var _4=0; if(this.selectionStart!=null){ _4=this.selectionStart; }else{ if(this.createTextRange){ var _5=_2.createTextRange(); var s=document.selection.createRange(); s.setEndPoint("StartToStart",_5); _4=s.text.length; } } if(_4>=0&&_4<=2){ _3.highlight=0; }else{ if(_4>=3&&_4<=5){ _3.highlight=1; }else{ if(_4>=6&&_4<=8){ _3.highlight=2; } } } _7(_2); }).bind("blur.timespinner",function(){ _6(_2); }); }; function _7(_8){ var _9=$.data(_8,"timespinner").options; var _a=0,_b=0; if(_9.highlight==0){ _a=0; _b=2; }else{ if(_9.highlight==1){ _a=3; _b=5; }else{ if(_9.highlight==2){ _a=6; _b=8; } } } if(_8.selectionStart!=null){ _8.setSelectionRange(_a,_b); }else{ if(_8.createTextRange){ var _c=_8.createTextRange(); _c.collapse(); _c.moveEnd("character",_b); _c.moveStart("character",_a); _c.select(); } } $(_8).focus(); }; function _d(_e,_f){ var _10=$.data(_e,"timespinner").options; if(!_f){ return null; } var vv=_f.split(_10.separator); for(var i=0;i<vv.length;i++){ if(isNaN(vv[i])){ return null; } } while(vv.length<3){ vv.push(0); } return new Date(1900,0,0,vv[0],vv[1],vv[2]); }; function _6(_11){ var _12=$.data(_11,"timespinner").options; var _13=$(_11).val(); var _14=_d(_11,_13); if(!_14){ _14=_d(_11,_12.value); } if(!_14){ _12.value=""; $(_11).val(""); return; } var _15=_d(_11,_12.min); var _16=_d(_11,_12.max); if(_15&&_15>_14){ _14=_15; } if(_16&&_16<_14){ _14=_16; } var tt=[_17(_14.getHours()),_17(_14.getMinutes())]; if(_12.showSeconds){ tt.push(_17(_14.getSeconds())); } var val=tt.join(_12.separator); _12.value=val; $(_11).val(val); function _17(_18){ return (_18<10?"0":"")+_18; }; }; function _19(_1a,_1b){ var _1c=$.data(_1a,"timespinner").options; var val=$(_1a).val(); if(val==""){ val=[0,0,0].join(_1c.separator); } var vv=val.split(_1c.separator); for(var i=0;i<vv.length;i++){ vv[i]=parseInt(vv[i],10); } if(_1b==true){ vv[_1c.highlight]-=_1c.increment; }else{ vv[_1c.highlight]+=_1c.increment; } $(_1a).val(vv.join(_1c.separator)); _6(_1a); _7(_1a); }; $.fn.timespinner=function(_1d,_1e){ if(typeof _1d=="string"){ var _1f=$.fn.timespinner.methods[_1d]; if(_1f){ return _1f(this,_1e); }else{ return this.spinner(_1d,_1e); } } _1d=_1d||{}; return this.each(function(){ var _20=$.data(this,"timespinner"); if(_20){ $.extend(_20.options,_1d); }else{ $.data(this,"timespinner",{options:$.extend({},$.fn.timespinner.defaults,$.fn.timespinner.parseOptions(this),_1d)}); _1(this); } }); }; $.fn.timespinner.methods={options:function(jq){ var _21=$.data(jq[0],"timespinner").options; return $.extend(_21,{value:jq.val()}); },setValue:function(jq,_22){ return jq.each(function(){ $(this).val(_22); _6(this); }); },getHours:function(jq){ var _23=$.data(jq[0],"timespinner").options; var vv=jq.val().split(_23.separator); return parseInt(vv[0],10); },getMinutes:function(jq){ var _24=$.data(jq[0],"timespinner").options; var vv=jq.val().split(_24.separator); return parseInt(vv[1],10); },getSeconds:function(jq){ var _25=$.data(jq[0],"timespinner").options; var vv=jq.val().split(_25.separator); return parseInt(vv[2],10)||0; }}; $.fn.timespinner.parseOptions=function(_26){ var t=$(_26); return $.extend({},$.fn.spinner.parseOptions(_26),{separator:t.attr("separator"),showSeconds:(t.attr("showSeconds")?t.attr("showSeconds")=="true":undefined),highlight:(parseInt(t.attr("highlight"))||undefined)}); }; $.fn.timespinner.defaults=$.extend({},$.fn.spinner.defaults,{separator:":",showSeconds:false,highlight:0,spin:function(_27){ _19(this,_27); }}); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.timespinner.js
JavaScript
asf20
3,842
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($) { function _1(_2) { var _3 = $.data(_2, "treegrid").options; $(_2).datagrid($.extend({}, _3, { url : null, onLoadSuccess : function() { }, onResizeColumn : function(_4, _5) { _14(_2); _3.onResizeColumn.call(_2, _4, _5); }, onSortColumn : function(_6, _7) { _3.sortName = _6; _3.sortOrder = _7; if (_3.remoteSort) { _13(_2); } else { var _8 = $(_2).treegrid("getData"); _3b(_2, 0, _8); } _3.onSortColumn.call(_2, _6, _7); }, onBeforeEdit : function(_9, _a) { if (_3.onBeforeEdit.call(_2, _a) == false) { return false; } }, onAfterEdit : function(_b, _c, _d) { _28(_2); _3.onAfterEdit.call(_2, _c, _d); }, onCancelEdit : function(_e, _f) { _28(_2); _3.onCancelEdit.call(_2, _f); } })); if (_3.pagination) { var _10 = $(_2).datagrid("getPager"); _10.pagination({ pageNumber : _3.pageNumber, pageSize : _3.pageSize, pageList : _3.pageList, onSelectPage : function(_11, _12) { _3.pageNumber = _11; _3.pageSize = _12; _13(_2); } }); _3.pageSize = _10.pagination("options").pageSize; } }; function _14(_15, _16) { var _17 = $.data(_15, "datagrid").options; var _18 = $.data(_15, "datagrid").panel; var _19 = _18.children("div.datagrid-view"); var _1a = _19.children("div.datagrid-view1"); var _1b = _19.children("div.datagrid-view2"); if (_17.rownumbers || (_17.frozenColumns && _17.frozenColumns.length > 0)) { if (_16) { _1c(_16); _1b.find("tr[node-id=" + _16 + "]").next("tr.treegrid-tr-tree") .find("tr[node-id]").each(function() { _1c($(this).attr("node-id")); }); } else { _1b.find("tr[node-id]").each(function() { _1c($(this).attr("node-id")); }); if (_17.showFooter) { var _1d = $.data(_15, "datagrid").footer || []; for (var i = 0; i < _1d.length; i++) { _1c(_1d[i][_17.idField]); } $(_15).datagrid("resize"); } } } if (_17.height == "auto") { var _1e = _1a.children("div.datagrid-body"); var _1f = _1b.children("div.datagrid-body"); var _20 = 0; var _21 = 0; _1f.children().each(function() { var c = $(this); if (c.is(":visible")) { _20 += c.outerHeight(); if (_21 < c.outerWidth()) { _21 = c.outerWidth(); } } }); if (_21 > _1f.width()) { _20 += 18; } _1e.height(_20); _1f.height(_20); _19.height(_1b.height()); } _1b.children("div.datagrid-body").triggerHandler("scroll"); function _1c(_22) { var tr1 = _1a.find("tr[node-id=" + _22 + "]"); var tr2 = _1b.find("tr[node-id=" + _22 + "]"); tr1.css("height", ""); tr2.css("height", ""); var _23 = Math.max(tr1.height(), tr2.height()); tr1.css("height", _23); tr2.css("height", _23); }; }; function _24(_25) { var _26 = $.data(_25, "treegrid").options; if (!_26.rownumbers) { return; } $(_25) .datagrid("getPanel") .find("div.datagrid-view1 div.datagrid-body div.datagrid-cell-rownumber") .each(function(i) { var _27 = i + 1; $(this).html(_27); }); }; function _28(_29) { var _2a = $.data(_29, "treegrid").options; var _2b = $(_29).datagrid("getPanel"); var _2c = _2b.find("div.datagrid-body"); _2c.find("span.tree-hit").unbind(".treegrid").bind("click.treegrid", function() { var tr = $(this).parent().parent().parent(); var id = tr.attr("node-id"); _94(_29, id); return false; }).bind("mouseenter.treegrid", function() { if ($(this).hasClass("tree-expanded")) { $(this).addClass("tree-expanded-hover"); } else { $(this).addClass("tree-collapsed-hover"); } }).bind("mouseleave.treegrid", function() { if ($(this).hasClass("tree-expanded")) { $(this).removeClass("tree-expanded-hover"); } else { $(this).removeClass("tree-collapsed-hover"); } }); _2c.find("tr[node-id]").unbind(".treegrid").bind("mouseenter.treegrid", function() { var id = $(this).attr("node-id"); _2c.find("tr[node-id=" + id + "]") .addClass("datagrid-row-over"); }).bind("mouseleave.treegrid", function() { var id = $(this).attr("node-id"); _2c.find("tr[node-id=" + id + "]").removeClass("datagrid-row-over"); }).bind("click.treegrid", function() { var id = $(this).attr("node-id"); if (_2a.singleSelect) { _2f(_29); _7e(_29, id); } else { if ($(this).hasClass("datagrid-row-selected")) { _82(_29, id); } else { _7e(_29, id); } } // //dnd zzy+ // var uuid = $(this).attr("uuid"); // if(!_2a[uuid]){ // alert(uuid); // initDD($(this).parent().children()); // _2a[uuid] = true; // } // // function initDD(target){ // alert(target.length) // var indicator = $('<div class="indicator">>></div>').appendTo('body'); // target.draggable({ // revert:true, // deltaX:0, // deltaY:0 // }).droppable({ // onDragOver:function(e,source){ // indicator.css({ // display:'block', // top:$(this).offset().top+$(this).outerHeight()-5 // }); // }, // onDragLeave:function(e,source){ // indicator.hide(); // }, // onDrop:function(e,source){ // $(source).insertAfter(this); // indicator.hide(); // } // }); // } _2a.onClickRow.call(_29, _46(_29, id)); _2a.onSelect.call(_29, _46(_29, id)); }).bind("dblclick.treegrid", function() { var id = $(this).attr("node-id"); _2a.onDblClickRow.call(_29, _46(_29, id)); }).bind("contextmenu.treegrid", function(e) { var id = $(this).attr("node-id"); _2a.onContextMenu.call(_29, e, _46(_29, id)); }); _2c.find("div.datagrid-cell-check input[type=checkbox]") .unbind(".treegrid").bind("click.treegrid", function(e) { var id = $(this).parent().parent().parent().attr("node-id"); if (_2a.singleSelect) { _2f(_29); _7e(_29, id); } else { if ($(this).attr("checked")) { _7e(_29, id); } else { _82(_29, id); } } e.stopPropagation(); }); var _2d = _2b.find("div.datagrid-header"); _2d.find("input[type=checkbox]").unbind().bind("click.treegrid", function() { if (_2a.singleSelect) { return false; } if ($(this).attr("checked")) { _2e(_29); } else { _2f(_29); } }); }; function _30(_31, _32) { var _33 = $.data(_31, "treegrid").options; var _34 = $(_31).datagrid("getPanel").children("div.datagrid-view"); var _35 = _34.children("div.datagrid-view1"); var _36 = _34.children("div.datagrid-view2"); var tr1 = _35.children("div.datagrid-body").find("tr[node-id=" + _32 + "]"); var tr2 = _36.children("div.datagrid-body").find("tr[node-id=" + _32 + "]"); var _37 = $(_31).datagrid("getColumnFields", true).length + (_33.rownumbers ? 1 : 0); var _38 = $(_31).datagrid("getColumnFields", false).length; _39(tr1, _37); _39(tr2, _38); function _39(tr, _3a) { $("<tr class=\"treegrid-tr-tree\">" + "<td style=\"border:0px\" colspan=\"" + _3a + "\">" + "<div></div>" + "</td>" + "</tr>").insertAfter(tr); }; }; /** * 处理数据,渲染组件 */ function _3b(_3c, _3d, _3e/*渲染值*/, _3f) { var _40 = $.data(_3c, "treegrid").options; _3e = _40.loadFilter.call(_3c, _3e, _3d); var _41 = $.data(_3c, "datagrid").panel; var _42 = _41.children("div.datagrid-view"); var _43 = _42.children("div.datagrid-view1"); var _44 = _42.children("div.datagrid-view2"); var _45 = _46(_3c, _3d); if (_45) { var _47 = _43.children("div.datagrid-body").find("tr[node-id=" + _3d + "]"); var _48 = _44.children("div.datagrid-body").find("tr[node-id=" + _3d + "]"); var cc1 = _47.next("tr.treegrid-tr-tree").children("td") .children("div"); var cc2 = _48.next("tr.treegrid-tr-tree").children("td") .children("div"); } else { var cc1 = _43.children("div.datagrid-body") .children("div.datagrid-body-inner"); var cc2 = _44.children("div.datagrid-body"); } if (!_3f) { $.data(_3c, "treegrid").data = []; cc1.empty(); cc2.empty(); } if (_40.view.onBeforeRender) { _40.view.onBeforeRender.call(_40.view, _3c, _3d, _3e); } _40.view.render.call(_40.view, _3c, cc1, true); _40.view.render.call(_40.view, _3c, cc2, false); if (_40.showFooter) { _40.view.renderFooter.call(_40.view, _3c, _43 .find("div.datagrid-footer-inner"), true); _40.view.renderFooter.call(_40.view, _3c, _44 .find("div.datagrid-footer-inner"), false); } if (_40.view.onAfterRender) { _40.view.onAfterRender.call(_40.view, _3c); } _40.onLoadSuccess.call(_3c, _45, _3e); if (!_3d && _40.pagination) { // 分页信息加载 var _49 = $.data(_3c, "treegrid").total; var _4a = $(_3c).datagrid("getPager"); if (_4a.pagination("options").total != _49) { _4a.pagination({ total : _49 }); } } _14(_3c); _24(_3c); _4b(); _28(_3c); function _4b() { var _4c = _42.find("div.datagrid-header"); var _4d = _42.find("div.datagrid-body"); var _4e = _4c.find("div.datagrid-header-check"); if (_4e.length) { var ck = _4d.find("div.datagrid-cell-check"); if ($.boxModel) { ck.width(_4e.width()); ck.height(_4e.height()); } else { ck.width(_4e.outerWidth()); ck.height(_4e.outerHeight()); } } }; //zzy+ 对于expand:true的行进行扩展 if(_3e['rows']){ var rows = _3e['rows']; var idField = _40['idField']; for (var index = 0; index < rows.length; index++) { var row = rows[index]; if(row['expand'] == true){ $(_3c).treegrid('expand', row[idField]); } } } }; // ajax请求 ==> 加载数据 function _13(_4f, _50, _51, _52, _53) { var _54 = $.data(_4f, "treegrid").options; var _55 = $(_4f).datagrid("getPanel").find("div.datagrid-body"); // zzy+ 动态参数修改 // if (_51) { // _54.queryParams = _51; // } _54.queryParams = _54.queryParams || {}; var param = $.isFunction(_54.queryParams) ? _54.queryParams() : _54.queryParams; // var _56 = $.extend({}, _54.queryParams); var _56 = $.extend( _51||{}, param||{}); // 如果第一次加载,并且有root,则直接渲染数据 if(_51== null && $.isObject(_54['root'])){ _3b(_4f, _50, {rows:[_54['root']]}, _52); return; } if (_54.pagination) { $.extend(_56, { page : _54.pageNumber, rows : _54.pageSize }); } if (_54.sortName) { $.extend(_56, { sort : _54.sortName, order : _54.sortOrder }); } var row = _46(_4f, _50); if (_54.onBeforeLoad.call(_4f, row, _56) == false) { return; } /*if (!_54.url) { return; }*/ var _57 = _55.find("tr[node-id=" + _50 + "] span.tree-folder"); _57.addClass("tree-loading"); $(_4f).treegrid("loading"); // zzy+ 用通用的ajax组件$.query $.query(_54.list, _56, function(_58){ _58 = $.decode(_58); // zzy+ 是个BUG if(_56 && $.isArray(_58['rows'])){ var rows = _58['rows']; for (var index = 0; index < rows.length; index++) { var row = rows[index]; // 遍历加载的数据 _54.eachLoadData.call(_4f, row, index); if(!row['iconCls']){ row['iconCls'] = 'icon-tree-folder'; } if(!row['parentId']){ row['parentId'] = _56[_54['idField']]; } if(!row['state']){ row['state'] = 'closed'; } row['checkbox'] = true; } } _57.removeClass("tree-loading"); $(_4f).treegrid("loaded"); _3b(_4f, _50, _58, _52); if (_53) { _53(); } },function() { _57.removeClass("tree-loading"); $(_4f).treegrid("loaded"); _54.onLoadError.apply(_4f, arguments); if (_53) { _53(); } }); // $.ajax({ // type : _54.method, // url : _54.url, // data : _56, // dataType : "json", // success : function(_58) { // _58 = $.decode(_58); // zzy+ 是个BUG // _57.removeClass("tree-loading"); // $(_4f).treegrid("loaded"); // _3b(_4f, _50, _58, _52); // if (_53) { // _53(); // } // }, // error : function() { // _57.removeClass("tree-loading"); // $(_4f).treegrid("loaded"); // _54.onLoadError.apply(_4f, arguments); // if (_53) { // _53(); // } // } // }); }; function _59(_5a) { var _5b = _5c(_5a); if (_5b.length) { return _5b[0]; } else { return null; } }; function _5c(_5d) { return $.data(_5d, "treegrid").data; }; /** * 获取父节点的id */ // function processRow(jq, row){ // // 如果没有配置,则默认使用_parentId属性 // if(!$.isEmpty(row['_parentId'])){ // return row // }; // // var parentField = $.data(jq, "treegrid").options['parentField']; // // // 如果字段是对象形式,则获取 // if(parentField.indexOf('.')!=-1){ // // }else{ // row['_parentId'] = row[parentField]; // } // // // if($.isObject(row[parentField])){ // row['_parentId'] = $.beanVal(row[parentField], ); // }else{ // row['_parentId'] = row[parentField]; // } // // // return row; // } function _5e(_5f, _60) { var row = _46(_5f, _60); if (row.parentId) { return _46(_5f, row.parentId); } else { return null; } }; function _61(_62, _63) { var _64 = $.data(_62, "treegrid").options; var _65 = $(_62).datagrid("getPanel") .find("div.datagrid-view2 div.datagrid-body"); var _66 = []; if (_63) { _67(_63); } else { var _68 = _5c(_62); for (var i = 0; i < _68.length; i++) { _66.push(_68[i]); _67(_68[i][_64.idField]); } } function _67(_69) { var _6a = _46(_62, _69); if (_6a && _6a.children) { for (var i = 0, len = _6a.children.length; i < len; i++) { var _6b = _6a.children[i]; _66.push(_6b); _67(_6b[_64.idField]); } } }; return _66; }; function _6c(_6d) { var _6e = _6f(_6d); if (_6e.length) { return _6e[0]; } else { return null; } }; function _6f(_70) { var _71 = []; var _72 = $(_70).datagrid("getPanel"); _72 .find("div.datagrid-view2 div.datagrid-body tr.datagrid-row-selected") .each(function() { var id = $(this).attr("node-id"); _71.push(_46(_70, id)); }); return _71; }; function _73(_74, _75) { if (!_75) { return 0; } var _76 = $.data(_74, "treegrid").options; var _77 = $(_74).datagrid("getPanel").children("div.datagrid-view"); var _78 = _77.find("div.datagrid-body tr[node-id=" + _75 + "]") .children("td[field=" + _76.treeField + "]"); return _78.find("span.tree-indent,span.tree-hit").length; }; function _46(_79, _7a) { var _7b = $.data(_79, "treegrid").options; var _7c = $.data(_79, "treegrid").data; var cc = [_7c]; while (cc.length) { var c = cc.shift(); for (var i = 0; i < c.length; i++) { var _7d = c[i]; if (_7d[_7b.idField] == _7a) { return _7d; } else { if (_7d["children"]) { cc.push(_7d["children"]); } } } } return null; }; function _7e(_7f, _80) { var _81 = $(_7f).datagrid("getPanel").find("div.datagrid-body"); var tr = _81.find("tr[node-id=" + _80 + "]"); tr.addClass("datagrid-row-selected"); tr.find("div.datagrid-cell-check input[type=checkbox]").attr("checked", true); }; function _82(_83, _84) { var _85 = $(_83).datagrid("getPanel").find("div.datagrid-body"); var tr = _85.find("tr[node-id=" + _84 + "]"); tr.removeClass("datagrid-row-selected"); tr.find("div.datagrid-cell-check input[type=checkbox]").attr("checked", false); }; function _2e(_86) { var tr = $(_86).datagrid("getPanel") .find("div.datagrid-body tr[node-id]"); tr.addClass("datagrid-row-selected"); tr.find("div.datagrid-cell-check input[type=checkbox]").attr("checked", true); }; function _2f(_87) { var tr = $(_87).datagrid("getPanel") .find("div.datagrid-body tr[node-id]"); tr.removeClass("datagrid-row-selected"); tr.find("div.datagrid-cell-check input[type=checkbox]").attr("checked", false); }; function _88(_89, _8a) { var _8b = $.data(_89, "treegrid").options; var _8c = $(_89).datagrid("getPanel").find("div.datagrid-body"); var row = _46(_89, _8a); var tr = _8c.find("tr[node-id=" + _8a + "]"); var hit = tr.find("span.tree-hit"); if (hit.length == 0) { return; } if (hit.hasClass("tree-collapsed")) { return; } if (_8b.onBeforeCollapse.call(_89, row) == false) { return; } hit.removeClass("tree-expanded tree-expanded-hover") .addClass("tree-collapsed"); hit.next().removeClass("tree-folder-open"); row.state = "closed"; tr = tr.next("tr.treegrid-tr-tree"); var cc = tr.children("td").children("div"); if (_8b.animate) { cc.slideUp("normal", function() { _14(_89, _8a); _8b.onCollapse.call(_89, row); }); } else { cc.hide(); _14(_89, _8a); _8b.onCollapse.call(_89, row); } }; function _8d(_8e, _8f) { var _90 = $.data(_8e, "treegrid").options; var _91 = $(_8e).datagrid("getPanel").find("div.datagrid-body"); var tr = _91.find("tr[node-id=" + _8f + "]"); var hit = tr.find("span.tree-hit"); var row = _46(_8e, _8f); if (hit.length == 0) { return; } if (hit.hasClass("tree-expanded")) { return; } if (_90.onBeforeExpand.call(_8e, row) == false) { return; } hit.removeClass("tree-collapsed tree-collapsed-hover") .addClass("tree-expanded"); hit.next().addClass("tree-folder-open"); var _92 = tr.next("tr.treegrid-tr-tree"); if (_92.length) { var cc = _92.children("td").children("div"); _93(cc); } else { _30(_8e, row[_90.idField]); var _92 = tr.next("tr.treegrid-tr-tree"); var cc = _92.children("td").children("div"); cc.hide(); _13(_8e, row[_90.idField], { id : row[_90.idField] }, true, function() { _93(cc); }); } function _93(cc) { row.state = "open"; if (_90.animate) { cc.slideDown("normal", function() { _14(_8e, _8f); _90.onExpand.call(_8e, row); }); } else { cc.show(); _14(_8e, _8f); _90.onExpand.call(_8e, row); } }; }; function _94(_95, _96) { var _97 = $(_95).datagrid("getPanel").find("div.datagrid-body"); var tr = _97.find("tr[node-id=" + _96 + "]"); var hit = tr.find("span.tree-hit"); if (hit.hasClass("tree-expanded")) { _88(_95, _96); } else { _8d(_95, _96); } }; function _98(_99, _9a) { var _9b = $.data(_99, "treegrid").options; var _9c = _61(_99, _9a); if (_9a) { _9c.unshift(_46(_99, _9a)); } for (var i = 0; i < _9c.length; i++) { _88(_99, _9c[i][_9b.idField]); } }; function _9d(_9e, _9f) { var _a0 = $.data(_9e, "treegrid").options; var _a1 = _61(_9e, _9f); if (_9f) { _a1.unshift(_46(_9e, _9f)); } for (var i = 0; i < _a1.length; i++) { _8d(_9e, _a1[i][_a0.idField]); } }; function _a2(_a3, _a4) { var _a5 = $.data(_a3, "treegrid").options; var ids = []; var p = _5e(_a3, _a4); while (p) { var id = p[_a5.idField]; ids.unshift(id); p = _5e(_a3, id); } for (var i = 0; i < ids.length; i++) { _8d(_a3, ids[i]); } }; function _a6(_a7, _a8) { var _a9 = $.data(_a7, "treegrid").options; if (_a8.parent) { var _aa = $(_a7).datagrid("getPanel").find("div.datagrid-body"); var tr = _aa.find("tr[node-id=" + _a8.parent + "]"); if (tr.next("tr.treegrid-tr-tree").length == 0) { _30(_a7, _a8.parent); } var _ab = tr.children("td[field=" + _a9.treeField + "]") .children("div.datagrid-cell"); var _ac = _ab.children("span.tree-icon"); if (_ac.hasClass("tree-file")) { _ac.removeClass("tree-file").addClass("tree-folder"); var hit = $("<span class=\"tree-hit tree-expanded\"></span>") .insertBefore(_ac); if (hit.prev().length) { hit.prev().remove(); } } } _3b(_a7, _a8.parent, _a8.data, true); }; function _ad(_ae, _af) { var _b0 = $.data(_ae, "treegrid").options; var _b1 = $(_ae).datagrid("getPanel").find("div.datagrid-body"); var tr = _b1.find("tr[node-id=" + _af + "]"); tr.next("tr.treegrid-tr-tree").remove(); tr.remove(); var _b2 = del(_af); if (_b2) { if (_b2.children.length == 0) { tr = _b1.find("tr[node-id=" + _b2[_b0.treeField] + "]"); var _b3 = tr.children("td[field=" + _b0.treeField + "]") .children("div.datagrid-cell"); _b3.find(".tree-icon").removeClass("tree-folder") .addClass("tree-file"); _b3.find(".tree-hit").remove(); $("<span class=\"tree-indent\"></span>").prependTo(_b3); } } _24(_ae); function del(id) { var cc; var _b4 = _5e(_ae, _af); if (_b4) { cc = _b4.children; } else { cc = $(_ae).treegrid("getData"); } for (var i = 0; i < cc.length; i++) { if (cc[i][_b0.treeField] == id) { cc.splice(i, 1); break; } } return _b4; }; }; /** * 初始化,构造方法 */ $.fn.treegrid = function(_b5, _b6) { var isFirstRender = false; if (typeof _b5 == "string") { var _b7 = $.fn.treegrid.methods[_b5]; if (_b7) { return _b7(this, _b6); } else { return this.datagrid(_b5, _b6); } } _b5 = _b5 || {}; //zzy+ 选中即扩展行 $.extend(_b5,{ onDblClickRow: function(){ // 获取选中的节点 var node = $(this).treegrid('getSelected'); // 扩展当中选中行 $(this).treegrid('expand', node.id); } }); // 设置CRUD的相关url $.createURL(_b5); return this.each(function() { var _b8 = $.data(this, "treegrid"); if (_b8) { $.extend(_b8.options, _b5); } else { isFirstRender = true; var opts = $.extend({}, $.fn.treegrid.defaults, $.fn.treegrid.parseOptions(this), _b5); //zzy+ $.createURL(opts); $.data(this, "treegrid", { options : opts, data : [] }); } var opts=null; if(opts=$.data(this, "treegrid").options){ if(isFirstRender){ _1(this); } // 是否自动 if(opts['autoLoad'] !== false){ _13(this); } } }); }; $.fn.treegrid.methods = { options : function(jq) { return $.data(jq[0], "treegrid").options; }, resize : function(jq, _b9) { return jq.each(function() { $(this).datagrid("resize", _b9); }); }, fixRowHeight : function(jq, _ba) { return jq.each(function() { _14(this, _ba); }); }, loadData : function(jq, _bb) { return jq.each(function() { _3b(this, null, _bb); }); }, reload : function(jq, id) { return jq.each(function() { if (!$.isEmpty(id)) { var _bc = $(this).treegrid("find", id); if (_bc.children) { _bc.children.splice(0, _bc.children.length); } var _bd = $(this).datagrid("getPanel") .find("div.datagrid-body"); var tr = _bd.find("tr[node-id=" + id + "]"); tr.next("tr.treegrid-tr-tree").remove(); var hit = tr.find("span.tree-hit"); hit.removeClass("tree-expanded tree-expanded-hover") .addClass("tree-collapsed"); _8d(this, id); } else { _13(this, null, {}); } }); }, reloadFooter : function(jq, _be) { return jq.each(function() { var _bf = $.data(this, "treegrid").options; var _c0 = $(this).datagrid("getPanel") .children("div.datagrid-view"); var _c1 = _c0.children("div.datagrid-view1"); var _c2 = _c0.children("div.datagrid-view2"); if (_be) { $.data(this, "treegrid").footer = _be; } if (_bf.showFooter) { _bf.view.renderFooter.call(_bf.view, this, _c1 .find("div.datagrid-footer-inner"), true); _bf.view.renderFooter.call(_bf.view, this, _c2 .find("div.datagrid-footer-inner"), false); if (_bf.view.onAfterRender) { _bf.view.onAfterRender.call(_bf.view, this); } $(this).treegrid("fixRowHeight"); } }); }, loading : function(jq) { return jq.each(function() { $(this).datagrid("loading"); }); }, loaded : function(jq) { return jq.each(function() { $(this).datagrid("loaded"); }); }, getData : function(jq) { return $.data(jq[0], "treegrid").data; }, getFooterRows : function(jq) { return $.data(jq[0], "treegrid").footer; }, getRoot : function(jq) { return _59(jq[0]); }, getRoots : function(jq) { return _5c(jq[0]); }, getParent : function(jq, id) { return _5e(jq[0], id); }, getChildren : function(jq, id) { return _61(jq[0], id); }, getSelected : function(jq) { return _6c(jq[0]); }, getSelections : function(jq) { return _6f(jq[0]); }, getLevel : function(jq, id) { return _73(jq[0], id); }, find : function(jq, id) { return _46(jq[0], id); }, isLeaf : function(jq, id) { var _c3 = $.data(jq[0], "treegrid").options; var tr = _c3.editConfig.getTr(jq[0], id); var hit = tr.find("span.tree-hit"); return hit.length == 0; }, select : function(jq, id) { return jq.each(function() { _7e(this, id); }); }, unselect : function(jq, id) { return jq.each(function() { _82(this, id); }); }, selectAll : function(jq) { return jq.each(function() { _2e(this); }); }, unselectAll : function(jq) { return jq.each(function() { _2f(this); }); }, collapse : function(jq, id) { return jq.each(function() { _88(this, id); }); }, expand : function(jq, id) { return jq.each(function() { _8d(this, id); }); }, toggle : function(jq, id) { return jq.each(function() { _94(this, id); }); }, collapseAll : function(jq, id) { return jq.each(function() { _98(this, id); }); }, expandAll : function(jq, id) { return jq.each(function() { _9d(this, id); }); }, expandTo : function(jq, id) { return jq.each(function() { _a2(this, id); }); }, append : function(jq, _c4) { return jq.each(function() { _a6(this, _c4); }); }, remove : function(jq, id) { return jq.each(function() { _ad(this, id); }); }, refresh : function(jq, id) { return jq.each(function() { var _c5 = $.data(this, "treegrid").options; _c5.view.refreshRow.call(_c5.view, this, id); }); }, beginEdit : function(jq, id) { return jq.each(function() { $(this).datagrid("beginEdit", id); $(this).treegrid("fixRowHeight", id); }); }, endEdit : function(jq, id) { return jq.each(function() { $(this).datagrid("endEdit", id); }); }, cancelEdit : function(jq, id) { return jq.each(function() { $(this).datagrid("cancelEdit", id); }); } }; $.fn.treegrid.parseOptions = function(_c6) { var t = $(_c6); var cfg = $.extend({}, $.fn.datagrid.parseOptions(_c6), { treeField : t.attr("treeField"), animate : (t.attr("animate") ? t.attr("animate") == "true" : undefined), root: t.attr("root")? $.decode(t.attr("root")) : null, //zzy+ autoLoad: t.attr("autoLoad")? $.decode(t.attr("autoLoad")) : null, //zzy+ list: t.attr("list")? $.decode(t.attr("list")) : null, //zzy+ save: t.attr("save")? $.decode(t.attr("save")) : null, //zzy+ remove: t.attr("remove")? $.decode(t.attr("remove")) : null //zzy+ }); // 其他配置项 if(t.attr("other")){ cfg = $.extend(cfg, eval(t.attr("other"))); } // 查询参数 if(t.attr('queryParams')){ cfg['queryParams'] = eval(t.attr("queryParams")); } return cfg; }; var _c7 = $.extend({}, $.fn.datagrid.defaults.view, { render : function(_c8, _c9, _ca) { var _cb = $.data(_c8, "treegrid").options; var _cc = $(_c8).datagrid("getColumnFields", _ca); var _cd = this; var _ce = _cf(_ca, this.treeLevel, this.treeNodes); var ctEl = $(_ce.join("")); $(_c9).append(ctEl); // alert($.uuidVal()); // alert(ctEl.find('tr[node-id*=][uuid*=]').length); // var indicator = $('<div class="indicator">>></div>').appendTo('body'); // ctEl.find('tr[node-id*=][uuid*=]').draggable({ // revert:true, // deltaX:0, // deltaY:0 // }).droppable({ // onDragOver:function(e,source){ // indicator.css({ // display:'block', // top:$(this).offset().top+$(this).outerHeight()-5 // }); // }, // onDragLeave:function(e,source){ // indicator.hide(); // }, // onDrop:function(e,source){ // $(source).insertAfter(this); // indicator.hide(); // } // }); function _cf(_d0, _d1, _d2) { var uuid = $.uuidVal(); var _d3 = ["<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>"]; for (var i = 0; i < _d2.length; i++) { var row = _d2[i]; if (row.state != "open" && row.state != "closed") { row.state = "open"; } var _d4 = _cb.rowStyler ? _cb.rowStyler.call(_c8, row) : ""; var _d5 = _d4 ? "style=\"" + _d4 + "\"" : ""; _d3.push("<tr uuid="+uuid+" node-id=" + row[_cb.idField] + " " + _d5 + ">"); _d3 = _d3.concat(_cd.renderRow.call(_cd, _c8, _cc, _d0, _d1, row)); _d3.push("</tr>"); if (row.children && row.children.length) { var tt = _cf(_d0, _d1 + 1, row.children); var v = row.state == "closed" ? "none" : "block"; _d3 .push("<tr class=\"treegrid-tr-tree\"><td style=\"border:0px\" colspan=" + (_cc.length + (_cb.rownumbers ? 1 : 0)) + "><div style=\"display:" + v + "\">"); _d3 = _d3.concat(tt); _d3.push("</div></td></tr>"); } } _d3.push("</tbody></table>"); return _d3; }; }, renderFooter : function(_d6, _d7, _d8) { var _d9 = $.data(_d6, "treegrid").options; var _da = $.data(_d6, "treegrid").footer || []; var _db = $(_d6).datagrid("getColumnFields", _d8); var _dc = ["<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>"]; for (var i = 0; i < _da.length; i++) { var row = _da[i]; row[_d9.idField] = row[_d9.idField] || ("foot-row-id" + i); _dc.push("<tr node-id=" + row[_d9.idField] + ">"); _dc.push(this.renderRow.call(this, _d6, _db, _d8, 0, row)); _dc.push("</tr>"); } _dc.push("</tbody></table>"); $(_d7).html(_dc.join("")); }, renderRow : function(_dd, _de, _df, _e0, row) { var _e1 = $.data(_dd, "treegrid").options; var cc = []; if (_df && _e1.rownumbers) { cc .push("<td class=\"datagrid-td-rownumber\"><div class=\"datagrid-cell-rownumber\">0</div></td>"); } for (var i = 0; i < _de.length; i++) { var _e2 = _de[i]; var col = $(_dd).datagrid("getColumnOption", _e2); if (col) { var _e3 = col.styler ? (col.styler(row[_e2], row) || "") : ""; var _e4 = col.hidden ? "style=\"display:none;" + _e3 + "\"" : (_e3 ? "style=\"" + _e3 + "\"" : ""); cc.push("<td field=\"" + _e2 + "\" " + _e4 + ">"); var _e4 = "width:" + (col.boxWidth) + "px;"; _e4 += "text-align:" + (col.align || "left") + ";"; _e4 += _e1.nowrap == false ? "white-space:normal;" : ""; cc.push("<div style=\"" + _e4 + "\" "); if (col.checkbox) { cc.push("class=\"datagrid-cell-check "); } else { cc.push("class=\"datagrid-cell "); } cc.push("\">"); if (col.checkbox) { if (row.checked) { cc .push("<input type=\"checkbox\" checked=\"checked\"/>"); } else { cc.push("<input type=\"checkbox\"/>"); } } else { var val = null; if (col.formatter) { val = col.formatter(row[_e2], row); } else { val = row[_e2] || "&nbsp;"; } if (_e2 == _e1.treeField) { for (var j = 0; j < _e0; j++) { cc.push("<span class=\"tree-indent\"></span>"); } if (row.state == "closed") { cc .push("<span class=\"tree-hit tree-collapsed\"></span>"); cc.push("<span class=\"tree-icon tree-folder " + (row.iconCls ? row.iconCls : "") + "\"></span>"); } else { if (row.children && row.children.length) { cc .push("<span class=\"tree-hit tree-expanded\"></span>"); cc .push("<span class=\"tree-icon tree-folder tree-folder-open " + (row.iconCls ? row.iconCls : "") + "\"></span>"); } else { cc .push("<span class=\"tree-indent\"></span>"); cc .push("<span class=\"tree-icon tree-file " + (row.iconCls ? row.iconCls : "") + "\"></span>"); } } // cc.push("<span class=\"tree-checkbox tree-checkbox1\"></span>"); cc.push("<span class=\"tree-title\">" + val + "</span>"); } else { cc.push(val); } } cc.push("</div>"); cc.push("</td>"); } } return cc.join(""); }, refreshRow : function(_e5, id) { var row = $(_e5).treegrid("find", id); var _e6 = $.data(_e5, "treegrid").options; var _e7 = $(_e5).datagrid("getPanel").find("div.datagrid-body"); var _e8 = _e6.rowStyler ? _e6.rowStyler.call(_e5, row) : ""; var _e9 = _e8 ? _e8 : ""; var tr = _e7.find("tr[node-id=" + id + "]"); tr.attr("style", _e9); tr.children("td").each(function() { var _ea = $(this).find("div.datagrid-cell"); var _eb = $(this).attr("field"); var col = $(_e5).datagrid("getColumnOption", _eb); if (col) { var _ec = col.styler ? (col.styler(row[_eb], row) || "") : ""; var _ed = col.hidden ? "display:none;" + _ec : (_ec ? _ec : ""); $(this).attr("style", _ed); var val = null; if (col.formatter) { val = col.formatter(row[_eb], row); } else { val = row[_eb] || "&nbsp;"; } if (_eb == _e6.treeField) { _ea.children("span.tree-title").html(val); var cls = "tree-icon"; var _ee = _ea.children("span.tree-icon"); if (_ee.hasClass("tree-folder")) { cls += " tree-folder"; } if (_ee.hasClass("tree-folder-open")) { cls += " tree-folder-open"; } if (_ee.hasClass("tree-file")) { cls += " tree-file"; } if (row.iconCls) { cls += " " + row.iconCls; } _ee.attr("class", cls); } else { _ea.html(val); } } }); $(_e5).treegrid("fixRowHeight", id); }, onBeforeRender : function(_ef, _f0, _f1) { if (!_f1) { return false; } var _f2 = $.data(_ef, "treegrid").options; if (_f1.length == undefined) { if (_f1.footer) { $.data(_ef, "treegrid").footer = _f1.footer; } if (_f1.total) { $.data(_ef, "treegrid").total = _f1.total; } _f1 = this.transfer(_ef, _f0, _f1.rows); } else { function _f3(_f4, _f5) { for (var i = 0; i < _f4.length; i++) { var row = _f4[i]; row.parentId = _f5; if (row.children && row.children.length) { _f3(row.children, row[_f2.idField]); } } }; _f3(_f1, _f0); } var _f6 = _46(_ef, _f0); if (_f6) { if (_f6.children) { _f6.children = _f6.children.concat(_f1); } else { _f6.children = _f1; } } else { $.data(_ef, "treegrid").data = $.data(_ef, "treegrid").data .concat(_f1); } if (!_f2.remoteSort) { this.sort(_ef, _f1); } this.treeNodes = _f1; this.treeLevel = $(_ef).treegrid("getLevel", _f0); }, sort : function(_f7, _f8) { var _f9 = $.data(_f7, "treegrid").options; var opt = $(_f7).treegrid("getColumnOption", _f9.sortName); if (opt) { var _fa = opt.sorter || function(a, b) { return (a > b ? 1 : -1); }; _fb(_f8); } function _fb(_fc) { _fc.sort(function(r1, r2) { return _fa(r1[_f9.sortName], r2[_f9.sortName]) * (_f9.sortOrder == "asc" ? 1 : -1); }); for (var i = 0; i < _fc.length; i++) { var _fd = _fc[i].children; if (_fd && _fd.length) { _fb(_fd); } } }; }, transfer : function(_fe, _ff, data) { var opts = $.data(_fe, "treegrid").options; var rows = []; for (var i = 0; i < data.length; i++) { rows.push(data[i]); } var _100 = []; for (var i = 0; i < rows.length; i++) { var row = rows[i]; if (!_ff) { if (!row.parentId) { _100.push(row); rows.remove(row); i--; } } else { if (row.parentId == _ff) { _100.push(row); rows.remove(row); i--; } } } var toDo = []; for (var i = 0; i < _100.length; i++) { toDo.push(_100[i]); } while (toDo.length) { var node = toDo.shift(); for (var i = 0; i < rows.length; i++) { var row = rows[i]; if (row.parentId == node[opts.idField]) { if (node.children) { node.children.push(row); } else { node.children = [row]; } toDo.push(row); rows.remove(row); i--; } } } return _100; } }); $.fn.treegrid.defaults = $.extend({}, $.fn.datagrid.defaults, { treeField : null, animate : false, singleSelect : true, view : _c7, loadFilter : function(data, _101) { return data; }, editConfig : { getTr : function(_102, id) { return $(_102).datagrid("getPanel") .find("div.datagrid-body tr[node-id=" + id + "]"); }, getRow : function(_103, id) { return $(_103).treegrid("find", id); } }, onBeforeLoad : function(row, _104) { }, onLoadSuccess : function(row, data) { }, onLoadError : function() { }, onBeforeCollapse : function(row) { }, onCollapse : function(row) { }, onBeforeExpand : function(row) { }, onExpand : function(row) { }, onClickRow : function(row) { }, onSelect : function(row) { }, onDblClickRow : function(row) { }, onContextMenu : function(e, row) { }, onBeforeEdit : function(row) { }, onAfterEdit : function(row, _105) { }, onCancelEdit : function(row) { }, eachLoadData : function(row, index) { }// zzy+ 添加加载数据的值的遍历 }); })(jQuery); $.extend($.fn.treegrid.methods, { /** * 添加记录 * @param {} jq jq对象,在调用时看不见 * @param {} ops 操作参数,共分3种情况: * 第一种:为空,则添加一行默认空行 * 第二种: json对象,则添加一行指定记录 * 第三种:json数组,则添加多行指定记录 * 第四种:如:{ * rows: [{},{}], //json数组 * isEdit: false //不需要编辑 * callFun: function(target, rows){} * } */ 'add': function(jq, ops){ // 如果当前已经有文件正在编辑,则不可用 if(jq.treegrid('getEdittingId') != null){ $.msg.show({ title: '提示', msg:'当前有行正在编辑,请保存正在编辑的行后进行其他操作!' }); return; } var target = null; jq.each(function(){target = this;}); // 获取idField var idField = $.data(target, 'treegrid')['options']['idField']; // 如果为空,则默认添加 if(!ops){ var row = {}; ops = { rows: [{}] }; }else if($.isArray(ops)){ // 如果是json数组 ops = { rows: ops }; }else if(!(ops['rows'] && String(ops['isEdit']))){// 如果是json ops = { rows: [ops] }; } ops = $.extend({ rows: [], isEdit: true, callFun: function(){} }, ops); for (var index = 0; index < ops.rows.length; index++) { var row = ops.rows[index]; ops.rows[index] = $.extend({ iconCls: 'icon-ok', state: 'closed' }, ops.rows[index]); if(!ops.rows[index][idField]){ ops.rows[index][idField] = $.uuidVal(); } } // 获取选中的节点 var node = jq.treegrid('getSelected'); // // 展开该几点 // jq.treegrid('expand', node.id); // 添加节点 jq.treegrid('append', { parent: (node?node[idField]:null), data: ops['rows'] }); if(ops['isEdit']){ // 清除选中行 jq.treegrid('unselectAll'); // 选中当前添加的记录 jq.treegrid('select', ops['rows'][0][idField]); $.data(target, 'treegrid')['currentEdittingOldRow'] = ops['rows'][0]; $.data(target, 'treegrid')['currentEdittingId'] = ops['rows'][0][idField]; jq.treegrid('beginEdit',ops['rows'][0][idField]); } // 执行回调函数 ops['callFun'](target, ops['rows']); }, /** * 编辑 * @param jq jq对象,在调用时看不见 */ 'edit': function(jq){ // 如果当前已经有文件正在编辑,则不可用 if(jq.treegrid('getEdittingId') != null){ $.msg.show({ title: '提示', msg:'正在编辑,请保存正在编辑的行后进行其他操作!' }); return false; } var target = null; jq.each(function(){target = this}); var node = jq.treegrid('getSelected'); if (node){ $.data(target, 'treegrid')['currentEdittingOldRow'] = node; $.data(target, 'treegrid')['currentEdittingId'] = node[ $.data(target, 'treegrid')['options']['idField']]; jq.treegrid('beginEdit',node.id); } }, 'save': function(jq){ var target = null; jq.each(function(){target = this;}); var id = jq.treegrid('getEdittingId'); if(id == null){ $.msg.show({ title: '提示', msg:'没有需要保存的记录!' }); return false; } var row = jq.treegrid('getCurrRow', id); $.exec($.data(target, 'treegrid')['options']['save'], row, function(data){ $.msg.say("保存成功!"); // 停止编辑 jq.treegrid('endEdit', id); // 更新界面行记录 jq.treegrid('updateRow', data); $.data(target, 'treegrid')['currentEdittingOldRow'] = null; $.data(target, 'treegrid')['currentEdittingId'] = null; }); }, 'delete': function(jq){ var target = null; jq.each(function(){target = this;}); // 获取选中的节点 var node = jq.treegrid('getSelected'); if(node == null){ $.msg.say("没有选中要删除的记录,请确认!"); return; } // 获取idField var idField = $.data(target, 'treegrid')['options']['idField']; $.msg.confirm('询问', '是否删除当前选中记录?', function(r){ if (r){ $.exec($.data(target, 'treegrid')['options']['remove'], node, function(data){ $.msg.say("删除成功!"); $.data(target, 'treegrid')['currentEdittingOldRow'] = null; $.data(target, 'treegrid')['currentEdittingId'] = null; jq.treegrid("remove", data[idField]); }); } }); }, /** * 获取正在编辑的行节点 * @param jq jq对象,在调用时看不见 */ 'getEdittingId': function(jq){ var target = null; jq.each(function(){target = this;}); return $.data(target, 'treegrid')['currentEdittingId']; } });
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.treegrid.js
JavaScript
asf20
44,868
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($) { function _1(_2) { var _3 = $.data(_2, "combogrid").options; var _4 = $.data(_2, "combogrid").grid; $(_2).addClass("combogrid-f"); $(_2).combo(_3); var _5 = $(_2).combo("panel"); if (!_4) { _4 = $("<table></table>").appendTo(_5); $.data(_2, "combogrid").grid = _4; } _4.datagrid($.extend({}, _3, { border : false, fit : true, singleSelect : (!_3.multiple), onLoadSuccess : function(_6) { var _7 = $.data(_2, "combogrid").remainText; var _8 = $(_2).combo("getValues"); _1c(_2, _8, _7); _3.onLoadSuccess.apply(_2, arguments); }, onClickRow : _9, onSelect : function(_a, _b) { _c(); _3.onSelect.call(this, _a, _b); }, onUnselect : function(_d, _e) { _c(); _3.onUnselect.call(this, _d, _e); }, onSelectAll : function(_f) { _c(); _3.onSelectAll.call(this, _f); }, onUnselectAll : function(_10) { if (_3.multiple) { _c(); } _3.onUnselectAll.call(this, _10); } })); function _9(_11, row) { $.data(_2, "combogrid").remainText = false; _c(); if (!_3.multiple) { $(_2).combo("hidePanel"); } _3.onClickRow.call(this, _11, row); }; function _c() { var _12 = $.data(_2, "combogrid").remainText; var _13 = _4.datagrid("getSelections"); var vv = [], ss = []; for (var i = 0; i < _13.length; i++) { vv.push(_13[i][_3.idField]); ss.push(_13[i][_3.textField]); } if (!_3.multiple) { $(_2).combo("setValues", (vv.length ? vv : [""])); } else { $(_2).combo("setValues", vv); } if (!_12) { $(_2).combo("setText", ss.join(_3.separator)); } }; }; function _14(_15, _16) { var _17 = $.data(_15, "combogrid").options; var _18 = $.data(_15, "combogrid").grid; var _19 = _18.datagrid("getRows").length; $.data(_15, "combogrid").remainText = false; var _1a; var _1b = _18.datagrid("getSelections"); if (_1b.length) { _1a = _18.datagrid("getRowIndex", _1b[_1b.length - 1][_17.idField]); _1a += _16; if (_1a < 0) { _1a = 0; } if (_1a >= _19) { _1a = _19 - 1; } } else { if (_16 > 0) { _1a = 0; } else { if (_16 < 0) { _1a = _19 - 1; } else { _1a = -1; } } } if (_1a >= 0) { _18.datagrid("clearSelections"); _18.datagrid("selectRow", _1a); } }; function _1c(_1d, _1e, _1f) { var _20 = $.data(_1d, "combogrid").options; var _21 = $.data(_1d, "combogrid").grid; var _22 = _21.datagrid("getRows"); // 如果是对象数组,则转换成普通key数组 if($.isArray(_1e) && $.isObject(_1e[0])){ var keyArr = []; for (var index = 0; index < _1e.length; index++) { var bean = _1e[index]; if(bean[_20.idField]){ keyArr.push(bean[_20.idField]); } } _1e = keyArr; } var ss = []; for (var i = 0; i < _1e.length; i++) { var _23 = _21.datagrid("getRowIndex", _1e[i]); if (_23 >= 0) { _21.datagrid("selectRow", _23); ss.push(_22[_23][_20.textField]); } else { ss.push(_1e[i]); } } if ($(_1d).combo("getValues").join(",") == _1e.join(",")) { return; } $(_1d).combo("setValues", _1e); if (!_1f) { $(_1d).combo("setText", ss.join(_20.separator)); } }; function _24(_25, q) { var _26 = $.data(_25, "combogrid").options; var _27 = $.data(_25, "combogrid").grid; $.data(_25, "combogrid").remainText = true; if (_26.multiple && !q) { _1c(_25, [], true); } else { _1c(_25, [q], true); } if (_26.mode == "remote") { _27.datagrid("clearSelections"); _27.datagrid("load", { q : q }); } else { if (!q) { return; } var _28 = _27.datagrid("getRows"); for (var i = 0; i < _28.length; i++) { if (_26.filter.call(_25, q, _28[i])) { _27.datagrid("clearSelections"); _27.datagrid("selectRow", i); return; } } } }; $.fn.combogrid = function(_29, _2a) { if (typeof _29 == "string") { var _2b = $.fn.combogrid.methods[_29]; if (_2b) { return _2b(this, _2a); } else { return $.fn.combo.methods[_29](this, _2a); } } _29 = _29 || {}; return this.each(function() { var _2c = $.data(this, "combogrid"); if (_2c) { $.extend(_2c.options, _29); } else { _2c = $.data(this, "combogrid", { options : $.extend({}, $.fn.combogrid.defaults, $.fn.combogrid.parseOptions(this), _29) }); } _1(this); }); }; $.fn.combogrid.methods = { options : function(jq) { return $.data(jq[0], "combogrid").options; }, grid : function(jq) { return $.data(jq[0], "combogrid").grid; }, setValues : function(jq, _2d) { return jq.each(function() { _1c(this, _2d); }); }, setValue : function(jq, _2e) { return jq.each(function() { _1c(this, [_2e]); }); }, clear : function(jq) { return jq.each(function() { $(this).combogrid("grid").datagrid("clearSelections"); $(this).combo("clear"); }); } }; /** * 解析配置项 */ $.fn.combogrid.parseOptions = function(_2f) { var t = $(_2f); return $.extend({}, $.fn.combo.parseOptions(_2f), $.fn.datagrid .parseOptions(_2f), { idField : (t.attr("idField") || undefined), textField : (t.attr("textField") || undefined), mode : t.attr("mode"), columns: $.eval(t.attr("columns")) }); }; $.fn.combogrid.defaults = $.extend({}, $.fn.combo.defaults, $.fn.datagrid.defaults, { xtype: 'combogrid', // zzy+ loadMsg : null, idField : null, textField : null, mode : "local", keyHandler : { up : function() { _14(this, -1); }, down : function() { _14(this, 1); }, enter : function() { _14(this, 0); $(this).combo("hidePanel"); }, query : function(q) { _24(this, q); } }, filter : function(q, row) { var _30 = $(this).combogrid("options"); return row[_30.textField].indexOf(q) == 0; } }); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.combogrid.js
JavaScript
asf20
6,483
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($) { function _1(_2) { var _3 = $(_2); _3.addClass("tree"); return _3; }; function _4(_5) { var _6 = []; _7(_6, $(_5)); function _7(aa, _8) { _8.children("li").each(function() { var _9 = $(this); var _a = {}; _a.text = _9.children("span").html(); if (!_a.text) { _a.text = _9.html(); } _a.id = _9.attr("id"); _a.iconCls = _9.attr("iconCls") || _9.attr("icon"); _a.checked = _9.attr("checked") == "true"; _a.state = _9.attr("state") || "open"; var _b = _9.children("ul"); if (_b.length) { _a.children = []; _7(_a.children, _b); } aa.push(_a); }); }; return _6; }; function _c(_d) { var _e = $.data(_d, "tree").options; var _f = $.data(_d, "tree").tree; $("div.tree-node", _f).unbind(".tree").bind("dblclick.tree", function() { _b1(_d, this); _e.onDblClick.call(_d, _8e(_d)); }).bind("click.tree", function() { _b1(_d, this); _e.onClick.call(_d, _8e(_d)); }).bind("mouseenter.tree", function() { $(this).addClass("tree-node-hover"); return false; }).bind("mouseleave.tree", function() { $(this).removeClass("tree-node-hover"); return false; }).bind("contextmenu.tree", function(e) { _e.onContextMenu.call(_d, e, _36(_d, this)); }); $("span.tree-hit", _f).unbind(".tree").bind("click.tree", function() { var _10 = $(this).parent(); _6b(_d, _10[0]); return false; }).bind("mouseenter.tree", function() { if ($(this).hasClass("tree-expanded")) { $(this).addClass("tree-expanded-hover"); } else { $(this).addClass("tree-collapsed-hover"); } }).bind("mouseleave.tree", function() { if ($(this).hasClass("tree-expanded")) { $(this).removeClass("tree-expanded-hover"); } else { $(this).removeClass("tree-collapsed-hover"); } }).bind("mousedown.tree", function() { return false; }); $("span.tree-checkbox", _f).unbind(".tree").bind("click.tree", function() { var _11 = $(this).parent(); _2d(_d, _11[0], !$(this).hasClass("tree-checkbox1")); return false; }).bind("mousedown.tree", function() { return false; }); }; function _12(_13) { var _14 = $(_13).find("div.tree-node"); _14.draggable("disable"); _14.css("cursor", "pointer"); }; /**拖拽---start*/ function _15(_16) { var _17 = $.data(_16, "tree").options; var _18 = $.data(_16, "tree").tree; // 对 _18.find("div.tree-node").draggable({ disabled : false, revert : true, cursor : "pointer", proxy : function(_19) { var p = $("<div class=\"tree-node-proxy tree-dnd-no\"></div>") .appendTo("body"); p.html($(_19).find(".tree-title").html()); p.hide(); return p; }, deltaX : 15, deltaY : 15, onBeforeDrag : function(e) { $._treeDragParentEl = this.parentNode.parentNode.parentNode; alert($(this.parentNode).html()); if (e.which != 1) { return false; } $(this).next("ul").find("div.tree-node").droppable({ accept : "no-accept" }); }, onStartDrag : function() { $.msg.say('onStartDrag') $(this).draggable("proxy").css({ left : -10000, top : -10000 }); }, onDrag : function(e) { var x1 = e.pageX, y1 = e.pageY, x2 = e.data.startX, y2 = e.data.startY; var d = Math .sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); if (d > 3) { if($(this).draggable("proxy")){ $(this).draggable("proxy").show(); } } this.pageY = e.pageY; }, onStopDrag : function() { $(this).next("ul").find("div.tree-node").droppable({ accept : "div.tree-node" }); } }).droppable({ // accept : "div.tree-node", accept : function(e){ return false; var _target = e.data.target; var _tarParent = _target.parentNode.parentNode.parentNode; var _parent = $._treeDragParentEl; alert(_parent) if(!_parent || _parent!=_tarParent)return false; var flag = $(_parent).find('div.tree-node').filter(function() { return this == _target; }).length > 0; $.msg.say("accept fun::::::" + flag); return flag; }, onDragOver : function(e, _1a) { var _1b = _1a.pageY; var top = $(this).offset().top; var _1c = top + $(this).outerHeight(); if( $(_1a).draggable("proxy")){ // zzy+ $(_1a).draggable("proxy").removeClass("tree-dnd-no") .addClass("tree-dnd-yes"); } $(this).removeClass("tree-node-append tree-node-top tree-node-bottom"); if (_1b > top + (_1c - top) / 2) { $.msg.say("aaaaaaaaaaaa") if (_1c - _1b < 5) { $(this).addClass("tree-node-bottom"); } else { // $(this).addClass("tree-node-append"); //zzy+ 不支持移动到文件夹,只支持排序 } } else { $.msg.say("bbbbbbbbbbbb") if (_1b - top < 5) { $(this).addClass("tree-node-top"); } else { // $(this).addClass("tree-node-append"); //zzy+ 不支持移动到文件夹,只支持排序 } } }, onDragLeave : function(e, _1d) { //zzy+ if($(_1d).draggable("proxy")){ $(_1d).draggable("proxy").removeClass("tree-dnd-yes") .addClass("tree-dnd-no"); } $(this).removeClass("tree-node-append tree-node-top tree-node-bottom"); }, onDrop : function(e, _1e) { var _1f = this; var _20, _21; // 放到文件夹中 if ($(this).hasClass("tree-node-append")) { _20 = _22; } else { // 放到底部或者上部 _20 = _23; _21 = $(this).hasClass("tree-node-top") ? "top" : "bottom"; } setTimeout(function() { _20(_1e, _1f, _21); }, 0); $(this).removeClass("tree-node-append tree-node-top tree-node-bottom"); } }); function _22(_24, _25) { if (_36(_16, _25).state == "closed") { _5f(_16, _25, function() { _26(); }); } else { _26(); } function _26() { var _27 = $(_16).tree("pop", _24); $(_16).tree("append", { parent : _25, data : [_27] }); _17.onDrop.call(_16, _25, _27, "append"); }; }; function _23(_28, _29, _2a) { var _2b = {}; if (_2a == "top") { _2b.before = _29; } else { _2b.after = _29; } var _2c = $(_16).tree("pop", _28); _2b.data = _2c; $(_16).tree("insert", _2b); _17.onDrop.call(_16, _29, _2c, _2a); }; }; /**拖拽---end*/ function _2d(_2e, _2f, _30) { var _31 = $.data(_2e, "tree").options; if (!_31.checkbox) { return; } var _32 = $(_2f); var ck = _32.find(".tree-checkbox"); ck.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2"); if (_30) { ck.addClass("tree-checkbox1"); } else { ck.addClass("tree-checkbox0"); } if (_31.cascadeCheck) { _33(_32); _34(_32); } var _35 = _36(_2e, _2f); _31.onCheck.call(_2e, _35, _30); function _34(_37) { var _38 = _37.next().find(".tree-checkbox"); _38.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2"); if (_37.find(".tree-checkbox").hasClass("tree-checkbox1")) { _38.addClass("tree-checkbox1"); } else { _38.addClass("tree-checkbox0"); } }; function _33(_39) { var _3a = _76(_2e, _39[0]); if (_3a) { var ck = $(_3a.target).find(".tree-checkbox"); ck.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2"); if (_3b(_39)) { ck.addClass("tree-checkbox1"); } else { if (_3c(_39)) { ck.addClass("tree-checkbox0"); } else { ck.addClass("tree-checkbox2"); } } _33($(_3a.target)); } function _3b(n) { var ck = n.find(".tree-checkbox"); if (ck.hasClass("tree-checkbox0") || ck.hasClass("tree-checkbox2")) { return false; } var b = true; n.parent().siblings().each(function() { if (!$(this).children("div.tree-node") .children(".tree-checkbox") .hasClass("tree-checkbox1")) { b = false; } }); return b; }; function _3c(n) { var ck = n.find(".tree-checkbox"); if (ck.hasClass("tree-checkbox1") || ck.hasClass("tree-checkbox2")) { return false; } var b = true; n.parent().siblings().each(function() { if (!$(this).children("div.tree-node") .children(".tree-checkbox") .hasClass("tree-checkbox0")) { b = false; } }); return b; }; }; }; function _3d(_3e, _3f) { var _40 = $.data(_3e, "tree").options; var _41 = $(_3f); if (_42(_3e, _3f)) { var ck = _41.find(".tree-checkbox"); if (ck.length) { if (ck.hasClass("tree-checkbox1")) { _2d(_3e, _3f, true); } else { _2d(_3e, _3f, false); } } else { if (_40.onlyLeafCheck) { $("<span class=\"tree-checkbox tree-checkbox0\"></span>") .insertBefore(_41.find(".tree-title")); _c(_3e); } } } else { var ck = _41.find(".tree-checkbox"); if (_40.onlyLeafCheck) { ck.remove(); } else { if (ck.hasClass("tree-checkbox1")) { _2d(_3e, _3f, true); } else { if (ck.hasClass("tree-checkbox2")) { var _43 = true; var _44 = true; var _45 = _46(_3e, _3f); for (var i = 0; i < _45.length; i++) { if (_45[i].checked) { _44 = false; } else { _43 = false; } } if (_43) { _2d(_3e, _3f, true); } if (_44) { _2d(_3e, _3f, false); } } } } } }; function _47(_48, ul, _49, _4a) { var _4b = $.data(_48, "tree").options; if (!_4a) { $(ul).empty(); } var _4c = []; var _4d = $(ul).prev("div.tree-node") .find("span.tree-indent, span.tree-hit").length; _4e(ul, _49, _4d); _c(_48); if (_4b.dnd) { _15(_48); } else { _12(_48); } for (var i = 0; i < _4c.length; i++) { _2d(_48, _4c[i], true); } var _4f = null; if (_48 != ul) { var _50 = $(ul).prev(); _4f = _36(_48, _50[0]); } _4b.onLoadSuccess.call(_48, _4f, _49); function _4e(ul, _51, _52) { for (var i = 0; i < _51.length; i++) { var li = $("<li></li>").appendTo(ul); var _53 = _51[i]; //zzy+ if(!_53['text']){ _53['text'] = _53[_4b['textField']]; } // 遍历加载的数据 _4b.eachLoadData.call(_48, _53, i); if( $.isEmpty(_53['text']) ){ _53['text'] = _53[_4b['textField']]; } if(!_53.iconCls){ _53.iconCls = 'icon-tree-folder'; } if (_53.state != "open" && _53.state != "closed") { _53.state = "open"; } var _54 = $("<div class=\"tree-node\"></div>").appendTo(li); _54.attr("node-id", _53.id); // $.data(_54[0], "tree-node", { // id : _53.id, // text : _53.text, // iconCls : _53.iconCls, // attributes : _53.attributes // }); $.data(_54[0], "tree-node", _53); $("<span class=\"tree-title\"></span>").html(_53.text).appendTo(_54); if (_4b.checkbox) { if (_4b.onlyLeafCheck) { if (_53.state == "open" && (!_53.children || !_53.children.length)) { if (_53.checked) { $("<span class=\"tree-checkbox tree-checkbox1\"></span>") .prependTo(_54); } else { $("<span class=\"tree-checkbox tree-checkbox0\"></span>") .prependTo(_54); } } } else { if (_53.checked) { $("<span class=\"tree-checkbox tree-checkbox1\"></span>") .prependTo(_54); _4c.push(_54[0]); } else { $("<span class=\"tree-checkbox tree-checkbox0\"></span>") .prependTo(_54); } } } // 新渲染规则:添加了leaf属性,与open协调工作 // 即,left判断是否是文件夹形式,state判断是否要打开文件夹 // 如果row有子节点,则 if (_53.children && _53.children.length) { var _55 = $("<ul></ul>").appendTo(li); if (_53.state == "open") { $("<span class=\"tree-icon tree-folder tree-folder-open\"></span>") .addClass(_53.iconCls).prependTo(_54); $("<span class=\"tree-hit tree-expanded\"></span>") .prependTo(_54); } else { $("<span class=\"tree-icon tree-folder\"></span>") .addClass(_53.iconCls).prependTo(_54); $("<span class=\"tree-hit tree-collapsed\"></span>") .prependTo(_54); _55.css("display", "none"); } _4e(_55, _53.children, _52 + 1); } else { // 当不是叶子节点,切状态为closed时,才为可请求节点 if (/*_53.state == "closed"*/ !_53.leaf && _53.state == "closed") { $("<span class=\"tree-icon tree-folder\"></span>") .addClass(_53.iconCls).prependTo(_54); $("<span class=\"tree-hit tree-collapsed\"></span>") .prependTo(_54); } else { $("<span class=\"tree-icon tree-file\"></span>") .addClass(_53.iconCls).prependTo(_54); $("<span class=\"tree-indent\"></span>").prependTo(_54); } } // 树渲染 // 渲染规则: // 如果row有子节点,且当前状态为open,则直接打开;否则关闭 // 如果row没有子节点,切当前状态为closed,则是文件夹,否则直接是文件 /*if (_53.children && _53.children.length) { var _55 = $("<ul></ul>").appendTo(li); if (_53.state == "open") { $("<span class=\"tree-icon tree-folder tree-folder-open\"></span>") .addClass(_53.iconCls).prependTo(_54); $("<span class=\"tree-hit tree-expanded\"></span>") .prependTo(_54); } else { $("<span class=\"tree-icon tree-folder\"></span>") .addClass(_53.iconCls).prependTo(_54); $("<span class=\"tree-hit tree-collapsed\"></span>") .prependTo(_54); _55.css("display", "none"); } _4e(_55, _53.children, _52 + 1); } else { if (_53.state == "closed") { $("<span class=\"tree-icon tree-folder\"></span>") .addClass(_53.iconCls).prependTo(_54); $("<span class=\"tree-hit tree-collapsed\"></span>") .prependTo(_54); } else { $("<span class=\"tree-icon tree-file\"></span>") .addClass(_53.iconCls).prependTo(_54); $("<span class=\"tree-indent\"></span>").prependTo(_54); } }*/ for (var j = 0; j < _52; j++) { $("<span class=\"tree-indent\"></span>").prependTo(_54); } } }; }; function _56(_57, ul, _58, _59) { var _5a = $.data(_57, "tree").options; _58 = _58 || {}; //zzy 参数设置 _5a.queryParams = _5a.queryParams || {}; var param = $.isFunction(_5a.queryParams) ? _5a.queryParams() : _5a.queryParams; param = param || {}; $.extend(_58, param); var _5b = null; if (_57 != ul) { var _5c = $(ul).prev(); _5b = _36(_57, _5c[0]); } if (_5a.onBeforeLoad.call(_57, _5b, _58) == false) { return; } if (!_5a.list/*url*/) { return; } var _5d = $(ul).prev().children("span.tree-folder"); _5d.addClass("tree-loading"); // zzy+ 用通用的ajax组件$.query $.query(_5a['list'], _58, function(_5e) { _5e = $.decode(_5e); //zzy+ 转换值 if(!$.isEmpty(_5e)){ if(_5e['rows']){ _5e = _5e['rows']; } } if(_5e && _5e.length>0){ // for (var index = 0; index < _5e.length; index++) { // var bean = _5e[index]; // // // 遍历加载的数据 // _5a.eachLoadData.call(_57, bean, index); // // if(!bean['iconCls']){ // bean['iconCls'] = 'icon-tree-folder'; // } // if( $.isEmpty(bean['text']) ){ // bean['text'] = bean[_5a['textField']]; // } // } _5e = make2TreeJson(_5e); } _5d.removeClass("tree-loading"); _47(_57, ul, _5e); if (_59) { _59(); } },function() { _5d.removeClass("tree-loading"); _5a.onLoadError.apply(_57, arguments); if (_59) { _59(); } }); // $.ajax({ // type : _5a.method, // url : _5a.url, // data : _58, // dataType : "json", // success : function(_5e) { // _5d.removeClass("tree-loading"); // _47(_57, ul, _5e); // if (_59) { // _59(); // } // }, // error : function() { // _5d.removeClass("tree-loading"); // _5a.onLoadError.apply(_57, arguments); // if (_59) { // _59(); // } // } // }); }; /** * 根据parentId,生成TREE——JSON * @param rows 行值 * @param treeJson * @returns */ function make2TreeJson(rows, treeJsonArr/**private*/, deepIdx/**private*/){ deepIdx = deepIdx ? deepIdx : 0; treeJsonArr = treeJsonArr ? treeJsonArr : []; if(deepIdx == 0){ deepIdx++; var rowBean = getRowsByParentId(rows, null); return make2TreeJson(rowBean['falseRows'], rowBean['trueRows'], deepIdx); }else{ $.each(treeJsonArr, function(idx, row){ var rowBean = getRowsByParentId(rows, row['id']); if(rowBean['trueRows'].length > 0){ row['children'] = make2TreeJson(rowBean['falseRows'], rowBean['trueRows'], deepIdx++); } }); return treeJsonArr; } } /** * 根据父节点,获取相关的子几点 * @param parentId * @returns */ function getRowsByParentId(rows, parentId){ var tmpRows = []; var expRows = []; $.each(rows, function(idx, row){ if($.isEmpty(parentId) && $.isEmpty(row['parentId'], false)){ tmpRows.push(row); }else if(parentId == row['parentId']){ tmpRows.push(row); }else{ expRows.push(row); } }); var rowBean = { trueRows: tmpRows, falseRows: expRows }; return rowBean; } // 扩展事件处理 function _5f(_60, _61, _62) { var _63 = $.data(_60, "tree").options; var hit = $(_61).children("span.tree-hit"); if (hit.length == 0) { return; } if (hit.hasClass("tree-expanded")) { return; } var _64 = _36(_60, _61); if (_63.onBeforeExpand.call(_60, _64) == false) { return; } hit.removeClass("tree-collapsed tree-collapsed-hover") .addClass("tree-expanded"); hit.next().addClass("tree-folder-open"); var ul = $(_61).next(); if (ul.length) { if (_63.animate) { ul.slideDown("normal", function() { _63.onExpand.call(_60, _64); if (_62) { _62(); } }); } else { ul.css("display", "block"); _63.onExpand.call(_60, _64); if (_62) { _62(); } } } else { //zzy+ 如果已经加载,则不做请求处理 if(_64['loaded'])return; var _65 = $("<ul style=\"display:none\"></ul>").insertAfter(_61); _56(_60, _65[0], { id : _64.id }, function() { if (_63.animate) { _65.slideDown("normal", function() { _63.onExpand.call(_60, _64); if (_62) { _62(); } }); } else { _65.css("display", "block"); _63.onExpand.call(_60, _64); if (_62) { _62(); } } }); } }; function _66(_67, _68) { var _69 = $.data(_67, "tree").options; var hit = $(_68).children("span.tree-hit"); if (hit.length == 0) { return; } if (hit.hasClass("tree-collapsed")) { return; } var _6a = _36(_67, _68); if (_69.onBeforeCollapse.call(_67, _6a) == false) { return; } hit.removeClass("tree-expanded tree-expanded-hover") .addClass("tree-collapsed"); hit.next().removeClass("tree-folder-open"); var ul = $(_68).next(); if (_69.animate) { ul.slideUp("normal", function() { _69.onCollapse.call(_67, _6a); }); } else { ul.css("display", "none"); _69.onCollapse.call(_67, _6a); } }; function _6b(_6c, _6d) { var hit = $(_6d).children("span.tree-hit"); if (hit.length == 0) { return; } if (hit.hasClass("tree-expanded")) { _66(_6c, _6d); } else { _5f(_6c, _6d); } }; function _6e(_6f, _70) { var _71 = _46(_6f, _70); if (_70) { _71.unshift(_36(_6f, _70)); } for (var i = 0; i < _71.length; i++) { _5f(_6f, _71[i].target); } }; function _72(_73, _74) { var _75 = []; var p = _76(_73, _74); while (p) { _75.unshift(p); p = _76(_73, p.target); } for (var i = 0; i < _75.length; i++) { _5f(_73, _75[i].target); } }; function _77(_78, _79) { var _7a = _46(_78, _79); if (_79) { _7a.unshift(_36(_78, _79)); } for (var i = 0; i < _7a.length; i++) { _66(_78, _7a[i].target); } }; function _7b(_7c) { var _7d = _7e(_7c); if (_7d.length) { return _7d[0]; } else { return null; } }; function _7e(_7f) { var _80 = []; $(_7f).children("li").each(function() { var _81 = $(this).children("div.tree-node"); _80.push(_36(_7f, _81[0])); }); return _80; }; function _46(_82, _83) { var _84 = []; if (_83) { _85($(_83)); } else { var _86 = _7e(_82); for (var i = 0; i < _86.length; i++) { _84.push(_86[i]); _85($(_86[i].target)); } } function _85(_87) { _87.next().find("div.tree-node").each(function() { _84.push(_36(_82, this)); }); }; return _84; }; function _76(_88, _89) { var ul = $(_89).parent().parent(); if (ul[0] == _88) { return null; } else { return _36(_88, ul.prev()[0]); } }; function _8a(_8b) { var _8c = []; $(_8b).find(".tree-checkbox1").each(function() { var _8d = $(this).parent(); _8c.push(_36(_8b, _8d[0])); }); return _8c; }; /** * 获取所有的节点,包括不饱和父节点 */ function getAllChecked(_8b) { var _8c = []; $(_8b).find(".tree-checkbox1, .tree-checkbox2").each(function() { var _8d = $(this).parent(); _8c.push(_36(_8b, _8d[0])); }); return _8c; }; /** * 清楚所有选中 */ function clearAllChecked(_this){ $(_this).find(".tree-checkbox1, .tree-checkbox2").each(function(){ $(this).removeClass('tree-checkbox1 tree-checkbox2').addClass('tree-checkbox0'); // var _11 = $(this).parent(); // _2d(_this, _11[0], true/*!$(this).hasClass("tree-checkbox1")*/); }); } function clearChecked(_this, id){ id = $.isString(id) ? id: id['id']; $(_this).find("div.tree-node[node-id=" + id + "]").find(".tree-checkbox1, .tree-checkbox2").each(function(){ $(this).removeClass('tree-checkbox1 tree-checkbox2').addClass('tree-checkbox0'); // var _11 = $(this).parent(); // _2d(_this, _11[0], true/*!$(this).hasClass("tree-checkbox1")*/); }); } /** * 设置选中 * @param id 可以是主键或者对象 */ function setChecked(_this, id){ id = $.isString(id) ? id: id['id']; $(_this).find("div.tree-node[node-id=" + id + "]").find(".tree-checkbox0, .tree-checkbox1, .tree-checkbox2").each(function(){ $(this).removeClass('tree-checkbox0').removeClass('tree-checkbox2').addClass('tree-checkbox1'); var _11 = $(this).parent(); _2d(_this, _11[0], true/*!$(this).hasClass("tree-checkbox1")*/); }); } /** * 设置选中,参数为数组 * @param _this * @param checkedArr 要选中的数组 * @returns */ function setListChecked(_this, checkedArr){ $.each(checkedArr, function(idx, row){ setChecked(_this, row); }); } function _8e(_8f) { var _90 = $(_8f).find("div.tree-node-selected"); if (_90.length) { return _36(_8f, _90[0]); } else { return null; } }; function _91(_92, _93) { var _94 = $(_93.parent); var ul; if (_94.length == 0) { ul = $(_92); } else { ul = _94.next(); if (ul.length == 0) { ul = $("<ul></ul>").insertAfter(_94); } } if (_93.data && _93.data.length) { var _95 = _94.find("span.tree-icon"); if (_95.hasClass("tree-file")) { _95.removeClass("tree-file").addClass("tree-folder"); var hit = $("<span class=\"tree-hit tree-expanded\"></span>") .insertBefore(_95); if (hit.prev().length) { hit.prev().remove(); } } } _47(_92, ul[0], _93.data, true); _3d(_92, ul.prev()); }; function _96(_97, _98) { var ref = _98.before || _98.after; var _99 = _76(_97, ref); var li; if (_99) { _91(_97, { parent : _99.target, data : [_98.data] }); li = $(_99.target).next().children("li:last"); } else { _91(_97, { parent : null, data : [_98.data] }); li = $(_97).children("li:last"); } if (_98.before) { li.insertBefore($(ref).parent()); } else { li.insertAfter($(ref).parent()); } }; function _9a(_9b, _9c) { var _9d = _76(_9b, _9c); var _9e = $(_9c); var li = _9e.parent(); var ul = li.parent(); li.remove(); if (ul.children("li").length == 0) { var _9e = ul.prev(); _9e.find(".tree-icon").removeClass("tree-folder") .addClass("tree-file"); _9e.find(".tree-hit").remove(); $("<span class=\"tree-indent\"></span>").prependTo(_9e); if (ul[0] != _9b) { ul.remove(); } } if (_9d) { _3d(_9b, _9d.target); } }; function _9f(_a0, _a1) { function _a2(aa, ul) { ul.children("li").each(function() { var _a3 = $(this).children("div.tree-node"); var _a4 = _36(_a0, _a3[0]); var sub = $(this).children("ul"); if (sub.length) { _a4.children = []; _9f(_a4.children, sub); } aa.push(_a4); }); }; if (_a1) { var _a5 = _36(_a0, _a1); _a5.children = []; _a2(_a5.children, $(_a1).next()); return _a5; } else { return null; } }; function _a6(_a7, _a8) { var _a9 = $(_a8.target); var _aa = $.data(_a8.target, "tree-node"); if (_aa.iconCls) { _a9.find(".tree-icon").removeClass(_aa.iconCls); } $.extend(_aa, _a8); $.data(_a8.target, "tree-node", _aa); _a9.attr("node-id", _aa.id); _a9.find(".tree-title").html(_aa.text); if (_aa.iconCls) { _a9.find(".tree-icon").addClass(_aa.iconCls); } var ck = _a9.find(".tree-checkbox"); ck.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2"); if (_aa.checked) { _2d(_a7, _a8.target, true); } else { _2d(_a7, _a8.target, false); } }; function _36(_ab, _ac) { var _ad = $.extend({}, $.data(_ac, "tree-node"), { target : _ac, checked : $(_ac).find(".tree-checkbox") .hasClass("tree-checkbox1") }); if (!_42(_ab, _ac)) { _ad.state = $(_ac).find(".tree-hit").hasClass("tree-expanded") ? "open" : "closed"; } return _ad; }; function _ae(_af, id) { var _b0 = $(_af).find("div.tree-node[node-id=" + id + "]"); if (_b0.length) { return _36(_af, _b0[0]); } else { return null; } }; /** * 选中某行记录 */ function _b1(_b2, _b3) { if($.isString(_b3)){ _b3 = $(_b2).find('div.tree-node[node-id='+_b3+']')[0]; } var _b4 = $.data(_b2, "tree").options; var _b5 = _36(_b2, _b3); if (_b4.onBeforeSelect.call(_b2, _b5) == false) { return; } $("div.tree-node-selected", _b2).removeClass("tree-node-selected"); $(_b3).addClass("tree-node-selected"); _b4.onSelect.call(_b2, _b5); }; function _42(_b6, _b7) { var _b8 = $(_b7); var hit = _b8.children("span.tree-hit"); return hit.length == 0; }; function _b9(_ba, _bb) { var _bc = $.data(_ba, "tree").options; var _bd = _36(_ba, _bb); if (_bc.onBeforeEdit.call(_ba, _bd) == false) { return; } $(_bb).css("position", "relative"); var nt = $(_bb).find(".tree-title"); var _be = nt.outerWidth(); nt.empty(); var _bf = $("<input class=\"tree-editor\">").appendTo(nt); _bf.val(_bd.text).focus(); _bf.width(_be + 20); _bf.height(document.compatMode == "CSS1Compat" ? (18 - (_bf .outerHeight() - _bf.height())) : 18); _bf.bind("click", function(e) { return false; }).bind("mousedown", function(e) { e.stopPropagation(); }).bind("mousemove", function(e) { e.stopPropagation(); }).bind("keydown", function(e) { if (e.keyCode == 13) { _c0(_ba, _bb); return false; } else { if (e.keyCode == 27) { _c6(_ba, _bb); return false; } } }).bind("blur", function(e) { e.stopPropagation(); _c0(_ba, _bb); }); }; function _c0(_c1, _c2) { var _c3 = $.data(_c1, "tree").options; $(_c2).css("position", ""); var _c4 = $(_c2).find("input.tree-editor"); var val = _c4.val(); _c4.remove(); var _c5 = _36(_c1, _c2); _c5.text = val; _a6(_c1, _c5); _c3.onAfterEdit.call(_c1, _c5); }; function _c6(_c7, _c8) { var _c9 = $.data(_c7, "tree").options; $(_c8).css("position", ""); $(_c8).find("input.tree-editor").remove(); var _ca = _36(_c7, _c8); _a6(_c7, _ca); _c9.onCancelEdit.call(_c7, _ca); }; $.fn.tree = function(_cb, _cc) { if (typeof _cb == "string") { return $.fn.tree.methods[_cb](this, _cc); } var _cb = _cb || {}; //zzy+ 设置CRUD的相关url $.createURL(_cb); // if(_cb.url != null){ // if(_cb.list == null){ // _cb.list = _cb.url + '/list' // }; // // if(_cb.remove == null){ // _cb.remove = _cb.url + '/remove' // } // // if(_cb.save == null){ // _cb.save = _cb.url + '/save' // } // } return this.each(function() { var _cd = $.data(this, "tree"); var _ce; if (_cd) { _ce = $.extend(_cd.options, _cb); _cd.options = _ce; } else { _ce = $.extend({}, $.fn.tree.defaults, $.fn.tree .parseOptions(this), _cb); // zzy+ $.createURL(_ce); $.data(this, "tree", { options : _ce, tree : _1(this) }); var _cf = _4(this); _47(this, this, _cf); } if (_ce.data) { _47(this, this, _ce.data); } else { if (_ce.dnd) { _15(this); } else { _12(this); } } if (_ce.list/*url*/) { _56(this, this); } }); }; $.fn.tree.methods = { options : function(jq) { return $.data(jq[0], "tree").options; }, loadData : function(jq, _d0) { return jq.each(function() { _47(this, this, _d0); }); }, getNode : function(jq, _d1) { return _36(jq[0], _d1); }, getData : function(jq, _d2) { return _9f(jq[0], _d2); }, reload : function(jq, _d3) { return jq.each(function() { if (_d3) { var _d4 = $(_d3); var hit = _d4.children("span.tree-hit"); hit .removeClass("tree-expanded tree-expanded-hover") .addClass("tree-collapsed"); _d4.next().remove(); _5f(this, _d3); } else { $(this).empty(); _56(this, this); } }); }, getRoot : function(jq) { return _7b(jq[0]); }, getRoots : function(jq) { return _7e(jq[0]); }, getParent : function(jq, _d5) { return _76(jq[0], _d5); }, getChildren : function(jq, _d6) { return _46(jq[0], _d6); }, getChecked : function(jq) { return _8a(jq[0]); }, getAllChecked : function(jq) { return getAllChecked(jq[0]); }, setChecked : function(jq, id) { return setChecked(jq[0], id); }, setListChecked : function(jq, list) { return setListChecked(jq[0], list); }, clearChecked : function(jq, id) { return _8a(jq[0], id); }, clearAllChecked : function(jq) { return clearAllChecked(jq[0]); }, getSelected : function(jq) { return _8e(jq[0]); }, isLeaf : function(jq, _d7) { return _42(jq[0], _d7); }, find : function(jq, id) { return _ae(jq[0], id); }, select : function(jq, _d8) { return jq.each(function() { _b1(this, _d8); }); }, check : function(jq, _d9) { return jq.each(function() { _2d(this, _d9, true); }); }, uncheck : function(jq, _da) { return jq.each(function() { _2d(this, _da, false); }); }, collapse : function(jq, _db) { return jq.each(function() { _66(this, _db); }); }, expand : function(jq, _dc) { return jq.each(function() { _5f(this, _dc); }); }, collapseAll : function(jq, _dd) { return jq.each(function() { _77(this, _dd); }); }, expandAll : function(jq, _de) { return jq.each(function() { _6e(this, _de); }); }, expandTo : function(jq, _df) { return jq.each(function() { _72(this, _df); }); }, toggle : function(jq, _e0) { return jq.each(function() { _6b(this, _e0); }); }, append : function(jq, _e1) { return jq.each(function() { _91(this, _e1); }); }, insert : function(jq, _e2) { return jq.each(function() { _96(this, _e2); }); }, remove : function(jq, _e3) { return jq.each(function() { _9a(this, _e3); }); }, pop : function(jq, _e4) { var _e5 = jq.tree("getData", _e4); jq.tree("remove", _e4); return _e5; }, update : function(jq, _e6) { return jq.each(function() { _a6(this, _e6); }); }, enableDnd : function(jq) { return jq.each(function() { _15(this); }); }, disableDnd : function(jq) { return jq.each(function() { _12(this); }); }, beginEdit : function(jq, _e7) { return jq.each(function() { _b9(this, _e7); }); }, endEdit : function(jq, _e8) { return jq.each(function() { _c0(this, _e8); }); }, cancelEdit : function(jq, _e9) { return jq.each(function() { _c6(this, _e9); }); } }; $.fn.tree.parseOptions = function(_ea) { var t = $(_ea); var cfg = { url : t.attr("url"), method : (t.attr("method") ? t.attr("method") : undefined), checkbox : (t.attr("checkbox") ? t.attr("checkbox") == "true" : undefined), cascadeCheck : (t.attr("cascadeCheck") ? t.attr("cascadeCheck") == "true" : undefined), onlyLeafCheck : (t.attr("onlyLeafCheck") ? t.attr("onlyLeafCheck") == "true" : undefined), animate : (t.attr("animate") ? t.attr("animate") == "true" : undefined), dnd : (t.attr("dnd") ? t.attr("dnd") == "true" : undefined), idField : t.attr("idField"), //zzy+ textField : t.attr("textField"), //zzy+ list : t.attr("list"), //zzy+ 查询url save : t.attr("save"), //zzy+ 保存url remove : t.attr("remove") //zzy+ 删除url }; // 其他配置项 if(t.attr("other")){ cfg = $.extend(cfg, eval(t.attr("other"))); } // 查询参数 if(t.attr('queryParams')){ cfg['queryParams'] = eval(t.attr("queryParams")); } return cfg; }; $.fn.tree.defaults = { url : null, method : "post", animate : false, checkbox : false, cascadeCheck : true, onlyLeafCheck : false, dnd : false, data : null, onBeforeLoad : function(_eb, _ec) { }, onLoadSuccess : function(_ed, _ee) { }, onLoadError : function() { }, onClick : function(_ef) { }, onDblClick : function(_f0) { }, onBeforeExpand : function(_f1) { }, onExpand : function(_f2) { }, onBeforeCollapse : function(_f3) { }, onCollapse : function(_f4) { }, onCheck : function(_f5, _f6) { }, onBeforeSelect : function(_f7) { }, onSelect : function(_f8) { }, onContextMenu : function(e, _f9) { }, onDrop : function(_fa, _fb, _fc) { }, onBeforeEdit : function(_fd) { }, onAfterEdit : function(_fe) { }, onCancelEdit : function(_ff) { }, eachLoadData: function(row, index){} }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.tree.js
JavaScript
asf20
36,475
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($) { function _1(_2) { var _3 = $.data(_2, "combotree").options; var _4 = $.data(_2, "combotree").tree; $(_2).addClass("combotree-f"); $(_2).combo(_3); var _5 = $(_2).combo("panel"); if (!_4) { _4 = $("<ul></ul>").appendTo(_5); $.data(_2, "combotree").tree = _4; } _4.tree($.extend({}, _3, { checkbox : _3.multiple, onLoadSuccess : function(_6, _7) { var _8 = $(_2).combotree("getValues"); if (_3.multiple) { var _9 = _4.tree("getChecked"); for (var i = 0; i < _9.length; i++) { var id = _9[i].id; (function () { for (var i = 0; i < _8.length; i++) { if (id == _8[i]) { return; } } _8.push(id); })(); } } $(_2).combotree("setValues", _8); _3.onLoadSuccess.call(this, _6, _7); }, onClick : function(_a) { _d(_2); $(_2).combo("hidePanel"); _3.onClick.call(this, _a); }, onCheck : function(_b, _c) { _d(_2); _3.onCheck.call(this, _b, _c); } })); }; /** * 选中操作 */ function _d(_e) { var _f = $.data(_e, "combotree").options; var _10 = $.data(_e, "combotree").tree; var vv = [], ss = []; if (_f.multiple) { var _11 = _10.tree("getChecked"); for (var i = 0; i < _11.length; i++) { vv.push(_11[i].id); ss.push(_11[i].text); } } else { var _12 = _10.tree("getSelected"); if (_12) { vv.push(_12.id); ss.push(_12.text); } } $(_e).combo("setValues", vv).combo("setText", ss.join(_f.separator)); }; function _13(_14, _15) { var _16 = $.data(_14, "combotree").options; var _17 = $.data(_14, "combotree").tree; _17.find("span.tree-checkbox").addClass("tree-checkbox0") .removeClass("tree-checkbox1 tree-checkbox2"); // 如果是对象数组,则转换成普通key数组 if($.isArray(_15) && $.isObject(_15[0])){ var keyArr = []; for (var index = 0; index < _15.length; index++) { var bean = _15[index]; if(bean[_16.idField]){ keyArr.push(bean[_16.idField]); } } _15 = keyArr; } var vv = [], ss = []; for (var i = 0; i < _15.length; i++) { var v = _15[i]; var s = v; var _18 = _17.tree("find", v); if (_18) { s = _18.text; _17.tree("check", _18.target); _17.tree("select", _18.target); } vv.push(v); ss.push(s); } $(_14).combo("setValues", vv).combo("setText", ss.join(_16.separator)); }; $.fn.combotree = function(_19, _1a) { if (typeof _19 == "string") { var _1b = $.fn.combotree.methods[_19]; if (_1b) { return _1b(this, _1a); } else { return this.combo(_19, _1a); } } _19 = _19 || {}; return this.each(function() { var _1c = $.data(this, "combotree"); if (_1c) { $.extend(_1c.options, _19); } else { $.data(this, "combotree", { options : $.extend({}, $.fn.combotree.defaults, $.fn.combotree.parseOptions(this), _19) }); } _1(this); }); }; $.fn.combotree.methods = { options : function(jq) { return $.data(jq[0], "combotree").options; }, tree : function(jq) { return $.data(jq[0], "combotree").tree; }, loadData : function(jq, _1d) { return jq.each(function() { var _1e = $.data(this, "combotree").options; _1e.data = _1d; var _1f = $.data(this, "combotree").tree; _1f.tree("loadData", _1d); }); }, reload : function(jq, url) { return jq.each(function() { var _20 = $.data(this, "combotree").options; var _21 = $.data(this, "combotree").tree; if (url) { _20.url = url; } _21.tree({ url : _20.url }); }); }, setValues : function(jq, _22) { return jq.each(function() { _13(this, _22); }); }, setValue : function(jq, _23) { return jq.each(function() { _13(this, [_23]); }); }, clear : function(jq) { return jq.each(function() { var _24 = $.data(this, "combotree").tree; _24.find("div.tree-node-selected") .removeClass("tree-node-selected"); $(this).combo("clear"); }); } }; $.fn.combotree.parseOptions = function(_25) { return $.extend({}, $.fn.combo.parseOptions(_25), $.fn.tree .parseOptions(_25)); }; $.fn.combotree.defaults = $.extend({}, $.fn.combo.defaults, $.fn.tree.defaults, { xtype: 'combotree', editable : false }); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.combotree.js
JavaScript
asf20
4,827
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($) { $.extend(Array.prototype, { indexOf : function(o) { for (var i = 0, _1 = this.length; i < _1; i++) { if (this[i] == o) { return i; } } return -1; }, remove : function(o) { var _2 = this.indexOf(o); if (_2 != -1) { this.splice(_2, 1); } return this; }, removeById : function(_3, id) { for (var i = 0, _4 = this.length; i < _4; i++) { if (this[i][_3] == id) { this.splice(i, 1); return this; } } return this; } }); function _5(_6, _7) { var _8 = $.data(_6, "datagrid").options; var _9 = $.data(_6, "datagrid").panel; if (_7) { if (_7.width) { _8.width = _7.width; } if (_7.height) { _8.height = _7.height; } } if (_8.fit == true) { var p = _9.panel("panel").parent(); _8.width = p.width(); _8.height = p.height(); } _9.panel("resize", { width : _8.width, height : _8.height }); }; function _a(_b) { var _c = $.data(_b, "datagrid").options; var _d = $.data(_b, "datagrid").panel; var _e = _d.width(); var _f = _d.height(); var _10 = _d.children("div.datagrid-view"); var _11 = _10.children("div.datagrid-view1"); var _12 = _10.children("div.datagrid-view2"); var _13 = _11.children("div.datagrid-header"); var _14 = _12.children("div.datagrid-header"); var _15 = _13.find("table"); var _16 = _14.find("table"); _10.width(_e); var _17 = _13.children("div.datagrid-header-inner").show(); _11.width(_17.find("table").width()); if (!_c.showHeader) { _17.hide(); } _12.width(_e - _11.outerWidth()); _11 .children("div.datagrid-header,div.datagrid-body,div.datagrid-footer") .width(_11.width()); _12 .children("div.datagrid-header,div.datagrid-body,div.datagrid-footer") .width(_12.width()); var hh; _13.css("height", ""); _14.css("height", ""); _15.css("height", ""); _16.css("height", ""); hh = Math.max(_15.height(), _16.height()); _15.height(hh); _16.height(hh); if ($.boxModel == true) { _13.height(hh - (_13.outerHeight() - _13.height())); _14.height(hh - (_14.outerHeight() - _14.height())); } else { _13.height(hh); _14.height(hh); } if (_c.height != "auto") { var _18 = _f - _12.children("div.datagrid-header").outerHeight(true) - _12.children("div.datagrid-footer").outerHeight(true) - _d.children("div.datagrid-toolbar").outerHeight(true) - _d.children("div.datagrid-pager").outerHeight(true); _11.children("div.datagrid-body").height(_18); _12.children("div.datagrid-body").height(_18); } _10.height(_12.height()); _12.css("left", _11.outerWidth()); }; function _19(_1a) { var _1b = $(_1a).datagrid("getPanel"); var _1c = _1b.children("div.datagrid-mask"); if (_1c.length) { _1c.css({ width : _1b.width(), height : _1b.height() }); var msg = _1b.children("div.datagrid-mask-msg"); msg.css({ left : (_1b.width() - msg.outerWidth()) / 2, top : (_1b.height() - msg.outerHeight()) / 2 }); } }; function _1d(_1e, _1f) { var _20 = $.data(_1e, "datagrid").data.rows; var _21 = $.data(_1e, "datagrid").options; var _22 = $.data(_1e, "datagrid").panel; var _23 = _22.children("div.datagrid-view"); var _24 = _23.children("div.datagrid-view1"); var _25 = _23.children("div.datagrid-view2"); if (!_24.find("div.datagrid-body-inner").is(":empty")) { if (_1f >= 0) { _26(_1f); } else { for (var i = 0; i < _20.length; i++) { _26(i); } if (_21.showFooter) { var _27 = $(_1e).datagrid("getFooterRows") || []; var c1 = _24.children("div.datagrid-footer"); var c2 = _25.children("div.datagrid-footer"); for (var i = 0; i < _27.length; i++) { _26(i, c1, c2); } _a(_1e); } } } if (_21.height == "auto") { var _28 = _24.children("div.datagrid-body"); var _29 = _25.children("div.datagrid-body"); var _2a = 0; var _2b = 0; _29.children().each(function() { var c = $(this); if (c.is(":visible")) { _2a += c.outerHeight(); if (_2b < c.outerWidth()) { _2b = c.outerWidth(); } } }); if (_2b > _29.width()) { _2a += 18; } _28.height(_2a); _29.height(_2a); _23.height(_25.height()); } _25.children("div.datagrid-body").triggerHandler("scroll"); function _26(_2c, c1, c2) { c1 = c1 || _24; c2 = c2 || _25; var tr1 = c1.find("tr[datagrid-row-index=" + _2c + "]"); var tr2 = c2.find("tr[datagrid-row-index=" + _2c + "]"); tr1.css("height", ""); tr2.css("height", ""); var _2d = Math.max(tr1.height(), tr2.height()); tr1.css("height", _2d); tr2.css("height", _2d); }; }; /** * 列解析 */ function _2e(_2f, _30) { function _31(_32) { var _33 = []; $("tr", _32).each(function() { var _34 = []; $("th", this).each(function() { var th = $(this); var col = { title : th.html(), align : th.attr("align") || "left", sortable : th.attr("sortable") == "true" || false, checkbox : th.attr("checkbox") == "true" || false }; if (th.attr("field")) { col.field = th.attr("field"); } if (th.attr("formatter")) { col.formatter = eval(th.attr("formatter")); } if (th.attr("styler")) { col.styler = eval(th.attr("styler")); } if (th.attr("editor")) { var s = $.trim(th.attr("editor")); if (s.substr(0, 1) == "{") { col.editor = eval("(" + s + ")"); } else { col.editor = s; } } if (th.attr("rowspan")) { col.rowspan = parseInt(th.attr("rowspan")); } if (th.attr("colspan")) { col.colspan = parseInt(th.attr("colspan")); } if (th.attr("width")) { col.width = parseInt(th.attr("width")); } if (th.attr("hidden")) { col.hidden = true; } if (th.attr("resizable")) { col.resizable = th.attr("resizable") == "true"; } _34.push(col); }); _33.push(_34); }); return _33; }; var _35 = $("<div class=\"datagrid-wrap\">" + "<div class=\"datagrid-view\">" + "<div class=\"datagrid-view1\">" + "<div class=\"datagrid-header\">" + "<div class=\"datagrid-header-inner\"></div>" + "</div>" + "<div class=\"datagrid-body\">" + "<div class=\"datagrid-body-inner\"></div>" + "</div>" + "<div class=\"datagrid-footer\">" + "<div class=\"datagrid-footer-inner\"></div>" + "</div>" + "</div>" + "<div class=\"datagrid-view2\">" + "<div class=\"datagrid-header\">" + "<div class=\"datagrid-header-inner\"></div>" + "</div>" + "<div class=\"datagrid-body\"></div>" + "<div class=\"datagrid-footer\">" + "<div class=\"datagrid-footer-inner\"></div>" + "</div>" + "</div>" + "<div class=\"datagrid-resize-proxy\"></div>" + "</div>" + "</div>").insertAfter(_2f); _35.panel({ doSize : false }); _35.panel("panel").addClass("datagrid").bind("_resize", function(e, _36) { var _37 = $.data(_2f, "datagrid").options; if (_37.fit == true || _36) { _5(_2f); setTimeout(function() { if ($.data(_2f, "datagrid")) { _38(_2f); } }, 0); } return false; }); $(_2f).hide().appendTo(_35.children("div.datagrid-view")); var _39 = _31($("thead[frozen=true]", _2f)); var _3a = _31($("thead[frozen!=true]", _2f)); return { panel : _35, frozenColumns : _39, columns : _3a }; }; function _3b(_3c) { var _3d = { total : 0, rows : [] }; var _3e = _3f(_3c, true).concat(_3f(_3c, false)); $(_3c).find("tbody tr").each(function() { _3d.total++; var col = {}; for (var i = 0; i < _3e.length; i++) { col[_3e[i]] = $("td:eq(" + i + ")", this).html(); } _3d.rows.push(col); }); return _3d; }; function _40(_41) { var _42 = $.data(_41, "datagrid").options; var _43 = $.data(_41, "datagrid").panel; _43.panel($.extend({}, _42, { doSize : false, onResize : function(_44, _45) { _19(_41); setTimeout(function() { if ($.data(_41, "datagrid")) { _a(_41); _7d(_41); _42.onResize.call(_43, _44, _45); } }, 0); }, onExpand : function() { _a(_41); _1d(_41); _42.onExpand.call(_43); } })); var _46 = _43.children("div.datagrid-view"); var _47 = _46.children("div.datagrid-view1"); var _48 = _46.children("div.datagrid-view2"); var _49 = _47.children("div.datagrid-header") .children("div.datagrid-header-inner"); var _4a = _48.children("div.datagrid-header") .children("div.datagrid-header-inner"); _4b(_49, _42.frozenColumns, true); _4b(_4a, _42.columns, false); _49.css("display", _42.showHeader ? "block" : "none"); _4a.css("display", _42.showHeader ? "block" : "none"); _47.find("div.datagrid-footer-inner").css("display", _42.showFooter ? "block" : "none"); _48.find("div.datagrid-footer-inner").css("display", _42.showFooter ? "block" : "none"); if (_42.toolbar) { if (typeof _42.toolbar == "string") { $(_42.toolbar).addClass("datagrid-toolbar").prependTo(_43); $(_42.toolbar).show(); } else { $("div.datagrid-toolbar", _43).remove(); var tb = $("<div class=\"datagrid-toolbar\"></div>") .prependTo(_43); for (var i = 0; i < _42.toolbar.length; i++) { var btn = _42.toolbar[i]; if (btn == "-") { $("<div class=\"datagrid-btn-separator\"></div>") .appendTo(tb); } else { var _4c = $("<a href=\"javascript:void(0)\"></a>"); _4c[0].onclick = eval(btn.handler || function() { }); _4c.css("float", "left").appendTo(tb).linkbutton($ .extend({}, btn, { plain : true })); } } } } else { $("div.datagrid-toolbar", _43).remove(); } $("div.datagrid-pager", _43).remove(); if (_42.pagination) { var _4d = $("<div class=\"datagrid-pager\"></div>").appendTo(_43); _4d.pagination({ pageNumber : _42.pageNumber, pageSize : _42.pageSize, pageList : _42.pageList, onSelectPage : function(_4e, _4f) { _42.pageNumber = _4e; _42.pageSize = _4f; _133(_41); } }); _42.pageSize = _4d.pagination("options").pageSize; } function _4b(_50, _51, _52) { if (!_51) { return; } $(_50).show(); $(_50).empty(); var t = $("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tbody></tbody></table>") .appendTo(_50); for (var i = 0; i < _51.length; i++) { var tr = $("<tr></tr>").appendTo($("tbody", t)); var _53 = _51[i]; for (var j = 0; j < _53.length; j++) { var col = _53[j]; var _54 = ""; if (col.rowspan) { _54 += "rowspan=\"" + col.rowspan + "\" "; } if (col.colspan) { _54 += "colspan=\"" + col.colspan + "\" "; } var td = $("<td " + _54 + "></td>").appendTo(tr); if (col.checkbox) { td.attr("field", col.field); $("<div class=\"datagrid-header-check\"></div>") .html("<input type=\"checkbox\"/>") .appendTo(td); } else { if (col.field) { td.attr("field", col.field); td .append("<div class=\"datagrid-cell\"><span></span><span class=\"datagrid-sort-icon\"></span></div>"); $("span", td).html(col.title); $("span.datagrid-sort-icon", td).html("&nbsp;"); var _55 = td.find("div.datagrid-cell"); if (col.resizable == false) { _55.attr("resizable", "false"); } col.boxWidth = $.boxModel ? (col.width - (_55 .outerWidth() - _55.width())) : col.width; _55.width(col.boxWidth); _55.css("text-align", (col.align || "left")); } else { $("<div class=\"datagrid-cell-group\"></div>") .html(col.title).appendTo(td); } } if (col.hidden) { td.hide(); } } } if (_52 && _42.rownumbers) { var td = $("<td rowspan=\"" + _42.frozenColumns.length + "\"><div class=\"datagrid-header-rownumber\"></div></td>"); if ($("tr", t).length == 0) { td.wrap("<tr></tr>").parent().appendTo($("tbody", t)); } else { td.prependTo($("tr:first", t)); } } }; }; function _56(_57) { var _58 = $.data(_57, "datagrid").panel; var _59 = $.data(_57, "datagrid").options; var _5a = $.data(_57, "datagrid").data; var _5b = _58.find("div.datagrid-body"); _5b.find("tr[datagrid-row-index]").unbind(".datagrid").bind( "mouseenter.datagrid", function() { var _5c = $(this).attr("datagrid-row-index"); _5b.find("tr[datagrid-row-index=" + _5c + "]") .addClass("datagrid-row-over"); }).bind("mouseleave.datagrid", function() { var _5d = $(this).attr("datagrid-row-index"); _5b.find("tr[datagrid-row-index=" + _5d + "]") .removeClass("datagrid-row-over"); }).bind("click.datagrid", function() { var _5e = $(this).attr("datagrid-row-index"); if (_59.singleSelect == true) { _68(_57); _69(_57, _5e); } else { if ($(this).hasClass("datagrid-row-selected")) { _6a(_57, _5e); } else { _69(_57, _5e); } } if (_59.onClickRow) { _59.onClickRow.call(_57, _5e, _5a.rows[_5e]); } }).bind("dblclick.datagrid", function() { var _5f = $(this).attr("datagrid-row-index"); if (_59.onDblClickRow) { _59.onDblClickRow.call(_57, _5f, _5a.rows[_5f]); } }).bind("contextmenu.datagrid", function(e) { var _60 = $(this).attr("datagrid-row-index"); if (_59.onRowContextMenu) { _59.onRowContextMenu.call(_57, e, _60, _5a.rows[_60]); } }); _5b.find("td[field]").unbind(".datagrid").bind("click.datagrid", function() { var _61 = $(this).parent().attr("datagrid-row-index"); var _62 = $(this).attr("field"); var _63 = _5a.rows[_61][_62]; _59.onClickCell.call(_57, _61, _62, _63); }).bind("dblclick.datagrid", function() { var _64 = $(this).parent().attr("datagrid-row-index"); var _65 = $(this).attr("field"); var _66 = _5a.rows[_64][_65]; _59.onDblClickCell.call(_57, _64, _65, _66); }); _5b.find("div.datagrid-cell-check input[type=checkbox]") .unbind(".datagrid").bind("click.datagrid", function(e) { var _67 = $(this).parent().parent().parent() .attr("datagrid-row-index"); if (_59.singleSelect) { _68(_57); _69(_57, _67); } else { if ($(this).is(":checked")) { _69(_57, _67); } else { _6a(_57, _67); } } e.stopPropagation(); }); }; function _6b(_6c) { var _6d = $.data(_6c, "datagrid").panel; var _6e = $.data(_6c, "datagrid").options; var _6f = _6d.find("div.datagrid-header"); _6f.find("td:has(div.datagrid-cell)").unbind(".datagrid").bind( "mouseenter.datagrid", function() { $(this).addClass("datagrid-header-over"); }).bind("mouseleave.datagrid", function() { $(this).removeClass("datagrid-header-over"); }).bind("contextmenu.datagrid", function(e) { var _70 = $(this).attr("field"); _6e.onHeaderContextMenu.call(_6c, e, _70); }); _6f.find("input[type=checkbox]").unbind(".datagrid").bind( "click.datagrid", function() { if (_6e.singleSelect) { return false; } if ($(this).is(":checked")) { _c4(_6c); } else { _c2(_6c); } }); var _71 = _6d.children("div.datagrid-view"); var _72 = _71.children("div.datagrid-view1"); var _73 = _71.children("div.datagrid-view2"); _73.children("div.datagrid-body").unbind(".datagrid").bind( "scroll.datagrid", function() { _72.children("div.datagrid-body").scrollTop($(this) .scrollTop()); _73.children("div.datagrid-header").scrollLeft($(this) .scrollLeft()); _73.children("div.datagrid-footer").scrollLeft($(this) .scrollLeft()); }); function _74(_75, _76) { _75.unbind(".datagrid"); if (!_76) { return; } _75.bind("click.datagrid", function(e) { var _77 = $(this).parent().attr("field"); var opt = _85(_6c, _77); if (!opt.sortable) { return; } _6e.sortName = _77; _6e.sortOrder = "asc"; var c = "datagrid-sort-asc"; if ($(this).hasClass("datagrid-sort-asc")) { c = "datagrid-sort-desc"; _6e.sortOrder = "desc"; } _6f .find("div.datagrid-cell") .removeClass("datagrid-sort-asc datagrid-sort-desc"); $(this).addClass(c); if (_6e.remoteSort) { _133(_6c); } else { var _78 = $.data(_6c, "datagrid").data; _a9(_6c, _78); } if (_6e.onSortColumn) { _6e.onSortColumn.call(_6c, _6e.sortName, _6e.sortOrder); } }); }; _74(_6f.find("div.datagrid-cell"), true); _6f.find("div.datagrid-cell").each(function() { $(this).resizable({ handles : "e", disabled : ($(this).attr("resizable") ? $(this) .attr("resizable") == "false" : false), minWidth : 25, onStartResize : function(e) { _6f.css("cursor", "e-resize"); _71.children("div.datagrid-resize-proxy").css({ left : e.pageX - $(_6d).offset().left - 1, display : "block" }); _74($(this), false); }, onResize : function(e) { _71.children("div.datagrid-resize-proxy").css({ display : "block", left : e.pageX - $(_6d).offset().left - 1 }); return false; }, onStopResize : function(e) { _6f.css("cursor", ""); var _79 = $(this).parent().attr("field"); var col = _85(_6c, _79); col.width = $(this).outerWidth(); col.boxWidth = $.boxModel == true ? $(this).width() : $(this).outerWidth(); _38(_6c, _79); _7d(_6c); setTimeout(function() { _74($(e.data.target), true); }, 0); var _7a = _6d.find("div.datagrid-view2"); _7a.find("div.datagrid-header").scrollLeft(_7a .find("div.datagrid-body").scrollLeft()); _71.children("div.datagrid-resize-proxy").css("display", "none"); _6e.onResizeColumn.call(_6c, _79, col.width); } }); }); _72.children("div.datagrid-header").find("div.datagrid-cell") .resizable({ onStopResize : function(e) { _6f.css("cursor", ""); var _7b = $(this).parent().attr("field"); var col = _85(_6c, _7b); col.width = $(this).outerWidth(); col.boxWidth = $.boxModel == true ? $(this).width() : $(this).outerWidth(); _38(_6c, _7b); var _7c = _6d.find("div.datagrid-view2"); _7c.find("div.datagrid-header").scrollLeft(_7c .find("div.datagrid-body").scrollLeft()); _71.children("div.datagrid-resize-proxy").css( "display", "none"); _a(_6c); _7d(_6c); setTimeout(function() { _74($(e.data.target), true); }, 0); _6e.onResizeColumn.call(_6c, _7b, col.width); } }); }; function _7d(_7e) { var _7f = $.data(_7e, "datagrid").options; if (!_7f.fitColumns) { return; } var _80 = $.data(_7e, "datagrid").panel; var _81 = _80.find("div.datagrid-view2 div.datagrid-header"); var _82 = 0; var _83; var _84 = _3f(_7e, false); for (var i = 0; i < _84.length; i++) { var col = _85(_7e, _84[i]); if (!col.hidden && !col.checkbox) { _82 += col.width; _83 = col; } } var _86 = _81.children("div.datagrid-header-inner").show(); var _87 = _81.width() - _81.find("table").width() - _7f.scrollbarSize; var _88 = _87 / _82; if (!_7f.showHeader) { _86.hide(); } for (var i = 0; i < _84.length; i++) { var col = _85(_7e, _84[i]); if (!col.hidden && !col.checkbox) { var _89 = Math.floor(col.width * _88); _8a(col, _89); _87 -= _89; } } _38(_7e); if (_87) { _8a(_83, _87); _38(_7e, _83.field); } function _8a(col, _8b) { if(!col)return; col.width += _8b; col.boxWidth += _8b; _81.find("td[field=\"" + col.field + "\"] div.datagrid-cell") .width(col.boxWidth); }; }; function _38(_8c, _8d) { var _8e = $.data(_8c, "datagrid").panel; var bf = _8e.find("div.datagrid-body,div.datagrid-footer"); if (_8d) { fix(_8d); } else { _8e.find("div.datagrid-header td[field]").each(function() { fix($(this).attr("field")); }); } _91(_8c); setTimeout(function() { _1d(_8c); _9a(_8c); }, 0); function fix(_8f) { var col = _85(_8c, _8f); bf.find("td[field=\"" + _8f + "\"]").each(function() { var td = $(this); var _90 = td.attr("colspan") || 1; if (_90 == 1) { td.find("div.datagrid-cell").width(col.boxWidth); td.find("div.datagrid-editable").width(col.width); } }); }; }; function _91(_92) { var _93 = $.data(_92, "datagrid").panel; var _94 = _93.find("div.datagrid-header"); _93.find("div.datagrid-body td.datagrid-td-merged").each(function() { var td = $(this); var _95 = td.attr("colspan") || 1; var _96 = td.attr("field"); var _97 = _94.find("td[field=\"" + _96 + "\"]"); var _98 = _97.width(); for (var i = 1; i < _95; i++) { _97 = _97.next(); _98 += _97.outerWidth(); } var _99 = td.children("div.datagrid-cell"); if ($.boxModel == true) { _99.width(_98 - (_99.outerWidth() - _99.width())); } else { _99.width(_98); } }); }; function _9a(_9b) { var _9c = $.data(_9b, "datagrid").panel; _9c.find("div.datagrid-editable").each(function() { var ed = $.data(this, "datagrid.editor"); if (ed.actions.resize) { ed.actions.resize(ed.target, $(this).width()); } }); }; function _85(_9d, _9e) { var _9f = $.data(_9d, "datagrid").options; if (_9f.columns) { for (var i = 0; i < _9f.columns.length; i++) { var _a0 = _9f.columns[i]; for (var j = 0; j < _a0.length; j++) { var col = _a0[j]; if (col.field == _9e) { return col; } } } } if (_9f.frozenColumns) { for (var i = 0; i < _9f.frozenColumns.length; i++) { var _a0 = _9f.frozenColumns[i]; for (var j = 0; j < _a0.length; j++) { var col = _a0[j]; if (col.field == _9e) { return col; } } } } return null; }; function _3f(_a1, _a2) { var _a3 = $.data(_a1, "datagrid").options; var _a4 = (_a2 == true) ? (_a3.frozenColumns || [[]]) : _a3.columns; if (!_a4 || _a4.length == 0) { return []; } var _a5 = []; function _a6(_a7) { var c = 0; var i = 0; while (true) { if (_a5[i] == undefined) { if (c == _a7) { return i; } c++; } i++; } }; function _a8(r) { var ff = []; var c = 0; for (var i = 0; i < _a4[r].length; i++) { var col = _a4[r][i]; if (col.field) { ff.push([c, col.field]); } c += parseInt(col.colspan || "1"); } for (var i = 0; i < ff.length; i++) { ff[i][0] = _a6(ff[i][0]); } for (var i = 0; i < ff.length; i++) { var f = ff[i]; _a5[f[0]] = f[1]; } }; for (var i = 0; i < _a4.length; i++) { _a8(i); } return _a5; }; function _a9(_aa, _ab) { var _ac = $.data(_aa, "datagrid").options; var _ad = $.data(_aa, "datagrid").panel; var _ae = $.data(_aa, "datagrid").selectedRows; _ab = _ac.loadFilter.call(_aa, _ab); var _af = _ab.rows; $.data(_aa, "datagrid").data = _ab; if (_ab.footer) { $.data(_aa, "datagrid").footer = _ab.footer; } if (!_ac.remoteSort) { var opt = _85(_aa, _ac.sortName); if (opt) { var _b0 = opt.sorter || function(a, b) { return (a > b ? 1 : -1); }; _ab.rows.sort(function(r1, r2) { return _b0(r1[_ac.sortName], r2[_ac.sortName]) * (_ac.sortOrder == "asc" ? 1 : -1); }); } } var _b1 = _ad.children("div.datagrid-view"); var _b2 = _b1.children("div.datagrid-view1"); var _b3 = _b1.children("div.datagrid-view2"); if (_ac.view.onBeforeRender) { _ac.view.onBeforeRender.call(_ac.view, _aa, _af); } _ac.view.render.call(_ac.view, _aa, _b3.children("div.datagrid-body"), false); _ac.view.render.call(_ac.view, _aa, _b2.children("div.datagrid-body") .children("div.datagrid-body-inner"), true); if (_ac.showFooter) { _ac.view.renderFooter.call(_ac.view, _aa, _b3 .find("div.datagrid-footer-inner"), false); _ac.view.renderFooter.call(_ac.view, _aa, _b2 .find("div.datagrid-footer-inner"), true); } if (_ac.view.onAfterRender) { _ac.view.onAfterRender.call(_ac.view, _aa); } _ac.onLoadSuccess.call(_aa, _ab); var _b4 = _ad.children("div.datagrid-pager"); if (_b4.length) { if (_b4.pagination("options").total != _ab.total) { _b4.pagination({ total : _ab.total }); } } _1d(_aa); _56(_aa); _b3.children("div.datagrid-body").triggerHandler("scroll"); if (_ac.idField) { for (var i = 0; i < _af.length; i++) { if (_b5(_af[i])) { _de(_aa, _af[i][_ac.idField]); } } } function _b5(row) { for (var i = 0; i < _ae.length; i++) { if (_ae[i][_ac.idField] == row[_ac.idField]) { _ae[i] = row; return true; } } return false; }; }; function _b6(_b7, row) { var _b8 = $.data(_b7, "datagrid").options; var _b9 = $.data(_b7, "datagrid").data.rows; if (typeof row == "object") { return _b9.indexOf(row); } else { for (var i = 0; i < _b9.length; i++) { if (_b9[i][_b8.idField] == row) { return i; } } return -1; } }; function _ba(_bb) { var _bc = $.data(_bb, "datagrid").options; var _bd = $.data(_bb, "datagrid").panel; var _be = $.data(_bb, "datagrid").data; if (_bc.idField) { return $.data(_bb, "datagrid").selectedRows; } else { var _bf = []; $("div.datagrid-view2 div.datagrid-body tr.datagrid-row-selected", _bd).each(function() { var _c0 = parseInt($(this).attr("datagrid-row-index")); _bf.push(_be.rows[_c0]); }); return _bf; } }; function _68(_c1) { _c2(_c1); var _c3 = $.data(_c1, "datagrid").selectedRows; _c3.splice(0, _c3.length); }; function _c4(_c5) { var _c6 = $.data(_c5, "datagrid").options; var _c7 = $.data(_c5, "datagrid").panel; var _c8 = $.data(_c5, "datagrid").data; var _c9 = $.data(_c5, "datagrid").selectedRows; var _ca = _c8.rows; var _cb = _c7.find("div.datagrid-body"); _cb.find("tr").addClass("datagrid-row-selected"); var _cc = _cb.find("div.datagrid-cell-check input[type=checkbox]"); $.fn.prop ? _cc.prop("checked", true) : _cc.attr("checked", true); for (var _cd = 0; _cd < _ca.length; _cd++) { if (_c6.idField) { (function() { var row = _ca[_cd]; for (var i = 0; i < _c9.length; i++) { if (_c9[i][_c6.idField] == row[_c6.idField]) { return; } } _c9.push(row); })(); } } _c6.onSelectAll.call(_c5, _ca); }; function _c2(_ce) { var _cf = $.data(_ce, "datagrid").options; var _d0 = $.data(_ce, "datagrid").panel; var _d1 = $.data(_ce, "datagrid").data; var _d2 = $.data(_ce, "datagrid").selectedRows; var _d3 = _d0 .find("div.datagrid-body div.datagrid-cell-check input[type=checkbox]"); $.fn.prop ? _d3.prop("checked", false) : _d3.attr("checked", false); $("div.datagrid-body tr.datagrid-row-selected", _d0) .removeClass("datagrid-row-selected"); if (_cf.idField) { for (var _d4 = 0; _d4 < _d1.rows.length; _d4++) { _d2.removeById(_cf.idField, _d1.rows[_d4][_cf.idField]); } } _cf.onUnselectAll.call(_ce, _d1.rows); }; function _69(_d5, _d6) { var _d7 = $.data(_d5, "datagrid").panel; var _d8 = $.data(_d5, "datagrid").options; var _d9 = $.data(_d5, "datagrid").data; var _da = $.data(_d5, "datagrid").selectedRows; if (_d6 < 0 || _d6 >= _d9.rows.length) { return; } if (_d8.singleSelect == true) { _68(_d5); } var tr = $("div.datagrid-body tr[datagrid-row-index=" + _d6 + "]", _d7); if (!tr.hasClass("datagrid-row-selected")) { tr.addClass("datagrid-row-selected"); var ck = $("div.datagrid-cell-check input[type=checkbox]", tr); $.fn.prop ? ck.prop("checked", true) : ck.attr("checked", true); if (_d8.idField) { var row = _d9.rows[_d6]; (function() { for (var i = 0; i < _da.length; i++) { if (_da[i][_d8.idField] == row[_d8.idField]) { return; } } _da.push(row); })(); } } _d8.onSelect.call(_d5, _d6, _d9.rows[_d6]); var _db = _d7.find("div.datagrid-view2"); var _dc = _db.find("div.datagrid-header").outerHeight(); var _dd = _db.find("div.datagrid-body"); var top = tr.position().top - _dc; if (top <= 0) { _dd.scrollTop(_dd.scrollTop() + top); } else { if (top + tr.outerHeight() > _dd.height() - 18) { _dd.scrollTop(_dd.scrollTop() + top + tr.outerHeight() - _dd.height() + 18); } } }; function _de(_df, _e0) { var _e1 = $.data(_df, "datagrid").options; var _e2 = $.data(_df, "datagrid").data; if (_e1.idField) { var _e3 = -1; for (var i = 0; i < _e2.rows.length; i++) { if (_e2.rows[i][_e1.idField] == _e0) { _e3 = i; break; } } if (_e3 >= 0) { _69(_df, _e3); } } }; function _6a(_e4, _e5) { var _e6 = $.data(_e4, "datagrid").options; var _e7 = $.data(_e4, "datagrid").panel; var _e8 = $.data(_e4, "datagrid").data; var _e9 = $.data(_e4, "datagrid").selectedRows; if (_e5 < 0 || _e5 >= _e8.rows.length) { return; } var _ea = _e7.find("div.datagrid-body"); var tr = $("tr[datagrid-row-index=" + _e5 + "]", _ea); var ck = $("tr[datagrid-row-index=" + _e5 + "] div.datagrid-cell-check input[type=checkbox]", _ea); tr.removeClass("datagrid-row-selected"); $.fn.prop ? ck.prop("checked", false) : ck.attr("checked", false); var row = _e8.rows[_e5]; if (_e6.idField) { _e9.removeById(_e6.idField, row[_e6.idField]); } _e6.onUnselect.call(_e4, _e5, row); }; function _eb(_ec, _ed) { var _ee = $.data(_ec, "datagrid").options; var tr = _ee.editConfig.getTr(_ec, _ed); var row = _ee.editConfig.getRow(_ec, _ed); if (tr.hasClass("datagrid-row-editing")) { return; } if (_ee.onBeforeEdit.call(_ec, _ed, row) == false) { return; } tr.addClass("datagrid-row-editing"); _ef(_ec, _ed); _9a(_ec); tr.find("div.datagrid-editable").each(function() { var _f0 = $(this).parent().attr("field"); var ed = $.data(this, "datagrid.editor"); ed.actions.setValue(ed.target, row[_f0]); }); _f1(_ec, _ed); }; /** * zzy+ * 获取当前正在编辑的行的值 */ function getCurrEdittingRow(_f3, _f4){ var _f6 = $.data(_f3, "datagrid").options; var tr = _f6.editConfig.getTr(_f3, _f4); var row = _f6.editConfig.getRow(_f3, _f4); if (!tr.hasClass("datagrid-row-editing")) { return; }; var _fa = {}; tr.find("div.datagrid-editable").each(function() { var _fb = $(this).parent().attr("field"); var ed = $.data(this, "datagrid.editor"); var _fc = ed.actions.getValue(ed.target); if (row[_fb] != _fc) { row[_fb] = _fc; _fa[_fb] = _fc; } }); return $.extend(row, _fa); } function _f2(_f3, _f4, _f5) { var _f6 = $.data(_f3, "datagrid").options; var _f7 = $.data(_f3, "datagrid").updatedRows; var _f8 = $.data(_f3, "datagrid").insertedRows; var tr = _f6.editConfig.getTr(_f3, _f4); var row = _f6.editConfig.getRow(_f3, _f4); if (!tr.hasClass("datagrid-row-editing")) { return; } if (!_f5) { if (!_f1(_f3, _f4)) { return; } var _f9 = false; var _fa = {}; tr.find("div.datagrid-editable").each(function() { var _fb = $(this).parent().attr("field"); var ed = $.data(this, "datagrid.editor"); var _fc = ed.actions.getValue(ed.target); if (row[_fb] != _fc) { row[_fb] = _fc; _f9 = true; _fa[_fb] = _fc; } }); if (_f9) { if (_f8.indexOf(row) == -1) { if (_f7.indexOf(row) == -1) { _f7.push(row); } } } } tr.removeClass("datagrid-row-editing"); _fd(_f3, _f4); $(_f3).datagrid("refreshRow", _f4); if (!_f5) { _f6.onAfterEdit.call(_f3, _f4, row, _fa); } else { _f6.onCancelEdit.call(_f3, _f4, row); } }; function _fe(_ff, _100) { var opts = $.data(_ff, "datagrid").options; var tr = opts.editConfig.getTr(_ff, _100); var _101 = []; tr.children("td").each(function() { var cell = $(this).find("div.datagrid-editable"); if (cell.length) { var ed = $.data(cell[0], "datagrid.editor"); _101.push(ed); } }); return _101; }; function _102(_103, _104) { var _105 = _fe(_103, _104.index); for (var i = 0; i < _105.length; i++) { if (_105[i].field == _104.field) { return _105[i]; } } return null; }; function _ef(_106, _107) { var opts = $.data(_106, "datagrid").options; var tr = opts.editConfig.getTr(_106, _107); tr.children("td").each(function() { var cell = $(this).find("div.datagrid-cell"); var _108 = $(this).attr("field"); var col = _85(_106, _108); if (col && col.editor) { var _109, _10a; if (typeof col.editor == "string") { _109 = col.editor; } else { _109 = col.editor.type; _10a = col.editor.options; } var _10b = opts.editors[_109]; if (_10b) { var _10c = cell.html(); var _10d = cell.outerWidth(); cell.addClass("datagrid-editable"); if ($.boxModel == true) { cell.width(_10d - (cell.outerWidth() - cell.width())); } cell .html("<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\"><tr><td></td></tr></table>"); cell.children("table").attr("align", col.align); cell.children("table").bind("click dblclick contextmenu", function(e) { e.stopPropagation(); }); $.data(cell[0], "datagrid.editor", { actions : _10b, target : _10b.init(cell.find("td"), _10a), field : _108, type : _109, oldHtml : _10c }); } } }); _1d(_106, _107); }; function _fd(_10e, _10f) { var opts = $.data(_10e, "datagrid").options; var tr = opts.editConfig.getTr(_10e, _10f); tr.children("td").each(function() { var cell = $(this).find("div.datagrid-editable"); if (cell.length) { var ed = $.data(cell[0], "datagrid.editor"); if (ed.actions.destroy) { ed.actions.destroy(ed.target); } cell.html(ed.oldHtml); $.removeData(cell[0], "datagrid.editor"); var _110 = cell.outerWidth(); cell.removeClass("datagrid-editable"); if ($.boxModel == true) { cell.width(_110 - (cell.outerWidth() - cell.width())); } } }); }; function _f1(_111, _112) { var tr = $.data(_111, "datagrid").options.editConfig.getTr(_111, _112); if (!tr.hasClass("datagrid-row-editing")) { return true; } var vbox = tr.find(".validatebox-text"); vbox.validatebox("validate"); vbox.trigger("mouseleave"); var _113 = tr.find(".validatebox-invalid"); return _113.length == 0; }; function _114(_115, _116) { var _117 = $.data(_115, "datagrid").insertedRows; var _118 = $.data(_115, "datagrid").deletedRows; var _119 = $.data(_115, "datagrid").updatedRows; if (!_116) { var rows = []; rows = rows.concat(_117); rows = rows.concat(_118); rows = rows.concat(_119); return rows; } else { if (_116 == "inserted") { return _117; } else { if (_116 == "deleted") { return _118; } else { if (_116 == "updated") { return _119; } } } } return []; }; function _11a(_11b, _11c) { var opts = $.data(_11b, "datagrid").options; var data = $.data(_11b, "datagrid").data; var _11d = $.data(_11b, "datagrid").insertedRows; var _11e = $.data(_11b, "datagrid").deletedRows; var _11f = $.data(_11b, "datagrid").selectedRows; $(_11b).datagrid("cancelEdit", _11c); var row = data.rows[_11c]; if (_11d.indexOf(row) >= 0) { _11d.remove(row); } else { _11e.push(row); } _11f.removeById(opts.idField, data.rows[_11c][opts.idField]); opts.view.deleteRow.call(opts.view, _11b, _11c); if (opts.height == "auto") { _1d(_11b); } }; function _120(_121, _122) { var view = $.data(_121, "datagrid").options.view; var _123 = $.data(_121, "datagrid").insertedRows; view.insertRow.call(view, _121, _122.index, _122.row); _56(_121); _123.push(_122.row); }; function _124(_125, row) { var view = $.data(_125, "datagrid").options.view; var _126 = $.data(_125, "datagrid").insertedRows; view.insertRow.call(view, _125, null, row); _56(_125); _126.push(row); }; function _127(_128) { var data = $.data(_128, "datagrid").data; var rows = data.rows; var _129 = []; for (var i = 0; i < rows.length; i++) { _129.push($.extend({}, rows[i])); } $.data(_128, "datagrid").originalRows = _129; $.data(_128, "datagrid").updatedRows = []; $.data(_128, "datagrid").insertedRows = []; $.data(_128, "datagrid").deletedRows = []; }; function _12a(_12b) { var data = $.data(_12b, "datagrid").data; var ok = true; for (var i = 0, len = data.rows.length; i < len; i++) { if (_f1(_12b, i)) { _f2(_12b, i, false); } else { ok = false; } } if (ok) { _127(_12b); } }; function _12c(_12d) { var opts = $.data(_12d, "datagrid").options; var _12e = $.data(_12d, "datagrid").originalRows; var _12f = $.data(_12d, "datagrid").insertedRows; var _130 = $.data(_12d, "datagrid").deletedRows; var _131 = $.data(_12d, "datagrid").selectedRows; var data = $.data(_12d, "datagrid").data; for (var i = 0; i < data.rows.length; i++) { _f2(_12d, i, true); } var _132 = []; for (var i = 0; i < _131.length; i++) { _132.push(_131[i][opts.idField]); } _131.splice(0, _131.length); data.total += _130.length - _12f.length; data.rows = _12e; _a9(_12d, data); for (var i = 0; i < _132.length; i++) { _de(_12d, _132[i]); } _127(_12d); }; function _133(_134, _135) { var _136 = $.data(_134, "datagrid").panel; var opts = $.data(_134, "datagrid").options; // if (_135) { // opts.queryParams = _135; // } opts.queryParams = opts.queryParams || {}; var param = $.isFunction(opts.queryParams) ? opts.queryParams() : opts.queryParams; var _137 = $.extend({}, param); if(_135){ $.extend(_137, _135); } // if (!opts.url) { // return; // } // var _137 = $.extend({}, opts.queryParams); // 分页信息 if (opts.pagination) { //zzy+ 修改后台分页参数 $.extend(_137, { start : ((opts.pageNumber-1) * opts.pageSize), limit : opts.pageSize }); // $.extend(_137, { // page : opts.pageNumber, // rows : opts.pageSize // }); } //排序信息 if (opts.sortName) { $.extend(_137, { sort : opts.sortName, order : opts.sortOrder }); } // 加载前事件 if (opts.onBeforeLoad.call(_134, _137) == false) { return; } $(_134).datagrid("loading"); // 延时加载 setTimeout(function() { _138(); }, 0); function _138() { // zzy+ 统一ajax请求 $.query(opts['list'], _137, function(data){ // 成功处理 setTimeout(function() { $(_134).datagrid("loaded"); }, 0); _a9(_134, data); setTimeout(function() { _127(_134); }, 0); }, function(){ // 失败处理 setTimeout(function() { $(_134).datagrid("loaded"); }, 0); if (opts.onLoadError) { opts.onLoadError.apply(_134, arguments); } }) // $.ajax({ // type : opts.method, // url : opts.url, // data : _137, // dataType : "json", // success : function(data) { // setTimeout(function() { // $(_134).datagrid("loaded"); // }, 0); // _a9(_134, data); // setTimeout(function() { // _127(_134); // }, 0); // }, // error : function() { // setTimeout(function() { $(_134).datagrid("loaded"); }, 0); // if (opts.onLoadError) { // opts.onLoadError.apply(_134, arguments); // } // } // }); }; }; function _139(_13a, _13b) { var rows = $.data(_13a, "datagrid").data.rows; var _13c = $.data(_13a, "datagrid").panel; _13b.rowspan = _13b.rowspan || 1; _13b.colspan = _13b.colspan || 1; if (_13b.index < 0 || _13b.index >= rows.length) { return; } if (_13b.rowspan == 1 && _13b.colspan == 1) { return; } var _13d = rows[_13b.index][_13b.field]; var tr = _13c.find("div.datagrid-body tr[datagrid-row-index=" + _13b.index + "]"); var td = tr.find("td[field=\"" + _13b.field + "\"]"); td.attr("rowspan", _13b.rowspan).attr("colspan", _13b.colspan); td.addClass("datagrid-td-merged"); for (var i = 1; i < _13b.colspan; i++) { td = td.next(); td.hide(); rows[_13b.index][td.attr("field")] = _13d; } for (var i = 1; i < _13b.rowspan; i++) { tr = tr.next(); var td = tr.find("td[field=\"" + _13b.field + "\"]").hide(); rows[_13b.index + i][td.attr("field")] = _13d; for (var j = 1; j < _13b.colspan; j++) { td = td.next(); td.hide(); rows[_13b.index + i][td.attr("field")] = _13d; } } setTimeout(function() { _91(_13a); }, 0); }; $.fn.datagrid = function(_13e, _13f) { if (typeof _13e == "string") { return $.fn.datagrid.methods[_13e](this, _13f); } _13e = _13e || {}; // zzy+ 设置CRUD的相关url $.createURL(_13e); return this.each(function() { var _140 = $.data(this, "datagrid"); var opts; if (_140) { opts = $.extend(_140.options, _13e); _140.options = opts; } else { opts = $.extend({}, $.extend({}, $.fn.datagrid.defaults, { queryParams : {} }), $.fn.datagrid.parseOptions(this), _13e); $.createURL(opts); $(this).css("width", "").css("height", ""); // 解析列 var _141 = _2e(this, opts.rownumbers); if (!opts.columns) { opts.columns = _141.columns; } if (!opts.frozenColumns) { opts.frozenColumns = _141.frozenColumns; } $.data(this, "datagrid", { options : opts, panel : _141.panel, selectedRows : [], data : { total : 0, rows : [] }, originalRows : [], updatedRows : [], insertedRows : [], deletedRows : [] }); } _40(this); if (!_140) { var data = _3b(this); if (data.total > 0) { _a9(this, data); _127(this); } } _5(this); if ((opts.url && opts.list) && opts['autoLoad']!==false) { _133(this); } _6b(this); }); }; var _142 = { text : { init : function(_143, _144) { var _145 = $("<input type=\"text\" class=\"datagrid-editable-input\">") .appendTo(_143); return _145; }, getValue : function(_146) { return $(_146).val(); }, setValue : function(_147, _148) { $(_147).val(_148); }, resize : function(_149, _14a) { var _14b = $(_149); if ($.boxModel == true) { _14b.width(_14a - (_14b.outerWidth() - _14b.width())); } else { _14b.width(_14a); } } }, textarea : { init : function(_14c, _14d) { var _14e = $("<textarea class=\"datagrid-editable-input\"></textarea>") .appendTo(_14c); return _14e; }, getValue : function(_14f) { return $(_14f).val(); }, setValue : function(_150, _151) { $(_150).val(_151); }, resize : function(_152, _153) { var _154 = $(_152); if ($.boxModel == true) { _154.width(_153 - (_154.outerWidth() - _154.width())); } else { _154.width(_153); } } }, checkbox : { init : function(_155, _156) { var _157 = $("<input type=\"checkbox\">").appendTo(_155); _157.val(_156.on); _157.attr("offval", _156.off); return _157; }, getValue : function(_158) { if ($(_158).is(":checked")) { return $(_158).val(); } else { return $(_158).attr("offval"); } }, setValue : function(_159, _15a) { var _15b = false; if ($(_159).val() == _15a) { _15b = true; } $.fn.prop ? $(_159).prop("checked", _15b) : $(_159).attr( "checked", _15b); } }, numberbox : { init : function(_15c, _15d) { var _15e = $("<input type=\"text\" class=\"datagrid-editable-input\">") .appendTo(_15c); _15e.numberbox(_15d); return _15e; }, destroy : function(_15f) { $(_15f).numberbox("destroy"); }, getValue : function(_160) { return $(_160).val(); }, setValue : function(_161, _162) { $(_161).val(_162); }, resize : function(_163, _164) { var _165 = $(_163); if ($.boxModel == true) { _165.width(_164 - (_165.outerWidth() - _165.width())); } else { _165.width(_164); } } }, validatebox : { init : function(_166, _167) { var _168 = $("<input type=\"text\" class=\"datagrid-editable-input\">") .appendTo(_166); _168.validatebox(_167); return _168; }, destroy : function(_169) { $(_169).validatebox("destroy"); }, getValue : function(_16a) { return $(_16a).val(); }, setValue : function(_16b, _16c) { $(_16b).val(_16c); }, resize : function(_16d, _16e) { var _16f = $(_16d); if ($.boxModel == true) { _16f.width(_16e - (_16f.outerWidth() - _16f.width())); } else { _16f.width(_16e); } } }, datebox : { init : function(_170, _171) { var _172 = $("<input type=\"text\">").appendTo(_170); _172.datebox(_171); return _172; }, destroy : function(_173) { $(_173).datebox("destroy"); }, getValue : function(_174) { return $(_174).datebox("getValue"); }, setValue : function(_175, _176) { $(_175).datebox("setValue", _176); }, resize : function(_177, _178) { $(_177).datebox("resize", _178); } }, // zzy+ datetimebox : { init : function(_170, _171) { var _172 = $("<input type=\"text\">").appendTo(_170); _172.datetimebox(_171); return _172; }, destroy : function(_173) { $(_173).datebox("destroy"); }, getValue : function(_174) { return $(_174).datebox("getValue"); }, setValue : function(_175, _176) { $(_175).datebox("setValue", _176); }, resize : function(_177, _178) { $(_177).datebox("resize", _178); } }, combobox : { init : function(_179, _17a) { var _17b = $("<input type=\"text\">").appendTo(_179); _17b.combobox(_17a || {}); return _17b; }, destroy : function(_17c) { $(_17c).combobox("destroy"); }, getValue : function(_17d) { return $(_17d).combobox("getValue"); }, setValue : function(_17e, _17f) { $(_17e).combobox("setValue", _17f); }, resize : function(_180, _181) { $(_180).combobox("resize", _181); } }, combotree : { init : function(_182, _183) { var _184 = $("<input type=\"text\">").appendTo(_182); _184.combotree(_183); return _184; }, destroy : function(_185) { $(_185).combotree("destroy"); }, getValue : function(_186) { return $(_186).combotree("getValue"); }, setValue : function(_187, _188) { $(_187).combotree("setValue", _188); }, resize : function(_189, _18a) { $(_189).combotree("resize", _18a); } } }; $.fn.datagrid.methods = { options : function(jq) { var _18b = $.data(jq[0], "datagrid").options; var _18c = $.data(jq[0], "datagrid").panel.panel("options"); var opts = $.extend(_18b, { width : _18c.width, height : _18c.height, closed : _18c.closed, collapsed : _18c.collapsed, minimized : _18c.minimized, maximized : _18c.maximized }); var _18d = jq.datagrid("getPager"); if (_18d.length) { var _18e = _18d.pagination("options"); $.extend(opts, { pageNumber : _18e.pageNumber, pageSize : _18e.pageSize }); } return opts; }, getPanel : function(jq) { return $.data(jq[0], "datagrid").panel; }, getPager : function(jq) { return $.data(jq[0], "datagrid").panel.find("div.datagrid-pager"); }, getColumnFields : function(jq, _18f) { return _3f(jq[0], _18f); }, getColumnOption : function(jq, _190) { return _85(jq[0], _190); }, resize : function(jq, _191) { return jq.each(function() { _5(this, _191); }); }, load : function(jq, _192) { return jq.each(function() { var opts = $(this).datagrid("options"); opts.pageNumber = 1; var _193 = $(this).datagrid("getPager"); _193.pagination({ pageNumber : 1 }); _133(this, _192); }); }, reload : function(jq, _194) { jq.datagrid('clearSelections'); return jq.each(function() { _133(this, _194); }); }, reloadFooter : function(jq, _195) { return jq.each(function() { var opts = $.data(this, "datagrid").options; var view = $(this).datagrid("getPanel") .children("div.datagrid-view"); var _196 = view.children("div.datagrid-view1"); var _197 = view.children("div.datagrid-view2"); if (_195) { $.data(this, "datagrid").footer = _195; } if (opts.showFooter) { opts.view.renderFooter.call(opts.view, this, _197 .find("div.datagrid-footer-inner"), false); opts.view.renderFooter.call(opts.view, this, _196 .find("div.datagrid-footer-inner"), true); if (opts.view.onAfterRender) { opts.view.onAfterRender.call(opts.view, this); } $(this).datagrid("fixRowHeight"); } }); }, loading : function(jq) { return jq.each(function() { var opts = $.data(this, "datagrid").options; $(this).datagrid("getPager").pagination("loading"); if (opts.loadMsg) { var _198 = $(this).datagrid("getPanel"); $("<div class=\"datagrid-mask\" style=\"display:block\"></div>") .appendTo(_198); $("<div class=\"datagrid-mask-msg\" style=\"display:block\"></div>") .html(opts.loadMsg).appendTo(_198); _19(this); } }); }, loaded : function(jq) { return jq.each(function() { $(this).datagrid("getPager").pagination("loaded"); var _199 = $(this).datagrid("getPanel"); _199.children("div.datagrid-mask-msg").remove(); _199.children("div.datagrid-mask").remove(); }); }, fitColumns : function(jq) { return jq.each(function() { _7d(this); }); }, fixColumnSize : function(jq) { return jq.each(function() { _38(this); }); }, fixRowHeight : function(jq, _19a) { return jq.each(function() { _1d(this, _19a); }); }, loadData : function(jq, data) { return jq.each(function() { _a9(this, data); _127(this); }); }, getData : function(jq) { return $.data(jq[0], "datagrid").data; }, getRows : function(jq) { return $.data(jq[0], "datagrid").data.rows; }, getFooterRows : function(jq) { return $.data(jq[0], "datagrid").footer; }, getRowIndex : function(jq, id) { return _b6(jq[0], id); }, getSelected : function(jq) { var rows = _ba(jq[0]); return rows.length > 0 ? rows[0] : null; }, getSelections : function(jq) { return _ba(jq[0]); }, clearSelections : function(jq) { return jq.each(function() { _68(this); }); }, selectAll : function(jq) { return jq.each(function() { _c4(this); }); }, unselectAll : function(jq) { return jq.each(function() { _c2(this); }); }, selectRow : function(jq, _19b) { return jq.each(function() { _69(this, _19b); }); }, selectRecord : function(jq, id) { return jq.each(function() { _de(this, id); }); }, unselectRow : function(jq, _19c) { return jq.each(function() { _6a(this, _19c); }); }, beginEdit : function(jq, _19d) { return jq.each(function() { _eb(this, _19d); }); }, endEdit : function(jq, _19e) { return jq.each(function() { _f2(this, _19e, false); }); }, /** * zzy+ * 获取当前正在编辑的行值 */ getCurrRow: function(jq, _19e){ var target = null; jq.each(function() { target = this; }); return getCurrEdittingRow(target, _19e); }, cancelEdit : function(jq, _19f) { return jq.each(function() { _f2(this, _19f, true); }); }, getEditors : function(jq, _1a0) { return _fe(jq[0], _1a0); }, getEditor : function(jq, _1a1) { return _102(jq[0], _1a1); }, refreshRow : function(jq, _1a2) { return jq.each(function() { var opts = $.data(this, "datagrid").options; opts.view.refreshRow.call(opts.view, this, _1a2); }); }, validateRow : function(jq, _1a3) { return _f1(jq[0], _1a3); }, updateRow : function(jq, _1a4) { return jq.each(function() { var opts = $.data(this, "datagrid").options; //zzy+ 处理更新 if(!_1a4.index || !_1a4.row){ _1a4 = { index: jq.datagrid('getRowIndex', _1a4[opts['idField']]), row: _1a4 }; } opts.view.updateRow.call(opts.view, this, _1a4.index, _1a4.row); }); }, appendRow : function(jq, row) { return jq.each(function() { _124(this, row); }); }, insertRow : function(jq, _1a5) { return jq.each(function() { _120(this, _1a5); }); }, deleteRow : function(jq, _1a6) { if($.isObject(_1a6)){ _1a6 = jq.datagrid('getRowIndex', _1a6) } return jq.each(function() { _11a(this, _1a6); }); }, getChanges : function(jq, _1a7) { return _114(jq[0], _1a7); }, acceptChanges : function(jq) { return jq.each(function() { _12a(this); }); }, rejectChanges : function(jq) { return jq.each(function() { _12c(this); }); }, mergeCells : function(jq, _1a8) { return jq.each(function() { _139(this, _1a8); }); }, showColumn : function(jq, _1a9) { return jq.each(function() { var _1aa = $(this).datagrid("getPanel"); _1aa.find("td[field=\"" + _1a9 + "\"]").show(); $(this).datagrid("getColumnOption", _1a9).hidden = false; $(this).datagrid("fitColumns"); }); }, hideColumn : function(jq, _1ab) { return jq.each(function() { var _1ac = $(this).datagrid("getPanel"); _1ac.find("td[field=\"" + _1ab + "\"]").hide(); $(this).datagrid("getColumnOption", _1ab).hidden = true; $(this).datagrid("fitColumns"); }); } }; /** * 解析配置项 */ $.fn.datagrid.parseOptions = function(_1ad) { var t = $(_1ad); var cfg = $.extend({}, $.fn.panel.parseOptions(_1ad), { fitColumns : (t.attr("fitColumns") ? t.attr("fitColumns") == "true" : undefined), striped : (t.attr("striped") ? t.attr("striped") == "true" : undefined), nowrap : (t.attr("nowrap") ? t.attr("nowrap") == "true" : undefined), rownumbers : (t.attr("rownumbers") ? t.attr("rownumbers") == "true" : undefined), singleSelect : (t.attr("singleSelect") ? t.attr("singleSelect") == "true" : undefined), pagination : (t.attr("pagination") ? t.attr("pagination") == "true" : undefined), pageSize : (t.attr("pageSize") ? parseInt(t.attr("pageSize")) : undefined), pageList : (t.attr("pageList") ? eval(t.attr("pageList")) : undefined), remoteSort : (t.attr("remoteSort") ? t.attr("remoteSort") == "true" : undefined), sortName : t.attr("sortName"), sortOrder : t.attr("sortOrder"), showHeader : (t.attr("showHeader") ? t.attr("showHeader") == "true" : undefined), showFooter : (t.attr("showFooter") ? t.attr("showFooter") == "true" : undefined), scrollbarSize : (t.attr("scrollbarSize") ? parseInt(t .attr("scrollbarSize")) : undefined), loadMsg : (t.attr("loadMsg") != undefined ? t.attr("loadMsg") : undefined), idField : t.attr("idField"), toolbar : t.attr("toolbar"), url : t.attr("url"), rowStyler : (t.attr("rowStyler") ? eval(t.attr("rowStyler")) : undefined), autoLoad: t.attr("autoLoad")? $.decode(t.attr("autoLoad")) : null, //zzy+ list: t.attr("list")? $.decode(t.attr("list")) : null, //zzy+ save: t.attr("save")? $.decode(t.attr("save")) : null, //zzy+ remove: t.attr("remove")? $.decode(t.attr("remove")) : null //zzy+ }); // 其他配置项 if(t.attr("other")){ cfg = $.extend(cfg, eval(t.attr("other"))); } // 查询参数 if(t.attr('queryParams')){ cfg['queryParams'] = eval(t.attr("queryParams")); } return cfg; }; var _1ae = { render : function(_1af, _1b0, _1b1) { var opts = $.data(_1af, "datagrid").options; var rows = $.data(_1af, "datagrid").data.rows; var _1b2 = $(_1af).datagrid("getColumnFields", _1b1); if (_1b1) { if (!(opts.rownumbers || (opts.frozenColumns && opts.frozenColumns.length))) { return; } } var _1b3 = ["<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>"]; for (var i = 0; i < rows.length; i++) { var cls = (i % 2 && opts.striped) ? "class=\"datagrid-row-alt\"" : ""; var _1b4 = opts.rowStyler ? opts.rowStyler.call(_1af, i, rows[i]) : ""; var _1b5 = _1b4 ? "style=\"" + _1b4 + "\"" : ""; _1b3.push("<tr datagrid-row-index=\"" + i + "\" " + cls + " " + _1b5 + ">"); _1b3.push(this.renderRow.call(this, _1af, _1b2, _1b1, i, rows[i])); _1b3.push("</tr>"); } _1b3.push("</tbody></table>"); $(_1b0).html(_1b3.join("")); }, renderFooter : function(_1b6, _1b7, _1b8) { var opts = $.data(_1b6, "datagrid").options; var rows = $.data(_1b6, "datagrid").footer || []; var _1b9 = $(_1b6).datagrid("getColumnFields", _1b8); var _1ba = ["<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>"]; for (var i = 0; i < rows.length; i++) { _1ba.push("<tr datagrid-row-index=\"" + i + "\">"); _1ba.push(this.renderRow.call(this, _1b6, _1b9, _1b8, i, rows[i])); _1ba.push("</tr>"); } _1ba.push("</tbody></table>"); $(_1b7).html(_1ba.join("")); }, renderRow : function(_1bb, _1bc, _1bd, _1be, _1bf) { var opts = $.data(_1bb, "datagrid").options; var cc = []; if (_1bd && opts.rownumbers) { var _1c0 = _1be + 1; if (opts.pagination) { _1c0 += (opts.pageNumber - 1) * opts.pageSize; } cc .push("<td class=\"datagrid-td-rownumber\"><div class=\"datagrid-cell-rownumber\">" + _1c0 + "</div></td>"); } for (var i = 0; i < _1bc.length; i++) { var _1c1 = _1bc[i]; var col = $(_1bb).datagrid("getColumnOption", _1c1); if (col) { var _1c2 = col.styler ? (col.styler(_1bf[_1c1], _1bf, _1be) || "") : ""; var _1c3 = col.hidden ? "style=\"display:none;" + _1c2 + "\"" : (_1c2 ? "style=\"" + _1c2 + "\"" : ""); cc.push("<td field=\"" + _1c1 + "\" " + _1c3 + ">"); var _1c3 = "width:" + (col.boxWidth) + "px;"; _1c3 += "text-align:" + (col.align || "left") + ";"; _1c3 += opts.nowrap == false ? "white-space:normal;" : ""; cc.push("<div style=\"" + _1c3 + "\" "); if (col.checkbox) { cc.push("class=\"datagrid-cell-check "); } else { cc.push("class=\"datagrid-cell "); } cc.push("\">"); if (col.checkbox) { cc.push("<input type=\"checkbox\"/>"); } else { if (col.formatter) { cc.push(col.formatter(_1bf[_1c1], _1bf, _1be)); } else { cc.push(_1bf[_1c1]); } } cc.push("</div>"); cc.push("</td>"); } } return cc.join(""); }, refreshRow : function(_1c4, _1c5) { var row = {}; var _1c6 = $(_1c4).datagrid("getColumnFields", true).concat($(_1c4) .datagrid("getColumnFields", false)); for (var i = 0; i < _1c6.length; i++) { row[_1c6[i]] = undefined; } var rows = $(_1c4).datagrid("getRows"); $.extend(row, rows[_1c5]); this.updateRow.call(this, _1c4, _1c5, row); }, updateRow : function(_1c7, _1c8, row) { var opts = $.data(_1c7, "datagrid").options; var _1c9 = $(_1c7).datagrid("getPanel"); var rows = $(_1c7).datagrid("getRows"); var tr = _1c9.find("div.datagrid-body tr[datagrid-row-index=" + _1c8 + "]"); for (var _1ca in row) { rows[_1c8][_1ca] = row[_1ca]; var td = tr.children("td[field=\"" + _1ca + "\"]"); var cell = td.find("div.datagrid-cell"); var col = $(_1c7).datagrid("getColumnOption", _1ca); if (col) { var _1cb = col.styler ? col.styler(rows[_1c8][_1ca], rows[_1c8], _1c8) : ""; td.attr("style", _1cb || ""); if (col.hidden) { td.hide(); } if (col.formatter) { cell.html(col.formatter(rows[_1c8][_1ca], rows[_1c8], _1c8)); } else { cell.html(rows[_1c8][_1ca]); } } } var _1cb = opts.rowStyler ? opts.rowStyler.call(_1c7, _1c8, rows[_1c8]) : ""; tr.attr("style", _1cb || ""); $(_1c7).datagrid("fixRowHeight", _1c8); }, insertRow : function(_1cc, _1cd, row) { var opts = $.data(_1cc, "datagrid").options; var data = $.data(_1cc, "datagrid").data; var view = $(_1cc).datagrid("getPanel") .children("div.datagrid-view"); var _1ce = view.children("div.datagrid-view1"); var _1cf = view.children("div.datagrid-view2"); if (_1cd == undefined || _1cd == null) { _1cd = data.rows.length; } if (_1cd > data.rows.length) { _1cd = data.rows.length; } for (var i = data.rows.length - 1; i >= _1cd; i--) { _1cf.children("div.datagrid-body") .find("tr[datagrid-row-index=" + i + "]").attr( "datagrid-row-index", i + 1); var tr = _1ce.children("div.datagrid-body") .find("tr[datagrid-row-index=" + i + "]").attr( "datagrid-row-index", i + 1); if (opts.rownumbers) { tr.find("div.datagrid-cell-rownumber").html(i + 2); } } var _1d0 = $(_1cc).datagrid("getColumnFields", true); var _1d1 = $(_1cc).datagrid("getColumnFields", false); var tr1 = "<tr datagrid-row-index=\"" + _1cd + "\">" + this.renderRow.call(this, _1cc, _1d0, true, _1cd, row) + "</tr>"; var tr2 = "<tr datagrid-row-index=\"" + _1cd + "\">" + this.renderRow.call(this, _1cc, _1d1, false, _1cd, row) + "</tr>"; if (_1cd >= data.rows.length) { var _1d2 = _1ce.children("div.datagrid-body") .children("div.datagrid-body-inner"); var _1d3 = _1cf.children("div.datagrid-body"); if (data.rows.length) { _1d2.find("tr:last[datagrid-row-index]").after(tr1); _1d3.find("tr:last[datagrid-row-index]").after(tr2); } else { _1d2 .html("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>" + tr1 + "</tbody></table>"); _1d3 .html("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>" + tr2 + "</tbody></table>"); } } else { _1ce.children("div.datagrid-body") .find("tr[datagrid-row-index=" + (_1cd + 1) + "]") .before(tr1); _1cf.children("div.datagrid-body") .find("tr[datagrid-row-index=" + (_1cd + 1) + "]") .before(tr2); } data.total += 1; data.rows.splice(_1cd, 0, row); this.refreshRow.call(this, _1cc, _1cd); }, deleteRow : function(_1d4, _1d5) { var opts = $.data(_1d4, "datagrid").options; var data = $.data(_1d4, "datagrid").data; var view = $(_1d4).datagrid("getPanel") .children("div.datagrid-view"); var _1d6 = view.children("div.datagrid-view1"); var _1d7 = view.children("div.datagrid-view2"); _1d6.children("div.datagrid-body").find("tr[datagrid-row-index=" + _1d5 + "]").remove(); _1d7.children("div.datagrid-body").find("tr[datagrid-row-index=" + _1d5 + "]").remove(); for (var i = _1d5 + 1; i < data.rows.length; i++) { _1d7.children("div.datagrid-body") .find("tr[datagrid-row-index=" + i + "]").attr( "datagrid-row-index", i - 1); var tr = _1d6.children("div.datagrid-body") .find("tr[datagrid-row-index=" + i + "]").attr( "datagrid-row-index", i - 1); if (opts.rownumbers) { tr.find("div.datagrid-cell-rownumber").html(i); } } data.total -= 1; data.rows.splice(_1d5, 1); }, onBeforeRender : function(_1d8, rows) { }, onAfterRender : function(_1d9) { var opts = $.data(_1d9, "datagrid").options; if (opts.showFooter) { var _1da = $(_1d9).datagrid("getPanel") .find("div.datagrid-footer"); _1da .find("div.datagrid-cell-rownumber,div.datagrid-cell-check") .css("visibility", "hidden"); } } }; $.fn.datagrid.defaults = $.extend({}, $.fn.panel.defaults, { frozenColumns : null, columns : null, fitColumns : true, toolbar : null, striped : false, method : "post", nowrap : true, idField : null, url : null, loadMsg : "Processing, please wait ...", rownumbers : false, singleSelect : false, pagination : false, pageNumber : 1, pageSize : 10, pageList : [10, 20, 30, 40, 50], queryParams : {}, sortName : null, sortOrder : "asc", remoteSort : true, showHeader : true, showFooter : false, scrollbarSize : 18, rowStyler : function(_1db, _1dc) { }, loadFilter : function(data) { if (typeof data.length == "number" && typeof data.splice == "function") { return { total : data.length, rows : data }; } else { return data; } }, editors : _142, editConfig : { getTr : function(_1dd, _1de) { return $(_1dd) .datagrid("getPanel") .find("div.datagrid-body tr[datagrid-row-index=" + _1de + "]"); }, getRow : function(_1df, _1e0) { return $.data(_1df, "datagrid").data.rows[_1e0]; } }, view : _1ae, onBeforeLoad : function(_1e1) { }, onLoadSuccess : function() { }, onLoadError : function() { }, onClickRow : function(_1e2, _1e3) { }, onDblClickRow : function(_1e4, _1e5) { }, onClickCell : function(_1e6, _1e7, _1e8) { }, onDblClickCell : function(_1e9, _1ea, _1eb) { }, onSortColumn : function(sort, _1ec) { }, onResizeColumn : function(_1ed, _1ee) { }, onSelect : function(_1ef, _1f0) { }, onUnselect : function(_1f1, _1f2) { }, onSelectAll : function(rows) { }, onUnselectAll : function(rows) { }, onBeforeEdit : function(_1f3, _1f4) { }, onAfterEdit : function(_1f5, _1f6, _1f7) { }, onCancelEdit : function(_1f8, _1f9) { }, onHeaderContextMenu : function(e, _1fa) { }, onRowContextMenu : function(e, _1fb, _1fc) { } }); })(jQuery); $.extend($.fn.datagrid.methods, { /** * 添加记录 * @param {} jq jq对象,在调用时看不见 * @param {} ops 操作参数,共分3种情况: * 第一种:为空,则添加一行默认空行 * 第二种: json对象,则添加一行指定记录 * 第三种:json数组,则添加多行指定记录 * 第四种:如:{ * rows: [{},{}], //json数组 * isEdit: false //不需要编辑 * callFun: function(target, rows){} * } */ 'add': function(jq, ops){ // 如果当前已经有文件正在编辑,则不可用 if(jq.datagrid('getEdittingId') != null){ $.msg.show({ title: '提示', msg:'当前有行正在编辑,请保存正在编辑的行后进行其他操作!' }); return; } var target = null; jq.each(function(){target = this;}); // 获取idField var idField = $.data(target, 'datagrid')['options']['idField']; // 如果为空,则默认添加 if(!ops){ var row = {}; ops = { rows: [{}] }; }else if($.isArray(ops)){ // 如果是json数组 ops = { rows: ops }; }else if(!(ops['rows'] && String(ops['isEdit']))){// 如果是json ops = { rows: [ops] }; } ops = $.extend({ rows: [], isEdit: true, callFun: function(){} }, ops); for (var index = 0; index < ops.rows.length; index++) { var row = ops.rows[index]; // 设置逻辑主键 if( !ops.rows[index][idField] ){ ops.rows[index][idField] = $.uuidVal(); } } // 添加节点 jq.datagrid('appendRow', ops['rows']); var rowIndex = jq.datagrid('getRowIndex', ops['rows'][idField]); if(ops['isEdit']){ // 清除选中行 jq.datagrid('unselectAll'); // 选中当前添加的记录 jq.datagrid('selectRow', rowIndex); $.data(target, 'datagrid')['currentEdittingOldRow'] = ops['rows'][0]; $.data(target, 'datagrid')['currentEdittingRowIndex'] = rowIndex; // 开始编辑 jq.datagrid('beginEdit',rowIndex); } // 执行回调函数 ops['callFun'](target, ops['rows']); }, /** * 编辑 * @param jq jq对象,在调用时看不见 */ 'edit': function(jq){ // 如果当前已经有文件正在编辑,则不可用 if(jq.datagrid('getEdittingId') != null){ $.msg.show({ title: '提示', msg:'正在编辑,请保存正在编辑的行后进行其他操作!' }); return false; } var target = null; jq.each(function(){target = this}); var row = jq.datagrid('getSelected'); // 获取idField var idField = $.data(target, 'datagrid')['options']['idField']; if (row){ $.data(target, 'datagrid')['currentEdittingOldRow'] = row; $.data(target, 'datagrid')['currentEdittingRowIndex'] = jq.datagrid('getRowIndex', row); jq.datagrid('beginEdit', $.data(target, 'datagrid')['currentEdittingRowIndex']); } }, 'save': function(jq){ var target = null; jq.each(function(){target = this;}); var id = jq.datagrid('getEdittingId'); if(id == null){ $.msg.show({ title: '提示', msg:'没有需要保存的记录!' }); return false; } var row = jq.datagrid('getCurrRow', $.data(target, 'datagrid')['currentEdittingRowIndex']); $.exec($.data(target, 'datagrid')['options']['save'], row[0], function(data){ $.msg.say("保存成功!"); // 停止编辑 jq.datagrid('endEdit', id); // 更新界面行记录 jq.datagrid('updateRow', data); $.data(target, 'datagrid')['currentEdittingOldRow'] = null; $.data(target, 'datagrid')['currentEdittingRowIndex'] = null; }); }, 'delete': function(jq){ var target = null; jq.each(function(){target = this;}); // 获取选中的节点 var node = jq.datagrid('getSelected'); if(node == null){ $.msg.say("没有选中要删除的记录,请确认!"); return; } // 获取idField var idField = $.data(target, 'datagrid')['options']['idField']; $.msg.confirm('询问', '是否删除当前选中记录?', function(r){ if (r){ $.exec($.data(target, 'datagrid')['options']['remove'], node, function(data){ $.msg.say("删除成功!"); $.data(target, 'datagrid')['currentEdittingOldRow'] = null; $.data(target, 'datagrid')['currentEdittingRowIndex'] = null; jq.datagrid("remove", data[idField]); }); } }); }, /** * 获取正在编辑的行节点 * @param jq jq对象,在调用时看不见 */ 'getEdittingId': function(jq){ var target = null; jq.each(function(){target = this;}); // 获取idField var idField = $.data(target, 'datagrid')['options']['idField']; return $.data(target, 'datagrid')['currentEdittingOldRow'] ? $.data(target, 'datagrid')['currentEdittingOldRow'][idField] : null; } });
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.datagrid.js
JavaScript
asf20
74,041
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ $(_2).appendTo("body"); $(_2).addClass("menu-top"); var _3=[]; _4($(_2)); var _5=null; for(var i=0;i<_3.length;i++){ var _6=_3[i]; _7(_6); _6.children("div.menu-item").each(function(){ _10(_2,$(this)); }); _6.bind("mouseenter",function(){ if(_5){ clearTimeout(_5); _5=null; } }).bind("mouseleave",function(){ _5=setTimeout(function(){ _19(_2); },100); }); } function _4(_8){ _3.push(_8); _8.find(">div").each(function(){ var _9=$(this); var _a=_9.find(">div"); if(_a.length){ _a.insertAfter(_2); _9[0].submenu=_a; _4(_a); } }); }; function _7(_b){ _b.addClass("menu").find(">div").each(function(){ var _c=$(this); if(_c.hasClass("menu-sep")){ _c.html("&nbsp;"); }else{ var _d=_c.addClass("menu-item").html(); _c.empty().append($("<div class=\"menu-text\"></div>").html(_d)); var _e=_c.attr("iconCls")||_c.attr("icon"); if(_e){ $("<div class=\"menu-icon\"></div>").addClass(_e).appendTo(_c); } if(_c[0].submenu){ $("<div class=\"menu-rightarrow\"></div>").appendTo(_c); } if($.boxModel==true){ var _f=_c.height(); _c.height(_f-(_c.outerHeight()-_c.height())); } } }); _b.hide(); }; }; function _10(_11,_12){ _12.unbind(".menu"); _12.bind("mousedown.menu",function(){ return false; }).bind("click.menu",function(){ if($(this).hasClass("menu-item-disabled")){ return; } if(!this.submenu){ _19(_11); var _13=$(this).attr("href"); if(_13){ location.href=_13; } } var _14=$(_11).menu("getItem",this); $.data(_11,"menu").options.onClick.call(_11,_14); }).bind("mouseenter.menu",function(e){ _12.siblings().each(function(){ if(this.submenu){ _18(this.submenu); } $(this).removeClass("menu-active"); }); _12.addClass("menu-active"); if($(this).hasClass("menu-item-disabled")){ _12.addClass("menu-active-disabled"); return; } var _15=_12[0].submenu; if(_15){ var _16=_12.offset().left+_12.outerWidth()-2; if(_16+_15.outerWidth()+5>$(window).width()+$(document).scrollLeft()){ _16=_12.offset().left-_15.outerWidth()+2; } var top=_12.offset().top-3; if(top+_15.outerHeight()>$(window).height()+$(document).scrollTop()){ top=$(window).height()+$(document).scrollTop()-_15.outerHeight()-5; } _1f(_15,{left:_16,top:top}); } }).bind("mouseleave.menu",function(e){ _12.removeClass("menu-active menu-active-disabled"); var _17=_12[0].submenu; if(_17){ if(e.pageX>=parseInt(_17.css("left"))){ _12.addClass("menu-active"); }else{ _18(_17); } }else{ _12.removeClass("menu-active"); } }); }; function _19(_1a){ var _1b=$.data(_1a,"menu").options; _18($(_1a)); $(document).unbind(".menu"); _1b.onHide.call(_1a); return false; }; function _1c(_1d,pos){ var _1e=$.data(_1d,"menu").options; if(pos){ _1e.left=pos.left; _1e.top=pos.top; if(_1e.left+$(_1d).outerWidth()>$(window).width()+$(document).scrollLeft()){ _1e.left=$(window).width()+$(document).scrollLeft()-$(_1d).outerWidth()-5; } if(_1e.top+$(_1d).outerHeight()>$(window).height()+$(document).scrollTop()){ _1e.top-=$(_1d).outerHeight(); } } _1f($(_1d),{left:_1e.left,top:_1e.top},function(){ $(document).unbind(".menu").bind("mousedown.menu",function(){ _19(_1d); $(document).unbind(".menu"); return false; }); _1e.onShow.call(_1d); }); }; function _1f(_20,pos,_21){ if(!_20){ return; } if(pos){ _20.css(pos); } _20.show(0,function(){ if(!_20[0].shadow){ _20[0].shadow=$("<div class=\"menu-shadow\"></div>").insertAfter(_20); } _20[0].shadow.css({display:"block",zIndex:$.fn.menu.defaults.zIndex++,left:_20.css("left"),top:_20.css("top"),width:_20.outerWidth(),height:_20.outerHeight()}); _20.css("z-index",$.fn.menu.defaults.zIndex++); if(_21){ _21(); } }); }; function _18(_22){ if(!_22){ return; } _23(_22); _22.find("div.menu-item").each(function(){ if(this.submenu){ _18(this.submenu); } $(this).removeClass("menu-active"); }); function _23(m){ m.stop(true,true); if(m[0].shadow){ m[0].shadow.hide(); } m.hide(); }; }; function _24(_25,_26){ var _27=null; var tmp=$("<div></div>"); function _28(_29){ _29.children("div.menu-item").each(function(){ var _2a=$(_25).menu("getItem",this); var s=tmp.empty().html(_2a.text).text(); if(_26==$.trim(s)){ _27=_2a; }else{ if(this.submenu&&!_27){ _28(this.submenu); } } }); }; _28($(_25)); tmp.remove(); return _27; }; function _2b(_2c,_2d,_2e){ var t=$(_2d); if(_2e){ t.addClass("menu-item-disabled"); if(_2d.onclick){ _2d.onclick1=_2d.onclick; _2d.onclick=null; } }else{ t.removeClass("menu-item-disabled"); if(_2d.onclick1){ _2d.onclick=_2d.onclick1; _2d.onclick1=null; } } }; function _2f(_30,_31){ var _32=$(_30); if(_31.parent){ _32=_31.parent.submenu; } var _33=$("<div class=\"menu-item\"></div>").appendTo(_32); $("<div class=\"menu-text\"></div>").html(_31.text).appendTo(_33); if(_31.iconCls){ $("<div class=\"menu-icon\"></div>").addClass(_31.iconCls).appendTo(_33); } if(_31.id){ _33.attr("id",_31.id); } if(_31.href){ _33.attr("href",_31.href); } if(_31.onclick){ if(typeof _31.onclick=="string"){ _33.attr("onclick",_31.onclick); }else{ _33[0].onclick=eval(_31.onclick); } } if(_31.handler){ _33[0].onclick=eval(_31.handler); } _10(_30,_33); }; function _34(_35,_36){ function _37(el){ if(el.submenu){ el.submenu.children("div.menu-item").each(function(){ _37(this); }); var _38=el.submenu[0].shadow; if(_38){ _38.remove(); } el.submenu.remove(); } $(el).remove(); }; _37(_36); }; function _39(_3a){ $(_3a).children("div.menu-item").each(function(){ _34(_3a,this); }); if(_3a.shadow){ _3a.shadow.remove(); } $(_3a).remove(); }; $.fn.menu=function(_3b,_3c){ if(typeof _3b=="string"){ return $.fn.menu.methods[_3b](this,_3c); } _3b=_3b||{}; return this.each(function(){ var _3d=$.data(this,"menu"); if(_3d){ $.extend(_3d.options,_3b); }else{ _3d=$.data(this,"menu",{options:$.extend({},$.fn.menu.defaults,_3b)}); _1(this); } $(this).css({left:_3d.options.left,top:_3d.options.top}); }); }; $.fn.menu.methods={show:function(jq,pos){ return jq.each(function(){ _1c(this,pos); }); },hide:function(jq){ return jq.each(function(){ _19(this); }); },destroy:function(jq){ return jq.each(function(){ _39(this); }); },setText:function(jq,_3e){ return jq.each(function(){ $(_3e.target).children("div.menu-text").html(_3e.text); }); },setIcon:function(jq,_3f){ return jq.each(function(){ var _40=$(this).menu("getItem",_3f.target); if(_40.iconCls){ $(_40.target).children("div.menu-icon").removeClass(_40.iconCls).addClass(_3f.iconCls); }else{ $("<div class=\"menu-icon\"></div>").addClass(_3f.iconCls).appendTo(_3f.target); } }); },getItem:function(jq,_41){ var _42={target:_41,id:$(_41).attr("id"),text:$.trim($(_41).children("div.menu-text").html()),disabled:$(_41).hasClass("menu-item-disabled"),href:$(_41).attr("href"),onclick:_41.onclick}; var _43=$(_41).children("div.menu-icon"); if(_43.length){ var cc=[]; var aa=_43.attr("class").split(" "); for(var i=0;i<aa.length;i++){ if(aa[i]!="menu-icon"){ cc.push(aa[i]); } } _42.iconCls=cc.join(" "); } return _42; },findItem:function(jq,_44){ return _24(jq[0],_44); },appendItem:function(jq,_45){ return jq.each(function(){ _2f(this,_45); }); },removeItem:function(jq,_46){ return jq.each(function(){ _34(this,_46); }); },enableItem:function(jq,_47){ return jq.each(function(){ _2b(this,_47,false); }); },disableItem:function(jq,_48){ return jq.each(function(){ _2b(this,_48,true); }); }}; $.fn.menu.defaults={zIndex:110000,left:0,top:0,onShow:function(){ },onHide:function(){ },onClick:function(_49){ }}; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.menu.js
JavaScript
asf20
7,476
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ var _3=$.data(_2,"splitbutton").options; var _4=$(_2); _4.removeClass("s-btn-active s-btn-plain-active"); _4.linkbutton($.extend({},_3,{text:_3.text+"<span class=\"s-btn-downarrow\">&nbsp;</span>"})); if(_3.menu){ $(_3.menu).menu({onShow:function(){ _4.addClass((_3.plain==true)?"s-btn-plain-active":"s-btn-active"); },onHide:function(){ _4.removeClass((_3.plain==true)?"s-btn-plain-active":"s-btn-active"); }}); } _5(_2,_3.disabled); }; function _5(_6,_7){ var _8=$.data(_6,"splitbutton").options; _8.disabled=_7; var _9=$(_6); var _a=_9.find(".s-btn-downarrow"); if(_7){ _9.linkbutton("disable"); _a.unbind(".splitbutton"); }else{ _9.linkbutton("enable"); _a.unbind(".splitbutton"); _a.bind("click.splitbutton",function(){ _b(); return false; }); var _c=null; _a.bind("mouseenter.splitbutton",function(){ _c=setTimeout(function(){ _b(); },_8.duration); return false; }).bind("mouseleave.splitbutton",function(){ if(_c){ clearTimeout(_c); } }); } function _b(){ if(!_8.menu){ return; } var _d=_9.offset().left; if(_d+$(_8.menu).outerWidth()+5>$(window).width()){ _d=$(window).width()-$(_8.menu).outerWidth()-5; } $("body>div.menu-top").menu("hide"); $(_8.menu).menu("show",{left:_d,top:_9.offset().top+_9.outerHeight()}); _9.blur(); }; }; $.fn.splitbutton=function(_e,_f){ if(typeof _e=="string"){ return $.fn.splitbutton.methods[_e](this,_f); } _e=_e||{}; return this.each(function(){ var _10=$.data(this,"splitbutton"); if(_10){ $.extend(_10.options,_e); }else{ $.data(this,"splitbutton",{options:$.extend({},$.fn.splitbutton.defaults,$.fn.splitbutton.parseOptions(this),_e)}); $(this).removeAttr("disabled"); } _1(this); }); }; $.fn.splitbutton.methods={options:function(jq){ return $.data(jq[0],"splitbutton").options; },enable:function(jq){ return jq.each(function(){ _5(this,false); }); },disable:function(jq){ return jq.each(function(){ _5(this,true); }); }}; $.fn.splitbutton.parseOptions=function(_11){ var t=$(_11); return $.extend({},$.fn.linkbutton.parseOptions(_11),{menu:t.attr("menu"),duration:t.attr("duration")}); }; $.fn.splitbutton.defaults=$.extend({},$.fn.linkbutton.defaults,{plain:true,menu:null,duration:100}); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.splitbutton.js
JavaScript
asf20
2,372
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ var _3=$.data(_2,"datetimebox"); var _4=_3.options; $(_2).datebox($.extend({},_4,{onShowPanel:function(){ var _5=$(_2).datetimebox("getValue"); _f(_2,_5,true); _4.onShowPanel.call(_2); }})); $(_2).removeClass("datebox-f").addClass("datetimebox-f"); $(_2).datebox("calendar").calendar({onSelect:function(_6){ _4.onSelect.call(_2,_6); }}); var _7=$(_2).datebox("panel"); if(!_3.spinner){ var p=$("<div style=\"padding:2px\"><input style=\"width:80px\"></div>").insertAfter(_7.children("div.datebox-calendar-inner")); _3.spinner=p.children("input"); _3.spinner.timespinner({showSeconds:true}).bind("mousedown",function(e){ e.stopPropagation(); }); _f(_2,_4.value); var _8=_7.children("div.datebox-button"); var ok=$("<a href=\"javascript:void(0)\" class=\"datebox-ok\"></a>").html(_4.okText).appendTo(_8); ok.hover(function(){ $(this).addClass("datebox-button-hover"); },function(){ $(this).removeClass("datebox-button-hover"); }).click(function(){ _9(_2); }); } }; function _a(_b){ var c=$(_b).datetimebox("calendar"); var t=$(_b).datetimebox("spinner"); var _c=c.calendar("options").current; return new Date(_c.getFullYear(),_c.getMonth(),_c.getDate(),t.timespinner("getHours"),t.timespinner("getMinutes"),t.timespinner("getSeconds")); }; function _d(_e,q){ _f(_e,q,true); }; function _9(_10){ var _11=$.data(_10,"datetimebox").options; var _12=_a(_10); _f(_10,_11.formatter(_12)); $(_10).combo("hidePanel"); }; function _f(_13,_14,_15){ var _16=$.data(_13,"datetimebox").options; $(_13).combo("setValue",_14); if(!_15){ if(_14){ var _17=_16.parser(_14); $(_13).combo("setValue",_16.formatter(_17)); $(_13).combo("setText",_16.formatter(_17)); }else{ $(_13).combo("setText",_14); } } var _17=_16.parser(_14); $(_13).datetimebox("calendar").calendar("moveTo",_16.parser(_14)); $(_13).datetimebox("spinner").timespinner("setValue",_18(_17)); function _18(_19){ function _1a(_1b){ return (_1b<10?"0":"")+_1b; }; var tt=[_1a(_19.getHours()),_1a(_19.getMinutes())]; if(_16.showSeconds){ tt.push(_1a(_19.getSeconds())); } return tt.join($(_13).datetimebox("spinner").timespinner("options").separator); }; }; $.fn.datetimebox=function(_1c,_1d){ if(typeof _1c=="string"){ var _1e=$.fn.datetimebox.methods[_1c]; if(_1e){ return _1e(this,_1d); }else{ return this.datebox(_1c,_1d); } } _1c=_1c||{}; return this.each(function(){ var _1f=$.data(this,"datetimebox"); if(_1f){ $.extend(_1f.options,_1c); }else{ $.data(this,"datetimebox",{options:$.extend({},$.fn.datetimebox.defaults,$.fn.datetimebox.parseOptions(this),_1c)}); } _1(this); }); }; $.fn.datetimebox.methods={options:function(jq){ return $.data(jq[0],"datetimebox").options; },spinner:function(jq){ return $.data(jq[0],"datetimebox").spinner; },setValue:function(jq,_20){ return jq.each(function(){ _f(this,_20); }); }}; $.fn.datetimebox.parseOptions=function(_21){ var t=$(_21); return $.extend({},$.fn.datebox.parseOptions(_21),{}); }; $.fn.datetimebox.defaults=$.extend({},$.fn.datebox.defaults,{showSeconds:true,keyHandler:{up:function(){ },down:function(){ },enter:function(){ _9(this); },query:function(q){ _d(this,q); }},formatter:function(_22){ var h=_22.getHours(); var M=_22.getMinutes(); var s=_22.getSeconds(); function _23(_24){ return (_24<10?"0":"")+_24; }; return $.fn.datebox.defaults.formatter(_22)+" "+_23(h)+":"+_23(M)+":"+_23(s); },parser:function(s){ if($.trim(s)==""){ return new Date(); } var dt=s.split(" "); var d=$.fn.datebox.defaults.parser(dt[0]); var tt=dt[1].split(":"); var _25=parseInt(tt[0],10); var _26=parseInt(tt[1],10); var _27=parseInt(tt[2],10); return new Date(d.getFullYear(),d.getMonth(),d.getDate(),_25,_26,_27); }}); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.datetimebox.js
JavaScript
asf20
3,846
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ var _3=$("<span class=\"spinner\">"+"<span class=\"spinner-arrow\">"+"<span class=\"spinner-arrow-up\"></span>"+"<span class=\"spinner-arrow-down\"></span>"+"</span>"+"</span>").insertAfter(_2); $(_2).addClass("spinner-text").prependTo(_3); return _3; }; function _4(_5,_6){ var _7=$.data(_5,"spinner").options; var _8=$.data(_5,"spinner").spinner; if(_6){ _7.width=_6; } var _9=$("<div style=\"display:none\"></div>").insertBefore(_8); _8.appendTo("body"); if(isNaN(_7.width)){ _7.width=$(_5).outerWidth(); } var _a=_8.find(".spinner-arrow").outerWidth(); var _6=_7.width-_a; if($.boxModel==true){ _6-=_8.outerWidth()-_8.width(); } $(_5).width(_6); _8.insertAfter(_9); _9.remove(); }; function _b(_c){ var _d=$.data(_c,"spinner").options; var _e=$.data(_c,"spinner").spinner; _e.find(".spinner-arrow-up,.spinner-arrow-down").unbind(".spinner"); if(!_d.disabled){ _e.find(".spinner-arrow-up").bind("mouseenter.spinner",function(){ $(this).addClass("spinner-arrow-hover"); }).bind("mouseleave.spinner",function(){ $(this).removeClass("spinner-arrow-hover"); }).bind("click.spinner",function(){ _d.spin.call(_c,false); _d.onSpinUp.call(_c); $(_c).validatebox("validate"); }); _e.find(".spinner-arrow-down").bind("mouseenter.spinner",function(){ $(this).addClass("spinner-arrow-hover"); }).bind("mouseleave.spinner",function(){ $(this).removeClass("spinner-arrow-hover"); }).bind("click.spinner",function(){ _d.spin.call(_c,true); _d.onSpinDown.call(_c); $(_c).validatebox("validate"); }); } }; function _f(_10,_11){ var _12=$.data(_10,"spinner").options; if(_11){ _12.disabled=true; $(_10).attr("disabled",true); }else{ _12.disabled=false; $(_10).removeAttr("disabled"); } }; $.fn.spinner=function(_13,_14){ if(typeof _13=="string"){ var _15=$.fn.spinner.methods[_13]; if(_15){ return _15(this,_14); }else{ return this.validatebox(_13,_14); } } _13=_13||{}; return this.each(function(){ var _16=$.data(this,"spinner"); if(_16){ $.extend(_16.options,_13); }else{ _16=$.data(this,"spinner",{options:$.extend({},$.fn.spinner.defaults,$.fn.spinner.parseOptions(this),_13),spinner:_1(this)}); $(this).removeAttr("disabled"); } $(this).val(_16.options.value); $(this).attr("readonly",!_16.options.editable); _f(this,_16.options.disabled); _4(this); $(this).validatebox(_16.options); _b(this); }); }; $.fn.spinner.methods={options:function(jq){ var _17=$.data(jq[0],"spinner").options; return $.extend(_17,{value:jq.val()}); },destroy:function(jq){ return jq.each(function(){ var _18=$.data(this,"spinner").spinner; $(this).validatebox("destroy"); _18.remove(); }); },resize:function(jq,_19){ return jq.each(function(){ _4(this,_19); }); },enable:function(jq){ return jq.each(function(){ _f(this,false); _b(this); }); },disable:function(jq){ return jq.each(function(){ _f(this,true); _b(this); }); },getValue:function(jq){ return jq.val(); },setValue:function(jq,_1a){ return jq.each(function(){ var _1b=$.data(this,"spinner").options; _1b.value=_1a; $(this).val(_1a); }); },clear:function(jq){ return jq.each(function(){ var _1c=$.data(this,"spinner").options; _1c.value=""; $(this).val(""); }); }}; $.fn.spinner.parseOptions=function(_1d){ var t=$(_1d); return $.extend({},$.fn.validatebox.parseOptions(_1d),{width:(parseInt(_1d.style.width)||undefined),value:(t.val()||undefined),min:t.attr("min"),max:t.attr("max"),increment:(parseFloat(t.attr("increment"))||undefined),editable:(t.attr("editable")?t.attr("editable")=="true":undefined),disabled:(t.attr("disabled")?true:undefined)}); }; $.fn.spinner.defaults=$.extend({},$.fn.validatebox.defaults,{width:"auto",value:"",min:null,max:null,increment:1,editable:true,disabled:false,spin:function(_1e){ },onSpinUp:function(){ },onSpinDown:function(){ }}); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.spinner.js
JavaScript
asf20
3,934
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($) { function _1(_2) { var _3 = $.data(_2, "datebox"); var _4 = _3.options; $(_2).addClass("datebox-f"); $(_2).combo($.extend({}, _4, { onShowPanel : function() { _3.calendar.calendar("resize"); _4.onShowPanel.call(_2); } })); $(_2).combo("textbox").parent().addClass("datebox"); if (!_3.calendar) { _5(); } function _5() { var _6 = $(_2).combo("panel"); _3.calendar = $("<div></div>").appendTo(_6) .wrap("<div class=\"datebox-calendar-inner\"></div>"); _3.calendar.calendar({ fit : true, border : false, onSelect : function(_7) { var _8 = _4.formatter(_7); _c(_2, _8); $(_2).combo("hidePanel"); _4.onSelect.call(_2, _7); } }); _c(_2, _4.value); var _9 = $("<div class=\"datebox-button\"></div>").appendTo(_6); $("<a href=\"javascript:void(0)\" class=\"datebox-current\"></a>") .html(_4.currentText).appendTo(_9); $("<a href=\"javascript:void(0)\" class=\"datebox-close\"></a>") .html(_4.closeText).appendTo(_9); _9.find(".datebox-current,.datebox-close").hover(function() { $(this).addClass("datebox-button-hover"); }, function() { $(this).removeClass("datebox-button-hover"); }); _9.find(".datebox-current").click(function() { _3.calendar.calendar({ year : new Date().getFullYear(), month : new Date().getMonth() + 1, current : new Date() }); }); _9.find(".datebox-close").click(function() { $(_2).combo("hidePanel"); }); }; }; function _a(_b, q) { _c(_b, q); }; function _d(_e) { var _f = $.data(_e, "datebox").options; var c = $.data(_e, "datebox").calendar; var _10 = _f.formatter(c.calendar("options").current); _c(_e, _10); $(_e).combo("hidePanel"); }; function _c(_11, _12) { var _13 = $.data(_11, "datebox"); var _14 = _13.options; $(_11).combo("setValue", _12).combo("setText", _12); _13.calendar.calendar("moveTo", _14.parser(_12)); }; $.fn.datebox = function(_15, _16) { if (typeof _15 == "string") { var _17 = $.fn.datebox.methods[_15]; if (_17) { return _17(this, _16); } else { return this.combo(_15, _16); } } _15 = _15 || {}; return this.each(function() { var _18 = $.data(this, "datebox"); if (_18) { $.extend(_18.options, _15); } else { $.data(this, "datebox", { options : $.extend({}, $.fn.datebox.defaults, $.fn.datebox .parseOptions(this), _15) }); } _1(this); }); }; $.fn.datebox.methods = { options : function(jq) { return $.data(jq[0], "datebox").options; }, calendar : function(jq) { return $.data(jq[0], "datebox").calendar; }, setValue : function(jq, _19) { return jq.each(function() { _c(this, _19); }); } }; $.fn.datebox.parseOptions = function(_1a) { var t = $(_1a); return $.extend({}, $.fn.combo.parseOptions(_1a), {}); }; $.fn.datebox.defaults = $.extend({}, $.fn.combo.defaults, { panelWidth : 180, panelHeight : "auto", keyHandler : { up : function() { }, down : function() { }, enter : function() { _d(this); }, query : function(q) { _a(this, q); } }, currentText : "Today", closeText : "Close", okText : "Ok", formatter : function(_1b) { var y = _1b.getFullYear(); var m = _1b.getMonth() + 1; var d = _1b.getDate(); return m + "/" + d + "/" + y; }, parser : function(s) { var t = Date.parse(s); if (!isNaN(t)) { return new Date(t); } else { return new Date(); } }, onSelect : function(_1c) { } }); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.datebox.js
JavaScript
asf20
4,058
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ $.parser={auto:true,onComplete:function(_1){ },plugins:["linkbutton","menu","menubutton","splitbutton","progressbar","tree","combobox","combogrid"/**zzy+*/,"combotree","numberbox","validatebox","searchbox","numberspinner","timespinner","calendar","datebox","datetimebox","layout","panel","datagrid","propertygrid","treegrid","tabs","accordion","window","dialog"],parse:function(_2){ var aa=[]; for(var i=0;i<$.parser.plugins.length;i++){ var _3=$.parser.plugins[i]; var r=$(".easyui-"+_3,_2); if(r.length){ if(r[_3]){ r[_3](); }else{ aa.push({name:_3,jq:r}); } } } if(aa.length&&window.easyloader){ var _4=[]; for(var i=0;i<aa.length;i++){ _4.push(aa[i].name); } easyloader.load(_4,function(){ for(var i=0;i<aa.length;i++){ var _5=aa[i].name; var jq=aa[i].jq; jq[_5](); } $.parser.onComplete.call($.parser,_2); }); }else{ $.parser.onComplete.call($.parser,_2); } }}; $(function(){ if(!window.easyloader&&$.parser.auto){ $.parser.parse(); } }); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.parser.js
JavaScript
asf20
1,165
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ var _3=$.data(_2,"propertygrid").options; $(_2).datagrid($.extend({},_3,{view:(_3.showGroup?_4:undefined),onClickRow:function(_5,_6){ if(_3.editIndex!=_5){ var _7=$(this).datagrid("getColumnOption","value"); _7.editor=_6.editor; _8(_3.editIndex); $(this).datagrid("beginEdit",_5); $(this).datagrid("getEditors",_5)[0].target.focus(); _3.editIndex=_5; } _3.onClickRow.call(_2,_5,_6); }})); $(_2).datagrid("getPanel").panel("panel").addClass("propertygrid"); $(_2).datagrid("getPanel").find("div.datagrid-body").unbind(".propertygrid").bind("mousedown.propertygrid",function(e){ e.stopPropagation(); }); $(document).unbind(".propertygrid").bind("mousedown.propertygrid",function(){ _8(_3.editIndex); _3.editIndex=undefined; }); function _8(_9){ if(_9==undefined){ return; } var t=$(_2); if(t.datagrid("validateRow",_9)){ t.datagrid("endEdit",_9); }else{ t.datagrid("cancelEdit",_9); } }; }; $.fn.propertygrid=function(_a,_b){ if(typeof _a=="string"){ var _c=$.fn.propertygrid.methods[_a]; if(_c){ return _c(this,_b); }else{ return this.datagrid(_a,_b); } } _a=_a||{}; return this.each(function(){ var _d=$.data(this,"propertygrid"); if(_d){ $.extend(_d.options,_a); }else{ $.data(this,"propertygrid",{options:$.extend({},$.fn.propertygrid.defaults,$.fn.propertygrid.parseOptions(this),_a)}); } _1(this); }); }; $.fn.propertygrid.methods={}; $.fn.propertygrid.parseOptions=function(_e){ var t=$(_e); return $.extend({},$.fn.datagrid.parseOptions(_e),{showGroup:(t.attr("showGroup")?t.attr("showGroup")=="true":undefined)}); }; var _4=$.extend({},$.fn.datagrid.defaults.view,{render:function(_f,_10,_11){ var _12=$.data(_f,"datagrid").options; var _13=$.data(_f,"datagrid").data.rows; var _14=$(_f).datagrid("getColumnFields",_11); var _15=[]; var _16=0; var _17=this.groups; for(var i=0;i<_17.length;i++){ var _18=_17[i]; _15.push("<div class=\"datagrid-group\" group-index="+i+">"); _15.push("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"height:100%\"><tbody>"); _15.push("<tr>"); _15.push("<td style=\"border:0;\">"); if(!_11){ _15.push("<span>"); _15.push(_12.groupFormatter.call(_f,_18.fvalue,_18.rows)); _15.push("</span>"); } _15.push("</td>"); _15.push("</tr>"); _15.push("</tbody></table>"); _15.push("</div>"); _15.push("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody>"); for(var j=0;j<_18.rows.length;j++){ var cls=(_16%2&&_12.striped)?"class=\"datagrid-row-alt\"":""; var _19=_12.rowStyler?_12.rowStyler.call(_f,_16,_18.rows[j]):""; var _1a=_19?"style=\""+_19+"\"":""; _15.push("<tr datagrid-row-index=\""+_16+"\" "+cls+" "+_1a+">"); _15.push(this.renderRow.call(this,_f,_14,_11,_16,_18.rows[j])); _15.push("</tr>"); _16++; } _15.push("</tbody></table>"); } $(_10).html(_15.join("")); },onAfterRender:function(_1b){ var _1c=$.data(_1b,"datagrid").options; var _1d=$(_1b).datagrid("getPanel").find("div.datagrid-view"); var _1e=_1d.children("div.datagrid-view1"); var _1f=_1d.children("div.datagrid-view2"); $.fn.datagrid.defaults.view.onAfterRender.call(this,_1b); if(_1c.rownumbers||_1c.frozenColumns.length){ var _20=_1e.find("div.datagrid-group"); }else{ var _20=_1f.find("div.datagrid-group"); } $("<td style=\"border:0\"><div class=\"datagrid-row-expander datagrid-row-collapse\" style=\"width:25px;height:16px;cursor:pointer\"></div></td>").insertBefore(_20.find("td")); _1d.find("div.datagrid-group").each(function(){ var _21=$(this).attr("group-index"); $(this).find("div.datagrid-row-expander").bind("click",{groupIndex:_21},function(e){ var _22=_1d.find("div.datagrid-group[group-index="+e.data.groupIndex+"]"); if($(this).hasClass("datagrid-row-collapse")){ $(this).removeClass("datagrid-row-collapse").addClass("datagrid-row-expand"); _22.next("table").hide(); }else{ $(this).removeClass("datagrid-row-expand").addClass("datagrid-row-collapse"); _22.next("table").show(); } $(_1b).datagrid("fixRowHeight"); }); }); },onBeforeRender:function(_23,_24){ var _25=$.data(_23,"datagrid").options; var _26=[]; for(var i=0;i<_24.length;i++){ var row=_24[i]; var _27=_28(row[_25.groupField]); if(!_27){ _27={fvalue:row[_25.groupField],rows:[row],startRow:i}; _26.push(_27); }else{ _27.rows.push(row); } } function _28(_29){ for(var i=0;i<_26.length;i++){ var _2a=_26[i]; if(_2a.fvalue==_29){ return _2a; } } return null; }; this.groups=_26; var _2b=[]; for(var i=0;i<_26.length;i++){ var _27=_26[i]; for(var j=0;j<_27.rows.length;j++){ _2b.push(_27.rows[j]); } } $.data(_23,"datagrid").data.rows=_2b; }}); $.fn.propertygrid.defaults=$.extend({},$.fn.datagrid.defaults,{singleSelect:true,remoteSort:false,fitColumns:true,loadMsg:"",frozenColumns:[[{field:"f",width:16,resizable:false}]],columns:[[{field:"name",title:"Name",width:100,sortable:true},{field:"value",title:"Value",width:100,resizable:false}]],showGroup:false,groupField:"group",groupFormatter:function(_2c){ return _2c; }}); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.propertygrid.js
JavaScript
asf20
5,070
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2,_3){ _3=_3||{}; if(_3.onSubmit){ if(_3.onSubmit.call(_2)==false){ return; } } var _4=$(_2); if(_3.url){ _4.attr("action",_3.url); } var _5="easyui_frame_"+(new Date().getTime()); var _6=$("<iframe id="+_5+" name="+_5+"></iframe>").attr("src",window.ActiveXObject?"javascript:false":"about:blank").css({position:"absolute",top:-1000,left:-1000}); var t=_4.attr("target"),a=_4.attr("action"); _4.attr("target",_5); try{ _6.appendTo("body"); _6.bind("load",cb); _4[0].submit(); } finally{ _4.attr("action",a); t?_4.attr("target",t):_4.removeAttr("target"); } var _7=10; function cb(){ _6.unbind(); var _8=$("#"+_5).contents().find("body"); var _9=_8.html(); if(_9==""){ if(--_7){ setTimeout(cb,100); return; } return; } var ta=_8.find(">textarea"); if(ta.length){ _9=ta.val(); }else{ var _a=_8.find(">pre"); if(_a.length){ _9=_a.html(); } } if(_3.success){ _3.success(_9); } setTimeout(function(){ _6.unbind(); _6.remove(); },100); }; }; function _b(_c,_d){ if(!$.data(_c,"form")){ $.data(_c,"form",{options:$.extend({},$.fn.form.defaults)}); } var _e=$.data(_c,"form").options; if(typeof _d=="string"){ var _f={}; if(_e.onBeforeLoad.call(_c,_f)==false){ return; } $.ajax({url:_d,data:_f,dataType:"json",success:function(_10){ _11(_10); },error:function(){ _e.onLoadError.apply(_c,arguments); }}); }else{ _11(_d); } function _11(_12){ var _13=$(_c); for(var _14 in _12){ var val=_12[_14]; var rr=_15(_14,val); if(!rr.length){ var f=_13.find("input[numberboxName=\""+_14+"\"]"); if(f.length){ f.numberbox("setValue",val); }else{ $("input[name=\""+_14+"\"]",_13).val(val); $("textarea[name=\""+_14+"\"]",_13).val(val); $("select[name=\""+_14+"\"]",_13).val(val); } } _16(_14,val); } _e.onLoadSuccess.call(_c,_12); _1f(_c); }; function _15(_17,val){ var _18=$(_c); var rr=$("input[name=\""+_17+"\"][type=radio], input[name=\""+_17+"\"][type=checkbox]",_18); $.fn.prop?rr.prop("checked",false):rr.attr("checked",false); rr.each(function(){ var f=$(this); if(f.val()==val){ $.fn.prop?f.prop("checked",true):f.attr("checked",true); } }); return rr; }; function _16(_19,val){ var _1a=$(_c); var cc=["combobox","combotree","combogrid","datetimebox","datebox","combo"]; var c=_1a.find("[comboName=\""+_19+"\"]"); if(c.length){ for(var i=0;i<cc.length;i++){ var _1b=cc[i]; if(c.hasClass(_1b+"-f")){ if(c[_1b]("options").multiple){ c[_1b]("setValues",val); }else{ c[_1b]("setValue",val); } return; } } } }; }; function _1c(_1d){ $("input,select,textarea",_1d).each(function(){ var t=this.type,tag=this.tagName.toLowerCase(); if(t=="text"||t=="hidden"||t=="password"||tag=="textarea"){ this.value=""; }else{ if(t=="file"){ var _1e=$(this); _1e.after(_1e.clone().val("")); _1e.remove(); }else{ if(t=="checkbox"||t=="radio"){ this.checked=false; }else{ if(tag=="select"){ this.selectedIndex=-1; } } } } }); if($.fn.combo){ $(".combo-f",_1d).combo("clear"); } if($.fn.combobox){ $(".combobox-f",_1d).combobox("clear"); } if($.fn.combotree){ $(".combotree-f",_1d).combotree("clear"); } if($.fn.combogrid){ $(".combogrid-f",_1d).combogrid("clear"); } _1f(_1d); }; function _20(_21){ var _22=$.data(_21,"form").options; var _23=$(_21); _23.unbind(".form").bind("submit.form",function(){ setTimeout(function(){ _1(_21,_22); },0); return false; }); }; function _1f(_24){ if($.fn.validatebox){ var box=$(".validatebox-text",_24); if(box.length){ box.validatebox("validate"); box.trigger("focus"); box.trigger("blur"); var _25=$(".validatebox-invalid:first",_24).focus(); return _25.length==0; } } return true; }; $.fn.form=function(_26,_27){ if(typeof _26=="string"){ return $.fn.form.methods[_26](this,_27); } _26=_26||{}; return this.each(function(){ if(!$.data(this,"form")){ $.data(this,"form",{options:$.extend({},$.fn.form.defaults,_26)}); } _20(this); }); }; $.fn.form.methods={ submit:function(jq,_28){ return jq.each(function(){ _1(this,$.extend({},$.fn.form.defaults,_28||{})); }); },load:function(jq,_29){ return jq.each(function(){ _b(this,_29); }); },clear:function(jq){ return jq.each(function(){ _1c(this); }); },validate:function(jq){ return _1f(jq[0]); }}; $.fn.form.defaults={url:null,onSubmit:function(){ return $(this).form("validate"); },success:function(_2a){ },onBeforeLoad:function(_2b){ },onLoadSuccess:function(_2c){ },onLoadError:function(){ }}; })(jQuery); //zzy+ /** * 扩展组件 */ $.extend($.fn.form.methods,{ /** * 支持ajax方式提交 * @param {} jq * @param {} param * @return {} */ 'ajax': function(jq, param){ return jq.each(function(){ if (param.onSubmit){ if (param.onSubmit.call(this) == false) { return; } } $.query(param['url'],param['data']||$(this).form('getValue'), param['success'], param['error']); }); }, /** * 获取Form所有组件的数据 */ getAllFields: function(jq){ var els = null; jq.each(function(){ els = this.elements; }); return els; }, /** * 获取Form所有组件的数据 */ findField: function(jq, name){ if(name.indexOf('.') != -1){ var els = jq.form('getAllFields'); for (var index = 0; index < els.length; index++) { var el = els[index]; if(el.name == name){ return $(el); } } } return jq.find('*[name='+name+']'); }, /** * 获取值,到时根据name拼接成json对象 * 如:组件form有name:user.name,user.id,dep.id, * 获取值后会拼接成{user:{name:11,id:22}, dep:{id:33}} * * 以便以后跟后台交互 */ getValue: function(jq, isJson){ var valArr = jq.form('getValueForArray'); if(isJson == true){ var valJson = {}; for (var index = 0; index < valArr.length; index++) { var param = valArr[index]; valJson[param['name']] = param['value']; } return valJson; }else{ return jQuery.param(valArr); } }, /** * 获取K-V对象数组 */ getValueForArray: function(jq) { var rCRLF = /\r?\n/g; var rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i; var rselectTextarea = /^(?:select|textarea)/i; return jq.map(function(){ return this.elements ? jQuery.makeArray( this.elements ) : this; }) .filter(function(){ return this.name && /*!this.disabled &&*/ ( this.checked || rselectTextarea.test( this.nodeName ) || rinput.test( this.type ) ); }) .map(function( i, elem ){ var val = jQuery( this ).val(); return val == null ? null : jQuery.isArray( val ) ? jQuery.map( val, function( val, i ){ return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; }) : { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; }).get(); } });
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.form.js
JavaScript
asf20
6,935
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ $(_2).hide(); var _3=$("<span class=\"searchbox\"></span>").insertAfter(_2); var _4=$("<input type=\"text\" class=\"searchbox-text\">").appendTo(_3); $("<span><span class=\"searchbox-button\"></span></span>").appendTo(_3); var _5=$(_2).attr("name"); if(_5){ _4.attr("name",_5); $(_2).removeAttr("name").attr("searchboxName",_5); } return _3; }; function _6(_7){ var _8=$.data(_7,"searchbox").options; var sb=$.data(_7,"searchbox").searchbox; if(_9){ _8.width=_9; } sb.appendTo("body"); if(isNaN(_8.width)){ _8.width=sb.find("input.searchbox.text").outerWidth(); } var _9=_8.width-sb.find("a.searchbox-menu").outerWidth()-sb.find("span.searchbox-button").outerWidth(); if($.boxModel==true){ _9-=sb.outerWidth()-sb.width(); } sb.find("input.searchbox-text").width(_9); sb.insertAfter(_7); }; function _a(_b){ var _c=$.data(_b,"searchbox"); var _d=_c.options; if(_d.menu){ _c.menu=$(_d.menu).menu({onClick:function(_e){ _f(_e); }}); var _10=_c.menu.menu("getItem",_c.menu.children("div.menu-item")[0]); _c.menu.children("div.menu-item").triggerHandler("click"); }else{ _c.searchbox.find("a.searchbox-menu").remove(); _c.menu=null; } function _f(_11){ _c.searchbox.find("a.searchbox-menu").remove(); var mb=$("<a class=\"searchbox-menu\" href=\"javascript:void(0)\"></a>").html(_11.text); mb.prependTo(_c.searchbox).menubutton({menu:_c.menu,iconCls:_11.iconCls}); _c.searchbox.find("input.searchbox-text").attr("name",$(_11.target).attr("name")||_11.text); _6(_b); }; }; function _12(_13){ var _14=$.data(_13,"searchbox"); var _15=_14.options; var _16=_14.searchbox.find("input.searchbox-text"); var _17=_14.searchbox.find(".searchbox-button"); _16.unbind(".searchbox").bind("blur.searchbox",function(e){ _15.value=$(this).val(); if(_15.value==""){ $(this).val(_15.prompt); $(this).addClass("searchbox-prompt"); }else{ $(this).removeClass("searchbox-prompt"); } }).bind("focus.searchbox",function(e){ if($(this).val()!=_15.value){ $(this).val(_15.value); } $(this).removeClass("searchbox-prompt"); }).bind("keydown.searchbox",function(e){ if(e.keyCode==13){ e.preventDefault(); _15.value=$(this).val(); _15.searcher.call(_13,_15.value,_16.attr("name")); return false; } }); _17.unbind(".searchbox").bind("click.searchbox",function(){ _15.searcher.call(_13,_15.value,_16.attr("name")); }).bind("mouseenter.searchbox",function(){ $(this).addClass("searchbox-button-hover"); }).bind("mouseleave.searchbox",function(){ $(this).removeClass("searchbox-button-hover"); }); }; function _18(_19){ var _1a=$.data(_19,"searchbox"); var _1b=_1a.options; var _1c=_1a.searchbox.find("input.searchbox-text"); if(_1b.value==""){ _1c.val(_1b.prompt); _1c.addClass("searchbox-prompt"); }else{ _1c.val(_1b.value); _1c.removeClass("searchbox-prompt"); } }; $.fn.searchbox=function(_1d,_1e){ if(typeof _1d=="string"){ return $.fn.searchbox.methods[_1d](this,_1e); } _1d=_1d||{}; return this.each(function(){ var _1f=$.data(this,"searchbox"); if(_1f){ $.extend(_1f.options,_1d); }else{ _1f=$.data(this,"searchbox",{options:$.extend({},$.fn.searchbox.defaults,$.fn.searchbox.parseOptions(this),_1d),searchbox:_1(this)}); } _a(this); _18(this); _12(this); _6(this); }); }; $.fn.searchbox.methods={options:function(jq){ return $.data(jq[0],"searchbox").options; },menu:function(jq){ return $.data(jq[0],"searchbox").menu; },textbox:function(jq){ return $.data(jq[0],"searchbox").searchbox.find("input.searchbox-text"); },getValue:function(jq){ return $.data(jq[0],"searchbox").options.value; },setValue:function(jq,_20){ return jq.each(function(){ $(this).searchbox("options").value=_20; $(this).searchbox("textbox").val(_20); $(this).searchbox("textbox").blur(); }); },getName:function(jq){ return $.data(jq[0],"searchbox").searchbox.find("input.searchbox-text").attr("name"); },destroy:function(jq){ return jq.each(function(){ var _21=$(this).searchbox("menu"); if(_21){ _21.menu("destroy"); } $.data(this,"searchbox").searchbox.remove(); $(this).remove(); }); },resize:function(jq,_22){ return jq.each(function(){ _6(this,_22); }); }}; $.fn.searchbox.parseOptions=function(_23){ var t=$(_23); return {width:(parseInt(_23.style.width)||undefined),prompt:t.attr("prompt"),value:t.val(),menu:t.attr("menu"),searcher:(t.attr("searcher")?eval(t.attr("searcher")):undefined)}; }; $.fn.searchbox.defaults={width:"auto",prompt:"",value:"",menu:null,searcher:function(_24,_25){ }}; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.searchbox.js
JavaScript
asf20
4,583
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ var _1=false; $.fn.resizable=function(_2,_3){ if(typeof _2=="string"){ return $.fn.resizable.methods[_2](this,_3); } function _4(e){ var _5=e.data; var _6=$.data(_5.target,"resizable").options; if(_5.dir.indexOf("e")!=-1){ var _7=_5.startWidth+e.pageX-_5.startX; _7=Math.min(Math.max(_7,_6.minWidth),_6.maxWidth); _5.width=_7; } if(_5.dir.indexOf("s")!=-1){ var _8=_5.startHeight+e.pageY-_5.startY; _8=Math.min(Math.max(_8,_6.minHeight),_6.maxHeight); _5.height=_8; } if(_5.dir.indexOf("w")!=-1){ _5.width=_5.startWidth-e.pageX+_5.startX; if(_5.width>=_6.minWidth&&_5.width<=_6.maxWidth){ _5.left=_5.startLeft+e.pageX-_5.startX; } } if(_5.dir.indexOf("n")!=-1){ _5.height=_5.startHeight-e.pageY+_5.startY; if(_5.height>=_6.minHeight&&_5.height<=_6.maxHeight){ _5.top=_5.startTop+e.pageY-_5.startY; } } }; function _9(e){ var _a=e.data; var _b=_a.target; if($.boxModel==true){ $(_b).css({width:_a.width-_a.deltaWidth,height:_a.height-_a.deltaHeight,left:_a.left,top:_a.top}); }else{ $(_b).css({width:_a.width,height:_a.height,left:_a.left,top:_a.top}); } }; function _c(e){ _1=true; $.data(e.data.target,"resizable").options.onStartResize.call(e.data.target,e); return false; }; function _d(e){ _4(e); if($.data(e.data.target,"resizable").options.onResize.call(e.data.target,e)!=false){ _9(e); } return false; }; function _e(e){ _1=false; _4(e,true); _9(e); $.data(e.data.target,"resizable").options.onStopResize.call(e.data.target,e); $(document).unbind(".resizable"); $("body").css("cursor","auto"); return false; }; return this.each(function(){ var _f=null; var _10=$.data(this,"resizable"); if(_10){ $(this).unbind(".resizable"); _f=$.extend(_10.options,_2||{}); }else{ _f=$.extend({},$.fn.resizable.defaults,_2||{}); $.data(this,"resizable",{options:_f}); } if(_f.disabled==true){ return; } $(this).bind("mousemove.resizable",{target:this},function(e){ if(_1){ return; } var dir=_11(e); if(dir==""){ $(e.data.target).css("cursor",""); }else{ $(e.data.target).css("cursor",dir+"-resize"); } }).bind("mousedown.resizable",{target:this},function(e){ var dir=_11(e); if(dir==""){ return; } function _12(css){ var val=parseInt($(e.data.target).css(css)); if(isNaN(val)){ return 0; }else{ return val; } }; var _13={target:e.data.target,dir:dir,startLeft:_12("left"),startTop:_12("top"),left:_12("left"),top:_12("top"),startX:e.pageX,startY:e.pageY,startWidth:$(e.data.target).outerWidth(),startHeight:$(e.data.target).outerHeight(),width:$(e.data.target).outerWidth(),height:$(e.data.target).outerHeight(),deltaWidth:$(e.data.target).outerWidth()-$(e.data.target).width(),deltaHeight:$(e.data.target).outerHeight()-$(e.data.target).height()}; $(document).bind("mousedown.resizable",_13,_c); $(document).bind("mousemove.resizable",_13,_d); $(document).bind("mouseup.resizable",_13,_e); $("body").css("cursor",dir+"-resize"); }).bind("mouseleave.resizable",{target:this},function(e){ $(e.data.target).css("cursor",""); }); function _11(e){ var tt=$(e.data.target); var dir=""; var _14=tt.offset(); var _15=tt.outerWidth(); var _16=tt.outerHeight(); var _17=_f.edge; if(e.pageY>_14.top&&e.pageY<_14.top+_17){ dir+="n"; }else{ if(e.pageY<_14.top+_16&&e.pageY>_14.top+_16-_17){ dir+="s"; } } if(e.pageX>_14.left&&e.pageX<_14.left+_17){ dir+="w"; }else{ if(e.pageX<_14.left+_15&&e.pageX>_14.left+_15-_17){ dir+="e"; } } var _18=_f.handles.split(","); for(var i=0;i<_18.length;i++){ var _19=_18[i].replace(/(^\s*)|(\s*$)/g,""); if(_19=="all"||_19==dir){ return dir; } } return ""; }; }); }; $.fn.resizable.methods={options:function(jq){ return $.data(jq[0],"resizable").options; },enable:function(jq){ return jq.each(function(){ $(this).resizable({disabled:false}); }); },disable:function(jq){ return jq.each(function(){ $(this).resizable({disabled:true}); }); }}; $.fn.resizable.defaults={disabled:false,handles:"n, e, s, w, ne, se, sw, nw, all",minWidth:10,minHeight:10,maxWidth:10000,maxHeight:10000,edge:5,onStartResize:function(e){ },onResize:function(e){ },onStopResize:function(e){ }}; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.resizable.js
JavaScript
asf20
4,203
/** * jQuery EasyUI 1.2.5 * * Licensed under the GPL terms * To use it on other terms please contact us * * Copyright(c) 2009-2011 stworthy [ stworthy@gmail.com ] * */ (function($){ function _1(_2){ var _3=$.data(_2,"accordion").options; var _4=$.data(_2,"accordion").panels; var cc=$(_2); if(_3.fit==true){ var p=cc.parent(); _3.width=p.width(); _3.height=p.height(); } if(_3.width>0){ cc.width($.boxModel==true?(_3.width-(cc.outerWidth()-cc.width())):_3.width); } var _5="auto"; if(_3.height>0){ cc.height($.boxModel==true?(_3.height-(cc.outerHeight()-cc.height())):_3.height); var _6=_4.length?_4[0].panel("header").css("height",null).outerHeight():"auto"; var _5=cc.height()-(_4.length-1)*_6; } for(var i=0;i<_4.length;i++){ var _7=_4[i]; var _8=_7.panel("header"); _8.height($.boxModel==true?(_6-(_8.outerHeight()-_8.height())):_6); _7.panel("resize",{width:cc.width(),height:_5}); } }; function _9(_a){ var _b=$.data(_a,"accordion").panels; for(var i=0;i<_b.length;i++){ var _c=_b[i]; if(_c.panel("options").collapsed==false){ return _c; } } return null; }; function _d(_e,_f,_10){ var _11=$.data(_e,"accordion").panels; for(var i=0;i<_11.length;i++){ var _12=_11[i]; if(_12.panel("options").title==_f){ if(_10){ _11.splice(i,1); } return _12; } } return null; }; function _13(_14){ var cc=$(_14); cc.addClass("accordion"); if(cc.attr("border")=="false"){ cc.addClass("accordion-noborder"); }else{ cc.removeClass("accordion-noborder"); } var _15=cc.children("div[selected=true]"); cc.children("div").not(_15).attr("collapsed","true"); if(_15.length==0){// zzy+ //cc.children("div:first").attr("collapsed","false"); } var _16=[]; cc.children("div").each(function(){ var pp=$(this); _16.push(pp); _19(_14,pp,{}); }); cc.bind("_resize",function(e,_17){ var _18=$.data(_14,"accordion").options; if(_18.fit==true||_17){ _1(_14); } return false; }); return {accordion:cc,panels:_16}; }; function _19(_1a,pp,_1b){ pp.panel($.extend({},_1b,{collapsible:false,minimizable:false,maximizable:false,closable:false,doSize:false,tools:[{iconCls:"accordion-collapse",handler:function(){ var _1c=$.data(_1a,"accordion").options.animate; if(pp.panel("options").collapsed){ _28(_1a); pp.panel("expand",_1c); }else{ _28(_1a); pp.panel("collapse",_1c); } return false; }}],onBeforeExpand:function(){ var _1d=_9(_1a); if(_1d){ var _1e=$(_1d).panel("header"); _1e.removeClass("accordion-header-selected"); _1e.find(".accordion-collapse").triggerHandler("click"); } var _1e=pp.panel("header"); _1e.addClass("accordion-header-selected"); _1e.find("div.accordion-collapse").removeClass("accordion-expand"); },onExpand:function(){ var _1f=$.data(_1a,"accordion").options; _1f.onSelect.call(_1a,pp.panel("options").title); },onBeforeCollapse:function(){ var _20=pp.panel("header"); _20.removeClass("accordion-header-selected"); _20.find("div.accordion-collapse").addClass("accordion-expand"); }})); pp.panel("body").addClass("accordion-body"); pp.panel("header").addClass("accordion-header").click(function(){ $(this).find(".accordion-collapse").triggerHandler("click"); return false; }); }; function _21(_22,_23){ var _24=$.data(_22,"accordion").options; var _25=$.data(_22,"accordion").panels; var _26=_9(_22); if(_26&&_26.panel("options").title==_23){ return; } var _27=_d(_22,_23); if(_27){ _27.panel("header").triggerHandler("click"); }else{ if(_26){ _26.panel("header").addClass("accordion-header-selected"); _24.onSelect.call(_22,_26.panel("options").title); } } }; function _28(_29){ var _2a=$.data(_29,"accordion").panels; for(var i=0;i<_2a.length;i++){ _2a[i].stop(true,true); } }; function add(_2b,_2c){ var _2d=$.data(_2b,"accordion").options; var _2e=$.data(_2b,"accordion").panels; _28(_2b); var pp=$("<div></div>").appendTo(_2b); _2e.push(pp); _19(_2b,pp,_2c); _1(_2b); _2d.onAdd.call(_2b,_2c.title); _21(_2b,_2c.title); }; function _2f(_30,_31){ var _32=$.data(_30,"accordion").options; var _33=$.data(_30,"accordion").panels; _28(_30); if(_32.onBeforeRemove.call(_30,_31)==false){ return; } var _34=_d(_30,_31,true); if(_34){ _34.panel("destroy"); if(_33.length){ _1(_30); var _35=_9(_30); if(!_35){ _21(_30,_33[0].panel("options").title); } } } _32.onRemove.call(_30,_31); }; $.fn.accordion=function(_36,_37){ if(typeof _36=="string"){ return $.fn.accordion.methods[_36](this,_37); } _36=_36||{}; return this.each(function(){ var _38=$.data(this,"accordion"); var _39; if(_38){ _39=$.extend(_38.options,_36); _38.opts=_39; }else{ _39=$.extend({},$.fn.accordion.defaults,$.fn.accordion.parseOptions(this),_36); var r=_13(this); $.data(this,"accordion",{options:_39,accordion:r.accordion,panels:r.panels}); } _1(this); _21(this); }); }; $.fn.accordion.methods={options:function(jq){ return $.data(jq[0],"accordion").options; },panels:function(jq){ return $.data(jq[0],"accordion").panels; },resize:function(jq){ return jq.each(function(){ _1(this); }); },getSelected:function(jq){ return _9(jq[0]); },getPanel:function(jq,_3a){ return _d(jq[0],_3a); },select:function(jq,_3b){ return jq.each(function(){ _21(this,_3b); }); },add:function(jq,_3c){ return jq.each(function(){ add(this,_3c); }); },remove:function(jq,_3d){ return jq.each(function(){ _2f(this,_3d); }); }}; $.fn.accordion.parseOptions=function(_3e){ var t=$(_3e); return {width:(parseInt(_3e.style.width)||undefined),height:(parseInt(_3e.style.height)||undefined),fit:(t.attr("fit")?t.attr("fit")=="true":undefined),border:(t.attr("border")?t.attr("border")=="true":undefined),animate:(t.attr("animate")?t.attr("animate")=="true":undefined)}; }; $.fn.accordion.defaults={width:"auto",height:"auto",fit:false,border:true,animate:true,onSelect:function(_3f){ },onAdd:function(_40){ },onBeforeRemove:function(_41){ },onRemove:function(_42){ }}; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/plugins/jquery.accordion.js
JavaScript
asf20
5,737
/** * dmenu - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2009 stworthy [ stworthy@gmail.com ] * * Dependencies: * shadow * * Options: * minWidth: integer, the menu minimum width. default 150 * shadow: boolean, true to show shadow and false to hide. default true * minZIndex: integer, the menu's zIndex value. default 500 */ (function($){ $.fn.dmenu = function(options){ options = $.extend({}, $.fn.dmenu.defaults, options || {}); return this.each(function(){ $('li ul li a', this).each(function(){ if (/^[u4E00-u9FA5]/.test($(this).html()) == false && $.browser.msie) { $(this).css('padding', '7px 20px 5px 30px'); } }); $('li.dmenu-sep', this).html('&nbsp;'); var mainmenu = $(this); var menus = mainmenu.find('ul').parent(); menus.each(function(i) { $(this).css('z-index', options.minZIndex + menus.length - i); if (mainmenu[0] != $(this).parent()[0]) { if ($('>ul', this).length > 0) { $('>a', this).append('<span class="dmenu-right-arrow"></span>'); } } else { if ($('>ul', this).length > 0) { $('<span></span>').addClass('dmenu-down-arrow') .css('top', $(this).height()/2-4) .appendTo($('>a', this)); } } if (options.shadow) { var shadow = $('<div class="dmenu-shadow"><div class="dmenu-shadow-inner"></div></div>'); shadow.css({ width:20, height:20 }); shadow.prependTo(this); $('.dmenu-shadow-inner', shadow).shadow({width:5, fit:true, hidden:true}); } }); $('a', this).each(function(){ var icon = $(this).attr('icon'); if (icon) { $('<span></span>').addClass('dmenu-icon').addClass(icon).appendTo(this); } }); // show the main menu $('>li', this).hover( function(){ var menu = $(this).find('ul:eq(0)'); if (menu.length == 0) return; $('a', menu).css('width', 'auto'); var menuWidth = menu.width(); if (menuWidth < options.minWidth) { menuWidth = options.minWidth; } if ($.boxModel == true) { $('>li>a', menu).css('width', menuWidth - 45); } else { $('>li', menu).css('width', menuWidth); $('>li>a', menu).css('width', menuWidth); } var parent = menu.parent(); if (parent.offset().left + menu.outerWidth() > $(window).width()) { var left = menu.offset().left; left -= parent.offset().left + menu.outerWidth() - $(window).width() + 5; menu.css('left', left); } $('li:last', menu).css('border-bottom', '0px'); menu.fadeIn('normal'); $('>div.dmenu-shadow', this).css({ left: parseInt(menu.css('left')) - 5, top: $(this).height(), width: menu.outerWidth() + 10, height: menu.outerHeight() + 5, display: 'block' }); $('.dmenu-shadow-inner', this).shadow({hidden:false}); }, function(){ var menu = $(this).find('ul:eq(0)'); menu.fadeOut('normal'); $('div.dmenu-shadow', this).css('display', 'none'); } ); // show the sub menu $('li ul li', this).hover( function(){ var menu = $(this).find('ul:eq(0)'); if (menu.length == 0) return; $('a', menu).css('width', 'auto'); var menuWidth = menu.width(); if (menuWidth < options.minWidth) { menuWidth = options.minWidth; } if ($.boxModel == true) { $('>li>a', menu).css('width', menuWidth - 45); } else { $('>li', menu).css('width', menuWidth); $('>li>a', menu).css('width', menuWidth); } var parent = menu.parent(); if (parent.offset().left + parent.outerWidth() + menu.outerWidth() > $(window).width()) { menu.css('left', - menu.outerWidth() + 5); } else { menu.css('left', parent.outerWidth() - 5); } menu.fadeIn('normal'); $('>div.dmenu-shadow', this).css({ left: parseInt(menu.css('left')) - 5, top: parseInt(menu.css('top')), width: menu.outerWidth() + 10, height: menu.outerHeight() + 5, display: 'block' }); $('.dmenu-shadow-inner', this).shadow({hidden:false}); }, function(){ $('>div.dmenu-shadow', this).css('display', 'none'); $(this).children('ul:first').animate({height:'hide',opacity:'hide'}); } ); }); }; $.fn.dmenu.defaults = { minWidth:150, shadow:true, minZIndex:500 }; $(function(){ $('ul.dmenu').dmenu(); }); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.dmenu.js
JavaScript
asf20
4,748
/** * easyloader - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * */ (function(){ var modules = { draggable:{ js:'jquery.draggable.js' }, droppable:{ js:'jquery.droppable.js' }, resizable:{ js:'jquery.resizable.js' }, linkbutton:{ js:'jquery.linkbutton.js', css:'linkbutton.css' }, pagination:{ js:'jquery.pagination.js', css:'pagination.css', dependencies:['linkbutton'] }, datagrid:{ js:'jquery.datagrid.js', css:'datagrid.css', dependencies:['panel','resizable','linkbutton','pagination'] }, treegrid:{ js:'jquery.treegrid.js', css:'tree.css', dependencies:['datagrid'] }, panel: { js:'jquery.panel.js', css:'panel.css' }, window:{ js:'jquery.window.js', css:'window.css', dependencies:['resizable','draggable','panel'] }, dialog:{ js:'jquery.dialog.js', css:'dialog.css', dependencies:['linkbutton','window'] }, messager:{ js:'jquery.messager.js', css:'messager.css', dependencies:['linkbutton','window'] }, layout:{ js:'jquery.layout.js', css:'layout.css', dependencies:['resizable','panel'] }, form:{ js:'jquery.form.js' }, menu:{ js:'jquery.menu.js', css:'menu.css' }, tabs:{ js:'jquery.tabs.js', css:'tabs.css', dependencies:['panel','linkbutton'] }, splitbutton:{ js:'jquery.splitbutton.js', css:'splitbutton.css', dependencies:['linkbutton','menu'] }, menubutton:{ js:'jquery.menubutton.js', css:'menubutton.css', dependencies:['linkbutton','menu'] }, accordion:{ js:'jquery.accordion.js', css:'accordion.css', dependencies:['panel'] }, calendar:{ js:'jquery.calendar.js', css:'calendar.css' }, combo:{ js:'jquery.combo.js', css:'combo.css', dependencies:['panel','validatebox'] }, combobox:{ js:'jquery.combobox.js', css:'combobox.css', dependencies:['combo'] }, combotree:{ js:'jquery.combotree.js', dependencies:['combo','tree'] }, combogrid:{ js:'jquery.combogrid.js', dependencies:['combo','datagrid'] }, validatebox:{ js:'jquery.validatebox.js', css:'validatebox.css' }, numberbox:{ js:'jquery.numberbox.js', dependencies:['validatebox'] }, spinner:{ js:'jquery.spinner.js', css:'spinner.css', dependencies:['validatebox'] }, numberspinner:{ js:'jquery.numberspinner.js', dependencies:['spinner','numberbox'] }, timespinner:{ js:'jquery.timespinner.js', dependencies:['spinner'] }, tree:{ js:'jquery.tree.js', css:'tree.css', dependencies:['draggable','droppable'] }, datebox:{ js:'jquery.datebox.js', css:'datebox.css', dependencies:['calendar','validatebox'] }, parser:{ js:'jquery.parser.js' } }; var locales = { 'af':'easyui-lang-af.js', 'bg':'easyui-lang-bg.js', 'ca':'easyui-lang-ca.js', 'cs':'easyui-lang-cs.js', 'da':'easyui-lang-da.js', 'de':'easyui-lang-de.js', 'en':'easyui-lang-en.js', 'fr':'easyui-lang-fr.js', 'nl':'easyui-lang-nl.js', 'zh_CN':'easyui-lang-zh_CN.js', 'zh_TW':'easyui-lang-zh_TW.js' }; var queues = {}; function loadJs(url, callback){ var done = false; var script = document.createElement('script'); script.type = 'text/javascript'; script.language = 'javascript'; script.src = url; script.onload = script.onreadystatechange = function(){ if (!done && (!script.readyState || script.readyState == 'loaded' || script.readyState == 'complete')){ done = true; script.onload = script.onreadystatechange = null; if (callback){ callback.call(script); } } } document.getElementsByTagName("head")[0].appendChild(script); } function runJs(url, callback){ loadJs(url, function(){ document.getElementsByTagName("head")[0].removeChild(this); if (callback){ callback(); } }); } function loadCss(url, callback){ var link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; link.media = 'screen'; link.href = url; document.getElementsByTagName('head')[0].appendChild(link); if (callback){ callback.call(link); } } function loadSingle(name, callback){ queues[name] = 'loading'; var module = modules[name]; var jsStatus = 'loading'; var cssStatus = (easyloader.css && module['css']) ? 'loading' : 'loaded'; if (easyloader.css && module['css']){ if (/^http/i.test(module['css'])){ var url = module['css']; } else { var url = easyloader.base + 'themes/' + easyloader.theme + '/' + module['css']; } loadCss(url, function(){ cssStatus = 'loaded'; if (jsStatus == 'loaded' && cssStatus == 'loaded'){ finish(); } }); } if (/^http/i.test(module['js'])){ var url = module['js']; } else { var url = easyloader.base + 'plugins/' + module['js']; } loadJs(url, function(){ jsStatus = 'loaded'; if (jsStatus == 'loaded' && cssStatus == 'loaded'){ finish(); } }); function finish(){ queues[name] = 'loaded'; easyloader.onProgress(name); if (callback){ callback(); } } } function loadModule(name, callback){ var mm = []; var doLoad = false; if (typeof name == 'string'){ add(name); } else { for(var i=0; i<name.length; i++){ add(name[i]); } } function add(name){ if (!modules[name]) return; var d = modules[name]['dependencies']; if (d){ for(var i=0; i<d.length; i++){ add(d[i]); } } mm.push(name); } function finish(){ if (callback){ callback(); } easyloader.onLoad(name); } var time = 0; function loadMm(){ if (mm.length){ var m = mm[0]; // the first module if (!queues[m]){ doLoad = true; loadSingle(m, function(){ mm.shift(); loadMm(); }); } else if (queues[m] == 'loaded'){ mm.shift(); loadMm(); } else { if (time < easyloader.timeout){ time += 10; setTimeout(arguments.callee, 10); } } } else { if (easyloader.locale && doLoad == true && locales[easyloader.locale]){ var url = easyloader.base + 'locale/' + locales[easyloader.locale]; runJs(url, function(){ finish(); }); } else { finish(); } } } loadMm(); } easyloader = { modules:modules, locales:locales, base:'.', theme:'default', css:true, locale:null, timeout:2000, load: function(name, callback){ if (/\.css$/i.test(name)){ if (/^http/i.test(name)){ loadCss(name, callback); } else { loadCss(easyloader.base + name, callback); } } else if (/\.js$/i.test(name)){ if (/^http/i.test(name)){ loadJs(name, callback); } else { loadJs(easyloader.base + name, callback); } } else { loadModule(name, callback); } }, onProgress: function(name){}, onLoad: function(name){} }; var scripts = document.getElementsByTagName('script'); for(var i=0; i<scripts.length; i++){ var src = scripts[i].src; if (!src) continue; var m = src.match(/easyloader\.js(\W|$)/i); if (m){ easyloader.base = src.substring(0, m.index); } } window.using = easyloader.load; if (window.jQuery){ jQuery(function(){ easyloader.load('parser', function(){ jQuery.parser.parse(); }); }); } })();
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/easyloader.js
JavaScript
asf20
7,758
/** * droppable - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] */ (function($){ function init(target){ $(target).addClass('droppable'); $(target).bind('_dragenter', function(e, source){ $.data(target, 'droppable').options.onDragEnter.apply(target, [e, source]); }); $(target).bind('_dragleave', function(e, source){ $.data(target, 'droppable').options.onDragLeave.apply(target, [e, source]); }); $(target).bind('_dragover', function(e, source){ $.data(target, 'droppable').options.onDragOver.apply(target, [e, source]); }); $(target).bind('_drop', function(e, source){ $.data(target, 'droppable').options.onDrop.apply(target, [e, source]); }); } $.fn.droppable = function(options){ options = options || {}; return this.each(function(){ var state = $.data(this, 'droppable'); if (state){ $.extend(state.options, options); } else { init(this); $.data(this, 'droppable', { options: $.extend({}, $.fn.droppable.defaults, options) }); } }); }; $.fn.droppable.defaults = { accept:null, onDragEnter:function(e, source){}, onDragOver:function(e, source){}, onDragLeave:function(e, source){}, onDrop:function(e, source){} }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.droppable.js
JavaScript
asf20
1,360
/** * calendar - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * */ (function($){ function setSize(target){ var opts = $.data(target, 'calendar').options; var t = $(target); if (opts.fit == true){ var p = t.parent(); opts.width = p.width(); opts.height = p.height(); } var header = t.find('.calendar-header'); if ($.boxModel == true){ t.width(opts.width - (t.outerWidth() - t.width())); t.height(opts.height - (t.outerHeight() - t.height())); } else { t.width(opts.width); t.height(opts.height); } var body = t.find('.calendar-body'); var height = t.height() - header.outerHeight(); if ($.boxModel == true){ body.height(height - (body.outerHeight() - body.height())); } else { body.height(height); } } function init(target){ $(target).addClass('calendar').wrapInner( '<div class="calendar-header">' + '<div class="calendar-prevmonth"></div>' + '<div class="calendar-nextmonth"></div>' + '<div class="calendar-prevyear"></div>' + '<div class="calendar-nextyear"></div>' + '<div class="calendar-title">' + '<span>Aprial 2010</span>' + '</div>' + '</div>' + '<div class="calendar-body">' + '<div class="calendar-menu">' + '<div class="calendar-menu-year-inner">' + '<span class="calendar-menu-prev"></span>' + '<span><input class="calendar-menu-year" type="text"></input></span>' + '<span class="calendar-menu-next"></span>' + '</div>' + '<div class="calendar-menu-month-inner">' + '</div>' + '</div>' + '</div>' ); $(target).find('.calendar-title span').hover( function(){$(this).addClass('calendar-menu-hover');}, function(){$(this).removeClass('calendar-menu-hover');} ).click(function(){ var menu = $(target).find('.calendar-menu'); if (menu.is(':visible')){ menu.hide(); } else { showSelectMenus(target); } }); $('.calendar-prevmonth,.calendar-nextmonth,.calendar-prevyear,.calendar-nextyear', target).hover( function(){$(this).addClass('calendar-nav-hover');}, function(){$(this).removeClass('calendar-nav-hover');} ); $(target).find('.calendar-nextmonth').click(function(){ showMonth(target, 1); }); $(target).find('.calendar-prevmonth').click(function(){ showMonth(target, -1); }); $(target).find('.calendar-nextyear').click(function(){ showYear(target, 1); }); $(target).find('.calendar-prevyear').click(function(){ showYear(target, -1); }); $(target).bind('_resize', function(){ var opts = $.data(target, 'calendar').options; if (opts.fit == true){ setSize(target); } return false; }); } /** * show the calendar corresponding to the current month. */ function showMonth(target, delta){ var opts = $.data(target, 'calendar').options; opts.month += delta; if (opts.month > 12){ opts.year++; opts.month = 1; } else if (opts.month < 1){ opts.year--; opts.month = 12; } show(target); var menu = $(target).find('.calendar-menu-month-inner'); menu.find('td.calendar-selected').removeClass('calendar-selected'); menu.find('td:eq(' + (opts.month-1) + ')').addClass('calendar-selected'); } /** * show the calendar corresponding to the current year. */ function showYear(target, delta){ var opts = $.data(target, 'calendar').options; opts.year += delta; show(target); var menu = $(target).find('.calendar-menu-year'); menu.val(opts.year); } /** * show the select menu that can change year or month, if the menu is not be created then create it. */ function showSelectMenus(target){ var opts = $.data(target, 'calendar').options; $(target).find('.calendar-menu').show(); if ($(target).find('.calendar-menu-month-inner').is(':empty')){ $(target).find('.calendar-menu-month-inner').empty(); var t = $('<table></table>').appendTo($(target).find('.calendar-menu-month-inner')); var idx = 0; for(var i=0; i<3; i++){ var tr = $('<tr></tr>').appendTo(t); for(var j=0; j<4; j++){ $('<td class="calendar-menu-month"></td>').html(opts.months[idx++]).attr('abbr',idx).appendTo(tr); } } $(target).find('.calendar-menu-prev,.calendar-menu-next').hover( function(){$(this).addClass('calendar-menu-hover');}, function(){$(this).removeClass('calendar-menu-hover');} ); $(target).find('.calendar-menu-next').click(function(){ var y = $(target).find('.calendar-menu-year'); if (!isNaN(y.val())){ y.val(parseInt(y.val()) + 1); } }); $(target).find('.calendar-menu-prev').click(function(){ var y = $(target).find('.calendar-menu-year'); if (!isNaN(y.val())){ y.val(parseInt(y.val() - 1)); } }); $(target).find('.calendar-menu-year').keypress(function(e){ if (e.keyCode == 13){ setDate(); } }); $(target).find('.calendar-menu-month').hover( function(){$(this).addClass('calendar-menu-hover');}, function(){$(this).removeClass('calendar-menu-hover');} ).click(function(){ var menu = $(target).find('.calendar-menu'); menu.find('.calendar-selected').removeClass('calendar-selected'); $(this).addClass('calendar-selected'); setDate(); }); } function setDate(){ var menu = $(target).find('.calendar-menu'); var year = menu.find('.calendar-menu-year').val(); var month = menu.find('.calendar-selected').attr('abbr'); if (!isNaN(year)){ opts.year = parseInt(year); opts.month = parseInt(month); show(target); } menu.hide(); } var body = $(target).find('.calendar-body'); var sele = $(target).find('.calendar-menu'); var seleYear = sele.find('.calendar-menu-year-inner'); var seleMonth = sele.find('.calendar-menu-month-inner'); seleYear.find('input').val(opts.year).focus(); seleMonth.find('td.calendar-selected').removeClass('calendar-selected'); seleMonth.find('td:eq('+(opts.month-1)+')').addClass('calendar-selected'); if ($.boxModel == true){ sele.width(body.outerWidth() - (sele.outerWidth() - sele.width())); sele.height(body.outerHeight() - (sele.outerHeight() - sele.height())); seleMonth.height(sele.height() - (seleMonth.outerHeight() - seleMonth.height()) - seleYear.outerHeight()); } else { sele.width(body.outerWidth()); sele.height(body.outerHeight()); seleMonth.height(sele.height() - seleYear.outerHeight()); } } /** * get weeks data. */ function getWeeks(year, month){ var dates = []; var lastDay = new Date(year, month, 0).getDate(); for(var i=1; i<=lastDay; i++) dates.push([year,month,i]); // group date by week var weeks = [], week = []; while(dates.length > 0){ var date = dates.shift(); week.push(date); if (new Date(date[0],date[1]-1,date[2]).getDay() == 6){ weeks.push(week); week = []; } } if (week.length){ weeks.push(week); } var firstWeek = weeks[0]; if (firstWeek.length < 7){ while(firstWeek.length < 7){ var firstDate = firstWeek[0]; var date = new Date(firstDate[0],firstDate[1]-1,firstDate[2]-1) firstWeek.unshift([date.getFullYear(), date.getMonth()+1, date.getDate()]); } } else { var firstDate = firstWeek[0]; var week = []; for(var i=1; i<=7; i++){ var date = new Date(firstDate[0], firstDate[1]-1, firstDate[2]-i); week.unshift([date.getFullYear(), date.getMonth()+1, date.getDate()]); } weeks.unshift(week); } var lastWeek = weeks[weeks.length-1]; while(lastWeek.length < 7){ var lastDate = lastWeek[lastWeek.length-1]; var date = new Date(lastDate[0], lastDate[1]-1, lastDate[2]+1); lastWeek.push([date.getFullYear(), date.getMonth()+1, date.getDate()]); } if (weeks.length < 6){ var lastDate = lastWeek[lastWeek.length-1]; var week = []; for(var i=1; i<=7; i++){ var date = new Date(lastDate[0], lastDate[1]-1, lastDate[2]+i); week.push([date.getFullYear(), date.getMonth()+1, date.getDate()]); } weeks.push(week); } return weeks; } /** * show the calendar day. */ function show(target){ var opts = $.data(target, 'calendar').options; $(target).find('.calendar-title span').html(opts.months[opts.month-1] + ' ' + opts.year); var body = $(target).find('div.calendar-body'); body.find('>table').remove(); var t = $('<table cellspacing="0" cellpadding="0" border="0"><thead></thead><tbody></tbody></table>').prependTo(body); var tr = $('<tr></tr>').appendTo(t.find('thead')); for(var i=0; i<opts.weeks.length; i++){ tr.append('<th>'+opts.weeks[i]+'</th>'); } var weeks = getWeeks(opts.year, opts.month); for(var i=0; i<weeks.length; i++){ var week = weeks[i]; var tr = $('<tr></tr>').appendTo(t.find('tbody')); for(var j=0; j<week.length; j++){ var day = week[j]; $('<td class="calendar-day calendar-other-month"></td>').attr('abbr',day[0]+','+day[1]+','+day[2]).html(day[2]).appendTo(tr); } } t.find('td[abbr^='+opts.year+','+opts.month+']').removeClass('calendar-other-month'); var now = new Date(); var today = now.getFullYear()+','+(now.getMonth()+1)+','+now.getDate(); t.find('td[abbr='+today+']').addClass('calendar-today'); if (opts.current){ t.find('.calendar-selected').removeClass('calendar-selected'); var current = opts.current.getFullYear()+','+(opts.current.getMonth()+1)+','+opts.current.getDate(); t.find('td[abbr='+current+']').addClass('calendar-selected'); } t.find('tr').find('td:first').addClass('calendar-sunday'); t.find('tr').find('td:last').addClass('calendar-saturday'); t.find('td').hover( function(){$(this).addClass('calendar-hover');}, function(){$(this).removeClass('calendar-hover');} ).click(function(){ t.find('.calendar-selected').removeClass('calendar-selected'); $(this).addClass('calendar-selected'); var parts = $(this).attr('abbr').split(','); opts.current = new Date(parts[0], parseInt(parts[1])-1, parts[2]); opts.onSelect.call(target, opts.current); }); } $.fn.calendar = function(options){ options = options || {}; return this.each(function(){ var state = $.data(this, 'calendar'); if (state){ $.extend(state.options, options); } else { init(this); state = $.data(this, 'calendar', { options:$.extend({}, $.fn.calendar.defaults, options) }); } if (state.options.border == false){ $(this).addClass('calendar-noborder'); } setSize(this); show(this); $(this).find('div.calendar-menu').hide(); // hide the calendar menu }); }; $.fn.calendar.defaults = { width:180, height:180, fit:false, border:true, weeks:['S','M','T','W','T','F','S'], months:['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], year:new Date().getFullYear(), month:new Date().getMonth()+1, current:new Date(), onSelect: function(date){} }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.calendar.js
JavaScript
asf20
11,328
/** * combo - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * * Dependencies: * panel * validatebox * */ (function($){ function setSize(target, width){ var opts = $.data(target, 'combo').options; var combo = $.data(target, 'combo').combo; var panel = $.data(target, 'combo').panel; if (width) opts.width = width; if (isNaN(opts.width)){ opts.width = combo.find('input.combo-text').outerWidth(); } var arrowWidth = combo.find('.combo-arrow').outerWidth(); var width = opts.width - arrowWidth; combo.find('input.combo-text').width(width); panel.panel('resize', { width: (opts.panelWidth ? opts.panelWidth : combo.outerWidth()), height: opts.panelHeight }); } /** * create the combo component. */ function init(target){ $(target).hide(); var span = $('<span class="combo"></span>').insertAfter(target); var input = $('<input type="text" class="combo-text">').appendTo(span); $('<span><span class="combo-arrow"></span></span>').appendTo(span); $('<input type="hidden" class="combo-value">').appendTo(span); var panel = $('<div class="combo-panel"></div>').appendTo('body'); panel.panel({ doSize:false, closed:true, style:{ position:'absolute' }, onOpen:function(){ $(this).panel('resize'); } }); var name = $(target).attr('name'); if (name){ span.find('input.combo-value').attr('name', name); $(target).removeAttr('name').attr('comboName', name); } input.attr('autocomplete', 'off'); return { combo: span, panel: panel }; } function destroy(target){ $.data(target, 'combo').panel.panel('destroy'); $.data(target, 'combo').combo.remove(); $(target).remove(); } function bindEvents(target){ var opts = $.data(target, 'combo').options; var combo = $.data(target, 'combo').combo; var panel = $.data(target, 'combo').panel; var input = combo.find('.combo-text'); var arrow = combo.find('.combo-arrow'); $(document).unbind('.combo'); combo.unbind('.combo'); panel.unbind('.combo'); input.unbind('.combo'); arrow.unbind('.combo'); if (!opts.disabled){ $(document).bind('mousedown.combo', function(e){ $('div.combo-panel').panel('close'); }); panel.bind('mousedown.combo', function(e){ return false; }); input.bind('focus.combo', function(){ showPanel(target); }).bind('mousedown.combo', function(e){ e.stopPropagation(); }).bind('keyup.combo', function(e){ switch(e.keyCode){ case 37: // left case 38: // up opts.selectPrev.call(target); break; case 39: // right case 40: // down opts.selectNext.call(target); break; case 13: // enter opts.selectCurr.call(target); break; case 27: // esc hidePanel(target); break; default: if (opts.editable){ opts.filter.call(target, $(this).val()); } } return false; }); arrow.bind('click.combo', function(){ input.focus(); }).bind('mouseenter.combo', function(){ $(this).addClass('combo-arrow-hover'); }).bind('mouseleave.combo', function(){ $(this).removeClass('combo-arrow-hover'); }); } } /** * show the drop down panel. */ function showPanel(target){ var combo = $.data(target, 'combo').combo; var panel = $.data(target, 'combo').panel; if ($.fn.window){ panel.panel('panel').css('z-index', $.fn.window.defaults.zIndex++); } panel.panel('open'); (function(){ if (panel.is(':visible')){ var top = combo.offset().top + combo.outerHeight(); if (top + panel.outerHeight() > $(window).height() + $(document).scrollTop()){ top = combo.offset().top - panel.outerHeight(); } if (top < $(document).scrollTop()){ top = combo.offset().top + combo.outerHeight(); } panel.panel('move', { left:combo.offset().left, top:top }); setTimeout(arguments.callee, 200); } })(); } /** * hide the drop down panel. */ function hidePanel(target){ var panel = $.data(target, 'combo').panel; panel.panel('close'); } function validate(target, doit){ if ($.fn.validatebox){ var opts = $.data(target, 'combo').options; var input = $.data(target, 'combo').combo.find('input.combo-text'); input.validatebox(opts); if (doit){ input.validatebox('validate'); input.trigger('mouseleave'); } } } function setDisabled(target, disabled){ var opts = $.data(target, 'combo').options; var combo = $.data(target, 'combo').combo; if (disabled){ opts.disabled = true; $(target).attr('disabled', true); combo.find('.combo-value').attr('disabled', true); combo.find('.combo-text').attr('disabled', true); } else { opts.disabled = false; $(target).removeAttr('disabled'); combo.find('.combo-value').removeAttr('disabled'); combo.find('.combo-text').removeAttr('disabled'); } } function clear(target){ var combo = $.data(target, 'combo').combo; combo.find('input.combo-value:gt(0)').remove(); combo.find('input.combo-value').val(''); combo.find('input.combo-text').val(''); } function getText(target){ var combo = $.data(target, 'combo').combo; return combo.find('input.combo-text').val(); } function setText(target, text){ var combo = $.data(target, 'combo').combo; combo.find('input.combo-text').val(text); validate(target, true); } function getValues(target){ var values = []; var combo = $.data(target, 'combo').combo; combo.find('input.combo-value').each(function(){ values.push($(this).val()); }); return values; } function setValues(target, values){ var opts = $.data(target, 'combo').options; var oldValues = getValues(target); var combo = $.data(target, 'combo').combo; combo.find('input.combo-value').remove(); var name = $(target).attr('comboName'); for(var i=0; i<values.length; i++){ var input = $('<input type="hidden" class="combo-value">').appendTo(combo); if (name) input.attr('name', name); input.val(values[i]); } var tmp = []; for(var i=0; i<oldValues.length; i++){ tmp[i] = oldValues[i]; } var aa = []; for(var i=0; i<values.length; i++){ for(var j=0; j<tmp.length; j++){ if (values[i] == tmp[j]){ aa.push(values[i]); tmp.splice(j, 1); break; } } } if (aa.length != values.length || values.length != oldValues.length){ if (opts.multiple){ opts.onChange.call(target, values, oldValues); } else { opts.onChange.call(target, values[0], oldValues[0]); } } } function getValue(target){ var values = getValues(target); return values[0]; } function setValue(target, value){ setValues(target, [value]); } /** * parse options from markup. */ function parseOptions(target){ var t = $(target); return { width: (parseInt(target.style.width) || undefined), panelWidth: (parseInt(t.attr('panelWidth')) || undefined), panelHeight: (t.attr('panelHeight')=='auto' ? 'auto' : parseInt(t.attr('panelHeight')) || undefined), separator: (t.attr('separator') || undefined), multiple: (t.attr('multiple') ? (t.attr('multiple') == 'true' || t.attr('multiple') == true) : undefined), editable: (t.attr('editable') ? t.attr('editable') == 'true' : undefined), disabled: (t.attr('disabled') ? true : undefined), required: (t.attr('required') ? (t.attr('required') == 'true' || t.attr('required') == true) : undefined), missingMessage: (t.attr('missingMessage') || undefined) }; } $.fn.combo = function(options, param){ if (typeof options == 'string'){ return $.fn.combo.methods[options](this, param); } options = options || {}; return this.each(function(){ var state = $.data(this, 'combo'); if (state){ $.extend(state.options, options); } else { var r = init(this); state = $.data(this, 'combo', { options: $.extend({}, $.fn.combo.defaults, parseOptions(this), options), combo: r.combo, panel: r.panel }); $(this).removeAttr('disabled'); } $('input.combo-text', state.combo).attr('readonly', !state.options.editable); setDisabled(this, state.options.disabled); setSize(this); bindEvents(this); validate(this); }); }; $.fn.combo.methods = { parseOptions: function(jq){ return parseOptions(jq[0]); }, options: function(jq){ return $.data(jq[0], 'combo').options; }, panel: function(jq){ return $.data(jq[0], 'combo').panel; }, textbox: function(jq){ return $.data(jq[0], 'combo').combo.find('input.combo-text'); }, destroy: function(jq){ return jq.each(function(){ destroy(this); }); }, resize: function(jq, width){ return jq.each(function(){ setSize(this, width); }); }, showPanel: function(jq){ return jq.each(function(){ showPanel(this); }); }, hidePanel: function(jq){ return jq.each(function(){ hidePanel(this); }); }, disable: function(jq){ return jq.each(function(){ setDisabled(this, true); bindEvents(this); }); }, enable: function(jq){ return jq.each(function(){ setDisabled(this, false); bindEvents(this); }); }, clear: function(jq){ return jq.each(function(){ clear(this); }); }, getText: function(jq){ return getText(jq[0]); }, setText: function(jq, text){ return jq.each(function(){ setText(this, text); }); }, getValues: function(jq){ return getValues(jq[0]); }, setValues: function(jq, values){ return jq.each(function(){ setValues(this, values); }); }, getValue: function(jq){ return getValue(jq[0]); }, setValue: function(jq, value){ return jq.each(function(){ setValue(this, value); }); } }; $.fn.combo.defaults = { width: 'auto', panelWidth: null, panelHeight: 200, multiple: false, separator: ',', editable: true, disabled: false, required: false, missingMessage: 'This field is required.', selectPrev: function(){}, selectNext: function(){}, selectCurr: function(){}, filter: function(query){}, onChange: function(newValue, oldValue){} }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.combo.js
JavaScript
asf20
10,622
/** * dialog - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * * Dependencies: * window * */ (function($){ /** * wrap dialog and return content panel. */ function wrapDialog(target){ var t = $(target); t.wrapInner('<div class="dialog-content"></div>'); var contentPanel = t.find('>div.dialog-content'); contentPanel.css('padding', t.css('padding')); t.css('padding', 0); contentPanel.panel({ border:false }); return contentPanel; } /** * build the dialog */ function buildDialog(target){ var opts = $.data(target, 'dialog').options; var contentPanel = $.data(target, 'dialog').contentPanel; $(target).find('div.dialog-toolbar').remove(); $(target).find('div.dialog-button').remove(); if (opts.toolbar){ var toolbar = $('<div class="dialog-toolbar"></div>').prependTo(target); for(var i=0; i<opts.toolbar.length; i++){ var p = opts.toolbar[i]; if (p == '-'){ toolbar.append('<div class="dialog-tool-separator"></div>'); } else { var tool = $('<a href="javascript:void(0)"></a>').appendTo(toolbar); tool.css('float','left').text(p.text); if (p.iconCls) tool.attr('icon', p.iconCls); if (p.handler) tool[0].onclick = p.handler; tool.linkbutton({ plain: true, disabled: (p.disabled || false) }); } } toolbar.append('<div style="clear:both"></div>'); } if (opts.buttons){ var buttons = $('<div class="dialog-button"></div>').appendTo(target); for(var i=0; i<opts.buttons.length; i++){ var p = opts.buttons[i]; var button = $('<a href="javascript:void(0)"></a>').appendTo(buttons); if (p.handler) button[0].onclick = p.handler; button.linkbutton(p); } } if (opts.href){ contentPanel.panel({ href: opts.href, onLoad: opts.onLoad }); opts.href = null; } $(target).window($.extend({}, opts, { onResize:function(width, height){ var wbody = $(target).panel('panel').find('>div.panel-body'); contentPanel.panel('resize', { width: wbody.width(), height: (height=='auto') ? 'auto' : wbody.height() - wbody.find('>div.dialog-toolbar').outerHeight() - wbody.find('>div.dialog-button').outerHeight() }); if (opts.onResize) opts.onResize.call(target, width, height); } })); } function refresh(target){ var contentPanel = $.data(target, 'dialog').contentPanel; contentPanel.panel('refresh'); } $.fn.dialog = function(options, param){ if (typeof options == 'string'){ switch(options){ case 'options': return $(this[0]).window('options'); case 'dialog': return $(this[0]).window('window'); case 'setTitle': return this.each(function(){ $(this).window('setTitle', param); }); case 'open': return this.each(function(){ $(this).window('open', param); }); case 'close': return this.each(function(){ $(this).window('close', param); }); case 'destroy': return this.each(function(){ $(this).window('destroy', param); }); case 'refresh': return this.each(function(){ refresh(this); }); case 'resize': return this.each(function(){ $(this).window('resize', param); }); case 'move': return this.each(function(){ $(this).window('move', param); }); case 'maximize': return this.each(function(){ $(this).window('maximize'); }); case 'minimize': return this.each(function(){ $(this).window('minimize'); }); case 'restore': return this.each(function(){ $(this).window('restore'); }); case 'collapse': return this.each(function(){ $(this).window('collapse', param); }); case 'expand': return this.each(function(){ $(this).window('expand', param); }); } } options = options || {}; return this.each(function(){ var state = $.data(this, 'dialog'); if (state){ $.extend(state.options, options); } else { var t = $(this); var opts = $.extend({}, $.fn.dialog.defaults, { title:(t.attr('title') ? t.attr('title') : undefined), href:t.attr('href'), collapsible: (t.attr('collapsible') ? t.attr('collapsible') == 'true' : undefined), minimizable: (t.attr('minimizable') ? t.attr('minimizable') == 'true' : undefined), maximizable: (t.attr('maximizable') ? t.attr('maximizable') == 'true' : undefined), resizable: (t.attr('resizable') ? t.attr('resizable') == 'true' : undefined) }, options); $.data(this, 'dialog', { options: opts, contentPanel: wrapDialog(this) }); } buildDialog(this); }); }; $.fn.dialog.defaults = { title: 'New Dialog', href: null, collapsible: false, minimizable: false, maximizable: false, resizable: false, toolbar:null, buttons:null }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.dialog.js
JavaScript
asf20
5,126
/** * panel - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * */ (function($){ function removeNode(node){ node.each(function(){ $(this).remove(); if ($.browser.msie){ this.outerHTML = ''; } }); } function setSize(target, param){ var opts = $.data(target, 'panel').options; var panel = $.data(target, 'panel').panel; var pheader = panel.find('>div.panel-header'); var pbody = panel.find('>div.panel-body'); if (param){ if (param.width) opts.width = param.width; if (param.height) opts.height = param.height; if (param.left != null) opts.left = param.left; if (param.top != null) opts.top = param.top; } if (opts.fit == true){ var p = panel.parent(); opts.width = p.width(); opts.height = p.height(); } panel.css({ left: opts.left, top: opts.top }); panel.css(opts.style); panel.addClass(opts.cls); pheader.addClass(opts.headerCls); pbody.addClass(opts.bodyCls); if (!isNaN(opts.width)){ if ($.boxModel == true){ panel.width(opts.width - (panel.outerWidth() - panel.width())); pheader.width(panel.width() - (pheader.outerWidth() - pheader.width())); pbody.width(panel.width() - (pbody.outerWidth() - pbody.width())); } else { panel.width(opts.width); pheader.width(panel.width()); pbody.width(panel.width()); } } else { panel.width('auto'); pbody.width('auto'); } if (!isNaN(opts.height)){ // var height = opts.height - (panel.outerHeight()-panel.height()) - pheader.outerHeight(); // if ($.boxModel == true){ // height -= pbody.outerHeight() - pbody.height(); // } // pbody.height(height); if ($.boxModel == true){ panel.height(opts.height - (panel.outerHeight() - panel.height())); pbody.height(panel.height() - pheader.outerHeight() - (pbody.outerHeight() - pbody.height())); } else { panel.height(opts.height); pbody.height(panel.height() - pheader.outerHeight()); } } else { pbody.height('auto'); } panel.css('height', null); opts.onResize.apply(target, [opts.width, opts.height]); panel.find('>div.panel-body>div').triggerHandler('_resize'); } function movePanel(target, param){ var opts = $.data(target, 'panel').options; var panel = $.data(target, 'panel').panel; if (param){ if (param.left != null) opts.left = param.left; if (param.top != null) opts.top = param.top; } panel.css({ left: opts.left, top: opts.top }); opts.onMove.apply(target, [opts.left, opts.top]); } function wrapPanel(target){ var panel = $(target).addClass('panel-body').wrap('<div class="panel"></div>').parent(); panel.bind('_resize', function(){ var opts = $.data(target, 'panel').options; if (opts.fit == true){ setSize(target); } return false; }); return panel; } function addHeader(target){ var opts = $.data(target, 'panel').options; var panel = $.data(target, 'panel').panel; removeNode(panel.find('>div.panel-header')); if (opts.title && !opts.noheader){ var header = $('<div class="panel-header"><div class="panel-title">'+opts.title+'</div></div>').prependTo(panel); if (opts.iconCls){ header.find('.panel-title').addClass('panel-with-icon'); $('<div class="panel-icon"></div>').addClass(opts.iconCls).appendTo(header); } var tool = $('<div class="panel-tool"></div>').appendTo(header); if (opts.closable){ $('<div class="panel-tool-close"></div>').appendTo(tool).bind('click', onClose); } if (opts.maximizable){ $('<div class="panel-tool-max"></div>').appendTo(tool).bind('click', onMax); } if (opts.minimizable){ $('<div class="panel-tool-min"></div>').appendTo(tool).bind('click', onMin); } if (opts.collapsible){ $('<div class="panel-tool-collapse"></div>').appendTo(tool).bind('click', onToggle); } if (opts.tools){ for(var i=opts.tools.length-1; i>=0; i--){ var t = $('<div></div>').addClass(opts.tools[i].iconCls).appendTo(tool); if (opts.tools[i].handler){ t.bind('click', eval(opts.tools[i].handler)); } } } tool.find('div').hover( function(){$(this).addClass('panel-tool-over');}, function(){$(this).removeClass('panel-tool-over');} ); panel.find('>div.panel-body').removeClass('panel-body-noheader'); } else { panel.find('>div.panel-body').addClass('panel-body-noheader'); } function onToggle(){ if ($(this).hasClass('panel-tool-expand')){ expandPanel(target, true); } else { collapsePanel(target, true); } return false; } function onMin(){ minimizePanel(target); return false; } function onMax(){ if ($(this).hasClass('panel-tool-restore')){ restorePanel(target); } else { maximizePanel(target); } return false; } function onClose(){ closePanel(target); return false; } } /** * load content from remote site if the href attribute is defined */ function loadData(target){ var state = $.data(target, 'panel'); if (state.options.href && (!state.isLoaded || !state.options.cache)){ state.isLoaded = false; var pbody = state.panel.find('>div.panel-body'); pbody.html($('<div class="panel-loading"></div>').html(state.options.loadingMessage)); pbody.load(state.options.href, null, function(){ if ($.parser){ $.parser.parse(pbody); } state.options.onLoad.apply(target, arguments); state.isLoaded = true; }); } } function openPanel(target, forceOpen){ var opts = $.data(target, 'panel').options; var panel = $.data(target, 'panel').panel; if (forceOpen != true){ if (opts.onBeforeOpen.call(target) == false) return; } panel.show(); opts.closed = false; opts.onOpen.call(target); if (opts.maximized == true) maximizePanel(target); if (opts.minimized == true) minimizePanel(target); if (opts.collapsed == true) collapsePanel(target); if (!opts.collapsed){ loadData(target); } } function closePanel(target, forceClose){ var opts = $.data(target, 'panel').options; var panel = $.data(target, 'panel').panel; if (forceClose != true){ if (opts.onBeforeClose.call(target) == false) return; } panel.hide(); opts.closed = true; opts.onClose.call(target); } function destroyPanel(target, forceDestroy){ var opts = $.data(target, 'panel').options; var panel = $.data(target, 'panel').panel; if (forceDestroy != true){ if (opts.onBeforeDestroy.call(target) == false) return; } removeNode(panel); opts.onDestroy.call(target); } function collapsePanel(target, animate){ var opts = $.data(target, 'panel').options; var panel = $.data(target, 'panel').panel; var body = panel.find('>div.panel-body'); var tool = panel.find('>div.panel-header .panel-tool-collapse'); if (tool.hasClass('panel-tool-expand')) return; body.stop(true, true); // stop animation if (opts.onBeforeCollapse.call(target) == false) return; tool.addClass('panel-tool-expand'); if (animate == true){ body.slideUp('normal', function(){ opts.collapsed = true; opts.onCollapse.call(target); }); } else { body.hide(); opts.collapsed = true; opts.onCollapse.call(target); } } function expandPanel(target, animate){ var opts = $.data(target, 'panel').options; var panel = $.data(target, 'panel').panel; var body = panel.find('>div.panel-body'); var tool = panel.find('>div.panel-header .panel-tool-collapse'); if (!tool.hasClass('panel-tool-expand')) return; body.stop(true, true); // stop animation if (opts.onBeforeExpand.call(target) == false) return; tool.removeClass('panel-tool-expand'); if (animate == true){ body.slideDown('normal', function(){ opts.collapsed = false; opts.onExpand.call(target); loadData(target); }); } else { body.show(); opts.collapsed = false; opts.onExpand.call(target); loadData(target); } } function maximizePanel(target){ var opts = $.data(target, 'panel').options; var panel = $.data(target, 'panel').panel; var tool = panel.find('>div.panel-header .panel-tool-max'); if (tool.hasClass('panel-tool-restore')) return; tool.addClass('panel-tool-restore'); $.data(target, 'panel').original = { width: opts.width, height: opts.height, left: opts.left, top: opts.top, fit: opts.fit }; opts.left = 0; opts.top = 0; opts.fit = true; setSize(target); opts.minimized = false; opts.maximized = true; opts.onMaximize.call(target); } function minimizePanel(target){ var opts = $.data(target, 'panel').options; var panel = $.data(target, 'panel').panel; panel.hide(); opts.minimized = true; opts.maximized = false; opts.onMinimize.call(target); } function restorePanel(target){ var opts = $.data(target, 'panel').options; var panel = $.data(target, 'panel').panel; var tool = panel.find('>div.panel-header .panel-tool-max'); if (!tool.hasClass('panel-tool-restore')) return; panel.show(); tool.removeClass('panel-tool-restore'); var original = $.data(target, 'panel').original; opts.width = original.width; opts.height = original.height; opts.left = original.left; opts.top = original.top; opts.fit = original.fit; setSize(target); opts.minimized = false; opts.maximized = false; opts.onRestore.call(target); } function setBorder(target){ var opts = $.data(target, 'panel').options; var panel = $.data(target, 'panel').panel; if (opts.border == true){ panel.find('>div.panel-header').removeClass('panel-header-noborder'); panel.find('>div.panel-body').removeClass('panel-body-noborder'); } else { panel.find('>div.panel-header').addClass('panel-header-noborder'); panel.find('>div.panel-body').addClass('panel-body-noborder'); } } function setTitle(target, title){ $.data(target, 'panel').options.title = title; $(target).panel('header').find('div.panel-title').html(title); } $(window).unbind('.panel').bind('resize.panel', function(){ var layout = $('body.layout'); if (layout.length){ layout.layout('resize'); } else { $('body>div.panel').triggerHandler('_resize'); } }); $.fn.panel = function(options, param){ if (typeof options == 'string'){ switch(options){ case 'options': return $.data(this[0], 'panel').options; case 'panel': return $.data(this[0], 'panel').panel; case 'header': return $.data(this[0], 'panel').panel.find('>div.panel-header'); case 'body': return $.data(this[0], 'panel').panel.find('>div.panel-body'); case 'setTitle': return this.each(function(){ setTitle(this, param); }); case 'open': return this.each(function(){ openPanel(this, param); }); case 'close': return this.each(function(){ closePanel(this, param); }); case 'destroy': return this.each(function(){ destroyPanel(this, param); }); case 'refresh': return this.each(function(){ $.data(this, 'panel').isLoaded = false; loadData(this); }); case 'resize': return this.each(function(){ setSize(this, param); }); case 'move': return this.each(function(){ movePanel(this, param); }); case 'maximize': return this.each(function(){ maximizePanel(this); }); case 'minimize': return this.each(function(){ minimizePanel(this); }); case 'restore': return this.each(function(){ restorePanel(this); }); case 'collapse': return this.each(function(){ collapsePanel(this, param); // param: boolean,indicate animate or not }); case 'expand': return this.each(function(){ expandPanel(this, param); // param: boolean,indicate animate or not }); } } options = options || {}; return this.each(function(){ var state = $.data(this, 'panel'); var opts; if (state){ opts = $.extend(state.options, options); } else { var t = $(this); opts = $.extend({}, $.fn.panel.defaults, { width: (parseInt(t.css('width')) || undefined), height: (parseInt(t.css('height')) || undefined), left: (parseInt(t.css('left')) || undefined), top: (parseInt(t.css('top')) || undefined), title: t.attr('title'), iconCls: t.attr('icon'), cls: t.attr('cls'), headerCls: t.attr('headerCls'), bodyCls: t.attr('bodyCls'), href: t.attr('href'), cache: (t.attr('cache') ? t.attr('cache') == 'true' : undefined), fit: (t.attr('fit') ? t.attr('fit') == 'true' : undefined), border: (t.attr('border') ? t.attr('border') == 'true' : undefined), noheader: (t.attr('noheader') ? t.attr('noheader') == 'true' : undefined), collapsible: (t.attr('collapsible') ? t.attr('collapsible') == 'true' : undefined), minimizable: (t.attr('minimizable') ? t.attr('minimizable') == 'true' : undefined), maximizable: (t.attr('maximizable') ? t.attr('maximizable') == 'true' : undefined), closable: (t.attr('closable') ? t.attr('closable') == 'true' : undefined), collapsed: (t.attr('collapsed') ? t.attr('collapsed') == 'true' : undefined), minimized: (t.attr('minimized') ? t.attr('minimized') == 'true' : undefined), maximized: (t.attr('maximized') ? t.attr('maximized') == 'true' : undefined), closed: (t.attr('closed') ? t.attr('closed') == 'true' : undefined) }, options); t.attr('title', ''); state = $.data(this, 'panel', { options: opts, panel: wrapPanel(this), isLoaded: false }); } if (opts.content){ $(this).html(opts.content); if ($.parser){ $.parser.parse(this); } } addHeader(this); setBorder(this); // loadData(this); if (opts.doSize == true){ state.panel.css('display','block'); setSize(this); } if (opts.closed == true){ state.panel.hide(); } else { openPanel(this); } }); }; $.fn.panel.defaults = { title: null, iconCls: null, width: 'auto', height: 'auto', left: null, top: null, cls: null, headerCls: null, bodyCls: null, style: {}, href: null, cache: true, fit: false, border: true, doSize: true, // true to set size and do layout noheader: false, content: null, // the body content if specified collapsible: false, minimizable: false, maximizable: false, closable: false, collapsed: false, minimized: false, maximized: false, closed: false, // custom tools, every tool can contain two properties: iconCls and handler // iconCls is a icon CSS class // handler is a function, which will be run when tool button is clicked tools: [], href: null, loadingMessage: 'Loading...', onLoad: function(){}, onBeforeOpen: function(){}, onOpen: function(){}, onBeforeClose: function(){}, onClose: function(){}, onBeforeDestroy: function(){}, onDestroy: function(){}, onResize: function(width,height){}, onMove: function(left,top){}, onMaximize: function(){}, onRestore: function(){}, onMinimize: function(){}, onBeforeCollapse: function(){}, onBeforeExpand: function(){}, onCollapse: function(){}, onExpand: function(){} }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.panel.js
JavaScript
asf20
15,759
/** * numberspinner - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * * Dependencies: * spinner * numberbox */ (function($){ function create(target){ var opts = $.data(target, 'numberspinner').options; $(target).spinner(opts).numberbox(opts); } function doSpin(target, down){ var opts = $.data(target, 'numberspinner').options; var v = parseFloat($(target).val() || opts.value) || 0; if (down == true){ v -= opts.increment; } else { v += opts.increment; } $(target).val(v).numberbox('fix'); } $.fn.numberspinner = function(options, param){ if (typeof options == 'string'){ var method = $.fn.numberspinner.methods[options]; if (method){ return method(this, param); } else { return this.spinner(options, param); } } options = options || {}; return this.each(function(){ var state = $.data(this, 'numberspinner'); if (state){ $.extend(state.options, options); } else { $.data(this, 'numberspinner', { options: $.extend({}, $.fn.numberspinner.defaults, $.fn.numberspinner.parseOptions(this), options) }); } create(this); }); }; $.fn.numberspinner.methods = { options: function(jq){ var opts = $.data(jq[0], 'numberspinner').options; return $.extend(opts, { value: jq.val() }); }, setValue: function(jq, value){ return jq.each(function(){ $(this).val(value).numberbox('fix'); }); } }; $.fn.numberspinner.parseOptions = function(target){ return $.extend({}, $.fn.spinner.parseOptions(target), $.fn.numberbox.parseOptions(target), { }); }; $.fn.numberspinner.defaults = $.extend({}, $.fn.spinner.defaults, $.fn.numberbox.defaults, { spin: function(down){doSpin(this, down);} }); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.numberspinner.js
JavaScript
asf20
1,913
/** * tabs - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] */ (function($){ // get the left position of the tab element function getTabLeftPosition(container, tab) { var w = 0; var b = true; $('>div.tabs-header ul.tabs li', container).each(function(){ if (this == tab) { b = false; } if (b == true) { w += $(this).outerWidth(true); } }); return w; } // get the max tabs scroll width(scope) function getMaxScrollWidth(container) { var header = $('>div.tabs-header', container); var tabsWidth = 0; // all tabs width $('ul.tabs li', header).each(function(){ tabsWidth += $(this).outerWidth(true); }); var wrapWidth = $('.tabs-wrap', header).width(); var padding = parseInt($('.tabs', header).css('padding-left')); return tabsWidth - wrapWidth + padding; } // set the tabs scrollers to show or not, // dependent on the tabs count and width function setScrollers(container) { var header = $('>div.tabs-header', container); var tabsWidth = 0; $('ul.tabs li', header).each(function(){ tabsWidth += $(this).outerWidth(true); }); if (tabsWidth > header.width()) { $('.tabs-scroller-left', header).css('display', 'block'); $('.tabs-scroller-right', header).css('display', 'block'); $('.tabs-wrap', header).addClass('tabs-scrolling'); if ($.boxModel == true) { $('.tabs-wrap', header).css('left',2); } else { $('.tabs-wrap', header).css('left',0); } var width = header.width() - $('.tabs-scroller-left', header).outerWidth() - $('.tabs-scroller-right', header).outerWidth(); $('.tabs-wrap', header).width(width); } else { $('.tabs-scroller-left', header).css('display', 'none'); $('.tabs-scroller-right', header).css('display', 'none'); $('.tabs-wrap', header).removeClass('tabs-scrolling').scrollLeft(0); $('.tabs-wrap', header).width(header.width()); $('.tabs-wrap', header).css('left',0); } } // set size of the tabs container function setSize(container) { var opts = $.data(container, 'tabs').options; var cc = $(container); if (opts.fit == true){ var p = cc.parent(); opts.width = p.width(); opts.height = p.height(); } cc.width(opts.width).height(opts.height); var header = $('>div.tabs-header', container); if ($.boxModel == true) { var delta = header.outerWidth() - header.width(); // var delta = header.outerWidth(true) - header.width(); header.width(cc.width() - delta); } else { header.width(cc.width()); } setScrollers(container); var panels = $('>div.tabs-panels', container); var height = opts.height; if (!isNaN(height)) { if ($.boxModel == true) { var delta = panels.outerHeight() - panels.height(); panels.css('height', (height - header.outerHeight() - delta) || 'auto'); } else { panels.css('height', height - header.outerHeight()); } } else { panels.height('auto'); } var width = opts.width; if (!isNaN(width)){ if ($.boxModel == true) { var delta = panels.outerWidth() - panels.width(); // var delta = panels.outerWidth(true) - panels.width(); panels.width(width - delta); } else { panels.width(width); } } else { panels.width('auto'); } if ($.parser){ $.parser.parse(container); } // // resize the children tabs container // $('div.tabs-container', container).tabs(); } /** * make the selected tab panel fit layout */ function fitContent(container){ var tab = $('>div.tabs-header ul.tabs li.tabs-selected', container); if (tab.length){ var panelId = $.data(tab[0], 'tabs.tab').id; var panel = $('#'+panelId); var panels = $('>div.tabs-panels', container); if (panels.css('height').toLowerCase() != 'auto'){ if ($.boxModel == true){ panel.height(panels.height() - (panel.outerHeight()-panel.height())); panel.width(panels.width() - (panel.outerWidth()-panel.width())); } else { panel.height(panels.height()); panel.width(panels.width()); } } $('>div', panel).triggerHandler('_resize'); } } // wrap the tabs header and body function wrapTabs(container) { $(container).addClass('tabs-container'); $(container).wrapInner('<div class="tabs-panels"/>'); $('<div class="tabs-header">' + '<div class="tabs-scroller-left"></div>' + '<div class="tabs-scroller-right"></div>' + '<div class="tabs-wrap">' + '<ul class="tabs"></ul>' + '</div>' + '</div>').prependTo(container); var header = $('>div.tabs-header', container); $('>div.tabs-panels>div', container).each(function(){ if (!$(this).attr('id')) { $(this).attr('id', 'gen-tabs-panel' + $.fn.tabs.defaults.idSeed++); } var options = { id: $(this).attr('id'), title: $(this).attr('title'), content: null, href: $(this).attr('href'), closable: $(this).attr('closable') == 'true', icon: $(this).attr('icon'), selected: $(this).attr('selected') == 'true', cache: $(this).attr('cache') == 'false' ? false : true }; $(this).attr('title',''); createTab(container, options); }); $('.tabs-scroller-left, .tabs-scroller-right', header).hover( function(){$(this).addClass('tabs-scroller-over');}, function(){$(this).removeClass('tabs-scroller-over');} ); $(container).bind('_resize', function(){ var opts = $.data(container, 'tabs').options; if (opts.fit == true){ setSize(container); fitContent(container); } return false; }); } function setProperties(container){ var opts = $.data(container, 'tabs').options; var header = $('>div.tabs-header', container); var panels = $('>div.tabs-panels', container); var tabs = $('ul.tabs', header); if (opts.plain == true) { header.addClass('tabs-header-plain'); } else { header.removeClass('tabs-header-plain'); } if (opts.border == true){ header.removeClass('tabs-header-noborder'); panels.removeClass('tabs-panels-noborder'); } else { header.addClass('tabs-header-noborder'); panels.addClass('tabs-panels-noborder'); } $('li', tabs).unbind('.tabs').bind('click.tabs', function(){ $('.tabs-selected', tabs).removeClass('tabs-selected'); $(this).addClass('tabs-selected'); $(this).blur(); $('>div.tabs-panels>div', container).css('display', 'none'); var wrap = $('.tabs-wrap', header); var leftPos = getTabLeftPosition(container, this); var left = leftPos - wrap.scrollLeft(); var right = left + $(this).outerWidth(); if (left < 0 || right > wrap.innerWidth()) { var pos = Math.min( leftPos - (wrap.width()-$(this).width()) / 2, getMaxScrollWidth(container) ); wrap.animate({scrollLeft:pos}, opts.scrollDuration); } var tabAttr = $.data(this, 'tabs.tab'); var panel = $('#' + tabAttr.id); panel.css('display', 'block'); if (tabAttr.href && (!tabAttr.loaded || !tabAttr.cache)) { panel.load(tabAttr.href, null, function(){ if ($.parser){ $.parser.parse(panel); } opts.onLoad.apply(this, arguments); tabAttr.loaded = true; }); } fitContent(container); opts.onSelect.call(panel, tabAttr.title); }); $('a.tabs-close', tabs).unbind('.tabs').bind('click.tabs', function(){ var elem = $(this).parent()[0]; var tabAttr = $.data(elem, 'tabs.tab'); closeTab(container, tabAttr.title); }); $('.tabs-scroller-left', header).unbind('.tabs').bind('click.tabs', function(){ var wrap = $('.tabs-wrap', header); var pos = wrap.scrollLeft() - opts.scrollIncrement; wrap.animate({scrollLeft:pos}, opts.scrollDuration); }); $('.tabs-scroller-right', header).unbind('.tabs').bind('click.tabs', function(){ var wrap = $('.tabs-wrap', header); var pos = Math.min( wrap.scrollLeft() + opts.scrollIncrement, getMaxScrollWidth(container) ); wrap.animate({scrollLeft:pos}, opts.scrollDuration); }); } function createTab(container, options) { var header = $('>div.tabs-header', container); var tabs = $('ul.tabs', header); var tab = $('<li></li>'); var tab_span = $('<span></span>').html(options.title); var tab_a = $('<a class="tabs-inner"></a>') .attr('href', 'javascript:void(0)') .append(tab_span); tab.append(tab_a).appendTo(tabs); if (options.closable) { tab_span.addClass('tabs-closable'); tab_a.after('<a href="javascript:void(0)" class="tabs-close"></a>'); } if (options.icon) { tab_span.addClass('tabs-with-icon'); tab_span.after($('<span/>').addClass('tabs-icon').addClass(options.icon)); } if (options.selected) { tab.addClass('tabs-selected'); } if (options.content) { $('#' + options.id).html(options.content); } $('#' + options.id).removeAttr('title'); $.data(tab[0], 'tabs.tab', { id: options.id, title: options.title, href: options.href, loaded: false, cache: options.cache }); } function addTab(container, options) { options = $.extend({ id: null, title: '', content: '', href: null, cache: true, icon: null, closable: false, selected: true, height: 'auto', width: 'auto' }, options || {}); if (options.selected) { $('.tabs-header .tabs-wrap .tabs li', container).removeClass('tabs-selected'); } options.id = options.id || 'gen-tabs-panel' + $.fn.tabs.defaults.idSeed++; $('<div></div>').attr('id', options.id) .attr('title', options.title) .height(options.height) .width(options.width) .appendTo($('>div.tabs-panels', container)); createTab(container, options); } // close a tab with specified title function closeTab(container, title) { var opts = $.data(container, 'tabs').options; var elem = $('>div.tabs-header li:has(a span:contains("' + title + '"))', container)[0]; if (!elem) return; var tabAttr = $.data(elem, 'tabs.tab'); var panel = $('#' + tabAttr.id); if (opts.onClose.call(panel, tabAttr.title) == false) return; var selected = $(elem).hasClass('tabs-selected'); $.removeData(elem, 'tabs.tab'); $(elem).remove(); panel.remove(); setSize(container); if (selected) { selectTab(container); } else { var wrap = $('>div.tabs-header .tabs-wrap', container); var pos = Math.min( wrap.scrollLeft(), getMaxScrollWidth(container) ); wrap.animate({scrollLeft:pos}, opts.scrollDuration); } } // active the selected tab item, if no selected item then active the first item function selectTab(container, title){ if (title) { var elem = $('>div.tabs-header li:has(a span:contains("' + title + '"))', container)[0]; if (elem) { $(elem).trigger('click'); } } else { var tabs = $('>div.tabs-header ul.tabs', container); if ($('.tabs-selected', tabs).length == 0) { $('li:first', tabs).trigger('click'); } else { $('.tabs-selected', tabs).trigger('click'); } } } function exists(container, title){ return $('>div.tabs-header li:has(a span:contains("' + title + '"))', container).length > 0; } $.fn.tabs = function(options, param){ if (typeof options == 'string') { switch(options) { case 'resize': return this.each(function(){ setSize(this); }); case 'add': return this.each(function(){ addTab(this, param); $(this).tabs(); }); case 'close': return this.each(function(){ closeTab(this, param); }); case 'select': return this.each(function(){ selectTab(this, param); }); case 'exists': return exists(this[0], param); } } options = options || {}; return this.each(function(){ var state = $.data(this, 'tabs'); var opts; if (state) { opts = $.extend(state.options, options); state.options = opts; } else { var t = $(this); opts = $.extend({},$.fn.tabs.defaults, { width: (parseInt(t.css('width')) || undefined), height: (parseInt(t.css('height')) || undefined), fit: (t.attr('fit') ? t.attr('fit') == 'true' : undefined), border: (t.attr('border') ? t.attr('border') == 'true' : undefined), plain: (t.attr('plain') ? t.attr('plain') == 'true' : undefined) }, options); wrapTabs(this); $.data(this, 'tabs', { options: opts }); } setProperties(this); setSize(this); selectTab(this); }); }; $.fn.tabs.defaults = { width: 'auto', height: 'auto', idSeed: 0, plain: false, fit: false, border: true, scrollIncrement: 100, scrollDuration: 400, onLoad: function(){}, onSelect: function(title){}, onClose: function(title){} }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.tabs.js
JavaScript
asf20
13,123
/** * window - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * * Dependencies: * panel * draggable * resizable * */ (function($){ function setSize(target, param){ $(target).panel('resize'); } /** * create and initialize window, the window is created based on panel component */ function init(target, options){ var state = $.data(target, 'window'); var opts; if (state){ opts = $.extend(state.opts, options); } else { var t = $(target); opts = $.extend({}, $.fn.window.defaults, { title: t.attr('title'), collapsible: (t.attr('collapsible') ? t.attr('collapsible') == 'true' : undefined), minimizable: (t.attr('minimizable') ? t.attr('minimizable') == 'true' : undefined), maximizable: (t.attr('maximizable') ? t.attr('maximizable') == 'true' : undefined), closable: (t.attr('closable') ? t.attr('closable') == 'true' : undefined), closed: (t.attr('closed') ? t.attr('closed') == 'true' : undefined), shadow: (t.attr('shadow') ? t.attr('shadow') == 'true' : undefined), modal: (t.attr('modal') ? t.attr('modal') == 'true' : undefined) }, options); $(target).attr('title', ''); state = $.data(target, 'window', {}); } // create window var win = $(target).panel($.extend({}, opts, { border: false, doSize: true, // size the panel, the property undefined in window component closed: true, // close the panel cls: 'window', headerCls: 'window-header', bodyCls: 'window-body', onBeforeDestroy: function(){ if (opts.onBeforeDestroy){ if (opts.onBeforeDestroy.call(target) == false) return false; } var state = $.data(target, 'window'); if (state.shadow) state.shadow.remove(); if (state.mask) state.mask.remove(); }, onClose: function(){ var state = $.data(target, 'window'); if (state.shadow) state.shadow.hide(); if (state.mask) state.mask.hide(); if (opts.onClose) opts.onClose.call(target); }, onOpen: function(){ var state = $.data(target, 'window'); if (state.mask){ state.mask.css({ display:'block', zIndex: $.fn.window.defaults.zIndex++ }); } if (state.shadow){ state.shadow.css({ display:'block', zIndex: $.fn.window.defaults.zIndex++, left: state.options.left, top: state.options.top, width: state.window.outerWidth(), height: state.window.outerHeight() }); } state.window.css('z-index', $.fn.window.defaults.zIndex++); // if (state.mask) state.mask.show(); if (opts.onOpen) opts.onOpen.call(target); }, onResize: function(width, height){ var state = $.data(target, 'window'); if (state.shadow){ state.shadow.css({ left: state.options.left, top: state.options.top, width: state.window.outerWidth(), height: state.window.outerHeight() }); } if (opts.onResize) opts.onResize.call(target, width, height); }, onMove: function(left, top){ var state = $.data(target, 'window'); if (state.shadow){ state.shadow.css({ left: state.options.left, top: state.options.top }); } if (opts.onMove) opts.onMove.call(target, left, top); }, onMinimize: function(){ var state = $.data(target, 'window'); if (state.shadow) state.shadow.hide(); if (state.mask) state.mask.hide(); if (opts.onMinimize) opts.onMinimize.call(target); }, onBeforeCollapse: function(){ if (opts.onBeforeCollapse){ if (opts.onBeforeCollapse.call(target) == false) return false; } var state = $.data(target, 'window'); if (state.shadow) state.shadow.hide(); }, onExpand: function(){ var state = $.data(target, 'window'); if (state.shadow) state.shadow.show(); if (opts.onExpand) opts.onExpand.call(target); } })); // save the window state state.options = win.panel('options'); state.opts = opts; state.window = win.panel('panel'); // create mask if (state.mask) state.mask.remove(); if (opts.modal == true){ state.mask = $('<div class="window-mask"></div>').appendTo('body'); state.mask.css({ // zIndex: $.fn.window.defaults.zIndex++, width: getPageArea().width, height: getPageArea().height, display: 'none' }); } // create shadow if (state.shadow) state.shadow.remove(); if (opts.shadow == true){ state.shadow = $('<div class="window-shadow"></div>').insertAfter(state.window); state.shadow.css({ // zIndex: $.fn.window.defaults.zIndex++, display: 'none' }); } // state.window.css('z-index', $.fn.window.defaults.zIndex++); // if require center the window if (state.options.left == null){ var width = state.options.width; if (isNaN(width)){ width = state.window.outerWidth(); } state.options.left = ($(window).width() - width) / 2 + $(document).scrollLeft(); } if (state.options.top == null){ var height = state.window.height; if (isNaN(height)){ height = state.window.outerHeight(); } state.options.top = ($(window).height() - height) / 2 + $(document).scrollTop(); } win.window('move'); if (state.opts.closed == false){ win.window('open'); // open the window } } /** * set window drag and resize property */ function setProperties(target){ var state = $.data(target, 'window'); state.window.draggable({ handle: '>div.panel-header>div.panel-title', disabled: state.options.draggable == false, onStartDrag: function(e){ if (state.mask) state.mask.css('z-index', $.fn.window.defaults.zIndex++); if (state.shadow) state.shadow.css('z-index', $.fn.window.defaults.zIndex++); state.window.css('z-index', $.fn.window.defaults.zIndex++); if (!state.proxy){ state.proxy = $('<div class="window-proxy"></div>').insertAfter(state.window); } state.proxy.css({ display:'none', zIndex: $.fn.window.defaults.zIndex++, left: e.data.left, top: e.data.top, width: ($.boxModel==true ? (state.window.outerWidth()-(state.proxy.outerWidth()-state.proxy.width())) : state.window.outerWidth()), height: ($.boxModel==true ? (state.window.outerHeight()-(state.proxy.outerHeight()-state.proxy.height())) : state.window.outerHeight()) }); setTimeout(function(){ if (state.proxy) state.proxy.show(); }, 500); }, onDrag: function(e){ state.proxy.css({ display:'block', left: e.data.left, top: e.data.top }); return false; }, onStopDrag: function(e){ state.options.left = e.data.left; state.options.top = e.data.top; $(target).window('move'); state.proxy.remove(); state.proxy = null; } }); state.window.resizable({ disabled: state.options.resizable == false, onStartResize:function(e){ if (!state.proxy){ state.proxy = $('<div class="window-proxy"></div>').insertAfter(state.window); } state.proxy.css({ zIndex: $.fn.window.defaults.zIndex++, left: e.data.left, top: e.data.top, width: ($.boxModel==true ? (e.data.width-(state.proxy.outerWidth()-state.proxy.width())) : e.data.width), height: ($.boxModel==true ? (e.data.height-(state.proxy.outerHeight()-state.proxy.height())) : e.data.height) }); }, onResize: function(e){ state.proxy.css({ left: e.data.left, top: e.data.top, width: ($.boxModel==true ? (e.data.width-(state.proxy.outerWidth()-state.proxy.width())) : e.data.width), height: ($.boxModel==true ? (e.data.height-(state.proxy.outerHeight()-state.proxy.height())) : e.data.height) }); return false; }, onStopResize: function(e){ state.options.left = e.data.left; state.options.top = e.data.top; state.options.width = e.data.width; state.options.height = e.data.height; setSize(target); state.proxy.remove(); state.proxy = null; } }); } function getPageArea() { if (document.compatMode == 'BackCompat') { return { width: Math.max(document.body.scrollWidth, document.body.clientWidth), height: Math.max(document.body.scrollHeight, document.body.clientHeight) } } else { return { width: Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth), height: Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) } } } // when window resize, reset the width and height of the window's mask $(window).resize(function(){ $('.window-mask').css({ width: $(window).width(), height: $(window).height() }); setTimeout(function(){ $('.window-mask').css({ width: getPageArea().width, height: getPageArea().height }); }, 50); }); $.fn.window = function(options, param){ if (typeof options == 'string'){ switch(options){ case 'options': return $.data(this[0], 'window').options; case 'window': return $.data(this[0], 'window').window; case 'setTitle': return this.each(function(){ $(this).panel('setTitle', param); }); case 'open': return this.each(function(){ $(this).panel('open', param); }); case 'close': return this.each(function(){ $(this).panel('close', param); }); case 'destroy': return this.each(function(){ $(this).panel('destroy', param); }); case 'refresh': return this.each(function(){ $(this).panel('refresh'); }); case 'resize': return this.each(function(){ $(this).panel('resize', param); }); case 'move': return this.each(function(){ $(this).panel('move', param); }); case 'maximize': return this.each(function(){ $(this).panel('maximize'); }); case 'minimize': return this.each(function(){ $(this).panel('minimize'); }); case 'restore': return this.each(function(){ $(this).panel('restore'); }); case 'collapse': return this.each(function(){ $(this).panel('collapse', param); }); case 'expand': return this.each(function(){ $(this).panel('expand', param); }); } } options = options || {}; return this.each(function(){ init(this, options); setProperties(this); }); }; $.fn.window.defaults = { zIndex: 9000, draggable: true, resizable: true, shadow: true, modal: false, // window's property which difference from panel title: 'New Window', collapsible: true, minimizable: true, maximizable: true, closable: true, closed: false }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.window.js
JavaScript
asf20
10,958
/** * combobox - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * * Dependencies: * combo * */ (function($){ /** * select previous item */ function selectPrev(target){ var panel = $(target).combo('panel'); var values = $(target).combo('getValues'); var item = panel.find('div.combobox-item[value=' + values.pop() + ']'); if (item.length){ var prev = item.prev(':visible'); if (prev.length){ item = prev; } } else { item = panel.find('div.combobox-item:visible:last'); } var value = item.attr('value'); setValues(target, [value]); if (item.position().top <= 0){ var h = panel.scrollTop() + item.position().top; panel.scrollTop(h); } else if (item.position().top + item.outerHeight() > panel.height()){ var h = panel.scrollTop() + item.position().top + item.outerHeight() - panel.height(); panel.scrollTop(h); } } /** * select next item */ function selectNext(target){ var panel = $(target).combo('panel'); var values = $(target).combo('getValues'); var item = panel.find('div.combobox-item[value=' + values.pop() + ']'); if (item.length){ var next = item.next(':visible'); if (next.length){ item = next; } } else { item = panel.find('div.combobox-item:visible:first'); } var value = item.attr('value'); setValues(target, [value]); if (item.position().top <= 0){ var h = panel.scrollTop() + item.position().top; panel.scrollTop(h); } else if (item.position().top + item.outerHeight() > panel.height()){ var h = panel.scrollTop() + item.position().top + item.outerHeight() - panel.height(); panel.scrollTop(h); } } function selectCurr(target){ var panel = $(target).combo('panel'); var item = panel.find('div.combobox-item-selected'); setValues(target, [item.attr('value')]); $(target).combo('hidePanel'); } /** * select the specified value */ function select(target, value){ var opts = $.data(target, 'combobox').options; var data = $.data(target, 'combobox').data; if (opts.multiple){ var values = $(target).combo('getValues'); for(var i=0; i<values.length; i++){ if (values[i] == value) return; } values.push(value); setValues(target, values); } else { setValues(target, [value]); $(target).combo('hidePanel'); } for(var i=0; i<data.length; i++){ if (data[i][opts.valueField] == value){ opts.onSelect.call(target, data[i]); return; } } } /** * unselect the specified value */ function unselect(target, value){ var opts = $.data(target, 'combobox').options; var data = $.data(target, 'combobox').data; var values = $(target).combo('getValues'); for(var i=0; i<values.length; i++){ if (values[i] == value){ values.splice(i, 1); setValues(target, values); break; } } for(var i=0; i<data.length; i++){ if (data[i][opts.valueField] == value){ opts.onUnselect.call(target, data[i]); return; } } } /** * set values */ function setValues(target, values, remainText){ var opts = $.data(target, 'combobox').options; var data = $.data(target, 'combobox').data; var panel = $(target).combo('panel'); panel.find('div.combobox-item-selected').removeClass('combobox-item-selected'); var vv = [], ss = []; for(var i=0; i<values.length; i++){ var v = values[i]; var s = v; for(var j=0; j<data.length; j++){ if (data[j][opts.valueField] == v){ s = data[j][opts.textField]; break; } } vv.push(v); ss.push(s); panel.find('div.combobox-item[value=' + v + ']').addClass('combobox-item-selected'); } $(target).combo('setValues', vv); if (!remainText){ $(target).combo('setText', ss.join(opts.separator)); } } /** * set value */ function setValue(target, value){ var opts = $.data(target, 'combobox').options; var v = value; if (typeof value == 'object'){ v = value[opts.valueField]; } setValues(target, [v]); } function transformData(target){ var opts = $.data(target, 'combobox').options; var data = []; $('>option', target).each(function(){ var item = {}; item[opts.valueField] = $(this).attr('value') || $(this).html(); item[opts.textField] = $(this).html(); item['selected'] = $(this).attr('selected'); data.push(item); }); return data; } /** * load data, the old list items will be removed. */ function loadData(target, data){ var opts = $.data(target, 'combobox').options; var panel = $(target).combo('panel'); $.data(target, 'combobox').data = data; var selected = []; panel.empty(); // clear old data for(var i=0; i<data.length; i++){ var item = $('<div class="combobox-item"></div>').appendTo(panel); item.attr('value', data[i][opts.valueField]); item.html(data[i][opts.textField]); if (data[i]['selected']){ selected.push(data[i][opts.valueField]); } } if (opts.multiple){ setValues(target, selected); } else { if (selected.length){ setValues(target, [selected[0]]); } else { setValues(target, []); } } opts.onLoadSuccess.call(target, data); $('.combobox-item', panel).hover( function(){$(this).addClass('combobox-item-hover');}, function(){$(this).removeClass('combobox-item-hover');} ).click(function(){ var item = $(this); if (opts.multiple){ if (item.hasClass('combobox-item-selected')){ unselect(target, item.attr('value')); } else { select(target, item.attr('value')); } } else { select(target, item.attr('value')); } }); } /** * request remote data if the url property is setted. */ function request(target, url){ var opts = $.data(target, 'combobox').options; if (url){ opts.url = url; } if (!opts.url) return; $.ajax({ url:opts.url, dataType:'json', success:function(data){ loadData(target, data); }, error:function(){ opts.onLoadError.apply(this, arguments); } }) } function filter(target, query){ $(target).combo('showPanel'); var data = $.data(target, 'combobox').data; var panel = $(target).combo('panel'); setValues(target, [], true); panel.find('div.combobox-item').each(function(){ var item = $(this); if (item.text().indexOf(query) == 0){ item.show(); if (item.text() == query){ item.addClass('combobox-item-selected'); } } else { item.hide(); } }); } function create(target){ var opts = $.data(target, 'combobox').options; $(target).combo(opts); } /** * parse options from markup. */ function parseOptions(target){ var t = $(target); return $.extend({}, t.combo('parseOptions'), { valueField: t.attr('valueField'), textField: t.attr('textField'), url: t.attr('url') }); } $.fn.combobox = function(options, param){ if (typeof options == 'string'){ var method = $.fn.combobox.methods[options]; if (method){ return method(this, param); } else { return this.combo(options, param); } } options = options || {}; return this.each(function(){ var state = $.data(this, 'combobox'); if (state){ $.extend(state.options, options); create(this); } else { state = $.data(this, 'combobox', { options: $.extend({}, $.fn.combo.defaults, $.fn.combobox.defaults, parseOptions(this), options) }); create(this); loadData(this, transformData(this)); } if (state.options.data){ loadData(this, state.options.data); } request(this); }); }; $.fn.combobox.methods = { parseOptions: function(jq){ return parseOptions(jq[0]); }, options: function(jq){ return $.data(jq[0], 'combobox').options; }, getData: function(jq){ return $.data(jq[0], 'combobox').data; }, setValues: function(jq, values){ return jq.each(function(){ setValues(this, values); }); }, setValue: function(jq, value){ return jq.each(function(){ setValue(this, value); }); }, loadData: function(jq, data){ return jq.each(function(){ loadData(this, data); }); }, reload: function(jq, url){ return jq.each(function(){ request(this, url); }); }, select: function(jq, value){ return jq.each(function(){ select(this, value); }); }, unselect: function(jq, value){ return jq.each(function(){ unselect(this, value); }); } }; $.fn.combobox.defaults = { valueField: 'value', textField: 'text', url: null, data: null, selectPrev: function(){selectPrev(this);}, selectNext: function(){selectNext(this);}, selectCurr: function(){selectCurr(this);}, filter: function(query){filter(this, query);}, onLoadSuccess: function(){}, onLoadError: function(){}, onSelect: function(record){}, onUnselect: function(record){} }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.combobox.js
JavaScript
asf20
9,216
/** * numberbox - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * * Dependencies: * validatebox * */ (function($){ function fixValue(target){ var opts = $.data(target, 'numberbox').options; var val = parseFloat($(target).val()).toFixed(opts.precision); if (isNaN(val)){ $(target).val(''); return; } if (opts.min != null && opts.min != undefined && val < opts.min){ $(target).val(opts.min.toFixed(opts.precision)); } else if (opts.max != null && opts.max != undefined && val > opts.max){ $(target).val(opts.max.toFixed(opts.precision)); } else { $(target).val(val); } } function bindEvents(target){ $(target).unbind('.numberbox'); $(target).bind('keypress.numberbox', function(e){ if (e.which == 45){ //- return true; } if (e.which == 46) { //. return true; } else if ((e.which >= 48 && e.which <= 57 && e.ctrlKey == false && e.shiftKey == false) || e.which == 0 || e.which == 8) { return true; } else if (e.ctrlKey == true && (e.which == 99 || e.which == 118)) { return true; } else { return false; } }).bind('paste.numberbox', function(){ if (window.clipboardData) { var s = clipboardData.getData('text'); if (! /\D/.test(s)) { return true; } else { return false; } } else { return false; } }).bind('dragenter.numberbox', function(){ return false; }).bind('blur.numberbox', function(){ fixValue(target); }); } /** * do the validate if necessary. */ function validate(target){ if ($.fn.validatebox){ var opts = $.data(target, 'numberbox').options; $(target).validatebox(opts); } } function setDisabled(target, disabled){ var opts = $.data(target, 'numberbox').options; if (disabled){ opts.disabled = true; $(target).attr('disabled', true); } else { opts.disabled = false; $(target).removeAttr('disabled'); } } $.fn.numberbox = function(options){ if (typeof options == 'string'){ switch(options){ case 'disable': return this.each(function(){ setDisabled(this, true); }); case 'enable': return this.each(function(){ setDisabled(this, false); }); } } options = options || {}; return this.each(function(){ var state = $.data(this, 'numberbox'); if (state){ $.extend(state.options, options); } else { var t = $(this); state = $.data(this, 'numberbox', { options: $.extend({}, $.fn.numberbox.defaults, { disabled: (t.attr('disabled') ? true : undefined), min: (t.attr('min')=='0' ? 0 : parseFloat(t.attr('min')) || undefined), max: (t.attr('max')=='0' ? 0 : parseFloat(t.attr('max')) || undefined), precision: (parseInt(t.attr('precision')) || undefined) }, options) }); t.removeAttr('disabled'); $(this).css({imeMode:"disabled"}); } setDisabled(this, state.options.disabled); bindEvents(this); validate(this); }); }; $.fn.numberbox.defaults = { disabled: false, min: null, max: null, precision: 0 }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.numberbox.js
JavaScript
asf20
3,270
/** * draggable - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] */ (function($){ function drag(e){ var opts = $.data(e.data.target, 'draggable').options; var dragData = e.data; var left = dragData.startLeft + e.pageX - dragData.startX; var top = dragData.startTop + e.pageY - dragData.startY; if (opts.deltaX != null && opts.deltaX != undefined){ left = e.pageX + opts.deltaX; } if (opts.deltaY != null && opts.deltaY != undefined){ top = e.pageY + opts.deltaY; } if (e.data.parnet != document.body) { if ($.boxModel == true) { left += $(e.data.parent).scrollLeft(); top += $(e.data.parent).scrollTop(); } } if (opts.axis == 'h') { dragData.left = left; } else if (opts.axis == 'v') { dragData.top = top; } else { dragData.left = left; dragData.top = top; } } function applyDrag(e){ var opts = $.data(e.data.target, 'draggable').options; var proxy = $.data(e.data.target, 'draggable').proxy; if (proxy){ proxy.css('cursor', opts.cursor); } else { proxy = $(e.data.target); $.data(e.data.target, 'draggable').handle.css('cursor', opts.cursor); } proxy.css({ left:e.data.left, top:e.data.top }); } function doDown(e){ var opts = $.data(e.data.target, 'draggable').options; var droppables = $('.droppable').filter(function(){ return e.data.target != this; }).filter(function(){ var accept = $.data(this, 'droppable').options.accept; if (accept){ return $(accept).filter(function(){ return this == e.data.target; }).length > 0; } else { return true; } }); $.data(e.data.target, 'draggable').droppables = droppables; var proxy = $.data(e.data.target, 'draggable').proxy; if (!proxy){ if (opts.proxy){ if (opts.proxy == 'clone'){ proxy = $(e.data.target).clone().insertAfter(e.data.target); } else { proxy = opts.proxy.call(e.data.target, e.data.target); } $.data(e.data.target, 'draggable').proxy = proxy; } else { proxy = $(e.data.target); } } proxy.css('position', 'absolute'); drag(e); applyDrag(e); opts.onStartDrag.call(e.data.target, e); return false; } function doMove(e){ drag(e); if ($.data(e.data.target, 'draggable').options.onDrag.call(e.data.target, e) != false){ applyDrag(e); } var source = e.data.target; $.data(e.data.target, 'draggable').droppables.each(function(){ var dropObj = $(this); var p2 = $(this).offset(); if (e.pageX > p2.left && e.pageX < p2.left + dropObj.outerWidth() && e.pageY > p2.top && e.pageY < p2.top + dropObj.outerHeight()){ if (!this.entered){ $(this).trigger('_dragenter', [source]); this.entered = true; } $(this).trigger('_dragover', [source]); } else { if (this.entered){ $(this).trigger('_dragleave', [source]); this.entered = false; } } }); return false; } function doUp(e){ drag(e); var proxy = $.data(e.data.target, 'draggable').proxy; var opts = $.data(e.data.target, 'draggable').options; if (opts.revert){ if (checkDrop() == true){ removeProxy(); $(e.data.target).css({ position:e.data.startPosition, left:e.data.startLeft, top:e.data.startTop }); } else { if (proxy){ proxy.animate({ left:e.data.startLeft, top:e.data.startTop }, function(){ removeProxy(); }); } else { $(e.data.target).animate({ left:e.data.startLeft, top:e.data.startTop }, function(){ $(e.data.target).css('position', e.data.startPosition); }); } } } else { $(e.data.target).css({ position:'absolute', left:e.data.left, top:e.data.top }); removeProxy(); checkDrop(); } opts.onStopDrag.call(e.data.target, e); function removeProxy(){ if (proxy){ proxy.remove(); } $.data(e.data.target, 'draggable').proxy = null; } function checkDrop(){ var dropped = false; $.data(e.data.target, 'draggable').droppables.each(function(){ var dropObj = $(this); var p2 = $(this).offset(); if (e.pageX > p2.left && e.pageX < p2.left + dropObj.outerWidth() && e.pageY > p2.top && e.pageY < p2.top + dropObj.outerHeight()){ if (opts.revert){ $(e.data.target).css({ position:e.data.startPosition, left:e.data.startLeft, top:e.data.startTop }); } $(this).trigger('_drop', [e.data.target]); dropped = true; this.entered = false; } }); return dropped; } $(document).unbind('.draggable'); return false; } $.fn.draggable = function(options){ if (typeof options == 'string'){ switch(options){ case 'options': return $.data(this[0], 'draggable').options; case 'proxy': return $.data(this[0], 'draggable').proxy; case 'enable': return this.each(function(){ $(this).draggable({disabled:false}); }); case 'disable': return this.each(function(){ $(this).draggable({disabled:true}); }); } } return this.each(function(){ // $(this).css('position','absolute'); var opts; var state = $.data(this, 'draggable'); if (state) { state.handle.unbind('.draggable'); opts = $.extend(state.options, options); } else { opts = $.extend({}, $.fn.draggable.defaults, options || {}); } if (opts.disabled == true) { $(this).css('cursor', 'default'); return; } var handle = null; if (typeof opts.handle == 'undefined' || opts.handle == null){ handle = $(this); } else { handle = (typeof opts.handle == 'string' ? $(opts.handle, this) : handle); } $.data(this, 'draggable', { options: opts, handle: handle }); // bind mouse event using event namespace draggable handle.bind('mousedown.draggable', {target:this}, onMouseDown); handle.bind('mousemove.draggable', {target:this}, onMouseMove); function onMouseDown(e) { if (checkArea(e) == false) return; var position = $(e.data.target).position(); var data = { startPosition: $(e.data.target).css('position'), startLeft: position.left, startTop: position.top, left: position.left, top: position.top, startX: e.pageX, startY: e.pageY, target: e.data.target, parent: $(e.data.target).parent()[0] }; $(document).bind('mousedown.draggable', data, doDown); $(document).bind('mousemove.draggable', data, doMove); $(document).bind('mouseup.draggable', data, doUp); } function onMouseMove(e) { if (checkArea(e)){ $(this).css('cursor', opts.cursor); } else { $(this).css('cursor', 'default'); } } // check if the handle can be dragged function checkArea(e) { var offset = $(handle).offset(); var width = $(handle).outerWidth(); var height = $(handle).outerHeight(); var t = e.pageY - offset.top; var r = offset.left + width - e.pageX; var b = offset.top + height - e.pageY; var l = e.pageX - offset.left; return Math.min(t,r,b,l) > opts.edge; } }); }; $.fn.draggable.defaults = { proxy:null, // 'clone' or a function that will create the proxy object, // the function has the source parameter that indicate the source object dragged. revert:false, cursor:'move', deltaX:null, deltaY:null, handle: null, disabled: false, edge:0, axis:null, // v or h onStartDrag: function(e){}, onDrag: function(e){}, onStopDrag: function(e){} }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.draggable.js
JavaScript
asf20
7,999
/** * linkbutton - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] */ (function($){ function createButton(target) { var opts = $.data(target, 'linkbutton').options; $(target).empty(); $(target).addClass('l-btn'); if (opts.id){ $(target).attr('id', opts.id); } else { $(target).removeAttr('id'); } if (opts.plain){ $(target).addClass('l-btn-plain'); } else { $(target).removeClass('l-btn-plain'); } if (opts.text){ $(target).html(opts.text).wrapInner( '<span class="l-btn-left">' + '<span class="l-btn-text">' + '</span>' + '</span>' ); if (opts.iconCls){ $(target).find('.l-btn-text').addClass(opts.iconCls).css('padding-left', '20px'); } } else { $(target).html('&nbsp;').wrapInner( '<span class="l-btn-left">' + '<span class="l-btn-text">' + '<span class="l-btn-empty"></span>' + '</span>' + '</span>' ); if (opts.iconCls){ $(target).find('.l-btn-empty').addClass(opts.iconCls); } } setDisabled(target, opts.disabled); } function setDisabled(target, disabled){ var state = $.data(target, 'linkbutton'); if (disabled){ state.options.disabled = true; var href = $(target).attr('href'); if (href){ state.href = href; $(target).attr('href', 'javascript:void(0)'); } var onclick = $(target).attr('onclick'); if (onclick) { state.onclick = onclick; $(target).attr('onclick', null); } $(target).addClass('l-btn-disabled'); } else { state.options.disabled = false; if (state.href) { $(target).attr('href', state.href); } if (state.onclick) { target.onclick = state.onclick; } $(target).removeClass('l-btn-disabled'); } } $.fn.linkbutton = function(options){ if (typeof options == 'string'){ switch(options){ case 'options': return $.data(this[0], 'linkbutton').options; case 'enable': return this.each(function(){ setDisabled(this, false); }); case 'disable': return this.each(function(){ setDisabled(this, true); }); } } options = options || {}; return this.each(function(){ var state = $.data(this, 'linkbutton'); if (state){ $.extend(state.options, options); } else { var t = $(this); $.data(this, 'linkbutton', { options: $.extend({}, $.fn.linkbutton.defaults, { id: t.attr('id'), disabled: (t.attr('disabled') ? true : undefined), plain: (t.attr('plain') ? t.attr('plain') == 'true' : undefined), text: $.trim(t.html()), iconCls: t.attr('icon') }, options) }); t.removeAttr('disabled'); } createButton(this); }); }; $.fn.linkbutton.defaults = { id: null, disabled: false, plain: false, text: '', iconCls: null }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.linkbutton.js
JavaScript
asf20
3,013
/** * numberTextBox - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2009 stworthy [ stworthy@gmail.com ] * * usage: <input class="number-textbox" min="1" max="100" precision="2"> * The plugin will make the input can only input number chars * Options: * min: The minimum allowed value * max: The maximum allowed value * precision: The maximum precision to display after the decimal separator */ (function($){ $.fn.numberTextBox = function(){ function fixValue(target){ var min = parseFloat($(target).attr('min')); var max = parseFloat($(target).attr('max')); var precision = $(target).attr("precision") || 0; var val = parseFloat($(target).val()).toFixed(precision); if (isNaN(val)) { $(target).val(''); return; } if (min && val < min) { $(target).val(min.toFixed(precision)); } else if (max && val > max) { $(target).val(max.toFixed(precision)); } else { $(target).val(val); } } return this.each(function(){ $(this).css({imeMode:"disabled"}); $(this).keypress(function(e){ if (e.which == 46) { return true; } else if ((e.which >= 48 && e.which <= 57 && e.ctrlKey == false && e.shiftKey == false) || e.which == 0 || e.which == 8) { return true; } else if (e.ctrlKey == true && (e.which == 99 || e.which == 118)) { return true; } else { return false; } }).bind('paste', function(){ if (window.clipboardData) { var s = clipboardData.getData('text'); if (! /\D/.test(s)) { return true; } else { return false; } } else { return false; } }).bind('dragenter', function(){ return false; }).blur(function(){ fixValue(this); }); }); }; $(function(){ $('.number-textbox').numberTextBox(); }); })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.numberTextBox.js
JavaScript
asf20
1,926
/** * messager - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * * Dependencies: * draggable * resizable * linkbutton * panel * window */ (function($){ /** * show window with animate, after sometime close the window */ function show(win, type, speed, timeout){ if (!win) return; switch(type){ case null: win.show(); break; case 'slide': win.slideDown(speed); break; case 'fade': win.fadeIn(speed); break; case 'show': win.show(speed); break; } var timer = null; if (timeout > 0){ timer = setTimeout(function(){ hide(win, type, speed); }, timeout); } win.hover( function(){ if (timer){ clearTimeout(timer); } }, function(){ if (timeout > 0){ timer = setTimeout(function(){ hide(win, type, speed); }, timeout); } } ) } /** * hide window with animate */ function hide(win, type, speed){ if (!win) return; switch(type){ case null: win.hide(); break; case 'slide': win.slideUp(speed); break; case 'fade': win.fadeOut(speed); break; case 'show': win.hide(speed); break; } setTimeout(function(){ win.remove(); }, speed); } /** * create a dialog, when dialog is closed destroy it */ function createDialog(title, content, buttons){ var win = $('<div class="messager-body"></div>').appendTo('body'); win.append(content); if (buttons){ var tb = $('<div class="messager-button"></div>').appendTo(win); for(var label in buttons){ $('<a></a>').attr('href', 'javascript:void(0)').text(label) .css('margin-left', 10) .bind('click', eval(buttons[label])) .appendTo(tb).linkbutton(); } } win.window({ title: title, width: 300, height: 'auto', modal: true, collapsible: false, minimizable: false, maximizable: false, resizable: false, onClose: function(){ setTimeout(function(){ win.window('destroy'); }, 100); } }); return win; } $.messager = { show: function(options){ var opts = $.extend({ showType: 'slide', showSpeed: 600, width: 250, height: 100, msg: '', title: '', timeout: 4000 }, options || {}); var win = $('<div class="messager-body"></div>').html(opts.msg).appendTo('body'); win.window({ title: opts.title, width: opts.width, height: opts.height, collapsible: false, minimizable: false, maximizable: false, shadow: false, draggable: false, resizable: false, closed: true, onBeforeOpen: function(){ show($(this).window('window'), opts.showType, opts.showSpeed, opts.timeout); return false; }, onBeforeClose: function(){ hide(win.window('window'), opts.showType, opts.showSpeed); return false; } }); // set the message window to the right bottom position win.window('window').css({ left: null, top: null, right: 0, bottom: -document.body.scrollTop-document.documentElement.scrollTop }); win.window('open'); }, alert: function(title, msg, icon, fn) { var content = '<div>' + msg + '</div>'; switch(icon) { case 'error': content = '<div class="messager-icon messager-error"></div>' + content; break; case 'info': content = '<div class="messager-icon messager-info"></div>' + content; break; case 'question': content = '<div class="messager-icon messager-question"></div>' + content; break; case 'warning': content = '<div class="messager-icon messager-warning"></div>' + content; break; } content += '<div style="clear:both;"/>'; var buttons = {}; buttons[$.messager.defaults.ok] = function(){ win.dialog({closed:true}); if (fn){ fn(); return false; } }; buttons[$.messager.defaults.ok] = function(){ win.window('close'); if (fn){ fn(); return false; } }; var win = createDialog(title,content,buttons); }, confirm: function(title, msg, fn) { var content = '<div class="messager-icon messager-question"></div>' + '<div>' + msg + '</div>' + '<div style="clear:both;"/>'; var buttons = {}; buttons[$.messager.defaults.ok] = function(){ win.window('close'); if (fn){ fn(true); return false; } }; buttons[$.messager.defaults.cancel] = function(){ win.window('close'); if (fn){ fn(false); return false; } }; var win = createDialog(title,content,buttons); }, prompt: function(title, msg, fn) { var content = '<div class="messager-icon messager-question"></div>' + '<div>' + msg + '</div>' + '<br/>' + '<input class="messager-input" type="text"/>' + '<div style="clear:both;"/>'; var buttons = {}; buttons[$.messager.defaults.ok] = function(){ win.window('close'); if (fn){ fn($('.messager-input', win).val()); return false; } }; buttons[$.messager.defaults.cancel] = function(){ win.window('close'); if (fn){ fn(); return false; } }; var win = createDialog(title,content,buttons); } }; $.messager.defaults = { ok: 'Ok', cancel: 'Cancel' }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.messager.js
JavaScript
asf20
5,583
/** * layout - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * * Dependencies: * resizable * panel */ (function($){ var resizing = false; // indicate if the region panel is resizing function setSize(container){ var opts = $.data(container, 'layout').options; var panels = $.data(container, 'layout').panels; var cc = $(container); if (opts.fit == true){ var p = cc.parent(); cc.width(p.width()).height(p.height()); } var cpos = { top:0, left:0, width:cc.width(), height:cc.height() }; // set north panel size function setNorthSize(pp){ if (pp.length == 0) return; pp.panel('resize', { width: cc.width(), height: pp.panel('options').height, left: 0, top: 0 }); cpos.top += pp.panel('options').height; cpos.height -= pp.panel('options').height; } if (isVisible(panels.expandNorth)){ setNorthSize(panels.expandNorth); } else { setNorthSize(panels.north); } // set south panel size function setSouthSize(pp){ if (pp.length == 0) return; pp.panel('resize', { width: cc.width(), height: pp.panel('options').height, left: 0, top: cc.height() - pp.panel('options').height }); cpos.height -= pp.panel('options').height; } if (isVisible(panels.expandSouth)){ setSouthSize(panels.expandSouth); } else { setSouthSize(panels.south); } // set east panel size function setEastSize(pp){ if (pp.length == 0) return; pp.panel('resize', { width: pp.panel('options').width, height: cpos.height, left: cc.width() - pp.panel('options').width, top: cpos.top }); cpos.width -= pp.panel('options').width; } if (isVisible(panels.expandEast)){ setEastSize(panels.expandEast); } else { setEastSize(panels.east); } // set west panel size function setWestSize(pp){ if (pp.length == 0) return; pp.panel('resize', { width: pp.panel('options').width, height: cpos.height, left: 0, top: cpos.top }); cpos.left += pp.panel('options').width; cpos.width -= pp.panel('options').width; } if (isVisible(panels.expandWest)){ setWestSize(panels.expandWest); } else { setWestSize(panels.west); } panels.center.panel('resize', cpos); } /** * initialize and wrap the layout */ function init(container){ var cc = $(container); if (cc[0].tagName == 'BODY'){ $('html').css({ height: '100%', overflow: 'hidden' }); $('body').css({ height: '100%', overflow: 'hidden', border: 'none' }); } cc.addClass('layout'); cc.css({ margin:0, padding:0 }); function createPanel(dir){ var pp = $('>div[region='+dir+']', container).addClass('layout-body'); var toolCls = null; if (dir == 'north'){ toolCls = 'layout-button-up'; } else if (dir == 'south'){ toolCls = 'layout-button-down'; } else if (dir == 'east'){ toolCls = 'layout-button-right'; } else if (dir == 'west'){ toolCls = 'layout-button-left'; } var cls = 'layout-panel layout-panel-' + dir; if (pp.attr('split') == 'true'){ cls += ' layout-split-' + dir; } pp.panel({ cls: cls, doSize: false, border: (pp.attr('border') == 'false' ? false : true), tools: [{ iconCls: toolCls, handler: function(){ collapsePanel(container, dir); } }] }); if (pp.attr('split') == 'true'){ var panel = pp.panel('panel'); var handles = ''; if (dir == 'north') handles = 's'; if (dir == 'south') handles = 'n'; if (dir == 'east') handles = 'w'; if (dir == 'west') handles = 'e'; panel.resizable({ handles:handles, onStartResize: function(e){ resizing = true; if (dir == 'north' || dir == 'south'){ var proxy = $('>div.layout-split-proxy-v', container); } else { var proxy = $('>div.layout-split-proxy-h', container); } var top=0,left=0,width=0,height=0; var pos = {display: 'block'}; if (dir == 'north'){ pos.top = parseInt(panel.css('top')) + panel.outerHeight() - proxy.height(); pos.left = parseInt(panel.css('left')); pos.width = panel.outerWidth(); pos.height = proxy.height(); } else if (dir == 'south'){ pos.top = parseInt(panel.css('top')); pos.left = parseInt(panel.css('left')); pos.width = panel.outerWidth(); pos.height = proxy.height(); } else if (dir == 'east'){ pos.top = parseInt(panel.css('top')) || 0; pos.left = parseInt(panel.css('left')) || 0; pos.width = proxy.width(); pos.height = panel.outerHeight(); } else if (dir == 'west'){ pos.top = parseInt(panel.css('top')) || 0; pos.left = panel.outerWidth() - proxy.width(); pos.width = proxy.width(); pos.height = panel.outerHeight(); } proxy.css(pos); $('<div class="layout-mask"></div>').css({ left:0, top:0, width:cc.width(), height:cc.height() }).appendTo(cc); }, onResize: function(e){ if (dir == 'north' || dir == 'south'){ var proxy = $('>div.layout-split-proxy-v', container); proxy.css('top', e.pageY - $(container).offset().top - proxy.height()/2); } else { var proxy = $('>div.layout-split-proxy-h', container); proxy.css('left', e.pageX - $(container).offset().left - proxy.width()/2); } return false; }, onStopResize: function(){ $('>div.layout-split-proxy-v', container).css('display','none'); $('>div.layout-split-proxy-h', container).css('display','none'); var opts = pp.panel('options'); opts.width = panel.outerWidth(); opts.height = panel.outerHeight(); opts.left = panel.css('left'); opts.top = panel.css('top'); pp.panel('resize'); setSize(container); resizing = false; cc.find('>div.layout-mask').remove(); } }); } return pp; } $('<div class="layout-split-proxy-h"></div>').appendTo(cc); $('<div class="layout-split-proxy-v"></div>').appendTo(cc); var panels = { center: createPanel('center') }; panels.north = createPanel('north'); panels.south = createPanel('south'); panels.east = createPanel('east'); panels.west = createPanel('west'); $(container).bind('_resize', function(){ var opts = $.data(container, 'layout').options; if (opts.fit == true){ setSize(container); } return false; }); $(window).resize(function(){ setSize(container); }); return panels; } function collapsePanel(container, region){ var panels = $.data(container, 'layout').panels; var cc = $(container); function createExpandPanel(dir){ var icon; if (dir == 'east') icon = 'layout-button-left' else if (dir == 'west') icon = 'layout-button-right' else if (dir == 'north') icon = 'layout-button-down' else if (dir == 'south') icon = 'layout-button-up'; var p = $('<div></div>').appendTo(cc).panel({ cls: 'layout-expand', title: '&nbsp;', closed: true, doSize: false, tools: [{ iconCls: icon, handler:function(){ expandPanel(container, region); } }] }); p.panel('panel').hover( function(){$(this).addClass('layout-expand-over');}, function(){$(this).removeClass('layout-expand-over');} ); return p; } if (region == 'east'){ if (panels.east.panel('options').onBeforeCollapse.call(panels.east) == false) return; panels.center.panel('resize', { width: panels.center.panel('options').width + panels.east.panel('options').width - 28 }); panels.east.panel('panel').animate({left:cc.width()}, function(){ panels.east.panel('close'); panels.expandEast.panel('open').panel('resize', { top: panels.east.panel('options').top, left: cc.width() - 28, width: 28, height: panels.east.panel('options').height }); panels.east.panel('options').onCollapse.call(panels.east); }); if (!panels.expandEast) { panels.expandEast = createExpandPanel('east'); panels.expandEast.panel('panel').click(function(){ panels.east.panel('open').panel('resize', {left:cc.width()}); panels.east.panel('panel').animate({ left: cc.width() - panels.east.panel('options').width }); return false; }); } } else if (region == 'west'){ if (panels.west.panel('options').onBeforeCollapse.call(panels.west) == false) return; panels.center.panel('resize', { width: panels.center.panel('options').width + panels.west.panel('options').width - 28, left: 28 }); panels.west.panel('panel').animate({left:-panels.west.panel('options').width}, function(){ panels.west.panel('close'); panels.expandWest.panel('open').panel('resize', { top: panels.west.panel('options').top, left: 0, width: 28, height: panels.west.panel('options').height }); panels.west.panel('options').onCollapse.call(panels.west); }); if (!panels.expandWest) { panels.expandWest = createExpandPanel('west'); panels.expandWest.panel('panel').click(function(){ panels.west.panel('open').panel('resize', {left: -panels.west.panel('options').width}); panels.west.panel('panel').animate({ left: 0 }); return false; }); } } else if (region == 'north'){ if (panels.north.panel('options').onBeforeCollapse.call(panels.north) == false) return; var hh = cc.height() - 28; if (isVisible(panels.expandSouth)){ hh -= panels.expandSouth.panel('options').height; } else if (isVisible(panels.south)){ hh -= panels.south.panel('options').height; } panels.center.panel('resize', {top:28, height:hh}); panels.east.panel('resize', {top:28, height:hh}); panels.west.panel('resize', {top:28, height:hh}); if (isVisible(panels.expandEast)) panels.expandEast.panel('resize', {top:28, height:hh}); if (isVisible(panels.expandWest)) panels.expandWest.panel('resize', {top:28, height:hh}); panels.north.panel('panel').animate({top:-panels.north.panel('options').height}, function(){ panels.north.panel('close'); panels.expandNorth.panel('open').panel('resize', { top: 0, left: 0, width: cc.width(), height: 28 }); panels.north.panel('options').onCollapse.call(panels.north); }); if (!panels.expandNorth) { panels.expandNorth = createExpandPanel('north'); panels.expandNorth.panel('panel').click(function(){ panels.north.panel('open').panel('resize', {top:-panels.north.panel('options').height}); panels.north.panel('panel').animate({top:0}); return false; }); } } else if (region == 'south'){ if (panels.south.panel('options').onBeforeCollapse.call(panels.south) == false) return; var hh = cc.height() - 28; if (isVisible(panels.expandNorth)){ hh -= panels.expandNorth.panel('options').height; } else if (isVisible(panels.north)){ hh -= panels.north.panel('options').height; } panels.center.panel('resize', {height:hh}); panels.east.panel('resize', {height:hh}); panels.west.panel('resize', {height:hh}); if (isVisible(panels.expandEast)) panels.expandEast.panel('resize', {height:hh}); if (isVisible(panels.expandWest)) panels.expandWest.panel('resize', {height:hh}); panels.south.panel('panel').animate({top:cc.height()}, function(){ panels.south.panel('close'); panels.expandSouth.panel('open').panel('resize', { top: cc.height() - 28, left: 0, width: cc.width(), height: 28 }); panels.south.panel('options').onCollapse.call(panels.south); }); if (!panels.expandSouth) { panels.expandSouth = createExpandPanel('south'); panels.expandSouth.panel('panel').click(function(){ panels.south.panel('open').panel('resize', {top:cc.height()}); panels.south.panel('panel').animate({top:cc.height()-panels.south.panel('options').height}); return false; }); } } } function expandPanel(container, region){ var panels = $.data(container, 'layout').panels; var cc = $(container); if (region == 'east' && panels.expandEast){ if (panels.east.panel('options').onBeforeExpand.call(panels.east) == false) return; panels.expandEast.panel('close'); panels.east.panel('panel').stop(true,true); panels.east.panel('open').panel('resize', {left:cc.width()}); panels.east.panel('panel').animate({ left: cc.width() - panels.east.panel('options').width }, function(){ setSize(container); panels.east.panel('options').onExpand.call(panels.east); }); } else if (region == 'west' && panels.expandWest){ if (panels.west.panel('options').onBeforeExpand.call(panels.west) == false) return; panels.expandWest.panel('close'); panels.west.panel('panel').stop(true,true); panels.west.panel('open').panel('resize', {left: -panels.west.panel('options').width}); panels.west.panel('panel').animate({ left: 0 }, function(){ setSize(container); panels.west.panel('options').onExpand.call(panels.west); }); } else if (region == 'north' && panels.expandNorth){ if (panels.north.panel('options').onBeforeExpand.call(panels.north) == false) return; panels.expandNorth.panel('close'); panels.north.panel('panel').stop(true,true); panels.north.panel('open').panel('resize', {top:-panels.north.panel('options').height}); panels.north.panel('panel').animate({top:0}, function(){ setSize(container); panels.north.panel('options').onExpand.call(panels.north); }); } else if (region == 'south' && panels.expandSouth){ if (panels.south.panel('options').onBeforeExpand.call(panels.south) == false) return; panels.expandSouth.panel('close'); panels.south.panel('panel').stop(true,true); panels.south.panel('open').panel('resize', {top:cc.height()}); panels.south.panel('panel').animate({top:cc.height()-panels.south.panel('options').height}, function(){ setSize(container); panels.south.panel('options').onExpand.call(panels.south); }); } } function bindEvents(container){ var panels = $.data(container, 'layout').panels; var cc = $(container); // bind east panel events if (panels.east.length){ panels.east.panel('panel').bind('mouseover','east',collapsePanel); } // bind west panel events if (panels.west.length){ panels.west.panel('panel').bind('mouseover','west',collapsePanel); } // bind north panel events if (panels.north.length){ panels.north.panel('panel').bind('mouseover','north',collapsePanel); } // bind south panel events if (panels.south.length){ panels.south.panel('panel').bind('mouseover','south',collapsePanel); } panels.center.panel('panel').bind('mouseover','center',collapsePanel); function collapsePanel(e){ if (resizing == true) return; if (e.data != 'east' && isVisible(panels.east) && isVisible(panels.expandEast)){ panels.east.panel('panel').animate({left:cc.width()}, function(){ panels.east.panel('close'); }); } if (e.data != 'west' && isVisible(panels.west) && isVisible(panels.expandWest)){ panels.west.panel('panel').animate({left:-panels.west.panel('options').width}, function(){ panels.west.panel('close'); }); } if (e.data != 'north' && isVisible(panels.north) && isVisible(panels.expandNorth)){ panels.north.panel('panel').animate({top:-panels.north.panel('options').height}, function(){ panels.north.panel('close'); }); } if (e.data != 'south' && isVisible(panels.south) && isVisible(panels.expandSouth)){ panels.south.panel('panel').animate({top:cc.height()}, function(){ panels.south.panel('close'); }); } return false; } } function isVisible(pp){ if (!pp) return false; if (pp.length){ return pp.panel('panel').is(':visible'); } else { return false; } } $.fn.layout = function(options, param){ if (typeof options == 'string'){ switch(options){ case 'panel': return $.data(this[0], 'layout').panels[param]; case 'collapse': return this.each(function(){ collapsePanel(this, param); }); case 'expand': return this.each(function(){ expandPanel(this, param); }); } } return this.each(function(){ var state = $.data(this, 'layout'); if (!state){ var opts = $.extend({}, { fit: $(this).attr('fit') == 'true' }); // var t1=new Date().getTime(); $.data(this, 'layout', { options: opts, panels: init(this) }); bindEvents(this); // var t2=new Date().getTime(); // alert(t2-t1) } setSize(this); }); }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.layout.js
JavaScript
asf20
17,366
/** * validatebox - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * */ (function($){ function init(target){ $(target).addClass('validatebox-text'); } /** * destroy the box, including it's tip object. */ function destroyBox(target){ var tip = $.data(target, 'validatebox').tip; if (tip){ tip.remove(); } $(target).remove(); } function bindEvents(target){ var box = $(target); var tip = $.data(target, 'validatebox').tip; var time = null; box.unbind('.validatebox').bind('focus.validatebox', function(){ if (time){ clearInterval(time); } time = setInterval(function(){ validate(target); }, 200); }).bind('blur.validatebox', function(){ clearInterval(time); time = null; hideTip(target); }).bind('mouseover.validatebox', function(){ if (box.hasClass('validatebox-invalid')){ showTip(target); } }).bind('mouseout.validatebox', function(){ hideTip(target); }); } /** * show tip message. */ function showTip(target){ var box = $(target); var msg = $.data(target, 'validatebox').message; var tip = $.data(target, 'validatebox').tip; if (!tip){ tip = $( '<div class="validatebox-tip">' + '<span class="validatebox-tip-content">' + '</span>' + '<span class="validatebox-tip-pointer">' + '</span>' + '</div>' ).appendTo('body'); $.data(target, 'validatebox').tip = tip; } tip.find('.validatebox-tip-content').html(msg); tip.css({ display:'block', left:box.offset().left + box.outerWidth(), top:box.offset().top }) } /** * hide tip message. */ function hideTip(target){ var tip = $.data(target, 'validatebox').tip; if (tip){ tip.remove(); $.data(target, 'validatebox').tip = null; } } /** * do validate action */ function validate(target){ var opts = $.data(target, 'validatebox').options; var tip = $.data(target, 'validatebox').tip; var box = $(target); var value = box.val(); function setTipMessage(msg){ $.data(target, 'validatebox').message = msg; } // if the box is disabled, skip validate action. var disabled = box.attr('disabled'); if (disabled == true || disabled == 'true'){ return true; } if (opts.required){ if (value == ''){ box.addClass('validatebox-invalid'); setTipMessage(opts.missingMessage); showTip(target); return false; } } if (opts.validType){ var result = /([a-zA-Z_]+)(.*)/.exec(opts.validType); var rule = opts.rules[result[1]]; if (value && rule){ var param = eval(result[2]); if (!rule['validator'](value, param)){ box.addClass('validatebox-invalid'); var message = rule['message']; if (param){ for(var i=0; i<param.length; i++){ message = message.replace(new RegExp("\\{" + i + "\\}", "g"), param[i]); } } setTipMessage(opts.invalidMessage || message); showTip(target); return false; } } } box.removeClass('validatebox-invalid'); hideTip(target); return true; } $.fn.validatebox = function(options){ if (typeof options == 'string'){ switch(options){ case 'destroy': return this.each(function(){ destroyBox(this); }); case 'validate': return this.each(function(){ validate(this); }); case 'isValid': return validate(this[0]); } } options = options || {}; return this.each(function(){ var state = $.data(this, 'validatebox'); if (state){ $.extend(state.options, options); } else { init(this); var t = $(this); state = $.data(this, 'validatebox', { options: $.extend({}, $.fn.validatebox.defaults, { required: (t.attr('required') ? (t.attr('required') == 'true' || t.attr('required') == true) : undefined), validType: (t.attr('validType') || undefined), missingMessage: (t.attr('missingMessage') || undefined), invalidMessage: (t.attr('invalidMessage') || undefined) }, options) }); } bindEvents(this); }); }; $.fn.validatebox.defaults = { required: false, validType: null, missingMessage: 'This field is required.', invalidMessage: null, rules: { email:{ validator: function(value){ return /^((([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.test(value); }, message: 'Please enter a valid email address.' }, url: { validator: function(value){ return /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([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])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value); }, message: 'Please enter a valid URL.' }, length: { validator: function(value, param){ var len = $.trim(value).length; return len >= param[0] && len <= param[1] }, message: 'Please enter a value between {0} and {1}.' } } }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.validatebox.js
JavaScript
asf20
7,046
/** * menubutton - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * * Copyright 2010 stworthy [ stworthy@gmail.com ] * * Dependencies: * linkbutton * menu */ (function($){ function init(target){ var opts = $.data(target, 'menubutton').options; var btn = $(target); btn.removeClass('m-btn-active m-btn-plain-active'); btn.linkbutton(opts); if (opts.menu){ $(opts.menu).menu({ onShow: function(){ btn.addClass((opts.plain==true) ? 'm-btn-plain-active' : 'm-btn-active'); }, onHide: function(){ btn.removeClass((opts.plain==true) ? 'm-btn-plain-active' : 'm-btn-active'); } }); } btn.unbind('.menubutton'); if (opts.disabled == false && opts.menu){ btn.bind('click.menubutton', function(){ showMenu(); return false; }); var timeout = null; btn.bind('mouseenter.menubutton', function(){ timeout = setTimeout(function(){ showMenu(); }, opts.duration); return false; }).bind('mouseleave.menubutton', function(){ if (timeout){ clearTimeout(timeout); } }); } function showMenu(){ var left = btn.offset().left; if (left + $(opts.menu).outerWidth() + 5 > $(window).width()){ left = $(window).width() - $(opts.menu).outerWidth() - 5; } $('.menu-top').menu('hide'); $(opts.menu).menu('show', { left: left, top: btn.offset().top + btn.outerHeight() }); btn.blur(); } } $.fn.menubutton = function(options){ options = options || {}; return this.each(function(){ var state = $.data(this, 'menubutton'); if (state){ $.extend(state.options, options); } else { $.data(this, 'menubutton', { options: $.extend({}, $.fn.menubutton.defaults, { disabled: $(this).attr('disabled') == 'true', plain: ($(this).attr('plain')=='false' ? false : true), menu: $(this).attr('menu'), duration: (parseInt($(this).attr('duration')) || 100) }, options) }); $(this).removeAttr('disabled'); $(this).append('<span class="m-btn-downarrow">&nbsp;</span>'); } init(this); }); }; $.fn.menubutton.defaults = { disabled: false, plain: true, menu: null, duration: 100 }; })(jQuery);
zzyapps
trunk/JqFw/WebRoot/resource/easyui/src/jquery.menubutton.js
JavaScript
asf20
2,336