mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
- Fix Alpine.js "function not defined" errors by adding typeof checks with fallbacks - Fix "Invalid left-hand side in assignment" error by replacing x-model with manual binding - Add Notebook namespace initialization to prevent "Notebook is not defined" errors - Add defensive checks for missing jQuery plugins (iconpicker, modal) - Ensure all Alpine.js expressions gracefully degrade when context unavailable - Timeline editor now functions without JavaScript console errors 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
55 lines
1.8 KiB
Plaintext
55 lines
1.8 KiB
Plaintext
$(document).ready(function() {
|
|
// Check if iconpicker plugin is available
|
|
if (typeof $.fn.iconpicker === 'undefined') {
|
|
console.warn('iconpicker plugin not loaded, skipping iconpicker initialization');
|
|
return;
|
|
}
|
|
|
|
$('.iconpicker-input').iconpicker({
|
|
icons: [
|
|
<% MATERIAL_ICONS.each do |icon_name| %>
|
|
{ title: "<%= icon_name %>", searchTerms: ["<%= icon_name %>"] },
|
|
<% end %>
|
|
], // list of icon objects [{title:String, searchTerms:String}]. By default, all Font Awesome icons are included.
|
|
fullClassFormatter: function (val) {
|
|
return 'material-icons ' + val;
|
|
}}
|
|
);
|
|
$(document).on('click','.iconpicker-item', function(e){
|
|
e.preventDefault();
|
|
return false;
|
|
});
|
|
|
|
$('.sortable').sortable({
|
|
axis: 'y',
|
|
cursor: 'move',
|
|
handle: '.sortable-handle',
|
|
|
|
update: function (event, ui) {
|
|
var dragged_element = $(ui.item[0]);
|
|
|
|
$.ajax({
|
|
type: "PUT",
|
|
dataType: "json",
|
|
url: '/plan/content/sort',
|
|
data: {
|
|
content_id: dragged_element.data('content-id'),
|
|
intended_position: dragged_element.index() - 1,
|
|
sortable_class: dragged_element.parent().data('sortable-class')
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
$('.js-update-field-name').click(function (e) {
|
|
var new_field_name = $(this).parent().find('.js-new-field-name').val();
|
|
var field_label = $(this).closest('li').find('.collapsible-header > .js-field-label');
|
|
field_label.text(new_field_name);
|
|
});
|
|
|
|
$('.js-update-category-name').click(function (e) {
|
|
var new_category_name = $(this).parent().find('.js-new-category-name').val();
|
|
var category_label = $(this).closest('.js-category-container').find('.js-category-label');
|
|
category_label.text(new_category_name);
|
|
});
|
|
}); |