Commit 7758aa3d authored by Xiaowu Zhang's avatar Xiaowu Zhang

Use jIO getAttachment instead of ajax in translation gadget

parent a249d771
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
/*global window, document, rJS, RSVP, jQuery, console, jQuery, XMLHttpRequest, loopEventListener, URI, location */\n /*global window, document, rJS, RSVP, jQuery, console, jQuery, XMLHttpRequest, loopEventListener, URI, location */\n
/*jslint nomen: true, indent: 2, maxerr: 3 */\n /*jslint nomen: true, indent: 2, maxerr: 3 */\n
(function (window, document, rJS, RSVP, $, XMLHttpRequest, console, loopEventListener, URI, location) {\n (function (window, document, rJS, RSVP, $, XMLHttpRequest, console, loopEventListener, location) {\n
"use strict";\n "use strict";\n
\n \n
var DEFAULT_VIEW_REFERENCE = "view";\n var DEFAULT_VIEW_REFERENCE = "view";\n
...@@ -257,7 +257,8 @@ ...@@ -257,7 +257,8 @@
\n \n
// bridge translation gadget\n // bridge translation gadget\n
.allowPublicAcquisition("getTranslationMethod", function () {\n .allowPublicAcquisition("getTranslationMethod", function () {\n
return this.props.translation_lookup;\n var root = (new URI("hateoas/")).absoluteTo(location.href).toString();\n
return root + this.props.translation_lookup;\n
})\n })\n
.allowPublicAcquisition("changeLanguage", function (param_list) {\n .allowPublicAcquisition("changeLanguage", function (param_list) {\n
if (this.setLanguage) {\n if (this.setLanguage) {\n
...@@ -435,7 +436,7 @@ ...@@ -435,7 +436,7 @@
// XXX translate: called before ready(), so props is not available.\n // XXX translate: called before ready(), so props is not available.\n
// Needed to lookup to retrieve HAL to fetch site module/runner languages \n // Needed to lookup to retrieve HAL to fetch site module/runner languages \n
.declareMethod(\'getSiteRoot\', function () {\n .declareMethod(\'getSiteRoot\', function () {\n
return "hateoas/";\n return (new URI("hateoas/")).absoluteTo(location.href).toString();\n
})\n })\n
\n \n
// Render the page\n // Render the page\n
...@@ -579,7 +580,7 @@ ...@@ -579,7 +580,7 @@
);\n );\n
});\n });\n
\n \n
}(window, document, rJS, RSVP, jQuery, XMLHttpRequest, console, loopEventListener, URI, location)); }(window, document, rJS, RSVP, jQuery, XMLHttpRequest, console, loopEventListener, location));
]]></string> </value> ]]></string> </value>
</item> </item>
...@@ -702,7 +703,7 @@ ...@@ -702,7 +703,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>romain</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -716,7 +717,7 @@ ...@@ -716,7 +717,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>940.49304.32028.23995</string> </value> <value> <string>940.50639.33715.55517</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -734,8 +735,8 @@ ...@@ -734,8 +735,8 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1423067269.03</float> <float>1423147262.73</float>
<string>GMT</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
</object> </object>
......
...@@ -114,17 +114,15 @@ ...@@ -114,17 +114,15 @@
cookie_lang = fetchLanguage(),\n cookie_lang = fetchLanguage(),\n
lang = cookie_lang || props.default_language || my_language,\n lang = cookie_lang || props.default_language || my_language,\n
path = props.src + "?language=" + lang + "&namespace=dict";\n path = props.src + "?language=" + lang + "&namespace=dict";\n
\n
return new RSVP.Queue()\n return new RSVP.Queue()\n
.push(function () {\n .push(function () {\n
return my_gadget.jio_ajax({\n return my_gadget.jio_getAttachment({\n
"method": "GET",\n "_id": "erp5",\n
"url": path,\n "_attachment": path\n
"xhrFields": {"withCredentials": true}\n
});\n });\n
})\n })\n
.push(function (my_event) {\n .push(function (my_event) {\n
return JSON.parse(my_event.target.responseText);\n return my_event.data;\n
});\n });\n
}\n }\n
\n \n
...@@ -164,23 +162,23 @@ ...@@ -164,23 +162,23 @@
]);\n ]);\n
})\n })\n
.push(function (my_config_list) {\n .push(function (my_config_list) {\n
var url;\n
url = my_config_list[0]\n
my_gadget.property_dict.src = my_config_list[1];\n my_gadget.property_dict.src = my_config_list[1];\n
return my_gadget.jio_ajax({\n return my_gadget.jio_getAttachment({\n
"method": "GET",\n "_id": "erp5",\n
"url": UriTemplate.parse(my_config_list[0]),\n "_attachment": url\n
"xhrFields": {"withCredentials": true}\n
});\n });\n
})\n })\n
.push(function (my_hateoas) {\n .push(function (my_hateoas) {\n
var url,\n var url;\n
site_hal = JSON.parse(my_hateoas.target.responseText);\n
// NOTE: at this point createJIO has not been called yet, so allDocs\n // NOTE: at this point createJIO has not been called yet, so allDocs\n
// is not available and must be called "manually"\n // is not available and must be called "manually"\n
// XXX: Improve\n // XXX: Improve\n
url = UriTemplate.parse(site_hal._links.raw_search.href)\n url = UriTemplate.parse(my_hateoas.data._links.raw_search.href)\n
.expand({\n .expand({\n
query: \'portal_type: "Web Site" AND title: "\'\n query: \'portal_type: "Web Site" AND title: "\'\n
+ site_hal._links.parent.name + \'"\',\n + my_hateoas.data._links.parent.name + \'"\',\n
select_list: [\n select_list: [\n
"available_language_set",\n "available_language_set",\n
"default_available_language"\n "default_available_language"\n
...@@ -188,15 +186,13 @@ ...@@ -188,15 +186,13 @@
limit: [0, 1]\n limit: [0, 1]\n
});\n });\n
\n \n
return my_gadget.jio_ajax({\n return my_gadget.jio_getAttachment({\n
"type": "GET",\n "_id": "erp5",\n
"url": url,\n "_attachment": url\n
"xhrFields": {withCredentials: true}\n
});\n });\n
})\n })\n
.push(function (my_site_configuration) {\n .push(function (my_site_configuration) {\n
var response = JSON.parse(my_site_configuration.target.responseText),\n var web_site = my_site_configuration.data._embedded.contents[0];\n
web_site = response._embedded.contents[0];\n
// set remaining properties\n // set remaining properties\n
my_gadget.property_dict.language_list =\n my_gadget.property_dict.language_list =\n
web_site.available_language_set;\n web_site.available_language_set;\n
...@@ -242,7 +238,7 @@ ...@@ -242,7 +238,7 @@
// acquired methods\n // acquired methods\n
/////////////////////////////////////////////////////////////////\n /////////////////////////////////////////////////////////////////\n
.declareAcquiredMethod("notifyUpdate", "notifyUpdate")\n .declareAcquiredMethod("notifyUpdate", "notifyUpdate")\n
.declareAcquiredMethod("jio_ajax", "jio_ajax")\n .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")\n
.declareAcquiredMethod("getSiteRoot", "getSiteRoot")\n .declareAcquiredMethod("getSiteRoot", "getSiteRoot")\n
.declareAcquiredMethod("getTranslationMethod", "getTranslationMethod")\n .declareAcquiredMethod("getTranslationMethod", "getTranslationMethod")\n
\n \n
...@@ -502,7 +498,7 @@ ...@@ -502,7 +498,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>940.10185.20882.26419</string> </value> <value> <string>940.50431.23564.44151</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -520,7 +516,7 @@ ...@@ -520,7 +516,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1420723441.28</float> <float>1423134793.61</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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