|
| 1 | +"use strict" |
| 2 | + |
| 3 | +config = require('../config') |
| 4 | +Url = require("../tools/url") |
| 5 | +Location = require('../tools/location_operations') |
| 6 | +cookies = require("../tools/cookies") |
| 7 | +cache = require("../tools/cache") |
| 8 | + |
| 9 | +module.exports = (window, document, jquery, navigator) -> |
| 10 | + Url = Url(document) |
| 11 | + cookies.init config, document |
| 12 | + location_operations = Location document |
| 13 | + |
| 14 | + cache.init cookies, config |
| 15 | + |
| 16 | + Materia = |
| 17 | + initialize: (public_key, options) -> |
| 18 | + config.key = public_key |
| 19 | + if options |
| 20 | + for i of options |
| 21 | + config.options[i] = options[i] |
| 22 | + return |
| 23 | + |
| 24 | + setOAuthdURL: (url) -> |
| 25 | + config.oauthd_url = url |
| 26 | + config.oauthd_base = Url.getAbsUrl(config.oauthd_url).match(/^.{2,5}:\/\/[^/]+/)[0] |
| 27 | + return |
| 28 | + |
| 29 | + getOAuthdURL: () -> return config.oauthd_url |
| 30 | + getVersion: () -> return config.version |
| 31 | + |
| 32 | + extend: (name, module) -> |
| 33 | + @[name] = module @ |
| 34 | + |
| 35 | + # private |
| 36 | + getConfig: () -> return config |
| 37 | + getWindow: () -> return window |
| 38 | + getDocument: () -> return document |
| 39 | + getNavigator: () -> return navigator |
| 40 | + getJquery: () -> return jquery |
| 41 | + getUrl: () -> return Url |
| 42 | + getCache: () -> return cache |
| 43 | + getCookies: () -> return cookies |
| 44 | + getLocationOperations: () -> return location_operations |
| 45 | + |
| 46 | + return Materia |
0 commit comments