Commit 2f1d915d008a7f75702e2561653db0d38689a3c0
1 parent
b9bc7db9
Exists in
master
and in
8 other branches
Change 'Main' module to global and move 'oauthPluginHandle' function to global a…
…ccess like it was made before by Victor.
Showing
1 changed file
with
7 additions
and
7 deletions
Show diff stats
js/main.js
1 | define(['handlebars','handlebars_helpers'], function(Handlebars){ | 1 | define(['handlebars','handlebars_helpers'], function(Handlebars){ |
2 | 2 | ||
3 | - | ||
4 | /* global Handlebars, $ */ | 3 | /* global Handlebars, $ */ |
5 | // The template code | 4 | // The template code |
6 | var templateSource = $('#proposal-template').html(); | 5 | var templateSource = $('#proposal-template').html(); |
@@ -170,7 +169,7 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ | @@ -170,7 +169,7 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ | ||
170 | $.ajax({ | 169 | $.ajax({ |
171 | type: 'post', | 170 | type: 'post', |
172 | url: host + $form.attr('action'), | 171 | url: host + $form.attr('action'), |
173 | - data: $('#'+this.id).serialize() + '&private_token=' + private_token + '&fields=id&article[name]=article_' + guid() | 172 | + data: $('#'+this.id).serialize() + '&private_token=' + private_token + '&fields=id&article[name]=article_' + Main.guid() |
174 | }) | 173 | }) |
175 | .done(function( /*data*/ ) { | 174 | .done(function( /*data*/ ) { |
176 | form.reset(); | 175 | form.reset(); |
@@ -194,7 +193,7 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ | @@ -194,7 +193,7 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ | ||
194 | var BARRA_ADDED = false; | 193 | var BARRA_ADDED = false; |
195 | var HIDE_BARRA_DO_GOVERNO = false; | 194 | var HIDE_BARRA_DO_GOVERNO = false; |
196 | 195 | ||
197 | - var Main = (function(){ | 196 | + Main = (function(){ |
198 | 197 | ||
199 | return { | 198 | return { |
200 | loadRandomProposal: function (topic_id, private_token) { | 199 | loadRandomProposal: function (topic_id, private_token) { |
@@ -306,9 +305,6 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ | @@ -306,9 +305,6 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ | ||
306 | loginButton.siblings('.login-container').show(); | 305 | loginButton.siblings('.login-container').show(); |
307 | } | 306 | } |
308 | }, | 307 | }, |
309 | - oauthPluginHandleLoginResult: function(loggedIn, token) { | ||
310 | - loginCallback(loggedIn, token); | ||
311 | - }, | ||
312 | guid: function() { | 308 | guid: function() { |
313 | function s4() { | 309 | function s4() { |
314 | return Math.floor((1 + Math.random()) * 0x10000) | 310 | return Math.floor((1 + Math.random()) * 0x10000) |
@@ -544,7 +540,7 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ | @@ -544,7 +540,7 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ | ||
544 | //withCredentials: true | 540 | //withCredentials: true |
545 | } | 541 | } |
546 | }).done(function(data) { | 542 | }).done(function(data) { |
547 | - loginCallback(true, data.private_token); | 543 | + Main.loginCallback(true, data.private_token); |
548 | }).fail(function( /*data*/ ) { | 544 | }).fail(function( /*data*/ ) { |
549 | message.show(); | 545 | message.show(); |
550 | message.text('Não foi possível logar'); | 546 | message.text('Não foi possível logar'); |
@@ -553,6 +549,10 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ | @@ -553,6 +549,10 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ | ||
553 | }); | 549 | }); |
554 | }); | 550 | }); |
555 | 551 | ||
552 | + window.oauthPluginHandleLoginResult = function(loggedIn, token) { | ||
553 | + Main.loginCallback(loggedIn, token); | ||
554 | + } | ||
555 | + | ||
556 | if('onhashchange' in window){ | 556 | if('onhashchange' in window){ |
557 | 557 | ||
558 | window.onhashchange = function(){ | 558 | window.onhashchange = function(){ |