part way through add links to topic cards
This commit is contained in:
parent
6182ba4e14
commit
85bfce0237
5 changed files with 114 additions and 72 deletions
6
app/assets/javascripts/librariesForAllPages/jquery.embedly.min.js
vendored
Normal file
6
app/assets/javascripts/librariesForAllPages/jquery.embedly.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -639,20 +639,6 @@ Metamaps.TopicCard = {
|
|||
$('.showcard').draggable({
|
||||
handle: ".metacodeImage"
|
||||
});
|
||||
$('#showcard').resizable({
|
||||
maxHeight: 500,
|
||||
maxWidth: 500,
|
||||
minHeight: 320,
|
||||
minWidth: 226,
|
||||
resize: function (event, ui) {
|
||||
var p = $('#showcard').find('.scroll');
|
||||
p.height(p.height()).mCustomScrollbar('update');
|
||||
}
|
||||
}).css({
|
||||
display: 'none',
|
||||
top: '300px',
|
||||
left: '100px'
|
||||
});
|
||||
},
|
||||
fadeInShowCard: function (topic) {
|
||||
$('.showcard').fadeIn('fast');
|
||||
|
@ -678,6 +664,38 @@ Metamaps.TopicCard = {
|
|||
var self = Metamaps.TopicCard;
|
||||
var showCard = document.getElementById('showcard');
|
||||
|
||||
|
||||
// starting embed.ly
|
||||
if (false && topic.get('link')) {
|
||||
$('.showcard .attachments a').embedly({
|
||||
query: {maxwidth: 300},
|
||||
key: '7983300f4c1f48569ca242e3d6bff1e9'
|
||||
});
|
||||
}
|
||||
|
||||
var addLinkFunc = function () {
|
||||
var addLinkDiv ='';
|
||||
var addLinkDesc ='Enter or paste a link';
|
||||
addLinkDiv+='<div class="addLink"><div id="addLinkBack"></div>';
|
||||
addLinkDiv+='<div id="addLinkInput"><input placeholder="' + addLinkDesc + '"></input>';
|
||||
addLinkDiv+='<div id="addLinkReset"></div></div></div>';
|
||||
$('.addAttachment').hide();
|
||||
$('.attachments').append(addLinkDiv);
|
||||
$('.showcard #addLinkBack').click(backFunc);
|
||||
$('.showcard #addLinkReset').click(resetFunc);
|
||||
};
|
||||
var backFunc = function () {
|
||||
$('.addLink').remove();
|
||||
$('.addAttachment').show();
|
||||
};
|
||||
var resetFunc = function () {
|
||||
$('#addLinkInput input').val('');
|
||||
$('#addLinkInput input').focus();
|
||||
};
|
||||
|
||||
$('.showcard #addlink').click(addLinkFunc);
|
||||
|
||||
|
||||
var selectingMetacode = false;
|
||||
// attach the listener that shows the metacode title when you hover over the image
|
||||
$('.showcard .metacodeImage').mouseenter(function () {
|
||||
|
@ -792,12 +810,6 @@ Metamaps.TopicCard = {
|
|||
var desc = $(this).html();
|
||||
topic.set("desc", desc);
|
||||
});
|
||||
|
||||
$(showCard).find('.best_in_place_link').bind("ajax:success", function () {
|
||||
var link = $(this).html();
|
||||
$(showCard).find('.go-link').attr('href', link);
|
||||
topic.set("link", link);
|
||||
});
|
||||
},
|
||||
populateShowCard: function (topic) {
|
||||
var self = Metamaps.TopicCard;
|
||||
|
@ -806,7 +818,8 @@ Metamaps.TopicCard = {
|
|||
|
||||
$(showCard).find('.permission').remove();
|
||||
|
||||
var html = self.generateShowcardHTML.render(self.buildObject(topic));
|
||||
var topicForTemplate = self.buildObject(topic);
|
||||
var html = self.generateShowcardHTML.render(topicForTemplate);
|
||||
|
||||
if (topic.authorizeToEdit(Metamaps.Active.Mapper)) {
|
||||
var perm = document.createElement('div');
|
||||
|
@ -828,29 +841,29 @@ Metamaps.TopicCard = {
|
|||
generateShowcardHTML: null, // will be initialized into a Hogan template within init function
|
||||
//generateShowcardHTML
|
||||
buildObject: function (topic) {
|
||||
|
||||
var nodeValues = {};
|
||||
|
||||
var authorized = topic.authorizeToEdit(Metamaps.Active.Mapper);
|
||||
|
||||
//link is rendered differently if user is logged out or in
|
||||
var go_link, a_tag, close_a_tag;
|
||||
if (!authorized) {
|
||||
go_link = '';
|
||||
if (topic.get("link") != "") {
|
||||
a_tag = '<a href="' + topic.get("link") + '" target="_blank">';
|
||||
close_a_tag = '</a>';
|
||||
} else {
|
||||
a_tag = '';
|
||||
close_a_tag = '';
|
||||
}
|
||||
|
||||
} else {
|
||||
go_link = '<a href="' + topic.get("link") + '" ' +
|
||||
' class="go-link" target="_blank"></a>';
|
||||
a_tag = '';
|
||||
close_a_tag = '';
|
||||
|
||||
}
|
||||
|
||||
var desc_nil = "Click to add description...";
|
||||
var link_nil = "Click to add link...";
|
||||
|
||||
if (false && topic.get('link')) {
|
||||
nodeValues.attachments = '<a href="'+topic.get('link')+'">'+topic.get('link')+'</a>';
|
||||
}
|
||||
else {
|
||||
nodeValues.attachments = '<div class="addAttachment">';
|
||||
nodeValues.attachments+= '<div id="addphoto">photo</div>';
|
||||
nodeValues.attachments+= '<div id="addlink">link</div>';
|
||||
nodeValues.attachments+= '<div id="addaudio">audio</div>';
|
||||
nodeValues.attachments+= '<div id="addupload">upload</div> </div>';
|
||||
}
|
||||
|
||||
nodeValues.permission = topic.get("permission");
|
||||
nodeValues.mk_permission = topic.get("permission").substring(0, 2);
|
||||
|
@ -864,14 +877,8 @@ Metamaps.TopicCard = {
|
|||
nodeValues.userid = topic.get("user_id");
|
||||
nodeValues.username = topic.getUser().get("name");
|
||||
nodeValues.date = topic.getDate();
|
||||
|
||||
// the code for this is stored in /views/main/_metacodeOptions.html.erb
|
||||
nodeValues.metacode_select = $('#metacodeOptions').html();
|
||||
nodeValues.go_link = go_link;
|
||||
nodeValues.a_tag = a_tag;
|
||||
nodeValues.close_a_tag = close_a_tag;
|
||||
nodeValues.link_nil = link_nil;
|
||||
nodeValues.link = (topic.get("link") == "" && authorized) ? link_nil : topic.get("link");
|
||||
nodeValues.desc_nil = desc_nil;
|
||||
nodeValues.desc = (topic.get("desc") == "" && authorized) ? desc_nil : topic.get("desc");
|
||||
return nodeValues;
|
||||
|
|
|
@ -6,24 +6,24 @@
|
|||
color:#444;
|
||||
}
|
||||
|
||||
.showcard, #showcard {
|
||||
.showcard {
|
||||
position:absolute;
|
||||
display:block;
|
||||
top:-1000px;
|
||||
left:-1000px;
|
||||
display:none;
|
||||
top:300px;
|
||||
left:100px;
|
||||
margin-top: -181px;
|
||||
width:226px;
|
||||
height:320px;
|
||||
width:300px;
|
||||
height:360px;
|
||||
color:#FFF;
|
||||
text-align: left;
|
||||
overflow: visible;
|
||||
z-index:14000;
|
||||
background: #FFF;
|
||||
border-radius:5px;
|
||||
border-radius:2px;
|
||||
box-shadow: 6px 6px 8px rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
#showcard .contributor {
|
||||
.showcard .contributor {
|
||||
font-size:14px;
|
||||
}
|
||||
|
||||
|
@ -358,7 +358,7 @@ float:left;
|
|||
}
|
||||
|
||||
|
||||
.CardOnGraph .link {
|
||||
.CardOnGraph .attachments {
|
||||
-webkit-box-flex: 1; /* OLD - iOS 6-, Safari 3.1-6 */
|
||||
-moz-box-flex: 1; /* OLD - Firefox 19- */
|
||||
-webkit-flex: 1; /* Chrome */
|
||||
|
@ -378,12 +378,10 @@ float:left;
|
|||
flex-direction: row;
|
||||
border-top: 1px solid #AAAAAA;
|
||||
width:100%;
|
||||
max-height:34px;
|
||||
background: url(MMCCicon_link.png) no-repeat 6px 5px;
|
||||
background-size:24px 24px;
|
||||
max-height:48px;
|
||||
}
|
||||
|
||||
.CardOnGraph .best_in_place_link {
|
||||
.attachments a {
|
||||
-webkit-box-flex: 1; /* OLD - iOS 6-, Safari 3.1-6 */
|
||||
-moz-box-flex: 1; /* OLD - Firefox 19- */
|
||||
-webkit-flex: 1; /* Chrome */
|
||||
|
@ -399,30 +397,58 @@ float:left;
|
|||
line-height: 16px;
|
||||
}
|
||||
|
||||
.best_in_place_link input{
|
||||
.addAttachment div {
|
||||
display: inline-block;
|
||||
width: 72px;
|
||||
height: 23px;
|
||||
text-align: center;
|
||||
padding-top: 25px;
|
||||
font-size: 12px;
|
||||
color: #9e9e9e;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.addAttachment div:hover {
|
||||
color: #616161;
|
||||
}
|
||||
|
||||
.addLink div {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#addLinkBack {
|
||||
height: 48px;
|
||||
width: 48px;
|
||||
cursor: pointer;
|
||||
}
|
||||
#addLinkInput {
|
||||
height: 32px;
|
||||
width: 236px;
|
||||
padding: 8px 16px 8px 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#addLinkInput input{
|
||||
padding: 7px 31px 7px 31px;
|
||||
height: 16px;
|
||||
margin: -1px 0 0 0;
|
||||
border: 0;
|
||||
width: 172px;
|
||||
margin: 0 0 0 0;
|
||||
border: 1px solid #EFEFEF;
|
||||
outline: none;
|
||||
font-size: 16px;
|
||||
line-height: 16px;
|
||||
line-height: 16px;
|
||||
background: white;
|
||||
color: black;
|
||||
font-family: 'LatoLight';
|
||||
}
|
||||
|
||||
.CardOnGraph .go-link {
|
||||
max-width: 34px;
|
||||
height: 34px;
|
||||
background: url(MMCCicon_go.png) no-repeat center center;
|
||||
background-size: 20px 20px;
|
||||
-webkit-box-flex: 1; /* OLD - iOS 6-, Safari 3.1-6 */
|
||||
-moz-box-flex: 1; /* OLD - Firefox 19- */
|
||||
-webkit-flex: 1; /* Chrome */
|
||||
-ms-flex: 1; /* IE 10 */
|
||||
flex: 1; /* NEW, Spec - Opera 12.1, Firefox 20+ */
|
||||
margin-right:12px;
|
||||
#addLinkReset {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 16px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cardSettings {
|
||||
|
|
|
@ -46,6 +46,9 @@
|
|||
.mapPage .mapElement {
|
||||
display: block;
|
||||
}
|
||||
.mapPage .mapElementHidden {
|
||||
display:none;
|
||||
}
|
||||
|
||||
/* loading */
|
||||
|
||||
|
|
|
@ -179,8 +179,8 @@
|
|||
<div class="clearfloat"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="link">
|
||||
{{a_tag}}<span class="best_in_place best_in_place_link" data-url="/topics/{{id}}" data-object="topic" data-nil="{{link_nil}}" data-attribute="link" data-type="input">{{link}}</span>{{close_a_tag}} {{{go_link}}}
|
||||
<div class="attachments">
|
||||
{{{attachments}}}
|
||||
</div>
|
||||
<div class="clearfloat"></div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue