annotate media/js/tiny_mce/plugins/fullpage/editor_plugin_src.js @ 197:2baadae33f2e

Got autocomplete working for the member search. Updated django and ran into a bug where url tags with comma separated kwargs starting consuming tons of CPU throughput. The work-around is to cut over to using spaces between arguments. This is now allowed to be consistent with other tags. Did some query optimization for the news app.
author Brian Neal <bgneal@gmail.com>
date Sat, 10 Apr 2010 04:32:24 +0000
parents 149c3567fec1
children 6ed2932901fa
rev   line source
bgneal@45 1 /**
bgneal@183 2 * editor_plugin_src.js
bgneal@45 3 *
bgneal@183 4 * Copyright 2009, Moxiecode Systems AB
bgneal@183 5 * Released under LGPL License.
bgneal@183 6 *
bgneal@183 7 * License: http://tinymce.moxiecode.com/license
bgneal@183 8 * Contributing: http://tinymce.moxiecode.com/contributing
bgneal@45 9 */
bgneal@45 10
bgneal@45 11 (function() {
bgneal@45 12 tinymce.create('tinymce.plugins.FullPagePlugin', {
bgneal@45 13 init : function(ed, url) {
bgneal@45 14 var t = this;
bgneal@45 15
bgneal@45 16 t.editor = ed;
bgneal@45 17
bgneal@45 18 // Register commands
bgneal@45 19 ed.addCommand('mceFullPageProperties', function() {
bgneal@45 20 ed.windowManager.open({
bgneal@45 21 file : url + '/fullpage.htm',
bgneal@45 22 width : 430 + parseInt(ed.getLang('fullpage.delta_width', 0)),
bgneal@45 23 height : 495 + parseInt(ed.getLang('fullpage.delta_height', 0)),
bgneal@45 24 inline : 1
bgneal@45 25 }, {
bgneal@45 26 plugin_url : url,
bgneal@45 27 head_html : t.head
bgneal@45 28 });
bgneal@45 29 });
bgneal@45 30
bgneal@45 31 // Register buttons
bgneal@45 32 ed.addButton('fullpage', {title : 'fullpage.desc', cmd : 'mceFullPageProperties'});
bgneal@45 33
bgneal@45 34 ed.onBeforeSetContent.add(t._setContent, t);
bgneal@45 35 ed.onSetContent.add(t._setBodyAttribs, t);
bgneal@45 36 ed.onGetContent.add(t._getContent, t);
bgneal@45 37 },
bgneal@45 38
bgneal@45 39 getInfo : function() {
bgneal@45 40 return {
bgneal@45 41 longname : 'Fullpage',
bgneal@45 42 author : 'Moxiecode Systems AB',
bgneal@45 43 authorurl : 'http://tinymce.moxiecode.com',
bgneal@45 44 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullpage',
bgneal@45 45 version : tinymce.majorVersion + "." + tinymce.minorVersion
bgneal@45 46 };
bgneal@45 47 },
bgneal@45 48
bgneal@45 49 // Private plugin internal methods
bgneal@45 50
bgneal@45 51 _setBodyAttribs : function(ed, o) {
bgneal@45 52 var bdattr, i, len, kv, k, v, t, attr = this.head.match(/body(.*?)>/i);
bgneal@45 53
bgneal@45 54 if (attr && attr[1]) {
bgneal@45 55 bdattr = attr[1].match(/\s*(\w+\s*=\s*".*?"|\w+\s*=\s*'.*?'|\w+\s*=\s*\w+|\w+)\s*/g);
bgneal@45 56
bgneal@45 57 if (bdattr) {
bgneal@45 58 for(i = 0, len = bdattr.length; i < len; i++) {
bgneal@45 59 kv = bdattr[i].split('=');
bgneal@45 60 k = kv[0].replace(/\s/,'');
bgneal@45 61 v = kv[1];
bgneal@45 62
bgneal@45 63 if (v) {
bgneal@45 64 v = v.replace(/^\s+/,'').replace(/\s+$/,'');
bgneal@45 65 t = v.match(/^["'](.*)["']$/);
bgneal@45 66
bgneal@45 67 if (t)
bgneal@45 68 v = t[1];
bgneal@45 69 } else
bgneal@45 70 v = k;
bgneal@45 71
bgneal@45 72 ed.dom.setAttrib(ed.getBody(), 'style', v);
bgneal@45 73 }
bgneal@45 74 }
bgneal@45 75 }
bgneal@45 76 },
bgneal@45 77
bgneal@45 78 _createSerializer : function() {
bgneal@45 79 return new tinymce.dom.Serializer({
bgneal@45 80 dom : this.editor.dom,
bgneal@45 81 apply_source_formatting : true
bgneal@45 82 });
bgneal@45 83 },
bgneal@45 84
bgneal@45 85 _setContent : function(ed, o) {
bgneal@45 86 var t = this, sp, ep, c = o.content, v, st = '';
bgneal@45 87
bgneal@45 88 if (o.source_view && ed.getParam('fullpage_hide_in_source_view'))
bgneal@45 89 return;
bgneal@45 90
bgneal@45 91 // Parse out head, body and footer
bgneal@45 92 c = c.replace(/<(\/?)BODY/gi, '<$1body');
bgneal@45 93 sp = c.indexOf('<body');
bgneal@45 94
bgneal@45 95 if (sp != -1) {
bgneal@45 96 sp = c.indexOf('>', sp);
bgneal@45 97 t.head = c.substring(0, sp + 1);
bgneal@45 98
bgneal@45 99 ep = c.indexOf('</body', sp);
bgneal@45 100 if (ep == -1)
bgneal@45 101 ep = c.indexOf('</body', ep);
bgneal@45 102
bgneal@45 103 o.content = c.substring(sp + 1, ep);
bgneal@45 104 t.foot = c.substring(ep);
bgneal@45 105
bgneal@45 106 function low(s) {
bgneal@45 107 return s.replace(/<\/?[A-Z]+/g, function(a) {
bgneal@45 108 return a.toLowerCase();
bgneal@45 109 })
bgneal@45 110 };
bgneal@45 111
bgneal@45 112 t.head = low(t.head);
bgneal@45 113 t.foot = low(t.foot);
bgneal@45 114 } else {
bgneal@45 115 t.head = '';
bgneal@45 116 if (ed.getParam('fullpage_default_xml_pi'))
bgneal@45 117 t.head += '<?xml version="1.0" encoding="' + ed.getParam('fullpage_default_encoding', 'ISO-8859-1') + '" ?>\n';
bgneal@45 118
bgneal@45 119 t.head += ed.getParam('fullpage_default_doctype', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
bgneal@45 120 t.head += '\n<html>\n<head>\n<title>' + ed.getParam('fullpage_default_title', 'Untitled document') + '</title>\n';
bgneal@45 121
bgneal@45 122 if (v = ed.getParam('fullpage_default_encoding'))
bgneal@45 123 t.head += '<meta http-equiv="Content-Type" content="' + v + '" />\n';
bgneal@45 124
bgneal@45 125 if (v = ed.getParam('fullpage_default_font_family'))
bgneal@45 126 st += 'font-family: ' + v + ';';
bgneal@45 127
bgneal@45 128 if (v = ed.getParam('fullpage_default_font_size'))
bgneal@45 129 st += 'font-size: ' + v + ';';
bgneal@45 130
bgneal@45 131 if (v = ed.getParam('fullpage_default_text_color'))
bgneal@45 132 st += 'color: ' + v + ';';
bgneal@45 133
bgneal@45 134 t.head += '</head>\n<body' + (st ? ' style="' + st + '"' : '') + '>\n';
bgneal@45 135 t.foot = '\n</body>\n</html>';
bgneal@45 136 }
bgneal@45 137 },
bgneal@45 138
bgneal@45 139 _getContent : function(ed, o) {
bgneal@45 140 var t = this;
bgneal@45 141
bgneal@45 142 if (!o.source_view || !ed.getParam('fullpage_hide_in_source_view'))
bgneal@45 143 o.content = tinymce.trim(t.head) + '\n' + tinymce.trim(o.content) + '\n' + tinymce.trim(t.foot);
bgneal@45 144 }
bgneal@45 145 });
bgneal@45 146
bgneal@45 147 // Register plugin
bgneal@45 148 tinymce.PluginManager.add('fullpage', tinymce.plugins.FullPagePlugin);
bgneal@45 149 })();