Commit 137a1e46 authored by Sven Franck's avatar Sven Franck

replaced window.App with dependency on App module in all gadgets

parent 4632b319
...@@ -67,7 +67,6 @@ ...@@ -67,7 +67,6 @@
, shim: { , shim: {
'jqm': { deps: ['jquery'], exports: 'mobile' } 'jqm': { deps: ['jquery'], exports: 'mobile' }
, 'jio': { deps: ['md5'] } , 'jio': { deps: ['md5'] }
, 'complex_queries': { exports: 'complex_queries' }
, 'localstorage': { deps: ['jio', 'complex_queries'] } , 'localstorage': { deps: ['jio', 'complex_queries'] }
, 'indexstorage': { deps: ['jio'] } , 'indexstorage': { deps: ['jio'] }
, 'renderjs': { deps: ['jquery'], exports: 'RenderJs' } , 'renderjs': { deps: ['jquery'], exports: 'RenderJs' }
...@@ -102,12 +101,10 @@ ...@@ -102,12 +101,10 @@
// expose App once everything is loaded // expose App once everything is loaded
spec.setup.done(function(App, Config) { spec.setup.done(function(App, Config) {
window.App = App;
// expose configuration - settings // expose configuration - settings
window.App.settings = Config.settings; App.settings = Config.settings;
// expose configuration - storages // expose configuration - storages
window.App.storage = Config.storage; App.storage = Config.storage;
for (i = 0; i < window.fallbackLoader.deferreds.length; i += 1) { for (i = 0; i < window.fallbackLoader.deferreds.length; i += 1) {
window.fallbackLoader.deferreds[i] window.fallbackLoader.deferreds[i]
......
define([ define([
'text!address.html!strip' 'app'
, 'text!address.html!strip'
, 'validval' , 'validval'
, 'css!address' , 'css!address'
], ],
function (source, validator) { function (App, source, validator) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!basket.html!strip' 'app'
, 'text!basket.html!strip'
, 'css!basket' , 'css!basket'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!browser.html!strip' 'app'
, 'text!browser.html!strip'
, 'css!browser' , 'css!browser'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'storage' 'app'
, 'storage'
, 'async' , 'async'
], ],
function (storage) { function (App, storage) {
"use strict"; "use strict";
var priv = {}; var priv = {};
...@@ -36,13 +37,10 @@ define([ ...@@ -36,13 +37,10 @@ define([
spec.config.settings.language_default = "en-EN"; 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_selector = "translate";
spec.config.settings.language_set = false;
} else { } else {
// create application settings // create application settings
spec.config.settings.language_default = spec.response.default_language || "en-EN";
spec.config.settings.language_current = spec.response.language_current || spec.config.settings.language_default; 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_selector = spec.response.selector || "translate";
spec.config.settings.language_set = spec.response.language_set || false;
} }
spec.config.settings.screen_format = priv.setScreenDimensions(); spec.config.settings.screen_format = priv.setScreenDimensions();
...@@ -75,7 +73,7 @@ define([ ...@@ -75,7 +73,7 @@ define([
function(data) { function(data) {
priv.config_call(data); priv.config_call(data);
} }
) );
// require( // require(
// ["async!http://www.franckreich.de/members/export/x/configuration.json"], // ["async!http://www.franckreich.de/members/export/x/configuration.json"],
// config_call // config_call
...@@ -98,6 +96,7 @@ define([ ...@@ -98,6 +96,7 @@ define([
} }
storage.queryStorage(spec); storage.queryStorage(spec);
} }
// return config // return config
return that; return that;
} }
......
define([ define([
'text!confirm.html!strip' 'app'
, 'text!confirm.html!strip'
, 'css!confirm' , 'css!confirm'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!description.html!strip' 'app'
, 'text!description.html!strip'
, 'css!description' , 'css!description'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!details.html!strip' 'app'
, 'text!details.html!strip'
, 'css!details' , 'css!details'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!footer.html!strip' 'app'
, 'text!footer.html!strip'
, 'css!footer' , 'css!footer'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!gallery.html!strip' 'app'
, 'text!gallery.html!strip'
, 'css!gallery' , 'css!gallery'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!index.html!strip' 'app'
, 'text!index.html!strip'
, 'css!index' , 'css!index'
], ],
function (source) { function (App, source) {
var response = {}, def; var response = {}, def;
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!item.html!strip' 'app'
, 'text!item.html!strip'
, 'css!item' , 'css!item'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!items.html!strip' 'app'
, 'text!items.html!strip'
, 'css!items' , 'css!items'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
// TODO: the method to query and display items should be set be
// either the searchbar or the storage?
response.mockup = function (source, callback_mockup) { response.mockup = function (source, callback_mockup) {
var markup, spec, var markup, spec,
gadget = RenderJs.getSelfGadget(), gadget = RenderJs.getSelfGadget(),
id = gadget.dom.attr('id').split("__").splice(-1)[0], id = gadget.dom.attr('id').split("__").splice(-1)[0],
config = gadget.state[0][id]._config, config = gadget.state[0][id]._config,
module = config.datasource.module, module = config.datasource.module,
screen = window.App.settings.screen_format, // settable options
screen = App.settings.screen_format,
size = screen === "small" ? "small" : "medium", size = screen === "small" ? "small" : "medium",
shortcut = size.substring(0, 1); shortcut = size.substring(0, 1),
identifier = App.settings.identifier || "item_id";
spec = {}; spec = {};
...@@ -27,9 +32,29 @@ define([ ...@@ -27,9 +32,29 @@ define([
"select_list": config.datasource.fields || undefined "select_list": config.datasource.fields || undefined
}; };
// if we have a search tag being passed, run a search
if (location.search !== "") {
spec.query = true;
spec.query_string = location.search.split("=")[1].replace("+", " ");
}
spec.callback = function(err, response) { spec.callback = function(err, response) {
var item, i, str = "", price; var item, i, str = "", price;
// cleanup
// no results
// TODO: show something for users like most-searched/sold...
// TODO: this is optionable
if (response.total_rows === 0) {
str += "<li data-icon='false' class='empty_results'>" +
"<h3 class='translate' data-i18n='items.results_zero'></h3>" +
"<p class='translate' data-i18n='items.results_modify'></p>" +
"</li>";
} else {
// generate results
for (i = 0; i < response.total_rows; i += 1) { for (i = 0; i < response.total_rows; i += 1) {
item = response.rows[i].value; item = response.rows[i].value;
...@@ -41,7 +66,8 @@ define([ ...@@ -41,7 +66,8 @@ define([
} }
str += "<li data-icon='false'>" + str += "<li data-icon='false'>" +
"<a href='details.html?product=" + item._id + "<a href='details.html?"+ identifier + "=" +
encodeURI(item[identifier]) +
"' title='" + item.brand + ", " + item.title + "'>" + "' title='" + item.brand + ", " + item.title + "'>" +
"<span class='img_container_items'>" + "<span class='img_container_items'>" +
"<img alt='" + item.title + "' src='" + "<img alt='" + item.title + "' src='" +
...@@ -49,6 +75,7 @@ define([ ...@@ -49,6 +75,7 @@ define([
size + "' /></span><span class='description_items'>" + size + "' /></span><span class='description_items'>" +
item.brand + " " + item.title + " " + price + "</span></a></li>"; item.brand + " " + item.title + " " + price + "</span></a></li>";
} }
}
// add to data // add to data
markup = source.replace(/<!-- items -->/g, str); markup = source.replace(/<!-- items -->/g, str);
...@@ -57,23 +84,54 @@ define([ ...@@ -57,23 +84,54 @@ define([
} }
// query for items // query for items
window.App[module].switchboard(spec); App[module].switchboard(spec);
}; };
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { var closest = function (elem, selector) {
var matchesSelector = elem.matches ||
elem.webkitMatchesSelector ||
elem.mozMatchesSelector ||
elem.msMatchesSelector;
while (elem) {
if (matchesSelector.bind(elem)(selector)) {
return elem;
} else {
elem = elem.parentNode;
}
}
return false;
};
// set binding for opening a detailed view
// TODO: this should also be a link-method call
self.dom.find("ul").on("click", "a", function (e) {
var key;
e.preventDefault();
key = closest(e.target, "a").getAttribute("href").split("?")[1];
// show this item
$.mobile.changePage("details.html", {
"transition": "slide",
"data": {
"product": key
}
});
});
if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!login.html!strip' 'app'
, 'text!login.html!strip'
, 'validval' , 'validval'
, 'css!login' , 'css!login'
], ],
function (source) { function (App, source, validator) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!media.html!strip' 'app'
, 'text!media.html!strip'
, 'css!media' , 'css!media'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!payment.html!strip' 'app'
, 'text!payment.html!strip'
, 'css!payment' , 'css!payment'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!refine.html!strip' 'app'
, 'text!refine.html!strip'
, 'css!refine' , 'css!refine'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!search.html!strip' 'app'
, 'text!search.html!strip'
, 'css!search' , 'css!search'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!searchbar.html!strip' 'app'
, 'text!searchbar.html!strip'
, 'css!searchbar' , 'css!searchbar'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
var filter = self.dom.find(".searchbar_filter");
filter.on("filterbarbeforefilter", function (e, data) { filter.on("filterbarbeforefilter", function (e, data) {
var value = data.input.value;
if ( value ) { if ( value ) {
// now we can autocomplete... // now we can autocomplete...
...@@ -34,19 +31,21 @@ define([ ...@@ -34,19 +31,21 @@ define([
} }
}); });
if (window.App === undefined) {
if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!seo.html!strip' 'app'
, 'text!seo.html!strip'
, 'css!seo' , 'css!seo'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!shipment.html!strip' 'app'
, 'text!shipment.html!strip'
, 'css!shipment' , 'css!shipment'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!sorting.html!strip' 'app'
, 'text!sorting.html!strip'
, 'css!sorting' , 'css!sorting'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!summary.html!strip' 'app'
, 'text!summary.html!strip'
, 'css!summary' , 'css!summary'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!teaser.html!strip' 'app'
, 'text!teaser.html!strip'
, 'css!teaser' , 'css!teaser'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!terms.html!strip' 'app'
, 'text!terms.html!strip'
, 'css!terms' , 'css!terms'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
}); });
window.fallbackLoader.deferreds.push(def); window.fallbackLoader.deferreds.push(def);
window.fallbackLoader.args.push(self); window.fallbackLoader.args.push(self);
} else { } else {
// prefix instance-ids, pass JSON // prefix instance-ids, pass JSON
window.App.renderGadgets(self); App.renderGadgets(self);
} }
}; };
......
define([ define([
'text!translate.html!strip' 'app'
, 'text!translate.html!strip'
, 'css!translate' , 'css!translate'
], ],
function (source) { function (App, source) {
var response = {}; var response = {};
response.data = source; response.data = source;
...@@ -59,7 +60,7 @@ define([ ...@@ -59,7 +60,7 @@ define([
// //
priv.translate = function (language, target) { priv.translate = function (language, target) {
var collection = target || $('body'); var collection = target || $('body');
collection.find("." + window.App.settings.language_selector).i18n(); collection.find("." + App.settings.language_selector).i18n();
}; };
// //
...@@ -68,7 +69,7 @@ define([ ...@@ -68,7 +69,7 @@ define([
// @param {string} language > default language to set // @param {string} language > default language to set
// //
priv.setTranslations = function (language) { priv.setTranslations = function (language) {
if (window.App.settings.language_set === "false") { if (App.settings.language_set === "false") {
$.i18n.init({ $.i18n.init({
"lng": language, "lng": language,
"load": 'current', "load": 'current',
...@@ -79,7 +80,7 @@ define([ ...@@ -79,7 +80,7 @@ define([
}, function () { }, function () {
priv.translate(language); priv.translate(language);
}); });
window.App.settings.language_set = "true"; App.settings.language_set = "true";
} else { } else {
priv.translate(language); priv.translate(language);
} }
...@@ -118,9 +119,9 @@ define([ ...@@ -118,9 +119,9 @@ define([
$(".popup_all").popup( 'close' ); $(".popup_all").popup( 'close' );
if (window.App.settings.language_current !== language) { if (App.settings.language_current !== language) {
// update language // update language
window.App.settings.language_current = language; App.settings.language_current = language;
// update icon // update icon
priv.setIcon(language); priv.setIcon(language);
...@@ -138,18 +139,19 @@ define([ ...@@ -138,18 +139,19 @@ define([
// PUBLISH METHODS // PUBLISH METHODS
// ==================================================================== // ====================================================================
// TODO: remove once callable via link // TODO: remove once callable via link
window.App.translate = priv.translate; // TODO: can I add methods to a module, when accessing the module from another module???
App.translate = priv.translate;
// prefix instance-ids, pass JSON, trigger("create") // prefix instance-ids, pass JSON, trigger("create")
window.App.renderGadgets(gadget); App.renderGadgets(gadget);
// ==================================================================== // ====================================================================
// INITIALIZE // INITIALIZE
// ==================================================================== // ====================================================================
priv.initialize(window.App.settings.language_current); priv.initialize(App.settings.language_current);
}; };
if (window.App === undefined) { if (App === undefined) {
def = new $.Deferred; def = new $.Deferred;
def.done(function(gadget) { def.done(function(gadget) {
......
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