Commit 9e95412f authored by Ivan Tyagov's avatar Ivan Tyagov

Improve gadget loading "ready" event.

parent a1c54608
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</item> </item>
<item> <item>
<key> <string>_EtagSupport__etag</string> </key> <key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts36978119.57</string> </value> <value> <string>ts36997821.03</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
...@@ -579,11 +579,12 @@ var GadgetIndex = {\n ...@@ -579,11 +579,12 @@ var GadgetIndex = {\n
*/\n */\n
var InteractionGadget = {\n var InteractionGadget = {\n
\n \n
bind: function (dom){\n bind: function (gadget_dom){\n
/*\n /*\n
* Bind event between gadgets.\n * Bind event between gadgets.\n
*/\n */\n
dom.find("connect").each(function (key, value){\n gadget_id = gadget_dom.attr("id");\n
gadget_dom.find("connect").each(function (key, value){\n
source = $(value).attr("source").split(".");\n source = $(value).attr("source").split(".");\n
source_gadget_id = source[0];\n source_gadget_id = source[0];\n
source_method_id = source[1];\n source_method_id = source[1];\n
...@@ -650,22 +651,12 @@ var RenderJs = {\n ...@@ -650,22 +651,12 @@ var RenderJs = {\n
url = gadget.attr("gadget");\n url = gadget.attr("gadget");\n
gadget_id = gadget.attr("id");\n gadget_id = gadget.attr("id");\n
\n \n
// XXX: How to know how long a form should be cached locally\n
// i.e. what happens if it changes at server side ?\n
\n
// register gadget in javascript namespace\n // register gadget in javascript namespace\n
gadget_js = new Gadget(gadget_id, gadget);\n gadget_js = new Gadget(gadget_id, gadget);\n
GadgetIndex.registerGadget(gadget_js);\n GadgetIndex.registerGadget(gadget_js);\n
if (url===undefined || url===""){\n
// gadget is an inline one so no need to load it from network\n
gadget_js.setReady();\n
RenderJs.checkAndTriggerReady(); \n
return;\n
}\n
\n \n
// handle caching\n if (url!==undefined && url!==""){\n
gadget_property = gadget.attr("gadget:property");\n gadget_property = gadget.attr("gadget:property");\n
\n
cacheable = false;\n cacheable = false;\n
if (gadget_property!==undefined) {\n if (gadget_property!==undefined) {\n
gadget_property = $.parseJSON(gadget_property);\n gadget_property = $.parseJSON(gadget_property);\n
...@@ -688,7 +679,7 @@ var RenderJs = {\n ...@@ -688,7 +679,7 @@ var RenderJs = {\n
Cache.set(cache_id, data);\n Cache.set(cache_id, data);\n
GadgetIndex.getGadgetById(gadget_id).setReady();\n GadgetIndex.getGadgetById(gadget_id).setReady();\n
RenderJs.updateAndRecurse(gadget, data);\n RenderJs.updateAndRecurse(gadget, data);\n
RenderJs.checkAndTriggerReady(); \n RenderJs.checkAndTriggerReady();\n
}});\n }});\n
}\n }\n
else {\n else {\n
...@@ -696,7 +687,7 @@ var RenderJs = {\n ...@@ -696,7 +687,7 @@ var RenderJs = {\n
data = app_cache;\n data = app_cache;\n
gadget_js.setReady();\n gadget_js.setReady();\n
this.updateAndRecurse(gadget, data);\n this.updateAndRecurse(gadget, data);\n
this.checkAndTriggerReady(); \n this.checkAndTriggerReady();\n
}\n }\n
}\n }\n
else {\n else {\n
...@@ -711,6 +702,12 @@ var RenderJs = {\n ...@@ -711,6 +702,12 @@ var RenderJs = {\n
RenderJs.checkAndTriggerReady();\n RenderJs.checkAndTriggerReady();\n
}});\n }});\n
}\n }\n
}\n
else {\n
// gadget is an inline one so no need to load it from network\n
gadget_js.setReady();\n
RenderJs.checkAndTriggerReady();\n
}\n
},\n },\n
\n \n
checkAndTriggerReady: function() {\n checkAndTriggerReady: function() {\n
...@@ -721,7 +718,7 @@ var RenderJs = {\n ...@@ -721,7 +718,7 @@ var RenderJs = {\n
is_gadget_list_loaded = GadgetIndex.isGadgetListLoaded();\n is_gadget_list_loaded = GadgetIndex.isGadgetListLoaded();\n
if (is_gadget_list_loaded){\n if (is_gadget_list_loaded){\n
if (!is_ready) {\n if (!is_ready) {\n
//console.log("trigger");\n console.log("trigger");\n
GadgetIndex.getRootGadget().getDom().trigger("ready");\n GadgetIndex.getRootGadget().getDom().trigger("ready");\n
}\n }\n
is_ready = true;\n is_ready = true;\n
...@@ -765,7 +762,7 @@ var RenderJs = {\n ...@@ -765,7 +762,7 @@ var RenderJs = {\n
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>25312</int> </value> <value> <int>25230</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
11 12
\ No newline at end of file \ No newline at end of file
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