allmedias.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. /**
  2. * @license Copyright (c) 2003-2013, webmote - codeex.cn. All rights reserved.
  3. * For licensing, see http://codeex.cn/
  4. * 2013-2-18 v1.0
  5. */
  6. (function() {
  7. // It is possible to set things in three different places.
  8. // 1. As attributes in the object tag.
  9. // 2. As param tags under the object tag.
  10. // 3. As attributes in the embed tag.
  11. // It is possible for a single attribute to be present in more than one place.
  12. // So let's define a mapping between a sementic attribute and its syntactic
  13. // equivalents.
  14. // Then we'll set and retrieve attribute values according to the mapping,
  15. // instead of having to check and set each syntactic attribute every time.
  16. //
  17. // Reference: http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12701
  18. var ATTRTYPE_OBJECT = 1,
  19. ATTRTYPE_PARAM = 2,
  20. ATTRTYPE_EMBED = 4;
  21. // object 与界面映射词典
  22. var attributesMap = {
  23. allowScriptAccess: [ {type: ATTRTYPE_PARAM, name: 'allowScriptAccess'}, {type: ATTRTYPE_EMBED, name: 'allowScriptAccess'}],
  24. allowFullScreen: [ {type: ATTRTYPE_PARAM, name: 'allowFullScreen'}, {type: ATTRTYPE_EMBED, name: 'allowFullScreen'}],
  25. align: [ {type: ATTRTYPE_OBJECT, name: 'align'}],
  26. bgcolor: [ {type: ATTRTYPE_PARAM, name: 'bgcolor'}, {type: ATTRTYPE_EMBED, name: 'bgcolor'}],
  27. base: [ {type: ATTRTYPE_PARAM, name: 'base'}, {type: ATTRTYPE_EMBED, name: 'base'}],
  28. 'class': [ {type: ATTRTYPE_OBJECT, name: 'class'}, {type: ATTRTYPE_EMBED, name: 'class'}],
  29. classid: [ {type: ATTRTYPE_OBJECT, name: 'classid'}],
  30. codebase: [ {type: ATTRTYPE_OBJECT, name: 'codebase'}],
  31. flashvars: [ {type: ATTRTYPE_PARAM, name: 'flashvars'}, {type: ATTRTYPE_EMBED, name: 'flashvars'}], //add by webmote
  32. height: [ {type: ATTRTYPE_OBJECT, name: 'height'}, {type: ATTRTYPE_EMBED, name: 'height'}],
  33. hSpace: [ {type: ATTRTYPE_OBJECT, name: 'hSpace'}, {type: ATTRTYPE_EMBED, name: 'hSpace'}],
  34. id: [ {type: ATTRTYPE_OBJECT, name: 'id'}],
  35. loop: [ {type: ATTRTYPE_PARAM, name: 'loop'}, {type: ATTRTYPE_EMBED, name: 'loop'}],
  36. mtype: [ {type: ATTRTYPE_OBJECT, name: 'mtype'}, {type: ATTRTYPE_EMBED, name: 'mtype'}], //add by webmote
  37. menu: [ {type: ATTRTYPE_PARAM, name: 'menu'}, {type: ATTRTYPE_EMBED, name: 'menu'}],
  38. name: [ {type: ATTRTYPE_EMBED, name: 'name'}],
  39. pluginspage: [ {type: ATTRTYPE_EMBED, name: 'pluginspage'}],
  40. play: [ {type: ATTRTYPE_PARAM, name: 'play'}, {type: ATTRTYPE_EMBED, name: 'autostart'}],
  41. quality: [ {type: ATTRTYPE_PARAM, name: 'quality'}, {type: ATTRTYPE_EMBED, name: 'quality'}],
  42. src: [ {type: ATTRTYPE_PARAM, name: 'movie'}, {type: ATTRTYPE_EMBED, name: 'rsrc'}, {type: ATTRTYPE_OBJECT, name: 'data'}],
  43. scale: [ {type: ATTRTYPE_PARAM, name: 'scale'}, {type: ATTRTYPE_EMBED, name: 'scale'}],
  44. style: [ {type: ATTRTYPE_OBJECT, name: 'style'}, {type: ATTRTYPE_EMBED, name: 'style'}],
  45. salign: [ {type: ATTRTYPE_PARAM, name: 'salign'}, {type: ATTRTYPE_EMBED, name: 'salign'}],
  46. seamlesstabbing: [ {type: ATTRTYPE_PARAM, name: 'seamlesstabbing'}, {type: ATTRTYPE_EMBED, name: 'seamlesstabbing'}],
  47. type: [ {type: ATTRTYPE_OBJECT, name: 'type'},{type: ATTRTYPE_EMBED, name: 'type'}],
  48. vSpace: [ {type: ATTRTYPE_OBJECT, name: 'vSpace'}, {type: ATTRTYPE_EMBED, name: 'vSpace'}],
  49. width: [ {type: ATTRTYPE_OBJECT, name: 'width'}, {type: ATTRTYPE_EMBED, name: 'width'}],
  50. wmode: [ {type: ATTRTYPE_PARAM, name: 'wmode'}, {type: ATTRTYPE_EMBED, name: 'wmode'}],
  51. };
  52. //赋默认值
  53. attributesMap[ 'mtype' ][ 0 ][ 'default' ] = attributesMap[ 'mtype' ][ 1 ][ 'default' ] = "allmedias";
  54. var names = [ 'allowFullScreen', 'play', 'loop', 'menu' ];
  55. for ( i = 0; i < names.length; i++ )
  56. attributesMap[ names[ i ] ][ 0 ][ 'default' ] = attributesMap[ names[ i ] ][ 1 ][ 'default' ] = true;
  57. attributesMap['seamlesstabbing'][0]['default'] = attributesMap['seamlesstabbing'][ 1 ][ 'default' ] = true;
  58. var mediaTypes = [ //video/x-ms-asf-plugin application/x-mplayer2
  59. {player:'wmpvideo',idx:0,
  60. types: ['video/x-ms-asf-plugin','video/x-ms-asf-plugin','video/x-ms-asf-plugin','video/x-ms-asf-plugin'],
  61. classid: 'clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6',
  62. codebase: 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
  63. pluginspage: 'http://activex.microsoft.com/',
  64. exts:['wmv','mpeg','asf','avi']
  65. },
  66. {player:'wmpaudio',idx:0,
  67. types: ['video/x-ms-asf-plugin','video/x-ms-asf-plugin','video/x-ms-asf-plugin','video/x-ms-asf-plugin','video/x-ms-asf-plugin','video/x-ms-asf-plugin'],
  68. classid: 'clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6',
  69. codebase: 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
  70. pluginspage: 'http://activex.microsoft.com/',
  71. exts:['wma','m4a','wav','mpg','mid','mp3']
  72. },
  73. {player:'rpvideo',idx:0,
  74. types: ['audio/x-pn-realaudio-plugin','audio/x-pn-realaudio-plugin','audio/x-pn-realaudio-plugin'],
  75. classid: 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA',
  76. codebase: 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
  77. pluginspage: 'http://download.macromedia.com',
  78. exts:['rm','rmvb','ra']
  79. },
  80. {player:'qmvideo',idx:0,types: ['video/quicktime'],
  81. classid: 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
  82. codebase: 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
  83. pluginspage: 'http://www.apple.com/qtactivex',
  84. exts:['qt']
  85. },
  86. {player:'flashvideo',idx:0,types: ['application/x-shockwave-flash','application/x-shockwave-flash','application/x-shockwave-flash', 'application/x-shockwave-flash','application/x-shockwave-flash'],
  87. classid: 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
  88. codebase: 'http://download.macroallMedias.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
  89. pluginspage: 'http://www.macroallMedias.com/go/getflashplayer',
  90. src: 'plugins/allmedias/jwplayer.swf', //相对插件路径
  91. exts:['flv','mov','mp4','m4v','f4v']
  92. },/*
  93. {player:'flashaudio',idx:0,types: ['application/x-shockwave-flash'],
  94. classid: 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
  95. codebase: 'http://download.macroallMedias.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
  96. pluginspage: 'http://www.macroallMedias.com/go/getflashplayer',
  97. src: 'plugins/allmedias/player.swf', //相对插件路径
  98. exts:['mp3']
  99. },*/
  100. {player:'pdfReader',idx:0,types: ['application/pdf'],
  101. classid: 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
  102. codebase: 'http://download.macroallMedias.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
  103. pluginspage: 'http://www.macroallMedias.com/go/getflashplayer',
  104. exts:['pdf']
  105. },
  106. ];
  107. function getUriExt(uri){
  108. if(!uri)return "";
  109. return uri.substring(uri.lastIndexOf(".") + 1, uri.length).toLowerCase();
  110. }
  111. function getMediaType(ext) {
  112. var i,
  113. k,
  114. mediaPlayer,
  115. mp;
  116. if(!ext){return mediaTypes[0];}
  117. for (i=0; i<mediaTypes.length; i++) {
  118. mediaPlayer = mediaTypes[i];
  119. //0-video 1-audio
  120. if (mediaPlayer) {
  121. for(k=0; k<mediaPlayer.exts.length; k++)
  122. {
  123. if(ext == mediaPlayer.exts[k]){
  124. mediaPlayer.idx = k;
  125. return mediaPlayer;
  126. }
  127. }
  128. }
  129. }
  130. return mediaTypes[0];
  131. }
  132. //var names = [ 'play', 'loop', 'menu', 'quality', 'scale', 'salign', 'wmode', 'bgcolor', 'base', 'flashvars', 'allowScriptAccess', 'allowFullScreen','seamlesstabbing' ];
  133. //for ( var i = 0; i < names.length; i++ )
  134. // attributesMap[ names[ i ] ] = [ {
  135. // type: ATTRTYPE_EMBED, name: names[ i ]
  136. //}, {
  137. // type: ATTRTYPE_PARAM, name: names[ i ]
  138. //}];
  139. var defaultToPixel = CKEDITOR.tools.cssLength;
  140. function loadValue( objectNode, embedNode, paramMap ) {
  141. var attributes = attributesMap[ this.id ];
  142. if ( !attributes )
  143. return;
  144. var isCheckbox = ( this instanceof CKEDITOR.ui.dialog.checkbox );
  145. for ( var i = 0; i < attributes.length; i++ ) {
  146. var attrDef = attributes[ i ];
  147. switch ( attrDef.type ) {
  148. case ATTRTYPE_OBJECT:
  149. if ( !objectNode )
  150. continue;
  151. if ( objectNode.getAttribute( attrDef.name ) !== null ) {
  152. var value = objectNode.getAttribute( attrDef.name );
  153. if ( isCheckbox )
  154. this.setValue( value.toLowerCase() == 'true' );
  155. else
  156. this.setValue( value );
  157. return;
  158. } else if ( isCheckbox )
  159. this.setValue( !!attrDef[ 'default' ] );
  160. break;
  161. case ATTRTYPE_PARAM:
  162. if ( !objectNode )
  163. continue;
  164. if ( attrDef.name in paramMap ) {
  165. value = paramMap[ attrDef.name ];
  166. if ( isCheckbox )
  167. this.setValue( value.toLowerCase() == 'true' );
  168. else
  169. this.setValue( value );
  170. return;
  171. } else if ( isCheckbox )
  172. this.setValue( !!attrDef[ 'default' ] );
  173. break;
  174. case ATTRTYPE_EMBED:
  175. if ( !embedNode )
  176. continue;
  177. if ( embedNode.getAttribute( attrDef.name ) ) {
  178. value = embedNode.getAttribute( attrDef.name );
  179. if ( isCheckbox )
  180. this.setValue( value.toLowerCase() == 'true' );
  181. else
  182. this.setValue( value );
  183. return;
  184. } else if ( isCheckbox )
  185. this.setValue( !!attrDef[ 'default' ] );
  186. }
  187. }
  188. }
  189. function commitValue( objectNode, embedNode, paramMap ) {
  190. var attributes = attributesMap[ this.id ];
  191. if ( !attributes )
  192. return;
  193. var isRemove = ( this.getValue() === '' ),
  194. isCheckbox = ( this instanceof CKEDITOR.ui.dialog.checkbox );
  195. for ( var i = 0; i < attributes.length; i++ ) {
  196. var attrDef = attributes[ i ];
  197. switch ( attrDef.type ) {
  198. case ATTRTYPE_OBJECT:
  199. // Avoid applying the data attribute when not needed (#7733)
  200. if ( !objectNode || ( attrDef.name == 'data' && embedNode && !objectNode.hasAttribute( 'data' ) ) )
  201. continue;
  202. var value = this.getValue();
  203. if ( isRemove )
  204. objectNode.removeAttribute( attrDef.name );
  205. else
  206. objectNode.setAttribute( attrDef.name, value );
  207. break;
  208. case ATTRTYPE_PARAM:
  209. if ( !objectNode )
  210. continue;
  211. value = this.getValue();
  212. if ( isRemove ) {
  213. if ( attrDef.name in paramMap )
  214. paramMap[ attrDef.name ].remove();
  215. } else {
  216. if ( attrDef.name in paramMap )
  217. paramMap[ attrDef.name ].setAttribute( 'value', value );
  218. else {
  219. var param = CKEDITOR.dom.element.createFromHtml( '<cke:param></cke:param>', objectNode.getDocument() );
  220. param.setAttributes({ name: attrDef.name, value: value } );
  221. if ( objectNode.getChildCount() < 1 )
  222. param.appendTo( objectNode );
  223. else
  224. param.insertBefore( objectNode.getFirst() );
  225. }
  226. }
  227. break;
  228. case ATTRTYPE_EMBED:
  229. if ( !embedNode )
  230. continue;
  231. value = this.getValue();
  232. if ( isRemove )
  233. embedNode.removeAttribute( attrDef.name );
  234. else
  235. embedNode.setAttribute( attrDef.name, value );
  236. }
  237. }
  238. }
  239. CKEDITOR.dialog.add( 'allmedias', function( editor ) {
  240. //此处更改为仅支持embed标签,简单跨浏览器
  241. //var makeObjectTag = !editor.config.allMediasEmbedTagOnly,
  242. // makeEmbedTag = editor.config.allMediasAddEmbedTag || editor.config.allMediasEmbedTagOnly;
  243. var makeObjectTag = false,
  244. makeEmbedTag = true;
  245. var previewPreloader,
  246. previewAreaHtml = '<div>' + CKEDITOR.tools.htmlEncode( editor.lang.common.preview ) + '<br>' +
  247. '<div id="cke_FlashPreviewLoader' + CKEDITOR.tools.getNextNumber() + '" style="display:none"><div class="loading">&nbsp;</div></div>' +
  248. '<div id="cke_FlashPreviewBox' + CKEDITOR.tools.getNextNumber() + '" class="FlashPreviewBox" style="width:100%;"></div></div>';
  249. return {
  250. title: editor.lang.allmedias.title,
  251. minWidth: 420,
  252. minHeight: 310,
  253. onShow: function() {
  254. // Clear previously saved elements.
  255. this.fakeImage = this.objectNode = this.embedNode = null;
  256. previewPreloader = new CKEDITOR.dom.element( 'embed', editor.document );
  257. // Try to detect any embed or object tag that has allMedias parameters.
  258. var fakeImage = this.getSelectedElement();
  259. if ( fakeImage && fakeImage.data( 'cke-real-element-type' ) && fakeImage.data( 'cke-real-element-type' ) == 'allmedias' ) {
  260. this.fakeImage = fakeImage;
  261. var realElement = editor.restoreRealElement( fakeImage ),
  262. objectNode = null,
  263. embedNode = null,
  264. paramMap = {};
  265. if ( realElement.getName() == 'cke:object' ) {
  266. objectNode = realElement;
  267. var embedList = objectNode.getElementsByTag( 'embed', 'cke' );
  268. if ( embedList.count() > 0 )
  269. embedNode = embedList.getItem( 0 );
  270. var paramList = objectNode.getElementsByTag( 'param', 'cke' );
  271. for ( var i = 0, length = paramList.count(); i < length; i++ ) {
  272. var item = paramList.getItem( i ),
  273. name = item.getAttribute( 'name' ),
  274. value = item.getAttribute( 'value' );
  275. paramMap[ name ] = value;
  276. }
  277. } else if ( realElement.getName() == 'cke:embed' )
  278. embedNode = realElement;
  279. this.objectNode = objectNode;
  280. this.embedNode = embedNode;
  281. this.setupContent( objectNode, embedNode, paramMap, fakeImage );
  282. }
  283. },
  284. onOk: function() {
  285. // If there's no selected object or embed, create one. Otherwise, reuse the
  286. // selected object and embed nodes.
  287. var objectNode = null,
  288. embedNode = null,
  289. paramMap = null,
  290. myExtPlayer;
  291. myExtPlayer = getMediaType(getUriExt(this.getValueOf('info', 'src')));
  292. if ( !this.fakeImage ) {
  293. if ( makeObjectTag ) {
  294. objectNode = CKEDITOR.dom.element.createFromHtml( '<cke:object></cke:object>', editor.document );
  295. var attributes = {
  296. classid: myExtPlayer.classid,
  297. type: myExtPlayer.types[myExtPlayer.idx],
  298. mtype: 'allmedias',
  299. codebase: myExtPlayer.codebase
  300. };
  301. objectNode.setAttributes( attributes );
  302. }
  303. if ( makeEmbedTag ) {
  304. embedNode = CKEDITOR.dom.element.createFromHtml( '<cke:embed></cke:embed>', editor.document );
  305. embedNode.setAttributes({
  306. type: myExtPlayer.types[myExtPlayer.idx],
  307. mtype: 'allmedias',
  308. pluginspage: myExtPlayer.pluginspage
  309. });
  310. if ( objectNode )
  311. embedNode.appendTo( objectNode );
  312. }
  313. } else {
  314. objectNode = this.objectNode;
  315. embedNode = this.embedNode;
  316. //如果更改文件,则有可能需要更改type
  317. embedNode.setAttributes({
  318. type: myExtPlayer.types[myExtPlayer.idx],
  319. pluginspage: myExtPlayer.pluginspage
  320. });
  321. }
  322. // Produce the paramMap if there's an object tag.
  323. if ( objectNode ) {
  324. paramMap = {};
  325. var paramList = objectNode.getElementsByTag( 'param', 'cke' );
  326. for ( var i = 0, length = paramList.count(); i < length; i++ )
  327. paramMap[ paramList.getItem( i ).getAttribute( 'name' ) ] = paramList.getItem( i );
  328. }
  329. // A subset of the specified attributes/styles
  330. // should also be applied on the fake element to
  331. // have better visual effect. (#5240)
  332. var extraStyles = {},
  333. extraAttributes = {};
  334. this.commitContent( objectNode, embedNode, paramMap, extraStyles, extraAttributes );
  335. //处理不同的文件类型
  336. var attributes = {};
  337. if(myExtPlayer.player == 'flashvideo'){
  338. attributes = {
  339. flashvars: 'file=' + CKEDITOR.tools.htmlEncode( this.getValueOf('info', 'src') || '') ,
  340. src: CKEDITOR.getUrl(myExtPlayer.src || '')
  341. };
  342. }else if(myExtPlayer.player =='wmpaudio'){
  343. attributes = {
  344. src: CKEDITOR.tools.htmlEncode( this.getValueOf('info', 'src') || ''),
  345. width: (this.getValueOf('info', 'width') || 400),
  346. height: 45
  347. };
  348. }/*else if(myExtPlayer.player == 'flashaudio'){
  349. attributes = {
  350. flashvars: 'soundFile=' + CKEDITOR.tools.htmlEncode( this.getValueOf('info', 'src') || '') ,
  351. src: CKEDITOR.getUrl(myExtPlayer.src || '') ,
  352. width: (this.getValueOf('info', 'width') || 50),
  353. height: 25
  354. };
  355. }*/
  356. else{
  357. attributes = {
  358. src: CKEDITOR.tools.htmlEncode( this.getValueOf('info', 'src') || '')
  359. };
  360. }
  361. embedNode.setAttributes(attributes);
  362. // Refresh the fake image.
  363. var newFakeImage = editor.createFakeElement( objectNode || embedNode, 'cke_allmedias', 'allmedias', true );
  364. newFakeImage.setAttributes( extraAttributes );
  365. newFakeImage.setStyles( extraStyles );
  366. if ( this.fakeImage ) {
  367. newFakeImage.replace( this.fakeImage );
  368. editor.getSelection().selectElement( newFakeImage );
  369. } else
  370. editor.insertElement( newFakeImage );
  371. },
  372. onHide: function() {
  373. if ( this.preview )
  374. this.preview.setHtml( '' );
  375. },
  376. contents: [
  377. {
  378. id: 'info',
  379. label: editor.lang.common.generalTab,
  380. accessKey: 'I',
  381. elements: [
  382. {
  383. type: 'vbox',
  384. padding: 0,
  385. children: [
  386. {
  387. type: 'hbox',
  388. widths: [ '280px', '110px' ],
  389. align: 'right',
  390. children: [
  391. {
  392. id: 'src',
  393. type: 'text',
  394. label: editor.lang.common.url,
  395. required: true,
  396. validate: CKEDITOR.dialog.validate.notEmpty( editor.lang.allmedias.validateSrc ),
  397. setup: loadValue,
  398. commit: commitValue,
  399. onLoad: function() {
  400. var dialog = this.getDialog(),
  401. updatePreview = function( src ) {
  402. var width = dialog.getValueOf('info', 'width');
  403. var height = dialog.getValueOf('info', 'height') ;
  404. // Query the preloader to figure out the url impacted by based href.
  405. previewPreloader.setAttribute( 'src', src );
  406. var mp = getMediaType(getUriExt(previewPreloader.getAttribute('src') ));
  407. var objsrc ;
  408. if(mp.player == 'flashvideo')
  409. {
  410. width = (dialog.getValueOf('info', 'width') || 400);
  411. height = (dialog.getValueOf('info', 'height') || 300);
  412. objsrc = ' flashvars="autostart=true&file=' + CKEDITOR.tools.htmlEncode( previewPreloader.getAttribute( 'src' )) +'" '
  413. +' style="height:' + height + 'px;width:'+ width +'px"'
  414. + 'pluginspage ="' + (mp.pluginspage || '') +'" '
  415. + 'src ="' + CKEDITOR.getUrl((mp.src || '')) +'" ';
  416. }
  417. else if (mp.player == 'wmpaudio'){
  418. width = (dialog.getValueOf('info', 'width') || 350);
  419. height = 45;
  420. objsrc = ' src="' + CKEDITOR.tools.htmlEncode( previewPreloader.getAttribute( 'src' )) +'" '
  421. + 'pluginspage ="' + (mp.pluginspage || '') +'" '
  422. +' style="height:' + height + 'px;width:'+ width +'px"';
  423. }
  424. /*else if(mp.player == 'flashaudio'){
  425. width = (dialog.getValueOf('info', 'width') || 25);
  426. height = (dialog.getValueOf('info', 'height') || 100);
  427. objsrc = ' flashvars="autostart=true&soundFile=' + CKEDITOR.tools.htmlEncode( previewPreloader.getAttribute( 'src' )) +'" '
  428. //+'width="' + width +'" height="' + height +'" '
  429. + 'soundFile="' + CKEDITOR.tools.htmlEncode( CKEDITOR.getUrl(previewPreloader.getAttribute( 'src' ))) + '" '
  430. + 'src ="' + CKEDITOR.getUrl((mp.src || '')) +'" ';
  431. }*/
  432. else
  433. {
  434. width = (dialog.getValueOf('info', 'width') || 400);
  435. height = (dialog.getValueOf('info', 'height') || 300);
  436. objsrc = ' src="' + CKEDITOR.tools.htmlEncode( previewPreloader.getAttribute( 'src' )) +'" '
  437. + 'pluginspage ="' + (mp.pluginspage || '') +'" '
  438. +' style="height:' + height + 'px;width:'+ width +'px"';
  439. }
  440. dialog.preview.setHtml( '<embed ' + objsrc
  441. + ' autostart="true'
  442. + '" type="'+ mp.types[mp.idx] +'"></embed>' );
  443. };
  444. // Preview element
  445. dialog.preview = dialog.getContentElement( 'info', 'preview' ).getElement().getChild( 3 );
  446. // Sync on inital value loaded.
  447. this.on( 'change', function( evt ) {
  448. if ( evt.data && evt.data.value )
  449. updatePreview( evt.data.value );
  450. });
  451. // Sync when input value changed.
  452. this.getInputElement().on( 'change', function( evt ) {
  453. updatePreview( this.getValue() );
  454. }, this );
  455. }
  456. },
  457. {
  458. type: 'button',
  459. id: 'browse',
  460. filebrowser: {target:'info:src', //update span area
  461. action : 'Browse', //QuickUpload ,Upload,Browse
  462. //url : '/ckfinder/ckfinder.html&amp;type=Images',
  463. params : // optional
  464. {
  465. mediaType : 'allmedias',
  466. by : 'ck'
  467. }
  468. },
  469. hidden: true,
  470. // v-align with the 'src' field.
  471. // TODO: We need something better than a fixed size here.
  472. style: 'display:inline-block;margin-top:15px;',
  473. label: editor.lang.common.browseServer
  474. }
  475. ]
  476. }
  477. ]
  478. },
  479. {
  480. type: 'hbox',
  481. widths: [ '25%', '25%', '25%', '25%', '25%' ],
  482. children: [
  483. {
  484. type: 'text',
  485. id: 'width',
  486. style: 'width:95px',
  487. label: editor.lang.common.width,
  488. validate: CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength.replace( '%1', editor.lang.common.width ) ),
  489. setup: loadValue,
  490. commit: commitValue
  491. },
  492. {
  493. type: 'text',
  494. id: 'height',
  495. style: 'width:95px',
  496. label: editor.lang.common.height,
  497. validate: CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength.replace( '%1', editor.lang.common.height ) ),
  498. setup: loadValue,
  499. commit: commitValue
  500. },
  501. {
  502. type: 'text',
  503. id: 'hSpace',
  504. style: 'width:95px',
  505. label: editor.lang.allmedias.hSpace,
  506. validate: CKEDITOR.dialog.validate.integer( editor.lang.allmedias.validateHSpace ),
  507. setup: loadValue,
  508. commit: commitValue
  509. },
  510. {
  511. type: 'text',
  512. id: 'vSpace',
  513. style: 'width:95px',
  514. label: editor.lang.allmedias.vSpace,
  515. validate: CKEDITOR.dialog.validate.integer( editor.lang.allmedias.validateVSpace ),
  516. setup: loadValue,
  517. commit: commitValue
  518. }
  519. ]
  520. },
  521. {
  522. type: 'vbox',
  523. children: [
  524. {
  525. type: 'html',
  526. id: 'preview',
  527. style: 'width:95%;',
  528. html: previewAreaHtml
  529. },
  530. {
  531. type: 'text',
  532. id: 'flashuri',
  533. label: 'hid1',
  534. 'default': 'plugins/allmedias/jwplayer.swf',
  535. style: 'display : none;',
  536. setup: loadValue,
  537. commit: commitValue
  538. }
  539. ]
  540. }
  541. ]
  542. },
  543. {
  544. id: 'Upload',
  545. hidden: true,
  546. filebrowser: 'uploadButton',
  547. label: editor.lang.common.upload,
  548. elements: [
  549. {
  550. type: 'file',
  551. id: 'upload',
  552. label: editor.lang.common.upload,
  553. size: 38
  554. },
  555. {
  556. type: 'fileButton',
  557. id: 'uploadButton',
  558. label: editor.lang.common.uploadSubmit,
  559. filebrowser: 'info:src',
  560. 'for': [ 'Upload', 'upload' ]
  561. }
  562. ]
  563. },
  564. {
  565. id: 'properties',
  566. label: editor.lang.allmedias.propertiesTab,
  567. elements: [
  568. {
  569. type: 'hbox',
  570. widths: [ '50%', '50%' ],
  571. children: [
  572. {
  573. id: 'scale',
  574. type: 'select',
  575. label: editor.lang.allmedias.scale,
  576. 'default': '',
  577. style: 'width : 100%;',
  578. items: [
  579. [ editor.lang.common.notSet, '' ],
  580. [ editor.lang.allmedias.scaleAll, 'showall' ],
  581. [ editor.lang.allmedias.scaleNoBorder, 'noborder' ],
  582. [ editor.lang.allmedias.scaleFit, 'exactfit' ]
  583. ],
  584. setup: loadValue,
  585. commit: commitValue
  586. },
  587. {
  588. id: 'allowScriptAccess',
  589. type: 'select',
  590. label: editor.lang.allmedias.access,
  591. 'default': '',
  592. style: 'width : 100%;',
  593. items: [
  594. [ editor.lang.common.notSet, '' ],
  595. [ editor.lang.allmedias.accessAlways, 'always' ],
  596. [ editor.lang.allmedias.accessSameDomain, 'samedomain' ],
  597. [ editor.lang.allmedias.accessNever, 'never' ]
  598. ],
  599. setup: loadValue,
  600. commit: commitValue
  601. }
  602. ]
  603. },
  604. {
  605. type: 'hbox',
  606. widths: [ '50%', '50%' ],
  607. children: [
  608. {
  609. id: 'wmode',
  610. type: 'select',
  611. label: editor.lang.allmedias.windowMode,
  612. 'default': '',
  613. style: 'width : 100%;',
  614. items: [
  615. [ editor.lang.common.notSet, '' ],
  616. [ editor.lang.allmedias.windowModeWindow, 'window' ],
  617. [ editor.lang.allmedias.windowModeOpaque, 'opaque' ],
  618. [ editor.lang.allmedias.windowModeTransparent, 'transparent' ]
  619. ],
  620. setup: loadValue,
  621. commit: commitValue
  622. },
  623. {
  624. id: 'quality',
  625. type: 'select',
  626. label: editor.lang.allmedias.quality,
  627. 'default': 'high',
  628. style: 'width : 100%;',
  629. items: [
  630. [ editor.lang.common.notSet, '' ],
  631. [ editor.lang.allmedias.qualityBest, 'best' ],
  632. [ editor.lang.allmedias.qualityHigh, 'high' ],
  633. [ editor.lang.allmedias.qualityAutoHigh, 'autohigh' ],
  634. [ editor.lang.allmedias.qualityMedium, 'medium' ],
  635. [ editor.lang.allmedias.qualityAutoLow, 'autolow' ],
  636. [ editor.lang.allmedias.qualityLow, 'low' ]
  637. ],
  638. setup: loadValue,
  639. commit: commitValue
  640. }
  641. ]
  642. },
  643. {
  644. type: 'hbox',
  645. widths: [ '50%', '50%' ],
  646. children: [
  647. {
  648. id: 'align',
  649. type: 'select',
  650. label: editor.lang.common.align,
  651. 'default': '',
  652. style: 'width : 100%;',
  653. items: [
  654. [ editor.lang.common.notSet, '' ],
  655. [ editor.lang.common.alignLeft, 'left' ],
  656. [ editor.lang.allmedias.alignAbsBottom, 'absBottom' ],
  657. [ editor.lang.allmedias.alignAbsMiddle, 'absMiddle' ],
  658. [ editor.lang.allmedias.alignBaseline, 'baseline' ],
  659. [ editor.lang.common.alignBottom, 'bottom' ],
  660. [ editor.lang.common.alignMiddle, 'middle' ],
  661. [ editor.lang.common.alignRight, 'right' ],
  662. [ editor.lang.allmedias.alignTextTop, 'textTop' ],
  663. [ editor.lang.common.alignTop, 'top' ]
  664. ],
  665. setup: loadValue,
  666. commit: function( objectNode, embedNode, paramMap, extraStyles, extraAttributes ) {
  667. var value = this.getValue();
  668. commitValue.apply( this, arguments );
  669. value && ( extraAttributes.align = value );
  670. }
  671. },
  672. {
  673. type: 'html',
  674. html: '<div></div>'
  675. }
  676. ]
  677. },
  678. {
  679. type: 'fieldset',
  680. label: CKEDITOR.tools.htmlEncode( editor.lang.allmedias.flashvars ),
  681. children: [
  682. {
  683. type: 'vbox',
  684. padding: 0,
  685. children: [
  686. /*{
  687. type: 'checkbox',
  688. id: 'menu',
  689. label: editor.lang.allMedias.chkMenu,
  690. 'default': true,
  691. setup: loadValue,
  692. commit: commitValue
  693. },*/
  694. {
  695. type: 'checkbox',
  696. id: 'loop',
  697. label: editor.lang.allmedias.chkLoop,
  698. 'default': true,
  699. setup: loadValue,
  700. commit: commitValue
  701. },
  702. {
  703. type: 'checkbox',
  704. id: 'play',
  705. label: editor.lang.allmedias.chkPlay,
  706. 'default': true,
  707. setup: loadValue,
  708. commit: commitValue
  709. },
  710. {
  711. type: 'checkbox',
  712. id: 'allowFullScreen',
  713. label: editor.lang.allmedias.chkFull,
  714. 'default': true,
  715. setup: loadValue,
  716. commit: commitValue
  717. }
  718. ]
  719. }
  720. ]
  721. }
  722. ]
  723. } ,
  724. {
  725. id: 'advanced',
  726. label: editor.lang.common.advancedTab,
  727. elements: [
  728. {
  729. type: 'hbox',
  730. children: [
  731. {
  732. type: 'text',
  733. id: 'id',
  734. label: editor.lang.common.id,
  735. setup: loadValue,
  736. commit: commitValue
  737. }
  738. ]
  739. },
  740. {
  741. type: 'hbox',
  742. widths: [ '45%', '55%' ],
  743. children: [
  744. {
  745. type: 'text',
  746. id: 'bgcolor',
  747. label: editor.lang.allmedias.bgcolor,
  748. setup: loadValue,
  749. commit: commitValue
  750. },
  751. {
  752. type: 'text',
  753. id: 'class',
  754. label: editor.lang.common.cssClass,
  755. setup: loadValue,
  756. commit: commitValue
  757. }
  758. ]
  759. },
  760. {
  761. type: 'text',
  762. id: 'style',
  763. validate: CKEDITOR.dialog.validate.inlineStyle( editor.lang.common.invalidInlineStyle ),
  764. label: editor.lang.common.cssStyle,
  765. setup: loadValue,
  766. commit: commitValue
  767. }
  768. ]
  769. }
  770. ]
  771. };
  772. });
  773. })();