home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Plugins / tinymce-advanced / mce / fullscreen / editor_plugin.js next >
Encoding:
Text File  |  2008-02-20  |  7.5 KB  |  237 lines

  1. /**
  2.  * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
  3.  *
  4.  * @author Moxiecode
  5.  * @copyright Copyright ⌐ 2004-2007, Moxiecode Systems AB, All rights reserved.
  6.  */
  7.  
  8. // UK lang variables
  9. tadvmce = realTinyMCE;
  10. tadvmce.addToLang('',{
  11. fullscreen_desc : 'Toggle fullscreen mode'
  12. });
  13.  
  14. /* Import plugin specific language pack */
  15. tinyMCE.importPluginLanguagePack('fullscreen');
  16.  
  17. var TinyMCE_FullScreenPlugin = {
  18.     getInfo : function() {
  19.         return {
  20.             longname : 'Fullscreen',
  21.             author : 'Moxiecode Systems AB',
  22.             authorurl : 'http://tinymce.moxiecode.com',
  23.             infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen',
  24.             version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
  25.         };
  26.     },
  27.  
  28.     initInstance : function(inst) {
  29.         if (!tinyMCE.settings['fullscreen_skip_plugin_css'])
  30.             tinyMCE.importCSS(inst.getContainerWin().document, tinyMCE.baseURL + "/../../../wp-content/plugins/tinymce-advanced/mce/fullscreen/css/page.css");
  31.     },
  32.  
  33.     getControlHTML : function(cn) {
  34.         switch (cn) {
  35.             case "fullscreen":
  36.                 return tinyMCE.getButtonHTML(cn, 'lang_fullscreen_desc', '{$pluginurl}/images/fullscreen.gif', 'mceFullScreen');
  37.         }
  38.  
  39.         return "";
  40.     },
  41.  
  42.     execCommand : function(editor_id, element, command, user_interface, value) {
  43.         var inst;
  44.  
  45.         // Handle commands
  46.         switch (command) {
  47.             case "mceFullScreen":
  48.                 inst = tinyMCE.getInstanceById(editor_id);
  49.  
  50.                 if (tinyMCE.getParam('fullscreen_new_window'))
  51.                     this._toggleFullscreenWin(inst);
  52.                 else
  53.                     this._toggleFullscreen(inst);
  54.  
  55.                 return true;
  56.         }
  57.  
  58.         // Pass to next handler in chain
  59.         return false;
  60.     },
  61.  
  62.     _toggleFullscreenWin : function(inst) {
  63.         if (tinyMCE.getParam('fullscreen_is_enabled')) {
  64.             // In fullscreen mode
  65.             window.opener.tinyMCE.execInstanceCommand(tinyMCE.getParam('fullscreen_editor_id'), 'mceSetContent', false, tinyMCE.getContent(inst.editorId));
  66.             top.close();
  67.         } else {
  68.             tinyMCE.setWindowArg('editor_id', inst.editorId);
  69.  
  70.             var win = window.open(tinyMCE.baseURL + "/../../../wp-content/plugins/tinymce-advanced/mce/fullscreen/fullscreen.htm", "mceFullScreenPopup", "fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width=" + screen.availWidth + ",height=" + screen.availHeight);
  71.             try { win.resizeTo(screen.availWidth, screen.availHeight); } catch (e) {}
  72.         }
  73.     },
  74.  
  75.     _toggleFullscreen : function(inst) {
  76.         var ds = inst.getData('fullscreen'), editorContainer, tableElm, iframe, vp, cw, cd, re, w, h, si, blo, delta = 0, cell, row, fcml, bcml;
  77.  
  78.         cw = inst.getContainerWin();
  79.         cd = cw.document;
  80.         editorContainer = cd.getElementById(inst.editorId + '_parent');
  81.         tableElm = editorContainer.firstChild;
  82.         iframe = inst.iframeElement;
  83.         re = cd.getElementById(inst.editorId + '_resize');
  84.         blo = document.getElementById('mce_fullscreen_blocker');
  85.         fcm = new TinyMCE_Layer(inst.editorId + '_fcMenu');
  86.         fcml = new TinyMCE_Layer(inst.editorId + '_fcMenu');
  87.         bcml = new TinyMCE_Layer(inst.editorId + '_bcMenu');
  88.  
  89.         if (fcml.exists() && fcml.isVisible()) {
  90.             tinyMCE.switchClass(inst.editorId + '_forecolor', 'mceMenuButton');
  91.             fcml.hide();
  92.         }
  93.  
  94.         if (bcml.exists() && bcml.isVisible()) {
  95.             tinyMCE.switchClass(inst.editorId + '_backcolor', 'mceMenuButton');
  96.             bcml.hide();
  97.         }
  98.  
  99.         if (!ds.enabled) {
  100.             // Handle External Toolbar
  101.             if (inst.toolbarElement) {
  102.                 delta += inst.toolbarElement.offsetHeight;
  103.  
  104.                 cell = tableElm.tBodies[0].insertRow(0).insertCell(-1);
  105.                 cell.className = 'mceToolbarTop';
  106.                 cell.nowrap = true;
  107.  
  108.                 ds.oldToolbarParent = inst.toolbarElement.parentNode;
  109.                 ds.toolbarHolder = document.createTextNode('...');
  110.  
  111.                 cell.appendChild(ds.oldToolbarParent.replaceChild(ds.toolbarHolder, inst.toolbarElement));
  112.             }
  113.  
  114.             ds.parents = [];
  115.  
  116.             vp = tinyMCE.getViewPort(cw);
  117.             ds.scrollX = vp.left;
  118.             ds.scrollY = vp.top;
  119.  
  120.             // Opera has a bug restoring scrollbars
  121.             if (!tinyMCE.isOpera)
  122.                 tinyMCE.addCSSClass(cd.body, 'mceFullscreen');
  123.  
  124.             tinyMCE.getParentNode(tableElm.parentNode, function (n) {
  125.                 if (n.nodeName == 'BODY')
  126.                     return true;
  127.  
  128.                 if (n.nodeType == 1)
  129.                     tinyMCE.addCSSClass(n, 'mceFullscreenPos');
  130.  
  131.                 return false;
  132.             });
  133.  
  134.             if (re)
  135.                 re.style.display = 'none';
  136.  
  137.             vp = tinyMCE.getViewPort(cw);
  138.  
  139.             ds.oldWidth = iframe.style.width ? iframe.style.width : iframe.offsetWidth;
  140.             ds.oldHeight = iframe.style.height ? iframe.style.height : iframe.offsetHeight;
  141.             ds.oldTWidth = tableElm.style.width ? tableElm.style.width : tableElm.offsetWidth;
  142.             ds.oldTHeight = tableElm.style.height ? tableElm.style.height : tableElm.offsetHeight;
  143.  
  144.             // Handle % width
  145.             if (ds.oldWidth && ds.oldWidth.indexOf)
  146.                 ds.oldTWidth = ds.oldWidth.indexOf('%') != -1 ? ds.oldWidth : ds.oldTWidth;
  147.  
  148.             if (!blo && tinyMCE.isRealIE) {
  149.                 blo = tinyMCE.createTag(document, 'iframe', {id : 'mce_fullscreen_blocker', src : 'about:blank', frameBorder : 0, width : vp.width, height : vp.height, style : 'display: block; position: absolute; left: 0; top: 0; z-index: 999; margin: 0; padding: 0;'});
  150.                 document.body.appendChild(blo);
  151.             }
  152.  
  153.             tableElm.style.position = 'absolute';
  154.             tableElm.style.zIndex = 1000;
  155.             tableElm.style.left = tableElm.style.top = '0';
  156.  
  157.             tableElm.style.width = vp.width + 'px';
  158.             tableElm.style.height = vp.height + 'px';
  159.  
  160.             if (tinyMCE.isRealIE) {
  161.                 iframe.style.width = vp.width + 'px';
  162.                 iframe.style.height = vp.height + 'px';
  163.  
  164.                 // Calc new width/height based on overflow
  165.                 w = iframe.parentNode.clientWidth - (tableElm.offsetWidth - vp.width);
  166.                 h = iframe.parentNode.clientHeight - (tableElm.offsetHeight - vp.height);
  167.             } else {
  168.                 w = iframe.parentNode.clientWidth;
  169.                 h = iframe.parentNode.clientHeight;
  170.             }
  171.  
  172.             iframe.style.width = w + "px";
  173.             iframe.style.height = (h+delta) + "px";
  174.  
  175.             tinyMCE.switchClass(inst.editorId + '_fullscreen', 'mceButtonSelected');
  176.             ds.enabled = true;
  177.  
  178.             inst.useCSS = false;
  179.         } else {
  180.             // Handle External Toolbar
  181.             if (inst.toolbarElement) {
  182.                 row = inst.toolbarElement.parentNode.parentNode;
  183.  
  184.                 row.parentNode.removeChild(row);
  185.  
  186.                 ds.oldToolbarParent.replaceChild(inst.toolbarElement, ds.toolbarHolder);
  187.  
  188.                 ds.oldToolbarParent = null;
  189.                 ds.toolbarHolder = null;
  190.             }
  191.  
  192.             if (blo)
  193.                 blo.parentNode.removeChild(blo);
  194.  
  195.             si = 0;
  196.             tinyMCE.getParentNode(tableElm.parentNode, function (n) {
  197.                 if (n.nodeName == 'BODY')
  198.                     return true;
  199.  
  200.                 if (n.nodeType == 1)
  201.                     tinyMCE.removeCSSClass(n, 'mceFullscreenPos');
  202.             });
  203.  
  204.             if (re && tinyMCE.getParam("theme_advanced_resizing", false))
  205.                 re.style.display = 'block';
  206.  
  207.             tableElm.style.position = 'static';
  208.             tableElm.style.zIndex = '';
  209.             tableElm.style.width = '';
  210.             tableElm.style.height = '';
  211.  
  212.             tableElm.style.width = ds.oldTWidth ? ds.oldTWidth : '';
  213.             tableElm.style.height = ds.oldTHeight ? ds.oldTHeight : '';
  214.  
  215.             iframe.style.width = ds.oldWidth ? ds.oldWidth : '';
  216.             iframe.style.height = ds.oldHeight ? ds.oldHeight : '';
  217.  
  218.             tinyMCE.switchClass(inst.editorId + '_fullscreen', 'mceButtonNormal');
  219.             ds.enabled = false;
  220.  
  221.             tinyMCE.removeCSSClass(cd.body, 'mceFullscreen');
  222.             cw.scrollTo(ds.scrollX, ds.scrollY);
  223.  
  224.             inst.useCSS = false;
  225.         }
  226.     },
  227.  
  228.     handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
  229.         if (tinyMCE.getParam('fullscreen_is_enabled'))
  230.             tinyMCE.switchClass(editor_id + '_fullscreen', 'mceButtonSelected');
  231.  
  232.         return true;
  233.     }
  234. };
  235.  
  236. tinyMCE.addPlugin("fullscreen", TinyMCE_FullScreenPlugin);
  237.