Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
77721978
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
77721978
编写于
2月 05, 2016
作者:
T
tfennelly
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactoring to extract the model parts into the modules in the model folder
上级
5d011731
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
206 addition
and
195 deletion
+206
-195
war/src/main/js/config-tabbar.js
war/src/main/js/config-tabbar.js
+11
-10
war/src/main/js/widgets/config/model/ConfigRowSet.js
war/src/main/js/widgets/config/model/ConfigRowSet.js
+30
-0
war/src/main/js/widgets/config/model/ConfigSection.js
war/src/main/js/widgets/config/model/ConfigSection.js
+149
-0
war/src/main/js/widgets/config/model/ConfigTableMetaData.js
war/src/main/js/widgets/config/model/ConfigTableMetaData.js
+8
-182
war/src/main/js/widgets/config/model/util.js
war/src/main/js/widgets/config/model/util.js
+5
-0
war/src/main/js/widgets/config/tabbar.js
war/src/main/js/widgets/config/tabbar.js
+3
-3
未找到文件。
war/src/main/js/config-tabbar.js
浏览文件 @
77721978
var
$
=
require
(
'
jquery-detached
'
).
getJQuery
();
var
localStorage
=
require
(
'
./util/jenkinsLocalStorage.js
'
);
var
jenkinsLocalStorage
=
require
(
'
./util/jenkinsLocalStorage.js
'
);
var
configMetadata
=
require
(
'
./widgets/config/model/ConfigTableMetaData.js
'
);
$
(
function
()
{
// Horrible ugly hack...
...
...
@@ -16,7 +17,7 @@ $(function() {
var
configTables
=
$
(
'
.job-config.tabbed
'
);
if
(
configTables
.
size
()
>
0
)
{
var
tabBarShowPreferenceKey
=
'
config:usetabs
'
;
var
tabBarShowPreference
=
l
ocalStorage
.
getGlobalItem
(
tabBarShowPreferenceKey
,
"
yes
"
);
var
tabBarShowPreference
=
jenkinsL
ocalStorage
.
getGlobalItem
(
tabBarShowPreferenceKey
,
"
yes
"
);
var
tabBarWidget
=
require
(
'
./widgets/config/tabbar.js
'
);
if
(
tabBarShowPreference
===
"
yes
"
)
{
...
...
@@ -30,7 +31,7 @@ $(function() {
fireBottomStickerAdjustEvent
();
});
tabBar
.
deactivator
.
click
(
function
()
{
l
ocalStorage
.
setGlobalItem
(
tabBarShowPreferenceKey
,
"
no
"
);
jenkinsL
ocalStorage
.
setGlobalItem
(
tabBarShowPreferenceKey
,
"
no
"
);
require
(
'
window-handle
'
).
getWindow
().
location
.
reload
();
});
$
(
'
.jenkins-config-widgets .find-container input
'
).
focus
(
function
()
{
...
...
@@ -39,9 +40,9 @@ $(function() {
if
(
tabBar
.
hasSections
())
{
var
tabBarLastSectionKey
=
'
config:
'
+
tabBar
.
configForm
.
attr
(
'
name
'
)
+
'
:last-tab
'
;
var
tabBarLastSection
=
l
ocalStorage
.
getPageItem
(
tabBarLastSectionKey
,
tabBar
.
sections
[
0
].
id
);
var
tabBarLastSection
=
jenkinsL
ocalStorage
.
getPageItem
(
tabBarLastSectionKey
,
tabBar
.
sections
[
0
].
id
);
tabBar
.
onShowSection
(
function
()
{
l
ocalStorage
.
setPageItem
(
tabBarLastSectionKey
,
this
.
id
);
jenkinsL
ocalStorage
.
setPageItem
(
tabBarLastSectionKey
,
this
.
id
);
});
tabBar
.
showSection
(
tabBarLastSection
);
}
...
...
@@ -50,9 +51,9 @@ $(function() {
configTables
.
each
(
function
()
{
var
configTable
=
$
(
this
);
var
activator
=
tabBarWidget
.
addTabsActivator
(
configTable
);
require
(
'
./widgets/config/table-metadata.js
'
).
markConfig
Form
(
configTable
);
configMetadata
.
markConfigTableParent
Form
(
configTable
);
activator
.
click
(
function
()
{
l
ocalStorage
.
setGlobalItem
(
tabBarShowPreferenceKey
,
"
yes
"
);
jenkinsL
ocalStorage
.
setGlobalItem
(
tabBarShowPreferenceKey
,
"
yes
"
);
require
(
'
window-handle
'
).
getWindow
().
location
.
reload
();
});
});
...
...
@@ -70,15 +71,15 @@ function addFinderToggle(configTableMetadata) {
var
findContainer
=
$
(
'
.find-container
'
,
configTableMetadata
.
configWidgets
);
if
(
findContainer
.
hasClass
(
'
visible
'
))
{
findContainer
.
removeClass
(
'
visible
'
);
localStorage
.
setGlobalItem
(
finderShowPreferenceKey
,
"
no
"
)
jenkinsLocalStorage
.
setGlobalItem
(
finderShowPreferenceKey
,
"
no
"
);
}
else
{
findContainer
.
addClass
(
'
visible
'
);
$
(
'
input
'
,
findContainer
).
focus
();
localStorage
.
setGlobalItem
(
finderShowPreferenceKey
,
"
yes
"
)
jenkinsLocalStorage
.
setGlobalItem
(
finderShowPreferenceKey
,
"
yes
"
);
}
});
if
(
l
ocalStorage
.
getGlobalItem
(
finderShowPreferenceKey
,
"
yes
"
)
===
'
yes
'
)
{
if
(
jenkinsL
ocalStorage
.
getGlobalItem
(
finderShowPreferenceKey
,
"
yes
"
)
===
'
yes
'
)
{
findToggle
.
click
();
}
}
...
...
war/src/main/js/widgets/config/model/ConfigRowSet.js
0 → 100644
浏览文件 @
77721978
var
jQD
=
require
(
'
../../../util/jquery-ext.js
'
);
module
.
exports
=
ConfigRowSet
;
/*
* =======================================================================================
* Configuration table section.
* =======================================================================================
*/
function
ConfigRowSet
(
startRow
)
{
this
.
startRow
=
startRow
;
this
.
rows
=
[];
this
.
endRow
=
undefined
;
this
.
toggleWidget
=
undefined
;
this
.
label
=
undefined
;
}
/*
* Find the row-set toggle widget i.e. the input element that indicates that
* the row-set rows should be made visible or not.
*/
ConfigRowSet
.
prototype
.
findToggleWidget
=
function
(
row
)
{
var
$
=
jQD
.
getJQuery
();
var
input
=
$
(
'
:input.block-control
'
,
row
);
if
(
input
.
size
()
===
1
)
{
this
.
toggleWidget
=
input
;
this
.
label
=
input
.
parent
().
find
(
'
label
'
).
text
();
input
.
addClass
(
'
disable-behavior
'
);
}
};
war/src/main/js/widgets/config/model/ConfigSection.js
0 → 100644
浏览文件 @
77721978
var
jQD
=
require
(
'
../../../util/jquery-ext.js
'
);
var
util
=
require
(
'
./util.js
'
);
var
ConfigRowSet
=
require
(
'
./ConfigRowSet.js
'
);
module
.
exports
=
ConfigSection
;
/*
* =======================================================================================
* Configuration table section.
* =======================================================================================
*/
function
ConfigSection
(
parentCMD
,
title
)
{
this
.
parentCMD
=
parentCMD
;
this
.
title
=
title
;
this
.
id
=
util
.
toId
(
title
);
this
.
rows
=
[];
this
.
rowSets
=
undefined
;
this
.
activator
=
undefined
;
}
/*
* Set the element (jquery) that activates the section (on click).
*/
ConfigSection
.
prototype
.
setActivator
=
function
(
activator
)
{
this
.
activator
=
activator
;
var
section
=
this
;
section
.
activator
.
click
(
function
()
{
section
.
parentCMD
.
showSection
(
section
);
});
};
ConfigSection
.
prototype
.
activate
=
function
()
{
if
(
this
.
activator
)
{
this
.
activator
.
click
();
}
else
{
console
.
warn
(
'
No activator attached to config section object.
'
);
}
};
ConfigSection
.
prototype
.
activeRowCount
=
function
()
{
var
activeRowCount
=
0
;
for
(
var
i
=
0
;
i
<
this
.
rows
.
length
;
i
++
)
{
if
(
this
.
rows
[
i
].
hasClass
(
'
active
'
))
{
activeRowCount
++
;
}
}
return
activeRowCount
;
};
ConfigSection
.
prototype
.
updateRowSetVisibility
=
function
()
{
if
(
this
.
rowSets
===
undefined
)
{
// Lazily gather rowset information.
this
.
gatherRowSets
();
}
for
(
var
i
=
0
;
i
<
this
.
rowSets
.
length
;
i
++
)
{
var
rowSet
=
this
.
rowSets
[
i
];
if
(
rowSet
.
toggleWidget
!==
undefined
)
{
var
isChecked
=
rowSet
.
toggleWidget
.
is
(
'
:checked
'
);
for
(
var
ii
=
0
;
ii
<
rowSet
.
rows
.
length
;
ii
++
)
{
if
(
isChecked
)
{
rowSet
.
rows
[
ii
].
show
();
}
else
{
rowSet
.
rows
[
ii
].
hide
();
}
}
}
}
};
ConfigSection
.
prototype
.
gatherRowSets
=
function
()
{
this
.
rowSets
=
[];
// Only tracking row-sets that are bounded by 'row-set-start' and 'row-set-end' (for now).
// Also, only capturing the rows after the 'block-control' input (checkbox, radio etc)
// and before the 'row-set-end'.
// TODO: Find out how these actually work. It seems like they can be nested into a hierarchy :(
// Also seems like you can have these "optional-block" thingies which are not wrapped
// in 'row-set-start' etc. Grrrrrr :(
var
curRowSet
=
undefined
;
// jshint ignore:line
for
(
var
i
=
0
;
i
<
this
.
rows
.
length
;
i
++
)
{
var
row
=
this
.
rows
[
i
];
if
(
row
.
hasClass
(
'
row-set-start
'
))
{
curRowSet
=
new
ConfigRowSet
(
row
);
curRowSet
.
findToggleWidget
(
row
);
}
else
if
(
curRowSet
!==
undefined
)
{
if
(
row
.
hasClass
(
'
row-set-end
'
))
{
curRowSet
.
endRow
=
row
;
// Only capture the row-set if we find a 'row-set-end'.
// Yeah, this does not handle hierarchical stuff (see above TO-DO).
this
.
rowSets
.
push
(
curRowSet
);
curRowSet
=
undefined
;
}
else
if
(
curRowSet
.
toggleWidget
===
undefined
)
{
curRowSet
.
findToggleWidget
(
row
);
}
else
{
// we have the toggleWidget, which means that this row is
// one of the rows after that row and is one of the rows that's
// subject to being made visible/hidden when the input is
// checked or unchecked.
curRowSet
.
rows
.
push
(
row
);
}
}
}
};
ConfigSection
.
prototype
.
getRowSetLabels
=
function
()
{
var
labels
=
[];
for
(
var
i
=
0
;
i
<
this
.
rowSets
.
length
;
i
++
)
{
var
rowSet
=
this
.
rowSets
[
i
];
if
(
rowSet
.
label
)
{
labels
.
push
(
rowSet
.
label
);
}
}
return
labels
;
};
ConfigSection
.
prototype
.
highlightText
=
function
(
text
)
{
var
$
=
jQD
.
getJQuery
();
var
selector
=
"
:containsci('
"
+
text
+
"
')
"
;
for
(
var
i
=
0
;
i
<
this
.
rows
.
length
;
i
++
)
{
var
row
=
this
.
rows
[
i
];
/*jshint loopfunc: true */
$
(
'
span.highlight-split
'
,
row
).
each
(
function
()
{
// jshint ignore:line
var
highlightSplit
=
$
(
this
);
highlightSplit
.
before
(
highlightSplit
.
text
());
highlightSplit
.
remove
();
});
if
(
text
!==
''
)
{
var
regex
=
new
RegExp
(
'
(
'
+
text
+
'
)
'
,
"
gi
"
);
/*jshint loopfunc: true */
$
(
selector
,
row
).
find
(
'
:not(:input)
'
).
each
(
function
()
{
var
$this
=
$
(
this
);
$this
.
contents
().
each
(
function
()
{
// We specifically only mess with text nodes
if
(
this
.
nodeType
===
3
)
{
var
highlightedMarkup
=
this
.
wholeText
.
replace
(
regex
,
'
<span class="highlight">$1</span>
'
);
$
(
this
).
replaceWith
(
'
<span class="highlight-split">
'
+
highlightedMarkup
+
'
</span>
'
);
}
});
});
}
}
};
war/src/main/js/widgets/config/
table-metad
ata.js
→
war/src/main/js/widgets/config/
model/ConfigTableMetaD
ata.js
浏览文件 @
77721978
...
...
@@ -2,9 +2,11 @@
* Internal support module for config tables.
*/
var
jQD
=
require
(
'
../../util/jquery-ext.js
'
);
var
jQD
=
require
(
'
../../../util/jquery-ext.js
'
);
var
ConfigSection
=
require
(
'
./ConfigSection.js
'
);
var
util
=
require
(
'
./util.js
'
);
exports
.
markConfigForm
=
function
(
configTable
)
{
exports
.
markConfig
TableParent
Form
=
function
(
configTable
)
{
var
form
=
configTable
.
closest
(
'
form
'
);
form
.
addClass
(
'
jenkins-config
'
);
return
form
;
...
...
@@ -17,10 +19,10 @@ exports.findConfigTables = function() {
return
$
(
'
form[name="config"] > table
'
);
};
exports
.
decorate
ConfigTable
=
function
(
configTable
)
{
exports
.
from
ConfigTable
=
function
(
configTable
)
{
var
$
=
jQD
.
getJQuery
();
var
sectionHeaders
=
$
(
'
.section-header
'
,
configTable
);
var
configForm
=
exports
.
markConfigForm
(
configTable
);
var
configForm
=
exports
.
markConfig
TableParent
Form
(
configTable
);
// Mark the ancestor <tr>s of the section headers and add a title
sectionHeaders
.
each
(
function
()
{
...
...
@@ -46,7 +48,7 @@ exports.decorateConfigTable = function(configTable) {
var
curSection
=
new
ConfigSection
(
configTableMetadata
,
'
General
'
);
configTableMetadata
.
sections
.
push
(
curSection
);
curSection
.
id
=
exports
.
toId
(
curSection
.
title
);
curSection
.
id
=
util
.
toId
(
curSection
.
title
);
topRows
.
each
(
function
()
{
var
tr
=
$
(
this
);
...
...
@@ -63,187 +65,11 @@ exports.decorateConfigTable = function(configTable) {
var
buttonsRow
=
$
(
'
#bottom-sticker
'
,
configTable
).
closest
(
'
tr
'
);
buttonsRow
.
removeClass
(
curSection
.
id
);
buttonsRow
.
addClass
(
exports
.
toId
(
'
buttons
'
));
buttonsRow
.
addClass
(
util
.
toId
(
'
buttons
'
));
return
configTableMetadata
;
};
exports
.
toId
=
function
(
string
)
{
string
=
string
.
trim
();
return
'
config_
'
+
string
.
replace
(
/
[\W
_
]
+/g
,
'
_
'
).
toLowerCase
();
};
/*
* =======================================================================================
* Configuration table section.
* =======================================================================================
*/
function
ConfigSection
(
parentCMD
,
title
)
{
this
.
parentCMD
=
parentCMD
;
this
.
title
=
title
;
this
.
id
=
exports
.
toId
(
title
);
this
.
rows
=
[];
this
.
rowSets
=
undefined
;
this
.
activator
=
undefined
;
}
/*
* Set the element (jquery) that activates the section (on click).
*/
ConfigSection
.
prototype
.
setActivator
=
function
(
activator
)
{
this
.
activator
=
activator
;
var
section
=
this
;
section
.
activator
.
click
(
function
()
{
section
.
parentCMD
.
showSection
(
section
);
});
};
ConfigSection
.
prototype
.
activate
=
function
()
{
if
(
this
.
activator
)
{
this
.
activator
.
click
();
}
else
{
console
.
warn
(
'
No activator attached to config section object.
'
);
}
};
ConfigSection
.
prototype
.
activeRowCount
=
function
()
{
var
activeRowCount
=
0
;
for
(
var
i
=
0
;
i
<
this
.
rows
.
length
;
i
++
)
{
if
(
this
.
rows
[
i
].
hasClass
(
'
active
'
))
{
activeRowCount
++
;
}
}
return
activeRowCount
;
};
ConfigSection
.
prototype
.
updateRowSetVisibility
=
function
()
{
if
(
this
.
rowSets
===
undefined
)
{
// Lazily gather rowset information.
this
.
gatherRowSets
();
}
for
(
var
i
=
0
;
i
<
this
.
rowSets
.
length
;
i
++
)
{
var
rowSet
=
this
.
rowSets
[
i
];
if
(
rowSet
.
toggleWidget
!==
undefined
)
{
var
isChecked
=
rowSet
.
toggleWidget
.
is
(
'
:checked
'
);
for
(
var
ii
=
0
;
ii
<
rowSet
.
rows
.
length
;
ii
++
)
{
if
(
isChecked
)
{
rowSet
.
rows
[
ii
].
show
();
}
else
{
rowSet
.
rows
[
ii
].
hide
();
}
}
}
}
};
ConfigSection
.
prototype
.
gatherRowSets
=
function
()
{
this
.
rowSets
=
[];
// Only tracking row-sets that are bounded by 'row-set-start' and 'row-set-end' (for now).
// Also, only capturing the rows after the 'block-control' input (checkbox, radio etc)
// and before the 'row-set-end'.
// TODO: Find out how these actually work. It seems like they can be nested into a hierarchy :(
// Also seems like you can have these "optional-block" thingies which are not wrapped
// in 'row-set-start' etc. Grrrrrr :(
var
curRowSet
=
undefined
;
// jshint ignore:line
for
(
var
i
=
0
;
i
<
this
.
rows
.
length
;
i
++
)
{
var
row
=
this
.
rows
[
i
];
if
(
row
.
hasClass
(
'
row-set-start
'
))
{
curRowSet
=
new
ConfigRowSet
(
row
);
curRowSet
.
findToggleWidget
(
row
);
}
else
if
(
curRowSet
!==
undefined
)
{
if
(
row
.
hasClass
(
'
row-set-end
'
))
{
curRowSet
.
endRow
=
row
;
// Only capture the row-set if we find a 'row-set-end'.
// Yeah, this does not handle hierarchical stuff (see above TO-DO).
this
.
rowSets
.
push
(
curRowSet
);
curRowSet
=
undefined
;
}
else
if
(
curRowSet
.
toggleWidget
===
undefined
)
{
curRowSet
.
findToggleWidget
(
row
);
}
else
{
// we have the toggleWidget, which means that this row is
// one of the rows after that row and is one of the rows that's
// subject to being made visible/hidden when the input is
// checked or unchecked.
curRowSet
.
rows
.
push
(
row
);
}
}
}
};
ConfigSection
.
prototype
.
getRowSetLabels
=
function
()
{
var
labels
=
[];
for
(
var
i
=
0
;
i
<
this
.
rowSets
.
length
;
i
++
)
{
var
rowSet
=
this
.
rowSets
[
i
];
if
(
rowSet
.
label
)
{
labels
.
push
(
rowSet
.
label
);
}
}
return
labels
;
};
ConfigSection
.
prototype
.
highlightText
=
function
(
text
)
{
var
$
=
jQD
.
getJQuery
();
var
selector
=
"
:containsci('
"
+
text
+
"
')
"
;
for
(
var
i
=
0
;
i
<
this
.
rows
.
length
;
i
++
)
{
var
row
=
this
.
rows
[
i
];
/*jshint loopfunc: true */
$
(
'
span.highlight-split
'
,
row
).
each
(
function
()
{
// jshint ignore:line
var
highlightSplit
=
$
(
this
);
highlightSplit
.
before
(
highlightSplit
.
text
());
highlightSplit
.
remove
();
});
if
(
text
!==
''
)
{
var
regex
=
new
RegExp
(
'
(
'
+
text
+
'
)
'
,
"
gi
"
);
/*jshint loopfunc: true */
$
(
selector
,
row
).
find
(
'
:not(:input)
'
).
each
(
function
()
{
var
$this
=
$
(
this
);
$this
.
contents
().
each
(
function
()
{
// We specifically only mess with text nodes
if
(
this
.
nodeType
===
3
)
{
var
highlightedMarkup
=
this
.
wholeText
.
replace
(
regex
,
'
<span class="highlight">$1</span>
'
);
$
(
this
).
replaceWith
(
'
<span class="highlight-split">
'
+
highlightedMarkup
+
'
</span>
'
);
}
});
});
}
}
};
/*
* =======================================================================================
* Configuration table section.
* =======================================================================================
*/
function
ConfigRowSet
(
startRow
)
{
this
.
startRow
=
startRow
;
this
.
rows
=
[];
this
.
endRow
=
undefined
;
this
.
toggleWidget
=
undefined
;
this
.
label
=
undefined
;
}
/*
* Find the row-set toggle widget i.e. the input element that indicates that
* the row-set rows should be made visible or not.
*/
ConfigRowSet
.
prototype
.
findToggleWidget
=
function
(
row
)
{
var
$
=
jQD
.
getJQuery
();
var
input
=
$
(
'
:input.block-control
'
,
row
);
if
(
input
.
size
()
===
1
)
{
this
.
toggleWidget
=
input
;
this
.
label
=
input
.
parent
().
find
(
'
label
'
).
text
();
input
.
addClass
(
'
disable-behavior
'
);
}
};
/*
* =======================================================================================
* ConfigTable MetaData class.
...
...
war/src/main/js/widgets/config/model/util.js
0 → 100644
浏览文件 @
77721978
exports
.
toId
=
function
(
string
)
{
string
=
string
.
trim
();
return
'
config_
'
+
string
.
replace
(
/
[\W
_
]
+/g
,
'
_
'
).
toLowerCase
();
};
\ No newline at end of file
war/src/main/js/widgets/config/tabbar.js
浏览文件 @
77721978
var
jQD
=
require
(
'
jquery-detached
'
);
var
tableMetadata
=
require
(
'
./
table-metadata
'
);
var
tableMetadata
=
require
(
'
./
model/ConfigTableMetaData.js
'
);
exports
.
addTabsOnFirst
=
function
()
{
return
exports
.
addTabs
(
tableMetadata
.
findConfigTables
().
first
());
...
...
@@ -18,11 +18,11 @@ exports.addTabs = function(configTable) {
if
(
configTableEl
.
size
()
===
0
)
{
throw
"
No config table found using selector '
"
+
configTable
+
"
'
"
;
}
else
{
configTableMetadata
=
tableMetadata
.
decorate
ConfigTable
(
configTableEl
);
configTableMetadata
=
tableMetadata
.
from
ConfigTable
(
configTableEl
);
}
}
else
{
// It's a config <table> element
configTableMetadata
=
tableMetadata
.
decorate
ConfigTable
(
configTable
);
configTableMetadata
=
tableMetadata
.
from
ConfigTable
(
configTable
);
}
var
tabBar
=
$
(
'
<div class="tabBar config-section-activators"></div>
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录