tinymce.ThemeManager.add('modern', function(editor) {
var self = this, settings = editor.settings, Factory = tinymce.ui.Factory,
- each = tinymce.each, DOM = tinymce.DOM, Rect = tinymce.ui.Rect, FloatPanel = tinymce.ui.FloatPanel;
+ each = tinymce.each, DOM = tinymce.DOM, Rect = tinymce.geom.Rect, FloatPanel = tinymce.ui.FloatPanel;
// Default menus
var defaultMenus = {
panelRect = tinymce.DOM.getRect(panel.getEl());
contentAreaRect = tinymce.DOM.getRect(editor.getContentAreaContainer() || editor.getBody());
+ // We need to use these instead of the rect values since the style
+ // size properites might not be the same as the real size for a table
+ elementRect.w = match.element.clientWidth;
+ elementRect.h = match.element.clientHeight;
+
if (!editor.inline) {
contentAreaRect.w = editor.getDoc().documentElement.offsetWidth;
}
// Inflate the elementRect so it doesn't get placed above resize handles
if (editor.selection.controlSelection.isResizable(match.element)) {
- elementRect = Rect.inflate(elementRect, 0, 7);
+ elementRect = Rect.inflate(elementRect, 0, 8);
}
relPos = Rect.findBestRelativePosition(panelRect, elementRect, contentAreaRect, testPositions);
}
}
- if (window.requestAnimationFrame) {
- window.requestAnimationFrame(execute);
- } else {
- execute();
- }
+ tinymce.util.Delay.requestAnimationFrame(execute);
}
function bindScrollEvent() {
return null;
}
- editor.on('click keyup', function() {
+ editor.on('click keyup setContent', function(e) {
+ // Only act on partial inserts
+ if (e.type == 'setcontent' && !e.selection) {
+ return;
+ }
+
// Needs to be delayed to avoid Chrome img focus out bug
- window.setTimeout(function() {
+ tinymce.util.Delay.setEditorTimeout(editor, function() {
var match;
- if (editor.removed) {
- return;
- }
-
match = findFrontMostMatch(editor.selection.getNode());
if (match) {
+ hideAllContextToolbars();
showContextToolbar(match);
} else {
hideAllContextToolbars();
}
- }, 0);
+ });
});
editor.on('blur hide', hideAllContextToolbars);
});
}
+ function fireSkinLoaded(editor) {
+ return function() {
+ if (editor.initialized) {
+ editor.fire('SkinLoaded');
+ } else {
+ editor.on('init', function() {
+ editor.fire('SkinLoaded');
+ });
+ }
+ };
+ }
+
/**
* Renders the inline editor UI.
*
// Preload skin css
if (args.skinUiCss) {
- tinymce.DOM.styleSheetLoader.load(args.skinUiCss);
+ tinymce.DOM.styleSheetLoader.load(args.skinUiCss, fireSkinLoaded(editor));
}
return {};
function renderIframeUI(args) {
var panel, resizeHandleCtrl, startSize;
+ function switchMode() {
+ return function(e) {
+ if (e.mode == 'readonly') {
+ panel.find('*').disabled(true);
+ } else {
+ panel.find('*').disabled(false);
+ }
+ };
+ }
+
if (args.skinUiCss) {
- tinymce.DOM.loadCSS(args.skinUiCss);
+ tinymce.DOM.styleSheetLoader.load(args.skinUiCss, fireSkinLoaded(editor));
}
// Basic UI layout
]});
}
- if (settings.readonly) {
- panel.find('*').disabled(true);
- }
-
editor.fire('BeforeRenderUI');
+ editor.on('SwitchMode', switchMode());
panel.renderBefore(args.targetNode).reflow();
+ if (settings.readonly) {
+ editor.setMode('readonly');
+ }
+
if (settings.width) {
tinymce.DOM.setStyle(panel.getEl(), 'width', settings.width);
}