callbacks now working - incluing to update card at top of topic view pages
This commit is contained in:
parent
d316df3192
commit
8f13413ab7
2 changed files with 34 additions and 8 deletions
|
@ -575,6 +575,7 @@ function onCreateLabelHandler(domElement, node) {
|
||||||
<span class="best_in_place best_in_place_link" \
|
<span class="best_in_place best_in_place_link" \
|
||||||
data-url="/topics/$_id_$" \
|
data-url="/topics/$_id_$" \
|
||||||
data-object="topic" \
|
data-object="topic" \
|
||||||
|
data-nil="$_link_nil_$" \
|
||||||
data-attribute="link" \
|
data-attribute="link" \
|
||||||
data-activator=".topic_$_id_$ .edit-link" \
|
data-activator=".topic_$_id_$ .edit-link" \
|
||||||
data-type="input">$_link_$</span> \
|
data-type="input">$_link_$</span> \
|
||||||
|
@ -610,18 +611,18 @@ function onCreateLabelHandler(domElement, node) {
|
||||||
html = html.replace(/\$_name_\$/g, node.name);
|
html = html.replace(/\$_name_\$/g, node.name);
|
||||||
html = html.replace(/\$_userid_\$/g, node.getData("userid"));
|
html = html.replace(/\$_userid_\$/g, node.getData("userid"));
|
||||||
html = html.replace(/\$_username_\$/g, node.getData("username"));
|
html = html.replace(/\$_username_\$/g, node.getData("username"));
|
||||||
|
html = html.replace(/\$_metacode_choices_\$/g, metacode_choices);
|
||||||
|
html = html.replace(/\$_link_\$/g, node.getData("link"));
|
||||||
|
|
||||||
var desc_nil = "<span class='gray'>Click to add description.</span>";
|
var desc_nil = "<span class='gray'>Click to add description.</span>";
|
||||||
html = html.replace(/\$_desc_nil_\$/g, desc_nil);
|
html = html.replace(/\$_desc_nil_\$/g, desc_nil);
|
||||||
if (node.getData("desc") == "" && userid != null) {
|
if (node.getData("desc") == "" && userid != null) {
|
||||||
|
//logged in but desc isn't there so it's invisible
|
||||||
html = html.replace(/\$_desc_\$/g, desc_nil);
|
html = html.replace(/\$_desc_\$/g, desc_nil);
|
||||||
} else {
|
} else {
|
||||||
html = html.replace(/\$_desc_\$/g, node.getData("desc"));
|
html = html.replace(/\$_desc_\$/g, node.getData("desc"));
|
||||||
}
|
}
|
||||||
|
|
||||||
html = html.replace(/\$_link_\$/g, node.getData("link"));
|
|
||||||
html = html.replace(/\$_metacode_choices_\$/g, metacode_choices);
|
|
||||||
|
|
||||||
var showCard = document.createElement('div');
|
var showCard = document.createElement('div');
|
||||||
showCard.className = 'showcard topic_' + node.id;
|
showCard.className = 'showcard topic_' + node.id;
|
||||||
showCard.innerHTML = html;
|
showCard.innerHTML = html;
|
||||||
|
@ -649,7 +650,7 @@ function onCreateLabelHandler(domElement, node) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//$(showCard).find('.scroll').mCustomScrollbar();
|
$(showCard).find('.scroll').mCustomScrollbar();
|
||||||
|
|
||||||
// Create a 'name' button and add it to the main node label
|
// Create a 'name' button and add it to the main node label
|
||||||
var nameContainer = document.createElement('span'),
|
var nameContainer = document.createElement('span'),
|
||||||
|
@ -708,13 +709,22 @@ function onCreateLabelHandler(domElement, node) {
|
||||||
$('.name.topic_' + node.id + ' .nodeOptions').css('display','none');
|
$('.name.topic_' + node.id + ' .nodeOptions').css('display','none');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//jQuery selector for the card thing at the top of a topic view
|
||||||
|
//only works if we're editing the topic whose page we are on
|
||||||
|
//e.g. on /topics/1 you only need to update .focus.topic_1
|
||||||
|
var topcard = '.focus.topic_' + node.id;
|
||||||
|
|
||||||
//bind callbacks
|
//bind best_in_place ajax callbacks
|
||||||
$(showCard).find('.type.best_in_place').bind("ajax:success", function() {
|
$(showCard).find('.best_in_place_metacode')
|
||||||
|
.bind("ajax:success", function() {
|
||||||
var metacode = $(this).html();
|
var metacode = $(this).html();
|
||||||
|
//changing img alt, img src for top card (topic view page)
|
||||||
|
//and on-canvas card. Also changing image of node
|
||||||
$(showCard).find('img.icon').attr('alt', metacode);
|
$(showCard).find('img.icon').attr('alt', metacode);
|
||||||
$(showCard).find('img.icon').attr('src', imgArray[metacode].src);
|
$(showCard).find('img.icon').attr('src', imgArray[metacode].src);
|
||||||
|
$(topcard + ' img').attr('alt', metacode);
|
||||||
|
$(topcard + ' img').attr('src', imgArray[metacode].src);
|
||||||
|
$(topcard + ' .focusleft p').html(metacode);
|
||||||
node.setData("metacode", metacode);
|
node.setData("metacode", metacode);
|
||||||
Mconsole.plot();
|
Mconsole.plot();
|
||||||
});
|
});
|
||||||
|
@ -722,6 +732,18 @@ function onCreateLabelHandler(domElement, node) {
|
||||||
$(showCard).find('.best_in_place_name').bind("ajax:success", function() {
|
$(showCard).find('.best_in_place_name').bind("ajax:success", function() {
|
||||||
var name = $(this).html();
|
var name = $(this).html();
|
||||||
$(nameContainer).find('.label').html(name);
|
$(nameContainer).find('.label').html(name);
|
||||||
|
$(topcard + ' .focusmiddle .title-text').html(name);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(showCard).find('.best_in_place_desc').bind("ajax:success", function() {
|
||||||
|
var desc = $(this).html();
|
||||||
|
$(topcard + ' .focusmiddle p').html(desc);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(showCard).find('.best_in_place_link').bind("ajax:success", function() {
|
||||||
|
var link = $(this).html();
|
||||||
|
$(topcard + ' .focusright a').html(link);
|
||||||
|
$(topcard + ' .focusright a').attr('href', link);
|
||||||
});
|
});
|
||||||
|
|
||||||
}//onCreateLabelHandler
|
}//onCreateLabelHandler
|
||||||
|
|
|
@ -95,3 +95,7 @@ line-height: 24px;}
|
||||||
.gray {
|
.gray {
|
||||||
color: #999999;
|
color: #999999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.edit-link {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue