Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
bd84d954
Commit
bd84d954
authored
Jun 12, 2014
by
Romain Courteaud
Committed by
Jérome Perrin
Aug 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Listfield gadget
parent
a00b5547
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
dream/platform/src2/list_field/index.html
dream/platform/src2/list_field/index.html
+27
-0
dream/platform/src2/list_field/listfield.js
dream/platform/src2/list_field/listfield.js
+49
-0
No files found.
dream/platform/src2/list_field/index.html
0 → 100644
View file @
bd84d954
<!DOCTYPE html>
<html>
<head>
<meta
http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no"
/>
<title>
Listfield
</title>
<!-- renderjs -->
<script
src=
"../<%= copy.rsvp.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"../<%= copy.renderjs.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"../<%= copy.handlebars.relative_dest %>"
type=
"text/javascript"
></script>
<!-- custom script -->
<script
src=
"listfield.js"
type=
"text/javascript"
></script>
<script
id=
"option-template"
type=
"text/x-handlebars-template"
>
<
option
value
=
"
{{value}}
"
>
{{
text
}}
<
/option
>
</script>
<script
id=
"selected-option-template"
type=
"text/x-handlebars-template"
>
<
option
selected
=
"
selected
"
value
=
"
{{value}}
"
>
{{
text
}}
<
/option
>
</script>
</head>
<body>
<select
/>
</body>
</html>
dream/platform/src2/list_field/listfield.js
0 → 100644
View file @
bd84d954
/*global window, rJS, console, RSVP, Handlebars */
/*jslint nomen: true */
(
function
(
window
,
rJS
,
console
,
RSVP
,
Handlebars
)
{
"
use strict
"
;
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var
gadget_klass
=
rJS
(
window
),
option_source
=
gadget_klass
.
__template_element
.
getElementById
(
"
option-template
"
)
.
innerHTML
,
option_template
=
Handlebars
.
compile
(
option_source
),
selected_option_source
=
gadget_klass
.
__template_element
.
getElementById
(
"
option-template
"
)
.
innerHTML
,
selected_option_template
=
Handlebars
.
compile
(
selected_option_source
);
gadget_klass
.
ready
(
function
(
g
)
{
return
g
.
getElement
()
.
push
(
function
(
element
)
{
g
.
element
=
element
;
});
})
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
select
=
this
.
element
.
getElementsByTagName
(
'
select
'
)[
0
],
i
,
template
,
field_json
=
options
.
field_json
,
tmp
=
''
;
select
.
setAttribute
(
'
name
'
,
field_json
.
key
);
for
(
i
=
0
;
i
<
field_json
.
items
.
length
;
i
+=
1
)
{
if
(
field_json
.
items
[
i
][
1
]
===
field_json
.
default
[
0
])
{
template
=
selected_option_template
;
}
else
{
template
=
option_template
;
}
tmp
+=
template
({
value
:
field_json
.
items
[
i
][
1
],
text
:
field_json
.
items
[
i
][
0
]
});
}
select
.
innerHTML
+=
tmp
;
});
}(
window
,
rJS
,
console
,
RSVP
,
Handlebars
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment