API
Class

Util ($UI/system/lib/base/util)

使用范围:UI2

Contents

class Util ($UI/system/lib/base/util)

Util工具类

Constructor Top

  Util ()

Static Methods Top

void addCookie (String name, String value, String path, Integer expiresHours)
Object apply (Object object, Object config, Object defaults)
function bindModelFn (ModelBase model, function fn, object caller)
callModelFn (Object option)
Object clone (Object value)
Boolean confirm (String text)
void deleteCookie (String name, String path)
void disableTouchMove (Element e)
void enableTouchMove (Element e)
String getCookie (String name)
String getHost ()
String getHref ()
ModelBase getModel (Element element)
String getPathname ()
String getSearch ()
void hint (String text, JSON options)
object iif (boolean condition, object trueValue, object falseValue)
Boolean isArray (Object value)
Boolean isBoolean (Object value)
Boolean isFunction (Object value)
Boolean isObject (Object value)
Boolean isString (Object value)
Array keys (JSON json)
Boolean testEmail (String value)
Boolean testInteger (String value)
Boolean testLength (String value, Integer min, Integer max)
Boolean testMobile (String value)
Boolean testNumber (String value)
Object toArray (Object iterable, Integer start, Integer end)
String toExprString (String dataType, Object value, Boolean isKSQL)
String toUrl (String url)

Constructor details Top

public Util ()

Util工具类

Static Methods Detail Top

static public void addCookie (String name, String value, String path, Integer expiresHours)

添加cookie

Parameters

String name

名称

String value

String path

路径

Integer expiresHours

有效期 单位为小时,不设置为session有效

Return Value

void

static public Object apply (Object object, Object config, Object defaults)

Parameters

Object object
Object config
Object defaults

Return Value

Object

static public function bindModelFn (ModelBase model, function fn, object caller)

返回和model关联的function

Parameters

ModelBase model

绑定的model

function fn

函数

object caller

执行函数的caller

Return Value

function

下函数执行后的返回

static public callModelFn (Object option)

执行model下的函数

  
    在html节点上绑定事件调用model的函数doClick,doClick接收参数event
    var html = "<button onclick='justep.Util.callModelFn({domNode:event.target||event.srcElement,\"doClick\"},event)'>"
    ...
   	

Parameters

Object option

执行函数相关参数
option参数格式:

{ fn: {string} 函数名, context: {bindingContext} 绑定上下文, domNode: {dom} html节点 } context、domNode只需要给出一个,同时给出时context有效

Return Value

model下函数执行后的返回

static public Object clone (Object value)

对象克隆

Parameters

Object value

Return Value

Object

static public Boolean confirm (String text)

询问提示框

Parameters

String text

显示的文本

Return Value

Boolean

static public void deleteCookie (String name, String path)

删除cookie

Parameters

String name

名称

String path

路径

Return Value

void

static public void disableTouchMove (Element e)

取消节点上的触摸功能

Parameters

Element e

Return Value

void

static public void enableTouchMove (Element e)

开启节点上的触摸功能

Parameters

Element e

Return Value

void

static public String getCookie (String name)

获取cookie

Parameters

String name

名称

Return Value

String

static public String getHost ()

获取当前完整域名和端口

Return Value

String

static public String getHref ()

获取当前完整URL

Return Value

String

static public ModelBase getModel (Element element)

根据dom node返回相应的Model实例

Parameters

Element element

DOM节点

Return Value

ModelBase

static public String getPathname ()

获取当前除域名以外的路径

Return Value

String

static public String getSearch ()

获取当前除域名?后部分

Return Value

String

static public void hint (String text, JSON options)

消息提醒

Parameters

String text

显示的文本

JSON options

选项
结构如下:

{ "type: {string} 提示类型,取值范围:info、success、warning、danger,缺省:info "delay" : {integer} 自动关闭时间,单位为:毫秒,缺省:3000 "parent": {DomNode} 父容器,缺省:body,使用jquery selector来设置或jquery对象,如"#abc" ".abc" "position": {string} 显示位置,取值范围:top、middle、bottom,缺省:top "style": {string} css样式,增加的自定义样式 }

Return Value

void

static public object iif (boolean condition, object trueValue, object falseValue)

条件判断

Parameters

boolean condition

条件

object trueValue

满足条件时返回值

object falseValue

不满足条件时返回值

Return Value

object

static public Boolean isArray (Object value)

判断值的类型是否是Array类型

Parameters

Object value

Return Value

Boolean

static public Boolean isBoolean (Object value)

判断值的类型是否是Boolean类型

Parameters

Object value

Return Value

Boolean

static public Boolean isFunction (Object value)

判断是否是函数

Parameters

Object value

Return Value

Boolean

static public Boolean isObject (Object value)

判断值的类型是否是Object类型

Parameters

Object value

Return Value

Boolean

static public Boolean isString (Object value)

判断值的类型是否是String类型

Parameters

Object value

Return Value

Boolean

static public Array keys (JSON json)

获取键组

Parameters

JSON json

json结构数据

Return Value

Array

static public Boolean testEmail (String value)

检查格式是否为Email

Parameters

String value

Return Value

Boolean

static public Boolean testInteger (String value)

检查格式是否为整数

Parameters

String value

Return Value

Boolean

static public Boolean testLength (String value, Integer min, Integer max)

字符长度是否在指定范围

Parameters

String value
Integer min

最小长度 为-1时表示不限制

Integer max

最大长度 为-1时表示不限制

Return Value

Boolean

static public Boolean testMobile (String value)

检查格式是否为手机号码

Parameters

String value

Return Value

Boolean

static public Boolean testNumber (String value)

检查格式是否为数值

Parameters

String value

Return Value

Boolean

static public Object toArray (Object iterable, Integer start, Integer end)

转换成数组

Parameters

Object iterable
Integer start
Integer end

Return Value

Object

数组

static public String toExprString (String dataType, Object value, Boolean isKSQL)

转换成表达式

Parameters

String dataType

类型

Object value

Boolean isKSQL

是否使用在KSQL中

Return Value

String

static public String toUrl (String url)

转换$UI开头的url

Parameters

String url

$UI开头的url

Return Value

String