1 |
85ad3d82
|
Assos Assos
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
(function ($) {
|
15 |
|
|
namespace('Drupal.media.popups');
|
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 |
|
|
Drupal.media.popups.mediaBrowser = function (onSelect, globalOptions, pluginOptions, widgetOptions) {
|
42 |
|
|
var options = Drupal.media.popups.mediaBrowser.getDefaults();
|
43 |
|
|
options.global = $.extend({}, options.global, globalOptions);
|
44 |
|
|
options.plugins = pluginOptions;
|
45 |
|
|
options.widget = $.extend({}, options.widget, widgetOptions);
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
var browserSrc = options.widget.src;
|
49 |
|
|
if ($.isArray(browserSrc) && browserSrc.length) {
|
50 |
|
|
browserSrc = browserSrc[browserSrc.length - 1];
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
var params = {};
|
54 |
|
|
$.extend(params, options.global);
|
55 |
|
|
params.plugins = options.plugins;
|
56 |
|
|
|
57 |
|
|
browserSrc += '&' + $.param(params);
|
58 |
|
|
var mediaIframe = Drupal.media.popups.getPopupIframe(browserSrc, 'mediaBrowser');
|
59 |
|
|
|
60 |
|
|
mediaIframe.bind('load', options, options.widget.onLoad);
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
var ok = 'OK';
|
66 |
|
|
var cancel = 'Cancel';
|
67 |
|
|
var notSelected = 'You have not selected anything!';
|
68 |
|
|
|
69 |
|
|
if (Drupal && Drupal.t) {
|
70 |
|
|
ok = Drupal.t(ok);
|
71 |
|
|
cancel = Drupal.t(cancel);
|
72 |
|
|
notSelected = Drupal.t(notSelected);
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
var dialogOptions = options.dialog;
|
77 |
|
|
|
78 |
|
|
dialogOptions.buttons[ok] = function () {
|
79 |
|
|
var selected = this.contentWindow.Drupal.media.browser.selectedMedia;
|
80 |
|
|
if (selected.length < 1) {
|
81 |
|
|
alert(notSelected);
|
82 |
|
|
return;
|
83 |
|
|
}
|
84 |
|
|
onSelect(selected);
|
85 |
|
|
$(this).dialog("close");
|
86 |
|
|
};
|
87 |
|
|
|
88 |
|
|
dialogOptions.buttons[cancel] = function () {
|
89 |
|
|
$(this).dialog("close");
|
90 |
|
|
};
|
91 |
|
|
|
92 |
|
|
Drupal.media.popups.setDialogPadding(mediaIframe.dialog(dialogOptions));
|
93 |
|
|
|
94 |
|
|
mediaIframe.parents(".ui-dialog").find(".ui-dialog-titlebar").remove();
|
95 |
|
|
Drupal.media.popups.overlayDisplace(mediaIframe.parents(".ui-dialog"));
|
96 |
|
|
return mediaIframe;
|
97 |
|
|
};
|
98 |
|
|
|
99 |
|
|
Drupal.media.popups.mediaBrowser.mediaBrowserOnLoad = function (e) {
|
100 |
|
|
var options = e.data;
|
101 |
|
|
if (this.contentWindow.Drupal.media == undefined) return;
|
102 |
|
|
|
103 |
|
|
if (this.contentWindow.Drupal.media.browser.selectedMedia.length > 0) {
|
104 |
|
|
var ok = (Drupal && Drupal.t) ? Drupal.t('OK') : 'OK';
|
105 |
|
|
var ok_func = $(this).dialog('option', 'buttons')[ok];
|
106 |
|
|
ok_func.call(this);
|
107 |
|
|
return;
|
108 |
|
|
}
|
109 |
|
|
};
|
110 |
|
|
|
111 |
|
|
Drupal.media.popups.mediaBrowser.getDefaults = function () {
|
112 |
|
|
return {
|
113 |
|
|
global: {
|
114 |
|
|
types: [],
|
115 |
|
|
activePlugins: []
|
116 |
|
|
},
|
117 |
|
|
widget: {
|
118 |
|
|
src: Drupal.settings.media.browserUrl,
|
119 |
|
|
onLoad: Drupal.media.popups.mediaBrowser.mediaBrowserOnLoad
|
120 |
|
|
},
|
121 |
|
|
dialog: Drupal.media.popups.getDialogOptions()
|
122 |
|
|
};
|
123 |
|
|
};
|
124 |
|
|
|
125 |
|
|
Drupal.media.popups.mediaBrowser.finalizeSelection = function () {
|
126 |
|
|
var selected = this.contentWindow.Drupal.media.browser.selectedMedia;
|
127 |
|
|
if (selected.length < 1) {
|
128 |
|
|
alert(notSelected);
|
129 |
|
|
return;
|
130 |
|
|
}
|
131 |
|
|
onSelect(selected);
|
132 |
|
|
$(this).dialog("close");
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
Drupal.media.popups.mediaStyleSelector = function (mediaFile, onSelect, options) {
|
150 |
|
|
var defaults = Drupal.media.popups.mediaStyleSelector.getDefaults();
|
151 |
|
|
|
152 |
|
|
defaults.src = defaults.src.replace('-media_id-', mediaFile.fid) + '&fields=' + JSON.stringify(mediaFile.fields);
|
153 |
|
|
options = $.extend({}, defaults, options);
|
154 |
|
|
|
155 |
|
|
var mediaIframe = Drupal.media.popups.getPopupIframe(options.src, 'mediaStyleSelector');
|
156 |
|
|
|
157 |
|
|
mediaIframe.bind('load', options, options.onLoad);
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
var ok = 'OK';
|
163 |
|
|
var cancel = 'Cancel';
|
164 |
|
|
var notSelected = 'Very sorry, there was an unknown error embedding media.';
|
165 |
|
|
|
166 |
|
|
if (Drupal && Drupal.t) {
|
167 |
|
|
ok = Drupal.t(ok);
|
168 |
|
|
cancel = Drupal.t(cancel);
|
169 |
|
|
notSelected = Drupal.t(notSelected);
|
170 |
|
|
}
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
var dialogOptions = Drupal.media.popups.getDialogOptions();
|
174 |
|
|
|
175 |
|
|
dialogOptions.buttons[ok] = function () {
|
176 |
|
|
|
177 |
|
|
var formattedMedia = this.contentWindow.Drupal.media.formatForm.getFormattedMedia();
|
178 |
|
|
if (!formattedMedia) {
|
179 |
|
|
alert(notSelected);
|
180 |
|
|
return;
|
181 |
|
|
}
|
182 |
|
|
onSelect(formattedMedia);
|
183 |
|
|
$(this).dialog("close");
|
184 |
|
|
};
|
185 |
|
|
|
186 |
|
|
dialogOptions.buttons[cancel] = function () {
|
187 |
|
|
$(this).dialog("close");
|
188 |
|
|
};
|
189 |
|
|
|
190 |
|
|
Drupal.media.popups.setDialogPadding(mediaIframe.dialog(dialogOptions));
|
191 |
|
|
|
192 |
|
|
mediaIframe.parents(".ui-dialog").find(".ui-dialog-titlebar").remove();
|
193 |
|
|
Drupal.media.popups.overlayDisplace(mediaIframe.parents(".ui-dialog"));
|
194 |
|
|
return mediaIframe;
|
195 |
|
|
};
|
196 |
|
|
|
197 |
|
|
Drupal.media.popups.mediaStyleSelector.mediaBrowserOnLoad = function (e) {
|
198 |
|
|
};
|
199 |
|
|
|
200 |
|
|
Drupal.media.popups.mediaStyleSelector.getDefaults = function () {
|
201 |
|
|
return {
|
202 |
|
|
src: Drupal.settings.media.styleSelectorUrl,
|
203 |
|
|
onLoad: Drupal.media.popups.mediaStyleSelector.mediaBrowserOnLoad
|
204 |
|
|
};
|
205 |
|
|
};
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
Drupal.media.popups.mediaFieldEditor = function (fid, onSelect, options) {
|
223 |
|
|
var defaults = Drupal.media.popups.mediaFieldEditor.getDefaults();
|
224 |
|
|
|
225 |
|
|
defaults.src = defaults.src.replace('-media_id-', fid);
|
226 |
|
|
options = $.extend({}, defaults, options);
|
227 |
|
|
|
228 |
|
|
var mediaIframe = Drupal.media.popups.getPopupIframe(options.src, 'mediaFieldEditor');
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
mediaIframe.bind('load', options, options.onLoad);
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
|
237 |
|
|
var ok = 'OK';
|
238 |
|
|
var cancel = 'Cancel';
|
239 |
|
|
var notSelected = 'Very sorry, there was an unknown error embedding media.';
|
240 |
|
|
|
241 |
|
|
if (Drupal && Drupal.t) {
|
242 |
|
|
ok = Drupal.t(ok);
|
243 |
|
|
cancel = Drupal.t(cancel);
|
244 |
|
|
notSelected = Drupal.t(notSelected);
|
245 |
|
|
}
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
var dialogOptions = Drupal.media.popups.getDialogOptions();
|
249 |
|
|
|
250 |
|
|
dialogOptions.buttons[ok] = function () {
|
251 |
|
|
var formattedMedia = this.contentWindow.Drupal.media.formatForm.getFormattedMedia();
|
252 |
|
|
if (!formattedMedia) {
|
253 |
|
|
alert(notSelected);
|
254 |
|
|
return;
|
255 |
|
|
}
|
256 |
|
|
onSelect(formattedMedia);
|
257 |
|
|
$(this).dialog("close");
|
258 |
|
|
};
|
259 |
|
|
|
260 |
|
|
dialogOptions.buttons[cancel] = function () {
|
261 |
|
|
$(this).dialog("close");
|
262 |
|
|
};
|
263 |
|
|
|
264 |
|
|
Drupal.media.popups.setDialogPadding(mediaIframe.dialog(dialogOptions));
|
265 |
|
|
|
266 |
|
|
mediaIframe.parents(".ui-dialog").find(".ui-dialog-titlebar").remove();
|
267 |
|
|
Drupal.media.popups.overlayDisplace(mediaIframe.parents(".ui-dialog"));
|
268 |
|
|
return mediaIframe;
|
269 |
|
|
};
|
270 |
|
|
|
271 |
|
|
Drupal.media.popups.mediaFieldEditor.mediaBrowserOnLoad = function (e) {
|
272 |
|
|
|
273 |
|
|
};
|
274 |
|
|
|
275 |
|
|
Drupal.media.popups.mediaFieldEditor.getDefaults = function () {
|
276 |
|
|
return {
|
277 |
|
|
|
278 |
|
|
src: '/media/-media_id-/edit?render=media-popup',
|
279 |
|
|
onLoad: Drupal.media.popups.mediaFieldEditor.mediaBrowserOnLoad
|
280 |
|
|
};
|
281 |
|
|
};
|
282 |
|
|
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
|
288 |
|
|
|
289 |
|
|
|
290 |
|
|
|
291 |
|
|
Drupal.media.popups.getDialogOptions = function () {
|
292 |
|
|
return {
|
293 |
|
|
buttons: {},
|
294 |
|
|
dialogClass: 'media-wrapper',
|
295 |
|
|
modal: true,
|
296 |
|
|
draggable: false,
|
297 |
|
|
resizable: false,
|
298 |
|
|
minWidth: 500,
|
299 |
|
|
width: 670,
|
300 |
|
|
height: 280,
|
301 |
|
|
position: 'center',
|
302 |
|
|
overlay: {
|
303 |
|
|
backgroundColor: '#000000',
|
304 |
|
|
opacity: 0.4
|
305 |
|
|
},
|
306 |
|
|
zIndex: 10000,
|
307 |
|
|
close: function (event, ui) {
|
308 |
|
|
$(event.target).remove();
|
309 |
|
|
}
|
310 |
|
|
};
|
311 |
|
|
};
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
|
318 |
|
|
|
319 |
|
|
Drupal.media.popups.setDialogPadding = function (dialogElement) {
|
320 |
|
|
|
321 |
|
|
|
322 |
|
|
|
323 |
|
|
|
324 |
|
|
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
dialogElement.height(dialogElement.dialog('option', 'height'));
|
329 |
|
|
dialogElement.width(dialogElement.dialog('option', 'width'));
|
330 |
|
|
};
|
331 |
|
|
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
Drupal.media.popups.getPopupIframe = function (src, id, options) {
|
336 |
|
|
var defaults = {width: '800px', scrolling: 'auto'};
|
337 |
|
|
var options = $.extend({}, defaults, options);
|
338 |
|
|
|
339 |
|
|
return $('<iframe class="media-modal-frame"/>')
|
340 |
|
|
.attr('src', src)
|
341 |
|
|
.attr('width', options.width)
|
342 |
|
|
.attr('id', id)
|
343 |
|
|
.attr('scrolling', options.scrolling);
|
344 |
|
|
};
|
345 |
|
|
|
346 |
|
|
Drupal.media.popups.overlayDisplace = function (dialog) {
|
347 |
|
|
if (parent.window.Drupal.overlay && jQuery.isFunction(parent.window.Drupal.overlay.getDisplacement)) {
|
348 |
|
|
var overlayDisplace = parent.window.Drupal.overlay.getDisplacement('top');
|
349 |
|
|
if (dialog.offset().top < overlayDisplace) {
|
350 |
|
|
dialog.css('top', overlayDisplace);
|
351 |
|
|
}
|
352 |
|
|
}
|
353 |
|
|
}
|
354 |
|
|
|
355 |
|
|
})(jQuery); |