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
5a4e3a53
Commit
5a4e3a53
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
d3d2e100
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
195 additions
and
0 deletions
+195
-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
+126
-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 @
5a4e3a53
<!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 @
5a4e3a53
<?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 @
5a4e3a53
/*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
state_dict
=
{
value
:
options
.
value
||
""
,
editor
:
options
.
editor
,
content_type
:
options
.
content_type
,
portal_type
:
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
();
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
&&
(
gadget
.
state
.
editor
===
'
codemirror
'
))
{
queue
.
push
(
function
()
{
return
gadget
.
declareGadget
(
"
codemirror.gadget.html
"
,
{
scope
:
'
editor
'
,
sandbox
:
'
iframe
'
,
element
:
div
}
);
});
}
else
if
(
gadget
.
state
.
editable
&&
(
gadget
.
state
.
editor
===
'
fck_editor
'
))
{
queue
.
push
(
function
()
{
return
gadget
.
declareGadget
(
"
ckeditor.gadget.html
"
,
{
scope
:
'
editor
'
,
sandbox
:
'
iframe
'
,
element
:
div
}
);
});
}
else
{
element
.
appendChild
(
document
.
createElement
(
'
pre
'
));
}
}
if
(
gadget
.
state
.
editable
&&
((
gadget
.
state
.
editor
===
'
codemirror
'
)
||
(
gadget
.
state
.
editor
===
'
fck_editor
'
)))
{
queue
.
push
(
function
()
{
return
gadget
.
getDeclaredGadget
(
'
editor
'
);
})
.
push
(
function
(
editor_gadget
)
{
return
editor_gadget
.
render
(
gadget
.
state
);
});
}
else
if
(
!
gadget
.
state
.
editable
&&
(
gadget
.
state
.
editor
===
'
fck_editor
'
))
{
element
.
innerHTML
=
gadget
.
state
.
value
;
}
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
'
)
||
(
this
.
state
.
editor
===
'
fck_editor
'
)))
{
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 @
5a4e3a53
<?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