Commit e4d1f20f authored by Sven Franck's avatar Sven Franck

jslint

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