|
176 | 176 | for(var n in res){
|
177 | 177 | var node = res[n];
|
178 | 178 | var splitList = $('<ul></ul>');
|
179 |
| - |
| 179 | + |
180 | 180 | var path_of = node.getRelatedNodes('path', 'outgoing');
|
181 | 181 | var features = node.getRelatedNodes('referee', 'outgoing');
|
182 | 182 | var tag_of = node.getRelatedNodes('tag', 'incoming');
|
183 | 183 | var annotates = node.getRelatedNodes('annotation', 'outgoing');
|
184 | 184 | var comments_on = node.getRelatedNodes('comment', 'outgoing');
|
185 | 185 |
|
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 | + |
187 | 203 | if(path_of.length > 0){
|
188 | 204 | var newList = $('<li><strong>Contains</strong><ol></ol></li>').appendTo(splitList).find('ol');
|
189 | 205 | for(var i in path_of){
|
|
262 | 278 | }
|
263 | 279 | }
|
264 | 280 |
|
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){ |
283 | 311 | e.preventDefault();
|
284 | 312 | $('#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(); |
286 | 322 | return false;
|
287 |
| - },base, node.slug)); |
| 323 | + }); |
| 324 | + |
288 | 325 | $nodeMatchItem.find('.collapse').collapse({toggle:false}).on('show.bs.collapse',function(){
|
289 | 326 | $(this).parents('li').find('.resultTitle small').removeClass('glyphicon-triangle-right').addClass('glyphicon-triangle-bottom');
|
290 | 327 | }).on('hide.bs.collapse',function(){
|
|
668 | 705 | '</div>'+
|
669 | 706 | '<div class="col-xs-12 col-sm-4 col-md-3">'+
|
670 | 707 | '<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>'+ |
672 | 709 | '<ul class="dropdown-menu" aria-labelledby="stateSelectorDropdown_'+node.slug.replace(/\//g, '_')+'">';
|
673 | 710 |
|
674 | 711 | for(var stateClass in base.node_states){
|
|
730 | 767 | $(this).data('unloading',false);
|
731 | 768 | $(this).prop('contenteditable',true);
|
732 | 769 | e.preventDefault();
|
| 770 | + //TODO: Remove scalarbeta and replace with scalar, once editor changes are released |
733 | 771 | var editor = CKEDITOR.inline( $(this).attr('id'), {
|
734 | 772 | // 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', |
737 | 777 | startupFocus: true,
|
738 | 778 | allowedContent: true,
|
739 | 779 | extraAllowedContent : 'code pre a[*]',
|
|
774 | 814 | editor.on('focus', $.proxy(function(editor,base,ev) {
|
775 | 815 | if($(this).hasClass('descriptionContent')) return;
|
776 | 816 | //base.stripPlaceholders($(this));
|
777 |
| - editor.plugins['scalar'].init(editor); |
| 817 | + editor.plugins['scalarbeta'].init(editor); |
778 | 818 | },this,editor,base));
|
779 | 819 | editor.on('blur',function(){
|
780 | 820 | return false;
|
|
0 commit comments