Commit 9cab121a authored by Jérome Perrin's avatar Jérome Perrin

update static version

parent 2aa28a74
/*global console, jQuery, rJS, RSVP, alert, Handlebars, initGadgetMixin */ /*global console, jQuery, rJS, RSVP, alert, Handlebars, initGadgetMixin, confirm */
/*jslint nomen: true */ /*jslint nomen: true */
(function(window, $, rJS, RSVP, Handlebars, initGadgetMixin) { (function(window, $, rJS, RSVP, Handlebars, initGadgetMixin) {
"use strict"; "use strict";
...@@ -9,10 +9,25 @@ ...@@ -9,10 +9,25 @@
$.mobile.linkBindingEnabled = false; $.mobile.linkBindingEnabled = false;
$.mobile.hashListeningEnabled = false; $.mobile.hashListeningEnabled = false;
$.mobile.pushStateEnabled = false; $.mobile.pushStateEnabled = false;
// Prompt user to reload after manifest update.
// from http://www.html5rocks.com/en/tutorials/appcache/beginner/#toc-updating-cache
window.addEventListener("load", function() {
if (window.applicationCache) {
window.applicationCache.addEventListener("updateready", function() {
if (window.applicationCache.status === window.applicationCache.UPDATEREADY) {
// Browser downloaded a new app cache.
// Swap it in and reload the page to get the new hotness.
window.applicationCache.swapCache();
if (confirm("A new version of this site is available. Load it?")) {
window.location.reload();
}
}
}, false);
}
}, false);
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Minimalistic ERP5's like portal type configuration // Minimalistic ERP5's like portal type configuration
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// XXX we should use lists instead to keep ordering
var portal_types = { var portal_types = {
"Input Module": { "Input Module": {
view: { view: {
...@@ -109,17 +124,37 @@ ...@@ -109,17 +124,37 @@
var nav_html, action; var nav_html, action;
if (portal_types[portal_type][options.action].type === "object_view") { if (portal_types[portal_type][options.action].type === "object_view") {
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
var url_list = [], key2; var url_list = [], action_item_list = [], i, key2;
for (key2 in portal_types[portal_type]) { for (key2 in portal_types[portal_type]) {
if (portal_types[portal_type].hasOwnProperty(key2)) { if (portal_types[portal_type].hasOwnProperty(key2)) {
action = portal_types[portal_type][key2]; action = portal_types[portal_type][key2];
if (action.type === "object_view") { if (action.type === "object_view") {
if (action.condition === undefined || action.condition(gadget)) { if (action.condition === undefined || action.condition(gadget)) {
url_list.push(calculateTabHTML(gadget, options, key2, action.title, key2 === options.action)); action_item_list.push([ key2, action ]);
} }
} }
} }
} }
/*
* Sort actions so that higher priorities are displayed first.
* If no priority is defined, sort by action id to have stable order.
*/
action_item_list.sort(function(a, b) {
var key_a = a[0], value_a = a[1], key_b = b[0], value_b = b[1];
if (!isNaN(value_a.priority)) {
if (!isNaN(value_b.priority)) {
return value_b.priority - value_a.priority;
}
return -1;
}
if (!isNaN(value_b.priority)) {
return 1;
}
return key_a < key_b ? -1 : key_a > key_b ? 1 : 0;
});
for (i = 0; i < action_item_list.length; i += 1) {
url_list.push(calculateTabHTML(gadget, options, action_item_list[i][0], action_item_list[i][1].title, action_item_list[i][0] === options.action));
}
return RSVP.all(url_list); return RSVP.all(url_list);
}).push(function(entry_list) { }).push(function(entry_list) {
var i; var i;
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
}); });
} }
queue = new RSVP.Queue().push(function() { queue = new RSVP.Queue().push(function() {
var property_item_list = [], i, property_name, property_definition, value;
//gadget.props.fieldset_element = document.createElement("fieldset"); //gadget.props.fieldset_element = document.createElement("fieldset");
//gadget.props.element.appendChild(gadget.props.fieldset_element); //gadget.props.element.appendChild(gadget.props.fieldset_element);
gadget.props.fieldset_element = gadget.props.element; gadget.props.fieldset_element = gadget.props.element;
...@@ -77,13 +78,35 @@ ...@@ -77,13 +78,35 @@
}, node_id); }, node_id);
} }
Object.keys(options.property_definition.properties).forEach(function(property_name) { Object.keys(options.property_definition.properties).forEach(function(property_name) {
var property_definition = options.property_definition.properties[property_name], value = (options.value || {})[property_name] === undefined ? property_definition.default : options.value[property_name]; property_item_list.push([ property_name, options.property_definition.properties[property_name] ]);
});
/*
* Sort properties so that higher priorities are displayed first.
* If no priority is defined, sort by property id to have stable order.
*/
property_item_list.sort(function(a, b) {
var key_a = a[0], value_a = a[1], key_b = b[0], value_b = b[1];
if (!isNaN(value_a.priority)) {
if (!isNaN(value_b.priority)) {
return value_b.priority - value_a.priority;
}
return -1;
}
if (!isNaN(value_b.priority)) {
return 1;
}
return key_a < key_b ? -1 : key_a > key_b ? 1 : 0;
});
for (i = 0; i < property_item_list.length; i += 1) {
property_name = property_item_list[i][0];
property_definition = property_item_list[i][1];
value = (options.value || {})[property_name] === undefined ? property_definition.default : options.value[property_name];
// XXX some properties are not editable // XXX some properties are not editable
// XXX should not be defined here // XXX should not be defined here
if (property_name !== "coordinate" && property_name !== "_class" && property_name !== "id") { if (property_name !== "coordinate" && property_name !== "_class" && property_name !== "id") {
addField(property_name, property_definition, value); addField(property_name, property_definition, value);
} }
}); }
}); });
return queue; return queue;
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
......
CACHE MANIFEST CACHE MANIFEST
# This manifest was generated by grunt-manifest HTML5 Cache Manifest Generator # This manifest was generated by grunt-manifest HTML5 Cache Manifest Generator
# Time: Wed May 27 2015 12:36:48 GMT+0200 (CEST) # Time: Fri Jun 19 2015 08:50:17 GMT+0200 (CEST)
CACHE: CACHE:
dream/InputModule_viewAddDocumentDialog.js dream/InputModule_viewAddDocumentDialog.js
......
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