diff --git a/index.html b/index.html index ca0c794..83da05c 100644 --- a/index.html +++ b/index.html @@ -14,32 +14,46 @@ */ var Url = (function(){ + var _base = ''; + return { initBase: function(){ - var base = window.location.href; + _base = window.location.href; var host = window.location.host; var regex = new RegExp(".*" + host + '/', "g"); if(host){ - base = base.replace(regex,''); + _base = _base.replace(regex,''); }else{ - base = base.replace('index.html',''); + _base = _base.replace('index.html',''); + } + return this; + }, + getBase: function(){ + + if(!_base){ + this.initBase(); } - return base + + return _base; }, removeUrlParameters: function(full_url){ + full_url = full_url || _base; var url_base = full_url.split('#').shift(); return url_base; }, addBaseUrl: function(filename){ - var base = window.location.href; + base = window.location.href; if(base.match(/file:/) || filename.match(/http:/)){ base = ''; }else{ base = this.removeUrlParameters(base) + '/'; } return base + filename; + }, + toString: function(){ + return this.getBase(); } } @@ -75,12 +89,21 @@ function loadJavaScriptAsync(file_path){ } - function loadRequireJS(){ + function loadRequireJS(onLoad){ var head = document.getElementsByTagName('head')[0]; var script_element = document.createElement('script'); script_element.type = 'text/javascript'; script_element.src = makeJSURL('js/require.js'); - script_element.setAttribute('data-main', makeJSURL('js/requirejs-config.js')); + // script_element.setAttribute('data-main', makeJSURL('js/requirejs-config.js')); + if(onLoad instanceof Function){ + script_element.onreadystatechange = function(){ + if (this.readyState == 'complete'){ + onload(); + } + } + script_element.addEventListener('load', onLoad); + } + head.appendChild(script_element); } loadCSSFiles(); @@ -197,7 +220,7 @@
Ela se tornará pública em até 24 horas após o envio e poderá ser apoiada por outros participantes.
Envie Sua Proposta
Login
-
+
@@ -230,7 +253,7 @@

Esta história pode nos ajudar a melhorar a nossa ação e não será divulgada.

- +
@@ -258,7 +281,7 @@
17/06/2015
19:00
  • - Tereza Campello + Teresa Campello Desenvolvimento Social
    18/06/2015
    19:00
  • @@ -333,17 +356,22 @@
    - + diff --git a/js/main.js b/js/main.js index cf4786a..2f701d3 100644 --- a/js/main.js +++ b/js/main.js @@ -1,4 +1,4 @@ -define(['handlebars','handlebars_helpers'], function(Handlebars){ +define(['handlebars_helpers','jquery_ui','jquery_slick', 'jquery_maxlength', 'layout'], function(Handlebars){ /* global Handlebars, $ */ // The template code @@ -43,11 +43,6 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ Main.navigateTo(window.location.hash); - $('.oauth-login').on('click touchstart', function(e) { - Main.oauthClientAction($(this).attr('href')); - e.preventDefault(); - }); - //Actions for links $( '#nav-proposal-categories a' ).on('click touchstart', function(e){ e.preventDefault(); @@ -372,7 +367,6 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ $('.results-container').hide(); $('.experience-proposal-container').hide(); $('.talk-proposal-container').hide(); - $('#proposal-item-' + proposal_id + '.proposal-detail').show(); $('#proposal-item-' + proposal_id + ' .body').show(); var url = host + '/api/v1/articles/' + proposal_id + '?private_token=' + private_token + '&fields=id,body&content_type=ProposalsDiscussionPlugin::Topic'; @@ -502,13 +496,17 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ $('html, body').animate({ scrollTop: 0 }, 'fast'); }, navigateToProposal: function(proposalId){ - var regexSubpages = /sobre-o-programa$/; if(proposalId === undefined){ this.display_proposals_tab(); - }else if(regexSubpages.exec(window.location.hash) == null){ - this.display_proposal('proposal-item-' + proposalId); }else{ - this.display_proposal_detail(proposalId); + this.display_proposal('proposal-item-' + proposalId); + + // show sub-page + var regexSubpages = /sobre-o-programa$/; + var m; + if((m = regexSubpages.exec(window.location.hash)) !== null ){ + this.display_proposal_detail(proposalId); + } } }, navigateToCategory: function(categoryId){ @@ -517,23 +515,6 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ }else{ this.display_proposal_by_category('proposal-item-' + categoryId); } - }, - oauthClientAction: function(url) { - var child = window.open(url, "_blank"); - var interval = setInterval(function() { - try { - if(!child.closed) { - child.postMessage({ message: "requestOauthClientPluginResult" }, "*"); - } - } - catch(e) { - // we're here when the child window has been navigated away or closed - if (child.closed) { - clearInterval(interval); - return; - } - } - }, 300); } } })(); @@ -569,12 +550,9 @@ define(['handlebars','handlebars_helpers'], function(Handlebars){ }); }); - window.addEventListener("message", function(ev) { - if (ev.data.message === "oauthClientPluginResult") { - Main.loginCallback(ev.data.logged_in, ev.data.private_token); - ev.source.close(); - } - }); + window.oauthPluginHandleLoginResult = function(loggedIn, token) { + Main.loginCallback(loggedIn, token); + } if('onhashchange' in window){ window.onhashchange = function(){ diff --git a/js/proposal-app.js b/js/proposal-app.js index 75b81a7..1e4655e 100644 --- a/js/proposal-app.js +++ b/js/proposal-app.js @@ -1,4 +1,4 @@ -define(['jquery','jquery_cookie'],function($){ +define(['jquery_cookie'],function(){ ProposalApp = (function (){ diff --git a/js/requirejs-config.js b/js/requirejs-config.js index cbe8487..3760e38 100644 --- a/js/requirejs-config.js +++ b/js/requirejs-config.js @@ -1,8 +1,10 @@ +var base,test = ''; + if(window.Url){ - var base = Url.initBase(); - base = Url.removeUrlParameters(base) + '/js/'; + var base = Url.initBase().removeUrlParameters()+'/js/'; }else{ base = '../js' + test = window.location.href.replace(/\/\w*\.html/g,''); } requirejs.config({ @@ -15,30 +17,35 @@ requirejs.config({ handlebars: 'handlebars-v3.0.1', handlebars_helpers: 'handlebars-helpers', jquery_maxlength: 'jquery.maxlength.min', - slick: 'slick.min', + jquery_slick: 'slick.min', layout: 'layout', main: 'main', - proposal_app: 'proposal-app' + proposal_app: 'proposal-app', + test:test }, shim: { 'handlebars':{ deps: ['jquery'], exports: 'Handlebars' }, + 'handlebars_helpers':{ + deps: ['handlebars'], + exports: 'Handlebars' + }, 'jquery_ui': { deps: ['jquery'] }, 'layout': { deps: ['jquery'] }, - 'jquery_maxlength': { + 'jquery_maxlength':{ deps: ['jquery'] }, - 'slick': { + 'jquery_cookie':{ deps: ['jquery'] }, - 'handlebars_helpers':{ - deps: ['handlebars'] + 'jquery_slick': { + deps: ['jquery'] }, 'proposal_app' :{ deps: ['jquery'], @@ -46,6 +53,3 @@ requirejs.config({ } } }); - -requirejs(['jquery', 'proposal_app', 'jquery_ui','handlebars_helpers']); -requirejs(['slick', 'jquery_maxlength', 'layout','main']); -- libgit2 0.21.2