Commit 5c7feef0 authored by Sven Franck's avatar Sven Franck

start adding state related content on initialization

parent a31d3ff6
[ [
{
"type": "hello",
"set_on": "login_dict",
"modernizr": ["localStorage"],
"property_dict": {
"use_login": true
},
"scheme": [{
"property_dict": {
"google" : "1028374738607-pg2qqcopjpoc09shlpul3mehu2dv76ln.apps.googleusercontent.com"
}
}],
"children": []
},
{
"type": "i18n",
"set_on": "lang_dict",
"initializer": "init",
"handler": "language",
"property_dict": {
"use_browser_language": false
},
"scheme": [{
"property_dict": {
"lng": "en-EN",
"load": "current",
"fallbackLng": "en-EN",
"resGetPath": "lang/__lng__/__ns__.json",
"ns": "dict",
"getAsync": false
}
}],
"children": []
},
{ {
"type": "StateMachine", "type": "StateMachine",
"set_on": "state_dict", "set_on": "state_dict",
...@@ -33,40 +67,18 @@ ...@@ -33,40 +67,18 @@
{"name": "found_connection", "from": "probing", "to": "online"} {"name": "found_connection", "from": "probing", "to": "online"}
] ]
} }
}]
},
{
"type": "hello",
"set_on": "login_dict",
"modernizr": ["localStorage"],
"property_dict": {
"use_login": true
},
"scheme": [{
"property_dict": {
"google" : "1028374738607-pg2qqcopjpoc09shlpul3mehu2dv76ln.apps.googleusercontent.com"
}
}], }],
"children": [] "children": [
}, {
{ "generate": "widget",
"type": "i18n", "type": "crumbs",
"set_on": "lang_dict", "children": [
"initializer": "init", {"href": "#", "text": "Synchronization", "text_i18n": "global_dict.sync_status", "icon": "random", "info": "sync_status"},
"handler": "language", {"href": "#", "text": "Login", "text_i18n": "global_dict.login_status", "icon": "user", "info":"login_status"},
"property_dict": { {"href": "#", "text": "Connection", "text_i18n": "global_dict.connection_status", "icon": "signal", "info": "connection_status"}
"use_browser_language": false ]
},
"scheme": [{
"property_dict": {
"lng": "en-EN",
"load": "current",
"fallbackLng": "en-EN",
"resGetPath": "lang/__lng__/__ns__.json",
"ns": "dict"
} }
}], ]
"children": []
}, },
{ {
"type": "status_dict", "type": "status_dict",
......
...@@ -3282,6 +3282,78 @@ ...@@ -3282,6 +3282,78 @@
return document.createDocumentFragment(); return document.createDocumentFragment();
}; };
/* ********************************************************************** */
/* CRUMBS */
/* ********************************************************************** */
/**
* Make a breadcrumb url for easy navigation
* @method breadcrumb
* @param {object} spec Configuration object
* @return {object} HTML fragment
*/
factory.crumbs = function (spec) {
var i, crumb, base, breadcrumb, makeLink, len, pass, icon, patch, space;
len = (spec.children || []).length;
base = "";
space = document.createTextNode("\u00A0");
patch = "#";
makeLink = function (config) {
icon = config.home || config.icon;
return factory.element(
"a",
{
"href": config.href || "#",
"className": (icon ? "ui-btn ui-btn-icon-notext ui-icon-" +
icon + " ui-shadow ui-corner-all" : "ui-link") +
(config.text_i18n ? " translate" : "")
},
{},
{
"data-action": config.action || null,
"data-info": config.info || null,
"data-i18n": config.text_i18n || null,
"text": config.home ? "Home" : (config.text || "\u00A0")
}
);
};
// base element
breadcrumb = factory.element(
"span",
{"className": "crumbs"},
{},
{
"data-info": spec.data_url ? "url" : null,
"data-reference": spec.data_url || null
}
);
// home
if (spec.home) {
breadcrumb.appendChild(
makeLink({"href": app.property_dict.home, "home": "home"})
);
}
// fragments
for (i = 0; i < len; i += 1) {
crumb = spec.children[i];
if (typeof crumb === "string") {
pass = {
"href": base += (patch + crumb),
"text": crumb
};
patch = "/";
}
breadcrumb.appendChild(space);
breadcrumb.appendChild(makeLink(pass || crumb));
breadcrumb.appendChild(space);
}
return breadcrumb;
};
/* ********************************************************************** */ /* ********************************************************************** */
/* JQM POPUP */ /* JQM POPUP */
/* ********************************************************************** */ /* ********************************************************************** */
...@@ -3387,6 +3459,8 @@ ...@@ -3387,6 +3459,8 @@
util.getPage(url_dict.data_url).appendChild(container); util.getPage(url_dict.data_url).appendChild(container);
// and return the placeholder for JQM // and return the placeholder for JQM
return placeholder; return placeholder;
} else {
document.body.appendChild(container);
} }
// also add placeholder to fragment // also add placeholder to fragment
...@@ -3512,6 +3586,8 @@ ...@@ -3512,6 +3586,8 @@
if (url_dict.data_url) { if (url_dict.data_url) {
util.getPage(url_dict.data_url).appendChild(header); util.getPage(url_dict.data_url).appendChild(header);
return undefined; return undefined;
} else {
document.body.appendChild(header);
} }
return header; return header;
...@@ -3607,7 +3683,10 @@ ...@@ -3607,7 +3683,10 @@
if (url_dict.data_url) { if (url_dict.data_url) {
util.getPanel(url_dict.data_url).appendChild(panel); util.getPanel(url_dict.data_url).appendChild(panel);
return undefined; return undefined;
} else {
document.body.insertBefore(panel, document.body.children[0]);
} }
return panel; return panel;
} }
}; };
...@@ -4605,7 +4684,11 @@ ...@@ -4605,7 +4684,11 @@
} }
); );
wrapper.appendChild(app.breadcrumb(url_dict)); wrapper.appendChild(factory.crumbs({
"children": url_dict.fragment_list,
"home": true,
"data-url": url_dict.data_url
}));
wrapper.appendChild(target); wrapper.appendChild(target);
container.appendChild(wrapper); container.appendChild(wrapper);
...@@ -6786,73 +6869,6 @@ ...@@ -6786,73 +6869,6 @@
}; };
}; };
/**
* Make a breadcrumb url for easy navigation
* @method breadcrumb
* @param {object} url_dict Current URL object
* @return {object} HTML fragment
*/
app.breadcrumb = function (url_dict) {
var i,
crumb,
indicator,
translation,
path_builder = "",
translation_failed = true,
breadcrumb = factory.element(
"span",
{"className": "crumbs"},
{"data-info": "url", "data-reference": url_dict.data_url}
),
makeLink = function (path, title, home) {
// test translation dict if the page title is translateable
if (title && i18n) {
translation = map.actions.translateLookup(
"page_dict." + title.split("?")[0] + ".title"
);
translation_failed = util.testForString(title, translation, true);
}
// return link element
return factory.element(
"a",
{
"href": path || "#",
"className": (home ? "ui-btn ui-btn-icon-notext ui-icon-home" +
" ui-shadow ui-corner-all" : "ui-link") +
(translation_failed ? "" : " translate")
},
{"data-enhanced": "true"},
{
"text": home ? "Home" : title,
"data-i18n": home ? "global_dict.home" : (translation_failed
? null : "page_dict." + title.split("?")[0] + ".title")
}
);
};
// home
breadcrumb.appendChild(
makeLink(app.property_dict.home, undefined, true)
);
// fragments
for (i = 0; i < url_dict.fragment_list.length; i += 1) {
crumb = url_dict.fragment_list[i];
indicator = i === 0 ? "#" : "/";
path_builder += indicator + crumb;
breadcrumb.appendChild(document.createTextNode("|\u00A0"));
breadcrumb.appendChild(makeLink(path_builder, crumb));
breadcrumb.appendChild(document.createTextNode("\u00A0"));
}
// translate
if (i18n) {
map.actions.translateNodeList(breadcrumb);
}
return breadcrumb;
};
/** /**
* Set the page title * Set the page title
* @method setPageTitle * @method setPageTitle
...@@ -8594,36 +8610,39 @@ ...@@ -8594,36 +8610,39 @@
} }
} }
return RSVP.all(promise_list) return RSVP.all(promise_list)
// TODO: remove all this, should be handled by setContent // // TODO: remove all this, should be handled by setContent, but
.then (function (response_list) { // // then setContent needs to know where to put things. So if
var target, l, container, i18n; // // we make a footer, set content should insert it into the page or
// // DOM. End.
// create a fragment for promises // .then (function (response_list) {
target = document.createDocumentFragment(); // var target, l, container, i18n;
//
for (l = 0; l < response_list.length; l += 1) { // // create a fragment for promises
container = response_list[l]; // target = document.createDocumentFragment();
// exclude undefined promises (i18n) //
if (container && container.nodeName) { // for (l = 0; l < response_list.length; l += 1) {
// container = response_list[l];
// translate // // exclude undefined promises (i18n)
if (i18n) { // if (container && container.nodeName) {
map.actions.translateNodeList(container); //
} // // translate
// if (i18n) {
// insert panel as first child into DOM // map.actions.translateNodeList(container);
if (util.testForString("ui-panel", container.className)) { // }
document.body.insertBefore( //
container, // // insert panel as first child into DOM
document.body.children[0] // if (util.testForString("ui-panel", container.className)) {
); // document.body.insertBefore(
} else { // container,
target.appendChild(container); // document.body.children[0]
} // );
} // } else {
document.body.appendChild(target); // target.appendChild(container);
} // }
}); // }
// document.body.appendChild(target);
// }
// });
} }
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"global_dict": { "global_dict": {
"connection_status": "Connection", "connection_status": "Connection",
"login_status": "Login", "login_status": "Login",
"sync_status": "Synchronized", "sync_status": "Synchronization",
"about": "About", "about": "About",
"about_subtitle": "", "about_subtitle": "",
"first": "First", "first": "First",
......
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