From ede1dfb91c7216ecb0cdd76576f4103d095012d2 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Mon, 1 Aug 2016 15:33:41 -0400 Subject: [PATCH] made the header more generic to serve other functions --- app/assets/javascripts/application.js | 4 +- .../javascripts/src/Metamaps.GlobalUI.js | 17 +++--- app/assets/javascripts/src/Metamaps.Header.js | 22 +++++++ app/assets/stylesheets/clean.css.erb | 3 +- .../doorkeeper/applications/_script.html.erb | 4 +- .../authorized_applications/_script.html.erb | 4 +- app/views/layouts/doorkeeper.html.erb | 2 +- frontend/src/components/ExploreHeader.js | 33 ----------- frontend/src/components/Header.js | 59 +++++++++++++++++++ frontend/src/index.js | 8 +-- public/famous/main.js | 36 ----------- public/famous/templates.js | 36 ----------- 12 files changed, 99 insertions(+), 129 deletions(-) create mode 100644 app/assets/javascripts/src/Metamaps.Header.js delete mode 100644 frontend/src/components/ExploreHeader.js create mode 100644 frontend/src/components/Header.js delete mode 100644 public/famous/main.js delete mode 100644 public/famous/templates.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 65aadbbb..cb22ab95 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -42,7 +42,5 @@ //= require ./src/Metamaps.Mapper //= require ./src/Metamaps.Admin //= require ./src/Metamaps.Import +//= require ./src/Metamaps.Header //= require ./src/Metamaps.JIT -//= require_directory ./shims -// require_directory ./require -// require_directory ./famous diff --git a/app/assets/javascripts/src/Metamaps.GlobalUI.js b/app/assets/javascripts/src/Metamaps.GlobalUI.js index ecf78a6e..bacc0a94 100644 --- a/app/assets/javascripts/src/Metamaps.GlobalUI.js +++ b/app/assets/javascripts/src/Metamaps.GlobalUI.js @@ -61,22 +61,21 @@ $(document).ready(function () { Metamaps.Views.exploreMaps.setCollection( Metamaps.Maps[capitalize] ); if (Metamaps.currentPage === "mapper") { Metamaps.Views.exploreMaps.fetchUserThenRender(); + Metamaps.Header.fetchUserThenChangeSection(!!Metamaps.Active.Mapper, Metamaps.Maps.Mapper.mapperId) } else { Metamaps.Views.exploreMaps.render(); + Metamaps.Header.changeSection(!!Metamaps.Active.Mapper, Metamaps.currentPage) } Metamaps.GlobalUI.showDiv('#exploreMaps') - //f.explore.set(Metamaps.currentPage, Metamaps.Maps.Mapper.mapperId); Metamaps.GlobalUI.showDiv('#exploreMapsHeader') } - else if (Metamaps.currentSection === "") { - if (Metamaps.Active.Mapper) { - Metamaps.Views.exploreMaps.setCollection( Metamaps.Maps.Active ); - Metamaps.Views.exploreMaps.render(); - Metamaps.GlobalUI.showDiv('#exploreMaps') - //f.explore.set('active'); - Metamaps.GlobalUI.showDiv('#exploreMapsHeader') - } + else if (Metamaps.currentSection === "" && Metamaps.Active.Mapper) { + Metamaps.Views.exploreMaps.setCollection( Metamaps.Maps.Active ); + Metamaps.Views.exploreMaps.render(); + Metamaps.GlobalUI.showDiv('#exploreMaps') + Metamaps.Header.changeSection(!!Metamaps.Active.Mapper, 'active') + Metamaps.GlobalUI.showDiv('#exploreMapsHeader') } else if (Metamaps.Active.Map || Metamaps.Active.Topic) { Metamaps.Loading.show() diff --git a/app/assets/javascripts/src/Metamaps.Header.js b/app/assets/javascripts/src/Metamaps.Header.js new file mode 100644 index 00000000..62ef5db9 --- /dev/null +++ b/app/assets/javascripts/src/Metamaps.Header.js @@ -0,0 +1,22 @@ +var Metamaps = Metamaps || {} + +Metamaps.Header = { + init: function () { + + }, + fetchUserThenChangeSection: function (signedIn, mapperId) { + $.ajax({ + url: '/users/' + mapperId + '.json', + success: function (response) { + Metamaps.Header.changeSection(signedIn, 'mapper', response.image, response.name) + }, + error: function () {} + }); + }, + changeSection: function (signedIn, section, userAvatar, userName) { + ReactDOM.render( + React.createElement(Metamaps.ReactComponents.Header, { signedIn: signedIn, section: section, userAvatar: userAvatar, userName: userName }), + document.getElementById('exploreMapsHeader') + ); + } +} diff --git a/app/assets/stylesheets/clean.css.erb b/app/assets/stylesheets/clean.css.erb index 7f0ce77d..d47976f5 100644 --- a/app/assets/stylesheets/clean.css.erb +++ b/app/assets/stylesheets/clean.css.erb @@ -25,7 +25,8 @@ } #yield { - + position: absolute; + width: 100%; } #toast { diff --git a/app/views/doorkeeper/applications/_script.html.erb b/app/views/doorkeeper/applications/_script.html.erb index 970791d4..7f4a7944 100644 --- a/app/views/doorkeeper/applications/_script.html.erb +++ b/app/views/doorkeeper/applications/_script.html.erb @@ -1,8 +1,8 @@