Project

General

Profile

« Previous | Next » 

Revision 7218849a

Added by koszko over 1 year ago

add a mapping/resources installation dialog

View differences:

html/item_preview.js
55 55
    }
56 56
}
57 57

  
58
/* Link click handler used in make_file_link(). */
58 59
async function file_link_clicked(preview_object, file_ref, event)
59 60
{
60 61
    event.preventDefault();
......
71 72
    }
72 73
}
73 74

  
75
/*
76
 * The default function to use to create file preview link. Links it creates can
77
 * be used to view files from IndexedDB.
78
 */
74 79
function make_file_link(preview_object, file_ref)
75 80
{
76 81
    const a = document.createElement("a");
......
82 87
    return a;
83 88
}
84 89

  
85
function resource_preview(resource, preview_object, dialog_context)
90
function resource_preview(resource, preview_object, dialog_context,
91
			  make_link_cb=make_file_link)
86 92
{
87 93
    if (preview_object === undefined)
88 94
	preview_object = clone_template("resource_preview");
......
98 104
    [...preview_object.dependencies.childNodes].forEach(n => n.remove());
99 105
    populate_list(preview_object.dependencies, resource.dependencies);
100 106

  
101
    const link_maker = file_ref => make_file_link(preview_object, file_ref);
107
    const link_maker = file_ref => make_link_cb(preview_object, file_ref);
102 108

  
103 109
    [...preview_object.scripts.childNodes].forEach(n => n.remove());
104 110
    populate_list(preview_object.scripts, resource.scripts.map(link_maker));
......
113 119
}
114 120
#EXPORT resource_preview
115 121

  
116
function mapping_preview(mapping, preview_object, dialog_context)
122
function mapping_preview(mapping, preview_object, dialog_context,
123
			 make_link_cb=make_file_link)
117 124
{
118 125
    if (preview_object === undefined)
119 126
	preview_object = clone_template("mapping_preview");
......
138 145
	}
139 146
    }
140 147

  
141
    const link_maker = file_ref => make_file_link(preview_object, file_ref);
148
    const link_maker = file_ref => make_link_cb(preview_object, file_ref);
142 149

  
143 150
    [...preview_object.copyright.childNodes].forEach(n => n.remove());
144 151
    populate_list(preview_object.copyright,

Also available in: Unified diff