diff -r c72b545f1304 -r 67bd3121a12e includes/clientside/tinymce/plugins/media/editor_plugin_src.js
--- a/includes/clientside/tinymce/plugins/media/editor_plugin_src.js Wed Dec 26 00:37:26 2007 -0500
+++ b/includes/clientside/tinymce/plugins/media/editor_plugin_src.js Thu Dec 27 22:09:33 2007 -0500
@@ -1,174 +1,128 @@
/**
- * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
+ * $Id: editor_plugin_src.js 490 2007-12-11 21:45:33Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
*/
-/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('media');
+(function() {
+ var each = tinymce.each;
-var TinyMCE_MediaPlugin = {
- getInfo : function() {
- return {
- longname : 'Media',
- author : 'Moxiecode Systems AB',
- authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/media',
- version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
- };
- },
+ tinymce.create('tinymce.plugins.MediaPlugin', {
+ init : function(ed, url) {
+ var t = this;
+
+ t.editor = ed;
+ t.url = url;
- initInstance : function(inst) {
- // Warn if user has flash plugin and media plugin at the same time
- if (inst.hasPlugin('flash') && !tinyMCE.flashWarn) {
- alert('Flash plugin is deprecated and should not be used together with the media plugin.');
- tinyMCE.flashWarn = true;
- }
+ function isMediaElm(n) {
+ return /^(mceItemFlash|mceItemShockWave|mceItemWindowsMedia|mceItemQuickTime|mceItemRealMedia)$/.test(n.className);
+ };
- if (!tinyMCE.settings['media_skip_plugin_css'])
- tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/media/css/content.css");
- },
-
- getControlHTML : function(cn) {
- switch (cn) {
- case "media":
- return tinyMCE.getButtonHTML(cn, 'lang_media_desc', '{$pluginurl}/images/media.gif', 'mceMedia');
- }
-
- return "";
- },
+ // Register commands
+ ed.addCommand('mceMedia', function() {
+ ed.windowManager.open({
+ file : url + '/media.htm',
+ width : 430 + ed.getLang('media.delta_width', 0),
+ height : 470 + ed.getLang('media.delta_height', 0),
+ inline : 1
+ }, {
+ plugin_url : url
+ });
+ });
- execCommand : function(editor_id, element, command, user_interface, value) {
- // Handle commands
- switch (command) {
- case "mceMedia":
- tinyMCE.openWindow({
- file : '../../plugins/media/media.htm',
- width : 430 + tinyMCE.getLang('lang_media_delta_width', 0),
- height : 470 + tinyMCE.getLang('lang_media_delta_height', 0)
- }, {
- editor_id : editor_id,
- inline : "yes"
- });
+ // Register buttons
+ ed.addButton('media', {title : 'media.desc', cmd : 'mceMedia'});
- return true;
- }
-
- // Pass to next handler in chain
- return false;
- },
+ ed.onNodeChange.add(function(ed, cm, n) {
+ cm.setActive('media', n.nodeName == 'IMG' && isMediaElm(n));
+ });
- cleanup : function(type, content, inst) {
- var nl, img, i, ne, d, s, ci;
+ ed.onInit.add(function() {
+ var lo = {
+ mceItemFlash : 'flash',
+ mceItemShockWave : 'shockwave',
+ mceItemWindowsMedia : 'windowsmedia',
+ mceItemQuickTime : 'quicktime',
+ mceItemRealMedia : 'realmedia'
+ };
+
+ ed.dom.loadCSS(url + "/css/content.css");
- switch (type) {
- case "insert_to_editor":
- img = tinyMCE.getParam("theme_href") + '/images/spacer.gif';
- content = content.replace(/';
}
- embedHTML = '';
- }
-
- // Insert embed/object chunk
- chunkBefore = content.substring(0, startPos);
- chunkAfter = content.substring(endPos);
- content = chunkBefore + embedHTML + chunkAfter;
- }
- break;
- }
-
- return content;
- },
-
- handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
- if (node == null)
- return;
+ return im;
+ });
+ });
+ }
+ },
- do {
- if (node.nodeName == "IMG" && /mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(tinyMCE.getAttrib(node, 'class'))) {
- tinyMCE.switchClass(editor_id + '_media', 'mceButtonSelected');
- return true;
- }
- } while ((node = node.parentNode));
-
- tinyMCE.switchClass(editor_id + '_media', 'mceButtonNormal');
-
- return true;
- },
+ getInfo : function() {
+ return {
+ longname : 'Media',
+ author : 'Moxiecode Systems AB',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/media',
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
+ };
+ },
- _createImgFromEmbed : function(n, d, cl) {
- var ne, at, i, ti = '', an;
+ // Private methods
- ne = d.createElement('img');
- ne.src = tinyMCE.getParam("theme_href") + '/images/spacer.gif';
- ne.width = tinyMCE.getAttrib(n, 'width');
- ne.height = tinyMCE.getAttrib(n, 'height');
- ne.className = cl;
+ _buildObj : function(o, n) {
+ var ob, ed = this.editor, dom = ed.dom, p = this._parse(n.title);
- at = n.attributes;
- for (i=0; i 0 ? ti.substring(0, ti.length - 1) : ti;
- ne.title = ti;
+ each (p, function(v, k) {
+ if (v && !/^(width|height|codebase|classid)$/.test(k))
+ dom.add(ob, 'div', {mce_name : 'param', name : k, '_value' : v});
+ });
- n.parentNode.replaceChild(ne, n);
- },
-
- _createImg : function(cl, d, n) {
- var i, nl, ti = "", an, av, al = new Array();
+ dom.add(ob, 'div', tinymce.extend({mce_name : 'embed', type : o.type}, p));
- ne = d.createElement('img');
- ne.src = tinyMCE.getParam("theme_href") + '/images/spacer.gif';
- ne.width = tinyMCE.getAttrib(n, 'width');
- ne.height = tinyMCE.getAttrib(n, 'height');
- ne.className = cl;
+ return ob;
+ },
- al.id = tinyMCE.getAttrib(n, 'id');
- al.name = tinyMCE.getAttrib(n, 'name');
- al.width = tinyMCE.getAttrib(n, 'width');
- al.height = tinyMCE.getAttrib(n, 'height');
- al.bgcolor = tinyMCE.getAttrib(n, 'bgcolor');
- al.align = tinyMCE.getAttrib(n, 'align');
- al.class_name = tinyMCE.getAttrib(n, 'mce_class');
+ _divsToImgs : function(p) {
+ var t = this, dom = t.editor.dom, im, ci;
- nl = n.getElementsByTagName('div');
- for (i=0; i 0 ? ti.substring(0, ti.length - 1) : ti;
- ne.title = ti;
+ case 'clsid:6bf52a52-394a-11d3-b153-00c04f79faa6':
+ case 'clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95':
+ case 'clsid:05589fa1-c356-11ce-bf01-00aa0055595a':
+ dom.replace(t._createImg('mceItemWindowsMedia', n), n);
+ break;
- return ne;
- },
+ case 'clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b':
+ dom.replace(t._createImg('mceItemQuickTime', n), n);
+ break;
- _getEmbed : function(cls, cb, mt, p, at) {
- var h = '', n;
-
- p.width = at.width ? at.width : p.width;
- p.height = at.height ? at.height : p.height;
+ case 'clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa':
+ dom.replace(t._createImg('mceItemRealMedia', n), n);
+ break;
- h += '';
+ // Setup base parameters
+ each(['id', 'name', 'width', 'height', 'bgcolor', 'align'], function(n) {
+ var v = dom.getAttrib(n, 'align');
- return h;
- },
-
- _parseAttributes : function(attribute_string) {
- var attributeName = "", endChr = '"';
- var attributeValue = "";
- var withInName;
- var withInValue;
- var attributes = new Array();
- var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
+ if (v)
+ pa[v] = v;
+ });
- if (attribute_string == null || attribute_string.length < 2)
- return null;
-
- withInName = withInValue = false;
+ // Add optional parameters
+ each(dom.select('div', n), function(n) {
+ if (dom.hasClass(n, 'mceItemParam'))
+ pa[dom.getAttrib(n, 'name')] = dom.getAttrib(n, '_value');
+ });
- for (var i=0; i