diff --git a/addons/im_livechat/include.html b/addons/im_livechat/include.html index 55de6212361..210bad6984c 100644 --- a/addons/im_livechat/include.html +++ b/addons/im_livechat/include.html @@ -1,2 +1,2 @@ - + \ No newline at end of file diff --git a/addons/im_livechat/static/ext/bower.json b/addons/im_livechat/static/ext/bower.json index b3e75dc51aa..f10d0de7b9c 100644 --- a/addons/im_livechat/static/ext/bower.json +++ b/addons/im_livechat/static/ext/bower.json @@ -12,6 +12,7 @@ "jquery": "1.8.3", "underscore": "1.3.1", "qweb": "git@github.com:OpenERP/qweb.git#~1.0.0", - "jquery-achtung": "git://github.com/joshvarner/jquery-achtung.git" + "jquery-achtung": "git://github.com/joshvarner/jquery-achtung.git", + "requirejs": "~2.1.8" } } diff --git a/addons/im_livechat/static/ext/static/js/require.js b/addons/im_livechat/static/ext/static/lib/requirejs/require.js similarity index 92% rename from addons/im_livechat/static/ext/static/js/require.js rename to addons/im_livechat/static/ext/static/lib/requirejs/require.js index f46a9245d97..52c2b076b7b 100644 --- a/addons/im_livechat/static/ext/static/js/require.js +++ b/addons/im_livechat/static/ext/static/lib/requirejs/require.js @@ -1,18 +1,18 @@ /** vim: et:ts=4:sw=4:sts=4 - * @license RequireJS 2.1.2 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. + * @license RequireJS 2.1.8 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. * Available via the MIT or new BSD license. * see: http://github.com/jrburke/requirejs for details */ //Not using strict: uneven strict support in browsers, #392, and causes //problems with requirejs.exec()/transpiler plugins that may not be strict. /*jslint regexp: true, nomen: true, sloppy: true */ -/*global window, navigator, document, importScripts, jQuery, setTimeout, opera */ +/*global window, navigator, document, importScripts, setTimeout, opera */ var requirejs, require, define; (function (global) { var req, s, head, baseElement, dataMain, src, interactiveScript, currentlyAddingScript, mainScript, subPath, - version = '2.1.2', + version = '2.1.8', commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, jsSuffixRegExp = /\.js$/, @@ -21,9 +21,8 @@ var requirejs, require, define; ostring = op.toString, hasOwn = op.hasOwnProperty, ap = Array.prototype, - aps = ap.slice, apsp = ap.splice, - isBrowser = !!(typeof window !== 'undefined' && navigator && document), + isBrowser = !!(typeof window !== 'undefined' && navigator && window.document), isWebWorker = !isBrowser && typeof importScripts !== 'undefined', //PS3 indicates loaded and complete, but need to wait for complete //specifically. Sequence is 'loading', 'loaded', execution, @@ -135,6 +134,10 @@ var requirejs, require, define; return document.getElementsByTagName('script'); } + function defaultOnError(err) { + throw err; + } + //Allow getting a global that expressed in //dot notation, like 'a.b.c'. function getGlobal(value) { @@ -192,15 +195,21 @@ var requirejs, require, define; var inCheckLoaded, Module, context, handlers, checkLoadedTimeoutId, config = { + //Defaults. Do not set a default for map + //config to speed up normalize(), which + //will run faster if there is no default. waitSeconds: 7, baseUrl: './', paths: {}, pkgs: {}, shim: {}, - map: {}, config: {} }, registry = {}, + //registry of just enabled modules, to speed + //cycle breaking code when lots of modules + //are registered, but not activated. + enabledRegistry = {}, undefEvents = {}, defQueue = [], defined = {}, @@ -296,7 +305,7 @@ var requirejs, require, define; } //Apply map config if available. - if (applyMap && (baseParts || starMap) && map) { + if (applyMap && map && (baseParts || starMap)) { nameParts = name.split('/'); for (i = nameParts.length; i > 0; i -= 1) { @@ -495,7 +504,12 @@ var requirejs, require, define; fn(defined[id]); } } else { - getModule(depMap).on(name, fn); + mod = getModule(depMap); + if (mod.error && name === 'error') { + fn(mod.error); + } else { + mod.on(name, fn); + } } } @@ -566,7 +580,13 @@ var requirejs, require, define; id: mod.map.id, uri: mod.map.url, config: function () { - return (config.config && getOwn(config.config, mod.map.id)) || {}; + var c, + pkg = getOwn(config.pkgs, mod.map.id); + // For packages, only support config targeted + // at the main module. + c = pkg ? getOwn(config.config, mod.map.id + '/' + pkg.main) : + getOwn(config.config, mod.map.id); + return c || {}; }, exports: defined[mod.map.id] }); @@ -577,6 +597,7 @@ var requirejs, require, define; function cleanRegistry(id) { //Clean up machinery used for waiting modules. delete registry[id]; + delete enabledRegistry[id]; } function breakCycle(mod, traced, processed) { @@ -625,7 +646,7 @@ var requirejs, require, define; inCheckLoaded = true; //Figure out the state of all the modules. - eachProp(registry, function (mod) { + eachProp(enabledRegistry, function (mod) { map = mod.map; modId = map.id; @@ -806,7 +827,7 @@ var requirejs, require, define; }, /** - * Checks is the module is ready to define itself, and if so, + * Checks if the module is ready to define itself, and if so, * define it. */ check: function () { @@ -834,8 +855,13 @@ var requirejs, require, define; if (this.depCount < 1 && !this.defined) { if (isFunction(factory)) { //If there is an error listener, favor passing - //to that instead of throwing an error. - if (this.events.error) { + //to that instead of throwing an error. However, + //only do it for define()'d modules. require + //errbacks should not be called for failures in + //their callbacks (#699). However if a global + //onError is set, use that. + if ((this.events.error && this.map.isDefine) || + req.onError !== defaultOnError) { try { exports = context.execCb(id, factory, depExports, exports); } catch (e) { @@ -863,8 +889,8 @@ var requirejs, require, define; if (err) { err.requireMap = this.map; - err.requireModules = [this.map.id]; - err.requireType = 'define'; + err.requireModules = this.map.isDefine ? [this.map.id] : null; + err.requireType = this.map.isDefine ? 'define' : 'require'; return onError((this.error = err)); } @@ -884,7 +910,7 @@ var requirejs, require, define; } //Clean up - delete registry[id]; + cleanRegistry(id); this.defined = true; } @@ -918,8 +944,7 @@ var requirejs, require, define; name = this.map.name, parentName = this.map.parentMap ? this.map.parentMap.name : null, localRequire = context.makeRequire(map.parentMap, { - enableBuildCallback: true, - skipMap: true + enableBuildCallback: true }); //If current map is not normalized, wait for that @@ -1017,8 +1042,11 @@ var requirejs, require, define; try { req.exec(text); } catch (e) { - throw new Error('fromText eval for ' + moduleName + - ' failed: ' + e); + return onError(makeError('fromtexteval', + 'fromText eval for ' + id + + ' failed: ' + e, + e, + [id])); } if (hasInteractive) { @@ -1048,6 +1076,7 @@ var requirejs, require, define; }, enable: function () { + enabledRegistry[this.map.id] = this; this.enabled = true; //Set flag mentioning that the module is enabling, @@ -1084,7 +1113,7 @@ var requirejs, require, define; })); if (this.errback) { - on(depMap, 'error', this.errback); + on(depMap, 'error', bind(this, this.errback)); } } @@ -1207,6 +1236,7 @@ var requirejs, require, define; Module: Module, makeModuleMap: makeModuleMap, nextTick: req.nextTick, + onError: onError, /** * Set a configuration for the context. @@ -1233,6 +1263,9 @@ var requirejs, require, define; eachProp(cfg, function (value, prop) { if (objs[prop]) { if (prop === 'map') { + if (!config.map) { + config.map = {}; + } mixin(config[prop], value, true, true); } else { mixin(config[prop], value, true); @@ -1344,7 +1377,7 @@ var requirejs, require, define; //Synchronous access to one module. If require.get is //available (as in the Node adapter), prefer that. if (req.get) { - return req.get(context, deps, relMap); + return req.get(context, deps, relMap, localRequire); } //Normalize module name, if it contains . or .. @@ -1395,16 +1428,20 @@ var requirejs, require, define; * plain URLs like nameToUrl. */ toUrl: function (moduleNamePlusExt) { - var index = moduleNamePlusExt.lastIndexOf('.'), - ext = null; + var ext, + index = moduleNamePlusExt.lastIndexOf('.'), + segment = moduleNamePlusExt.split('/')[0], + isRelative = segment === '.' || segment === '..'; - if (index !== -1) { + //Have a file extension alias, and it is not the + //dots from a relative path. + if (index !== -1 && (!isRelative || index > 1)) { ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length); moduleNamePlusExt = moduleNamePlusExt.substring(0, index); } return context.nameToUrl(normalize(moduleNamePlusExt, - relMap && relMap.id, true), ext); + relMap && relMap.id, true), ext, true); }, defined: function (id) { @@ -1449,10 +1486,11 @@ var requirejs, require, define; /** * Called to enable a module if it is still in the registry - * awaiting enablement. parent module is passed in for context, - * used by the optimizer. + * awaiting enablement. A second arg, parent, the parent module, + * is passed in for context, when this method is overriden by + * the optimizer. Not shown here to keep code compact. */ - enable: function (depMap, parent) { + enable: function (depMap) { var mod = getOwn(registry, depMap.id); if (mod) { getModule(depMap).enable(); @@ -1522,7 +1560,7 @@ var requirejs, require, define; * it is assumed to have already been normalized. This is an * internal API, not a public one. Use toUrl for the public API. */ - nameToUrl: function (moduleName, ext) { + nameToUrl: function (moduleName, ext, skipExt) { var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url, parentPath; @@ -1571,7 +1609,7 @@ var requirejs, require, define; //Join the path parts together, then figure out if baseUrl is needed. url = syms.join('/'); - url += (ext || (/\?/.test(url) ? '' : '.js')); + url += (ext || (/\?/.test(url) || skipExt ? '' : '.js')); url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url; } @@ -1587,7 +1625,7 @@ var requirejs, require, define; }, /** - * Executes a module callack function. Broken out as a separate function + * Executes a module callback function. Broken out as a separate function * solely to allow the build system to sequence the files in the built * layer in the right sequence. * @@ -1625,7 +1663,7 @@ var requirejs, require, define; onScriptError: function (evt) { var data = getScriptData(evt); if (!hasPathFallback(data.id)) { - return onError(makeError('scripterror', 'Script error', evt, [data.id])); + return onError(makeError('scripterror', 'Script error for: ' + data.id, evt, [data.id])); } } }; @@ -1754,8 +1792,19 @@ var requirejs, require, define; * function. Intercept/override it if you want custom error handling. * @param {Error} err the error object. */ - req.onError = function (err) { - throw err; + req.onError = defaultOnError; + + /** + * Creates the node for the load command. Only used in browser envs. + */ + req.createNode = function (config, moduleName, url) { + var node = config.xhtml ? + document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : + document.createElement('script'); + node.type = config.scriptType || 'text/javascript'; + node.charset = 'utf-8'; + node.async = true; + return node; }; /** @@ -1772,12 +1821,7 @@ var requirejs, require, define; node; if (isBrowser) { //In the browser so use a script tag - node = config.xhtml ? - document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : - document.createElement('script'); - node.type = config.scriptType || 'text/javascript'; - node.charset = 'utf-8'; - node.async = true; + node = req.createNode(config, moduleName, url); node.setAttribute('data-requirecontext', context.contextName); node.setAttribute('data-requiremodule', moduleName); @@ -1810,7 +1854,7 @@ var requirejs, require, define; node.attachEvent('onreadystatechange', context.onScriptLoad); //It would be great to add an error handler here to catch //404s in IE9+. However, onreadystatechange will fire before - //the error handler, so that does not help. If addEvenListener + //the error handler, so that does not help. If addEventListener //is used, then IE will fire error before load, but we cannot //use that pathway given the connect.microsoft.com issue //mentioned above about not doing the 'script execute, @@ -1839,16 +1883,24 @@ var requirejs, require, define; return node; } else if (isWebWorker) { - //In a web worker, use importScripts. This is not a very - //efficient use of importScripts, importScripts will block until - //its script is downloaded and evaluated. However, if web workers - //are in play, the expectation that a build has been done so that - //only one script needs to be loaded anyway. This may need to be - //reevaluated if other use cases become common. - importScripts(url); + try { + //In a web worker, use importScripts. This is not a very + //efficient use of importScripts, importScripts will block until + //its script is downloaded and evaluated. However, if web workers + //are in play, the expectation that a build has been done so that + //only one script needs to be loaded anyway. This may need to be + //reevaluated if other use cases become common. + importScripts(url); - //Account for anonymous modules - context.completeLoad(moduleName); + //Account for anonymous modules + context.completeLoad(moduleName); + } catch (e) { + context.onError(makeError('importscripts', + 'importScripts failed for ' + + moduleName + ' at ' + url, + e, + [moduleName])); + } } }; @@ -1880,24 +1932,31 @@ var requirejs, require, define; //baseUrl, if it is not already set. dataMain = script.getAttribute('data-main'); if (dataMain) { + //Preserve dataMain in case it is a path (i.e. contains '?') + mainScript = dataMain; + //Set final baseUrl if there is not already an explicit one. if (!cfg.baseUrl) { //Pull off the directory of data-main for use as the //baseUrl. - src = dataMain.split('/'); + src = mainScript.split('/'); mainScript = src.pop(); subPath = src.length ? src.join('/') + '/' : './'; cfg.baseUrl = subPath; - dataMain = mainScript; } - //Strip off any trailing .js since dataMain is now + //Strip off any trailing .js since mainScript is now //like a module name. - dataMain = dataMain.replace(jsSuffixRegExp, ''); + mainScript = mainScript.replace(jsSuffixRegExp, ''); + + //If mainScript is still a path, fall back to dataMain + if (req.jsExtRegExp.test(mainScript)) { + mainScript = dataMain; + } //Put the data-main script in the files to load. - cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain]; + cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript]; return true; } @@ -1925,12 +1984,13 @@ var requirejs, require, define; //This module may not have dependencies if (!isArray(deps)) { callback = deps; - deps = []; + deps = null; } //If no name, and callback is a function, then figure out if it a //CommonJS thing with dependencies. - if (!deps.length && isFunction(callback)) { + if (!deps && isFunction(callback)) { + deps = []; //Remove comments from the callback string, //look for require calls, and pull them into the dependencies, //but only if there are function args. @@ -1990,4 +2050,4 @@ var requirejs, require, define; //Set up with config info. req(cfg); -}(this)); \ No newline at end of file +}(this)); diff --git a/addons/im_livechat/static/ext/test.html b/addons/im_livechat/static/ext/test.html index e4a45ffc9b4..22d33261227 100644 --- a/addons/im_livechat/static/ext/test.html +++ b/addons/im_livechat/static/ext/test.html @@ -1,7 +1,7 @@ - +