]> git.openstreetmap.org Git - rails.git/blob - app/assets/javascripts/oauth.js
Ignore clicks on history entries if the mouse has moved
[rails.git] / app / assets / javascripts / oauth.js
1 //= require ohauth
2
3 $(document).ready(function () {
4   function makeAbsolute(url) {
5     var a = document.createElement('a');
6     a.href = url;
7     return a.href;
8   }
9
10   if (OSM.oauth_token) {
11     var headerGenerator = window.ohauth.headerGenerator({
12       consumer_key: OSM.oauth_consumer_key,
13       consumer_secret: OSM.oauth_consumer_secret,
14       token: OSM.oauth_token,
15       token_secret: OSM.oauth_token_secret
16     });
17
18     $.ajaxPrefilter(function(options, jqxhr) {
19       if (options.oauth) {
20         options.headers = options.headers || {};
21         options.headers.Authorization = headerGenerator(options.type, makeAbsolute(options.url), jqxhr.data);
22       }
23     });
24   }
25 });