blob: b709af05ecf5951f93587c70f67271e353a7dd39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
elgg.provide('elgg.embed');
elgg.embed.init = function() {
// inserts the embed content into the textarea
$(".embed-wrapper .elgg-list-item").live('click', elgg.embed.insert);
// caches the current textarea id
$(".embed-control").live('click', function() {
var classes = $(this).attr('class');
var class = classes.split(/[, ]+/).pop();
var textAreaId = class.substr(class.indexOf('embed-control-') + "embed-control-".length);
elgg.embed.textAreaId = textAreaId;
});
// special pagination helper for lightbox
$('.embed-wrapper .elgg-pagination a').live('click', elgg.embed.pagination);
}
/**
* Inserts data attached to an embed list item in textarea
*
* @todo generalize lightbox closing and wysiwyg refreshing
*
* @param {Object} event
* @return void
*/
elgg.embed.insert = function(event) {
var textAreaId = elgg.embed.textAreaId;
var content = $(this).data('embed_code');
$('#' + textAreaId).val($('#' + textAreaId).val() + ' ' + content + ' ');
<?php echo elgg_view('embed/custom_insert_js'); ?>
$.fancybox.close();
event.preventDefault();
}
/**
* Loads the next chunk of content within the lightbox
*
* @param {Object} event
* @return void
*/
elgg.embed.pagination = function(event) {
$('.embed-wrapper').parent().load($(this).attr('href'));
event.preventDefault();
}
elgg.register_hook_handler('init', 'system', elgg.embed.init);
|