Commit 0ea54899 authored by Sven Franck's avatar Sven Franck

linting

parent a6188c92
/*jslint indent: 2, maxlen: 80, todo: true, nomen: true */
/*global document: true, require: true */
(function () {
"use strict";
var IS_LOCAL = /(:\/\/localhost|file:\/\/)/.test(document.location.href);
require.config({
waitSeconds : (IS_LOCAL? 10 : 45)
, paths: {
waitSeconds : (IS_LOCAL ? 10 : 45),
paths: {
// core
app: '../modules/core/app/app'
, config: '../modules/core/config/config'
, polyfill: '../modules/core/polyfill/polyfill'
, overrides: '../modules/core/overrides/overrides'
, utilities: '../modules/core/utilities/utilities'
, extensions: '../modules/core/extensions/extensions'
, storage: '../modules/core/storage/storage'
app: '../modules/core/app/app',
config: '../modules/core/config/config',
polyfill: '../modules/core/polyfill/polyfill',
overrides: '../modules/core/overrides/overrides',
utilities: '../modules/core/utilities/utilities',
extensions: '../modules/core/extensions/extensions',
storage: '../modules/core/storage/storage',
// requireJs
, almond: '../js/libs/require/almond'
, text: '../js/libs/require/text'
, css: '../js/plugins/require-css/require-css'
, normalize: '../js/plugins/require-css/normalize'
, json: '../js/plugins/requirejs-plugins/json'
, async: '../js/plugins/requirejs-plugins/async'
almond: '../js/libs/require/almond',
text: '../js/libs/require/text',
css: '../js/plugins/require-css/require-css',
normalize: '../js/plugins/require-css/normalize',
json: '../js/plugins/requirejs-plugins/json',
async: '../js/plugins/requirejs-plugins/async',
// support
, modernizr: '../js/plugins/modernizr'
, selectivzr: '../js/plugins/selectivzr'
modernizr: '../js/plugins/modernizr',
selectivzr: '../js/plugins/selectivzr',
// plugins/libs
, jquery: '../js/libs/jquery/jquery'
, jqm: '../js/libs/jquery-mobile/jquery-mobile'
, i18next: '../js/plugins/i18next/i18next'
, renderjs: '../js/plugins/renderjs/renderjs'
, jio: '../js/libs/jio/jio'
, md5: '../js/libs/jio/md5'
, localstorage: '../js/libs/jio/localstorage'
, indexstorage: '../js/libs/jio/indexstorage'
, complex_queries:'../js/libs/jio/complex_queries'
, validval: '../js/plugins/validval/validval'
jquery: '../js/libs/jquery/jquery',
jqm: '../js/libs/jquery-mobile/jquery-mobile',
i18next: '../js/plugins/i18next/i18next',
renderjs: '../js/plugins/renderjs/renderjs',
jio: '../js/libs/jio/jio',
md5: '../js/libs/jio/md5',
localstorage: '../js/libs/jio/localstorage',
indexstorage: '../js/libs/jio/indexstorage',
complex_queries: '../js/libs/jio/complex_queries',
validval: '../js/plugins/validval/validval',
// page gadgets
, address: '../modules/ui/address/address'
, basket: '../modules/ui/basket/basket'
, pagination: '../modules/ui/pagination/pagination'
, confirm: '../modules/ui/confirm/confirm'
, details: '../modules/ui/details/details'
, footer: '../modules/ui/footer/footer'
, gallery: '../modules/ui/gallery/gallery'
, header: '../modules/ui/header/header'
, index: '../modules/ui/index/index'
, item: '../modules/ui/item/item'
, items: '../modules/ui/items/items'
, login: '../modules/ui/login/login'
, media: '../modules/ui/media/media'
, payment: '../modules/ui/payment/payment'
, refine: '../modules/ui/refine/refine'
, register: '../modules/ui/register/register'
, products: '../modules/ui/products/products'
, searchbar: '../modules/ui/searchbar/searchbar'
, seo: '../modules/ui/seo/seo'
, shipment: '../modules/ui/shipment/shipment'
, sorting: '../modules/ui/sorting/sorting'
, summary: '../modules/ui/summary/summary'
, teaser: '../modules/ui/teaser/teaser'
, terms: '../modules/ui/terms/terms'
, translate: '../modules/ui/translate/translate'
, pageheader: '../modules/ui/pageheader/pageheader'
, pagefooter: '../modules/ui/pagefooter/pagefooter'
}
, shim: {
'jqm': { deps: ['jquery'], exports: 'mobile' }
, 'jio': { deps: ['md5'] }
, 'localstorage': { deps: ['jio', 'complex_queries'] }
, 'indexstorage': { deps: ['jio'] }
, 'renderjs': { deps: ['jquery'], exports: 'RenderJs' }
, 'app': { deps: ['jio'], exports: 'App' }
, 'validval': { deps: ['jquery'] }
}
, map: {
address: '../modules/ui/address/address',
basket: '../modules/ui/basket/basket',
pagination: '../modules/ui/pagination/pagination',
confirm: '../modules/ui/confirm/confirm',
details: '../modules/ui/details/details',
footer: '../modules/ui/footer/footer',
gallery: '../modules/ui/gallery/gallery',
header: '../modules/ui/header/header',
index: '../modules/ui/index/index',
item: '../modules/ui/item/item',
items: '../modules/ui/items/items',
login: '../modules/ui/login/login',
media: '../modules/ui/media/media',
payment: '../modules/ui/payment/payment',
refine: '../modules/ui/refine/refine',
register: '../modules/ui/register/register',
products: '../modules/ui/products/products',
searchbar: '../modules/ui/searchbar/searchbar',
seo: '../modules/ui/seo/seo',
shipment: '../modules/ui/shipment/shipment',
sorting: '../modules/ui/sorting/sorting',
summary: '../modules/ui/summary/summary',
teaser: '../modules/ui/teaser/teaser',
terms: '../modules/ui/terms/terms',
translate: '../modules/ui/translate/translate',
pageheader: '../modules/ui/pageheader/pageheader',
pagefooter: '../modules/ui/pagefooter/pagefooter'
},
shim: {
'jqm': { deps: ['jquery'], exports: 'mobile' },
'jio': { deps: ['md5'] },
'localstorage': { deps: ['jio', 'complex_queries'] },
'indexstorage': { deps: ['jio'] },
'renderjs': { deps: ['jquery'], exports: 'RenderJs' },
'app': { deps: ['jio'], exports: 'App' },
'validval': { deps: ['jquery'] }
},
map: {
'*': {
'css': '../js/plugins/require-css/css'
}
......@@ -86,12 +87,11 @@
});
require(['app', 'config'], function(App, Config) {
require(['app', 'config'], function (App, Config) {
var setup = new $.Deferred();
var spec = {};
var i;
var def;
var i,
setup = new $.Deferred(),
spec = {};
spec.app = App;
spec.config = Config;
......@@ -100,16 +100,18 @@
// fallback for fast browsers...
spec.fallbackLoader = {
deferreds: [],
args: [],
args: []
};
// expose App once everything is loaded
spec.setup.done(function(App, Config) {
spec.setup.done(function (App, Config) {
// expose configuration - settings
App.settings = Config.settings;
// expose configuration - storages
App.storage = Config.storage;
// expose errors
App.errors = [];
for (i = 0; i < window.fallbackLoader.deferreds.length; i += 1) {
window.fallbackLoader.deferreds[i]
......
This diff is collapsed.
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global document: true, require: true, define: true, RenderJs: true */
define([
'app'
, 'storage'
, 'utilities'
, 'async'
],
function (App, storage) {
'storage',
'app',
'utilities',
'async'
],
function (storage) {
"use strict";
var priv = {};
var that = {};
var priv = {},
that = {};
// set return object
that.settings = {};
......@@ -23,11 +25,11 @@ define([
spec.framed = "medium";
if ($.mobile.media("screen and (max-width:20em)") ||
($.mobile.browser.oldIE && $(window).width() < o.lowerThresh)) {
spec.framed = "small";
($.mobile.browser.oldIE && $(window).width() < spec.lowerThresh)) {
spec.framed = "small";
} else if ($.mobile.media("screen and (min-width:45em)") ||
($.mobile.browser.oldIE && $(window).width() >= o.upperThresh )) {
spec.framed = "large";
($.mobile.browser.oldIE && $(window).width() >= spec.upperThresh)) {
spec.framed = "large";
}
return spec.framed;
};
......@@ -36,17 +38,24 @@ define([
if (spec.response === undefined) {
// TODO: this defaults could be set somewhere else as well
spec.config.settings.language_default = "en-EN";
spec.config.settings.language_current = spec.config.settings.language_default;
spec.config.settings.language_current =
spec.config.settings.language_default;
spec.config.settings.language_selector = "translate";
spec.config.settings.language_set = "false";
spec.config.settings.item_selector = "item_id";
} else {
// create application settings
spec.config.settings.language_default = spec.response.language_default || "en-EN";
spec.config.settings.language_current = spec.response.language_current || spec.config.settings.language_default;
spec.config.settings.language_selector = spec.response.selector || "translate";
spec.config.settings.language_set = spec.response.language_set || "false";
spec.config.settings.item_selector = spec.response.item_selector || "item_id";
spec.config.settings.language_default =
spec.response.language_default || "en-EN";
spec.config.settings.language_current =
spec.response.language_current ||
spec.config.settings.language_default;
spec.config.settings.language_selector =
spec.response.selector || "translate";
spec.config.settings.language_set =
spec.response.language_set || "false";
spec.config.settings.item_selector =
spec.response.item_selector || "item_id";
}
spec.config.settings.screen_format = priv.setScreenDimensions();
......@@ -60,7 +69,7 @@ define([
// store settings
if (data !== undefined) {
// add to localstorage
data["_id"] = "config";
data._id = "config";
storage.queryStorage({
"storage": "settings",
......@@ -75,15 +84,16 @@ define([
};
// fallback: collect configuration from file
$.getJSON(
"http://www.franckreich.de/members/export/x/configuration.json?callback=?",
function(data) {
priv.config_call(data);
}
"http://www.franckreich.de/members/export/x/" +
"configuration.json?callback=?",
function (data) {
priv.config_call(data);
}
);
// require(
// ["async!http://www.franckreich.de/members/export/x/configuration.json"],
// config_call
// );
// require(
// ["async!http://www.franckreich.de/members/export/x/configuration.json"],
// config_call
// );
};
that.set = function (param) {
......@@ -91,19 +101,20 @@ define([
spec.storage = "settings";
spec.method = "get";
spec.doc = {"_id":"config"};
spec.doc = {"_id": "config"};
spec.callback = function(err, response) {
spec.callback = function (err, response) {
if (err) {
priv.JSONPfallback(param);
}
param.response = response;
priv.setApplicationSetters(param);
}
};
storage.queryStorage(spec);
}
};
// return config
return that;
}
);
);
This diff is collapsed.
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global document: true, $: true, define: true, */
define(['jquery'], function ($) {
"use strict";
......
This diff is collapsed.
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global document: true, define: true, $: true */
define([
'app'
], function (App) {
],
function (App) {
"use strict";
// this module provides generic methods usable across all gadgets/modules
var that = {};
......@@ -16,20 +19,19 @@ define([
if (matchesSelector) {
while (elem) {
if (matchesSelector.bind(elem)(selector)) {
return elem;
} else {
elem = elem.parentNode;
return elem;
}
}
return false;
} else {
// opera...
fallback = $( elem ).closest(selector);
if (fallback.length > 0) {
return fallback;
elem = elem.parentNode;
}
return false;
}
// opera...
fallback = $(elem).closest(selector);
if (fallback.length > 0) {
return fallback;
}
return false;
};
// object size
that.objectSize = function (obj) {
......@@ -37,7 +39,7 @@ define([
for (key in obj) {
if (obj.hasOwnProperty(key)) {
size++;
size += 1;
}
}
return size;
......@@ -47,4 +49,4 @@ define([
return undefined;
}
);
\ No newline at end of file
);
/*jslint indent: 2, maxlen: 80 */
/*global define: true, $: true, define: true, window: true */
define([
'app'
, 'text!address.html!strip'
, 'validval'
, 'css!address'
],
function (App, source, validator) {
var response = {};
'app',
'text!address.html!strip',
'validval',
'css!address'
],
function (App, source) {
"use strict";
var response = {}, def;
response.data = source;
response.after = function (self) {
if (App === undefined) {
def = new $.Deferred;
def = new $.Deferred();
def.done(function(gadget) {
def.done(function (gadget) {
// prefix instance-ids, pass JSON
App.renderGadgets(gadget);
});
......@@ -25,7 +29,7 @@ define([
}
};
// return response object
return response;
// return response object
return response;
}
);
);
/*jslint indent: 2, maxlen: 80 */
/*global define: true, define: true, $: true, window: true */
define([
'app'
, 'text!basket.html!strip'
, 'css!basket'
],
'app',
'text!basket.html!strip',
'validval',
'css!basket'
],
function (App, source) {
var response = {};
"use strict";
var response = {}, def;
response.data = source;
response.after = function (self) {
if (App === undefined) {
def = new $.Deferred;
def = new $.Deferred();
def.done(function(gadget) {
def.done(function (gadget) {
// prefix instance-ids, pass JSON
App.renderGadgets(gadget);
});
......@@ -24,7 +29,8 @@ define([
}
};
// return response object
return response;
// return response object
return response;
}
);
);
/*jslint indent: 2, maxlen: 80 */
/*global define: true, define: true, $: true, window: true */
define([
'app'
, 'text!confirm.html!strip'
, 'css!confirm'
],
'app',
'text!confirm.html!strip',
'validval',
'css!confirm'
],
function (App, source) {
var response = {};
"use strict";
var response = {}, def;
response.data = source;
response.after = function (self) {
if (App === undefined) {
def = new $.Deferred;
def = new $.Deferred();
def.done(function(gadget) {
def.done(function (gadget) {
// prefix instance-ids, pass JSON
App.renderGadgets(gadget);
});
......@@ -24,7 +29,7 @@ define([
}
};
// return response object
return response;
// return response object
return response;
}
);
);
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global define: true, $: true, define: true, window: true, App: true */
define([
'app'
, 'text!details.html!strip'
, 'css!details'
],
'app',
'text!details.html!strip',
'css!details'
],
function (App, source) {
var that = {};
var priv = {};
"use strict";
var that = {},
priv = {};
// cleanup memory
priv.cleanupMemory = function (memory) {
......@@ -40,30 +44,33 @@ define([
var id, now, spec, module;
// we will have an item to display. Grab it and go!
if (location.search !== "") {
if (window.location.search !== "") {
spec = {};
spec.pointer = location.search.split("=")[1];
spec.storage = "items"
spec.method = "get"
spec.doc = {"_id": spec.pointer }
spec.pointer = window.location.search.split("=")[1];
spec.storage = "items";
spec.method = "get";
spec.doc = {"_id": spec.pointer };
// TODO: should be passed via JSON?
module = "storage";
now = new Date().getTime();
} else {
// route to all products
$.mobile.changePage("products.html", {"transition":"fade"});
$.mobile.changePage("products.html", {"transition": "fade"});
}
// jio response
spec.callback = function(err, response) {
spec.callback = function (err, response) {
if (err) {
// error handling
App.errors.push({
module: "details",
timestamp: now,
error: err
});
} else {
id = response._id;
App.cacheItems[id] = [response, now];
// memory
......@@ -72,7 +79,7 @@ define([
// this is not response.callback(!!)
params.callback_mockup(params.source);
}
};
// query for items
App[module].switchboard(spec);
};
......@@ -89,36 +96,42 @@ define([
// TODO: this should also fetch the full document along with attachments,
// while all other request should only work with the "meta" data.
// that.before = function (source, callback_mockup) {
// var spec = {};
// that.before = function (source, callback_mockup) {
// var spec = {};
//
// spec.gadget = RenderJs.getSelfGadget();
// // TODO: this is for page event bindings. Once JQM content replaces
// // page, remove this and make the gadget the content section to
// // be updated.
// spec.page = App.util.closest(spec.gadget.dom.get(0), "div[data-role='page']");
// spec.pageId = "#" + spec.page.id;
// spec.source = source;
// spec.callback_mockup = callback_mockup;
// spec.gadget = RenderJs.getSelfGadget();
// // TODO: this is for page event bindings. Once JQM content replaces
// // page, remove this and make the gadget the content section to
// // be updated.
// spec.page = App.util.closest(
// spec.gadget.dom.get(0),
// "div[data-role='page']"
// );
// spec.pageId = "#" + spec.page.id;
// spec.source = source;
// spec.callback_mockup = callback_mockup;
//
// if (!spec.page.getAttribute("events_details")) {
// spec.page.setAttribute("events_details", true);
// $(document).on("pagebeforeshow.details", spec.pageId, function (e, data) {
// // TODO: if we allow to reload, we also need to trigger refresh on
// // so we need to reload this every time a page is shown. question
// // is how to trigger a refresh on this element ONLY
// priv.storeItem(spec);
// });
// // and run intial
// if (!spec.page.getAttribute("events_details")) {
// spec.page.setAttribute("events_details", true);
// $(document).on(
// "pagebeforeshow.details",
// spec.pageId,
// function (e, data) {
// // TODO: if we allow to reload, we also need to trigger refresh on
// // so we need to reload this every time a page is shown. question
// // is how to trigger a refresh on this element ONLY
// priv.storeItem(spec);
// }
// };
// });
// // and run intial
// priv.storeItem(spec);
// }
// };
that.after = function (self) {
if (App === undefined) {
def = new $.Deferred;
var def = new $.Deferred();
def.done(function(gadget) {
def.done(function (gadget) {
// prefix instance-ids, pass JSON
App.renderGadgets(gadget);
});
......@@ -131,7 +144,7 @@ define([
}
};
// return response object
return that;
// return response object
return that;
}
);
);
/*jslint indent: 2, maxlen: 80 */
/*global define: true, define: true, $: true, window: true */
define([
'app'
, 'text!footer.html!strip'
, 'css!footer'
],
'app',
'text!footer.html!strip',
'css!footer'
],
function (App, source) {
var response = {};
"use strict";
var response = {}, def;
response.data = source;
response.after = function (self) {
if (App === undefined) {
def = new $.Deferred;
def = new $.Deferred();
def.done(function(gadget) {
def.done(function (gadget) {
// prefix instance-ids, pass JSON
App.renderGadgets(gadget);
});
......@@ -24,7 +28,7 @@ define([
}
};
// return response object
return response;
// return response object
return response;
}
);
);
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global define: true, $: true, define: true, window: true, App: true, RenderJs: true,
document: true */
define([
'app'
, 'text!gallery.html!strip'
, 'css!gallery'
],
'app',
'text!gallery.html!strip',
'css!gallery'
],
function (App, source) {
var that = {};
var priv = {};