diff --git a/app/assets/javascripts/lib/cloudcarousel.js b/app/assets/javascripts/lib/cloudcarousel.js index 9f26592a..52a26539 100644 --- a/app/assets/javascripts/lib/cloudcarousel.js +++ b/app/assets/javascripts/lib/cloudcarousel.js @@ -164,16 +164,17 @@ jQuery.browser = browser; // START METAMAPS CODE // Add code that makes tab and shift+tab scroll through metacodes $('.new_topic').bind('keydown',this,function(event){ - if (event.keyCode == 9) { - if (event.shiftKey) { - event.data.rotate(-1) - } else { - event.data.rotate(1) - } - event.preventDefault(); - event.stopPropagation(); - Metamaps.Create.newTopic.metacode = $(items[event.data.frontIndex].image).attr('data-id'); - } + if (event.keyCode == 9 && event.shiftKey) { + $(container).show() + event.data.rotate(-1); + event.preventDefault(); + event.stopPropagation(); + } else if (event.keyCode == 9) { + $(container).show() + event.data.rotate(1); + event.preventDefault(); + event.stopPropagation(); + } }); // END METAMAPS CODE @@ -181,14 +182,14 @@ jQuery.browser = browser; if (options.mouseWheel) { // START METAMAPS CODE - $('body').bind('mousewheel',this,function(event, delta) { - if (Metamaps.Create.newTopic.beingCreated && - !Metamaps.Create.isSwitchingSet && - !Metamaps.Create.newTopic.pinned) { - event.data.rotate(delta); - return false; - } - }); + /*$('body').bind('mousewheel',this,function(event, delta) { + if (Metamaps.Create.newTopic.beingCreated && + !Metamaps.Create.isSwitchingSet && + !Metamaps.Create.newTopic.pinned) { + event.data.rotate(delta); + return false; + } + });*/ // END METAMAPS CODE // ORIGINAL CODE // $(container).bind('mousewheel',this,function(event, delta) { @@ -255,8 +256,11 @@ jQuery.browser = browser; this.showFrontText = function() { if ( items[this.frontIndex] === undefined ) { return; } // Images might not have loaded yet. - $(options.titleBox).html( $(items[this.frontIndex].image).attr('title')); - $(options.altBox).html( $(items[this.frontIndex].image).attr('alt')); + // METAMAPS CODE + Metamaps.Create.newTopic.setMetacode($(items[this.frontIndex].image).attr('data-id')) + // NOT METAMAPS CODE + //$(options.titleBox).html( $(items[this.frontIndex].image).attr('title')); + //$(options.altBox).html( $(items[this.frontIndex].image).attr('alt')); }; this.go = function() @@ -269,7 +273,10 @@ jQuery.browser = browser; this.stop = function() { clearTimeout(this.controlTimer); - this.controlTimer = 0; + this.controlTimer = 0; + // METAMAPS CODE + $(container).hide() + // END METAMAPS CODE }; @@ -390,7 +397,7 @@ jQuery.browser = browser; } // If all images have valid widths and heights, we can stop checking. clearInterval(this.tt); - this.showFrontText(); + // METAMAPS COMMENT this.showFrontText(); this.autoRotate(); this.updateAll(); diff --git a/app/assets/stylesheets/application.scss.erb b/app/assets/stylesheets/application.scss.erb index 3bb0b369..465a3058 100644 --- a/app/assets/stylesheets/application.scss.erb +++ b/app/assets/stylesheets/application.scss.erb @@ -531,18 +531,48 @@ button.button.btn-no:hover { left: -1000px; display: block; position: absolute; - width: 340px; - margin: -40px 0 0 -35px; z-index: 1; } +.selectedMetacode { + float: left; + background: #FFF; + border-top-left-radius: 2px; + border-bottom-left-radius: 2px; + padding: 5px 10px 5px 6px; + vertical-align: top; + border-right: 1px solid #DDD; + cursor: pointer; +} +.selectedMetacode:hover, .selectedMetacode.isBeingSelected { + background: #EDEDED; +} +.selectedMetacode img { + width: 24px; + height: 24px; + display: inline-block; + vertical-align: middle; +} +.selectedMetacode span { + vertical-align: middle; +} +.selectedMetacode .downArrow { + display: inline-block; + vertical-align: middle; + width: 0; + height: 0; + border-style: solid; + border-width: 8px 6px 0 6px; + border-color: #777 transparent transparent transparent; + margin-left: 2px; + margin-top: 4px; +} + #new_topic .twitter-typeahead { - position: absolute !important; - top: 45px; - left: 41px; z-index: 9999; width: 256px; height: 34px; + float: left; } .new_topic #topic_name, .new_topic .tt-hint { @@ -552,7 +582,8 @@ button.button.btn-no:hover { margin: 0; padding: 10px 6px; border: none; - border-radius: 2px; + border-top-right-radius: 2px; + border-bottom-right-radius: 2px; outline: none; font-size: 14px; line-height: 14px; @@ -563,7 +594,7 @@ button.button.btn-no:hover { color: #BDBDBD; } .openMetacodeSwitcher { - display: block; + display: none; height: 16px; width: 16px; background-image: url(<%= asset_data_uri('metacodesettings_sprite.png') %>); @@ -583,8 +614,8 @@ button.button.btn-no:hover { background-image: url(<%= asset_data_uri('pincarousel_sprite.png') %>); position: absolute; z-index: 2; - top: 20px; - right: 16px; + top: -20px; + right: -16px; } .pinCarousel:hover { background-position: 0 -16px; @@ -597,8 +628,14 @@ button.button.btn-no:hover { } #metacodeImg { height: 120px; + width: 380px; + display: none; + position: absolute !important; + top: -30px; + z-index: -1; } #metacodeImgTitle { + display: none; float: left; width: 120px; text-align: center; diff --git a/app/assets/stylesheets/metacode-select.scss.erb b/app/assets/stylesheets/metacode-select.scss.erb new file mode 100644 index 00000000..3e30303a --- /dev/null +++ b/app/assets/stylesheets/metacode-select.scss.erb @@ -0,0 +1,72 @@ +#metacodeSelector { + display: none; +} + +.metacodeSelect { + border-top: 1px solid #DDD; + padding: 0; + + .tabList { + float: left; + background: #FFF; + + div { + border-right: 1px solid #DDD; + border-bottom: 1px solid #DDD; + } + + div:last-child { + border-bottom: none; + } + + div.active { + border-right: none; + background: #EEE; + + .metacodeFilterInput { + background: #EEE; + } + } + + .metacodeFilterInput { + width: 100px; + outline: none; + border: 0; + padding: 8px; + font-size: 14px; + line-height: 14px; + color: #424242; + font-family: 'din-medium', helvetica, sans-serif; + } + + span { + padding: 8px; + display: block; + } + } + + .metacodeList { + float:left; + list-style: none; + background: #FFF; + min-height: 107px; + min-width: 100px; + + li { + padding: 8px; + cursor: pointer; + + &:hover, &.keySelect { + background: #EEE; + } + } + + img { + width: 24px; + height: 24px; + display: inline-block; + vertical-align: middle; + padding-right: 6px; + } + } +} \ No newline at end of file diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7aff655d..224d3ff6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -91,6 +91,16 @@ class UsersController < ApplicationController format.json { render json: @user } end end + + # PUT /user/update_metacode_focus + def update_metacode_focus + @user = current_user + @user.settings.metacode_focus = params[:value] + @user.save + respond_to do |format| + format.json { render json: { success: "success" }} + end + end # PUT /user/update_metacode_focus def update_metacode_focus diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7d0f4f68..860cd38c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -41,6 +41,10 @@ module ApplicationHelper def user_metacode current_user.settings.metacode_focus ? Metacode.find(current_user.settings.metacode_focus.to_i) : nil end + + def user_metacode + current_user.settings.metacode_focus ? Metacode.find(current_user.settings.metacode_focus.to_i) || user_metacodes()[0] : user_metacodes()[0] + end def user_most_used_metacodes @metacodes = current_user.most_used_metacodes.map { |id| Metacode.find(id) } diff --git a/app/models/user.rb b/app/models/user.rb index 915d06db..ede2918c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -66,6 +66,28 @@ class User < ApplicationRecord json['rtype'] = 'mapper' json end + + def recentMetacodes + array = [] + self.topics.sort{|a,b| b.created_at <=> a.created_at }.each do |t| + if array.length < 5 and array.index(t.metacode_id) == nil + array.push(t.metacode_id) + end + end + array + end + + def mostUsedMetacodes + self.topics.to_a.reduce({}) { |memo, topic| + if memo[topic.metacode_id] == nil + memo[topic.metacode_id] = 1 + else + memo[topic.metacode_id] = memo[topic.metacode_id] + 1 + end + + memo + }.to_a.sort{ |a, b| b[1] <=> a[1] }.map{|i| i[0]}.slice(0, 5) + end def as_rdf(opts = {}) base_url = opts[:base_url] || 'https://metamaps.cc' diff --git a/app/views/maps/_newtopic.html.erb b/app/views/maps/_newtopic.html.erb index 8e10c7a7..cc65d6ac 100644 --- a/app/views/maps/_newtopic.html.erb +++ b/app/views/maps/_newtopic.html.erb @@ -11,24 +11,36 @@