diff --git a/app/assets/javascripts/Metamaps.ServerData.js.erb b/app/assets/javascripts/Metamaps.ServerData.js.erb new file mode 100644 index 00000000..86c8d2b9 --- /dev/null +++ b/app/assets/javascripts/Metamaps.ServerData.js.erb @@ -0,0 +1,18 @@ +/* global Metamaps */ + +/* erb variables from rails */ +Metamaps.ServerData = Metamaps.ServerData || {} +Metamaps.ServerData['junto_spinner_darkgrey.gif'] = '<%= asset_path('junto_spinner_darkgrey.gif') %>' +Metamaps.ServerData['user.png'] = '<%= asset_path('user.png') %>' +Metamaps.ServerData['icons/wildcard.png'] = '<%= asset_path('icons/wildcard.png') %>' +Metamaps.ServerData['topic_description_signifier.png'] = '<%= asset_path('topic_description_signifier.png') %>' +Metamaps.ServerData['topic_link_signifier.png'] = '<%= asset_path('topic_link_signifier.png') %>' +Metamaps.ServerData['synapse16.png'] = '<%= asset_path('synapse16.png') %>' +Metamaps.ServerData['sounds/MM_sounds.mp3'] = '<%= asset_path 'sounds/MM_sounds.mp3' %>' +Metamaps.ServerData['sounds/MM_sounds.ogg'] = '<%= asset_path 'sounds/MM_sounds.ogg' %>' +Metamaps.ServerData.Metacodes = <%= Metacode.all.to_json.gsub(%r[(icon.*?)(\"},)], '\1?purple=stupid\2').html_safe %> +Metamaps.ServerData.REALTIME_SERVER = '<%= ENV['REALTIME_SERVER'] %>' +Metamaps.ServerData.RAILS_ENV = '<%= ENV['RAILS_ENV'] %>' +Metamaps.ServerData.VERSION = '<%= METAMAPS_VERSION %>' +Metamaps.ServerData.BUILD = '<%= METAMAPS_BUILD %>' +Metamaps.ServerData.LAST_UPDATED = '<%= METAMAPS_LAST_UPDATED %>' diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 051edc8b..d669012a 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -14,5 +14,5 @@ //= require jquery-ui //= require jquery_ujs //= require_directory ./lib -//= require ./src/Metamaps.Erb //= require ./webpacked/metamaps.bundle +//= require ./Metamaps.ServerData diff --git a/app/assets/javascripts/src/Metamaps.Erb.js.erb b/app/assets/javascripts/src/Metamaps.Erb.js.erb deleted file mode 100644 index 57f26c98..00000000 --- a/app/assets/javascripts/src/Metamaps.Erb.js.erb +++ /dev/null @@ -1,24 +0,0 @@ -/* global Metamaps */ - -/* - * Metamaps.Erb.js.erb - */ - -/* erb variables from rails */ -window.Metamaps = window.Metamaps || {} -Metamaps.Erb = {} -Metamaps.Erb['REALTIME_SERVER'] = '<%= ENV['REALTIME_SERVER'] %>' -Metamaps.Erb['RAILS_ENV'] = '<%= ENV['RAILS_ENV'] %>' -Metamaps.Erb['junto_spinner_darkgrey.gif'] = '<%= asset_path('junto_spinner_darkgrey.gif') %>' -Metamaps.Erb['user.png'] = '<%= asset_path('user.png') %>' -Metamaps.Erb['icons/wildcard.png'] = '<%= asset_path('icons/wildcard.png') %>' -Metamaps.Erb['topic_description_signifier.png'] = '<%= asset_path('topic_description_signifier.png') %>' -Metamaps.Erb['topic_link_signifier.png'] = '<%= asset_path('topic_link_signifier.png') %>' -Metamaps.Erb['synapse16.png'] = '<%= asset_path('synapse16.png') %>' -Metamaps.Erb['import-example.png'] = '<%= asset_path('import-example.png') %>' -Metamaps.Erb['sounds/MM_sounds.mp3'] = '<%= asset_path 'sounds/MM_sounds.mp3' %>' -Metamaps.Erb['sounds/MM_sounds.ogg'] = '<%= asset_path 'sounds/MM_sounds.ogg' %>' -Metamaps.Metacodes = <%= Metacode.all.to_json.gsub(%r[(icon.*?)(\"},)], '\1?purple=stupid\2').html_safe %> -Metamaps.VERSION = '<%= METAMAPS_VERSION %>' -Metamaps.BUILD = '<%= METAMAPS_BUILD %>' -Metamaps.LAST_UPDATED = '<%= METAMAPS_LAST_UPDATED %>' diff --git a/frontend/src/Metamaps/Account.js b/frontend/src/Metamaps/Account.js index 1ac87811..15b6f30b 100644 --- a/frontend/src/Metamaps/Account.js +++ b/frontend/src/Metamaps/Account.js @@ -1,17 +1,17 @@ /* global $, CanvasLoader */ -/* - * Metamaps.Erb - */ - const Account = { listenersInitialized: false, + userIconUrl: null, initListeners: function () { var self = Account $('#user_image').change(self.showImagePreview) self.listenersInitialized = true }, + init: function (serverData) { + Account.userIconUrl = serverData['user.png'] + }, toggleChangePicture: function () { var self = Account @@ -25,24 +25,18 @@ const Account = { if (!self.listenersInitialized) self.initListeners() }, closeChangePicture: function () { - var self = Account - $('.userImageMenu').hide() }, showLoading: function () { - var self = Account - var loader = new CanvasLoader('accountPageLoading') - loader.setColor('#4FC059'); // default is '#000000' + loader.setColor('#4FC059') // default is '#000000' loader.setDiameter(28) // default is 40 loader.setDensity(41) // default is 40 - loader.setRange(0.9); // default is 1.3 + loader.setRange(0.9) // default is 1.3 loader.show() // Hidden by default $('#accountPageLoading').show() }, showImagePreview: function () { - var self = Account - var file = $('#user_image')[0].files[0] var reader = new window.FileReader() @@ -90,7 +84,7 @@ const Account = { var self = Account $('.userImageDiv canvas').remove() - $('.userImageDiv img').attr('src', window.Metamaps.Erb['user.png']).show() + $('.userImageDiv img').attr('src', self.userIconUrl).show() $('.userImageMenu').hide() var input = $('#user_image') diff --git a/frontend/src/Metamaps/DataModel/Synapse.js b/frontend/src/Metamaps/DataModel/Synapse.js index 0be1cfda..09f75743 100644 --- a/frontend/src/Metamaps/DataModel/Synapse.js +++ b/frontend/src/Metamaps/DataModel/Synapse.js @@ -1,4 +1,4 @@ -/* global Metamaps, $ */ +/* global $ */ import _ from 'lodash' import Backbone from 'backbone' @@ -13,10 +13,6 @@ import Visualize from '../Visualize' import DataModel from './index' -/* - * Metamaps.Erb - */ - const Synapse = Backbone.Model.extend({ urlRoot: '/synapses', blacklist: ['edge', 'created_at', 'updated_at'], @@ -82,7 +78,7 @@ const Synapse = Backbone.Model.extend({ prepareLiForFilter: function () { var li = '' li += '
  • ' - li += '
  • ' return li diff --git a/frontend/src/Metamaps/GlobalUI/Search.js b/frontend/src/Metamaps/GlobalUI/Search.js index eb5fe0a7..1d4b82e4 100644 --- a/frontend/src/Metamaps/GlobalUI/Search.js +++ b/frontend/src/Metamaps/GlobalUI/Search.js @@ -1,12 +1,8 @@ -/* global Metamaps, $, Hogan, Bloodhound, CanvasLoader */ +/* global $, Hogan, Bloodhound, CanvasLoader */ import Active from '../Active' import Router from '../Router' -/* - * Metamaps.Erb - */ - const Search = { locked: false, isOpen: false, @@ -54,7 +50,7 @@ const Search = { return Hogan.compile(topicheader + $('#topicSearchTemplate').html()).render({ value: 'No results', label: 'No results', - typeImageURL: Metamaps.Erb['icons/wildcard.png'], + typeImageURL: Metamaps.ServerData['icons/wildcard.png'], rtype: 'noresult' }) }, @@ -122,7 +118,7 @@ const Search = { value: 'No results', label: 'No results', rtype: 'noresult', - profile: Metamaps.Erb['user.png'] + profile: Metamaps.ServerData['user.png'] }) }, header: mapperheader, diff --git a/frontend/src/Metamaps/JIT.js b/frontend/src/Metamaps/JIT.js index e57244c0..cbcd131b 100644 --- a/frontend/src/Metamaps/JIT.js +++ b/frontend/src/Metamaps/JIT.js @@ -1,4 +1,4 @@ -/* global Metamaps, $, Image, CanvasLoader */ +/* global $, Image, CanvasLoader */ import _ from 'lodash' import outdent from 'outdent' @@ -24,10 +24,6 @@ import Util from './Util' import Visualize from './Visualize' import clipboard from 'clipboard-js' -/* - * Metamaps.Erb - */ - let panningInt const JIT = { @@ -69,10 +65,10 @@ const JIT = { $('.takeScreenshot').click(Map.exportImage) self.topicDescImage = new Image() - self.topicDescImage.src = Metamaps.Erb['topic_description_signifier.png'] + self.topicDescImage.src = Metamaps.ServerData['topic_description_signifier.png'] self.topicLinkImage = new Image() - self.topicLinkImage.src = Metamaps.Erb['topic_link_signifier.png'] + self.topicLinkImage.src = Metamaps.ServerData['topic_link_signifier.png'] }, /** * convert our topic JSON into something JIT can use diff --git a/frontend/src/Metamaps/Map/InfoBox.js b/frontend/src/Metamaps/Map/InfoBox.js index 95455fd4..a3e31f19 100644 --- a/frontend/src/Metamaps/Map/InfoBox.js +++ b/frontend/src/Metamaps/Map/InfoBox.js @@ -1,4 +1,4 @@ -/* global Metamaps, $, Hogan, Bloodhound, Countable */ +/* global $, Hogan, Bloodhound, Countable */ import outdent from 'outdent' @@ -8,10 +8,6 @@ import GlobalUI from '../GlobalUI' import Router from '../Router' import Util from '../Util' -/* - * Metamaps.Erb - */ - const InfoBox = { isOpen: false, changing: false, @@ -112,7 +108,7 @@ const InfoBox = { obj['contributor_count'] = relevantPeople.length obj['contributors_class'] = relevantPeople.length > 1 ? 'multiple' : '' obj['contributors_class'] += relevantPeople.length === 2 ? ' mTwo' : '' - obj['contributor_image'] = relevantPeople.length > 0 ? relevantPeople.models[0].get('image') : Metamaps.Erb['user.png'] + obj['contributor_image'] = relevantPeople.length > 0 ? relevantPeople.models[0].get('image') : Metamaps.ServerData['user.png'] obj['contributor_list'] = self.createContributorList() obj['user_name'] = isCreator ? 'You' : map.get('user_name') @@ -214,7 +210,7 @@ const InfoBox = { value: "No results", label: "No results", rtype: "noresult", - profile: Metamaps.Erb['user.png'], + profile: Metamaps.ServerData['user.png'], }); }, suggestion: function(s) { @@ -317,7 +313,7 @@ const InfoBox = { if (relevantPeople.length === 2) contributors_class = 'multiple mTwo' else if (relevantPeople.length > 2) contributors_class = 'multiple' - var contributors_image = Metamaps.Erb['user.png'] + var contributors_image = Metamaps.ServerData['user.png'] if (relevantPeople.length > 0) { // get the first contributor and use their image contributors_image = relevantPeople.models[0].get('image') diff --git a/frontend/src/Metamaps/Map/index.js b/frontend/src/Metamaps/Map/index.js index 7ff806a5..578c1f9f 100644 --- a/frontend/src/Metamaps/Map/index.js +++ b/frontend/src/Metamaps/Map/index.js @@ -21,13 +21,6 @@ import Visualize from '../Visualize' import CheatSheet from './CheatSheet' import InfoBox from './InfoBox' -/* - * Metamaps.Map.js.erb - * - * Dependencies: - * - Metamaps.Erb - */ - const Map = { events: { editedByActiveMapper: 'Metamaps:Map:events:editedByActiveMapper' diff --git a/frontend/src/Metamaps/Views/ChatView.js b/frontend/src/Metamaps/Views/ChatView.js index 8febe9e1..fe33ac68 100644 --- a/frontend/src/Metamaps/Views/ChatView.js +++ b/frontend/src/Metamaps/Views/ChatView.js @@ -1,9 +1,4 @@ -/* global Metamaps, $ */ - -/* - * Dependencies: - * Metamaps.Erb - */ +/* global $ */ import Backbone from 'backbone' import { Howl } from 'howler' @@ -128,7 +123,7 @@ var Private = { }, initializeSounds: function () { this.sound = new Howl({ - src: [Metamaps.Erb['sounds/MM_sounds.mp3'], Metamaps.Erb['sounds/MM_sounds.ogg']], + src: [Metamaps.ServerData['sounds/MM_sounds.mp3'], Metamaps.ServerData['sounds/MM_sounds.ogg']], sprite: { joinmap: [0, 561], leavemap: [1000, 592], diff --git a/frontend/src/patched/JIT.js b/frontend/src/patched/JIT.js index d3cac135..a41f1c65 100644 --- a/frontend/src/patched/JIT.js +++ b/frontend/src/patched/JIT.js @@ -3261,7 +3261,7 @@ var Canvas; ctx = base.getCtx(), scale = base.scaleOffsetX; //var pattern = new Image(); - //pattern.src = Metamaps.Erb['cubes.png'] + //pattern.src = Metamaps.ServerData['cubes.png'] //var ptrn = ctx.createPattern(pattern, 'repeat'); //ctx.fillStyle = ptrn; ctx.fillStyle = Metamaps.Settings.colors.background;