Commit 719d051e authored by Sven Franck's avatar Sven Franck

jslint...

parent 3fd2cbad
...@@ -877,22 +877,24 @@ ...@@ -877,22 +877,24 @@
img = spec.image || {}; img = spec.image || {};
// button group wrappers and title (inserted before last wrapper!) // button group wrappers and title (inserted before last wrapper!)
target = function (j, len, conf) { target = function (spec) {
var position, drop_content, fragment; var position, drop_content, fragment, count, config;
count = spec.j;
config = spec.config;
fragment = document.createDocumentFragment(); fragment = document.createDocumentFragment();
position = (conf.section_list || ["first", "last"])[j]; position = (config.section_list || ["first", "last"])[count];
drop_content = conf.add_content === 0 ? 0 : 1; drop_content = config.add_content === 0 ? 0 : 1;
if (j === drop_content) { if (count === drop_content) {
if (conf && conf.img) { if (config && config.img) {
fragment.appendChild(factory.element({ fragment.appendChild(factory.element({
"type": "img", "type": "img",
"direct": {"src": conf.src, "className": "ui-title-logo"}, "direct": {"src": config.src, "className": "ui-title-logo"},
"attributes": {"alt": conf.title}, "attributes": {"alt": config.title},
"logic": { "logic": {
"data-i18n": conf.title_i18n ? "data-i18n": config.title_i18n ?
("[alt]" + conf.title_i18n) : null ("[alt]" + config.title_i18n) : null
} }
})); }));
} else { } else {
...@@ -900,11 +902,11 @@ ...@@ -900,11 +902,11 @@
"type": "h1", "type": "h1",
"direct": {"className": "translate ui-title"}, "direct": {"className": "translate ui-title"},
"attributes": { "attributes": {
"data-i18n": conf.title_i18n || "", "data-i18n": config.title_i18n || "",
"role": "heading", "role": "heading",
"aria-level": "1" "aria-level": "1"
}, },
"logic": {"text": conf.title || "\u00A0"} "logic": {"text": config.title || "\u00A0"}
})); }));
} }
} }
...@@ -991,16 +993,17 @@ ...@@ -991,16 +993,17 @@
direction = spec.direction || "vertical"; direction = spec.direction || "vertical";
// NOTE: will only be used for dynamic element creation // NOTE: will only be used for dynamic element creation
generator = function (el, wrapper, i) { generator = function (spec) {
var element = spec.item;
// TODO: no! // TODO: no!
if (el.center) { if (element.center) {
el.text = el.center[0].title; element.text = element.center[0].title;
el.text_i18n = el.center[0].title_i18n; element.text_i18n = element.center[0].title_i18n;
} }
el.iconpos = "right"; element.iconpos = "right";
return { return {
"type": "item", "type": "item",
"content": factory.util.generateContentElement("link", el, {})[0] "content": factory.util.generateContentElement("link", element, {})[0]
}; };
}; };
...@@ -1240,11 +1243,11 @@ ...@@ -1240,11 +1243,11 @@
var container, controls, element, target; var container, controls, element, target;
container = document.createDocumentFragment(); container = document.createDocumentFragment();
target = function (j) { target = function (spec) {
return factory.element({ return factory.element({
"type": "li", "type": "li",
"direct": { "direct": {
"className": "ui-block-" + util.toLetter(j + 1).toLowerCase() "className": "ui-block-" + util.toLetter(spec.j + 1).toLowerCase()
} }
}); });
}; };
...@@ -1370,9 +1373,12 @@ ...@@ -1370,9 +1373,12 @@
id = spec.id || ((spec.data_url || "global") + "-panel"); id = spec.id || ((spec.data_url || "global") + "-panel");
// content wrapper with optional close button // content wrapper with optional close button
wrap = function (j, len) { wrap = function (spec) {
var fragment, element; var fragment, element, count, len;
if (j === 0) {
count = spec.j;
len = spec.len;
if (count === 0) {
fragment = document.createDocumentFragment(); fragment = document.createDocumentFragment();
element = factory.element({ element = factory.element({
"type": "div", "type": "div",
...@@ -1384,7 +1390,7 @@ ...@@ -1384,7 +1390,7 @@
element.appendChild(closer); element.appendChild(closer);
} }
fragment.appendChild(element); fragment.appendChild(element);
} else if (j === len - 1) { } else if (count === len - 1) {
fragment = factory.element({ fragment = factory.element({
"type": "div", "type": "div",
"direct": {"className": "panel_element panel_element_last"} "direct": {"className": "panel_element panel_element_last"}
...@@ -1561,6 +1567,7 @@ ...@@ -1561,6 +1567,7 @@
// assemble // assemble
container.appendChild(form); container.appendChild(form);
// TODO: WHY?
wrap = undefined; wrap = undefined;
return { return {
"fragment": container, "fragment": container,
...@@ -1618,13 +1625,15 @@ ...@@ -1618,13 +1625,15 @@
controller, i, id, radio_id; controller, i, id, radio_id;
// makes carousel elements // makes carousel elements
generator = function (element, wrapper, i) { generator = function (spec) {
var item, target, has_link; var element, target, has_link, count, item;
element = spec.item;
count = spec.count;
has_link = element.href; has_link = element.href;
item = factory.element({ item = factory.element({
"type": "li", "type": "li",
"direct": {"className": (i === 0 ? "ui-carousel-active" : "")} "direct": {"className": (count === 0 ? "ui-carousel-active" : "")}
}); });
if (has_link) { if (has_link) {
...@@ -1811,11 +1820,13 @@ ...@@ -1811,11 +1820,13 @@
var fragment, has_filter, generator; var fragment, has_filter, generator;
// generate list item // generate list item
generator = function (element, wrapper, i) { generator = function (spec) {
var divider, static_item, theme, config, auto, last, item, target, list, var divider, static_item, theme, config, auto, last, item, target, list,
content; content, element, count;
config = wrapper.property_dict; element = spec.item;
config = spec.wrapper.property_dict;
count = spec.i;
divider = element.type === "divider" ? true : undefined; divider = element.type === "divider" ? true : undefined;
static_item = (element.href === undefined && !divider) ? true : undefined; static_item = (element.href === undefined && !divider) ? true : undefined;
theme = config.divider_theme || config.theme || "inherit"; theme = config.divider_theme || config.theme || "inherit";
...@@ -1829,8 +1840,8 @@ ...@@ -1829,8 +1840,8 @@
"type": "li", "type": "li",
"direct": { "direct": {
"className": "ui-li-divider ui-bar-" + theme + "className": "ui-li-divider ui-bar-" + theme +
(i === 0 ? " ui-first-child" : (count === 0 ? " ui-first-child" :
((i === config.length - 1) ? ((count === config.length - 1) ?
" ui-last-child" : "")) " ui-last-child" : ""))
}, },
"attributes": {}, "attributes": {},
...@@ -1861,8 +1872,8 @@ ...@@ -1861,8 +1872,8 @@
"type": "li", "type": "li",
"direct": { "direct": {
"className": divider ? ("ui-li-divider ui-bar-" + theme) : " " + "className": divider ? ("ui-li-divider ui-bar-" + theme) : " " +
(i === 0 ? " ui-first-child " : (count === 0 ? " ui-first-child " :
((i === config.length - 1) ? ((count === config.length - 1) ?
" ui-last-child " : " ")) + content.pop() + " ui-last-child " : " ")) + content.pop() +
(static_item ? " ui-li-static ui-body-inherit " : " ") + (static_item ? " ui-li-static ui-body-inherit " : " ") +
(config.form_item ? "ui-field-contain " : " ") + (config.form_item ? "ui-field-contain " : " ") +
...@@ -2043,13 +2054,14 @@ ...@@ -2043,13 +2054,14 @@
}); });
}; };
generator = function (element, wrapper, i) { generator = function (spec) {
var quirk_dict, row, temp, cell, j, field, link, logic, faux_id, var quirk_dict, row, temp, cell, j, field, link, logic, faux_id,
attributes, property, snippet, title, k, button, group, dict, set, attributes, property, snippet, title, k, button, group, dict, set,
wrap, lookup, item_href; wrap, lookup, item_href, element;
quirk_dict = wrapper.property_dict; element = spec.item;
wrap = wrapper.wrap; quirk_dict = spec.wrapper.property_dict;
wrap = spec.wrapper.wrap;
temp = {}; temp = {};
row = factory.element({ row = factory.element({
"type": "tr", "type": "tr",
...@@ -2291,7 +2303,7 @@ ...@@ -2291,7 +2303,7 @@
"child_mapper": spec.map_children, "child_mapper": spec.map_children,
"base": "tr", "base": "tr",
"count": counter, "count": counter,
"target": target.fragment "target": target
}; };
}; };
...@@ -3267,12 +3279,20 @@ ...@@ -3267,12 +3279,20 @@
if (wrapper.child_mapper) { if (wrapper.child_mapper) {
if (element.scheme) { if (element.scheme) {
// NOTE: chaining allows the mapper to make additional async requests! // NOTE: chaining allows the mapper to make additional async requests!
return map[wrapper.child_mapper](element, wrapper, i) return map[wrapper.child_mapper]({
"item": element,
"wrapper": wrapper,
"count": i
})
.then(function (response) { .then(function (response) {
// may still need a widget constructor to run over mapped response // may still need a widget constructor to run over mapped response
if (wrapper.child_constructor) { if (wrapper.child_constructor) {
return RSVP.resolve( return RSVP.resolve(
wrapper.child_constructor(response, wrapper, i) wrapper.child_constructor({
"item": response,
"wrapper": wrapper,
"count": i
})
); );
} }
// no need for constructor // no need for constructor
...@@ -3292,18 +3312,17 @@ ...@@ -3292,18 +3312,17 @@
/** /**
* Map records to factory widget table item * Map records to factory widget table item
* @method tableItem * @method tableItem
* @param {object} item Items to be mapped * @param {object} spec Object containing element, parent and counter
* @param {object} wrapper Configuration object containing parent info
* @param {integer} i Counter indicating current item
* @return {object} mapped object * @return {object} mapped object
**/ **/
// TODO: multiple header rows! // TODO: multiple header rows!
// TODO: action_menu input + form? // TODO: action_menu input + form?
// TODO: how to handle translations of record texts? // TODO: how to handle translations of record texts?
map.tableItem = function (item, wrapper, i) { map.tableItem = function (spec) {
var j, k, segment, row, cell, id, quirk_dict, record, new_item; var j, k, segment, row, cell, id, quirk_dict, record, new_item, item;
quirk_dict = wrapper.property_dict; quirk_dict = spec.parent.property_dict;
item = spec.item;
record = item.doc; record = item.doc;
id = record[quirk_dict.link_identifier] || record._id || item._id; id = record[quirk_dict.link_identifier] || record._id || item._id;
new_item = {}; new_item = {};
...@@ -3351,20 +3370,19 @@ ...@@ -3351,20 +3370,19 @@
/** /**
* Map records to factory widget listview and carousel * Map records to factory widget listview and carousel
* @method listItem * @method listItem
* @param {object} item Item to be mapped * @param {object} spec Object containing element, parent and counter
* @param {object} wrapper Configuration object containing parent info
* @param {integer} i Counter indicating current item
* @return {object} mapped object * @return {object} mapped object
**/ **/
// TODO: move radio/check into property_dict and item? or do same on tableItem // TODO: move radio/check into property_dict and item? or do same on tableItem
// TODO: not nice & find better handling for text elements and i18n tags // TODO: not nice & find better handling for text elements and i18n tags
// NOTE: make sure there is no "id" flying through here!!! only _id // NOTE: make sure there is no "id" flying through here!!! only _id
map.listItem = function (item, wrapper, i) { map.listItem = function (spec) {
var quirk_dict, section, pos, label, j, k, field, setter, record, new_item, var quirk_dict, section, pos, label, j, k, field, setter, record, new_item,
id, key, obj, translation_fields; id, key, obj, translation_fields, item;
translation_fields = "titletextlabel"; translation_fields = "titletextlabel";
quirk_dict = wrapper.property_dict; quirk_dict = spec.wrapper.property_dict;
item = spec.item;
record = item.doc; record = item.doc;
id = record[quirk_dict.link_identifier] || record._id || item._id; id = record[quirk_dict.link_identifier] || record._id || item._id;
new_item = {}; new_item = {};
...@@ -3425,19 +3443,18 @@ ...@@ -3425,19 +3443,18 @@
/** /**
* Map records to factory widget form item * Map records to factory widget form item
* @method formItem * @method formItem
* @param {object} item Item to be mapped (record) * @param {object} spec Object containing element, parent and counter
* @param {object} wrapper Configuration object containing parent info
* @param {integer} i Counter indicating current item
* @return {object} mapped object * @return {object} mapped object
**/ **/
// TODO: should a span still have full structure (label/container)? // TODO: should a span still have full structure (label/container)?
// TODO: should we wrap in span_12 here. why do we wrap at all, do with CSS // TODO: should we wrap in span_12 here. why do we wrap at all, do with CSS
map.formItem = function (item, wrapper, i) { map.formItem = function (spec) {
var helper, getHelp, j, k, segment, section, field, setValue, root, veto, var helper, getHelp, j, k, segment, section, field, setValue, root, veto,
textarea_value, override_value, value, field_value, validation_list, textarea_value, override_value, value, field_value, validation_list,
class_list, el, type, clear, alt_name, fetch_items, pass, class_list, el, type, clear, alt_name, fetch_items, pass,
field_list, l, m, section_list, container, disabled, readonly; field_list, l, m, section_list, container, disabled, readonly, item;
item = spec.item;
getHelp = function (prop) { getHelp = function (prop) {
return { return {
"generate": "widget", "generate": "widget",
...@@ -4483,7 +4500,7 @@ ...@@ -4483,7 +4500,7 @@
app.util.loader("", "status_dict.forwarding"); app.util.loader("", "status_dict.forwarding");
answer = util.parse(response); answer = util.parse(response);
id = answer.id; id = answer.id;
decode = /%[0-9a-f]{2}/i..test(id); decode = /%[0-9a-f]{2}/i.test(id);
goto_page = decode ? id : window.encodeURIComponent(id); goto_page = decode ? id : window.encodeURIComponent(id);
$.mobile.changePage(obj.state.callback.replace("__id__", goto_page)); $.mobile.changePage(obj.state.callback.replace("__id__", goto_page));
...@@ -6271,11 +6288,11 @@ ...@@ -6271,11 +6288,11 @@
// NOTE: len is needed for header only to place title // NOTE: len is needed for header only to place title
// TODO: no longer needed, remove // TODO: no longer needed, remove
if (wrapper.target) { if (wrapper.target) {
wrapper_selector = wrapper.target( wrapper_selector = wrapper.target({
wrapper.child_selector.children.length, "j": wrapper.child_selector.children.length,
kids.length, "len": kids.length,
wrapper.spec "config": wrapper.spec
); });
// NOTE: wrapper_selector will return a fragment (set to // NOTE: wrapper_selector will return a fragment (set to
// first/last-ElementChild or a DOM node // first/last-ElementChild or a DOM node
done_target = done_target =
......
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