bgneal@45: /** bgneal@45: * $Id: editor_plugin_src.js 1029 2009-02-24 22:32:21Z spocke $ bgneal@45: * bgneal@45: * @author Moxiecode bgneal@45: * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. bgneal@45: */ bgneal@45: bgneal@45: (function() { bgneal@45: tinymce.create('tinymce.plugins.FullPagePlugin', { bgneal@45: init : function(ed, url) { bgneal@45: var t = this; bgneal@45: bgneal@45: t.editor = ed; bgneal@45: bgneal@45: // Register commands bgneal@45: ed.addCommand('mceFullPageProperties', function() { bgneal@45: ed.windowManager.open({ bgneal@45: file : url + '/fullpage.htm', bgneal@45: width : 430 + parseInt(ed.getLang('fullpage.delta_width', 0)), bgneal@45: height : 495 + parseInt(ed.getLang('fullpage.delta_height', 0)), bgneal@45: inline : 1 bgneal@45: }, { bgneal@45: plugin_url : url, bgneal@45: head_html : t.head bgneal@45: }); bgneal@45: }); bgneal@45: bgneal@45: // Register buttons bgneal@45: ed.addButton('fullpage', {title : 'fullpage.desc', cmd : 'mceFullPageProperties'}); bgneal@45: bgneal@45: ed.onBeforeSetContent.add(t._setContent, t); bgneal@45: ed.onSetContent.add(t._setBodyAttribs, t); bgneal@45: ed.onGetContent.add(t._getContent, t); bgneal@45: }, bgneal@45: bgneal@45: getInfo : function() { bgneal@45: return { bgneal@45: longname : 'Fullpage', bgneal@45: author : 'Moxiecode Systems AB', bgneal@45: authorurl : 'http://tinymce.moxiecode.com', bgneal@45: infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullpage', bgneal@45: version : tinymce.majorVersion + "." + tinymce.minorVersion bgneal@45: }; bgneal@45: }, bgneal@45: bgneal@45: // Private plugin internal methods bgneal@45: bgneal@45: _setBodyAttribs : function(ed, o) { bgneal@45: var bdattr, i, len, kv, k, v, t, attr = this.head.match(/body(.*?)>/i); bgneal@45: bgneal@45: if (attr && attr[1]) { bgneal@45: bdattr = attr[1].match(/\s*(\w+\s*=\s*".*?"|\w+\s*=\s*'.*?'|\w+\s*=\s*\w+|\w+)\s*/g); bgneal@45: bgneal@45: if (bdattr) { bgneal@45: for(i = 0, len = bdattr.length; i < len; i++) { bgneal@45: kv = bdattr[i].split('='); bgneal@45: k = kv[0].replace(/\s/,''); bgneal@45: v = kv[1]; bgneal@45: bgneal@45: if (v) { bgneal@45: v = v.replace(/^\s+/,'').replace(/\s+$/,''); bgneal@45: t = v.match(/^["'](.*)["']$/); bgneal@45: bgneal@45: if (t) bgneal@45: v = t[1]; bgneal@45: } else bgneal@45: v = k; bgneal@45: bgneal@45: ed.dom.setAttrib(ed.getBody(), 'style', v); bgneal@45: } bgneal@45: } bgneal@45: } bgneal@45: }, bgneal@45: bgneal@45: _createSerializer : function() { bgneal@45: return new tinymce.dom.Serializer({ bgneal@45: dom : this.editor.dom, bgneal@45: apply_source_formatting : true bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: _setContent : function(ed, o) { bgneal@45: var t = this, sp, ep, c = o.content, v, st = ''; bgneal@45: bgneal@45: if (o.source_view && ed.getParam('fullpage_hide_in_source_view')) bgneal@45: return; bgneal@45: bgneal@45: // Parse out head, body and footer bgneal@45: c = c.replace(/<(\/?)BODY/gi, '<$1body'); bgneal@45: sp = c.indexOf('
', sp); bgneal@45: t.head = c.substring(0, sp + 1); bgneal@45: bgneal@45: ep = c.indexOf('\n'; bgneal@45: bgneal@45: t.head += ed.getParam('fullpage_default_doctype', ''); bgneal@45: t.head += '\n\n\n