From 31817d31a5de20c80bae0bf5d8e0b69e9ce9df08 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Mon, 9 Jun 2014 13:36:23 -0400 Subject: [PATCH] closes #202, closes #301, closes #320, closes #337 --- app/assets/javascripts/application.js | 4 ++-- .../carousel/cloud-carousel.1.0.5.js | 15 +++++-------- .../jquery/AuthCanEditMappingPages.js | 21 ++++++++++++++---- app/assets/javascripts/typeahead.js | 14 ++++++++++-- app/assets/stylesheets/application.css | 22 ++++++++++++++----- app/views/maps/show.html.erb | 4 ++-- 6 files changed, 55 insertions(+), 25 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index bd3932c7..d2b6fdba 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -264,14 +264,14 @@ function updateMetacodeSet(set, index, custom) { $('#metacodeImg').removeData('cloudcarousel'); var newMetacodes = ""; for (var i = 0; i < codesToSwitchTo.length; i++) { - newMetacodes += ''; + newMetacodes += '' + codesToSwitchTo[i] + ''; }; $('#metacodeImg').empty().append(newMetacodes).CloudCarousel({ titleBox: $('#metacodeImgTitle'), yRadius: 40, xPos: 150, yPos: 40, - speed: 0.15, + speed: 0.3, mouseWheel: true, bringToFront: true }); diff --git a/app/assets/javascripts/carousel/cloud-carousel.1.0.5.js b/app/assets/javascripts/carousel/cloud-carousel.1.0.5.js index 901f952e..467ae3c4 100644 --- a/app/assets/javascripts/carousel/cloud-carousel.1.0.5.js +++ b/app/assets/javascripts/carousel/cloud-carousel.1.0.5.js @@ -163,18 +163,15 @@ jQuery.browser = browser; // Add code that makes tab and shift+tab scroll through metacodes $('.new_topic').bind('keydown',this,function(event){ - if (event.keyCode == 9 || (event.keyCode == 9 && event.shiftKey)) { - event.preventDefault(); - } - }); - $('.new_topic').bind('keyup',this,function(event){ - //console.log(event); - /*key navigation through elements*/ - if (event.keyCode == 9 && event.shiftKey) { + if (event.keyCode == 9 && event.shiftKey) { event.data.rotate(-1); + event.preventDefault(); + event.stopPropagation(); } else if (event.keyCode == 9) { event.data.rotate(1); - } + event.preventDefault(); + event.stopPropagation(); + } }); // You will need this plugin for the mousewheel to work: http://plugins.jquery.com/project/mousewheel diff --git a/app/assets/javascripts/jquery/AuthCanEditMappingPages.js b/app/assets/javascripts/jquery/AuthCanEditMappingPages.js index 0b03ba02..e952e338 100644 --- a/app/assets/javascripts/jquery/AuthCanEditMappingPages.js +++ b/app/assets/javascripts/jquery/AuthCanEditMappingPages.js @@ -25,19 +25,25 @@ $(document).ready(function () { engine: Hogan } ]); - + + var topicTypeahead = false; // tell the autocomplete to submit the form with the topic you clicked on if you pick from the autocomplete $('#topic_name').bind('typeahead:selected', function (event, datum, dataset) { $('#topic_grabTopic').val(datum.id); event.preventDefault(); event.stopPropagation(); + $('.new_topic').submit(); + topicTypeahead = true; + }); + $('#topic_name').bind('typeahead:opened', function () { + topicTypeahead = false; }); // bind keyboard handlers $('#topic_name').bind('keyup', function (e) { switch (e.which) { case 13: - $('.new_topic').submit(); + if (!topicTypeahead) $('.new_topic').submit(); break; default: break; @@ -65,7 +71,7 @@ $(document).ready(function () { $('#synapse_desc').typeahead([ { name: 'synapse_autocomplete', - template: "{{label}}", + template: "
{{label}}
", remote: { url: '/search/synapses?term=%QUERY' }, @@ -86,6 +92,8 @@ $(document).ready(function () { header: "

Existing Synapses

" }, ]); + + var synapseTypeahead = false; // tell the autocomplete to submit the form with the topic you clicked on if you pick from the autocomplete $('#synapse_desc').bind('typeahead:selected', function (event, datum, dataset) { if (datum.id) { // if they clicked on an existing synapse get it @@ -93,12 +101,17 @@ $(document).ready(function () { } event.preventDefault(); event.stopPropagation(); + $('.new_synapse').submit(); + synapseTypeahead = true; + }); + $('#synapse_desc').bind('typeahead:opened', function () { + synapseTypeahead = false; }); // bind keyboard handlers $('#synapse_desc').bind('keyup', function (e) { switch (e.which) { case 13: - $('.new_synapse').submit(); + if (!synapseTypeahead) $('.new_synapse').submit(); break; default: break; diff --git a/app/assets/javascripts/typeahead.js b/app/assets/javascripts/typeahead.js index 1fb987d5..74e3de5d 100644 --- a/app/assets/javascripts/typeahead.js +++ b/app/assets/javascripts/typeahead.js @@ -566,7 +566,9 @@ var that = this; utils.bindAll(this); this.specialKeyCodeMap = { - 9: "tab", + // START METAMAPS CODE + //9: "tab", + // END METAMAPS CODE 27: "esc", 37: "left", 39: "right", @@ -714,11 +716,19 @@ }, _handleMouseleave: function() { this.isMouseOverDropdown = false; + + // START METAMAPS CODE + this._getSuggestions().removeClass("tt-is-under-cursor"); + this._getSuggestions().removeClass("tt-is-under-mouse-cursor"); + // END METAMAPS CODE }, _handleMouseover: function($e) { var $suggestion = $($e.currentTarget); this._getSuggestions().removeClass("tt-is-under-cursor"); - $suggestion.addClass("tt-is-under-cursor"); + // START METAMAPS CODE + this._getSuggestions().removeClass("tt-is-under-mouse-cursor"); + $suggestion.addClass("tt-is-under-mouse-cursor"); + // ORIGINAL CODE $suggestion.addClass("tt-is-under-cursor"); }, _handleSelection: function($e) { var $suggestion = $($e.currentTarget); diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index dcb9b4cc..80db82c9 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -309,6 +309,12 @@ input[type="submit"]:hover { } /* synapse autocomplete */ +.new_topic #topic_name { + color: white; +} +.new_topic .tt-hint { + color: grey; +} .new_topic #topic_name, .new_topic .tt-hint { width: 190px; @@ -320,9 +326,14 @@ input[type="submit"]:hover { outline: none; font-size: 18px; line-height: 35px; - color: white; font-family: 'LatoRegular'; } +.new_synapse #synapse_desc { + color: rgba(255, 255, 255, 0.7); +} +.new_synapse .tt-hint { + color: rgba(255, 255, 255, 0.4); +} .new_synapse #synapse_desc, .new_synapse .tt-hint { width: 200px; @@ -334,7 +345,6 @@ input[type="submit"]:hover { outline: none; font-size: 16px; line-height: 20px; - color: rgba(255, 255, 255, 0.7); font-family: 'LatoRegular'; } label, @@ -1283,13 +1293,13 @@ h3.filterByMetacode { /* topic autocomplete */ -#new_topic .tt-suggestion.tt-is-under-cursor { +#new_topic .tt-suggestion.tt-is-under-cursor, #new_topic .tt-suggestion.tt-is-under-mouse-cursor { background: #0E161D; } #new_topic .tt-suggestion { padding: 5px; font-family: 'LatoLight'; - background: #2A343C; + background: rgba(42, 52, 60, 0.9);; } #new_topic .autocompleteSection { float: left; @@ -1342,7 +1352,7 @@ h3.filterByMetacode { padding: 2px 5px 2px; z-index: 100; } -/* topic autocomplete */ +/* synapse autocomplete */ #new_synapse .tt-dropdown-menu { width: 212px; @@ -1356,7 +1366,7 @@ h3.filterByMetacode { line-height: 16px; margin: 3px; } -#new_synapse .tt-suggestion.tt-is-under-cursor { +#new_synapse .tt-suggestion.tt-is-under-cursor, #new_synapse .tt-suggestion.tt-is-under-mouse-cursor { background: #0E161D; } #new_synapse .tt-suggestion { diff --git a/app/views/maps/show.html.erb b/app/views/maps/show.html.erb index 6fd4daf9..58a3b3a8 100644 --- a/app/views/maps/show.html.erb +++ b/app/views/maps/show.html.erb @@ -104,13 +104,13 @@ if (json.length > 0) { <% if authenticated? && (@map.permission == "commons" || @map.user == user) %> // this is for the heroku staging environment -window.realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com'); +//window.realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com'); // this is for metamaps.cc //window.realtime.socket = io.connect('http://metamaps.cc:5001'); // this is for localhost development -//window.realtime.socket = io.connect('http://localhost:5001'); +window.realtime.socket = io.connect('http://localhost:5001'); window.realtime.socket.on('connect', function () { console.log('socket connected');