Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
22805545
Commit
22805545
authored
Feb 07, 2017
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_core] gadget_editor to replace EditorField
parent
0a4aad76
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
181 additions
and
0 deletions
+181
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_editor.html.html
...mplateItem/portal_skins/erp5_core/gadget_editor.html.html
+13
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_editor.html.xml
...emplateItem/portal_skins/erp5_core/gadget_editor.html.xml
+28
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_editor.js.js
...inTemplateItem/portal_skins/erp5_core/gadget_editor.js.js
+112
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_editor.js.xml
...nTemplateItem/portal_skins/erp5_core/gadget_editor.js.xml
+28
-0
No files found.
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_editor.html.html
0 → 100644
View file @
22805545
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>
Text editor gadget
</title>
<script
src=
"rsvp.js"
></script>
<script
src=
"renderjs.js"
></script>
<script
src=
"gadget_editor.js"
></script>
</head>
<body>
</body>
</html>
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_editor.html.xml
0 → 100644
View file @
22805545
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"File"
module=
"OFS.Image"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
__name__
</string>
</key>
<value>
<string>
gadget_editor.html
</string>
</value>
</item>
<item>
<key>
<string>
content_type
</string>
</key>
<value>
<string>
text/html
</string>
</value>
</item>
<item>
<key>
<string>
precondition
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_editor.js.js
0 → 100644
View file @
22805545
/*jslint nomen: true, indent: 2 */
/*global window, rJS, RSVP, document, FileReader, Blob*/
(
function
(
window
,
rJS
,
RSVP
,
document
,
FileReader
,
Blob
)
{
"
use strict
"
;
/*
function readBlobAsDataURL(blob) {
var fr = new FileReader();
return new RSVP.Promise(function (resolve, reject, notify) {
fr.addEventListener("load", resolve);
fr.addEventListener("error", reject);
fr.addEventListener("progress", notify);
fr.readAsDataURL(blob);
}, function () {
fr.abort();
});
}
*/
rJS
(
window
)
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
json_options
=
JSON
.
parse
(
options
.
value
||
"
{}
"
),
state_dict
=
{
value
:
json_options
.
value
||
""
,
editor
:
json_options
.
editor
,
content_type
:
json_options
.
content_type
,
portal_type
:
json_options
.
portal_type
,
editable
:
options
.
editable
||
false
,
key
:
options
.
key
};
return
this
.
changeState
(
state_dict
);
})
.
onStateChange
(
function
(
modification_dict
)
{
return
this
.
renderAsynchronously
(
modification_dict
);
})
.
declareJob
(
'
renderAsynchronously
'
,
function
(
modification_dict
)
{
var
element
=
this
.
element
,
gadget
=
this
,
url
,
div
=
document
.
createElement
(
'
div
'
),
queue
=
new
RSVP
.
Queue
();
console
.
log
(
modification_dict
);
if
((
modification_dict
.
hasOwnProperty
(
'
editable
'
))
||
(
modification_dict
.
hasOwnProperty
(
'
editor
'
)))
{
// Clear first to DOM, append after to reduce flickering/manip
while
(
element
.
firstChild
)
{
element
.
removeChild
(
element
.
firstChild
);
}
element
.
appendChild
(
div
);
if
(
gadget
.
state
.
editable
&&
(
modification_dict
.
editor
===
'
codemirror
'
))
{
queue
.
push
(
function
()
{
return
gadget
.
declareGadget
(
"
codemirror.gadget.html
"
,
{
scope
:
'
editor
'
,
sandbox
:
'
iframe
'
,
element
:
div
}
);
});
}
else
{
element
.
appendChild
(
document
.
createElement
(
'
pre
'
));
}
}
if
(
gadget
.
state
.
editable
&&
(
gadget
.
state
.
editor
===
'
codemirror
'
))
{
queue
.
push
(
function
()
{
return
gadget
.
getDeclaredGadget
(
'
editor
'
);
})
.
push
(
function
(
editor_gadget
)
{
return
editor_gadget
.
render
(
gadget
.
state
);
});
}
else
{
element
.
querySelector
(
'
pre
'
).
textContent
=
gadget
.
state
.
value
;
}
return
queue
;
})
.
declareMethod
(
'
getContent
'
,
function
()
{
var
argument_list
=
arguments
,
context
=
this
;
if
(
this
.
state
.
editable
&&
(
this
.
state
.
editor
===
'
codemirror
'
))
{
return
this
.
getDeclaredGadget
(
'
editor
'
)
.
push
(
function
(
editor_gadget
)
{
return
editor_gadget
.
getContent
.
apply
(
editor_gadget
,
argument_list
);
});
/*
.push(function (result) {
var value = result[context.state.key] || '';
return readBlobAsDataURL(new Blob([value], {type: 'text/plain'}));
})
.push(function (evt) {
var result = {};
result[context.state.key] = evt.target.result;
return result;
});
*/
}
return
{};
});
}(
window
,
rJS
,
RSVP
,
document
,
FileReader
,
Blob
));
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_editor.js.xml
0 → 100644
View file @
22805545
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"File"
module=
"OFS.Image"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
__name__
</string>
</key>
<value>
<string>
gadget_editor.js
</string>
</value>
</item>
<item>
<key>
<string>
content_type
</string>
</key>
<value>
<string>
application/javascript
</string>
</value>
</item>
<item>
<key>
<string>
precondition
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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