Commit e4d1f20f authored by Sven Franck's avatar Sven Franck

jslint

parent b286b8c0
...@@ -4966,8 +4966,8 @@ ...@@ -4966,8 +4966,8 @@
}; };
} }
// NOTE: currentTarget needed for bubbling (eg tree) // NOTE: currentTarget needed for bubbling (eg tree)
current = e.currentTarget; current = e.currentTarget === document ? undefined : e.currentTarget;
element = (current === document ? undefined : current) || e.target || e; element = current || e.target || e;
// NOTE: used to be if no popup/panel, use data-ref or data-url else if // NOTE: used to be if no popup/panel, use data-ref or data-url else if
// no href use data-url else href. Should work if element (button) does // no href use data-url else href. Should work if element (button) does
...@@ -4982,7 +4982,8 @@ ...@@ -4982,7 +4982,8 @@
"gadget": document.getElementById(id) "gadget": document.getElementById(id)
}; };
return util.mergeObject({ return util.mergeObject(
{
"form": response.gadget.getElementsByTagName("form")[0], "form": response.gadget.getElementsByTagName("form")[0],
"state": (response.gadget || {}).state "state": (response.gadget || {}).state
}, },
...@@ -5018,15 +5019,15 @@ ...@@ -5018,15 +5019,15 @@
* @param {object} data Data passed along with this (JQM) event * @param {object} data Data passed along with this (JQM) event
*/ */
app.parsePage = function (e, data) { app.parsePage = function (e, data) {
var page, base, create, config, raw_url, handle, clean_url, parsed_url, var page, base, config, raw_url, handle, clean_url, parsed_url, first;
destination, first;
if (data) { if (data) {
// update page title on backwards transition to the first page (still // update page title on backwards transition to the first page (still
// is in DOM, so no new page created, so no title update...) // is in DOM, so no new page created, so no title update...)
// TODO: not bulletproof i18n handling... we expect i18n to be defined // TODO: not bulletproof i18n handling... we expect i18n to be defined
if (typeof data.toPage === "object") { if (typeof data.toPage === "object") {
if ($.mobile.firstPage[0].getAttribute("data-url") === data.toPage[0].getAttribute("data-url")) { if ($.mobile.firstPage[0].getAttribute("data-url") ===
data.toPage[0].getAttribute("data-url")) {
app.setPageTitle("global_dict.home"); app.setPageTitle("global_dict.home");
} }
} }
...@@ -5052,7 +5053,8 @@ ...@@ -5052,7 +5053,8 @@
if (e) { if (e) {
page = util.getPage(raw_url.split("#").pop()); page = util.getPage(raw_url.split("#").pop());
base = page ? page.getAttribute("data-external-page") : null; base = page ? page.getAttribute("data-external-page") : null;
first = $.mobile.firstPage[0].getAttribute("data-url") === config.data_url; first = $.mobile.firstPage[0].getAttribute("data-url") ===
config.data_url;
if (first || (page && base) || raw_url === $.mobile.getDocumentUrl() || if (first || (page && base) || raw_url === $.mobile.getDocumentUrl() ||
data.options.role === "popup") { data.options.role === "popup") {
...@@ -5146,7 +5148,7 @@ ...@@ -5146,7 +5148,7 @@
// panel close (since default does not work on dynamic content // panel close (since default does not work on dynamic content
// TODO: integrate this into action if there is no other way! // TODO: integrate this into action if there is no other way!
.on("click", "div.ui-panel a.ui-panel-close", function (e) { .on("click", "div.ui-panel a.ui-panel-close", function () {
$(this).closest("div.ui-panel").panel("close"); $(this).closest("div.ui-panel").panel("close");
}) })
...@@ -5255,7 +5257,7 @@ ...@@ -5255,7 +5257,7 @@
}, },
//customValidations: util.declareJS(), //customValidations: util.declareJS(),
form: { form: {
onInvalid: function (error) { onInvalid: function () {
util.return_out(); util.return_out();
} }
} }
...@@ -5299,6 +5301,7 @@ ...@@ -5299,6 +5301,7 @@
if (!isNaN(parseFloat(str)) && isFinite(str)) { if (!isNaN(parseFloat(str)) && isFinite(str)) {
return Math.round(str).toFixed(spec.digits); return Math.round(str).toFixed(spec.digits);
} }
return str;
} }
return str; return str;
}; };
...@@ -5332,7 +5335,7 @@ ...@@ -5332,7 +5335,7 @@
* @param {array} arr Path leading to a value * @param {array} arr Path leading to a value
* @return {string} value * @return {string} value
**/ **/
util.fetchByArray = function(obj, arr) { util.fetchByArray = function (obj, arr) {
var n, key; var n, key;
for (n = 0; n < arr.length; n += 1) { for (n = 0; n < arr.length; n += 1) {
...@@ -5644,7 +5647,7 @@ ...@@ -5644,7 +5647,7 @@
* @return {object} promise * @return {object} promise
**/ **/
app.content.set = function (content_dict, url_dict, create, purge) { app.content.set = function (content_dict, url_dict, create, purge) {
var pass, set_url_dict, set_content_dict; var pass;
if (!content_dict) { if (!content_dict) {
util.loader("", "status_dict.parse_error", "ban-circle"); util.loader("", "status_dict.parse_error", "ban-circle");
...@@ -5667,8 +5670,9 @@ ...@@ -5667,8 +5670,9 @@
// and go // and go
return storage.fetchConfigAttachment({ return storage.fetchConfigAttachment({
"storage": app.storage_dict.settings, "storage": app.storage_dict.settings,
"file": pass.url_dict.href ? app.storage_dict.property_dict.name_dict.gadgets : "file": (pass.url_dict.href ?
app.storage_dict.property_dict.name_dict.settings, app.storage_dict.property_dict.name_dict.gadgets :
app.storage_dict.property_dict.name_dict.settings),
"attachment": pass.url_dict.href || "attachment": pass.url_dict.href ||
app.storage_dict.property_dict.name_dict.configuration, app.storage_dict.property_dict.name_dict.configuration,
"pass": pass "pass": pass
...@@ -5732,7 +5736,8 @@ ...@@ -5732,7 +5736,8 @@
// try to get 1 record for this portal_type // try to get 1 record for this portal_type
if (app.storage_dict.property_dict.allow_sample_data && pass.grant && if (app.storage_dict.property_dict.allow_sample_data && pass.grant &&
(pass.create !== false || pass.purge) && pass.config_dict.initial_query (pass.create !== false || pass.purge) &&
pass.config_dict.initial_query
) { ) {
return storage.fetch({ return storage.fetch({
"pass": pass, "pass": pass,
...@@ -5740,7 +5745,7 @@ ...@@ -5740,7 +5745,7 @@
"query": storage.parseQuery( "query": storage.parseQuery(
{"limit": [0, 1]}, {"limit": [0, 1]},
pass.config_dict.portal_type_source pass.config_dict.portal_type_source
), )
}); });
} }
} }
...@@ -5789,9 +5794,13 @@ ...@@ -5789,9 +5794,13 @@
} }
return RSVP.all(promise_list) return RSVP.all(promise_list)
.then(function(response_list) { .then(function (response_list) {
if (!response_list[0]) { if (!response_list[0]) {
app.util.loader("", "status_dict.internal_error", "ban-circle"); app.util.loader(
"",
"status_dict.internal_error",
"ban-circle"
);
} else { } else {
app.util.loader("", "status_dict.success", "check"); app.util.loader("", "status_dict.success", "check");
} }
...@@ -5874,7 +5883,7 @@ ...@@ -5874,7 +5883,7 @@
// TODO: get ALL RECORDS matching query (and make this if disappear ...) // TODO: get ALL RECORDS matching query (and make this if disappear ...)
if ((!app.storage_dict.property_dict.skip_total_records && if ((!app.storage_dict.property_dict.skip_total_records &&
pass.config_dict.skip_total_records !== true) && pass.config_dict.skip_total_records !== true) &&
(pass.grant || (pass.url_dict.mode === "new" || pass.purge) && ((pass.grant || (pass.url_dict.mode === "new" || pass.purge)) &&
(pass.state && pass.state.query._id === undefined) && (pass.state && pass.state.query._id === undefined) &&
pass.config_dict.initial_query) pass.config_dict.initial_query)
) { ) {
...@@ -5911,7 +5920,8 @@ ...@@ -5911,7 +5920,8 @@
// fetch full documents (unless force_field_definitions is set) // fetch full documents (unless force_field_definitions is set)
if (pass.create === false) { if (pass.create === false) {
if (!storage || (storage && !app.storage_dict.property_dict.force_field_definitions)) { if (!storage || (storage &&
!app.storage_dict.property_dict.force_field_definitions)) {
pass.state.query.include_docs = true; pass.state.query.include_docs = true;
} }
pass.state.query.limit = pass.store_limit; pass.state.query.limit = pass.store_limit;
...@@ -5919,7 +5929,8 @@ ...@@ -5919,7 +5929,8 @@
// only fetch columns based on gadget configuration // only fetch columns based on gadget configuration
} else { } else {
if (pass.data_dict.field_dict && if (pass.data_dict.field_dict &&
storage && app.storage_dict.property_dict.force_field_definitions && storage &&
app.storage_dict.property_dict.force_field_definitions &&
pass.config_dict.scheme pass.config_dict.scheme
) { ) {
pass.data_dict.field_list = storage.makeSelectList( pass.data_dict.field_list = storage.makeSelectList(
...@@ -6013,13 +6024,15 @@ ...@@ -6013,13 +6024,15 @@
case "select": case "select":
case "textarea": case "textarea":
case "force_form_element": case "force_form_element":
generator = {"fragment": factory.widget.formElement(pass.content_dict)}; generator = {
"fragment": factory.widget.formElement(pass.content_dict)
};
break; break;
case "divider": case "divider":
case "item": case "item":
generator = {"fragment": pass.content_dict.content}; generator = {"fragment": pass.content_dict.content};
break; break;
case (undefined): case undefined:
generator = {"fragment": document.createDocumentFragment()}; generator = {"fragment": document.createDocumentFragment()};
break; break;
default: default:
...@@ -6101,7 +6114,7 @@ ...@@ -6101,7 +6114,7 @@
// add caption // add caption
if (quirk_dict.caption) { if (quirk_dict.caption) {
kids.push({ kids.push({
"generate":"widget", "generate": "widget",
"type": "controlbar", "type": "controlbar",
"property_dict": {"slot": quirk_dict.caption.slot || 1}, "property_dict": {"slot": quirk_dict.caption.slot || 1},
"children": [{ "children": [{
...@@ -6121,7 +6134,7 @@ ...@@ -6121,7 +6134,7 @@
} }
// 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({}));
...@@ -6159,7 +6172,8 @@ ...@@ -6159,7 +6172,8 @@
kid.direct.href = kid.direct.href.replace("__id__", is_id); kid.direct.href = kid.direct.href.replace("__id__", is_id);
} else if (kid.property_dict) { } else if (kid.property_dict) {
// continue inheriting to all widgets // continue inheriting to all widgets
kid.property_dict.item_identifier = window.encodeURIComponent(is_id); kid.property_dict.item_identifier =
window.encodeURIComponent(is_id);
} }
} }
...@@ -6213,16 +6227,12 @@ ...@@ -6213,16 +6227,12 @@
// reference // reference
if (quirk_dict.reference) { if (quirk_dict.reference) {
switch (true) { if (!!kid.attribute) {
case !!kid.attributes:
kid.attributes["data-reference"] = quirk_dict.reference; kid.attributes["data-reference"] = quirk_dict.reference;
break; } else if (!!kid.property_dict) {
case !!kid.property_dict:
kid.property_dict.reference = quirk_dict.reference; kid.property_dict.reference = quirk_dict.reference;
break; } else {
default:
kid.reference = quirk_dict.reference; kid.reference = quirk_dict.reference;
break;
} }
} }
...@@ -6236,11 +6246,11 @@ ...@@ -6236,11 +6246,11 @@
// go-go-gadget-o-promise... // go-go-gadget-o-promise...
promise_list[i] = map.element(kid, wrapper, i) promise_list[i] = map.element(kid, wrapper, i)
.then(function(mapping) { .then(function (mapping) {
if (mapping.inherit) { if (mapping.inherit) {
return app.content.set({}, mapping); return app.content.set({}, mapping);
} }
return app.content.set(mapping) return app.content.set(mapping);
}) })
.fail(util.error); .fail(util.error);
} }
...@@ -6249,11 +6259,11 @@ ...@@ -6249,11 +6259,11 @@
return RSVP.all(promise_list) return RSVP.all(promise_list)
.then(function (response_list) { .then(function (response_list) {
var k, l, target, wrapper_selector, response, content; var k, l, done_target, wrapper_selector, response, content;
for (k = 0, l = response_list.length; k < l; k += 1) { for (k = 0, l = response_list.length; k < l; k += 1) {
response = response_list[k]; response = response_list[k];
target = undefined; done_target = undefined;
if (response) { if (response) {
// generate target for and append response // generate target for and append response
// NOTE: wrapper.spec is used for header only. // NOTE: wrapper.spec is used for header only.
...@@ -6268,9 +6278,10 @@ ...@@ -6268,9 +6278,10 @@
); );
// 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
target = wrapper_selector[wrapper.target_selector + "ElementChild"] done_target =
wrapper_selector[wrapper.target_selector + "ElementChild"]
|| wrapper_selector; || wrapper_selector;
target.appendChild(response); done_target.appendChild(response);
} }
content = wrapper_selector || response; content = wrapper_selector || response;
...@@ -6289,14 +6300,18 @@ ...@@ -6289,14 +6300,18 @@
if (util.testForString("ui-footer", last.className)) { if (util.testForString("ui-footer", last.className)) {
document.body.insertBefore(wrapper.fragment, last); document.body.insertBefore(wrapper.fragment, last);
} else { } else {
document.body.insertBefore(content, document.body.children[0]); document.body.insertBefore(
content,
document.body.children[0]
);
} }
} 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).appendChild(content); (wrapper.child_selector || wrapper.fragment)
.appendChild(content);
} }
} }
} }
...@@ -6321,7 +6336,7 @@ ...@@ -6321,7 +6336,7 @@
} }
//and add new dynamic content //and add new dynamic content
update_target.appendChild(wrapper.fragment) update_target.appendChild(wrapper.fragment);
// CREATE // CREATE
} else { } else {
selector = wrapper.fragment.firstElementChild || wrapper.fragment; selector = wrapper.fragment.firstElementChild || wrapper.fragment;
...@@ -6339,7 +6354,7 @@ ...@@ -6339,7 +6354,7 @@
} }
// tuck to gadget // tuck to gadget
// WARNING: this should use data(), it is BAD practice to store like this // WARNING: this should use data(), it BAD to store like this
selector.state = pass.state; selector.state = pass.state;
// not auth, no mojo! // not auth, no mojo!
...@@ -6599,7 +6614,7 @@ ...@@ -6599,7 +6614,7 @@
**/ **/
app.init.config = function (content_dict) { app.init.config = function (content_dict) {
var i, j, arr, promise_list, len, feature, feature_len, name, dict, var i, j, arr, promise_list, len, feature, feature_len, name, dict,
set, child_len, type, nav, language, target, initializer, solver; set, type, nav, language, target, initializer;
arr = app.empty_array; arr = app.empty_array;
promise_list = []; promise_list = [];
...@@ -6611,11 +6626,16 @@ ...@@ -6611,11 +6626,16 @@
// test support // test support
if (app.init.testSupport(feature.modernizr || [])) { if (app.init.testSupport(feature.modernizr || [])) {
set = feature.set_on;
feature_len = (feature.scheme || arr).length; feature_len = (feature.scheme || arr).length;
type = feature.type; type = feature.type;
initializer = feature.initializer; initializer = feature.initializer;
target = (set ? app[feature.set_on] = {} : undefined) || app; set = feature.set_on;
if (set) {
target = app[feature.set_on] = {};
} else {
target = app;
}
//target = (set ? app[set] = {} : undefined) || app;
// merge properties on target // merge properties on target
target.property_dict = util.mergeObject( target.property_dict = util.mergeObject(
...@@ -6645,13 +6665,14 @@ ...@@ -6645,13 +6665,14 @@
// set promise and access to this module // set promise and access to this module
target[name] = promise_list[j] = initializer ? target[name] = promise_list[j] = initializer ?
window[type][feature.initializer](dict.property_dict) : window[type]; window[type][feature.initializer](dict.property_dict) :
window[type];
} }
} }
if ((feature.children || arr).length > 0) { if ((feature.children || arr).length > 0) {
promise_list[j + 1] = app.content.set(feature); promise_list[j + 1] = app.content.set(feature);
}; }
} }
return RSVP.all(promise_list); return RSVP.all(promise_list);
}; };
......
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