JC.common Class
JC 组件通用静态方法和属性 ( JC.common, 别名: JC.f )
所有 JC 组件都会依赖这个静态类
require: jQuery
Item Index
Methods
- addUrlParams static
- arrayId static
- cloneDate static
- cloneObject static
- dateDetect static
- dateFormat static
- delUrlParam static
- delUrlParams static
- docSize static
- easyEffect static
- encoder static
- extendObject static
- filterXSS static
- formatISODate static
- funcName static
- getJqParent static
- getUrlParam static
- getUrlParams static
- hasUrlParam static
- httpRequire static
- isSameDay static
- isSameMonth static
- isSameSeason static
- isSameWeek static
- isSameYear static
- jcAutoInitComps static
- maxDayOfMonth static
- moneyFormat static
- mousewheelEvent static
- padChar static
- parentSelector static
- parseBool static
- parseDate static
- parseFinance static
- parseISODate static
- printf static
- printKey static
- pureDate
- relativePath static
- reloadPage static
- removeUrlSharp static
- safeTimeout static
- scriptContent static
- scriptPath static
- seasonOfYear static
- sliceArgs static
- urlDetect static
- urlHostName static
- weekOfYear static
- winSize static
Properties
- ZINDEX_COUNT static
Methods
addUrlParams
-
_url
-
_params
添加URL参数
require: delUrlParam, filterXSS
Returns:
string
Example:
var url = addUrlParams( location.href, {'key1': 'key1value', 'key2': 'key2value' } );
dateDetect
-
_dateStr
日期占位符识别功能
Parameters:
-
_dateStr
String如果起始字符为 NOW, 那么将视为当前日期 , 如果起始字符为 NOWFirst, 那么将视为当前月的1号
Returns:
Example:
dateDetect( 'now' ); //2014-10-02
dateDetect( 'now,3d' ); //2013-10-05
dateDetect( 'now,-3d' ); //2013-09-29
dateDetect( 'now,2w' ); //2013-10-16
dateDetect( 'now,-2m' ); //2013-08-02
dateDetect( 'now,4y' ); //2017-10-02
dateDetect( 'now,1d,1w,1m,1y' ); //2014-11-10
dateFormat
-
_date
-
_format
日期格式化 (具体格式请查看 PHP Date Formats)
Returns:
string
delUrlParam
-
_url
-
_key
删除URL参数
require: filterXSS
Returns:
string
Example:
var url = delUrlParam( location.href, 'tag' );
delUrlParams
-
_url
-
_keys
批量删除URL参数
require: delUrlParam
Returns:
string
Example:
var url = delUrlParam( location.href, [ 'k1', 'k2' ] );
docSize
-
_doc
获取 document 的 相关大小
Parameters:
-
_doc
Document
Returns:
Object
easyEffect
-
_cb
-
_maxVal
-
_startVal
-
_duration
-
_stepMs
缓动函数, 动画效果为按时间缓动
这个函数只考虑递增, 你如果需要递减的话, 在回调里用 _maxVal - _stepval
Parameters:
Returns:
interval
Example:
$(document).ready(function(){
window.js_output = $('span.js_output');
window.ls = [];
window.EFF_INTERVAL = easyEffect( effectcallback, 100);
});
function effectcallback( _stepval, _done ){
js_output.html( _stepval );
ls.push( _stepval );
!_done && js_output.html( _stepval );
_done && js_output.html( _stepval + '<br />' + ls.join() );
}
encoder
-
_selector
URL 请求时, 获取对URL参数进行编码的函数
Parameters:
-
_selector
Selector
Returns:
default encodeURIComponent
extendObject
-
_source
-
_new
-
_overwrite
扩展对象属性
Returns:
object
formatISODate
-
_date
-
_split
格式化日期为 YYYY-mm-dd 格式
require: pad_char_f
Returns:
string
getJqParent
-
_selector
-
_filter
获取 selector 的指定父级标签
Parameters:
-
_selector
Selector -
_filter
Selector
Returns:
selector
getUrlParam
-
_url
-
_key
取URL参数的值
require: filterXSS
Returns:
string
Example:
var defaultTag = getUrlParam(location.href, 'tag');
getUrlParams
-
_url
-
_key
取URL参数的值, 这个方法返回数组
与 getUrlParam 的区别是可以获取 checkbox 的所有值
require: filterXSS
Returns:
Array
Example:
var params = getUrlParams(location.href, 'tag');
hasUrlParam
-
_url
-
_key
判断URL中是否有某个get参数
Returns:
bool
Example:
var bool = hasUrlParam( 'getkey' );
httpRequire
-
_msg
提示需要 HTTP 环境
Parameters:
-
_msg
String要提示的文字, 默认 "本示例需要HTTP环境'
Returns:
bool 如果是HTTP环境返回true, 否则返回false
isSameDay
-
_d1
-
_d2
判断两个日期是否为同一天
Returns:
isSameMonth
-
_d1
-
_d2
判断两个日期是否为同一月份
Returns:
isSameSeason
-
_d1
-
_d2
判断两个日期是否为同一季度
Returns:
isSameWeek
-
_d1
-
_d2
判断两个日期是否为同一季度
Returns:
isSameYear
-
_d1
-
_d2
判断两个日期是否为同一年
Returns:
jcAutoInitComps
-
_selector
动态添加内容时, 初始化可识别的组件
- 目前会自动识别的组件
-
Bizs.CommonModify, JC.Panel, JC.Dialog
自动识别的组件不用显式调用 jcAutoInitComps 去识别可识别的组件 - 可识别的组件
-
JC.AutoSelect, JC.AutoChecked, JC.AjaxUpload, JC.Calendar
, JC.Drag, JC.DCalendar, JC.Placeholder, JC.TableFreeze, JC.ImageCutter
Bizs.DisableLogic, Bizs.FormLogic, Bizs.MoneyTips, Bizs.AutoSelectComplete
Parameters:
-
_selector
Selector
moneyFormat
-
_number
-
_len
-
_floatLen
-
_splitSymbol
逗号格式化金额
Parameters:
-
_number
Int | String -
_len
Int -
_floatLen
Int -
_splitSymbol
Int
Returns:
string
mousewheelEvent
-
_cb
-
_detach
-
_selector,
绑定或清除 mousewheel 事件
Parameters:
-
_cb
Function -
_detach
Bool -
_selector,
Selectordefault = document
padChar
-
_str
-
_len
-
_char
js 附加字串函数
Returns:
string
parentSelector
-
_item
-
_selector
-
_finder
扩展 jquery 选择器
扩展起始字符的 '/' 符号为 jquery 父节点选择器
扩展起始字符的 '|' 符号为 jquery 子节点选择器
扩展起始字符的 '(' 符号为 jquery 父节点查找识别符( getJqParent )
Parameters:
-
_item
Selector -
_selector
String -
_finder
Selector
Returns:
selector
parseBool
-
_input
把输入值转换为布尔值
Parameters:
-
_input
Returns:
bool
parseDate
-
_date
-
_selector
-
_forceISO
从日期字符串解析日期对象
兼容 JC.Calendar 日期格式
Parameters:
Returns:
parseFinance
-
_i
-
_dot,
取小数点的N位
JS 解析 浮点数的时候,经常出现各种不可预知情况,这个函数就是为了解决这个问题
Parameters:
-
_i
Number -
_dot,
Intdefault = 2
Returns:
number
printf
-
_str
按格式输出字符串
Parameters:
-
_str
String
Returns:
string
Example:
printf( 'asdfasdf{0}sdfasdf{1}', '000', 1111 );
//return asdfasdf000sdfasdf1111
printKey
-
_str
-
_keys
按格式输出字符串
Returns:
string
Example:
JC.f.printKey( 'asdfasdf{key1}sdfasdf{key2},{0}', { 'key1': '000', 'key2': 1111, '0': 222 );
//return asdfasdf000sdfasdf1111,222
relativePath
-
_path
-
_url
把 URL 相对路径 转换为 绝对路径
Returns:
string
reloadPage
-
_url
-
_nornd
-
_delayms
重载页面
require: removeUrlSharp, addUrlParams, filterXSS
Parameters:
-
_url
String -
_nornd
Bool -
_delayms
Int
removeUrlSharp
-
_url
-
_nornd
-
_rndName
删除 URL 的锚点
require: addUrlParams, filterXSS
Returns:
string
safeTimeout
-
_timeout
-
_obj
-
_name
-
_ms
timeout 控制逻辑, 避免相同功能的 setTimeout 重复执行
Parameters:
Returns:
object
scriptContent
-
_selector
获取脚本模板的内容
Parameters:
-
_selector
Selector
Returns:
string
seasonOfYear
-
_year
取一年中所有的季度, 及其开始结束日期
Parameters:
-
_year
Int
Returns:
Array
sliceArgs
-
args
把函数的参数转为数组
Parameters:
-
args
Arguments
Returns:
Array
urlDetect
-
_url
URL 占位符识别功能
require: addUrlParams, filterXSS
Parameters:
-
_url
String如果 起始字符为 URL, 那么 URL 将祝为本页的URL
Returns:
string
Example:
urlDetect( '?test' ); //output: ?test
urlDetect( 'URL,a=1&b=2' ); //output: your.com?a=1&b=2
urlDetect( 'URL,a=1,b=2' ); //output: your.com?a=1&b=2
urlDetect( 'URLa=1&b=2' ); //output: your.com?a=1&b=2
weekOfYear
-
_year
-
_dayOffset
取一年中所有的星期, 及其开始结束日期
Parameters:
-
_year
Int -
_dayOffset
Int每周的默认开始为周几, 默认0(周一)
Returns:
Array
winSize
-
_win,
获取 window 的 相关大小
Parameters:
-
_win,
Windowdefault = window
Returns:
Object
Properties
ZINDEX_COUNT
Int
static
全局 css z-index 控制属性
注意: 这个变量是 window.ZINDEX_COUNT
Default: 50001