[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 (function () { 2 var fullscreen = (function (domGlobals) { 3 'use strict'; 4 5 var Cell = function (initial) { 6 var value = initial; 7 var get = function () { 8 return value; 9 }; 10 var set = function (v) { 11 value = v; 12 }; 13 var clone = function () { 14 return Cell(get()); 15 }; 16 return { 17 get: get, 18 set: set, 19 clone: clone 20 }; 21 }; 22 23 var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); 24 25 var get = function (fullscreenState) { 26 return { 27 isFullscreen: function () { 28 return fullscreenState.get() !== null; 29 } 30 }; 31 }; 32 var Api = { get: get }; 33 34 var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); 35 36 var fireFullscreenStateChanged = function (editor, state) { 37 editor.fire('FullscreenStateChanged', { state: state }); 38 }; 39 var Events = { fireFullscreenStateChanged: fireFullscreenStateChanged }; 40 41 var DOM = global$1.DOM; 42 var getWindowSize = function () { 43 var w; 44 var h; 45 var win = domGlobals.window; 46 var doc = domGlobals.document; 47 var body = doc.body; 48 if (body.offsetWidth) { 49 w = body.offsetWidth; 50 h = body.offsetHeight; 51 } 52 if (win.innerWidth && win.innerHeight) { 53 w = win.innerWidth; 54 h = win.innerHeight; 55 } 56 return { 57 w: w, 58 h: h 59 }; 60 }; 61 var getScrollPos = function () { 62 var vp = DOM.getViewPort(); 63 return { 64 x: vp.x, 65 y: vp.y 66 }; 67 }; 68 var setScrollPos = function (pos) { 69 domGlobals.window.scrollTo(pos.x, pos.y); 70 }; 71 var toggleFullscreen = function (editor, fullscreenState) { 72 var body = domGlobals.document.body; 73 var documentElement = domGlobals.document.documentElement; 74 var editorContainerStyle; 75 var editorContainer, iframe, iframeStyle; 76 var fullscreenInfo = fullscreenState.get(); 77 var resize = function () { 78 DOM.setStyle(iframe, 'height', getWindowSize().h - (editorContainer.clientHeight - iframe.clientHeight)); 79 }; 80 var removeResize = function () { 81 DOM.unbind(domGlobals.window, 'resize', resize); 82 }; 83 editorContainer = editor.getContainer(); 84 editorContainerStyle = editorContainer.style; 85 iframe = editor.getContentAreaContainer().firstChild; 86 iframeStyle = iframe.style; 87 if (!fullscreenInfo) { 88 var newFullScreenInfo = { 89 scrollPos: getScrollPos(), 90 containerWidth: editorContainerStyle.width, 91 containerHeight: editorContainerStyle.height, 92 iframeWidth: iframeStyle.width, 93 iframeHeight: iframeStyle.height, 94 resizeHandler: resize, 95 removeHandler: removeResize 96 }; 97 iframeStyle.width = iframeStyle.height = '100%'; 98 editorContainerStyle.width = editorContainerStyle.height = ''; 99 DOM.addClass(body, 'mce-fullscreen'); 100 DOM.addClass(documentElement, 'mce-fullscreen'); 101 DOM.addClass(editorContainer, 'mce-fullscreen'); 102 DOM.bind(domGlobals.window, 'resize', resize); 103 editor.on('remove', removeResize); 104 resize(); 105 fullscreenState.set(newFullScreenInfo); 106 Events.fireFullscreenStateChanged(editor, true); 107 } else { 108 iframeStyle.width = fullscreenInfo.iframeWidth; 109 iframeStyle.height = fullscreenInfo.iframeHeight; 110 if (fullscreenInfo.containerWidth) { 111 editorContainerStyle.width = fullscreenInfo.containerWidth; 112 } 113 if (fullscreenInfo.containerHeight) { 114 editorContainerStyle.height = fullscreenInfo.containerHeight; 115 } 116 DOM.removeClass(body, 'mce-fullscreen'); 117 DOM.removeClass(documentElement, 'mce-fullscreen'); 118 DOM.removeClass(editorContainer, 'mce-fullscreen'); 119 setScrollPos(fullscreenInfo.scrollPos); 120 DOM.unbind(domGlobals.window, 'resize', fullscreenInfo.resizeHandler); 121 editor.off('remove', fullscreenInfo.removeHandler); 122 fullscreenState.set(null); 123 Events.fireFullscreenStateChanged(editor, false); 124 } 125 }; 126 var Actions = { toggleFullscreen: toggleFullscreen }; 127 128 var register = function (editor, fullscreenState) { 129 editor.addCommand('mceFullScreen', function () { 130 Actions.toggleFullscreen(editor, fullscreenState); 131 }); 132 }; 133 var Commands = { register: register }; 134 135 var postRender = function (editor) { 136 return function (e) { 137 var ctrl = e.control; 138 editor.on('FullscreenStateChanged', function (e) { 139 ctrl.active(e.state); 140 }); 141 }; 142 }; 143 var register$1 = function (editor) { 144 editor.addMenuItem('fullscreen', { 145 text: 'Fullscreen', 146 shortcut: 'Ctrl+Shift+F', 147 selectable: true, 148 cmd: 'mceFullScreen', 149 onPostRender: postRender(editor), 150 context: 'view' 151 }); 152 editor.addButton('fullscreen', { 153 active: false, 154 tooltip: 'Fullscreen', 155 cmd: 'mceFullScreen', 156 onPostRender: postRender(editor) 157 }); 158 }; 159 var Buttons = { register: register$1 }; 160 161 global.add('fullscreen', function (editor) { 162 var fullscreenState = Cell(null); 163 if (editor.settings.inline) { 164 return Api.get(fullscreenState); 165 } 166 Commands.register(editor, fullscreenState); 167 Buttons.register(editor); 168 editor.addShortcut('Ctrl+Shift+F', '', 'mceFullScreen'); 169 return Api.get(fullscreenState); 170 }); 171 function Plugin () { 172 } 173 174 return Plugin; 175 176 }(window)); 177 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Nov 23 08:20:01 2024 | Cross-referenced by PHPXref |