Skip to content

Instantly share code, notes, and snippets.

@maxlath
Created March 2, 2016 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxlath/8994f08f45df4bf4cdb2 to your computer and use it in GitHub Desktop.
Save maxlath/8994f08f45df4bf4cdb2 to your computer and use it in GitHub Desktop.
app.js missing the templates/confirmation_modal file
(function() {
'use strict';
var globals = typeof window === 'undefined' ? global : window;
if (typeof globals.require === 'function') return;
var modules = {};
var cache = {};
var aliases = {};
var has = ({}).hasOwnProperty;
var endsWith = function(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
};
var _cmp = 'components/';
var unalias = function(alias, loaderPath) {
var start = 0;
if (loaderPath) {
if (loaderPath.indexOf(_cmp) === 0) {
start = _cmp.length;
}
if (loaderPath.indexOf('/', start) > 0) {
loaderPath = loaderPath.substring(start, loaderPath.indexOf('/', start));
}
}
var result = aliases[alias + '/index.js'] || aliases[loaderPath + '/deps/' + alias + '/index.js'];
if (result) {
return _cmp + result.substring(0, result.length - '.js'.length);
}
return alias;
};
var _reg = /^\.\.?(\/|$)/;
var expand = function(root, name) {
var results = [], part;
var parts = (_reg.test(name) ? root + '/' + name : name).split('/');
for (var i = 0, length = parts.length; i < length; i++) {
part = parts[i];
if (part === '..') {
results.pop();
} else if (part !== '.' && part !== '') {
results.push(part);
}
}
return results.join('/');
};
var dirname = function(path) {
return path.split('/').slice(0, -1).join('/');
};
var localRequire = function(path) {
return function expanded(name) {
var absolute = expand(dirname(path), name);
return globals.require(absolute, path);
};
};
var initModule = function(name, definition) {
var module = {id: name, exports: {}};
cache[name] = module;
definition(module.exports, localRequire(name), module);
return module.exports;
};
var require = function(name, loaderPath) {
var path = expand(name, '.');
if (loaderPath == null) loaderPath = '/';
path = unalias(name, loaderPath);
if (has.call(cache, path)) return cache[path].exports;
if (has.call(modules, path)) return initModule(path, modules[path]);
var dirIndex = expand(path, './index');
if (has.call(cache, dirIndex)) return cache[dirIndex].exports;
if (has.call(modules, dirIndex)) return initModule(dirIndex, modules[dirIndex]);
throw new Error('Cannot find module "' + name + '" from '+ '"' + loaderPath + '"');
};
require.alias = function(from, to) {
aliases[to] = from;
};
require.register = require.define = function(bundle, fn) {
if (typeof bundle === 'object') {
for (var key in bundle) {
if (has.call(bundle, key)) {
modules[key] = bundle[key];
}
}
} else {
modules[bundle] = fn;
}
};
require.list = function() {
var result = [];
for (var item in modules) {
if (has.call(modules, item)) {
result.push(item);
}
}
return result;
};
require.brunch = true;
require._cache = cache;
globals.require = require;
})();
require.register("api/api", function(exports, require, module) {
module.exports = function(_) {
return {
auth: require('./auth'),
users: require('./users'),
groups: require('./groups'),
items: require('./items'),
entities: require('./entities'),
services: require('./services'),
data: require('./data'),
img: sharedLib('api/img')(_),
comments: {
"public": '/api/comments/public',
"private": '/api/comments'
},
transactions: '/api/transactions',
relations: '/api/relations',
invitations: '/api/invitations',
user: '/api/user',
notifs: '/api/notifs',
feedback: '/api/feedback/public',
i18n: function(lang) {
return "/public/i18n/dist/" + lang + ".json?DIGEST152";
},
moment: function(lang) {
return "/public/javascripts/moment/" + lang + ".js?DIGEST";
},
proxy: function(url) {
return "/api/proxy/public/" + url;
},
test: '/api/tests/public',
scripts: {
pouchdb: '/public/javascripts/pouchdb-3.3.1.min.js'
},
upload: {
post: '/api/upload',
del: '/api/upload/delete'
}
};
};
});
;require.register("api/auth", function(exports, require, module) {
var auth, authPublic;
auth = function(action) {
return "/api/auth?action=" + action;
};
authPublic = function(action) {
return "/api/auth/public?action=" + action;
};
module.exports = {
signup: authPublic('signup'),
login: authPublic('login'),
logout: authPublic('logout'),
usernameAvailability: authPublic('username-availability'),
emailAvailability: authPublic('email-availability'),
emailConfirmation: auth('email-confirmation'),
updatePassword: auth('update-password'),
resetPassword: authPublic('reset-password')
};
});
;require.register("api/commons", function(exports, require, module) {
module.exports = {
search: function(base, text) {
return _.buildPath(base, {
action: 'search',
search: text
});
},
searchByPosition: function(base, bbox) {
return _.buildPath(base, {
action: 'search-by-position',
bbox: JSON.stringify(bbox)
});
}
};
});
;require.register("api/data", function(exports, require, module) {
var dataQuery;
dataQuery = _.buildPath.bind(_, '/api/data/public');
module.exports = {
wdQuery: function(query, qid, refresh) {
return dataQuery({
api: 'wd-query',
query: query,
qid: qid,
refresh: refresh
});
},
wdq: function(query, pid, qid, refresh) {
return dataQuery({
api: 'wdq',
query: query,
pid: pid,
qid: qid,
refresh: refresh
});
},
commonsThumb: function(file, width) {
return dataQuery({
api: 'commons-thumb',
file: file,
width: width
});
},
wikipediaExtract: function(lang, title) {
return dataQuery({
api: 'wp-extract',
lang: lang,
title: title
});
},
openLibraryCover: function(openLibraryId, type) {
if (type == null) {
type = 'book';
}
return dataQuery({
api: 'openlibrary-cover',
id: openLibraryId,
type: type
});
},
enWpImage: function(enWpTitle) {
return dataQuery({
api: 'en-wikipedia-image',
title: enWpTitle
});
}
};
});
;require.register("api/entities", function(exports, require, module) {
module.exports = {
search: function(search) {
return _.buildPath("/api/entities/public", {
action: 'search',
search: search,
language: app.user.lang
});
},
getImages: function(entityUri, data) {
return _.buildPath("/api/entities/public", {
action: 'get-images',
entity: entityUri,
data: data
});
},
isbns: function(isbns) {
return _.buildPath('/api/entities/public', {
action: 'get-isbn-entities',
isbns: _.piped(isbns)
});
},
inv: {
create: '/api/entities',
get: function(ids) {
return _.buildPath('/api/entities/public', {
action: 'get-inv-entities',
ids: _.piped(ids)
});
}
}
};
});
;require.register("api/groups", function(exports, require, module) {
var privat, publik, ref, search, searchByPosition;
privat = '/api/groups';
publik = '/api/groups/public';
ref = require('./commons'), search = ref.search, searchByPosition = ref.searchByPosition;
module.exports = {
"private": privat,
"public": publik,
last: publik + "?action=last",
search: search.bind(null, publik),
searchByPosition: searchByPosition.bind(null, publik)
};
});
;require.register("api/items", function(exports, require, module) {
var base, itemsPublic, publicBase;
base = '/api/items';
publicBase = '/api/items/public';
itemsPublic = function(action, query) {
if (query == null) {
query = {};
}
return _.buildPath(publicBase, _.extend(query, {
action: action
}));
};
module.exports = {
base: base,
lastPublicItems: function(limit, offset, assertImage) {
if (limit == null) {
limit = 15;
}
if (offset == null) {
offset = 0;
}
return itemsPublic('last-public-items', {
limit: limit,
offset: offset,
'assert-image': assertImage
});
},
publicNearby: function(range) {
if (range == null) {
range = 50;
}
return _.buildPath(base, {
action: 'get-items-nearby',
range: range
});
},
publicById: function(id) {
return itemsPublic('public-by-id', {
id: id
});
},
publicByEntity: function(uri) {
return itemsPublic('public-by-entity', {
uri: uri
});
},
publicByUsernameAndEntity: function(username, EntityUri) {
return itemsPublic('public-by-username-and-entity', {
username: username,
uri: EntityUri
});
},
usersPublicItems: function(usersIds) {
usersIds = _.forceArray(usersIds);
return itemsPublic('users-public-items', {
users: usersIds.join('|')
});
}
};
});
;require.register("api/services", function(exports, require, module) {
module.exports = {
emailValidation: function(email) {
email = encodeURIComponent(email);
return "/api/services/public?service=email-validation&email=" + email;
}
};
});
;require.register("api/users", function(exports, require, module) {
var privat, publik, ref, search, searchByPosition;
privat = '/api/users';
publik = '/api/users/public';
ref = require('./commons'), search = ref.search, searchByPosition = ref.searchByPosition;
module.exports = {
data: function(ids) {
ids = _.forceArray(ids);
if (_.all(ids, _.isUserId)) {
ids = ids.join('|');
return privat + "?action=get-users&ids=" + ids;
} else {
throw new Error("users data API needs an array of valid user ids");
}
},
items: function(ids) {
ids = _.forceArray(ids);
if (ids != null) {
ids = ids.join('|');
return privat + "?action=get-items&ids=" + ids;
} else {
throw new Error("users' items API needs an id");
}
},
search: search.bind(null, publik),
searchByPosition: searchByPosition.bind(null, publik),
publicItemsNearby: function(range) {
if (range == null) {
range = 50;
}
return _.buildPath(privat, {
action: 'get-items-nearby',
range: range
});
}
};
});
;require.register("app", function(exports, require, module) {
var App, Session, scrollToPageTop;
Session = require('modules/general/models/session');
App = Marionette.Application.extend({
initialize: function() {
this.session = new Session;
this.vent = new Backbone.Wreqr.EventAggregator();
this.Behaviors = require('modules/general/behaviors/base');
this.Behaviors.initialize();
this.docTitle = function(docTitle, noCompletion) {
return this.execute('metadata:update:title', docTitle, noCompletion);
};
this.navigate = function(route, options) {
var base;
if (!_.isString(route)) {
return _.error(route, "invalid route: can't navigate");
}
route = route.replace(/^\//, '');
this.vent.trigger('route:change', _.routeSection(route), route);
this.session.record(route);
route = route.replace(/(\s|')/g, '_');
route = this.request('route:querystring:keep', route);
(base = Backbone.history).last || (base.last = []);
Backbone.history.last.unshift(route);
Backbone.history.navigate(route, options);
if (!(options != null ? options.preventScrollTop : void 0)) {
return scrollToPageTop();
}
};
this.goTo = function(route, options) {
options || (options = {});
options.trigger = true;
return Backbone.history.navigate(route, options);
};
this.navigateReplace = function(route, options) {
options || (options = {});
options.replace = true;
return this.navigate(route, options);
};
return this.once('start', (function(_this) {
return function(options) {
var routeFound;
routeFound = Backbone.history.start({
pushState: true
});
_this.session.record(Backbone.history.fragment);
Backbone.history.on('route', function() {
var route;
route = _.currentRoute();
return app.vent.trigger('route:change', _.routeSection(route), route);
});
if (!routeFound) {
console.error('route: not found! check if route is defined before app.start()');
return _.log(Backbone.history.handlers, 'route: handlers at start');
}
};
})(this));
}
});
module.exports = new App();
scrollToPageTop = function() {
return window.scrollTo(0, 0);
};
});
;require.register("init_app", function(exports, require, module) {
module.exports = function() {
var AppLayout, LocalDB, _, app;
app = require('app');
window.app = app;
_ = require('lib/builders/utils')(Backbone, window._, app, window);
app.API = require('api/api')(_);
require('lib/handlebars_helpers/base').initialize(app.API);
require('lib/global_libs_extender')(_);
require('lib/global_helpers')(app, _);
LocalDB = require('lib/data/local_db')(window, _);
app.LocalCache = require('lib/data/local_cache')(LocalDB, _, require('lib/preq'));
app.data = require('lib/data_state');
app.data.initialize();
require('lib/i18n').initialize(app);
app.module('Redirect', require('modules/redirect'));
app.module('Users', require('modules/users/users'));
app.module('Entities', require('modules/entities/entities'));
app.module('User', require('modules/user/user'));
app.module('Search', require('modules/search/search'));
app.module('Inventory', require('modules/inventory/inventory'));
app.module('Transactions', require('modules/transactions/transactions'));
app.module('Network', require('modules/network/network'));
app.module('Notifications', require('modules/notifications/notifications'));
app.module('Settings', require('modules/settings/settings'));
require('modules/map/map')();
require('modules/comments/comments')();
AppLayout = require('modules/general/views/app_layout');
app.request('i18n:set').done(function() {
return $(function() {
app.layout = new AppLayout;
require('lib/foundation').initialize(app);
app.execute('show:user:menu:update');
app.start();
app.vent.trigger('layout:ready');
return app.layout.ready = true;
});
});
require('lib/piwik')();
return require('lib/jquery-jk').initialize($);
};
});
;require.register("initialize", function(exports, require, module) {
var envConfig, featureDetection, initApp, reportError;
envConfig = require('lib/env_config')();
window.sharedLib = require('lib/shared/shared_libs');
window.requireProxy = function(path) {
return require(path);
};
featureDetection = require('lib/feature_detection');
initApp = require('./init_app');
reportError = function(label, err) {
if ((typeof _ !== "undefined" && _ !== null ? _.error : void 0) != null) {
return _.error(label, err);
} else {
throw err;
}
};
featureDetection()["catch"](reportError.bind(null, 'featureDetection err')).then(initApp);
require('lib/unhandled_error_logger').initialize();
});
;require.register("lib/allow_persistant_query", function(exports, require, module) {
var allowRedirectPersistantQuery, alwaysKeep, redirectTest,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
alwaysKeep = function() {
return true;
};
redirectTest = function(section) {
return indexOf.call(allowRedirectPersistantQuery, section) >= 0;
};
allowRedirectPersistantQuery = ['signup', 'login'];
module.exports = {
debug: alwaysKeep,
lang: alwaysKeep,
redirect: redirectTest
};
});
;require.register("lib/books", function(exports, require, module) {
var books_;
books_ = sharedLib('books')(_);
books_.getImage = function(entityUri, data) {
return _.preq.get(app.API.entities.getImages(entityUri, data)).then(_.property('images'));
};
books_.getIsbnEntities = function(isbns) {
isbns = isbns.map(books_.normalizeIsbn);
return _.preq.get(app.API.entities.isbns(isbns))["catch"](_.Error('getIsbnEntities err'));
};
module.exports = books_;
});
;require.register("lib/builders/utils", function(exports, require, module) {
module.exports = function(Backbone, _, app, window) {
var csle, local, shared_;
_ = window.invUtils(_);
csle = CONFIG.debug ? window.console : require('lib/noop_console');
local = require('lib/utils')(Backbone, _, app, window, csle);
shared_ = sharedLib('utils');
_.extend(_, local, shared_);
_.preq = require('lib/preq');
_.isMobile = require('lib/mobile_check');
return _;
};
});
;require.register("lib/data/local_cache", function(exports, require, module) {
module.exports = function(LocalDB, _, promises_) {
var LocalCache;
return LocalCache = function(options) {
var API, args, completeWithRemoteData, defaultParser, findId, findMissingIds, formatData, getLocalData, getMissingData, localdb, logError, name, normalizeId, parseData, parseJSON, putInLocalDb, putLocalData, remote, types;
name = options.name, remote = options.remote, normalizeId = options.normalizeId, parseData = options.parseData;
args = [name, remote, normalizeId, parseData];
types = ['string', 'object', 'function|undefined', 'function|undefined'];
_.types(args, types);
localdb = LocalDB(name);
defaultParser = _.identity;
parseData || (parseData = defaultParser);
API = {
get: function(ids, format, refresh) {
var err, error, promise;
try {
ids = _.forceArray(ids);
} catch (error) {
err = error;
return Promise.reject(err);
}
if (ids.length === 0) {
promise = _.preq.resolve({});
} else if (refresh) {
promise = getMissingData(ids);
} else {
promise = getLocalData(ids).then(completeWithRemoteData);
}
return promise.then(formatData.bind(null, format))["catch"](logError);
},
save: function(id, value) {
_.types(arguments, ['string', 'object']);
return putInLocalDb(id, value);
},
reset: function() {
return localdb.destroy();
},
db: localdb
};
getLocalData = function(ids) {
_.types(ids, 'strings...');
if (normalizeId != null) {
ids = ids.map(normalizeId);
}
return localdb.get(ids).then(parseJSON);
};
parseJSON = function(data) {
var err, error, k, parsed, v;
_.type(data, 'object');
parsed = {};
for (k in data) {
v = data[k];
try {
parsed[k] = JSON.parse(v);
} catch (error) {
err = error;
_.error("invalid json: " + v);
}
}
return parsed;
};
completeWithRemoteData = function(data) {
var missingIds;
_.type(data, 'object');
missingIds = findMissingIds(data);
if (missingIds.length > 0) {
return getMissingData(missingIds).then(function(missingData) {
return _.extend(data, missingData);
});
} else {
return data;
}
};
findMissingIds = function(data) {
var k, missingIds, v;
_.type(data, 'object');
missingIds = [];
for (k in data) {
v = data[k];
if (v == null) {
missingIds.push(k);
}
}
return missingIds;
};
getMissingData = function(ids) {
var promise;
_.type(ids, 'array');
promise = remote.get(ids).then(parseData);
if ((promise != null ? promise.then : void 0) == null) {
throw new Error('couldnt get missing data');
}
promise.then(putLocalData);
return promise;
};
putLocalData = function(data) {
var id, v;
_.type(data, 'object');
for (id in data) {
v = data[id];
putInLocalDb(id, v);
}
return data;
};
putInLocalDb = function(id, value) {
_.types(arguments, ['string', 'object']);
localdb.put(id, JSON.stringify(value));
return value;
};
formatData = function(format, data) {
if (format == null) {
format = 'index';
}
_.type(data, 'object');
if (format === 'collection') {
data = _.values(data);
}
return data;
};
logError = function(err) {
_.error(err, 'local cache err');
};
if (remote.post != null) {
API.post = function(data) {
return remote.post(data).then(function(res) {
var id;
id = findId(res);
return putInLocalDb(id, res);
})["catch"](_.Error(name + " local.post err"));
};
findId = function(res) {
var id;
id = res._id || res.id;
if (id != null) {
return id;
} else {
throw new Error("id not found: " + (JSON.stringify(res)));
}
};
}
_.extend(this, API);
};
};
});
;require.register("lib/data/local_db", function(exports, require, module) {
var resetDbsPeriodically;
resetDbsPeriodically = require('./reset_dbs_periodically');
module.exports = function(global, _) {
var DB, Level, LocalDB, deleteBatch, inspect, pushKey, reset;
global.dbs = {
list: {}
};
if (window.supportsIndexedDB) {
DB = LevelJs;
_.log('supportsIndexedDB true: using LevelJs');
setTimeout(resetDbsPeriodically, 10 * 1000);
} else {
DB = MemDown;
_.log('supportsIndexedDB false: using MemDown');
}
Level = function(dbName) {
return LevelMultiply(LevelUp(dbName, {
db: DB
}));
};
reset = function(db, dbName) {
var ops;
ops = [];
return db.createKeyStream().on('data', pushKey.bind(null, ops)).on('end', deleteBatch.bind(null, db, ops, dbName));
};
inspect = function(db, dbName) {
var dbObj;
dbObj = {};
return db.createReadStream().on('data', function(res) {
var key, value;
key = res.key, value = res.value;
return _.log(JSON.parse(value), key);
}).on('end', _.Log("-- " + dbName + " inspect end"));
};
pushKey = function(ops, key) {
return ops.push({
type: 'del',
key: key
});
};
deleteBatch = function(db, ops, dbName) {
return db.batch(ops, function(err) {
if (err) {
return _.log(err, dbName + " reset failed");
} else {
return _.log(dbName + " reset successfully!");
}
});
};
dbs.reset = function() {
var db, dbName, ref, results;
ref = dbs.list;
results = [];
for (dbName in ref) {
db = ref[dbName];
results.push(db.reset());
}
return results;
};
dbs.inspect = function() {
var db, dbName, ref, results;
ref = dbs.list;
results = [];
for (dbName in ref) {
db = ref[dbName];
results.push(db.inspect());
}
return results;
};
return LocalDB = function(dbName) {
var API, db;
db = Level(dbName);
API = {
get: Promise.promisify(db.get),
put: Promise.promisify(db.put),
batch: Promise.promisify(db.batch),
reset: reset.bind(null, db, dbName),
inspect: inspect.bind(null, db, dbName),
db: db
};
return dbs.list[dbName] = API;
};
};
});
;require.register("lib/data/reset_dbs_periodically", function(exports, require, module) {
var getLastResetTime, initPeriodicalReset, period, periodIsOver, resetDbsNow, resetIfOnline;
period = 15 * 24 * 3600 * 1000;
module.exports = function() {
var lastResetTime;
lastResetTime = getLastResetTime();
if (lastResetTime == null) {
return initPeriodicalReset();
}
if (periodIsOver(lastResetTime)) {
return app.request('ifOnline', resetIfOnline);
} else {
return _.log(lastResetTime, 'not reseting dbs: last reset is fresh enough');
}
};
resetIfOnline = function() {
return resetDbsNow('starting periodic dbs.reset');
};
getLastResetTime = function() {
var lastReset;
lastReset = localStorageProxy.getItem('last_db_reset');
lastReset = Number(lastReset);
if (_.typeOf(lastReset) === 'number') {
return lastReset;
} else {
}
};
initPeriodicalReset = function() {
return resetDbsNow('intializing dbs.reset');
};
periodIsOver = function(lastResetTime) {
return _.now() - lastResetTime > period;
};
resetDbsNow = function(label) {
if (label != null) {
_.log(label);
}
dbs.reset();
return localStorageProxy.setItem('last_db_reset', _.now());
};
});
;require.register("lib/data_state", function(exports, require, module) {
var data, findMissingDataSets, initDataWaiters, online, ping;
app.online = online = null;
initDataWaiters = require('./data_waiters');
module.exports = {
initialize: function() {
this.ready = false;
this._updateStatus();
setTimeout(this.warnOnExcessiveTime.bind(this), 8000);
ping();
initDataWaiters();
return app.reqres.setHandlers({
'ifOnline': function(success, showOfflineError) {
var cb;
cb = function() {
if (online) {
return success();
} else {
if (showOfflineError) {
return app.execute('show:offline:error');
} else {
return console.warn("can't reach the server");
}
}
};
if (online != null) {
return cb();
} else {
return app.vent.once('app:online', cb());
}
}
});
},
_updateStatus: function() {
if (this.missing == null) {
this.missing = findMissingDataSets();
this._listenForReadyEvents();
} else {
this.missing = findMissingDataSets();
}
return this._checkIfDataReady();
},
_listenForReadyEvents: function() {
var el, i, len, ref, results;
ref = this.missing;
results = [];
for (i = 0, len = ref.length; i < len; i++) {
el = ref[i];
results.push(app.vent.once(el.eventName, app.data._updateStatus, app.data));
}
return results;
},
_checkIfDataReady: function() {
if (this.missing.length === 0) {
this.ready = true;
app.vent.trigger('data:ready');
setTimeout(app.vent.trigger.bind(app.vent, 'data:ready:after'), 100);
return true;
} else {
return false;
}
},
warnOnExcessiveTime: function() {
var warn;
if (!this.ready) {
warn = 'data:ready didnt arrived yet! Missing events:';
return console.warn(warn, this.missingEvents());
}
},
missingEvents: function() {
return JSON.stringify(_.pluck(this.missing, 'eventName'));
}
};
findMissingDataSets = function() {
var el, i, len, missing;
missing = [];
for (i = 0, len = data.length; i < len; i++) {
el = data[i];
if (!el.ready()) {
missing.push(el);
}
}
return missing;
};
data = [
{
eventName: 'user:ready',
ready: function() {
var ref;
return typeof app !== "undefined" && app !== null ? (ref = app.user) != null ? ref.fetched : void 0 : void 0;
}
}, {
eventName: 'items:ready',
ready: function() {
var ref;
return typeof Items !== "undefined" && Items !== null ? (ref = Items.personal) != null ? ref.fetched : void 0 : void 0;
}
}, {
eventName: 'users:ready',
ready: function() {
var ref;
return typeof app !== "undefined" && app !== null ? (ref = app.users) != null ? ref.fetched : void 0 : void 0;
}
}
];
ping = function() {
return _.preq.get(app.API.test).then(function() {
online = true;
return app.vent.trigger('app:online');
})["catch"](function(err) {
online = false;
return console.warn('server: unreachable. You might be offline', err);
});
};
});
;require.register("lib/data_waiters", function(exports, require, module) {
module.exports = function() {
var Waiter, waitForItems;
Waiter = function(eventName, ready) {
var fn;
_.time(eventName);
fn = function() {
if (ready()) {
return _.preq.resolved;
} else {
return new Promise(function(resolve, reject) {
return app.vent.once(eventName, function() {
_.timeEnd(eventName);
return resolve();
});
});
}
};
return _.once(fn);
};
waitForItems = function() {
var ref, ref1;
if (!app.user.loggedIn) {
return _.preq.resolved;
}
if ((typeof Items !== "undefined" && Items !== null ? (ref = Items.friends) != null ? ref.fetched : void 0 : void 0) && ((ref1 = Items.personal) != null ? ref1.fetched : void 0)) {
return _.preq.resolved;
} else {
return new Promise(function(resolve, reject) {
app.vent.once('friends:items:ready', function() {
var ref2;
if ((ref2 = Items.personal) != null ? ref2.fetched : void 0) {
return resolve();
}
});
return app.vent.once('items:ready', function() {
var ref2;
if ((ref2 = Items.friends) != null ? ref2.fetched : void 0) {
return resolve();
}
});
});
}
};
return app.reqres.setHandlers({
'waitForData': Waiter('data:ready', function() {
return app.data.ready;
}),
'waitForData:after': Waiter('data:ready:after', function() {
return app.data.ready;
}),
'waitForUserData': Waiter('user:ready', function() {
var ref;
return (ref = app.user) != null ? ref.fetched : void 0;
}),
'waitForFriendsItems': Waiter('friends:items:ready', function() {
var ref;
return typeof Items !== "undefined" && Items !== null ? (ref = Items.friends) != null ? ref.fetched : void 0 : void 0;
}),
'waitForItems': _.once(waitForItems),
'waitForLayout': Waiter('layout:ready', function() {
var ref;
return (ref = app.layout) != null ? ref.ready : void 0;
})
});
};
});
;require.register("lib/env_config", function(exports, require, module) {
if (location.hostname === 'localhost') {
window.env = 'dev';
} else {
window.env = 'prod';
}
module.exports = function() {
if (env === 'dev') {
Promise.config({
longStackTraces: true,
warnings: {
wForgottenReturn: false
}
});
}
return window.CONFIG = {
images: {
maxSize: 1600
},
debug: false
};
};
});
;require.register("lib/error", function(exports, require, module) {
var error_, throwComplete;
error_ = {
"new": function(message, context) {
var err;
err = new Error(message);
err.context = context;
return err;
},
complete: function(selector, err) {
err.selector = selector;
return err;
}
};
throwComplete = function(selector, err) {
err.selector = selector;
throw err;
};
error_.Complete = function(selector) {
return throwComplete.bind(null, selector);
};
module.exports = error_;
});
;require.register("lib/feature_detection", function(exports, require, module) {
var ISODatePolyFill, sayHi, setDebugSetting, solveIdbSupport, testFlexSupport, testIndexedDbSupport, testLocalStorage;
module.exports = function() {
ISODatePolyFill();
sayHi();
testFlexSupport();
testLocalStorage();
setDebugSetting();
return testIndexedDbSupport();
};
sayHi = function() {
return console.log("\n,___,\n[-.-] I've been expecting you, Mr Bond\n/)__)\n-\"--\"-\nWant to make Inventaire better? Jump in! https://github.com/inventaire/inventaire\nGuidelines and inspiration: https://inventaire.io/guidelines-and-inspiration\n------");
};
testFlexSupport = function() {
var detector;
detector = document.createElement('detect');
detector.style.display = 'flex';
if (detector.style.display !== 'flex') {
return console.warn('Flex is not supported');
}
};
ISODatePolyFill = function() {
var pad;
if (typeof DatetoISOString === "undefined" || DatetoISOString === null) {
pad = function(number) {
if (number < 10) {
return '0' + number;
}
return number;
};
return Date.prototype.toISOString = function() {
return this.getUTCFullYear() + '-' + pad(this.getUTCMonth() + 1) + '-' + pad(this.getUTCDate()) + 'T' + pad(this.getUTCHours()) + ':' + pad(this.getUTCMinutes()) + ':' + pad(this.getUTCSeconds()) + '.' + (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z';
};
}
};
testLocalStorage = function() {
var err, error, localStorageProxy, storage;
try {
window.localStorage.setItem('localStorage-support', true);
localStorageProxy = localStorage;
} catch (error) {
err = error;
console.warn('localStorage isnt supported');
storage = {};
localStorageProxy = {
getItem: function(key) {
return storage[key] || null;
},
setItem: function(key, value) {
storage[key] = value;
},
clear: function() {
return storage = {};
}
};
}
return window.localStorageProxy = localStorageProxy;
};
setDebugSetting = function() {
var persistantDebug, queryStringDebug;
persistantDebug = localStorageProxy.getItem('debug') === 'true';
queryStringDebug = window.location.search.split('debug=true').length > 1;
if (persistantDebug || queryStringDebug) {
console.log('debug enabled');
return CONFIG.debug = true;
} else {
return console.warn("logs are disabled.\n Activate logs by entering this command and reloading the page:\n localStorage.setItem('debug', true)\n Or activate logs once by adding debug=true as a query parameter");
}
};
testIndexedDbSupport = function() {
var indexedDB;
indexedDB = indexedDB || window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.OIndexedDB || window.msIndexedDB;
return solveIdbSupport(indexedDB).then(function(bool) {
window.supportsIndexedDB = bool;
if (!bool) {
return console.warn('Indexeddb isnt supported');
}
})["catch"](console.error.bind(console, 'testIndexedDbSupport err'));
};
solveIdbSupport = function(indexedDB) {
return new Promise(function(resolve, reject) {
var test;
test = indexedDB.open('_indexeddb_support_detection', 1);
test.onsuccess = function() {
return resolve(true);
};
test.onerror = function() {
window.supportsIndexedDB = false;
return resolve(false);
};
});
};
});
;require.register("lib/fetch_moment_local", function(exports, require, module) {
var momentLang, pickMomentLang,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
module.exports = function(lang) {
var validLang;
validLang = pickMomentLang(lang);
if (validLang != null) {
return _.preq.getScript(app.API.moment(lang)).then(function() {
return moment.locale(lang);
})["catch"](_.Error('fetchMomentLocale err'));
}
};
pickMomentLang = function(lang) {
lang = lang.toLowerCase();
if (indexOf.call(momentLang, lang) >= 0) {
return lang;
} else {
return null;
}
};
momentLang = ['af', 'ar', 'ar-ma', 'ar-sa', 'az', 'be', 'bg', 'bn', 'bo', 'br', 'bs', 'ca', 'cs', 'cv', 'cy', 'da', 'de-at', 'de', 'el', 'en-au', 'en-ca', 'en-gb', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fo', 'fr-ca', 'fr', 'gl', 'he', 'hi', 'hr', 'hu', 'hy-am', 'id', 'is', 'it', 'ja', 'ka', 'km', 'ko', 'lb', 'lt', 'lv', 'mk', 'ml', 'mr', 'ms-my', 'my', 'nb', 'ne', 'nl', 'nn', 'pl', 'pt-br', 'pt', 'ro', 'ru', 'sk', 'sl', 'sq', 'sr-cyrl', 'sr', 'sv', 'ta', 'th', 'tl-ph', 'tr', 'tzm', 'tzm-latn', 'uk', 'uz', 'vi', 'zh-cn', 'zh-tw'];
});
;require.register("lib/foundation", function(exports, require, module) {
var focusFirstInput, foundationReload, largeModal, modalClose, modalOpen, normalModal, startJoyride;
module.exports.initialize = function(app) {
return app.commands.setHandlers({
'foundation:reload': _.debounce(foundationReload, 50),
'modal:open': modalOpen,
'modal:close': modalClose,
'foundation:joyride:start': startJoyride
});
};
foundationReload = function(options) {
$(document).foundation(options);
return app.vent.trigger('foundation:reload');
};
modalOpen = function(size) {
if (size === 'large') {
largeModal();
} else {
normalModal();
}
$('#modal').foundation('reveal', 'open');
app.execute('foundation:reload');
return setTimeout(focusFirstInput, 600);
};
focusFirstInput = function() {
return $('#modal').find('input, textarea').first().focus();
};
modalClose = function() {
return $('#modal').foundation('reveal', 'close');
};
largeModal = function() {
return $('#modal').addClass('large');
};
normalModal = function() {
return $('#modal').removeClass('large');
};
startJoyride = function(options) {
return $(document).foundation(options).foundation('joyride', 'start');
};
});
;require.register("lib/global_helpers", function(exports, require, module) {
module.exports = function(app, _) {
return require('./querystring_helpers')(app, _);
};
});
;require.register("lib/global_libs_extender", function(exports, require, module) {
var error_, triggerChange,
slice = [].slice;
error_ = require('lib/error');
module.exports = function(_) {
var ArrayHandler, ajax;
sharedLib('global_libs_extender')();
window.location.root = window.location.protocol + '//' + window.location.host;
Backbone.Model.prototype.idAttribute = '_id';
ArrayHandler = function(handler) {
var fn;
return fn = function(attr, value) {
var array;
array = this.get(attr) || [];
_.typeArray(array);
array = handler(array, value);
this.set(attr, array);
return triggerChange(this, attr, value);
};
};
Backbone.Model.prototype.push = ArrayHandler(function(array, value) {
array.push(value);
return array;
});
Backbone.Model.prototype.unshift = ArrayHandler(function(array, value) {
array.unshift(value);
return array;
});
Backbone.Model.prototype.without = ArrayHandler(function(array, value) {
return _.without(array, value);
});
Backbone.Model.prototype.gets = function() {
var attributes;
attributes = 1 <= arguments.length ? slice.call(arguments, 0) : [];
if (_.isArray(attributes[0])) {
throw new Error('gets expects attributes as different arguments');
}
return attributes.map(this.get.bind(this));
};
Backbone.Model.prototype.reqGrab = function(request, id, name) {
return app.request(request, id).then(this.grab.bind(this, name))["catch"](_.Error("reqGrab " + request + " " + id + " " + name));
};
Backbone.Model.prototype.grab = function(name, model) {
if (model == null) {
throw error_["new"]('grab failed: missing model', arguments);
}
this[name] = model;
return this.triggerGrab(name, model);
};
Backbone.Model.prototype.triggerGrab = function(name, model) {
this.trigger('grab', name, model);
return this.trigger("grab:" + name, model);
};
Backbone.Collection.prototype.findOne = function() {
return this.models[0];
};
Backbone.Collection.prototype.byId = function(id) {
return this._byId[id];
};
Backbone.Collection.prototype.byIds = function(ids) {
return ids.map((function(_this) {
return function(id) {
return _this._byId[id];
};
})(this));
};
Backbone.Collection.prototype.attributes = function() {
return this.toJSON();
};
FilteredCollection.prototype.filterByText = function(text, reset) {
var filterExpr;
if (reset == null) {
reset = true;
}
if (reset) {
this.resetFilters();
}
filterExpr = new RegExp(text, 'i');
return this.filterBy('text', function(model) {
if (model.matches != null) {
return model.matches(filterExpr);
} else {
return _.error(model, 'model has no matches method');
}
});
};
Marionette.Region.prototype.Show = function(view, options) {
var docTitle, noCompletion;
if (options == null) {
options = {};
}
if (_.isString(options)) {
docTitle = options;
} else {
docTitle = options.docTitle, noCompletion = options.noCompletion;
}
if (docTitle != null) {
app.docTitle(_.softDecodeURI(docTitle), noCompletion);
}
return this.show(view, options);
};
$.fn.once = $.fn.one;
$.postJSON = function(url, data) {
return ajax('POST', url, 'json', data);
};
$.put = function(url, data) {
return $.ajax({
url: url,
data: data,
type: 'PUT'
});
};
$.putJSON = function(url, data) {
return ajax('PUT', url, 'json', data);
};
$["delete"] = function(url) {
return ajax('DELETE', url);
};
$.getXML = function(url) {
return ajax('GET', url, 'xml');
};
return ajax = function(verb, url, dataType, data) {
return $.ajax({
url: url,
type: verb,
data: data,
dataType: dataType
});
};
};
triggerChange = function(model, attr, value) {
model.trigger('change', model, attr, value);
return model.trigger("change:" + attr, model, value);
};
});
;require.register("lib/handlebars_helpers/base", function(exports, require, module) {
module.exports = {
initialize: function(appApi) {
var API, fn, name, register, results;
API = _.extend.apply(null, [{}, require('./blocks'), require('./misc'), require('./utils'), require('./partials'), require('./wikidata_claims'), require('./user_content'), require('./images'), require('./input'), require('../shared/handlebars_helpers')(_, appApi)]);
register = function(name, fn) {
return Handlebars.registerHelper(name, fn);
};
results = [];
for (name in API) {
fn = API[name];
results.push(register(name, fn.bind(API)));
}
return results;
}
};
});
;require.register("lib/handlebars_helpers/blocks", function(exports, require, module) {
module.exports = {
loggedIn: function(options) {
if (app.user.loggedIn) {
return options.fn(this);
}
},
notLoggedIn: function(options) {
if (!app.user.loggedIn) {
return options.fn(this);
}
}
};
});
;require.register("lib/handlebars_helpers/claims_helpers", function(exports, require, module) {
var P, Q, SafeString, escapeExpression, wdP, wdQ;
wdQ = require('modules/general/views/behaviors/templates/wikidata_Q');
wdP = require('modules/general/views/behaviors/templates/wikidata_P');
SafeString = Handlebars.SafeString, escapeExpression = Handlebars.escapeExpression;
P = function(id) {
if (/^P[0-9]+$/.test(id)) {
return wdP({
id: id
});
} else {
return wdP({
id: "P" + id
});
}
};
Q = function(id, linkify, alt) {
if (id != null) {
if (typeof alt !== 'string') {
alt = '';
}
app.execute('qlabel:update');
alt = escapeExpression(alt);
return wdQ({
id: id,
linkify: linkify,
alt: alt,
label: alt
});
}
};
module.exports = {
P: P,
Q: Q,
neutralizeDataObject: function(args) {
var last;
last = args.last();
if (((last != null ? last.hash : void 0) != null) && (last.data != null)) {
return args.slice(0, -1);
} else {
return args;
}
},
getQsTemplates: function(valueArray, linkify) {
return _.compact(valueArray).map(function(id) {
return Q(id, linkify).trim();
}).join(', ');
},
labelString: function(pid, omitLabel) {
if (omitLabel) {
return '';
} else {
return P(pid);
}
},
claimString: function(label, values, inline) {
var text;
text = label + " " + values;
if (!inline) {
text += ' <br>';
}
return new SafeString(text);
}
};
});
;require.register("lib/handlebars_helpers/format_author", function(exports, require, module) {
var Q, SafeString, escapeExpression, formatString, linkifyAuthorString;
Q = require('./wikidata_claims').Q;
SafeString = Handlebars.SafeString, escapeExpression = Handlebars.escapeExpression;
module.exports = function(linkify, arg) {
var label, type, value;
if (_.isString(arg)) {
return formatString(arg, linkify);
} else {
type = arg.type, value = arg.value, label = arg.label;
switch (type) {
case 'string':
return formatString(value, linkify);
case 'wikidata_id':
return Q(value, linkify, label);
default:
_.warn(arg, 'unknown author data type');
}
}
};
formatString = function(str, linkify) {
var t;
t = linkify ? linkifyAuthorString(str) : escapeExpression(str);
return new SafeString(t);
};
linkifyAuthorString = function(text) {
var q, str;
str = escapeExpression(text);
q = encodeURIComponent(text);
return "<a href='/search?q=" + q + "' class='link searchAuthor'>" + str + "</a>";
};
});
;require.register("lib/handlebars_helpers/images", function(exports, require, module) {
var SafeString, images, imagesList,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
SafeString = Handlebars.SafeString;
exports.icon = function(name, classes) {
var src;
if (_.isString(name)) {
if (indexOf.call(imagesList, name) >= 0) {
src = images[name];
return new SafeString("<img class='icon' src='" + src + "'>");
} else {
if (!_.isString(classes)) {
classes = '';
}
return new SafeString(_.icon(name, classes));
}
}
};
images = {
wikipedia: '/public/images/wikipedia-64.png',
wikidata: '/public/images/wikidata.svg',
wikisource: '/public/images/wikisource-64.png',
pouchdb: '/public/images/pouchdb.svg'
};
imagesList = Object.keys(images);
exports.iconLink = function(name, url, classes) {
var icon;
icon = this.icon.call(null, name, classes);
return this.link.call(this, icon, url, '');
};
exports.iconLinkText = function(name, url, text, classes) {
var icon;
icon = this.icon.call(null, name, classes);
return this.link.call(this, icon + "<span>" + text + "</span>", url, '');
};
});
;require.register("lib/handlebars_helpers/input", function(exports, require, module) {
var SafeString, applyOptions, behavior, check, input, textarea;
behavior = function(name) {
return require("modules/general/views/behaviors/templates/" + name);
};
check = behavior('success_check');
input = behavior('input');
textarea = behavior('textarea');
SafeString = Handlebars.SafeString;
module.exports = {
input: function(data, options) {
var base, button, field, icon, name, ref;
if (data == null) {
_.log(arguments, 'input arguments @err');
throw new Error('no data');
}
field = {
type: 'text',
dotdotdot: '...'
};
button = {
classes: 'success postfix'
};
name = data.nameBase;
if (name != null) {
field.id = name + 'Field';
field.name = name;
button.id = name + 'Button';
button.text = name;
}
if (((ref = data.button) != null ? ref.icon : void 0) != null) {
icon = _.icon(data.button.icon);
if (data.button.text != null) {
data.button.text = icon + "<span>" + data.button.text + "</span>";
} else {
data.button.text = icon;
}
}
data = {
id: name + "Group",
field: _.extend(field, data.field),
button: _.extend(button, data.button)
};
if ((base = data.field).placeholder == null) {
base.placeholder = _.i18n(name);
}
if (data.special) {
data.special = 'autocorrect="off" autocapitalize="off"';
}
return applyOptions(input(data), options);
},
disableAuto: function() {
return 'autocorrect="off" autocapitalize="off"';
},
textarea: function(data, options) {
if (data == null) {
_.log(arguments, 'textarea arguments err');
throw new Error('no data');
}
return applyOptions(textarea(data), options);
}
};
applyOptions = function(html, options) {
html = options === 'check' ? check(html) : html;
return new SafeString(html);
};
});
;require.register("lib/handlebars_helpers/linkify", function(exports, require, module) {
module.exports = function(text, url, classes) {
if (classes == null) {
classes = 'link';
}
if (typeof classes !== 'string') {
classes = '';
}
return "<a href=\"" + url + "\" class='" + classes + "' target='_blank'>" + text + "</a>";
};
});
;require.register("lib/handlebars_helpers/misc", function(exports, require, module) {
var SafeString,
slice = [].slice;
SafeString = Handlebars.SafeString;
module.exports = {
i18n: function() {
var args, context, data, firstArg, i, key;
key = arguments[0], args = 3 <= arguments.length ? slice.call(arguments, 1, i = arguments.length - 1) : (i = 1, []), data = arguments[i++];
if (key == null) {
return '';
}
firstArg = args[0];
if (_.isObject(firstArg) || _.isNumber(firstArg)) {
context = firstArg;
} else if (args.length % 2 === 0) {
context = _.objectifyPairs(args);
} else {
context = null;
}
return _.i18n(key, context);
},
I18n: function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _.capitaliseFirstLetter(this.i18n.apply(this, args));
},
link: function(text, url, classes) {
return new SafeString(this.linkify(text, url, classes));
},
i18nLink: function(text, url) {
text = _.i18n(text);
return this.link(text, url);
},
limit: function(text, limit) {
var t;
if (text == null) {
return '';
}
t = text.slice(0, +limit + 1 || 9e9);
if (text.length > limit) {
t += '[...]';
}
return new SafeString(t);
},
ifvalue: function(attr, value) {
if (value != null) {
return attr + "=" + value;
} else {
}
},
inlineOptions: function(options) {
var k, str, v;
str = '';
for (k in options) {
v = options[k];
str += k + ":" + v + "; ";
}
return str;
},
linkify: require('./linkify'),
qrcode: function(url, size) {
return _.qrcode(url, size);
},
debug: function() {
_.log(arguments, 'hb debug arguments');
return _.log(this, 'hb debug this');
},
timeFromNow: function(time) {
return moment(time).fromNow();
},
dateYear: function(date) {
return date.split('-')[0];
}
};
});
;require.register("lib/handlebars_helpers/partials", function(exports, require, module) {
var SafeString, behavior, check, tip;
behavior = function(name) {
return require("modules/general/views/behaviors/templates/" + name);
};
check = behavior('success_check');
tip = behavior('tip');
SafeString = Handlebars.SafeString;
module.exports = {
partial: function(name, context, option) {
var file, module, partial, parts, path, ref, subfolder, template;
parts = name.split(':');
switch (parts.length) {
case 3:
module = parts[0], subfolder = parts[1], file = parts[2];
break;
case 2:
module = parts[0], file = parts[1];
break;
case 1:
ref = ['general', name], module = ref[0], file = ref[1];
}
if (subfolder != null) {
path = "modules/" + module + "/views/" + subfolder + "/templates/" + file;
} else {
path = "modules/" + module + "/views/templates/" + file;
}
template = require(path);
partial = new SafeString(template(context));
switch (option) {
case 'check':
partial = new SafeString(check(partial));
}
return partial;
},
tip: function(text, position) {
var context;
context = {
text: _.i18n(text),
position: position || 'rigth'
};
return new SafeString(tip(context));
}
};
});
;require.register("lib/handlebars_helpers/platforms", function(exports, require, module) {
var gutenbergBase, images_;
images_ = require('./images');
module.exports = {
P1938: {
label: function() {
return images_.icon('download');
},
text: function(id) {
return _.i18n("ebooks on gutenberg.org");
},
url: function(id) {
return (gutenbergBase()) + "ebooks/author/" + id;
}
},
P2002: {
label: function() {
return images_.icon('twitter');
},
text: function(username) {
return "@" + username;
},
url: function(username) {
return "https://twitter.com/" + username;
}
},
P2003: {
label: function() {
return images_.icon('instagram');
},
text: function(username) {
return username;
},
url: function(username) {
return "https://instagram.com/" + username;
}
},
P2013: {
label: function() {
return images_.icon('facebook');
},
text: function(facebookId) {
return facebookId;
},
url: function(facebookId) {
return "https://facebook.com/" + facebookId;
}
},
P2034: {
label: function() {
return images_.icon('download');
},
text: function(id) {
return _.i18n('download ebook');
},
url: function(id) {
return (gutenbergBase()) + "ebooks/" + id;
}
}
};
gutenbergBase = function() {
var base;
base = _.smallScreen() ? 'http://m.' : 'https://www.';
return base + "gutenberg.org/";
};
});
;require.register("lib/handlebars_helpers/user_content", function(exports, require, module) {
var SafeString, escapeExpression, link, protocolText;
SafeString = Handlebars.SafeString, escapeExpression = Handlebars.escapeExpression;
link = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]+)/gim;
protocolText = '<a href="$1" class="content-link" target="_blank" rel="nofollow">$1</a>';
module.exports = {
userContent: function(text) {
if (text != null) {
text = escapeExpression(text);
text = text.replace(/\n/g, '<br>').replace(link, protocolText);
return new SafeString(text);
} else {
}
}
};
});
;require.register("lib/handlebars_helpers/utils", function(exports, require, module) {
var formatAuthor;
formatAuthor = require('./format_author');
module.exports = {
join: function(array, separator) {
if (array == null) {
return '';
}
if (!_.isString(separator)) {
separator = ', ';
}
return array.join(separator);
},
log: function(args, data) {
return _.log.apply(_, args);
},
"default": function(text, def) {
return text || def;
},
joinAuthors: function(array, linkify) {
if (array == null) {
return '';
}
if (!_.isBoolean(linkify)) {
linkify = true;
}
return this.join(array.map(formatAuthor.bind(null, linkify)));
}
};
});
;require.register("lib/handlebars_helpers/wikidata_claims", function(exports, require, module) {
var P, Q, SafeString, claimString, getQsTemplates, images_, labelString, linkify_, neutralizeDataObject, platforms_, ref, wd_,
slice = [].slice;
SafeString = Handlebars.SafeString;
wd_ = require('lib/wikidata');
linkify_ = require('./linkify');
images_ = require('./images');
platforms_ = require('./platforms');
ref = require('./claims_helpers'), P = ref.P, Q = ref.Q, neutralizeDataObject = ref.neutralizeDataObject, getQsTemplates = ref.getQsTemplates, labelString = ref.labelString, claimString = ref.claimString;
module.exports = {
P: P,
Q: Q,
claim: function() {
var args, claims, inline, label, linkify, omitLabel, pid, ref1, ref2, values;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
ref1 = neutralizeDataObject(args), claims = ref1[0], pid = ref1[1], linkify = ref1[2], omitLabel = ref1[3], inline = ref1[4];
if ((claims != null ? (ref2 = claims[pid]) != null ? ref2[0] : void 0 : void 0) != null) {
label = labelString(pid, omitLabel);
values = getQsTemplates(claims[pid], linkify);
return claimString(label, values, inline);
}
},
timeClaim: function() {
var args, claims, format, inline, label, omitLabel, pid, ref1, ref2, values;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
ref1 = neutralizeDataObject(args), claims = ref1[0], pid = ref1[1], format = ref1[2], omitLabel = ref1[3], inline = ref1[4];
format || (format = 'year');
if ((claims != null ? (ref2 = claims[pid]) != null ? ref2[0] : void 0 : void 0) != null) {
values = claims[pid].map(function(unixTime) {
var time;
time = new Date(unixTime);
switch (format) {
case 'year':
return time.getUTCFullYear();
}
});
label = labelString(pid, omitLabel);
values = _.uniq(values).join(" " + (_.i18n('or')) + " ");
return claimString(label, values, inline);
}
},
imageClaim: function(claims, pid, omitLabel, inline, data) {
var file, ref1, src;
if ((claims != null ? (ref1 = claims[pid]) != null ? ref1[0] : void 0 : void 0) != null) {
file = claims[pid][0];
src = wd_.wmCommonsSmallThumb(file, 200);
return new SafeString("<img src='" + src + "'>");
}
},
stringClaim: function() {
var args, claims, inline, label, linkify, omitLabel, pid, ref1, ref2, ref3, values;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
ref1 = neutralizeDataObject(args), claims = ref1[0], pid = ref1[1], linkify = ref1[2], omitLabel = ref1[3], inline = ref1[4];
if ((claims != null ? (ref2 = claims[pid]) != null ? ref2[0] : void 0 : void 0) != null) {
label = labelString(pid, omitLabel);
values = (ref3 = claims[pid]) != null ? ref3.join(', ') : void 0;
return claimString(label, values, inline);
}
},
urlClaim: function() {
var args, claims, cleanedUrl, firstUrl, label, pid, ref1, ref2, values;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
ref1 = neutralizeDataObject(args), claims = ref1[0], pid = ref1[1];
firstUrl = claims != null ? (ref2 = claims[pid]) != null ? ref2[0] : void 0 : void 0;
if (firstUrl != null) {
label = images_.icon('link');
cleanedUrl = _.dropProtocol(firstUrl);
values = linkify_(cleanedUrl, firstUrl, 'link website');
return claimString(label, values);
}
},
platformClaim: function() {
var args, claims, firstUsername, label, pid, platform, ref1, ref2, values;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
ref1 = neutralizeDataObject(args), claims = ref1[0], pid = ref1[1];
firstUsername = claims != null ? (ref2 = claims[pid]) != null ? ref2[0] : void 0 : void 0;
if (firstUsername != null) {
platform = platforms_[pid];
label = platform.label();
values = linkify_(platform.text(firstUsername), platform.url(firstUsername), 'link social-network');
return claimString(label, values);
}
},
wdRemoteHref: function(id) {
return "https://www.wikidata.org/entity/" + id;
},
wdLocalHref: function(id, label) {
return app.request('get:entity:local:href', 'wd', id, label);
}
};
});
;require.register("lib/i18n", function(exports, require, module) {
var doneChanging, fetchMomentLocale, qlabel, requestI18nFile, setLanguage, updatePolyglot, updateQlabel;
fetchMomentLocale = require('./fetch_moment_local');
qlabel = require('lib/qlabel/qlabel');
module.exports = {
initialize: function(app) {
var missingKey;
app.reqres.setHandlers({
'i18n:set': function() {
return _.preq.start.then(setLanguage);
},
'i18n:current': function() {
return app.user.lang;
}
});
if (window.env === 'dev') {
missingKey = require('./i18n_missing_key');
} else {
missingKey = _.noop;
}
app.commands.setHandlers({
'i18n:missing:key': missingKey,
'qlabel:update': updateQlabel,
'qlabel:refresh': qlabel.refreshData
});
return app.vent.on('i18n:set', updateQlabel);
}
};
setLanguage = function() {
var changeNeeded, lang, polyglot;
lang = app.user.lang;
polyglot = app.polyglot || (app.polyglot = new Polyglot);
app.vent.trigger('i18n:set', lang);
changeNeeded = _.isEmpty(polyglot.phrases) || (lang !== polyglot.currentLocale);
if (!changeNeeded) {
return;
}
if (lang !== polyglot.changingTo) {
return requestI18nFile(polyglot, lang);
} else {
return _.warn('i18n: language changing, can not be re-set yet');
}
};
requestI18nFile = function(polyglot, lang) {
polyglot.changingTo = lang;
fetchMomentLocale(lang);
return _.preq.get(app.API.i18n(lang)).then(updatePolyglot.bind(null, polyglot, lang))["catch"](_.Error("i18n: failed to get the i18n file for " + lang))["finally"](doneChanging.bind(null, polyglot));
};
updatePolyglot = function(polyglot, lang, res) {
polyglot.replace(res);
polyglot.locale(lang);
return app.vent.trigger('i18n:reset');
};
doneChanging = function(polyglot) {
return polyglot.changingTo = null;
};
updateQlabel = function() {
var lang;
lang = app.user.lang;
return qlabel.update(lang);
};
});
;require.register("lib/i18n_missing_key", function(exports, require, module) {
var lazyMissingKey, missingKeys, sendMissingKeys;
missingKeys = [];
module.exports = function(key) {
if (key != null) {
missingKeys.push(key);
return lazyMissingKey();
}
};
sendMissingKeys = function() {
if ((missingKeys != null ? missingKeys.length : void 0) > 0) {
return _.preq.post('/log/i18n', {
missingKeys: _.uniq(missingKeys)
}).then(function(res) {
_.log(missingKeys, 'i18n:missing added');
return missingKeys = [];
})["catch"](_.Error('i18n:missing keys failed to be added'));
}
};
lazyMissingKey = _.debounce(sendMissingKeys, 500);
});
;require.register("lib/images", function(exports, require, module) {
var error_, getResizedDimensions, handlers, saveDimensions;
error_ = require('lib/error');
handlers = {
addDataUrlToArray: function(file, array, event) {
return resize.photo(file, 600, 'dataURL', function(data) {
array.unshift(data);
if ((array.trigger != null) && (event != null)) {
return array.trigger(event);
}
});
},
getFileDataUrl: function(file) {
var reader;
reader = new FileReader();
return new Promise(function(resolve, reject) {
reader.onerror = reject;
reader.onload = function(readerEvent) {
return resolve(readerEvent.target.result);
};
return reader.readAsDataURL(file);
});
},
getUrlDataUrl: function(url) {
if (/^http/.test(url)) {
url = app.API.proxy(url);
}
return new Promise(function(resolve, reject) {
return window.toDataURL(url, {
callback: function(err, res) {
if (err != null) {
return reject(err);
} else {
return resolve(res);
}
}
});
});
},
getElementDataUrl: function($el) {
return $el.toDataURL();
},
resizeDataUrl: function(dataURL, maxSize, outputQuality) {
if (outputQuality == null) {
outputQuality = 1;
}
return new Promise(function(resolve, reject) {
var data, image;
data = {
original: {},
resized: {}
};
image = new Image();
image.onload = function(imageEvent) {
var canvas, height, ref, width;
canvas = document.createElement('canvas');
width = image.width, height = image.height;
saveDimensions(data, 'original', width, height);
ref = getResizedDimensions(width, height, maxSize), width = ref[0], height = ref[1];
saveDimensions(data, 'resized', width, height);
canvas.width = width;
canvas.height = height;
canvas.getContext('2d').drawImage(image, 0, 0, width, height);
data.dataUrl = canvas.toDataURL('image/jpeg', outputQuality);
return resolve(data);
};
image.onerror = reject;
return image.src = dataURL;
});
},
canvasToBlob: function(canvas) {
if (_.isCanvas(canvas)) {
return canvas.toBlob();
} else {
throw new Error('expected a canvas');
}
},
dataUrlToBlob: function(data) {
if (_.isDataUrl(data)) {
return window.dataURLtoBlob(data);
} else {
throw new Error('expected a dataURL');
}
},
upload: function(blobsData) {
var blob, blobData, formData, i, id, j, len;
blobsData = _.forceArray(blobsData);
formData = new FormData();
i = 0;
for (j = 0, len = blobsData.length; j < len; j++) {
blobData = blobsData[j];
blob = blobData.blob, id = blobData.id;
id || (id = "file-" + (++i));
formData.append(id, blob);
}
return new Promise(function(resolve, reject) {
var request;
request = new XMLHttpRequest();
request.onreadystatechange = function() {
var status, statusText;
if (request.readyState === 4) {
status = request.status, statusText = request.statusText;
if (/^2/.test(request.status.toString())) {
return resolve(request.response);
} else {
return reject(error_["new"](statusText, status));
}
}
};
request.onerror = reject;
request.ontimeout = reject;
request.open('POST', app.API.upload.post);
request.responseType = 'json';
return request.send(formData);
});
},
del: function(imageUrlToDelete) {
_.inspect(imageUrlToDelete, 'imageUrlToDelete');
return _.preq.post(app.API.upload.del, {
urls: imageUrlToDelete
}).then(_.Log('image del res'))["catch"](_.Error('image del err'));
},
getNonResizedUrl: function(url) {
return url.replace(/\/img\/\d+x\d+\//, '/img/');
}
};
getResizedDimensions = function(width, height, maxSize) {
if (width > height) {
if (width > maxSize) {
height *= maxSize / width;
width = maxSize;
}
} else {
if (height > maxSize) {
width *= maxSize / height;
height = maxSize;
}
}
return [width, height];
};
saveDimensions = function(data, attribute, width, height) {
data[attribute].width = width;
return data[attribute].height = height;
};
module.exports = handlers;
});
;require.register("lib/jquery-jk", function(exports, require, module) {
module.exports.initialize = function($) {
var attempt, focusOn, focused, nextKey, prevKey, selectKey, selectOn, selected;
focused = function() {
return this.find('.focus');
};
focusOn = function(dir) {
var focusedNew, focusedOld;
if (!this.focused().length) {
return this.find('*:first').addClass('focus');
}
focusedOld = this.focused();
focusedNew = focusedOld[dir]();
if (focusedNew.size()) {
focusedOld.trigger('focus:lost').removeClass('focus');
return focusedNew.trigger('focus:added').addClass('focus');
} else {
return this.trigger('paginate:' + dir);
}
};
selected = function() {
return this.find('.selected');
};
selectOn = function() {
focused = this.focused();
if (focused.toggleClass('selected').hasClass('selected')) {
return focused.trigger('selection:added');
} else {
return focused.trigger('selection:lost');
}
};
nextKey = function() {
return $.jk.NEXT.charCodeAt();
};
prevKey = function() {
return $.jk.PREV.charCodeAt();
};
selectKey = function() {
return $.jk.SELECT.charCodeAt();
};
attempt = function(event) {
if (!event.which) {
return;
}
if ($(event.target).is(':input')) {
return;
}
if (event.which === nextKey()) {
$.jk.focusNext();
$.jk.scrollToFocused();
}
if (event.which === prevKey()) {
$.jk.focusPrev();
$.jk.scrollToFocused();
}
if (event.which === selectKey()) {
return $.jk.select();
}
};
$.jk = {
PREV: 'k',
NEXT: 'j',
SELECT: 'x',
focusNext: function() {
return $('.jk').focusOn('next');
},
focusPrev: function() {
return $('.jk').focusOn('prev');
},
select: function() {
return $('.jk').selectOn();
},
scrollToFocused: function() {
var $focus, targetedHeight;
$focus = $('.focus');
if ($focus.length > 0) {
targetedHeight = $focus.offset().top - 50;
return $('html, body').animate({
scrollTop: targetedHeight
}, 100);
}
}
};
$.fn.focused = focused;
$.fn.focusOn = focusOn;
$.fn.selected = selected;
$.fn.selectOn = selectOn;
return $(document).ready(function() {
return $(document).bind('keypress', attempt);
});
};
});
;require.register("lib/loggers", function(exports, require, module) {
var slice = [].slice;
module.exports = function(_, csle) {
var error, log, loggers, partialLoggers, proxied, spy, warn;
csle || (csle = window.console);
log = function(obj, label, stack) {
var ref;
if (_.isString(obj)) {
if (label != null) {
obj.logIt(label);
} else {
csle.log(obj);
}
} else {
if (label != null) {
csle.log("===== " + label + " =====");
}
csle.log(obj);
if (label != null) {
csle.log("-----");
}
}
if (stack) {
csle.log(label + " stack", (ref = new Error('fake error').stack) != null ? ref.split("\n") : void 0);
}
return obj;
};
error = function(err, label) {
var newErr, ref, ref1, report;
if ((err != null ? err.status : void 0) != null) {
if ((err != null ? err.responseText : void 0) != null) {
label = err.responseText + " (" + label + ")";
}
switch (err.status) {
case 401:
return csle.warn('401', label);
case 404:
return csle.warn('404', label);
}
}
if ((err != null ? err.stack : void 0) == null) {
label || (label = 'empty error');
newErr = new Error(label);
report = [err, newErr.message, (ref = newErr.stack) != null ? ref.split('\n') : void 0];
} else {
report = [err.message || err, (ref1 = err.stack) != null ? ref1.split('\n') : void 0];
}
if ((err != null ? err.context : void 0) != null) {
report.push(err.context);
}
window.reportErr({
error: report
});
return csle.error.apply(csle, report);
};
warn = function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
csle.warn('/!\\');
loggers.log.apply(null, args);
};
spy = function(res, label) {
console.log(label);
return res;
};
partialLoggers = {
Log: function(label) {
return _.partial(log, _, label);
},
Error: function(label) {
return _.partial(error, _, label);
},
Warn: function(label) {
return _.partial(warn, _, label);
},
Spy: function(label) {
return _.partial(spy, _, label);
},
ErrorRethrow: function(label) {
var fn;
return fn = function(err) {
error(err, label);
throw err;
};
}
};
loggers = {
log: log,
error: error,
warn: warn,
spy: spy,
logAllEvents: function(obj, prefix) {
if (prefix == null) {
prefix = 'logAllEvents';
}
return obj.on('all', function(event) {
csle.log("[" + prefix + ":" + event + "]");
csle.log(arguments);
return csle.log('---');
});
},
logArgs: function(args) {
csle.log("[arguments]");
csle.log(args);
return csle.log('---');
},
logServer: function(obj, label) {
var report;
report = {
obj: obj,
label: label
};
$.post(app.API.test, report);
return obj;
}
};
String.prototype.logIt = function(label) {
csle.log("[" + label + "] " + (this.toString()));
return this.toString();
};
proxied = {
trace: csle.trace.bind(csle),
time: csle.time.bind(csle),
timeEnd: csle.timeEnd.bind(csle)
};
return _.extend(loggers, partialLoggers, proxied);
};
});
;require.register("lib/mobile_check", function(exports, require, module) {
var mobileChecker, test;
test = function(agent) {
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge|maemo|midp|mmp|mobile.+firefox|netfront|operam(ob|in)i|palm(os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windowsce|xda|xiino|android|ipad|playbook|silk/i.test(agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|awa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r|s)|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp(i|ip)|hs\-c|ht(c(\-||_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac(|\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt(|\/)|klon|kpt|kwc\-|kyo(c|k)|le(no|xi)|lg(g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-||o|v)|zz)|mt(50|p1|v)|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v)|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-|)|webc|whit|wi(g|nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(agent.substr(0, 4));
};
mobileChecker = function() {
var agent;
agent = navigator.userAgent || navigator.vendor || window.opera;
if (test(agent)) {
return true;
} else {
return false;
}
};
module.exports = mobileChecker();
});
;require.register("lib/model_update", function(exports, require, module) {
var Updater, error_, rollbackUpdate;
error_ = require('lib/error');
Updater = function(fixedOptions) {
var action, endpoint, modelIdLabel, uniqueModel, updater;
endpoint = fixedOptions.endpoint, action = fixedOptions.action, uniqueModel = fixedOptions.uniqueModel, modelIdLabel = fixedOptions.modelIdLabel;
return updater = function(options) {
var attribute, body, bothInexistant, defaultPreviousValue, model, previousValue, promise, selector, value;
model = options.model, attribute = options.attribute, value = options.value, defaultPreviousValue = options.defaultPreviousValue, selector = options.selector;
model || (model = uniqueModel);
previousValue = model.get(attribute);
if (previousValue == null) {
previousValue = defaultPreviousValue;
}
bothInexistant = (value == null) && (previousValue == null);
if (bothInexistant || _.isEqual(value, previousValue)) {
_.log(options, 'the model is already up-to-date');
promise = _.preq.resolved;
} else {
model.set(attribute, value);
options.previousValue = previousValue;
options.model = model;
body = {
attribute: attribute,
value: value
};
if (action != null) {
body.action = action;
}
if (modelIdLabel != null) {
body[modelIdLabel] = model.id;
}
promise = _.preq.put(endpoint, body)["catch"](rollbackUpdate.bind(null, options));
}
if (selector != null) {
app.request('waitForCheck', {
promise: promise,
selector: selector
});
}
return promise;
};
};
rollbackUpdate = function(options, err) {
var attribute, model, previousValue, selector;
model = options.model, attribute = options.attribute, previousValue = options.previousValue, selector = options.selector;
if (previousValue != null) {
_.warn(previousValue, "reversing " + attribute + " update");
model.set(attribute, previousValue);
} else {
_.warn(previousValue, "couldn't reverse update: previousValue not found");
}
err = selector != null ? error_.complete(selector, err) : err;
throw err;
};
module.exports = {
Updater: Updater
};
});
;require.register("lib/noop_console", function(exports, require, module) {
var noop;
noop = function() {};
module.exports = {
log: noop,
warn: noop,
error: noop,
info: noop,
trace: noop,
time: noop,
timeEnd: noop
};
});
;require.register("lib/piwik", function(exports, require, module) {
var _paq, env, trackerUrl,
slice = [].slice;
window._paq || (window._paq = []);
_paq = window._paq, env = window.env;
trackerUrl = require('lib/urls').tracker;
module.exports = function() {
var friend, group, invitation, item, login, setUserId, signup, trackEvent, trackPageView, tracker, transaction;
if (env === 'dev') {
trackerUrl = app.API.test;
}
_paq.push(['enableLinkTracking']);
_paq.push(['setTrackerUrl', trackerUrl]);
_paq.push(['setSiteId', 11]);
tracker = Piwik.getAsyncTracker();
setUserId = function(id) {
if (_.isUserId(id)) {
return _paq.push(['setUserId', id]);
}
};
trackPageView = function(title) {
tracker.setCustomUrl(location.href);
return _paq.push(['trackPageView', title]);
};
trackEvent = function() {
var args, ev;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
args = _.compact(args);
ev = ['trackEvent'].concat(args);
return _paq.push(ev);
};
signup = function(type) {
return trackEvent('auth', 'signup', type);
};
login = function(type) {
return trackEvent('auth', 'login', type);
};
transaction = function(action, userStatus) {
return trackEvent('transaction', "transaction:" + action, userStatus);
};
friend = function(action) {
return trackEvent('friend', "friend:" + action);
};
invitation = function(action, count) {
return trackEvent('invitation', "invitation:" + action, 'count', count);
};
group = function(action) {
return trackEvent('group', "group:" + action);
};
item = function(action, listing, transaction) {
return trackEvent('item', "item:" + action, listing, transaction);
};
return app.commands.setHandlers({
'track:user:id': setUserId,
'track:page:view': _.debounce(trackPageView, 300),
'track:auth:signup': signup,
'track:auth:login': login,
'track:transaction': transaction,
'track:friend': friend,
'track:invitation': invitation,
'track:group': group,
'track:item': item
});
};
});
;require.register("lib/poster", function(exports, require, module) {
module.exports = {
UpdateModelIdRev: function(model) {
var updater;
return updater = function(res) {
var _id, _rev, id, rev;
_id = res._id, _rev = res._rev, id = res.id, rev = res.rev;
id || (id = _id);
rev || (rev = _rev);
return model.set({
_id: id,
_rev: rev
});
};
},
Rewind: function(model, collection) {
var rewinder;
return rewinder = function(err) {
collection.remove(model);
throw err;
};
}
};
});
;require.register("lib/preq", function(exports, require, module) {
var preq, proxiedUrl, rewriteError, wrap;
Promise.prototype.fail = Promise.prototype.caught;
Promise.prototype.always = Promise.prototype["finally"];
Promise.onPossiblyUnhandledRejection(function(err) {
var clue, label, ref, report, stack;
label = "[PossiblyUnhandledError] " + err.name + ": " + err.message + " (" + (typeof err.message) + ")";
stack = err != null ? (ref = err.stack) != null ? ref.split('\n') : void 0 : void 0;
report = {
label: label,
error: err,
stack: stack
};
if (err.message === "[object Object]") {
report.clue = clue = "this is probably an error from a jQuery promise wrapped into a Bluebird one";
}
window.reportErr(report);
return console.error(label, stack, clue);
});
preq = sharedLib('promises')(Promise);
module.exports = _.extend(preq, {
get: function(url, options) {
if (proxiedUrl(url)) {
url = app.API.proxy(url);
}
return wrap($.get(url), url);
},
post: function(url, body) {
return wrap($.post(url, body), url);
},
put: function(url, body) {
return wrap($.put(url, body), url);
},
"delete": function(url) {
return wrap($["delete"](url), url);
},
getScript: function(url) {
return wrap($.getScript(url), url);
},
catch401: function(err) {
if (err.status === 401) {
}
},
catch404: function(err) {
if (err.status === 404) {
}
},
Sleep: function(ms) {
var fn;
return fn = function(res) {
return new Promise(function(resolve, reject) {
var cb;
cb = function() {
return resolve(res);
};
return setTimeout(cb, ms);
});
};
},
fallbackChain: function(getters) {
var first, next, p;
_.types(getters, 'functions...');
first = true;
p = preq.resolved;
while (getters.length > 0) {
next = getters.shift();
if (first) {
p = p.then(next);
first = false;
} else {
p = p["catch"](next);
}
}
return p;
}
});
proxiedUrl = function(url) {
return /wikidata\.org/.test(url);
};
preq.wrap = wrap = function(jqPromise, url) {
return new Promise(function(resolve, reject) {
return jqPromise.then(resolve).fail(function(err) {
return reject(rewriteError(err, url));
});
});
};
rewriteError = function(err, url) {
var error, responseJSON, responseText, status, statusText;
status = err.status, statusText = err.statusText, responseText = err.responseText, responseJSON = err.responseJSON;
error = new Error(status + ": " + statusText + " - " + responseText + " - " + url);
return _.extend(error, {
status: status,
statusText: statusText,
responseText: responseText,
responseJSON: responseJSON
});
};
});
;require.register("lib/qlabel/labels_helpers", function(exports, require, module) {
var labels;
labels = {};
module.exports = {
getLabel: function(qid, lang) {
var data;
data = labels[qid];
if (data != null) {
return data[lang] || data.en || data.original || _.pickOne(data);
}
},
setLabel: function(qid, lang, label) {
labels[qid] || (labels[qid] = {});
labels[qid][lang] = label;
return label;
},
getKnownQids: function() {
return Object.keys(labels);
},
resetLabels: function() {
return labels = {};
}
};
});
;require.register("lib/qlabel/qlabel", function(exports, require, module) {
var attribute, className, display, elements, endRefreshMode, gatherRequiredQids, getElements, getKnownQids, getLabel, getMissingEntities, getQid, getWikidataEntities, language, ref, refresh, refreshData, resetLabels, selector, setEntityOriginalLang, setLabel, update, wd_;
className = 'qlabel';
selector = "." + className;
attribute = 'data-qid';
wd_ = require('lib/wikidata');
ref = require('./labels_helpers'), getLabel = ref.getLabel, setLabel = ref.setLabel, getKnownQids = ref.getKnownQids, resetLabels = ref.resetLabels;
language = null;
elements = null;
refresh = false;
getQid = function(el) {
return el.getAttribute(attribute);
};
getElements = function() {
return document.querySelectorAll(selector);
};
gatherRequiredQids = function() {
return [].map.call(getElements(), getQid);
};
display = function() {
var el, i, label, len, qid, ref1;
ref1 = getElements();
for (i = 0, len = ref1.length; i < len; i++) {
el = ref1[i];
qid = getQid(el);
if (qid != null) {
label = getLabel(qid, language);
if (label != null) {
el.textContent = label;
el.className = el.className.replace(className, '');
}
}
}
};
getWikidataEntities = function(qids) {
return Entities.data.wd.local.get(qids, null, refresh).then(function(entities) {
var claims, entity, id, label, labels, lang;
for (id in entities) {
entity = entities[id];
labels = entity.labels, claims = entity.claims;
setEntityOriginalLang(id, claims, labels);
for (lang in labels) {
label = labels[lang];
setLabel(id, lang, label.value);
}
}
});
};
setEntityOriginalLang = function(id, claims, labels) {
var originalLang, originalValue, ref1;
originalLang = wd_.getOriginalLang(claims, true);
originalValue = (ref1 = labels[originalLang]) != null ? ref1.value : void 0;
if (originalValue != null) {
setLabel(id, 'original', originalValue);
}
};
getMissingEntities = function(qids) {
var missingQids;
missingQids = _.without(qids, getKnownQids());
if (missingQids.length > 0) {
return getWikidataEntities(qids);
} else {
return _.preq.resolved;
}
};
update = function(lang) {
var qids;
language = lang;
qids = gatherRequiredQids();
if (qids.length === 0) {
return;
}
getMissingEntities(qids).then(display)["catch"](_.Error('qlabel err'));
return null;
};
refreshData = function() {
refresh = true;
resetLabels();
return setTimeout(endRefreshMode, 5000);
};
endRefreshMode = function() {
return refresh = false;
};
module.exports = {
update: _.debounce(update, 200),
refreshData: refreshData
};
wd_.getLabel = function(qids, lang) {
return getWikidataEntities(qids).then(function() {
return _.forceArray(qids).map(function(qid) {
return getLabel(qid, lang);
}).join(', ');
});
};
});
;require.register("lib/querystring_helpers", function(exports, require, module) {
var allowPersistantQuery;
allowPersistantQuery = require('./allow_persistant_query');
module.exports = function(app, _) {
var get, getPathname, getQuery, keep, set;
get = function(key) {
var ref;
return (ref = getQuery()) != null ? ref[key] : void 0;
};
set = function(key, value) {
var fullPath, pathname, query;
pathname = getPathname();
query = getQuery();
query[key] = value;
fullPath = _.buildPath(pathname, query);
return app.navigateReplace(fullPath);
};
keep = function(newRoute) {
var currentQuery, k, keptQuery, newQuery, newRouteSection, ref, test, v;
ref = newRoute.split('?'), newRoute = ref[0], newQuery = ref[1];
newQuery = _.parseQuery(newQuery);
currentQuery = getQuery();
keptQuery = {};
newRouteSection = _.routeSection(newRoute);
for (k in currentQuery) {
v = currentQuery[k];
test = allowPersistantQuery[k];
if (typeof test === "function" ? test(newRouteSection) : void 0) {
keptQuery[k] = v;
}
}
newQuery = _.extend(keptQuery, newQuery);
return _.buildPath(newRoute, newQuery);
};
getPathname = function() {
return window.location.pathname.slice(1);
};
getQuery = function() {
return _.parseQuery(window.location.search.slice(1));
};
app.reqres.setHandlers({
'route:querystring:get': get,
'route:querystring:keep': keep
});
return app.commands.setHandlers({
'route:querystring:set': set
});
};
});
;require.register("lib/scanner", function(exports, require, module) {
module.exports = {
url: (function() {
var callback, encodedCallback, url;
callback = _.buildPath(window.location.root + "/entity/isbn:{CODE}/add", {
SCAN_FORMATS: 'UPC_A,EAN_13',
raw: '{RAWCODE}'
});
encodedCallback = encodeURIComponent(callback);
url = _.buildPath("zxing://scan/", {
ret: encodedCallback
});
return url;
})()
};
});
;require.register("lib/shared/api/img", function(exports, require, module) {
module.exports = function(_, root) {
var img;
if (root == null) {
root = '';
}
return img = function(path, width, height) {
var href, key;
if (width == null) {
width = 1600;
}
if (height == null) {
height = 1600;
}
if (!_.isNonEmptyString(path)) {
return;
}
if (/^http/.test(path)) {
key = _.hashCode(path);
href = encodeURIComponent(path);
return root + "/img/" + width + "x" + height + "/" + key + "?href=" + href;
} else {
path = path.replace('/img/', '');
return root + "/img/" + width + "x" + height + "/" + path;
}
};
};
});
;require.register("lib/shared/books", function(exports, require, module) {
module.exports = function(_) {
var methods;
return methods = {
isIsbn: function(text) {
var cleanedText;
cleanedText = this.normalizeIsbn(text);
if (this.isNormalizedIsbn(cleanedText)) {
switch (cleanedText.length) {
case 10:
return 10;
case 13:
return 13;
}
}
return false;
},
normalizeIsbn: function(text) {
return text.trim().replace(/-/g, '').replace(/\s/g, '');
},
isNormalizedIsbn: function(text) {
return /^(97(8|9))?\d{9}(\d|X)$/.test(text);
},
uncurl: function(url) {
return url.replace('&edge=curl', '');
},
zoom: function(url) {
return url.replace('&zoom=1', '&zoom=2');
}
};
};
});
;require.register("lib/shared/global_libs_extender", function(exports, require, module) {
module.exports = function() {
var add;
Array.prototype.first = function() {
return this[0];
};
Array.prototype.last = function() {
return this.slice(-1)[0];
};
Array.prototype.clone = function() {
return this.slice(0);
};
add = function(a, b) {
return a + b;
};
Array.prototype.sum = function() {
return this.reduce(add, 0);
};
};
});
;require.register("lib/shared/handlebars_helpers", function(exports, require, module) {
module.exports = function(_, appApi) {
var getImgDimension, helpers_, onePictureOnly;
onePictureOnly = function(arg) {
if (_.isArray(arg)) {
return arg[0];
} else {
return arg;
}
};
getImgDimension = function(dimension, defaultValue) {
if (_.isNumber(dimension)) {
return dimension;
} else {
return defaultValue;
}
};
return helpers_ = {
src: function(path, width, height, extend) {
if (_.isDataUrl(path)) {
return path;
}
width = getImgDimension(width, 1600);
width = _.bestImageWidth(width);
height = getImgDimension(height, width);
path = onePictureOnly(path);
if (path == null) {
return '';
}
return appApi.img(path, width, height);
}
};
};
});
;require.register("lib/shared/notifications_settings_list", function(exports, require, module) {
module.exports = ['global', 'inventories_activity_summary', 'friend_accepted_request', 'friendship_request', 'group_invite', 'group_acceptRequest', 'your_item_was_requested', 'update_on_your_item', 'update_on_item_you_requested'];
});
;require.register("lib/shared/promises", function(exports, require, module) {
var resolved;
resolved = Object.freeze(Promise.resolve());
module.exports = function(Promise) {
return {
resolve: Promise.resolve.bind(Promise),
reject: Promise.reject.bind(Promise),
resolved: resolved,
start: resolved
};
};
});
;require.register("lib/shared/regex", function(exports, require, module) {
module.exports = {
Email: /.+@.+\..+/i,
Uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,
CouchUuid: /^[0-9a-f]{32}$/,
Lang: /^\w{2}$/,
LocalImg: /^\/img\/[0-9a-f]{40}.jpg$/,
Username: /^\w{1,20}$/,
EntityUri: /^(wd:Q[0-9]+|(isbn|inv):[\w\-]+)$/
};
});
;require.register("lib/shared/shared_libs", function(exports, require, module) {
var sharedPath;
sharedPath = 'lib/shared/';
module.exports = function(name) {
return require("" + sharedPath + name);
};
});
;require.register("lib/shared/tests", function(exports, require, module) {
module.exports = function(regex_) {
return {
isLocalImg: function(url) {
return regex_.LocalImg.test(url);
}
};
};
});
;require.register("lib/shared/transaction_side_effects", function(exports, require, module) {
module.exports = function(actions, _) {
var changeOwnerIfOneWay, setItemBusyness, setItemToBusy, setItemToNotBusy, sideEffets;
setItemBusyness = actions.setItemBusyness, changeOwnerIfOneWay = actions.changeOwnerIfOneWay;
setItemToBusy = _.partial(setItemBusyness, true);
setItemToNotBusy = _.partial(setItemBusyness, false);
return sideEffets = {
accepted: setItemToBusy,
declined: _.noop,
confirmed: changeOwnerIfOneWay,
returned: setItemToNotBusy,
cancelled: setItemToNotBusy
};
};
});
;require.register("lib/shared/transactions", function(exports, require, module) {
module.exports = function(_) {
var basicNextActions, findNextActions, getNextActionsList, isActive, isArchived, nextActionsWithReturn;
basicNextActions = {
requested: {
owner: 'accept/decline',
requester: 'waiting:accepted'
},
accepted: {
owner: 'waiting:confirmed',
requester: 'confirm'
},
declined: {
owner: null,
requester: null
},
confirmed: {
owner: null,
requester: null
}
};
nextActionsWithReturn = _.extend({}, basicNextActions, {
confirmed: {
owner: 'returned',
requester: 'waiting:returned'
},
returned: {
owner: null,
requester: null
}
});
getNextActionsList = function(transactionName) {
if (transactionName === 'lending') {
return nextActionsWithReturn;
} else {
return basicNextActions;
}
};
findNextActions = function(transacData) {
var mainUserIsOwner, name, nextActions, role, state;
name = transacData.name, state = transacData.state, mainUserIsOwner = transacData.mainUserIsOwner;
nextActions = getNextActionsList(name, state);
role = mainUserIsOwner ? 'owner' : 'requester';
return nextActions[state][role];
};
isActive = function(transacData) {
return findNextActions(transacData) != null;
};
isArchived = function(transacData) {
return !isActive(transacData);
};
return module.exports = {
findNextActions: findNextActions,
isActive: isActive,
isArchived: isArchived
};
};
});
;require.register("lib/shared/utils", function(exports, require, module) {
var slice = [].slice;
module.exports = {
Full: function() {
var args, context, fn, fullFn;
fn = arguments[0], context = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
return fullFn = function() {
return fn.apply(context, args);
};
}
};
});
;require.register("lib/shared/wiki_sitelinks", function(exports, require, module) {
var getBestWikiProjectInfo, getEpubLink, getWikiProjectTitle, pickOneWikiProjectTitle;
module.exports = {
wikipedia: function(sitelinks, lang) {
return getBestWikiProjectInfo(sitelinks, 'wiki', 'wikipedia', lang, this.originalLang);
},
wikisource: function(sitelinks, lang) {
var wsData;
wsData = getBestWikiProjectInfo(sitelinks, 'wikisource', 'wikisource', lang, this.originalLang);
if (wsData != null) {
wsData.epub = getEpubLink(wsData);
return wsData;
}
}
};
getBestWikiProjectInfo = function(sitelinks, projectBaseName, projectRoot, lang, originalLang) {
var L, getTitleForLang, ref, ref1, ref2, ref3, title, url;
getTitleForLang = function(Lang) {
return getWikiProjectTitle(sitelinks, projectBaseName, Lang);
};
ref = [getTitleForLang(lang), lang], title = ref[0], L = ref[1];
if ((originalLang != null) && (title == null)) {
ref1 = [getTitleForLang(originalLang), originalLang], title = ref1[0], L = ref1[1];
}
if (title == null) {
ref2 = [getTitleForLang('en'), 'en'], title = ref2[0], L = ref2[1];
}
if (title == null) {
ref3 = pickOneWikiProjectTitle(sitelinks, projectBaseName), title = ref3[0], L = ref3[1];
}
if ((title != null) && L) {
title = encodeURIComponent(title);
url = "https://" + L + "." + projectRoot + ".org/wiki/" + title;
return {
title: title,
lang: L,
url: url
};
}
};
getWikiProjectTitle = function(sitelinks, projectBaseName, lang) {
var link;
link = sitelinks != null ? sitelinks["" + lang + projectBaseName] : void 0;
if ((link != null ? link.title : void 0) != null) {
return link.title;
}
};
pickOneWikiProjectTitle = function(sitelinks, projectBaseName) {
var L, k, match, v;
for (k in sitelinks) {
v = sitelinks[k];
match = k.split(projectBaseName);
if (match.length === 2) {
L = match[0];
return [v.title, L];
}
}
return [];
};
getEpubLink = function(wikisourceData) {
var lang, title;
title = wikisourceData.title, lang = wikisourceData.lang;
return "http://wsexport.wmflabs.org/tool/book.php?lang=" + lang + "&format=epub&page=" + title;
};
});
;require.register("lib/shared/wikidata", function(exports, require, module) {
var Q;
Q = require('./wikidata_aliases').Q;
module.exports = function(promises_, _, wdk) {
var API, helpers;
API = require('./wikidata_api')(_);
return helpers = {
API: API,
getEntities: function(ids, languages, props) {
var url;
url = wdk.getEntities(ids, languages, props);
return promises_.get(url);
},
getUri: function(id) {
return 'wd:' + wdk.normalizeId(id);
},
isBook: function(P31Array) {
return _.haveAMatch(Q.books, P31Array);
},
isArticle: function(P31Array) {
return _.haveAMatch(Q.articles, P31Array);
},
entityIsBook: function(entity) {
return helpers.isBook(entity.claims.P31);
},
entityIsArticle: function(entity) {
return helpers.isArticle(entity.claims.P31);
},
isAuthor: function(P106Array) {
return _.haveAMatch(Q.authors, P106Array);
},
isHuman: function(P31Array) {
return _.haveAMatch(Q.humans, P31Array);
},
isGenre: function(P31Array) {
return _.haveAMatch(Q.genres, P31Array);
},
type: function(entity) {
var P31, ref, ref1;
if (_.isModel(entity)) {
P31 = typeof entity.get === "function" ? (ref = entity.get('claims')) != null ? ref.P31 : void 0 : void 0;
} else {
P31 = (ref1 = entity.claims) != null ? ref1.P31 : void 0;
}
if (P31 != null) {
if (this.isBook(P31)) {
return 'book';
}
if (this.isArticle(P31)) {
return 'article';
}
if (this.isHuman(P31)) {
return 'human';
}
if (this.isGenre(P31)) {
return 'genre';
}
}
},
wmCommonsSmallThumb: function(file, width) {
if (width == null) {
width = "100";
}
return "https://commons.wikimedia.org/w/thumb.php?width=" + width + "&f=" + file;
}
};
};
});
;require.register("lib/shared/wikidata_aliases", function(exports, require, module) {
var P, Q, aliasedP, aliasedPs, aliases, i, len, mainP;
Q = {
books: ['Q571', 'Q2831984', 'Q1004', 'Q1760610', 'Q14406742', 'Q8261', 'Q25379', 'Q7725634', 'Q17518870', 'Q5185279', 'Q2150386', 'Q37484', 'Q386724', 'Q49084', 'Q34620', 'Q8274'],
edition: ['Q3972943', 'Q17902573'],
articles: ['Q191067', 'Q13442814'],
humans: ['Q5', 'Q10648343', 'Q14073567'],
authors: ['Q36180'],
genres: ['Q483394', 'Q223393']
};
P = {
P50: ['P58']
};
aliases = {};
for (mainP in P) {
aliasedPs = P[mainP];
for (i = 0, len = aliasedPs.length; i < len; i++) {
aliasedP = aliasedPs[i];
aliases[aliasedP] = mainP;
}
}
Q.softAuthors = Q.authors.concat(Q.humans);
module.exports = {
aliases: aliases,
Q: Q,
P: P
};
});
;require.register("lib/shared/wikidata_api", function(exports, require, module) {
module.exports = function(_) {
var API;
return API = {
wikidata: {
base: 'https://www.wikidata.org/w/api.php',
search: function(search, limit, format) {
if (limit == null) {
limit = '25';
}
if (format == null) {
format = 'json';
}
return _.buildPath(API.wikidata.base, {
action: 'query',
list: 'search',
srlimit: limit,
format: format,
srsearch: search
});
}
}
};
};
});
;require.register("lib/translate", function(exports, require, module) {
var hasModifiers, isShortkey, modifiers, vowels,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
module.exports = function(key, ctx) {
var lang, val;
lang = app.polyglot.currentLocale;
val = app.polyglot.t(key, ctx);
if (indexOf.call(hasModifiers, lang) >= 0) {
return modifiers[lang](key, val, ctx);
} else {
return val;
}
};
modifiers = {
fr: function(key, val, data) {
var firstLetter, k, re, username;
if ((data != null) && isShortkey(key)) {
k = app.polyglot.phrases[key];
username = data.username;
if (username != null) {
firstLetter = username[0].toLowerCase();
if (indexOf.call(vowels, firstLetter) >= 0) {
if (/de\s(<strong>)?%{username}/.test(k)) {
re = new RegExp("de (<strong>)?" + username);
return val.replace(re, "d'$1" + username);
}
}
}
}
return val;
}
};
hasModifiers = Object.keys(modifiers);
isShortkey = function(key) {
return /_/.test(key);
};
vowels = 'aeiouy';
});
;require.register("lib/unhandled_error_logger", function(exports, require, module) {
var getContext, parseErrorObject;
module.exports.initialize = function() {
return window.onerror = function() {
var args, err, name;
args = [].slice.call(arguments, 0);
if ((args != null ? args[4] : void 0) != null) {
name = args[4].name;
if (name === 'InvalidStateError') {
return console.warn('InvalidStateError: no worries, already handled');
}
if (name === 'ViewDestroyedError') {
return console.warn('ViewDestroyedError: not reported');
}
}
err = parseErrorObject.apply(null, args);
if (window.navigator.webkitGetGamepads == null) {
console.error.apply(console, err, '(handled by window.onerror)');
}
return window.reportErr(err);
};
};
parseErrorObject = function(errorMsg, url, lineNumber, columnNumber, errObj) {
var context, report, stack;
if (errObj) {
stack = errObj.stack, context = errObj.context;
stack = stack != null ? stack.split('\n') : void 0;
report = [errorMsg + " " + url + " " + lineNumber + ":" + columnNumber, stack];
if (context != null) {
report.push(context);
}
return report;
} else {
return [errorMsg, url, lineNumber, columnNumber];
}
};
window.reportErr = function(report) {
var err, ref;
if ((report != null ? report.error : void 0) == null) {
err = report;
report = {
error: err
};
}
report.context = getContext();
if ((typeof app !== "undefined" && app !== null ? (ref = app.session) != null ? ref.recordError : void 0 : void 0) != null) {
return app.session.recordError(report);
} else {
return $.post('/api/logs/public', report);
}
};
getContext = function() {
var context, id, ref, userData, username;
context = [];
if (typeof app !== "undefined" && app !== null ? (ref = app.user) != null ? ref.loggedIn : void 0 : void 0) {
id = app.user.id;
username = app.user.get('username');
if ((id != null) && (username != null)) {
userData = "user: " + id + " (" + username + ")";
} else {
userData = "user logged in but error happened before data arrived";
}
} else {
userData = "user: not logged user";
}
context = [userData, navigator.userAgent];
return context;
};
});
;require.register("lib/urls", function(exports, require, module) {
var bcHash, host, root;
host = 'https://inventaire.io';
root = window.env === 'dev' ? host : '';
bcHash = '1QGMFXJevme8eNCusNmLddiecAiXspSguw';
module.exports = {
host: host,
contact: {
email: 'hello@inventaire.io',
mailto: 'mailto:hello@inventaire.io'
},
blog: 'http://asongofinventoryandfire.tumblr.com',
twitter: 'https://twitter.com/inventaire_io',
facebook: 'https://facebook.com/inventaire.io',
github: 'https://github.com/inventaire/inventaire',
transifex: 'https://www.transifex.com/organization/inventaire',
trello: 'https://trello.com/b/0lKcsZDj/inventaire-roadmap',
tracker: 'https://piwik.allmende.io/piwik.php',
images: {
banner: root + "/img/a703e4c65a44dab0e9086722ac2967c3cdf03024.jpg",
bokeh: root + "/img/6fca0921e336dd4dab1f1900e8f1143a9a9e9623.jpg",
ginnerobot: root + "/img/28945a3c26a986b371767cfdb9d0e11156a6d641.jpg",
brittanystevens: root + "/img/f3c063914d81996e3d262201d1e71c5e38212948.jpg"
},
bitcoin: {
hash: bcHash,
url: "bitcoin:" + bcHash,
coinbase: 'https://www.coinbase.com/inventaire',
qrcode: root + "/img/f086157157209ee0b3a09ff7bd8eb88c79fb658d.jpg"
},
gratipay: 'https://gratipay.com/inventaire-io'
};
});
;require.register("lib/utils", function(exports, require, module) {
var books_, isCouchUuid, oneDay, regex_, tests_, wd_,
slice = [].slice;
wd_ = requireProxy('lib/wikidata');
books_ = requireProxy('lib/books');
regex_ = sharedLib('regex');
tests_ = sharedLib('tests')(regex_);
isCouchUuid = regex_.CouchUuid.test.bind(regex_.CouchUuid);
oneDay = 24 * 60 * 60 * 1000;
module.exports = function(Backbone, _, app, window, csle) {
var loggers, utils;
loggers = require('./loggers')(_, csle);
utils = {
setCookie: function(key, value) {
return this.preq.post('/api/cookie', {
key: key,
value: value
})["catch"](_.Error("setCookie: failed: " + key + " - " + value));
},
i18n: require('./translate'),
I18n: function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _.capitaliseFirstLetter(_.i18n.apply(_, args));
},
icon: function(name, classes) {
return "<i class='fa fa-" + name + " " + classes + "'></i>&nbsp;&nbsp;";
},
updateQuery: function(newParams) {
var currentQueryString, pathname, query, ref, route;
ref = Backbone.history.fragment.split('?'), pathname = ref[0], currentQueryString = ref[1];
query = this.parseQuery(currentQueryString);
_.extend(query, newParams);
route = this.buildPath(pathname, query);
if (route != null) {
return app.navigate(route);
} else {
return _.error([query, newParams], 'couldnt updateQuery');
}
},
inspect: function(obj, label) {
if (label != null) {
_.log(obj, label + " added to window.current for inspection");
}
if (window.current != null) {
window.previous || (window.previous = []);
window.previous.unshift(window.current);
}
return window.current = obj;
},
hasKnownUriDomain: function(str) {
var id, prefix, ref;
if (_.isString(str)) {
ref = str.split(':'), prefix = ref[0], id = ref[1];
if ((prefix != null) && (id != null)) {
switch (prefix) {
case 'wd':
if (wd_.isWikidataId(id)) {
return true;
}
break;
case isbn:
if (books_.isIsbn(id)) {
return true;
}
break;
case 'inv':
if (this.isUuid(id)) {
return true;
}
}
}
}
return false;
},
lastRouteMatch: function(regex) {
var last, ref;
if (((ref = Backbone.history.last) != null ? ref[1] : void 0) != null) {
last = Backbone.history.last[1];
return regex.test(last);
} else {
return false;
}
},
openJsonWindow: function(obj, windowName) {
var data, json;
json = JSON.stringify(obj, null, 4);
data = 'data:application/json;charset=utf-8,' + encodeURI(json);
return window.open(data, windowName);
},
style: function(text, style) {
switch (style) {
case 'strong':
return "<strong>" + text + "</strong>";
}
},
stringOnly: function(str) {
if (typeof str === 'string') {
return str;
} else {
}
},
isntEmpty: function(array) {
return !this.isEmpty(array);
},
pickOne: function(obj) {
var k;
k = Object.keys(obj)[0];
return obj[k];
},
isModel: function(obj) {
return obj instanceof Backbone.Model;
},
isView: function(obj) {
return obj instanceof Backbone.View;
},
validImageSrc: function(url, callback) {
var cb, image;
image = new Image();
image.src = url;
cb = function() {
if (image.complete) {
return this.preq.resolve(url);
} else {
return this.preq.reject(url);
}
};
return setTimeout(cb, 500);
},
allValid: function(array, test) {
var el, j, len, result;
result = true;
for (j = 0, len = array.length; j < len; j++) {
el = array[j];
if (!test(el)) {
result = false;
}
}
return result;
},
isUri: function(str) {
var id, prefix, ref;
ref = str.split(':'), prefix = ref[0], id = ref[1];
if ((prefix != null) && (id != null)) {
switch (prefix) {
case 'wd':
return wd.isWikidataId(id);
case 'isbn':
return books_.isNormalizedIsbn(id);
}
}
return false;
},
uniq: function(array) {
var j, len, obj, value;
obj = {};
for (j = 0, len = array.length; j < len; j++) {
value = array[j];
obj[value] = true;
}
return Object.keys(obj);
},
values: function(obj) {
var index, length, props, result;
index = -1;
props = Object.keys(obj);
length = props.length;
result = Array(length);
while (++index < length) {
result[index] = obj[props[index]];
}
return result;
},
localUrl: function(url) {
return /^\//.test(url);
},
allValues: function(obj) {
return this.flatten(this.values(obj));
},
now: function() {
return new Date().getTime();
},
getYearFromEpoch: function(epochTime) {
return new Date(epochTime).getYear() + 1900;
},
yearsAgo: function(years) {
return new Date().getYear() + 1900 - years;
},
objectifyPairs: function(array) {
var err, i, key, obj, pairs, ref, value;
pairs = array.length / 2;
if (pairs % 1 !== 0) {
err = 'expected pairs, got odd number of arguments';
throw new Error(err, arguments);
}
obj = {};
if (pairs >= 1) {
i = 0;
while (i < pairs) {
ref = [array[i], array[i + 1]], key = ref[0], value = ref[1];
obj[key] = value;
i += 1;
}
}
return obj;
},
smallScreen: function(ceil) {
if (ceil == null) {
ceil = 1200;
}
return $(window).width() < ceil;
},
deepClone: function(obj) {
this.type(obj, 'object');
return JSON.parse(JSON.stringify(obj));
},
capitaliseFirstLetter: function(str) {
if (str === '') {
return '';
}
return str[0].toUpperCase() + str.slice(1);
},
isUuid: function(str) {
return regex_.Uuid.test(str);
},
isEmail: function(str) {
return regex_.Email.test(str);
},
isUserId: isCouchUuid,
isItemId: isCouchUuid,
isUsername: function(username) {
return regex_.Username.test(username);
},
isEntityUri: function(uri) {
return regex_.EntityUri.test(uri);
},
isOpenedOutside: function(e) {
return e.ctrlKey;
},
noop: function() {},
escapeKeyPressed: function(e) {
return e.keyCode === 27;
},
currentRoute: function() {
return location.pathname.slice(1);
},
currentQuerystring: function() {
return location.search;
},
setQuerystring: function(url, key, value) {
var href, qs, qsObj, ref;
ref = url.split('?'), href = ref[0], qs = ref[1];
if (qs != null) {
qsObj = _.parseQuery(qs);
qsObj[key] = value;
return _.buildPath(href, qsObj);
} else {
return href + "?" + key + "=" + value;
}
},
routeSection: function(route) {
return route.split(/[^\w]/)[0];
},
currentSection: function() {
return _.routeSection(_.currentRoute());
},
scrollTop: function($el, duration) {
var top;
if (duration == null) {
duration = 500;
}
if (_.isString) {
$el = $($el);
}
top = $el.position().top;
return $('html, body').animate({
scrollTop: top
}, duration);
},
scrollHeight: function(height, ms) {
if (ms == null) {
ms = 500;
}
return $('html, body').animate({
scrollTop: height
}, ms);
},
BasicPlugin: function(events, handlers) {
return _.partial(_.basicPlugin, events, handlers);
},
basicPlugin: function(events, handlers) {
this.events || (this.events = {});
_.extend(this.events, events);
_.extend(this, handlers);
},
stringContains: function(str, target) {
return str.split(target).length > 1;
},
cutBeforeWord: function(text, limit) {
var shortenedText;
shortenedText = text.slice(0, +limit + 1 || 9e9);
return shortenedText.replace(/\s\w+$/, '');
},
isCanvas: function(obj) {
var ref;
return (obj != null ? (ref = obj.nodeName) != null ? ref.toLowerCase() : void 0 : void 0) === 'canvas';
},
LazyRender: function(view, timespan) {
var cautiousRender;
if (timespan == null) {
timespan = 200;
}
cautiousRender = function() {
if (!view.isDestroyed) {
return view.render();
}
};
return _.debounce(cautiousRender, timespan);
},
invertAttr: function($target, a, b) {
var aVal, bVal;
aVal = $target.attr(a);
bVal = $target.attr(b);
$target.attr(a, bVal);
return $target.attr(b, aVal);
},
daysAgo: function(epochTime) {
return Math.floor((_.now() - epochTime) / oneDay);
}
};
return _.extend({}, utils, loggers, tests_);
};
});
;require.register("lib/view_state", function(exports, require, module) {
module.exports = {
CheckViewState: function(view, label) {
var check;
if (label == null) {
label = '';
}
return check = function(data) {
var err;
if (view.isDestroyed) {
err = new Error(label + " view was destroyed: actions stopped");
err.destroyed_view = true;
throw err;
} else {
return data;
}
};
},
catchDestroyedView: function(err) {
if (err.destroyed_view) {
_.warn(err.message);
} else {
throw err;
}
}
};
});
;require.register("lib/wikidata", function(exports, require, module) {
var aliases, langProperties, preq, sourcedExtract, wd_;
aliases = sharedLib('wikidata_aliases');
preq = requireProxy('lib/preq');
module.exports = wd_ = sharedLib('wikidata')(preq, _, wdk);
wd_.wmCommonsThumbData = function(file, width) {
if (width == null) {
width = 500;
}
width = _.bestImageWidth(width);
return preq.get(app.API.data.commonsThumb(file, width));
};
wd_.wmCommonsThumb = function(file, width) {
if (width == null) {
width = 500;
}
return wd_.wmCommonsThumbData(file, width).then(_.property('thumbnail'))["catch"]((function(_this) {
return function(err) {
console.warn("couldnt find " + file + " via tools.wmflabs.org, will use the small thumb version");
return _this.wmCommonsSmallThumb(file, 200);
};
})(this));
};
wd_.enWpImage = function(enWpTitle) {
return preq.get(app.API.data.enWpImage(enWpTitle)).then(_.property('url'))["catch"](_.ErrorRethrow('wikipediaExtract err'));
};
wd_.wikipediaExtract = function(lang, title) {
return preq.get(app.API.data.wikipediaExtract(lang, title)).then(function(data) {
var extract, url;
extract = data.extract, url = data.url;
return sourcedExtract(extract, url);
})["catch"](_.ErrorRethrow('wikipediaExtract err'));
};
sourcedExtract = function(extract, url) {
var text;
if (url != null) {
text = _.i18n('read_more_on_wikipedia');
return extract += "<br><a href='" + url + "' class='source link' target='_blank'>" + text + "</a>";
} else {
return extract;
}
};
wd_.sitelinks = sharedLib('wiki_sitelinks');
wd_.aliasingClaims = function(claims) {
var after, aliasId, aliased, before, claim, err, error, id;
for (id in claims) {
claim = claims[id];
aliasId = aliases[id];
if (aliasId != null) {
before = claims[aliasId] || (claims[aliasId] = []);
aliased = claims[id];
try {
_.types(before, 'strings...|numbers...');
_.types(aliased, 'strings...|numbers...');
after = _.uniq(before.concat(aliased));
claims[aliasId] = after;
} catch (error) {
err = error;
_.warn([err, id, claim], 'aliasingClaims err');
}
}
}
return claims;
};
wd_.getReverseClaims = function(property, value, refresh) {
return preq.get(app.API.data.wdq('claim', property, value, refresh)).then(wdk.parse.wdq.entities);
};
wd_.queryAuthorWorks = function(authorQid, refresh) {
return preq.get(app.API.data.wdQuery('author-works', authorQid, refresh)).then(wdk.parse.wdq.entities);
};
langProperties = ['P364', 'P103'];
wd_.getOriginalLang = function(claims, notSimplified) {
var langClaims, originalLangWdId, ref, ref1;
langClaims = _.pick(claims, langProperties);
if (_.objLength(langClaims) === 0) {
return;
}
if (notSimplified) {
langClaims = wdk.simplifyClaims(langClaims);
}
originalLangWdId = (ref = _.pickOne(langClaims)) != null ? ref[0] : void 0;
return (ref1 = window.wdLang.byWdId[originalLangWdId]) != null ? ref1.code : void 0;
};
});
;require.register("modules/comments/collections/comments", function(exports, require, module) {
module.exports = Backbone.Collection.extend({
model: require('../models/comment'),
comparator: function(comment) {
return comment.get('created');
},
initialize: function(comments, options) {
return this.item = options.item;
}
});
});
;require.register("modules/comments/comments", function(exports, require, module) {
var Comments, addComment, deleteComment, fetchComments, initComments, postComment, poster_, updateComment;
Comments = require('./collections/comments');
poster_ = require('lib/poster');
module.exports = function() {
return app.reqres.setHandlers({
'comments:init': initComments,
'comments:post': postComment,
'comments:update': updateComment,
'comments:delete': deleteComment
});
};
initComments = function(model) {
var comments, fetching;
fetching = null;
if (model.comments == null) {
model.comments = comments = new Comments([], {
item: model
});
fetching = fetchComments(model.id, comments);
}
return [model.comments, fetching];
};
fetchComments = function(itemId, commentsCollection) {
return _.preq.get(_.buildPath(app.API.comments["public"], {
item: itemId
})).then(commentsCollection.add.bind(commentsCollection));
};
postComment = function(itemId, message, commentsCollection) {
var comment, commentModel;
comment = {
item: itemId,
message: message
};
commentModel = addComment(comment, commentsCollection);
return _.preq.post(app.API.comments["private"], comment).then(poster_.UpdateModelIdRev(commentModel))["catch"](poster_.Rewind(commentModel, commentsCollection))["catch"](_.ErrorRethrow('postComment'));
};
addComment = function(comment, commentsCollection) {
_.extend(comment, {
user: app.user.id,
created: _.now()
});
return commentsCollection.add(comment);
};
updateComment = function(commentModel, newMessage) {
var currentMessage;
currentMessage = commentModel.get('message');
if (newMessage === currentMessage) {
return _.preq.resolved;
}
commentModel.set({
message: newMessage,
edited: _.now()
});
return _.preq.put(app.API.comments["private"], {
id: commentModel.id,
message: newMessage
});
};
deleteComment = function(commentModel, view) {
return view.$el.trigger('askConfirmation', {
confirmationText: _.i18n('comment_delete_confirmation'),
warningText: _.i18n('cant_undo_warning'),
action: function() {
return _.preq.resolve(commentModel.destroy());
},
selector: view.uniqueSelector
});
};
});
;require.register("modules/comments/models/comment", function(exports, require, module) {
module.exports = Backbone.Model.extend({
url: function() {
return _.buildPath(app.API.comments["private"], {
id: this.id
});
},
commentOwner: function() {
return app.user.id === this.get('user');
},
itemOwner: function() {
return app.user.id === this.collection.item.get('owner');
},
deleteRight: function() {
return this.commentOwner() || this.itemOwner();
},
initialize: function() {
return this.set({
editRight: this.commentOwner(),
deleteRight: this.deleteRight()
});
}
});
});
;require.register("modules/entities/collections/entities", function(exports, require, module) {
module.exports = Backbone.Collection.extend({
byUri: function(uri) {
return this.findWhere({
uri: uri
});
}
});
});
;require.register("modules/entities/collections/isbn_entities", function(exports, require, module) {
var Entities;
Entities = require('./entities');
module.exports = Entities.extend({
model: require('../models/isbn_entity')
});
});
;require.register("modules/entities/collections/wikidata_entities", function(exports, require, module) {
var Entities;
Entities = require('./entities');
module.exports = Entities.extend({
model: require('../models/wikidata_entity'),
byType: function(type) {
return _(this.models).where({
type: type
});
}
});
});
;require.register("modules/entities/entities", function(exports, require, module) {
var API, AuthorLi, Entities, EntityCreate, EntityShow, GenreLayout, InvEntity, IsbnEntity, WikidataEntity, books_, createEntity, error_, getEntitiesLabels, getEntityLocalHref, getEntityModel, getModelFromPrefix, getPrefixId, normalizeEntityUri, saveEntityModel, setHandlers, wd_;
books_ = require('lib/books');
wd_ = require('lib/wikidata');
WikidataEntity = require('./models/wikidata_entity');
IsbnEntity = require('./models/isbn_entity');
InvEntity = require('./models/inv_entity');
Entities = require('./collections/entities');
AuthorLi = require('./views/author_li');
EntityShow = require('./views/entity_show');
EntityCreate = require('./views/entity_create');
GenreLayout = require('./views/genre_layout');
error_ = require('lib/error');
module.exports = {
define: function(Entities, app, Backbone, Marionette, $, _) {
var EntitiesRouter;
EntitiesRouter = Marionette.AppRouter.extend({
appRoutes: {
'entity/:uri(/:label)/add(/)': 'showAddEntity',
'entity/:uri(/:label)(/)': 'showEntity'
}
});
return app.addInitializer(function() {
return new EntitiesRouter({
controller: API
});
});
},
initialize: function() {
setHandlers();
window.Entities = Entities = new Entities;
return Entities.data = require('./entities_data')(app, _, _.preq);
}
};
API = {
showEntity: function(uri, label, params, region) {
var id, prefix, ref, refresh;
region || (region = app.layout.main);
app.execute('show:loader', {
region: region
});
ref = getPrefixId(uri), prefix = ref[0], id = ref[1];
if (!((prefix != null) && (id != null))) {
_.warn('prefix or id missing at showEntity');
}
refresh = params != null ? params.refresh : void 0;
if (refresh) {
app.execute('qlabel:refresh');
}
return this._getEntityView(prefix, id, refresh).then(region.show.bind(region))["catch"](this.solveMissingEntity.bind(this, prefix, id))["catch"](function(err) {
_.error(err, 'couldnt showEntity');
return app.execute('show:404');
});
},
_getEntityView: function(prefix, id, refresh) {
return this.getEntityModel(prefix, id, refresh).then(_.Tap(this._replaceEntityPathname.bind(this))).then(this._getDomainEntityView.bind(this, prefix, refresh));
},
_replaceEntityPathname: function(entity) {
return app.navigateReplace(entity.get('pathname'));
},
_getDomainEntityView: function(prefix, refresh, entity) {
switch (prefix) {
case 'isbn':
case 'inv':
return this.getCommonBookEntityView(entity);
case 'wd':
return this.getWikidataEntityView(entity, refresh);
default:
return _.error("getDomainEntityView err: unknown domain " + prefix);
}
},
getWikidataEntityView: function(entity, refresh) {
switch (wd_.type(entity)) {
case 'human':
return this.getAuthorView(entity, refresh);
case 'book':
return this.getCommonBookEntityView(entity);
default:
return new GenreLayout({
model: entity
});
}
},
getCommonBookEntityView: function(entity) {
return new EntityShow({
model: entity
});
},
getAuthorView: function(entity, refresh) {
return new AuthorLi({
model: entity,
standalone: true,
displayBooks: true,
initialLength: 20,
refresh: refresh
});
},
getEntitiesModels: function(prefix, ids, refresh) {
var Model, err, error;
refresh = refresh === true;
try {
Model = getModelFromPrefix(prefix);
} catch (error) {
err = error;
return _.preq.reject(err);
}
return Entities.data.get(prefix, ids, 'collection', refresh).then(function(data) {
var models;
if (data == null) {
throw error_["new"]('no data at getEntitiesModels', arguments);
}
models = data.map(function(el) {
var model;
if (el == null) {
return _.warn('missing entity(possible reason: reached API limit, pagination is needed)');
}
model = new Model(el);
Entities.add(model);
return model;
});
return models;
});
},
getEntitiesModelsWithCatcher: function() {
return this.getEntitiesModels.apply(this, arguments)["catch"](_.Error('getEntitiesModels err'));
},
getEntityModel: function(prefix, id, refresh) {
if (!((prefix != null) && (id != null))) {
throw error_["new"]('missing prefix or id', arguments);
}
return this.getEntitiesModels(prefix, id, refresh).then(function(models) {
if ((models != null ? models[0] : void 0) != null) {
return models[0];
} else {
_.log("getEntityModel entity_not_found: " + prefix + ":" + id);
throw error_["new"]('entity_not_found', [prefix, id, models]);
}
});
},
showAddEntity: function(uri) {
var id, prefix, ref;
ref = getPrefixId(uri), prefix = ref[0], id = ref[1];
if ((prefix != null) && (id != null)) {
return this.getEntityModel(prefix, id).then(function(entity) {
return app.execute('show:item:creation:form', {
entity: entity
});
})["catch"](this.solveMissingEntity.bind(this, prefix, id))["catch"](_.Error('showAddEntity err'));
}
},
solveMissingEntity: function(prefix, id, err) {
if (err.message === 'entity_not_found') {
return this.showCreateEntity(id);
} else {
throw err;
}
},
showCreateEntity: function(isbn) {
return app.layout.main.show(new EntityCreate({
data: isbn,
standalone: true
}));
},
getEntityPublicItems: function(uri) {
return _.preq.get(app.API.items.publicByEntity(uri));
}
};
setHandlers = function() {
app.commands.setHandlers({
'show:entity': function(uri, label, params, region) {
var path;
API.showEntity(uri, label, params, region);
path = "entity/" + uri;
if (label != null) {
path += "/" + label;
}
return app.navigate(path);
},
'show:entity:from:model': function(model, params, region) {
var label, ref, uri;
ref = model.gets('uri', 'label'), uri = ref[0], label = ref[1];
if ((uri != null) && (label != null)) {
return app.execute('show:entity', uri, label, params, region);
} else {
throw new Error('couldnt show:entity:from:model');
}
},
'show:entity:refresh': function(model) {
return app.execute('show:entity:from:model', model, {
refresh: true
});
}
});
return app.reqres.setHandlers({
'get:entity:model': getEntityModel,
'get:entities:models': API.getEntitiesModelsWithCatcher.bind(API),
'save:entity:model': saveEntityModel,
'get:entity:public:items': API.getEntityPublicItems,
'get:entities:labels': getEntitiesLabels,
'create:entity': createEntity,
'get:entity:local:href': getEntityLocalHref,
'normalize:entity:uri': normalizeEntityUri
});
};
getEntityModel = function(prefix, id) {
var ref;
ref = getPrefixId(prefix, id), prefix = ref[0], id = ref[1];
if ((prefix != null) && (id != null)) {
return API.getEntityModel(prefix, id);
} else {
throw error_["new"]('missing prefix or id', arguments);
}
};
getEntitiesLabels = function(Qids) {
return Qids.map(function(Qid) {
var ref;
return (ref = Entities.byUri("wd:" + Qid)) != null ? ref.get('label') : void 0;
});
};
getPrefixId = function(prefix, id) {
var ref;
if (id == null) {
ref = prefix != null ? prefix.split(':') : void 0, prefix = ref[0], id = ref[1];
}
if ((prefix != null) && (id != null)) {
return [prefix, id];
} else {
throw new Error("prefix and id not found for: " + prefix + " / " + id);
}
};
getModelFromPrefix = function(prefix) {
switch (prefix) {
case 'wd':
return WikidataEntity;
case 'isbn':
return IsbnEntity;
case 'inv':
return InvEntity;
default:
throw new Error("prefix not implemented: " + prefix);
}
};
saveEntityModel = function(prefix, data) {
if ((data != null ? data.id : void 0) != null) {
return Entities.data[prefix].local.save(data.id, data);
} else {
return _.error(arguments, 'couldnt save entity model');
}
};
createEntity = function(data) {
return Entities.data.inv.local.post(data).then(function(entityData) {
var model;
_.type(entityData, 'object');
if (entityData.isbn != null) {
model = new IsbnEntity(entityData);
} else {
model = new InvEntity(entityData);
}
Entities.add(model);
return model;
});
};
getEntityLocalHref = function(domain, id, label) {
var href, possibleId, ref, ref1;
ref = domain != null ? domain.split(':') : void 0, domain = ref[0], possibleId = ref[1];
if (possibleId != null) {
ref1 = [possibleId, id], id = ref1[0], label = ref1[1];
}
if ((domain != null ? domain.length : void 0) > 0 && (id != null ? id.length : void 0) > 0) {
href = "/entity/" + domain + ":" + id;
if (label != null) {
label = _.softEncodeURI(label);
href += "/" + label;
}
return href;
} else {
throw new Error("couldnt find EntityLocalHref: domain=" + domain + ", id=" + id + ", label=" + label);
}
};
normalizeEntityUri = function(prefix, id) {
var ref;
ref = getPrefixId(prefix, id), prefix = ref[0], id = ref[1];
if (prefix === 'isbn') {
id = books_.normalizeIsbn(id);
}
return prefix + ":" + id;
};
});
;require.register("modules/entities/entities_data", function(exports, require, module) {
var InvData, IsbnData, WdData, books_, wd_;
WdData = require('./lib/wikidata/wikidata_data');
IsbnData = require('./lib/isbn/isbn_data');
InvData = require('./lib/inv/inv_data');
wd_ = require('lib/wikidata');
books_ = require('lib/books');
module.exports = function(app, _, promises_) {
var data, get, invData, isbnData, wdData;
wdData = WdData(app, _, wd_, promises_);
isbnData = IsbnData(app, _, books_, promises_);
invData = InvData(app, _);
data = {
wd: wdData,
isbn: isbnData,
inv: invData
};
get = function(prefix, ids, format, refresh) {
var provider, types;
types = ['string', 'array|string', 'string|undefined', 'boolean'];
_.types(arguments, types, 2);
provider = data[prefix];
if (provider == null) {
return _.error([prefix, id], 'not implemented prefix, cant getEntityModel');
}
return provider.local.get(ids, format, refresh);
};
return data = {
wd: wdData,
isbn: isbnData,
inv: invData,
get: get
};
};
});
;require.register("modules/entities/lib/images", function(exports, require, module) {
var setPictureCredits, wd_;
wd_ = require('lib/wikidata');
module.exports = {
openLibrary: function(openLibraryId) {
var type;
_.log(openLibraryId, 'ol');
type = this.type === 'book' ? 'book' : 'author';
return _.preq.get(app.API.data.openLibraryCover(openLibraryId, type)).then(_.property('url'))["catch"](_.ErrorRethrow('openLibrary'));
},
wmCommons: function(title) {
_.log(title, 'wm');
return wd_.wmCommonsThumbData(title, 1000).then((function(_this) {
return function(data) {
var author, license, thumbnail;
thumbnail = data.thumbnail, author = data.author, license = data.license;
setPictureCredits.call(_this, title, author, license);
return thumbnail;
};
})(this))["catch"](_.ErrorRethrow('wmCommons'));
},
enWikipedia: function(enWpTitle) {
_.log(enWpTitle, 'wp');
return wd_.enWpImage(enWpTitle)["catch"](_.ErrorRethrow('enWikipedia'));
}
};
setPictureCredits = function(title, author, license) {
var text;
if ((author != null) && (license != null)) {
text = author + " - " + license;
} else {
text = author || license;
}
return this.set('pictureCredits', {
url: "https://commons.wikimedia.org/wiki/File:" + title,
text: text
});
};
});
;require.register("modules/entities/lib/inv/entity_data_tests", function(exports, require, module) {
var books_, forms_;
books_ = require('lib/books');
forms_ = require('modules/general/lib/forms');
module.exports = function(data) {
var authors, isbn, title;
title = data.title, authors = data.authors, isbn = data.isbn;
if (!_.isNonEmptyString(title)) {
forms_.throwError('a title is required', '#titleField', data);
}
if (!_.isNonEmptyString(authors)) {
forms_.throwError('an author is required', '#authorsField', data);
}
if (_.isNonEmptyString(isbn)) {
if (!books_.isIsbn(isbn)) {
return forms_.throwError('invalid ISBN', '.entityCreate #isbnField', data);
}
}
};
});
;require.register("modules/entities/lib/inv/inv_data", function(exports, require, module) {
module.exports = function(app, _) {
var invData, local, remote;
remote = {
get: function(ids) {
return _.preq.get(app.API.entities.inv.get(ids))["catch"](_.Error('inv_data get err'));
},
post: function(body) {
var url;
url = app.API.entities.inv.create;
return _.preq.post(url, body)["catch"](_.Error('inv_data post err'));
}
};
local = new app.LocalCache({
name: 'entities_inv',
remote: remote
});
return invData = {
local: local,
remote: remote
};
};
});
;require.register("modules/entities/lib/isbn/isbn_data", function(exports, require, module) {
module.exports = function(app, _, books, promises_) {
var isbnData, local, remote;
remote = {
get: books.getIsbnEntities
};
local = new app.LocalCache({
name: 'entities_isbn',
normalizeId: books.normalizeIsbn,
remote: remote
});
return isbnData = {
local: local,
remote: remote
};
};
});
;require.register("modules/entities/lib/wikidata/authors", function(exports, require, module) {
var aliases, fetchAuthorsWorksEntities, fetchAuthorsWorksIds, parseEntities, wd_;
wd_ = require('lib/wikidata');
aliases = sharedLib('wikidata_aliases');
module.exports = {
fetchAuthorsWorks: function(authorModel, refresh) {
return fetchAuthorsWorksIds(authorModel, refresh).then(fetchAuthorsWorksEntities.bind(null, authorModel, refresh)).then(parseEntities)["catch"](_.Error('wdAuthors_.fetchAuthorsWorks'));
}
};
fetchAuthorsWorksIds = function(authorModel, refresh) {
var ref;
if ((!refresh) && (((ref = authorModel.get('reverseClaims')) != null ? ref.P50 : void 0) != null)) {
return _.preq.resolved;
}
return wd_.queryAuthorWorks(authorModel.id, refresh).then(_.Log('worksIds')).then(authorModel.save.bind(authorModel, 'reverseClaims.P50'))["catch"](_.Error('fetchAuthorsWorksIds err'));
};
fetchAuthorsWorksEntities = function(authorModel, refresh) {
var authorsWorks;
authorsWorks = authorModel.get('reverseClaims.P50');
_.log(authorsWorks, 'authorsWorks');
if (!((authorsWorks != null ? authorsWorks.length : void 0) > 0)) {
return _.preq.resolved;
}
authorsWorks = authorsWorks.slice(0, 50);
return app.request('get:entities:models', 'wd', authorsWorks, refresh);
};
parseEntities = function(entities) {
return {
books: _.compact(entities).filter(wd_.entityIsBook),
articles: _.compact(entities).filter(wd_.entityIsArticle)
};
};
});
;require.register("modules/entities/lib/wikidata/books", function(exports, require, module) {
var books_, requestBookCover, wdBooks_, wd_;
wd_ = require('lib/wikidata');
books_ = require('lib/books');
requestBookCover = require('./request_book_cover');
wdBooks_ = {};
wdBooks_.findAPictureByBookData = function(bookModel) {
if (bookModel.get('status.imageRequested')) {
return;
}
return requestBookCover(bookModel);
};
wdBooks_.fetchAuthorsEntities = function(bookModel) {
var authors, label;
authors = bookModel.get('claims.P50');
if ((authors != null ? authors.length : void 0) > 0) {
return app.request('get:entities:models', 'wd', authors);
} else {
label = bookModel.get('label');
_.warn("no author found for " + label);
return _.preq.resolved;
}
};
module.exports = wdBooks_;
});
;require.register("modules/entities/lib/wikidata/genre", function(exports, require, module) {
var getReverseClaims, wdGenre_, wd_;
wd_ = require('lib/wikidata');
module.exports = wdGenre_ = {};
wdGenre_.fetchBooksAndAuthors = function(genreModel) {
return wdGenre_.fetchBooksAndAuthorsIds(genreModel).then(wdGenre_.fetchBooksAndAuthorsEntities.bind(null, genreModel, null, null))["catch"](_.ErrorRethrow('wdGenre_.fetchBooksAndAuthors'));
};
wdGenre_.fetchBooksAndAuthorsIds = function(genreModel) {
var P135, P136, reverseClaims;
reverseClaims = genreModel.get('reverseClaims');
if (reverseClaims != null) {
P135 = reverseClaims.P135, P136 = reverseClaims.P136;
if ((P135 != null) || (P136 != null)) {
return _.preq.resolved;
}
}
return Promise.all([getReverseClaims('P135', genreModel), getReverseClaims('P136', genreModel)]).then(_.flatten)["catch"](_.ErrorRethrow('wdGenre_.fetchBooksAndAuthorsIds'));
};
getReverseClaims = function(P, genreModel) {
var Q;
Q = genreModel.id;
return wd_.getReverseClaims(P, Q).then(_.uniq).then(_.Log("books and authors ids (" + P + ")")).then(genreModel.save.bind(genreModel, "reverseClaims." + P));
};
wdGenre_.fetchBooksAndAuthorsEntities = function(genreModel, limit, offset) {
var first, ids, last, range;
if (limit == null) {
limit = 10;
}
if (offset == null) {
offset = 0;
}
_.types([genreModel, limit, offset], ['object', 'number', 'number']);
ids = _.flatten(genreModel.gets('reverseClaims.P135', 'reverseClaims.P136'));
first = offset;
last = offset + limit;
range = ids.slice(first, last);
if (!(range.length > 0)) {
_.warn('no more ids: range is empty');
return _.preq.resolved;
}
return app.request('get:entities:models', 'wd', range);
};
wdGenre_.spreadBooksAndAuthors = function(books, authors, entities) {
var entity, i, len, results;
if (entities == null) {
return _.warn('no entities to spread');
}
results = [];
for (i = 0, len = entities.length; i < len; i++) {
entity = entities[i];
switch (wd_.type(entity)) {
case 'book':
results.push(books.add(entity));
break;
case 'human':
results.push(authors.add(entity));
break;
default:
results.push(_.warn([entity, entity.get('label'), entity.get('claims.P31')], 'neither a book or a human'));
}
}
return results;
};
});
;require.register("modules/entities/lib/wikidata/request_book_cover", function(exports, require, module) {
var attachPictures, books_, findIsbn, getMostAccurateData, getTitleAndAuthor;
books_ = require('lib/books');
module.exports = function(bookModel) {
var data, entityUri;
data = getMostAccurateData(bookModel);
entityUri = bookModel.get('uri');
books_.getImage(entityUri, data).then(attachPictures.bind(null, bookModel))["catch"](_.Error('requestBookCover'));
bookModel.set('status.imageRequested', true);
return bookModel.save();
};
getMostAccurateData = function(bookModel) {
var isbn;
isbn = findIsbn(bookModel.claims);
if (isbn != null) {
return isbn;
} else {
return getTitleAndAuthor(bookModel);
}
};
findIsbn = function(claims) {
var isbn, isbn10, isbn13, ref, ref1;
isbn13 = _.stringOnly(claims != null ? (ref = claims.P957) != null ? ref[0] : void 0 : void 0);
isbn10 = _.stringOnly(claims != null ? (ref1 = claims.P212) != null ? ref1[0] : void 0 : void 0);
isbn = isbn13 || isbn10;
if (isbn != null) {
return books_.normalizeIsbn(isbn);
}
};
getTitleAndAuthor = function(bookModel) {
var authors, ref, title;
title = bookModel.get('label');
if ((title != null) && (((ref = bookModel.claims) != null ? ref.P50 : void 0) != null)) {
authors = app.request('get:entities:labels', bookModel.claims.P50);
if ((authors != null ? authors[0] : void 0) != null) {
authors = authors.join(' ');
return title + " " + authors;
}
}
};
attachPictures = function(bookModel, pictures) {
var pics;
_.log(pictures, 'pictures');
_.types(pictures, 'objects...');
if (pictures.length > 0) {
pics = bookModel.get('pictures') || [];
pictures = pictures.map(_.property('image'));
bookModel.set('pictures', pictures.concat(pics));
return bookModel.save();
}
};
});
;require.register("modules/entities/lib/wikidata/wikidata_data", function(exports, require, module) {
module.exports = function(app, _, wd, promises_) {
var local, remote, wdData;
remote = {
get: wd.getEntities
};
local = new app.LocalCache({
name: 'entities_wd',
remote: remote,
parseData: _.property('entities')
});
return wdData = {
local: local,
remote: remote
};
};
});
;require.register("modules/entities/models/entity", function(exports, require, module) {
var customSave,
slice = [].slice;
module.exports = Backbone.NestedModel.extend({
initLazySave: function() {
var lazySave;
lazySave = _.debounce(customSave.bind(this), 100);
return this.save = function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
this.set.apply(this, args);
lazySave();
return this;
};
},
updateMetadata: function() {
return _.preq.start.then(this.executeMetadataUpdate.bind(this));
},
executeMetadataUpdate: function() {
var ref, ref1;
return app.execute('metadata:update', {
title: this.buildBookTitle(),
description: (ref = this.findBestDescription()) != null ? ref.slice(0, 501) : void 0,
image: (ref1 = this.get('pictures')) != null ? ref1[0] : void 0,
url: this.get('canonical')
});
},
findBestDescription: function() {
return this.get('description');
},
buildBookTitle: function() {
var title;
title = this.get('title');
return (title + " - ") + _.I18n('book');
}
});
customSave = function() {
return app.request('save:entity:model', this.prefix, this.toJSON());
};
});
;require.register("modules/entities/models/inv_entity", function(exports, require, module) {
var Entity, parseAuthors;
Entity = require('./entity');
module.exports = Entity.extend({
prefix: 'inv',
initialize: function() {
var canonical, pathname, title;
this.initLazySave();
this.id = this.get('_id');
canonical = pathname = "/entity/" + this.prefix + ":" + this.id;
if (title = this.get('title')) {
pathname += "/" + _.softEncodeURI(title);
}
return this.set({
canonical: canonical,
pathname: pathname,
uri: this.prefix + ":" + this.id,
domain: 'inv'
});
},
getAuthorsString: function() {
var authors, str;
authors = this.get('authors');
str = (function() {
switch (_.typeOf(authors)) {
case 'string':
return authors;
case 'array':
return parseAuthors(authors);
}
})();
return _.preq.resolve(str);
}
});
parseAuthors = function(authors) {
return authors.map(_.property('value')).join(', ');
};
});
;require.register("modules/entities/models/isbn_entity", function(exports, require, module) {
var Entity, books_, parseAuthor;
Entity = require('./entity');
books_ = require('lib/books');
module.exports = Entity.extend({
prefix: 'isbn',
initialize: function() {
var canonical, isbn, pathname, title;
this.initLazySave();
this.id = this.get('id');
isbn = this.get('isbn');
if (isbn == null) {
throw new Error("isbn entity doesn't have an isbn: " + (this.get('uri')));
}
this.uri = this.get('uri') || ("isbn:" + isbn);
canonical = pathname = "/entity/" + this.uri;
this.findAPicture();
if (title = this.get('title')) {
pathname += "/" + _.softEncodeURI(title);
}
return this.set({
canonical: canonical,
pathname: pathname,
domain: 'isbn',
uri: this.uri
});
},
findAPicture: function() {
var pictures;
pictures = this.get('pictures');
if (_.isEmpty(pictures)) {
return this._fetchPicture();
} else {
return this.set('pictures', pictures.map(books_.uncurl));
}
},
_fetchPicture: function() {
return books_.getImage(this.uri).then((function(_this) {
return function(images) {
return _this.set('pictures', images.map(_.property('image')));
};
})(this))["catch"](_.Error('findAPicture'));
},
getAuthorsString: function() {
var str;
str = this.get('authors').map(parseAuthor).join(', ');
_.log(str, 'isbn author');
return _.preq.resolve(str);
}
});
parseAuthor = function(a) {
switch (a.type) {
case 'wikidata_id':
return a.label;
case 'string':
return a.value;
}
};
});
;require.register("modules/entities/models/wikidata_entity", function(exports, require, module) {
var Entity, error_, getEntityValue, getLangPriorityOrder, images_, wdAuthors_, wdBooks_, wd_;
Entity = require('./entity');
wd_ = require('lib/wikidata');
wdBooks_ = require('modules/entities/lib/wikidata/books');
wdAuthors_ = require('modules/entities/lib/wikidata/books');
error_ = require('lib/error');
images_ = require('../lib/images');
module.exports = Entity.extend({
idAttribute: 'id',
prefix: 'wd',
initialize: function() {
var lang, ref;
this.initLazySave();
this._updates = {};
if (!((ref = this.get('status')) != null ? ref.formatted : void 0)) {
if (Entities.byUri('wd:#{@id}') != null) {
console.warn("reformatting " + this.id + " while it was already cached! Probably because the server returned fresh data (ex: during entity search)");
}
lang = app.user.lang;
this.setWikiLinks(lang);
this.setWikipediaExtract(lang);
this._updates.sitelinks = {};
this.rebaseClaims();
this.setAttributes(this.attributes, lang);
this.type = wd_.type(this._updates);
this.findAPicture();
this.set(this._updates);
this._updates = null;
this.set('status.formatted', true);
this.save();
}
if (this.waitForExtract == null) {
this.waitForExtract = _.preq.resolved;
}
if (this.waitForPicture == null) {
this.waitForPicture = _.preq.resolved;
}
this.waitForData = Promise.all([this.waitForExtract, this.waitForPicture]);
this.claims = this.get('claims');
this.wikidata = true;
return this.typeSpecificInitilize();
},
rebaseClaims: function() {
var claims, publicationDate, ref;
claims = this.get('claims');
if (claims != null) {
claims = wdk.simplifyClaims(claims);
this._updates.claims = claims = wd_.aliasingClaims(claims);
this.originalLang = wd_.getOriginalLang(claims);
publicationDate = (ref = claims.P577) != null ? ref[0] : void 0;
if (publicationDate != null) {
this.publicationYear = _.getYearFromEpoch(publicationDate);
}
}
},
setAttributes: function(attrs, lang) {
var description, label, pathname, ref, ref1;
pathname = "/entity/wd:" + this.id;
this._updates.canonical = pathname;
label = getEntityValue(attrs, 'labels', lang, this.originalLang);
if (label == null) {
label = (ref = this._updates.wikipedia) != null ? (ref1 = ref.title) != null ? ref1.replace(/\s\(\w+\)/, '') : void 0 : void 0;
}
if (label != null) {
this._updates.label = label;
this._updates.title = label;
pathname += "/" + _.softEncodeURI(label);
}
this._updates.pathname = pathname;
this._updates.domain = 'wd';
description = getEntityValue(attrs, 'descriptions', lang, this.originalLang);
if (description != null) {
this._updates.description = description;
}
this._updates.reverseClaims = {};
},
setWikiLinks: function(lang) {
var ref, ref1, ref2, sitelinks;
this._updates.wikidata = {
url: "https://www.wikidata.org/entity/" + this.id,
wiki: "https://www.wikidata.org/wiki/" + this.id
};
this._updates.uri = "wd:" + this.id;
this.originalLang = (ref = this._updates.claims) != null ? (ref1 = ref.P364) != null ? ref1[0] : void 0 : void 0;
sitelinks = this.get('sitelinks');
if (sitelinks != null) {
this.enWpTitle = (ref2 = sitelinks.enwiki) != null ? ref2.title : void 0;
this._updates.wikipedia = wd_.sitelinks.wikipedia(sitelinks, lang);
this._updates.wikisource = wd_.sitelinks.wikisource(sitelinks, lang);
}
},
setWikipediaExtract: function(lang) {
var ref, ref1, title;
title = (ref = this.get('sitelinks')) != null ? (ref1 = ref[lang + "wiki"]) != null ? ref1.title : void 0 : void 0;
if (title != null) {
this.waitForExtract = wd_.wikipediaExtract(lang, title).then((function(_this) {
return function(extract) {
if (extract != null) {
_this.set('extract', extract);
return _this.save();
}
};
})(this))["catch"](_.Error('getWikipediaExtract err'));
}
},
findAPicture: function() {
var commonsImage, openLibraryId, pictures, ref, ref1, ref2, ref3;
this._updates.pictures = pictures = [];
this.save();
openLibraryId = (ref = this._updates.claims) != null ? (ref1 = ref.P648) != null ? ref1[0] : void 0 : void 0;
commonsImage = (ref2 = this._updates.claims) != null ? (ref3 = ref2.P18) != null ? ref3[0] : void 0 : void 0;
return this.waitForPicture = this._pickBestPic(openLibraryId, commonsImage);
},
_pickBestPic: function(openLibraryId, commonsImage) {
var candidates, getters, order;
getters = {};
if (openLibraryId != null) {
getters.ol = images_.openLibrary.bind(this, openLibraryId);
}
if (commonsImage != null) {
getters.wm = images_.wmCommons.bind(this, commonsImage);
}
if (this.enWpTitle != null) {
getters.wp = images_.enWikipedia.bind(this, this.enWpTitle);
}
if (this.type === 'human') {
order = ['wm', 'ol', 'wp'];
} else {
if ((this.publicationYear != null) && this.publicationYear < _.yearsAgo(70)) {
order = ['ol', 'wm', 'wp'];
} else {
order = ['ol', 'wp', 'wm'];
}
}
candidates = _.values(_.pick(getters, order));
if (candidates.length === 0) {
return _.preq.resolved;
}
return _.preq.fallbackChain(candidates).then(this._savePicture.bind(this))["catch"](_.Error('_pickBestPic err'));
},
_savePicture: function(url) {
this.push('pictures', url);
return this.save();
},
typeSpecificInitilize: function() {
switch (this.type) {
case 'book':
return this.initializeBook();
case 'human':
return this.initializeAuthor();
}
},
initializeBook: function() {
return wdBooks_.fetchAuthorsEntities(this).then(this.findAPictureIfMissing.bind(this))["catch"](_.Error('fetchAuthorsEntities err'));
},
findAPictureIfMissing: function() {
return this.waitForPicture.then((function(_this) {
return function() {
if (_this.get('pictures').length === 0) {
return wdBooks_.findAPictureByBookData(_this);
}
};
})(this));
},
initializeAuthor: function() {},
updateMetadata: function() {
return this.waitForData.then(this.executeMetadataUpdate.bind(this))["catch"](_.Error('updateMetadata err'));
},
executeMetadataUpdate: function() {
var ref, ref1;
return app.execute('metadata:update', {
title: this.findBestTitle(),
description: (ref = this.findBestDescription()) != null ? ref.slice(0, 501) : void 0,
image: (ref1 = this.get('pictures')) != null ? ref1[0] : void 0,
url: this.get('canonical')
});
},
findBestTitle: function() {
var title;
title = this.get('title');
switch (this.type) {
case 'human':
return _.i18n('books_by_author', {
author: title
});
case 'book':
return this.buildBookTitle();
default:
return title;
}
},
findBestDescription: function() {
var description, extract;
extract = this.get('extract');
description = this.get('description');
if ((extract != null) && extract.length > 300) {
return extract;
} else {
return description || extract;
}
},
getAuthorsString: function() {
var qids;
qids = this.claims.P50;
return wd_.getLabel(qids, app.user.lang);
}
});
getEntityValue = function(attrs, props, lang, originalLang) {
var nextLang, order, property, ref, value;
property = attrs[props];
if (property != null) {
order = getLangPriorityOrder(lang, originalLang, property);
while (order.length > 0) {
nextLang = order.shift();
value = (ref = property[nextLang]) != null ? ref.value : void 0;
if (value != null) {
return value;
}
}
}
};
getLangPriorityOrder = function(lang, originalLang, property) {
var availableLangs, order;
order = [lang];
if (originalLang != null) {
order.push(originalLang);
}
order.push('en');
availableLangs = Object.keys(property);
return _.uniq(order.concat(availableLangs));
};
});
;require.register("modules/entities/views/article_li", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
template: require('./templates/article_li'),
tagName: 'li',
className: 'articleLi',
serializeData: function() {
var attrs;
attrs = this.model.toJSON();
attrs.wikidata.customStyle = true;
return _.extend(attrs, {
href: this.getHref(),
hasDate: this.hasDate()
});
},
getHref: function() {
var DOI, ref, ref1;
DOI = (ref = this.model.get('claims')) != null ? (ref1 = ref.P356) != null ? ref1[0] : void 0 : void 0;
if (DOI != null) {
return "https://dx.doi.org/" + DOI;
}
},
hasDate: function() {
var ref, ref1;
return ((ref = this.model.get('claims')) != null ? (ref1 = ref.P577) != null ? ref1[0] : void 0 : void 0) != null;
}
});
});
;require.register("modules/entities/views/author_li", function(exports, require, module) {
var WorksList, behaviorsPlugin, wdAuthors_, wikiBarPlugin;
wdAuthors_ = require('modules/entities/lib/wikidata/authors');
behaviorsPlugin = require('modules/general/plugins/behaviors');
wikiBarPlugin = require('modules/general/plugins/wiki_bar');
WorksList = require('./works_list');
module.exports = Marionette.LayoutView.extend({
template: require('./templates/author_li'),
tagName: 'li',
className: 'authorLi',
behaviors: {
Loading: {}
},
regions: {
booksRegion: '.books',
articlesRegion: '.articles'
},
initialize: function() {
this.initPlugins();
this.books = new Backbone.Collection;
this.articles = new Backbone.Collection;
this.lazyRender = _.LazyRender(this);
this.$el.once('inview', this.fetchBooks.bind(this));
this.listenTo(this.model, 'change', this.lazyRender.bind(this));
if (this.options.standalone) {
return app.execute('metadata:update:needed');
}
},
initPlugins: function() {
_.extend(this, behaviorsPlugin);
if (this.options.standalone) {
return wikiBarPlugin.call(this);
}
},
events: {
'click .refreshData': 'refreshData'
},
modelEvents: {
'add:pictures': 'lazyRender'
},
serializeData: function() {
return _.extend(this.model.toJSON(), {
standalone: this.options.standalone,
canRefreshData: true,
hideWikisourceEpub: true
});
},
fetchBooks: function() {
var refresh;
refresh = this.options.refresh === true;
this.startLoading();
return wdAuthors_.fetchAuthorsWorks(this.model, refresh).then(this.addToCollections.bind(this))["catch"](_.Error('author_li fetchBooks err'))["finally"](this.stopLoading.bind(this));
},
addToCollections: function(works) {
var articles, books;
books = works.books, articles = works.articles;
if (!((books != null) || (articles != null))) {
return _.warn('no work found for #{@model.title}');
}
this.books.add(books);
this.articles.add(articles);
if (this.articles.length > 0) {
return this.showArticles();
}
},
onRender: function() {
this.showBooks();
if (this.options.standalone) {
return this.model.updateMetadata()["finally"](app.execute.bind(app, 'metadata:update:done'));
}
},
showBooks: function() {
return this.booksRegion.show(new WorksList({
collection: this.books,
type: 'books'
}));
},
showArticles: function() {
return this.articlesRegion.show(new WorksList({
collection: this.articles,
type: 'articles'
}));
},
refreshData: function() {
return app.execute('show:entity:refresh', this.model);
}
});
});
;require.register("modules/entities/views/book_li", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
template: require('./templates/book_li'),
tagName: 'li',
className: 'bookLi',
initialize: function() {
this.listenTo(this.model, 'change', this.render);
this.listenTo(this.model, 'add:pictures', this.render);
return app.execute('qlabel:update');
},
behaviors: {
PreventDefault: {},
PlainTextAuthorLink: {}
},
ui: {
zoomButtons: '.zoom-button .buttons span',
cover: 'img'
},
events: {
'click a.addToInventory': 'showItemCreationForm',
'click a.zoom-button': 'toggleZoom'
},
showItemCreationForm: function(e) {
if (!_.isOpenedOutside(e)) {
return app.execute('show:item:creation:form', {
entity: this.model
});
}
},
serializeData: function() {
var attrs;
attrs = _.extend(this.model.toJSON(), {
counter: this.counter()
});
if (attrs.extract != null) {
attrs.description = attrs.extract;
}
return attrs;
},
counter: function() {
var count, counter;
count = app.request('items:count:byEntity', this.model.get('uri'));
return counter = {
count: count,
highlight: count > 0
};
},
toggleZoom: function() {
_.invertAttr(this.ui.cover, 'src', 'data-zoom-toggle');
this.ui.zoomButtons.toggle();
return this.$el.toggleClass('zoom', {
duration: 500
});
}
});
});
;require.register("modules/entities/views/entity_actions", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
template: require('./templates/entity_actions'),
className: 'entityActions',
behaviors: {
PreventDefault: {}
},
initialize: function() {
this.uri = this.model.get('uri');
return this.mainUserInstances = app.request('item:main:user:instances', this.uri);
},
serializeData: function() {
return {
transactions: this.transactionsData(),
mainUserHasOne: this.mainUserHasOne(),
mainUserInstances: this.mainUserInstances,
instances: {
count: this.mainUserInstances.length,
pathname: this.mainUserInstancesPathname()
}
};
},
transactionsData: function() {
var transactions;
transactions = Items.transactions();
transactions.inventorying.icon = 'plus';
transactions.inventorying.label = 'just_inventorize_it';
return transactions;
},
onRender: function() {
return app.execute('foundation:reload');
},
events: {
'click #addToInventory, #inventorying': 'inventorying',
'click #giving': 'giving',
'click #lending': 'lending',
'click #selling': 'selling',
'click .hasAnInstance a': 'showMainUserInstances'
},
giving: function() {
return this.showItemCreation('giving');
},
lending: function() {
return this.showItemCreation('lending');
},
selling: function() {
return this.showItemCreation('selling');
},
inventorying: function() {
return this.showItemCreation('inventorying');
},
showItemCreation: function(transaction) {
if (this.model.delegateItemCreation) {
this.model.trigger('delegate:item:creation', transaction);
return _.log('delegating item creation');
} else {
return app.execute('show:item:creation:form', {
entity: this.model,
transaction: transaction
});
}
},
mainUserHasOne: function() {
return this.mainUserInstances.length > 0;
},
showMainUserInstances: function() {
return app.execute('show:items', this.mainUserInstances);
},
mainUserInstancesPathname: function() {
var uri, username;
uri = this.uri;
username = app.user.get('username');
return "/inventory/" + username + "/" + uri;
}
});
});
;require.register("modules/entities/views/entity_create", function(exports, require, module) {
var EntityActions, PicturePicker, books_, entityDataTests, forms_;
books_ = require('lib/books');
forms_ = require('modules/general/lib/forms');
entityDataTests = require('../lib/inv/entity_data_tests');
EntityActions = require('./entity_actions');
PicturePicker = require('modules/general/views/behaviors/picture_picker');
module.exports = Marionette.LayoutView.extend({
template: require('./templates/entity_create'),
className: function() {
if (this.options.standalone) {
return 'entityCreate standalone';
} else {
return 'entityCreate';
}
},
regions: {
entityActions: '#entityActions'
},
events: {
'click #addPicture': 'addPicture'
},
ui: {
title: '#titleField',
authors: '#authorsField',
isbn: '#isbnField'
},
behaviors: {
AlertBox: {},
BackupForm: {}
},
initialize: function() {
return this.initModel();
},
serializeData: function() {
return _.extend(this.model.toJSON(), {
header: this.getHeader(),
titleField: this.fieldData('title', 'ex: Hamlet'),
authorsField: this.fieldData('authors', 'ex: William Shakespeare'),
isbnField: this.fieldData('isbn', 'ex: 978-2070368228'),
standalone: this.options.standalone
});
},
getHeader: function() {
var header;
header = "let's just create the book card";
if (this.options.secondChoice) {
header = "otherwise, " + header;
}
if (this.options.standalone) {
header = "this book isnt in the database: " + header;
}
return _.i18n(header);
},
fieldData: function(attr, placeholder) {
return {
id: attr,
value: this.model.get(attr),
placeholder: placeholder
};
},
initModel: function() {
this.model = new Backbone.Model;
this.model.set('pictures', []);
this.listenTo(this.model, 'change:pictures', this.render);
this.model.delegateItemCreation = true;
return this.listenTo(this.model, 'delegate:item:creation', this.showItemCreation.bind(this));
},
updateModel: function(attr) {
var val;
val = this.ui[attr].val();
return this.model.set(attr, val);
},
onRender: function() {
return this.showEntityActions();
},
onShow: function() {
this.prefillForm();
if (this.options.standalone) {
return this.ui.title.focus();
}
},
prefillForm: function() {
var data;
data = this.options.data;
if (data != null) {
if (books_.isIsbn(data)) {
this.ui.isbn.val(data);
return this.model.set('isbn', data);
} else {
this.ui.title.val(data);
return this.model.set('title', data);
}
}
},
addPicture: function() {
var picturePicker;
picturePicker = new PicturePicker({
pictures: this.model.get('pictures'),
limit: 1,
save: this.model.set.bind(this.model, 'pictures')
});
return app.layout.modal.show(picturePicker);
},
showItemCreation: function(transaction) {
return _.preq.start.then(this.createEntity.bind(this)).then(this.showItemCreationForm.bind(this, transaction))["catch"](forms_.catchAlert.bind(null, this));
},
createEntity: function() {
var entityData;
this.updateModel('title');
this.updateModel('authors');
this.updateModel('isbn');
entityData = this.normalizeEntityData();
return app.request('create:entity', entityData);
},
normalizeEntityData: function() {
var authors, entity, entityData, isbn, pictures, title;
entityData = this.model.toJSON();
entityDataTests(entityData);
title = entityData.title, authors = entityData.authors, isbn = entityData.isbn, pictures = entityData.pictures;
if (authors.trim() === '') {
authors = null;
}
if (isbn.trim() === '') {
isbn = null;
}
entity = {
title: title.trim(),
authors: authors != null ? authors.split(',').map(function(str) {
return str.trim();
}) : void 0,
pictures: pictures
};
if (isbn != null) {
entity.isbn = books_.normalizeIsbn(isbn);
}
return _.log(entity, 'entity?');
},
showItemCreationForm: function(transaction, entityModel) {
return app.execute('show:item:creation:form', {
entity: entityModel,
transaction: transaction
});
},
showEntityActions: function() {
return this.entityActions.show(new EntityActions({
model: this.model
}));
}
});
});
;require.register("modules/entities/views/entity_data", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
template: require('./templates/entity_data'),
className: 'entityData',
initialize: function(options) {
this.lazyRender = _.LazyRender(this);
this.listenTo(this.model, 'change', this.lazyRender);
this.hidePicture = options.hidePicture;
if (!this.hidePicture) {
return this.listenTo(this.model, 'add:pictures', this.lazyRender);
}
},
serializeData: function() {
var attrs;
attrs = this.model.toJSON();
attrs = this.setDescriptionAttributes(attrs);
attrs.entityPage = this.options.entityPage;
attrs.hidePicture = this.hidePicture;
return attrs;
},
ui: {
description: '.description',
togglers: '.toggler i'
},
behaviors: {
PreventDefault: {},
PlainTextAuthorLink: {}
},
onRender: function() {
return app.execute('qlabel:update');
},
events: {
'click .toggler': 'toggleDescLength'
},
toggleDescLength: function() {
this.ui.description.toggleClass('clamped');
return this.ui.togglers.toggleClass('hidden');
},
setDescriptionAttributes: function(attrs) {
if (attrs.extract != null) {
attrs.description = attrs.extract;
}
if (attrs.description != null) {
attrs.descOverflow = attrs.description.length > 400;
}
return attrs;
}
});
});
;require.register("modules/entities/views/entity_show", function(exports, require, module) {
var EntityActions, EntityData, ItemsList, backMessage, fetchPublicItems, showItems, spreadPublicData, wikiBarPlugin;
EntityData = require('./entity_data');
EntityActions = require('./entity_actions');
wikiBarPlugin = require('modules/general/plugins/wiki_bar');
ItemsList = require('modules/inventory/views/items_list');
module.exports = Marionette.LayoutView.extend({
template: require('./templates/entity_show'),
regions: {
entityData: '#entityData',
entityActions: '#entityActions',
localItems: '#localItems',
publicItems: '#publicItems'
},
serializeData: function() {
return _.extend(this.model.toJSON(), {
back: backMessage(),
canRefreshData: true
});
},
initialize: function() {
this.initPlugins();
this.uri = this.model.get('uri');
fetchPublicItems(this.uri);
return app.execute('metadata:update:needed');
},
initPlugins: function() {
return wikiBarPlugin.call(this);
},
onShow: function() {
this.showEntityData();
app.request('waitForUserData').then(this.showEntityActions.bind(this));
if (app.user.loggedIn) {
this.showLocalItems();
}
this.showPublicItems();
return this.model.updateMetadata()["finally"](app.execute.bind(app, 'metadata:update:done'));
},
events: {
'click a.showWikipediaPreview': 'toggleWikipediaPreview',
'click #toggleWikiediaPreview': 'toggleWikiediaPreview',
'click .refreshData': 'refreshData'
},
showEntityData: function() {
return this.entityData.show(new EntityData({
model: this.model,
entityPage: true
}));
},
showEntityActions: function() {
return this.entityActions.show(new EntityActions({
model: this.model
}));
},
showLocalItems: function() {
return showItems(Items.network, this.localItems, this.uri);
},
showPublicItems: function() {
return showItems(Items["public"], this.publicItems, this.uri);
},
toggleWikipediaPreview: function() {
return this.$el.trigger('toggleWikiIframe', this);
},
refreshData: function() {
return app.execute('show:entity:refresh', this.model);
}
});
showItems = function(baseCollection, region, uri) {
var items;
items = baseCollection.filtered.resetFilters().filteredByEntityUri(uri);
return region.show(new ItemsList({
collection: items
}));
};
backMessage = function() {
if (_.lastRouteMatch(/search\?/)) {
return {
message: _.i18n('back to search results')
};
}
};
fetchPublicItems = function(uri) {
return app.request('get:entity:public:items', uri).then(_.Log('public items')).then(spreadPublicData)["catch"](_.Error('fetchPublicItems'));
};
spreadPublicData = function(data) {
app.execute('users:public:add', data.users);
return Items["public"].add(data.items);
};
});
;require.register("modules/entities/views/genre_data", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
className: 'genreData',
template: require('./templates/genre_data'),
initialize: function() {
return this.listenTo(this.model, 'change', this.render.bind(this));
}
});
});
;require.register("modules/entities/views/genre_layout", function(exports, require, module) {
var Entities, GenreData, ResultsList, behaviorsPlugin, wdGenre_, wd_, wikiBarPlugin;
wd_ = require('lib/wikidata');
wdGenre_ = require('modules/entities/lib/wikidata/genre');
Entities = require('modules/entities/collections/entities');
ResultsList = require('modules/search/views/results_list');
wikiBarPlugin = require('modules/general/plugins/wiki_bar');
behaviorsPlugin = require('modules/general/plugins/behaviors');
GenreData = require('./genre_data');
module.exports = Marionette.LayoutView.extend({
id: 'genreLayout',
template: require('./templates/genre_layout'),
regions: {
genreRegion: '#genre',
authorsRegion: '#authors',
booksRegion: '#books'
},
ui: {
headerBg: '.headerBg'
},
behaviors: {
Loading: {}
},
initialize: function() {
this.initPlugins();
this.initCollections();
this.fetchBooksAndAuthors();
return this.fetchAndSetHeaderBackground();
},
initPlugins: function() {
wikiBarPlugin.call(this);
return _.extend(this, behaviorsPlugin);
},
initCollections: function() {
this.books = new Entities;
return this.authors = new Entities;
},
fetchBooksAndAuthors: function() {
return wdGenre_.fetchBooksAndAuthors(this.model).then(wdGenre_.spreadBooksAndAuthors.bind(null, this.books, this.authors))["catch"](_.Error('fetchBooksAndAuthors')).then(this.stopLoading.bind(this)).then(this.fetchAndSetHeaderBackground.bind(this)).then(this.blockLoader.bind(this));
},
blockLoader: function() {
return this._dataFetched = true;
},
fetchAndSetHeaderBackground: function() {
var wmCommonsFile;
if (!this._headerBackgroundSet) {
wmCommonsFile = this.findPicture();
if (wmCommonsFile != null) {
this._headerBackgroundSet = true;
return wd_.wmCommonsThumb(wmCommonsFile, window.screen.width).then(this.setHeaderBackground.bind(this))["catch"](_.Error('fetchAndSetHeaderBackground'));
}
}
},
findPicture: function() {
return this.findModelFirstPicture() || this.findEntitiesFirstPicture();
},
findModelFirstPicture: function() {
var ref;
return (ref = this.model.get('claims.P18')) != null ? ref[0] : void 0;
},
findEntitiesFirstPicture: function() {
var images;
if (this.books != null) {
images = this.books.map(function(entity) {
var pics;
pics = entity.get('claims.P18');
return pics != null ? pics[0] : void 0;
});
return _.compact(images)[0];
}
},
setHeaderBackground: function(url) {
this.headerBgUrl = url;
if (this.isRendered) {
return this.showHeaderBackground();
}
},
onRender: function() {
if (!this._dataFetched) {
this.startLoading();
}
this.showHeaderBackground();
this.showGenreData();
return this.showResults();
},
showHeaderBackground: function() {
if (this.headerBgUrl != null) {
this.ui.headerBg.css('background-image', "url(" + this.headerBgUrl + ")");
return this.$el.addClass('with-bg-image');
}
},
showGenreData: function() {
return this.genreRegion.show(new GenreData({
model: this.model
}));
},
showResults: function() {
var collection, i, len, ref, region, results, type;
ref = ['authors', 'books'];
results = [];
for (i = 0, len = ref.length; i < len; i++) {
type = ref[i];
collection = this[type];
region = this[type + "Region"];
results.push(region.show(new ResultsList({
collection: collection,
type: type,
hideIfEmpty: true
})));
}
return results;
}
});
});
;require.register("modules/entities/views/templates/article_li", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div>\n <img src='"
+ alias3((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,(depth0 != null ? depth0.pictures : depth0),150,{"name":"src","hash":{},"data":data}))
+ "' alt='"
+ alias3(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
+ "'>\n</div>\n";
},"3":function(container,depth0,helpers,partials,data) {
return " "
+ container.escapeExpression((helpers.iconLinkText || (depth0 && depth0.iconLinkText) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"link",(depth0 != null ? depth0.href : depth0),(depth0 != null ? depth0.title : depth0),{"name":"iconLinkText","hash":{},"data":data}))
+ "\n";
},"5":function(container,depth0,helpers,partials,data) {
var helper;
return " "
+ container.escapeExpression(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"title","hash":{},"data":data}) : helper)))
+ "\n";
},"7":function(container,depth0,helpers,partials,data) {
return " <span class=\"date\">\n ("
+ container.escapeExpression((helpers.timeClaim || (depth0 && depth0.timeClaim) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.claims : depth0),"P577","year",true,true,{"name":"timeClaim","hash":{},"data":data}))
+ " ) \n </span>\n";
},"9":function(container,depth0,helpers,partials,data) {
var stack1, helper;
return " <p class=\"grey\">"
+ ((stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"description","hash":{},"data":data}) : helper))) != null ? stack1 : "")
+ "</p>\n";
},"11":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression, alias2=depth0 != null ? depth0 : {}, alias3=helpers.helperMissing;
return " <a href=\""
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.wikisource : depth0)) != null ? stack1.url : stack1), depth0))
+ "\" target=\"_blank\" title=\""
+ alias1((helpers.I18n || (depth0 && depth0.I18n) || alias3).call(alias2,"read online",{"name":"I18n","hash":{},"data":data}))
+ "\">\n "
+ alias1((helpers.icon || (depth0 && depth0.icon) || alias3).call(alias2,"wikisource",{"name":"icon","hash":{},"data":data}))
+ "\n </a>\n";
},"13":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression, alias2=depth0 != null ? depth0 : {}, alias3=helpers.helperMissing;
return " <a href=\""
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.wikipedia : depth0)) != null ? stack1.url : stack1), depth0))
+ "\" target=\"_blank\" title=\""
+ alias1((helpers.I18n || (depth0 && depth0.I18n) || alias3).call(alias2,"see on Wikipedia",{"name":"I18n","hash":{},"data":data}))
+ "\">\n "
+ alias1((helpers.icon || (depth0 && depth0.icon) || alias3).call(alias2,"wikipedia",{"name":"icon","hash":{},"data":data}))
+ "\n </a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.pictures : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "<div class=\"main\">\n <h4>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.href : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.program(5, data, 0),"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.hasDate : depth0),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </h4>\n\n\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.description : depth0),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n <p>\n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P50",true,false,true,{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.stringClaim || (depth0 && depth0.stringClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P2093",true,true,true,{"name":"stringClaim","hash":{},"data":data}))
+ " \n </p>\n\n</div>\n<div class=\"right-bar\">\n <span class=\"fa fa-file-text-o\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"article_limitation",{"name":"i18n","hash":{},"data":data}))
+ "\"></span>\n <div class=\"sitelinks\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"entities:edit_wikidata",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.wikisource : depth0),{"name":"if","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.wikipedia : depth0),{"name":"if","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/author_claims", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class='wiki-attributes'>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"entities:birth_death_dates",(depth0 != null ? depth0.claims : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"entities:edit_wikidata",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n <p class=\"claims\">\n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P135",true,{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P136",true,{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P27",{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P103",{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P69",{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P106",{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P166",{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P39",{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P1066",true,{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P737",true,{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P738",true,{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.urlClaim || (depth0 && depth0.urlClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P856",{"name":"urlClaim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.platformClaim || (depth0 && depth0.platformClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P1938",{"name":"platformClaim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.platformClaim || (depth0 && depth0.platformClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P2002",{"name":"platformClaim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.platformClaim || (depth0 && depth0.platformClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P2013",{"name":"platformClaim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.platformClaim || (depth0 && depth0.platformClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P2003",{"name":"platformClaim","hash":{},"data":data}))
+ " \n </p>\n "
+ alias3((helpers.imageClaim || (depth0 && depth0.imageClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P109",{"name":"imageClaim","hash":{},"data":data}))
+ " \n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/author_li", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <img src='"
+ alias3((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,(depth0 != null ? depth0.pictures : depth0),600,{"name":"src","hash":{},"data":data}))
+ "' alt='"
+ alias3(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
+ " cover'>\n";
},"3":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"entities:wikipedia_iframe",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:embedded_welcome",{"name":"partial","hash":{},"data":data}))
+ "\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<div class=\"innerAuthorLi\">\n <div class='infobox'>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.pictures : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " <div class=\"authorData text-center\">\n <h3><a class=\"showEntity\" href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\">"
+ alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
+ "</a></h3>\n <h4 class=\"subheader\">"
+ alias4(((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"description","hash":{},"data":data}) : helper)))
+ "</h4>\n "
+ alias4((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"entities:author_claims",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n <p class=\"extract\">"
+ ((stack1 = ((helper = (helper = helpers.extract || (depth0 != null ? depth0.extract : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"extract","hash":{},"data":data}) : helper))) != null ? stack1 : "")
+ "</p>\n "
+ alias4((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"entities:photo_credits",(depth0 != null ? depth0.pictureCredits : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n </div>\n\n <div class=\"works\">\n <div class='books'></div>\n <div class='articles'></div>\n </div>\n</div>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.standalone : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/birth_death_dates", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " \n<p>\n "
+ alias3((helpers.timeClaim || (depth0 && depth0.timeClaim) || alias2).call(alias1,depth0,"P569","year",true,true,{"name":"timeClaim","hash":{},"data":data}))
+ "\n &nbsp;&nbsp;-&nbsp;&nbsp;\n "
+ alias3((helpers.timeClaim || (depth0 && depth0.timeClaim) || alias2).call(alias1,depth0,"P570","year",true,{"name":"timeClaim","hash":{},"data":data}))
+ "\n</p>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.P569 : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/book_claims", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"entities:edit_wikidata",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n<div class='wiki-attributes'>\n <p class=\"claims\">\n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P1680",{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.stringClaim || (depth0 && depth0.stringClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P1476",{"name":"stringClaim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P364",{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P50",true,null,true,{"name":"claim","hash":{},"data":data}))
+ " \n "
+ ((stack1 = (helpers.joinAuthors || (depth0 && depth0.joinAuthors) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.claims : depth0)) != null ? stack1.P2093 : stack1),{"name":"joinAuthors","hash":{},"data":data})) != null ? stack1 : "")
+ "<br> \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P110",true,{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.timeClaim || (depth0 && depth0.timeClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P577",{"name":"timeClaim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P155",true,{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P156",true,{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P136",true,{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P135",{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P921",{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P840",{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P674",{"name":"claim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.urlClaim || (depth0 && depth0.urlClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P856",{"name":"urlClaim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.urlClaim || (depth0 && depth0.urlClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P953",{"name":"urlClaim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.platformClaim || (depth0 && depth0.platformClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P2034",{"name":"platformClaim","hash":{},"data":data}))
+ " \n "
+ alias3((helpers.platformClaim || (depth0 && depth0.platformClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P2002",{"name":"platformClaim","hash":{},"data":data}))
+ " \n </p>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/book_li", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <a class=\"zoom-button\">\n <img src=\""
+ alias3((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,(depth0 != null ? depth0.pictures : depth0),200,400,{"name":"src","hash":{},"data":data}))
+ "\"\n data-zoom-toggle=\""
+ alias3((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,(depth0 != null ? depth0.pictures : depth0),500,1000,{"name":"src","hash":{},"data":data}))
+ "\"\n alt='"
+ alias3(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
+ " cover'>\n <span class=\"buttons\">\n <span>"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"search-plus",{"name":"icon","hash":{},"data":data}))
+ "</span>\n <span class=\"hidden\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"search-minus",{"name":"icon","hash":{},"data":data}))
+ "</span>\n </span>\n </a>\n";
},"3":function(container,depth0,helpers,partials,data) {
var stack1, helper;
return " <p class=\"clamped grey\">"
+ ((stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"description","hash":{},"data":data}) : helper))) != null ? stack1 : "")
+ "</p>\n";
},"5":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <p>\n "
+ alias3((helpers.claim || (depth0 && depth0.claim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P50",true,{"name":"claim","hash":{},"data":data}))
+ " \n </p>\n <p class=\"date\">\n "
+ alias3((helpers.timeClaim || (depth0 && depth0.timeClaim) || alias2).call(alias1,(depth0 != null ? depth0.claims : depth0),"P577","year",true,{"name":"timeClaim","hash":{},"data":data}))
+ " \n </p>\n";
},"7":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing;
return " <p class=\"isbn-attributes\">\n "
+ ((stack1 = (helpers.P || (depth0 && depth0.P) || alias2).call(alias1,"50",{"name":"P","hash":{},"data":data})) != null ? stack1 : "")
+ " "
+ ((stack1 = (helpers.joinAuthors || (depth0 && depth0.joinAuthors) || alias2).call(alias1,(depth0 != null ? depth0.authors : depth0),{"name":"joinAuthors","hash":{},"data":data})) != null ? stack1 : "")
+ " <br>\n </p>\n";
},"9":function(container,depth0,helpers,partials,data) {
return "highlight";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<div class=\"bookCover\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.pictures : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>\n<div class=\"bookLiData\">\n <h3><a class='showEntity' href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\">"
+ alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
+ "</a></h3>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.description : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.wikidata : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.program(7, data, 0),"data":data})) != null ? stack1 : "")
+ "</div>\n\n<div class='actions'>\n <a class='showEntity' href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\">\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"chevron-right",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias4((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"more details",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n <a class='addToInventory' href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "/add\" rel=\"nofollow\">\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"plus",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias4((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"add to my inventory",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n <div class=\"counters\">\n <a class='showEntity counter "
+ ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.counter : depth0)) != null ? stack1.highlight : stack1),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "' href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\">\n <span class=\"count\">"
+ alias4(container.lambda(((stack1 = (depth0 != null ? depth0.counter : depth0)) != null ? stack1.count : stack1), depth0))
+ "</span>\n </a>\n "
+ alias4((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"network_counter_label",{"name":"i18n","hash":{},"data":data}))
+ "\n </div>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/edit_wikidata", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return "class=\"editWikidata\"";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression, alias2=depth0 != null ? depth0 : {}, alias3=helpers.helperMissing;
return "<a href=\""
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.wikidata : depth0)) != null ? stack1.wiki : stack1), depth0))
+ "\" "
+ ((stack1 = helpers.unless.call(alias2,((stack1 = (depth0 != null ? depth0.wikidata : depth0)) != null ? stack1.customStyle : stack1),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " title=\""
+ alias1((helpers.i18n || (depth0 && depth0.i18n) || alias3).call(alias2,"edit data on Wikidata",{"name":"i18n","hash":{},"data":data}))
+ "\" target=\"_blank\">"
+ alias1((helpers.icon || (depth0 && depth0.icon) || alias3).call(alias2,"pencil",{"name":"icon","hash":{},"data":data}))
+ "</a>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/entity_actions", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1;
return " <p class=\"hasAnInstance\">\n "
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"item_existing_instances",(depth0 != null ? depth0.instances : depth0),{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "\n </p>\n";
},"3":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <li><a id=\""
+ alias3(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
+ "\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,(depth0 != null ? depth0.icon : depth0),{"name":"icon","hash":{},"data":data}))
+ " <span>"
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,(depth0 != null ? depth0.label : depth0),{"name":"I18n","hash":{},"data":data}))
+ "</span></a></li>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.mainUserHasOne : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "<div class=\"entityAction\">\n <div class=\"custom-button-group\">\n <a id='addToInventory' class=\"has-tip button success bold\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"add it to my inventory",{"name":"i18n","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"plus",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"add it to my inventory",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n <a class=\"button success\" data-options=\"is_hover:true\" data-dropdown=\"have\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"chevron-down",{"name":"icon","hash":{},"data":data}))
+ "</a>\n <ul id=\"have\" class=\"small f-dropdown\" data-dropdown-content>\n <li class=\"dropdownLegend\">\n <label>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"I have it and it is available for:",{"name":"i18n","hash":{},"data":data}))
+ "</label>\n </li>\n"
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.transactions : depth0),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </ul>\n </div>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/entity_create", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return " <img src=\""
+ container.escapeExpression((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},depth0,300,{"name":"src","hash":{},"data":data}))
+ "\">\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<form class=\"entityCreateForm\">\n <div class=\"fields\">\n <h3>"
+ alias3(((helper = (helper = helpers.header || (depth0 != null ? depth0.header : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"header","hash":{},"data":data}) : helper)))
+ "</h3>\n <h4>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"title",{"name":"i18n","hash":{},"data":data}))
+ " "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"entities:needed",{"name":"partial","hash":{},"data":data}))
+ "</h4>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"text_field",(depth0 != null ? depth0.titleField : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n\n <h4>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"P50",{"name":"i18n","hash":{},"data":data}))
+ " "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"entities:needed",{"name":"partial","hash":{},"data":data}))
+ "</h4>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"text_field",(depth0 != null ? depth0.authorsField : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n\n <h4>ISBN</h4>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"text_field",(depth0 != null ? depth0.isbnField : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n <div class=\"pics\">\n <div class=\"pictures\">\n"
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.pictures : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n <a id=\"addPicture\" class=\"button\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"camera",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"add a picture",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n </div>\n</form>\n\n<div id=\"entityActions\"></div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/entity_data", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.pictures : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"2":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <div class=\"cover\">\n <img src=\""
+ alias3((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,(depth0 != null ? depth0.pictures : depth0),300,{"name":"src","hash":{},"data":data}))
+ "\" alt=\""
+ alias3(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
+ " "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"cover",{"name":"i18n","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"entities:photo_credits",(depth0 != null ? depth0.pictureCredits : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n";
},"4":function(container,depth0,helpers,partials,data) {
var helper;
return " <h2>"
+ container.escapeExpression(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"title","hash":{},"data":data}) : helper)))
+ "</h2>\n";
},"6":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <h2><a href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\" class=\"showEntity\">"
+ alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
+ "</a></h2>\n";
},"8":function(container,depth0,helpers,partials,data) {
return "clamped";
},"10":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <a class='toggler'>\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"chevron-down",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"chevron-up","hidden",{"name":"icon","hash":{},"data":data}))
+ "\n </a>\n";
},"12":function(container,depth0,helpers,partials,data) {
return " "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"entities:book_claims",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n";
},"14":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {};
return " <p class=\"isbn-attributes\">\n "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.authors : depth0),{"name":"if","hash":{},"fn":container.program(15, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.publishedDate : depth0),{"name":"if","hash":{},"fn":container.program(17, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.publisher : depth0),{"name":"if","hash":{},"fn":container.program(19, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.pageCount : depth0),{"name":"if","hash":{},"fn":container.program(21, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n </p>\n";
},"15":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing;
return " "
+ ((stack1 = (helpers.P || (depth0 && depth0.P) || alias2).call(alias1,"50",{"name":"P","hash":{},"data":data})) != null ? stack1 : "")
+ " "
+ ((stack1 = (helpers.joinAuthors || (depth0 && depth0.joinAuthors) || alias2).call(alias1,(depth0 != null ? depth0.authors : depth0),{"name":"joinAuthors","hash":{},"data":data})) != null ? stack1 : "")
+ " <br> ";
},"17":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing;
return ((stack1 = (helpers.P || (depth0 && depth0.P) || alias2).call(alias1,"P577",{"name":"P","hash":{},"data":data})) != null ? stack1 : "")
+ " "
+ container.escapeExpression((helpers.dateYear || (depth0 && depth0.dateYear) || alias2).call(alias1,(depth0 != null ? depth0.publishedDate : depth0),{"name":"dateYear","hash":{},"data":data}))
+ " <br> ";
},"19":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<span>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"publisher",{"name":"i18n","hash":{},"data":data}))
+ ":</span>"
+ alias3(((helper = (helper = helpers.publisher || (depth0 != null ? depth0.publisher : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"publisher","hash":{},"data":data}) : helper)))
+ " <br> ";
},"21":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<span>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"pages",{"name":"i18n","hash":{},"data":data}))
+ ":</span>"
+ alias3(((helper = (helper = helpers.pageCount || (depth0 != null ? depth0.pageCount : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"pageCount","hash":{},"data":data}) : helper)))
+ " <br> ";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function";
return ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.hidePicture : depth0),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n<div class=\"data\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.entityPage : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.program(6, data, 0),"data":data})) != null ? stack1 : "")
+ " <p class=\"uri\">"
+ container.escapeExpression(((helper = (helper = helpers.uri || (depth0 != null ? depth0.uri : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"uri","hash":{},"data":data}) : helper)))
+ "</p>\n\n <p class=\"description "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.descOverflow : depth0),{"name":"if","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\">\n "
+ ((stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"description","hash":{},"data":data}) : helper))) != null ? stack1 : "")
+ "\n </p>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.descOverflow : depth0),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " <div class=\"attributes\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.wikidata : depth0),{"name":"if","hash":{},"fn":container.program(12, data, 0),"inverse":container.program(14, data, 0),"data":data})) != null ? stack1 : "")
+ " </div>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/entity_show", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return " "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"back",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n";
},"3":function(container,depth0,helpers,partials,data) {
return " "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"entities:wikipedia_iframe",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<section class=\"entityShow custom-column\">\n <p class=\"back\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.back : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </p>\n <div class='dark-panel'>\n <div id=\"entityData\"></div>\n <div id=\"entityActions\"></div>\n <div class='check'></div>\n </div>\n\n <div class=\"allItems\">\n <h3 class=\"subheader publicHeader\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"your friends' and groups' books",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n <div id=\"localItems\" class=\"items\"></div>\n <h3 class=\"subheader publicHeader\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"public books",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n <div id=\"publicItems\" class=\"items\"></div>\n </div>\n\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.wikidata : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</section>\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:embedded_welcome",{"name":"partial","hash":{},"data":data}))
+ "\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/genre_data", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function";
return "<h2 class=\"title\">"
+ container.escapeExpression(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
+ "</h2>\n<p class=\"extract\">"
+ ((stack1 = ((helper = (helper = helpers.extract || (depth0 != null ? depth0.extract : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"extract","hash":{},"data":data}) : helper))) != null ? stack1 : "")
+ "</p>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/genre_layout", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<div class=\"restBg\"></div>\n<div class=\"headerBg\"></div>\n<section id=\"genre\"></section>\n<span class=\"loading\"></span>\n<section id=\"authors\"></section>\n<section id=\"books\"></section>\n"
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"entities:wikipedia_iframe",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/needed", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<span class=\"needed\">("
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"needed",{"name":"i18n","hash":{},"data":data}))
+ ")</span>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/photo_credits", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"photo credits:",{"name":"i18n","hash":{},"data":data}))
+ " "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,(depth0 != null ? depth0.text : depth0),(depth0 != null ? depth0.url : depth0),"link",{"name":"link","hash":{},"data":data}))
+ "\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return "<p class=\"photo-credits\">\n"
+ ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.text : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</p>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/wikipedia_iframe", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <div class=\"wikipediaPreviewToggler\">\n <a class=\"showWikipediaPreview\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"on_wikipedia",depth0,{"name":"i18n","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"chevron-down",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"chevron-up","hidden",{"name":"icon","hash":{},"data":data}))
+ "\n </a>\n </div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {};
return "<div class=\"wikipedia-iframe\">\n <div class=\"wiki-menu-bar\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.wikipedia : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(alias1,"wiki_sitelinks",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/templates/works_list", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <a class=\"displayMore\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"chevron-down",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"more",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {};
return "<div class=\"header\">\n <h3>"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(alias1,(depth0 != null ? depth0.title : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</h3><span class=\"counter\"></span>\n</div>\n<ul class=\"container\"></ul>\n<div class=\"more\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.more : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " <span class=\"loading\"></span>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/entities/views/works_list", function(exports, require, module) {
var paginationPlugin, strings;
paginationPlugin = require('modules/general/plugins/pagination');
module.exports = Marionette.CompositeView.extend({
template: require('./templates/works_list'),
behaviors: {
Loading: {}
},
childViewContainer: '.container',
getChildView: function() {
if (this.options.type === 'articles') {
return require('./article_li');
} else {
return require('./book_li');
}
},
emptyView: require('modules/inventory/views/no_item'),
ui: {
counter: '.counter'
},
initialize: function() {
this.initPlugins();
this.collection = this.options.collection;
return this.initBookCounter();
},
initPlugins: function() {
return paginationPlugin.call(this, {
batchLength: 15,
initialLength: this.options.initialLength || 5
});
},
initBookCounter: function() {
this.lazyUpdateBookCounter = _.debounce(this.updateBookCounter.bind(this), 1000);
return this.listenTo(this.collection, 'add remove', this.lazyUpdateBookCounter);
},
events: {
'click a.displayMore': 'displayMore'
},
collectionEvents: {
'add': 'lazyRender'
},
serializeData: function() {
return _.extend({}, strings[this.options.type], {
more: this.more(),
canRefreshData: true
});
},
onRender: function() {
return this.lazyUpdateBookCounter();
},
updateBookCounter: function() {
var base, count;
count = this.collection.length;
return typeof (base = this.ui.counter).text === "function" ? base.text(count).hide().slideDown() : void 0;
}
});
strings = {
books: {
title: 'books'
},
articles: {
title: 'articles'
}
};
});
;require.register("modules/general/behaviors/alertbox", function(exports, require, module) {
module.exports = Marionette.Behavior.extend({
ui: {
hasAlertbox: ".has-alertbox"
},
events: {
'alert': 'showAlertBox',
'hideAlertBox': 'hideAlertBox',
'keydown': 'hideAlertBox',
'click a.close': 'hideAlertBox',
'click .button': 'hideAlertBox'
},
showAlertBox: function(e, params) {
var $parent, $target, box, message, selector;
message = params.message, selector = params.selector;
if (message == null) {
_.error(params, 'couldnt display the alertbox with those params');
return;
}
if (selector != null) {
if (!/\.|#/.test(selector)) {
_.error(selector, 'invalid selector');
}
$target = $(selector);
} else {
$target = this.ui.hasAlertbox;
}
box = "<div class='alert hidden alert-box'>" + message + " <a class='close'>&times;</a> </div>";
$parent = $target.parent();
$parent.find('.alert-box').remove();
$parent.append(box);
$parent.find('.alert-box').slideDown(500);
return this._showAlertTimestamp = _.now();
},
hideAlertBox: function() {
if (!((this._showAlertTimestamp != null) && !_.expired(this._showAlertTimestamp, 1000))) {
return this.$el.find('.alert-box').hide();
}
}
});
});
;require.register("modules/general/behaviors/backup_form", function(exports, require, module) {
var buildIdSelector, buildNameSelector, customRecover;
module.exports = Marionette.Behavior.extend({
events: {
'change input, textarea': 'backup'
},
initialize: function() {
return this._backup = {
byId: {},
byName: {}
};
},
backup: function(e) {
var id, name, ref, type, value;
ref = e.currentTarget, id = ref.id, value = ref.value, type = ref.type, name = ref.name;
if (!_.isNonEmptyString(value)) {
return;
}
if (!(type === 'text' || type === 'textarea')) {
return;
}
if (_.isNonEmptyString(id)) {
return this._backup.byId[id] = value;
} else if (_.isNonEmptyString(name)) {
return this._backup.byName[name] = value;
}
},
recover: function() {
_.log(this._backup, 'recovering form data');
customRecover(this.$el, this._backup.byId, buildIdSelector);
return customRecover(this.$el, this._backup.byName, buildNameSelector);
},
onRender: function() {
return this.recover();
}
});
customRecover = function($el, store, selectorBuilder) {
var key, results, selector, value;
results = [];
for (key in store) {
value = store[key];
_.log(value, key);
selector = selectorBuilder(key);
results.push($el.find(selector).val(value));
}
return results;
};
buildIdSelector = function(id) {
return "#" + id;
};
buildNameSelector = function(name) {
return "[name='" + name + "']";
};
});
;require.register("modules/general/behaviors/base", function(exports, require, module) {
module.exports = {
initialize: function() {
return Marionette.Behaviors.behaviorsLookup = function() {
return app.Behaviors;
};
},
General: require('./general'),
AlertBox: require('./alertbox'),
ConfirmationModal: require('./confirmation_modal'),
Loading: require('./loading'),
SuccessCheck: require('./success_check'),
TogglePassword: require('./toggle_password'),
PreventDefault: require('./prevent_default'),
ElasticTextarea: require('./elastic_textarea'),
BackupForm: require('./backup_form'),
LocalSeachBar: require('./local_seach_bar'),
PlainTextAuthorLink: require('./plain_text_author_link'),
Unselect: require('./unselect')
};
});
;require.register("modules/general/behaviors/confirmation_modal", function(exports, require, module) {
var ConfirmationModal;
ConfirmationModal = require('../views/behaviors/confirmation_modal');
module.exports = Marionette.Behavior.extend({
events: {
'askConfirmation': 'askConfirmation'
},
askConfirmation: function(e, options) {
return app.layout.modal.show(new ConfirmationModal(options));
}
});
});
;require.register("modules/general/behaviors/elastic_textarea", function(exports, require, module) {
module.exports = Marionette.Behavior.extend({
ui: {
textarea: "textarea"
},
onRender: function() {
return autosize(this.ui.textarea);
}
});
});
;require.register("modules/general/behaviors/general", function(exports, require, module) {
var enterClick, moveCaretToEnd;
moveCaretToEnd = require('modules/general/lib/move_caret_to_end');
enterClick = require('modules/general/lib/enter_click');
module.exports = Marionette.Behavior.extend({
events: {
'submit form': function(e) {
return e.preventDefault();
},
'focus textarea': moveCaretToEnd,
'keyup input.enterClick': enterClick.input,
'keyup textarea.ctrlEnterClick': enterClick.textarea,
'keyup a.button': enterClick.button,
'click a.back': function() {
return window.history.back();
},
'click #home, .showHome': function() {
return app.execute('show:home');
},
'click .showWelcome': function() {
return app.execute('show:welcome');
},
'click .showLogin': function() {
return app.execute('show:login');
},
'click .showInventory': function() {
return app.execute('show:inventory');
}
}
});
});
;require.register("modules/general/behaviors/loading", function(exports, require, module) {
module.exports = Marionette.Behavior.extend({
ui: {
loading: '.loading, .check'
},
events: {
'loading': 'showSpinningLoader',
'stopLoading': 'hideSpinningLoader',
'somethingWentWrong': 'somethingWentWrong'
},
showSpinningLoader: function(e, params) {
var body, cb, mes, timeout;
this.$target = this.getTarget(params);
body = _.icon('circle-o-notch', 'fa-spin');
if ((params != null ? params.message : void 0) != null) {
mes = params.message;
body += "<p class='grey'>" + mes + "</p>";
}
this.$target.html(body);
timeout = (params != null ? params.timeout : void 0) || 16;
if (timeout !== 'none') {
cb = this.somethingWentWrong.bind(this, null, params);
return setTimeout(cb, timeout * 1000);
}
},
hideSpinningLoader: function(e, params) {
this.$target || (this.$target = this.getTarget(params));
this.$target.empty();
return this.hidden = true;
},
somethingWentWrong: function(e, params) {
var body, oups;
if (!this.hidden) {
this.$target || (this.$target = this.getTarget(params));
oups = _.i18n('Something went wrong :(');
body = _.icon('bolt') + ("<p> " + oups + "</p>");
return this.$target.html(body);
}
},
getTarget: function(params) {
if ((params != null ? params.selector : void 0) != null) {
return $(params.selector).find('.loading');
} else {
return this.ui.loading;
}
}
});
});
;require.register("modules/general/behaviors/local_seach_bar", function(exports, require, module) {
module.exports = Marionette.Behavior.extend({
ui: {
localSearchField: '#localSearchField'
},
events: {
'click a#localSearchButton': 'search',
'inview #localSearchGroup': 'toggleGlobalSearchBar'
},
onShow: function() {
return this.updateSearchBar();
},
search: function() {
app.execute('search:global', this.ui.localSearchField.val());
return app.execute('last:add:mode:set', 'search');
},
updateSearchBar: function() {
return this.ui.localSearchField.val(this.view.query);
},
toggleGlobalSearchBar: function(e, isInView) {
if (isInView) {
return app.vent.trigger('search:global:hide');
} else {
return app.vent.trigger('search:global:show', this.ui.localSearchField.val());
}
}
});
});
;require.register("modules/general/behaviors/plain_text_author_link", function(exports, require, module) {
module.exports = Marionette.Behavior.extend({
events: {
'click .searchAuthor': 'searchAuthor'
},
searchAuthor: function(e) {
var author;
author = e.target.firstChild.textContent;
if (!_.isOpenedOutside(e)) {
return app.execute('search:global', author);
}
}
});
});
;require.register("modules/general/behaviors/prevent_default", function(exports, require, module) {
var smartPreventDefault;
smartPreventDefault = require('modules/general/lib/smart_prevent_default');
module.exports = Marionette.Behavior.extend({
events: {
'click a': 'smartPreventDefault'
},
smartPreventDefault: smartPreventDefault
});
});
;require.register("modules/general/behaviors/success_check", function(exports, require, module) {
module.exports = Marionette.Behavior.extend({
events: {
'check': 'showSuccessCheck',
'fail': 'showFail'
},
showSuccessCheck: function(e, cb) {
return this.showSignal(e, cb, 'check-circle');
},
showFail: function(e, cb) {
return this.showSignal(e, cb, 'times-circle');
},
showSignal: function(e, cb, signal) {
var $check, $wrapper, afterTimeout;
$wrapper = $(e.target).parents('.checkWrapper');
if ($wrapper.length === 1) {
$check = $wrapper.find('.check');
} else {
$check = $(e.target).find('.check');
}
if ($check.length !== 1) {
return _.warn('.check target not found');
}
$check.hide().html(_.icon(signal, 'text-center')).slideDown(300);
afterTimeout = function() {
$check.slideUp();
if (cb != null) {
return cb();
}
};
return setTimeout(afterTimeout, 600);
}
});
});
;require.register("modules/general/behaviors/toggle_password", function(exports, require, module) {
module.exports = Marionette.Behavior.extend({
ui: {
showPassword: '.showPassword'
},
initialize: function() {
return this.passwordShown = false;
},
events: {
'click .showPassword': 'togglePassword'
},
togglePassword: function() {
if (this.passwordShown) {
return this.passwordType('password');
} else {
return this.passwordType('text');
}
},
passwordType: function(type) {
var el;
el = this.view.ui.passwords || this.view.ui.password;
el.attr('type', type);
this.ui.showPassword.toggleClass('toggled');
return this.passwordShown = !this.passwordShown;
}
});
});
;require.register("modules/general/behaviors/unselect", function(exports, require, module) {
module.exports = Marionette.Behavior.extend({
events: {
'click .unselect': 'unselect'
},
unselect: function() {
return app.execute('show:inventory:general');
}
});
});
;require.register("modules/general/collections/imgs", function(exports, require, module) {
module.exports = Backbone.Collection.extend({
model: require('../models/img')
});
});
;require.register("modules/general/lib/active_langs", function(exports, require, module) {
var alternateLangs, territorialize;
territorialize = {
de: 'de_DE',
es: 'es_ES',
fr: 'fr_FR',
pl: 'pl_PL',
sv: 'sv_SE'
};
alternateLangs = Object.keys(territorialize);
territorialize.en = 'en_US';
module.exports = {
alternateLangs: alternateLangs,
territorialize: territorialize
};
});
;require.register("modules/general/lib/document_lang", function(exports, require, module) {
var alternateLangs, origin, ref, setHreflang, territorialize, updateBodyLang, updateHeadAlternateLangs;
origin = location.origin;
ref = require('./active_langs'), alternateLangs = ref.alternateLangs, territorialize = ref.territorialize;
exports.keepBodyLangUpdated = function() {
updateBodyLang.call(this, app.request('i18n:current'));
return this.listenTo(app.vent, 'i18n:set', updateBodyLang.bind(this));
};
updateBodyLang = function(lang) {
return this.$el.attr('lang', lang);
};
exports.keepHeadAlternateLangsUpdated = function() {
return updateHeadAlternateLangs(null, _.currentRoute());
};
updateHeadAlternateLangs = function(section, route) {
var i, lang, len, results;
setHreflang(route, false, 'en');
results = [];
for (i = 0, len = alternateLangs.length; i < len; i++) {
lang = alternateLangs[i];
results.push(setHreflang(route, true, lang));
}
return results;
};
setHreflang = function(route, withLangQueryString, lang) {
var href;
href = origin + "/" + route;
if (withLangQueryString) {
href = _.setQuerystring(href, 'lang', lang);
}
return $("head link[hreflang='" + lang + "']").attr('href', href);
};
exports.updateOgLocalAlternates = function() {
var i, lang, len, local, otherTerritories, results, territory;
lang = app.request('i18n:current');
local = territorialize[lang];
$('head').append("<meta property='og:locale' content='" + local + "' />");
otherTerritories = _.values(_.omit(territorialize, lang));
results = [];
for (i = 0, len = otherTerritories.length; i < len; i++) {
territory = otherTerritories[i];
results.push($('head').append("<meta property='og:locale:alternate' content='" + territory + "' />"));
}
return results;
};
});
;require.register("modules/general/lib/dynamic_background", function(exports, require, module) {
var coverBgRoots,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
module.exports = function() {
var setBackgroundFromRoute, setCoverBg, setNormalBg;
setCoverBg = this.ui.bg.addClass.bind(this.ui.bg, 'cover');
setNormalBg = this.ui.bg.removeClass.bind(this.ui.bg, 'cover');
setBackgroundFromRoute = function(section) {
if (indexOf.call(coverBgRoots, section) >= 0) {
return setCoverBg();
} else {
return setNormalBg();
}
};
setBackgroundFromRoute(_.currentSection());
app.vent.on('route:change', setBackgroundFromRoute);
return app.commands.setHandlers({
'background:cover': setCoverBg,
'background:normal': setNormalBg
});
};
coverBgRoots = ['login', 'settings', 'signup', 'welcome'];
});
;require.register("modules/general/lib/enter_click", function(exports, require, module) {
var clickTarget;
module.exports = {
input: function(e) {
var row;
if (e.keyCode === 13 && $(e.currentTarget).val().length > 0) {
row = $(e.currentTarget).parents('form, .inputGroup')[0];
return clickTarget($(row).find('.button, .tiny-button, .saveButton'));
}
},
textarea: function(e) {
var $el;
if (e.keyCode === 13 && e.ctrlKey) {
$el = $(e.currentTarget);
if ($el.val().length > 0) {
return clickTarget($el.parents('form').first().find('.sendMessage, .postComment'));
}
}
},
button: function(e) {
if (e.keyCode === 13) {
return $(e.currentTarget).trigger('click');
}
}
};
clickTarget = function($target) {
if ($target.length > 0) {
return $target.trigger('click');
} else {
return _.error('target not found');
}
};
});
;require.register("modules/general/lib/forms", function(exports, require, module) {
var forms_,
slice = [].slice;
module.exports = forms_ = {};
forms_.pass = function(options) {
var err, results, selector, test, tests, value;
value = options.value, tests = options.tests, selector = options.selector;
_.types([value, tests, selector], ['string', 'object', 'string']);
results = [];
for (err in tests) {
test = tests[err];
if (test(value)) {
results.push(forms_.throwError(err, selector, value));
} else {
results.push(void 0);
}
}
return results;
};
forms_.earlyVerify = function(view, e, verificator) {
var ref;
if (((ref = $(e.target)) != null ? ref.val() : void 0) !== '') {
return _.preq.start.then(verificator)["catch"](forms_.catchAlert.bind(null, view));
}
};
forms_.catchAlert = function(view, err) {
if (err.selector != null) {
view.$el.trigger('stopLoading');
return forms_.alert(view, err);
} else {
view.$el.trigger('somethingWentWrong');
return _.error(err, 'catchAlert err');
}
};
forms_.alert = function(view, err) {
var errMessage, ref, selector;
selector = err.selector;
errMessage = ((ref = err.responseJSON) != null ? ref.status_verbose : void 0) || err.message;
_.types([view, err, selector, errMessage], ['object', 'object', 'string', 'string']);
if (/^\d/.test(errMessage)) {
errMessage = 'something went wrong :(';
}
_.log(errMessage, "alert message on " + selector);
return view.$el.trigger('alert', {
message: _.i18n(errMessage),
selector: selector
});
};
forms_.throwError = function() {
var context, err, message, selector;
message = arguments[0], selector = arguments[1], context = 3 <= arguments.length ? slice.call(arguments, 2) : [];
err = new Error(message);
err.selector = selector;
err.context = context;
throw err;
};
});
;require.register("modules/general/lib/head_metadata", function(exports, require, module) {
var applyTransformers, host, metaNodes, metadataUpdate, metadataUpdateDone, metadataUpdateNeeded, possibleFields, transformers, translateMetadata, updateMetadata, updateNodeContent, updateTitle, withTransformers,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
host = require('lib/urls').host;
metadataUpdate = function(key, value) {
var k, results, updates, v;
_.log(arguments, 'metadataUpdate');
updates = _.forceObject(key, value);
results = [];
for (k in updates) {
v = updates[k];
results.push(updateMetadata(k, v));
}
return results;
};
updateMetadata = function(key, value, noCompletion) {
var el, i, len, ref, results;
if (indexOf.call(possibleFields, key) < 0) {
return _.error([key, value], 'invalid metadata data');
}
if (value == null) {
_.warn("missing metadata value: " + key);
return;
}
if (key === 'title') {
app.execute('track:page:view', value);
}
value = applyTransformers(key, value, noCompletion);
ref = metaNodes[key];
results = [];
for (i = 0, len = ref.length; i < len; i++) {
el = ref[i];
results.push(updateNodeContent(value, el));
}
return results;
};
updateNodeContent = function(value, el) {
var attribute, selector;
selector = el.selector, attribute = el.attribute;
attribute || (attribute = 'content');
return document.querySelector(selector)[attribute] = value;
};
updateTitle = function(title, noCompletion) {
return updateMetadata('title', title, noCompletion);
};
metaNodes = {
title: [
{
selector: 'title',
attribute: 'text'
}, {
selector: "[property='og:title']"
}, {
selector: "[name='twitter:title']"
}
],
description: [
{
selector: "[property='og:description']"
}, {
selector: "[name='twitter:description']"
}
],
image: [
{
selector: "[property='og:image']"
}, {
selector: "[name='twitter:image']"
}
],
url: [
{
selector: "[property='og:url']"
}, {
selector: "[rel='canonical']",
attribute: 'href'
}
]
};
applyTransformers = function(key, value, noCompletion) {
if (indexOf.call(withTransformers, key) >= 0) {
return transformers[key](value, noCompletion);
} else {
return value;
}
};
possibleFields = Object.keys(metaNodes);
transformers = {
title: function(value, noCompletion) {
if (noCompletion) {
return value;
} else {
return value + " - Inventaire";
}
},
url: function(canonical) {
return host + canonical;
},
image: function(url) {
return host + app.API.img(url);
}
};
withTransformers = Object.keys(transformers);
metadataUpdateNeeded = function() {
return window.prerenderReady = false;
};
metadataUpdateDone = function() {
return window.prerenderReady = true;
};
translateMetadata = function() {
var tagline;
tagline = _.i18n('your friends and communities are your best library');
return metadataUpdate({
title: "Inventaire - " + tagline,
description: _.I18n('make the inventory of your books and mutualize with your friends and communities into an infinite library!')
});
};
module.exports = function() {
if (app.user.lang !== 'en') {
translateMetadata();
}
return app.commands.setHandlers({
'metadata:update:needed': metadataUpdateNeeded,
'metadata:update': metadataUpdate,
'metadata:update:done': metadataUpdateDone,
'metadata:update:title': updateTitle
});
};
});
;require.register("modules/general/lib/icon_nav", function(exports, require, module) {
var noIconNavRoutes,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
module.exports = function() {
var $el, hide, show;
$el = this.iconNav.$el;
show = function() {
$el.show();
return $('main').removeClass('no-icon-nav');
};
hide = function() {
$el.hide();
return $('main').addClass('no-icon-nav');
};
return this.listenTo(app.vent, 'route:change', function(section) {
if (indexOf.call(noIconNavRoutes, section) >= 0) {
return hide();
} else {
return show();
}
});
};
noIconNavRoutes = ['welcome', 'login', 'signup'];
});
;require.register("modules/general/lib/move_caret_to_end", function(exports, require, module) {
module.exports = function(e) {
var el, range;
el = e.target;
if (_.isNumber(el.selectionStart)) {
return el.selectionStart = el.selectionEnd = el.value.length;
} else if (el.createTextRange != null) {
el.focus();
range = el.createTextRange();
range.collapse(false);
return range.select();
}
};
});
;require.register("modules/general/lib/querystring_actions", function(exports, require, module) {
var ValidEmailConfirmation, showValidEmailConfirmation;
ValidEmailConfirmation = require('modules/user/views/valid_email_confirmation');
module.exports = function() {
var validEmail;
validEmail = app.request('route:querystring:get', 'validEmail');
if (validEmail != null) {
validEmail = validEmail === 'true';
return app.request('waitForUserData').then(function() {
return app.request('waitForLayout');
}).then(showValidEmailConfirmation.bind(null, validEmail));
}
};
showValidEmailConfirmation = function(validEmail) {
if (app.user.loggedIn) {
validEmail = app.user.get('validEmail');
}
return app.layout.modal.show(new ValidEmailConfirmation({
validEmail: validEmail
}));
};
});
;require.register("modules/general/lib/show_views", function(exports, require, module) {
var DonateMenu, FeedbackMenu, JoyrideWelcomeTour, Loader, ShareMenu;
JoyrideWelcomeTour = require('modules/welcome/views/joyride_welcome_tour');
DonateMenu = require('../views/donate_menu');
FeedbackMenu = require('../views/feedback_menu');
ShareMenu = require('../views/share_menu');
Loader = require('../views/behaviors/loader');
module.exports = {
showLoader: function(options) {
var loader, ref, region, selector, title;
if (options == null) {
options = {};
}
ref = _.pickToArray(options, ['region', 'selector', 'title']), region = ref[0], selector = ref[1], title = ref[2];
if (region != null) {
return region.Show(new Loader, title);
} else if (selector != null) {
loader = new Loader;
$(selector).html(loader.render());
if (title != null) {
return app.docTitle(title);
}
} else {
return app.layout.main.Show(new Loader, title);
}
},
showEntity: function(e) {
var data, href, label, ref, uri;
href = e.currentTarget.href;
if (href == null) {
throw new Error("couldnt showEntity: href not found");
}
if (!_.isOpenedOutside(e)) {
data = href.split('/entity/').last();
ref = data.split('/'), uri = ref[0], label = ref[1];
return app.execute('show:entity', uri, label);
}
},
showJoyrideWelcomeTour: function() {
return this.joyride.show(new JoyrideWelcomeTour);
},
showDonateMenu: function() {
return app.layout.modal.show(new DonateMenu);
},
showFeedbackMenu: function(options) {
return app.layout.modal.show(new FeedbackMenu(options));
},
shareLink: function() {
return app.layout.modal.show(new ShareMenu);
}
};
});
;require.register("modules/general/lib/smart_prevent_default", function(exports, require, module) {
module.exports = function(e) {
var $link, href;
if (e.which !== 1) {
return;
}
if (_.isOpenedOutside(e)) {
return;
}
if (e.currentTarget != null) {
$link = $(e.currentTarget);
href = $link.attr("href");
if (!href) {
return;
}
}
if (/^#|javascript:|mailto:|(?:\w+:)?\/\//.test(href)) {
return;
}
return e.preventDefault();
};
});
;require.register("modules/general/lib/wait_for_check", function(exports, require, module) {
module.exports = function(options) {
var $selector, action, error, promise, selector, success;
selector = options.selector, $selector = options.$selector, action = options.action, promise = options.promise, success = options.success, error = options.error;
$selector || ($selector = $(selector));
$selector.trigger('loading', {
selector: selector
});
if (action != null) {
promise = action();
}
promise.then(function(res) {
return $selector.trigger('check', success);
})["catch"](function(err) {
return $selector.trigger('fail', error);
});
return promise;
};
});
;require.register("modules/general/models/filterable", function(exports, require, module) {
module.exports = Backbone.NestedModel.extend({
asMatchable: function(expr) {
return [];
},
matches: function(expr) {
var hasMatch;
if (expr == null) {
return true;
}
hasMatch = _.some(this.asMatchable(), function(field) {
return (field != null ? field.match(expr) : void 0) != null;
});
if (hasMatch) {
return true;
} else {
return false;
}
}
});
});
;require.register("modules/general/models/img", function(exports, require, module) {
var images_, maxSize;
images_ = require('lib/images');
maxSize = CONFIG.images.maxSize;
module.exports = Backbone.NestedModel.extend({
initialize: function() {
var dataUrl, input, ref, url;
ref = this.toJSON(), url = ref.url, dataUrl = ref.dataUrl;
input = url || dataUrl;
if (input == null) {
throw new Error('at least one input attribute is required');
}
if (url != null) {
this.initFromUrl(url);
}
if (dataUrl != null) {
this.initDataUrl(dataUrl);
}
return this.crop = this.get('crop');
},
initFromUrl: function(url) {
return this.waitForReady = this.setDataUrlFromUrl(url).then(this.resize.bind(this))["catch"](_.Error('initFromUrl err'));
},
initDataUrl: function(dataUrl) {
this.set('originalDataUrl', dataUrl);
return this.waitForReady = this.resize();
},
setDataUrlFromUrl: function(url) {
return images_.getUrlDataUrl(url).then(this.set.bind(this, 'originalDataUrl'));
},
resize: function() {
var dataUrl;
dataUrl = this.get('originalDataUrl');
return images_.resizeDataUrl(dataUrl, maxSize).then(this.set.bind(this))["catch"](_.Error('resize'));
},
select: function() {
return this.set('selected', true);
},
setCroppedDataUrl: function() {
var croppedData, dataUrl, height, width;
if (this.view != null) {
croppedData = this.view.getCroppedDataUrl();
dataUrl = croppedData.dataUrl, width = croppedData.width, height = croppedData.height;
return this.set({
croppedDataUrl: dataUrl,
cropped: {
width: width,
height: height
}
});
}
},
getFinalDataUrl: function() {
return this.get('croppedDataUrl') || this.get('dataUrl');
},
imageHasChanged: function() {
var finalAttribute, heightChange, widthChange;
finalAttribute = this.crop ? 'cropped' : 'resized';
widthChange = this._areDifferent(finalAttribute, 'original', 'width');
heightChange = this._areDifferent(finalAttribute, 'original', 'height');
return _.log(widthChange || heightChange, 'image changed?');
},
_areDifferent: function(a, b, value) {
return this.get(a)[value] !== this.get(b)[value];
},
getFinalUrl: function() {
var originalUrl;
if (this.crop) {
this.setCroppedDataUrl();
}
originalUrl = this.get('url');
if ((originalUrl != null) && !this.imageHasChanged()) {
return _.preq.resolve(originalUrl);
}
return images_.upload({
blob: images_.dataUrlToBlob(this.getFinalDataUrl()),
id: this.cid
}).then(_.property(this.cid)).then(_.Log('url?'));
}
});
});
;require.register("modules/general/models/positionable", function(exports, require, module) {
var Filterable;
Filterable = require('./filterable');
module.exports = Filterable.extend({
hasPosition: function() {
return this.has('position');
},
getCoords: function() {
var lat, latLng, lng;
latLng = this.get('position');
if (latLng != null) {
lat = latLng[0], lng = latLng[1];
return {
lat: lat,
lng: lng
};
} else {
return {};
}
},
getLatLng: function() {
if (this._latLng != null) {
return this._latLng;
} else {
return this.setLatLng();
}
},
setLatLng: function() {
var lat, lng, ref;
if (this.hasPosition()) {
ref = this.get('position'), lat = ref[0], lng = ref[1];
return this._latLng = new L.LatLng(lat, lng);
} else {
return this._latLng = null;
}
}
});
});
;require.register("modules/general/models/session", function(exports, require, module) {
var push, startTime;
startTime = new Date().getTime();
module.exports = Backbone.NestedModel.extend({
initialize: function() {
this.set('navigation', []);
this.set('error', []);
this.set('time', {
first: startTime
});
this.logFirstLoadTime();
this.once('update', this.setId.bind(this));
this.on('update', _.debounce(this.sync, 1000));
return setInterval(this.update.bind(this), 30 * 1000);
},
setId: function() {
var badLuckToken, day, millisec;
day = _.niceDate().replace(/-/g, '');
millisec = _.timeSinceMidnight();
badLuckToken = _.idGenerator(4);
return this.set('_id', day + "-" + millisec + "-" + badLuckToken);
},
update: function() {
this.updateLastPageTime(this.timer());
return this.trigger('update');
},
sync: function() {
var report;
report = this.toJSON();
if (report.navigation != null) {
return $.post('/api/logs/public', report);
}
},
record: function(page) {
var action, timestamp;
timestamp = _.now();
action = {
page: ("/" + page).replace('//', '/'),
timestamp: timestamp
};
this.updateLastPageTime(timestamp);
this.updateSessionTime();
push(this, 'navigation', action);
return this.trigger('update');
},
recordError: function(error) {
var hash;
if (!this.dupplicatedError(error)) {
hash = _.hashCode(JSON.stringify(error));
error.hash = hash;
push(this, 'error', error);
this.lastPageSet('errorHash', hash);
return this.trigger('update');
}
},
dupplicatedError: function(error) {
var msg, ref, sameMessage;
msg = ((ref = error.error) != null ? ref[0] : void 0) || error.message;
sameMessage = function(err) {
return err.error[0] === msg;
};
return this.get('error').filter(sameMessage).length > 0;
},
updateLastPageTime: function(timestamp) {
var key, last, lastIndex, pageTime, ref;
last = (ref = this.get('navigation')) != null ? ref.slice(-1)[0] : void 0;
if (last != null) {
lastIndex = this.get('navigation').length - 1;
key = "navigation[" + lastIndex + "].time";
pageTime = (timestamp - last.timestamp) / 1000;
return this.set(key, pageTime);
}
},
lastPageSet: function(attr, value) {
var key, last, lastIndex, ref;
last = (ref = this.get('navigation')) != null ? ref.slice(-1)[0] : void 0;
if (last != null) {
lastIndex = this.get('navigation').length - 1;
key = "navigation[" + lastIndex + "]." + attr;
if (key != null) {
return this.set(key, value);
}
} else {
return push(this, 'navigation', {
attr: value
});
}
},
logFirstLoadTime: function() {
return window.onload = this.firstLoadTime.bind(this);
},
firstLoadTime: function() {
var time;
time = this.timer();
_.log(time, 'first load time');
return this.set('time.firstLoadTime', time);
},
timer: function() {
var first, now, time;
first = this.get('time.first');
now = _.now();
this.set('time.last', now);
time = (now - first) / 1000;
return time;
},
updateSessionTime: function() {
return this.set('time.sessionTimeSec', this.timer());
}
});
push = function(model, attribute, value) {
var arr;
arr = model.get(attribute);
arr.push(value);
return model.set(attribute, arr);
};
});
;require.register("modules/general/plugins/behaviors", function(exports, require, module) {
var alert_, loading_, successCheck_;
loading_ = {
startLoading: function(options) {
if (_.isString(options)) {
options = {
selector: options
};
}
return this.$el.trigger('loading', options);
},
stopLoading: function() {
return this.$el.trigger('stopLoading');
}
};
successCheck_ = {
check: function(label, cb, res) {
this.$el.trigger('check', cb);
if ((label != null) && (res != null)) {
return _.log(res, label);
}
},
fail: function(label, cb, err) {
this.$el.trigger('fail', cb);
if ((label != null) && (err != null)) {
return _.error(err, label);
}
}
};
successCheck_.Check = function(label, cb) {
return successCheck_.check.bind(this, label, cb);
};
successCheck_.Fail = function(label, cb) {
return successCheck_.fail.bind(this, label, cb);
};
alert_ = {
alert: function(message) {
console.warn(message);
this.$el.trigger('alert', {
message: _.i18n(message)
});
}
};
module.exports = _.extend({}, loading_, successCheck_, alert_);
});
;require.register("modules/general/plugins/login", function(exports, require, module) {
var events, handlers;
events = {
'click #signupRequest': 'showSignup',
'click #loginRequest': 'showLogin'
};
handlers = {
showSignup: function() {
return app.execute('show:signup');
},
showLogin: function() {
return app.execute('show:login');
}
};
module.exports = _.BasicPlugin(events, handlers);
});
;require.register("modules/general/plugins/masonry", function(exports, require, module) {
var itemWidth;
itemWidth = 230;
module.exports = function(containerSelector, itemSelector, minWidth) {
var initMasonry, refresh;
if (minWidth == null) {
minWidth = 500;
}
if (!_.isView(this)) {
throw new Error('should be called with a view as context');
}
initMasonry = function() {
var $itemsList, container, itemsPerLine, positionBefore, tooFewItems;
$itemsList = $('.itemsList');
if ($itemsList.length === 0) {
return;
}
itemsPerLine = $itemsList.width() / itemWidth;
tooFewItems = this.collection.length < itemsPerLine;
if (!(_.smallScreen(minWidth) || tooFewItems)) {
_.log('masonry:reinit');
positionBefore = window.scrollY;
container = document.querySelector(containerSelector);
$(containerSelector).css('opacity', 0);
new Masonry(container, {
itemSelector: itemSelector,
isFitWidth: true,
isResizable: true,
isAnimated: true,
gutter: 5
});
_.scrollHeight(positionBefore, 0);
return $(containerSelector).css('opacity', 1);
}
};
refresh = function() {
return $(containerSelector).imagesLoaded(initMasonry.bind(this));
};
this.lazyMasonryRefresh = _.debounce(refresh.bind(this), 200);
};
});
;require.register("modules/general/plugins/messages", function(exports, require, module) {
var forms_;
forms_ = require('modules/general/lib/forms');
module.exports = {
postMessage: function(posterReqRes, collection, maxLength) {
var id, message;
message = this.ui.message.val();
if (!this.validMessageLength(message, maxLength)) {
return;
}
id = this.model.id;
app.request(posterReqRes, id, message, collection)["catch"](this.postMessageFail.bind(this, message));
return this.emptyTextarea();
},
validMessageLength: function(message, maxLength) {
var err;
if (maxLength == null) {
maxLength = 5000;
}
if (message.length === 0) {
return false;
}
if (message.length > maxLength) {
err = new Error("can't be longer than " + maxLength + " characters");
this.postMessageFail(message, err);
return false;
}
return true;
},
postMessageFail: function(message, err) {
this.recoverMessage(message);
err.selector = '.alertBox';
return forms_.alert(this, err);
},
emptyTextarea: function() {
return this.ui.message.val('');
},
recoverMessage: function(message) {
return this.ui.message.val(message);
}
};
});
;require.register("modules/general/plugins/pagination", function(exports, require, module) {
module.exports = function(params) {
var batchLength, displayedLimit, fetchMore, initialLength, more;
batchLength = params.batchLength, initialLength = params.initialLength, fetchMore = params.fetchMore, more = params.more;
batchLength || (batchLength = 5);
if (!_.isView(this)) {
throw new Error('should be called with a view as context');
}
displayedLimit = initialLength || batchLength;
this.lazyRender = _.LazyRender(this);
if (fetchMore == null) {
fetchMore = function() {
return _.preq.resolved;
};
more = function() {
return this.collection.length > displayedLimit;
};
}
return _.extend(this, {
filter: function(child, index, collection) {
return (-1 < index && index < displayedLimit);
},
more: more,
displayMore: function() {
return fetchMore().then((function(_this) {
return function() {
displayedLimit += batchLength;
return _this.lazyRender();
};
})(this));
}
});
};
});
;require.register("modules/general/plugins/wiki_bar", function(exports, require, module) {
var appendWikipediaFrame, events, handlers, scrollToIframeTop;
events = {
'click a.showWikipediaPreview': 'toggleWikiIframe'
};
handlers = {
toggleWikiIframe: function() {
var $carets, $iframe, $wpiframe, hasIframe;
$wpiframe = this.$el.find('.wikipedia-iframe');
$iframe = $wpiframe.find('iframe');
$carets = this.$el.find('.wikipedia-iframe').find('.fa');
$iframe.toggle();
$carets.toggle();
hasIframe = $iframe.length > 0;
if (!hasIframe) {
appendWikipediaFrame.call(this, $wpiframe);
$wpiframe.find('iframe').show();
return _.scrollTop($wpiframe);
}
}
};
appendWikipediaFrame = function($el) {
var src, url;
url = this.model.get('wikipedia.url');
src = url + "?useskin=mobil&mobileaction=toggle_view_mobile";
return $el.append("<iframe src=\"" + src + "\" frameborder='0'></iframe>");
};
scrollToIframeTop = function($el) {
var height;
height = $el.offset().top;
return $('body').animate({
scrollTop: height
}, 500);
};
module.exports = _.BasicPlugin(events, handlers);
});
;require.register("modules/general/regions/common_el", function(exports, require, module) {
module.exports = Marionette.Region.extend({
attachHtml: function(view) {
return $(view.el).insertAfter(this.$el);
}
});
});
;require.register("modules/general/views/app_layout", function(exports, require, module) {
var IconNav, documentLang, initDynamicBackground, initHeadMetadataCommands, initIconNavHandlers, initWindowResizeEvents, showViews, waitForCheck;
waitForCheck = require('../lib/wait_for_check');
documentLang = require('../lib/document_lang');
showViews = require('../lib/show_views');
IconNav = require('./icon_nav');
initIconNavHandlers = require('../lib/icon_nav');
initDynamicBackground = require('../lib/dynamic_background');
initHeadMetadataCommands = require('../lib/head_metadata');
module.exports = Marionette.LayoutView.extend({
template: require('./templates/app_layout'),
el: '#app',
regions: {
iconNav: '#iconNav',
main: 'main',
accountMenu: '#accountMenu',
modal: '#modalContent',
joyride: '#joyride'
},
ui: {
bg: '#bg'
},
events: {
'click .showDonateMenu': 'showDonateMenu',
'click .showFeedbackMenu': 'showFeedbackMenu',
'click a.wd-Q, a.showEntity': 'showEntity',
'click .shareLink': 'shareLink'
},
behaviors: {
General: {},
PreventDefault: {}
},
initialize: function(e) {
_.extend(this, showViews);
this.render();
app.commands.setHandlers({
'show:loader': this.showLoader,
'main:fadeIn': function() {
return app.layout.main.$el.hide().fadeIn(200);
},
'current:username:set': this.setCurrentUsername,
'current:username:hide': this.hideCurrentUsername,
'show:joyride:welcome:tour': this.showJoyrideWelcomeTour.bind(this),
'show:feedback:menu': this.showFeedbackMenu
});
app.reqres.setHandlers({
'waitForCheck': waitForCheck
});
documentLang.keepBodyLangUpdated.call(this);
documentLang.keepHeadAlternateLangsUpdated.call(this);
documentLang.updateOgLocalAlternates();
initHeadMetadataCommands();
initIconNavHandlers.call(this);
initDynamicBackground.call(this);
return app.request('waitForData').then(initWindowResizeEvents);
},
serializeData: function() {
return {
topbar: this.topBarData()
};
},
onRender: function() {
return this.iconNav.show(new IconNav);
},
topBarData: function() {
return {
options: {
custom_back_text: true,
back_text: _.icon('caret-left') + ' ' + _.i18n('back'),
is_hover: false
}
};
},
setCurrentUsername: function(username) {
$('#currentUsername').text(username);
return $('#currentUser').slideDown();
},
hideCurrentUsername: function() {
return $('#currentUser').hide();
}
});
initWindowResizeEvents = function() {
var resize, resizeEnd;
resizeEnd = function() {
return app.vent.trigger('window:resize');
};
resize = _.debounce(resizeEnd, 150);
return $(window).resize(resize);
};
});
;require.register("modules/general/views/behaviors/change_picture", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
template: require('./templates/change_picture'),
serializeData: function() {
return this.model.serializeData();
}
});
});
;require.register("modules/general/views/behaviors/confirmation_modal", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
className: 'confirmationModal',
template: require('./templates/confirmation_modal'),
onShow: function() {
return app.execute('modal:open');
},
behaviors: {
SuccessCheck: {},
ElasticTextarea: {},
General: {}
},
serializeData: function() {
var data;
data = this.options;
data.yes || (data.yes = 'yes');
data.no || (data.no = 'no');
return data;
},
events: {
'click a#yes': 'yesClick',
'click a#no': 'close'
},
yesClick: function() {
var action, ref, selector;
ref = this.options, action = ref.action, selector = ref.selector;
return _.preq.start.then(this.executeFormAction.bind(this)).then(action).then(this.success.bind(this))["catch"](this.error.bind(this))["finally"](this.stopLoading.bind(null, selector));
},
success: function(res) {
this.$el.trigger('check', this.close.bind(this));
return res;
},
error: function(err) {
_.error(err, 'confirmation action err');
this.$el.trigger('fail', this.close.bind(this));
return err;
},
close: function() {
return app.execute('modal:close');
},
stopLoading: function(selector) {
if (selector != null) {
return $(selector).trigger('stopLoading');
} else {
return _.warn('no selector was provided');
}
},
executeFormAction: function() {
var formAction, formContent;
formAction = this.options.formAction;
if (formAction != null) {
formContent = this.$el.find('#confirmationForm').val();
if (_.isNonEmptyString(formContent)) {
return formAction(formContent);
}
}
}
});
});
;require.register("modules/general/views/behaviors/loader", function(exports, require, module) {
var behaviorsPlugin;
behaviorsPlugin = require('modules/general/plugins/behaviors');
module.exports = Marionette.ItemView.extend({
template: require('./templates/loader'),
behaviors: {
Loading: {}
},
onShow: function() {
return behaviorsPlugin.startLoading.call(this);
}
});
});
;require.register("modules/general/views/behaviors/picture", function(exports, require, module) {
var behaviorsPlugin;
behaviorsPlugin = require('modules/general/plugins/behaviors');
module.exports = Marionette.ItemView.extend({
tagName: 'div',
template: require('./templates/picture'),
behaviors: {
Loading: {}
},
initialize: function() {
this.lazyRender = _.LazyRender(this);
this.listenTo(this.model, 'change:selected', this.lazyRender);
this.model.waitForReady.then((function(_this) {
return function() {
return _this.ready = true;
};
})(this)).then(this.lazyRender);
return this.model.view = this;
},
serializeData: function() {
return _.extend(this.model.toJSON(), {
classes: this.getClasses(),
ready: this.ready
});
},
ui: {
figure: 'figure',
img: '.original'
},
getClasses: function() {
if (this.model.get('selected')) {
return 'selected';
} else {
return '';
}
},
onRender: function() {
if (this.model.get('crop')) {
behaviorsPlugin.startLoading.call(this, 'figure');
if (this.ready && this.model.get('selected')) {
setTimeout(this.initCropper.bind(this), 200);
return behaviorsPlugin.stopLoading.call(this, 'figure');
}
}
},
initCropper: function() {
return this.ui.img.cropper({
aspectRatio: 1 / 1,
minCropBoxWidth: 300,
minCropBoxHeight: 300
});
},
getCroppedDataUrl: function(outputQuality) {
var canvas, data;
if (outputQuality == null) {
outputQuality = 1;
}
data = this.ui.img.cropper('getData');
canvas = this.ui.img.cropper('getCroppedCanvas');
data.dataUrl = canvas.toDataURL('image/jpeg', outputQuality);
return data;
}
});
});
;require.register("modules/general/views/behaviors/picture_picker", function(exports, require, module) {
var Imgs, behaviorsPlugin, error_, forms_, getImgData, images_, isSelectedModel, validateUrlInput;
Imgs = require('modules/general/collections/imgs');
images_ = require('lib/images');
forms_ = require('modules/general/lib/forms');
error_ = require('lib/error');
behaviorsPlugin = require('modules/general/plugins/behaviors');
module.exports = Marionette.CompositeView.extend({
className: function() {
var limit;
limit = this.options.limit;
return "picture-picker limit-" + limit;
},
template: require('./templates/picture_picker'),
childViewContainer: '#availablePictures',
childView: require('./picture'),
behaviors: {
General: {},
AlertBox: {},
SuccessCheck: {},
Loading: {},
PreventDefault: {}
},
initialize: function() {
var collectionData, pictures;
this.limit = this.options.limit || 1;
pictures = _.forceArray(this.options.pictures);
collectionData = pictures.map(getImgData.bind(null, this.options.crop));
return this.collection = new Imgs(collectionData);
},
serializeData: function() {
return {
urlInput: this.urlInputData()
};
},
urlInputData: function() {
return {
nameBase: 'url',
field: {
type: 'url',
placeholder: _.i18n('enter an image url')
},
button: {
text: _.i18n('go get it!')
},
allowMultiple: this.limit > 1
};
},
onShow: function() {
app.execute('modal:open', 'large');
this.selectFirst();
return this.ui.urlInput.focus();
},
ui: {
urlInput: '#urlField'
},
events: {
'click #validate': 'validate',
'click #cancel': 'close',
'change input[type=file]': 'getFilesPictures',
'click #urlButton': 'fetchUrlPicture'
},
selectFirst: function() {
var ref;
return (ref = this.collection.models[0]) != null ? ref.select() : void 0;
},
validate: function() {
behaviorsPlugin.startLoading.call(this, '#validate');
return this.getFinalUrls()["catch"](error_.Complete('.alertBox')).then(_.Log('final urls')).then(this._saveAndClose.bind(this))["catch"](forms_.catchAlert.bind(null, this));
},
getFinalUrls: function() {
var selectedModels;
selectedModels = this.collection.models.filter(isSelectedModel);
_.log(selectedModels, 'selected models');
selectedModels = selectedModels.slice(0, this.limit);
_.log(selectedModels, 'sliced models');
return Promise.all(_.invoke(selectedModels, 'getFinalUrl'));
},
_saveAndClose: function(urls) {
this.options.save(urls);
return this.close();
},
fetchUrlPicture: function(e) {
var url;
url = this.ui.urlInput.val();
url = images_.getNonResizedUrl(url);
return _.preq.start.then(validateUrlInput.bind(null, url)).then(images_.getUrlDataUrl.bind(null, url)).then(this._addToPictures.bind(this))["catch"](forms_.catchAlert.bind(null, this));
},
getFilesPictures: function(e) {
var file, files, i, len, results;
files = _.toArray(e.target.files);
_.log(files, 'files');
results = [];
for (i = 0, len = files.length; i < len; i++) {
file = files[i];
results.push(this._addFileToPictures(file));
}
return results;
},
_addFileToPictures: function(file) {
if (!_.isObject(file)) {
return _.warn(file, 'couldnt _addFileToPictures');
}
return images_.getFileDataUrl(file).then(this._addToPictures.bind(this))["catch"](_.Error('_addFileToPictures'));
},
_addToPictures: function(dataUrl) {
if (this.limit === 1) {
this._unselectAll();
}
return this._addDataUrlToCollection(dataUrl);
},
_unselectAll: function(dataUrl) {
return this.collection.invoke('set', 'selected', false);
},
_addDataUrlToCollection: function(dataUrl) {
return this.collection.add({
dataUrl: dataUrl,
selected: true,
crop: this.options.crop
});
},
close: function() {
return app.execute('modal:close');
}
});
isSelectedModel = function(model) {
return model.get('selected');
};
validateUrlInput = function(url) {
if (!_.isUrl(url)) {
return forms_.throwError('invalid url', '#urlField', arguments);
}
};
getImgData = function(crop, url) {
return {
url: url,
crop: crop
};
};
});
;require.register("modules/general/views/behaviors/templates/wikidata_P", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<span class='wd-P'>"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.id : depth0),{"name":"i18n","hash":{},"data":data}))
+ ":</span>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/behaviors/templates/wikidata_Q", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression, alias4="function";
return " <a\n href=\""
+ alias3((helpers.wdLocalHref || (depth0 && depth0.wdLocalHref) || alias2).call(alias1,(depth0 != null ? depth0.id : depth0),(depth0 != null ? depth0.label : depth0),{"name":"wdLocalHref","hash":{},"data":data}))
+ "\"\n class='link qlabel wd-Q'\n resource='"
+ alias3((helpers.wdRemoteHref || (depth0 && depth0.wdRemoteHref) || alias2).call(alias1,(depth0 != null ? depth0.id : depth0),{"name":"wdRemoteHref","hash":{},"data":data}))
+ "'\n data-qid='"
+ alias3(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
+ "'>\n "
+ alias3(((helper = (helper = helpers.alt || (depth0 != null ? depth0.alt : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"alt","hash":{},"data":data}) : helper)))
+ "\n </a>\n";
},"3":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression, alias4="function";
return " <span\n class='qlabel wd-Q'\n resource='"
+ alias3((helpers.wdRemoteHref || (depth0 && depth0.wdRemoteHref) || alias2).call(alias1,(depth0 != null ? depth0.id : depth0),{"name":"wdRemoteHref","hash":{},"data":data}))
+ "'\n data-qid='"
+ alias3(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
+ "'>\n "
+ alias3(((helper = (helper = helpers.alt || (depth0 != null ? depth0.alt : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"alt","hash":{},"data":data}) : helper)))
+ "\n </span>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.linkify : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data})) != null ? stack1 : "");
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/call_to_connection", function(exports, require, module) {
var banner, loginPlugin;
loginPlugin = require('modules/general/plugins/login');
banner = require('lib/urls').images.banner;
module.exports = Marionette.ItemView.extend({
template: require('./templates/call_to_connection'),
behaviors: {
General: {}
},
onShow: function() {
return app.execute('modal:open');
},
serializeData: function() {
return _.extend(this.options, {
banner: banner
});
},
initialize: function() {
return loginPlugin.call(this);
}
});
});
;require.register("modules/general/views/donate_menu", function(exports, require, module) {
var bitcoin, gratipay, ref;
ref = require('lib/urls'), bitcoin = ref.bitcoin, gratipay = ref.gratipay;
module.exports = Marionette.ItemView.extend({
template: require('./templates/donate_menu'),
className: 'donate-menu',
behaviors: {
General: {}
},
onShow: function() {
return app.execute('modal:open');
},
serializeData: function() {
return {
bitcoin: bitcoin
};
}
});
});
;require.register("modules/general/views/error", function(exports, require, module) {
module.exports = Marionette.LayoutView.extend({
id: 'error',
template: require('./templates/error'),
behaviors: {
PreventDefault: {}
},
serializeData: function() {
return this.options;
},
events: {
'click .button': 'buttonAction'
},
ui: {
errorBox: '.errorBox'
},
buttonAction: function(e) {
var buttonAction;
if (!_.isOpenedOutside(e)) {
buttonAction = this.options.redirection.buttonAction;
if (_.isFunction(buttonAction)) {
return buttonAction();
}
}
},
onShow: function() {
app.execute('background:cover');
return this.ui.errorBox.fadeIn();
}
});
});
;require.register("modules/general/views/feedback_menu", function(exports, require, module) {
var behaviorsPlugin, contact;
behaviorsPlugin = require('modules/general/plugins/behaviors');
contact = require('lib/urls').contact;
module.exports = Marionette.ItemView.extend({
template: require('./templates/feedback_menu'),
className: 'feedback-menu',
onShow: function() {
return app.execute('modal:open');
},
behaviors: {
Loading: {},
SuccessCheck: {},
ElasticTextarea: {},
General: {},
PreventDefault: {}
},
initialize: function() {
return _.extend(this, behaviorsPlugin);
},
serializeData: function() {
return {
loggedIn: app.user.loggedIn,
user: app.user.toJSON(),
contact: contact,
subject: this.options.subject
};
},
ui: {
unknownUser: '.unknownUser',
subject: '#subject',
message: '#message',
sendFeedback: '#sendFeedback'
},
events: {
'click a#sendFeedback': 'sendFeedback'
},
sendFeedback: function() {
this.startLoading('#sendFeedback');
return this.postFeedback().then(this.Check('feedback res', function() {
return app.execute('modal:close');
}))["catch"](this.Fail('feedback err'));
},
postFeedback: function() {
return _.preq.post(app.API.feedback, {
subject: _.log(this.ui.subject.val(), 'subject'),
message: _.log(this.ui.message.val(), 'message'),
unknownUser: _.log(this.ui.unknownUser.val(), 'unknownUser')
});
}
});
});
;require.register("modules/general/views/icon_nav", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
template: require('./templates/icon_nav'),
className: 'innerIconNav',
initialize: function() {
this.lazyRender = _.LazyRender(this);
return this.once('render', this.initListeners.bind(this));
},
initListeners: function() {
return this.listenTo(app.vent, {
'route:change': this.selectButtonFromRoute.bind(this),
'transactions:unread:change': this.lazyRender,
'i18n:reset': this.lazyRender,
'network:requests:udpate': this.lazyRender
});
},
events: {
'click .add': 'showAddLayout',
'click .network': 'showNetwork',
'click .browse': 'showInventory',
'click .map': 'showMap',
'click .exchanges': 'showTransactions'
},
ui: {
all: 'a.iconButton',
add: '.add',
network: '.network',
browse: '.browse',
map: '.map',
exchanges: '.exchanges'
},
behaviors: {
PreventDefault: {}
},
serializeData: function() {
return {
networkUpdates: this.networkUpdates(),
exchangesUpdates: this.exchangesUpdates()
};
},
onRender: function() {
return this.selectButtonFromRoute(_.currentSection());
},
selectButtonFromRoute: function(section) {
this.unselectAll();
switch (section) {
case 'add':
case 'search':
return this.selectButton('add');
case 'network':
return this.selectButton('network');
case 'inventory':
case 'groups':
return this.selectButton('browse');
case 'map':
return this.selectButton('map');
case 'transactions':
return this.selectButton('exchanges');
}
},
unselectAll: function() {
return this.ui.all.removeClass('selected');
},
selectButton: function(uiName) {
return this.ui[uiName].addClass('selected');
},
showAddLayout: function(e) {
if (!_.isOpenedOutside(e)) {
this.selectButton('add');
return app.execute('show:add:layout');
}
},
showNetwork: function(e) {
if (!_.isOpenedOutside(e)) {
this.selectButton('network');
return app.execute('show:network');
}
},
showInventory: function(e) {
if (!_.isOpenedOutside(e)) {
this.selectButton('browse');
return app.execute('show:inventory:general');
}
},
showMap: function(e) {
if (!_.isOpenedOutside(e)) {
this.selectButton('map');
return app.execute('show:map');
}
},
showTransactions: function(e) {
if (!_.isOpenedOutside(e)) {
this.selectButton('exchanges');
return app.execute('show:transactions');
}
},
networkUpdates: function() {
return app.request('get:network:counters').total;
},
exchangesUpdates: function() {
return app.request('transactions:unread:count');
}
});
});
;require.register("modules/general/views/menu/account_menu", function(exports, require, module) {
var CommonEl, NotificationsList, searchInputData, sectionWithLocalSearch, urls,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
NotificationsList = require('modules/notifications/views/notifications_list');
CommonEl = require('modules/general/regions/common_el');
searchInputData = require('./search_input_data');
urls = require('lib/urls');
sectionWithLocalSearch = ['search', 'add'];
module.exports = Marionette.LayoutView.extend({
template: require('./templates/account_menu'),
events: {
'click #name': 'selectMainUser',
'click #editProfile': function() {
return app.execute('show:settings:profile');
},
'click #editNotifications': function() {
return app.execute('show:settings:notifications');
},
'click #editLabs': function() {
return app.execute('show:settings:labs');
},
'click #signout': function() {
return app.execute('logout');
},
'click a#searchButton': 'search',
'click .showWelcome': 'closeMenu'
},
behaviors: {
PreventDefault: {}
},
serializeData: function() {
return _.extend(this.model.toJSON(), {
search: searchInputData(),
urls: urls,
smallScreen: _.smallScreen()
});
},
initialize: function() {
this.addRegion('notifs', CommonEl.extend({
el: '#before-notifications'
}));
return this.listenTo(app.vent, {
'window:resize': this.render,
'search:global:show': this.showGlobalSearch.bind(this),
'search:global:hide': this.hideGlobalSearch.bind(this),
'route:change': (function(_this) {
return function(section) {
if (indexOf.call(sectionWithLocalSearch, section) >= 0) {
return _this.hideGlobalSearch();
} else {
return _this.showGlobalSearch();
}
};
})(this)
});
},
onShow: function() {
var ref;
app.execute('foundation:reload');
this.showNotifications();
if (ref = _.currentSection(), indexOf.call(sectionWithLocalSearch, ref) >= 0) {
return this.hideGlobalSearch();
}
},
showNotifications: function() {
return this.notifs.show(new NotificationsList({
collection: app.user.notifications
}));
},
selectMainUser: function(e) {
if (!_.isOpenedOutside(e)) {
return app.execute('show:inventory:user', app.user);
}
},
ui: {
searchGroup: '#searchGroup',
searchField: '#searchField'
},
search: function() {
var query;
query = this.ui.searchField.val();
return app.execute('search:global', query);
},
showGlobalSearch: function(query) {
this.ui.searchGroup.fadeIn(200);
if (_.isNonEmptyString(query)) {
return this.ui.searchField.val(query);
}
},
hideGlobalSearch: function() {
return this.ui.searchGroup.fadeOut(200);
},
closeMenu: function() {
if (_.smallScreen) {
return $('.toggle-topbar').trigger('click');
}
}
});
});
;require.register("modules/general/views/menu/list_with_counter", function(exports, require, module) {
module.exports = Marionette.CompositeView.extend({
template: require('./templates/list_with_counter'),
ui: {
counter: '.counter',
list: 'ul'
},
onRender: function() {
return this.updateCounter();
},
initialize: function() {
return this.initUpdaters();
},
initUpdaters: function() {
return this.listenTo(this.collection, 'all', this.updateCounter);
},
tagName: 'li',
className: 'has-dropdown not-click',
childViewContainer: '.dropdown',
count: function() {
return this.collection.length;
},
updateCounter: function() {
if (this.count() === 0) {
return this.hideCounter();
} else {
return this.showCounter();
}
},
hideCounter: function() {
return this.ui.counter.hide();
},
showCounter: function() {
this.ui.counter.html(this.count());
return this.ui.counter.slideDown().attr('style', '');
}
});
});
;require.register("modules/general/views/menu/not_logged_menu", function(exports, require, module) {
var loginPlugin;
loginPlugin = require('modules/general/plugins/login');
module.exports = Marionette.ItemView.extend({
template: require('./templates/not_logged_menu'),
className: 'notLoggedMenu',
initialize: function() {
return loginPlugin.call(this);
},
onShow: function() {
return app.execute('foundation:reload');
}
});
});
;require.register("modules/general/views/menu/search_input_data", function(exports, require, module) {
module.exports = function(nameBase, postfix) {
var data, extraClasses;
if (nameBase == null) {
nameBase = 'search';
}
extraClasses = postfix ? 'postfix' : '';
return data = {
nameBase: nameBase,
field: {
type: 'search',
placeholder: _.i18n('search a book by title, author or ISBN')
},
button: {
icon: 'search',
classes: "secondary " + extraClasses
}
};
};
});
;require.register("modules/general/views/share_menu", function(exports, require, module) {
var behaviorsPlugin, host;
behaviorsPlugin = require('modules/general/plugins/behaviors');
host = require('lib/urls').host;
module.exports = Marionette.ItemView.extend({
template: require('./templates/share_menu'),
className: 'shareMenu',
behaviors: {
General: {}
},
initialize: function() {
this.href = encodeURIComponent(host + document.location.pathname);
return this.title = encodeURIComponent(document.title);
},
onShow: function() {
return app.execute('modal:open');
},
serializeData: function() {
return {
facebookUrl: this.getFacebookUrl(),
twitterUrl: this.getTwitterUrl(),
tumblrUrl: this.getTumblrUrl()
};
},
getFacebookUrl: function() {
return "https://www.facebook.com/dialog/share?app_id=1383915125249576&href=" + this.href + "&caption=Inventaire&redirect_uri=" + this.href;
},
getTwitterUrl: function() {
return "https://twitter.com/intent/tweet?text=" + this.title + "&url=" + this.href + "&via=inventaire_io";
},
getTumblrUrl: function() {
return "https://www.tumblr.com/widgets/share/tool?canonicalUrl=&url=" + this.href;
}
});
});
;require.register("modules/general/views/templates/app_layout", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div id=\"bg\"></div>\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"topbar",(depth0 != null ? depth0.topbar : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n<div id=\"iconNav\"></div>\n<main></main>\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"lateral_buttons",{"name":"partial","hash":{},"data":data}))
+ "\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"modals",{"name":"partial","hash":{},"data":data}))
+ "\n<div id=\"joyride\"></div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/back", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.lambda, alias2=container.escapeExpression;
return "<a class=\"back "
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.back : depth0)) != null ? stack1.classes : stack1), depth0))
+ "\">"
+ alias2((helpers.icon || (depth0 && depth0.icon) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"arrow-left",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.back : depth0)) != null ? stack1.message : stack1), depth0))
+ "</a>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/call_to_connection", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"connect\">\n <img src=\""
+ alias3((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,(depth0 != null ? depth0.banner : depth0),560,{"name":"src","hash":{},"data":data}))
+ "\" alt=\"inventaire banner\">\n <h2>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"call_to_connect_welcome_title",{"name":"i18n","hash":{},"data":data}))
+ "</h2>\n <h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"call_to_connect_welcome_message",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n <p class=\"callToConnection\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.connectionMessage : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</p>\n <div class=\"login-buttons\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:login_buttons",{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/common_separator", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return " "
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},depth0,{"name":"i18n","hash":{},"data":data}))
+ "\n <div class=\"rule\"></div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return "<div class=\"rule\"></div>\n"
+ ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},depth0,{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/ctrl_enter_click_tip", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<span class=\"shortcut-tip\">"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"Ctrl+Enter to send",{"name":"i18n","hash":{},"data":data}))
+ "</span>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/donate_menu", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"donate",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n<p>"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"donate_intro",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</p>\n<ul>\n <li>\n <h4>"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"credit-card",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"credit/debit card",{"name":"I18n","hash":{},"data":data}))
+ "</h4>\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"not available yet",{"name":"i18n","hash":{},"data":data}))
+ "\n </li>\n <li>\n <h4>"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"bitcoin",{"name":"icon","hash":{},"data":data}))
+ " Bitcoin</h4>\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.bitcoin : depth0)) != null ? stack1.hash : stack1),((stack1 = (depth0 != null ? depth0.bitcoin : depth0)) != null ? stack1.url : stack1),{"name":"link","hash":{},"data":data}))
+ "\n <span>\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"or",{"name":"i18n","hash":{},"data":data}))
+ " "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"via coinbase",((stack1 = (depth0 != null ? depth0.bitcoin : depth0)) != null ? stack1.coinbase : stack1),{"name":"link","hash":{},"data":data}))
+ "\n </span>\n </li>\n <li>\n <h4>"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"gratipay",{"name":"icon","hash":{},"data":data}))
+ " Gratipay</h4>\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"make a one-time or reccurent donation via gratipay",(depth0 != null ? depth0.gratipay : depth0),{"name":"link","hash":{},"data":data}))
+ "\n </li>\n</ul>\n\n<h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"non-monetary donations",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n<p>"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"non_monetary_donations",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</p>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/error", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {};
return " <h2 class=\"subheader\">\n "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.icon : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n "
+ container.escapeExpression(((helper = (helper = helpers.header || (depth0 != null ? depth0.header : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"header","hash":{},"data":data}) : helper)))
+ "\n </h2>\n";
},"2":function(container,depth0,helpers,partials,data) {
return container.escapeExpression((helpers.icon || (depth0 && depth0.icon) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.icon : depth0),{"name":"icon","hash":{},"data":data}));
},"4":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.lambda, alias2=container.escapeExpression;
return " <div class=\"redirection\">\n <p>"
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.redirection : depth0)) != null ? stack1.legend : stack1), depth0))
+ "</p>\n <a "
+ ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.href : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n class=\"button radius "
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.redirection : depth0)) != null ? stack1.classes : stack1), depth0))
+ "\">"
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.redirection : depth0)) != null ? stack1.text : stack1), depth0))
+ "</a>\n </div>\n";
},"5":function(container,depth0,helpers,partials,data) {
var stack1;
return " href=\""
+ container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.redirection : depth0)) != null ? stack1.href : stack1), depth0))
+ "\" ";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {};
return "<div class=\"errorBox\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.header : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " <p>"
+ container.escapeExpression(((helper = (helper = helpers.message || (depth0 != null ? depth0.message : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"message","hash":{},"data":data}) : helper)))
+ "</p>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.redirection : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/feedback_menu", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression;
return " <label>"
+ alias1((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"from:",{"name":"i18n","hash":{},"data":data}))
+ "</label>\n <span class=\"username\">"
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.username : stack1), depth0))
+ "</span>\n";
},"3":function(container,depth0,helpers,partials,data) {
return " <input type=\"email\" name=\"email\" class=\"radius unknownUser\" placeholder=\""
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"from",{"name":"i18n","hash":{},"data":data}))
+ "...\">\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"feedback_title",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n<p>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"feedback_intro",{"name":"i18n","hash":{},"data":data}))
+ "</p>\n<form>\n <div class=\"from\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.loggedIn : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data})) != null ? stack1 : "")
+ " </div>\n <div class=\"to\">\n <label>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"to:",{"name":"i18n","hash":{},"data":data}))
+ "</label>\n <span class=\"email\">"
+ alias3(container.lambda(((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.email : stack1), depth0))
+ "</span>\n </div>\n\n <input type=\"text\" id=\"subject\" name=\"subject\" placeholder=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"subject",{"name":"i18n","hash":{},"data":data}))
+ "...\" class=\"radius\" value=\""
+ alias3(((helper = (helper = helpers.subject || (depth0 != null ? depth0.subject : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"subject","hash":{},"data":data}) : helper)))
+ "\">\n <textarea id=\"message\" name=\"feedback\" placeholder=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"your message",{"name":"i18n","hash":{},"data":data}))
+ "...\"></textarea>\n <div>\n <a id=\"sendFeedback\" class=\"button success radius bold\" tabindex=\"0\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"send",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"send feedback",{"name":"i18n","hash":{},"data":data}))
+ "\n <span class=\"loading\"></span>\n </a>\n </div>\n</form>\n<div class=\"checkWrapper\">\n <span class=\"check\"></span>\n</div>\n<div id=\"getInvolved\">\n <h5>"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"get_involved",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</h5>\n <p>"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"contribution_ideas",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</p>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/feedbacks_menu", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression;
return " <label>"
+ alias1((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"from:",{"name":"i18n","hash":{},"data":data}))
+ "</label>\n <span class=\"username\">"
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.username : stack1), depth0))
+ "</span>\n";
},"3":function(container,depth0,helpers,partials,data) {
return " <input type=\"email\" name=\"email\" class=\"radius unknownUser\" placeholder=\""
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"from",{"name":"i18n","hash":{},"data":data}))
+ "...\">\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"feedback_title",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n<p>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"feedback_intro",{"name":"i18n","hash":{},"data":data}))
+ "</p>\n<form>\n <div class=\"from\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.loggedIn : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data})) != null ? stack1 : "")
+ " </div>\n <div class=\"to\">\n <label>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"to:",{"name":"i18n","hash":{},"data":data}))
+ "</label>\n <span class=\"email\">hello@inventaire.io</span>\n </div>\n\n <input type=\"text\" id=\"subject\" name=\"subject\" placeholder=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"subject",{"name":"i18n","hash":{},"data":data}))
+ "...\" class=\"radius\">\n <textarea id=\"message\" name=\"feedback\" placeholder=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"your message",{"name":"i18n","hash":{},"data":data}))
+ "...\"></textarea>\n <div>\n <a id=\"sendFeedback\" class=\"button success radius bold\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"send",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"send feedback",{"name":"i18n","hash":{},"data":data}))
+ "\n <span class=\"loading\"></span>\n </a>\n </div>\n</form>\n<div class=\"checkWrapper\">\n <span class=\"check\"></span>\n</div>\n<div id=\"getInvolved\">\n <h5>"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"get_involved",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</h5>\n <p>"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"contribution_ideas",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</p>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/filter", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression, alias4="function";
return "<div class=\"filter-wrapper\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"search",{"name":"icon","hash":{},"data":data}))
+ "\n <input id=\""
+ alias3(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
+ "\" type=\"text\" placeholder=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.placeholder : depth0),{"name":"i18n","hash":{},"data":data}))
+ "...\" value="
+ alias3(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper)))
+ ">\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/horizontal_separator", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<div class=\"horizontal-separator separator\">\n "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"common_separator",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/icon_nav", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression, alias4="function";
return "<div id=\"addIconButtonTop\" class=\"positioner\"></div>\n<a href=\"/add\" id=\"addIconButton\" class=\"iconButton add\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"title_add_layout",{"name":"i18n","hash":{},"data":data}))
+ "\">\n <div class=\"double-icon\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"search",{"name":"icon","hash":{},"data":data}))
+ "\n <span>/</span>\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"plus",{"name":"icon","hash":{},"data":data}))
+ "\n </div>\n <div class=\"label\">\n <span>"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"search/add a book",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</span>\n </div>\n</a>\n<div id=\"networkIconButtonTop\" class=\"positioner\"></div>\n<a href=\"/network\" id=\"networkIconButton\" class=\"iconButton network\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"title_networt_layout",{"name":"i18n","hash":{},"data":data}))
+ "\">\n <div class=\"iconWithCounter count-"
+ alias3(((helper = (helper = helpers.networkUpdates || (depth0 != null ? depth0.networkUpdates : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"networkUpdates","hash":{},"data":data}) : helper)))
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"users",{"name":"icon","hash":{},"data":data}))
+ "\n <span class=\"counter\">"
+ alias3(((helper = (helper = helpers.networkUpdates || (depth0 != null ? depth0.networkUpdates : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"networkUpdates","hash":{},"data":data}) : helper)))
+ "</span>\n </div>\n <div class=\"label\">\n <span>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"friends & groups",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n </div>\n</a>\n<a href=\"/inventory\" id=\"browseIconButton\" class=\"iconButton browse\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"title_browse_layout",{"name":"i18n","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"list",{"name":"icon","hash":{},"data":data}))
+ "\n <span>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"browse books",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n</a>\n<a href=\"/transactions\" id=\"exchangesIconButton\" class=\"iconButton exchanges\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"title_exchanges_layout",{"name":"i18n","hash":{},"data":data}))
+ "\">\n <div class=\"iconWithCounter count-"
+ alias3(((helper = (helper = helpers.exchangesUpdates || (depth0 != null ? depth0.exchangesUpdates : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"exchangesUpdates","hash":{},"data":data}) : helper)))
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"exchange",{"name":"icon","hash":{},"data":data}))
+ "\n <span class=\"counter\">"
+ alias3(((helper = (helper = helpers.exchangesUpdates || (depth0 != null ? depth0.exchangesUpdates : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"exchangesUpdates","hash":{},"data":data}) : helper)))
+ "</span>\n </div>\n <div class=\"label\">\n <span>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"exchanges",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n </div>\n</a>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/lateral_buttons", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div id=\"lateral-buttons\">\n <a class=\"showDonateMenu\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"money",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"donate",{"name":"I18n","hash":{},"data":data}))
+ "\n </a>\n <a class=\"showFeedbackMenu\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"comments",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"feedback",{"name":"I18n","hash":{},"data":data}))
+ "\n </a>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/loader", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<div class=\"generic-loader\">\n "
+ container.escapeExpression((helpers.icon || (depth0 && depth0.icon) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"circle-o-notch","fa-spin loader",{"name":"icon","hash":{},"data":data}))
+ "\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/modals", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<div id=\"modal\" class=\"reveal-modal\" data-reveal>\n <div id=\"modalContent\"></div>\n <a class=\"close-reveal-modal\">&#215;</a>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/new_message", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<form class=\"newMessage\">\n <div class=\"main\">\n <div class=\"avatar\">\n <img src=\""
+ alias3((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.picture : stack1),50,{"name":"src","hash":{},"data":data}))
+ "\" alt=\"\">\n </div>\n <textarea class=\"message ctrlEnterClick\" name=\"message\" placeholder=\"post a message...\">"
+ alias3(((helper = (helper = helpers.message || (depth0 != null ? depth0.message : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"message","hash":{},"data":data}) : helper)))
+ "</textarea>\n </div>\n <div class=\"alertBox\"></div>\n <div class=\"bottom\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"ctrl_enter_click_tip",{"name":"partial","hash":{},"data":data}))
+ "\n <a class=\"tiny-success-button sendMessage\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"send",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n </div>\n</form>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/save_cancel", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<a class=\"cancelButton\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"times",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"cancel",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n<a class=\"saveButton\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"check",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"save",{"name":"i18n","hash":{},"data":data}))
+ "</a>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/share_menu", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return alias3((helpers.iconLinkText || (depth0 && depth0.iconLinkText) || alias2).call(alias1,"facebook",(depth0 != null ? depth0.facebookUrl : depth0),"Share on facebook","facebook",{"name":"iconLinkText","hash":{},"data":data}))
+ "\n"
+ alias3((helpers.iconLinkText || (depth0 && depth0.iconLinkText) || alias2).call(alias1,"twitter",(depth0 != null ? depth0.twitterUrl : depth0),"Share on twitter","twitter",{"name":"iconLinkText","hash":{},"data":data}))
+ "\n"
+ alias3((helpers.iconLinkText || (depth0 && depth0.iconLinkText) || alias2).call(alias1,"tumblr",(depth0 != null ? depth0.tumblrUrl : depth0),"Share on tumblr","tumblr",{"name":"iconLinkText","hash":{},"data":data}))
+ "\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/social_networks", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return alias3((helpers.iconLinkText || (depth0 && depth0.iconLinkText) || alias2).call(alias1,"trello",(depth0 != null ? depth0.trello : depth0),"Roadmap",{"name":"iconLinkText","hash":{},"data":data}))
+ "\n"
+ alias3((helpers.iconLinkText || (depth0 && depth0.iconLinkText) || alias2).call(alias1,"code",(depth0 != null ? depth0.github : depth0),"Code",{"name":"iconLinkText","hash":{},"data":data}))
+ "\n"
+ alias3((helpers.iconLinkText || (depth0 && depth0.iconLinkText) || alias2).call(alias1,"language",(depth0 != null ? depth0.transifex : depth0),"Translation",{"name":"iconLinkText","hash":{},"data":data}))
+ "\n"
+ alias3((helpers.iconLinkText || (depth0 && depth0.iconLinkText) || alias2).call(alias1,"pencil",(depth0 != null ? depth0.blog : depth0),"Blog",{"name":"iconLinkText","hash":{},"data":data}))
+ "\n"
+ alias3((helpers.iconLinkText || (depth0 && depth0.iconLinkText) || alias2).call(alias1,"facebook",(depth0 != null ? depth0.facebook : depth0),"Facebook",{"name":"iconLinkText","hash":{},"data":data}))
+ "\n"
+ alias3((helpers.iconLinkText || (depth0 && depth0.iconLinkText) || alias2).call(alias1,"twitter",(depth0 != null ? depth0.twitter : depth0),"Twitter",{"name":"iconLinkText","hash":{},"data":data}))
+ "\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/text_field", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <div id=\""
+ alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
+ "Group\">\n <input id=\""
+ alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
+ "Field\" type=\"text\" placeholder=\""
+ alias4(((helper = (helper = helpers.placeholder || (depth0 != null ? depth0.placeholder : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"placeholder","hash":{},"data":data}) : helper)))
+ "\" value=\""
+ alias4(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper)))
+ "\">\n </div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/toggle_wrap", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <a class='wrapper "
+ alias3(((helper = (helper = helpers.nameBase || (depth0 != null ? depth0.nameBase : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"nameBase","hash":{},"data":data}) : helper)))
+ "ToggleWrap right'>\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"chevron-down",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"chevron-up","hidden",{"name":"icon","hash":{},"data":data}))
+ "\n </a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.wrap : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/toggler", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return "inverted";
},"3":function(container,depth0,helpers,partials,data) {
return "checked=\"true\"";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression, alias4="function";
return "<div class=\"toggler-wrapper "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.inverted : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\">\n <span class=\"capitalized\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.label : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</span>\n <div class=\"toggler\">\n <input id=\""
+ alias3(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
+ "\" class=\"toggler-input\" type=\"checkbox\" "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.checked : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ">\n <label for=\""
+ alias3(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
+ "\" class=\"toggler-label\"></label>\n </div>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/token", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper;
return "<input type=\"text\" style=\"display:none\" id=\"token\" name=\"_csrf\", value="
+ container.escapeExpression(((helper = (helper = helpers.token || (depth0 != null ? depth0.token : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"token","hash":{},"data":data}) : helper)))
+ ">";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/topbar", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div id=\"topBar\">\n <nav class=\"top-bar\" data-topbar data-options=\""
+ alias3((helpers.inlineOptions || (depth0 && depth0.inlineOptions) || alias2).call(alias1,(depth0 != null ? depth0.options : depth0),{"name":"inlineOptions","hash":{},"data":data}))
+ "\">\n <ul class=\"title-area\">\n <li class=\"name\">\n <h1 id=\"topheader\">\n <a id=\"home\">"
+ ((stack1 = (helpers.Q || (depth0 && depth0.Q) || alias2).call(alias1,"Q815410",null,"inventaire",{"name":"Q","hash":{},"data":data})) != null ? stack1 : "")
+ " </a></h1>\n </li>\n <li class=\"toggle-topbar menu-icon\">\n <a><span></span></a>\n </li>\n </ul>\n\n <section class=\"top-bar-section\">\n <ul class=\"left\">\n <li id=\"currentUser\" class=\"hidden breadcrumb\">\n <a>"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"chevron-right",{"name":"icon","hash":{},"data":data}))
+ " <span id=\"currentUsername\"></span></a>\n </li>\n </ul>\n <ul id=\"accountMenu\" class=\"right\"></ul>\n </section>\n </nav>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/unselect", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<a class=\"unselect\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"unselect",{"name":"i18n","hash":{},"data":data}))
+ "\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"times",{"name":"icon","hash":{},"data":data}))
+ "</a>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/validation_buttons", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"button-group\">\n <a id=\"cancel\" class=\"button grey\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"cancel",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n <a id=\"validate\" tabindex=\"0\" class=\"button success\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"validate",{"name":"i18n","hash":{},"data":data}))
+ " <span class='loading'></span></a>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/vertical_separator", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<div class=\"vertical-separator separator\">\n "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"common_separator",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/general/views/templates/wiki_sitelinks", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.lambda, alias2=container.escapeExpression, alias3=depth0 != null ? depth0 : {}, alias4=helpers.helperMissing;
return " <span class=\"wikipedia two-buttons\">\n <a href=\""
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.wikipedia : depth0)) != null ? stack1.url : stack1), depth0))
+ "\" target=\"_blank\">\n "
+ alias2((helpers.icon || (depth0 && depth0.icon) || alias4).call(alias3,"wikipedia",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias2((helpers.I18n || (depth0 && depth0.I18n) || alias4).call(alias3,"see on Wikipedia",{"name":"I18n","hash":{},"data":data}))
+ "</a>\n <a href=\""
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.wikipedia : depth0)) != null ? stack1.url : stack1), depth0))
+ "?veaction=edit\" target=\"_blank\">\n "
+ alias2((helpers.i18n || (depth0 && depth0.i18n) || alias4).call(alias3,"edit",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n </span>\n";
},"3":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression, alias2=depth0 != null ? depth0 : {}, alias3=helpers.helperMissing;
return " <span class=\"wikisource two-buttons\">\n <a href=\""
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.wikisource : depth0)) != null ? stack1.url : stack1), depth0))
+ "\" target=\"_blank\">\n "
+ alias1((helpers.icon || (depth0 && depth0.icon) || alias3).call(alias2,"wikisource",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias1((helpers.I18n || (depth0 && depth0.I18n) || alias3).call(alias2,"read online",{"name":"I18n","hash":{},"data":data}))
+ "</a>\n"
+ ((stack1 = helpers.unless.call(alias2,(depth0 != null ? depth0.hideWikisourceEpub : depth0),{"name":"unless","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </span>\n";
},"4":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression, alias2=depth0 != null ? depth0 : {}, alias3=helpers.helperMissing;
return " <a class=\"epub\" href=\""
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.wikisource : depth0)) != null ? stack1.epub : stack1), depth0))
+ "\" target=\"_blank\">\n "
+ alias1((helpers.icon || (depth0 && depth0.icon) || alias3).call(alias2,"download",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias1((helpers.i18n || (depth0 && depth0.i18n) || alias3).call(alias2,"epub",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n";
},"6":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=container.escapeExpression, alias3=helpers.helperMissing;
return "\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.canRefreshData : depth0),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n <a class=\"wikidata\" href=\""
+ alias2(container.lambda(((stack1 = (depth0 != null ? depth0.wikidata : depth0)) != null ? stack1.wiki : stack1), depth0))
+ "\" target=\"_blank\">\n "
+ alias2((helpers.icon || (depth0 && depth0.icon) || alias3).call(alias1,"wikidata",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias2((helpers.I18n || (depth0 && depth0.I18n) || alias3).call(alias1,"edit data",{"name":"I18n","hash":{},"data":data}))
+ "</a>\n\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.canRefreshData : depth0),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"7":function(container,depth0,helpers,partials,data) {
return " <span class=\"wikidata two-buttons\">\n";
},"9":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <a class=\"refreshData\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"refresh_wikidata_data",{"name":"i18n","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"refresh",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"refresh data",{"name":"I18n","hash":{},"data":data}))
+ "</a>\n </span>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {};
return "<div class=\"wiki-sitelinks\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.wikipedia : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.wikisource : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.wikidata : depth0),{"name":"if","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/collections/friends_items", function(exports, require, module) {
var Items;
Items = require('./items');
module.exports = Items.extend({
friendsItemsToFetch: [],
fetchFriendItems: function(friendModel) {
this.friendsItemsToFetch.push(friendModel.id);
return this.lazyFetchFriendsItems();
},
fetchFriendsItems: function() {
var ids;
ids = this.friendsItemsToFetch;
this.friendsItemsToFetch = new Array;
return _.preq.get(app.API.users.items(ids)).then(this.add.bind(this)).always(this.friendsReady.bind(this))["catch"](_.Error('fetchFriendsItems err'));
},
initialize: function() {
this.lazyFetchFriendsItems = _.debounce(this.fetchFriendsItems, 50);
app.commands.setHandlers({
'friends:zero': this.friendsReady.bind(this)
});
this.on('add', this.updateCounter.bind(this, 1));
return this.on('remove', this.updateCounter.bind(this, -1));
},
friendsReady: function() {
app.vent.trigger('friends:items:ready');
return this.fetched = true;
},
inventoryLength: {},
updateCounter: function(operation, item) {
var base, counter, owner;
owner = item.get('owner');
if (owner != null) {
counter = (base = this.inventoryLength)[owner] || (base[owner] = 0);
counter += operation;
this.inventoryLength[owner] = counter;
return app.vent.trigger("inventory:" + owner + ":change", counter);
}
}
});
});
;require.register("modules/inventory/collections/items", function(exports, require, module) {
module.exports = Backbone.Collection.extend({
model: require("../models/item"),
url: function() {
return app.API.items.base;
},
comparator: function(item) {
return -item.get('created');
},
byOwner: function(ownerId) {
return this.where({
owner: ownerId
});
},
byEntityUri: function(uri) {
return this.where({
entity: uri
});
},
byUsername: function(username) {
var owner;
owner = app.request('get:userId:from:username', username);
return this.where({
owner: owner
});
}
});
});
;require.register("modules/inventory/inventory", function(exports, require, module) {
var API, AddLayout, Filters, InventoryLayout, ItemCreationForm, ItemShow, ItemsList, Transactions, displayFoundItems, fetchEntityData, fetchItems, findItemById, findItemByUsernameAndEntity, initAddHelpers, initLayout, initializeInventoriesHandlers, itemCreate, itemsCountByEntity, mainUserPrivateInventoryLength, publicById, publicByUsernameAndEntity, ref, requestPublicItem, showGroupInventory, showInventory, showItemShowFromModel, showItemsList, triggerItemsReady, usersPublicItems;
ItemShow = require('./views/item_show');
Filters = require('./lib/filters');
Transactions = require('./lib/transactions');
InventoryLayout = require('./views/inventory');
ItemCreationForm = require('./views/form/item_creation');
initLayout = require('./lib/layout');
AddLayout = require('./views/add/add_layout');
initAddHelpers = require('./lib/add_helpers');
ItemsList = require('./views/items_list');
ref = app.API.items, publicByUsernameAndEntity = ref.publicByUsernameAndEntity, publicById = ref.publicById, usersPublicItems = ref.usersPublicItems;
module.exports = {
define: function(Inventory, app, Backbone, Marionette, $, _) {
var InventoryRouter;
InventoryRouter = Marionette.AppRouter.extend({
appRoutes: {
'inventory(/)': 'showGeneralInventory',
'inventory/nearby': 'showInventoryNearby',
'inventory/last': 'showInventoryLast',
'inventory/:username(/)': 'showUserInventory',
'inventory/:username/:entity(/:title)(/)': 'showUserItemsByEntity',
'items/:id(/)': 'showItemFromId',
'items(/)': 'showGeneralInventoryNavigate',
'add(/)': 'showAddLayout',
'groups/:id(/:name)(/)': 'showGroupInventory'
}
});
return app.addInitializer(function() {
return new InventoryRouter({
controller: API
});
});
},
initialize: function() {
var Items;
window.Items = Items = require('./items_collections')(app, _);
app.request('waitForUserData').then(fetchItems.bind(null, app));
Filters.initialize(app);
Transactions(Items);
initializeInventoriesHandlers(app);
initAddHelpers();
return initLayout(app);
}
};
API = {
showGeneralInventory: function() {
if (app.request('require:loggedIn', 'inventory')) {
return showInventory({
generalInventory: true
});
}
},
showGeneralInventoryNavigate: function() {
API.showGeneralInventory();
return app.navigate('inventory');
},
showUserInventory: function(user, navigate) {
return showInventory({
user: user,
navigate: navigate
});
},
showGroupInventory: function(id, name, navigate) {
return showInventory({
group: id,
navigate: navigate
});
},
showInventoryNearby: function() {
if (app.request('require:loggedIn', 'inventory/nearby')) {
return showInventory({
nearby: true
});
}
},
showInventoryLast: function() {
if (app.request('require:loggedIn', 'inventory/last')) {
return showInventory({
last: true
});
}
},
showItemCreationForm: function(options) {
var form;
form = new ItemCreationForm(options);
return app.layout.main.show(form);
},
showItemFromId: function(id) {
if (!_.isItemId(id)) {
return app.execute('show:404');
}
app.execute('show:loader');
return findItemById(id).then(showItemShowFromModel)["catch"](function(err) {
if (err.status === 404) {
return app.execute('show:404');
} else {
return _.error(err, 'showItemFromId');
}
});
},
showUserItemsByEntity: function(username, entity, label) {
if (!(_.isUsername(username) && _.isEntityUri(entity))) {
return app.execute('show:404');
}
app.execute('show:loader', {
title: label + " - " + username
});
return fetchEntityData(entity).then(function() {
return app.request('waitForItems');
}).then(function() {
return findItemByUsernameAndEntity(username, entity);
}).then(displayFoundItems)["catch"](_.Error('showItemShowFromUserAndEntity'));
},
removeUserItems: function(userId) {
var userItems;
_.log(userId, 'removeUserItems');
userItems = Items.byOwner(userId);
if ((userItems != null ? userItems.length : void 0) > 0) {
return Items.remove(userItems);
}
},
showAddLayout: function() {
return app.layout.main.Show(new AddLayout, _.I18n('title_add_layout'));
}
};
findItemById = function(itemId) {
return app.request('waitForItems').then(Items.byId.bind(Items, itemId)).then(function(item) {
if (item != null) {
return item;
} else {
return _.preq.get(publicById(itemId)).then(Items["public"].add);
}
})["catch"](_.ErrorRethrow('findItemById err (maybe the item was deleted or its visibility changed?)'));
};
fetchEntityData = function(entity) {
return app.request('get:entity:model', entity);
};
findItemByUsernameAndEntity = function(username, entity) {
var owner;
owner = app.request('get:userId:from:username', username);
if (app.request('user:isPublicUser', owner)) {
return requestPublicItem(username, entity);
} else {
return Items.where({
owner: owner,
entity: entity
});
}
};
displayFoundItems = function(items) {
_.log(items, 'displayFoundItems items');
if ((items != null ? items.length : void 0) == null) {
throw new Error('shouldnt be at least an empty array here?');
}
switch (items.length) {
case 0:
return app.execute('show:404');
case 1:
return showItemShowFromModel(items[0]);
default:
return showItemsList(items);
}
};
showInventory = function(options) {
return app.layout.main.show(new InventoryLayout(options));
};
showItemsList = function(items) {
var collection;
collection = new Backbone.Collection(items);
return app.layout.main.show(new ItemsList({
collection: collection
}));
};
fetchItems = function(app) {
var ref1;
if ((ref1 = app.user) != null ? ref1.loggedIn : void 0) {
Items.fetch({
reset: true
}).always(triggerItemsReady);
} else {
_.log('user isnt logged in. not fetching items');
triggerItemsReady();
}
return app.reqres.setHandlers({
'item:create': itemCreate,
'items:count:byEntity': itemsCountByEntity
});
};
triggerItemsReady = function() {
Items.personal.fetched = true;
app.user.itemsFetched = true;
return app.vent.trigger('items:ready');
};
requestPublicItem = function(username, entity) {
return _.preq.get(publicByUsernameAndEntity(username, entity)).then(function(res) {
app.execute('users:public:add', res.user);
return Items["public"].add(res.items);
})["catch"](_.Error('requestPublicItem err'));
};
itemCreate = function(itemData) {
var itemModel, ref1;
if (((ref1 = itemData.entity) != null ? ref1.label : void 0) != null) {
itemData.title = itemData.entity.label;
}
if (!((itemData.title != null) && itemData.title !== '')) {
throw new Error('cant create item: missing title');
}
itemModel = Items.add(itemData);
_.preq.resolve(itemModel.save()).then(_.Log('item creation server res')).then(itemModel.onCreation.bind(itemModel))["catch"](_.Error('item creation err'));
return itemModel;
};
itemsCountByEntity = function(uri) {
return Items.where({
entity: uri
}).length;
};
showGroupInventory = function(group) {
return API.showGroupInventory(group.id, group.get('name'), true);
};
showItemShowFromModel = function(item) {
app.layout.main.show(new ItemShow({
model: item
}));
if (item.pathname != null) {
return app.navigate(item.pathname);
} else {
return _.error(item, 'missing item.pathname');
}
};
initializeInventoriesHandlers = function(app) {
app.commands.setHandlers({
'show:inventory:general': API.showGeneralInventoryNavigate,
'show:inventory:user': function(user) {
return API.showUserInventory(user, true);
},
'show:inventory:main:user': function() {
return API.showUserInventory(app.user, true);
},
'show:inventory:group': showGroupInventory,
'show:inventory:group:byId': function(groupId) {
var group;
group = app.request('get:group:model:sync', groupId);
return showGroupInventory(group);
},
'show:item:creation:form': function(params) {
var entity, entityPathname, pathname, uri;
entity = params.entity;
if (entity == null) {
throw new Error('missing entity');
}
uri = entity.get('uri');
entityPathname = params.entity.get('pathname');
pathname = entityPathname + "/add";
if (app.request('require:loggedIn', pathname)) {
API.showItemCreationForm(params);
return app.navigate(pathname.replace(/\/add$/, ''));
}
},
'show:item:show:from:model': showItemShowFromModel,
'show:add:layout': function() {
API.showAddLayout();
return app.navigate('add');
},
'inventory:remove:user:items': function(userId) {
return setTimeout(API.removeUserItems.bind(null, userId), 0);
},
'show:inventory:nearby': API.showInventoryNearby,
'show:inventory:last': API.showInventoryLast,
'show:items': displayFoundItems
});
return app.reqres.setHandlers({
'item:update': function(options) {
var attribute, data, item, promise, selector, value;
item = options.item, attribute = options.attribute, value = options.value, data = options.data, selector = options.selector;
_.types([item, selector], ['object', 'string|undefined']);
if (data != null) {
_.type(data, 'object');
item.set(data);
} else {
_.type(attribute, 'string');
item.set(attribute, value);
}
promise = _.preq.resolve(item.save());
if (selector != null) {
app.request('waitForCheck', {
promise: promise,
selector: selector
});
}
return promise;
},
'item:destroy': function(options) {
var action, model, next, selector, title;
model = options.model, selector = options.selector, next = options.next;
_.types([model, selector, next], ['object', 'string', 'function']);
title = model.get('title');
action = function() {
return model.destroy().then(next);
};
return $(selector).trigger('askConfirmation', {
confirmationText: _.i18n('destroy_item_text', {
title: title
}),
warningText: _.i18n("this action can't be undone"),
action: action
});
},
'get:item:model': findItemById,
'get:item:model:sync': function(id) {
return Items.byId(id);
},
'inventory:main:user:length': function(nonPrivate) {
var fullInventoryLength, privateInventoryLength;
fullInventoryLength = Items.personal.length;
privateInventoryLength = mainUserPrivateInventoryLength();
if (nonPrivate) {
return fullInventoryLength - privateInventoryLength;
} else {
return fullInventoryLength;
}
},
'inventory:user:length': function(userId) {
return Items.inventoryLength[userId];
},
'inventory:user:items': function(userId) {
return Items.where({
owner: userId
});
},
'inventory:fetch:users:public:items': function(usersIds) {
if (usersIds.length === 0) {
_.warn(usersIds, 'no user ids, no items fetched');
return _.preq.resolve([]);
}
return _.preq.get(usersPublicItems(usersIds)).then(_.property('items'));
},
'item:main:user:instances': function(entityUri) {
return Items.personal.byEntityUri(entityUri);
}
});
};
mainUserPrivateInventoryLength = function() {
return Items.personal.where({
listing: 'private'
}).length;
};
});
;require.register("modules/inventory/items_collections", function(exports, require, module) {
var FriendsItems;
FriendsItems = require('./collections/friends_items');
module.exports = function(app, _) {
var Items, friends, isFriend, isMainUser, isPublicUser, isntPublicUser, itemsAddProxy, network, personal, publik;
Items = new FriendsItems;
isMainUser = function(model) {
return model.get('owner') === app.user.id;
};
personal = new FilteredCollection(Items);
personal.filterBy('personal', isMainUser);
personal.add = Items.add.bind(Items);
personal.create = Items.create.bind(Items);
personal.byEntityUri = Items.byEntityUri.bind(personal);
app.user.once('change', function() {
return personal.refilter();
});
itemsAddProxy = Items.add.bind(Items);
isFriend = function(model) {
return app.request('user:isFriend', model.get('owner'));
};
friends = new FilteredCollection(Items).filterBy('friends', isFriend);
friends.fetchFriendItems = Items.fetchFriendItems.bind(Items);
friends.add = itemsAddProxy;
app.vent.once('friends:items:ready', function() {
return friends.fetched = true;
});
isPublicUser = function(model) {
return app.request('user:isPublicUser', model.get('owner'));
};
publik = new FilteredCollection(Items).filterBy('public', isPublicUser);
publik.add = itemsAddProxy;
isntPublicUser = function(model) {
return !isPublicUser(model);
};
network = new FilteredCollection(Items).filterBy('network', isntPublicUser);
network.add = itemsAddProxy;
return _.extend(Items, {
personal: personal,
friends: friends,
"public": publik,
network: network
});
};
});
;require.register("modules/inventory/lib/add_helpers", function(exports, require, module) {
var get, set;
set = localStorageProxy.setItem.bind(localStorageProxy);
get = localStorageProxy.getItem.bind(localStorageProxy);
module.exports = function() {
app.commands.setHandlers({
'last:add:mode:set': set.bind(null, 'lastAddMode'),
'last:transaction:set': set.bind(null, 'lastTransaction'),
'last:listing:set': set.bind(null, 'lastListing')
});
return app.reqres.setHandlers({
'last:add:mode:get': get.bind(null, 'lastAddMode'),
'last:transaction:get': get.bind(null, 'lastTransaction'),
'last:listing:get': get.bind(null, 'lastListing')
});
};
});
;require.register("modules/inventory/lib/add_users_and_items", function(exports, require, module) {
module.exports = function(itemsCollection, res) {
var err, items, users;
items = res.items, users = res.users;
if (!((items != null ? items.length : void 0) > 0)) {
err = new Error('no public items');
err.status = 404;
throw err;
}
app.execute('users:public:add', users);
itemsCollection.add(items);
};
});
;require.register("modules/inventory/lib/filters", function(exports, require, module) {
var excludeTransaction, filterInventory, filterInventoryByFriendsAndMainUser, filterInventoryByGroup, filterInventoryByOwner, filterItemsByText, includeTransaction, isntPrivateItem, itemsFiltered, ownedByFriendOrMainUser, singleFilterReady,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
itemsFiltered = require('./items_filtered');
module.exports = {
initialize: function(app) {
Items.filtered = itemsFiltered(Items);
Items.personal.filtered = itemsFiltered(Items.personal);
Items.friends.filtered = itemsFiltered(Items.friends);
Items["public"].filtered = itemsFiltered(Items["public"]);
Items.network.filtered = itemsFiltered(Items.network);
app.commands.setHandlers({
'filter:inventory:owner': filterInventoryByOwner,
'filter:inventory:friends:and:main:user': filterInventoryByFriendsAndMainUser,
'filter:inventory:group': filterInventoryByGroup,
'filter:items:byText': filterItemsByText,
'filter:inventory:transaction:include': includeTransaction,
'filter:inventory:transaction:exclude': excludeTransaction
});
return app.request('waitForFriendsItems').delay(400).then(Items.filtered.refilter.bind(Items.filtered));
}
};
filterInventory = function(filterName, filterFn) {
if (!singleFilterReady(filterName)) {
Items.filtered.resetFilters();
return Items.filtered.filterBy(filterName, filterFn);
}
};
filterInventoryByOwner = function(owner) {
return filterInventory("owner:" + owner, function(itemModel) {
return itemModel.get('owner') === owner;
});
};
ownedByFriendOrMainUser = function(itemModel) {
var ownerId;
ownerId = itemModel.get('owner');
if (app.request('user:isMainUser', ownerId)) {
return true;
} else if (app.request('user:isFriend', ownerId)) {
return true;
} else {
return false;
}
};
filterInventoryByFriendsAndMainUser = filterInventory.bind(null, 'friendsAndMainUser', ownedByFriendOrMainUser);
filterInventoryByGroup = function(groupModel) {
var allMembersIds, mainUserId;
Items.filtered.resetFilters();
allMembersIds = groupModel.allMembersIds();
mainUserId = app.user.id;
return Items.filtered.filterBy('group', function(itemModel) {
var owner;
owner = itemModel.get('owner');
if (indexOf.call(allMembersIds, owner) < 0) {
return false;
}
if (owner === mainUserId) {
return isntPrivateItem(itemModel);
} else {
return true;
}
});
};
isntPrivateItem = function(itemModel) {
return itemModel.get('listing') !== 'private';
};
filterItemsByText = function(text, reset) {
return Items.filtered.filterByText(text, reset);
};
includeTransaction = function(transaction) {
return Items.filtered.removeFilter("exclude:" + transaction);
};
excludeTransaction = function(transaction) {
return Items.filtered.filterBy("exclude:" + transaction, function(item) {
return item.get('transaction') !== transaction;
});
};
singleFilterReady = function(filter) {
var filters;
filters = Items.filtered.getFilters();
return filters.length === 1 && filters[0] === filter;
};
});
;require.register("modules/inventory/lib/items_filtered", function(exports, require, module) {
var itemsFilters;
itemsFilters = {
filteredByEntityUri: function(uri) {
return this.filterBy('entityUri', function(model) {
return model.get('entity') === uri;
});
}
};
module.exports = function(baseCollection) {
var filteredCollection;
filteredCollection = new FilteredCollection(baseCollection);
return _.extend(filteredCollection, itemsFilters);
};
});
;require.register("modules/inventory/lib/items_per_pages", function(exports, require, module) {
var howManyItemsToFillTheScreen, itemHeight, itemWidth, sideNavWidth;
sideNavWidth = 280;
itemWidth = 200 + 50;
itemHeight = 350;
module.exports = function(margin) {
if (margin == null) {
margin = 5;
}
return howManyItemsToFillTheScreen() + margin;
};
howManyItemsToFillTheScreen = function() {
var itemPerLine, lines, total;
itemPerLine = Math.floor((window.screen.width - sideNavWidth) / itemWidth);
lines = Math.ceil(window.screen.height / itemHeight);
total = itemPerLine * lines;
if (total < 10) {
total = 10;
}
return total;
};
});
;require.register("modules/inventory/lib/layout", function(exports, require, module) {
var defaultLayout;
defaultLayout = 'cascade';
module.exports = function(app) {
var layout, setLayout;
layout = localStorageProxy.getItem('layout') || defaultLayout;
setLayout = function(newLayout) {
layout = newLayout;
return localStorageProxy.setItem('layout', layout);
};
app.reqres.setHandlers({
'inventory:layout': function() {
return layout;
}
});
return app.vent.on('inventory:layout:change', setLayout);
};
});
;require.register("modules/inventory/lib/transactions", function(exports, require, module) {
module.exports = function(Items) {
Items.transactions = function() {
return {
giving: {
id: 'giving',
icon: 'heart',
label: 'giving',
labelShort: "I'm giving it",
labelPersonalized: 'giving_personalized_strong',
unicodeIcon: '&#xf004;'
},
lending: {
id: 'lending',
icon: 'refresh',
label: 'lending',
labelShort: "I can lend it",
labelPersonalized: 'lending_personalized_strong',
unicodeIcon: '&#xf021;'
},
selling: {
id: 'selling',
icon: 'money',
label: 'selling',
labelShort: "I'm selling it",
labelPersonalized: 'selling_personalized_strong',
unicodeIcon: '&#xf0d6;'
},
inventorying: {
id: 'inventorying',
icon: 'cube',
label: 'in my inventory',
labelShort: 'in my inventory',
labelPersonalized: 'inventorying_personalized_strong',
unicodeIcon: '&#xf1b2;'
}
};
};
return Items.transactions.data = Object.freeze(Items.transactions());
};
});
;require.register("modules/inventory/models/item", function(exports, require, module) {
var Filterable;
Filterable = require('modules/general/models/filterable');
module.exports = Filterable.extend({
url: function() {
return app.API.items.base;
},
validate: function(attrs, options) {
if (attrs.title == null) {
return "a title must be provided";
}
if (attrs.owner == null) {
return "a owner must be provided";
}
},
initialize: function(attrs, options) {
var entity, owner, title;
entity = attrs.entity, title = attrs.title, owner = attrs.owner;
if (entity == null) {
throw new Error("item should have an associated entity");
}
this.entityUri = app.request('normalize:entity:uri', entity);
this.waitForEntity = this.reqGrab('get:entity:model', this.entityUri, 'entity');
this.set({
created: this.get('created') || _.now(),
_id: this.getId()
});
this.setPathname();
this.entityPathname = app.request('get:entity:local:href', this.entityUri, title);
this.userReady = false;
return this.reqGrab('get:user:model', owner, 'user').then(this.setUserData.bind(this)).then((function(_this) {
return function() {
return _this.waitForEntity;
};
})(this)).then(this.updateAuthor.bind(this));
},
onCreation: function(serverRes) {
this.set(serverRes);
return this.setPathname();
},
setUserData: function() {
var user;
user = this.user;
this.username = user.get('username');
this.authorized = (user.id != null) && user.id === app.user.id;
this.restricted = !this.authorized;
return this.userReady = true;
},
getId: function() {
return this.get('_id') || 'new';
},
setPathname: function() {
return this.pathname = '/items/' + this.id;
},
serializeData: function() {
var attrs, listing, mainModel, ref, ref1, transacs, transaction;
attrs = this.toJSON();
_.extend(attrs, {
pathname: this.pathname,
entityData: (ref = this.entity) != null ? ref.toJSON() : void 0,
entityPathname: this.entityPathname,
restricted: this.restricted,
userReady: this.userReady,
user: this.userData()
});
attrs.cid = this.cid;
transaction = attrs.transaction;
transacs = Items.transactions();
attrs.currentTransaction = transacs[transaction];
attrs[transaction] = true;
if (this.authorized) {
attrs.transactions = transacs;
attrs.transactions[transaction].classes = 'selected';
listing = attrs.listing;
if (listing == null) {
mainModel = app.request('get:item:model:sync', attrs._id);
listing = mainModel != null ? mainModel.get('listing') : void 0;
}
attrs.currentListing = app.user.listings()[listing];
attrs.listings = app.user.listings();
attrs.listings[listing].classes = 'selected';
} else {
attrs.hasActiveTransaction = this.hasActiveTransaction();
}
attrs.picture = (ref1 = attrs.pictures) != null ? ref1[0] : void 0;
return attrs;
},
userData: function() {
var user, userData;
if (this.userReady) {
user = this.user;
return userData = {
username: this.username,
picture: user.get('picture'),
pathname: user.get('pathname'),
distance: user.distanceFromMainUser
};
}
},
asMatchable: function() {
return [this.get('title'), this.get('authors'), this.username, this.get('details'), this.get('notes'), this.get('entity')];
},
destroy: function() {
var url;
this.trigger('destroy', this, this.collection);
url = _.buildPath(this.url(), {
id: this.id,
rev: this.get('_rev')
});
return _.preq["delete"](url);
},
updateMetadata: function() {
return this.waitForEntity.then((function(_this) {
return function() {
return _this.entity.updateMetadata();
};
})(this)).then(this.executeMetadataUpdate.bind(this));
},
executeMetadataUpdate: function() {
var ref, ref1;
return app.execute('metadata:update', {
title: this.findBestTitle(),
description: (ref = this.findBestDescription()) != null ? ref.slice(0, 501) : void 0,
image: (ref1 = this.get('pictures')) != null ? ref1[0] : void 0,
url: this.pathname
});
},
findBestTitle: function() {
var context, title, transaction;
title = this.get('title');
transaction = this.get('transaction');
context = _.i18n(transaction + "_personalized", {
username: this.username
});
return title + " - " + context;
},
findBestDescription: function() {
var details;
details = this.get('details');
if (_.isNonEmptyString(details)) {
return details;
}
},
updateAuthor: function() {
var current;
if (this.restricted) {
return;
}
current = this.get('authors');
return this.entity.getAuthorsString().then((function(_this) {
return function(update) {
if (_.isNonEmptyString(update) && current !== update) {
_.log([current, update], 'updateAuthor');
return _this.save('authors', update);
}
};
})(this))["catch"](_.Error('updateAuthor'));
},
hasActiveTransaction: function() {
return app.request('has:transactions:ongoing:byItemId', this.id);
}
});
});
;require.register("modules/inventory/plugins/item_actions", function(exports, require, module) {
var events, handlers;
handlers = {
itemShow: function(e) {
if (!_.isOpenedOutside(e)) {
return app.execute('show:item:show:from:model', this.model);
}
},
showUser: function(e) {
if (!_.isOpenedOutside(e)) {
return app.execute('show:user', this.model.username);
}
},
showTransaction: function(e) {
var transac;
if (!_.isOpenedOutside(e)) {
transac = app.request('get:transaction:ongoing:byItemId', this.model.id);
return app.execute('show:transaction', transac.id);
}
}
};
events = {
'click a.itemShow': 'itemShow',
'click a.user': 'showUser',
'click a.userShow': 'showUser',
'click a.mainUserRequested': 'showTransaction'
};
module.exports = _.BasicPlugin(events, handlers);
});
;require.register("modules/inventory/plugins/item_updaters", function(exports, require, module) {
var error_;
error_ = require('lib/error');
module.exports = function() {
_.extend(this.events, {
'click a.transaction': 'updateTransaction',
'click a.listing': 'updateListing',
'click a.remove': 'itemDestroy'
});
_.extend(this, {
updateTransaction: function(e) {
return this.updateItem('transaction', e.target.id);
},
updateListing: function(e) {
return this.updateItem('listing', e.target.id);
},
updateItem: function(attribute, value) {
if (!((attribute != null) && (value != null))) {
return _.preq.reject(error_["new"]('invalid item udpate', arguments));
}
return app.request('item:update', {
item: this.model,
attribute: attribute,
value: value
});
},
itemDestroy: function() {
var afterDestroy, cb;
afterDestroy = this.afterDestroy || (cb = function() {
return console.log('item deleted');
});
return app.request('item:destroy', {
model: this.model,
selector: this.uniqueSelector,
next: afterDestroy
});
}
});
};
});
;require.register("modules/inventory/side_nav/lib/headers", function(exports, require, module) {
module.exports = {
"public": {
id: 'publicListHeader',
label: 'public books'
},
groups: {
id: 'groupsListHeader',
label: 'groups'
},
members: {
id: 'membersListHeader',
label: 'group members'
},
users: {
id: 'usersListHeader',
label: 'friends'
}
};
});
;require.register("modules/inventory/side_nav/views/side_nav", function(exports, require, module) {
var Group, GroupsList, UserLi, UserProfile, UsersList, UsersSearch, headersData;
UserLi = require('modules/users/views/user_li');
UsersList = require('modules/users/views/users_list');
UserProfile = require('./user_profile');
GroupsList = require('modules/network/views/groups_list');
Group = require('modules/network/views/group');
UsersSearch = require('modules/network/plugins/users_search');
headersData = require('../lib/headers');
module.exports = Marionette.LayoutView.extend({
id: 'innerNav',
template: require('./templates/side_nav'),
regions: {
one: '#one',
groupsList: '#groupsList',
membersList: '#membersList',
mainUser: '#mainUser'
},
behaviors: {
PreventDefault: {}
},
ui: {
two: '#two',
friendsSection: '#usersListHeader, #usersList',
usersList: '#usersList',
usersToggler: '#usersListHeader .listToggler',
groupsSection: '#groupsListHeader, #groupsList',
groupsList: '#groupsList',
groupsToggler: '#groups .listToggler',
publicSection: '#publicListHeader, #publicList',
publicList: '#publicList',
publicToggler: '#public .listToggler',
membersSection: '#membersListHeader, #membersList',
membersList: '#membersList',
membersToggler: '#members .listToggler',
memberSearch: '#memberSearch',
nearby: 'li.nearby',
last: 'li.last',
togglers: '.toggler'
},
initialize: function() {
this.initPlugins();
this.listenTo(app.vent, {
'sidenav:show:base': this.showBase.bind(this),
'sidenav:show:user': this.showUser.bind(this),
'sidenav:show:group': this.showGroup.bind(this)
});
return this.lazyMemberFilter = _.debounce(this.updateMemberFilter, 100);
},
initPlugins: function() {
return UsersSearch.call(this);
},
events: {
'keyup #memberField': 'lazyMemberFilter',
'click .listHeader': 'toggleListHeader',
'click #nearby': 'showInventoryNearby',
'click #last': 'showInventoryLast'
},
serializeData: function() {
return _.extend(headersData, {
smallScreen: _.smallScreen()
});
},
showBase: function(active) {
this._listReady = false;
this._usersListShown = false;
this._groupsListShown = false;
this._publicListShown = false;
this.showMainUser();
this.ui.two.show();
this.ui.membersSection.hide();
this.ui.memberSearch.hide();
this.ui.publicSection.removeClass('force-hidden');
this.ui.publicSection.show();
this.ui.groupsSection.removeClass('force-hidden');
this.ui.groupsSection.show();
this.ui.friendsSection.removeClass('force-hidden');
this.ui.friendsSection.show();
switch (active) {
case 'last':
case 'nearby':
this.ui[active].addClass('active');
}
if (_.smallScreen()) {
return app.request('waitForUserData').then(this.initBaseSmallScreen.bind(this));
} else {
this.showUsersList();
this.showPublicList();
return app.request('waitForUserData').then(this.showGroupsList.bind(this)).then(this.initBaseSmallScreen.bind(this));
}
},
initBaseSmallScreen: function() {
this._listReady = true;
return this.ui.togglers.show();
},
showUser: function(userModel) {
this.ui.two.hide();
return this.one.show(new UserProfile({
model: userModel
}));
},
showMainUser: function() {
return this.mainUser.show(new UserLi({
model: app.user
}));
},
showUsersList: function() {
this._usersListShown = true;
this.ui.friendsSection.show();
this.showUsersSearchBase();
return this.adjustHeight(app.users.friends, this.ui.usersList);
},
showGroupsList: function() {
this._groupsListShown = true;
this.ui.groupsSection.show();
this.groupsList.show(new GroupsList({
collection: app.user.groups.mainUserMember
}));
return this.adjustHeight(app.user.groups.mainUserMember, this.ui.groupsList);
},
adjustHeight: function(collection, $el) {
var offsetHeight, ref, scrollHeight;
if (collection.length > 1) {
ref = $el[0], offsetHeight = ref.offsetHeight, scrollHeight = ref.scrollHeight;
if (scrollHeight > offsetHeight) {
return $el.addClass('expend');
}
}
},
showPublicList: function() {
this._publicListShown = true;
return this.ui.publicSection.show();
},
showGroup: function(groupModel) {
this._membersListShown = false;
this._currentGroup = groupModel;
if (_.smallScreen()) {
this.one.show(new Group({
model: groupModel,
highlighted: true
}));
} else {
this.showMembersList();
this.ui.userSearch.hide();
this.ui.memberSearch.show();
}
this.ui.groupsSection.hide();
this.ui.friendsSection.hide();
this.ui.membersSection.removeClass('force-hidden');
this.ui.membersSection.show();
this.setGroupHeader(groupModel);
return this.initBaseSmallScreen();
},
showMembersList: function() {
this._membersListShown = true;
return this.membersList.show(new UsersList({
collection: this._currentGroup.members,
textFilter: true,
emptyViewMessage: "can't find any group member with that name"
}));
},
updateMemberFilter: function(e) {
var text;
text = e.currentTarget.value;
return this.membersList.currentView.trigger('filter:text', text);
},
setGroupHeader: function(group) {
return this.ui.usersListHeader.find('.header').text(_.i18n('group members'));
},
toggleListHeader: function(e) {
var id;
if (this._listReady && _.smallScreen()) {
id = e.currentTarget.id;
switch (id) {
case 'usersListHeader':
this.toggleUserSearch();
return this.toggleList('users', this._usersListShown);
case 'groupsListHeader':
return this.toggleList('groups', this._groupsListShown);
case 'membersListHeader':
this.toggleList('members', this._membersListShown);
return this.ui.memberSearch.toggle();
case 'publicListHeader':
return this.toggleList('public', this._publicListShown);
default:
return _.error(id, 'unknown list header');
}
}
},
toggleList: function(name, shown) {
if (shown) {
this.ui[name + "List"].slideToggle(200);
return this.ui[name + "Toggler"].toggle();
} else {
this.showList(name);
return this.ui[name + "Toggler"].toggle();
}
},
showList: function(name) {
switch (name) {
case 'users':
return this.showUsersList();
case 'groups':
return this.showGroupsList();
case 'members':
return this.showMembersList();
case 'public':
return this.showPublicList();
default:
return _.error(name, 'unknown list');
}
},
toggleUserSearch: function() {
if (this._usersListShown) {
return this.ui.userSearch.toggle();
} else {
return this.ui.userSearch.show();
}
},
showInventoryNearby: function() {
return app.execute('show:inventory:nearby');
},
showInventoryLast: function() {
return app.execute('show:inventory:last');
}
});
});
;require.register("modules/inventory/side_nav/views/user_profile", function(exports, require, module) {
var formatErr, forms_, parseGroupData, relationsActions;
forms_ = require('modules/general/lib/forms');
relationsActions = require('modules/users/plugins/relations_actions');
module.exports = Marionette.ItemView.extend({
template: require('./templates/user_profile'),
events: {
'click #editBio': 'editBio',
'click #saveBio': 'saveBio',
'click #cancelBio': 'cancelBio',
'click #editPicture': 'editPicture',
'click a#changePicture': 'changePicture',
'click a.showGroup': 'showGroup',
'click #showPositionPicker': function() {
return app.execute('show:position:picker:main:user');
}
},
behaviors: {
AlertBox: {},
SuccessCheck: {},
Loading: {},
ElasticTextarea: {},
ConfirmationModal: {},
PreventDefault: {},
Unselect: {}
},
ui: {
bio: '.bio',
bioText: 'textarea.bio'
},
initialize: function() {
this.isMainUser = this.model.isMainUser;
this.listenTo(this.model, 'change', this.render.bind(this));
return this.initPlugin();
},
initPlugin: function() {
return relationsActions.call(this);
},
serializeData: function() {
return _.extend(this.model.serializeData(), {
onUserProfile: true,
loggedIn: app.user.loggedIn,
commonGroups: this.commonGroupsData(),
visitedGroups: this.visitedGroupsData(),
distance: this.model.distanceFromMainUser
});
},
onShow: function() {
this.makeRoom();
this.updateBreadCrumb();
return this.listenTo(app.vent, 'inventory:change', this.destroyOnInventoryChange);
},
destroyOnInventoryChange: function(username) {
if (username !== this.model.get('username')) {
return this.$el.slideUp(500, this.destroy.bind(this));
}
},
onDestroy: function() {
this.giveRoomBack();
return this.notifyBreadCrumb();
},
makeRoom: function() {
return $('#one').addClass('notEmpty');
},
giveRoomBack: function() {
return $('#one').removeClass('notEmpty');
},
updateBreadCrumb: function() {
return app.execute('current:username:set', this.model.get('username'));
},
notifyBreadCrumb: function() {
return app.execute('current:username:hide');
},
editBio: function() {
return this.ui.bio.toggle();
},
cancelBio: function() {
return this.ui.bio.toggle();
},
saveBio: function() {
var bio;
bio = this.ui.bioText.val();
return _.preq.start.then(this.testBio.bind(null, bio)).then(this.updateUserBio.bind(null, bio)).then(this.ui.bio.toggle.bind(this.ui.bio))["catch"](forms_.catchAlert.bind(null, this));
},
testBio: function(bio) {
if (bio.length > 1000) {
return formatErr(new Error("the bio can't be longer than 1000 characters"));
}
},
updateUserBio: function(bio) {
return app.request('user:update', {
attribute: 'bio',
value: bio,
selector: '#usernameButton'
})["catch"](formatErr);
},
changePicture: require('modules/user/lib/change_user_picture'),
commonGroupsData: function() {
return this._requestGroupData('get:groups:common');
},
visitedGroupsData: function() {
return this._requestGroupData('get:groups:others:visited');
},
_requestGroupData: function(request) {
var groups;
if (this.isMainUser) {
return;
}
groups = app.request(request, this.model).map(parseGroupData);
if (groups.length > 0) {
return groups;
} else {
return null;
}
},
showGroup: function(e) {
var groupId;
if (!_.isOpenedOutside(e)) {
groupId = e.currentTarget.attributes['data-id'].value;
return app.execute('show:inventory:group:byId', groupId);
}
}
});
parseGroupData = function(group) {
return {
id: group.id,
name: group.get('name'),
pathname: group.get('pathname')
};
};
formatErr = function(err) {
err.selector = 'textarea.bio';
throw err;
};
});
;require.register("modules/inventory/views/add/add_layout", function(exports, require, module) {
var scanner, searchInputData;
searchInputData = require('modules/general/views/menu/search_input_data');
scanner = require('lib/scanner');
module.exports = Marionette.LayoutView.extend({
template: require('./templates/add_layout'),
id: 'addLayout',
initialize: function() {
return this.loggedIn = app.user.loggedIn;
},
serializeData: function() {
var attrs;
attrs = {
search: searchInputData('localSearch', true),
loggedIn: this.loggedIn
};
if (_.isMobile) {
attrs.scanner = scanner.url;
}
return attrs;
},
behaviors: {
PreventDefault: {},
ElasticTextarea: {},
LocalSeachBar: {}
},
events: {
'click #scanner': 'setAddModeScan'
},
setAddModeScan: function() {
return app.execute('last:add:mode:set', 'scan');
},
onShow: function() {
var msg;
if (!this.loggedIn) {
msg = 'you need to be connected to add a book to your inventory';
return app.execute('show:call:to:connection', msg);
}
},
onDestroy: function() {
if (!this.loggedIn) {
return app.execute('modal:close');
}
}
});
});
;require.register("modules/inventory/views/comment", function(exports, require, module) {
var forms_;
forms_ = require('modules/general/lib/forms');
module.exports = Marionette.ItemView.extend({
template: require('./templates/comment'),
className: "comment " + this.cid,
serializeData: function() {
var attrs;
attrs = this.model.toJSON();
attrs.cid = this.cid;
attrs.user = this.userData(attrs.user);
return attrs;
},
userData: function(userId) {
var ref;
return (ref = app.request('get:userModel:from:userId', userId)) != null ? ref.toJSON() : void 0;
},
behaviors: {
AlertBox: {},
ConfirmationModal: {},
ElasticTextarea: {}
},
initialize: function() {
this.uniqueSelector = "" + this.cid;
return this.listenTo(this.model, 'change', this.render);
},
ui: {
core: '.core',
displayed: 'span.message',
editor: 'textarea.message',
menu: '.icon-buttons'
},
events: {
'click .edit': 'editComment',
'click .delete': 'requestDeletion',
'click .cancelButton': 'toggleEditMode',
'keyup textarea.message': 'escapeEditMode',
'click .saveButton': 'saveEdit',
'dblclick span.message': 'editCommentIfMobile'
},
onShow: function() {
return app.execute('foundation:reload');
},
editComment: function() {
this.toggleEditMode();
return this.ui.editor.focus();
},
editCommentIfMobile: function() {
if (_.isMobile) {
return this.editComment();
}
},
requestDeletion: function() {
return app.request('comments:delete', this.model, this);
},
escapeEditMode: function(e) {
if (_.escapeKeyPressed(e)) {
return this.toggleEditMode();
}
},
toggleEditMode: function() {
this.trigger('edit:toggle');
this.ui.core.toggle();
return this.ui.menu.toggle();
},
saveEdit: function() {
var newMessage;
newMessage = this.ui.editor.val();
app.request('comments:update', this.model, newMessage)["catch"](this.saveFail.bind(this, newMessage));
return this.trigger('edit:toggle');
},
saveFail: function(newMessage, err) {
err.selector = 'textarea.message';
return forms_.alert(this, err);
}
});
});
;require.register("modules/inventory/views/controls", function(exports, require, module) {
var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
module.exports = Marionette.ItemView.extend({
template: require('./templates/controls'),
className: 'controls',
ui: {
filter: 'input.filter',
layoutTogglers: '.layouts a',
cascade: '.cascade',
grid: '.grid'
},
serializeData: function() {
return {
transactions: this.transactionsData()
};
},
transactionsData: function() {
return _.values(Items.transactions()).map(function(transaction) {
var label;
label = transaction.label;
transaction.title = "show/hide \"" + label + "\" books";
return transaction;
});
},
events: {
'keyup input.filter': 'filterItems',
'click .cascade': 'displayCascade',
'click .grid': 'displayGrid',
'click .showControls': 'toggleControls',
'click a.transaction': 'toggleTransaction'
},
initialize: function() {
return this.lastFilter = null;
},
onRender: function() {
this.setActiveLayout();
return this.recoverControls();
},
setActiveLayout: function(layout) {
this.ui.layoutTogglers.removeClass('active');
layout = layout || app.request('inventory:layout');
return this.ui[layout].addClass('active');
},
displayCascade: function() {
app.vent.trigger('inventory:layout:change', 'cascade');
return this.setActiveLayout('cascade');
},
displayGrid: function() {
app.vent.trigger('inventory:layout:change', 'grid');
return this.setActiveLayout('grid');
},
filterItems: function() {
var text;
text = this.ui.filter.val();
if (text !== this.lastFilter) {
this.lastFilter = text;
return app.execute('filter:items:byText', text, false);
}
},
toggleControls: function() {
if (this.$el.hasClass('displayed')) {
return this.wrapControls();
} else {
return this.displayControls();
}
},
recoverControls: function() {
var bool;
bool = JSON.parse(localStorageProxy.getItem('controls:display'));
if (bool) {
return this.displayControls();
} else {
return this.wrapControls();
}
},
displayControls: function() {
this.$el.addClass('displayed');
return localStorageProxy.setItem('controls:display', true);
},
wrapControls: function() {
this.$el.removeClass('displayed');
return localStorageProxy.setItem('controls:display', false);
},
toggleTransaction: function(e) {
var classes, transac;
classes = e.currentTarget.attributes["class"].value.split(' ');
transac = classes[0];
if (indexOf.call(classes, 'active') >= 0) {
$(e.currentTarget).removeClass('active');
return app.execute('filter:inventory:transaction:exclude', transac);
} else {
$(e.currentTarget).addClass('active');
return app.execute('filter:inventory:transaction:include', transac);
}
}
});
});
;require.register("modules/inventory/views/form/item_creation", function(exports, require, module) {
var EntityData, scanner;
EntityData = require('modules/entities/views/entity_data');
scanner = require('lib/scanner');
module.exports = Marionette.LayoutView.extend({
template: require('./templates/item_creation'),
className: 'addEntity',
regions: {
entityRegion: '#entity'
},
behaviors: {
ElasticTextarea: {}
},
ui: {
'transaction': '#transaction',
'listing': '#listing',
'details': '#details',
'notes': '#notes'
},
initialize: function() {
this.entity = this.options.entity;
return this.createItem();
},
createItem: function() {
var attrs, pictures;
attrs = {
title: this.entity.get('title'),
entity: this.entity.get('uri'),
transaction: this.guessTransaction(),
listing: this.guessListing()
};
if (pictures = this.entity.get('pictures')) {
attrs.pictures = pictures;
}
attrs.owner = app.user.id;
if (!((attrs.entity != null) && (attrs.title != null))) {
throw new Error('missing uri or title at item creation from entity');
}
return this.model = app.request('item:create', attrs);
},
guessTransaction: function() {
var transaction;
transaction = this.options.transaction || app.request('last:transaction:get');
app.execute('last:transaction:set', transaction);
return transaction;
},
guessListing: function() {
return app.request('last:listing:get');
},
onShow: function() {
app.execute('foundation:reload');
this.selectTransaction();
this.selectListing();
return this.showEntityData();
},
onDestroy: function() {
var listing, transaction;
listing = this.model.get('listing');
transaction = this.model.get('transaction');
return app.execute('track:item', 'create', listing, transaction);
},
selectTransaction: function() {
return this.selectButton('transaction');
},
selectListing: function() {
return this.selectButton('listing');
},
selectButton: function(attr) {
var $el, value;
value = this.model.get(attr);
if (value != null) {
$el = this.ui[attr].find("a[id=" + value + "]");
if ($el.length === 1) {
this.ui[attr].find('a').removeClass('active');
return $el.addClass('active');
}
}
},
serializeData: function() {
var attrs, title;
title = this.entity.get('title');
attrs = {
title: title,
listings: this.listingsData(),
transactions: this.transactionsData(),
header: _.i18n('add_item_text', {
title: title
})
};
attrs = this.setAddModeSpecificAttr(attrs);
return attrs;
},
listingsData: function() {
var listings;
listings = app.user.listings();
listings["private"].classes = 'active';
return listings;
},
transactionsData: function() {
var transactions;
transactions = Items.transactions();
_.extend(transactions.inventorying, {
label: 'just_inventorize_it',
classes: 'active'
});
return transactions;
},
setAddModeSpecificAttr: function(attrs) {
if (_.isMobile) {
this._addMode = app.request('last:add:mode:get');
if (this._addMode === 'scan') {
attrs.scanner = scanner;
}
}
return attrs;
},
events: {
'click .select-button-group > .button': 'updateSelector',
'click #transaction': 'updateTransaction',
'click #listing': 'updateListing',
'click #cancel': 'destroyItem',
'click #validate': 'validateSimple',
'click #validateAndAddNext': 'validateAndAddNext'
},
showEntityData: function() {
return this.entityRegion.show(new EntityData({
model: this.entity
}));
},
updateSelector: function(e) {
var $el;
$el = $(e.currentTarget);
$el.siblings().removeClass('active');
return $el.addClass('active');
},
updateTransaction: function() {
var transaction;
transaction = this.ui.transaction.find('.active').attr('id');
app.execute('last:transaction:set', transaction);
return this.updateItem({
transaction: transaction
})["catch"](_.Error('updateTransaction err'));
},
updateListing: function() {
var listing;
listing = this.ui.listing.find('.active').attr('id');
app.execute('last:listing:set', listing);
return this.updateItem({
listing: listing
})["catch"](_.Error('updateListing err'));
},
updateDetails: function() {
return this.updateTextAttribute('details');
},
updateNotes: function() {
return this.updateTextAttribute('notes');
},
updateTextAttribute: function(attr) {
var update, val;
_.log(arguments, 'updateTextAttribute');
val = this.ui[attr].val();
update = {};
update[attr] = val;
return this.updateItem(update)["catch"](_.Error('updateTextAttribute err'));
},
validateSimple: function() {
return this.validateItem().then(function() {
return app.execute('show:inventory:main:user');
})["catch"](_.Error('validateSimple err'));
},
validateAndAddNext: function() {
return this.validateItem().then(this.addNext.bind(this))["catch"](_.Error('validateAndAddNext err'));
},
addNext: function() {
return app.execute('show:add:layout');
},
validateItem: function() {
return this.updateItem({
details: this.ui.details.val(),
notes: this.ui.notes.val()
});
},
updateItem: function(data) {
return app.request('item:update', {
item: this.model,
data: data
});
},
destroyItem: function() {
return this.model.destroy().then(function() {
return window.history.back();
})["catch"](_.Error('destroyItem err'));
}
});
});
;require.register("modules/inventory/views/inventory", function(exports, require, module) {
var CheckViewState, Controls, Group, ItemsCollection, ItemsGrid, ItemsList, PositionWelcome, SideNav, addUsersAndItems, catchDestroyedView, fetchUserPublicItems, gridMinWidth, navigateToUserInventory, prepareUserItemsList, ref, showLastPublicItems, updateInventoryMetadata;
SideNav = require('../side_nav/views/side_nav');
ItemsList = require('./items_list');
ItemsGrid = require('./items_grid');
ItemsCollection = require('modules/inventory/collections/items');
Controls = require('./controls');
Group = require('modules/network/views/group');
showLastPublicItems = require('modules/welcome/lib/show_last_public_items');
addUsersAndItems = require('modules/inventory/lib/add_users_and_items');
PositionWelcome = require('modules/map/views/position_welcome');
ref = require('lib/view_state'), CheckViewState = ref.CheckViewState, catchDestroyedView = ref.catchDestroyedView;
gridMinWidth = 750;
module.exports = Marionette.LayoutView.extend({
id: 'inventory',
template: require('./templates/inventory'),
regions: {
sideNav: '#sideNav',
header: '#header',
itemsView: '#itemsView',
controls: '#controls'
},
initialize: function() {
return this.listenTo(app.vent, 'inventory:layout:change', this.showItemsListStep3.bind(this));
},
onShow: function() {
this.showSideNav();
this.showItemsListOnceData();
if (_.smallScreen()) {
if (this.options.user != null) {
return _.scrollTop('#sideNav');
} else {
return _.scrollTop('#itemsView');
}
}
},
showSideNav: function() {
return this.sideNav.show(new SideNav);
},
showItemsListOnceData: function() {
app.execute('metadata:update:needed');
return app.request('waitForData').then(CheckViewState(this, 'inventory')).then(this.showItemsList.bind(this)).then(app.execute.bind(app, 'metadata:update:done'))["catch"](catchDestroyedView)["catch"](_.Error('showItemsListOnceData err'));
},
showItemsList: function() {
var group, last, nearby, ref1, user;
ref1 = this.options, user = ref1.user, group = ref1.group, nearby = ref1.nearby, last = ref1.last;
if (nearby) {
if (app.user.hasPosition()) {
this.showItemsNearby();
} else {
this.showPositionWelcome();
}
app.vent.trigger('sidenav:show:base', 'nearby');
app.navigate('inventory/nearby');
return;
}
if (last) {
this.showLastPublicItems();
app.vent.trigger('sidenav:show:base', 'last');
app.navigate('inventory/last');
return;
}
if (user != null) {
return app.request('resolve:to:userModel', user).then(this.showItemsListStep2.bind(this))["catch"](function(err) {
_.error(err, 'resolve:to:userModel err');
return app.execute('show:404');
});
} else if (group != null) {
return app.request('get:group:model', group).then(this.showItemsListStep2.bind(this, null))["catch"](function(err) {
_.error(err, 'get:group:model err');
return app.execute('show:404');
});
} else {
return this.showItemsListStep2();
}
},
showItemsListStep2: function(user, group) {
var eventName, generalInventory, isMainUser, navigate, ref1;
ref1 = this.options, navigate = ref1.navigate, generalInventory = ref1.generalInventory;
if (Items.length === 0) {
isMainUser = user != null ? app.request('user:isMainUser', user.id) : false;
if (generalInventory || isMainUser) {
this.showInventoryWelcome(user);
if (isMainUser) {
navigateToUserInventory(user);
app.vent.trigger('sidenav:show:user', user);
} else {
app.vent.trigger('sidenav:show:base');
}
return;
}
}
if (user != null) {
prepareUserItemsList(user, navigate);
eventName = user.get('username');
user.updateMetadata();
} else if (group != null) {
this.prepareGroupItemsList(group, navigate);
eventName = "group:" + group.id;
group.updateMetadata();
} else {
app.vent.trigger('sidenav:show:base');
app.execute('filter:inventory:friends:and:main:user');
eventName = 'general';
updateInventoryMetadata();
}
this.showItemsListStep3();
return app.vent.trigger('inventory:change', eventName);
},
showItemsListStep3: function() {
var ItemsListView, itemsList;
ItemsListView = this.getItemsListView();
itemsList = new ItemsListView({
collection: Items.filtered
});
this.itemsView.show(itemsList);
return this.showControls();
},
getItemsListView: function() {
switch (app.request('inventory:layout')) {
case 'cascade':
return ItemsList;
case 'grid':
return ItemsGrid;
default:
throw new Error('unknow items list layout');
}
},
showInventoryWelcome: function(user) {
var inventoryWelcome;
inventoryWelcome = require('./inventory_welcome');
this.header.show(new inventoryWelcome);
return this.showLastPublicItems();
},
showLastPublicItems: function() {
return showLastPublicItems({
region: this.itemsView,
limit: 25,
allowMore: true
})["catch"](_.Error('showLastPublicItems err'));
},
showControls: function() {
if (!_.smallScreen(gridMinWidth)) {
return this.controls.show(new Controls);
}
},
prepareGroupItemsList: function(group, navigate) {
var pathname;
app.execute('filter:inventory:group', group);
app.vent.trigger('sidenav:show:group', group);
if (!_.smallScreen()) {
this.header.show(new Group({
model: group,
highlighted: true
}));
}
pathname = group.get('pathname');
if (navigate) {
return app.navigate(pathname);
} else {
return app.navigateReplace(pathname);
}
},
showItemsNearby: function() {
var items;
items = new ItemsCollection;
return _.preq.get(app.API.users.publicItemsNearby()).then(_.Log('showItemsNearby res')).then(addUsersAndItems.bind(null, items)).then((function(_this) {
return function() {
return _this.itemsView.show(new ItemsList({
collection: items,
showDistance: true
}));
};
})(this))["catch"](_.Error('showItemsNearby'));
},
showPositionWelcome: function() {
return this.itemsView.show(new PositionWelcome);
}
});
prepareUserItemsList = function(user, navigate) {
var username;
if (!app.request('user:itemsFetched', user)) {
fetchUserPublicItems(user);
}
username = user.get('username');
app.execute('filter:inventory:owner', user.id);
app.vent.trigger('sidenav:show:user', user);
if (navigate) {
return navigateToUserInventory(user);
}
};
navigateToUserInventory = function(user) {
return app.navigate(user.get('pathname'));
};
fetchUserPublicItems = function(user) {
var cb, removeUserItems;
app.request('inventory:fetch:users:public:items', user.id).then(_.Log('public user public items')).then(Items["public"].add)["catch"](_.Error('fetchUserPublicItems'));
removeUserItems = function() {
return app.execute('inventory:remove:user:items', user.id);
};
cb = function() {
return app.vent.once('inventory:change', removeUserItems);
};
return setTimeout(cb, 500);
};
updateInventoryMetadata = function() {
return app.execute('metadata:update', {
title: _.I18n('title_browse_layout'),
url: '/inventory'
});
};
});
;require.register("modules/inventory/views/inventory_welcome", function(exports, require, module) {
var NoItem;
NoItem = require('./no_item');
module.exports = Marionette.ItemView.extend({
className: "inventoryWelcome",
template: require('./templates/inventory_welcome'),
events: {
'click #jumpIn': function() {
return app.execute('show:joyride:welcome:tour');
}
}
});
});
;require.register("modules/inventory/views/item_comments", function(exports, require, module) {
var behaviorsPlugin, forms_, loginPlugin, messagesPlugin;
behaviorsPlugin = require('modules/general/plugins/behaviors');
messagesPlugin = require('modules/general/plugins/messages');
forms_ = require('modules/general/lib/forms');
loginPlugin = require('modules/general/plugins/login');
module.exports = Marionette.CompositeView.extend({
className: 'itemComments panel',
template: require('./templates/item_comments'),
childViewContainer: '.comments',
childView: require('./comment'),
initialize: function() {
var ref;
ref = app.request('comments:init', this.model), this.collection = ref[0], this.fetching = ref[1];
return this.initPlugins();
},
initPlugins: function() {
_.extend(this, behaviorsPlugin, messagesPlugin);
if (!app.user.loggedIn) {
return loginPlugin.call(this);
}
},
events: {
'click .postComment': 'postComment'
},
childEvents: {
'edit:toggle': 'toggleNewComment'
},
behaviors: {
AlertBox: {},
Loading: {},
ElasticTextarea: {}
},
ui: {
message: 'textarea.message',
newCommentDiv: '.newComment'
},
serializeData: function() {
return {
user: app.user.toJSON(),
loggedIn: app.user.loggedIn
};
},
onShow: function() {
if (this.fetching != null) {
this.startLoading();
return this.fetching["finally"](this.stopLoading.bind(this));
}
},
postComment: function() {
return this.postMessage('comments:post', this.model.comments);
},
toggleNewComment: function() {
return this.ui.newCommentDiv.toggle();
}
});
});
;require.register("modules/inventory/views/item_figure", function(exports, require, module) {
var detailsLimit, itemActions, itemUpdaters;
itemActions = require('../plugins/item_actions');
itemUpdaters = require('../plugins/item_updaters');
detailsLimit = 150;
module.exports = Marionette.ItemView.extend({
tagName: 'figure',
className: function() {
var busy;
this.uniqueSelector = "." + this.cid;
busy = this.model.get('busy') ? 'busy' : '';
return "itemContainer " + this.cid + " " + busy;
},
template: require('./templates/item_figure'),
behaviors: {
PreventDefault: {},
ConfirmationModal: {}
},
initialize: function() {
this.initPlugins();
this.lazyRender = _.LazyRender(this, 400);
this.listenTo(this.model, 'change', this.lazyRender);
return this.listenTo(this.model, 'grab:entity', this.lazyRender);
},
initPlugins: function() {
itemActions.call(this);
return itemUpdaters.call(this);
},
onRender: function() {
app.execute('foundation:reload');
return app.execute('qlabel:update');
},
events: {
'click .edit': 'itemEdit',
'click a.requestItem': function() {
return app.execute('show:item:request', this.model);
}
},
serializeData: function() {
var attrs, ref;
attrs = this.model.serializeData();
attrs.date = {
date: attrs.created
};
attrs.detailsMore = this.detailsMoreData(attrs.details);
attrs.details = this.detailsData(attrs.details);
attrs.showDistance = this.options.showDistance && (((ref = attrs.user) != null ? ref.distance : void 0) != null);
return attrs;
},
itemEdit: function() {
return app.execute('show:item:form:edition', this.model);
},
detailsMoreData: function(details) {
if ((details != null ? details.length : void 0) > detailsLimit) {
return true;
} else {
return false;
}
},
detailsData: function(details) {
if ((details != null ? details.length : void 0) > detailsLimit) {
return _.cutBeforeWord(details, detailsLimit) + " ...";
} else {
return details;
}
}
});
});
;require.register("modules/inventory/views/item_row", function(exports, require, module) {
var itemActions;
itemActions = require('../plugins/item_actions');
module.exports = Marionette.ItemView.extend({
tagName: 'tr',
template: require('./templates/item_row'),
behaviors: {
PreventDefault: {},
PlainTextAuthorLink: {}
},
initialize: function() {
return this.initPlugins();
},
initPlugins: function() {
return itemActions.call(this);
},
serializeData: function() {
return this.model.serializeData();
},
onRender: function() {
return app.execute('qlabel:update');
}
});
});
;require.register("modules/inventory/views/item_show", function(exports, require, module) {
var ChangePicture, EntityData, ItemComments, ItemTransactions, PicturePicker, itemActions, itemUpdaters;
ItemComments = require('./item_comments');
ItemTransactions = require('./item_transactions');
EntityData = require('modules/entities/views/entity_data');
PicturePicker = require('modules/general/views/behaviors/picture_picker');
ChangePicture = require('modules/general/views/behaviors/change_picture');
itemActions = require('../plugins/item_actions');
itemUpdaters = require('../plugins/item_updaters');
module.exports = Marionette.LayoutView.extend({
id: 'itemShowLayout',
template: require('./templates/item_show'),
regions: {
entityRegion: '#entity',
pictureRegion: '#picture',
transactionsRegion: '#transactions',
commentsRegion: '#comments'
},
behaviors: {
PreventDefault: {},
ConfirmationModal: {},
ElasticTextarea: {}
},
initialize: function() {
this.lazyRender = _.LazyRender(this);
this.initPlugins();
this.uniqueSelector = '#' + this.id;
this.listenTo(this.model, 'change:details', this.lazyRender);
this.listenTo(this.model, 'change:notes', this.lazyRender);
this.listenTo(this.model, 'add:pictures', this.lazyRender);
this.listenTo(this.model, 'grab:user', this.lazyRender);
return app.execute('metadata:update:needed');
},
initPlugins: function() {
itemActions.call(this);
return itemUpdaters.call(this);
},
onRender: function() {
this.showEntityData();
this.showPicture();
this.showComments();
app.execute('foundation:reload');
if (app.user.loggedIn) {
return this.showTransactions();
}
},
onShow: function() {
return this.model.updateMetadata()["finally"](app.execute.bind(app, 'metadata:update:done'));
},
showEntityData: function() {
var entity;
entity = this.model.entity;
if (entity != null) {
return this.showEntity(entity);
} else {
return this.listenTo(this.model, 'grab:entity', this.showEntity.bind(this));
}
},
showEntity: function(entity) {
return this.entityRegion.show(new EntityData({
model: entity,
hidePicture: true
}));
},
showPicture: function() {
var picture;
picture = new ChangePicture({
model: this.model
});
return this.pictureRegion.show(picture);
},
events: {
'click a#destroy': 'itemDestroy',
'click a#changePicture': 'changePicture',
'click a#editDetails, a#cancelDetailsEdition': 'toggleDetailsEditor',
'click a#validateDetails': 'validateDetails',
'click a#editNotes, a#cancelNotesEdition': 'toggleNotesEditor',
'click a#validateNotes': 'validateNotes',
'click a.requestItem': function() {
return app.execute('show:item:request', this.model);
}
},
serializeData: function() {
var attrs;
attrs = this.model.serializeData();
return _.extend(attrs, {
nextPictures: this.nextPicturesData(attrs)
});
},
nextPicturesData: function(attrs) {
var ref;
if (((ref = attrs.pictures) != null ? ref.length : void 0) > 1) {
return attrs.pictures.slice(1);
}
},
itemEdit: function() {
return app.execute('show:item:form:edition', this.model);
},
changePicture: function() {
var picturePicker;
picturePicker = new PicturePicker({
pictures: this.model.get('pictures'),
limit: 1,
save: this.savePicture.bind(this)
});
return app.layout.modal.show(picturePicker);
},
savePicture: function(value) {
return app.request('item:update', {
item: this.model,
attribute: 'pictures',
value: value
});
},
itemDestroy: function() {
return app.request('item:destroy', {
model: this.model,
selector: this.uniqueSelector,
next: function() {
return app.execute('show:home');
}
});
},
toggleDetailsEditor: function() {
return this.toggleEditor('details');
},
toggleNotesEditor: function() {
return this.toggleEditor('notes');
},
validateDetails: function() {
return this.validateEdit('details');
},
validateNotes: function() {
return this.validateEdit('notes');
},
toggleEditor: function(nameBase) {
$("#" + nameBase).toggle();
return $("#" + nameBase + "Editor").toggle();
},
validateEdit: function(nameBase) {
var edited;
this.toggleEditor(nameBase);
edited = $("#" + nameBase + "Editor textarea").val();
if (edited !== this.model.get(nameBase)) {
return app.request('item:update', {
item: this.model,
attribute: nameBase,
value: edited,
selector: "#" + nameBase + "Editor"
});
}
},
showComments: function() {
return this.commentsRegion.show(new ItemComments({
model: this.model
}));
},
showTransactions: function() {
if (this.transactions == null) {
this.transactions = app.request('get:transactions:ongoing:byItemId', this.model.id);
}
return this.transactionsRegion.show(new ItemTransactions({
collection: this.transactions
}));
},
afterDestroy: function() {
return app.execute('show:inventory:main:user');
}
});
});
;require.register("modules/inventory/views/item_transactions", function(exports, require, module) {
module.exports = Marionette.CompositeView.extend({
className: 'itemTransactions',
template: require('./templates/item_transactions'),
childViewContainer: '.transactions',
childView: require('modules/transactions/views/transaction_preview'),
childViewOptions: {
onItem: true
}
});
});
;require.register("modules/inventory/views/items_grid", function(exports, require, module) {
module.exports = Marionette.CompositeView.extend({
className: 'itemsGrid',
template: require('./templates/items_grid'),
childViewContainer: 'tbody',
childView: require('./item_row'),
emptyView: require('./no_item')
});
});
;require.register("modules/inventory/views/items_list", function(exports, require, module) {
var behaviorsPlugin, itemsPerPage, masonryPlugin, paginationPlugin;
behaviorsPlugin = require('modules/general/plugins/behaviors');
paginationPlugin = require('modules/general/plugins/pagination');
masonryPlugin = require('modules/general/plugins/masonry');
itemsPerPage = require('modules/inventory/lib/items_per_pages');
module.exports = Marionette.CompositeView.extend({
className: 'itemsListWrapper',
template: require('./templates/items_list'),
childViewContainer: '.itemsList',
childView: require('./item_figure'),
emptyView: require('./no_item'),
behaviors: {
Loading: {}
},
ui: {
itemsList: '.itemsList'
},
childViewOptions: function() {
return {
showDistance: this.options.showDistance
};
},
initialize: function() {
return this.initPlugins();
},
initPlugins: function() {
_.extend(this, behaviorsPlugin);
paginationPlugin.call(this, {
batchLength: itemsPerPage(),
fetchMore: this.options.fetchMore,
more: this.options.more
});
return masonryPlugin.call(this, '.itemsList', '.itemContainer');
},
serializeData: function() {
return {
header: this.options.header
};
},
events: {
'inview .more': 'infiniteScroll'
},
collectionEvents: {
'render': 'stopLoading',
'filtered:add': 'lazyMasonryRefresh'
},
childEvents: {
'render': 'lazyMasonryRefresh',
'resize': 'lazyMasonryRefresh'
},
infiniteScroll: function() {
if (this.more()) {
this.startLoading('.more');
return this.displayMore();
}
}
});
});
;require.register("modules/inventory/views/no_item", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
tagName: "div",
className: "text-center hidden",
template: require('./templates/no_item'),
onShow: function() {
return this.$el.fadeIn();
}
});
});
;require.register("modules/inventory/views/templates/comment", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <span class=\"edited core\">\n - <a title=\""
+ alias3((helpers.timeFromNow || (depth0 && depth0.timeFromNow) || alias2).call(alias1,(depth0 != null ? depth0.edited : depth0),{"name":"timeFromNow","hash":{},"data":data}))
+ "\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"edited",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n </span>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"avatar\">\n <img src=\""
+ alias3((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.picture : stack1),50,{"name":"src","hash":{},"data":data}))
+ "\">\n</div>\n\n<div class=\"rest\">\n\n <div class=\"header\">\n <div class=\"core\">\n <span class=\"username\">"
+ alias3(container.lambda(((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.username : stack1), depth0))
+ "</span>\n <span class=\"message\">"
+ alias3((helpers.userContent || (depth0 && depth0.userContent) || alias2).call(alias1,(depth0 != null ? depth0.message : depth0),{"name":"userContent","hash":{},"data":data}))
+ "</span>\n </div>\n <div class=\"core hidden\">\n <form>\n <textarea class=\"message\" name=\"message\" placeholder=\"edit comment...\">"
+ alias3(((helper = (helper = helpers.message || (depth0 != null ? depth0.message : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"message","hash":{},"data":data}) : helper)))
+ "</textarea>\n <div class=\"right\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"save_cancel",{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n </form>\n </div>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory:comment_edit_menu",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n <div>\n <span class=\"time core\">"
+ alias3((helpers.timeFromNow || (depth0 && depth0.timeFromNow) || alias2).call(alias1,(depth0 != null ? depth0.created : depth0),{"name":"timeFromNow","hash":{},"data":data}))
+ "</span>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.edited : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/comment_edit_menu", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <a class=\"menu\" data-options=\"align:left\" data-dropdown=\""
+ alias4(((helper = (helper = helpers.cid || (depth0 != null ? depth0.cid : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"cid","hash":{},"data":data}) : helper)))
+ "-menu\" title=\""
+ alias4((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"edit",{"name":"i18n","hash":{},"data":data}))
+ "\" aria-autoclose=\"true\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.editRight : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.program(4, data, 0),"data":data})) != null ? stack1 : "")
+ " </a>\n <ul id=\""
+ alias4(((helper = (helper = helpers.cid || (depth0 != null ? depth0.cid : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"cid","hash":{},"data":data}) : helper)))
+ "-menu\" class=\"tiny f-dropdown\" data-dropdown-content>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.editRight : depth0),{"name":"if","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " <li>\n <a class=\"delete\">\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"times",{"name":"icon","hash":{},"data":data}))
+ alias4((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"delete",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n </li>\n </ul>\n";
},"2":function(container,depth0,helpers,partials,data) {
return " "
+ container.escapeExpression((helpers.icon || (depth0 && depth0.icon) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"pencil",{"name":"icon","hash":{},"data":data}))
+ "\n";
},"4":function(container,depth0,helpers,partials,data) {
return " "
+ container.escapeExpression((helpers.icon || (depth0 && depth0.icon) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"times",{"name":"icon","hash":{},"data":data}))
+ "\n";
},"6":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <li>\n <a class=\"edit\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"pencil",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"edit",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n </li>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return "<div class=\"icon-buttons\">\n"
+ ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.deleteRight : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/controls", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <a class=\""
+ alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
+ " transaction active\" title=\""
+ alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
+ "\">"
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,(depth0 != null ? depth0.icon : depth0),{"name":"icon","hash":{},"data":data}))
+ "</a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<a class=\"showControls\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"wrench",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"chevron-right",{"name":"icon","hash":{},"data":data}))
+ "\n</a>\n<div class=\"innerControls\">\n <div class=\"layouts\">\n <a class=\"cascade\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"th-large",{"name":"icon","hash":{},"data":data}))
+ "</a>\n <a class=\"grid\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"align-justify",{"name":"icon","hash":{},"data":data}))
+ "</a>\n </div>\n <div class=\"transactions\">\n"
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.transactions : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n <input type=\"text\" class=\"filter\" placeholder=\"filter...\">\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/inventory", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<div id=\"innerMain\">\n <div id=\"sideNav\" class=\"sideNavClones\"></div>\n <div id=\"shadowSideNav\" class=\"sideNavClones\"></div>\n <div id=\"inventoryView\">\n <div id=\"header\"></div>\n <div id=\"itemsView\">"
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"loader",{"name":"partial","hash":{},"data":data}))
+ "</div>\n <div id=\"controls\"></div>\n </div>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/inventory_welcome", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<h2>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"welcome in your inventory!",{"name":"i18n","hash":{},"data":data}))
+ "</h2>\n<div>\n <a id=\"jumpIn\" class=\"button secondary radius bold\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"get a tour",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n</div>\n<div>\n <a class=\"showWelcome\" class=\"grey\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"back to welcome screen",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/item_comments", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <div class=\"local-fog\">\n <p>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"you need to be connected to comment",{"name":"i18n","hash":{},"data":data}))
+ "</p>\n <div class=\"login-buttons\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:login_buttons",{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n </div>\n";
},"3":function(container,depth0,helpers,partials,data) {
var stack1;
return " <img src=\""
+ container.escapeExpression((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.picture : stack1),50,{"name":"src","hash":{},"data":data}))
+ "\">\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"comments\">\n <div class=\"loading\"></div>\n</div>\n\n<div class=\"newComment\">\n"
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.loggedIn : depth0),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " <form>\n <div class=\"main\">\n <div class=\"avatar\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.loggedIn : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n <textarea class=\"message ctrlEnterClick\" name=\"message\" placeholder=\"post a comment...\">"
+ alias3(((helper = (helper = helpers.message || (depth0 != null ? depth0.message : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"message","hash":{},"data":data}) : helper)))
+ "</textarea>\n </div>\n <div class=\"alertBox\"></div>\n <div class=\"bottom\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"ctrl_enter_click_tip",{"name":"partial","hash":{},"data":data}))
+ "\n <a class=\"tiny-success-button postComment right\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"post comment",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n </div>\n </form>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/item_details", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <a id=\"editDetails\" class=\"editButton\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"edit",{"name":"i18n","hash":{},"data":data}))
+ "\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"pencil",{"name":"icon","hash":{},"data":data}))
+ "</a>\n <span data-tooltip class=\"has-tip indicator\"\n title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"this is visible by anyone who can see this item",{"name":"i18n","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.currentListing : depth0)) != null ? stack1.icon : stack1),{"name":"icon","hash":{},"data":data}))
+ "\n </span>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"detailsPanel panel\">\n <div class=\"icon-buttons-header\">\n <label>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"details",{"name":"i18n","hash":{},"data":data}))
+ "</label>\n <div class=\"right\">\n"
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.restricted : depth0),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n </div>\n <p id=\"details\" class=\"user-content\">\n "
+ alias3((helpers.userContent || (depth0 && depth0.userContent) || alias2).call(alias1,(depth0 != null ? depth0.details : depth0),{"name":"userContent","hash":{},"data":data}))
+ "\n </p>\n <div id=\"detailsEditor\" class='hidden'>\n <textarea placeholder='("
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"details_placeholder",{"name":"i18n","hash":{},"data":data}))
+ ")'>"
+ alias3(((helper = (helper = helpers.details || (depth0 != null ? depth0.details : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"details","hash":{},"data":data}) : helper)))
+ "</textarea>\n <div class=\"button-group-right\">\n <a id=\"cancelDetailsEdition\" class=\"cancelButton\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"cancel",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n <a id=\"validateDetails\" class=\"validateButton\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"edit",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n </div>\n </div>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/item_figure", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <div class=\"busy-sign\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"unavailable",{"name":"i18n","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"sign-out",{"name":"icon","hash":{},"data":data}))
+ "\n </div>\n";
},"3":function(container,depth0,helpers,partials,data) {
return " <img src=\""
+ container.escapeExpression((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.picture : depth0),300,{"name":"src","hash":{},"data":data}))
+ "\">\n";
},"5":function(container,depth0,helpers,partials,data) {
var stack1;
return " "
+ container.escapeExpression((helpers.claim || (depth0 && depth0.claim) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.entityData : depth0)) != null ? stack1.claims : stack1),"P50",{"name":"claim","hash":{},"data":data}))
+ "\n";
},"7":function(container,depth0,helpers,partials,data) {
var stack1;
return " "
+ ((stack1 = (helpers.joinAuthors || (depth0 && depth0.joinAuthors) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.entityData : depth0)) != null ? stack1.authors : stack1),false,{"name":"joinAuthors","hash":{},"data":data})) != null ? stack1 : "")
+ "\n";
},"9":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {};
return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.restricted : depth0),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.program(12, data, 0),"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.details : depth0),{"name":"if","hash":{},"fn":container.program(14, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(alias1,"inventory:item_request_box",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n";
},"10":function(container,depth0,helpers,partials,data) {
return " "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"inventory:item_mixed_box",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n";
},"12":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory:item_user_box",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n <div class=\"item-settings itemBox\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory:item_transaction_box",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory:item_visibility_box",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n";
},"14":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {};
return " <div class=\"detailsBox\">\n <span class=\"details wrapped user-content\">\n "
+ container.escapeExpression((helpers.userContent || (depth0 && depth0.userContent) || helpers.helperMissing).call(alias1,(depth0 != null ? depth0.details : depth0),{"name":"userContent","hash":{},"data":data}))
+ "\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.detailsMore : depth0),{"name":"if","hash":{},"fn":container.program(15, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </span>\n </div>\n";
},"15":function(container,depth0,helpers,partials,data) {
return " <a class='itemShow more'>"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"see more",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.busy : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "<a class=\"itemShow\" href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\" rel=\"nofollow\">\n <div class=\"cover\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.picture : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n <div class=\"data\">\n <h3 class=\"title\">\n "
+ alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
+ "\n </h3>\n <hr>\n <div class=\"authors\">\n"
+ ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.entityData : depth0)) != null ? stack1.wikidata : stack1),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.program(7, data, 0),"data":data})) != null ? stack1 : "")
+ " </div>\n </div>\n</a>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.userReady : depth0),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/item_mixed_box", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return " <span class=\"distance\">"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"km_away",(depth0 != null ? depth0.user : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</span>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.lambda, alias2=container.escapeExpression, alias3=depth0 != null ? depth0 : {}, alias4=helpers.helperMissing;
return "<div class=\"mixedBox\">\n <a href=\""
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.pathname : stack1), depth0))
+ "\" class=\"userShow\">\n <img class=\"profilePic\" src=\""
+ alias2((helpers.src || (depth0 && depth0.src) || alias4).call(alias3,((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.picture : stack1),48,{"name":"src","hash":{},"data":data}))
+ "\">\n </a>\n <a class=\"itemShow\">\n <div class=\"transactionBox "
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.currentTransaction : depth0)) != null ? stack1.id : stack1), depth0))
+ "\">\n "
+ alias2((helpers.icon || (depth0 && depth0.icon) || alias4).call(alias3,((stack1 = (depth0 != null ? depth0.currentTransaction : depth0)) != null ? stack1.icon : stack1),{"name":"icon","hash":{},"data":data}))
+ "\n </div>\n </a>\n</div>\n<div class=\"labelBox "
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.currentTransaction : depth0)) != null ? stack1.id : stack1), depth0))
+ "\">\n <a class=\"itemShow label\">\n "
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias4).call(alias3,((stack1 = (depth0 != null ? depth0.currentTransaction : depth0)) != null ? stack1.labelPersonalized : stack1),(depth0 != null ? depth0.user : depth0),{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "\n </a>\n"
+ ((stack1 = helpers["if"].call(alias3,(depth0 != null ? depth0.showDistance : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/item_note", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"noteBox dark-panel\">\n <div class=\"icon-buttons-header\">\n <label>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"private notes",{"name":"i18n","hash":{},"data":data}))
+ "</label>\n <div class=\"right\">\n <a id=\"editNotes\" class=\"editButton\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"edit notes",{"name":"i18n","hash":{},"data":data}))
+ "\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"pencil",{"name":"icon","hash":{},"data":data}))
+ "</a>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory:item_notes_lock",{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n </div>\n <p id=\"notes\" class=\"user-content\">\n "
+ alias3((helpers.userContent || (depth0 && depth0.userContent) || alias2).call(alias1,(depth0 != null ? depth0.notes : depth0),{"name":"userContent","hash":{},"data":data}))
+ "\n </p>\n <div id=\"notesEditor\" class='hidden'>\n <textarea placeholder='("
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"notes_placeholder",{"name":"i18n","hash":{},"data":data}))
+ ")'>"
+ alias3(((helper = (helper = helpers.notes || (depth0 != null ? depth0.notes : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"notes","hash":{},"data":data}) : helper)))
+ "</textarea>\n <div class=\"button-group-right\">\n <a id=\"cancelNotesEdition\" class=\"cancelButton\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"cancel",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n <a id=\"validateNotes\" class=\"validateButton\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"edit",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n </div>\n </div>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/item_notes_lock", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<span data-tooltip class=\"has-tip indicator\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"notes_placeholder",{"name":"i18n","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"lock",{"name":"icon","hash":{},"data":data}))
+ "\n</span>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/item_request_box", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.busy : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.program(4, data, 0),"data":data})) != null ? stack1 : "");
},"2":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <div class=\"busy-box\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"sign-out",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"unavailable",{"name":"i18n","hash":{},"data":data}))
+ "\n </div>\n";
},"4":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.hasActiveTransaction : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.program(7, data, 0),"data":data})) != null ? stack1 : "");
},"5":function(container,depth0,helpers,partials,data) {
return " <a class=\"mainUserRequested\">\n "
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"main_user_requested",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n";
},"7":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.inventorying : depth0),{"name":"unless","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"8":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <div class=\"itemBox\">\n <a class=\"requestItem\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"comments",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"send request",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n </div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.restricted : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/item_row", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1;
return " "
+ container.escapeExpression((helpers.claim || (depth0 && depth0.claim) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.entityData : depth0)) != null ? stack1.claims : stack1),"P50",true,true,{"name":"claim","hash":{},"data":data}))
+ "\n";
},"3":function(container,depth0,helpers,partials,data) {
var stack1;
return " "
+ ((stack1 = (helpers.joinAuthors || (depth0 && depth0.joinAuthors) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.entityData : depth0)) != null ? stack1.authors : stack1),{"name":"joinAuthors","hash":{},"data":data})) != null ? stack1 : "")
+ "\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression, alias4=container.lambda;
return "<td class=\"title itemShow\">\n <a class=\"link itemShow\">"
+ alias3(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
+ "</a>\n</td>\n<td class=\"authors\">\n"
+ ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.entityData : depth0)) != null ? stack1.wikidata : stack1),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data})) != null ? stack1 : "")
+ "</td>\n<td class=\"user\">\n <a class=\"user link serif\" href=\""
+ alias3(alias4(((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.pathname : stack1), depth0))
+ "\">\n <img src=\""
+ alias3((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.picture : stack1),16,{"name":"src","hash":{},"data":data}))
+ "\">\n "
+ alias3(alias4(((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.username : stack1), depth0))
+ "\n </a>\n</td>\n<td>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.transaction : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</td>\n<td>"
+ alias3((helpers.timeFromNow || (depth0 && depth0.timeFromNow) || alias2).call(alias1,(depth0 != null ? depth0.created : depth0),{"name":"timeFromNow","hash":{},"data":data}))
+ "</td>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/item_show", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper;
return " <div class=\"entityData\">\n <h2>"
+ container.escapeExpression(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"title","hash":{},"data":data}) : helper)))
+ "</h2>\n </div>\n";
},"3":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.restricted : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.program(6, data, 0),"data":data})) != null ? stack1 : "");
},"4":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory:item_mixed_box",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory:item_request_box",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n";
},"6":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory:item_user_box",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n <div class=\"item-settings itemBox\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory:item_transaction_box",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory:item_visibility_box",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory:remove_item",{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n";
},"8":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.restricted : depth0),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.program(12, data, 0),"data":data})) != null ? stack1 : "");
},"9":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.details : depth0),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"10":function(container,depth0,helpers,partials,data) {
return " "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"inventory:item_details",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n";
},"12":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory:item_note",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory:item_details",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<div id=\"entityData\">\n <div id=\"picture\"></div>\n <div id=\"entity\">\n"
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.entityData : depth0),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n <div class=\"icon-bar\">\n <a href=\""
+ alias4(((helper = (helper = helpers.entityPathname || (depth0 != null ? depth0.entityPathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"entityPathname","hash":{},"data":data}) : helper)))
+ "\" class=\"showEntity\">\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"cube",{"name":"icon","hash":{},"data":data}))
+ "\n <span>"
+ alias4((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"who else has it?",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n </a>\n <a class=\"shareLink\" href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\">\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"share-alt",{"name":"icon","hash":{},"data":data}))
+ "\n <span>"
+ alias4((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"share",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n </a>\n </div>\n</div>\n\n<div class=\"itemData\">\n <div class=\"leftBox\">\n <div class=\"panel\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.userReady : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n <div id=\"transactions\"></div>\n </div>\n <div class=\"rightBox\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.userReady : depth0),{"name":"if","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " <div id=\"comments\"></div>\n </div>\n</div>\n"
+ alias4((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:embedded_welcome",{"name":"partial","hash":{},"data":data}));
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/item_transaction_box", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <a class=\"current itemShow\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.currentTransaction : depth0)) != null ? stack1.icon : stack1),{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.currentTransaction : depth0)) != null ? stack1.labelShort : stack1),{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n";
},"3":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <a class=\"current\" data-dropdown=\""
+ alias4(((helper = (helper = helpers.cid || (depth0 != null ? depth0.cid : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"cid","hash":{},"data":data}) : helper)))
+ "-t-menu\">\n <span class=\"icon\">\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.currentTransaction : depth0)) != null ? stack1.icon : stack1),{"name":"icon","hash":{},"data":data}))
+ "\n </span>\n <span class=\"rest\">\n <span class=\"label\">"
+ alias4((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.currentTransaction : depth0)) != null ? stack1.labelShort : stack1),{"name":"i18n","hash":{},"data":data}))
+ "</span>\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"caret-down",{"name":"icon","hash":{},"data":data}))
+ "\n </span>\n </a>\n <ul id=\""
+ alias4(((helper = (helper = helpers.cid || (depth0 != null ? depth0.cid : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"cid","hash":{},"data":data}) : helper)))
+ "-t-menu\" data-options=\"align:right\"\n class=\"tiny f-dropdown\" data-dropdown-content>\n <li class=\"label2 capitalized\">"
+ alias4((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"available for",{"name":"i18n","hash":{},"data":data}))
+ ":</li>\n"
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.transactions : depth0),{"name":"each","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </ul>\n";
},"4":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <li>\n <a id=\""
+ alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
+ "\" class=\"transaction "
+ alias4(((helper = (helper = helpers.classes || (depth0 != null ? depth0.classes : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"classes","hash":{},"data":data}) : helper)))
+ "\">\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,(depth0 != null ? depth0.icon : depth0),{"name":"icon","hash":{},"data":data}))
+ " "
+ alias4((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.label : depth0),{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n </li>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return "<div class=\"transactionBox "
+ container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.currentTransaction : depth0)) != null ? stack1.id : stack1), depth0))
+ "\">\n"
+ ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.restricted : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data})) != null ? stack1 : "")
+ "</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/item_transactions", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<div class=\"transactions\"></div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/item_user_box", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.lambda, alias2=container.escapeExpression;
return "<a class=\"user\" href=\""
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.pathname : stack1), depth0))
+ "\">\n <div class=\"userBox\">\n <img class=\"profilePic\" src=\""
+ alias2((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.picture : stack1),48,{"name":"src","hash":{},"data":data}))
+ "\">\n <span class=\"user\" href=\""
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.pathname : stack1), depth0))
+ "\">\n <strong class=\"username\">"
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.username : stack1), depth0))
+ "</strong>\n </span>\n </div>\n</a>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/item_visibility_box", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=container.escapeExpression, alias2=depth0 != null ? depth0 : {}, alias3=helpers.helperMissing, alias4="function";
return " <div class=\"listingMenu "
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.currentListing : depth0)) != null ? stack1.id : stack1), depth0))
+ "\">\n <a class=\"current\" data-dropdown=\""
+ alias1(((helper = (helper = helpers.cid || (depth0 != null ? depth0.cid : depth0)) != null ? helper : alias3),(typeof helper === alias4 ? helper.call(alias2,{"name":"cid","hash":{},"data":data}) : helper)))
+ "-l-menu\">\n <span class=\"icon\">"
+ alias1((helpers.icon || (depth0 && depth0.icon) || alias3).call(alias2,((stack1 = (depth0 != null ? depth0.currentListing : depth0)) != null ? stack1.icon : stack1),{"name":"icon","hash":{},"data":data}))
+ "</span>\n <span class=\"rest\">\n <span class=\"label\">"
+ alias1((helpers.i18n || (depth0 && depth0.i18n) || alias3).call(alias2,((stack1 = (depth0 != null ? depth0.currentListing : depth0)) != null ? stack1.label : stack1),{"name":"i18n","hash":{},"data":data}))
+ "</span>\n "
+ alias1((helpers.icon || (depth0 && depth0.icon) || alias3).call(alias2,"caret-down",{"name":"icon","hash":{},"data":data}))
+ "\n </span>\n </a>\n <ul id=\""
+ alias1(((helper = (helper = helpers.cid || (depth0 != null ? depth0.cid : depth0)) != null ? helper : alias3),(typeof helper === alias4 ? helper.call(alias2,{"name":"cid","hash":{},"data":data}) : helper)))
+ "-l-menu\" data-options=\"align:right\"\n class=\"tiny f-dropdown\" data-dropdown-content>\n <li class=\"label2 capitalized\">"
+ alias1((helpers.i18n || (depth0 && depth0.i18n) || alias3).call(alias2,"change visibility:",{"name":"i18n","hash":{},"data":data}))
+ "</li>\n"
+ ((stack1 = helpers.each.call(alias2,(depth0 != null ? depth0.listings : depth0),{"name":"each","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " <li><label>"
+ alias1((helpers.i18n || (depth0 && depth0.i18n) || alias3).call(alias2,"other operations:",{"name":"i18n","hash":{},"data":data}))
+ "</label></li>\n <li>\n "
+ alias1((helpers.partial || (depth0 && depth0.partial) || alias3).call(alias2,"inventory:remove_item",{"name":"partial","hash":{},"data":data}))
+ "\n </li>\n </ul>\n </div>\n";
},"2":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <li>\n <a id=\""
+ alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
+ "\" class=\"listing "
+ alias4(((helper = (helper = helpers.classes || (depth0 != null ? depth0.classes : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"classes","hash":{},"data":data}) : helper)))
+ "\">\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,(depth0 != null ? depth0.icon : depth0),{"name":"icon","hash":{},"data":data}))
+ " "
+ alias4((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.label : depth0),{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n </li>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.restricted : depth0),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/items_grid", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<table>\n <thead>\n <tr>\n <th>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"title",{"name":"i18n","hash":{},"data":data}))
+ "</th>\n <th>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"authors",{"name":"i18n","hash":{},"data":data}))
+ "</th>\n <th>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"owner",{"name":"i18n","hash":{},"data":data}))
+ "</th>\n <th>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"transaction",{"name":"i18n","hash":{},"data":data}))
+ "</th>\n <th>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"added",{"name":"i18n","hash":{},"data":data}))
+ "</th>\n </tr>\n </thead>\n <tbody></tbody>\n</table>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/items_list", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression;
return " <h3 class=\""
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.header : depth0)) != null ? stack1.classes : stack1), depth0))
+ "\">"
+ alias1((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.header : depth0)) != null ? stack1.text : stack1),{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.header : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "<div class=\"itemsList\"></div>\n<div class=\"more\">\n <span class=\"loading\"></span>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/no_item", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"cube","big grey",{"name":"icon","hash":{},"data":data}))
+ "\n<p class=\"grey\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"no item here",{"name":"i18n","hash":{},"data":data}))
+ "...</p>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/inventory/views/templates/remove_item", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<a class=\"remove dark-grey\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"trash-o",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"delete",{"name":"I18n","hash":{},"data":data}))
+ "</a>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/map/lib/build_marker", function(exports, require, module) {
var ObjectMarker, customIcon, groupMarker, markers, userMarker;
userMarker = require('../views/templates/user_marker');
groupMarker = require('../views/templates/group_marker');
customIcon = require('./custom_icon');
ObjectMarker = function(markerBuilder) {
var objectMarker;
return objectMarker = function(params) {
var html, icon, lat, lng, marker, model, ref;
model = params.model;
ref = model.getCoords(), lat = ref.lat, lng = ref.lng;
html = markerBuilder(model.serializeData());
icon = customIcon(html);
marker = L.marker([lat, lng], {
icon: icon
});
return marker;
};
};
markers = {
user: ObjectMarker(userMarker),
group: ObjectMarker(groupMarker),
circle: function(params) {
var latLng, metersRadius;
latLng = params.latLng, metersRadius = params.metersRadius;
if (metersRadius == null) {
metersRadius = 200;
}
return L.circle(latLng, metersRadius);
}
};
module.exports = function(params) {
var markerType;
markerType = params.markerType;
return markers[markerType](params);
};
});
;require.register("modules/map/lib/config", function(exports, require, module) {
var accessToken;
accessToken = "pk.eyJ1IjoibWF4bGF0aGEiLCJhIjoiY2lldm9xdjFrMDBkMnN6a3NmY211MzQxcyJ9.a7_CBy6Xao-yF6f1cjsBNA";
L.Icon.Default.imagePath = '/public/images/map';
module.exports = {
tileUrl: "https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=" + accessToken,
settings: {
attribution: "Map data &copy; <a href=\"http://openstreetmap.org\">OpenStreetMap</a> contributors,\n<a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA</a>,\nImagery © <a href=\"http://mapbox.com\">Mapbox</a>",
minZoom: 2,
maxZoom: 18,
id: 'maxlatha.gd5jof9d',
accessToken: accessToken,
noWrap: true
},
defaultZoom: 13
};
});
;require.register("modules/map/lib/custom_icon", function(exports, require, module) {
module.exports = function(html, className) {
if (className == null) {
className = '';
}
return L.divIcon({
className: "map-icon " + className,
html: html
});
};
});
;require.register("modules/map/lib/draw", function(exports, require, module) {
var AddMarkerToCluster, AddMarkerToMap, buildMarker, defaultZoom, error_, initWithCluster, initWithoutCluster, ref, settings, tileUrl,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
ref = require('./config'), tileUrl = ref.tileUrl, settings = ref.settings, defaultZoom = ref.defaultZoom;
buildMarker = require('./build_marker');
error_ = require('lib/error');
module.exports = function(params) {
var cluster, containerId, latLng, map, zoom;
containerId = params.containerId, latLng = params.latLng, zoom = params.zoom, cluster = params.cluster;
zoom || (zoom = defaultZoom);
map = L.map(containerId).setView(latLng, zoom);
L.tileLayer(tileUrl, settings).addTo(map);
if (cluster) {
initWithCluster(map);
} else {
initWithoutCluster(map);
}
return map;
};
initWithCluster = function(map) {
var cluster;
cluster = L.markerClusterGroup();
cluster._objectIds = [];
map.addLayer(cluster);
map.addMarker = AddMarkerToCluster(cluster);
};
initWithoutCluster = function(map) {
map.addMarker = AddMarkerToMap(map);
};
AddMarkerToMap = function(map) {
var addMarkerToMap;
return addMarkerToMap = function(params) {
var marker;
marker = buildMarker(params);
marker.addTo(map);
return marker;
};
};
AddMarkerToCluster = function(cluster) {
var addMarkerToCluster;
return addMarkerToCluster = function(params) {
var marker, objectId;
objectId = params.objectId;
if (indexOf.call(cluster._objectIds, objectId) >= 0) {
_.log(objectId, 'not re-adding known object');
return;
}
marker = buildMarker(params);
cluster.addLayer(marker);
cluster._objectIds.push(objectId);
_.log(objectId, 'added unknown object');
return marker;
};
};
});
;require.register("modules/map/lib/map", function(exports, require, module) {
var defaultZoom, formatLeafletEvent, getCurrentPosition, map_, showGroupOnMap, showUserInventory, smartPreventDefault;
defaultZoom = require('./config').defaultZoom;
getCurrentPosition = require('./navigator_position');
smartPreventDefault = require('modules/general/lib/smart_prevent_default');
module.exports = map_ = {
draw: require('./draw'),
getCurrentPosition: getCurrentPosition,
updateRoute: function(root, lat, lng, zoom) {
var route;
if (zoom == null) {
zoom = defaultZoom;
}
route = _.buildPath(root, {
lat: lat,
lng: lng,
zoom: zoom
});
return app.navigate(route, {
preventScrollTop: true
});
},
updateRouteFromEvent: function(root, e) {
var _zoom, lat, lng, ref;
ref = e.target.getCenter(), lat = ref.lat, lng = ref.lng;
_zoom = e.target._zoom;
return map_.updateRoute(root, lat, lng, _zoom);
},
updateMarker: function(marker, coords) {
var lat, lng;
lat = coords.lat, lng = coords.lng;
return marker.setLatLng([lat, lng]);
},
showUsersOnMap: function(map, users) {
var i, len, ref, results, user;
ref = _.forceArray(users);
results = [];
for (i = 0, len = ref.length; i < len; i++) {
user = ref[i];
results.push(map_.showUserOnMap(map, user));
}
return results;
},
showGroupsOnMap: function(map, groups) {
var group, i, len, ref, results;
ref = _.forceArray(groups);
results = [];
for (i = 0, len = ref.length; i < len; i++) {
group = ref[i];
results.push(showGroupOnMap(map, group));
}
return results;
},
BoundFilter: function(map) {
var bounds, filter;
bounds = map.getBounds();
return filter = function(model) {
var point;
if (!model.hasPosition()) {
return false;
}
point = model.getLatLng();
return bounds.contains(point);
};
},
distanceBetween: function(a, b) {
_.types(arguments, 'arrays...');
a = new L.LatLng(a[0], a[1]);
b = new L.LatLng(b[0], b[1]);
return a.distanceTo(b) / 1000;
},
getBbox: function(map) {
var _northEast, _southWest, ref;
ref = map.getBounds(), _southWest = ref._southWest, _northEast = ref._northEast;
return [_southWest.lng, _southWest.lat, _northEast.lng, _northEast.lat];
},
showUserOnMap: function(map, user) {
var marker;
if (user.hasPosition()) {
marker = map.addMarker({
objectId: user.cid,
model: user,
markerType: 'user'
});
if (marker != null) {
return marker.on('click', showUserInventory.bind(null, user));
}
}
}
};
showGroupOnMap = function(map, group) {
if (group.hasPosition()) {
return map.addMarker({
objectId: group.cid,
model: group,
markerType: 'group'
});
}
};
showUserInventory = function(user, e) {
e = formatLeafletEvent(e);
smartPreventDefault(e);
if (!_.isOpenedOutside(e)) {
return app.execute('show:inventory:user', user);
}
};
formatLeafletEvent = function(e) {
e.which = e.originalEvent.which;
e.preventDefault = e.originalEvent.preventDefault.bind(e.originalEvent);
return e;
};
});
;require.register("modules/map/lib/navigator_position", function(exports, require, module) {
var PositionError, currentPosition, errIcon, normalizeCoords;
errIcon = _.icon('bolt');
currentPosition = function() {
return new Promise(function(resolve, reject) {
var err, formattedReject, ref;
if (((ref = navigator.geolocation) != null ? ref.getCurrentPosition : void 0) == null) {
err = new Error('getCurrentPosition isnt accessible');
return reject(err);
}
formattedReject = function(err) {
_.error(err, 'currentPosition err');
return reject(new Error(err.message || 'getCurrentPosition error'));
};
return navigator.geolocation.getCurrentPosition(resolve, formattedReject, {
timeout: 20 * 1000
});
});
};
normalizeCoords = function(position) {
var latitude, longitude, ref;
ref = position.coords, latitude = ref.latitude, longitude = ref.longitude;
return {
lat: latitude,
lng: longitude
};
};
PositionError = function(containerId) {
var catcher;
return catcher = function(err) {
$("#" + containerId).addClass('position-error').html(errIcon + _.i18n("couldn't obtain your position"));
throw err;
};
};
module.exports = function(containerId) {
return currentPosition().then(normalizeCoords).then(_.Log('current position'))["catch"](PositionError(containerId));
};
});
;require.register("modules/map/map", function(exports, require, module) {
var PositionPicker, map_, promptGroupPositionPicker, showGroupPositionPicker, showMainUserPositionPicker, showPositionPicker, updatePosition;
PositionPicker = require('./views/position_picker');
map_ = require('./lib/map');
module.exports = function() {
app.commands.setHandlers({
'show:position:picker:main:user': showMainUserPositionPicker,
'show:position:picker:group': showGroupPositionPicker
});
return app.reqres.setHandlers({
'prompt:group:position:picker': promptGroupPositionPicker
});
};
showPositionPicker = function(options) {
return app.layout.modal.show(new PositionPicker(options));
};
updatePosition = function(model, updateReqres, type) {
return showPositionPicker({
model: model,
type: type,
resolve: function(newCoords, selector) {
return app.request(updateReqres, {
attribute: 'position',
value: newCoords,
selector: selector,
model: model
});
}
});
};
showMainUserPositionPicker = function() {
return updatePosition(app.user, 'user:update', 'user');
};
showGroupPositionPicker = function(group) {
return updatePosition(group, 'group:update:settings', 'group');
};
promptGroupPositionPicker = function() {
return new Promise(function(resolve, reject) {
var err, error;
try {
return showPositionPicker({
resolve: resolve,
type: 'group'
});
} catch (error) {
err = error;
return reject(err);
}
});
};
});
;require.register("modules/map/views/position_picker", function(exports, require, module) {
var Check, containerId, error_, forms_, map_, ref, startLoading, stopLoading, typeStrings, updateMarker;
map_ = require('../lib/map');
forms_ = require('modules/general/lib/forms');
error_ = require('lib/error');
ref = require('modules/general/plugins/behaviors'), startLoading = ref.startLoading, stopLoading = ref.stopLoading, Check = ref.Check;
containerId = 'positionPickerMap';
module.exports = Marionette.ItemView.extend({
template: require('./templates/position_picker'),
className: 'positionPicker',
behaviors: {
AlertBox: {},
Loading: {},
SuccessCheck: {},
General: {}
},
events: {
'click #validatePosition': 'validatePosition',
'click #removePosition': 'removePosition'
},
initialize: function() {
var model;
model = this.options.model;
if (model != null) {
this.hasPosition = model.hasPosition();
return this.position = model.getCoords();
} else {
this.hasPosition = false;
return this.position = null;
}
},
serializeData: function() {
return _.extend({}, typeStrings[this.options.type], {
hasPosition: this.hasPosition,
position: this.position
});
},
onShow: function() {
app.execute('modal:open', 'large');
return setTimeout(this.initMap.bind(this), 500);
},
initMap: function() {
if (this.hasPosition) {
return this._initMap(this.position);
} else {
return map_.getCurrentPosition(containerId).then(this._initMap.bind(this));
}
},
_initMap: function(coords) {
var lat, lng, map, zoom;
lat = coords.lat, lng = coords.lng, zoom = coords.zoom;
map = map_.draw({
containerId: containerId,
latLng: [lat, lng],
zoom: zoom,
cluster: false
});
this.marker = map.addMarker({
markerType: 'circle',
metersRadius: this.getMarkerMetersRadius(),
latLng: [lat, lng]
});
return map.on('move', updateMarker.bind(null, this.marker));
},
getCoords: function() {
var lat, lng, ref1;
ref1 = this.marker._latlng, lat = ref1.lat, lng = ref1.lng;
return [lat, lng];
},
validatePosition: function() {
return this._updatePosition(this.getCoords(), '#validatePosition');
},
removePosition: function() {
return this._updatePosition(null, '#removePosition');
},
_updatePosition: function(newCoords, selector) {
startLoading.call(this, selector);
this.position = newCoords;
return _.preq.start.then(this.options.resolve.bind(null, newCoords, selector)).then(stopLoading.bind(this)).then(Check.call(this, '_updatePosition', this.close.bind(this)))["catch"](error_.Complete('.alertBox'))["catch"](forms_.catchAlert.bind(null, this));
},
close: function() {
return app.execute('modal:close');
},
getMarkerMetersRadius: function() {
switch (this.options.type) {
case 'group':
return 20;
case 'user':
return 200;
}
}
});
typeStrings = {
user: {
title: 'select your position',
context: 'position_privacy_context',
tip: 'position_privacy_tip'
},
group: {
title: "select the group's position",
context: 'group_position_context'
}
};
updateMarker = function(marker, e) {
return map_.updateMarker(marker, e.target.getCenter());
};
});
;require.register("modules/map/views/position_welcome", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
className: 'position-welcome',
template: require('./templates/map_welcome'),
events: {
'click #showPositionPicker': function() {
return app.execute('show:position:picker:main:user');
}
}
});
});
;require.register("modules/map/views/templates/group_marker", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<div class=\"groupIcon objectIcon\">\n <a href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\" title=\""
+ alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ " - "
+ alias4((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"group",{"name":"I18n","hash":{},"data":data}))
+ "\">\n <img src=\""
+ alias4((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,(depth0 != null ? depth0.picture : depth0),96,{"name":"src","hash":{},"data":data}))
+ "\">\n <p class=\"name label\">"
+ alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ "</p>\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"group",{"name":"icon","hash":{},"data":data}))
+ "\n </a>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/map/views/templates/map_welcome", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"map-welcome\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"map-marker",{"name":"icon","hash":{},"data":data}))
+ "\n <h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"you can now find books people nearby have to give, share or sell!",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"arrow-down",{"name":"icon","hash":{},"data":data}))
+ "\n</div>\n<section id=\"position-picker\" class=\"centered\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"map:position_picker_button",{"name":"partial","hash":{},"data":data}))
+ "\n</section>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/map/views/templates/position_picker", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <p class=\"tip\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"info-circle",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.tip : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</p>\n";
},"3":function(container,depth0,helpers,partials,data) {
return " <a id=\"removePosition\" class=\"button bold radius warning\">\n "
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"delete position",{"name":"i18n","hash":{},"data":data}))
+ "\n <span class=\"loading\"></span>\n </a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.title : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n<p class=\"context\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.context : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</p>\n<div id=\"positionPickerMap\" class=\"map-container\"></div>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.tip : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "<div class=\"bottom\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.position : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " <a id=\"validatePosition\" class=\"button bold radius success\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"save position",{"name":"i18n","hash":{},"data":data}))
+ "\n <span class=\"loading\"></span>\n </a>\n</div>\n<span class='check alertBox'></span>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/map/views/templates/position_picker_button", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<a id=\"showPositionPicker\" class=\"button bold radius\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"map-marker",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"edit your position",{"name":"i18n","hash":{},"data":data}))
+ "\n</a>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/map/views/templates/user_marker", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<div class=\"userIcon objectIcon\">\n <a href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\" title=\""
+ alias4(((helper = (helper = helpers.username || (depth0 != null ? depth0.username : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"username","hash":{},"data":data}) : helper)))
+ " - "
+ alias4((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"user",{"name":"I18n","hash":{},"data":data}))
+ "\">\n <img src=\""
+ alias4((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,(depth0 != null ? depth0.picture : depth0),60,{"name":"src","hash":{},"data":data}))
+ "\">\n <p class=\"username label\">"
+ alias4(((helper = (helper = helpers.username || (depth0 != null ? depth0.username : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"username","hash":{},"data":data}) : helper)))
+ "</p>\n </a>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/collections/groups", function(exports, require, module) {
module.exports = Backbone.Collection.extend({
model: require('../models/group'),
otherUsersRequestsCount: function() {
return this.map(function(group) {
return group.requestsCount();
}).sum();
}
});
});
;require.register("modules/network/lib/aggregate_users_ids", function(exports, require, module) {
var aggregates;
module.exports = function() {
var Name, all, cache, categories, getUserIds, name, recalculateAll;
cache = {};
all = function(name, categories) {
categories || (categories = name);
return cache[name] || recalculateAll(name, categories);
};
getUserIds = this.getUserIds.bind(this);
recalculateAll = function(name, categories) {
var ids;
categories = _.forceArray(categories);
ids = _.chain(categories).map(getUserIds).flatten().value();
return cache[name] = ids;
};
for (name in aggregates) {
categories = aggregates[name];
Name = _.capitaliseFirstLetter(name);
this["all" + Name + "Ids"] = all.bind(this, name, categories);
}
return this.recalculateAllLists = function() {
var results;
results = [];
for (name in aggregates) {
categories = aggregates[name];
results.push(recalculateAll(name, categories));
}
return results;
};
};
aggregates = {
admins: 'admins',
membersStrict: 'members',
members: ['admins', 'members'],
invited: 'invited',
requested: 'requested'
};
});
;require.register("modules/network/lib/group_actions", function(exports, require, module) {
var error_, triggerUserChange;
error_ = require('lib/error');
module.exports = {
inviteUser: function(user) {
return this.action('invite', user.id).then(this.updateInvited.bind(this, user));
},
updateInvited: function(user) {
this.push('invited', {
user: user.id,
invitor: app.user.id,
timestamp: _.now()
});
this.triggeredListChange();
return triggerUserChange(user);
},
acceptInvitation: function() {
this.moveMembership(app.user, 'invited', 'members');
return this.action('accept').then(this.fetchGroupUsersMissingItems.bind(this))["catch"](this.revertMove.bind(this, app.user, 'invited', 'members'));
},
declineInvitation: function() {
this.moveMembership(app.user, 'invited', 'declined');
return this.action('decline')["catch"](this.revertMove.bind(this, app.user, 'invited', 'declined'));
},
requestToJoin: function() {
this.createRequest();
return this.action('request')["catch"](this.revertMove.bind(this, app.user, null, 'requested'));
},
createRequest: function() {
return this.push('requested', {
user: app.user.id,
timestamp: _.now()
});
},
cancelRequest: function() {
this.moveMembership(app.user, 'requested', 'tmp');
return this.action('cancel-request')["catch"](this.revertMove.bind(this, app.user, 'requested', 'tmp'));
},
acceptRequest: function(user) {
this.moveMembership(user, 'requested', 'members');
return this.action('accept-request', user.id)["catch"](this.revertMove.bind(this, user, 'requested', 'members'));
},
refuseRequest: function(user) {
this.moveMembership(user, 'requested', 'tmp');
return this.action('refuse-request', user.id)["catch"](this.revertMove.bind(this, user, 'requested', 'tmp'));
},
makeAdmin: function(user) {
this.moveMembership(user, 'members', 'admins');
triggerUserChange(user);
return this.action('make-admin', user.id)["catch"](this.revertMove.bind(this, user, 'members', 'admins'));
},
kick: function(user) {
this.moveMembership(user, 'members', 'tmp');
return this.action('kick', user.id)["catch"](this.revertMove.bind(this, user, 'members', 'tmp'));
},
leave: function() {
var initialCategory;
initialCategory = this.mainUserIsAdmin() ? 'admins' : 'members';
this.moveMembership(app.user, initialCategory, 'tmp');
return this.action('leave')["catch"](this.revertMove.bind(this, app.user, initialCategory, 'tmp'));
},
action: function(action, userId) {
return _.preq.put(app.API.groups["private"], {
action: action,
group: this.id,
user: userId
}).then(_.Tap(this._postActionHooks.bind(this, action)));
},
_postActionHooks: function(action) {
app.execute('track:group', action);
return this.trigger("action:" + action);
},
revertMove: function(user, previousCategory, newCategory, err) {
this.moveMembership(user, newCategory, previousCategory);
triggerUserChange(user);
throw err;
},
moveMembership: function(user, previousCategory, newCategory) {
var membership;
membership = this.findMembership(previousCategory, user);
if (membership == null) {
throw error_["new"]('membership not found', arguments);
}
this.without(previousCategory, membership);
if (newCategory != null) {
this.push(newCategory, membership);
}
if (app.request('user:isMainUser', user.id)) {
app.vent.trigger('group:main:user:move');
}
return this.triggeredListChange();
},
triggeredListChange: function() {
this.trigger('list:change');
return this.trigger('list:change:after');
}
};
triggerUserChange = function(user) {
var trigger;
trigger = function() {
return user.trigger('group:user:change');
};
return setTimeout(trigger, 100);
};
});
;require.register("modules/network/lib/group_form_data", function(exports, require, module) {
module.exports = {
description: function(description) {
return {
id: 'description',
placeholder: 'help other users to understand what this group is about',
value: description
};
},
searchability: function(active) {
if (active == null) {
active = true;
}
return {
id: 'searchabilityToggler',
checked: active,
label: 'appear in search results'
};
}
};
});
;require.register("modules/network/lib/group_helpers", function(exports, require, module) {
var Groups, Updater, filters, initGroupFilteredCollection;
Groups = require('modules/network/collections/groups');
Updater = require('lib/model_update').Updater;
module.exports = function() {
var fetchLastGroupsCreated, getGroupModel, getGroupPublicData, getGroupsInCommon, groupSettingsUpdater, groups, lastGroupFetched, otherVisitedGroups, ref;
groups = ((ref = app.user) != null ? ref.groups : void 0) || new Groups;
getGroupModel = function(id) {
var group;
group = groups.byId(id);
if (group != null) {
return _.preq.resolve(group);
} else {
return getGroupPublicData(id);
}
};
getGroupPublicData = function(id) {
return _.preq.get(_.buildPath(app.API.groups["public"], {
id: id
})).then(function(res) {
var group, groupModel, items, users;
group = res.group, users = res.users, items = res.items;
app.execute('users:public:add', users);
Items["public"].add(items);
groupModel = groups.add(group);
groupModel.publicDataOnly = true;
return groupModel;
});
};
groupSettingsUpdater = Updater({
endpoint: app.API.groups["private"],
action: 'update-settings',
modelIdLabel: 'group'
});
getGroupsInCommon = function(user) {
return groups.filter(function(group) {
return group.mainUserIsMember() && group.userStatus(user) === 'member';
});
};
otherVisitedGroups = function(user) {
return groups.filter(function(group) {
var mainUserIsntMember;
mainUserIsntMember = !group.mainUserIsMember();
return mainUserIsntMember && group.userStatus(user) === 'member';
});
};
app.reqres.setHandlers({
'get:group:model': getGroupModel,
'get:group:model:sync': groups.byId.bind(groups),
'group:update:settings': groupSettingsUpdater,
'get:groups:common': getGroupsInCommon,
'get:groups:others:visited': otherVisitedGroups
});
initGroupFilteredCollection(groups, 'mainUserMember');
initGroupFilteredCollection(groups, 'mainUserInvited');
groups.filtered = require('./groups_search')(groups);
lastGroupFetched = false;
fetchLastGroupsCreated = function() {
if (!lastGroupFetched) {
lastGroupFetched = true;
return _.preq.get(app.API.groups.last).then(groups.add.bind(groups))["catch"](_.ErrorRethrow('fetchLastGroupsCreated'));
}
};
return app.commands.setHandlers({
'fetch:last:group:created': fetchLastGroupsCreated
});
};
initGroupFilteredCollection = function(groups, name) {
var filtered;
filtered = groups[name] = new FilteredCollection(groups);
filtered.filterBy(name, filters[name]);
return filtered.listenTo(app.vent, 'group:main:user:move', filtered.refilter.bind(filtered));
};
filters = {
mainUserMember: function(group) {
return group.mainUserIsMember();
},
mainUserInvited: function(group) {
return group.mainUserIsInvited();
}
};
});
;require.register("modules/network/lib/groups", function(exports, require, module) {
var forms_, groupDescriptionTests, groupNameTests;
forms_ = require('modules/general/lib/forms');
module.exports = {
createGroup: function(data) {
var coords, description, groups, name, searchable;
name = data.name, description = data.description, searchable = data.searchable, coords = data.coords;
groups = app.user.groups;
return _.preq.post(app.API.groups["private"], {
action: 'create',
name: name,
description: description,
searchable: searchable
}).then(groups.add.bind(groups)).then(_.Tap(app.execute.bind(app, 'track:group', 'create'))).then(_.Log('group'))["catch"](_.Error('group create'));
},
validateName: function(name, selector) {
forms_.pass({
value: name,
tests: groupNameTests,
selector: selector
});
},
validateDescription: function(description, selector) {
forms_.pass({
value: description,
tests: groupDescriptionTests,
selector: selector
});
}
};
groupNameTests = {
"group name can't be longer than 60 characters": function(name) {
return name.length > 60;
}
};
groupDescriptionTests = {
"group description can't be longer than 5000 characters": function(description) {
return description.length > 5000;
}
};
});
;require.register("modules/network/lib/groups_search", function(exports, require, module) {
var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
module.exports = function(groups) {
var addGroupUnlessHere, addGroupsAndFilterByText, addGroupsUnlessHere, filtered, queried, queryIfNeeded, searchByPosition, searchByText;
filtered = new FilteredCollection(groups);
queried = [];
searchByText = function(text) {
return queryIfNeeded(text).then(addGroupsAndFilterByText.bind(null, text))["catch"](function(err) {
queried = _.without(queried, text);
throw err;
});
};
queryIfNeeded = function(text) {
var noQueryNeeded;
noQueryNeeded = indexOf.call(queried, text) >= 0 || text === '';
if (noQueryNeeded) {
return Promise.resolve(false);
} else {
queried.push(text);
return _.preq.get(app.API.groups.search(text));
}
};
addGroupsAndFilterByText = function(text, groupsData) {
if (groupsData) {
groups.add(groupsData);
}
return filtered.filterByText(text);
};
searchByPosition = function(bbox) {
return _.preq.get(app.API.groups.searchByPosition(bbox)).then(_.Log('groups by position')).then(addGroupsUnlessHere);
};
addGroupsUnlessHere = function(groups) {
return app.request('waitForData').then(function() {
var group, i, len;
for (i = 0, len = groups.length; i < len; i++) {
group = groups[i];
addGroupUnlessHere(group);
}
});
};
addGroupUnlessHere = function(group) {
var _id;
_id = group._id;
if (app.user.groups.byId(_id) == null) {
return app.user.groups.add(group);
}
};
filtered.searchByText = _.debounce(searchByText, 200);
filtered.searchByPosition = searchByPosition;
return filtered;
};
});
;require.register("modules/network/lib/nearby_layouts", function(exports, require, module) {
var BoundFilter, containerId, drawMap, initEventListners, initMap, map_, solvePosition, updateRoute, updateRouteFromEvent;
map_ = require('modules/map/lib/map');
updateRoute = map_.updateRoute, updateRouteFromEvent = map_.updateRouteFromEvent, BoundFilter = map_.BoundFilter;
containerId = 'map';
initMap = function(params) {
var query;
query = params.query;
return solvePosition(query).then(drawMap.bind(null, params)).then(initEventListners.bind(null, params));
};
solvePosition = function(coords) {
var lat, lng, user, zoom;
lat = coords.lat, lng = coords.lng, zoom = coords.zoom;
if ((lat != null) && (lng != null)) {
return _.preq.resolve(coords);
}
user = app.user;
if (user.hasPosition()) {
return _.preq.resolve(user.getCoords());
}
return map_.getCurrentPosition(containerId);
};
drawMap = function(params, coords) {
var fn, lat, lng, map, path, showObjects, zoom;
lat = coords.lat, lng = coords.lng, zoom = coords.zoom;
showObjects = params.showObjects, path = params.path;
map = map_.draw({
containerId: containerId,
latLng: [lat, lng],
zoom: zoom,
cluster: true
});
showObjects(map);
fn = updateRoute.bind(null, path, lat, lng, zoom);
setTimeout(fn, 500);
_.type(map, 'object');
return map;
};
initEventListners = function(params, map) {
var onMoveend, path;
_.type(map, 'object');
path = params.path, onMoveend = params.onMoveend;
map.on('moveend', updateRouteFromEvent.bind(null, path));
map.on('moveend', onMoveend);
return map;
};
module.exports = {
initMap: initMap,
regions: {
list: '#list'
},
grabMap: function(map) {
_.type(map, 'object');
return this.map = map;
},
refreshListFilter: function() {
return this.collection.filterBy('geobox', BoundFilter(this.map));
}
};
});
;require.register("modules/network/lib/network_tabs", function(exports, require, module) {
var addPath, groupsTabs, groupsTabsDefault, resolveCurrentTab, usersTabs, usersTabsDefault;
usersTabsDefault = 'searchUsers';
groupsTabsDefault = 'searchGroups';
usersTabs = {
searchUsers: {
name: 'searchUsers',
section: 'search',
title: 'search',
icon: 'search',
layout: 'users_search_layout'
},
friends: {
name: 'friends',
section: 'friends',
title: 'friends',
icon: 'list',
layout: 'friends_layout',
counter: 'friendsRequestsCount'
},
invite: {
name: 'invite',
section: 'invite',
title: 'invite',
icon: 'envelope',
layout: 'invite_friends'
},
nearbyUsers: {
name: 'nearbyUsers',
section: 'nearby',
title: 'nearby',
icon: 'map-marker',
layout: 'nearby_users_layout'
}
};
groupsTabs = {
searchGroups: {
name: 'searchGroups',
section: 'search',
title: 'search',
icon: 'search',
layout: 'groups_search_layout'
},
userGroups: {
name: 'userGroups',
section: 'user',
title: 'your groups',
icon: 'list',
layout: 'groups_layout',
counter: 'groupsRequestsCount'
},
createGroup: {
name: 'createGroup',
section: 'create',
title: 'create',
icon: 'plus',
layout: 'create_group_layout'
},
nearbyGroups: {
name: 'nearbyGroups',
section: 'nearby',
title: 'nearby',
icon: 'map-marker',
layout: 'nearby_groups_layout'
}
};
addPath = function(category, categoryData) {
var key, obj, results, section;
results = [];
for (key in categoryData) {
obj = categoryData[key];
section = obj.section;
obj.parent = category;
results.push(obj.path = "network/" + category + "/" + section);
}
return results;
};
addPath('users', usersTabs);
addPath('groups', groupsTabs);
resolveCurrentTab = function(tab) {
switch (tab) {
case 'users':
return usersTabsDefault;
case 'groups':
return groupsTabsDefault;
default:
return tab;
}
};
module.exports = {
tabsData: {
all: _.extend({}, usersTabs, groupsTabs),
users: usersTabs,
groups: groupsTabs
},
usersTabs: usersTabs,
groupsTabs: groupsTabs,
resolveCurrentTab: resolveCurrentTab,
getNameFromId: function(id) {
return id.replace('Tab', '');
},
defaultTab: usersTabsDefault
};
});
;require.register("modules/network/lib/update_query_route", function(exports, require, module) {
var allTabs, updateRoute;
allTabs = require('../lib/network_tabs').tabsData.all;
updateRoute = function(path, query) {
return app.navigate(_.buildPath(path, {
q: query
}));
};
module.exports = function(key) {
var path;
path = allTabs[key].path;
return _.debounce(updateRoute.bind(null, path), 300);
};
});
;require.register("modules/network/models/group", function(exports, require, module) {
var Positionable, aggregateUsersIds, defaultCover, error_, escapeExpression, groupActions, userItemsCount,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
error_ = require('lib/error');
aggregateUsersIds = require('../lib/aggregate_users_ids');
groupActions = require('../lib/group_actions');
defaultCover = require('lib/urls').images.brittanystevens;
escapeExpression = Handlebars.escapeExpression;
Positionable = require('modules/general/models/positionable');
module.exports = Positionable.extend({
url: app.API.groups["private"],
initialize: function() {
var _id, canonical, name, pathname, ref, uriEscapedGroupName;
aggregateUsersIds.call(this);
_.extend(this, groupActions);
ref = this.toJSON(), _id = ref._id, name = ref.name;
uriEscapedGroupName = this.getUriEscapedName();
canonical = "/groups/" + _id;
pathname = canonical + "/" + uriEscapedGroupName;
this.set({
canonical: canonical,
pathname: pathname,
boardPathname: "/network" + pathname,
tmp: []
});
this.initMembersCollection();
this.initRequestersCollection();
this.on('list:change', this.recalculateAllLists.bind(this));
this.on('list:change:after', this.initMembersCollection.bind(this));
return this.on('list:change:after', this.initRequestersCollection.bind(this));
},
initMembersCollection: function() {
return this.initUsersCollection('members');
},
initRequestersCollection: function() {
return this.initUsersCollection('requested');
},
initUsersCollection: function(name) {
var Name, i, ids, len, results, userId;
this[name] || (this[name] = new Backbone.Collection);
this[name].remove(this[name].models);
Name = _.capitaliseFirstLetter(name);
ids = this["all" + Name + "Ids"]();
results = [];
for (i = 0, len = ids.length; i < len; i++) {
userId = ids[i];
results.push(this.fetchUser(this[name], userId));
}
return results;
},
fetchUser: function(collection, userId) {
return app.request('get:group:user:model', userId).then(collection.add.bind(collection))["catch"](_.Error('fetchMembers'));
},
getUserIds: function(category) {
return this.get(category).map(_.property('user'));
},
membersCount: function() {
return this.allMembersIds().length;
},
requestsCount: function() {
if (this.mainUserIsAdmin()) {
return this.requested.length;
} else {
return 0;
}
},
itemsCount: function() {
return this.members.map(userItemsCount).sum();
},
serializeData: function() {
var attrs, status;
attrs = this.toJSON();
status = this.mainUserStatus();
attrs.picture || (attrs.picture = defaultCover);
attrs["status_" + status] = true;
if (attrs.position != null) {
attrs.position = {
lat: attrs.position[0],
lng: attrs.position[1]
};
}
return _.extend(attrs, {
publicDataOnly: this.publicDataOnly,
membersCount: this.membersCount(),
itemsCount: !this.publicDataOnly ? this.itemsCount() : void 0,
mainUserIsAdmin: this.mainUserIsAdmin(),
mainUserIsMember: this.mainUserIsMember(),
hasPosition: this.hasPosition()
});
},
userStatus: function(user) {
var id;
id = user.id;
if (indexOf.call(this.allMembersIds(), id) >= 0) {
return 'member';
} else if (indexOf.call(this.allInvitedIds(), id) >= 0) {
return 'invited';
} else if (indexOf.call(this.allRequestedIds(), id) >= 0) {
return 'requested';
} else {
return 'none';
}
},
userIsAdmin: function(userId) {
return indexOf.call(this.allAdminsIds(), userId) >= 0;
},
mainUserStatus: function() {
return this.userStatus(app.user);
},
mainUserIsAdmin: function() {
var ref;
return ref = app.user.id, indexOf.call(this.allAdminsIds(), ref) >= 0;
},
mainUserIsMember: function() {
var ref;
return ref = app.user.id, indexOf.call(this.allMembersIds(), ref) >= 0;
},
mainUserIsInvited: function() {
var ref;
return ref = app.user.id, indexOf.call(this.allInvitedIds(), ref) >= 0;
},
findMembership: function(category, user) {
return _.findWhere(this.get(category), {
user: user.id
});
},
findInvitation: function(user) {
return this.findMembership('invited', user);
},
findUserInvitor: function(user) {
var invitation;
invitation = this.findInvitation(user);
if (invitation != null) {
return app.request('get:userModel:from:userId', invitation.invitor);
}
},
findMainUserInvitor: function() {
return this.findUserInvitor(app.user);
},
fetchGroupUsersMissingItems: function() {
var groupNonFriendsUsersIds;
groupNonFriendsUsersIds = app.request('get:non:friends:ids', this.allMembersIds());
_.log(groupNonFriendsUsersIds, 'groupNonFriendsUsersIds');
if (groupNonFriendsUsersIds.length > 0) {
return _.preq.get(app.API.users.items(groupNonFriendsUsersIds)).then(_.Log('groupNonFriendsUsers items')).then(Items.add.bind(Items))["catch"](_.Error('fetchGroupUsersMissingItems err'));
}
},
getEscapedName: function() {
return escapeExpression(this.get('name'));
},
getUriEscapedName: function() {
return encodeURIComponent(this.get('name'));
},
userCanLeave: function() {
var mainUserIsTheOnlyAdmin, thereAreOtherMembers;
if (!this.mainUserIsAdmin()) {
return true;
}
mainUserIsTheOnlyAdmin = this.allAdminsIds().length === 1;
thereAreOtherMembers = this.allMembersStrictIds().length > 0;
if (mainUserIsTheOnlyAdmin && thereAreOtherMembers) {
return false;
} else {
return true;
}
},
userIsLastUser: function() {
return this.allMembersIds().length === 1;
},
updateMetadata: function() {
return app.execute('metadata:update', {
title: this.get('name'),
description: this.getDescription(),
image: this.getCover(),
url: this.get('canonical')
});
},
getDescription: function() {
var desc;
desc = this.get('description');
if (_.isNonEmptyString(desc)) {
return desc;
} else {
return _.i18n('group_default_description', {
groupName: this.get('name')
});
}
},
getCover: function() {
return this.get('picture') || defaultCover;
},
asMatchable: function() {
return [this.get('name'), this.get('description')];
}
});
userItemsCount = function(user) {
var nonPrivate;
nonPrivate = true;
return user.inventoryLength(nonPrivate) || 0;
};
});
;require.register("modules/network/network", function(exports, require, module) {
var API, GroupBoard, NetworkLayout, counterUnlessZero, defaultTab, initGroupHelpers, initRequestsCollectionsEvent, networkCounters, showGroupBoardFromModel, tabsData;
NetworkLayout = require('./views/network_layout');
GroupBoard = require('./views/group_board');
initGroupHelpers = require('./lib/group_helpers');
tabsData = require('./lib/network_tabs').tabsData;
defaultTab = require('./lib/network_tabs').defaultTab;
module.exports = {
define: function(Redirect, app, Backbone, Marionette, $, _) {
var Router;
Router = Marionette.AppRouter.extend({
appRoutes: {
'network(/users)(/search)(/)': 'showSearchUsers',
'network/users/friends(/)': 'showFriends',
'network/users/invite(/)': 'showInvite',
'network/users/nearby(/)': 'showNearbyUsers',
'network(/groups)(/search)(/)': 'showSearchGroups',
'network/groups/user(/)': 'showUserGroups',
'network/groups/create(/)': 'showCreateGroup',
'network/groups/nearby(/)': 'showNearbyGroups',
'network/groups/:id(/:name)(/)': 'showGroupBoard',
'network/friends(/)': 'showFriends'
}
});
return app.addInitializer(function() {
return new Router({
controller: API
});
});
},
initialize: function() {
app.commands.setHandlers({
'show:network': API.showNetworkLayout,
'show:network:friends': API.showFriends,
'show:network:groups': API.showGroups,
'show:group:board': API.showGroupBoardFromModel
});
app.reqres.setHandlers({
'get:network:counters': networkCounters
});
return app.request('waitForUserData').then(initGroupHelpers).then(initRequestsCollectionsEvent.bind(this));
}
};
initRequestsCollectionsEvent = function() {
if (app.user.loggedIn) {
return app.request('waitForData').then(function() {
return app.vent.trigger('network:requests:udpate');
});
}
};
API = {
showSearchUsers: function(qs) {
return API.showNetworkLayout('searchUsers', qs);
},
showFriends: function() {
return API.showNetworkLayout('friends');
},
showInvite: function() {
return API.showNetworkLayout('invite');
},
showNearbyUsers: function(qs) {
return API.showNetworkLayout('nearbyUsers', qs);
},
showSearchGroups: function(qs) {
return API.showNetworkLayout('searchGroups', qs);
},
showUserGroups: function() {
return API.showNetworkLayout('userGroups');
},
showCreateGroup: function() {
return API.showNetworkLayout('createGroup');
},
showNearbyGroups: function(qs) {
return API.showNetworkLayout('nearbyGroups', qs);
},
showNetworkLayout: function(tab, qs) {
var path, query;
if (tab == null) {
tab = defaultTab;
}
path = tabsData.all[tab].path;
query = _.isNonEmptyString(qs) ? _.parseQuery(qs) : {};
if (app.request('require:loggedIn', _.buildPath(path, query))) {
return app.layout.main.show(new NetworkLayout({
tab: tab,
query: query
}));
}
},
showGroupBoard: function(id, name) {
return app.request('waitForUserData').then(function() {
return app.request('get:group:model', id);
}).then(showGroupBoardFromModel)["catch"](function(err) {
_.error(err, 'get:group:model err');
return app.execute('show:404');
});
},
showGroupBoardFromModel: function(model) {
showGroupBoardFromModel(model);
return app.navigate(model.get('boardPathname'));
}
};
showGroupBoardFromModel = function(group) {
if (group.mainUserIsMember()) {
return app.layout.main.show(new GroupBoard({
model: group,
standalone: true
}));
} else {
return app.execute('show:inventory:group', group);
}
};
networkCounters = function() {
var counters, friendsRequestsCount, groups, groupsRequestsCount, mainUserInvitationsCount, otherUsersRequestsCount, ref;
friendsRequestsCount = ((ref = app.users.otherRequested) != null ? ref.length : void 0) || 0;
groups = app.user.groups;
mainUserInvitationsCount = (groups != null ? groups.mainUserInvited.length : void 0) || 0;
otherUsersRequestsCount = (groups != null ? groups.otherUsersRequestsCount() : void 0) || 0;
groupsRequestsCount = mainUserInvitationsCount + otherUsersRequestsCount;
return counters = {
friendsRequestsCount: counterUnlessZero(friendsRequestsCount),
groupsRequestsCount: counterUnlessZero(groupsRequestsCount),
total: counterUnlessZero(friendsRequestsCount + groupsRequestsCount)
};
};
counterUnlessZero = function(count) {
if (count === 0) {
} else {
return count;
}
};
});
;require.register("modules/network/plugins/group", function(exports, require, module) {
var UsersList, behaviorsPlugin, events, handlers;
UsersList = require('modules/users/views/users_list');
behaviorsPlugin = require('modules/general/plugins/behaviors');
events = {
'click .showGroup': 'showGroup',
'click .showGroupBoard': 'showGroupBoard',
'click .accept': 'acceptInvitation',
'click .decline': 'declineInvitation',
'click .joinRequest': 'joinRequest',
'click .cancelRequest': 'cancelRequest'
};
handlers = {
showGroup: function(e) {
if (!_.isOpenedOutside(e)) {
return app.execute('show:inventory:group', this.model);
}
},
showGroupBoard: function(e) {
if (!_.isOpenedOutside(e)) {
return app.execute('show:group:board', this.model);
}
},
getGroupMembersListView: function() {
return new UsersList({
collection: this.model.members,
groupContext: true,
group: this.model
});
},
getFriendsInvitorView: function() {
var group;
group = this.model;
return new UsersList({
collection: app.users.friends,
groupContext: true,
group: group,
emptyViewMessage: 'no friends to invite',
filter: function(child, index, collection) {
return group.userStatus(child) !== 'member';
}
});
},
getJoinRequestsView: function() {
return new UsersList({
collection: this.model.requested,
groupContext: true,
group: this.model,
emptyViewMessage: 'no more pending requests'
});
},
acceptInvitation: function() {
return this.model.acceptInvitation();
},
declineInvitation: function() {
return this.model.declineInvitation();
},
joinRequest: function() {
if (app.request('require:loggedIn', this.model.get('pathname'))) {
return this.model.requestToJoin()["catch"](behaviorsPlugin.Fail.call(this, 'joinRequest'));
}
},
cancelRequest: function() {
return this.model.cancelRequest()["catch"](behaviorsPlugin.Fail.call(this, 'cancelRequest'));
}
};
module.exports = _.BasicPlugin(events, handlers);
});
;require.register("modules/network/plugins/users_search", function(exports, require, module) {
var UsersList, events, handlers, regions, ui;
UsersList = require('modules/users/views/users_list');
regions = {
usersList: '#usersList'
};
ui = {
usersListHeader: '#usersListHeader',
userSearch: '#userSearch',
userField: '#userField'
};
events = {
'keyup #userField': 'lazyUserSearch',
'click a.close': 'resetSearch'
};
handlers = {
showUsersSearchBase: function(stretch) {
this.ui.userSearch.show();
return this.showFriends(stretch);
},
showFriends: function(stretch) {
if (stretch == null) {
stretch = false;
}
this.usersList.show(new UsersList({
collection: app.users.filtered.friends(),
stretch: stretch
}));
return this.setFriendsHeader();
},
updateUserSearch: function(e) {
return this.searchUsers(e.target.value);
},
searchUsers: function(query) {
if (query !== this.lastQuery) {
this.lastQuery = query;
app.request('users:search', query);
if ((query != null) && query !== '') {
return this.setUserSearchHeader();
} else {
return this.setFriendsHeader();
}
}
},
setFriendsHeader: function() {
this.ui.usersListHeader.find('.header').text(_.i18n('friends'));
this.ui.usersListHeader.find('.close').hide();
return this.callToActionIfFriendsListIsEmpty();
},
setUserSearchHeader: function() {
this.ui.usersListHeader.find('.header').text(_.i18n('user search'));
return this.ui.usersListHeader.find('.close').show();
},
resetSearch: function() {
this.searchUsers('');
return this.ui.userField.val('');
},
callToActionIfFriendsListIsEmpty: function() {
if (app.users.friends.length === 0) {
$('.noUser').hide();
return $('.findFriends').show();
}
}
};
module.exports = function() {
this.lastQuery = null;
_.extend(this, handlers);
this.lazyUserSearch = _.debounce(this.updateUserSearch.bind(this), 100);
this.addRegions(regions);
_.extend((this.events || (this.events = {})), events);
_.extend((this.ui || (this.ui = {})), ui);
};
});
;require.register("modules/network/views/create_group_layout", function(exports, require, module) {
var forms_, groupFormData, groupPlugin, groups_;
forms_ = require('modules/general/lib/forms');
groups_ = require('../lib/groups');
groupPlugin = require('../plugins/group');
groupFormData = require('../lib/group_form_data');
module.exports = Marionette.LayoutView.extend({
id: 'createGroupLayout',
template: require('./templates/create_group_layout'),
tagName: 'form',
behaviors: {
AlertBox: {},
ElasticTextarea: {}
},
regions: {
invite: '#invite'
},
ui: {
nameField: '#nameField',
description: '#description',
searchabilityToggler: '#searchabilityToggler',
searchabilityWarning: '.searchability .warning'
},
initialize: function() {
return this.initPlugin();
},
initPlugin: function() {
return groupPlugin.call(this);
},
events: {
'click #createGroup': 'createGroup',
'change #searchabilityToggler': 'toggleSearchabilityWarning',
'click #showPositionPicker': 'showPositionPicker'
},
serializeData: function() {
return {
description: groupFormData.description(),
searchability: groupFormData.searchability()
};
},
toggleSearchabilityWarning: function() {
return this.ui.searchabilityWarning.slideToggle();
},
showPositionPicker: function() {
return app.request('prompt:group:position:picker').then((function(_this) {
return function(coords) {
return _this.coords = coords;
};
})(this))["catch"](_.Error('showPositionPicker'));
},
createGroup: function() {
var data, description, name;
name = this.ui.nameField.val();
description = this.ui.description.val();
data = {
name: name,
description: description,
searchable: this.ui.searchabilityToggler[0].checked,
coords: this.coords
};
return _.preq.start.then(groups_.validateName.bind(this, name, '#nameField')).then(groups_.validateDescription.bind(this, description, '#description')).then(groups_.createGroup.bind(null, data)).then(app.execute.bind(app, 'show:group:board'))["catch"](forms_.catchAlert.bind(null, this));
}
});
});
;require.register("modules/network/views/friends_layout", function(exports, require, module) {
var Users, UsersList, behaviorsPlugin;
UsersList = require('modules/users/views/users_list');
Users = require('modules/users/collections/users');
behaviorsPlugin = require('modules/general/plugins/behaviors');
module.exports = Marionette.LayoutView.extend({
template: require('./templates/friends_layout'),
id: 'friendsLayout',
tagName: 'section',
regions: {
friendsRequests: '#friendsRequests',
friendsList: '#friendsList'
},
ui: {
friendsRequestsWrapper: '.friends-requests-wrapper',
friendsFilterWrapper: '.friends-filter-wrapper',
friendsFilter: '#friendsFilter'
},
behaviors: {
Loading: {},
PreventDefault: {}
},
initialize: function() {
return this.friends = app.users.friends.filtered;
},
events: {
'keyup #friendsFilter': 'filterFriends'
},
serializeData: function() {
return {
friendsFilter: {
id: 'friendsFilter',
placeholder: 'search for your friends'
}
};
},
onRender: function() {
behaviorsPlugin.startLoading.call(this, '#friendsList');
return app.request('waitForFriendsItems').then(this.showFriends.bind(this))["catch"](_.Error('showTabFriends'));
},
showFriends: function() {
this.showFriendsRequests();
this.showFriendsFilter();
return this.showFriendsLists();
},
showFriendsRequests: function() {
var otherRequested;
otherRequested = app.users.otherRequested;
if (otherRequested.length > 0) {
this.ui.friendsRequestsWrapper.show();
return this.friendsRequests.show(new UsersList({
collection: otherRequested,
emptyViewMessage: 'no pending requests',
stretch: true
}));
}
},
showFriendsFilter: function() {
if (this.friends.length > 8) {
return this.ui.friendsFilterWrapper.show();
}
},
filterFriends: function() {
var text;
text = this.ui.friendsFilter.val();
return this.friends.filterByText(text);
},
showFriendsLists: function() {
this.friends.resetFilters();
return this.friendsList.show(new UsersList({
collection: this.friends,
emptyViewMessage: "you aren't connected to anyone yet",
emptyViewLink: 'inviteFriends',
stretch: true
}));
}
});
});
;require.register("modules/network/views/group", function(exports, require, module) {
var groupPlugin;
groupPlugin = require('../plugins/group');
module.exports = Marionette.ItemView.extend({
getTemplate: function() {
if (this.options.highlighted) {
return require('./templates/group_show');
} else {
return require('./templates/group');
}
},
className: function() {
if (this.options.highlighted) {
return 'groupShow';
} else {
return 'group';
}
},
tagName: function() {
if (this.options.highlighted) {
return 'div';
} else {
return 'li';
}
},
initialize: function() {
this.initPlugin();
this.lazyRender = _.LazyRender(this);
return this.listenTo(this.model, 'change', this.lazyRender);
},
initPlugin: function() {
return groupPlugin.call(this);
},
behaviors: {
PreventDefault: {},
SuccessCheck: {},
Unselect: {}
},
onShow: function() {
if (this.options.highlighted) {
return app.execute('current:username:set', this.model.get('name'));
}
},
onDestroy: function() {
if (this.options.highlighted) {
return app.execute('current:username:hide');
}
},
serializeData: function() {
return _.extend(this.model.serializeData(), {
highlighted: this.options.highlighted
});
}
});
});
;require.register("modules/network/views/group_board", function(exports, require, module) {
var GroupBoardHeader, GroupSettings, groupPlugin, sectionsData;
groupPlugin = require('../plugins/group');
GroupBoardHeader = require('./group_board_header');
GroupSettings = require('./group_settings');
module.exports = Marionette.LayoutView.extend({
template: require('./templates/group_board'),
className: function() {
var standalone;
standalone = this.options.standalone ? 'standalone' : '';
return "groupBoard " + standalone;
},
initialize: function() {
this.initPlugin();
return this.listenTo(this.model, 'action:leave', this.render.bind(this));
},
initPlugin: function() {
return groupPlugin.call(this);
},
behaviors: {
PreventDefault: {}
},
regions: {
header: '.header',
groupSettings: '#groupSettings > .inner',
groupRequests: '#groupRequests > .inner',
groupMembers: '#groupMembers > .inner',
groupInvite: '#groupInvite > .inner'
},
ui: {
groupSettings: '#groupSettings > .inner',
groupRequests: '#groupRequests > .inner',
groupMembers: '#groupMembers > .inner',
groupInvite: '#groupInvite > .inner',
groupRequestsSection: '#groupRequests'
},
serializeData: function() {
var attrs;
attrs = this.model.serializeData();
attrs.sections = sectionsData;
return attrs;
},
events: {
'click .section-toggler': 'toggleSection',
'click .joinRequest': 'requestToJoin'
},
showHeader: function() {
return this.header.show(new GroupBoardHeader({
model: this.model
}));
},
toggleSection: function(e) {
var section;
section = e.currentTarget.parentElement.attributes.id.value;
if (section === 'groupSettings') {
return this.toggleSettings();
} else {
return this.toggleUi(section);
}
},
toggleUi: function(uiLabel, skipToggle) {
var $el, $parent;
if (skipToggle == null) {
skipToggle = false;
}
$el = this.ui[uiLabel];
$parent = $el.parent();
if (!skipToggle) {
$el.slideToggle();
}
$parent.find('.fa-caret-down').toggleClass('toggled');
if ($el.visible()) {
return _.scrollTop($parent);
}
},
onRender: function() {
this.showHeader();
this.showMembers();
this.showJoinRequests();
if (this.model.mainUserIsMember()) {
this.initSettings();
return this.showFriendsInvitor();
}
},
onShow: function() {
return this.listenToOnce(this.model.requested, 'add', this.showJoinRequests.bind(this));
},
initSettings: function() {
if (this.options.standalone && this.model.mainUserIsAdmin()) {
return this.showSettings();
} else {
this.toggleUi('groupSettings');
return this._settingsShownOnce = false;
}
},
toggleSettings: function() {
if (this._settingsShownOnce) {
return this.toggleUi('groupSettings');
} else {
this.showSettings();
return this.toggleUi('groupSettings', true);
}
},
showSettings: function() {
this._settingsShownOnce = true;
return this.groupSettings.show(new GroupSettings({
model: this.model
}));
},
showJoinRequests: function() {
if (this.model.requested.length > 0 && this.model.mainUserIsAdmin()) {
this.groupRequests.show(this.getJoinRequestsView());
return this.ui.groupRequestsSection.show();
} else {
return this.ui.groupRequestsSection.hide();
}
},
showMembers: function() {
return this.groupMembers.show(this.getGroupMembersListView());
},
showFriendsInvitor: function() {
return this.groupInvite.show(this.getFriendsInvitorView());
}
});
sectionsData = {
settings: {
label: 'settings',
icon: 'cog'
},
requests: {
label: 'requests waiting your approval',
icon: 'inbox'
},
members: {
label: 'members',
icon: 'users'
},
invite: {
label: 'invite friends',
icon: 'envelope'
}
};
});
;require.register("modules/network/views/group_board_header", function(exports, require, module) {
var groupPlugin;
groupPlugin = require('../plugins/group');
module.exports = Marionette.ItemView.extend({
template: require('./templates/group_board_header'),
className: 'group-board-header',
initialize: function() {
this.initPlugin();
this.lazyRender = _.LazyRender(this);
this.listenTo(this.model, 'change', this.lazyRender);
return app.request('waitForFriendsItems').then(this.lazyRender);
},
initPlugin: function() {
return groupPlugin.call(this);
},
behaviors: {
PreventDefault: {}
},
serializeData: function() {
var attrs;
attrs = this.model.serializeData();
attrs.invitor = this.invitorData();
return attrs;
},
invitorData: function() {
var ref, username;
username = (ref = this.model.findMainUserInvitor()) != null ? ref.get('username') : void 0;
return {
username: username
};
}
});
});
;require.register("modules/network/views/group_settings", function(exports, require, module) {
var PicturePicker, behaviorsPlugin, error_, forms_, groupFormData, groups_;
behaviorsPlugin = require('modules/general/plugins/behaviors');
forms_ = require('modules/general/lib/forms');
groups_ = require('../lib/groups');
error_ = require('lib/error');
PicturePicker = require('modules/general/views/behaviors/picture_picker');
groupFormData = require('../lib/group_form_data');
module.exports = Marionette.ItemView.extend({
template: require('./templates/group_settings'),
behaviors: {
AlertBox: {},
ConfirmationModal: {},
ElasticTextarea: {},
PreventDefault: {},
SuccessCheck: {},
BackupForm: {}
},
initialize: function() {
return this.lazyRender = _.LazyRender(this, 500);
},
serializeData: function() {
var attrs;
attrs = this.model.serializeData();
return _.extend(attrs, {
editName: this.editNameData(attrs.name),
editDescription: groupFormData.description(attrs.description),
userCanLeave: this.model.userCanLeave(),
userIsLastUser: this.model.userIsLastUser(),
searchability: groupFormData.searchability(attrs.searchable)
});
},
editNameData: function(groupName) {
return {
nameBase: 'editName',
field: {
value: groupName,
placeholder: groupName
},
button: {
text: _.I18n('save')
},
check: true
};
},
ui: {
editNameField: '#editNameField',
description: '#description',
saveCancel: '.saveCancel',
searchabilityWarning: '.searchability .warning'
},
events: {
'click #editNameButton': 'editName',
'click a#changePicture': 'changePicture',
'change #searchabilityToggler': 'toggleSearchability',
'keyup #description': 'showSaveCancel',
'click .cancelButton': 'cancelDescription',
'click .saveButton': 'saveDescription',
'click a.leave': 'leaveGroup',
'click a.destroy': 'destroyGroup',
'click #showPositionPicker': 'showPositionPicker'
},
onShow: function() {
this.listenTo(this.model, 'change:picture', this.lazyRender);
this.listenTo(this.model, 'change:searchable', this.lazyRender);
this.listenTo(this.model, 'change:position', this.lazyRender);
return this.listenTo(this.model, 'list:change:after', this.lazyRender);
},
editName: function() {
var name;
name = this.ui.editNameField.val();
if (name != null) {
return _.preq.start.then(groups_.validateName.bind(this, name, '#editNameField')).then(_.Full(this._updateGroup, this, 'name', name, '#editNameField'))["catch"](forms_.catchAlert.bind(null, this));
}
},
_updateGroup: function(attribute, value, selector) {
return app.request('group:update:settings', {
model: this.model,
attribute: attribute,
value: value,
selector: selector
});
},
changePicture: function() {
return app.layout.modal.show(new PicturePicker({
pictures: this.model.get('picture'),
save: this._savePicture.bind(this),
limit: 1
}));
},
_savePicture: function(pictures) {
var picture;
picture = pictures[0];
_.log(picture, 'picture');
if (!_.isLocalImg(picture)) {
throw new Error('couldnt save picture: requires a local image url');
}
return this.updateSettings({
attribute: 'picture',
value: picture,
selector: '#changePicture'
});
},
toggleSearchability: function(e) {
var checked;
checked = e.currentTarget.checked;
this.ui.searchabilityWarning.slideToggle();
return this.updateSettings({
attribute: 'searchable',
value: checked
});
},
updateSettings: function(update) {
update.model = this.model;
return app.request('group:update:settings', update);
},
showSaveCancel: function() {
this._saveCancelShown = false;
if (!this._saveCancelShown) {
this.ui.saveCancel.slideDown();
return this._saveCancelShown = true;
}
},
cancelDescription: function() {
this.render();
return this._saveCancelShown = false;
},
saveDescription: function() {
var description;
this.ui.saveCancel.slideUp();
this._saveCancelShown = false;
description = this.ui.description.val();
if (description != null) {
return _.preq.start.then(groups_.validateDescription.bind(this, description, '#description')).then(_.Full(this._updateGroup, this, 'description', description, '#description'))["catch"](forms_.catchAlert.bind(null, this));
}
},
leaveGroup: function() {
return this._leaveGroup('leave_group_confirmation', 'leave_group_warning');
},
destroyGroup: function() {
return this._leaveGroup('destroy_group_confirmation', 'cant_undo_warning');
},
_leaveGroup: function(confirmationText, warningText) {
var args, group;
group = this.model;
args = {
groupName: group.get('name')
};
return this.$el.trigger('askConfirmation', {
confirmationText: _.i18n(confirmationText, args),
warningText: _.i18n(warningText),
action: group.leave.bind(group),
selector: '#usernameGroup'
});
},
showPositionPicker: function() {
return app.execute('show:position:picker:group', this.model);
}
});
});
;require.register("modules/network/views/groups_layout", function(exports, require, module) {
var GroupsList, UsersList, behaviorsPlugin;
UsersList = require('modules/users/views/users_list');
GroupsList = require('./groups_list');
behaviorsPlugin = require('modules/general/plugins/behaviors');
module.exports = Marionette.LayoutView.extend({
template: require('./templates/groups_layout'),
id: 'groupsLayout',
tagName: 'section',
regions: {
groupsInvitations: '#groupsInvitations',
groupList: '#groupsList'
},
behaviors: {
Loading: {}
},
onShow: function() {
behaviorsPlugin.startLoading.call(this, '#groupsList');
return app.request('waitForFriendsItems').then(this.showGroupsLists.bind(this))["catch"](_.Error('showTabGroups'));
},
showGroupsLists: function() {
this.showGroupsInvitations();
return this.showGroupsList();
},
showGroupsInvitations: function() {
var mainUserInvited;
mainUserInvited = app.user.groups.mainUserInvited;
if (mainUserInvited.length > 0) {
return this.groupsInvitations.show(new GroupsList({
collection: mainUserInvited,
mode: 'board',
emptyViewMessage: "you have no more pending invitations"
}));
}
},
showGroupsList: function() {
return this.groupList.show(new GroupsList({
collection: app.user.groups.mainUserMember,
mode: 'board'
}));
}
});
});
;require.register("modules/network/views/groups_list", function(exports, require, module) {
module.exports = Marionette.CollectionView.extend({
className: 'groupsList',
tagName: 'ul',
getChildView: function() {
switch (this.options.mode) {
case 'board':
return require('./group_board');
case 'preview':
return require('./group_board_header');
default:
return require('./group');
}
},
emptyView: require('./no_group'),
emptyViewOptions: function() {
var ref;
return {
message: ((ref = this.options) != null ? ref.emptyViewMessage : void 0) || "you aren't in any group yet"
};
}
});
});
;require.register("modules/network/views/groups_search_layout", function(exports, require, module) {
var GroupsList, updateRoute;
GroupsList = require('./groups_list');
updateRoute = require('../lib/update_query_route')('searchGroups');
module.exports = Marionette.LayoutView.extend({
template: require('./templates/groups_search_layout'),
id: 'groupsSearchLayout',
regions: {
'groupsList': '#groupsList'
},
ui: {
groupSearch: '#groupSearch'
},
events: {
'keyup #groupSearch': 'searchGroupFromEvent'
},
initialize: function() {
var q;
q = this.options.query.q;
this.lastSearch = q || '';
return app.request('waitForUserData').then(this.initSearch.bind(this, q));
},
initSearch: function(q) {
this.collection = app.user.groups.filtered.resetFilters();
app.execute('fetch:last:group:created');
if (_.isNonEmptyString(q)) {
return this.searchGroup(q);
}
},
serializeData: function() {
return {
groupsSearch: {
id: 'groupSearch',
placeholder: 'search a group',
value: this.lastSearch
}
};
},
onShow: function() {
return app.request('waitForData').then(this.showGroupList.bind(this));
},
showGroupList: function() {
this.groupsList.show(new GroupsList({
collection: this.collection,
mode: 'preview',
emptyViewMessage: 'no group found with this name'
}));
return $('.noGroup').hide();
},
searchGroupFromEvent: function() {
return this.searchGroup(this.ui.groupSearch.val());
},
searchGroup: function(text) {
updateRoute(text);
this.lastSearch = text;
return this.collection.searchByText(text);
}
});
});
;require.register("modules/network/views/invite_friends", function(exports, require, module) {
var UsersList, behaviorsPlugin, forms_, invitationsError, sendInvitationsByEmails;
UsersList = require('modules/users/views/users_list');
behaviorsPlugin = require('modules/general/plugins/behaviors');
forms_ = require('modules/general/lib/forms');
module.exports = Marionette.LayoutView.extend({
template: require('./templates/invite_friends'),
id: 'inviteFriends',
regions: {
usersAlreadyThereRegion: '#usersAlreadyThere'
},
ui: {
invitations: '#invitations',
addMessage: '#addMessage',
message: '#message',
output: '#output',
usersAlreadyThere: '.usersAlreadyThere'
},
behaviors: {
Loading: {},
ElasticTextarea: {},
AlertBox: {},
SuccessCheck: {}
},
events: {
'click #sendInvitations': 'sendInvitations',
'click #addMessage': 'toggleMessage'
},
initialize: function() {
this.emailsInvited = [];
return this.usersAlreadyThere = new Backbone.Collection;
},
onRender: function() {
return this.usersAlreadyThereRegion.show(new UsersList({
collection: this.usersAlreadyThere,
stretch: true
}));
},
serializeData: function() {
return {
rawEmails: this.rawEmails,
message: this.message,
emailsInvited: this.emailsInvited
};
},
sendInvitations: function() {
this.rawEmails = this.ui.invitations.val();
this.message = this.ui.message.val();
return sendInvitationsByEmails(this.rawEmails, this.message)["catch"](invitationsError).then(_.Log('invitation data')).then(this._spreadUsers.bind(this)).then(this._showResults.bind(this))["catch"](forms_.catchAlert.bind(null, this))["catch"](behaviorsPlugin.Fail.call(this, 'invitations err'));
},
_spreadUsers: function(data) {
var emails, i, len, results, user, users;
users = data.users, emails = data.emails;
this.addEmailsInvited(emails);
results = [];
for (i = 0, len = users.length; i < len; i++) {
user = users[i];
results.push(this._addUser(user));
}
return results;
},
addEmailsInvited: function(emails) {
return this.emailsInvited = _.uniq(this.emailsInvited.concat(emails));
},
_addUser: function(user) {
var userModel;
userModel = app.request('user:public:add', user);
userModel.set('email', user.email);
this.usersAlreadyThere.add(userModel);
switch (userModel.get('status')) {
case 'public':
return app.request('request:send', userModel);
case 'otherRequested':
return app.request('request:accept', userModel, false);
}
},
_showResults: function() {
this.render();
if (this.usersAlreadyThere.length > 0) {
this.ui.usersAlreadyThere.slideDown();
}
return setTimeout(_.scrollTop.bind(null, this.ui.invitations), 250);
},
toggleMessage: function() {
this.ui.addMessage.slideUp();
return this.ui.message.slideDown();
}
});
sendInvitationsByEmails = function(rawEmails, message) {
return app.request('invitations:by:emails', rawEmails, message);
};
invitationsError = function(err) {
err.selector = '#invitations';
throw err;
};
});
;require.register("modules/network/views/nearby_groups_layout", function(exports, require, module) {
var GroupsList, getBbox, grabMap, initMap, path, ref, ref1, refreshListFilter, regions, showGroupsOnMap;
ref = require('../lib/nearby_layouts'), initMap = ref.initMap, regions = ref.regions, grabMap = ref.grabMap, refreshListFilter = ref.refreshListFilter;
ref1 = require('modules/map/lib/map'), showGroupsOnMap = ref1.showGroupsOnMap, getBbox = ref1.getBbox;
path = require('../lib/network_tabs').tabsData.groups.nearbyGroups.path;
GroupsList = require('./groups_list');
module.exports = Marionette.LayoutView.extend({
template: require('./templates/nearby_layout'),
id: 'nearbyGroupsLayout',
regions: regions,
behaviors: {
PreventDefault: {}
},
events: {
'click .groupIcon a': 'showGroup'
},
initMap: function() {
this.collection || (this.collection = app.user.groups.filtered.resetFilters());
return initMap({
query: this.options.query,
path: path,
showObjects: this.showGroupsNearby.bind(this),
onMoveend: this.onMovend.bind(this)
}).then(grabMap.bind(this)).then(this.initList.bind(this))["catch"](_.Error('initMap'));
},
initialize: function() {
return this.lazyInitMap = _.debounce(this.initMap.bind(this), 300);
},
onRender: function() {
return app.request('waitForData').then(this.lazyInitMap.bind(this));
},
onMovend: function() {
refreshListFilter.call(this);
return this.showGroupsNearby(this.map);
},
showGroupsNearby: function(map) {
return this.collection.searchByPosition(getBbox(map)).then(this.updateGroupsMarkers.bind(this));
},
updateGroupsMarkers: function() {
return showGroupsOnMap(this.map, this.collection.models);
},
showGroup: function(e) {
var id;
if (!_.isOpenedOutside(e)) {
id = e.currentTarget.href.split('/')[2];
return app.execute('show:inventory:group', id);
}
},
initList: function() {
this.list.show(new GroupsList({
collection: this.collection,
mode: 'preview',
emptyViewMessage: "can't find any group at this location"
}));
return refreshListFilter.call(this);
}
});
});
;require.register("modules/network/views/nearby_users_layout", function(exports, require, module) {
var UsersList, getBbox, grabMap, initMap, path, ref, ref1, refreshListFilter, regions, showUserOnMap, showUsersOnMap, updateMarker;
ref = require('modules/map/lib/map'), showUsersOnMap = ref.showUsersOnMap, showUserOnMap = ref.showUserOnMap, updateMarker = ref.updateMarker, getBbox = ref.getBbox;
path = require('../lib/network_tabs').tabsData.users.nearbyUsers.path;
UsersList = require('modules/users/views/users_list');
ref1 = require('../lib/nearby_layouts'), initMap = ref1.initMap, regions = ref1.regions, grabMap = ref1.grabMap, refreshListFilter = ref1.refreshListFilter;
module.exports = Marionette.LayoutView.extend({
template: require('./templates/nearby_users_layout'),
id: 'nearbyUsersLayout',
regions: regions,
behaviors: {
PreventDefault: {}
},
events: {
'click #showPositionPicker': function() {
return app.execute('show:position:picker:main:user');
}
},
initMap: function() {
return initMap({
query: this.options.query,
path: path,
showObjects: this.showUsersNearby.bind(this),
onMoveend: this.onMovend.bind(this)
}).then(grabMap.bind(this)).then(this.initList.bind(this))["catch"](_.Error('initMap'));
},
initialize: function() {
this.collection = app.users.filtered.resetFilters();
this.listenTo(app.user, 'change:position', this.updateMainUserPosition.bind(this));
return this.lazyInitMap = _.debounce(this.initMap.bind(this), 300);
},
onRender: function() {
return app.request('waitForData').then(this.lazyInitMap.bind(this));
},
serializeData: function() {
return {
hasPosition: app.user.hasPosition()
};
},
onMovend: function() {
refreshListFilter.call(this);
return this.showUsersNearby(this.map);
},
showUsersNearby: function(map) {
return app.request('users:search:byPosition', getBbox(map)).then(this.updateUsersMarkers.bind(this));
},
updateUsersMarkers: function() {
showUsersOnMap(this.map, this.collection.models);
return this.mainUserMarker = showUserOnMap(this.map, app.user);
},
initList: function() {
this.list.show(new UsersList({
collection: this.collection,
stretch: true,
emptyViewMessage: "can't find any user at this location",
filter: function(model) {
return model.id !== app.user.id;
}
}));
return refreshListFilter.call(this);
},
updateMainUserPosition: function() {
if (this.mainUserMarker != null) {
return updateMarker(this.mainUserMarker, app.user.getCoords());
}
}
});
});
;require.register("modules/network/views/network_layout", function(exports, require, module) {
var Tabs, ref, resolveCurrentTab, tabsData;
Tabs = require('./tabs');
ref = require('../lib/network_tabs'), tabsData = ref.tabsData, resolveCurrentTab = ref.resolveCurrentTab;
module.exports = Marionette.LayoutView.extend({
template: require('./templates/network_layout'),
id: 'networkLayout',
regions: {
tabs: '.custom-tabs-titles',
content: '.custom-tabs-content'
},
childEvents: {
'tabs:change': 'updateLayout'
},
onShow: function() {
var tab;
tab = this.options.tab;
this.tabs.show(new Tabs({
tab: tab
}));
return this.showLayout(tab);
},
updateLayout: function(view, tab) {
return this.showLayout(tab);
},
showLayout: function(tab) {
var Layout, layout;
tab = resolveCurrentTab(tab);
layout = tabsData.all[tab].layout;
Layout = require("./" + layout);
return this.content.show(new Layout(this.options));
}
});
});
;require.register("modules/network/views/no_group", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
template: require('./templates/no_group'),
className: 'noGroup',
tagName: 'li',
serializeData: function() {
return {
message: this.options.message
};
},
onShow: function() {
return this.$el.hide().fadeIn();
}
});
});
;require.register("modules/network/views/tabs", function(exports, require, module) {
var getNameFromId, navigate, ref, resolveCurrentTab, tabsData, updateTitle;
ref = require('../lib/network_tabs'), tabsData = ref.tabsData, resolveCurrentTab = ref.resolveCurrentTab, getNameFromId = ref.getNameFromId;
module.exports = Marionette.ItemView.extend({
template: require('./templates/tabs'),
className: 'tabs',
events: {
'click .tab': 'updateTabs'
},
behaviors: {
PreventDefault: {}
},
initialize: function() {
var tab;
tab = this.options.tab;
this.currentTab = tab;
this.currentTabData = tabsData.all[tab];
this.lazyRender = _.LazyRender(this);
return app.request('waitForData').then(this.lazyRender).then(this.listenToRequestsCollections.bind(this));
},
updateTabs: function(e) {
var tab;
if (!_.isOpenedOutside(e)) {
tab = getNameFromId(e.currentTarget.id);
tab = resolveCurrentTab(tab);
if (tab !== this.currentTab) {
this.triggerMethod('tabs:change', tab);
this.currentTab = tab;
this.currentTabData = tabsData.all[tab];
return this.render();
}
}
},
serializeData: function() {
var counter, counters, data, k, name, parent, ref1, subTabsData, v;
counters = app.request('get:network:counters');
ref1 = this.currentTabData, parent = ref1.parent, name = ref1.name;
subTabsData = tabsData[parent];
for (k in subTabsData) {
v = subTabsData[k];
v.active = false;
counter = v.counter;
if (counter != null) {
v.count = counters[counter];
}
}
subTabsData[name].active = true;
data = _.extend(counters, {
subTabsData: subTabsData
});
data[parent] = true;
return data;
},
onRender: function() {
return this.updateMetadata();
},
listenToRequestsCollections: function() {
return this.listenTo(app.vent, 'network:requests:udpate', this.lazyRender);
},
updateMetadata: function() {
var path, ref1, title;
ref1 = this.currentTabData, path = ref1.path, title = ref1.title;
navigate(path);
return updateTitle(title);
}
});
navigate = function(path) {
if (path !== _.currentRoute()) {
return app.navigate(path);
}
};
updateTitle = function(title) {
var network;
title = _.I18n(title);
network = _.I18n('network');
return app.execute('metadata:update:title', title + " - " + network);
};
});
;require.register("modules/network/views/templates/create_group_layout", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<label for=\"nameField\">"
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"group name",{"name":"I18n","hash":{},"data":data}))
+ "</label>\n<div class=\"inputContainer\">\n <input id=\"nameField\" type=\"text\" placeholder=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"ex: the secret club of Proustian experts",{"name":"i18n","hash":{},"data":data}))
+ "\" class=\"enterClick\">\n</div>\n\n<label for=\"description\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"description",{"name":"i18n","hash":{},"data":data}))
+ "</label>\n"
+ alias3((helpers.textarea || (depth0 && depth0.textarea) || alias2).call(alias1,(depth0 != null ? depth0.description : depth0),{"name":"textarea","hash":{},"data":data}))
+ "\n\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"network:searchability",(depth0 != null ? depth0.searchability : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"network:group_position_setting",{"name":"partial","hash":{},"data":data}))
+ "\n\n<a id=\"createGroup\" class=\"button light-blue bold radius\" tabindex=\"0\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"plus",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"create group",{"name":"I18n","hash":{},"data":data}))
+ "\n</a>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/friends_layout", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<section class=\"friends-requests-wrapper hidden\">\n <h3 id=\"friendsRequestsHeader\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"pending friends requests",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n <div id=\"friendsRequests\"></div>\n</section>\n\n<section class=\"friends-list\">\n <div class=\"friends-filter-wrapper hidden\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"filter",(depth0 != null ? depth0.friendsFilter : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n <div id=\"friendsList\">\n <span class=\"loading\"></span>\n </div>\n</section>\n\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/group", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<a href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\" class=\"showGroup\">\n <img src=\""
+ alias4((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,(depth0 != null ? depth0.picture : depth0),48,{"name":"src","hash":{},"data":data}))
+ "\" alt=\""
+ alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ "\" class=\"groupPic\">\n <span class=\"name\">"
+ alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ "</span>\n</a>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/group_actions", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <a class=\"accept\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"accept invitation",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n <a class=\"decline\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"decline",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n";
},"3":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <div>\n <p class=\"requested\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"you requested to join is waiting for approval",{"name":"i18n","hash":{},"data":data}))
+ "\n </p>\n <a class=\"cancelRequest\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"cancel request",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n <span class=\"check\"></span>\n </div>\n";
},"5":function(container,depth0,helpers,partials,data) {
return " <a class=\"joinRequest\">"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"request to join group",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n <span class=\"check\"></span>\n";
},"7":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <p class=\"restrictions\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"globe",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"as you are not a member of the group, you can only see members' public books",{"name":"i18n","hash":{},"data":data}))
+ "\n </p>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {};
return "<div class=\"actions\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.status_invited : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.status_requested : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.status_none : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>\n"
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.mainUserIsMember : depth0),{"name":"unless","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/group_board", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return "class=\"hidden\"";
},"3":function(container,depth0,helpers,partials,data) {
var stack1;
return " <section id=\"groupSettings\">\n "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"network:group_board_section",((stack1 = (depth0 != null ? depth0.sections : depth0)) != null ? stack1.settings : stack1),{"name":"partial","hash":{},"data":data}))
+ "\n </section>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"header\"></div>\n<div class=\"body\">\n <section id=\"groupRequests\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"network:group_board_section",((stack1 = (depth0 != null ? depth0.sections : depth0)) != null ? stack1.requests : stack1),{"name":"partial","hash":{},"data":data}))
+ "\n </section>\n <section id=\"groupMembers\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"network:group_board_section",((stack1 = (depth0 != null ? depth0.sections : depth0)) != null ? stack1.members : stack1),{"name":"partial","hash":{},"data":data}))
+ "\n </section>\n <section id=\"groupInvite\" "
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.status_member : depth0),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"network:group_board_section",((stack1 = (depth0 != null ? depth0.sections : depth0)) != null ? stack1.invite : stack1),{"name":"partial","hash":{},"data":data}))
+ "\n </section>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.mainUserIsMember : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/group_board_header", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return " class=\"cover\"\n style=\"background-image: url('"
+ container.escapeExpression((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.picture : depth0),540,{"name":"src","hash":{},"data":data}))
+ "')\"\n";
},"3":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <span class=\"searchable\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"this group appears in search resuts",{"name":"i18n","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"globe",{"name":"icon","hash":{},"data":data}))
+ "\n </span>\n";
},"5":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <span class=\"not-searchable\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"only those who get the link or are invited can find this group",{"name":"i18n","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"lock",{"name":"icon","hash":{},"data":data}))
+ "\n </span>\n";
},"7":function(container,depth0,helpers,partials,data) {
return " <span class=\"invitor\">"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"group_invitor",(depth0 != null ? depth0.invitor : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</span>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<a href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\" class=\"cover-link showGroup\">\n <div\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.picture : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " >\n <span class=\"name\">"
+ alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ "</span>\n <span class=\"description\">"
+ alias4(((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"description","hash":{},"data":data}) : helper)))
+ "</span>\n "
+ alias4((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"network:group_stats",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n</a>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.searchable : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.program(5, data, 0),"data":data})) != null ? stack1 : "")
+ "<a href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\" class=\"link showGroup\">"
+ alias4((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"go to the group inventory",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n<div class=\"bottom\">\n"
+ ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.invitor : depth0)) != null ? stack1.username : stack1),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " "
+ alias4((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"network:group_actions",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/group_board_section", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<a class=\"section-toggler\">\n <h4>"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,(depth0 != null ? depth0.icon : depth0),{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,(depth0 != null ? depth0.label : depth0),{"name":"I18n","hash":{},"data":data}))
+ "</h4>\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"caret-down",{"name":"icon","hash":{},"data":data}))
+ "\n</a>\n<div class=\"inner\"></div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/group_position_setting", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"group-position-setting\">\n <div>\n <label for=\"showPositionPicker\">\n "
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"set the group's position",{"name":"I18n","hash":{},"data":data}))
+ "\n </label>\n <span class=\"tip\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"group_position_context",{"name":"i18n","hash":{},"data":data}))
+ "\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"info-circle",{"name":"icon","hash":{},"data":data}))
+ "</span>\n </div>\n <a id=\"showPositionPicker\" class=\"button radius\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"map-marker",{"name":"icon","hash":{},"data":data}))
+ "\n </a>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/group_settings", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <section>\n <label for=\"editName\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"name",{"name":"i18n","hash":{},"data":data}))
+ "</label>\n "
+ alias3((helpers.input || (depth0 && depth0.input) || alias2).call(alias1,(depth0 != null ? depth0.editName : depth0),"check",{"name":"input","hash":{},"data":data}))
+ "\n </section>\n <hr>\n\n <section>\n <label for=\"editDescription\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"description",{"name":"i18n","hash":{},"data":data}))
+ "</label>\n "
+ alias3((helpers.textarea || (depth0 && depth0.textarea) || alias2).call(alias1,(depth0 != null ? depth0.editDescription : depth0),"check",{"name":"textarea","hash":{},"data":data}))
+ "\n <div class=\"saveCancel hidden\">"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"save_cancel",{"name":"partial","hash":{},"data":data}))
+ "</div>\n <div class=\"check\"></div>\n </section>\n <hr>\n\n <section>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"network:searchability",(depth0 != null ? depth0.searchability : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n </section>\n <hr>\n\n <section>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"general:behaviors:change_picture",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n </section>\n <hr>\n\n <label>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"geolocation",{"name":"i18n","hash":{},"data":data}))
+ "</label>\n <p class=\"position-status\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.hasPosition : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.program(4, data, 0),"data":data})) != null ? stack1 : "")
+ " </p>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"network:group_position_setting",{"name":"partial","hash":{},"data":data}))
+ "\n <hr>\n";
},"2":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression, alias4=container.lambda;
return " "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"the group has a position set",{"name":"i18n","hash":{},"data":data}))
+ " "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"check",{"name":"icon","hash":{},"data":data}))
+ "<br>\n <span class=\"coordinates\">"
+ alias3(alias4(((stack1 = (depth0 != null ? depth0.position : depth0)) != null ? stack1.lat : stack1), depth0))
+ ", "
+ alias3(alias4(((stack1 = (depth0 != null ? depth0.position : depth0)) != null ? stack1.lng : stack1), depth0))
+ "</span>\n";
},"4":function(container,depth0,helpers,partials,data) {
return " "
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"the group's positon isn't set yet",{"name":"i18n","hash":{},"data":data}))
+ "\n";
},"6":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.userIsLastUser : depth0),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.program(9, data, 0),"data":data})) != null ? stack1 : "")
+ " </a>\n";
},"7":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <a class=\"destroy\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"trash",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"destroy group",{"name":"I18n","hash":{},"data":data}))
+ "\n";
},"9":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <a class=\"leave\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"sign-out",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"leave group",{"name":"I18n","hash":{},"data":data}))
+ "\n";
},"11":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <span class=\"leave disabled\" title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"leave_button_disabled",{"name":"i18n","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"ban",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"leave group",{"name":"i18n","hash":{},"data":data}))
+ "\n </span>\n <p class=\"reason\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"leave_button_disabled",{"name":"i18n","hash":{},"data":data}))
+ "</p>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {};
return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.mainUserIsAdmin : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n<section id=\"groupControls\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.userCanLeave : depth0),{"name":"if","hash":{},"fn":container.program(6, data, 0),"inverse":container.program(11, data, 0),"data":data})) != null ? stack1 : "")
+ "</section>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/group_show", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <a class=\"showGroupBoard\" href=\""
+ alias3(((helper = (helper = helpers.boardPathname || (depth0 != null ? depth0.boardPathname : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"boardPathname","hash":{},"data":data}) : helper)))
+ "\"\n title=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"settings",{"name":"i18n","hash":{},"data":data}))
+ "\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"cog",{"name":"icon","hash":{},"data":data}))
+ "</a>\n";
},"3":function(container,depth0,helpers,partials,data) {
return " class=\"cover\"\n style=\"background-image: url('"
+ container.escapeExpression((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.picture : depth0),1600,{"name":"src","hash":{},"data":data}))
+ "')\"\n";
},"5":function(container,depth0,helpers,partials,data) {
return " <p class=\"description\">"
+ container.escapeExpression((helpers.userContent || (depth0 && depth0.userContent) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.description : depth0),{"name":"userContent","hash":{},"data":data}))
+ "</p>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"iconButtons\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"unselect",{"name":"partial","hash":{},"data":data}))
+ "\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.mainUserIsMember : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>\n<div\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.picture : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ">\n <span class=\"name\">"
+ alias3(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ "</span>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.description : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"network:group_stats",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n</div>\n\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"network:group_actions",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/group_stats", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <li class=\"booksCount count\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"books:",{"name":"i18n","hash":{},"data":data}))
+ " "
+ alias3(((helper = (helper = helpers.itemsCount || (depth0 != null ? depth0.itemsCount : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"itemsCount","hash":{},"data":data}) : helper)))
+ "</li>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<ul class=\"stats\">\n <li class=\"membersCount count\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"members:",{"name":"i18n","hash":{},"data":data}))
+ " "
+ alias3(((helper = (helper = helpers.membersCount || (depth0 != null ? depth0.membersCount : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"membersCount","hash":{},"data":data}) : helper)))
+ "</li>\n"
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.publicDataOnly : depth0),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</ul>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/groups_layout", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<div id=\"groupsInvitations\"></div>\n<div id=\"groupsList\">\n <span class=\"loading\"></span>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/groups_list", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<ul class=\"groups\"></ul>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/groups_search_layout", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"filter",(depth0 != null ? depth0.groupsSearch : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n<div id=\"groupsList\">\n <span class=\"loading\"></span>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/invite_friends", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return "has-message";
},"3":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing;
return " <p class=\"email-sent\">"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"email_invitation_sent","email",depth0,{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ " "
+ container.escapeExpression((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"check-circle",{"name":"icon","hash":{},"data":data}))
+ "</p>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression, alias4="function";
return "<form>\n <label for=\"invitations\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"envelope",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"by email address",{"name":"I18n","hash":{},"data":data}))
+ "</label>\n <div class=\"invitations\">\n <textarea id=\"invitations\" name=\"invitations\" placeholder=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"emails separated by a comma",{"name":"i18n","hash":{},"data":data}))
+ "\">"
+ alias3(((helper = (helper = helpers.rawEmails || (depth0 != null ? depth0.rawEmails : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"rawEmails","hash":{},"data":data}) : helper)))
+ "</textarea>\n </div>\n <div class=\"message "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.message : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\">\n <a id=\"addMessage\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"add a personalized message",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n <textarea id=\"message\" name=\"message\" placeholder=\""
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"personalized message",{"name":"i18n","hash":{},"data":data}))
+ "...\">"
+ alias3(((helper = (helper = helpers.message || (depth0 != null ? depth0.message : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"message","hash":{},"data":data}) : helper)))
+ "</textarea>\n </div>\n <a id=\"sendInvitations\" class=\"button success bold radius\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"send invitations",{"name":"i18n","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"general:behaviors:success_check","",{"name":"partial","hash":{},"data":data}))
+ "\n </a>\n</form>\n<div class=\"output\">\n"
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.emailsInvited : depth0),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>\n<div class=\"usersAlreadyThere hidden\">\n <h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"Look who was already there! Friend request sent",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n <div id=\"usersAlreadyThere\"></div>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/nearby_layout", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<section id=\"map\" class=\"map-container\"></section>\n<section id=\"list\"></section>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/nearby_users_layout", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"network:nearby_layout",{"name":"partial","hash":{},"data":data}))
+ "\n<section id=\"position-picker\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"map:position_picker_button",{"name":"partial","hash":{},"data":data}))
+ "\n</section>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/network_layout", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<div class=\"custom-tabs-titles\"></div>\n<div class=\"custom-tabs-content\"></div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/network_sub_tabs", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <a id=\""
+ alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ "Tab\" href=\"/"
+ alias4(((helper = (helper = helpers.path || (depth0 != null ? depth0.path : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"path","hash":{},"data":data}) : helper)))
+ "\" class=\"tab "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.active : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\">\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,(depth0 != null ? depth0.icon : depth0),{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias4((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,(depth0 != null ? depth0.title : depth0),{"name":"I18n","hash":{},"data":data}))
+ "\n "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.count : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n </a>\n";
},"2":function(container,depth0,helpers,partials,data) {
return "active";
},"4":function(container,depth0,helpers,partials,data) {
var helper;
return "<span class=\"counter\">"
+ container.escapeExpression(((helper = (helper = helpers.count || (depth0 != null ? depth0.count : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"count","hash":{},"data":data}) : helper)))
+ "</span>";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},depth0,{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/no_group", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<em>"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.message : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</em>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/searchability", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return "hidden";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"searchability\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"toggler",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n <p class=\"warning "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.checked : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"lock",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"only those who get the link or are invited can find this group",{"name":"i18n","hash":{},"data":data}))
+ "\n </p>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/tabs", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return "active";
},"3":function(container,depth0,helpers,partials,data) {
return " <section class=\"users-level-2 level-2\">\n "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"network:network_sub_tabs",(depth0 != null ? depth0.subTabsData : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n </section>\n";
},"5":function(container,depth0,helpers,partials,data) {
return " <section class=\"groups-level-2 level-2\">\n "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"network:network_sub_tabs",(depth0 != null ? depth0.subTabsData : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n </section>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression, alias4="function";
return "<section class=\"level-1\">\n <a id=\"usersTab\" href=\"/network/users\" class=\"tab "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.users : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"user",{"name":"icon","hash":{},"data":data}))
+ "\n <span class=\"label\">"
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"users",{"name":"I18n","hash":{},"data":data}))
+ "</span>\n <span class=\"counter\">"
+ alias3(((helper = (helper = helpers.friendsRequestsCount || (depth0 != null ? depth0.friendsRequestsCount : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"friendsRequestsCount","hash":{},"data":data}) : helper)))
+ "</span>\n </a>\n <a id=\"groupsTab\" href=\"/network/groups\" class=\"tab "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.groups : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"group",{"name":"icon","hash":{},"data":data}))
+ "\n <span class=\"label\">"
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"groups",{"name":"I18n","hash":{},"data":data}))
+ "</span>\n <span class=\"counter\">"
+ alias3(((helper = (helper = helpers.groupsRequestsCount || (depth0 != null ? depth0.groupsRequestsCount : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"groupsRequestsCount","hash":{},"data":data}) : helper)))
+ "</span>\n </a>\n</section>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.users : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.groups : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/templates/users_search_layout", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"filter",(depth0 != null ? depth0.usersSearch : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n<div id=\"usersList\">\n <span class=\"loading\"></span>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/network/views/users_search_layout", function(exports, require, module) {
var UsersList, behaviorsPlugin, updateRoute;
UsersList = require('modules/users/views/users_list');
behaviorsPlugin = require('modules/general/plugins/behaviors');
updateRoute = require('../lib/update_query_route')('searchUsers');
module.exports = Marionette.LayoutView.extend({
id: 'usersSearchLayout',
template: require('./templates/users_search_layout'),
regions: {
usersList: '#usersList'
},
behaviors: {
Loading: {}
},
events: {
'keyup #usersSearch': 'searchUserFromEvent'
},
initialize: function() {
this.collection = app.users.filtered.resetFilters();
return this.initSearch();
},
serializeData: function() {
return {
usersSearch: {
id: 'usersSearch',
placeholder: 'search for users',
value: this.lastQuery
}
};
},
onShow: function() {
this.lastQuery = '';
this.usersList.show(new UsersList({
collection: this.collection,
stretch: true
}));
return $('.noUser').hide();
},
onRender: function() {
return behaviorsPlugin.startLoading.call(this, '#usersList');
},
initSearch: function() {
var q;
q = this.options.query.q;
if (_.isNonEmptyString(q)) {
return this.searchUser(q);
}
},
searchUserFromEvent: function(e) {
var query;
query = e.target.value;
updateRoute(query);
return this.searchUser(query);
},
searchUser: function(query) {
this.lastQuery = query;
return app.request('users:search', query);
}
});
});
;require.register("modules/notifications/collections/notifications", function(exports, require, module) {
var createTypedModel, error_, models;
error_ = require('lib/error');
models = require('../lib/notifications_types').models;
module.exports = Backbone.Collection.extend({
comparator: function(notif) {
return -notif.get('time');
},
unread: function() {
return this.filter(function(model) {
return model.get('status') === 'unread';
});
},
markAsRead: function() {
return this.each(function(model) {
return model.set('status', 'read');
});
},
initialize: function() {
this.toUpdate = [];
return this.batchUpdate = _.debounce(this.update.bind(this), 200);
},
updateStatus: function(time) {
this.toUpdate.push(time);
return this.batchUpdate();
},
update: function() {
var ids;
_.log(this.toUpdate, 'notifs:update');
ids = this.toUpdate;
this.toUpdate = [];
return $.postJSON(app.API.notifs, {
times: ids
}).fail(console.warn.bind(console));
},
addPerType: function(docs) {
return this.add(_.forceArray(docs).map(createTypedModel));
}
});
createTypedModel = function(doc) {
var Model, type;
type = doc.type;
Model = models[type];
if (Model == null) {
throw error_["new"]('unknown notification type', doc);
}
return new Model(doc);
};
});
;require.register("modules/notifications/lib/notifications_types", function(exports, require, module) {
var groupNotificationModel, groupNotificationTemplate, model, template;
template = function(name) {
return require("../views/templates/" + name);
};
model = function(name) {
return require("../models/" + name);
};
groupNotificationTemplate = template('group_notification');
groupNotificationModel = model('group_notification');
module.exports = {
templates: {
friendAcceptedRequest: template('friend_accepted_request'),
newCommentOnFollowedItem: template('new_comment_on_followed_item'),
userMadeAdmin: groupNotificationTemplate,
groupUpdate: groupNotificationTemplate
},
models: {
friendAcceptedRequest: model('friend_accepted_request'),
newCommentOnFollowedItem: model('new_comment_on_followed_item'),
userMadeAdmin: groupNotificationModel,
groupUpdate: groupNotificationModel
}
};
});
;require.register("modules/notifications/models/friend_accepted_request", function(exports, require, module) {
var Notification;
Notification = require('./notification');
module.exports = Notification.extend({
initSpecific: function() {
return this.grabAttributeModel('user');
},
serializeData: function() {
var attrs, ref, ref1;
attrs = this.toJSON();
attrs.username = (ref = this.user) != null ? ref.get('username') : void 0;
attrs.picture = (ref1 = this.user) != null ? ref1.get('picture') : void 0;
attrs.pathname = "/inventory/" + attrs.username;
return attrs;
}
});
});
;require.register("modules/notifications/models/group_notification", function(exports, require, module) {
var Notification, escapeExpression, getText, getUpdateValue, texts;
Notification = require('./notification');
escapeExpression = Handlebars.escapeExpression;
module.exports = Notification.extend({
initSpecific: function() {
this.grabAttributeModel('group');
this.grabAttributeModel('user');
return this.groupId = this.get('data.group');
},
serializeData: function() {
var attrs, ref;
attrs = this.toJSON();
attrs.username = (ref = this.user) != null ? ref.get('username') : void 0;
attrs = getUpdateValue(attrs);
attrs.pathname = "/network/groups/" + this.groupId;
if (this.group != null) {
attrs.picture = this.group.get('picture');
attrs.groupName = this.group.getEscapedName();
attrs.text = getText(attrs.type, attrs.data.attribute);
attrs.previousValue;
}
return attrs;
}
});
getText = function(type, attribute) {
if (attribute != null) {
return texts[type][attribute];
} else {
return texts[type];
}
};
texts = {
userMadeAdmin: 'user_made_admin',
groupUpdate: {
name: 'group_update_name',
description: 'group_update_description'
}
};
getUpdateValue = function(attrs) {
var newValue, previousValue, ref;
ref = attrs.data, previousValue = ref.previousValue, newValue = ref.newValue;
if (previousValue != null) {
attrs.previousValue = escapeExpression(previousValue);
attrs.newValue = escapeExpression(newValue);
}
return attrs;
};
});
;require.register("modules/notifications/models/new_comment_on_followed_item", function(exports, require, module) {
var Notification;
Notification = require('./notification');
module.exports = Notification.extend({
initSpecific: function() {
this.grabAttributeModel('user');
return this.grabAttributeModel('item');
},
serializeData: function() {
var attrs, entity, ref, ref1, ref2, title;
attrs = this.toJSON();
attrs.username = (ref = this.user) != null ? ref.get('username') : void 0;
attrs.picture = (ref1 = this.user) != null ? ref1.get('picture') : void 0;
if (this.item != null) {
ref2 = this.item.gets('title', 'entity'), title = ref2[0], entity = ref2[1];
attrs.pathname = "/inventory/" + attrs.username + "/" + entity;
attrs.title = title;
}
return attrs;
}
});
});
;require.register("modules/notifications/models/notification", function(exports, require, module) {
module.exports = Backbone.NestedModel.extend({
initialize: function() {
this.on('change:status', this.update);
return this.initSpecific();
},
initSpecific: function() {},
update: function() {
return this.collection.updateStatus(this.get('time'));
},
isUnread: function() {
return this.get('status') === 'unread';
},
grabAttributeModel: function(attribute) {
return app.request('waitForData').then((function(_this) {
return function() {
var id;
id = _this.get("data." + attribute);
return _this.reqGrab("get:" + attribute + ":model", id, attribute);
};
})(this));
}
});
});
;require.register("modules/notifications/notifications", function(exports, require, module) {
var API, Notifications, NotificationsLayout, NotificationsList, getUsersData, getUsersIds;
Notifications = require('./collections/notifications');
NotificationsList = require('./views/notifications_list');
NotificationsLayout = require('./views/notifications_layout');
module.exports = {
define: function(module, app, Backbone, Marionette, $, _) {
var Router;
Router = Marionette.AppRouter.extend({
appRoutes: {
'notifications': 'showNotifications'
}
});
return app.addInitializer(function() {
return new Router({
controller: API
});
});
},
initialize: function() {
var addNotifications, notifications;
notifications = app.user.notifications = new Notifications;
addNotifications = function(notifs) {
_.log(notifs, 'notifications:add');
return getUsersData(notifs).then(_.Full(notifications.addPerType, notifications, notifs))["catch"](_.Error('addNotifications'));
};
app.reqres.setHandlers({
'notifications:add': addNotifications.bind(this)
});
return app.commands.setHandlers({
'show:notifications': function() {
API.showNotifications();
return app.navigate('notifications');
}
});
}
};
getUsersData = function(notifications) {
var ids;
ids = getUsersIds(notifications);
return app.request('get:users:data', ids);
};
getUsersIds = function(notifications) {
var ids;
ids = notifications.map(function(notif) {
return notif.data.user;
});
return _.uniq(ids);
};
API = {
showNotifications: function() {
if (app.request('require:loggedIn', 'notifications')) {
return app.layout.main.Show(new NotificationsLayout, {
docTitle: _.i18n('notifications')
});
}
}
};
});
;require.register("modules/notifications/views/no_notification", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
tagName: 'li',
className: 'notification',
template: require('./templates/no_notification')
});
});
;require.register("modules/notifications/views/notification_li", function(exports, require, module) {
var templates;
templates = require('../lib/notifications_types').templates;
module.exports = Marionette.ItemView.extend({
tagName: 'li',
className: function() {
var status;
status = this.model.get('status');
return "notification " + status;
},
getTemplate: function() {
var notifType, template;
notifType = this.model.get('type');
template = templates[notifType];
if (template == null) {
return _.error('notification type unknown');
}
return template;
},
behaviors: {
PreventDefault: {}
},
initialize: function() {
this.lazyRender = _.LazyRender(this);
this.listenTo(this.model, 'change', this.lazyRender);
return this.listenTo(this.model, 'grab', this.lazyRender);
},
serializeData: function() {
return this.model.serializeData();
},
events: {
'click .friendAcceptedRequest': 'showUserProfile',
'click .newCommentOnFollowedItem': 'showItem',
'click .groupNotification': 'showGroupBoard'
},
showUserProfile: function(e) {
if (!_.isOpenedOutside(e)) {
return app.execute('show:user', this.model.user);
}
},
showItem: function(e) {
if (!_.isOpenedOutside(e)) {
return app.execute('show:item:show:from:model', this.model.item);
}
},
showGroupBoard: function(e) {
if (!_.isOpenedOutside(e)) {
return app.execute('show:group:board', this.model.group);
}
}
});
});
;require.register("modules/notifications/views/notifications_layout", function(exports, require, module) {
module.exports = Marionette.CompositeView.extend({
id: 'notificationsLayout',
childView: require('./notification_li'),
emptyView: require('./no_notification'),
template: require('./templates/notifications_layout'),
childViewContainer: 'ul',
initialize: function() {
return this.collection = app.user.notifications;
}
});
});
;require.register("modules/notifications/views/notifications_list", function(exports, require, module) {
var ListWithCounter, seeAll, seeAllData;
ListWithCounter = require('modules/general/views/menu/list_with_counter');
seeAll = require('./templates/see_all');
seeAllData = {
pathname: 'notifications',
text: 'see all'
};
module.exports = ListWithCounter.extend({
childView: require('./notification_li'),
emptyView: require('./no_notification'),
initialize: function() {
this.initUpdaters();
return app.request('waitForData').then(_.preq.Sleep(1000)).then(this.updateSeeAllLink.bind(this));
},
serializeData: function() {
return {
icon: 'globe',
label: _.i18n('notifications')
};
},
className: 'notifications has-dropdown not-click',
events: {
'click .listWithCounter': 'markNotificationsAsRead',
'click .seeAll': 'showAllNotification'
},
markNotificationsAsRead: function() {
return this.collection.markAsRead();
},
count: function() {
return this.collection.unread().length;
},
filter: function(child, index, collection) {
if (child.isUnread()) {
return true;
} else {
return (-1 < index && index < 5);
}
},
updateSeeAllLink: function() {
var ref;
if ((((ref = this.ui) != null ? ref.list.append : void 0) != null) && _.isFunction(this.ui.list.append)) {
return this.ui.list.append(seeAll(seeAllData));
} else {
return setTimeout(this.updateSeeAllLink, 3000);
}
},
showAllNotification: function() {
return app.execute('show:notifications');
}
});
});
;require.register("modules/notifications/views/templates/friend_accepted_request", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"friendAcceptedRequest\">\n <img src=\""
+ alias3((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,(depth0 != null ? depth0.picture : depth0),48,{"name":"src","hash":{},"data":data}))
+ "\">\n <a href=\""
+ alias3(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\">\n <span>"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"friend_accepted_request",depth0,{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</span><br>\n <span class=\"time\">"
+ alias3((helpers.timeFromNow || (depth0 && depth0.timeFromNow) || alias2).call(alias1,(depth0 != null ? depth0.time : depth0),{"name":"timeFromNow","hash":{},"data":data}))
+ "</span>\n </a>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/notifications/views/templates/group_notification", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<div class=\"groupNotification "
+ alias4(((helper = (helper = helpers.type || (depth0 != null ? depth0.type : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"type","hash":{},"data":data}) : helper)))
+ "\">\n <img src=\""
+ alias4((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,(depth0 != null ? depth0.picture : depth0),48,{"name":"src","hash":{},"data":data}))
+ "\">\n <a href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\">\n <span>"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.text : depth0),depth0,{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</span><br>\n <span class=\"time\">"
+ alias4((helpers.timeFromNow || (depth0 && depth0.timeFromNow) || alias2).call(alias1,(depth0 != null ? depth0.time : depth0),{"name":"timeFromNow","hash":{},"data":data}))
+ "</span>\n </a>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/notifications/views/templates/new_comment_on_followed_item", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"newCommentOnFollowedItem\">\n <img src=\""
+ alias3((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,(depth0 != null ? depth0.picture : depth0),48,{"name":"src","hash":{},"data":data}))
+ "\">\n <a href=\""
+ alias3(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\">\n <span>"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"new_comment_on_followed_item",depth0,{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</span><br>\n <span class=\"time\">"
+ alias3((helpers.timeFromNow || (depth0 && depth0.timeFromNow) || alias2).call(alias1,(depth0 != null ? depth0.time : depth0),{"name":"timeFromNow","hash":{},"data":data}))
+ "</span>\n </a>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/notifications/views/templates/no_notification", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<div class=\"empty\">"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"no notification",{"name":"i18n","hash":{},"data":data}))
+ "</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/notifications/views/templates/notifications_layout", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<h2>"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"notifications",{"name":"i18n","hash":{},"data":data}))
+ "</h2>\n<ul></ul>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/notifications/views/templates/see_all", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<li><a href=\""
+ alias3(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\" class=\"seeAll\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.text : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</a></li>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/redirect", function(exports, require, module) {
var API, CallToConnection, ErrorView, Welcome, initQuerystringActions;
Welcome = require('modules/welcome/views/welcome');
ErrorView = require('modules/general/views/error');
CallToConnection = require('modules/general/views/call_to_connection');
initQuerystringActions = require('modules/general/lib/querystring_actions');
module.exports = {
define: function(module, app, Backbone, Marionette, $, _) {
var Router;
Router = Marionette.AppRouter.extend({
appRoutes: {
'(home)': 'showHome',
'welcome': 'showWelcome',
'me': 'showMainUser',
'*route': 'notFound'
}
});
return app.addInitializer(function() {
return new Router({
controller: API
});
});
},
initialize: function() {
app.reqres.setHandlers({
'require:loggedIn': API.requireLoggedIn,
'show:login:redirect': API.requireLoggedIn
});
app.commands.setHandlers({
'show:home': API.showHome,
'show:welcome': API.showWelcome,
'show:error': API.showError,
'show:403': API.show403,
'show:404': API.show404,
'show:offline:error': API.showOfflineError,
'show:call:to:connection': API.showCallToConnection,
'show:error:cookieRequired': API.showErrorCookieRequired
});
return initQuerystringActions();
}
};
API = {
requireLoggedIn: function(route) {
if (app.user.loggedIn) {
return true;
} else {
app.execute('show:login');
route = route.replace(/^\//, '');
app.execute('prepare:login:redirect', route);
return false;
}
},
showHome: function() {
if (app.user.loggedIn) {
return app.execute('show:inventory:general');
} else {
return app.execute('show:welcome');
}
},
notFound: function(route) {
if (app.user.loggedIn) {
_.log(route, 'route:notFound', true);
return app.execute('show:404');
} else {
return this.showWelcome();
}
},
showWelcome: function() {
app.layout.main.Show(new Welcome, {
docTitle: _.i18n('Welcome on Inventaire'),
noCompletion: true
});
return app.navigate('welcome');
},
showMainUser: function() {
return app.execute('show:inventory:main:user');
},
show403: function() {
return app.execute('show:error', {
header: 403,
message: _.i18n('forbidden')
});
},
show404: function() {
return app.execute('show:error', {
header: 404,
message: _.i18n('not found')
});
},
showOfflineError: function() {
return app.execute('show:error', {
message: _.i18n("can't reach the server")
});
},
showError: function(options) {
_.log(options, 'showError', true);
return app.layout.main.show(new ErrorView(options));
},
showCallToConnection: function(message) {
return app.layout.modal.show(new CallToConnection({
connectionMessage: message
}));
},
showErrorCookieRequired: function(command) {
return app.execute('show:error', {
icon: 'cog',
header: _.I18n('cookies are disabled'),
message: _.i18n('cookies_are_required'),
redirection: {
text: _.I18n('retry'),
classes: 'dark-grey',
buttonAction: function() {
if (command != null) {
return app.execute(command);
} else {
return location.href = location.href;
}
}
}
});
}
};
});
;require.register("modules/search/search", function(exports, require, module) {
var API, Search, error_;
Search = require('./views/search');
error_ = require('lib/error');
module.exports = {
define: function(module, app, Backbone, Marionette, $, _) {
var SearchRouter;
SearchRouter = Marionette.AppRouter.extend({
appRoutes: {
'search': 'searchFromQueryString'
}
});
return app.addInitializer(function() {
return new SearchRouter({
controller: API
});
});
},
initialize: function() {
app.commands.setHandlers({
'search:global': API.search
});
return app.reqres.setHandlers({
'search:entities': API.searchEntities
});
}
};
API = {};
API.search = function(query) {
var docTitle, searchLayout;
if (!_.isNonEmptyString(query)) {
app.execute('show:add:layout');
return;
}
app.search = searchLayout = new Search({
query: _.softDecodeURI(query)
});
docTitle = (query + " - ") + _.i18n('Search');
app.layout.main.Show(searchLayout, docTitle);
return app.navigate("search?q=" + query);
};
API.searchFromQueryString = function(querystring) {
var q;
q = _.parseQuery(querystring).q;
q = q.replace(/\+/g, ' ');
return API.search(q);
};
});
;require.register("modules/search/views/find_by_isbn", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
template: require('./templates/find_by_isbn'),
className: 'findByIsbn',
serializeData: function() {
return {
findByIsbn: {
nameBase: 'isbn',
field: {
placeholder: _.i18n('ex: 978-2-07-036822-8'),
dotdotdot: ''
},
button: {
icon: 'search',
classes: 'secondary postfix'
}
},
isMobile: _.isMobile
};
},
events: {
'click #isbnButton': 'searchByIsbn'
},
searchByIsbn: function() {
var query;
query = $('input#isbnField').val();
_.log(query, 'isbn query');
return app.execute('search:global', query);
}
});
});
;require.register("modules/search/views/results_list", function(exports, require, module) {
var AuthorLi, BookLi;
BookLi = require('modules/entities/views/book_li');
AuthorLi = require('modules/entities/views/author_li');
module.exports = Marionette.CompositeView.extend({
template: require('./templates/results_list'),
childViewContainer: '.resultsList',
getChildView: function() {
switch (this.options.type) {
case 'books':
return BookLi;
case 'editions':
return BookLi;
case 'authors':
return AuthorLi;
default:
throw new Error('unvalid type provided: cant choose getChildView');
}
},
emptyView: require('modules/inventory/views/no_item'),
serializeData: function() {
return {
type: _.i18n(this.options.type)
};
},
collectionEvents: {
'add': 'hideIfEmpty'
},
onShow: function() {
return this.hideIfEmpty();
},
hideIfEmpty: function() {
if (this.options.hideIfEmpty) {
if (this.collection.length === 0) {
this.$el.addClass('hidden');
return this._hidden = true;
} else if (this._hidden) {
this.$el.removeClass('hidden');
return this._hidden = false;
}
}
},
childViewOptions: {
standalone: false
}
});
});
;require.register("modules/search/views/search", function(exports, require, module) {
var Entities, EntityCreate, FindByIsbn, IsbnEntities, ItemsList, ResultsList, WikidataEntities, addIsbnEntities, addWikidataEntities, behaviorsPlugin, books_, searchInputData, spreadResults, wd_;
ResultsList = require('./results_list');
Entities = require('modules/entities/collections/entities');
WikidataEntities = require('modules/entities/collections/wikidata_entities');
IsbnEntities = require('modules/entities/collections/isbn_entities');
FindByIsbn = require('./find_by_isbn');
ItemsList = require('modules/inventory/views/items_list');
EntityCreate = require('modules/entities/views/entity_create');
wd_ = require('lib/wikidata');
books_ = require('lib/books');
behaviorsPlugin = require('modules/general/plugins/behaviors');
searchInputData = require('modules/general/views/menu/search_input_data');
module.exports = Marionette.LayoutView.extend({
id: 'searchLayout',
template: require('./templates/search'),
behaviors: {
AlertBox: {},
LocalSeachBar: {}
},
serializeData: function() {
return {
search: searchInputData('localSearch', true)
};
},
regions: {
inventoryItems: '#inventoryItems',
authors: '#authors',
books: '#books',
editions: '#editions',
findByIsbn: '#findByIsbn',
createEntity: '#create'
},
ui: {
localSearchField: '#localSearchField'
},
initialize: function(params) {
_.extend(this, behaviorsPlugin);
return this.query = params.query;
},
onShow: function() {
app.request('waitForFriendsItems').then(this.showItems.bind(this));
this.searchEntities();
if (!books_.isIsbn(this.query)) {
this.showFindByIsbn();
return this.showEntityCreationForm();
} else {
return this.showEntityCreationForm(true);
}
},
updateSearchBar: function() {
return this.ui.localSearchField.val(this.query);
},
showItems: function() {
var collection;
collection = Items.filtered.resetFilters().filterByText(this.query);
if (collection.length > 0) {
return this.inventoryItems.show(new ItemsList({
collection: collection,
header: {
text: 'matching books in your network',
classes: 'subheader'
}
}));
}
},
sameAsPreviousQuery: function() {
var ref, ref1, ref2;
if (((ref = app.results) != null ? ref.search : void 0) === this.query && ((ref1 = app.results) != null ? (ref2 = ref1.books) != null ? ref2.length : void 0 : void 0) > 0) {
this.displayResults();
this.authors.$el.hide().fadeIn(200);
return true;
}
},
searchEntities: function() {
var search;
search = this.query;
_.log(search, 'search');
if (!this.sameAsPreviousQuery()) {
app.results = {};
_.preq.get(app.API.entities.search(search))["catch"](_.preq.catch404).then((function(_this) {
return function(res) {
_this.authors.empty();
if (res != null) {
return spreadResults(res);
} else {
}
};
})(this)).then(this.displayResults.bind(this))["catch"]((function(_this) {
return function(err) {
_this.alert('no item found');
_this.displayResults();
return _.error(err, 'searchEntities err');
};
})(this));
return app.execute('show:loader', {
region: this.authors
});
}
},
displayResults: function() {
var authors, books, editions, humans, ref;
ref = app.results, humans = ref.humans, authors = ref.authors, books = ref.books, editions = ref.editions;
this.showAuthors(authors, humans);
this.showBooks(books);
return this.showEditions(editions);
},
showAuthors: function(authors, humans) {
var authorsList;
if ((authors != null ? authors.length : void 0) === 0) {
authors = humans;
}
if ((authors != null ? authors.length : void 0) > 0) {
authorsList = new ResultsList({
collection: authors,
type: 'authors'
});
return this.authors.show(authorsList);
}
},
showBooks: function(books) {
var booksList;
if ((books != null ? books.length : void 0) > 0) {
booksList = new ResultsList({
collection: books,
type: 'books',
entity: 'Q571'
});
return this.books.show(booksList);
}
},
showEditions: function(editions) {
var editionsList;
if ((editions != null ? editions.length : void 0) > 0) {
editionsList = new ResultsList({
collection: editions,
type: 'editions',
entity: 'Q17902573'
});
return this.editions.show(editionsList);
}
},
showFindByIsbn: function() {
return this.findByIsbn.show(new FindByIsbn);
},
showEntityCreationForm: function(queryIsIsbn) {
var options;
options = {
data: this.query
};
if (!queryIsIsbn) {
options.secondChoice = true;
}
this.createEntity.show(new EntityCreate(options));
return this.$el.find('h3.create').show();
}
});
spreadResults = function(res) {
var google, ol, wd;
_.log(res, 'res at spreadResults');
app.results = {
humans: new Entities,
authors: new Entities,
books: new Entities,
editions: new Entities,
search: res.search
};
wd = res.wd, ol = res.ol, google = res.google;
if (wd != null) {
addWikidataEntities(wd.items);
}
if (ol != null) {
addIsbnEntities(ol.items);
}
if (google != null) {
return addIsbnEntities(google.items);
}
};
addWikidataEntities = function(resultsArray) {
var claims, i, len, model, ref, results, wdEntities;
wdEntities = new WikidataEntities(resultsArray);
ref = wdEntities.models;
results = [];
for (i = 0, len = ref.length; i < len; i++) {
model = ref[i];
claims = model.get('claims');
if (_.isntEmpty(claims.P31)) {
if (wd_.isBook(claims.P31)) {
app.results.books.add(model);
}
if (wd_.isHuman(claims.P31)) {
app.results.humans.add(model);
}
}
if (_.isntEmpty(claims.P106)) {
if (wd_.isAuthor(claims.P106)) {
results.push(app.results.authors.add(model));
} else {
results.push(void 0);
}
} else {
results.push(void 0);
}
}
return results;
};
addIsbnEntities = function(resultsArray) {
var editions;
editions = new IsbnEntities(resultsArray);
return app.results.editions.add(editions.models);
};
});
;require.register("modules/search/views/templates/find_by_isbn", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper;
return " <a id=\"scanner\" href=\""
+ container.escapeExpression(((helper = (helper = helpers.scanner || (depth0 != null ? depth0.scanner : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"scanner","hash":{},"data":data}) : helper)))
+ "\">\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<h4>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"find_by_isbn_title",{"name":"i18n","hash":{},"data":data}))
+ "</h4>\n"
+ alias3((helpers.input || (depth0 && depth0.input) || alias2).call(alias1,(depth0 != null ? depth0.findByIsbn : depth0),{"name":"input","hash":{},"data":data}))
+ "\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isMobile : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/search/views/templates/results_list", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper;
return " <h3 class='subheader'>"
+ container.escapeExpression(((helper = (helper = helpers.type || (depth0 != null ? depth0.type : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"type","hash":{},"data":data}) : helper)))
+ "</h3>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.type : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "<ul class=\"resultsList jk\"></ul>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/search/views/templates/search", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return alias3((helpers.input || (depth0 && depth0.input) || alias2).call(alias1,(depth0 != null ? depth0.search : depth0),{"name":"input","hash":{},"data":data}))
+ "\n<section id=\"results\">\n <div id=\"inventoryItems\"></div>\n <div id=\"authors\"></div>\n <div id=\"books\"></div>\n <div id=\"editions\"></div>\n</section>\n\n<section id=\"createGroup\">\n <h3 class=\"create\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"couldn't find your book?",{"name":"i18n","hash":{},"data":data}))
+ "\n </h3>\n <div id=\"findByIsbn\"></div>\n <div id=\"create\"></div>\n</section>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/settings/lib/periodicity_days", function(exports, require, module) {
var days, i, num;
days = [];
for (num = i = 1; i <= 180; num = ++i) {
if (num <= 30 || num % 10 === 0) {
days.push({
num: num
});
}
}
module.exports = function(selectedDay) {
return days.map(function(el) {
if (el.num === selectedDay) {
el.selected = true;
}
return el;
});
};
});
;require.register("modules/settings/settings", function(exports, require, module) {
var API, SettingsLayout, setHandlers, showSettings;
SettingsLayout = require('./views/settings');
module.exports = {
define: function(module, app, Backbone, Marionette, $, _) {
var SettingsRouter;
SettingsRouter = Marionette.AppRouter.extend({
appRoutes: {
'settings(/profile)(/)': 'showProfileSettings',
'settings/notifications(/)': 'showNotificationsSettings',
'settings/labs(/)': 'showLabsSettings'
}
});
return app.addInitializer(function() {
return new SettingsRouter({
controller: API
});
});
},
initialize: function() {
return setHandlers();
}
};
API = {
showProfileSettings: function() {
return showSettings('profile');
},
showNotificationsSettings: function() {
return showSettings('notifications');
},
showLabsSettings: function() {
return showSettings('labs');
}
};
showSettings = function(tab) {
var options, title;
if (app.request('require:loggedIn', "settings/" + tab)) {
title = _.I18n('settings');
options = {
model: app.user,
tab: tab
};
return app.layout.main.Show(new SettingsLayout(options), title);
}
};
setHandlers = function() {
return app.commands.setHandlers({
'show:settings:profile': API.showProfileSettings,
'show:settings:notifications': API.showNotificationsSettings,
'show:settings:labs': API.showLabsSettings
});
};
});
;require.register("modules/settings/views/labs_settings", function(exports, require, module) {
var behaviorsPlugin, cleaningDb, getRoot, putItems;
behaviorsPlugin = require('modules/general/plugins/behaviors');
module.exports = Marionette.ItemView.extend({
template: require('./templates/labs_settings'),
className: 'labsSettings',
behaviors: {
AlertBox: {},
SuccessCheck: {},
Loading: {}
},
events: {
'click a#jsonInventoryExport': 'jsonInventoryExport',
'click a#pouchdbButton': 'pouchdbInventoryExport'
},
ui: {
url: '#pouchdbField'
},
initialize: function() {
return _.extend(this, behaviorsPlugin);
},
serializeData: function() {
return {
pouchdb: this.pouchDbData()
};
},
pouchDbData: function() {
return {
nameBase: 'pouchdb',
field: {
placeholder: _.i18n('enter the url of your CouchDB database'),
type: 'url'
},
button: {
text: _.i18n('replicate'),
classes: 'dark-grey postfix'
}
};
},
jsonInventoryExport: function() {
var date, name, userInventory, username;
userInventory = Items.personal.toJSON();
username = app.user.get('username');
date = new Date().toLocaleDateString();
name = "inventaire.io-" + username + "-" + date + ".json";
return _.openJsonWindow(userInventory, name);
},
pouchdbInventoryExport: function() {
var url;
url = this.validUrl();
if (url != null) {
return this.validCouchDB(url).then(this.triggerReplication.bind(this));
}
},
triggerReplication: function() {
_.log('couchdb ok');
this.startLoading('#pouchdbButton');
return this.importPouchDbScript().then(this.replicateInventory.bind(this));
},
importPouchDbScript: function() {
_.log('Importing PouchDB');
return _.preq.getScript(app.API.scripts.pouchdb)["catch"](_.Error('failed to import PouchDB'));
},
replicateInventory: function() {
var invDb, url;
_.log('Start replication process');
if (window.PouchDB != null) {
_.log('Found PouchDB');
url = this.validUrl();
if (url != null) {
invDb = new PouchDB('inv');
return putItems(invDb).then(this.replicateDb.bind(this, invDb, url)).then(function() {
return cleaningDb(invDb);
});
}
}
},
validUrl: function() {
var url;
url = this.ui.url.val();
if (!_.isUrl(url)) {
return this.alert('invalid url');
} else {
return url;
}
},
validCouchDB: function(url) {
var root;
root = getRoot(url);
if (root != null) {
return $.getJSON(root).then((function(_this) {
return function(res) {
if (res.couchdb != null) {
return 'ok';
} else {
return _this.alert("the server doesn't answer as a CouchDB. You might need to enable CORS on your CouchDB");
}
};
})(this)).fail((function(_this) {
return function(err) {
_.error(err, err.statusText);
return _this.alert("the server doesn't answer as expected.");
};
})(this));
} else {
return this.alert("it doesn't seem to be valid CouchDB url");
}
},
replicateDb: function(db, url) {
_.log('Replicate to PouchDB!');
return db.replicate.to(url).then(this.Check('replicateDb success'))["catch"](this.Fail('replicateDb success'))["finally"](this.stopLoading.bind(this));
}
});
putItems = function(db) {
var docs;
docs = Items.personal.toJSON();
_.log(docs, 'transfer items to PouchDB');
return db.bulkDocs(docs);
};
cleaningDb = function(db) {
return db.destroy().then(_.Log('cleaning DB'))["catch"](_.Error('cleaning DB err'));
};
getRoot = function(url) {
var root;
root = url != null ? url.split('/').slice(0, -1).join('/') : void 0;
if (_.isUrl(root)) {
return root;
} else {
}
};
});
;require.register("modules/settings/views/notifications_settings", function(exports, require, module) {
var defaultPeriodicity, getPeriodicityDays, notificationsList;
notificationsList = sharedLib('notifications_settings_list');
getPeriodicityDays = require('../lib/periodicity_days');
defaultPeriodicity = 20;
module.exports = Marionette.ItemView.extend({
template: require('./templates/notifications_settings'),
className: 'notificationsSettings',
initialize: function() {
this.lazyRender = _.LazyRender(this);
return this.listenTo(app.user, 'change:settings', this.lazyRender);
},
behaviors: {
SuccessCheck: {}
},
serializeData: function() {
var notifications, summaryPeriodicity;
notifications = app.user.get('settings.notifications');
summaryPeriodicity = app.user.get('summaryPeriodicity') || defaultPeriodicity;
return _.extend(this.getNotificationsData(notifications), {
warning: 'global_email_toggle_warning',
showWarning: !notifications.global,
showPeriodicity: !notifications.inventories_activity_summary,
days: getPeriodicityDays(summaryPeriodicity)
});
},
getNotificationsData: function(notifications) {
var data, i, len, notif;
data = {};
for (i = 0, len = notificationsList.length; i < len; i++) {
notif = notificationsList[i];
data[notif] = {
id: notif,
checked: notifications[notif] !== false,
label: notif + "_notification"
};
}
return data;
},
ui: {
global: '#global',
warning: '.warning',
globalFog: '.rest-fog',
periodicityFog: '.periodicity-fog'
},
events: {
'change .toggler-input': 'toggleSetting',
'change #periodicityPicker': 'updatePeriodicity'
},
toggleSetting: function(e) {
var checked, id, ref;
ref = e.currentTarget, id = ref.id, checked = ref.checked;
return this.updateSetting(id, checked);
},
updateSetting: function(id, value) {
app.request('user:update', {
attribute: "settings.notifications." + id,
value: value,
defaultPreviousValue: true
});
if (id === 'global') {
this.toggleWarning();
}
if (id === 'inventories_activity_summary') {
return this.togglePeriodicity();
}
},
toggleWarning: function() {
this.ui.warning.slideToggle(200);
return this.ui.globalFog.fadeToggle(200);
},
togglePeriodicity: function() {
return this.ui.periodicityFog.fadeToggle(200);
},
updatePeriodicity: function(e) {
return app.request('user:update', {
attribute: 'summaryPeriodicity',
value: e.target.value,
selector: '#periodicityPicker'
});
}
});
});
;require.register("modules/settings/views/profile_settings", function(exports, require, module) {
var behaviorsPlugin, email_, forms_, password_, pickerData, sendDeletionFeedback, testAttribute, username_;
username_ = require('modules/user/lib/username_tests');
email_ = require('modules/user/lib/email_tests');
password_ = require('modules/user/lib/password_tests');
forms_ = require('modules/general/lib/forms');
behaviorsPlugin = require('modules/general/plugins/behaviors');
module.exports = Marionette.ItemView.extend({
template: require('./templates/profile_settings'),
className: 'profileSettings',
behaviors: {
AlertBox: {},
SuccessCheck: {},
Loading: {},
ConfirmationModal: {},
TogglePassword: {}
},
ui: {
username: '#usernameField',
email: '#emailField',
currentPassword: '#currentPassword',
newPassword: '#newPassword',
passwords: '.password',
passwordUpdater: '#passwordUpdater',
languagePicker: '#languagePicker'
},
initialize: function() {
_.extend(this, behaviorsPlugin);
this.listenTo(this.model, 'change:picture', this.render);
this.listenTo(this.model, 'change:position', this.render);
return this.listenTo(app.vent, 'i18n:reset', _.debounce(this.render.bind(this), 1000));
},
onShow: function() {
return app.execute('foundation:reload');
},
serializeData: function() {
var attrs;
attrs = this.model.toJSON();
return _.extend(attrs, {
usernamePicker: this.usernamePickerData(),
emailPicker: this.emailPickerData(),
languages: this.languagesData(),
changePicture: {
classes: 'max-large-profilePic'
},
localCreationStrategy: attrs.creationStrategy === 'local',
hasPassword: attrs.creationStrategy === 'local' || attrs.hasPassword,
hasPosition: this.model.hasPosition(),
position: this.model.getCoords()
});
},
usernamePickerData: function() {
return pickerData(this.model, 'username');
},
emailPickerData: function() {
return pickerData(this.model, 'email');
},
languagesData: function() {
var currentLanguages, languages, ref;
languages = _.deepClone(window.wdLang.byCode);
currentLanguages = _.shortLang(this.model.get('language'));
if ((ref = languages[currentLanguages]) != null) {
ref.selected = true;
}
return languages;
},
events: {
'click a#changePicture': 'changePicture',
'click a#usernameButton': 'updateUsername',
'click a#emailButton': 'updateEmail',
'click a#emailConfirmationRequest': 'emailConfirmationRequest',
'change select#languagePicker': 'changeLanguage',
'click a#updatePassword': 'updatePassword',
'click #forgotPassword': function() {
return app.execute('show:forgot:password');
},
'click #deleteAccount': 'askDeleteAccountConfirmation',
'click #showPositionPicker': function() {
return app.execute('show:position:picker:main:user');
}
},
updateUsername: function() {
var username;
username = this.ui.username.val();
return _.preq.start.then(this.testUsername.bind(this, username)).then((function(_this) {
return function() {
if (_this.usernameCaseChange(username)) {
} else {
return username_.verifyUsername(username, '#usernameField');
}
};
})(this)).then(_.Full(this.confirmUsernameChange, this, username))["catch"](forms_.catchAlert.bind(null, this));
},
usernameCaseChange: function(username) {
return username.toLowerCase() === this.model.get('username').toLowerCase();
},
testUsername: function(username) {
return testAttribute('username', username, username_);
},
confirmUsernameChange: function(username) {
var action;
action = this.updateUserUsername.bind(this, username);
return this.askConfirmation(action, {
requestedUsername: username,
currentUsername: app.user.get('username'),
usernameCaseChange: this.usernameCaseChange(username),
model: this.model
});
},
askConfirmation: function(action, args) {
var usernameCaseChange;
usernameCaseChange = args.usernameCaseChange;
return this.$el.trigger('askConfirmation', {
confirmationText: _.i18n('username_change_confirmation', args),
warningText: !usernameCaseChange ? _.i18n('username_change_warning') : void 0,
action: action,
selector: '#usernameGroup'
});
},
updateUserUsername: function(username) {
return app.request('user:update', {
attribute: 'username',
value: username,
selector: '#usernameButton'
});
},
updateEmail: function() {
var email;
email = this.ui.email.val();
return _.preq.start.then(this.testEmail.bind(this, email)).then(this.startLoading.bind(this, '#emailButton')).then(email_.verifyAvailability.bind(null, email, "#emailField")).then(email_.verifyExistance.bind(email_, email, '#emailField')).then(this.sendEmailRequest.bind(this, email)).then(this.showConfirmationEmailSuccessMessage.bind(this))["catch"](forms_.catchAlert.bind(null, this))["finally"](this.hardStopLoading.bind(this));
},
testEmail: function(email) {
return testAttribute('email', email, email_);
},
sendEmailRequest: function(email) {
return _.preq.post(app.API.auth.emailAvailability, {
email: email
}).then(_.property('email')).then(this.sendEmailChangeRequest);
},
sendEmailChangeRequest: function(email) {
return app.request('user:update', {
attribute: 'email',
value: email,
selector: '#emailField'
});
},
hardStopLoading: function() {
return this.$el.find('.loading').empty();
},
emailConfirmationRequest: function() {
$('#notValidEmail').fadeOut();
return app.request('email:confirmation:request').then(this.showConfirmationEmailSuccessMessage);
},
showConfirmationEmailSuccessMessage: function() {
$('#confirmationEmailSent').fadeIn();
return $('#emailButton').once('click', this.hideConfirmationEmailSent);
},
hideConfirmationEmailSent: function() {
return $('#confirmationEmailSent').fadeOut();
},
updatePassword: function() {
var currentPassword, newPassword;
currentPassword = this.ui.currentPassword.val();
newPassword = this.ui.newPassword.val();
return _.preq.start.then(function() {
return password_.pass(currentPassword, '#currentPasswordAlert');
}).then(function() {
return password_.pass(newPassword, '#newPasswordAlert');
}).then(this.startLoading.bind(this, '#updatePassword')).then(this.confirmCurrentPassword.bind(this, currentPassword)).then(this.updateUserPassword.bind(this, currentPassword, newPassword)).then(this.passwordSuccessCheck.bind(this))["catch"](forms_.catchAlert.bind(null, this))["finally"](this.stopLoading.bind(this));
},
confirmCurrentPassword: function(currentPassword) {
return app.request('password:confirmation', currentPassword)["catch"](function(err) {
if (err.status === 401) {
err = new Error('wrong password');
err.selector = '#currentPasswordAlert';
throw err;
} else {
throw err;
}
});
},
updateUserPassword: function(currentPassword, newPassword) {
return app.request('password:update', currentPassword, newPassword);
},
passwordSuccessCheck: function(password) {
this.ui.passwords.val('');
return this.ui.passwordUpdater.trigger('check');
},
passwordFail: function(password) {
return this.ui.passwordUpdater.trigger('fail');
},
changeLanguage: function(e) {
return app.request('user:update', {
attribute: 'language',
value: e.target.value,
selector: '#languagePicker'
});
},
changePicture: require('modules/user/lib/change_user_picture'),
askDeleteAccountConfirmation: function() {
var args;
args = {
username: this.model.get('username')
};
return this.$el.trigger('askConfirmation', {
confirmationText: _.i18n('delete_account_confirmation', args),
warningText: _.i18n('delete_account_warning'),
action: this.model.deleteAccount.bind(this.model),
selector: '#usernameGroup',
formAction: sendDeletionFeedback,
formLabel: "that would really help us if you could say a few words about why you're leaving:",
formPlaceholder: "our love wasn't possible because",
yes: 'delete your account',
no: 'cancel'
});
}
});
sendDeletionFeedback = function(message) {
return _.preq.post(app.API.feedback, {
subject: '[account deletion]',
message: message
});
};
testAttribute = function(attribute, value, validator_) {
var err, selector;
selector = "#" + attribute + "Field";
if (value === app.user.get(attribute)) {
err = new Error("that's already your " + attribute);
err.selector = selector;
throw err;
} else {
validator_.pass(value, selector);
return value;
}
};
pickerData = function(model, attribute) {
return {
nameBase: attribute,
special: true,
field: {
value: model.get(attribute)
},
button: {
text: _.i18n("change " + attribute),
classes: 'grey postfix'
}
};
};
});
;require.register("modules/settings/views/settings", function(exports, require, module) {
var LabsSettings, NotificationsSettings, ProfileSettings, updateDocTitle;
ProfileSettings = require('./profile_settings');
NotificationsSettings = require('./notifications_settings');
LabsSettings = require('./labs_settings');
module.exports = Marionette.LayoutView.extend({
id: 'settings',
template: require('./templates/settings'),
regions: {
tabsContent: '.custom-tabs-content'
},
ui: {
tabsTitles: '.custom-tabs-titles',
profileTitle: '#profile',
notificationsTitle: '#notifications',
labsTitle: '#labs'
},
onShow: function() {
var fn, tab;
tab = this.options.tab;
switch (tab) {
case 'profile':
fn = this.showProfileSettings;
break;
case 'notifications':
fn = this.showNotificationsSettings;
break;
case 'labs':
fn = this.showLabsSettings;
break;
default:
_.error('unknown tab requested');
}
return app.request('waitForUserData').then(fn.bind(this));
},
events: {
'click #profile': 'showProfileSettings',
'click #notifications': 'showNotificationsSettings',
'click #labs': 'showLabsSettings'
},
showProfileSettings: function() {
this.tabsContent.show(new ProfileSettings({
model: this.model
}));
return this.tabUpdate('profile');
},
showNotificationsSettings: function() {
this.tabsContent.show(new NotificationsSettings({
model: this.model
}));
return this.tabUpdate('notifications');
},
showLabsSettings: function() {
this.tabsContent.show(new LabsSettings({
model: this.model
}));
return this.tabUpdate('labs');
},
tabUpdate: function(tab) {
this.setActiveTab(tab);
updateDocTitle(tab);
return app.navigate("settings/" + tab);
},
setActiveTab: function(name) {
var tab;
tab = name + "Title";
this.ui.tabsTitles.find('a').removeClass('active');
return this.ui[tab].addClass('active');
}
});
updateDocTitle = function(tab) {
var settings;
tab = _.I18n(tab);
settings = _.I18n('settings');
return app.execute('metadata:update:title', tab + " - " + settings);
};
});
;require.register("modules/settings/views/templates/email_me_when", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<span class=\"email-me\">"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"email me when",{"name":"i18n","hash":{},"data":data}))
+ "</span>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/settings/views/templates/labs_settings", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<p class=\"intro\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"quote-left",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"labs_intro",{"name":"i18n","hash":{},"data":data}))
+ "\n <br>\n "
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"contribute_with_code_or_ideas",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "!\n</p>\n\n<h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"data exports",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"data_export_intro",{"name":"i18n","hash":{},"data":data}))
+ "\n\n<h4 class=\"subheader\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"personal inventory data",{"name":"i18n","hash":{},"data":data}))
+ "</h4>\n\n<div class=\"panel\">\n <h5>"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"pouchdb",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"PouchDB export",{"name":"i18n","hash":{},"data":data}))
+ ":</h5>\n <p class=\"intro\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"Replicate your data to a CouchDB instance you control",{"name":"i18n","hash":{},"data":data}))
+ "!\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"It's just a backup for the moment, it won't stay in sync",{"name":"i18n","hash":{},"data":data}))
+ ".\n <br>\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"question-circle",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18nLink || (depth0 && depth0.i18nLink) || alias2).call(alias1,"what is PouchDB?","http://pouchdb.com/",{"name":"i18nLink","hash":{},"data":data}))
+ "\n </p>\n "
+ alias3((helpers.input || (depth0 && depth0.input) || alias2).call(alias1,(depth0 != null ? depth0.pouchdb : depth0),"check",{"name":"input","hash":{},"data":data}))
+ "\n</div>\n\n<div class=\"panel\">\n <h5>"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"download",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"downloads",{"name":"I18n","hash":{},"data":data}))
+ ":</h5>\n <a id=\"jsonInventoryExport\" class=\"button grey\">JSON</a>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/settings/views/templates/notifications_settings", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return "shown";
},"3":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <option value=\""
+ alias4(((helper = (helper = helpers.num || (depth0 != null ? depth0.num : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"num","hash":{},"data":data}) : helper)))
+ "\" "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.selected : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ">"
+ alias4(((helper = (helper = helpers.num || (depth0 != null ? depth0.num : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"num","hash":{},"data":data}) : helper)))
+ "</option>\n";
},"4":function(container,depth0,helpers,partials,data) {
return "selected";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"global\">\n <h3 class=\"first\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"global",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"toggler",(depth0 != null ? depth0.global : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n <p class=\"warning "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.showWarning : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"warning",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.warning : depth0),{"name":"i18n","hash":{},"data":data}))
+ "\n </p>\n <hr>\n</div>\n\n<div class=\"rest\">\n <div class=\"rest-fog local-fog "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.showWarning : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\"></div>\n <div class=\"news\">\n <h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"news",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"toggler",(depth0 != null ? depth0.inventories_activity_summary : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n <div class=\"summary-periodicity checkWrapper\">\n <div class=\"periodicity-fog local-fog "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.showPeriodicity : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\"></div>\n <div class=\"row\">\n <span>"
+ ((stack1 = (helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"activity_summary_periodicity_tip",{"name":"I18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</span>\n <select id=\"periodicityPicker\" name=\"periodicity\">\n"
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.days : depth0),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </select>\n </div>\n <span class=\"check\"></span>\n </div>\n </div>\n <div class=\"friends\">\n <h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"friends",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"settings:email_me_when",{"name":"partial","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"toggler",(depth0 != null ? depth0.friendship_request : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n <hr>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"toggler",(depth0 != null ? depth0.friend_accepted_request : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n <hr>\n </div>\n\n <div class=\"groups\">\n <h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"groups",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"settings:email_me_when",{"name":"partial","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"toggler",(depth0 != null ? depth0.group_invite : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n <hr>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"toggler",(depth0 != null ? depth0.group_acceptRequest : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n <hr>\n </div>\n\n <div class=\"exchanges\">\n <h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"exchanges",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"settings:email_me_when",{"name":"partial","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"toggler",(depth0 != null ? depth0.your_item_was_requested : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n <hr>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"toggler",(depth0 != null ? depth0.update_on_your_item : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n <hr>\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"toggler",(depth0 != null ? depth0.update_on_item_you_requested : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n <hr>\n </div>\n\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/settings/views/templates/password_update_input", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression, alias4="function";
return "<h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"password",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n<form id=\"passwordUpdater\">\n\n <span class=\"note\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"current password",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n <div class=\"passwordGroup\">\n <input type=\"password\" id=\"currentPassword\" class=\"password enterClick radius-left\" "
+ alias3(((helper = (helper = helpers.disableAuto || (depth0 != null ? depth0.disableAuto : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"disableAuto","hash":{},"data":data}) : helper)))
+ ">\n <a class=\"showPassword\" class=\"radius-right\">\n <span class=\"displayed\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"show",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n <span class=\"substitute\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"hide",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n </a>\n </div>\n <div>\n <div id=\"currentPasswordAlert\"></div>\n </div>\n <div class=\"forgotPassword\">\n <a id=\"forgotPassword\" class=\"link\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"forgot your password?",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n </div>\n\n <span class=\"note\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"new password",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n <div class=\"passwordGroup\">\n <input type=\"password\" id=\"newPassword\" class=\"password enterClick radius-left\" "
+ alias3(((helper = (helper = helpers.disableAuto || (depth0 != null ? depth0.disableAuto : depth0)) != null ? helper : alias2),(typeof helper === alias4 ? helper.call(alias1,{"name":"disableAuto","hash":{},"data":data}) : helper)))
+ ">\n <a class=\"showPassword\" class=\"radius-right\">\n <span class=\"displayed\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"show",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n <span class=\"substitute\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"hide",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n </a>\n </div>\n <div>\n <div id=\"newPasswordAlert\"></div>\n </div>\n\n <a id=\"updatePassword\" class=\"button grey postfix\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"change password",{"name":"i18n","hash":{},"data":data}))
+ "\n <span class=\"loading\"></span>\n </a>\n</form>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/settings/views/templates/profile_settings", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <hr>\n <h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"email",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n\n <p class=\"note\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"email will not be publicly displayed.",{"name":"i18n","hash":{},"data":data}))
+ "\n </p>\n "
+ alias3((helpers.input || (depth0 && depth0.input) || alias2).call(alias1,(depth0 != null ? depth0.emailPicker : depth0),{"name":"input","hash":{},"data":data}))
+ "\n\n"
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.validEmail : depth0),{"name":"unless","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n <div id=\"confirmationEmailSent\" class=\"hidden successMessageBox\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"check",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"new_confirmation_email",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "\n </div>\n";
},"2":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <div id=\"notValidEmail\" class=\"alertMessageBox\">\n <span class=\"alert\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"warning",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"email_wasnt_verified",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "\n </span>\n <a id=\"emailConfirmationRequest\" class=\"button dark-grey radius\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"email_confirmation_error_button",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n </div>\n";
},"4":function(container,depth0,helpers,partials,data) {
return " <hr>\n "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"settings:password_update_input",depth0,"check",{"name":"partial","hash":{},"data":data}))
+ "\n";
},"6":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression, alias2=container.lambda;
return " "
+ alias1((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"you have a position set",{"name":"i18n","hash":{},"data":data}))
+ "<br>\n <span class=\"coordinates\">"
+ alias1(alias2(((stack1 = (depth0 != null ? depth0.position : depth0)) != null ? stack1.lat : stack1), depth0))
+ ", "
+ alias1(alias2(((stack1 = (depth0 != null ? depth0.position : depth0)) != null ? stack1.lng : stack1), depth0))
+ "</span>\n";
},"8":function(container,depth0,helpers,partials,data) {
return " "
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"your positon isn't set yet",{"name":"i18n","hash":{},"data":data}))
+ "\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<h3 class=\"first\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"profile pic",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"general:behaviors:change_picture",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n\n<hr>\n<h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"language",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"user:language_picker",depth0,"check",{"name":"partial","hash":{},"data":data}))
+ "\n\n<hr>\n<h3 class=\"with-tip\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"username",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n"
+ alias3((helpers.tip || (depth0 && depth0.tip) || alias2).call(alias1,"username_tip","right",{"name":"tip","hash":{},"data":data}))
+ "\n"
+ alias3((helpers.input || (depth0 && depth0.input) || alias2).call(alias1,(depth0 != null ? depth0.usernamePicker : depth0),{"name":"input","hash":{},"data":data}))
+ "\n\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.localCreationStrategy : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.hasPassword : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n<hr>\n<h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"geolocation",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n<p class=\"position-status\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.hasPosition : depth0),{"name":"if","hash":{},"fn":container.program(6, data, 0),"inverse":container.program(8, data, 0),"data":data})) != null ? stack1 : "")
+ "</p>\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"map:position_picker_button",{"name":"partial","hash":{},"data":data}))
+ "\n\n<hr>\n<h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"danger zone",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n\n<div class=\"deleteAccount\">\n <a id=\"deleteAccount\" class=\"dangerous-button\">"
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"delete your account",{"name":"I18n","hash":{},"data":data}))
+ "</a>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/settings/views/templates/settings", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"custom-column\">\n <div class=\"custom-tabs\">\n <ul class=\"custom-tabs-titles\">\n <a id=\"profile\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"sliders",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"edit profile",{"name":"I18n","hash":{},"data":data}))
+ "</a>\n <a id=\"notifications\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"envelope",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"notifications",{"name":"I18n","hash":{},"data":data}))
+ "</a>\n <a id=\"labs\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"flask",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"labs",{"name":"I18n","hash":{},"data":data}))
+ "</a>\n </ul>\n <div class=\"custom-tabs-content\"></div>\n </div>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/transactions/collections/timeline", function(exports, require, module) {
module.exports = Backbone.Collection.extend({
comparator: function(model) {
return model.get('created') || model.get('timestamp');
}
});
});
;require.register("modules/transactions/collections/transactions", function(exports, require, module) {
module.exports = Backbone.Collection.extend({
model: require('../models/transaction'),
comparator: function(transaction) {
return -transaction.get('created');
}
});
});
;require.register("modules/transactions/helpers", function(exports, require, module) {
var API, Message, addMessageToTimeline, initLateHelpers, poster_;
Message = require('./models/message');
poster_ = require('lib/poster');
module.exports = function() {
app.reqres.setHandlers({
'transactions:add': API.addTransaction,
'get:transaction:byId': API.getTransaction,
'transaction:post:message': API.postMessage
});
return app.request('waitForUserData').then(initLateHelpers);
};
API = {
addTransaction: function(transaction) {
return app.user.transactions.add(transaction);
},
getTransaction: function(id) {
return app.user.transactions.byId(id);
},
postMessage: function(transactionId, message, timeline) {
var mesModel, messegeData;
messegeData = {
transaction: transactionId,
message: message
};
mesModel = addMessageToTimeline(messegeData, timeline);
messegeData.action = 'new-message';
return _.preq.post(app.API.transactions, messegeData).then(poster_.UpdateModelIdRev(mesModel))["catch"](poster_.Rewind(mesModel, timeline))["catch"](_.Error('postMessage'));
}
};
addMessageToTimeline = function(messegeData, timeline) {
var mesModel;
_.extend(messegeData, {
user: app.user.id,
created: _.now()
});
mesModel = new Message(messegeData);
timeline.add(mesModel);
return mesModel;
};
initLateHelpers = function() {
var filtered, getOneOngoingTransactionByItemId, getOngoingTransactionsByItemId, getOngoingTransactionsModelsByItemId, hasOngoingTransactionsByItemId;
if (app.user.transactions != null) {
filtered = new FilteredCollection(app.user.transactions);
getOngoingTransactionsByItemId = function(itemId) {
filtered.resetFilters();
filtered.filterBy('item', function(transac) {
return transac.get('item') === itemId && !transac.archived;
});
return filtered;
};
getOngoingTransactionsModelsByItemId = function(itemId) {
return app.user.transactions.filter(function(transac) {
return transac.get('item') === itemId && !transac.archived;
});
};
getOneOngoingTransactionByItemId = function(itemId) {
return getOngoingTransactionsModelsByItemId(itemId)[0];
};
hasOngoingTransactionsByItemId = function(itemId) {
return getOngoingTransactionsModelsByItemId(itemId).length > 0;
};
return app.reqres.setHandlers({
'get:transactions:ongoing:byItemId': getOngoingTransactionsByItemId,
'get:transaction:ongoing:byItemId': getOneOngoingTransactionByItemId,
'has:transactions:ongoing:byItemId': hasOngoingTransactionsByItemId
});
}
};
});
;require.register("modules/transactions/lib/apply_side_effects", function(exports, require, module) {
var actions, changeOwnerIfOneWay, oneWay, setItemBusyness, sideEffects;
module.exports = function(transaction, state) {
var item;
_.log(arguments, 'applySideEffects');
item = transaction.item;
sideEffects[state](transaction, item);
};
setItemBusyness = function(bool, transaction, item) {
return item.set('busy', bool);
};
oneWay = {
giving: true,
lending: false,
selling: true
};
changeOwnerIfOneWay = function(transaction, item) {
var isOneWay, transactionMode;
transactionMode = transaction.get('transaction');
isOneWay = oneWay[transactionMode];
if (isOneWay == null) {
throw new Error("invalid transaction mode: " + transactionMode);
}
if (isOneWay) {
return item.set({
owner: transaction.get('requester'),
details: '',
transaction: 'inventorying',
listing: 'private'
});
}
};
actions = {
setItemBusyness: setItemBusyness,
changeOwnerIfOneWay: changeOwnerIfOneWay
};
sideEffects = sharedLib('transaction_side_effects')(actions, _);
});
;require.register("modules/transactions/lib/folders", function(exports, require, module) {
module.exports = {
ongoing: {
id: 'ongoing',
filter: function(transac, index, collection) {
return !transac.archived;
},
icon: 'exchange',
text: 'ongoing'
},
archived: {
id: 'archived',
filter: function(transac, index, collection) {
return transac.archived;
},
icon: 'archive',
text: 'archived'
}
};
});
;require.register("modules/transactions/lib/format_snapshot_data", function(exports, require, module) {
var formatSnapshotItem, formatSnapshotUser;
module.exports = function() {
var item, itemId, owner, ownerId, ref, ref1, requester, requesterId;
ref = this.gets('item', 'owner', 'requester'), itemId = ref[0], ownerId = ref[1], requesterId = ref[2];
ref1 = this.get('snapshot'), item = ref1.item, owner = ref1.owner, requester = ref1.requester;
return this.set({
'snapshot.item': formatSnapshotItem(itemId, item),
'snapshot.owner': formatSnapshotUser(ownerId, owner, 'owner'),
'snapshot.requester': formatSnapshotUser(requesterId, requester, 'requester')
});
};
formatSnapshotItem = function(itemId, data) {
data.pathname = '/items/' + itemId;
return data;
};
formatSnapshotUser = function(userId, data, role) {
data.pathname = '/inventory/' + userId;
return data;
};
});
;require.register("modules/transactions/lib/next_actions", function(exports, require, module) {
var actionsData, addTransactionInfo, findNextActions, getNextActionsData, grabOtherUsername, isArchived, proxyFindNextActions, ref, sharedLibAdapter;
ref = sharedLib('transactions')(_), findNextActions = ref.findNextActions, isArchived = ref.isArchived;
getNextActionsData = function(transaction) {
var data, nextActions;
nextActions = proxyFindNextActions(transaction);
data = actionsData[nextActions];
if (data != null) {
data = addTransactionInfo(data, transaction);
return grabOtherUsername(transaction, data);
} else {
}
};
proxyFindNextActions = function(transaction) {
return findNextActions(sharedLibAdapter(transaction));
};
sharedLibAdapter = function(transaction) {
return {
name: transaction.get('transaction'),
state: transaction.get('state'),
mainUserIsOwner: transaction.mainUserIsOwner
};
};
addTransactionInfo = function(data, transaction) {
var transactionMode;
transactionMode = transaction.get('transaction');
return data.map(function(action) {
action.info = action.text + "_info_" + transactionMode;
action.itemId = transaction.get('item');
return action;
});
};
grabOtherUsername = function(transaction, actions) {
var ref1, username;
username = (ref1 = transaction.otherUser()) != null ? ref1.get('username') : void 0;
return actions.map(function(action) {
return _.extend({}, action, {
username: username
});
});
};
actionsData = {
'accept/decline': [
{
classes: 'accept',
text: 'accept_request'
}, {
classes: 'decline',
text: 'decline_request'
}
],
'confirm': [
{
classes: 'confirm',
text: 'confirm_reception'
}
],
'returned': [
{
classes: 'returned',
text: 'confirm_returned'
}
],
'waiting:accepted': [
{
classes: 'waiting',
text: 'waiting_accepted'
}
],
'waiting:confirmed': [
{
classes: 'waiting',
text: 'waiting_confirmation'
}
],
'waiting:returned': [
{
classes: 'waiting',
text: 'waiting_return_confirmation'
}
]
};
module.exports = {
getNextActionsData: getNextActionsData,
isArchived: function(transaction) {
return isArchived(sharedLibAdapter(transaction));
}
};
});
;require.register("modules/transactions/models/action", function(exports, require, module) {
var ownerActions,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
module.exports = Backbone.Model.extend({
initialize: function() {
return this.action = this.get('action');
},
serializeData: function() {
return _.extend(this.toJSON(), {
icon: this.icon(),
context: this.context(true)
});
},
icon: function() {
switch (this.action) {
case 'requested':
return 'envelope';
case 'accepted':
return 'check';
case 'confirmed':
return 'sign-in';
case 'declined':
return 'times';
case 'returned':
return 'check';
default:
return _.warn(this, 'unknown action', true);
}
},
context: function(withLink) {
return this.userAction(this.findUser(), withLink);
},
findUser: function() {
var ref, ref1, ref2;
if (((ref = this.transaction) != null ? ref.owner : void 0) != null) {
if (this.transaction.mainUserIsOwner) {
if (ref1 = this.action, indexOf.call(ownerActions, ref1) >= 0) {
return 'main';
} else {
return 'other';
}
} else {
if (ref2 = this.action, indexOf.call(ownerActions, ref2) >= 0) {
return 'other';
} else {
return 'main';
}
}
}
},
userAction: function(user, withLink) {
if (user != null) {
return _.i18n(user + "_user_" + this.action, {
username: this.otherUsername(withLink)
});
}
},
otherUsername: function(withLink) {
var href, ref, ref1, ref2, username;
if (((ref = this.transaction) != null ? ref.otherUser() : void 0) != null) {
username = (ref1 = this.transaction.otherUser()) != null ? ref1.get('username') : void 0;
if (withLink) {
href = (ref2 = this.transaction.otherUser()) != null ? ref2.get('pathname') : void 0;
return "<a href='" + href + "' class='username'>" + username + "</a>";
} else {
return username;
}
}
}
});
ownerActions = ['accepted', 'declined', 'returned'];
});
;require.register("modules/transactions/models/message", function(exports, require, module) {
module.exports = Backbone.Model.extend({
initialize: function() {
return this.reqGrab('get:user:model', this.get('user'), 'user');
},
serializeData: function() {
var ref;
return _.extend(this.toJSON(), {
user: (ref = this.user) != null ? ref.serializeData() : void 0
});
}
});
});
;require.register("modules/transactions/models/transaction", function(exports, require, module) {
var Action, Filterable, Message, Timeline, applySideEffects, formatSnapshotData, getNextActionsData, isArchived, ref;
ref = require('../lib/next_actions'), getNextActionsData = ref.getNextActionsData, isArchived = ref.isArchived;
Filterable = require('modules/general/models/filterable');
Action = require('../models/action');
Message = require('../models/message');
Timeline = require('../collections/timeline');
formatSnapshotData = require('../lib/format_snapshot_data');
applySideEffects = require('../lib/apply_side_effects');
module.exports = Filterable.extend({
url: function() {
return app.API.transactions;
},
initialize: function() {
this.set('pathname', "/transactions/" + this.id);
this.grabLinkedModels();
this.buildTimeline();
this.fetchMessages();
this.setArchivedStatus();
this.listenToOnce(app.user, 'change', this.setMainUserIsOwner.bind(this));
this.set('actionsReady', false);
this.once('grab:owner', this.setNextActions.bind(this));
this.once('grab:requester', this.setNextActions.bind(this));
this.on('change:state', this.setNextActions.bind(this));
this.on('change:state', this.setArchivedStatus.bind(this));
this.on('change:read', this.deduceReadStatus.bind(this));
this.set('icon', this.getIcon());
return formatSnapshotData.call(this);
},
grabLinkedModels: function() {
this.reqGrab('get:user:model', this.get('requester'), 'requester');
return this.reqGrab('get:user:model', this.get('owner'), 'owner').then((function(_this) {
return function() {
return _this.reqGrab('get:item:model', _this.get('item'), 'item');
};
})(this));
},
setMainUserIsOwner: function() {
this.mainUserIsOwner = this.get('owner') === app.user.id;
this.role = this.mainUserIsOwner ? 'owner' : 'requester';
return this.deduceReadStatus();
},
deduceReadStatus: function() {
var prev;
this.mainUserRead = this.get('read')[this.role];
prev = this.unreadUpdate;
this.unreadUpdate = this.mainUserRead ? 0 : 1;
if (this.unreadUpdate !== prev) {
return app.vent.trigger('transactions:unread:change');
}
},
markAsRead: function() {
if (!this.mainUserRead) {
this.set("read." + this.role, true);
return _.preq.put(app.API.transactions, {
id: this.id,
action: 'mark-as-read'
})["catch"](_.Error('markAsRead'));
}
},
buildTimeline: function() {
var action, i, len, ref1, results;
this.timeline = new Timeline;
ref1 = this.get('actions');
results = [];
for (i = 0, len = ref1.length; i < len; i++) {
action = ref1[i];
results.push(this.addActionToTimeline(action));
}
return results;
},
addActionToTimeline: function(action) {
action = new Action(action);
action.transaction = this;
return this.timeline.add(action);
},
fetchMessages: function() {
var url;
url = _.buildPath(app.API.transactions, {
action: 'get-messages',
transaction: this.id
});
return _.preq.get(url).then(this.addMessagesToTimeline.bind(this));
},
addMessagesToTimeline: function(messages) {
var i, len, message, results;
results = [];
for (i = 0, len = messages.length; i < len; i++) {
message = messages[i];
results.push(this.timeline.add(new Message(message)));
}
return results;
},
setNextActions: function() {
if ((this.owner != null) && (this.requester != null)) {
return this.set({
nextActions: getNextActionsData(this),
actionsReady: true
});
}
},
serializeData: function() {
var attrs, ref1;
attrs = this.toJSON();
attrs[attrs.state] = true;
_.extend(attrs, {
item: this.itemData(),
owner: this.ownerData(),
requester: this.requesterData(),
messages: this.messages,
mainUserIsOwner: this.mainUserIsOwner,
context: this.context(),
mainUserRead: this.mainUserRead
});
ref1 = this.aliasUsers(attrs), attrs.user = ref1[0], attrs.other = ref1[1];
return attrs;
},
itemData: function() {
var ref1;
return ((ref1 = this.item) != null ? ref1.serializeData() : void 0) || this.get('snapshot.item');
},
ownerData: function() {
var ref1;
return ((ref1 = this.owner) != null ? ref1.serializeData() : void 0) || this.get('snapshot.owner');
},
requesterData: function() {
var ref1;
return ((ref1 = this.requester) != null ? ref1.serializeData() : void 0) || this.get('snapshot.requester');
},
aliasUsers: function(attrs) {
if (this.mainUserIsOwner) {
return [attrs.owner, attrs.requester];
} else {
return [attrs.requester, attrs.owner];
}
},
otherUser: function() {
if (this.mainUserIsOwner) {
return this.requester;
} else {
return this.owner;
}
},
getIcon: function() {
var transaction;
transaction = this.get('transaction');
return Items.transactions.data[transaction].icon;
},
context: function() {
var ref1, transaction;
if (this.owner != null) {
transaction = this.get('transaction');
if (this.mainUserIsOwner) {
return _.i18n("main_user_" + transaction);
} else {
return _.i18n("other_user_" + transaction, {
username: (ref1 = this.owner) != null ? ref1.get('username') : void 0
});
}
}
},
accepted: function() {
return this.updateState('accepted');
},
declined: function() {
return this.updateState('declined');
},
confirmed: function() {
return this.updateState('confirmed');
},
returned: function() {
return this.updateState('returned');
},
updateState: function(state) {
var action, actionModel, tracker, userStatus;
this.backup();
this.set({
state: state
});
action = {
action: state,
timestamp: _.now()
};
this.push('actions', action);
actionModel = this.addActionToTimeline(action);
userStatus = this.otherUser().get('status');
tracker = app.execute.bind(app, 'track:transaction', state, userStatus);
return _.preq.put(app.API.transactions, {
id: this.id,
state: state,
action: 'update-state'
}).then(_.Full(applySideEffects, null, this, state)).then(tracker)["catch"](this._updateFail.bind(this, actionModel));
},
_updateFail: function(actionModel, err) {
this.restore();
this.timeline.remove(actionModel);
throw err;
},
backup: function() {
return this._backup = this.toJSON();
},
restore: function() {
return this.set(this._backup);
},
setArchivedStatus: function() {
var previousStatus;
previousStatus = this.archived;
this.archived = this.isArchived();
if (this.archived !== previousStatus) {
return app.vent.trigger('transactions:folder:change');
}
},
isArchived: function() {
return isArchived(this);
}
});
});
;require.register("modules/transactions/transactions", function(exports, require, module) {
var API, RequestItemModal, TransactionsLayout, findFirstTransaction, initHelpers, lastTransactionId, navigate, triggerTransactionSelect, unreadCount, updateTransactionRoute;
TransactionsLayout = require('./views/transactions_layout');
RequestItemModal = require('./views/request_item_modal');
initHelpers = require('./helpers');
lastTransactionId = null;
module.exports = {
define: function(module, app, Backbone, Marionette, $, _) {
var TransactionsRouter;
TransactionsRouter = Marionette.AppRouter.extend({
appRoutes: {
'transactions(/)': 'showFirstTransaction',
'transactions/:id(/)': 'showTransaction'
}
});
return app.addInitializer(function() {
return new TransactionsRouter({
controller: API
});
});
},
initialize: function() {
this.listenTo(app.vent, 'transaction:select', updateTransactionRoute);
app.commands.setHandlers({
'show:item:request': API.showItemRequestModal,
'show:transactions': navigate.showTransactions,
'show:transaction': navigate.showTransaction
});
app.reqres.setHandlers({
'last:transaction:id': function() {
return lastTransactionId;
},
'transactions:unread:count': unreadCount
});
return initHelpers();
}
};
API = {
showTransactions: function() {
if (app.request('require:loggedIn', 'transactions')) {
return app.layout.main.Show(new TransactionsLayout, _.i18n('transactions'));
}
},
showFirstTransaction: function() {
if (app.request('require:loggedIn', 'transactions')) {
this.showTransactions();
return app.request('waitForUserData').then(findFirstTransaction).then(function(transac) {
var nonExplicitSelection;
if (transac != null) {
lastTransactionId = transac.id;
nonExplicitSelection = true;
return app.vent.trigger('transaction:select', transac, nonExplicitSelection);
} else {
return app.vent.trigger('transactions:welcome');
}
})["catch"](_.Error('showFirstTransaction'));
}
},
showTransaction: function(id) {
if (app.request('require:loggedIn', "transactions/" + id)) {
lastTransactionId = id;
this.showTransactions();
return app.request('waitForUserData').then(triggerTransactionSelect.bind(null, id));
}
},
showItemRequestModal: function(model) {
if (app.request('require:loggedIn', model.pathname)) {
return app.layout.modal.show(new RequestItemModal({
model: model
}));
}
}
};
navigate = {
showTransactions: function() {
API.showFirstTransaction();
return app.navigate('transactions');
},
showTransaction: function(id) {
API.showTransaction(id);
return app.navigate("transactions/" + id);
}
};
triggerTransactionSelect = function(id) {
var transaction;
transaction = app.request('get:transaction:byId', id);
if (transaction != null) {
return app.vent.trigger('transaction:select', transaction);
} else {
return app.execute('show:404');
}
};
updateTransactionRoute = function(transaction, nonExplicitSelection) {
var id;
id = transaction.id;
if (nonExplicitSelection) {
return app.navigateReplace("transactions/" + id);
} else {
return app.navigate("transactions/" + id);
}
};
findFirstTransaction = function() {
var candidate, firstTransac, transacs;
firstTransac = null;
transacs = _.clone(app.user.transactions.models);
while (transacs.length > 0 && (firstTransac == null)) {
candidate = transacs.shift();
if (!candidate.archived) {
firstTransac = candidate;
}
}
return firstTransac;
};
unreadCount = function() {
var ref, transac;
transac = (ref = app.user.transactions) != null ? ref.models : void 0;
if (!((transac != null ? transac.length : void 0) > 0)) {
return 0;
}
return transac.map(_.property('unreadUpdate')).reduce(function(a, b) {
if (_.isNumber(b)) {
return a + b;
} else {
return a;
}
});
};
});
;require.register("modules/transactions/views/event", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
behaviors: {
PreventDefault: {}
},
initialize: function() {
this.isMessage = this.model.get('message') != null;
return this.setClassNames();
},
getTemplate: function() {
if (this.isMessage) {
return require('./templates/message');
} else {
return require('./templates/action');
}
},
setClassNames: function() {
if (this.isMessage) {
return this.$el.addClass('message');
} else {
return this.$el.addClass('action');
}
},
serializeData: function() {
var attrs;
attrs = this.model.serializeData();
attrs.sameUser = this.sameUser();
return attrs;
},
modelEvents: {
'grab': 'render'
},
events: {
'click .username': 'showOtherUser'
},
sameUser: function() {
var index, prev;
if (!this.isMessage) {
return;
}
index = this.model.collection.indexOf(this.model);
if (!(index > 0)) {
return;
}
prev = this.model.collection.models[index - 1];
if ((prev != null ? prev.get('message') : void 0) == null) {
return;
}
if (prev.get('user') === this.model.get('user')) {
return true;
}
},
showOtherUser: function(e) {
var ref;
if (!_.isOpenedOutside(e)) {
return app.execute('show:inventory:user', (ref = this.model.transaction) != null ? ref.otherUser() : void 0);
}
}
});
});
;require.register("modules/transactions/views/no_transaction", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
className: 'noTransaction',
template: require('./templates/no_transaction')
});
});
;require.register("modules/transactions/views/request_item_modal", function(exports, require, module) {
var addTransaction, behaviorsPlugin, showRequest;
behaviorsPlugin = require('modules/general/plugins/behaviors');
module.exports = Marionette.ItemView.extend({
template: require('./templates/request_item_modal'),
className: 'requestItemModal',
behaviors: {
PreventDefault: {},
Loading: {},
SuccessCheck: {},
ElasticTextarea: {},
General: {}
},
initialize: function() {
return _.extend(this, behaviorsPlugin);
},
events: {
'click a#sendItemRequest': 'sendRequest'
},
ui: {
message: '#message'
},
onShow: function() {
return app.execute('modal:open');
},
serializeData: function() {
return {
item: this.model.serializeData(),
user: this.userData(),
suggestedText: this.suggestedText()
};
},
userData: function() {
var user;
user = app.users.findWhere({
username: this.model.username
});
return user.serializeData();
},
suggestedText: function() {
var transaction;
transaction = this.model.get('transaction');
return "item_request_text_suggestion_" + transaction;
},
sendRequest: function() {
this.startLoading('#sendItemRequest');
return this.postRequest().then(addTransaction).then(showRequest)["catch"](this.Fail('item request err'));
},
postRequest: function() {
var ref, tracker;
tracker = app.execute.bind(app, 'track:transaction', 'request', (ref = this.userData()) != null ? ref.status : void 0);
return _.preq.post(app.API.transactions, {
action: 'request',
item: this.model.id,
message: this.ui.message.val()
}).then(_.Tap(tracker));
}
});
addTransaction = function(transaction) {
return app.request('transactions:add', transaction);
};
showRequest = function(transaction) {
app.execute('modal:close');
return app.execute('show:transaction', transaction.id);
};
});
;require.register("modules/transactions/views/templates/action", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<span class=\"context\">"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,(depth0 != null ? depth0.icon : depth0),{"name":"icon","hash":{},"data":data}))
+ " "
+ ((stack1 = ((helper = (helper = helpers.context || (depth0 != null ? depth0.context : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"context","hash":{},"data":data}) : helper))) != null ? stack1 : "")
+ "</span>\n<span class=\"time\">"
+ alias3((helpers.timeFromNow || (depth0 && depth0.timeFromNow) || alias2).call(alias1,(depth0 != null ? depth0.timestamp : depth0),{"name":"timeFromNow","hash":{},"data":data}))
+ "</span>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/transactions/views/templates/message", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return "sameUser";
},"3":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.picture : stack1),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"4":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression;
return " <div class=\"innerAvatar\">\n <img src=\""
+ alias1((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.picture : stack1),36,{"name":"src","hash":{},"data":data}))
+ "\" alt=\""
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.user : depth0)) != null ? stack1.username : stack1), depth0))
+ "\">\n </div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"avatar "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.sameUser : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\">\n"
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.sameUser : depth0),{"name":"unless","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>\n<div class=\"rest "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.sameUser : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\">\n <span class=\"time\">"
+ alias3((helpers.timeFromNow || (depth0 && depth0.timeFromNow) || alias2).call(alias1,(depth0 != null ? depth0.created : depth0),{"name":"timeFromNow","hash":{},"data":data}))
+ "</span>\n <span class=\"message\">"
+ alias3(((helper = (helper = helpers.message || (depth0 != null ? depth0.message : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"message","hash":{},"data":data}) : helper)))
+ "</span>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/transactions/views/templates/no_transaction", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<em>"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"no_transaction",{"name":"i18n","hash":{},"data":data}))
+ "</em>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/transactions/views/templates/request_item_modal", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1;
return " <img src=\""
+ container.escapeExpression((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.picture : stack1),100,{"name":"src","hash":{},"data":data}))
+ "\">\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.lambda, alias2=container.escapeExpression, alias3=depth0 != null ? depth0 : {}, alias4=helpers.helperMissing;
return "<div class=\"header\">\n <div class=\"item\">\n <div class=\"cover\">\n <a href=\""
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.pathname : stack1), depth0))
+ "\" rel=\"nofollow\">\n"
+ ((stack1 = helpers["if"].call(alias3,((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.picture : stack1),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </a>\n </div>\n <span class=\"title\">"
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.title : stack1), depth0))
+ "</span>\n <span class=\"entity\">"
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.entity : stack1), depth0))
+ "</span>\n <p class=\"details\">"
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.details : stack1), depth0))
+ "</p>\n </div>\n <div class=\"user\">\n "
+ alias2((helpers.partial || (depth0 && depth0.partial) || alias4).call(alias3,"inventory:item_mixed_box",(depth0 != null ? depth0.item : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n </div>\n</div>\n\n<textarea id=\"message\" name=\"request-item\">\n "
+ alias2((helpers.i18n || (depth0 && depth0.i18n) || alias4).call(alias3,(depth0 != null ? depth0.suggestedText : depth0),(depth0 != null ? depth0.user : depth0),{"name":"i18n","hash":{},"data":data}))
+ "\n</textarea>\n\n<a id=\"sendItemRequest\" class=\"button success radius bold\">\n "
+ alias2((helpers.icon || (depth0 && depth0.icon) || alias4).call(alias3,"send",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias2((helpers.i18n || (depth0 && depth0.i18n) || alias4).call(alias3,"send request",{"name":"i18n","hash":{},"data":data}))
+ "\n <a class=\"loading\"></a>\n</a>\n<div class=\"checkWrapper\">\n <span class=\"check\"></span>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/transactions/views/templates/transaction", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression;
return " <img src=\""
+ alias1((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.pictures : stack1),100,{"name":"src","hash":{},"data":data}))
+ "\" alt=\""
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.title : stack1), depth0))
+ "\">\n";
},"3":function(container,depth0,helpers,partials,data) {
var stack1;
return " "
+ container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.authors : stack1), depth0))
+ "\n";
},"5":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},((stack1 = ((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.entityData : stack1)) != null ? stack1.wikidata : stack1),{"name":"if","hash":{},"fn":container.program(6, data, 0),"inverse":container.program(8, data, 0),"data":data})) != null ? stack1 : "");
},"6":function(container,depth0,helpers,partials,data) {
var stack1;
return " "
+ container.escapeExpression((helpers.claim || (depth0 && depth0.claim) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = ((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.entityData : stack1)) != null ? stack1.claims : stack1),"P50",{"name":"claim","hash":{},"data":data}))
+ "\n";
},"8":function(container,depth0,helpers,partials,data) {
var stack1;
return " "
+ ((stack1 = (helpers.joinAuthors || (depth0 && depth0.joinAuthors) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = ((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.entityData : stack1)) != null ? stack1.authors : stack1),false,{"name":"joinAuthors","hash":{},"data":data})) != null ? stack1 : "")
+ "\n";
},"10":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.lambda, alias2=container.escapeExpression;
return " <a href=\""
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.owner : depth0)) != null ? stack1.pathname : stack1), depth0))
+ "\" class=\"owner\" title=\""
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.owner : depth0)) != null ? stack1.username : stack1), depth0))
+ "\">\n <img src=\""
+ alias2((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.owner : depth0)) != null ? stack1.picture : stack1),48,{"name":"src","hash":{},"data":data}))
+ "\" alt=\""
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.owner : depth0)) != null ? stack1.username : stack1), depth0))
+ "\">\n </a>\n";
},"12":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.nextActions : depth0),{"name":"if","hash":{},"fn":container.program(13, data, 0),"inverse":container.program(17, data, 0),"data":data})) != null ? stack1 : "");
},"13":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {};
return " <h3 class=\"next\">"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(alias1,"next action",{"name":"i18n","hash":{},"data":data}))
+ ":</h3>\n <section>\n <div class=\"actions\">\n"
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.nextActions : depth0),{"name":"each","hash":{},"fn":container.program(14, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n </section>\n";
},"14":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing;
return " <div class=\"action\">\n <a class=\""
+ container.escapeExpression(((helper = (helper = helpers.classes || (depth0 != null ? depth0.classes : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"classes","hash":{},"data":data}) : helper)))
+ "\">"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.text : depth0),depth0,{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</a>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.info : depth0),{"name":"if","hash":{},"fn":container.program(15, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n";
},"15":function(container,depth0,helpers,partials,data) {
var stack1;
return " <p class=\"info\">"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.info : depth0),depth0,{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</p>\n";
},"17":function(container,depth0,helpers,partials,data) {
return " <br>\n <span class=\"finished\">"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"transaction_finished",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=container.lambda, alias2=container.escapeExpression, alias3=depth0 != null ? depth0 : {}, alias4=helpers.helperMissing, alias5="function";
return "<section>\n <div class=\"header\">\n <div class=\"facts\">\n <a class=\"item\" href=\""
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.pathname : stack1), depth0))
+ "\" title=\""
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.title : stack1), depth0))
+ "\">\n <div class=\"cover\">\n"
+ ((stack1 = helpers["if"].call(alias3,((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.pictures : stack1),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n <div class=\"data\">\n <h4 class=\"title\">"
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.title : stack1), depth0))
+ "</h4>\n <div class=\"authors\">\n"
+ ((stack1 = helpers["if"].call(alias3,((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.authors : stack1),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.program(5, data, 0),"data":data})) != null ? stack1 : "")
+ " </div>\n </div>\n </a>\n <div class=\"context "
+ alias2(((helper = (helper = helpers.transaction || (depth0 != null ? depth0.transaction : depth0)) != null ? helper : alias4),(typeof helper === alias5 ? helper.call(alias3,{"name":"transaction","hash":{},"data":data}) : helper)))
+ "\">\n "
+ alias2((helpers.icon || (depth0 && depth0.icon) || alias4).call(alias3,(depth0 != null ? depth0.icon : depth0),{"name":"icon","hash":{},"data":data}))
+ "\n "
+ ((stack1 = ((helper = (helper = helpers.context || (depth0 != null ? depth0.context : depth0)) != null ? helper : alias4),(typeof helper === alias5 ? helper.call(alias3,{"name":"context","hash":{},"data":data}) : helper))) != null ? stack1 : "")
+ "\n"
+ ((stack1 = helpers["if"].call(alias3,((stack1 = (depth0 != null ? depth0.owner : depth0)) != null ? stack1.picture : stack1),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n </div>\n </div>\n <div class=\"timeline\"></div>\n</section>\n"
+ ((stack1 = helpers["if"].call(alias3,(depth0 != null ? depth0.actionsReady : depth0),{"name":"if","hash":{},"fn":container.program(12, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "<section class=\"new-message\">\n "
+ alias2((helpers.partial || (depth0 && depth0.partial) || alias4).call(alias3,"new_message",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n</section>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/transactions/views/templates/transaction_preview", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return "unread";
},"3":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {};
return " <div class=\"profile-pic\">\n"
+ ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.requester : depth0)) != null ? stack1.picture : stack1),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n <div class=\"text\">\n <span class=\"context\">"
+ ((stack1 = ((helper = (helper = helpers.requestContext || (depth0 != null ? depth0.requestContext : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"requestContext","hash":{},"data":data}) : helper))) != null ? stack1 : "")
+ "</span>\n </div>\n";
},"4":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression;
return " <img src=\""
+ alias1((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.requester : depth0)) != null ? stack1.picture : stack1),48,{"name":"src","hash":{},"data":data}))
+ "\" alt=\""
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.requester : depth0)) != null ? stack1.username : stack1), depth0))
+ "\">\n";
},"6":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=container.lambda, alias3=container.escapeExpression;
return " <div class=\"profile-pic\">\n"
+ ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.other : depth0)) != null ? stack1.picture : stack1),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n <div class=\"text\">\n <span class=\"title\">"
+ alias3(alias2(((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.title : stack1), depth0))
+ "</span>\n <span class=\"context\">"
+ alias3(alias2(((stack1 = (depth0 != null ? depth0.other : depth0)) != null ? stack1.username : stack1), depth0))
+ "</span>\n </div>\n <div class=\"item-pic\">\n"
+ ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.pictures : stack1),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n";
},"7":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression;
return " <img src=\""
+ alias1((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.other : depth0)) != null ? stack1.picture : stack1),48,{"name":"src","hash":{},"data":data}))
+ "\" alt=\""
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.other : depth0)) != null ? stack1.username : stack1), depth0))
+ "\">\n";
},"9":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression;
return " <img src=\""
+ alias1((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.pictures : stack1),48,{"name":"src","hash":{},"data":data}))
+ "\" alt=\""
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.item : depth0)) != null ? stack1.title : stack1), depth0))
+ "\">\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<a href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\" class=\"showTransaction "
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.mainUserRead : depth0),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\">\n <div class=\"current transactionBox "
+ alias4(((helper = (helper = helpers.transaction || (depth0 != null ? depth0.transaction : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"transaction","hash":{},"data":data}) : helper)))
+ "\">\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,(depth0 != null ? depth0.icon : depth0),{"name":"icon","hash":{},"data":data}))
+ "\n </div>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.onItem : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.program(6, data, 0),"data":data})) != null ? stack1 : "")
+ " <div class=\"flags\">\n <div class=\"unread-flag\">\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"circle",{"name":"icon","hash":{},"data":data}))
+ "\n </div>\n </div>\n</a>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/transactions/views/templates/transactions_layout", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <label for=\""
+ alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
+ "\">\n "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"caret-down",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias4((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,(depth0 != null ? depth0.icon : depth0),{"name":"icon","hash":{},"data":data}))
+ " "
+ alias4((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,(depth0 != null ? depth0.text : depth0),{"name":"I18n","hash":{},"data":data}))
+ "\n </label>\n <section id=\""
+ alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
+ "\"></section>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return "<div id=\"list\">\n"
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.folders : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</div>\n\n<div id=\"fullview\"></div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/transactions/views/templates/transactions_list", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<div class=\"transactions\"></div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/transactions/views/templates/transactions_welcome", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div>\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"exchange",{"name":"icon","hash":{},"data":data}))
+ "\n <h2>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"exchanges_manager_welcome_title",{"name":"i18n","hash":{},"data":data}))
+ "</h2>\n <p>"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"exchanges_manager_welcome_text",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</p>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/transactions/views/transaction", function(exports, require, module) {
var behaviorsPlugin, error_, forms_, messagesPlugin;
behaviorsPlugin = require('modules/general/plugins/behaviors');
messagesPlugin = require('modules/general/plugins/messages');
forms_ = require('modules/general/lib/forms');
error_ = require('lib/error');
module.exports = Marionette.CompositeView.extend({
template: require('./templates/transaction'),
id: 'transactionView',
behaviors: {
AlertBox: {},
ElasticTextarea: {},
PreventDefault: {},
BackupForm: {}
},
initialize: function() {
this.lazyRender = _.LazyRender(this);
this.collection = this.model.timeline;
return this.initPlugins();
},
initPlugins: function() {
return _.extend(this, behaviorsPlugin, messagesPlugin);
},
serializeData: function() {
return this.model.serializeData();
},
onShow: function() {
this.model.markAsRead();
if (_.smallScreen() && !this.options.nonExplicitSelection) {
return _.scrollTop(this.$el);
}
},
modelEvents: {
'grab': 'lazyRender',
'change': 'lazyRender'
},
childViewContainer: '.timeline',
childView: require('./event'),
ui: {
message: 'textarea.message',
avatars: '.avatar img'
},
events: {
'click .sendMessage': 'sendMessage',
'click .accept': 'accept',
'click .decline': 'decline',
'click .confirm': 'confirm',
'click .returned': 'returned',
'click .archive': 'archive',
'click .item': 'showItem',
'click .owner': 'showOwner'
},
sendMessage: function() {
return this.postMessage('transaction:post:message', this.model.timeline);
},
accept: function() {
return this.updateState('accepted');
},
decline: function() {
return this.updateState('declined');
},
confirm: function() {
return this.updateState('confirmed');
},
returned: function() {
return this.updateState('returned');
},
archive: function() {
return this.updateState('archive');
},
updateState: function(state) {
return this.model.updateState(state)["catch"](error_.Complete('.actions'))["catch"](forms_.catchAlert.bind(null, this));
},
showItem: function(e) {
if (!_.isOpenedOutside(e)) {
return app.execute('show:item:show:from:model', this.model.item);
}
},
showOwner: function(e) {
if (!_.isOpenedOutside(e)) {
return app.execute('show:inventory:user', this.model.owner);
}
}
});
});
;require.register("modules/transactions/views/transaction_preview", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
template: require('./templates/transaction_preview'),
className: 'transactionPreview',
behaviors: {
PreventDefault: {}
},
initialize: function() {
this.lazyRender = _.LazyRender(this);
return this.listenTo(app.vent, 'transaction:select', this.autoSelect.bind(this));
},
serializeData: function() {
return _.extend(this.model.serializeData(), {
onItem: this.options.onItem,
requestContext: this.requestContext()
});
},
modelEvents: {
'grab': 'lazyRender',
'change:read': 'lazyRender'
},
events: {
'click .showTransaction': 'showTransaction'
},
ui: {
showTransaction: 'a.showTransaction'
},
onRender: function() {
if (app.request('last:transaction:id') === this.model.id) {
return this.$el.addClass('selected');
}
},
showTransaction: function(e) {
if (!_.isOpenedOutside(e)) {
if (this.options.onItem) {
return app.execute('show:transaction', this.model.id);
} else {
return app.vent.trigger('transaction:select', this.model);
}
}
},
autoSelect: function(transac) {
if (transac === this.model) {
return this.$el.addClass('selected');
} else {
return this.$el.removeClass('selected');
}
},
requestContext: function() {
return this.model.timeline.models[0].context();
}
});
});
;require.register("modules/transactions/views/transactions_layout", function(exports, require, module) {
var Transaction, TransactionsList, TransactionsWelcome, folders, foldersNames;
Transaction = require('modules/transactions/views/transaction');
TransactionsList = require('modules/transactions/views/transactions_list');
TransactionsWelcome = require('./transactions_welcome');
folders = require('../lib/folders');
foldersNames = Object.keys(folders);
module.exports = Marionette.LayoutView.extend({
className: 'transactionsLayout',
template: require('./templates/transactions_layout'),
regions: {
ongoingRegion: '#ongoing',
archivedRegion: '#archived',
fullviewRegion: '#fullview'
},
initialize: function() {
return this.listenTo(app.vent, {
'transaction:select': this.showTransactionFull.bind(this),
'transactions:welcome': this.showTransactionWelcome.bind(this)
});
},
serializeData: function() {
return {
folders: folders
};
},
onShow: function() {
return app.request('waitForFriendsItems').then(this.showTransactionsFolders.bind(this));
},
showTransactionsFolders: function() {
var folder, i, len, results;
results = [];
for (i = 0, len = foldersNames.length; i < len; i++) {
folder = foldersNames[i];
results.push(this.showTransactionList(folder));
}
return results;
},
showTransactionList: function(folder) {
return this[folder + "Region"].show(new TransactionsList({
folder: folder,
collection: app.user.transactions
}));
},
showTransactionFull: function(transaction, nonExplicitSelection) {
return this.fullviewRegion.show(new Transaction({
model: transaction,
nonExplicitSelection: nonExplicitSelection
}));
},
events: {
'click label': 'toggleSection'
},
toggleSection: function(e) {
var region;
region = e.currentTarget.htmlFor;
$(e.currentTarget).toggleClass('toggled');
return $("#" + region).slideToggle(200);
},
showTransactionWelcome: function() {
return this.fullviewRegion.show(new TransactionsWelcome);
}
});
});
;require.register("modules/transactions/views/transactions_list", function(exports, require, module) {
var folders;
folders = require('../lib/folders');
module.exports = Marionette.CompositeView.extend({
template: require('./templates/transactions_list'),
className: 'transactionList',
childViewContainer: '.transactions',
childView: require('./transaction_preview'),
emptyView: require('./no_transaction'),
initialize: function() {
this.folder = this.options.folder;
this.filter = folders[this.folder].filter;
return this.listenTo(app.vent, 'transactions:folder:change', this.render.bind(this));
},
serializeData: function() {
var attrs;
attrs = {};
attrs[this.folder] = true;
return attrs;
}
});
});
;require.register("modules/transactions/views/transactions_welcome", function(exports, require, module) {
module.exports = Marionette.ItemView.extend({
className: 'transactionsWelcome',
template: require('./templates/transactions_welcome')
});
});
;require.register("modules/user/lib/auth", function(exports, require, module) {
var classicLogin, emailConfirmationRequest, fakeFormSubmit, passwordConfirmation, passwordResetRequest, passwordUpdate, prepareLoginRedirect, requestClassicLogin, requestClassicSignup, requestLogout;
requestLogout = require('./request_logout');
module.exports = function() {
app.reqres.setHandlers({
'signup:classic': requestClassicSignup,
'login:classic': requestClassicLogin,
'password:confirmation': passwordConfirmation,
'password:update': passwordUpdate,
'password:reset:request': passwordResetRequest,
'email:confirmation:request': emailConfirmationRequest
});
return app.commands.setHandlers({
'prepare:login:redirect': prepareLoginRedirect,
'logout': requestLogout
});
};
requestClassicSignup = function(options) {
var password, username;
username = options.username, password = options.password;
return _.preq.post(app.API.auth.signup, options).then(_.Tap(app.execute.bind(app, 'track:auth:signup', 'classic'))).then(fakeFormSubmit.bind(null, username, password));
};
passwordConfirmation = function(currentPassword) {
var username;
username = app.user.get('username');
return classicLogin(username, currentPassword);
};
requestClassicLogin = function(username, password) {
return classicLogin(username, password).then(_.Tap(app.execute.bind(app, 'track:auth:login', 'classic'))).then(fakeFormSubmit.bind(null, username, password));
};
classicLogin = function(username, password) {
return _.preq.post(app.API.auth.login, {
strategy: 'local',
username: username,
password: password
});
};
passwordUpdate = function(currentPassword, newPassword, selector) {
var username;
username = app.user.get('username');
return _.preq.post(app.API.auth.updatePassword, {
currentPassword: currentPassword,
newPassword: newPassword
}).then(function() {
if (selector != null) {
return $(selector).trigger('check');
}
}).then(fakeFormSubmit.bind(null, username, newPassword));
};
fakeFormSubmit = function(username, password) {
$('#browserLogin').find('input[name=username]').val(username);
$('#browserLogin').find('input[name=password]').val(password);
return $('#browserLogin').trigger('submit');
};
passwordResetRequest = function(email) {
return _.preq.post(app.API.auth.resetPassword, {
email: email
});
};
prepareLoginRedirect = function(redir) {
var path, query, querystring, ref;
_.type(redir, 'string');
if (redir[0] === '/') {
redir = redir.slice(1);
}
app.execute('route:querystring:set', 'redirect', redir);
ref = $('#browserLogin')[0].action.split('?'), path = ref[0], querystring = ref[1];
query = _.parseQuery(querystring);
query.redirect = redir;
return $('#browserLogin')[0].action = _.buildPath(path, query);
};
emailConfirmationRequest = function() {
_.log('sending emailConfirmationRequest');
return _.preq.post(app.API.auth.emailConfirmation);
};
});
;require.register("modules/user/lib/change_user_picture", function(exports, require, module) {
var PicturePicker, regex_, savePicture;
regex_ = sharedLib('regex');
PicturePicker = require('modules/general/views/behaviors/picture_picker');
module.exports = function() {
return app.layout.modal.show(new PicturePicker({
pictures: app.user.get('picture'),
save: savePicture,
crop: true,
limit: 1
}));
};
savePicture = function(pictures) {
var picture;
picture = pictures[0];
_.log(picture, 'picture');
if (!_.isLocalImg(picture)) {
throw new Error('couldnt save picture: requires a local image url');
}
return app.request('user:update', {
attribute: 'picture',
value: picture,
selector: '#changePicture'
});
};
});
;require.register("modules/user/lib/email_tests", function(exports, require, module) {
var emailTests, forms_;
forms_ = require('modules/general/lib/forms');
module.exports = {
pass: function(email, selector) {
return forms_.pass({
value: email,
tests: emailTests,
selector: selector
});
},
verifyExistance: function(email, selector) {
return _.preq.get(app.API.services.emailValidation(email)).then(function(res) {
var err;
_.log(res, 'email verifyExistance res');
if (!res.is_valid) {
err = new Error('invalid email');
err.selector = selector;
throw err;
} else {
return res.did_you_mean;
}
});
},
verifyAvailability: function(email, selector) {
return _.preq.post(app.API.auth.emailAvailability, {
email: email
})["catch"](function(err) {
err.selector = selector;
throw err;
});
}
};
emailTests = {
"it doesn't look like an email": function(email) {
return !_.isEmail(email);
}
};
});
;require.register("modules/user/lib/password_tests", function(exports, require, module) {
var forms_, passwordTests;
forms_ = require('modules/general/lib/forms');
module.exports = {
pass: function(password, selector) {
return forms_.pass({
value: password,
tests: passwordTests,
selector: selector
});
}
};
passwordTests = {
'password should be 8 characters minimum': function(password) {
return password.length < 8;
},
'password should be 60 characters maximum': function(password) {
return password.length > 60;
}
};
});
;require.register("modules/user/lib/recover_user_data", function(exports, require, module) {
var fetchError, fetchSuccess, fetchUser, resetSession, userReady;
module.exports = function(app) {
var base;
if ($.cookie('lang')) {
(base = app.user).lang || (base.lang = $.cookie('lang'));
}
if ($.cookie('loggedIn') != null) {
app.user.loggedIn = true;
return fetchUser();
} else {
app.user.loggedIn = false;
return userReady();
}
};
fetchUser = function() {
return app.user.fetch().then(fetchSuccess).fail(fetchError).always(userReady);
};
fetchSuccess = function(userAttrs) {
var lang;
if (app.user.get('language') == null) {
if (lang = $.cookie('lang')) {
return _.log(app.user.set('language', lang), 'language set from cookie');
}
}
};
fetchError = function(err) {
_.error(err, 'recoverUserData fail');
return resetSession();
};
userReady = function() {
app.vent.trigger('user:ready');
return app.user.fetched = true;
};
resetSession = function() {
return app.user.loggedIn = false;
};
});
;require.register("modules/user/lib/request_logout", function(exports, require, module) {
var deleteLocalDatabases, logoutError, logoutSuccess;
module.exports = function() {
return _.preq.post(app.API.auth.logout).then(logoutSuccess)["catch"](logoutError);
};
logoutSuccess = function(data) {
deleteLocalDatabases();
_.log("You have been successfully logged out");
return window.location.href = '/';
};
logoutError = function(err) {
return _.error(err, 'logout error');
};
deleteLocalDatabases = function() {
var debug;
debug = localStorageProxy.getItem('debug');
localStorageProxy.clear();
localStorageProxy.setItem('debug', debug);
return window.dbs.reset();
};
});
;require.register("modules/user/lib/solve_lang", function(exports, require, module) {
var guessLanguage, guessShortLang;
guessLanguage = function() {
var lang;
lang = $.cookie('lang');
if (lang != null) {
return lang;
}
lang = window.browserLocale();
if (lang != null) {
return lang;
}
return 'en';
};
guessShortLang = function() {
return _.shortLang(guessLanguage());
};
module.exports = function(userLanguage) {
var lang, qsLang;
qsLang = app.request('route:querystring:get', 'lang');
lang = qsLang || userLanguage || guessLanguage();
return _.log(_.shortLang(lang), 'lang');
};
});
;require.register("modules/user/lib/user_language_update", function(exports, require, module) {
module.exports = function(app) {
return app.user.on('change:language', function(data) {
var lang;
if (app.polyglot != null) {
lang = app.user.get('language');
if (lang !== app.polyglot.currentLocale) {
app.request('i18n:set', lang);
return _.setCookie('lang', lang);
}
}
});
};
});
;require.register("modules/user/lib/user_listings", function(exports, require, module) {
module.exports = function(app) {
app.user.listings = function() {
return {
"private": {
id: 'private',
icon: 'lock',
unicodeIcon: '&#xf023;',
label: 'private'
},
friends: {
id: 'friends',
icon: 'users',
unicodeIcon: '&#xf0c0;',
label: 'friends and groups'
},
"public": {
id: 'public',
icon: 'globe',
unicodeIcon: '&#xf0ac;',
label: 'public'
}
};
};
return app.user.listings.data = Object.freeze(app.user.listings());
};
});
;require.register("modules/user/lib/user_menu_update", function(exports, require, module) {
var AccountMenu, NotLoggedMenu, showMenu;
AccountMenu = require('modules/general/views/menu/account_menu');
NotLoggedMenu = require('modules/general/views/menu/not_logged_menu');
module.exports = function() {
app.commands.setHandlers({
'show:user:menu:update': showMenu
});
return app.user.on('change', showMenu);
};
showMenu = function() {
var ref, ref1;
if (app.user.has('email')) {
return (ref = app.layout) != null ? ref.accountMenu.show(new AccountMenu({
model: app.user
})) : void 0;
} else {
return (ref1 = app.layout) != null ? ref1.accountMenu.show(new NotLoggedMenu) : void 0;
}
};
});
;require.register("modules/user/lib/user_update", function(exports, require, module) {
var Updater;
Updater = require('lib/model_update').Updater;
module.exports = function(app) {
var userUpdater;
userUpdater = Updater({
endpoint: app.API.user,
uniqueModel: app.user
});
return app.reqres.setHandlers({
'user:update': userUpdater
});
};
});
;require.register("modules/user/lib/username_tests", function(exports, require, module) {
var forms_, usernameTests, username_;
forms_ = require('modules/general/lib/forms');
module.exports = username_ = {
pass: function(username, selector) {
return forms_.pass({
value: username,
tests: usernameTests,
selector: selector
});
},
verifyAvailability: function(username, selector) {
return _.preq.post(app.API.auth.usernameAvailability, {
username: username
})["catch"](function(err) {
err.selector = selector;
throw err;
});
}
};
username_.verifyUsername = function(username, selector) {
return _.preq.start.then(username_.pass.bind(null, username, selector)).then(username_.verifyAvailability.bind(null, username, selector));
};
usernameTests = {
"username can't be empty": function(username) {
return username === '';
},
'username should be 20 characters maximum': function(username) {
return username.length > 20;
},
"username can't contain space": function(username) {
return /\s/.test(username);
},
'username can only contain letters, figures or _': function(username) {
return /\W/.test(username);
}
};
});
;require.register("modules/user/models/main_user", function(exports, require, module) {
var Groups, Transactions, UserCommons, notificationsList, solveLang;
UserCommons = require('modules/users/models/user_commons');
Transactions = require('modules/transactions/collections/transactions');
Groups = require('modules/network/collections/groups');
solveLang = require('../lib/solve_lang');
notificationsList = sharedLib('notifications_settings_list');
module.exports = UserCommons.extend({
isMainUser: true,
url: function() {
return app.API.user;
},
parse: function(data) {
var groups, notifications, relations, settings, transactions;
notifications = data.notifications, relations = data.relations, transactions = data.transactions, groups = data.groups, settings = data.settings;
this.addNotifications(notifications);
data.settings = this.setDefaultSettings(settings);
this.relations = relations;
this.transactions = new Transactions(transactions);
this.groups = new Groups(groups);
app.vent.trigger('transactions:unread:changes');
return _(data).omit(['relations', 'notifications', 'transactions', 'groups']);
},
initialize: function() {
this.setLang();
this.on('change:language', this.setLang.bind(this));
this.on('change:username', this.setPathname.bind(this));
this.on('change:position', this.setLatLng.bind(this));
return this.once('change:_id', function(model, id) {
return app.execute('track:user:id', id);
});
},
setLang: function() {
return this.lang = solveLang(this.get('language'));
},
addNotifications: function(notifications) {
if (notifications != null) {
return app.request('waitForData').then(app.request.bind(app, 'notifications:add', notifications));
}
},
setDefaultSettings: function(settings) {
settings.notifications = this.setDefaultNotificationsSettings(settings.notifications);
return settings;
},
setDefaultNotificationsSettings: function(notifications) {
var i, len, notif;
for (i = 0, len = notificationsList.length; i < len; i++) {
notif = notificationsList[i];
notifications[notif] = notifications[notif] !== false;
}
return notifications;
},
serializeData: function(nonPrivate) {
var attrs;
attrs = this.toJSON();
attrs.mainUser = true;
attrs.inventoryLength = this.inventoryLength(nonPrivate);
return attrs;
},
inventoryLength: function(nonPrivate) {
if (this.itemsFetched) {
return app.request('inventory:main:user:length', nonPrivate);
}
},
deleteAccount: function() {
console.log('starting to play "Somebody that I use to know" and cry a little bit');
return _.preq.wrap(this.destroy()).then(function() {
return app.execute('logout');
});
},
distanceFromMainUser: function() {
return null;
}
});
});
;require.register("modules/user/user", function(exports, require, module) {
var API, ForgotPassword, Login, LoginPersona, MainUser, ResetPassword, SignupClassic, initCommands, initSubModules, redirected, subModules;
MainUser = require('./models/main_user');
SignupClassic = require('./views/signup_classic');
Login = require('./views/login');
LoginPersona = require('./views/login_persona');
ForgotPassword = require('./views/forgot_password');
ResetPassword = require('./views/reset_password');
module.exports = {
define: function(module, app, Backbone, Marionette, $, _) {
var UserRouter;
UserRouter = Marionette.AppRouter.extend({
appRoutes: {
'signup(/persona)(/)': 'showSignup',
'login(/)': 'showLogin',
'login/persona(/)': 'showLoginPersona',
'login/forgot-password(/)': 'showForgotPassword',
'login/reset-password(/)': 'showResetPassword'
}
});
app.addInitializer(function() {
return new UserRouter({
controller: API
});
});
app.user = new MainUser;
initCommands(app);
return initSubModules(app);
}
};
API = {
showSignup: function() {
if (!redirected('show:signup')) {
app.layout.main.Show(new SignupClassic, _.I18n('sign up'));
return app.navigate('signup');
}
},
showLogin: function() {
if (!redirected('show:login')) {
app.layout.main.Show(new Login, _.I18n('login'));
return app.navigate('login');
}
},
showLoginPersona: function() {
if (!redirected('show:login:persona')) {
app.navigate('login/persona');
return app.layout.main.Show(new LoginPersona, _.I18n('login with Persona'));
}
},
showForgotPassword: function(options) {
app.layout.main.Show(new ForgotPassword(options), _.I18n('forgot password'));
return app.navigate('login/forgot-password');
},
showResetPassword: function() {
if (app.user.loggedIn) {
return app.layout.main.Show(new ResetPassword, _.I18n('reset password'));
} else {
return app.execute('show:forgot:password');
}
}
};
redirected = function(command) {
if (!navigator.cookieEnabled) {
app.execute('show:error:cookieRequired', command);
return true;
}
if (!app.user.loggedIn) {
return false;
}
app.execute('show:home');
return true;
};
initCommands = function(app) {
return app.commands.setHandlers({
'show:signup': API.showSignup,
'show:login': API.showLogin,
'show:login:persona': API.showLoginPersona,
'show:forgot:password': API.showForgotPassword
});
};
subModules = ['auth', 'recover_user_data', 'user_listings', 'user_update', 'user_menu_update', 'user_language_update'];
initSubModules = function(app) {
var i, len, results, subModule;
results = [];
for (i = 0, len = subModules.length; i < len; i++) {
subModule = subModules[i];
results.push(require("./lib/" + subModule)(app));
}
return results;
};
});
;require.register("modules/user/views/forgot_password", function(exports, require, module) {
var behaviorsPlugin, email_, formatErr, forms_, unknownEmail, verifyKnownEmail;
email_ = require('modules/user/lib/email_tests');
forms_ = require('modules/general/lib/forms');
behaviorsPlugin = require('modules/general/plugins/behaviors');
module.exports = Marionette.ItemView.extend({
className: 'authMenu login',
template: require('./templates/forgot_password'),
behaviors: {
AlertBox: {},
SuccessCheck: {},
Loading: {}
},
ui: {
email: '#emailField',
confirmationEmailSent: '#confirmationEmailSent'
},
initialize: function() {
_.extend(this, behaviorsPlugin);
return this.lazySendEmail = _.debounce(this.sendEmail.bind(this), 1500, true);
},
serializeData: function() {
return {
emailPicker: this.emailPickerData(),
header: this.headerData()
};
},
headerData: function() {
if (this.options.createPasswordMode) {
return 'create a password';
} else {
return 'forgot password?';
}
},
emailPickerData: function() {
return {
nameBase: 'email',
special: true,
field: {
value: app.user.get('email')
},
button: {
text: _.i18n('send email'),
classes: 'grey postfix'
}
};
},
events: function() {
return {
'click a#emailButton': 'lazySendEmail'
};
},
sendEmail: function() {
var email;
email = this.ui.email.val();
return _.preq.start.then(function() {
return email_.pass(email, '#emailField');
}).then(this.startLoading.bind(this, '#emailButton')).then(verifyKnownEmail.bind(null, email)).then(this.sendResetPasswordLink.bind(this, email)).then(this.showSuccessMessage.bind(this))["catch"](forms_.catchAlert.bind(null, this))["finally"](this.stopLoading.bind(this));
},
sendResetPasswordLink: function(email) {
return app.request('password:reset:request', email)["catch"](formatErr);
},
showSuccessMessage: function() {
return this.ui.confirmationEmailSent.fadeIn();
}
});
verifyKnownEmail = function(email) {
return email_.verifyAvailability(email, "#emailField").then(unknownEmail)["catch"](function(err) {
if (err.status === 400) {
return 'known email';
} else {
throw err;
}
});
};
unknownEmail = function() {
return formatErr(new Error('this email is unknown'));
};
formatErr = function(err) {
err.selector = '#emailField';
throw err;
};
});
;require.register("modules/user/views/login", function(exports, require, module) {
var behaviorsPlugin, forms_, password_, username_;
username_ = require('modules/user/lib/username_tests');
password_ = require('modules/user/lib/password_tests');
forms_ = require('modules/general/lib/forms');
behaviorsPlugin = require('modules/general/plugins/behaviors');
module.exports = Marionette.ItemView.extend({
className: 'authMenu login',
template: require('./templates/login'),
events: {
'blur #username': 'earlyVerifyUsername',
'click #classicLogin': 'classicLoginAttempt',
'click #personaLogin': 'showPersonaLogin',
'click #createAccount': function() {
return app.execute('show:signup');
},
'click #forgotPassword': function() {
return app.execute('show:forgot:password');
}
},
behaviors: {
Loading: {},
SuccessCheck: {},
AlertBox: {},
TogglePassword: {}
},
ui: {
username: '#username',
password: '#password'
},
initialize: function() {
return _.extend(this, behaviorsPlugin);
},
onShow: function() {
return this.ui.username.focus();
},
serializeData: function() {
return {
passwordLabel: 'password'
};
},
classicLoginAttempt: function() {
return _.preq.start.then(this.verifyUsername.bind(this)).then(this.verifyPassword.bind(this)).then(this.classicLogin.bind(this))["catch"](forms_.catchAlert.bind(null, this));
},
verifyUsername: function(username) {
username = this.ui.username.val();
if (!_.isEmail(username)) {
return username_.pass(username, '#username');
}
},
earlyVerifyUsername: function(e) {
return forms_.earlyVerify(this, e, this.verifyUsername.bind(this));
},
verifyPassword: function() {
return password_.pass(this.ui.password.val(), '#finalAlertbox');
},
classicLogin: function() {
var password, username;
username = this.ui.username.val();
password = this.ui.password.val();
app.request('login:classic', username, password)["catch"](this.loginError.bind(this));
return this.startLoading('#classicLogin');
},
loginError: function(err) {
this.stopLoading();
if (err.status === 401) {
return this.alert(this.getErrMessage());
} else {
return _.error(err, 'classic login err');
}
},
getErrMessage: function() {
var username;
username = this.ui.username.val();
if (_.isEmail(username)) {
return 'email or password is incorrect';
} else {
return 'username or password is incorrect';
}
},
showPersonaLogin: function() {
return app.execute('show:login:persona');
}
});
});
;require.register("modules/user/views/login_persona", function(exports, require, module) {
var subject;
subject = 'I need help on switching from Persona to an account with a password';
module.exports = Marionette.ItemView.extend({
className: 'authMenu persona',
template: require('./templates/login_persona'),
events: {
'click #createPassword': 'createPassword',
'click #askForHelp': 'askForHelp'
},
createPassword: function() {
return app.execute('show:forgot:password', {
createPasswordMode: true
});
},
askForHelp: function() {
return app.execute('show:feedback:menu', {
subject: _.i18n(subject)
});
}
});
});
;require.register("modules/user/views/reset_password", function(exports, require, module) {
var behaviorsPlugin, formatErr, forms_, password_;
password_ = require('modules/user/lib/password_tests');
forms_ = require('modules/general/lib/forms');
behaviorsPlugin = require('modules/general/plugins/behaviors');
module.exports = Marionette.ItemView.extend({
className: 'authMenu login',
template: require('./templates/reset_password'),
behaviors: {
AlertBox: {},
SuccessCheck: {},
Loading: {},
TogglePassword: {}
},
ui: {
password: '#password'
},
initialize: function() {
return _.extend(this, behaviorsPlugin);
},
events: {
'click #updatePassword': 'updatePassword',
'click #forgotPassword': function() {
return app.execute('show:forgot:password');
}
},
serializeData: function() {
return {
passwordLabel: 'new password',
username: app.user.get('username')
};
},
updatePassword: function() {
var password;
password = this.ui.password.val();
return _.preq.start.then(function() {
return password_.pass(password, '#finalAlertbox');
}).then(this.startLoading.bind(this, '#updatePassword')).then(this.updateUserPassword.bind(this, password)).then(this.passwordSuccessCheck.bind(this))["catch"](forms_.catchAlert.bind(null, this))["finally"](this.stopLoading.bind(this));
},
updateUserPassword: function(password) {
app.execute('prepare:login:redirect', 'home');
return app.request('password:update', void 0, password, '#password')["catch"](formatErr);
},
passwordSuccessCheck: function() {
this.ui.passwords.val('');
return this.ui.password.trigger('check');
}
});
formatErr = function(err) {
_.error(err, 'formatErr');
err.selector = '#finalAlertbox';
throw err;
};
});
;require.register("modules/user/views/signup_classic", function(exports, require, module) {
var behaviorsPlugin, email_, forms_, password_, username_;
username_ = require('modules/user/lib/username_tests');
email_ = require('modules/user/lib/email_tests');
password_ = require('modules/user/lib/password_tests');
forms_ = require('modules/general/lib/forms');
behaviorsPlugin = require('modules/general/plugins/behaviors');
module.exports = Marionette.LayoutView.extend({
className: 'authMenu signup',
template: require('./templates/signup_classic'),
behaviors: {
AlertBox: {},
TogglePassword: {},
Loading: {}
},
ui: {
classicUsername: '#classicUsername',
email: '#email',
suggestionGroup: '#suggestionGroup',
suggestion: '#suggestion',
password: '#password'
},
initialize: function() {
return _.extend(this, behaviorsPlugin);
},
events: {
'blur #classicUsername': 'earlyVerifyClassicUsername',
'blur #email': 'earlyVerifyEmail',
'click #classicSignup': 'validClassicSignup',
'click #suggestion': 'replaceEmail'
},
onShow: function() {
return this.ui.classicUsername.focus();
},
serializeData: function() {
return {
passwordLabel: 'password'
};
},
validClassicSignup: function() {
return this.verifyClassicUsername().then(this.verifyEmail.bind(this)).then(this.verifyPassword.bind(this)).then(this.startLoading.bind(this, '#classicSignup')).then(this.sendClassicSignupRequest.bind(this))["catch"](forms_.catchAlert.bind(null, this));
},
verifyClassicUsername: function() {
return this.verifyUsername('classicUsername');
},
verifyEmail: function() {
var email;
email = this.ui.email.val();
email_.pass(email, '#email');
return email_.verifyAvailability(email, "#email").then(email_.verifyExistance.bind(email_, email, '#email')).then(this.showSuggestion.bind(this));
},
showSuggestion: function(suggestion) {
if (suggestion != null) {
this.ui.suggestion.text(suggestion);
this.ui.suggestionGroup.fadeIn();
return this.suggestion = suggestion;
} else {
return _.log('no suggestion');
}
},
replaceEmail: function() {
this.ui.email.val(this.suggestion);
return this.ui.suggestionGroup.fadeOut();
},
verifyPassword: function() {
return password_.pass(this.ui.password.val(), '#finalAlertbox');
},
sendClassicSignupRequest: function() {
return app.request('signup:classic', {
username: this.ui.classicUsername.val(),
password: this.ui.password.val(),
email: this.ui.email.val(),
strategy: 'local'
});
},
verifyUsername: function(name) {
var username;
username = this.ui[name].val();
return username_.verifyUsername(username, "#" + name);
},
earlyVerifyClassicUsername: function(e) {
return forms_.earlyVerify(this, e, this.verifyClassicUsername.bind(this));
},
earlyVerifyEmail: function(e) {
return forms_.earlyVerify(this, e, this.verifyEmail.bind(this));
},
earlyVerifyPassword: function(e) {
return forms_.earlyVerify(this, e, this.verifyPassword.bind(this));
}
});
});
;require.register("modules/user/views/templates/forgot_password", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"custom-cell\">\n <h2 class=\"subheader\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.header : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</h2>\n <p class=\"note\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"send an email to reset my password",{"name":"i18n","hash":{},"data":data}))
+ "</p>\n "
+ alias3((helpers.input || (depth0 && depth0.input) || alias2).call(alias1,(depth0 != null ? depth0.emailPicker : depth0),{"name":"input","hash":{},"data":data}))
+ "\n <div id=\"confirmationEmailSent\" class=\"hidden successMessageBox\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"check",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"confirmation_password_reset_email_sent",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "\n </div>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/user/views/templates/language_picker", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <option value=\""
+ alias4(((helper = (helper = helpers.code || (depth0 != null ? depth0.code : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"code","hash":{},"data":data}) : helper)))
+ "\" "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.selected : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ">"
+ alias4(((helper = (helper = helpers.code || (depth0 != null ? depth0.code : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"code","hash":{},"data":data}) : helper)))
+ " - "
+ alias4(((helper = (helper = helpers["native"] || (depth0 != null ? depth0["native"] : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"native","hash":{},"data":data}) : helper)))
+ "</option>\n";
},"2":function(container,depth0,helpers,partials,data) {
return "selected";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return "<select id=\"languagePicker\" name=\"language\">\n"
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.languages : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</select>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/user/views/templates/login", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"custom-cell\">\n <h2 class=\"subheader\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"login",{"name":"i18n","hash":{},"data":data}))
+ "</h2>\n <form>\n <label for=\"username\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"username",{"name":"i18n","hash":{},"data":data}))
+ "<br>\n <span class=\"complement\">("
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"or email address",{"name":"i18n","hash":{},"data":data}))
+ ")</span>\n </label>\n <div>\n <input type=\"text\" id=\"username\" name=\"username\" class=\"enterClick radius\">\n </div>\n\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"user:password_input",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n\n <a id=\"classicLogin\" class=\"button radius light-blue\" tabindex=\"0\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"login",{"name":"i18n","hash":{},"data":data}))
+ "\n <span class=\"loading\"></span>\n </a>\n </form>\n\n <div class=\"otherOptions\">\n <a id=\"createAccount\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"create an account",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n <a id=\"forgotPassword\" class=\"link\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"forgot your password?",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n </div>\n\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"horizontal_separator","or login with",{"name":"partial","hash":{},"data":data}))
+ "\n\n <a id=\"personaLogin\" class=\"button radius dark-grey\" tabindex=\"0\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"persona",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/user/views/templates/login_persona", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"custom-cell\">\n <h2 class=\"subheader\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"login with Persona",{"name":"i18n","hash":{},"data":data}))
+ "</h2>\n <p class=\"persona-sunset\">\n "
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"persona_sunset",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "\n </p>\n <a id=\"createPassword\" class=\"button dark-grey radius bold\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"create a password",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n <br>\n <p class=\"help\">\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"life-ring",{"name":"icon","hash":{},"data":data}))
+ "\n <a id=\"askForHelp\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"ask for help",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n </p>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/user/views/templates/password_input", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<label for=\"password\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.passwordLabel : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</label>\n<div class=\"passwordGroup\">\n <input type=\"password\" id=\"password\" name=\"password\" class=\"enterClick radius-left\" "
+ alias3(((helper = (helper = helpers.disableAuto || (depth0 != null ? depth0.disableAuto : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"disableAuto","hash":{},"data":data}) : helper)))
+ ">\n <a class=\"showPassword\" class=\"radius-right\">\n <span class=\"displayed\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"show",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n <span class=\"substitute\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"hide",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n </a>\n</div>\n\n<div>\n <div id=\"finalAlertbox\" class=\"has-alertbox\"></div>\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/user/views/templates/reset_password", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div class=\"custom-cell resetPassword\">\n <h2 class=\"subheader\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"reset password",{"name":"i18n","hash":{},"data":data}))
+ "</h2>\n <form>\n <input type=\"text\" name=\"username\" value=\""
+ alias3(((helper = (helper = helpers.username || (depth0 != null ? depth0.username : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"username","hash":{},"data":data}) : helper)))
+ "\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"user:password_input",depth0,"check",{"name":"partial","hash":{},"data":data}))
+ "\n <a id=\"updatePassword\" class=\"button success radius\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"udpate password",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n </form>\n <div>\n <a id=\"forgotPassword\" class=\"link\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"request_new_token",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n </div>\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/user/views/templates/signup_classic", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<form class=\"custom-cell\">\n <h2 class=\"subheader\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"sign up",{"name":"i18n","hash":{},"data":data}))
+ "</h2>\n\n <label for=\"classicUsername\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"username",{"name":"i18n","hash":{},"data":data}))
+ "</label>\n <div>\n <input type=\"text\" name=\"username\" id=\"classicUsername\" class=\"enterClick radius\">\n </div>\n\n <label for=\"email\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"email",{"name":"i18n","hash":{},"data":data}))
+ "</label>\n <div>\n <input type=\"text\" name=\"email\" id=\"email\" class=\"enterClick radius\" "
+ alias3(((helper = (helper = helpers.disableAuto || (depth0 != null ? depth0.disableAuto : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"disableAuto","hash":{},"data":data}) : helper)))
+ ">\n </div>\n <div id=\"suggestionGroup\" class=\"hidden\">\n <span class=\"legend\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"did you mean:",{"name":"i18n","hash":{},"data":data}))
+ "</span>\n <a id=\"suggestion\"></a>\n </div>\n\n\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"user:password_input",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n\n <a id=\"classicSignup\" class=\"button radius light-blue\" tabindex=\"0\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"sign up",{"name":"i18n","hash":{},"data":data}))
+ "\n <span class=\"loading\"></span>\n </a>\n</form>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/user/views/templates/valid_email_confirmation", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <div class=\"valid\">\n <p>\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"check",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"email_confirmation_success",{"name":"i18n","hash":{},"data":data}))
+ "\n </p>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.loggedIn : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.program(4, data, 0),"data":data})) != null ? stack1 : "")
+ " </div>\n";
},"2":function(container,depth0,helpers,partials,data) {
return " <a class=\"button dark-grey radius showHome\">\n "
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"back to your inventory",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n";
},"4":function(container,depth0,helpers,partials,data) {
return " <a class=\"button dark-grey radius showLogin\">\n "
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"login to your inventory",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n";
},"6":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <div class=\"invalid\">\n <p>\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"bolt",{"name":"icon","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"email_confirmation_error",{"name":"i18n","hash":{},"data":data}))
+ "\n </p>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.loggedIn : depth0),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.program(9, data, 0),"data":data})) != null ? stack1 : "")
+ " </div>\n <div class=\"loading\"></div>\n";
},"7":function(container,depth0,helpers,partials,data) {
return " <a id=\"emailConfirmationRequest\" class=\"button dark-grey radius\">\n "
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"email_confirmation_error_button",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n";
},"9":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <p class=\"offline\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"email_confirmation_offline_error",{"name":"i18n","hash":{},"data":data}))
+ "\n </p>\n <a class=\"button dark-grey radius showLoginRedirectSettings\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"login",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.validEmail : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(6, data, 0),"data":data})) != null ? stack1 : "");
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/user/views/valid_email_confirmation", function(exports, require, module) {
var emailFail, emailSent;
module.exports = Marionette.ItemView.extend({
className: 'validEmailConfirmation',
template: require('./templates/valid_email_confirmation'),
behaviors: {
Loading: {},
General: {}
},
events: {
'click .showHome, .showLoginRedirectSettings': function() {
return app.execute('modal:close');
},
'click .showLoginRedirectSettings': 'showLoginRedirectSettings',
'click #emailConfirmationRequest': 'emailConfirmationRequest'
},
onShow: function() {
return app.execute('modal:open');
},
serializeData: function() {
return {
validEmail: this.options.validEmail,
loggedIn: app.user.loggedIn
};
},
emailConfirmationRequest: function() {
this.$el.trigger('loading');
return app.request('email:confirmation:request').then(emailSent)["catch"](emailFail.bind(this));
},
showLoginRedirectSettings: function() {
return app.request('show:login:redirect', 'settings/profile');
}
});
emailSent = function() {
return app.execute('modal:close');
};
emailFail = function() {
return this.$el.trigger('somethingWentWrong');
};
});
;require.register("modules/users/collections/users", function(exports, require, module) {
module.exports = Backbone.Collection.extend({
model: require("../models/user"),
url: function() {
return app.API.users.friends;
},
initialize: function() {
this.lazyResort = _.debounce(this.sort.bind(this), 500);
return this.on('change:highlightScore', this.lazyResort);
},
comparator: 'highlightScore',
filtered: function(text) {
return this.filter(function(user) {
var filterExpr;
filterExpr = new RegExp('^' + text, "i");
return filterExpr.test(user.get('username'));
});
},
byUsername: function(username) {
return this.findWhere({
username: username
});
}
});
});
;require.register("modules/users/helpers", function(exports, require, module) {
var error_,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
error_ = require('lib/error');
module.exports = function(app) {
var addPublicUser, addPublicUsers, adders, async, filterOutAlreadyThere, ref, searchByPosition, searchByText, sync;
sync = {
getUserModelFromUserId: function(id) {
var userModel;
if (id === app.user.id) {
return app.user;
}
userModel = app.users.byId(id);
if (userModel != null) {
return userModel;
} else {
}
},
getUserIdFromUsername: function(username) {
var userModel;
if (username === app.user.get('username')) {
return app.user.id;
}
userModel = app.users.findWhere({
username: username
});
if (userModel != null) {
return userModel.id;
} else {
return console.warn("couldnt find the user from username: " + username);
}
},
isMainUser: function(userId) {
if (userId != null) {
return userId === app.user.id;
}
},
isFriend: function(userId) {
var ref, ref1;
if (!((userId != null) && (((ref = app.users) != null ? (ref1 = ref.friends) != null ? ref1.list : void 0 : void 0) != null))) {
_.warn(userId, 'isFriend isnt ready (use or recalculate after data waiters)');
return false;
}
return indexOf.call(app.users.friends.list, userId) >= 0;
},
isPublicUser: function(userId) {
var ref, ref1;
if (sync.isMainUser(userId)) {
return false;
}
if (!app.user.loggedIn) {
return true;
}
if (!((userId != null) && (((ref = app.users) != null ? (ref1 = ref["public"]) != null ? ref1.list : void 0 : void 0) != null))) {
_.warn(userId, 'isPublicUser isnt ready (use or recalculate after data waiters)');
return true;
}
return indexOf.call(app.users["public"].list, userId) >= 0;
},
itemsFetched: function(userModel) {
if (!_.isModel(userModel)) {
throw error_["new"]('itemsFetched expected a model', userModel);
}
return userModel.itemsFetched === true;
},
getNonFriendsIds: function(usersIds) {
_.type(usersIds, 'array');
return _(usersIds).chain().without(app.user.id).reject(sync.isFriend).value();
}
};
async = {
getUsersData: function(ids) {
if (!(ids.length > 0)) {
return _.preq.resolve([]);
}
return app.request('waitForData').then(function() {
return app.users.data.local.get(ids, 'collection');
}).then(function(users) {
var compacted, missingIds;
compacted = _.compact(users);
if (compacted.length !== ids.length) {
missingIds = _.difference(ids, compacted.map(_.property('_id')));
_.warn(missingIds, 'getUsersData missing ids');
}
return compacted;
}).then(addPublicUsers);
},
getUserModel: function(id, category) {
if (category == null) {
category = 'public';
}
return app.request('waitForData').then(function() {
var userModel;
userModel = app.request('get:userModel:from:userId', id);
if (userModel != null) {
return userModel;
} else {
return app.users.data.local.get(id, 'collection').then(function(usersData) {
if (usersData.length !== 1) {
throw new Error("user not found: " + id);
}
return adders[category](usersData)[0];
});
}
})["catch"](_.ErrorRethrow('getUserModel err'));
},
getGroupUserModel: function(id) {
return async.getUserModel(id, 'nonRelationGroupUser');
},
resolveToUserModel: function(user) {
var username;
if (_.isModel(user)) {
return _.preq.resolve(user);
} else {
username = user;
return app.request('get:userModel:from:username', username).then(function(userModel) {
if (userModel != null) {
return userModel;
} else {
throw new Error("user model not found: " + user);
}
});
}
},
getUserModelFromUsername: function(username) {
var userModel;
if (username === app.user.get('username')) {
return _.preq.resolve(app.user);
}
userModel = app.users.findWhere({
username: username
});
if (userModel != null) {
return _.preq.resolve(userModel);
} else {
return app.users.data.remote.findOneByUsername(username).then(function(user) {
if (user != null) {
userModel = app.users["public"].add(user);
return userModel;
}
});
}
}
};
filterOutAlreadyThere = function(users) {
var current;
current = app.users.list();
current.push(app.user.id);
return users.filter(function(user) {
var ref;
return !(ref = user._id, indexOf.call(current, ref) >= 0);
});
};
addPublicUsers = function(users) {
var allUsersIds;
allUsersIds = users.map(_.property('_id'));
users = filterOutAlreadyThere(_.forceArray(users));
app.users["public"].add(users);
return app.users.byIds(allUsersIds);
};
addPublicUser = function(user) {
var _id, knownUser;
_id = user._id;
knownUser = app.users.byId(_id);
if (knownUser != null) {
return knownUser;
} else {
return app.users["public"].add(user);
}
};
adders = {
"public": addPublicUsers,
nonRelationGroupUser: app.users.nonRelationGroupUser.add.bind(app.users.nonRelationGroupUser)
};
ref = require('./lib/search')(app), searchByText = ref.searchByText, searchByPosition = ref.searchByPosition;
app.reqres.setHandlers({
'get:user:model': async.getUserModel,
'get:group:user:model': async.getGroupUserModel,
'get:users:data': async.getUsersData,
'resolve:to:userModel': async.resolveToUserModel,
'get:userModel:from:username': async.getUserModelFromUsername,
'get:userModel:from:userId': sync.getUserModelFromUserId,
'get:userId:from:username': sync.getUserIdFromUsername,
'get:non:friends:ids': sync.getNonFriendsIds,
'user:isMainUser': sync.isMainUser,
'user:isFriend': sync.isFriend,
'user:isPublicUser': sync.isPublicUser,
'user:itemsFetched': sync.itemsFetched,
'users:search': searchByText,
'users:search:byPosition': searchByPosition,
'user:public:add': addPublicUser
});
app.commands.setHandlers({
'users:public:add': addPublicUsers
});
};
});
;require.register("modules/users/invitations", function(exports, require, module) {
module.exports = function(app, _) {
var invitationsByEmails;
invitationsByEmails = function(emails, message) {
var tracker;
return tracker = _.preq.post(app.API.invitations, {
action: 'by-emails',
emails: emails,
message: message
}).then(function(data) {
app.execute('track:invitation', 'email', data.emails.length);
return data;
});
};
app.reqres.setHandlers({
'invitations:by:emails': invitationsByEmails
});
};
});
;require.register("modules/users/lib/remote_queries", function(exports, require, module) {
module.exports = function(app, _) {
return {
get: function(ids) {
return _.preq.get(app.API.users.data(ids))["catch"](_.Error('users_data get err'));
},
search: function(text) {
if (_.isEmpty(text)) {
return _.preq.resolve([]);
}
return _.preq.get(app.API.users.search(text)).then(_.property('users'))["catch"](_.Error('users_data search err'));
},
findOneByUsername: function(username) {
return this.search(username).then(function(res) {
var user;
user = res != null ? res[0] : void 0;
if ((user != null ? user.username.toLowerCase() : void 0) === username.toLowerCase()) {
return user;
}
});
},
searchByPosition: function(latLng) {
return _.preq.get(app.API.users.searchByPosition(latLng)).then(_.property('users'))["catch"](_.Error('searchByPosition err'));
}
};
};
});
;require.register("modules/users/lib/search", function(exports, require, module) {
module.exports = function(app) {
var API, addUsersUnlessHere, searchByPosition, searchByText;
app.users.queried = [];
searchByText = function(text) {
if (!_.isNonEmptyString(text)) {
return app.users.filtered.friends();
}
return app.users.data.remote.search(text).then(addUsersUnlessHere).then(function() {
app.users.queried.push(text);
return app.users.filtered.filterByText(text);
});
};
searchByPosition = function(bbox) {
return app.users.data.remote.searchByPosition(bbox).then(addUsersUnlessHere);
};
addUsersUnlessHere = function(users) {
return app.request('waitForData').then(function() {
return app.execute('users:public:add', users);
});
};
return API = {
searchByText: searchByText,
searchByPosition: searchByPosition
};
};
});
;require.register("modules/users/models/user", function(exports, require, module) {
var UserCommons, highlightRescentlyUpdated, map_;
UserCommons = require('./user_commons');
map_ = require('modules/map/lib/map');
module.exports = UserCommons.extend({
isMainUser: false,
initialize: function() {
this.setPathname();
if (this.hasPosition()) {
this.listenTo(app.user, 'change:position', this.calculateDistance.bind(this));
this.calculateDistance();
}
return this.listenToOnce(app.vent, 'friends:items:ready', this.calculateHighlightScore.bind(this));
},
serializeData: function() {
var attrs, relationStatus;
attrs = this.toJSON();
attrs.cid = this.cid;
relationStatus = attrs.status;
attrs[relationStatus] = true;
if (relationStatus === 'nonRelationGroupUser') {
attrs["public"] = true;
}
attrs.inventoryLength = this.inventoryLength();
return attrs;
},
inventoryLength: function() {
if (this.itemsFetched) {
return app.request('inventory:user:length', this.id);
}
},
calculateDistance: function() {
var a, b, distance, precision;
if (!(app.user.has('position') && this.has('position'))) {
return;
}
a = app.user.get('position');
b = this.get('position');
distance = this.kmDistanceFormMainUser = map_.distanceBetween(a, b);
precision = distance > 20 ? 0 : 1;
this.distanceFromMainUser = Number(distance.toFixed(precision)).toLocaleString();
},
calculateHighlightScore: function() {
var distanceFactor, itemsAgeFactor, points, randomFactor, userItems;
userItems = app.request('inventory:user:items', this.id);
if (!(userItems.length > 0)) {
return 0;
}
itemsAgeFactor = userItems.map(highlightRescentlyUpdated).sum();
distanceFactor = this.kmDistanceFormMainUser != null ? 10 / this.kmDistanceFormMainUser : 0;
randomFactor = Math.random() * 0.1;
points = itemsAgeFactor + distanceFactor + randomFactor;
return this.set('highlightScore', -points);
}
});
highlightRescentlyUpdated = function(item) {
var daysAgo, updateTime;
updateTime = item.get('updated') || item.get('created');
daysAgo = _.daysAgo(updateTime);
return 1 / (Math.pow(daysAgo, 2) + 1);
};
});
;require.register("modules/users/models/user_commons", function(exports, require, module) {
var Positionable;
Positionable = require('modules/general/models/positionable');
module.exports = Positionable.extend({
setPathname: function() {
var username;
username = this.get('username');
return this.set('pathname', "/inventory/" + username);
},
asMatchable: function() {
return [this.get('username'), this.get('bio')];
},
updateMetadata: function() {
return app.execute('metadata:update', {
title: this.get('username'),
description: this.getDescription(),
image: this.get('picture'),
url: this.get('pathname')
});
},
getDescription: function() {
var bio;
bio = this.get('bio');
if (_.isNonEmptyString(bio)) {
return bio;
} else {
return _.i18n('user_default_description', {
username: this.get('username')
});
}
}
});
});
;require.register("modules/users/plugins/relations_actions", function(exports, require, module) {
var behaviorsPlugin, confirmAction, confirmUnfriend, events, handlers;
behaviorsPlugin = require('modules/general/plugins/behaviors');
events = {
'click .cancel': 'cancel',
'click .discard': 'discard',
'click .accept': 'accept',
'click .request': 'send',
'click .unfriend': 'unfriend',
'click .invite': 'invite',
'click .acceptRequest': 'acceptRequest',
'click .refuseRequest': 'refuseRequest',
'click .makeAdmin': 'makeAdmin',
'click .kick': 'kick'
};
confirmAction = function(actionLabel, actionFn, warningText) {
var confirmationText;
confirmationText = _.I18n(actionLabel + "_confirmation", {
username: this.model.get('username')
});
return this.$el.trigger('askConfirmation', {
confirmationText: confirmationText,
warningText: warningText,
action: actionFn
});
};
confirmUnfriend = function() {
return confirmAction.call(this, 'unfriend', app.request.bind(app, 'unfriend', this.model));
};
handlers = {
cancel: function() {
return app.request('request:cancel', this.model);
},
discard: function() {
return app.request('request:discard', this.model);
},
accept: function() {
return app.request('request:accept', this.model);
},
send: function() {
if (app.request('require:loggedIn', this.model.get('pathname'))) {
return app.request('request:send', this.model);
}
},
unfriend: confirmUnfriend,
invite: function() {
if (this.group == null) {
return _.error('inviteUser err: group is missing');
}
return this.group.inviteUser(this.model)["catch"](behaviorsPlugin.Fail.call(this, 'invite user'));
},
acceptRequest: function() {
if (this.group == null) {
return _.error('acceptRequest err: group is missing');
}
return this.group.acceptRequest(this.model)["catch"](behaviorsPlugin.Fail.call(this, 'accept user request'));
},
refuseRequest: function() {
if (this.group == null) {
return _.error('refuseRequest err: group is missing');
}
return this.group.refuseRequest(this.model)["catch"](behaviorsPlugin.Fail.call(this, 'refuse user request'));
},
makeAdmin: function() {
var actionFn, warningText;
if (this.group == null) {
return _.error('makeAdmin err: group is missing');
}
actionFn = this.group.makeAdmin.bind(this.group, this.model);
warningText = _.I18n('group_make_admin_warning');
return confirmAction.call(this, 'group_make_admin', actionFn, warningText);
},
kick: function() {
var actionFn;
if (this.group == null) {
return _.error('kick err: group is missing');
}
actionFn = this.group.kick.bind(this.group, this.model);
return confirmAction.call(this, 'group_kick', actionFn);
}
};
module.exports = _.BasicPlugin(events, handlers);
});
;require.register("modules/users/requests", function(exports, require, module) {
module.exports = function(app, _) {
var API, Rewind, action, normalizeUser, server;
server = {
request: function(userId) {
return this.base('request', userId);
},
cancel: function(userId) {
return this.base('cancel', userId);
},
accept: function(userId) {
return this.base('accept', userId);
},
discard: function(userId) {
return this.base('discard', userId);
},
unfriend: function(userId) {
return this.base('unfriend', userId);
},
base: function(action, userId) {
return _.preq.post(app.API.relations, {
action: action,
user: userId
});
}
};
action = function(user, action, newStatus, label) {
var currentStatus, ref, userId;
ref = normalizeUser(user), user = ref[0], userId = ref[1];
currentStatus = user.get('status');
user.set('status', newStatus);
return server[action](userId).then(_.Tap(app.execute.bind(app, 'track:friend', action)))["catch"](Rewind(user, currentStatus, 'action err'));
};
Rewind = function(user, currentStatus, label) {
var handler;
return handler = function(err) {
user.set('status', currentStatus);
return _.error(err, 'action');
};
};
API = {
sendRequest: function(user) {
return action(user, 'request', 'userRequested');
},
cancelRequest: function(user) {
return action(user, 'cancel', 'public');
},
acceptRequest: function(user, showUserInvetory) {
if (showUserInvetory == null) {
showUserInvetory = true;
}
action(user, 'accept', 'friends');
if (showUserInvetory) {
return app.execute('show:inventory:user', user);
}
},
discardRequest: function(user) {
return action(user, 'discard', 'public');
},
unfriend: function(user) {
var ref, userId;
ref = normalizeUser(user), user = ref[0], userId = ref[1];
app.execute('inventory:remove:user:items', userId);
return action(user, 'unfriend', 'public');
}
};
normalizeUser = function(user) {
if (!_.isModel(user)) {
throw new Error('exepected a user Model, got', user);
}
if (user.id != null) {
return [user, user.id];
} else {
throw new Error('user missing id', user);
}
};
app.reqres.setHandlers({
'request:send': API.sendRequest,
'request:cancel': API.cancelRequest,
'request:accept': API.acceptRequest,
'request:discard': API.discardRequest,
'unfriend': API.unfriend
});
};
});
;require.register("modules/users/users", function(exports, require, module) {
var addUser, fetchFriendItems, fetchFriendsAndTheirItems, fetchItemsOnNewFriend, fetchRelationsDataSuccess, initUsersItems, possiblyInGroups, removeContactItems, spreadRelationsData, usersReady,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
module.exports = {
define: function(module, app, Backbone, Marionette, $, _) {},
initialize: function() {
app.users = require('./users_collections')(app);
app.users.data = require('./users_data')(app, $, _);
require('./helpers')(app);
require('./requests')(app, _);
require('./invitations')(app, _);
initUsersItems();
return app.request('waitForUserData').then(fetchFriendsAndTheirItems);
}
};
initUsersItems = function() {
return app.commands.setHandlers({
'show:user': function(username) {
return app.execute('show:inventory:user', username);
},
'friend:fetchItems': fetchFriendItems
});
};
fetchFriendsAndTheirItems = function() {
if (!app.user.loggedIn) {
return usersReady();
}
return app.users.data.fetchRelationsData().then(fetchRelationsDataSuccess)["catch"](_.Error('fetchFriendsAndTheirItems err'));
};
fetchRelationsDataSuccess = function(relationsData) {
var friends, nonRelationGroupUser, ref;
ref = relationsData.lists, friends = ref.friends, nonRelationGroupUser = ref.nonRelationGroupUser;
if (friends.length === 0 && nonRelationGroupUser.length === 0) {
app.execute('friends:zero');
}
spreadRelationsData(relationsData);
usersReady();
return fetchItemsOnNewFriend();
};
usersReady = function() {
app.users.fetched = true;
app.vent.trigger('users:ready');
};
spreadRelationsData = function(relationsData) {
var inGroups, lists, results, status, userData, usersData;
lists = relationsData.lists, inGroups = relationsData.inGroups;
results = [];
for (status in lists) {
usersData = lists[status];
results.push((function() {
var i, len, results1;
results1 = [];
for (i = 0, len = usersData.length; i < len; i++) {
userData = usersData[i];
results1.push(addUser(inGroups, status, userData));
}
return results1;
})());
}
return results;
};
addUser = function(inGroups, status, user) {
var ref, userModel;
userModel = app.users[status].add(user);
if (indexOf.call(possiblyInGroups, status) >= 0) {
if (ref = userModel.id, indexOf.call(inGroups[status], ref) < 0) {
userModel.itemsFetched = false;
return;
}
}
userModel.itemsFetched = true;
return app.execute('friend:fetchItems', userModel);
};
possiblyInGroups = ['userRequested', 'otherRequested'];
fetchItemsOnNewFriend = function() {
return app.users.friends.on('add', function(friend) {
app.execute('friend:fetchItems', friend);
return app.request('show:inventory:user', friend);
});
};
fetchFriendItems = function(userModel) {
return Items.friends.fetchFriendItems(userModel);
};
removeContactItems = function() {
return Items.friends.remove(Items.friends.where({
owner: this.id
}));
};
});
;require.register("modules/users/users_collections", function(exports, require, module) {
var Users, keepMembersListUpdated;
Users = require('./collections/users');
module.exports = function(app) {
var subCollections, users;
users = new Users;
subCollections = ['public', 'friends', 'userRequested', 'otherRequested', 'nonRelationGroupUser'];
subCollections.forEach(function(status) {
var setStatus;
users[status] = new FilteredCollection(users);
users[status].filterBy({
status: status
});
users[status].filtered = new FilteredCollection(users[status]);
setStatus = function(userData) {
return userData.status = status;
};
return users[status].add = function(data) {
if (_.isArray(data)) {
data.forEach(setStatus);
} else {
setStatus(data);
}
return users.add(data);
};
});
users.filtered = new FilteredCollection(users);
users.filtered.friends = function() {
this.resetFilters();
return this.filterBy({
status: 'friends'
});
};
keepMembersListUpdated(users.friends);
keepMembersListUpdated(users["public"]);
users.list = function() {
return users.map(_.property('id')).concat([app.user.id]);
};
return users;
};
keepMembersListUpdated = function(collection) {
var addMember, removeMember;
collection.list = collection.map(function(member) {
return member.id;
});
addMember = function(model) {
return collection.list.push(model.id);
};
removeMember = function(model) {
return collection.list = _.without(collection.list, model.id);
};
collection.on('add', addMember);
return collection.on('remove', removeMember);
};
});
;require.register("modules/users/users_data", function(exports, require, module) {
var concatGroupIds, extractGroupsIds;
module.exports = function(app, $, _) {
var data, fetchRelationsData, inGroupsNonFriendsRelations, localData, remote, spreadRelationsData;
remote = require('./lib/remote_queries')(app, _);
localData = new app.LocalCache({
name: 'users',
remote: remote,
parseData: _.property('users')
});
fetchRelationsData = function() {
var groups, groupsIds, inGroups, networkIds, ref, relations, relationsIds;
ref = app.user, relations = ref.relations, groups = ref.groups;
if (!((relations != null) || (groups != null))) {
return _.preq.reject('no relations found at fetchRelationsData');
}
relationsIds = _.allValues(relations);
groupsIds = extractGroupsIds(groups);
relations.nonRelationGroupUser = _.difference(groupsIds, relationsIds);
inGroups = inGroupsNonFriendsRelations(relations, groupsIds);
networkIds = _.union(relationsIds, groupsIds);
return localData.get(networkIds).then(spreadRelationsData.bind(null, relations, inGroups));
};
inGroupsNonFriendsRelations = function(relations, groupsIds) {
return {
userRequested: _.intersection(groupsIds, relations.userRequested),
otherRequested: _.intersection(groupsIds, relations.otherRequested)
};
};
spreadRelationsData = function(relations, inGroups, data) {
var i, len, list, lists, relationType, relationsData, userData, userId;
lists = {
friends: [],
userRequested: [],
otherRequested: [],
nonRelationGroupUser: []
};
for (relationType in relations) {
list = relations[relationType];
for (i = 0, len = list.length; i < len; i++) {
userId = list[i];
userData = data[userId];
lists[relationType].push(userData);
}
}
return relationsData = {
lists: lists,
inGroups: inGroups
};
};
return data = {
remote: remote,
local: localData,
fetchRelationsData: fetchRelationsData
};
};
extractGroupsIds = function(groups) {
return _.chain(groups.models).map(concatGroupIds).flatten().uniq().without(app.user.id).value();
};
concatGroupIds = function(group) {
return group.allMembersIds();
};
});
;require.register("modules/users/views/no_user", function(exports, require, module) {
var links;
module.exports = Marionette.ItemView.extend({
tagName: 'li',
className: 'text-center hidden',
template: require('./templates/no_user'),
initialize: function() {
return this.getLink();
},
getLink: function() {
var link;
link = this.options.link;
if (link != null) {
return this.link = links[link];
}
},
onShow: function() {
return this.$el.fadeIn();
},
serializeData: function() {
return {
message: this.options.message || "can't find anyone with that name",
link: this.link
};
},
events: {
'click .linkAction': 'triggerLinkAction'
},
triggerLinkAction: function() {
return this.link.action();
}
});
links = {
inviteFriends: {
text: 'invite friends',
href: '/network/users/invite',
action: function() {
return app.execute('show:network', 'invite');
}
}
};
});
;require.register("modules/users/views/templates/no_user", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.escapeExpression;
return " &nbsp;-&nbsp;\n <a href=\""
+ alias1(container.lambda(((stack1 = (depth0 != null ? depth0.link : depth0)) != null ? stack1.href : stack1), depth0))
+ "\" class=\"linkAction\">"
+ alias1((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.link : depth0)) != null ? stack1.text : stack1),{"name":"i18n","hash":{},"data":data}))
+ "</a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<p class=\"grey noUser\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,(depth0 != null ? depth0.message : depth0),{"name":"i18n","hash":{},"data":data}))
+ "\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.link : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</p>\n\n<p class=\"white findFriends hidden\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"find friends to share your inventory with!",{"name":"i18n","hash":{},"data":data}))
+ " "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"arrow-down",{"name":"icon","hash":{},"data":data}))
+ "\n</p>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/users/views/templates/user_li", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return container.escapeExpression((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.picture : depth0),80,{"name":"src","hash":{},"data":data}));
},"3":function(container,depth0,helpers,partials,data) {
return container.escapeExpression((helpers.src || (depth0 && depth0.src) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.picture : depth0),48,{"name":"src","hash":{},"data":data}));
},"5":function(container,depth0,helpers,partials,data) {
var helper;
return " <span class=\"email\">"
+ container.escapeExpression(((helper = (helper = helpers.email || (depth0 != null ? depth0.email : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"email","hash":{},"data":data}) : helper)))
+ "</span>\n";
},"7":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.inventoryLength : depth0),{"name":"if","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"8":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <span class=\"inventoryLength short serif\">"
+ alias3(((helper = (helper = helpers.inventoryLength || (depth0 != null ? depth0.inventoryLength : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"inventoryLength","hash":{},"data":data}) : helper)))
+ "</span>\n <span class=\"inventoryLength long serif\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"num_books",(depth0 != null ? depth0.inventoryLength : depth0),{"name":"i18n","hash":{},"data":data}))
+ "</span>\n";
},"10":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.bio : depth0),{"name":"if","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"11":function(container,depth0,helpers,partials,data) {
var helper;
return " <div class=\"details\">\n <p class=\"bio user-content\">"
+ container.escapeExpression(((helper = (helper = helpers.bio || (depth0 != null ? depth0.bio : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"bio","hash":{},"data":data}) : helper)))
+ "</p>\n </div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<div class=\"left-box\">\n <a class=\"select\" href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\" title=\""
+ alias4(((helper = (helper = helpers.username || (depth0 != null ? depth0.username : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"username","hash":{},"data":data}) : helper)))
+ "\">\n <img class=\"profilePic\" alt=\""
+ alias4(((helper = (helper = helpers.username || (depth0 != null ? depth0.username : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"username","hash":{},"data":data}) : helper)))
+ "\"\n src=\""
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.stretch : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data})) != null ? stack1 : "")
+ "\">\n </a>\n</div>\n<div class=\"right-box\">\n <a class=\"select\" href=\""
+ alias4(((helper = (helper = helpers.pathname || (depth0 != null ? depth0.pathname : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pathname","hash":{},"data":data}) : helper)))
+ "\" title=\""
+ alias4(((helper = (helper = helpers.username || (depth0 != null ? depth0.username : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"username","hash":{},"data":data}) : helper)))
+ "\">\n <div class=\"top\">\n <span class=\"username serif\">"
+ alias4(((helper = (helper = helpers.username || (depth0 != null ? depth0.username : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"username","hash":{},"data":data}) : helper)))
+ "</span>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.showEmail : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.groupContext : depth0),{"name":"unless","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.stretch : depth0),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </a>\n "
+ alias4((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"inventory/side_nav:user_menu",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n</div>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/users/views/user_li", function(exports, require, module) {
var relationsActions;
relationsActions = require('../plugins/relations_actions');
module.exports = Marionette.ItemView.extend({
tagName: 'li',
template: require('./templates/user_li'),
className: function() {
var classes, groupContext, status, stretch;
classes = "userLi";
status = this.model.get('status') || 'noStatus';
stretch = this.options.stretch ? 'stretch' : '';
groupContext = this.options.groupContext ? 'group-context' : '';
return "userLi " + status + " " + stretch + " " + groupContext;
},
behaviors: {
PreventDefault: {},
ConfirmationModal: {},
SuccessCheck: {}
},
events: {
'click .select, .select-2': 'selectUser'
},
initialize: function() {
this.group = this.options.group;
this.groupContext = this.options.groupContext;
this.initPlugins();
this.lazyRender = _.debounce(this.render, 200);
this.listenTo(this.model, 'change', this.lazyRender);
this.listenTo(this.model, 'group:user:change', this.lazyRender);
return this.listenTo(app.vent, "inventory:" + this.model.id + ":change", this.lazyRender);
},
initPlugins: function() {
return relationsActions.call(this);
},
onShow: function() {
return app.execute('foundation:reload');
},
serializeData: function() {
var attrs, nonPrivateInventoryLength;
nonPrivateInventoryLength = true;
attrs = this.model.serializeData(nonPrivateInventoryLength);
attrs.showEmail = this.options.showEmail;
attrs.stretch = this.options.stretch;
if (this.groupContext) {
return this.attachGroupsAttributes(attrs);
} else {
return attrs;
}
},
attachGroupsAttributes: function(attrs) {
var groupStatus, userId;
attrs.groupContext = true;
groupStatus = this.group.userStatus(this.model);
attrs[groupStatus] = true;
userId = this.model.id;
if (this.group.userIsAdmin(userId)) {
attrs.admin = true;
}
attrs.mainUserIsAdmin = this.group.mainUserIsAdmin();
return attrs;
},
selectUser: function(e) {
if (!_.isOpenedOutside(e)) {
return app.execute('show:inventory:user', this.model);
}
}
});
});
;require.register("modules/users/views/users_list", function(exports, require, module) {
module.exports = Marionette.CollectionView.extend({
tagName: 'ul',
className: 'usersList',
childView: require('./user_li'),
childViewOptions: function() {
return {
groupContext: this.options.groupContext,
group: this.options.group,
showEmail: this.options.showEmail,
stretch: this.options.stretch
};
},
emptyView: require('./no_user'),
emptyViewOptions: function() {
return {
message: this.options.emptyViewMessage,
link: this.options.emptyViewLink
};
},
initialize: function() {
var filter, ref, textFilter;
ref = this.options, filter = ref.filter, textFilter = ref.textFilter;
if (filter != null) {
this.filter = filter;
}
if (textFilter) {
return this.on('filter:text', this.setTextFilter.bind(this));
}
},
onShow: function() {
return app.execute('foundation:reload');
},
setTextFilter: function(text) {
this.filter = function(model) {
return model.matches(text);
};
return this.render();
}
});
});
;require.register("modules/welcome/lib/show_last_public_items", function(exports, require, module) {
var FetchMore, Items, ItemsList, addUsersAndItems, lastPublicItems;
Items = require('modules/inventory/collections/items');
ItemsList = require('modules/inventory/views/items_list');
addUsersAndItems = require('modules/inventory/lib/add_users_and_items');
lastPublicItems = app.API.items.lastPublicItems;
module.exports = function(params) {
var allowMore, assertImage, collection, fetchMore, limit, more, moreData, region;
region = params.region, allowMore = params.allowMore, limit = params.limit, assertImage = params.assertImage;
collection = new Items;
moreData = {
status: true
};
more = function() {
return moreData.status;
};
fetchMore = FetchMore(collection, moreData, limit, assertImage);
return fetchMore().then(function() {
return region.show(new ItemsList({
collection: collection,
fetchMore: allowMore ? fetchMore : void 0,
more: allowMore ? more : void 0,
showDistance: true
}));
});
};
FetchMore = function(collection, moreData, limit, assertImage) {
var busy, catch404, fetchMore;
busy = false;
fetchMore = function() {
var offset;
if (busy) {
return _.preq.resolved;
}
busy = true;
offset = collection.length;
return _.preq.get(lastPublicItems(limit, offset, assertImage)).then(addUsersAndItems.bind(null, collection))["catch"](catch404)["finally"](function() {
return busy = false;
});
};
catch404 = function(err) {
if (err.status === 404) {
moreData.status = false;
return _.warn('no more public items to show');
} else {
throw err;
}
};
return fetchMore;
};
});
;require.register("modules/welcome/views/joyride_welcome_tour", function(exports, require, module) {
var banner, closeHiddenParts, closeSmallScreenSettingsMenu, elMiddle, nubOffset, openHiddenParts, openSettingsMenu, openSmallScreenMenu, reflow, tipOptions, urls;
urls = require('lib/urls');
banner = urls.images.banner;
module.exports = Marionette.ItemView.extend({
template: require('./templates/joyride_welcome_tour'),
onShow: function() {
app.execute('foundation:joyride:start', {
joyride: {
expose: true,
modal: false,
pre_step_callback: openHiddenParts,
post_step_callback: closeHiddenParts
}
});
return setTimeout(this.hackNubPositions.bind(this), 400);
},
serializeData: function() {
return {
urls: urls,
banner: banner,
add: {
pointer: _.smallScreen() ? 'addIconButton' : 'addIconButtonTop',
options: tipOptions({
prev_button: false
})
},
network: {
pointer: _.smallScreen() ? 'networkIconButton' : 'networkIconButtonTop',
options: tipOptions()
}
};
},
hackNubPositions: function() {
var middle;
if (_.smallScreen()) {
middle = elMiddle('#addIconButton', '#networkIconButton');
$('.joyride-tip-guide[data-index="0"] .joyride-nub').css('margin-left', middle);
middle = elMiddle('#networkIconButton', '#browseIconButton');
return $('.joyride-tip-guide[data-index="1"] .joyride-nub').css('margin-left', middle);
}
}
});
nubOffset = 22;
elMiddle = function(selector, next) {
var end, start;
start = $(selector).offset().left;
end = $(next).offset().left;
return (start + end) / 2 - nubOffset;
};
tipOptions = function(options) {
var base;
if (options == null) {
options = {};
}
base = {
tip_location: _.smallScreen() ? 'bottom' : 'right',
tip_animation: 'fade'
};
_.log(base, 'base');
return _.extend(base, options);
};
openHiddenParts = function() {
var id;
id = this.$target[0].id;
switch (id) {
case 'searchField':
return openSmallScreenMenu();
case 'editProfile':
return openSettingsMenu();
}
};
closeHiddenParts = function() {
var id;
id = this.$target[0].id;
switch (id) {
case 'editProfile':
return closeSmallScreenSettingsMenu();
}
};
openSmallScreenMenu = function() {
return $('.menu-icon').trigger('click');
};
openSettingsMenu = function() {
if (_.smallScreen()) {
$('#settingsMenu').find('a').first().trigger('click');
return reflow();
} else {
return $('#settingsMenu').trigger('click');
}
};
closeSmallScreenSettingsMenu = function() {
if (_.smallScreen()) {
return $('#settingsMenu').find('.back').trigger('click');
}
};
reflow = function() {
return $(document).foundation('joyride', 'reflow');
};
});
;require.register("modules/welcome/views/templates/credits", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<section id=\"credits\">\n <h5>"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"assembled_by",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</h5>\n <p class=\"contributors\">\n <strong>"
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"contributors",{"name":"I18n","hash":{},"data":data}))
+ ":</strong><br>\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"Lucie","http://fuzzle.me",{"name":"link","hash":{},"data":data}))
+ " <span class=\"domain\">("
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"translation",{"name":"i18n","hash":{},"data":data}))
+ "-de)</span>,\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"Allmende","http://allmende.io",{"name":"link","hash":{},"data":data}))
+ " <span class=\"domain\">("
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"analytics",{"name":"i18n","hash":{},"data":data}))
+ ")</span>,\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"Albin Larsson","http://abbe98.github.io",{"name":"link","hash":{},"data":data}))
+ " <span class=\"domain\">("
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"code",{"name":"i18n","hash":{},"data":data}))
+ ")</span>,\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"Wikidata contributors","https://wikidata.org",{"name":"link","hash":{},"data":data}))
+ " <span class=\"domain\">("
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"data",{"name":"i18n","hash":{},"data":data}))
+ ")</span>\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"req","https://www.transifex.com/user/profile/req",{"name":"link","hash":{},"data":data}))
+ " <span class=\"domain\">("
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"translation",{"name":"i18n","hash":{},"data":data}))
+ "-de)</span>,\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"Benny Andersson","https://about.me/BennyAndersson",{"name":"link","hash":{},"data":data}))
+ " <span class=\"domain\">("
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"translation",{"name":"i18n","hash":{},"data":data}))
+ "-sv)</span>,\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"David Abián","http://davidabian.com/",{"name":"link","hash":{},"data":data}))
+ " <span class=\"domain\">("
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"translation",{"name":"i18n","hash":{},"data":data}))
+ "-es)</span>,\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"Robert Wolniak","https://www.transifex.com/user/profile/Szkodnix",{"name":"link","hash":{},"data":data}))
+ " <span class=\"domain\">("
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"translation",{"name":"i18n","hash":{},"data":data}))
+ "-pl)</span>,\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"Steffi","http://berlin.imwandel.net",{"name":"link","hash":{},"data":data}))
+ " <span class=\"domain\">("
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"translation",{"name":"i18n","hash":{},"data":data}))
+ "-de)</span>\n </p>\n <p>"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"open_source_credits",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</p>\n <p>\n "
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"beautiful Creative Commons pictures by:",{"name":"I18n","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"Sarah Buckley","https://www.flickr.com/photos/17207222@N02/6117998074",{"name":"link","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"Luci Correia","https://www.flickr.com/photos/lucorreia/15171119938",{"name":"link","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"Brittany Stevens","https://www.flickr.com/photos/brittanystevens/13947832357",{"name":"link","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"Ginny","https://www.flickr.com/photos/ginnerobot/3102623100",{"name":"link","hash":{},"data":data}))
+ "\n - "
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"thanks!",{"name":"I18n","hash":{},"data":data}))
+ "\n </p>\n\n</section>\n<section id=\"legals\">\n <p>"
+ alias3((helpers.link || (depth0 && depth0.link) || alias2).call(alias1,"contacts",((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.mailto : stack1),{"name":"link","hash":{},"data":data}))
+ "</p>\n</section>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/embedded_welcome", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <section id=\"embedded-welcome\">\n <div>\n <h2>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"Welcome on Inventaire",{"name":"i18n","hash":{},"data":data}))
+ "</h2>\n <span class=\"tagline\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"the library of your friends and communities",{"name":"i18n","hash":{},"data":data}))
+ "\n </span>\n </div>\n <a href=\"/welcome\" class=\"showWelcome button secondary bold radius\">\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"learn more",{"name":"i18n","hash":{},"data":data}))
+ "\n </a>\n </section>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, options, buffer = "";
stack1 = ((helper = (helper = helpers.notLoggedIn || (depth0 != null ? depth0.notLoggedIn : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"notLoggedIn","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},options) : helper));
if (!helpers.notLoggedIn) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
if (stack1 != null) { buffer += stack1; }
return buffer;
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/joyride_add", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<h5>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"A book you want to share? Add it to your inventory!",{"name":"i18n","hash":{},"data":data}))
+ "</h5>\n<p>\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"Search from here by title, author or book id (ISBN)",{"name":"i18n","hash":{},"data":data}))
+ " <br>\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"or just scan your books' barcode",{"name":"i18n","hash":{},"data":data}))
+ "\n</p>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/joyride_conclusion_one", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<img src=\""
+ alias3((helpers.src || (depth0 && depth0.src) || alias2).call(alias1,(depth0 != null ? depth0.banner : depth0),400,{"name":"src","hash":{},"data":data}))
+ "\">\n<h5>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"you're all set to start exploring!",{"name":"i18n","hash":{},"data":data}))
+ "</h5>\n<p>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"joyride_last",{"name":"i18n","hash":{},"data":data}))
+ "</p>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/joyride_conclusion_two", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<div id=\"conclusion\">\n <h5>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"joyride_last_conlusion_point_1",{"name":"i18n","hash":{},"data":data}))
+ "</h5>\n <h5>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"joyride_last_conlusion_point_2",{"name":"i18n","hash":{},"data":data}))
+ "</h5>\n</div>\n<div id=\"socialNetworks\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"social_networks",(depth0 != null ? depth0.urls : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n</div>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/joyride_network", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<h5>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"who would you like to share books with?",{"name":"i18n","hash":{},"data":data}))
+ "</h5>\n<p>\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"Search your friends in the current users or invite them to join!",{"name":"i18n","hash":{},"data":data}))
+ "\n "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"That's also the place where you can create groups.",{"name":"i18n","hash":{},"data":data}))
+ "\n</p>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/joyride_settings", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<h5>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"edit your settings",{"name":"i18n","hash":{},"data":data}))
+ "</h5>\n<p>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"switch to another language or change your profile picture from there",{"name":"i18n","hash":{},"data":data}))
+ "</p>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/joyride_tip", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<li data-button=\""
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"times",{"name":"icon","hash":{},"data":data}))
+ "\" data-prev-text=\""
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"arrow-left",{"name":"icon","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:joyride_conclusion",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n</li>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/joyride_welcome_tour", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <li data-id=\""
+ alias3(((helper = (helper = helpers.pointer || (depth0 != null ? depth0.pointer : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"pointer","hash":{},"data":data}) : helper)))
+ "\"\n data-text=\""
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"arrow-right",{"name":"icon","hash":{},"data":data}))
+ "\"\n data-options=\""
+ alias3((helpers.inlineOptions || (depth0 && depth0.inlineOptions) || alias2).call(alias1,(depth0 != null ? depth0.options : depth0),{"name":"inlineOptions","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:joyride_add",{"name":"partial","hash":{},"data":data}))
+ "\n </li>\n";
},"3":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return " <li data-id=\""
+ alias3(((helper = (helper = helpers.pointer || (depth0 != null ? depth0.pointer : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"pointer","hash":{},"data":data}) : helper)))
+ "\" data-button=\""
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"arrow-right",{"name":"icon","hash":{},"data":data}))
+ "\"\n data-prev-text=\""
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"arrow-left",{"name":"icon","hash":{},"data":data}))
+ "\"\n data-options=\""
+ alias3((helpers.inlineOptions || (depth0 && depth0.inlineOptions) || alias2).call(alias1,(depth0 != null ? depth0.options : depth0),{"name":"inlineOptions","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:joyride_network",{"name":"partial","hash":{},"data":data}))
+ "\n </li>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<ol class=\"joyride-list\" data-joyride>\n"
+ ((stack1 = helpers["with"].call(alias1,(depth0 != null ? depth0.add : depth0),{"name":"with","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["with"].call(alias1,(depth0 != null ? depth0.network : depth0),{"name":"with","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " <li data-button=\""
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"arrow-right",{"name":"icon","hash":{},"data":data}))
+ "\" data-prev-text=\""
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"arrow-left",{"name":"icon","hash":{},"data":data}))
+ "\" data-options=\"tip_location:left;tip_animation:fade\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:joyride_conclusion_one",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n </li>\n <li data-button=\""
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"times",{"name":"icon","hash":{},"data":data}))
+ "\" data-prev-text=\""
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"arrow-left",{"name":"icon","hash":{},"data":data}))
+ "\">\n "
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:joyride_conclusion_two",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n </li>\n</ol>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/landing_screen", function(exports, require, module) {
var __templateData = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
return " <a id=\"loginRequest\" class=\"button dark-grey\">"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"back to your inventory",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n";
},"3":function(container,depth0,helpers,partials,data) {
return " "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"welcome:login_buttons",{"name":"partial","hash":{},"data":data}))
+ "\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<section id=\"landingScreen\" class=\"text-center\">\n <div class=\"pusher\"></div>\n <div class=\"polyglotTitle\">\n <h2>"
+ ((stack1 = (helpers.Q || (depth0 && depth0.Q) || alias2).call(alias1,"Q815410",false,"Inventaire",{"name":"Q","hash":{},"data":data})) != null ? stack1 : "")
+ "</h2>\n <h2 class=\"toggler\">Inventaire</h2>\n </div>\n <div class=\"pitch\">\n <h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"keep an inventory of your books",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n <h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"share it with your friends and communities",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n <h3>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"discover the books available in your network!",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n </div>\n <div id=\"loginButtons\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.loggedIn : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data})) != null ? stack1 : "")
+ " </div>\n <div class=\"pusher\"></div>\n</section>\n";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/last_public_books", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<section id=\"lastPublicBooks\">\n <h3 class=\"text-center\">"
+ container.escapeExpression((helpers.i18n || (depth0 && depth0.i18n) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"some of the last books published",{"name":"i18n","hash":{},"data":data}))
+ "</h3>\n <div id=\"previewColumns\"></div>\n</section>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/login_buttons", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<a id=\"signupRequest\" class=\"button secondary bold\" title=\""
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"sign up",{"name":"I18n","hash":{},"data":data}))
+ "\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"sign up",{"name":"i18n","hash":{},"data":data}))
+ "</a>\n<a id=\"loginRequest\" class=\"button success bold\" title=\""
+ alias3((helpers.I18n || (depth0 && depth0.I18n) || alias2).call(alias1,"login",{"name":"I18n","hash":{},"data":data}))
+ "\">"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"login",{"name":"i18n","hash":{},"data":data}))
+ "</a>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/mission", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return "<section id=\"mission\">\n <a class='toggleMission'>\n <span class=\"pusher\"></span>\n <h2>"
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"our mission & values",{"name":"i18n","hash":{},"data":data}))
+ "</h2>\n "
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"chevron-down",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"chevron-up","hidden",{"name":"icon","hash":{},"data":data}))
+ "\n <span class=\"pusher\"></span>\n </a>\n <ul class=\"mission\">\n <li>\n <h4>"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"random",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"Empowering the Transition",{"name":"i18n","hash":{},"data":data}))
+ "</h4>\n <p class=\"capitalized\">"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"pitch_transition",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</p>\n </li>\n <li>\n <h4>"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"book",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"Just Books. For now.",{"name":"i18n","hash":{},"data":data}))
+ "</h4>\n <p class=\"capitalized\">"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"pitch_just_books",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</p>\n </li>\n <li id=\"middle-three\">\n <h4>"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"puzzle-piece",{"name":"icon","hash":{},"data":data}))
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"Built on and for Open Knowledge",{"name":"i18n","hash":{},"data":data}))
+ "</h4>\n <p class=\"capitalized\">"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"pitch_open_knowledge",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</p>\n </li>\n <li>\n <h4>"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"gears",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"Built on and in Open Source",{"name":"i18n","hash":{},"data":data}))
+ "</h4>\n <p class=\"capitalized\">"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"pitch_open_source",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</p>\n </li>\n <li>\n <h4>"
+ alias3((helpers.icon || (depth0 && depth0.icon) || alias2).call(alias1,"database",{"name":"icon","hash":{},"data":data}))
+ " "
+ alias3((helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"You own your data",{"name":"i18n","hash":{},"data":data}))
+ "</h4>\n <p class=\"capitalized\">"
+ ((stack1 = (helpers.i18n || (depth0 && depth0.i18n) || alias2).call(alias1,"pitch_your_data",{"name":"i18n","hash":{},"data":data})) != null ? stack1 : "")
+ "</p>\n </li>\n </ul>\n</section>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/social_networks", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<section id=\"social-networks\">\n "
+ container.escapeExpression((helpers.partial || (depth0 && depth0.partial) || helpers.helperMissing).call(depth0 != null ? depth0 : {},"social_networks",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n</section>";
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/templates/welcome", function(exports, require, module) {
var __templateData = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression;
return alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:landing_screen",depth0,{"name":"partial","hash":{},"data":data}))
+ "\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:last_public_books",{"name":"partial","hash":{},"data":data}))
+ "\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:mission",{"name":"partial","hash":{},"data":data}))
+ "\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:social_networks",(depth0 != null ? depth0.urls : depth0),{"name":"partial","hash":{},"data":data}))
+ "\n"
+ alias3((helpers.partial || (depth0 && depth0.partial) || alias2).call(alias1,"welcome:credits",(depth0 != null ? depth0.urls : depth0),{"name":"partial","hash":{},"data":data}));
},"useData":true});
if (typeof define === 'function' && define.amd) {
define([], function() {
return __templateData;
});
} else if (typeof module === 'object' && module && module.exports) {
module.exports = __templateData;
} else {
__templateData;
}
});
;require.register("modules/welcome/views/welcome", function(exports, require, module) {
var NotLoggedMenu, loginPlugin, showLastPublicItems, urls;
NotLoggedMenu = require('modules/general/views/menu/not_logged_menu');
loginPlugin = require('modules/general/plugins/login');
showLastPublicItems = require('../lib/show_last_public_items');
urls = require('lib/urls');
module.exports = Marionette.LayoutView.extend({
id: 'welcome',
template: require('./templates/welcome'),
regions: {
previewColumns: '#previewColumns'
},
initialize: function() {
return loginPlugin.call(this);
},
events: {
'click .toggleMission': 'toggleMission'
},
behaviors: {
AlertBox: {},
Loading: {},
SuccessCheck: {}
},
serializeData: function() {
return {
loggedIn: app.user.loggedIn,
urls: urls
};
},
ui: {
topBarTrigger: '#middle-three',
thanks: '#thanks',
missions: 'ul.mission li',
missionsTogglers: '.toggleMission .fa'
},
onShow: function() {
this.showPublicItems();
if (!app.user.loggedIn) {
this.hideTopBar();
this.ui.topBarTrigger.once('inview', this.showTopBar);
return this.hideFeedbackButton();
}
},
showPublicItems: function() {
return showLastPublicItems({
region: this.previewColumns,
limit: 15,
allowMore: false,
assertImage: true
})["catch"](this.hidePublicItems.bind(this))["catch"](_.Error('hidePublicItems err'));
},
onDestroy: function() {
this.showTopBar();
return this.showFeedbackButton();
},
hidePublicItems: function(err) {
$('#lastPublicBooks').hide();
if (err != null) {
throw err;
}
},
hideTopBar: function() {
$('.top-bar').hide();
return $('main').addClass('no-topbar');
},
showTopBar: function() {
$('.top-bar').slideDown();
return $('main').removeClass('no-topbar');
},
hideFeedbackButton: function() {
return $('#feedback').hide();
},
showFeedbackButton: function() {
return $('#feedback').fadeIn();
},
toggleMission: function() {
this.ui.missions.slideToggle();
return this.ui.missionsTogglers.toggle();
}
});
});
;
//# sourceMappingURL=app.js.map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment