mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
28 lines
1.1 KiB
Plaintext
28 lines
1.1 KiB
Plaintext
<%= content_for :javascript do %>
|
|
$(document).ready(function() {
|
|
var tribute = new Tribute({
|
|
values: [
|
|
<% @linkables_cache.each do |class_name, collection| %>
|
|
<% linkable_class = class_name.constantize %>
|
|
<% collection.each do |page_name, page_id| %>
|
|
{
|
|
key: "<%= page_name.gsub('"', "\"").gsub("\n", " ").gsub("\r", " ").strip %>",
|
|
value: '[[<%= class_name %>-<%= page_id %>]]',
|
|
color: '<%= linkable_class.color %>',
|
|
icon: '<%= linkable_class.icon %>'
|
|
},
|
|
<% end %>
|
|
<% end %>
|
|
],
|
|
selectTemplate: function (item) {
|
|
// We're overriding the default here so we don't prepend a @
|
|
return item.original.value;
|
|
},
|
|
menuItemTemplate: function (item) {
|
|
return '<i class="material-icons right ' + item.original.color + '-text">' + item.original.icon + '</i>' + item.string;
|
|
},
|
|
spaceSelectsMatch: false
|
|
});
|
|
tribute.attach(document.querySelectorAll('.js-can-mention-pages'));
|
|
});
|
|
<% end %> |