annotate static/js/tiny_mce/plugins/xhtmlxtras/editor_plugin_src.js @ 661:15dbe0ccda95

Prevent exceptions when viewing downloads in the admin when the file doesn't exist on the filesystem. This is usually seen in development but can also happen in production if the file is missing.
author Brian Neal <bgneal@gmail.com>
date Tue, 14 May 2013 21:02:47 -0500
parents 6c182ceb7147
children
rev   line source
bgneal@312 1 /**
bgneal@312 2 * editor_plugin_src.js
bgneal@312 3 *
bgneal@312 4 * Copyright 2009, Moxiecode Systems AB
bgneal@312 5 * Released under LGPL License.
bgneal@312 6 *
bgneal@312 7 * License: http://tinymce.moxiecode.com/license
bgneal@312 8 * Contributing: http://tinymce.moxiecode.com/contributing
bgneal@312 9 */
bgneal@312 10
bgneal@312 11 (function() {
bgneal@312 12 tinymce.create('tinymce.plugins.XHTMLXtrasPlugin', {
bgneal@312 13 init : function(ed, url) {
bgneal@312 14 // Register commands
bgneal@312 15 ed.addCommand('mceCite', function() {
bgneal@312 16 ed.windowManager.open({
bgneal@312 17 file : url + '/cite.htm',
bgneal@312 18 width : 350 + parseInt(ed.getLang('xhtmlxtras.cite_delta_width', 0)),
bgneal@312 19 height : 250 + parseInt(ed.getLang('xhtmlxtras.cite_delta_height', 0)),
bgneal@312 20 inline : 1
bgneal@312 21 }, {
bgneal@312 22 plugin_url : url
bgneal@312 23 });
bgneal@312 24 });
bgneal@312 25
bgneal@312 26 ed.addCommand('mceAcronym', function() {
bgneal@312 27 ed.windowManager.open({
bgneal@312 28 file : url + '/acronym.htm',
bgneal@312 29 width : 350 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_width', 0)),
bgneal@442 30 height : 250 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_height', 0)),
bgneal@312 31 inline : 1
bgneal@312 32 }, {
bgneal@312 33 plugin_url : url
bgneal@312 34 });
bgneal@312 35 });
bgneal@312 36
bgneal@312 37 ed.addCommand('mceAbbr', function() {
bgneal@312 38 ed.windowManager.open({
bgneal@312 39 file : url + '/abbr.htm',
bgneal@312 40 width : 350 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_width', 0)),
bgneal@442 41 height : 250 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_height', 0)),
bgneal@312 42 inline : 1
bgneal@312 43 }, {
bgneal@312 44 plugin_url : url
bgneal@312 45 });
bgneal@312 46 });
bgneal@312 47
bgneal@312 48 ed.addCommand('mceDel', function() {
bgneal@312 49 ed.windowManager.open({
bgneal@312 50 file : url + '/del.htm',
bgneal@312 51 width : 340 + parseInt(ed.getLang('xhtmlxtras.del_delta_width', 0)),
bgneal@442 52 height : 310 + parseInt(ed.getLang('xhtmlxtras.del_delta_height', 0)),
bgneal@312 53 inline : 1
bgneal@312 54 }, {
bgneal@312 55 plugin_url : url
bgneal@312 56 });
bgneal@312 57 });
bgneal@312 58
bgneal@312 59 ed.addCommand('mceIns', function() {
bgneal@312 60 ed.windowManager.open({
bgneal@312 61 file : url + '/ins.htm',
bgneal@312 62 width : 340 + parseInt(ed.getLang('xhtmlxtras.ins_delta_width', 0)),
bgneal@442 63 height : 310 + parseInt(ed.getLang('xhtmlxtras.ins_delta_height', 0)),
bgneal@312 64 inline : 1
bgneal@312 65 }, {
bgneal@312 66 plugin_url : url
bgneal@312 67 });
bgneal@312 68 });
bgneal@312 69
bgneal@312 70 ed.addCommand('mceAttributes', function() {
bgneal@312 71 ed.windowManager.open({
bgneal@312 72 file : url + '/attributes.htm',
bgneal@442 73 width : 380 + parseInt(ed.getLang('xhtmlxtras.attr_delta_width', 0)),
bgneal@442 74 height : 370 + parseInt(ed.getLang('xhtmlxtras.attr_delta_height', 0)),
bgneal@312 75 inline : 1
bgneal@312 76 }, {
bgneal@312 77 plugin_url : url
bgneal@312 78 });
bgneal@312 79 });
bgneal@312 80
bgneal@312 81 // Register buttons
bgneal@312 82 ed.addButton('cite', {title : 'xhtmlxtras.cite_desc', cmd : 'mceCite'});
bgneal@312 83 ed.addButton('acronym', {title : 'xhtmlxtras.acronym_desc', cmd : 'mceAcronym'});
bgneal@312 84 ed.addButton('abbr', {title : 'xhtmlxtras.abbr_desc', cmd : 'mceAbbr'});
bgneal@312 85 ed.addButton('del', {title : 'xhtmlxtras.del_desc', cmd : 'mceDel'});
bgneal@312 86 ed.addButton('ins', {title : 'xhtmlxtras.ins_desc', cmd : 'mceIns'});
bgneal@312 87 ed.addButton('attribs', {title : 'xhtmlxtras.attribs_desc', cmd : 'mceAttributes'});
bgneal@312 88
bgneal@312 89 ed.onNodeChange.add(function(ed, cm, n, co) {
bgneal@312 90 n = ed.dom.getParent(n, 'CITE,ACRONYM,ABBR,DEL,INS');
bgneal@312 91
bgneal@312 92 cm.setDisabled('cite', co);
bgneal@312 93 cm.setDisabled('acronym', co);
bgneal@312 94 cm.setDisabled('abbr', co);
bgneal@312 95 cm.setDisabled('del', co);
bgneal@312 96 cm.setDisabled('ins', co);
bgneal@312 97 cm.setDisabled('attribs', n && n.nodeName == 'BODY');
bgneal@312 98 cm.setActive('cite', 0);
bgneal@312 99 cm.setActive('acronym', 0);
bgneal@312 100 cm.setActive('abbr', 0);
bgneal@312 101 cm.setActive('del', 0);
bgneal@312 102 cm.setActive('ins', 0);
bgneal@312 103
bgneal@312 104 // Activate all
bgneal@312 105 if (n) {
bgneal@312 106 do {
bgneal@312 107 cm.setDisabled(n.nodeName.toLowerCase(), 0);
bgneal@312 108 cm.setActive(n.nodeName.toLowerCase(), 1);
bgneal@312 109 } while (n = n.parentNode);
bgneal@312 110 }
bgneal@312 111 });
bgneal@312 112
bgneal@312 113 ed.onPreInit.add(function() {
bgneal@312 114 // Fixed IE issue where it can't handle these elements correctly
bgneal@312 115 ed.dom.create('abbr');
bgneal@312 116 });
bgneal@312 117 },
bgneal@312 118
bgneal@312 119 getInfo : function() {
bgneal@312 120 return {
bgneal@312 121 longname : 'XHTML Xtras Plugin',
bgneal@312 122 author : 'Moxiecode Systems AB',
bgneal@312 123 authorurl : 'http://tinymce.moxiecode.com',
bgneal@312 124 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras',
bgneal@312 125 version : tinymce.majorVersion + "." + tinymce.minorVersion
bgneal@312 126 };
bgneal@312 127 }
bgneal@312 128 });
bgneal@312 129
bgneal@312 130 // Register plugin
bgneal@312 131 tinymce.PluginManager.add('xhtmlxtras', tinymce.plugins.XHTMLXtrasPlugin);
bgneal@312 132 })();