Commit 4d8f8028 authored by Romain Courteaud's avatar Romain Courteaud

romain_dev: wip presentation viewer

parent 62f2914b
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left (Page Properties)</string>
<string>right (Publication)</string>
<string>center</string>
<string>bottom</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>your_text_content</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left (Page Properties)</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>right (Publication)</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>OOoDocument_viewAsWeb</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>OOoDocument_viewAsWeb</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Presentation</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>description</string>
<string>enabled</string>
<string>gadget_url</string>
<string>js_sandbox</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_text_content</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Content of the web page</string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_text_content</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewWebFieldLibrary</string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string>presentationviewer.gadget.html</string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>40</int> </value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string>iframe</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Page Content</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.asEntireHTML()</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>not:here/isExternalDocument</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<!DOCTYPE html>
<html>
<head>
<!--
data-i18n=Maximize
-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Presentation Viewer Gadget</title>
<link rel="stylesheet" href="reveal/reveal.css">
<link rel="stylesheet" href="reveal/reveal_theme_white.css">
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_global.js"></script>
<script src="domsugar.js"></script>
<script src="jiodev.js"></script>
<script src="reveal/reveal.js" type="text/javascript"></script>
<script src="presentationviewer.gadget.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>must_revalidate_http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>presentationviewer.gadget.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>
/*global window, rJS, RSVP, domsugar, Reveal, URL, DOMParser*/
/*jslint nomen: true, maxlen:80, indent:2*/
(function (window, rJS, RSVP, domsugar, Reveal, URL, DOMParser) {
"use strict";
function fixupERP5UrlCompatibility(jio_key, url) {
if (!jio_key) {
return url;
}
return new URL(
url,
new URL(jio_key + '/', window.location.href).href
).href;
}
/*
function getSlideElementList(presentation_html) {
// Convert to an Array so that array methods can be used to reorder slides
return Array.prototype.slice.call(domsugar('div', {
'class': 'slide_list',
html: presentation_html
}).querySelectorAll(':scope > section'));
}
*/
function replaceNode(current_node, new_tag) {
var fragment = domsugar(new_tag);
while (current_node.firstChild) {
fragment.appendChild(current_node.firstChild);
}
current_node.parentNode.removeChild(
current_node
);
return fragment;
}
function cleanupSlide(slide_html, jio_key) {
var slide_doc = (new DOMParser()).parseFromString(slide_html,
'text/html').body,
// slide_doc = domsugar('div', {html: slide_html}),
slide_img_url = slide_doc.querySelector('img').getAttribute('src'),
br_element = slide_doc.querySelector('h3').nextSibling,
note_list = [],
note;
console.log(slide_img_url, br_element);
if (br_element !== null) {
note = br_element.nextSibling;
while (note) {
note_list.push(note);
note = note.nextSibling;
}
}
return domsugar('section', [
domsugar('section', [
domsugar('img', {src: fixupERP5UrlCompatibility(jio_key, slide_img_url)})
]),
domsugar('section', note_list)
]);
var detail_list = Array.prototype.slice.call(
slide_element.querySelectorAll(':scope > details')
),
len = detail_list.length,
i,
section_element;
if (len > 0) {
// Create the first vertical section containing every else than details
section_element = domsugar('section');
while (slide_element.firstChild) {
section_element.appendChild(slide_element.firstChild);
}
slide_element.appendChild(section_element);
// Transform every details into a section,
// and move it outside the first vertical section
for (i = 0; i < len; i += 1) {
if (detail_list[i].firstChild) {
slide_element.appendChild(replaceNode(detail_list[i], 'section'));
} else {
// Drop empty details element
section_element.removeChild(detail_list[i]);
}
}
}
// Rewrite img url to support sub document ID
detail_list = Array.prototype.slice.call(
slide_element.querySelectorAll('img')
);
len = detail_list.length;
for (i = 0; i < len; i += 1) {
detail_list[i].src = fixupERP5UrlCompatibility(
jio_key,
detail_list[i].getAttribute('src')
)
}
return slide_element;
}
function calculateFullPresentationFormat(first_slide_html, jio_key) {
return domsugar('div', {class: 'reveal'}, [
domsugar('div', {class: 'slides'}, [
cleanupSlide(first_slide_html, jio_key)
])
]);
console.log(result.outerHTML);
return result;
/*
var slide_list = getSlideElementList(presentation_html),
i,
len = slide_list.length;
for (i = 0; i < len; i += 1) {
cleanupSlide(slide_list[i], jio_key);
}
return domsugar('div', {class: 'reveal'}, [
domsugar('div', {class: 'slides'}, slide_list)
]);
*/
}
///////////////////////////////////////////////////
// Gadget
///////////////////////////////////////////////////
rJS(window)
.declareMethod('render', function (options) {
return this.changeState({
value: options.value || "",
jio_key: options.jio_key
});
})
.onStateChange(function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
domsugar(gadget.element, [
calculateFullPresentationFormat(gadget.state.value, gadget.state.jio_key)
]);
return Reveal.initialize(gadget.element, {
controls: true,
progress: true,
history: true,
center: false,
transition: 'slide',
// Exposes the reveal.js API through window.postMessage
postMessage: true,
// Dispatches all reveal.js events to the parent window
// through postMessage
postMessageEvents: false
});
})
.push(function () {
Reveal.configure({
slideNumber: 'c / t',
// XXX This will not work if iframe is from another domain
width: window.parent.innerWidth,
height: window.parent.innerHeight,
minScale: 0.01,
maxScale: 10
});
Reveal.layout();
});
});
}(window, rJS, RSVP, domsugar, Reveal, URL, DOMParser));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>must_revalidate_http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>presentationviewer.gadget.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>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment