Commit f7a641e7 authored by Sven Franck's avatar Sven Franck

app: add configurable action button (default search)

parent 2ad4cc98
......@@ -483,21 +483,25 @@
}
// add action button
// TODO: should this be a submit via option?
if (spec.logic.action) {
container.appendChild(factory.element({
"type": "a",
"direct": {
"title": "Search",
"className": "action ui-input-action ui-btn ui-icon-search " +
"ui-btn-icon-notext ui-corner-all translate ",
"title": spec.logic.action.text || "Search",
"className": "ui-input-action ui-btn ui-icon-" +
(spec.logic.action.icon || "search") +
" ui-btn-icon-notext ui-corner-all translate ",
"href": "#"
},
"attributes": {
"data-i18n": "global_dict.search",
"data-i18n": ("[title]" + spec.logic.action.text_i18n + ";" +
spec.logic.action.text_i18n) ||
"[title]global_dict.search;global_dict.search",
"tabindex": "-1",
"data-action": "search"
"data-action": spec.logic.action.action || "search"
},
"logic": {"text": "Search"}
"logic": {"text": spec.logic.action.text || "Search"}
}));
}
......@@ -802,7 +806,7 @@
},
"logic": {}
});
// TODO?
if (spec.form) {
target.appendChild(factory.element({
......@@ -837,7 +841,12 @@
* "id": null,
* "title": "",
* "title_i18n":"",
* "fixed": true
* "fixed": true,
* "image": {
* "src": null,
* "alt": null,
* "alt_i18n": null
* }
* },
* "children": [],
* }
......@@ -846,25 +855,13 @@
* @return {object} object including fragment, child-selector, placeholder
*/
factory.widget.header = function (spec) {
var container, id, title, target, fragment;
var container, id, target, fragment;
container = document.createDocumentFragment();
id = spec.id || ((spec.data_url || "global") + "-header");
// generate title (needed for JQM), default to empty string
title = factory.element({
"type": "h1",
"direct": {"className": "translate ui-title"},
"attributes": {
"data-i18n": spec.title_i18n || "",
"role": "heading",
"aria-level": "1"
},
"logic": {"text": spec.title || "\u00A0"}
});
// button group wrappers and title (inserted before last wrapper!)
target = function (j, len) {
target = function (j, len, conf) {
switch (true) {
case (j === 0):
return factory.element({
......@@ -873,7 +870,28 @@
});
case (j === len - 1):
fragment = document.createDocumentFragment();
fragment.appendChild(title);
if (conf.img) {
fragment.appendChild(factory.element({
"type": "img",
"direct": {"src": conf.src},
"attributes": {"alt": conf.title},
"logic": {
"data-i18n": config.title_i18n ?
("[alt]" + config.title_i18n) : null
}
}));
} else {
fragment.appendChild(factory.element({
"type": "h1",
"direct": {"className": "translate ui-title"},
"attributes": {
"data-i18n": conf.title_i18n || "",
"role": "heading",
"aria-level": "1"
},
"logic": {"text": conf.title || "\u00A0"}
}));
}
fragment.appendChild(
factory.element({
"type": "div",
......@@ -909,7 +927,13 @@
"fragment": container,
"child_selector": container.querySelector("#" + id),
"target": target,
"target_selector": "last"
"target_selector": "last",
"spec": {
"img": spec.image,
"src": spec.src,
"title": spec.title || spec.alt,
"title_i18n": spec.title_i18n || spec.alt_i18n
}
};
};
......@@ -1344,7 +1368,7 @@
"attributes": {
"data-role": "panel",
"data-theme": spec.theme,
"data-position": "left",
"data-position": spec.position || "left",
"data-display": "push",
"data-position-fixed": true
},
......@@ -2666,7 +2690,7 @@
}
obj.gadget.setAttribute("data-reference", pointer);
};
/* ====================================================================== */
/* MAPPING */
......@@ -3232,7 +3256,7 @@
app.search(obj);
}
};
/* ********************************************************************** */
/* Mapper Generic Element */
/* ********************************************************************** */
......@@ -4183,7 +4207,7 @@
if (field.field && select_list.indexOf(field.field) === -1) {
select_list.push(field.field);
}
}
}
}
// if nothing is to be fetched, make sure we return at least the _id
if (select_list.length === 0 && select_list.indexOf("_id") === -1) {
......@@ -5916,7 +5940,7 @@
// ============= TODO: improve property_dict generation ==============
// TODO: no all elements need them?
// TODO:
// TODO:
// wrapper object and properties
quirk_dict = util.mergeObject(
(pass[method ? "content_dict" : "config_dict"].property_dict),
......@@ -5938,7 +5962,7 @@
if (quirk_dict.skip) {
if (!pass.content_dict.generate) {
route = type;
// force custom elements into form layout...
// force custom elements into form layout...
if (pass.content_dict.logic && pass.content_dict.logic.route) {
route = pass.content_dict.logic.route;
}
......@@ -6187,10 +6211,12 @@
target = undefined;
if (response) {
// generate target for and append response
// NOTE: wrapper.spec is used for header only
if (wrapper.target) {
wrapper_selector = wrapper.target(
wrapper.child_selector.children.length,
kids.length
kids.length,
wrapper.spec
);
// NOTE: wrapper_selector will return a fragment (set to
// first/last-ElementChild or a DOM node
......
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