helper.php
5.35 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
class N2ImageHelper extends N2ImageHelperAbstract
{
public static function initLightbox() {
static $inited = false;
if (!$inited) {
JHtml::_('behavior.modal');
$inited = true;
}
}
public static function getLightboxFunction() {
return 'function (callback) {
var jInsertFieldValue = window.jInsertFieldValue;
window.jInsertFieldValue = $.proxy(function (value) {
callback("$/" + value);
this.joomlaModal.hide();
window.jInsertFieldValue = jInsertFieldValue;
}, this);
this.joomlaModal = new NextendModal({
zero: {
fit: true,
size: [
980,
680
],
title: "' . n2_('Media Library') . '",
controls: [\'<a href="#" class="n2-a n2-uc n2-h5">Use legacy image selector</a>\'],
content: \'\',
fn: {
show: function () {
this.content.append(nextend.browse.getNode("single", $.proxy(function(image){
callback(image);
this.hide(null);
window.jInsertFieldValue = jInsertFieldValue;
}, this)));
this.controls.find(".n2-a")
.on("click", $.proxy(function (e) {
e.preventDefault();
this.loadPane("legacy");
}, this));
}
}
},
legacy: {
size: [
920,
680
],
back: "zero",
title: "' . n2_('Images') . '",
content: \'<iframe src="index.php?option=com_media&view=images&tmpl=component&asset=com_content&author=&fieldid=notused&folder=" width="900" height="590" frameborder="0" style="margin:10px -10px 10px -10px;"></iframe>\'
}
}, true);
}';
}
public static function getLightboxMultipleFunction() {
return 'function (callback) {
var jInsertFieldValue = window.jInsertFieldValue;
window.jInsertFieldValue = $.proxy(function (value) {
callback([{
image: "$/" + value,
title: value,
description: ""
}]);
this.joomlaModal.hide();
window.jInsertFieldValue = jInsertFieldValue;
}, this);
this.joomlaModal = new NextendModal({
zero: {
fit: true,
size: [
980,
680
],
title: "' . n2_('Media Library') . '",
controlsClass: "n2-modal-controls-side",
controls: [\'<a href="#" class="n2-a n2-uc n2-h5">Use legacy image selector</a>\', \'<a href="#" class="n2-button n2-button-normal n2-button-l n2-button-green n2-h4 n2-uc">' . n2_('Select') . '</a>\'],
content: \'\',
fn: {
show: function () {
this.content.append(nextend.browse.getNode("multiple"));
this.controls.find(".n2-button-green")
.on("click", $.proxy(function (e) {
e.preventDefault();
var selected = nextend.browse.getSelected(),
images = [];
for(var i = 0; i < selected.length; i++){
images[i] = {
image: selected[i],
title: selected[i].split("/").pop(),
description: ""
};
}
this.hide(e);
callback(images);
window.jInsertFieldValue = jInsertFieldValue;
}, this));
this.controls.find(".n2-a")
.on("click", $.proxy(function (e) {
e.preventDefault();
this.loadPane("legacy");
}, this));
}
}
},
legacy: {
size: [
920,
680
],
back: "zero",
title: "' . n2_('Images') . '",
content: \'<iframe src="index.php?option=com_media&view=images&tmpl=component&asset=com_content&author=&fieldid=notused&folder=" width="900" height="590" frameborder="0" style="margin:10px -10px 10px -10px;"></iframe>\'
}
}, true);
}';
}
}