Commit ed662e5c authored by Sven Franck's avatar Sven Franck Committed by Sebastien Robin

test for tabs before initiating tabs gadget (wip)

parent 9d87fd5f
......@@ -153,11 +153,10 @@
\n
<article></article>\n
\n
<section data-gadget-url="gadget_jio.html"\n
data-gadget-scope="jio_gadget"\n
data-gadget-sandbox="public"></section>\n
<aside>\n
</aside>\n
<section data-gadget-url="gadget_jio.html"\n
data-gadget-scope="jio_gadget"\n
data-gadget-sandbox="public"></section>\n
<!-- <aside></aside> -->\n
</body>\n
</html>
......@@ -282,7 +281,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>romain</string> </value>
<value> <string>sven</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -296,7 +295,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>936.47410.50555.22340</string> </value>
<value> <string>936.49302.26306.5341</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -314,7 +313,7 @@
</tuple>
<state>
<tuple>
<float>1407397647.36</float>
<float>1407832402.03</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -101,8 +101,8 @@
<key> <string>text_content</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*global rJS, RSVP, jQuery, URI, console */\n
/*jslint nomen: true */\n
/*global rJS, RSVP, jQuery, URI, console, $ */\n
/*jslint indent: 2, maxlen: 80, nomen: true */\n
(function (rJS, RSVP, URI) {\n
"use strict";\n
\n
......@@ -126,41 +126,41 @@
});\n
});\n
}\n
function renderFrontpage(gadget, options) {\n
\n
function renderFrontpage(gadget, options) {\n
return gadget.props.breadcrumb_gadget.render({title: "ERP5"})\n
.push(function () {\n
return gadget.declareGadget(gadget.props.frontpage_gadget, {\n
scope: "frontpage_gadget"\n
.push(function () {\n
return gadget.declareGadget(gadget.props.frontpage_gadget, {\n
scope: "frontpage_gadget"\n
});\n
})\n
})\n
.push(function (sub_gadget) {\n
.push(function (sub_gadget) {\n
return RSVP.all([\n
sub_gadget.render(),\n
sub_gadget.getElement()\n
]);\n
});\n
});\n
}\n
\n
function renderLoginForm(gadget, options) {\n
\n
return gadget.props.breadcrumb_gadget.render({title: "Login"})\n
.push(function () {\n
return gadget.declareGadget("gadget_erp5_pt_loginform.html", {\n
scope: "login_gadget"\n
.push(function () {\n
return gadget.declareGadget("gadget_erp5_pt_loginform.html", {\n
scope: "login_gadget"\n
});\n
})\n
})\n
.push(function (sub_gadget) {\n
.push(function (sub_gadget) {\n
return RSVP.all([\n
sub_gadget.render(),\n
sub_gadget.getElement()\n
]);\n
});\n
});\n
}\n
\n
function renderJioDocument(gadget, options) {\n
var sub_options,\n
breadcrumb_options = {};\n
\n
return gadget.getDeclaredGadget("jio_gadget")\n
.push(function (jio_gadget) {\n
var jio_key = options.jio_key,\n
......@@ -173,9 +173,13 @@
return jio_gadget.get({"_id": jio_key}, {"_view": view});\n
})\n
.push(function (result) {\n
breadcrumb_options.title = result.data.title || result.data.reference || options.jio_key;\n
var uri;\n
\n
breadcrumb_options.title = result.data.title ||\n
result.data.reference || options.jio_key;\n
breadcrumb_options.parent_link = result.data._links.parent;\n
var uri = new URI(\n
\n
uri = new URI(\n
result.data._embedded._view._links.form_definition.href\n
);\n
// if ((uri.scheme() === "urn") &&\n
......@@ -194,43 +198,55 @@
]);\n
})\n
.push(function (result) {\n
var content_list = [];\n
\n
sub_options = options.form_gadget || {};\n
sub_options.erp5_document = result[0].data;\n
sub_options.form_definition = result[1].data;\n
sub_options.view = options.view;\n
sub_options.action_view = gadget.props.action_view;\n
\n
return gadget.declareGadget("gadget_erp5_pt_" + sub_options.form_definition.pt + ".html", {\n
scope: "form_gadget"\n
});\n
return RSVP.all([\n
gadget.declareGadget("gadget_erp5_pt_" + sub_options.form_definition.pt + ".html", {\n
scope: "form_gadget"\n
}),\n
gadget.declareGadget("gadget_erp5_tab_list.html", {\n
scope: "erp5_tab"\n
})\n
]);\n
})\n
.push(function (gadget_list) {\n
var form_gadget = gadget_list[0],\n
tab_gadget = gadget_list[1],\n
new_content_action = sub_options.erp5_document._links.action_object_new_content_action,\n
plus_queue,\n
new_element;\n
\n
.push(function (form_gadget) {\n
\n
var new_content_action = sub_options.erp5_document._links.action_object_new_content_action,\n
plus_queue;\n
if (new_content_action === undefined) {\n
var new_element = gadget.__element.querySelector(".ui-icon-plus");\n
new_element.href = "";\n
if (!new_element.classList.contains("ui-disabled")) {\n
new_element.classList.add("ui-disabled");\n
}\n
new_element = gadget.__element.querySelector(".ui-icon-plus");\n
new_element.href = "";\n
if (!new_element.classList.contains("ui-disabled")) {\n
new_element.classList.add("ui-disabled");\n
}\n
} else {\n
// XXX copied from whoWantToDisplayThisPage\n
plus_queue = gadget.aq_pleasePublishMyState({jio_key: gadget.props.jio_key, view: new_content_action.name})\n
.push(function (hash) {\n
var new_element = gadget.__element.querySelector(".ui-icon-plus");\n
new_element = gadget.__element.querySelector(".ui-icon-plus");\n
new_element.href = hash;\n
new_element.classList.remove("ui-disabled");\n
});\n
}\n
\n
return RSVP.all([\n
tab_gadget.render(sub_options),\n
tab_gadget.getElement(),\n
form_gadget.render(sub_options),\n
form_gadget.getElement(),\n
gadget.props.breadcrumb_gadget.render(breadcrumb_options),\n
plus_queue\n
]);\n
})\n
});\n
}\n
\n
\n
......@@ -345,7 +361,6 @@
queue;\n
\n
if (options.jio_key === undefined) {\n
\n
var new_element = gadget.__element.querySelector(".ui-icon-plus");\n
new_element.href = "";\n
if (!new_element.classList.contains("ui-disabled")) {\n
......@@ -374,20 +389,26 @@
\n
$.mobile.loading(\'show\');\n
return queue\n
.push(function (all_response) {\n
var page_element = all_response[1],\n
element = document.querySelector("article");\n
// XXX JQuery mobile\n
// // $.mobile.loading(\'hide\');\n
.push(function (response_list) {\n
var element = document.querySelector("article"),\n
fragment = document.createDocumentFragment(),\n
i,\n
len,\n
item;\n
\n
// add all HTML nodes to fragment\n
for (i = 0, len = response_list.length; i < len; i += 1) {\n
item = response_list[i] || {};\n
if (item.nodeType && item.nodeType == 1) {\n
fragment.appendChild(item);\n
}\n
}\n
\n
// Append in the DOM at the end to reduce flickering and reduce DOM\n
// modifications\n
// Clear the previous rendering\n
// Clear first to DOM, append after to reduce flickering/manip\n
while (element.firstChild) {\n
element.removeChild(element.firstChild);\n
}\n
element.appendChild(page_element);\n
element.appendChild(fragment);\n
\n
$.mobile.loading(\'hide\');\n
return $(element).trigger("create");\n
......@@ -528,7 +549,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>romain</string> </value>
<value> <string>sven</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -542,7 +563,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>936.48944.48108.750</string> </value>
<value> <string>936.54931.34982.25019</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -560,7 +581,7 @@
</tuple>
<state>
<tuple>
<float>1407492633.6</float>
<float>1407849144.68</float>
<string>GMT</string>
</tuple>
</state>
......
50
\ No newline at end of file
51
\ 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