Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vincent Bechu
renderjs
Commits
1a85fb74
Commit
1a85fb74
authored
Feb 01, 2014
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Form Gadget: Add basic form gadget
parent
cb939431
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
132 additions
and
58 deletions
+132
-58
examples/fwi/form.html
examples/fwi/form.html
+23
-0
examples/fwi/form.js
examples/fwi/form.js
+72
-0
examples/fwi/index_list.js
examples/fwi/index_list.js
+1
-1
examples/fwi/io.js
examples/fwi/io.js
+0
-1
examples/fwi/officejs.html
examples/fwi/officejs.html
+3
-6
examples/fwi/officejs.js
examples/fwi/officejs.js
+32
-50
examples/fwi/property.html
examples/fwi/property.html
+1
-0
No files found.
examples/fwi/form.html
0 → 100644
View file @
1a85fb74
<!DOCTYPE html>
<html>
<head>
<title>
Free Web Initiative
</title>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
>
<link
rel=
"stylesheet"
href=
"blog.css"
>
<script
src=
"../../lib/jquery/jquery.js"
type=
"text/javascript"
></script>
<script
src=
"../../node_modules/rsvp/dist/rsvp-2.0.4.js"
type=
"text/javascript"
></script>
<script
src=
"../../dist/renderjs-latest.js"
type=
"text/javascript"
></script>
<script
src=
"form.js"
type=
"text/javascript"
></script>
</head>
<body
style=
"background-color: white; color: black;"
>
<div
class=
"editor_a"
>
<div
data-role=
"fieldcontain"
class=
"editor_a_safe"
>
</div>
<div
data-role=
"fieldcontain"
class=
"property_a_safe"
>
</div>
<div
data-role=
"fieldcontain"
class=
"editor_a"
>
</div>
</div>
</body>
</html>
examples/fwi/form.js
0 → 100644
View file @
1a85fb74
/*jslint indent: 2 */
/*global EventEmitter, RSVP, jIO */
(
function
(
window
,
rJS
,
$
,
RSVP
)
{
/**
* Web site configurations
*/
var
gk
=
rJS
(
window
),
that
,
editor_context
,
property_context
,
current_document
,
editor
,
property
;
gk
.
declareMethod
(
'
setContent
'
,
function
(
value
)
{
current_document
=
value
;
return
RSVP
.
all
([
editor
.
setContent
(
value
.
text_content
),
property
.
setContent
(
value
)
])
})
.
declareMethod
(
'
getContent
'
,
function
()
{
return
RSVP
.
all
([
editor
.
getContent
(),
property
.
getContent
()
])
.
then
(
function
(
result_list
)
{
var
document
=
result_list
[
1
];
document
.
text_content
=
result_list
[
0
];
return
document
;
});
})
.
declareMethod
(
'
setForm
'
,
function
()
{
return
that
.
declareGadget
(
'
./property.html
'
)
.
then
(
function
(
gadget
){
console
.
log
(
'
prepared property
'
);
property
=
gadget
;
console
.
log
(
property
);
property_context
=
$
(
'
.property_a_safe
'
).
last
();
editor_context
=
$
(
'
.editor_a
'
).
last
();
console
.
log
(
'
property:
'
);
console
.
log
(
property
);
property_context
[
0
].
appendChild
(
property
.
element
);
})
.
fail
(
function
(
error
){
console
.
log
(
error
);
})
})
.
declareMethod
(
'
setEditor
'
,
function
(
editor_path
)
{
var
g
=
this
;
editor_context
.
empty
();
return
g
.
declareGadget
(
editor_path
,
{
element
:
editor_context
[
0
],
sandbox
:
'
iframe
'
}
)
.
then
(
function
(
gadget
){
editor
=
gadget
;
$
(
editor
.
element
).
trigger
(
'
create
'
);
if
(
current_document
){
return
editor
.
setContent
(
current_document
.
text_content
);
}
})
;
});
gk
.
ready
(
function
(
g
)
{
console
.
log
(
'
prepare form
'
);
that
=
g
;
});
}(
window
,
rJS
,
jQuery
,
RSVP
));
\ No newline at end of file
examples/fwi/index_list.js
View file @
1a85fb74
...
...
@@ -12,7 +12,7 @@
document
,
index_list_panel
=
$
(
'
#index_list
'
);
for
(
i
=
0
;
i
<
document_list
.
length
;
i
+=
1
)
{
document
=
document_list
[
i
].
doc
;
document
=
$
.
extend
({},
document_list
[
i
].
doc
)
;
index_list_panel
.
append
(
"
<li><a href=#>
"
+
document
.
title
...
...
examples/fwi/io.js
View file @
1a85fb74
...
...
@@ -38,7 +38,6 @@
])
.
then
(
function
(
result_list
)
{
var
document
=
result_list
[
1
];
document
.
_id
=
key
;
document
.
text_content
=
result_list
[
0
];
return
g
.
setIO
(
document
);
});
...
...
examples/fwi/officejs.html
View file @
1a85fb74
...
...
@@ -38,20 +38,17 @@
<div
data-role=
"content"
>
<!-- editor A -->
<div
class=
"editor_a"
>
<div
data-role=
"fieldcontain"
class=
"editor_a_safe"
>
</div>
<div
class=
"form_a"
>
<div
data-role=
"fieldcontain"
class=
"sidebar"
></div>
<div
data-role=
"fieldcontain"
class=
"
property
_a_safe"
>
<div
data-role=
"fieldcontain"
class=
"
form
_a_safe"
>
</div>
<div
data-role=
"fieldcontain"
class=
"
editor
_a"
>
<div
data-role=
"fieldcontain"
class=
"
form
_a"
>
</div>
</div>
<!-- blog A -->
<div
class=
"blog_a"
>
<div
data-role=
"fieldcontain"
class=
"blog_a_safe"
>
</div>
<div
data-role=
"fieldcontain"
class=
"blog_a"
>
</div>
</div>
...
...
examples/fwi/officejs.js
View file @
1a85fb74
...
...
@@ -2,22 +2,19 @@
(
function
(
window
,
$
,
rJS
,
RSVP
)
{
"
use strict
"
;
function
attachIOTo
Editor
(
all_param
)
{
var
editor
=
all_param
[
0
],
function
attachIOTo
Form
(
all_param
,
editor_path
)
{
var
form
=
all_param
[
0
],
io
=
all_param
[
1
],
id
=
all_param
[
2
],
property
=
all_param
[
3
],
index
=
all_param
[
4
],
index
=
all_param
[
2
],
jio_config
=
{
"
type
"
:
"
dropbox
"
,
"
access_token
"
:
"
v43SQLCEoi8AAAAAAAAAAVixCoMfDelgGj3NRPfEnqscAuNGp2LhoS8-GiAaDD4C
"
};
$
(
io
.
element
).
trigger
(
'
create
'
);
$
(
property
.
element
).
trigger
(
'
create
'
);
$
(
editor
.
element
).
trigger
(
'
create
'
);
return
io
.
configureIO
(
jio_config
)
$
(
form
.
element
).
trigger
(
'
create
'
);
return
form
.
setEditor
(
editor_path
)
.
then
(
function
()
{
return
;
return
io
.
configureIO
(
jio_config
)
})
.
then
(
function
()
{
return
io
.
getIOList
().
fail
(
function
(
error
)
{
...
...
@@ -30,16 +27,13 @@
.
then
(
function
(
document_list
)
{
console
.
log
(
document_list
);
return
RSVP
.
all
([
editor
.
setContent
(
document_list
[
0
].
doc
.
text_content
),
property
.
setContent
(
document_list
[
0
].
doc
),
form
.
setContent
(
document_list
[
0
].
doc
),
index
.
setDocumentList
(
document_list
,
editor
,
editor
.
setContent
,
property
,
property
.
setContent
),
form
,
form
.
setContent
,
io
,
io
.
getIO
),
io
.
configureDataSourceCallback
(
editor
,
editor
.
getContent
,
property
,
property
.
getContent
,
document_list
[
0
].
id
)
form
,
form
.
getContent
)
]);
});
}
...
...
@@ -52,12 +46,8 @@
"
type
"
:
"
dropbox
"
,
"
access_token
"
:
"
v43SQLCEoi8AAAAAAAAAAVixCoMfDelgGj3NRPfEnqscAuNGp2LhoS8-GiAaDD4C
"
};
$
(
io
.
element
).
trigger
(
'
create
'
);
$
(
blog
.
element
).
trigger
(
'
create
'
);
return
io
.
configureIO
(
jio_config
)
.
then
(
function
()
{
return
io
.
configureDataSourceCallback
(
blog
,
blog
.
displayHTML
,
'
48c3ca06-78b9-2f4c-80db-d5cb2417de45
'
);
})
.
then
(
function
()
{
return
io
.
getIO
(
'
48c3ca06-78b9-2f4c-80db-d5cb2417de45
'
).
fail
(
function
(
error
)
{
if
(
error
.
status
===
404
)
{
...
...
@@ -84,25 +74,24 @@
throw
rejectedReason
;
}
function
createLoadNewEditorCallback
(
g
,
editor_path
,
e_c
,
io_path
,
i_c
,
property_path
,
p
_c
,
index_path
,
index_c
)
{
function
createLoadNewEditorCallback
(
g
,
form_path
,
f_c
,
editor_path
,
io_path
,
i
_c
,
index_path
,
index_c
)
{
return
function
()
{
e_c
.
empty
();
p_c
.
empty
().
attr
(
"
style
"
,
""
);
f_c
.
empty
();
index_c
.
empty
().
attr
(
"
style
"
,
""
);
$
(
'
.editor_a_safe
'
).
attr
(
"
style
"
,
""
);
return
RSVP
.
all
([
g
.
declareGadget
(
editor_path
,
{
element
:
e_c
[
0
],
sandbox
:
'
iframe
'
}
),
g
.
declareGadget
(
form_path
),
g
.
declareGadget
(
io_path
),
"
officejs
"
,
g
.
declareGadget
(
property_path
),
g
.
declareGadget
(
index_path
)
])
.
then
(
function
(
all_param
)
{
i_c
.
empty
();
f_c
[
0
].
appendChild
(
all_param
[
0
].
element
);
i_c
[
0
].
appendChild
(
all_param
[
1
].
element
);
p_c
[
0
].
appendChild
(
all_param
[
3
].
element
);
index_c
[
0
].
appendChild
(
all_param
[
4
].
element
);
return
attachIOToEditor
(
all_param
);
index_c
[
0
].
appendChild
(
all_param
[
2
].
element
);
return
all_param
[
0
].
setForm
()
.
then
(
function
(){
attachIOToForm
(
all_param
,
editor_path
);
})
})
.
fail
(
handleError
);
};
...
...
@@ -120,8 +109,6 @@
"
officejs
"
])
.
then
(
function
(
all_param
)
{
i_c
.
empty
();
i_c
[
0
].
appendChild
(
all_param
[
1
].
element
);
return
attachIOToBlog
(
all_param
);
})
.
fail
(
handleError
);
...
...
@@ -129,14 +116,12 @@
}
rJS
(
window
).
ready
(
function
(
g
)
{
var
editor_a_context
=
$
(
g
.
element
).
find
(
"
.editor_a
"
).
last
(),
io_a_context
=
$
(
g
.
element
).
find
(
"
.editor_a_safe
"
).
last
(),
io_blog_a_context
=
$
(
g
.
element
).
find
(
"
.editor_a_safe
"
).
last
(),
blog_a_context
=
$
(
g
.
element
).
find
(
"
.editor_a
"
).
last
(),
index_a_context
=
$
(
g
.
element
).
find
(
"
.sidebar
"
).
last
(),
property_a_context
=
$
(
g
.
element
).
find
(
"
.property_a_safe
"
).
last
()
var
io_a_context
=
$
(
g
.
element
).
find
(
"
.form_a_safe
"
).
last
(),
io_blog_a_context
=
$
(
g
.
element
).
find
(
"
.form_a_safe
"
).
last
(),
blog_a_context
=
$
(
g
.
element
).
find
(
"
.form_a
"
).
last
(),
form_a_context
=
$
(
g
.
element
).
find
(
"
.form_a
"
).
last
(),
index_a_context
=
$
(
g
.
element
).
find
(
"
.sidebar
"
).
last
()
;
// First, load the catalog gadget
g
.
declareGadget
(
'
./catalog.html
'
)
.
then
(
function
(
catalog
)
{
...
...
@@ -163,20 +148,17 @@
})
.
then
(
function
(
all_list
)
{
var
panel_context
=
$
(
g
.
element
).
find
(
"
.bare_panel
"
),
editor_list
=
all_list
[
0
],
form_path
=
'
./form.html
'
,
editor_list
=
all_list
[
0
],
io_list
=
all_list
[
1
],
blog_list
=
all_list
[
2
],
property_list
=
all_list
[
3
],
index_list
=
all_list
[
4
],
editor_definition
,
blog_definition
,
index_definition
=
index_list
[
0
].
path
,
property_definition
,
i
;
// Load 1 editor and 1 IO and plug them
editor_a_context
.
empty
();
$
(
'
.editor_a_safe
'
).
attr
(
"
style
"
,
"
display:none
"
);
$
(
'
.property_a_safe
'
).
attr
(
"
style
"
,
"
display:none
"
);
console
.
log
(
'
Ready to prepare
'
);
return
RSVP
.
all
([
g
.
declareGadget
(
blog_list
[
0
].
path
,
...
...
@@ -186,13 +168,13 @@
"
officejs
"
])
.
then
(
function
(
all_param
)
{
console
.
log
(
'
setting blog
'
);
io_blog_a_context
.
empty
();
io_blog_a_context
[
0
].
appendChild
(
all_param
[
1
].
element
);
return
attachIOToBlog
(
all_param
);
})
.
then
(
function
()
{
// Fill the panel
property_definition
=
property_list
[
0
]
;
console
.
log
(
'
fill panel
'
)
;
for
(
i
=
0
;
i
<
blog_list
.
length
;
i
+=
1
)
{
blog_definition
=
blog_list
[
i
];
panel_context
.
append
(
...
...
@@ -212,9 +194,9 @@
);
panel_context
.
find
(
'
a
'
).
last
().
click
(
createLoadNewEditorCallback
(
g
,
editor_definition
.
path
,
editor_a_context
,
io_list
[
0
].
path
,
io_a_context
,
property_definition
.
path
,
property
_a_context
,
g
,
form_
path
,
form_a_context
,
editor_definition
.
path
,
io_list
[
0
].
path
,
io
_a_context
,
index_definition
,
index_a_context
)
);
...
...
examples/fwi/property.html
View file @
1a85fb74
...
...
@@ -12,6 +12,7 @@
<body
style=
"background-color: white; color: black;"
>
<div
class=
"main-container"
>
<form
id=
"document-property"
>
<input
id=
"_id"
type=
"hidden"
name=
"_id"
>
Title:
<input
id=
"title"
type=
"text"
name=
"title"
>
Reference:
<input
id=
"reference"
type=
"text"
name=
"reference"
>
</form>
...
...
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