Skip to content

Commit b7e3339

Browse files
committed
Fixing various small bugs in editorial path
1 parent b52e610 commit b7e3339

File tree

3 files changed

+75
-28
lines changed

3 files changed

+75
-28
lines changed

system/application/views/melons/cantaloupe/css/editorial_path.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,21 @@ body.shortHeader #editorialSidePanel>.affix{
8383
outline: 0;
8484
border: 0;
8585
background-color: transparent;
86-
8786
}
8887
#editorialSidePanel.tall #editorialOutline li>a, #editorialOutline li.active>a, #matchedNodes li>a>small{
8988
color: #000;
9089
}
90+
#matchedNodes>li{
91+
padding-left: 2rem;
92+
}
93+
9194
#matchedNodes li>a{
9295
cursor: pointer;
9396
}
97+
#matchedNodes li .dropdownCaret{
98+
float: left;
99+
margin-left: -2rem;
100+
}
94101
#matchedNodes li>a>small{
95102
margin-right: 1rem;
96103
font-size: 10px;

system/application/views/melons/cantaloupe/editorialpath.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
<span class="text-muted">Content order: </span>
4848
<div class="dropdown" id="contentOrderDropdown">
4949
<button class="btn btn-default dropdown-toggle" type="button" id="contentOrderDropdownButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
50-
<span class="text">Name</span>
5150
<span class="caret pull-right"></span>
51+
<span class="text">Name</span>
5252
</button>
5353
<ul class="dropdown-menu dropdown-menu-left" aria-labelledby="contentOrderDropdownButton">
5454
<li class="active"><a href="#" data-sort="Name">Name</a></li>

system/application/views/melons/cantaloupe/js/scalareditorialpath.jquery.js

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,30 @@
176176
for(var n in res){
177177
var node = res[n];
178178
var splitList = $('<ul></ul>');
179-
179+
180180
var path_of = node.getRelatedNodes('path', 'outgoing');
181181
var features = node.getRelatedNodes('referee', 'outgoing');
182182
var tag_of = node.getRelatedNodes('tag', 'incoming');
183183
var annotates = node.getRelatedNodes('annotation', 'outgoing');
184184
var comments_on = node.getRelatedNodes('comment', 'outgoing');
185185

186-
console.log(path_of,features,tag_of,annotates,comments_on);
186+
187+
var hasRelations = path_of.length + features.length + tag_of.length + annotates.length + annotates.length > 0;
188+
var hasDescription = (typeof node.current.description !== 'undefined' || typeof node.current.content !== 'undefined') &&
189+
(node.current.description !== null || node.current.content !== null) &&
190+
(node.current.description !== '' || node.current.content !== '');
191+
var description = '';
192+
if(hasDescription){
193+
if(typeof node.current.description !== 'undefined' && node.current.description !== null && node.current.description !== ''){
194+
description = node.current.description;
195+
}else{
196+
description = node.current.content;
197+
}
198+
199+
var node_url = scalarapi.model.urlPrefix+node.slug;
200+
description = $('<div>'+description+'</div>').text().substring(0,100)+'... <a class="moreLink" href="'+node_url+'">[More]</a>';
201+
}
202+
187203
if(path_of.length > 0){
188204
var newList = $('<li><strong>Contains</strong><ol></ol></li>').appendTo(splitList).find('ol');
189205
for(var i in path_of){
@@ -262,29 +278,50 @@
262278
}
263279
}
264280

265-
var nodeMatchItemHTML = '<li class="heading_font">'+
266-
'<a class="resultTitle" data-toggle="collapse" data-target="#result_'+node.slug.replace(/\//g, '_')+'" aria-expanded="false" aria-controls="result_'+node.slug.replace(/\//g, '_')+'">'+
267-
'<small class="glyphicon glyphicon-triangle-right" aria-hidden="true"></small>'+node.getDisplayTitle()+
268-
'</a>'+
269-
'<div class="collapse" id="result_'+node.slug.replace(/\//g, '_')+'">'+
270-
(!node.current.content?(
271-
'<div class="content"><a class="moreLink" href="#">[no content]</a></div>'
272-
):(
273-
'<div class="content">'+$('<div>'+node.current.content+'</div>').text().substring(0,100)+'... <a class="moreLink" href="#">[More]</a></div>'
274-
))+
275-
'<div class="relations">'+
276-
'</div>'+
277-
'</div>'+
278-
'</li>';
279-
//var nodeMatchItemHTML = '<li class="'+node.editorialState+'"><a data-node="'+node.slug+'" href="#node_'+node.slug.replace(/\//g, '_')+'">'+node.getDisplayTitle()+'</a></li>';
280-
var $nodeMatchItem = $(nodeMatchItemHTML).appendTo('#matchedNodes');
281-
$nodeMatchItem.find('.relations').append(splitList);
282-
$nodeMatchItem.find('.moreLink').click($.proxy(function(slug, e){
281+
if(hasRelations || hasDescription){
282+
var nodeMatchItemHTML = '<li class="heading_font">'+
283+
'<a class="resultTitle" href="#">'+
284+
'<small class="glyphicon glyphicon-triangle-right dropdownCaret" aria-hidden="true" data-toggle="collapse" data-target="#result_'+node.slug.replace(/\//g, '_')+'" aria-expanded="false" aria-controls="result_'+node.slug.replace(/\//g, '_')+'"></small>'+node.getDisplayTitle()+
285+
'</a>'+
286+
'<div class="collapse" id="result_'+node.slug.replace(/\//g, '_')+'">'+
287+
'<div class="description"></div>'+
288+
'<div class="relations"></div>'+
289+
'</div>'+
290+
'</li>';
291+
console.log(nodeMatchItemHTML);
292+
}else{
293+
var nodeMatchItemHTML = '<li class="heading_font">'+
294+
'<a class="resultTitle" href="#">'+
295+
node.getDisplayTitle()+
296+
'</a>'+
297+
'</li>';
298+
}
299+
300+
var $nodeMatchItem = $(nodeMatchItemHTML).appendTo('#matchedNodes').data('slug',node.slug);
301+
302+
if(hasRelations){
303+
$nodeMatchItem.find('.relations').append(splitList);
304+
}
305+
306+
if(hasDescription){
307+
$nodeMatchItem.find('.description').append('<div class="content">'+description+'</div>');
308+
}
309+
310+
$nodeMatchItem.find('.resultTitle').click(function(e){
283311
e.preventDefault();
284312
$('#editorialSidePanel').addClass('loading_nodes');
285-
window.setTimeout($.proxy(function(slug){ this.scrollToNode(slug,false); },base,slug),1);
313+
var slug = $(this).parents('li').data('slug');
314+
window.setTimeout(function(){base.scrollToNode(slug,false);},1);
315+
return false;
316+
});
317+
318+
319+
$nodeMatchItem.find('.dropdownCaret').click(function(e){
320+
$(this).parents('li').find('.collapse').collapse('toggle');
321+
e.stopPropagation();
286322
return false;
287-
},base, node.slug));
323+
});
324+
288325
$nodeMatchItem.find('.collapse').collapse({toggle:false}).on('show.bs.collapse',function(){
289326
$(this).parents('li').find('.resultTitle small').removeClass('glyphicon-triangle-right').addClass('glyphicon-triangle-bottom');
290327
}).on('hide.bs.collapse',function(){
@@ -668,7 +705,7 @@
668705
'</div>'+
669706
'<div class="col-xs-12 col-sm-4 col-md-3">'+
670707
'<div class="dropdown state_dropdown">'+
671-
'<button class="'+state+' btn state_btn btn-block dropdown-toggle" type="button" id="stateSelectorDropdown_'+node.slug.replace(/\//g, '_')+'" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="btn_text">'+stateName+'</span><span class="caret pull-right"></span></button>'+
708+
'<button class="'+state+' btn state_btn btn-block dropdown-toggle" type="button" id="stateSelectorDropdown_'+node.slug.replace(/\//g, '_')+'" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="caret pull-right"></span><span class="btn_text">'+stateName+'</span></button>'+
672709
'<ul class="dropdown-menu" aria-labelledby="stateSelectorDropdown_'+node.slug.replace(/\//g, '_')+'">';
673710

674711
for(var stateClass in base.node_states){
@@ -730,10 +767,13 @@
730767
$(this).data('unloading',false);
731768
$(this).prop('contenteditable',true);
732769
e.preventDefault();
770+
//TODO: Remove scalarbeta and replace with scalar, once editor changes are released
733771
var editor = CKEDITOR.inline( $(this).attr('id'), {
734772
// Remove scalar plugin for description - also remove codeMirror, as it seems to have issues with inline editing
735-
removePlugins: $(this).hasClass('descriptionContent')?'scalar, codemirror, removeformat, colorbutton, format, specialchar, indent, indentlist, list, blockquote, iframe, codeTag'
736-
:'codemirror, removeformat',
773+
removePlugins: $(this).hasClass('descriptionContent')?'scalar, scalarbeta, codemirror, removeformat, colorbutton, format, specialchar, indent, indentlist, list, blockquote, iframe, codeTag'
774+
:'scalar, codemirror, removeformat',
775+
extraPlugins: $(this).hasClass('descriptionContent')?''
776+
:'scalarbeta',
737777
startupFocus: true,
738778
allowedContent: true,
739779
extraAllowedContent : 'code pre a[*]',
@@ -774,7 +814,7 @@
774814
editor.on('focus', $.proxy(function(editor,base,ev) {
775815
if($(this).hasClass('descriptionContent')) return;
776816
//base.stripPlaceholders($(this));
777-
editor.plugins['scalar'].init(editor);
817+
editor.plugins['scalarbeta'].init(editor);
778818
},this,editor,base));
779819
editor.on('blur',function(){
780820
return false;

0 commit comments

Comments
 (0)