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

jslint...

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