cannow handle multiple metacodes with same names
This commit is contained in:
parent
0449e28177
commit
1cceaceb06
6 changed files with 27 additions and 27 deletions
|
@ -208,7 +208,7 @@ jQuery.browser = browser;
|
|||
{
|
||||
$(options.titleBox).html( ($(event.target).attr('title') ));
|
||||
// METAMAPS CODE
|
||||
Metamaps.Create.newTopic.metacode = $(event.target).attr('title');
|
||||
Metamaps.Create.newTopic.metacode = $(event.target).attr('data-id');
|
||||
// NOT METAMAPS CODE
|
||||
var idx = $(event.target).data('itemIndex');
|
||||
var frontIndex = event.data.frontIndex;
|
||||
|
@ -246,7 +246,7 @@ jQuery.browser = browser;
|
|||
{
|
||||
if ( items[this.frontIndex] === undefined ) { return; } // Images might not have loaded yet.
|
||||
// METAMAPS CODE
|
||||
Metamaps.Create.newTopic.metacode = $(items[this.frontIndex].image).attr('title');
|
||||
Metamaps.Create.newTopic.metacode = $(items[this.frontIndex].image).attr('data-id');
|
||||
//$('img.cloudcarousel').css({"background":"none", "width":"","height":""});
|
||||
//$(items[this.frontIndex].image).css({"width":"45px","height":"45px"});
|
||||
// NOT METAMAPS CODE
|
||||
|
|
|
@ -410,37 +410,39 @@ Metamaps.Create = {
|
|||
return false;
|
||||
}
|
||||
|
||||
var codesToSwitchTo;
|
||||
var codesToSwitchToIds;
|
||||
var metacodeModels = new Metamaps.Backbone.MetacodeCollection();
|
||||
Metamaps.Create.selectedMetacodeSetIndex = index;
|
||||
Metamaps.Create.selectedMetacodeSet = "metacodeset-" + set;
|
||||
|
||||
if (!custom) {
|
||||
codesToSwitchTo = $('#metacodeSwitchTabs' + set).attr('data-metacodes').split(',');
|
||||
codesToSwitchToIds = $('#metacodeSwitchTabs' + set).attr('data-metacodes').split(',');
|
||||
$('.customMetacodeList li').addClass('toggledOff');
|
||||
Metamaps.Create.selectedMetacodes = [];
|
||||
Metamaps.Create.selectedMetacodeNames = [];
|
||||
Metamaps.Create.newSelectedMetacodes = [];
|
||||
Metamaps.Create.newSelectedMetacodeNames = [];
|
||||
}
|
||||
if (custom) {
|
||||
else if (custom) {
|
||||
// uses .slice to avoid setting the two arrays to the same actual array
|
||||
Metamaps.Create.selectedMetacodes = Metamaps.Create.newSelectedMetacodes.slice(0);
|
||||
Metamaps.Create.selectedMetacodeNames = Metamaps.Create.newSelectedMetacodeNames.slice(0);
|
||||
codesToSwitchTo = Metamaps.Create.selectedMetacodeNames.slice(0);
|
||||
codesToSwitchToIds = Metamaps.Create.selectedMetacodes.slice(0);
|
||||
}
|
||||
|
||||
// sort by name
|
||||
codesToSwitchTo.sort();
|
||||
codesToSwitchTo.reverse();
|
||||
for (var i = 0; i < codesToSwitchToIds.length; i++) {
|
||||
metacodeModels.add( Metamaps.Metacodes.get(codesToSwitchToIds[i]) );
|
||||
};
|
||||
metacodeModels.sort();
|
||||
|
||||
$('#metacodeImg, #metacodeImgTitle').empty();
|
||||
$('#metacodeImg').removeData('cloudcarousel');
|
||||
var newMetacodes = "";
|
||||
var metacode;
|
||||
for (var i = 0; i < codesToSwitchTo.length; i++) {
|
||||
metacode = Metamaps.Metacodes.findWhere({ name: codesToSwitchTo[i] });
|
||||
newMetacodes += '<img class="cloudcarousel" width="40" height="40" src="' + metacode.get('icon') + '" title="' + metacode.get('name') + '" alt="' + metacode.get('name') + '"/>';
|
||||
};
|
||||
metacodeModels.each(function(metacode){
|
||||
newMetacodes += '<img class="cloudcarousel" width="40" height="40" src="' + metacode.get('icon') + '" data-id="' + metacode.id + '" title="' + metacode.get('name') + '" alt="' + metacode.get('name') + '"/>';
|
||||
});
|
||||
|
||||
$('#metacodeImg').empty().append(newMetacodes).CloudCarousel({
|
||||
titleBox: $('#metacodeImgTitle'),
|
||||
yRadius: 40,
|
||||
|
@ -772,13 +774,11 @@ Metamaps.TopicCard = {
|
|||
|
||||
var metacodeLiClick = function () {
|
||||
selectingMetacode = false;
|
||||
var metacodeName = $(this).find('.mSelectName').text();
|
||||
var metacode = Metamaps.Metacodes.findWhere({
|
||||
name: metacodeName
|
||||
});
|
||||
$('.CardOnGraph').find('.metacodeTitle').html(metacodeName)
|
||||
var metacodeId = parseInt($(this).attr('data-id'));
|
||||
var metacode = Metamaps.Metacodes.get(metacodeId);
|
||||
$('.CardOnGraph').find('.metacodeTitle').html(metacode.get('name'))
|
||||
.append('<div class="expandMetacodeSelect"></div>')
|
||||
.attr('class', 'metacodeTitle mbg' + metacodeName.replace(/\s/g, ''));
|
||||
.attr('class', 'metacodeTitle mbg' + metacode.id);
|
||||
$('.CardOnGraph').find('.metacodeImage').css('background-image', 'url(' + metacode.get('icon') + ')');
|
||||
topic.save({
|
||||
metacode_id: metacode.id
|
||||
|
@ -993,7 +993,7 @@ Metamaps.TopicCard = {
|
|||
nodeValues.synapse_count = topic.get("synapse_count").toString();
|
||||
nodeValues.id = topic.isNew() ? topic.cid : topic.id;
|
||||
nodeValues.metacode = topic.getMetacode().get("name");
|
||||
nodeValues.metacode_class = 'mbg' + topic.getMetacode().get("name").replace(/\s/g, '');
|
||||
nodeValues.metacode_class = 'mbg' + topic.get('metacode_id');
|
||||
nodeValues.imgsrc = topic.getMetacode().get("icon");
|
||||
nodeValues.name = topic.get("name");
|
||||
nodeValues.userid = topic.get("user_id");
|
||||
|
@ -3285,9 +3285,7 @@ Metamaps.Topic = {
|
|||
|
||||
$(document).trigger(Metamaps.Map.events.editedByActiveMapper);
|
||||
|
||||
var metacode = Metamaps.Metacodes.findWhere({
|
||||
name: Metamaps.Create.newTopic.metacode
|
||||
});
|
||||
var metacode = Metamaps.Metacodes.get(Metamaps.Create.newTopic.metacode);
|
||||
|
||||
var topic = new Metamaps.Backbone.Topic({
|
||||
name: Metamaps.Create.newTopic.name,
|
||||
|
|
|
@ -1669,8 +1669,10 @@ float: left;
|
|||
background-position: 0 0;
|
||||
}
|
||||
/* only display share button if 'public' or 'commons' */
|
||||
/* we're currently disabling this, as we're not ready for it
|
||||
and it won't be important on password protected instances */
|
||||
.shareable .mapInfoShare {
|
||||
display: block;
|
||||
display: none;
|
||||
}
|
||||
.mapInfoDelete {
|
||||
background-image: url(delete_mapinfo.png);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<% end %>
|
||||
<% @metacodes.sort! {|m1,m2| m2.name.downcase <=> m1.name.downcase }.rotate!(-1) %>
|
||||
<% @metacodes.each do |metacode| %>
|
||||
<img class="cloudcarousel" width="40" height="40" src="<%= metacode.icon %>" alt="<%= metacode.name %>" title="<%= metacode.name %>"/>
|
||||
<img class="cloudcarousel" width="40" height="40" src="<%= metacode.icon %>" alt="<%= metacode.name %>" title="<%= metacode.name %>" data-id="<%= metacode.id %>" />
|
||||
<% end %>
|
||||
</div>
|
||||
<%= form.text_field :name, :maxlength => 140, :placeholder => "title..." %>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<style>
|
||||
<% Metacode.all.each do |m| %>
|
||||
<% if m.color %>
|
||||
<%= ".mbg" + m.name.gsub(/\s+/, "") + "{" %>
|
||||
<%= ".mbg" + m.id.to_s + "{" %>
|
||||
<%= "background-color:" + m.color + " !important;" %>
|
||||
<%= "}" %>
|
||||
<% end %>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
</ul>
|
||||
<% allMetacodeSets.each_with_index do |m, localindex| %>
|
||||
<div id="metacodeSwitchTabs<%= m.id %>"
|
||||
data-metacodes="<%= m.metacodes.map(&:name).join(',') %>">
|
||||
data-metacodes="<%= m.metacodes.map(&:id).join(',') %>">
|
||||
<% @list = '' %>
|
||||
<% m.metacodes.sort{|x,y| x.name <=> y.name }.each_with_index do |m, index| %>
|
||||
<% @list += '<li><img src="' + m.icon + '" alt="' + m.name + '" /><p>' + m.name.downcase + '</p><div class="clearfloat"></div></li>' %>
|
||||
|
|
Loading…
Reference in a new issue