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",
"set_on": "state_dict",
......@@ -33,40 +67,18 @@
{"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": []
},
{
"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"
"children": [
{
"generate": "widget",
"type": "crumbs",
"children": [
{"href": "#", "text": "Synchronization", "text_i18n": "global_dict.sync_status", "icon": "random", "info": "sync_status"},
{"href": "#", "text": "Login", "text_i18n": "global_dict.login_status", "icon": "user", "info":"login_status"},
{"href": "#", "text": "Connection", "text_i18n": "global_dict.connection_status", "icon": "signal", "info": "connection_status"}
]
}
}],
"children": []
]
},
{
"type": "status_dict",
......
......@@ -3282,6 +3282,78 @@
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 */
/* ********************************************************************** */
......@@ -3387,6 +3459,8 @@
util.getPage(url_dict.data_url).appendChild(container);
// and return the placeholder for JQM
return placeholder;
} else {
document.body.appendChild(container);
}
// also add placeholder to fragment
......@@ -3512,6 +3586,8 @@
if (url_dict.data_url) {
util.getPage(url_dict.data_url).appendChild(header);
return undefined;
} else {
document.body.appendChild(header);
}
return header;
......@@ -3607,7 +3683,10 @@
if (url_dict.data_url) {
util.getPanel(url_dict.data_url).appendChild(panel);
return undefined;
} else {
document.body.insertBefore(panel, document.body.children[0]);
}
return panel;
}
};
......@@ -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);
container.appendChild(wrapper);
......@@ -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
* @method setPageTitle
......@@ -8594,36 +8610,39 @@
}
}
return RSVP.all(promise_list)
// TODO: remove all this, should be handled by setContent
.then (function (response_list) {
var target, l, container, i18n;
// create a fragment for promises
target = document.createDocumentFragment();
for (l = 0; l < response_list.length; l += 1) {
container = response_list[l];
// exclude undefined promises (i18n)
if (container && container.nodeName) {
// translate
if (i18n) {
map.actions.translateNodeList(container);
}
// insert panel as first child into DOM
if (util.testForString("ui-panel", container.className)) {
document.body.insertBefore(
container,
document.body.children[0]
);
} else {
target.appendChild(container);
}
}
document.body.appendChild(target);
}
});
// // TODO: remove all this, should be handled by setContent, but
// // then setContent needs to know where to put things. So if
// // we make a footer, set content should insert it into the page or
// // DOM. End.
// .then (function (response_list) {
// var target, l, container, i18n;
//
// // create a fragment for promises
// target = document.createDocumentFragment();
//
// for (l = 0; l < response_list.length; l += 1) {
// container = response_list[l];
// // exclude undefined promises (i18n)
// if (container && container.nodeName) {
//
// // translate
// if (i18n) {
// map.actions.translateNodeList(container);
// }
//
// // insert panel as first child into DOM
// if (util.testForString("ui-panel", container.className)) {
// document.body.insertBefore(
// container,
// document.body.children[0]
// );
// } else {
// target.appendChild(container);
// }
// }
// document.body.appendChild(target);
// }
// });
}
};
......
......@@ -2,7 +2,7 @@
"global_dict": {
"connection_status": "Connection",
"login_status": "Login",
"sync_status": "Synchronized",
"sync_status": "Synchronization",
"about": "About",
"about_subtitle": "",
"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