Commit b874a0b0 authored by Sven Franck's avatar Sven Franck

debug: firstElementChild and firstChild

parent 5a1fae4c
...@@ -272,7 +272,8 @@ ...@@ -272,7 +272,8 @@
// optionally wrap input in a div-fieldcontain // optionally wrap input in a div-fieldcontain
// NOTE: route is for custom HTML elements... service_instance_status // NOTE: route is for custom HTML elements... service_instance_status
if (!spec.logic.route && (spec.logic.wrap !== true && spec.wrap !== true) || hidden_field) { if ((!spec.logic.route && (spec.logic.wrap !== true && spec.wrap !== true))
|| hidden_field) {
wrapper = document.createDocumentFragment(); wrapper = document.createDocumentFragment();
} else { } else {
wrapper = factory.element({ wrapper = factory.element({
...@@ -447,8 +448,7 @@ ...@@ -447,8 +448,7 @@
// add <span> which contains JQM current select // add <span> which contains JQM current select
if (element_reverse) { if (element_reverse) {
element_target.appendChild(factory.element({ element_target.appendChild(factory.element({"type": "span"}));
"type": "span"}));
} else { } else {
element_target = container; element_target = container;
} }
...@@ -473,7 +473,7 @@ ...@@ -473,7 +473,7 @@
element_target.appendChild(factory.element({ element_target.appendChild(factory.element({
"type": "span", "type": "span",
"direct": {"className": "ui-invalid-label translate"}, "direct": {"className": "ui-invalid-label translate"},
"attributes": {"data-i18n":"validation_dict.required_field"} "attributes": {"data-i18n": "validation_dict.required_field"}
})); }));
} }
...@@ -886,7 +886,7 @@ ...@@ -886,7 +886,7 @@
// button group wrappers and title (inserted before last wrapper!) // button group wrappers and title (inserted before last wrapper!)
target = function (new_spec) { target = function (new_spec) {
var position, drop_content, fragment, count, config, i, len, source; var position, drop_content, fragment, count, config, i, len;
count = new_spec.j; count = new_spec.j;
config = new_spec.config; config = new_spec.config;
...@@ -911,11 +911,6 @@ ...@@ -911,11 +911,6 @@
pic = factory.element({"type": "picture"}); pic = factory.element({"type": "picture"});
len = config.src_set.length; len = config.src_set.length;
// // all hail IE9
// pic.appendChild(
// document.createTextNode('<!--[if IE 9]><video style="display: none;"><![endif]-->')
// );
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
pic.appendChild(factory.element({ pic.appendChild(factory.element({
"type": "source", "type": "source",
...@@ -924,21 +919,16 @@ ...@@ -924,21 +919,16 @@
})); }));
} }
// // again...
// pic.appendChild(
// document.createTextNode('<!--[if IE 9]></video><![endif]-->')
// );
pic.appendChild(factory.element({ pic.appendChild(factory.element({
"type": "img", "type": "img",
"direct": {"className": "ui-title-logo", "alt": config.alt}, "direct": {"className": "ui-title-logo", "alt": config.alt},
"attributes": {"srcset": config.src_set[len - 1].srcset} "attributes": {"srcset": config.src_set[len - 1].srcset}
})); }));
source = factory.element({ // source = factory.element({
"type": "img", // "type": "img",
"direct": {"alt": config.alt}, // "direct": {"alt": config.alt},
"attributes": {"srcset": config.src_set[len - 1].srcset} // "attributes": {"srcset": config.src_set[len - 1].srcset}
}); // });
fragment.appendChild(pic); fragment.appendChild(pic);
} else { } else {
fragment.appendChild(factory.element({ fragment.appendChild(factory.element({
...@@ -1317,7 +1307,7 @@ ...@@ -1317,7 +1307,7 @@
"type": "div", "type": "div",
"direct": {"className": "navbar ui-navbar " + (spec.class_list || "")}, "direct": {"className": "navbar ui-navbar " + (spec.class_list || "")},
"attributes": { "attributes": {
"role": "navigation", "role": "navigation"
}, },
"logic": {"data-reference": spec.reference || null} "logic": {"data-reference": spec.reference || null}
}); });
...@@ -1882,7 +1872,7 @@ ...@@ -1882,7 +1872,7 @@
// TODO: dividers? will not be in spec, so can only be listview option! // TODO: dividers? will not be in spec, so can only be listview option!
// TODO: find better way to set mapper/widget // TODO: find better way to set mapper/widget
factory.widget.listview = function (spec) { factory.widget.listview = function (spec) {
var fragment, has_filter, generator; var fragment, generator;
// generate list item // generate list item
generator = function (generator_spec) { generator = function (generator_spec) {
...@@ -1972,14 +1962,12 @@ ...@@ -1972,14 +1962,12 @@
// NOTE: if input provided, the filter is already there! // NOTE: if input provided, the filter is already there!
// THIS MAKES B // THIS MAKES B
if (spec.filter && !spec.input) { if (spec.filter && !spec.input) {
has_filter = true; fragment.appendChild(factory.widget.formElement(
fragment.appendChild(factory.widget.formElement( factory.util.searchBarTemplate({
factory.util.searchBarTemplate({
"search_id": spec.id || "search", "search_id": spec.id || "search",
"text": spec.text || "", "text": spec.text || "",
"text_i18n": spec.text_i18n || null "text_i18n": spec.text_i18n || null
}) })
)); ));
} }
...@@ -2005,7 +1993,8 @@ ...@@ -2005,7 +1993,8 @@
return { return {
"fragment": fragment, "fragment": fragment,
"child_selector": spec.update !== true ? fragment.querySelector("ul") : fragment, "child_selector": spec.update !== true ?
fragment.querySelector("ul") : fragment,
"child_constructor": generator, "child_constructor": generator,
"child_mapper": spec.map_children, "child_mapper": spec.map_children,
"base": "li", "base": "li",
...@@ -2327,7 +2316,7 @@ ...@@ -2327,7 +2316,7 @@
tag = factory.element({"type": "thead"}); tag = factory.element({"type": "thead"});
tag.appendChild( tag.appendChild(
generator({ generator({
"item":section.field_list, "item": section.field_list,
"wrapper": { "wrapper": {
"property_dict": spec, "property_dict": spec,
"wrap": true "wrap": true
...@@ -2388,7 +2377,7 @@ ...@@ -2388,7 +2377,7 @@
" translate" " translate"
}, },
"attributes": { "attributes": {
"data-i18n": "global_dict." + config.href.replace(/[#\/]/g,'') "data-i18n": "global_dict." + config.href.replace(/[#\/]/g, '')
}, },
"logic": { "logic": {
"data-action": config.action || null, "data-action": config.action || null,
...@@ -2589,7 +2578,8 @@ ...@@ -2589,7 +2578,8 @@
"direct": { "direct": {
"id": "select_" + (spec.id || id), "id": "select_" + (spec.id || id),
"name": "select_" + "name": "select_" +
(is_type ? (spec.id || id) : (spec.id || id || config.id).slice(0, -2)), (is_type ? (spec.id || id) :
(spec.id || id || config.id).slice(0, -2)),
"className": spec.action ? "action" : "" "className": spec.action ? "action" : ""
}, },
"attributes": input_dict, "attributes": input_dict,
...@@ -2768,7 +2758,7 @@ ...@@ -2768,7 +2758,7 @@
"clear": "true", "clear": "true",
"action": "search", "action": "search",
"data-i18n": spec.text_i18n ? "data-i18n": spec.text_i18n ?
("[placeholder]" + spec.text_i18n) : null ("[placeholder]" + spec.text_i18n) : null
} }
}; };
}; };
...@@ -2779,7 +2769,7 @@ ...@@ -2779,7 +2769,7 @@
* @return {object} finished config object * @return {object} finished config object
**/ **/
factory.util.searchBar = function (spec) { factory.util.searchBar = function (spec) {
var i, element_list, search_id, props, class_list, spec_list; var i, element_list, search_id, props, spec_list;
search_id = spec.search_id = "search_" + util.uuid(); search_id = spec.search_id = "search_" + util.uuid();
props = spec.slot ? {"slot": spec.slot} : {}; props = spec.slot ? {"slot": spec.slot} : {};
...@@ -3030,9 +3020,15 @@ ...@@ -3030,9 +3020,15 @@
}) })
.fail(function (error) { .fail(function (error) {
switch (error.status) { switch (error.status) {
case 408: app.util.loader("", "status_dict.timeout", "clock-o"); break; case 408:
case 400: app.util.loader("", "validation_dict.general", "ban"); break; app.util.loader("", "status_dict.timeout", "clock-o");
default: app.util.loader("", "status_dict.error", "ban"); break; break;
case 400:
app.util.loader("", "validation_dict.general", "ban");
break;
default:
app.util.loader("", "status_dict.error", "ban");
break;
} }
}); });
}, },
...@@ -3052,7 +3048,7 @@ ...@@ -3052,7 +3048,7 @@
* @param {object} obj Action Object * @param {object} obj Action Object
**/ **/
"update_bip": function (obj) { "update_bip": function (obj) {
var identifier, element_list, i, len, value = undefined; var element_list, i, len, value;
if (obj.form) { if (obj.form) {
element_list = obj.form.getElementsByTagName("input"); element_list = obj.form.getElementsByTagName("input");
for (i = 0, len = element_list.length; i < len; i += 1) { for (i = 0, len = element_list.length; i < len; i += 1) {
...@@ -3063,45 +3059,57 @@ ...@@ -3063,45 +3059,57 @@
} }
if (value) { if (value) {
return storage.fetch({ storage.fetch({
"query": {"_id": value}, "query": {"_id": value},
"pass": obj.pass || {} "pass": obj.pass || {}
}) })
.then(function (reply) { .then(function (reply) {
obj.backpack = reply.response.data.rows[0].doc; obj.backpack = reply.response.data.rows[0].doc;
}) })
.then(function () { .then(function () {
return storage.write(obj) return storage.write(obj)
.then(function (response) { .then(function (response) {
app.util.loader("", "status_dict.saved", "check"); app.util.loader("", "status_dict.saved", "check");
app.navigate(obj, response); app.navigate(obj, response);
}) })
.fail(function (error) { .fail(function (error) {
switch (error.status) { switch (error.status) {
case 408: app.util.loader("", "status_dict.timeout", "clock-o"); break; case 408:
case 400: app.util.loader("", "validation_dict.general", "ban"); break; app.util.loader("", "status_dict.timeout", "clock-o");
default: app.util.loader("", "status_dict.error", "ban"); break; break;
} case 400:
}); app.util.loader("", "validation_dict.general", "ban");
}) break;
.fail(app.util.error); default:
app.util.loader("", "status_dict.error", "ban");
break;
}
});
})
.fail(app.util.error);
} else { } else {
return storage.write(obj) storage.write(obj)
.then(function (response) { .then(function (response) {
app.util.loader("", "status_dict.saved", "check"); app.util.loader("", "status_dict.saved", "check");
app.navigate(obj, response); app.navigate(obj, response);
}) })
.fail(function (error) { .fail(function (error) {
switch (error.status) { switch (error.status) {
case 408: app.util.loader("", "status_dict.timeout", "clock-o"); break; case 408:
case 400: app.util.loader("", "validation_dict.general", "ban"); break; app.util.loader("", "status_dict.timeout", "clock-o");
default: app.util.loader("", "status_dict.error", "ban"); break; break;
case 400:
app.util.loader("", "validation_dict.general", "ban");
break;
default:
app.util.loader("", "status_dict.error", "ban");
break;
} }
}); });
} }
}, },
/** /**
* PUT an object * PUT an object
* @method update * @method update
...@@ -3115,21 +3123,27 @@ ...@@ -3115,21 +3123,27 @@
}) })
.fail(function (error) { .fail(function (error) {
switch (error.status) { switch (error.status) {
case 408: app.util.loader("", "status_dict.timeout", "clock-o"); break; case 408:
case 400: app.util.loader("", "validation_dict.general", "ban"); break; app.util.loader("", "status_dict.timeout", "clock-o");
default: app.util.loader("", "status_dict.error", "ban"); break; break;
case 400:
app.util.loader("", "validation_dict.general", "ban");
break;
default:
app.util.loader("", "status_dict.error", "ban");
break;
} }
}); });
}, },
/** /**
* Same as put but since there is no time to make dyno interaction, we cheat! * Same as put but since there is no time to make dyno interaction, cheat!
* @method update * @method update
* @param {object} obj Action Object * @param {object} obj Action Object
**/ **/
"update_custom": function (obj) { "update_custom": function (obj) {
storage.write(obj) storage.write(obj)
.then(function (response) { .then(function () {
var i, len, dyno_list, dyno, promise_list, dump; var i, len, dyno_list, dyno, promise_list, dump;
// clear active page, because we need to reload // clear active page, because we need to reload
...@@ -3152,7 +3166,8 @@ ...@@ -3152,7 +3166,8 @@
"portal_type_title": dyno.state.title, "portal_type_title": dyno.state.title,
"property_dict": util.mergeObject( "property_dict": util.mergeObject(
{"dynamic": true}, {"dynamic": true},
dyno.state.dyno_dict), dyno.state.dyno_dict
),
"scheme": dyno.state.scheme "scheme": dyno.state.scheme
}, },
{ {
...@@ -3163,10 +3178,10 @@ ...@@ -3163,10 +3178,10 @@
}, },
false false
) )
.fail(app.util.error); .fail(app.util.error);
} }
return RSVP.all(promise_list) return RSVP.all(promise_list)
.then(function (response_list) { .then(function () {
app.util.loader("", "status_dict.saved", "check"); app.util.loader("", "status_dict.saved", "check");
//app.navigate(obj, response); //app.navigate(obj, response);
}) })
...@@ -3175,9 +3190,15 @@ ...@@ -3175,9 +3190,15 @@
.then(app.setPageBindings) .then(app.setPageBindings)
.fail(function (error) { .fail(function (error) {
switch (error.status) { switch (error.status) {
case 408: app.util.loader("", "status_dict.timeout", "clock-o"); break; case 408:
case 400: app.util.loader("", "validation_dict.general", "ban"); break; app.util.loader("", "status_dict.timeout", "clock-o");
default: app.util.loader("", "status_dict.error", "ban"); break; break;
case 400:
app.util.loader("", "validation_dict.general", "ban");
break;
default:
app.util.loader("", "status_dict.error", "ban");
break;
} }
}); });
}, },
...@@ -3249,7 +3270,8 @@ ...@@ -3249,7 +3270,8 @@
element.value = i18n.t(target[1]); element.value = i18n.t(target[1]);
break; break;
case "[parent": case "[parent":
element.parentNode.childNodes[0].textContent = i18n.t(target[1]); element.parentNode.childNodes[0].textContent =
i18n.t(target[1]);
break; break;
case "[node": case "[node":
element.childNodes[0].textContent = i18n.t(target[1]); element.childNodes[0].textContent = i18n.t(target[1]);
...@@ -3261,7 +3283,9 @@ ...@@ -3261,7 +3283,9 @@
default: default:
// NOTE: empty - setting .translate on a wrapper will empty it // NOTE: empty - setting .translate on a wrapper will empty it
util.deleteChildren(element); util.deleteChildren(element);
element.appendChild(document.createTextNode(i18n.t(target[0]))); element.appendChild(
document.createTextNode(i18n.t(target[0]))
);
break; break;
} }
} }
...@@ -3603,7 +3627,7 @@ ...@@ -3603,7 +3627,7 @@
// TODO: subordinated fields should have links, not id only!!! // TODO: subordinated fields should have links, not id only!!!
// 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 (spec) { map.listItem = function (spec) {
var quirk_dict, section, label, j, k, field, setter, record, new_item, var quirk_dict, section, label, j, k, field, record, new_item,
id, key, translation_fields, item, relation, promise_list, pass, count; id, key, translation_fields, item, relation, promise_list, pass, count;
promise_list = []; promise_list = [];
...@@ -3671,8 +3695,8 @@ ...@@ -3671,8 +3695,8 @@
} }
return RSVP.all(promise_list) return RSVP.all(promise_list)
.then(function(response_list) { .then(function (response_list) {
var l, len, response, obj, setter, pos; var l, len, response, obj, new_setter, pos;
for (l = 0, len = response_list.length; l < len; l += 1) { for (l = 0, len = response_list.length; l < len; l += 1) {
response = response_list[l]; response = response_list[l];
...@@ -3683,12 +3707,12 @@ ...@@ -3683,12 +3707,12 @@
// text/label/... all stuff translateable // text/label/... all stuff translateable
if (response.text_element) { if (response.text_element) {
obj[response.key + "_18n"] = record[response.key + "_i18n"]; obj[response.key + "_18n"] = record[response.key + "_i18n"];
setter = key; new_setter = key;
} else { } else {
setter = "value"; new_setter = "value";
} }
obj[setter] = response.value; obj[new_setter] = response.value;
new_item[pos].push(util.mergeObject(response.field, obj)); new_item[pos].push(util.mergeObject(response.field, obj));
} }
return new_item; return new_item;
...@@ -3727,8 +3751,7 @@ ...@@ -3727,8 +3751,7 @@
// TODO: remove this crap or make it generic... // TODO: remove this crap or make it generic...
// set = setter_list ... JSLINT // set = setter_list ... JSLINT
setValue = function (setter) { setValue = function (setter) {
var n, len, set_value, set_flux, set, val, set_reference, logic, var n, len, set_value, set_flux, set, val, set_reference, logic;
selection, split;
logic = setter.logic; logic = setter.logic;
if (logic) { if (logic) {
...@@ -4113,7 +4136,9 @@ ...@@ -4113,7 +4136,9 @@
case 0: case 0:
clone.position = len === 1 ? null : true; clone.position = len === 1 ? null : true;
break; break;
case len -1: clone.position = false; break; case len - 1:
clone.position = false;
break;
} }
group.children.push(clone); group.children.push(clone);
} }
...@@ -4150,7 +4175,8 @@ ...@@ -4150,7 +4175,8 @@
helper.children.push(section_response_list[m]); helper.children.push(section_response_list[m]);
} }
// HACK for Thierry // HACK for Thierry
helper.reference = helper.property_dict.reference = spec.wrapper.reference; helper.reference = helper.property_dict.reference =
spec.wrapper.reference;
return RSVP.resolve(helper); return RSVP.resolve(helper);
}) })
...@@ -4193,7 +4219,7 @@ ...@@ -4193,7 +4219,7 @@
var data = answer.response.data; var data = answer.response.data;
// set subordinate value // set subordinate value
if (data.total_rows > 0) { if (data.total_rows > 0) {
spec.value = data.rows[0].doc[spec.subordinate] spec.value = data.rows[0].doc[spec.subordinate];
} }
// NOTE: delete here, otherwise impossible to track. This will still // NOTE: delete here, otherwise impossible to track. This will still
...@@ -4296,7 +4322,7 @@ ...@@ -4296,7 +4322,7 @@
// TODO: storage.add included prefetch of field_items and validation // TODO: storage.add included prefetch of field_items and validation
// TODO: storage.add deleted identifier if create_new was set // TODO: storage.add deleted identifier if create_new was set
storage.write = function (obj) { storage.write = function (obj) {
var form, data, valid, prefix, config, method, action, pointer, sample; var form, data, valid, prefix, config, method, action, pointer;
form = obj.form; form = obj.form;
pointer = (obj.element || storage.span).getAttribute("data-action"); pointer = (obj.element || storage.span).getAttribute("data-action");
...@@ -4304,9 +4330,9 @@ ...@@ -4304,9 +4330,9 @@
config = {}; config = {};
prefix = obj.id + "_"; prefix = obj.id + "_";
valid = obj.sample_store || storage.validate(form); valid = obj.sample_store || storage.validate(form);
if (valid) { if (valid) {
data = obj.sample_data || storage.parseForm(valid, prefix, true); data = obj.sample_data || storage.parseForm(valid, prefix, true);
// HACK: Thierry // HACK: Thierry
if (obj.backpack) { if (obj.backpack) {
data = util.mergeObject(obj.backpack, data); data = util.mergeObject(obj.backpack, data);
...@@ -4342,6 +4368,7 @@ ...@@ -4342,6 +4368,7 @@
app.storage_dict.items[method || "post"](data, config) app.storage_dict.items[method || "post"](data, config)
); );
} }
$.mobile.loading("show");
app.util.loader("", "validation_dict.general", "ban"); app.util.loader("", "validation_dict.general", "ban");
return RSVP.reject({"status": 400}); return RSVP.reject({"status": 400});
}; };
...@@ -4609,7 +4636,8 @@ ...@@ -4609,7 +4636,8 @@
break; break;
default: default:
if (plain) { if (plain) {
container[property.replace(clean, "").replace("select_", "")] = value; container[property.replace(clean, "").replace("select_", "")] =
value;
} else { } else {
container.append(property.replace(clean, ""), value); container.append(property.replace(clean, ""), value);
} }
...@@ -4871,7 +4899,8 @@ ...@@ -4871,7 +4899,8 @@
"portal_type_title": config.state.title, "portal_type_title": config.state.title,
"property_dict": util.mergeObject( "property_dict": util.mergeObject(
{"dynamic": true}, {"dynamic": true},
config.state.dyno_dict), config.state.dyno_dict
),
"scheme": config.state.scheme "scheme": config.state.scheme
}, },
{ {
...@@ -4892,10 +4921,9 @@ ...@@ -4892,10 +4921,9 @@
* @param {string} direction Direction to sort * @param {string} direction Direction to sort
* @param {string} prev Previous icon * @param {string} prev Previous icon
* @param {string} next Next icon * @param {string} next Next icon
* @param {boolean} single Single state sort
*/ */
// TODO: overwrite direction on single state sorting // TODO: overwrite direction on single state sorting
app.sort = function (config, direction, prev, next, single) { app.sort = function (config, direction, prev, next) {
var i, in_array, sort_by, delay, state; var i, in_array, sort_by, delay, state;
// NOTE: if column title is not set, we might be sortling a list! // NOTE: if column title is not set, we might be sortling a list!
...@@ -5126,7 +5154,8 @@ ...@@ -5126,7 +5154,8 @@
"portal_type_title": state.title, "portal_type_title": state.title,
"property_dict": util.mergeObject( "property_dict": util.mergeObject(
{"dynamic": true}, {"dynamic": true},
state.dyno_dict), state.dyno_dict
),
"scheme": state.scheme "scheme": state.scheme
}, },
{ {
...@@ -5528,7 +5557,7 @@ ...@@ -5528,7 +5557,7 @@
.enhanceWithin() .enhanceWithin()
.on("click", "img.ui-title-logo", function (e, data) { .on("click", "img.ui-title-logo", function () {
$.mobile.changePage("#home"); $.mobile.changePage("#home");
}) })
...@@ -5939,10 +5968,9 @@ ...@@ -5939,10 +5968,9 @@
* Get the active JQM page in JavaScript-only * Get the active JQM page in JavaScript-only
* @method getPage * @method getPage
* @param {string} url url of the page to fetch * @param {string} url url of the page to fetch
* @param {string} straight If not set, we start searching from behind
* @return {string} id of active page * @return {string} id of active page
*/ */
util.getPage = function (url, straight) { util.getPage = function (url) {
var i, kid, len, kids = document.body.children; var i, kid, len, kids = document.body.children;
// reverse, because in JQM last page is the active page! // reverse, because in JQM last page is the active page!
...@@ -6023,22 +6051,6 @@ ...@@ -6023,22 +6051,6 @@
return new RegExp("(?:^|\\s)" + className + "(?!\\S)", "g"); return new RegExp("(?:^|\\s)" + className + "(?!\\S)", "g");
}; };
// /**
// * Property to set whether classlist is supported
// * @property support_classList
// */
// // TODO: add to support module/Modernizr
// util.no_support_classList = document.documentElement.classList === undefined;
//
// util.testForString = util.no_support_classList ?
// function(el, clss) {
// return el.className && new RegExp("(^|\\s)" +
// clss + "(\\s|$)").test(el.className);
// } :
// function(el, clss) {
// return el.classList.contains(clss);
// };
/** /**
* Test for a class name * Test for a class name
* @method testForString * @method testForString
...@@ -6131,12 +6143,12 @@ ...@@ -6131,12 +6143,12 @@
// HACK Thierryfic hack // HACK Thierryfic hack
if (is_html) { if (is_html) {
return util.ajax( return util.ajax({
{"url": "data/" + pass.url_dict.href} "url": "data/" + pass.url_dict.href
).then(function(e) { }).then(function (e) {
// Don't look... // Don't look...
var i, len, fragment, response = $.parseHTML( var i, len, fragment, response = $.parseHTML(
e.target.response.replace("/erp5/","/", "g") e.target.response.replace("/erp5/", "/", "g")
); );
fragment = document.createDocumentFragment(); fragment = document.createDocumentFragment();
...@@ -6473,10 +6485,10 @@ ...@@ -6473,10 +6485,10 @@
// will be passed down the rendering tree // will be passed down the rendering tree
app.content.make = function (reply) { app.content.make = function (reply) {
var pass, method, type, kids, promise_list, route, var pass, method, type, kids, promise_list, route,
search, search_id, kid, is_html, is_dynamic, is_id, i, j, k, last, search, search_id, kid, is_html, is_dynamic, is_id, i, last,
encoded, wrapper, active, selector, update_target, target, widget, encoded, wrapper, active, selector, update_target, widget,
quirk_dict, generator, pointer_results, data_total_rows, is_parameter, quirk_dict, generator, pointer_results, data_total_rows, is_parameter,
param_len, parameter, no_item, dyno, container, has_props, widget_dyno, no_item, dyno, container, has_props, widget_dyno,
set_reference; set_reference;
pass = reply.pass; pass = reply.pass;
...@@ -6590,7 +6602,7 @@ ...@@ -6590,7 +6602,7 @@
// ===================================================================== // =====================================================================
// NOTE: store state on wrapper property_dict to inherit! // NOTE: store state on wrapper property_dict to inherit!
wrapper.property_dict.state = pass.state wrapper.property_dict.state = pass.state;
// ===================================================================== // =====================================================================
// inherit item id, so it's available in form as indentifier // inherit item id, so it's available in form as indentifier
...@@ -6662,7 +6674,9 @@ ...@@ -6662,7 +6674,9 @@
"children": [{ "children": [{
"type": "p", "type": "p",
"direct": {"className": "ui-table-caption translate"}, "direct": {"className": "ui-table-caption translate"},
"attributes": {"data-i18n": quirk_dict.caption.text_i18n || null}, "attributes": {
"data-i18n": quirk_dict.caption.text_i18n || null
},
"logic": {"text": quirk_dict.caption.text} "logic": {"text": quirk_dict.caption.text}
}] }]
}); });
...@@ -6677,11 +6691,11 @@ ...@@ -6677,11 +6691,11 @@
// add popup (local/global) // add popup (local/global)
switch (quirk_dict.need_popup) { switch (quirk_dict.need_popup) {
case "local": // case "local":
if (util.getPage().querySelectorAll("div.local_popup") === null) { // if (util.getPage().querySelectorAll("div.local_popup") === null) {
target.appendChild(factory.widget.popup({})); // target.appendChild(factory.widget.popup({}));
} // }
break; // break;
case "global": case "global":
if (document.getElementById("global_popup") === null) { if (document.getElementById("global_popup") === null) {
document.documentElement.appendChild(factory.widget.popup({})); document.documentElement.appendChild(factory.widget.popup({}));
...@@ -6693,11 +6707,15 @@ ...@@ -6693,11 +6707,15 @@
// TODO: can this be done without storing on and querying DOM???!!! // TODO: can this be done without storing on and querying DOM???!!!
// TODO: THIS MAKES ME INSANE... qsa || widget does not work! // TODO: THIS MAKES ME INSANE... qsa || widget does not work!
widget = pass.state.gadget; widget = pass.state.gadget;
widget_dyno = widget.querySelector("[data-update]") || widget.getElementsByTagName("form")[0]; widget_dyno = widget.querySelector("[data-update]") ||
wrapper.property_dict.map_children = widget_dyno.getAttribute("data-map"); widget.getElementsByTagName("form")[0];
wrapper.property_dict.map_children =
widget_dyno.getAttribute("data-map");
wrapper = util.mergeObject( wrapper = util.mergeObject(
factory.widget[widget_dyno.getAttribute("data-widget")](wrapper.property_dict), factory.widget[widget_dyno.getAttribute("data-widget")](
wrapper.property_dict
),
wrapper wrapper
); );
...@@ -6827,11 +6845,11 @@ ...@@ -6827,11 +6845,11 @@
return RSVP.all(promise_list) return RSVP.all(promise_list)
.then(function (response_list) { .then(function (response_list) {
var k, l, m, len, done_target, wrapper_selector, response, content, var h, l, m, len, done_target, wrapper_selector, response, content,
content_target, last_child, detach, child_list; last_child, detach, child_list;
for (k = 0, l = response_list.length; k < l; k += 1) { for (h = 0, l = response_list.length; h < l; h += 1) {
response = response_list[k]; response = response_list[h];
done_target = undefined; done_target = undefined;
if (response) { if (response) {
...@@ -6881,13 +6899,13 @@ ...@@ -6881,13 +6899,13 @@
); );
} }
} else { } else {
// TODO: terrible. what about footer/header/popup. // TODO: terrible. what about footer/header/popup.
if (content.querySelector("div.panel")) { if (content.querySelector("div.panel")) {
wrapper.fragment.appendChild(content); wrapper.fragment.appendChild(content);
} else { } else {
(wrapper.child_selector || wrapper.fragment) (wrapper.child_selector || wrapper.fragment)
.appendChild(content); .appendChild(content);
} }
} }
} }
} }
...@@ -6903,10 +6921,12 @@ ...@@ -6903,10 +6921,12 @@
// UPDATES - same %&/( as above // UPDATES - same %&/( as above
if (quirk_dict.update) { if (quirk_dict.update) {
selector = pass.state.gadget; selector = pass.state.gadget;
update_target = widget.querySelector("[data-update]") || widget.getElementsByTagName("form")[0]; update_target = widget.querySelector("[data-update]") ||
widget.getElementsByTagName("form")[0];
// TODO: generic method! // TODO: generic method!
// TODO: or inherit reference to controlgroup without being child of form? // TODO: or inherit reference to controlgroup without being
// child of form?
// rescue persistent elements from dump // rescue persistent elements from dump
detach = document.createDocumentFragment(); detach = document.createDocumentFragment();
child_list = update_target.children; child_list = update_target.children;
...@@ -6925,8 +6945,8 @@ ...@@ -6925,8 +6945,8 @@
// CREATE // CREATE
} else { } else {
selector = wrapper.fragment.firstElementChild || wrapper.fragment; selector = wrapper.fragment.firstElementChild ||
wrapper.fragment.firstChild || wrapper.fragment;
// TODO: find way to dig down into tree // TODO: find way to dig down into tree
if (util.testForString("dyno", selector.className) === false) { if (util.testForString("dyno", selector.className) === false) {
...@@ -7063,7 +7083,8 @@ ...@@ -7063,7 +7083,8 @@
// TODO: clean up, no exceptions (location), clear key + val! // TODO: clean up, no exceptions (location), clear key + val!
// TODO: make lookup parsing robust! // TODO: make lookup parsing robust!
app.util.setParam = function (kid, wrapper) { app.util.setParam = function (kid, wrapper) {
var i, len, param_list, param, href, loc, splitter, key, val, lookup, new_val; var i, len, param_list, param, href, loc, splitter, key, val, lookup,
new_val;
param_list = kid.logic.setParam; param_list = kid.logic.setParam;
for (i = 0, len = param_list.length; i < len; i += 1) { for (i = 0, len = param_list.length; i < len; i += 1) {
...@@ -7072,40 +7093,41 @@ ...@@ -7072,40 +7093,41 @@
key = param[0]; key = param[0];
switch (val) { switch (val) {
// NOTE: hacked for oauth redirect url // NOTE: hacked for oauth redirect url
// TODO: find way to include encoding when setting a href // TODO: find way to include encoding when setting a href
case "location": case "location":
href = kid.direct.href; href = kid.direct.href;
splitter = href.indexOf("?") > 0 ? "&" : "?"; splitter = href.indexOf("?") > 0 ? "&" : "?";
loc = window.location; loc = window.location;
kid.direct.href += splitter + window.encodeURIComponent(key) + kid.direct.href += splitter + window.encodeURIComponent(key) +
"=" + window.encodeURIComponent( "=" + window.encodeURIComponent(
loc.origin + loc.pathname + loc.hash.split("?")[0] loc.origin + loc.pathname + loc.hash.split("?")[0]
); );
break; break;
// set values or flag for subordination inside map.element // set values or flag for subordination inside map.element
default: default:
kid.logic[key] = kid.logic[key] || ""; kid.logic[key] = kid.logic[key] || "";
if (val.split("subordinate_").length > 1) { if (val.split("subordinate_").length > 1) {
// NOTE: try to get value from state/URL before flagging // NOTE: try to get value from state/URL before flagging
// NOTE: must check for equality, otherwise id foo > foofoo // NOTE: must check for equality, otherwise id foo > foofoo
// TODO: this is still super-not-robust... redo! // TODO: this is still super-not-robust... redo!
lookup = wrapper.property_dict.state.query.query; lookup = wrapper.property_dict.state.query.query;
if (lookup && lookup.indexOf(val) > -1) { if (lookup && lookup.indexOf(val) > -1) {
new_val = lookup.split(val)[1].split("+")[0] new_val = lookup.split(val)[1].split("+")[0]
.replace(":=", "").replace(")",""); .replace(":=", "").replace(")", "");
if (kid.logic[key] !== new_val) { if (kid.logic[key] !== new_val) {
kid.logic[key] += new_val; kid.logic[key] += new_val;
}
} else {
kid.needs_subordination = true;
} }
} else { } else {
kid.logic[key] += wrapper.property_dict.data.doc[val]; kid.needs_subordination = true;
delete kid.logic.setParam[i];
} }
} else {
kid.logic[key] += wrapper.property_dict.data.doc[val];
delete kid.logic.setParam[i];
}
break;
} }
} }
return kid; return kid;
...@@ -7126,8 +7148,7 @@ ...@@ -7126,8 +7148,7 @@
* @returns {object} Query to run based on parameters * @returns {object} Query to run based on parameters
*/ */
app.util.parseQueryParameter = function (str) { app.util.parseQueryParameter = function (str) {
var i, param_list, param_len, param, initial_query, indicator, var i, param_list, param_len, param, initial_query, indicator;
value_list;
param_list = str.split("&"); param_list = str.split("&");
initial_query = {}; initial_query = {};
...@@ -7135,27 +7156,25 @@ ...@@ -7135,27 +7156,25 @@
for (i = 0, param_len = param_list.length; i < param_len; i += 1) { for (i = 0, param_len = param_list.length; i < param_len; i += 1) {
param = param_list[i].split(":"); param = param_list[i].split(":");
indicator = param[0]; indicator = param[0];
value_list = param[1];
switch (indicator) { switch (indicator) {
case "query": case "query":
initial_query.query = param[1].replace("=", ":=", "g") initial_query.query = param[1].replace("=", ":=", "g")
.replace("+", " AND ", "g"); .replace("+", " AND ", "g");
break; break;
case "limit": case "limit":
// NOTE: Thanks Tristan! // NOTE: Thanks Tristan!
initial_query.limit = param[1].split("+") initial_query.limit = param[1].split("+")
.map(function (part) { return part.split("=")[1]; }); .map(function (part) { return part.split("=")[1]; });
break; break;
case "sort": case "sort":
initial_query.sort_on = param[1].split("+").map(function (part) { initial_query.sort_on = param[1].split("+").map(function (part) {
var s = part.split("="); var s = part.split("=");
return [s[0], s[1]]; return [s[0], s[1]];
}); });
break; break;
case "select": case "select":
initial_query.select_list = param[1].replace("+", ",", "g"); initial_query.select_list = param[1].replace("+", ",", "g");
break; break;
} }
} }
return initial_query; return initial_query;
...@@ -7168,7 +7187,7 @@ ...@@ -7168,7 +7187,7 @@
* @return {object} navigation object * @return {object} navigation object
**/ **/
app.util.parseLink = function (url) { app.util.parseLink = function (url) {
var i, hash, path, clean_hash, decode, root, last, stripped, url_query, var hash, path, clean_hash, decode, root, last, stripped, url_query,
strip; strip;
hash = $.mobile.path.parseUrl( hash = $.mobile.path.parseUrl(
...@@ -7201,7 +7220,7 @@ ...@@ -7201,7 +7220,7 @@
} }
// check for mode // check for mode
path = stripped.split("/"); path = stripped.split("/");
last = path.length -1; last = path.length - 1;
return { return {
"mode": path[last], "mode": path[last],
......
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