Commit a9885b4a authored by Vivek's avatar Vivek

wip

parent 9e34de6e
......@@ -121,15 +121,15 @@
<script type="text/javascript" src="jquery.js"></script>\n
<script type="text/javascript" src="rsvp.js"></script>\n
<script type="text/javascript" src="renderjs.js"></script>\n
<script type="text/javascript" src="handlebars.js"></script>\n
<script type="text/javascript" src="gadget_global.js" ></script>\n
<script type="text/javascript" src="jquerymobile.js"></script>\n
<script type="text/javascript" src="i18next.js"></script>\n
\n
<!-- specific script -->\n
<script type="text/javascript" src="editor_test_gadget.js"></script>\n
\n
</head>\n
<body>\n
<div data-role="page" id="document">\n
<script class="sub-gadget-template" type="text/x-handlebars-template">\n
<div class="ui-grid-a ui-responsive">\n
<div class="ui-block-a" style="width:60%">\n
<div class="ui-content"></div>\n
......@@ -137,17 +137,28 @@
<div class="ui-block-b" style="width:30%">\n
<form class="gadget-select-form">\n
<div data-role="fieldcontain">\n
<label for="gadget_selector" class="select"></label>\n
<select name="gadget_selector">\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/editor_demo/bootstrap-wysiwyg.html">Text Editor 1</option>\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/editor_demo/bootstrap3-wysiwyg.html">Text Editor 2</option>\n
<label for="gadget_selector" >Main Gadget</label>\n
<select name="gadget_selector" class="select">\n
<option value="./bootstrap-wysiwyg.html">Text Editor 1</option>\n
<option value="./bootstrap3-wysiwyg.html">Text Editor 2</option>\n
</select>\n
</div>\n
<input data-inline="true" type="submit" value="Submit" data-theme="b">\n
</form>\n
</div>\n
</div> \n
</div>\n
</script>\n
</head>\n
\n
<body>\n
<div data-role="page">\n
<div data-role="header" data-position="fixed" class="gadget-header" data-theme="b">\n
<h1></h1>\n
</div>\n
<div role="main" class="ui-content gadget-content"></div>\n
</div>\n
</body>\n
\n
</html>\n
\n
......@@ -287,7 +298,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>944.56298.5921.30532</string> </value>
<value> <string>944.57834.1936.52684</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -305,7 +316,7 @@
</tuple>
<state>
<tuple>
<float>1438783361.36</float>
<float>1438875522.58</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -101,11 +101,48 @@
<key> <string>text_content</string> </key>
<value> <string>/*jslint indent: 2, maxlen: 80, nomen: true */\n
/*global console, window, document, rJS, RSVP, $ */\n
(function (window, document, rJS) {\n
(function (window, document, rJS, Handlebars, promiseEventListener) {\n
"use strict";\n
\n
var EDITOR_GADGET_1 = "./bootstrap-wysiwyg.html";\n
var EDITOR_GADGET_2 = "./bootstrap3-wysiwyg.html";\n
var DEFAULT_EDITOR_GADGET = "./bootstrap-wysiwyg.html";\n
\n
function declareEditorGadget(gadget, editor_g) {\n
console.log("inside declareEditorGadget");\n
return gadget.declareGadget(editor_g, {\n
sandbox: \'iframe\',\n
element: document.body.querySelector("[data-role=page]"),\n
scope: "editor"\n
});\n
}\n
function gadgetSwitchHandler(gadget) {\n
console.log("Listening");\n
return new RSVP.Queue()\n
.push(function() {\n
gadget.props.content_element.innerHTML =\n
gadget.props.sub_gadget_template({});\n
return promiseEventListener(\n
gadget.props.content_element.querySelector(\'form.gadget-select-form\'),\n
\'submit\',\n
false\n
);\n
})\n
.push(function(submit_event) {\n
console.log("submit_event",submit_event);\n
gadget.props.content_element.querySelector("input[type=submit]")\n
.disabled = true;\n
gadget.props.content_element.querySelector("div.ui-content").innerHTML = "";\n
console.log("Selected:", submit_event.target[0].value);\n
return declareEditorGadget(gadget,submit_event.target[0].value);\n
})\n
.push(function(){\n
console.log("Calling self again");\n
gadget.props.content_element.querySelector("input[type=submit]")\n
.disabled = false;\n
return gadgetSwitchHandler(gadget);\n
});\n
\n
}\n
\n
// block JQM auto-start\n
$(document)\n
.on("mobileinit", function () {\n
......@@ -115,32 +152,29 @@
rJS(window)\n
\n
.ready(function (g) {\n
g.props = {};\n
return g.getElement()\n
.push(function (element) {\n
$(element).trigger("create");\n
g.props.element = element;\n
g.props.header_element = element.querySelector(\'.gadget-header\');\n
g.props.content_element = element.querySelector(\'.gadget-content\');\n
g.props.sub_gadget_template = Handlebars.compile(\n
document.querySelector(".sub-gadget-template").innerHTML\n
);\n
});\n
})\n
\n
.declareMethod(\'render\', function () {\n
var gadget, page_list, page;\n
\n
gadget = this;\n
page_list = document.body.querySelectorAll("[data-role=page]");\n
page = page_list[page_list.length - 1];\n
\n
// helper: declare edtior\n
function declareEditorGadget(editor_g) {\n
return gadget.declareGadget(editor_g, {\n
sandbox: \'iframe\',\n
element: page.querySelector("div.ui-content"),\n
scope: "editor"\n
});\n
}\n
var gadget = this;\n
\n
return new RSVP.Queue()\n
.push(function() {\n
console.log("first gadget");\n
return declareEditorGadget(EDITOR_GADGET_1);\n
console.log("default gadget");\n
return declareEditorGadget(gadget, DEFAULT_EDITOR_GADGET);\n
})\n
.push(function(){\n
page.querySelector("div.ui-content").innerHTML = "";\n
return declareEditorGadget(EDITOR_GADGET_2);\n
return gadgetSwitchHandler(gadget);\n
});\n
\n
})\n
......@@ -165,7 +199,7 @@
});\n
});\n
\n
}(window, document, rJS));</string> </value>
}(window, document, rJS, Handlebars, promiseEventListener));</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......@@ -300,7 +334,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>944.56235.17061.26624</string> </value>
<value> <string>944.57850.5818.19541</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -318,7 +352,7 @@
</tuple>
<state>
<tuple>
<float>1438780043.78</float>
<float>1438876472.39</float>
<string>GMT</string>
</tuple>
</state>
......
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