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