Commit 155c33aa authored by Vivek's avatar Vivek

erp5_officejs: modified router logic.

parent ef31cd51
......@@ -208,7 +208,7 @@
gadget.props.element.innerHTML = html;\n
return gadget.updateHeader({\n
title: options.doc.title + " | Web Page",\n
back_url: "#page=text_editor_list",\n
back_url: "#?page=text_editor_list",\n
panel_action: false,\n
save_action: true\n
});\n
......@@ -397,7 +397,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>cedric.le.ninivin</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -411,7 +411,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.18929.62498.39526</string> </value>
<value> <string>946.54860.11845.29678</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -429,7 +429,7 @@
</tuple>
<state>
<tuple>
<float>1444320970.58</float>
<float>1446729331.89</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -164,10 +164,10 @@
<div class="ui-controlgroup ui-controlgroup-horizontal">\n
<div class="ui-grid-a ui-responsive">\n
<div class="ui-block-a">\n
<a class="ui-btn" href="#page=sync" data-i18n="Synchronize">Synchronize</a>\n
<a class="ui-btn" href="#?page=sync" data-i18n="Synchronize">Synchronize</a>\n
</div>\n
<div class="ui-block-b">\n
<a class="ui-btn" href="#page=document_list" data-i18n="Go to document List">Go to document List</a>\n
<a class="ui-btn" href="#?page=document_list" data-i18n="Go to document List">Go to document List</a>\n
</div>\n
</div>\n
</div>\n
......@@ -297,7 +297,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>cedric.le.ninivin</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -311,7 +311,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.61353.27590.61969</string> </value>
<value> <string>946.4378.53544.28347</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -329,7 +329,7 @@
</tuple>
<state>
<tuple>
<float>1443018896.6</float>
<float>1446729498.99</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -170,10 +170,10 @@
<div class="ui-controlgroup ui-controlgroup-horizontal">\n
<div class="ui-grid-a ui-responsive">\n
<div class="ui-block-a">\n
<a class="ui-btn" href="#page=sync">Synchronize</a>\n
<a class="ui-btn" href="#?page=sync">Synchronize</a>\n
</div>\n
<div class="ui-block-b">\n
<a class="ui-btn" href="#page=document_list">Go to document List</a>\n
<a class="ui-btn" href="#?page=document_list">Go to document List</a>\n
</div>\n
</div>\n
</div>\n
......@@ -306,7 +306,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>cedric.le.ninivin</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -320,7 +320,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.58544.33560.24866</string> </value>
<value> <string>946.4378.53544.28347</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -338,7 +338,7 @@
</tuple>
<state>
<tuple>
<float>1443010638.45</float>
<float>1446729536.73</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -188,7 +188,7 @@
var gadget = this;\n
return gadget.updateHeader({\n
title: "Connect To DAV Storage",\n
back_url: "#page=jio_configurator",\n
back_url: "#?page=jio_configurator",\n
panel_action: false\n
}).push(function () {\n
return gadget.props.deferred.resolve();\n
......@@ -341,7 +341,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>cedric.le.ninivin</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -355,7 +355,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.61336.46618.42325</string> </value>
<value> <string>946.54860.11845.29678</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -373,7 +373,7 @@
</tuple>
<state>
<tuple>
<float>1444319088.33</float>
<float>1446729573.71</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -108,35 +108,111 @@
\n
var gadget_klass = rJS(window),\n
MAIN_PAGE_PREFIX = "gadget_officejs_",\n
DEFAULT_PAGE = "text_editor_list";\n
DEFAULT_PAGE = "text_editor_list",\n
REDIRECT_TIMEOUT = 5000;\n
\n
function listenHashChange(gadget) {\n
// Handle hash in this format: #$path1/path2?a=b&c=d\n
function extractHashAndDispatch(evt) {\n
var hash = (evt.newURL || window.location.toString()).split(\'#\')[1],\n
split,\n
command = "",\n
query = "",\n
subhashes,\n
subhash,\n
keyvalue,\n
index,\n
args = {};\n
if (hash !== undefined) {\n
split = hash.split(\'?\');\n
command = split[0] || "";\n
query = split[1] || "";\n
}\n
subhashes = query.split(\'&\');\n
for (index in subhashes) {\n
if (subhashes.hasOwnProperty(index)) {\n
subhash = subhashes[index];\n
if (subhash !== \'\') {\n
keyvalue = subhash.split(\'=\');\n
if (keyvalue.length === 2) {\n
args[decodeURIComponent(keyvalue[0])] = decodeURIComponent(keyvalue[1]);\n
}\n
}\n
}\n
}\n
\n
return gadget.renderApplication({\n
method: command[0],\n
path: command.substr(1),\n
args: args\n
});\n
\n
}\n
\n
var result = loopEventListener(window, \'hashchange\', false,\n
extractHashAndDispatch),\n
event = document.createEvent("Event");\n
event.initEvent(\'hashchange\', true, true);\n
event.newURL = window.location.toString();\n
window.dispatchEvent(event);\n
return result;\n
}\n
\n
gadget_klass\n
.declareAcquiredMethod(\'pleaseRedirectMyHash\', \'pleaseRedirectMyHash\')\n
.declareAcquiredMethod(\'jio_get\', \'jio_get\')\n
\n
.ready(function (gadget) {\n
gadget.props = {};\n
gadget.props = {\n
start_deferred: RSVP.defer()\n
};\n
})\n
\n
.declareMethod("getCommandUrlFor", function(options) {\n
var prefix = \'?\',\n
result,\n
key;\n
result = "#";\n
for (key in options) {\n
if (options.hasOwnProperty(key) && options[key] !== undefined) {\n
// Don\'t keep empty values\n
result += prefix + encodeURIComponent(key) + "=" + encodeURIComponent(options[key]);\n
prefix = \'&\';\n
}\n
}\n
return result;\n
})\n
\n
.declareMethod(\'redirect\', function (options) {\n
return this.getCommandUrlFor(options)\n
.push(function (hash) {\n
window.location.replace(hash);\n
// prevent returning unexpected response\n
// wait for the hash change to occur\n
// fail if nothing happens\n
return RSVP.timeout(REDIRECT_TIMEOUT);\n
});\n
})\n
\n
.declareMethod(\'route\', function (options) {\n
var gadget = this;\n
var gadget = this,\n
args = options.args;\n
gadget.options = options;\n
if (options.jio_key === undefined || options.jio_key === \'\') {\n
if (options.page === undefined || options.page === \'\' || options.page === "document_list") {\n
options.page = DEFAULT_PAGE;\n
if (args.jio_key === undefined || args.jio_key === \'\') {\n
if (args.page === undefined || args.page === \'\' || args.page === "document_list") {\n
args.page = DEFAULT_PAGE;\n
}\n
return {\n
url: MAIN_PAGE_PREFIX + "page_" + options.page + ".html",\n
options: options\n
url: MAIN_PAGE_PREFIX + "page_" + args.page + ".html",\n
options: args\n
};\n
}\n
return gadget.jio_get(options.jio_key)\n
return gadget.jio_get(args.jio_key)\n
.push(function (doc) {\n
var sub_options = {},\n
base_portal_type = doc.portal_type.toLowerCase().replace(/\\s/g, "_");\n
sub_options = {\n
doc: doc,\n
jio_key: options.jio_key,\n
search: options.search\n
jio_key: args.jio_key,\n
search: args.search\n
};\n
if (base_portal_type.search(/_temp$/) >= 0) {\n
//Remove "_temp"\n
......@@ -148,10 +224,26 @@
return {\n
url: MAIN_PAGE_PREFIX + "jio_"\n
+ base_portal_type\n
+ "_" + options.page + ".html",\n
+ "_" + args.page + ".html",\n
options: sub_options\n
};\n
});\n
})\n
\n
.declareAcquiredMethod(\'jio_get\', \'jio_get\')\n
.declareAcquiredMethod(\'renderApplication\', \'renderApplication\')\n
.declareMethod(\'start\', function () {\n
this.props.start_deferred.resolve();\n
})\n
.declareService(function () {\n
var gadget = this;\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.props.start_deferred.promise;\n
})\n
.push(function () {\n
return listenHashChange(gadget);\n
});\n
});\n
\n
}(window, rJS));
......@@ -277,7 +369,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>cedric.le.ninivin</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -291,7 +383,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.54379.5447.43417</string> </value>
<value> <string>946.4378.53544.28347</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -309,7 +401,7 @@
</tuple>
<state>
<tuple>
<float>1442858756.66</float>
<float>1446729681.9</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -182,9 +182,9 @@
<script class="panel-template" type="text/x-handlebars-template">\n
<div class="ui-content">\n
<ul data-role="listview" class="ui-listview">\n
<li><a href="#page=text_editor_list" data-i18n="Text Documents">Text Documents</a></li>\n
<li><a href="#page=sync" data-i18n="Sync">Sync</a></li>\n
<li class="ui-last-child"><a href="#page=logout" data-i18n="Logout">Logout</a></li>\n
<li><a href="#?page=text_editor_list" data-i18n="Text Documents">Text Documents</a></li>\n
<li><a href="#?page=sync" data-i18n="Sync">Sync</a></li>\n
<li class="ui-last-child"><a href="#?page=logout" data-i18n="Logout">Logout</a></li>\n
</ul>\n
</div>\n
</script>\n
......@@ -334,7 +334,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>cedric.le.ninivin</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -348,7 +348,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.18361.2224.61866</string> </value>
<value> <string>946.4378.53544.28347</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -366,7 +366,7 @@
</tuple>
<state>
<tuple>
<float>1440439282.96</float>
<float>1446729798.11</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -140,10 +140,10 @@
<script id="panel-template-body" type="text/x-handlebars-template">\n
<div class="ui-content">\n
<ul data-role="listview" class="ui-listview">\n
<li><a href="#page=text_editor_list" data-i18n="Text Documents">Text Documents</a></li>\n
<li><a href="#page=jio_configurator" data-i18n="Storage Configuration">Storage Configuration</a></li>\n
<li><a href="#page=sync" data-i18n="Syncronization">Syncronization</a></li>\n
<li class="ui-last-child"><a href="#page=logout" data-i18n="Logout">Logout</a></li>\n
<li><a href="#?page=text_editor_list" data-i18n="Text Documents">Text Documents</a></li>\n
<li><a href="#?page=jio_configurator" data-i18n="Storage Configuration">Storage Configuration</a></li>\n
<li><a href="#?page=sync" data-i18n="Syncronization">Syncronization</a></li>\n
<li class="ui-last-child"><a href="#?page=logout" data-i18n="Logout">Logout</a></li>\n
</ul>\n
</div>\n
</script>\n
......@@ -278,7 +278,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>cedric.le.ninivin</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -292,7 +292,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.61348.56996.63675</string> </value>
<value> <string>946.54860.11845.29678</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -310,7 +310,7 @@
</tuple>
<state>
<tuple>
<float>1444319473.8</float>
<float>1446729867.48</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -156,6 +156,10 @@
.declareMethod(\'toggle\', function () {\n
this.props.jelement.panel("toggle");\n
})\n
\n
.declareMethod(\'close\', function () {\n
this.props.jelement.panel("close");\n
})\n
\n
.declareMethod(\'render\', function () {\n
return;\n
......@@ -320,7 +324,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>cedric.le.ninivin</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -334,7 +338,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.38557.26146.25275</string> </value>
<value> <string>946.4378.53544.28347</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -352,7 +356,7 @@
</tuple>
<state>
<tuple>
<float>1441651247.96</float>
<float>1446730020.92</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -430,7 +430,7 @@
</item>
<item>
<key> <string>configuration_translation_gadget_url</string> </key>
<value> <string>gadget_officejs_translation.html</string> </value>
<value> <string>gadget_translation.html</string> </value>
</item>
<item>
<key> <string>configuration_view_action_category</string> </key>
......@@ -707,7 +707,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>cedric.le.ninivin</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -721,7 +721,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.58604.38981.59955</string> </value>
<value> <string>946.4378.53544.28347</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -739,7 +739,7 @@
</tuple>
<state>
<tuple>
<float>1442858486.32</float>
<float>1446730078.39</float>
<string>UTC</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