Project

General

Profile

1
var oEditor = window.parent.InnerDialogLoaded() ;
2
var FCK		= oEditor.FCK ;
3

    
4
// Set the language direction.
5
window.document.dir = oEditor.FCKLang.Dir ;
6

    
7
// Set the Skin CSS.
8
document.write( '<link href="' + oEditor.FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
9

    
10
var sAgent = navigator.userAgent.toLowerCase() ;
11

    
12
var is_ie = (sAgent.indexOf("msie") != -1); // FCKBrowserInfo.IsIE
13
var is_gecko = !is_ie; // FCKBrowserInfo.IsGecko
14

    
15
var oMedia = null;
16
var is_new_flvplayer = true;
17

    
18
function window_onload()
19
{
20
	// Translate the dialog box texts.
21
	oEditor.FCKLanguageManager.TranslatePage(document) ;
22

    
23
	// Load the selected element information (if any).
24
	LoadSelection() ;
25

    
26
	// Show/Hide the "Browse Server" button.
27
	GetE('tdBrowse').style.display = oEditor.FCKConfig.FlashBrowser ? '' : 'none' ;
28

    
29
	// Activate the "OK" button.
30
	window.parent.SetOkButton( true ) ;
31
}
32

    
33

    
34
function getSelectedMovie(){
35
	var oSel = null;
36
	oMedia = new Media();
37
	oSel = FCK.Selection.GetParentElement();
38
	// If in "Get the Flash Player" a href, do it again
39
	if (oSel.id != null && !oSel.id.match(/^player[0-9]*$/)) {
40
		oSel = oSel.parentNode;
41
	}
42
	if (oSel.id != null && oSel.id.match(/^player[0-9]*$/)) {
43
		for (var i = 0; i < oSel.childNodes.length; i++) {
44
			if (oSel.childNodes.item(i).nodeName=="DIV") {
45
				var oC=oSel.childNodes.item(i).innerHTML.split(' ');
46
				for (var o = 0; o < oC.length ; o++) {
47
					var tmp=oC[o].split('=');
48
					oMedia.setAttribute(tmp[0],tmp[1]);
49
				}
50
				is_new_flvplayer = false;
51
			}
52
		}
53
	}
54
	return oMedia;
55
}
56

    
57
function updatePlaylistOption () {
58
	if (GetE('selDispPlaylist').value == "right" || GetE('selDispPlaylist').value == "below") {
59
		GetE('chkPLThumbs').disabled=false;
60
		GetE('chkPLThumbs').checked=true;
61
		GetE('txtPLDim').disabled=false;
62
		GetE('txtPLDim').style.background='#ffffff';
63
		GetE('spanDimText').style.display='none';
64
		if (GetE('selDispPlaylist').value == "right") {
65
			GetE('spanDimWText').style.display='';
66
			GetE('spanDimHText').style.display='none';
67
		} else if (GetE('selDispPlaylist').value == "below") {
68
			GetE('spanDimWText').style.display='none';
69
			GetE('spanDimHText').style.display='';
70
		}
71
	} else {
72
		GetE('chkPLThumbs').disabled=true;
73
		GetE('chkPLThumbs').checked=false;
74
		GetE('txtPLDim').value = "";
75
		GetE('txtPLDim').disabled=true;
76
		GetE('txtPLDim').style.background='transparent';
77
		GetE('spanDimText').style.display='';
78
		GetE('spanDimWText').style.display='none';
79
		GetE('spanDimHText').style.display='none';
80
	}
81
}
82

    
83

    
84
function LoadSelection()
85
{
86
	oMedia = new Media();
87
	oMedia = getSelectedMovie();
88
	//alert('test');
89
/*	
90
	alert (
91
		"id: " + oMedia.id +
92
		"\nUrl: " + oMedia.url + 
93
		"\nWidth: " + oMedia.width +
94
		"\nHeight: " + oMedia.height +
95
		"\nQuality: " + oMedia.quality +
96
		"\nScale: " + oMedia.scale +
97
		"\nVSpace: " + oMedia.vspace +
98
		"\nHSpace: " + oMedia.hspace +
99
		"\nAlign: " + oMedia.align +
100
		"\nBgcolor: " + oMedia.bgcolor +
101
		"\nLoop: " + oMedia.loop +
102
		"\nPlay: " + oMedia.play
103
	);
104
*/
105
	GetE('rbFileType').value	= oMedia.fileType;
106
	GetE('txtURL').value    	= oMedia.url;
107
	GetE('txtPlaylist').value   = oMedia.purl;
108
	GetE('txtImgURL').value    	= oMedia.iurl;
109
	GetE('txtWMURL').value    	= oMedia.wmurl;
110
	GetE('txtWidth').value		= oMedia.width;
111
	GetE('txtHeight').value		= oMedia.height;
112
	GetE('chkLoop').checked		= oMedia.loop;
113
	GetE('chkAutoplay').checked	= oMedia.play;
114
	GetE('chkDownload').checked 	= oMedia.downloadable;
115
	GetE('chkFullscreen').checked	= oMedia.fullscreen;
116
	GetE('txtBgColor').value	= oMedia.bgcolor;
117
	GetE('txtToolbarColor').value	= oMedia.toolcolor;
118
	GetE('txtToolbarTxtColor').value	= oMedia.tooltcolor;
119
	GetE('txtToolbarTxtRColor').value	= oMedia.tooltrcolor;
120
	GetE('chkShowNavigation').checked	= oMedia.displayNavigation;
121
	GetE('chkShowDigits').checked	= oMedia.displayDigits;
122
	GetE('selAlign').value		= oMedia.align;
123
	GetE('selDispPlaylist').value = oMedia.dispPlaylist;
124
	GetE('txtRURL').value = oMedia.rurl;
125
	GetE('txtPLDim').value = oMedia.playlistDim;
126
	GetE('chkPLThumbs').checked = oMedia.playlistThumbs;
127

    
128
	//updatePreview();
129
}
130

    
131
//#### The OK button was hit.
132
function Ok()
133
{
134
	var rbFileTypeVal = "single";
135
	if (GetE('rbFileType').checked == false) {
136
		rbFileTypeVal = "list";
137
	}
138

    
139
	if ( rbFileTypeVal == "single") {
140
		if ( GetE('txtURL').value.length == 0 )
141
		{
142
			GetE('txtURL').focus() ;	
143

    
144
			alert( oEditor.FCKLang.DlgFLVPlayerAlertUrl ) ;
145
			return false ;
146
		}
147
	}
148

    
149
	if (rbFileTypeVal == "list") {
150
		if ( GetE('txtPlaylist').value.length == 0 )
151
		{
152
			GetE('txtPlaylist').focus() ;	
153

    
154
			alert( oEditor.FCKLang.DlgFLVPlayerAlertPlaylist ) ;
155
			return false ;
156
		}
157
	}
158

    
159

    
160
	if ( GetE('txtWidth').value.length == 0 )
161
	{
162
		GetE('txtWidth').focus() ;	
163

    
164
		alert( oEditor.FCKLang.DlgFLVPlayerAlertWidth ) ;
165
		return false ;
166
	}
167

    
168
	if ( GetE('txtHeight').value.length == 0 )
169
	{
170
		GetE('txtHeight').focus() ;	
171

    
172
		alert( oEditor.FCKLang.DlgFLVPlayerAlertHeight ) ;
173
		return false ;
174
	}
175

    
176

    
177
	var e = (oMedia || new Media()) ;
178

    
179
	updateMovie(e) ;
180

    
181
	// Replace or insert?
182
	if (!is_new_flvplayer) {
183
		// Find parent..
184
	        oSel = FCK.Selection.GetParentElement();
185
		while (oSel != null && !oSel.id.match(/^player[0-9]*-parent$/)) {
186
			oSel=oSel.parentNode;
187
		}
188
		// Found - So replace
189
		if (oSel != null) {
190
			oSel.parentNode.removeChild(oSel);
191
			FCK.InsertHtml(e.getInnerHTML());
192
		}
193
	} else {
194
		FCK.InsertHtml(e.getInnerHTML());
195
	}
196

    
197
	return true ;
198
}
199

    
200

    
201
function updateMovie(e){
202
	e.fileType = GetE('rbFileType').value;
203
	e.url = GetE('txtURL').value;
204
	e.purl = GetE('txtPlaylist').value;
205
	e.iurl = GetE('txtImgURL').value;
206
	e.wmurl = GetE('txtWMURL').value;
207
	e.bgcolor = GetE('txtBgColor').value;
208
	e.toolcolor = GetE('txtToolbarColor').value;
209
	e.tooltcolor = GetE('txtToolbarTxtColor').value;
210
	e.tooltrcolor = GetE('txtToolbarTxtRColor').value;
211
	e.width = (isNaN(GetE('txtWidth').value)) ? 0 : parseInt(GetE('txtWidth').value);
212
	e.height = (isNaN(GetE('txtHeight').value)) ? 0 : parseInt(GetE('txtHeight').value);
213
	e.loop = (GetE('chkLoop').checked) ? 'true' : 'false';
214
	e.play = (GetE('chkAutoplay').checked) ? 'true' : 'false';
215
	e.downloadable = (GetE('chkDownload').checked) ? 'true' : 'false';
216
	e.fullscreen = (GetE('chkFullscreen').checked) ? 'true' : 'false';
217
	e.displayNavigation = (GetE('chkShowNavigation').checked) ? 'true' : 'false';
218
	e.displayDigits = (GetE('chkShowDigits').checked) ? 'true' : 'false';
219
	e.align =	GetE('selAlign').value;
220
	e.dispPlaylist =	GetE('selDispPlaylist').value;
221
	e.rurl = GetE('txtRURL').value;
222
	e.playlistDim = GetE('txtPLDim').value;
223
	e.playlistThumbs = (GetE('chkPLThumbs').checked) ? 'true' : 'false';
224
}
225

    
226

    
227
function BrowseServer()
228
{
229
	OpenServerBrowser(
230
		'flv',
231
		oEditor.FCKConfig.MediaBrowserURL,
232
		oEditor.FCKConfig.MediaBrowserWindowWidth,
233
		oEditor.FCKConfig.MediaBrowserWindowHeight ) ;
234
}
235

    
236

    
237
function LnkBrowseServer()
238
{
239
	OpenServerBrowser(
240
		'link',
241
		oEditor.FCKConfig.LinkBrowserURL,
242
		oEditor.FCKConfig.LinkBrowserWindowWidth,
243
		oEditor.FCKConfig.LinkBrowserWindowHeight ) ;
244
}
245

    
246
function Lnk2BrowseServer()
247
{
248
	OpenServerBrowser(
249
		'link2',
250
		oEditor.FCKConfig.LinkBrowserURL,
251
		oEditor.FCKConfig.LinkBrowserWindowWidth,
252
		oEditor.FCKConfig.LinkBrowserWindowHeight ) ;
253
}
254

    
255
function img1BrowseServer()
256
{
257
	OpenServerBrowser(
258
		'img1',
259
		oEditor.FCKConfig.ImageBrowserURL,
260
		oEditor.FCKConfig.ImageBrowserWindowWidth,
261
		oEditor.FCKConfig.ImageBrowserWindowHeight ) ;
262
}
263

    
264
function img2BrowseServer()
265
{
266
	OpenServerBrowser(
267
		'img2',
268
		oEditor.FCKConfig.ImageBrowserURL,
269
		oEditor.FCKConfig.ImageBrowserWindowWidth,
270
		oEditor.FCKConfig.ImageBrowserWindowHeight ) ;
271
}
272

    
273

    
274
function OpenServerBrowser( type, url, width, height )
275
{
276
	sActualBrowser = type ;
277
	OpenFileBrowser( url, width, height ) ;
278
}
279

    
280
var sActualBrowser ;
281

    
282

    
283
function SetUrl( url ) {
284
	if ( sActualBrowser == 'flv' ) {
285
		document.getElementById('txtURL').value = url ;
286
		GetE('txtHeight').value = GetE('txtWidth').value = '' ;
287
	} else if ( sActualBrowser == 'link' ) {
288
		document.getElementById('txtPlaylist').value = url ;
289
	} else if ( sActualBrowser == 'link2' ) {
290
		document.getElementById('txtRURL').value = url ;
291
	} else if ( sActualBrowser == 'img1' ) {
292
		document.getElementById('txtImgURL').value = url ;
293
	} else if ( sActualBrowser == 'img2' ) {
294
		document.getElementById('txtWMURL').value = url ;
295
	}
296
}
297

    
298

    
299

    
300

    
301
var Media = function (o){
302
	this.fileType = '';
303
	this.url = '';
304
	this.purl = '';
305
	this.iurl = '';
306
	this.wmurl = '';
307
	this.width = '';
308
	this.height = '';
309
	this.loop = '';
310
	this.play = '';
311
	this.downloadable = '';
312
	this.fullscreen = true;
313
	this.bgcolor = '';
314
	this.toolcolor = '';
315
	this.tooltcolor = '';
316
	this.tooltrcolor = '';
317
	this.displayNavigation = true;
318
	this.displayDigits = true;
319
	this.align = '';
320
	this.dispPlaylist = '';
321
	this.rurl = '';
322
	this.playlistDim = '';
323
	this.playlistThumbs = '';
324

    
325
	if (o) 
326
		this.setObjectElement(o);
327
};
328

    
329
Media.prototype.setObjectElement = function (e){
330
	if (!e) return ;
331
	this.width = GetAttribute( e, 'width', this.width );
332
	this.height = GetAttribute( e, 'height', this.height );
333
};
334

    
335
Media.prototype.setAttribute = function(attr, val) {
336
	if (val=="true") {
337
		this[attr]=true;
338
	} else if (val=="false") {
339
		this[attr]=false;
340
	} else {
341
		this[attr]=val;
342
	}
343
};
344

    
345
Media.prototype.getInnerHTML = function (objectId){
346
	var randomnumber = Math.floor(Math.random()*1000001);
347
	var thisWidth = this.width;
348
	var thisHeight = this.height;
349

    
350
	var thisMediaType = "single";
351
	if (GetE('rbFileType').checked == false) {
352
		thisMediaType = "mpl";
353
	}
354

    
355
	// Align
356
	var cssalign='';
357
	var cssfloat='';
358
	if (this.align=="center") {
359
		cssalign='margin-left: auto;margin-right: auto;';
360
	} else if (this.align=="right") {
361
		cssfloat='float: right;';
362
	} else if (this.align=="left") {
363
		cssfloat='float: left;';
364
	}
365

    
366
	var s = "";
367
	//s+= '<p>\n';
368
	s+= '<div id="player' + randomnumber + '-parent" style="text-align: center;' + cssfloat + '">\n';
369
	s+= '<div style="border-style: none; height: ' + thisHeight + 'px; width: ' + thisWidth + 'px; overflow: hidden; background-color: rgb(220, 220, 220); background-image: url(' + oEditor.FCKConfig.PluginsPath + 'flvPlayer/flvPlayer.gif); background-repeat:no-repeat; background-position:center;' + cssalign + '">';
370
	s+= '<script src="' + oEditor.FCKConfig.PluginsPath + 'flvPlayer/swfobject.js" type="text/javascript"></script>\n';
371
	s+= '<div id="player' + randomnumber + '">';
372
	s+= '<a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.';
373
	// Moved after info - Added width,height,overflow for MSIE7
374
	s+= '<div id="player' + randomnumber + '-config" style="display: none;visibility: hidden;width: 0px;height:0px;overflow: hidden;">';
375
	// Save settings
376
	for (var i in this) {
377
		if (!i || !this[i]) continue;
378
	        if (!i.match(/(set|get)/)) {
379
        	        s+=i+"="+this[i]+" ";
380
        	}
381
	}
382
	s+= '</div>';
383
	s+= '</div>';
384
	s+= '<script type="text/javascript">\n';
385
	//s+= '	//NOTE: FOR LIST OF POSSIBLE SETTINGS GOTO http://www.jeroenwijering.com/extras/readme.html\n';
386
	s+= '	var s1 = new SWFObject("' + oEditor.FCKConfig.PluginsPath + 'flvPlayer/mediaplayer.swf","' + thisMediaType + '","' + thisWidth + '","' + thisHeight + '","7");\n';
387
	s+= '	s1.addVariable("width","' + thisWidth + '");\n';
388
	s+= '	s1.addVariable("height","' + thisHeight + '");\n';
389
	s+= '	s1.addVariable("autostart","' + this.play + '");\n';
390

    
391
	if (thisMediaType == 'mpl') {
392
		s+= '	s1.addVariable("file","' + this.purl + '");\n';
393
		s+= '	s1.addVariable("autoscroll","true");\n';
394
		s+= '	s1.addParam("allowscriptaccess","always");\n';
395

    
396
		var dispWidth = thisWidth
397
		var dispHeight = thisHeight
398
		var dispThumbs = false
399

    
400
		if (this.dispPlaylist != "none") {
401
			if (this.dispPlaylist == "right") {
402

    
403
				if (this.playlistDim.length > 0) {
404
					dispWidth = thisWidth - this.playlistDim
405
					if (this.playlistDim < 100) {
406
						dispThumbs = false
407
					} else {
408
						dispThumbs = true
409
					}
410
				} else {
411
					if (thisWidth >= 550) {
412
						dispWidth = thisWidth - 200
413
						dispThumbs = true
414
					} else if (thisWidth >= 450) {
415
						dispWidth = thisWidth - 100
416
						dispThumbs = false
417
					} else if (thisWidth >= 350) {
418
						dispWidth = thisWidth - 50
419
						dispThumbs = false
420
					}
421
				}
422

    
423
				s+= '	s1.addVariable("displaywidth","' + dispWidth + '");\n';
424
			} else if (this.dispPlaylist == "below") {
425
				dispThumbs = true
426
				
427
				if (this.playlistDim.length > 0) {
428
					dispHeight = thisWidth - this.playlistDim
429
				} else {
430
					if (thisHeight >= 550) {
431
						dispHeight = thisWidth - 200
432
					} else if (thisHeight >= 450) {
433
						dispHeight = thisHeight - 150
434
					} else if (thisHeight >= 350) {
435
						dispHeight = thisHeight - 100
436
					}
437
				}
438

    
439
				s+= '	s1.addVariable("displayheight","' + dispHeight + '");\n';
440
			}
441

    
442
			if (this.playlistThumbs == "false") {
443
				dispThumbs = false;
444
			}
445
				
446
			s+= '	s1.addVariable("thumbsinplaylist","' + dispThumbs + '");\n';
447
		}
448

    
449
		s+= '	s1.addVariable("shuffle","false");\n';
450
		if (this.loop == true) {
451
			s+= '	s1.addVariable("repeat","list");\n';
452
		} else {
453
			s+= '	s1.addVariable("repeat","' + this.loop + '");\n';
454
		}
455
		s+= '	//s1.addVariable("transition","bgfade");\n';
456
	} else {
457
		s+= '	s1.addVariable("file","' + this.url + '");\n';
458
		s+= '	s1.addVariable("repeat","' + this.loop + '");\n';
459
		s+= '	s1.addVariable("image","' + this.iurl + '");\n';
460
	}
461

    
462
	s+= '	s1.addVariable("showdownload","' + this.downloadable + '");\n';
463
	s+= '	s1.addVariable("link","' + this.url + '");\n';
464
	s+= '	s1.addParam("allowfullscreen","' + this.fullscreen + '");\n';
465
	s+= '	s1.addVariable("showdigits","' + this.displayDigits + '");\n';
466
	s+= '	s1.addVariable("shownavigation","' + this.displayNavigation + '");\n';
467

    
468
	// SET THE COLOR OF THE TOOLBAR
469
	var colorChoice1 = this.toolcolor
470
	if (colorChoice1.length > 0) {
471
		colorChoice1 = colorChoice1.replace("#","0x")
472
		s+= '	s1.addVariable("backcolor","' + colorChoice1 + '");\n';
473
	}
474
	// SET THE COLOR OF THE TOOLBARS TEXT AND BUTTONS
475
	var colorChoice2 = this.tooltcolor
476
	if (colorChoice2.length > 0) {
477
		colorChoice2 = colorChoice2.replace("#","0x")
478
		s+= '	s1.addVariable("frontcolor","' + colorChoice2 + '");\n';
479
	}
480
	//SET COLOR OF ROLLOVER TEXT AND BUTTONS
481
	var colorChoice3 = this.tooltrcolor
482
	if (colorChoice3.length > 0) {
483
		colorChoice3 = colorChoice3.replace("#","0x")
484
		s+= '	s1.addVariable("lightcolor","' + colorChoice3 + '");\n';
485
	}
486
	//SET COLOR OF BACKGROUND
487
	var colorChoice4 = this.bgcolor
488
	if (colorChoice4.length > 0) {
489
		colorChoice4 = colorChoice4.replace("#","0x")
490
		s+= '	s1.addVariable("screencolor","' + colorChoice4 + '");\n';
491
	}
492

    
493
	s+= '	s1.addVariable("logo","' + this.wmurl + '");\n';
494
	if (this.rurl.length > 0) {
495
		s+= '	s1.addVariable("recommendations","' + this.rurl + '");\n';
496
	}
497

    
498
	//s+= '	//s1.addVariable("largecontrols","true");\n';
499
	//s+= '	//s1.addVariable("bufferlength","3");\n';
500
	//s+= '	//s1.addVariable("audio","http://www.jeroenwijering.com/extras/readme.html");\n';
501

    
502
	s+= '	s1.write("player' + randomnumber + '");\n';
503
	s+= '</script>\n';
504
	s+= '</div>\n';
505
	s+= '</div>\n';
506
	//s+= '</p>\n';
507

    
508
	return s;
509
};
510

    
511

    
512

    
513

    
514

    
515

    
516

    
517

    
518

    
519

    
520

    
521

    
522

    
523

    
524

    
525
function SelectColor1()
526
{
527
	oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', oEditor.FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectBackColor, window ) ;
528
}
529

    
530
function SelectColor2()
531
{
532
	oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', oEditor.FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectToolColor, window ) ;
533
}
534

    
535
function SelectColor3()
536
{
537
	oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', oEditor.FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectToolTextColor, window ) ;
538
}
539

    
540
function SelectColor4()
541
{
542
	oEditor.FCKDialog.OpenDialog( 'FCKDialog_Color', oEditor.FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, SelectToolTextRColor, window ) ;
543
}
544

    
545
function SelectBackColor( color )
546
{
547
	if ( color && color.length > 0 ) {
548
		GetE('txtBgColor').value = color ;
549
		//updatePreview()
550
	}
551
}
552

    
553
function SelectToolColor( color )
554
{
555
	if ( color && color.length > 0 ) {
556
		GetE('txtToolbarColor').value = color ;
557
		//updatePreview()
558
	}
559
}
560

    
561
function SelectToolTextColor( color )
562
{
563
	if ( color && color.length > 0 ) {
564
		GetE('txtToolbarTxtColor').value = color ;
565
		//updatePreview()
566
	}
567
}
568

    
569
function SelectToolTextRColor( color )
570
{
571
	if ( color && color.length > 0 ) {
572
		GetE('txtToolbarTxtRColor').value = color ;
573
		//updatePreview()
574
	}
575
}
(5-5/13)