Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaVerou committed Jul 9, 2012
1 parent e057c42 commit 45c1795
Show file tree
Hide file tree
Showing 13 changed files with 737 additions and 1,824 deletions.
6 changes: 0 additions & 6 deletions code/dabblet.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,6 @@ setTimeout(function(){
}, 500);

document.addEventListener('DOMContentLoaded', function() {
if(ACCESS_TOKEN) {
gist.getUser(function(user){
Dabblet.user.afterLogin(user);
});
}

var a = $('h1 > a');

if(parent !== window) {
Expand Down
292 changes: 0 additions & 292 deletions code/gist.js

This file was deleted.

22 changes: 18 additions & 4 deletions code/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var gist = {
o.method = o.method || 'GET';
o.id = o.id || '';
o.rev = o.rev || '';
o.accepted = o.accepted || [];

var anon = o.anon || o.method === 'GET';

Expand All @@ -54,9 +55,9 @@ var gist = {
url: 'https://api.github.com/' + path + (!o.anon && window.ACCESS_TOKEN? '?access_token=' + ACCESS_TOKEN : ''),
headers: o.headers,
callback: function(xhr) {
var data = JSON.parse(xhr.responseText);
var data = xhr.responseText? JSON.parse(xhr.responseText) : null;

if(data.message) {
if (data && data.message && o.accepted.indexOf(xhr.status) === -1) {
alert('Sorry, I got a ' + xhr.status + ' (' + data.message + ')');
}
else {
Expand All @@ -73,6 +74,10 @@ var gist = {
callback: function(data) {
window.user = data;

document.documentElement.classList.add('logged-in');

$u.event.fire(window, 'gotUserInfo');

callback && callback(data);
}
});
Expand All @@ -83,7 +88,7 @@ var gist = {
},

getUserURL: function(user) {
return 'https://gist.github.com/' + user.login;
return '/user/' + user.login;
},

save: function(options){
Expand All @@ -110,7 +115,7 @@ var gist = {
id: anonymous || options.forceNew? null : id,
method: 'POST',
headers: {
'Content-Type': 'text/plain; charset=UTF-8'
'Content-Type': 'application/json; charset=UTF-8'
},
callback: function(data, xhr) {
if(data.id) {
Expand Down Expand Up @@ -303,6 +308,7 @@ var Dabblet = {
currentuser.innerHTML = gist.getUserHTML(user);
currentuser.href = gist.getUserURL(user);
currentuser.parentNode.className = currentuser.parentNode.className.replace('-inactive-', '-');
$('.my-profile').href = '/user/' + user.login;
}

if(window['save-button']) {
Expand Down Expand Up @@ -336,6 +342,14 @@ if(!$('#loader')) {
});
}

document.addEventListener('DOMContentLoaded', function() {
if(ACCESS_TOKEN) {
gist.getUser(function(user){
Dabblet.user.afterLogin(user);
});
}
});

// If only :focus and :checked bubbled...
(function() {
function ancestorClass(action, className, element) {
Expand Down
2 changes: 1 addition & 1 deletion code/incrementable.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var _ = window.Incrementable = function(textField, multiplier, units) {
var me = this;

this.textField = textField;
console.log(textField);

this.step = +textField.getAttribute('step') ||
+textField.getAttribute('data-step') || 1;

Expand Down
Loading

0 comments on commit 45c1795

Please sign in to comment.