Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
知鸟1号
AdminLTE
提交
51142e7f
A
AdminLTE
项目概览
知鸟1号
/
AdminLTE
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AdminLTE
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
51142e7f
编写于
2月 25, 2017
作者:
A
Abdullah Almsaeed
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add BoxRefresh plugin
上级
28c75ef8
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
119 addition
and
0 deletion
+119
-0
build/js/BoxRefresh.js
build/js/BoxRefresh.js
+119
-0
未找到文件。
build/js/BoxRefresh.js
0 → 100644
浏览文件 @
51142e7f
/* BoxRefresh()
* =========
* Adds AJAX content control to a box.
*
* @Usage: $('#my-box').boxRefresh(options)
* or add [data-widget="box-refresh"] to the box element
* Pass any option as data-option="value"
*/
+
function
(
$
)
{
'
use strict
'
var
DataKey
=
'
lte.boxrefresh
'
var
Default
=
{
source
:
''
,
params
:
{},
trigger
:
'
.refresh-btn
'
,
content
:
'
.box-body
'
,
loadInContent
:
true
,
responseType
:
''
,
overlayTemplate
:
'
<div class="overlay"><div class="fa fa-refresh fa-spin"></div></div>
'
,
onLoadStart
:
function
()
{
},
onLoadDone
:
function
(
response
)
{
return
response
}
}
var
Selector
=
{
data
:
'
[data-widget="box-refresh"]
'
}
// BoxRefresh Class Definition
// =========================
var
BoxRefresh
=
function
(
element
,
options
)
{
this
.
element
=
element
this
.
options
=
options
this
.
$overlay
=
$
(
options
.
overlay
)
if
(
options
.
source
===
''
)
{
throw
new
Error
(
'
Source url was not defined. Please specify a url in your BoxRefresh source option.
'
)
}
this
.
_setUpListeners
()
this
.
load
()
}
BoxRefresh
.
prototype
.
load
=
function
()
{
this
.
_addOverlay
()
this
.
options
.
onLoadStart
.
call
(
$
(
this
))
$
.
get
(
this
.
options
.
source
,
this
.
options
.
params
,
function
(
response
)
{
if
(
this
.
options
.
loadInContent
)
{
$
(
this
.
options
.
content
).
html
(
response
)
}
this
.
options
.
onLoadDone
.
call
(
$
(
this
),
response
)
this
.
_removeOverlay
()
}.
bind
(
this
),
this
.
options
.
responseType
!==
''
&&
this
.
options
.
responseType
)
}
// Private
BoxRefresh
.
prototype
.
_setUpListeners
=
function
()
{
$
(
this
.
element
).
on
(
'
click
'
,
Selector
.
trigger
,
function
(
event
)
{
if
(
event
)
event
.
preventDefault
()
this
.
load
()
}.
bind
(
this
))
}
BoxRefresh
.
prototype
.
_addOverlay
=
function
()
{
$
(
this
.
element
).
append
(
this
.
$overlay
)
}
BoxRefresh
.
prototype
.
_removeOverlay
=
function
()
{
$
(
this
.
element
).
remove
(
this
.
$overlay
)
}
// Plugin Definition
// =================
function
Plugin
(
option
)
{
return
this
.
each
(
function
()
{
var
$this
=
$
(
this
)
var
data
=
$this
.
data
(
DataKey
)
if
(
!
data
)
{
var
options
=
$
.
extend
({},
Default
,
$this
.
data
(),
typeof
option
==
'
object
'
&&
option
)
$this
.
data
(
DataKey
,
(
data
=
new
BoxRefresh
(
$this
,
options
)))
}
if
(
typeof
data
==
'
string
'
)
{
if
(
typeof
data
[
option
]
==
'
undefined
'
)
{
throw
new
Error
(
'
No method named
'
+
option
)
}
data
[
option
]()
}
})
}
var
old
=
$
.
fn
.
boxRefresh
$
.
fn
.
boxRefresh
=
Plugin
$
.
fn
.
boxRefresh
.
Constructor
=
BoxRefresh
// No Conflict Mode
// ================
$
.
fn
.
boxRefresh
.
noConflict
=
function
()
{
$
.
fn
.
boxRefresh
=
old
return
this
}
// BoxRefresh Data API
// =================
$
(
window
).
on
(
'
load
'
,
function
()
{
$
(
Selector
.
data
).
each
(
function
()
{
Plugin
.
call
(
$
(
this
))
})
})
}(
jQuery
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录