first commit
This commit is contained in:
63
js/tinymce/classes/ui/AbsoluteLayout.js
Normal file
63
js/tinymce/classes/ui/AbsoluteLayout.js
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* AbsoluteLayout.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* LayoutManager for absolute positioning. This layout manager is more of
|
||||
* a base class for other layouts but can be created and used directly.
|
||||
*
|
||||
* @-x-less AbsoluteLayout.less
|
||||
* @class tinymce.ui.AbsoluteLayout
|
||||
* @extends tinymce.ui.Layout
|
||||
*/
|
||||
define("tinymce/ui/AbsoluteLayout", [
|
||||
"tinymce/ui/Layout"
|
||||
], function(Layout) {
|
||||
"use strict";
|
||||
|
||||
return Layout.extend({
|
||||
Defaults: {
|
||||
containerClass: 'abs-layout',
|
||||
controlClass: 'abs-layout-item'
|
||||
},
|
||||
|
||||
/**
|
||||
* Recalculates the positions of the controls in the specified container.
|
||||
*
|
||||
* @method recalc
|
||||
* @param {tinymce.ui.Container} container Container instance to recalc.
|
||||
*/
|
||||
recalc: function(container) {
|
||||
container.items().filter(':visible').each(function(ctrl) {
|
||||
var settings = ctrl.settings;
|
||||
|
||||
ctrl.layoutRect({
|
||||
x: settings.x,
|
||||
y: settings.y,
|
||||
w: settings.w,
|
||||
h: settings.h
|
||||
});
|
||||
|
||||
if (ctrl.recalc) {
|
||||
ctrl.recalc();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the specified container and any layout specific HTML.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @param {tinymce.ui.Container} container Container to render HTML for.
|
||||
*/
|
||||
renderHtml: function(container) {
|
||||
return '<div id="' + container._id + '-absend" class="' + container.classPrefix + 'abs-end"></div>' + this._super(container);
|
||||
}
|
||||
});
|
||||
});
|
||||
98
js/tinymce/classes/ui/BoxUtils.js
Normal file
98
js/tinymce/classes/ui/BoxUtils.js
Normal file
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* BoxUtils.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Utility class for box parsing and measuring.
|
||||
*
|
||||
* @private
|
||||
* @class tinymce.ui.BoxUtils
|
||||
*/
|
||||
define("tinymce/ui/BoxUtils", [
|
||||
], function() {
|
||||
"use strict";
|
||||
|
||||
return {
|
||||
/**
|
||||
* Parses the specified box value. A box value contains 1-4 properties in clockwise order.
|
||||
*
|
||||
* @method parseBox
|
||||
* @param {String/Number} value Box value "0 1 2 3" or "0" etc.
|
||||
* @return {Object} Object with top/right/bottom/left properties.
|
||||
* @private
|
||||
*/
|
||||
parseBox: function(value) {
|
||||
var len, radix = 10;
|
||||
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof value === "number") {
|
||||
value = value || 0;
|
||||
|
||||
return {
|
||||
top: value,
|
||||
left: value,
|
||||
bottom: value,
|
||||
right: value
|
||||
};
|
||||
}
|
||||
|
||||
value = value.split(' ');
|
||||
len = value.length;
|
||||
|
||||
if (len === 1) {
|
||||
value[1] = value[2] = value[3] = value[0];
|
||||
} else if (len === 2) {
|
||||
value[2] = value[0];
|
||||
value[3] = value[1];
|
||||
} else if (len === 3) {
|
||||
value[3] = value[1];
|
||||
}
|
||||
|
||||
return {
|
||||
top: parseInt(value[0], radix) || 0,
|
||||
right: parseInt(value[1], radix) || 0,
|
||||
bottom: parseInt(value[2], radix) || 0,
|
||||
left: parseInt(value[3], radix) || 0
|
||||
};
|
||||
},
|
||||
|
||||
measureBox: function(elm, prefix) {
|
||||
function getStyle(name) {
|
||||
var defaultView = document.defaultView;
|
||||
|
||||
if (defaultView) {
|
||||
// Remove camelcase
|
||||
name = name.replace(/[A-Z]/g, function(a) {
|
||||
return '-' + a;
|
||||
});
|
||||
|
||||
return defaultView.getComputedStyle(elm, null).getPropertyValue(name);
|
||||
}
|
||||
|
||||
return elm.currentStyle[name];
|
||||
}
|
||||
|
||||
function getSide(name) {
|
||||
var val = parseFloat(getStyle(name), 10);
|
||||
|
||||
return isNaN(val) ? 0 : val;
|
||||
}
|
||||
|
||||
return {
|
||||
top: getSide(prefix + "TopWidth"),
|
||||
right: getSide(prefix + "RightWidth"),
|
||||
bottom: getSide(prefix + "BottomWidth"),
|
||||
left: getSide(prefix + "LeftWidth")
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
199
js/tinymce/classes/ui/Button.js
Normal file
199
js/tinymce/classes/ui/Button.js
Normal file
@@ -0,0 +1,199 @@
|
||||
/**
|
||||
* Button.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used to create buttons. You can create them directly or through the Factory.
|
||||
*
|
||||
* @example
|
||||
* // Create and render a button to the body element
|
||||
* tinymce.ui.Factory.create({
|
||||
* type: 'button',
|
||||
* text: 'My button'
|
||||
* }).renderTo(document.body);
|
||||
*
|
||||
* @-x-less Button.less
|
||||
* @class tinymce.ui.Button
|
||||
* @extends tinymce.ui.Widget
|
||||
*/
|
||||
define("tinymce/ui/Button", [
|
||||
"tinymce/ui/Widget"
|
||||
], function(Widget) {
|
||||
"use strict";
|
||||
|
||||
return Widget.extend({
|
||||
Defaults: {
|
||||
classes: "widget btn",
|
||||
role: "button"
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructs a new button instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
* @setting {String} size Size of the button small|medium|large.
|
||||
* @setting {String} image Image to use for icon.
|
||||
* @setting {String} icon Icon to use for button.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this, size;
|
||||
|
||||
self._super(settings);
|
||||
settings = self.settings;
|
||||
|
||||
size = self.settings.size;
|
||||
|
||||
self.on('click mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
self.on('touchstart', function(e) {
|
||||
self.fire('click', e);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
if (settings.subtype) {
|
||||
self.classes.add(settings.subtype);
|
||||
}
|
||||
|
||||
if (size) {
|
||||
self.classes.add('btn-' + size);
|
||||
}
|
||||
|
||||
if (settings.icon) {
|
||||
self.icon(settings.icon);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets/gets the current button icon.
|
||||
*
|
||||
* @method icon
|
||||
* @param {String} [icon] New icon identifier.
|
||||
* @return {String|tinymce.ui.MenuButton} Current icon or current MenuButton instance.
|
||||
*/
|
||||
icon: function(icon) {
|
||||
if (!arguments.length) {
|
||||
return this.state.get('icon');
|
||||
}
|
||||
|
||||
this.state.set('icon', icon);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Repaints the button for example after it's been resizes by a layout engine.
|
||||
*
|
||||
* @method repaint
|
||||
*/
|
||||
repaint: function() {
|
||||
var btnElm = this.getEl().firstChild,
|
||||
btnStyle;
|
||||
|
||||
if (btnElm) {
|
||||
btnStyle = btnElm.style;
|
||||
btnStyle.width = btnStyle.height = "100%";
|
||||
}
|
||||
|
||||
this._super();
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, id = self._id, prefix = self.classPrefix;
|
||||
var icon = self.state.get('icon'), image, text = self.state.get('text'), textHtml = '';
|
||||
|
||||
image = self.settings.image;
|
||||
if (image) {
|
||||
icon = 'none';
|
||||
|
||||
// Support for [high dpi, low dpi] image sources
|
||||
if (typeof image != "string") {
|
||||
image = window.getSelection ? image[0] : image[1];
|
||||
}
|
||||
|
||||
image = ' style="background-image: url(\'' + image + '\')"';
|
||||
} else {
|
||||
image = '';
|
||||
}
|
||||
|
||||
if (text) {
|
||||
self.classes.add('btn-has-text');
|
||||
textHtml = '<span class="' + prefix + 'txt">' + self.encode(text) + '</span>';
|
||||
}
|
||||
|
||||
icon = self.settings.icon ? prefix + 'ico ' + prefix + 'i-' + icon : '';
|
||||
|
||||
return (
|
||||
'<div id="' + id + '" class="' + self.classes + '" tabindex="-1" aria-labelledby="' + id + '">' +
|
||||
'<button role="presentation" type="button" tabindex="-1">' +
|
||||
(icon ? '<i class="' + icon + '"' + image + '></i>' : '') +
|
||||
textHtml +
|
||||
'</button>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this, $ = self.$, textCls = self.classPrefix + 'txt';
|
||||
|
||||
function setButtonText(text) {
|
||||
var $span = $('span.' + textCls, self.getEl());
|
||||
|
||||
if (text) {
|
||||
if (!$span[0]) {
|
||||
$('button:first', self.getEl()).append('<span class="' + textCls + '"></span>');
|
||||
$span = $('span.' + textCls, self.getEl());
|
||||
}
|
||||
|
||||
$span.html(self.encode(text));
|
||||
} else {
|
||||
$span.remove();
|
||||
}
|
||||
|
||||
self.classes.toggle('btn-has-text', !!text);
|
||||
}
|
||||
|
||||
self.state.on('change:text', function(e) {
|
||||
setButtonText(e.value);
|
||||
});
|
||||
|
||||
self.state.on('change:icon', function(e) {
|
||||
var icon = e.value, prefix = self.classPrefix;
|
||||
|
||||
self.settings.icon = icon;
|
||||
icon = icon ? prefix + 'ico ' + prefix + 'i-' + self.settings.icon : '';
|
||||
|
||||
var btnElm = self.getEl().firstChild, iconElm = btnElm.getElementsByTagName('i')[0];
|
||||
|
||||
if (icon) {
|
||||
if (!iconElm || iconElm != btnElm.firstChild) {
|
||||
iconElm = document.createElement('i');
|
||||
btnElm.insertBefore(iconElm, btnElm.firstChild);
|
||||
}
|
||||
|
||||
iconElm.className = icon;
|
||||
} else if (iconElm) {
|
||||
btnElm.removeChild(iconElm);
|
||||
}
|
||||
|
||||
setButtonText(self.state.get('text'));
|
||||
});
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
62
js/tinymce/classes/ui/ButtonGroup.js
Normal file
62
js/tinymce/classes/ui/ButtonGroup.js
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* ButtonGroup.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This control enables you to put multiple buttons into a group. This is
|
||||
* useful when you want to combine similar toolbar buttons into a group.
|
||||
*
|
||||
* @example
|
||||
* // Create and render a buttongroup with two buttons to the body element
|
||||
* tinymce.ui.Factory.create({
|
||||
* type: 'buttongroup',
|
||||
* items: [
|
||||
* {text: 'Button A'},
|
||||
* {text: 'Button B'}
|
||||
* ]
|
||||
* }).renderTo(document.body);
|
||||
*
|
||||
* @-x-less ButtonGroup.less
|
||||
* @class tinymce.ui.ButtonGroup
|
||||
* @extends tinymce.ui.Container
|
||||
*/
|
||||
define("tinymce/ui/ButtonGroup", [
|
||||
"tinymce/ui/Container"
|
||||
], function(Container) {
|
||||
"use strict";
|
||||
|
||||
return Container.extend({
|
||||
Defaults: {
|
||||
defaultType: 'button',
|
||||
role: 'group'
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, layout = self._layout;
|
||||
|
||||
self.classes.add('btn-group');
|
||||
self.preRender();
|
||||
layout.preRender(self);
|
||||
|
||||
return (
|
||||
'<div id="' + self._id + '" class="' + self.classes + '">' +
|
||||
'<div id="' + self._id + '-body">' +
|
||||
(self.settings.html || '') + layout.renderHtml(self) +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
162
js/tinymce/classes/ui/Checkbox.js
Normal file
162
js/tinymce/classes/ui/Checkbox.js
Normal file
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* Checkbox.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This control creates a custom checkbox.
|
||||
*
|
||||
* @example
|
||||
* // Create and render a checkbox to the body element
|
||||
* tinymce.ui.Factory.create({
|
||||
* type: 'checkbox',
|
||||
* checked: true,
|
||||
* text: 'My checkbox'
|
||||
* }).renderTo(document.body);
|
||||
*
|
||||
* @-x-less Checkbox.less
|
||||
* @class tinymce.ui.Checkbox
|
||||
* @extends tinymce.ui.Widget
|
||||
*/
|
||||
define("tinymce/ui/Checkbox", [
|
||||
"tinymce/ui/Widget"
|
||||
], function(Widget) {
|
||||
"use strict";
|
||||
|
||||
return Widget.extend({
|
||||
Defaults: {
|
||||
classes: "checkbox",
|
||||
role: "checkbox",
|
||||
checked: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructs a new Checkbox instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
* @setting {Boolean} checked True if the checkbox should be checked by default.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
self._super(settings);
|
||||
|
||||
self.on('click mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
self.on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!self.disabled()) {
|
||||
self.checked(!self.checked());
|
||||
}
|
||||
});
|
||||
|
||||
self.checked(self.settings.checked);
|
||||
},
|
||||
|
||||
/**
|
||||
* Getter/setter function for the checked state.
|
||||
*
|
||||
* @method checked
|
||||
* @param {Boolean} [state] State to be set.
|
||||
* @return {Boolean|tinymce.ui.Checkbox} True/false or checkbox if it's a set operation.
|
||||
*/
|
||||
checked: function(state) {
|
||||
if (!arguments.length) {
|
||||
return this.state.get('checked');
|
||||
}
|
||||
|
||||
this.state.set('checked', state);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Getter/setter function for the value state.
|
||||
*
|
||||
* @method value
|
||||
* @param {Boolean} [state] State to be set.
|
||||
* @return {Boolean|tinymce.ui.Checkbox} True/false or checkbox if it's a set operation.
|
||||
*/
|
||||
value: function(state) {
|
||||
if (!arguments.length) {
|
||||
return this.checked();
|
||||
}
|
||||
|
||||
return this.checked(state);
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, id = self._id, prefix = self.classPrefix;
|
||||
|
||||
return (
|
||||
'<div id="' + id + '" class="' + self.classes + '" unselectable="on" aria-labelledby="' + id + '-al" tabindex="-1">' +
|
||||
'<i class="' + prefix + 'ico ' + prefix + 'i-checkbox"></i>' +
|
||||
'<span id="' + id + '-al" class="' + prefix + 'label">' + self.encode(self.state.get('text')) + '</span>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
function checked(state) {
|
||||
self.classes.toggle("checked", state);
|
||||
self.aria('checked', state);
|
||||
}
|
||||
|
||||
self.state.on('change:text', function(e) {
|
||||
self.getEl('al').firstChild.data = self.translate(e.value);
|
||||
});
|
||||
|
||||
self.state.on('change:checked change:value', function(e) {
|
||||
self.fire('change');
|
||||
checked(e.value);
|
||||
});
|
||||
|
||||
self.state.on('change:icon', function(e) {
|
||||
var icon = e.value, prefix = self.classPrefix;
|
||||
|
||||
if (typeof icon == 'undefined') {
|
||||
return self.settings.icon;
|
||||
}
|
||||
|
||||
self.settings.icon = icon;
|
||||
icon = icon ? prefix + 'ico ' + prefix + 'i-' + self.settings.icon : '';
|
||||
|
||||
var btnElm = self.getEl().firstChild, iconElm = btnElm.getElementsByTagName('i')[0];
|
||||
|
||||
if (icon) {
|
||||
if (!iconElm || iconElm != btnElm.firstChild) {
|
||||
iconElm = document.createElement('i');
|
||||
btnElm.insertBefore(iconElm, btnElm.firstChild);
|
||||
}
|
||||
|
||||
iconElm.className = icon;
|
||||
} else if (iconElm) {
|
||||
btnElm.removeChild(iconElm);
|
||||
}
|
||||
});
|
||||
|
||||
if (self.state.get('checked')) {
|
||||
checked(true);
|
||||
}
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
149
js/tinymce/classes/ui/ClassList.js
Normal file
149
js/tinymce/classes/ui/ClassList.js
Normal file
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* ClassList.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles adding and removal of classes.
|
||||
*
|
||||
* @private
|
||||
* @class tinymce.ui.ClassList
|
||||
*/
|
||||
define("tinymce/ui/ClassList", [
|
||||
"tinymce/util/Tools"
|
||||
], function(Tools) {
|
||||
"use strict";
|
||||
|
||||
function noop() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new class list the specified onchange
|
||||
* callback will be executed when the class list gets modifed.
|
||||
*
|
||||
* @constructor ClassList
|
||||
* @param {function} onchange Onchange callback to be executed.
|
||||
*/
|
||||
function ClassList(onchange) {
|
||||
this.cls = [];
|
||||
this.cls._map = {};
|
||||
this.onchange = onchange || noop;
|
||||
this.prefix = '';
|
||||
}
|
||||
|
||||
Tools.extend(ClassList.prototype, {
|
||||
/**
|
||||
* Adds a new class to the class list.
|
||||
*
|
||||
* @method add
|
||||
* @param {String} cls Class to be added.
|
||||
* @return {tinymce.ui.ClassList} Current class list instance.
|
||||
*/
|
||||
add: function(cls) {
|
||||
if (cls && !this.contains(cls)) {
|
||||
this.cls._map[cls] = true;
|
||||
this.cls.push(cls);
|
||||
this._change();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the specified class from the class list.
|
||||
*
|
||||
* @method remove
|
||||
* @param {String} cls Class to be removed.
|
||||
* @return {tinymce.ui.ClassList} Current class list instance.
|
||||
*/
|
||||
remove: function(cls) {
|
||||
if (this.contains(cls)) {
|
||||
for (var i = 0; i < this.cls.length; i++) {
|
||||
if (this.cls[i] === cls) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.cls.splice(i, 1);
|
||||
delete this.cls._map[cls];
|
||||
this._change();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggles a class in the class list.
|
||||
*
|
||||
* @method toggle
|
||||
* @param {String} cls Class to be added/removed.
|
||||
* @param {Boolean} state Optional state if it should be added/removed.
|
||||
* @return {tinymce.ui.ClassList} Current class list instance.
|
||||
*/
|
||||
toggle: function(cls, state) {
|
||||
var curState = this.contains(cls);
|
||||
|
||||
if (curState !== state) {
|
||||
if (curState) {
|
||||
this.remove(cls);
|
||||
} else {
|
||||
this.add(cls);
|
||||
}
|
||||
|
||||
this._change();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true if the class list has the specified class.
|
||||
*
|
||||
* @method contains
|
||||
* @param {String} cls Class to look for.
|
||||
* @return {Boolean} true/false if the class exists or not.
|
||||
*/
|
||||
contains: function(cls) {
|
||||
return !!this.cls._map[cls];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a space separated list of classes.
|
||||
*
|
||||
* @method toString
|
||||
* @return {String} Space separated list of classes.
|
||||
*/
|
||||
|
||||
_change: function() {
|
||||
delete this.clsValue;
|
||||
this.onchange.call(this);
|
||||
}
|
||||
});
|
||||
|
||||
// IE 8 compatibility
|
||||
ClassList.prototype.toString = function() {
|
||||
var value;
|
||||
|
||||
if (this.clsValue) {
|
||||
return this.clsValue;
|
||||
}
|
||||
|
||||
value = '';
|
||||
for (var i = 0; i < this.cls.length; i++) {
|
||||
if (i > 0) {
|
||||
value += ' ';
|
||||
}
|
||||
|
||||
value += this.prefix + this.cls[i];
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
return ClassList;
|
||||
});
|
||||
438
js/tinymce/classes/ui/Collection.js
Normal file
438
js/tinymce/classes/ui/Collection.js
Normal file
@@ -0,0 +1,438 @@
|
||||
/**
|
||||
* Collection.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Control collection, this class contains control instances and it enables you to
|
||||
* perform actions on all the contained items. This is very similar to how jQuery works.
|
||||
*
|
||||
* @example
|
||||
* someCollection.show().disabled(true);
|
||||
*
|
||||
* @class tinymce.ui.Collection
|
||||
*/
|
||||
define("tinymce/ui/Collection", [
|
||||
"tinymce/util/Tools",
|
||||
"tinymce/ui/Selector",
|
||||
"tinymce/util/Class"
|
||||
], function(Tools, Selector, Class) {
|
||||
"use strict";
|
||||
|
||||
var Collection, proto, push = Array.prototype.push, slice = Array.prototype.slice;
|
||||
|
||||
proto = {
|
||||
/**
|
||||
* Current number of contained control instances.
|
||||
*
|
||||
* @field length
|
||||
* @type Number
|
||||
*/
|
||||
length: 0,
|
||||
|
||||
/**
|
||||
* Constructor for the collection.
|
||||
*
|
||||
* @constructor
|
||||
* @method init
|
||||
* @param {Array} items Optional array with items to add.
|
||||
*/
|
||||
init: function(items) {
|
||||
if (items) {
|
||||
this.add(items);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds new items to the control collection.
|
||||
*
|
||||
* @method add
|
||||
* @param {Array} items Array if items to add to collection.
|
||||
* @return {tinymce.ui.Collection} Current collection instance.
|
||||
*/
|
||||
add: function(items) {
|
||||
var self = this;
|
||||
|
||||
// Force single item into array
|
||||
if (!Tools.isArray(items)) {
|
||||
if (items instanceof Collection) {
|
||||
self.add(items.toArray());
|
||||
} else {
|
||||
push.call(self, items);
|
||||
}
|
||||
} else {
|
||||
push.apply(self, items);
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the contents of the collection. This will remove any existing items
|
||||
* and replace them with the ones specified in the input array.
|
||||
*
|
||||
* @method set
|
||||
* @param {Array} items Array with items to set into the Collection.
|
||||
* @return {tinymce.ui.Collection} Collection instance.
|
||||
*/
|
||||
set: function(items) {
|
||||
var self = this, len = self.length, i;
|
||||
|
||||
self.length = 0;
|
||||
self.add(items);
|
||||
|
||||
// Remove old entries
|
||||
for (i = self.length; i < len; i++) {
|
||||
delete self[i];
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Filters the collection item based on the specified selector expression or selector function.
|
||||
*
|
||||
* @method filter
|
||||
* @param {String} selector Selector expression to filter items by.
|
||||
* @return {tinymce.ui.Collection} Collection containing the filtered items.
|
||||
*/
|
||||
filter: function(selector) {
|
||||
var self = this, i, l, matches = [], item, match;
|
||||
|
||||
// Compile string into selector expression
|
||||
if (typeof selector === "string") {
|
||||
selector = new Selector(selector);
|
||||
|
||||
match = function(item) {
|
||||
return selector.match(item);
|
||||
};
|
||||
} else {
|
||||
// Use selector as matching function
|
||||
match = selector;
|
||||
}
|
||||
|
||||
for (i = 0, l = self.length; i < l; i++) {
|
||||
item = self[i];
|
||||
|
||||
if (match(item)) {
|
||||
matches.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
return new Collection(matches);
|
||||
},
|
||||
|
||||
/**
|
||||
* Slices the items within the collection.
|
||||
*
|
||||
* @method slice
|
||||
* @param {Number} index Index to slice at.
|
||||
* @param {Number} len Optional length to slice.
|
||||
* @return {tinymce.ui.Collection} Current collection.
|
||||
*/
|
||||
slice: function() {
|
||||
return new Collection(slice.apply(this, arguments));
|
||||
},
|
||||
|
||||
/**
|
||||
* Makes the current collection equal to the specified index.
|
||||
*
|
||||
* @method eq
|
||||
* @param {Number} index Index of the item to set the collection to.
|
||||
* @return {tinymce.ui.Collection} Current collection.
|
||||
*/
|
||||
eq: function(index) {
|
||||
return index === -1 ? this.slice(index) : this.slice(index, +index + 1);
|
||||
},
|
||||
|
||||
/**
|
||||
* Executes the specified callback on each item in collection.
|
||||
*
|
||||
* @method each
|
||||
* @param {function} callback Callback to execute for each item in collection.
|
||||
* @return {tinymce.ui.Collection} Current collection instance.
|
||||
*/
|
||||
each: function(callback) {
|
||||
Tools.each(this, callback);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an JavaScript array object of the contents inside the collection.
|
||||
*
|
||||
* @method toArray
|
||||
* @return {Array} Array with all items from collection.
|
||||
*/
|
||||
toArray: function() {
|
||||
return Tools.toArray(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Finds the index of the specified control or return -1 if it isn't in the collection.
|
||||
*
|
||||
* @method indexOf
|
||||
* @param {Control} ctrl Control instance to look for.
|
||||
* @return {Number} Index of the specified control or -1.
|
||||
*/
|
||||
indexOf: function(ctrl) {
|
||||
var self = this, i = self.length;
|
||||
|
||||
while (i--) {
|
||||
if (self[i] === ctrl) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a new collection of the contents in reverse order.
|
||||
*
|
||||
* @method reverse
|
||||
* @return {tinymce.ui.Collection} Collection instance with reversed items.
|
||||
*/
|
||||
reverse: function() {
|
||||
return new Collection(Tools.toArray(this).reverse());
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true/false if the class exists or not.
|
||||
*
|
||||
* @method hasClass
|
||||
* @param {String} cls Class to check for.
|
||||
* @return {Boolean} true/false state if the class exists or not.
|
||||
*/
|
||||
hasClass: function(cls) {
|
||||
return this[0] ? this[0].classes.contains(cls) : false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets/gets the specific property on the items in the collection. The same as executing control.<property>(<value>);
|
||||
*
|
||||
* @method prop
|
||||
* @param {String} name Property name to get/set.
|
||||
* @param {Object} value Optional object value to set.
|
||||
* @return {tinymce.ui.Collection} Current collection instance or value of the first item on a get operation.
|
||||
*/
|
||||
prop: function(name, value) {
|
||||
var self = this, undef, item;
|
||||
|
||||
if (value !== undef) {
|
||||
self.each(function(item) {
|
||||
if (item[name]) {
|
||||
item[name](value);
|
||||
}
|
||||
});
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
item = self[0];
|
||||
|
||||
if (item && item[name]) {
|
||||
return item[name]();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Executes the specific function name with optional arguments an all items in collection if it exists.
|
||||
*
|
||||
* @example collection.exec("myMethod", arg1, arg2, arg3);
|
||||
* @method exec
|
||||
* @param {String} name Name of the function to execute.
|
||||
* @param {Object} ... Multiple arguments to pass to each function.
|
||||
* @return {tinymce.ui.Collection} Current collection.
|
||||
*/
|
||||
exec: function(name) {
|
||||
var self = this, args = Tools.toArray(arguments).slice(1);
|
||||
|
||||
self.each(function(item) {
|
||||
if (item[name]) {
|
||||
item[name].apply(item, args);
|
||||
}
|
||||
});
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove all items from collection and DOM.
|
||||
*
|
||||
* @method remove
|
||||
* @return {tinymce.ui.Collection} Current collection.
|
||||
*/
|
||||
remove: function() {
|
||||
var i = this.length;
|
||||
|
||||
while (i--) {
|
||||
this[i].remove();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a class to all items in the collection.
|
||||
*
|
||||
* @method addClass
|
||||
* @param {String} cls Class to add to each item.
|
||||
* @return {tinymce.ui.Collection} Current collection instance.
|
||||
*/
|
||||
addClass: function(cls) {
|
||||
return this.each(function(item) {
|
||||
item.classes.add(cls);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the specified class from all items in collection.
|
||||
*
|
||||
* @method removeClass
|
||||
* @param {String} cls Class to remove from each item.
|
||||
* @return {tinymce.ui.Collection} Current collection instance.
|
||||
*/
|
||||
removeClass: function(cls) {
|
||||
return this.each(function(item) {
|
||||
item.classes.remove(cls);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires the specified event by name and arguments on the control. This will execute all
|
||||
* bound event handlers.
|
||||
*
|
||||
* @method fire
|
||||
* @param {String} name Name of the event to fire.
|
||||
* @param {Object} args Optional arguments to pass to the event.
|
||||
* @return {tinymce.ui.Collection} Current collection instance.
|
||||
*/
|
||||
// fire: function(event, args) {}, -- Generated by code below
|
||||
|
||||
/**
|
||||
* Binds a callback to the specified event. This event can both be
|
||||
* native browser events like "click" or custom ones like PostRender.
|
||||
*
|
||||
* The callback function will have two parameters the first one being the control that received the event
|
||||
* the second one will be the event object either the browsers native event object or a custom JS object.
|
||||
*
|
||||
* @method on
|
||||
* @param {String} name Name of the event to bind. For example "click".
|
||||
* @param {String/function} callback Callback function to execute ones the event occurs.
|
||||
* @return {tinymce.ui.Collection} Current collection instance.
|
||||
*/
|
||||
// on: function(name, callback) {}, -- Generated by code below
|
||||
|
||||
/**
|
||||
* Unbinds the specified event and optionally a specific callback. If you omit the name
|
||||
* parameter all event handlers will be removed. If you omit the callback all event handles
|
||||
* by the specified name will be removed.
|
||||
*
|
||||
* @method off
|
||||
* @param {String} name Optional name for the event to unbind.
|
||||
* @param {function} callback Optional callback function to unbind.
|
||||
* @return {tinymce.ui.Collection} Current collection instance.
|
||||
*/
|
||||
// off: function(name, callback) {}, -- Generated by code below
|
||||
|
||||
/**
|
||||
* Shows the items in the current collection.
|
||||
*
|
||||
* @method show
|
||||
* @return {tinymce.ui.Collection} Current collection instance.
|
||||
*/
|
||||
// show: function() {}, -- Generated by code below
|
||||
|
||||
/**
|
||||
* Hides the items in the current collection.
|
||||
*
|
||||
* @method hide
|
||||
* @return {tinymce.ui.Collection} Current collection instance.
|
||||
*/
|
||||
// hide: function() {}, -- Generated by code below
|
||||
|
||||
/**
|
||||
* Sets/gets the text contents of the items in the current collection.
|
||||
*
|
||||
* @method text
|
||||
* @return {tinymce.ui.Collection} Current collection instance or text value of the first item on a get operation.
|
||||
*/
|
||||
// text: function(value) {}, -- Generated by code below
|
||||
|
||||
/**
|
||||
* Sets/gets the name contents of the items in the current collection.
|
||||
*
|
||||
* @method name
|
||||
* @return {tinymce.ui.Collection} Current collection instance or name value of the first item on a get operation.
|
||||
*/
|
||||
// name: function(value) {}, -- Generated by code below
|
||||
|
||||
/**
|
||||
* Sets/gets the disabled state on the items in the current collection.
|
||||
*
|
||||
* @method disabled
|
||||
* @return {tinymce.ui.Collection} Current collection instance or disabled state of the first item on a get operation.
|
||||
*/
|
||||
// disabled: function(state) {}, -- Generated by code below
|
||||
|
||||
/**
|
||||
* Sets/gets the active state on the items in the current collection.
|
||||
*
|
||||
* @method active
|
||||
* @return {tinymce.ui.Collection} Current collection instance or active state of the first item on a get operation.
|
||||
*/
|
||||
// active: function(state) {}, -- Generated by code below
|
||||
|
||||
/**
|
||||
* Sets/gets the selected state on the items in the current collection.
|
||||
*
|
||||
* @method selected
|
||||
* @return {tinymce.ui.Collection} Current collection instance or selected state of the first item on a get operation.
|
||||
*/
|
||||
// selected: function(state) {}, -- Generated by code below
|
||||
|
||||
/**
|
||||
* Sets/gets the selected state on the items in the current collection.
|
||||
*
|
||||
* @method visible
|
||||
* @return {tinymce.ui.Collection} Current collection instance or visible state of the first item on a get operation.
|
||||
*/
|
||||
// visible: function(state) {}, -- Generated by code below
|
||||
};
|
||||
|
||||
// Extend tinymce.ui.Collection prototype with some generated control specific methods
|
||||
Tools.each('fire on off show hide append prepend before after reflow'.split(' '), function(name) {
|
||||
proto[name] = function() {
|
||||
var args = Tools.toArray(arguments);
|
||||
|
||||
this.each(function(ctrl) {
|
||||
if (name in ctrl) {
|
||||
ctrl[name].apply(ctrl, args);
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
});
|
||||
|
||||
// Extend tinymce.ui.Collection prototype with some property methods
|
||||
Tools.each('text name disabled active selected checked visible parent value data'.split(' '), function(name) {
|
||||
proto[name] = function(value) {
|
||||
return this.prop(name, value);
|
||||
};
|
||||
});
|
||||
|
||||
// Create class based on the new prototype
|
||||
Collection = Class.extend(proto);
|
||||
|
||||
// Stick Collection into Selector to prevent circual references
|
||||
Selector.Collection = Collection;
|
||||
|
||||
return Collection;
|
||||
});
|
||||
72
js/tinymce/classes/ui/ColorBox.js
Normal file
72
js/tinymce/classes/ui/ColorBox.js
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* ColorBox.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This widget lets you enter colors and browse for colors by pressing the color button. It also displays
|
||||
* a preview of the current color.
|
||||
*
|
||||
* @-x-less ColorBox.less
|
||||
* @class tinymce.ui.ColorBox
|
||||
* @extends tinymce.ui.ComboBox
|
||||
*/
|
||||
define("tinymce/ui/ColorBox", [
|
||||
"tinymce/ui/ComboBox"
|
||||
], function(ComboBox) {
|
||||
"use strict";
|
||||
|
||||
return ComboBox.extend({
|
||||
/**
|
||||
* Constructs a new control instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
settings.spellcheck = false;
|
||||
|
||||
if (settings.onaction) {
|
||||
settings.icon = 'none';
|
||||
}
|
||||
|
||||
self._super(settings);
|
||||
|
||||
self.classes.add('colorbox');
|
||||
self.on('change keyup postrender', function() {
|
||||
self.repaintColor(self.value());
|
||||
});
|
||||
},
|
||||
|
||||
repaintColor: function(value) {
|
||||
var elm = this.getEl().getElementsByTagName('i')[0];
|
||||
|
||||
if (elm) {
|
||||
try {
|
||||
elm.style.background = value;
|
||||
} catch (ex) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
self.state.on('change:value', function(e) {
|
||||
if (self._rendered) {
|
||||
self.repaintColor(e.value);
|
||||
}
|
||||
});
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
124
js/tinymce/classes/ui/ColorButton.js
Normal file
124
js/tinymce/classes/ui/ColorButton.js
Normal file
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* ColorButton.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class creates a color button control. This is a split button in which the main
|
||||
* button has a visual representation of the currently selected color. When clicked
|
||||
* the caret button displays a color picker, allowing the user to select a new color.
|
||||
*
|
||||
* @-x-less ColorButton.less
|
||||
* @class tinymce.ui.ColorButton
|
||||
* @extends tinymce.ui.PanelButton
|
||||
*/
|
||||
define("tinymce/ui/ColorButton", [
|
||||
"tinymce/ui/PanelButton",
|
||||
"tinymce/dom/DOMUtils"
|
||||
], function(PanelButton, DomUtils) {
|
||||
"use strict";
|
||||
|
||||
var DOM = DomUtils.DOM;
|
||||
|
||||
return PanelButton.extend({
|
||||
/**
|
||||
* Constructs a new ColorButton instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
*/
|
||||
init: function(settings) {
|
||||
this._super(settings);
|
||||
this.classes.add('colorbutton');
|
||||
},
|
||||
|
||||
/**
|
||||
* Getter/setter for the current color.
|
||||
*
|
||||
* @method color
|
||||
* @param {String} [color] Color to set.
|
||||
* @return {String|tinymce.ui.ColorButton} Current color or current instance.
|
||||
*/
|
||||
color: function(color) {
|
||||
if (color) {
|
||||
this._color = color;
|
||||
this.getEl('preview').style.backgroundColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
return this._color;
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets the current color.
|
||||
*
|
||||
* @method resetColor
|
||||
* @return {tinymce.ui.ColorButton} Current instance.
|
||||
*/
|
||||
resetColor: function() {
|
||||
this._color = null;
|
||||
this.getEl('preview').style.backgroundColor = null;
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, id = self._id, prefix = self.classPrefix, text = self.state.get('text');
|
||||
var icon = self.settings.icon ? prefix + 'ico ' + prefix + 'i-' + self.settings.icon : '';
|
||||
var image = self.settings.image ? ' style="background-image: url(\'' + self.settings.image + '\')"' : '',
|
||||
textHtml = '';
|
||||
|
||||
if (text) {
|
||||
self.classes.add('btn-has-text');
|
||||
textHtml = '<span class="' + prefix + 'txt">' + self.encode(text) + '</span>';
|
||||
}
|
||||
|
||||
return (
|
||||
'<div id="' + id + '" class="' + self.classes + '" role="button" tabindex="-1" aria-haspopup="true">' +
|
||||
'<button role="presentation" hidefocus="1" type="button" tabindex="-1">' +
|
||||
(icon ? '<i class="' + icon + '"' + image + '></i>' : '') +
|
||||
'<span id="' + id + '-preview" class="' + prefix + 'preview"></span>' +
|
||||
textHtml +
|
||||
'</button>' +
|
||||
'<button type="button" class="' + prefix + 'open" hidefocus="1" tabindex="-1">' +
|
||||
' <i class="' + prefix + 'caret"></i>' +
|
||||
'</button>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called after the control has been rendered.
|
||||
*
|
||||
* @method postRender
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this, onClickHandler = self.settings.onclick;
|
||||
|
||||
self.on('click', function(e) {
|
||||
if (e.aria && e.aria.key == 'down') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.control == self && !DOM.getParent(e.target, '.' + self.classPrefix + 'open')) {
|
||||
e.stopImmediatePropagation();
|
||||
onClickHandler.call(self, e);
|
||||
}
|
||||
});
|
||||
|
||||
delete self.settings.onclick;
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
206
js/tinymce/classes/ui/ColorPicker.js
Normal file
206
js/tinymce/classes/ui/ColorPicker.js
Normal file
@@ -0,0 +1,206 @@
|
||||
/**
|
||||
* ColorPicker.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Color picker widget lets you select colors.
|
||||
*
|
||||
* @-x-less ColorPicker.less
|
||||
* @class tinymce.ui.ColorPicker
|
||||
* @extends tinymce.ui.Widget
|
||||
*/
|
||||
define("tinymce/ui/ColorPicker", [
|
||||
"tinymce/ui/Widget",
|
||||
"tinymce/ui/DragHelper",
|
||||
"tinymce/ui/DomUtils",
|
||||
"tinymce/util/Color"
|
||||
], function(Widget, DragHelper, DomUtils, Color) {
|
||||
"use strict";
|
||||
|
||||
return Widget.extend({
|
||||
Defaults: {
|
||||
classes: "widget colorpicker"
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructs a new colorpicker instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
* @setting {String} color Initial color value.
|
||||
*/
|
||||
init: function(settings) {
|
||||
this._super(settings);
|
||||
},
|
||||
|
||||
postRender: function() {
|
||||
var self = this, color = self.color(), hsv, hueRootElm, huePointElm, svRootElm, svPointElm;
|
||||
|
||||
hueRootElm = self.getEl('h');
|
||||
huePointElm = self.getEl('hp');
|
||||
svRootElm = self.getEl('sv');
|
||||
svPointElm = self.getEl('svp');
|
||||
|
||||
function getPos(elm, event) {
|
||||
var pos = DomUtils.getPos(elm), x, y;
|
||||
|
||||
x = event.pageX - pos.x;
|
||||
y = event.pageY - pos.y;
|
||||
|
||||
x = Math.max(0, Math.min(x / elm.clientWidth, 1));
|
||||
y = Math.max(0, Math.min(y / elm.clientHeight, 1));
|
||||
|
||||
return {
|
||||
x: x,
|
||||
y: y
|
||||
};
|
||||
}
|
||||
|
||||
function updateColor(hsv, hueUpdate) {
|
||||
var hue = (360 - hsv.h) / 360;
|
||||
|
||||
DomUtils.css(huePointElm, {
|
||||
top: (hue * 100) + '%'
|
||||
});
|
||||
|
||||
if (!hueUpdate) {
|
||||
DomUtils.css(svPointElm, {
|
||||
left: hsv.s + '%',
|
||||
top: (100 - hsv.v) + '%'
|
||||
});
|
||||
}
|
||||
|
||||
svRootElm.style.background = new Color({s: 100, v: 100, h: hsv.h}).toHex();
|
||||
self.color().parse({s: hsv.s, v: hsv.v, h: hsv.h});
|
||||
}
|
||||
|
||||
function updateSaturationAndValue(e) {
|
||||
var pos;
|
||||
|
||||
pos = getPos(svRootElm, e);
|
||||
hsv.s = pos.x * 100;
|
||||
hsv.v = (1 - pos.y) * 100;
|
||||
|
||||
updateColor(hsv);
|
||||
self.fire('change');
|
||||
}
|
||||
|
||||
function updateHue(e) {
|
||||
var pos;
|
||||
|
||||
pos = getPos(hueRootElm, e);
|
||||
hsv = color.toHsv();
|
||||
hsv.h = (1 - pos.y) * 360;
|
||||
updateColor(hsv, true);
|
||||
self.fire('change');
|
||||
}
|
||||
|
||||
self._repaint = function() {
|
||||
hsv = color.toHsv();
|
||||
updateColor(hsv);
|
||||
};
|
||||
|
||||
self._super();
|
||||
|
||||
self._svdraghelper = new DragHelper(self._id + '-sv', {
|
||||
start: updateSaturationAndValue,
|
||||
drag: updateSaturationAndValue
|
||||
});
|
||||
|
||||
self._hdraghelper = new DragHelper(self._id + '-h', {
|
||||
start: updateHue,
|
||||
drag: updateHue
|
||||
});
|
||||
|
||||
self._repaint();
|
||||
},
|
||||
|
||||
rgb: function() {
|
||||
return this.color().toRgb();
|
||||
},
|
||||
|
||||
value: function(value) {
|
||||
var self = this;
|
||||
|
||||
if (arguments.length) {
|
||||
self.color().parse(value);
|
||||
|
||||
if (self._rendered) {
|
||||
self._repaint();
|
||||
}
|
||||
} else {
|
||||
return self.color().toHex();
|
||||
}
|
||||
},
|
||||
|
||||
color: function() {
|
||||
if (!this._color) {
|
||||
this._color = new Color();
|
||||
}
|
||||
|
||||
return this._color;
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, id = self._id, prefix = self.classPrefix, hueHtml;
|
||||
var stops = '#ff0000,#ff0080,#ff00ff,#8000ff,#0000ff,#0080ff,#00ffff,#00ff80,#00ff00,#80ff00,#ffff00,#ff8000,#ff0000';
|
||||
|
||||
function getOldIeFallbackHtml() {
|
||||
var i, l, html = '', gradientPrefix, stopsList;
|
||||
|
||||
gradientPrefix = 'filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=';
|
||||
stopsList = stops.split(',');
|
||||
for (i = 0, l = stopsList.length - 1; i < l; i++) {
|
||||
html += (
|
||||
'<div class="' + prefix + 'colorpicker-h-chunk" style="' +
|
||||
'height:' + (100 / l) + '%;' +
|
||||
gradientPrefix + stopsList[i] + ',endColorstr=' + stopsList[i + 1] + ');' +
|
||||
'-ms-' + gradientPrefix + stopsList[i] + ',endColorstr=' + stopsList[i + 1] + ')' +
|
||||
'"></div>'
|
||||
);
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
var gradientCssText = (
|
||||
'background: -ms-linear-gradient(top,' + stops + ');' +
|
||||
'background: linear-gradient(to bottom,' + stops + ');'
|
||||
);
|
||||
|
||||
hueHtml = (
|
||||
'<div id="' + id + '-h" class="' + prefix + 'colorpicker-h" style="' + gradientCssText + '">' +
|
||||
getOldIeFallbackHtml() +
|
||||
'<div id="' + id + '-hp" class="' + prefix + 'colorpicker-h-marker"></div>' +
|
||||
'</div>'
|
||||
);
|
||||
|
||||
return (
|
||||
'<div id="' + id + '" class="' + self.classes + '">' +
|
||||
'<div id="' + id + '-sv" class="' + prefix + 'colorpicker-sv">' +
|
||||
'<div class="' + prefix + 'colorpicker-overlay1">' +
|
||||
'<div class="' + prefix + 'colorpicker-overlay2">' +
|
||||
'<div id="' + id + '-svp" class="' + prefix + 'colorpicker-selector1">' +
|
||||
'<div class="' + prefix + 'colorpicker-selector2"></div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
hueHtml +
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
306
js/tinymce/classes/ui/ComboBox.js
Normal file
306
js/tinymce/classes/ui/ComboBox.js
Normal file
@@ -0,0 +1,306 @@
|
||||
/**
|
||||
* ComboBox.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class creates a combobox control. Select box that you select a value from or
|
||||
* type a value into.
|
||||
*
|
||||
* @-x-less ComboBox.less
|
||||
* @class tinymce.ui.ComboBox
|
||||
* @extends tinymce.ui.Widget
|
||||
*/
|
||||
define("tinymce/ui/ComboBox", [
|
||||
"tinymce/ui/Widget",
|
||||
"tinymce/ui/Factory",
|
||||
"tinymce/ui/DomUtils",
|
||||
"tinymce/dom/DomQuery"
|
||||
], function(Widget, Factory, DomUtils, $) {
|
||||
"use strict";
|
||||
|
||||
return Widget.extend({
|
||||
/**
|
||||
* Constructs a new control instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
* @setting {String} placeholder Placeholder text to display.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
self._super(settings);
|
||||
settings = self.settings;
|
||||
|
||||
self.classes.add('combobox');
|
||||
self.subinput = true;
|
||||
self.ariaTarget = 'inp'; // TODO: Figure out a better way
|
||||
|
||||
settings.menu = settings.menu || settings.values;
|
||||
|
||||
if (settings.menu) {
|
||||
settings.icon = 'caret';
|
||||
}
|
||||
|
||||
self.on('click', function(e) {
|
||||
var elm = e.target, root = self.getEl();
|
||||
|
||||
if (!$.contains(root, elm) && elm != root) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (elm && elm != root) {
|
||||
if (elm.id && elm.id.indexOf('-open') != -1) {
|
||||
self.fire('action');
|
||||
|
||||
if (settings.menu) {
|
||||
self.showMenu();
|
||||
|
||||
if (e.aria) {
|
||||
self.menu.items()[0].focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
elm = elm.parentNode;
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: Rework this
|
||||
self.on('keydown', function(e) {
|
||||
if (e.target.nodeName == "INPUT" && e.keyCode == 13) {
|
||||
self.parents().reverse().each(function(ctrl) {
|
||||
var stateValue = self.state.get('value'), inputValue = self.getEl('inp').value;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
self.state.set('value', inputValue);
|
||||
|
||||
if (stateValue != inputValue) {
|
||||
self.fire('change');
|
||||
}
|
||||
|
||||
if (ctrl.hasEventListeners('submit') && ctrl.toJSON) {
|
||||
ctrl.fire('submit', {data: ctrl.toJSON()});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
self.on('keyup', function(e) {
|
||||
if (e.target.nodeName == "INPUT") {
|
||||
self.state.set('value', e.target.value);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
showMenu: function() {
|
||||
var self = this, settings = self.settings, menu;
|
||||
|
||||
if (!self.menu) {
|
||||
menu = settings.menu || [];
|
||||
|
||||
// Is menu array then auto constuct menu control
|
||||
if (menu.length) {
|
||||
menu = {
|
||||
type: 'menu',
|
||||
items: menu
|
||||
};
|
||||
} else {
|
||||
menu.type = menu.type || 'menu';
|
||||
}
|
||||
|
||||
self.menu = Factory.create(menu).parent(self).renderTo(self.getContainerElm());
|
||||
self.fire('createmenu');
|
||||
self.menu.reflow();
|
||||
self.menu.on('cancel', function(e) {
|
||||
if (e.control === self.menu) {
|
||||
self.focus();
|
||||
}
|
||||
});
|
||||
|
||||
self.menu.on('show hide', function(e) {
|
||||
e.control.items().each(function(ctrl) {
|
||||
ctrl.active(ctrl.value() == self.value());
|
||||
});
|
||||
}).fire('show');
|
||||
|
||||
self.menu.on('select', function(e) {
|
||||
self.value(e.control.value());
|
||||
});
|
||||
|
||||
self.on('focusin', function(e) {
|
||||
if (e.target.tagName.toUpperCase() == 'INPUT') {
|
||||
self.menu.hide();
|
||||
}
|
||||
});
|
||||
|
||||
self.aria('expanded', true);
|
||||
}
|
||||
|
||||
self.menu.show();
|
||||
self.menu.layoutRect({w: self.layoutRect().w});
|
||||
self.menu.moveRel(self.getEl(), self.isRtl() ? ['br-tr', 'tr-br'] : ['bl-tl', 'tl-bl']);
|
||||
},
|
||||
|
||||
/**
|
||||
* Focuses the input area of the control.
|
||||
*
|
||||
* @method focus
|
||||
*/
|
||||
focus: function() {
|
||||
this.getEl('inp').focus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Repaints the control after a layout operation.
|
||||
*
|
||||
* @method repaint
|
||||
*/
|
||||
repaint: function() {
|
||||
var self = this, elm = self.getEl(), openElm = self.getEl('open'), rect = self.layoutRect();
|
||||
var width, lineHeight;
|
||||
|
||||
if (openElm) {
|
||||
width = rect.w - DomUtils.getSize(openElm).width - 10;
|
||||
} else {
|
||||
width = rect.w - 10;
|
||||
}
|
||||
|
||||
// Detect old IE 7+8 add lineHeight to align caret vertically in the middle
|
||||
var doc = document;
|
||||
if (doc.all && (!doc.documentMode || doc.documentMode <= 8)) {
|
||||
lineHeight = (self.layoutRect().h - 2) + 'px';
|
||||
}
|
||||
|
||||
$(elm.firstChild).css({
|
||||
width: width,
|
||||
lineHeight: lineHeight
|
||||
});
|
||||
|
||||
self._super();
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Post render method. Called after the control has been rendered to the target.
|
||||
*
|
||||
* @method postRender
|
||||
* @return {tinymce.ui.ComboBox} Current combobox instance.
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this;
|
||||
|
||||
$(this.getEl('inp')).on('change', function(e) {
|
||||
self.state.set('value', e.target.value);
|
||||
self.fire('change', e);
|
||||
});
|
||||
|
||||
return self._super();
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, id = self._id, settings = self.settings, prefix = self.classPrefix;
|
||||
var value = self.state.get('value') || '';
|
||||
var icon, text, openBtnHtml = '', extraAttrs = '';
|
||||
|
||||
if ("spellcheck" in settings) {
|
||||
extraAttrs += ' spellcheck="' + settings.spellcheck + '"';
|
||||
}
|
||||
|
||||
if (settings.maxLength) {
|
||||
extraAttrs += ' maxlength="' + settings.maxLength + '"';
|
||||
}
|
||||
|
||||
if (settings.size) {
|
||||
extraAttrs += ' size="' + settings.size + '"';
|
||||
}
|
||||
|
||||
if (settings.subtype) {
|
||||
extraAttrs += ' type="' + settings.subtype + '"';
|
||||
}
|
||||
|
||||
if (self.disabled()) {
|
||||
extraAttrs += ' disabled="disabled"';
|
||||
}
|
||||
|
||||
icon = settings.icon;
|
||||
if (icon && icon != 'caret') {
|
||||
icon = prefix + 'ico ' + prefix + 'i-' + settings.icon;
|
||||
}
|
||||
|
||||
text = self.state.get('text');
|
||||
|
||||
if (icon || text) {
|
||||
openBtnHtml = (
|
||||
'<div id="' + id + '-open" class="' + prefix + 'btn ' + prefix + 'open" tabIndex="-1" role="button">' +
|
||||
'<button id="' + id + '-action" type="button" hidefocus="1" tabindex="-1">' +
|
||||
(icon != 'caret' ? '<i class="' + icon + '"></i>' : '<i class="' + prefix + 'caret"></i>') +
|
||||
(text ? (icon ? ' ' : '') + text : '') +
|
||||
'</button>' +
|
||||
'</div>'
|
||||
);
|
||||
|
||||
self.classes.add('has-open');
|
||||
}
|
||||
|
||||
return (
|
||||
'<div id="' + id + '" class="' + self.classes + '">' +
|
||||
'<input id="' + id + '-inp" class="' + prefix + 'textbox" value="' +
|
||||
self.encode(value, false) + '" hidefocus="1"' + extraAttrs + ' placeholder="' +
|
||||
self.encode(settings.placeholder) + '" />' +
|
||||
openBtnHtml +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
value: function(value) {
|
||||
if (arguments.length) {
|
||||
this.state.set('value', value);
|
||||
return this;
|
||||
}
|
||||
|
||||
// Make sure the real state is in sync
|
||||
if (this.state.get('rendered')) {
|
||||
this.state.set('value', this.getEl('inp').value);
|
||||
}
|
||||
|
||||
return this.state.get('value');
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
self.state.on('change:value', function(e) {
|
||||
if (self.getEl('inp').value != e.value) {
|
||||
self.getEl('inp').value = e.value;
|
||||
}
|
||||
});
|
||||
|
||||
self.state.on('change:disabled', function(e) {
|
||||
self.getEl('inp').disabled = e.value;
|
||||
});
|
||||
|
||||
return self._super();
|
||||
},
|
||||
|
||||
remove: function() {
|
||||
$(this.getEl('inp')).off();
|
||||
this._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
506
js/tinymce/classes/ui/Container.js
Normal file
506
js/tinymce/classes/ui/Container.js
Normal file
@@ -0,0 +1,506 @@
|
||||
/**
|
||||
* Container.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Container control. This is extended by all controls that can have
|
||||
* children such as panels etc. You can also use this class directly as an
|
||||
* generic container instance. The container doesn't have any specific role or style.
|
||||
*
|
||||
* @-x-less Container.less
|
||||
* @class tinymce.ui.Container
|
||||
* @extends tinymce.ui.Control
|
||||
*/
|
||||
define("tinymce/ui/Container", [
|
||||
"tinymce/ui/Control",
|
||||
"tinymce/ui/Collection",
|
||||
"tinymce/ui/Selector",
|
||||
"tinymce/ui/Factory",
|
||||
"tinymce/ui/KeyboardNavigation",
|
||||
"tinymce/util/Tools",
|
||||
"tinymce/dom/DomQuery",
|
||||
"tinymce/ui/ClassList",
|
||||
"tinymce/ui/ReflowQueue"
|
||||
], function(Control, Collection, Selector, Factory, KeyboardNavigation, Tools, $, ClassList, ReflowQueue) {
|
||||
"use strict";
|
||||
|
||||
var selectorCache = {};
|
||||
|
||||
return Control.extend({
|
||||
/**
|
||||
* Constructs a new control instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
* @setting {Array} items Items to add to container in JSON format or control instances.
|
||||
* @setting {String} layout Layout manager by name to use.
|
||||
* @setting {Object} defaults Default settings to apply to all items.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
self._super(settings);
|
||||
settings = self.settings;
|
||||
|
||||
if (settings.fixed) {
|
||||
self.state.set('fixed', true);
|
||||
}
|
||||
|
||||
self._items = new Collection();
|
||||
|
||||
if (self.isRtl()) {
|
||||
self.classes.add('rtl');
|
||||
}
|
||||
|
||||
self.bodyClasses = new ClassList(function() {
|
||||
if (self.state.get('rendered')) {
|
||||
self.getEl('body').className = this.toString();
|
||||
}
|
||||
});
|
||||
self.bodyClasses.prefix = self.classPrefix;
|
||||
|
||||
self.classes.add('container');
|
||||
self.bodyClasses.add('container-body');
|
||||
|
||||
if (settings.containerCls) {
|
||||
self.classes.add(settings.containerCls);
|
||||
}
|
||||
|
||||
self._layout = Factory.create((settings.layout || '') + 'layout');
|
||||
|
||||
if (self.settings.items) {
|
||||
self.add(self.settings.items);
|
||||
} else {
|
||||
self.add(self.render());
|
||||
}
|
||||
|
||||
// TODO: Fix this!
|
||||
self._hasBody = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a collection of child items that the container currently have.
|
||||
*
|
||||
* @method items
|
||||
* @return {tinymce.ui.Collection} Control collection direct child controls.
|
||||
*/
|
||||
items: function() {
|
||||
return this._items;
|
||||
},
|
||||
|
||||
/**
|
||||
* Find child controls by selector.
|
||||
*
|
||||
* @method find
|
||||
* @param {String} selector Selector CSS pattern to find children by.
|
||||
* @return {tinymce.ui.Collection} Control collection with child controls.
|
||||
*/
|
||||
find: function(selector) {
|
||||
selector = selectorCache[selector] = selectorCache[selector] || new Selector(selector);
|
||||
|
||||
return selector.find(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds one or many items to the current container. This will create instances of
|
||||
* the object representations if needed.
|
||||
*
|
||||
* @method add
|
||||
* @param {Array/Object/tinymce.ui.Control} items Array or item that will be added to the container.
|
||||
* @return {tinymce.ui.Collection} Current collection control.
|
||||
*/
|
||||
add: function(items) {
|
||||
var self = this;
|
||||
|
||||
self.items().add(self.create(items)).parent(self);
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Focuses the current container instance. This will look
|
||||
* for the first control in the container and focus that.
|
||||
*
|
||||
* @method focus
|
||||
* @param {Boolean} keyboard Optional true/false if the focus was a keyboard focus or not.
|
||||
* @return {tinymce.ui.Collection} Current instance.
|
||||
*/
|
||||
focus: function(keyboard) {
|
||||
var self = this, focusCtrl, keyboardNav, items;
|
||||
|
||||
if (keyboard) {
|
||||
keyboardNav = self.keyboardNav || self.parents().eq(-1)[0].keyboardNav;
|
||||
|
||||
if (keyboardNav) {
|
||||
keyboardNav.focusFirst(self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
items = self.find('*');
|
||||
|
||||
// TODO: Figure out a better way to auto focus alert dialog buttons
|
||||
if (self.statusbar) {
|
||||
items.add(self.statusbar.items());
|
||||
}
|
||||
|
||||
items.each(function(ctrl) {
|
||||
if (ctrl.settings.autofocus) {
|
||||
focusCtrl = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ctrl.canFocus) {
|
||||
focusCtrl = focusCtrl || ctrl;
|
||||
}
|
||||
});
|
||||
|
||||
if (focusCtrl) {
|
||||
focusCtrl.focus();
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Replaces the specified child control with a new control.
|
||||
*
|
||||
* @method replace
|
||||
* @param {tinymce.ui.Control} oldItem Old item to be replaced.
|
||||
* @param {tinymce.ui.Control} newItem New item to be inserted.
|
||||
*/
|
||||
replace: function(oldItem, newItem) {
|
||||
var ctrlElm, items = this.items(), i = items.length;
|
||||
|
||||
// Replace the item in collection
|
||||
while (i--) {
|
||||
if (items[i] === oldItem) {
|
||||
items[i] = newItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= 0) {
|
||||
// Remove new item from DOM
|
||||
ctrlElm = newItem.getEl();
|
||||
if (ctrlElm) {
|
||||
ctrlElm.parentNode.removeChild(ctrlElm);
|
||||
}
|
||||
|
||||
// Remove old item from DOM
|
||||
ctrlElm = oldItem.getEl();
|
||||
if (ctrlElm) {
|
||||
ctrlElm.parentNode.removeChild(ctrlElm);
|
||||
}
|
||||
}
|
||||
|
||||
// Adopt the item
|
||||
newItem.parent(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates the specified items. If any of the items is plain JSON style objects
|
||||
* it will convert these into real tinymce.ui.Control instances.
|
||||
*
|
||||
* @method create
|
||||
* @param {Array} items Array of items to convert into control instances.
|
||||
* @return {Array} Array with control instances.
|
||||
*/
|
||||
create: function(items) {
|
||||
var self = this, settings, ctrlItems = [];
|
||||
|
||||
// Non array structure, then force it into an array
|
||||
if (!Tools.isArray(items)) {
|
||||
items = [items];
|
||||
}
|
||||
|
||||
// Add default type to each child control
|
||||
Tools.each(items, function(item) {
|
||||
if (item) {
|
||||
// Construct item if needed
|
||||
if (!(item instanceof Control)) {
|
||||
// Name only then convert it to an object
|
||||
if (typeof item == "string") {
|
||||
item = {type: item};
|
||||
}
|
||||
|
||||
// Create control instance based on input settings and default settings
|
||||
settings = Tools.extend({}, self.settings.defaults, item);
|
||||
item.type = settings.type = settings.type || item.type || self.settings.defaultType ||
|
||||
(settings.defaults ? settings.defaults.type : null);
|
||||
item = Factory.create(settings);
|
||||
}
|
||||
|
||||
ctrlItems.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
return ctrlItems;
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders new control instances.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
renderNew: function() {
|
||||
var self = this;
|
||||
|
||||
// Render any new items
|
||||
self.items().each(function(ctrl, index) {
|
||||
var containerElm;
|
||||
|
||||
ctrl.parent(self);
|
||||
|
||||
if (!ctrl.state.get('rendered')) {
|
||||
containerElm = self.getEl('body');
|
||||
|
||||
// Insert or append the item
|
||||
if (containerElm.hasChildNodes() && index <= containerElm.childNodes.length - 1) {
|
||||
$(containerElm.childNodes[index]).before(ctrl.renderHtml());
|
||||
} else {
|
||||
$(containerElm).append(ctrl.renderHtml());
|
||||
}
|
||||
|
||||
ctrl.postRender();
|
||||
ReflowQueue.add(ctrl);
|
||||
}
|
||||
});
|
||||
|
||||
self._layout.applyClasses(self.items().filter(':visible'));
|
||||
self._lastRect = null;
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Appends new instances to the current container.
|
||||
*
|
||||
* @method append
|
||||
* @param {Array/tinymce.ui.Collection} items Array if controls to append.
|
||||
* @return {tinymce.ui.Container} Current container instance.
|
||||
*/
|
||||
append: function(items) {
|
||||
return this.add(items).renderNew();
|
||||
},
|
||||
|
||||
/**
|
||||
* Prepends new instances to the current container.
|
||||
*
|
||||
* @method prepend
|
||||
* @param {Array/tinymce.ui.Collection} items Array if controls to prepend.
|
||||
* @return {tinymce.ui.Container} Current container instance.
|
||||
*/
|
||||
prepend: function(items) {
|
||||
var self = this;
|
||||
|
||||
self.items().set(self.create(items).concat(self.items().toArray()));
|
||||
|
||||
return self.renderNew();
|
||||
},
|
||||
|
||||
/**
|
||||
* Inserts an control at a specific index.
|
||||
*
|
||||
* @method insert
|
||||
* @param {Array/tinymce.ui.Collection} items Array if controls to insert.
|
||||
* @param {Number} index Index to insert controls at.
|
||||
* @param {Boolean} [before=false] Inserts controls before the index.
|
||||
*/
|
||||
insert: function(items, index, before) {
|
||||
var self = this, curItems, beforeItems, afterItems;
|
||||
|
||||
items = self.create(items);
|
||||
curItems = self.items();
|
||||
|
||||
if (!before && index < curItems.length - 1) {
|
||||
index += 1;
|
||||
}
|
||||
|
||||
if (index >= 0 && index < curItems.length) {
|
||||
beforeItems = curItems.slice(0, index).toArray();
|
||||
afterItems = curItems.slice(index).toArray();
|
||||
curItems.set(beforeItems.concat(items, afterItems));
|
||||
}
|
||||
|
||||
return self.renderNew();
|
||||
},
|
||||
|
||||
/**
|
||||
* Populates the form fields from the specified JSON data object.
|
||||
*
|
||||
* Control items in the form that matches the data will have it's value set.
|
||||
*
|
||||
* @method fromJSON
|
||||
* @param {Object} data JSON data object to set control values by.
|
||||
* @return {tinymce.ui.Container} Current form instance.
|
||||
*/
|
||||
fromJSON: function(data) {
|
||||
var self = this;
|
||||
|
||||
for (var name in data) {
|
||||
self.find('#' + name).value(data[name]);
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Serializes the form into a JSON object by getting all items
|
||||
* that has a name and a value.
|
||||
*
|
||||
* @method toJSON
|
||||
* @return {Object} JSON object with form data.
|
||||
*/
|
||||
toJSON: function() {
|
||||
var self = this, data = {};
|
||||
|
||||
self.find('*').each(function(ctrl) {
|
||||
var name = ctrl.name(), value = ctrl.value();
|
||||
|
||||
if (name && typeof value != "undefined") {
|
||||
data[name] = value;
|
||||
}
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, layout = self._layout, role = this.settings.role;
|
||||
|
||||
self.preRender();
|
||||
layout.preRender(self);
|
||||
|
||||
return (
|
||||
'<div id="' + self._id + '" class="' + self.classes + '"' + (role ? ' role="' + this.settings.role + '"' : '') + '>' +
|
||||
'<div id="' + self._id + '-body" class="' + self.bodyClasses + '">' +
|
||||
(self.settings.html || '') + layout.renderHtml(self) +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Post render method. Called after the control has been rendered to the target.
|
||||
*
|
||||
* @method postRender
|
||||
* @return {tinymce.ui.Container} Current combobox instance.
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this, box;
|
||||
|
||||
self.items().exec('postRender');
|
||||
self._super();
|
||||
|
||||
self._layout.postRender(self);
|
||||
self.state.set('rendered', true);
|
||||
|
||||
if (self.settings.style) {
|
||||
self.$el.css(self.settings.style);
|
||||
}
|
||||
|
||||
if (self.settings.border) {
|
||||
box = self.borderBox;
|
||||
self.$el.css({
|
||||
'border-top-width': box.top,
|
||||
'border-right-width': box.right,
|
||||
'border-bottom-width': box.bottom,
|
||||
'border-left-width': box.left
|
||||
});
|
||||
}
|
||||
|
||||
if (!self.parent()) {
|
||||
self.keyboardNav = new KeyboardNavigation({
|
||||
root: self
|
||||
});
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the current controls layout rect.
|
||||
* This will be executed by the layout managers to determine the
|
||||
* default minWidth/minHeight etc.
|
||||
*
|
||||
* @method initLayoutRect
|
||||
* @return {Object} Layout rect instance.
|
||||
*/
|
||||
initLayoutRect: function() {
|
||||
var self = this, layoutRect = self._super();
|
||||
|
||||
// Recalc container size by asking layout manager
|
||||
self._layout.recalc(self);
|
||||
|
||||
return layoutRect;
|
||||
},
|
||||
|
||||
/**
|
||||
* Recalculates the positions of the controls in the current container.
|
||||
* This is invoked by the reflow method and shouldn't be called directly.
|
||||
*
|
||||
* @method recalc
|
||||
*/
|
||||
recalc: function() {
|
||||
var self = this, rect = self._layoutRect, lastRect = self._lastRect;
|
||||
|
||||
if (!lastRect || lastRect.w != rect.w || lastRect.h != rect.h) {
|
||||
self._layout.recalc(self);
|
||||
rect = self.layoutRect();
|
||||
self._lastRect = {x: rect.x, y: rect.y, w: rect.w, h: rect.h};
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Reflows the current container and it's children and possible parents.
|
||||
* This should be used after you for example append children to the current control so
|
||||
* that the layout managers know that they need to reposition everything.
|
||||
*
|
||||
* @example
|
||||
* container.append({type: 'button', text: 'My button'}).reflow();
|
||||
*
|
||||
* @method reflow
|
||||
* @return {tinymce.ui.Container} Current container instance.
|
||||
*/
|
||||
reflow: function() {
|
||||
var i;
|
||||
|
||||
ReflowQueue.remove(this);
|
||||
|
||||
if (this.visible()) {
|
||||
Control.repaintControls = [];
|
||||
Control.repaintControls.map = {};
|
||||
|
||||
this.recalc();
|
||||
i = Control.repaintControls.length;
|
||||
|
||||
while (i--) {
|
||||
Control.repaintControls[i].repaint();
|
||||
}
|
||||
|
||||
// TODO: Fix me!
|
||||
if (this.settings.layout !== "flow" && this.settings.layout !== "stack") {
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
Control.repaintControls = [];
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
1287
js/tinymce/classes/ui/Control.js
Normal file
1287
js/tinymce/classes/ui/Control.js
Normal file
File diff suppressed because it is too large
Load Diff
107
js/tinymce/classes/ui/DomUtils.js
Normal file
107
js/tinymce/classes/ui/DomUtils.js
Normal file
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* DomUtils.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Private UI DomUtils proxy.
|
||||
*
|
||||
* @private
|
||||
* @class tinymce.ui.DomUtils
|
||||
*/
|
||||
define("tinymce/ui/DomUtils", [
|
||||
"tinymce/util/Tools",
|
||||
"tinymce/dom/DOMUtils"
|
||||
], function(Tools, DOMUtils) {
|
||||
"use strict";
|
||||
|
||||
var count = 0;
|
||||
|
||||
return {
|
||||
id: function() {
|
||||
return 'mceu_' + (count++);
|
||||
},
|
||||
|
||||
createFragment: function(html) {
|
||||
return DOMUtils.DOM.createFragment(html);
|
||||
},
|
||||
|
||||
getWindowSize: function() {
|
||||
return DOMUtils.DOM.getViewPort();
|
||||
},
|
||||
|
||||
getSize: function(elm) {
|
||||
var width, height;
|
||||
|
||||
if (elm.getBoundingClientRect) {
|
||||
var rect = elm.getBoundingClientRect();
|
||||
|
||||
width = Math.max(rect.width || (rect.right - rect.left), elm.offsetWidth);
|
||||
height = Math.max(rect.height || (rect.bottom - rect.bottom), elm.offsetHeight);
|
||||
} else {
|
||||
width = elm.offsetWidth;
|
||||
height = elm.offsetHeight;
|
||||
}
|
||||
|
||||
return {width: width, height: height};
|
||||
},
|
||||
|
||||
getPos: function(elm, root) {
|
||||
return DOMUtils.DOM.getPos(elm, root);
|
||||
},
|
||||
|
||||
getViewPort: function(win) {
|
||||
return DOMUtils.DOM.getViewPort(win);
|
||||
},
|
||||
|
||||
get: function(id) {
|
||||
return document.getElementById(id);
|
||||
},
|
||||
|
||||
addClass: function(elm, cls) {
|
||||
return DOMUtils.DOM.addClass(elm, cls);
|
||||
},
|
||||
|
||||
removeClass: function(elm, cls) {
|
||||
return DOMUtils.DOM.removeClass(elm, cls);
|
||||
},
|
||||
|
||||
hasClass: function(elm, cls) {
|
||||
return DOMUtils.DOM.hasClass(elm, cls);
|
||||
},
|
||||
|
||||
toggleClass: function(elm, cls, state) {
|
||||
return DOMUtils.DOM.toggleClass(elm, cls, state);
|
||||
},
|
||||
|
||||
css: function(elm, name, value) {
|
||||
return DOMUtils.DOM.setStyle(elm, name, value);
|
||||
},
|
||||
|
||||
getRuntimeStyle: function(elm, name) {
|
||||
return DOMUtils.DOM.getStyle(elm, name, true);
|
||||
},
|
||||
|
||||
on: function(target, name, callback, scope) {
|
||||
return DOMUtils.DOM.bind(target, name, callback, scope);
|
||||
},
|
||||
|
||||
off: function(target, name, callback) {
|
||||
return DOMUtils.DOM.unbind(target, name, callback);
|
||||
},
|
||||
|
||||
fire: function(target, name, args) {
|
||||
return DOMUtils.DOM.fire(target, name, args);
|
||||
},
|
||||
|
||||
innerHtml: function(elm, html) {
|
||||
// Workaround for <div> in <p> bug on IE 8 #6178
|
||||
DOMUtils.DOM.setHTML(elm, html);
|
||||
}
|
||||
};
|
||||
});
|
||||
144
js/tinymce/classes/ui/DragHelper.js
Normal file
144
js/tinymce/classes/ui/DragHelper.js
Normal file
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* DragHelper.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Drag/drop helper class.
|
||||
*
|
||||
* @example
|
||||
* var dragHelper = new tinymce.ui.DragHelper('mydiv', {
|
||||
* start: function(evt) {
|
||||
* },
|
||||
*
|
||||
* drag: function(evt) {
|
||||
* },
|
||||
*
|
||||
* end: function(evt) {
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* @class tinymce.ui.DragHelper
|
||||
*/
|
||||
define("tinymce/ui/DragHelper", [
|
||||
"tinymce/dom/DomQuery"
|
||||
], function($) {
|
||||
"use strict";
|
||||
|
||||
function getDocumentSize(doc) {
|
||||
var documentElement, body, scrollWidth, clientWidth;
|
||||
var offsetWidth, scrollHeight, clientHeight, offsetHeight, max = Math.max;
|
||||
|
||||
documentElement = doc.documentElement;
|
||||
body = doc.body;
|
||||
|
||||
scrollWidth = max(documentElement.scrollWidth, body.scrollWidth);
|
||||
clientWidth = max(documentElement.clientWidth, body.clientWidth);
|
||||
offsetWidth = max(documentElement.offsetWidth, body.offsetWidth);
|
||||
|
||||
scrollHeight = max(documentElement.scrollHeight, body.scrollHeight);
|
||||
clientHeight = max(documentElement.clientHeight, body.clientHeight);
|
||||
offsetHeight = max(documentElement.offsetHeight, body.offsetHeight);
|
||||
|
||||
return {
|
||||
width: scrollWidth < offsetWidth ? clientWidth : scrollWidth,
|
||||
height: scrollHeight < offsetHeight ? clientHeight : scrollHeight
|
||||
};
|
||||
}
|
||||
|
||||
function updateWithTouchData(e) {
|
||||
var keys, i;
|
||||
|
||||
if (e.changedTouches) {
|
||||
keys = "screenX screenY pageX pageY clientX clientY".split(' ');
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
e[keys[i]] = e.changedTouches[0][keys[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return function(id, settings) {
|
||||
var $eventOverlay, doc = settings.document || document, downButton, start, stop, drag, startX, startY;
|
||||
|
||||
settings = settings || {};
|
||||
|
||||
function getHandleElm() {
|
||||
return doc.getElementById(settings.handle || id);
|
||||
}
|
||||
|
||||
start = function(e) {
|
||||
var docSize = getDocumentSize(doc), handleElm, cursor;
|
||||
|
||||
updateWithTouchData(e);
|
||||
|
||||
e.preventDefault();
|
||||
downButton = e.button;
|
||||
handleElm = getHandleElm();
|
||||
startX = e.screenX;
|
||||
startY = e.screenY;
|
||||
|
||||
// Grab cursor from handle so we can place it on overlay
|
||||
if (window.getComputedStyle) {
|
||||
cursor = window.getComputedStyle(handleElm, null).getPropertyValue("cursor");
|
||||
} else {
|
||||
cursor = handleElm.runtimeStyle.cursor;
|
||||
}
|
||||
|
||||
$eventOverlay = $('<div>').css({
|
||||
position: "absolute",
|
||||
top: 0, left: 0,
|
||||
width: docSize.width,
|
||||
height: docSize.height,
|
||||
zIndex: 0x7FFFFFFF,
|
||||
opacity: 0.0001,
|
||||
cursor: cursor
|
||||
}).appendTo(doc.body);
|
||||
|
||||
$(doc).on('mousemove touchmove', drag).on('mouseup touchend', stop);
|
||||
|
||||
settings.start(e);
|
||||
};
|
||||
|
||||
drag = function(e) {
|
||||
updateWithTouchData(e);
|
||||
|
||||
if (e.button !== downButton) {
|
||||
return stop(e);
|
||||
}
|
||||
|
||||
e.deltaX = e.screenX - startX;
|
||||
e.deltaY = e.screenY - startY;
|
||||
|
||||
e.preventDefault();
|
||||
settings.drag(e);
|
||||
};
|
||||
|
||||
stop = function(e) {
|
||||
updateWithTouchData(e);
|
||||
|
||||
$(doc).off('mousemove touchmove', drag).off('mouseup touchend', stop);
|
||||
|
||||
$eventOverlay.remove();
|
||||
|
||||
if (settings.stop) {
|
||||
settings.stop(e);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroys the drag/drop helper instance.
|
||||
*
|
||||
* @method destroy
|
||||
*/
|
||||
this.destroy = function() {
|
||||
$(getHandleElm()).off();
|
||||
};
|
||||
|
||||
$(getHandleElm()).on('mousedown touchstart', start);
|
||||
};
|
||||
});
|
||||
79
js/tinymce/classes/ui/ElementPath.js
Normal file
79
js/tinymce/classes/ui/ElementPath.js
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* ElementPath.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This control creates an path for the current selections parent elements in TinyMCE.
|
||||
*
|
||||
* @class tinymce.ui.ElementPath
|
||||
* @extends tinymce.ui.Path
|
||||
*/
|
||||
define("tinymce/ui/ElementPath", [
|
||||
"tinymce/ui/Path",
|
||||
"tinymce/EditorManager"
|
||||
], function(Path, EditorManager) {
|
||||
return Path.extend({
|
||||
/**
|
||||
* Post render method. Called after the control has been rendered to the target.
|
||||
*
|
||||
* @method postRender
|
||||
* @return {tinymce.ui.ElementPath} Current combobox instance.
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this, editor = EditorManager.activeEditor;
|
||||
|
||||
function isHidden(elm) {
|
||||
if (elm.nodeType === 1) {
|
||||
if (elm.nodeName == "BR" || !!elm.getAttribute('data-mce-bogus')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (elm.getAttribute('data-mce-type') === 'bookmark') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (editor.settings.elementpath !== false) {
|
||||
self.on('select', function(e) {
|
||||
editor.focus();
|
||||
editor.selection.select(this.row()[e.index].element);
|
||||
editor.nodeChanged();
|
||||
});
|
||||
|
||||
editor.on('nodeChange', function(e) {
|
||||
var outParents = [], parents = e.parents, i = parents.length;
|
||||
|
||||
while (i--) {
|
||||
if (parents[i].nodeType == 1 && !isHidden(parents[i])) {
|
||||
var args = editor.fire('ResolveName', {
|
||||
name: parents[i].nodeName.toLowerCase(),
|
||||
target: parents[i]
|
||||
});
|
||||
|
||||
if (!args.isDefaultPrevented()) {
|
||||
outParents.push({name: args.name, element: parents[i]});
|
||||
}
|
||||
|
||||
if (args.isPropagationStopped()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.row(outParents);
|
||||
});
|
||||
}
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
105
js/tinymce/classes/ui/Factory.js
Normal file
105
js/tinymce/classes/ui/Factory.js
Normal file
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* Factory.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
|
||||
/**
|
||||
* This class is a factory for control instances. This enables you
|
||||
* to create instances of controls without having to require the UI controls directly.
|
||||
*
|
||||
* It also allow you to override or add new control types.
|
||||
*
|
||||
* @class tinymce.ui.Factory
|
||||
*/
|
||||
define("tinymce/ui/Factory", [], function() {
|
||||
"use strict";
|
||||
|
||||
var types = {}, namespaceInit;
|
||||
|
||||
return {
|
||||
/**
|
||||
* Adds a new control instance type to the factory.
|
||||
*
|
||||
* @method add
|
||||
* @param {String} type Type name for example "button".
|
||||
* @param {function} typeClass Class type function.
|
||||
*/
|
||||
add: function(type, typeClass) {
|
||||
types[type.toLowerCase()] = typeClass;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true/false if the specified type exists or not.
|
||||
*
|
||||
* @method has
|
||||
* @param {String} type Type to look for.
|
||||
* @return {Boolean} true/false if the control by name exists.
|
||||
*/
|
||||
has: function(type) {
|
||||
return !!types[type.toLowerCase()];
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new control instance based on the settings provided. The instance created will be
|
||||
* based on the specified type property it can also create whole structures of components out of
|
||||
* the specified JSON object.
|
||||
*
|
||||
* @example
|
||||
* tinymce.ui.Factory.create({
|
||||
* type: 'button',
|
||||
* text: 'Hello world!'
|
||||
* });
|
||||
*
|
||||
* @method create
|
||||
* @param {Object/String} settings Name/Value object with items used to create the type.
|
||||
* @return {tinymce.ui.Control} Control instance based on the specified type.
|
||||
*/
|
||||
create: function(type, settings) {
|
||||
var ControlType, name, namespace;
|
||||
|
||||
// Build type lookup
|
||||
if (!namespaceInit) {
|
||||
namespace = tinymce.ui;
|
||||
|
||||
for (name in namespace) {
|
||||
types[name.toLowerCase()] = namespace[name];
|
||||
}
|
||||
|
||||
namespaceInit = true;
|
||||
}
|
||||
|
||||
// If string is specified then use it as the type
|
||||
if (typeof type == 'string') {
|
||||
settings = settings || {};
|
||||
settings.type = type;
|
||||
} else {
|
||||
settings = type;
|
||||
type = settings.type;
|
||||
}
|
||||
|
||||
// Find control type
|
||||
type = type.toLowerCase();
|
||||
ControlType = types[type];
|
||||
|
||||
// #if debug
|
||||
|
||||
if (!ControlType) {
|
||||
throw new Error("Could not find control by type: " + type);
|
||||
}
|
||||
|
||||
// #endif
|
||||
|
||||
ControlType = new ControlType(settings);
|
||||
ControlType.type = type; // Set the type on the instance, this will be used by the Selector engine
|
||||
|
||||
return ControlType;
|
||||
}
|
||||
};
|
||||
});
|
||||
59
js/tinymce/classes/ui/FieldSet.js
Normal file
59
js/tinymce/classes/ui/FieldSet.js
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* FieldSet.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class creates fieldset containers.
|
||||
*
|
||||
* @-x-less FieldSet.less
|
||||
* @class tinymce.ui.FieldSet
|
||||
* @extends tinymce.ui.Form
|
||||
*/
|
||||
define("tinymce/ui/FieldSet", [
|
||||
"tinymce/ui/Form"
|
||||
], function(Form) {
|
||||
"use strict";
|
||||
|
||||
return Form.extend({
|
||||
Defaults: {
|
||||
containerCls: 'fieldset',
|
||||
layout: 'flex',
|
||||
direction: 'column',
|
||||
align: 'stretch',
|
||||
flex: 1,
|
||||
padding: "25 15 5 15",
|
||||
labelGap: 30,
|
||||
spacing: 10,
|
||||
border: 1
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, layout = self._layout, prefix = self.classPrefix;
|
||||
|
||||
self.preRender();
|
||||
layout.preRender(self);
|
||||
|
||||
return (
|
||||
'<fieldset id="' + self._id + '" class="' + self.classes + '" hidefocus="1" tabindex="-1">' +
|
||||
(self.settings.title ? ('<legend id="' + self._id + '-title" class="' + prefix + 'fieldset-title">' +
|
||||
self.settings.title + '</legend>') : '') +
|
||||
'<div id="' + self._id + '-body" class="' + self.bodyClasses + '">' +
|
||||
(self.settings.html || '') + layout.renderHtml(self) +
|
||||
'</div>' +
|
||||
'</fieldset>'
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
85
js/tinymce/classes/ui/FilePicker.js
Normal file
85
js/tinymce/classes/ui/FilePicker.js
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* FilePicker.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
|
||||
/**
|
||||
* This class creates a file picker control.
|
||||
*
|
||||
* @class tinymce.ui.FilePicker
|
||||
* @extends tinymce.ui.ComboBox
|
||||
*/
|
||||
define("tinymce/ui/FilePicker", [
|
||||
"tinymce/ui/ComboBox",
|
||||
"tinymce/util/Tools"
|
||||
], function(ComboBox, Tools) {
|
||||
"use strict";
|
||||
|
||||
return ComboBox.extend({
|
||||
/**
|
||||
* Constructs a new control instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this, editor = tinymce.activeEditor, editorSettings = editor.settings;
|
||||
var actionCallback, fileBrowserCallback, fileBrowserCallbackTypes;
|
||||
|
||||
settings.spellcheck = false;
|
||||
|
||||
fileBrowserCallbackTypes = editorSettings.file_picker_types || editorSettings.file_browser_callback_types;
|
||||
if (fileBrowserCallbackTypes) {
|
||||
fileBrowserCallbackTypes = Tools.makeMap(fileBrowserCallbackTypes, /[, ]/);
|
||||
}
|
||||
|
||||
if (!fileBrowserCallbackTypes || fileBrowserCallbackTypes[settings.filetype]) {
|
||||
fileBrowserCallback = editorSettings.file_picker_callback;
|
||||
if (fileBrowserCallback && (!fileBrowserCallbackTypes || fileBrowserCallbackTypes[settings.filetype])) {
|
||||
actionCallback = function() {
|
||||
var meta = self.fire('beforecall').meta;
|
||||
|
||||
meta = Tools.extend({filetype: settings.filetype}, meta);
|
||||
|
||||
// file_picker_callback(callback, currentValue, metaData)
|
||||
fileBrowserCallback.call(
|
||||
editor,
|
||||
function(value, meta) {
|
||||
self.value(value).fire('change', {meta: meta});
|
||||
},
|
||||
self.value(),
|
||||
meta
|
||||
);
|
||||
};
|
||||
} else {
|
||||
// Legacy callback: file_picker_callback(id, currentValue, filetype, window)
|
||||
fileBrowserCallback = editorSettings.file_browser_callback;
|
||||
if (fileBrowserCallback && (!fileBrowserCallbackTypes || fileBrowserCallbackTypes[settings.filetype])) {
|
||||
actionCallback = function() {
|
||||
fileBrowserCallback(
|
||||
self.getEl('inp').id,
|
||||
self.value(),
|
||||
settings.filetype,
|
||||
window
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (actionCallback) {
|
||||
settings.icon = 'browse';
|
||||
settings.onaction = actionCallback;
|
||||
}
|
||||
|
||||
self._super(settings);
|
||||
}
|
||||
});
|
||||
});
|
||||
48
js/tinymce/classes/ui/FitLayout.js
Normal file
48
js/tinymce/classes/ui/FitLayout.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* FitLayout.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This layout manager will resize the control to be the size of it's parent container.
|
||||
* In other words width: 100% and height: 100%.
|
||||
*
|
||||
* @-x-less FitLayout.less
|
||||
* @class tinymce.ui.FitLayout
|
||||
* @extends tinymce.ui.AbsoluteLayout
|
||||
*/
|
||||
define("tinymce/ui/FitLayout", [
|
||||
"tinymce/ui/AbsoluteLayout"
|
||||
], function(AbsoluteLayout) {
|
||||
"use strict";
|
||||
|
||||
return AbsoluteLayout.extend({
|
||||
/**
|
||||
* Recalculates the positions of the controls in the specified container.
|
||||
*
|
||||
* @method recalc
|
||||
* @param {tinymce.ui.Container} container Container instance to recalc.
|
||||
*/
|
||||
recalc: function(container) {
|
||||
var contLayoutRect = container.layoutRect(), paddingBox = container.paddingBox;
|
||||
|
||||
container.items().filter(':visible').each(function(ctrl) {
|
||||
ctrl.layoutRect({
|
||||
x: paddingBox.left,
|
||||
y: paddingBox.top,
|
||||
w: contLayoutRect.innerW - paddingBox.right - paddingBox.left,
|
||||
h: contLayoutRect.innerH - paddingBox.top - paddingBox.bottom
|
||||
});
|
||||
|
||||
if (ctrl.recalc) {
|
||||
ctrl.recalc();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
246
js/tinymce/classes/ui/FlexLayout.js
Normal file
246
js/tinymce/classes/ui/FlexLayout.js
Normal file
@@ -0,0 +1,246 @@
|
||||
/**
|
||||
* FlexLayout.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This layout manager works similar to the CSS flex box.
|
||||
*
|
||||
* @setting {String} direction row|row-reverse|column|column-reverse
|
||||
* @setting {Number} flex A positive-number to flex by.
|
||||
* @setting {String} align start|end|center|stretch
|
||||
* @setting {String} pack start|end|justify
|
||||
*
|
||||
* @class tinymce.ui.FlexLayout
|
||||
* @extends tinymce.ui.AbsoluteLayout
|
||||
*/
|
||||
define("tinymce/ui/FlexLayout", [
|
||||
"tinymce/ui/AbsoluteLayout"
|
||||
], function(AbsoluteLayout) {
|
||||
"use strict";
|
||||
|
||||
return AbsoluteLayout.extend({
|
||||
/**
|
||||
* Recalculates the positions of the controls in the specified container.
|
||||
*
|
||||
* @method recalc
|
||||
* @param {tinymce.ui.Container} container Container instance to recalc.
|
||||
*/
|
||||
recalc: function(container) {
|
||||
// A ton of variables, needs to be in the same scope for performance
|
||||
var i, l, items, contLayoutRect, contPaddingBox, contSettings, align, pack, spacing, totalFlex, availableSpace, direction;
|
||||
var ctrl, ctrlLayoutRect, ctrlSettings, flex, maxSizeItems = [], size, maxSize, ratio, rect, pos, maxAlignEndPos;
|
||||
var sizeName, minSizeName, posName, maxSizeName, beforeName, innerSizeName, deltaSizeName, contentSizeName;
|
||||
var alignAxisName, alignInnerSizeName, alignSizeName, alignMinSizeName, alignBeforeName, alignAfterName;
|
||||
var alignDeltaSizeName, alignContentSizeName;
|
||||
var max = Math.max, min = Math.min;
|
||||
|
||||
// Get container items, properties and settings
|
||||
items = container.items().filter(':visible');
|
||||
contLayoutRect = container.layoutRect();
|
||||
contPaddingBox = container.paddingBox;
|
||||
contSettings = container.settings;
|
||||
direction = container.isRtl() ? (contSettings.direction || 'row-reversed') : contSettings.direction;
|
||||
align = contSettings.align;
|
||||
pack = container.isRtl() ? (contSettings.pack || 'end') : contSettings.pack;
|
||||
spacing = contSettings.spacing || 0;
|
||||
|
||||
if (direction == "row-reversed" || direction == "column-reverse") {
|
||||
items = items.set(items.toArray().reverse());
|
||||
direction = direction.split('-')[0];
|
||||
}
|
||||
|
||||
// Setup axis variable name for row/column direction since the calculations is the same
|
||||
if (direction == "column") {
|
||||
posName = "y";
|
||||
sizeName = "h";
|
||||
minSizeName = "minH";
|
||||
maxSizeName = "maxH";
|
||||
innerSizeName = "innerH";
|
||||
beforeName = 'top';
|
||||
deltaSizeName = "deltaH";
|
||||
contentSizeName = "contentH";
|
||||
|
||||
alignBeforeName = "left";
|
||||
alignSizeName = "w";
|
||||
alignAxisName = "x";
|
||||
alignInnerSizeName = "innerW";
|
||||
alignMinSizeName = "minW";
|
||||
alignAfterName = "right";
|
||||
alignDeltaSizeName = "deltaW";
|
||||
alignContentSizeName = "contentW";
|
||||
} else {
|
||||
posName = "x";
|
||||
sizeName = "w";
|
||||
minSizeName = "minW";
|
||||
maxSizeName = "maxW";
|
||||
innerSizeName = "innerW";
|
||||
beforeName = 'left';
|
||||
deltaSizeName = "deltaW";
|
||||
contentSizeName = "contentW";
|
||||
|
||||
alignBeforeName = "top";
|
||||
alignSizeName = "h";
|
||||
alignAxisName = "y";
|
||||
alignInnerSizeName = "innerH";
|
||||
alignMinSizeName = "minH";
|
||||
alignAfterName = "bottom";
|
||||
alignDeltaSizeName = "deltaH";
|
||||
alignContentSizeName = "contentH";
|
||||
}
|
||||
|
||||
// Figure out total flex, availableSpace and collect any max size elements
|
||||
availableSpace = contLayoutRect[innerSizeName] - contPaddingBox[beforeName] - contPaddingBox[beforeName];
|
||||
maxAlignEndPos = totalFlex = 0;
|
||||
for (i = 0, l = items.length; i < l; i++) {
|
||||
ctrl = items[i];
|
||||
ctrlLayoutRect = ctrl.layoutRect();
|
||||
ctrlSettings = ctrl.settings;
|
||||
flex = ctrlSettings.flex;
|
||||
availableSpace -= (i < l - 1 ? spacing : 0);
|
||||
|
||||
if (flex > 0) {
|
||||
totalFlex += flex;
|
||||
|
||||
// Flexed item has a max size then we need to check if we will hit that size
|
||||
if (ctrlLayoutRect[maxSizeName]) {
|
||||
maxSizeItems.push(ctrl);
|
||||
}
|
||||
|
||||
ctrlLayoutRect.flex = flex;
|
||||
}
|
||||
|
||||
availableSpace -= ctrlLayoutRect[minSizeName];
|
||||
|
||||
// Calculate the align end position to be used to check for overflow/underflow
|
||||
size = contPaddingBox[alignBeforeName] + ctrlLayoutRect[alignMinSizeName] + contPaddingBox[alignAfterName];
|
||||
if (size > maxAlignEndPos) {
|
||||
maxAlignEndPos = size;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate minW/minH
|
||||
rect = {};
|
||||
if (availableSpace < 0) {
|
||||
rect[minSizeName] = contLayoutRect[minSizeName] - availableSpace + contLayoutRect[deltaSizeName];
|
||||
} else {
|
||||
rect[minSizeName] = contLayoutRect[innerSizeName] - availableSpace + contLayoutRect[deltaSizeName];
|
||||
}
|
||||
|
||||
rect[alignMinSizeName] = maxAlignEndPos + contLayoutRect[alignDeltaSizeName];
|
||||
|
||||
rect[contentSizeName] = contLayoutRect[innerSizeName] - availableSpace;
|
||||
rect[alignContentSizeName] = maxAlignEndPos;
|
||||
rect.minW = min(rect.minW, contLayoutRect.maxW);
|
||||
rect.minH = min(rect.minH, contLayoutRect.maxH);
|
||||
rect.minW = max(rect.minW, contLayoutRect.startMinWidth);
|
||||
rect.minH = max(rect.minH, contLayoutRect.startMinHeight);
|
||||
|
||||
// Resize container container if minSize was changed
|
||||
if (contLayoutRect.autoResize && (rect.minW != contLayoutRect.minW || rect.minH != contLayoutRect.minH)) {
|
||||
rect.w = rect.minW;
|
||||
rect.h = rect.minH;
|
||||
|
||||
container.layoutRect(rect);
|
||||
this.recalc(container);
|
||||
|
||||
// Forced recalc for example if items are hidden/shown
|
||||
if (container._lastRect === null) {
|
||||
var parentCtrl = container.parent();
|
||||
if (parentCtrl) {
|
||||
parentCtrl._lastRect = null;
|
||||
parentCtrl.recalc();
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle max size elements, check if they will become to wide with current options
|
||||
ratio = availableSpace / totalFlex;
|
||||
for (i = 0, l = maxSizeItems.length; i < l; i++) {
|
||||
ctrl = maxSizeItems[i];
|
||||
ctrlLayoutRect = ctrl.layoutRect();
|
||||
maxSize = ctrlLayoutRect[maxSizeName];
|
||||
size = ctrlLayoutRect[minSizeName] + ctrlLayoutRect.flex * ratio;
|
||||
|
||||
if (size > maxSize) {
|
||||
availableSpace -= (ctrlLayoutRect[maxSizeName] - ctrlLayoutRect[minSizeName]);
|
||||
totalFlex -= ctrlLayoutRect.flex;
|
||||
ctrlLayoutRect.flex = 0;
|
||||
ctrlLayoutRect.maxFlexSize = maxSize;
|
||||
} else {
|
||||
ctrlLayoutRect.maxFlexSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Setup new ratio, target layout rect, start position
|
||||
ratio = availableSpace / totalFlex;
|
||||
pos = contPaddingBox[beforeName];
|
||||
rect = {};
|
||||
|
||||
// Handle pack setting moves the start position to end, center
|
||||
if (totalFlex === 0) {
|
||||
if (pack == "end") {
|
||||
pos = availableSpace + contPaddingBox[beforeName];
|
||||
} else if (pack == "center") {
|
||||
pos = Math.round(
|
||||
(contLayoutRect[innerSizeName] / 2) - ((contLayoutRect[innerSizeName] - availableSpace) / 2)
|
||||
) + contPaddingBox[beforeName];
|
||||
|
||||
if (pos < 0) {
|
||||
pos = contPaddingBox[beforeName];
|
||||
}
|
||||
} else if (pack == "justify") {
|
||||
pos = contPaddingBox[beforeName];
|
||||
spacing = Math.floor(availableSpace / (items.length - 1));
|
||||
}
|
||||
}
|
||||
|
||||
// Default aligning (start) the other ones needs to be calculated while doing the layout
|
||||
rect[alignAxisName] = contPaddingBox[alignBeforeName];
|
||||
|
||||
// Start laying out controls
|
||||
for (i = 0, l = items.length; i < l; i++) {
|
||||
ctrl = items[i];
|
||||
ctrlLayoutRect = ctrl.layoutRect();
|
||||
size = ctrlLayoutRect.maxFlexSize || ctrlLayoutRect[minSizeName];
|
||||
|
||||
// Align the control on the other axis
|
||||
if (align === "center") {
|
||||
rect[alignAxisName] = Math.round((contLayoutRect[alignInnerSizeName] / 2) - (ctrlLayoutRect[alignSizeName] / 2));
|
||||
} else if (align === "stretch") {
|
||||
rect[alignSizeName] = max(
|
||||
ctrlLayoutRect[alignMinSizeName] || 0,
|
||||
contLayoutRect[alignInnerSizeName] - contPaddingBox[alignBeforeName] - contPaddingBox[alignAfterName]
|
||||
);
|
||||
rect[alignAxisName] = contPaddingBox[alignBeforeName];
|
||||
} else if (align === "end") {
|
||||
rect[alignAxisName] = contLayoutRect[alignInnerSizeName] - ctrlLayoutRect[alignSizeName] - contPaddingBox.top;
|
||||
}
|
||||
|
||||
// Calculate new size based on flex
|
||||
if (ctrlLayoutRect.flex > 0) {
|
||||
size += ctrlLayoutRect.flex * ratio;
|
||||
}
|
||||
|
||||
rect[sizeName] = size;
|
||||
rect[posName] = pos;
|
||||
ctrl.layoutRect(rect);
|
||||
|
||||
// Recalculate containers
|
||||
if (ctrl.recalc) {
|
||||
ctrl.recalc();
|
||||
}
|
||||
|
||||
// Move x/y position
|
||||
pos += size + spacing;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
409
js/tinymce/classes/ui/FloatPanel.js
Normal file
409
js/tinymce/classes/ui/FloatPanel.js
Normal file
@@ -0,0 +1,409 @@
|
||||
/**
|
||||
* FloatPanel.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class creates a floating panel.
|
||||
*
|
||||
* @-x-less FloatPanel.less
|
||||
* @class tinymce.ui.FloatPanel
|
||||
* @extends tinymce.ui.Panel
|
||||
* @mixes tinymce.ui.Movable
|
||||
* @mixes tinymce.ui.Resizable
|
||||
*/
|
||||
define("tinymce/ui/FloatPanel", [
|
||||
"tinymce/ui/Panel",
|
||||
"tinymce/ui/Movable",
|
||||
"tinymce/ui/Resizable",
|
||||
"tinymce/ui/DomUtils",
|
||||
"tinymce/dom/DomQuery",
|
||||
"tinymce/util/Delay"
|
||||
], function(Panel, Movable, Resizable, DomUtils, $, Delay) {
|
||||
"use strict";
|
||||
|
||||
var documentClickHandler, documentScrollHandler, windowResizeHandler, visiblePanels = [];
|
||||
var zOrder = [], hasModal;
|
||||
|
||||
function isChildOf(ctrl, parent) {
|
||||
while (ctrl) {
|
||||
if (ctrl == parent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ctrl = ctrl.parent();
|
||||
}
|
||||
}
|
||||
|
||||
function skipOrHidePanels(e) {
|
||||
// Hide any float panel when a click/focus out is out side that float panel and the
|
||||
// float panels direct parent for example a click on a menu button
|
||||
var i = visiblePanels.length;
|
||||
|
||||
while (i--) {
|
||||
var panel = visiblePanels[i], clickCtrl = panel.getParentCtrl(e.target);
|
||||
|
||||
if (panel.settings.autohide) {
|
||||
if (clickCtrl) {
|
||||
if (isChildOf(clickCtrl, panel) || panel.parent() === clickCtrl) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
e = panel.fire('autohide', {target: e.target});
|
||||
if (!e.isDefaultPrevented()) {
|
||||
panel.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function bindDocumentClickHandler() {
|
||||
|
||||
if (!documentClickHandler) {
|
||||
documentClickHandler = function(e) {
|
||||
// Gecko fires click event and in the wrong order on Mac so lets normalize
|
||||
if (e.button == 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
skipOrHidePanels(e);
|
||||
};
|
||||
|
||||
$(document).on('click touchstart', documentClickHandler);
|
||||
}
|
||||
}
|
||||
|
||||
function bindDocumentScrollHandler() {
|
||||
if (!documentScrollHandler) {
|
||||
documentScrollHandler = function() {
|
||||
var i;
|
||||
|
||||
i = visiblePanels.length;
|
||||
while (i--) {
|
||||
repositionPanel(visiblePanels[i]);
|
||||
}
|
||||
};
|
||||
|
||||
$(window).on('scroll', documentScrollHandler);
|
||||
}
|
||||
}
|
||||
|
||||
function bindWindowResizeHandler() {
|
||||
if (!windowResizeHandler) {
|
||||
var docElm = document.documentElement, clientWidth = docElm.clientWidth, clientHeight = docElm.clientHeight;
|
||||
|
||||
windowResizeHandler = function() {
|
||||
// Workaround for #7065 IE 7 fires resize events event though the window wasn't resized
|
||||
if (!document.all || clientWidth != docElm.clientWidth || clientHeight != docElm.clientHeight) {
|
||||
clientWidth = docElm.clientWidth;
|
||||
clientHeight = docElm.clientHeight;
|
||||
FloatPanel.hideAll();
|
||||
}
|
||||
};
|
||||
|
||||
$(window).on('resize', windowResizeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Repositions the panel to the top of page if the panel is outside of the visual viewport. It will
|
||||
* also reposition all child panels of the current panel.
|
||||
*/
|
||||
function repositionPanel(panel) {
|
||||
var scrollY = DomUtils.getViewPort().y;
|
||||
|
||||
function toggleFixedChildPanels(fixed, deltaY) {
|
||||
var parent;
|
||||
|
||||
for (var i = 0; i < visiblePanels.length; i++) {
|
||||
if (visiblePanels[i] != panel) {
|
||||
parent = visiblePanels[i].parent();
|
||||
|
||||
while (parent && (parent = parent.parent())) {
|
||||
if (parent == panel) {
|
||||
visiblePanels[i].fixed(fixed).moveBy(0, deltaY).repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (panel.settings.autofix) {
|
||||
if (!panel.state.get('fixed')) {
|
||||
panel._autoFixY = panel.layoutRect().y;
|
||||
|
||||
if (panel._autoFixY < scrollY) {
|
||||
panel.fixed(true).layoutRect({y: 0}).repaint();
|
||||
toggleFixedChildPanels(true, scrollY - panel._autoFixY);
|
||||
}
|
||||
} else {
|
||||
if (panel._autoFixY > scrollY) {
|
||||
panel.fixed(false).layoutRect({y: panel._autoFixY}).repaint();
|
||||
toggleFixedChildPanels(false, panel._autoFixY - scrollY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addRemove(add, ctrl) {
|
||||
var i, zIndex = FloatPanel.zIndex || 0xFFFF, topModal;
|
||||
|
||||
if (add) {
|
||||
zOrder.push(ctrl);
|
||||
} else {
|
||||
i = zOrder.length;
|
||||
|
||||
while (i--) {
|
||||
if (zOrder[i] === ctrl) {
|
||||
zOrder.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (zOrder.length) {
|
||||
for (i = 0; i < zOrder.length; i++) {
|
||||
if (zOrder[i].modal) {
|
||||
zIndex++;
|
||||
topModal = zOrder[i];
|
||||
}
|
||||
|
||||
zOrder[i].getEl().style.zIndex = zIndex;
|
||||
zOrder[i].zIndex = zIndex;
|
||||
zIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
var modalBlockEl = $('#' + ctrl.classPrefix + 'modal-block', ctrl.getContainerElm())[0];
|
||||
|
||||
if (topModal) {
|
||||
$(modalBlockEl).css('z-index', topModal.zIndex - 1);
|
||||
} else if (modalBlockEl) {
|
||||
modalBlockEl.parentNode.removeChild(modalBlockEl);
|
||||
hasModal = false;
|
||||
}
|
||||
|
||||
FloatPanel.currentZIndex = zIndex;
|
||||
}
|
||||
|
||||
var FloatPanel = Panel.extend({
|
||||
Mixins: [Movable, Resizable],
|
||||
|
||||
/**
|
||||
* Constructs a new control instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
* @setting {Boolean} autohide Automatically hide the panel.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
self._super(settings);
|
||||
self._eventsRoot = self;
|
||||
|
||||
self.classes.add('floatpanel');
|
||||
|
||||
// Hide floatpanes on click out side the root button
|
||||
if (settings.autohide) {
|
||||
bindDocumentClickHandler();
|
||||
bindWindowResizeHandler();
|
||||
visiblePanels.push(self);
|
||||
}
|
||||
|
||||
if (settings.autofix) {
|
||||
bindDocumentScrollHandler();
|
||||
|
||||
self.on('move', function() {
|
||||
repositionPanel(this);
|
||||
});
|
||||
}
|
||||
|
||||
self.on('postrender show', function(e) {
|
||||
if (e.control == self) {
|
||||
var $modalBlockEl, prefix = self.classPrefix;
|
||||
|
||||
if (self.modal && !hasModal) {
|
||||
$modalBlockEl = $('#' + prefix + 'modal-block', self.getContainerElm());
|
||||
if (!$modalBlockEl[0]) {
|
||||
$modalBlockEl = $(
|
||||
'<div id="' + prefix + 'modal-block" class="' + prefix + 'reset ' + prefix + 'fade"></div>'
|
||||
).appendTo(self.getContainerElm());
|
||||
}
|
||||
|
||||
Delay.setTimeout(function() {
|
||||
$modalBlockEl.addClass(prefix + 'in');
|
||||
$(self.getEl()).addClass(prefix + 'in');
|
||||
});
|
||||
|
||||
hasModal = true;
|
||||
}
|
||||
|
||||
addRemove(true, self);
|
||||
}
|
||||
});
|
||||
|
||||
self.on('show', function() {
|
||||
self.parents().each(function(ctrl) {
|
||||
if (ctrl.state.get('fixed')) {
|
||||
self.fixed(true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (settings.popover) {
|
||||
self._preBodyHtml = '<div class="' + self.classPrefix + 'arrow"></div>';
|
||||
self.classes.add('popover').add('bottom').add(self.isRtl() ? 'end' : 'start');
|
||||
}
|
||||
},
|
||||
|
||||
fixed: function(state) {
|
||||
var self = this;
|
||||
|
||||
if (self.state.get('fixed') != state) {
|
||||
if (self.state.get('rendered')) {
|
||||
var viewport = DomUtils.getViewPort();
|
||||
|
||||
if (state) {
|
||||
self.layoutRect().y -= viewport.y;
|
||||
} else {
|
||||
self.layoutRect().y += viewport.y;
|
||||
}
|
||||
}
|
||||
|
||||
self.classes.toggle('fixed', state);
|
||||
self.state.set('fixed', state);
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Shows the current float panel.
|
||||
*
|
||||
* @method show
|
||||
* @return {tinymce.ui.FloatPanel} Current floatpanel instance.
|
||||
*/
|
||||
show: function() {
|
||||
var self = this, i, state = self._super();
|
||||
|
||||
i = visiblePanels.length;
|
||||
while (i--) {
|
||||
if (visiblePanels[i] === self) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i === -1) {
|
||||
visiblePanels.push(self);
|
||||
}
|
||||
|
||||
return state;
|
||||
},
|
||||
|
||||
/**
|
||||
* Hides the current float panel.
|
||||
*
|
||||
* @method hide
|
||||
* @return {tinymce.ui.FloatPanel} Current floatpanel instance.
|
||||
*/
|
||||
hide: function() {
|
||||
removeVisiblePanel(this);
|
||||
addRemove(false, this);
|
||||
|
||||
return this._super();
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide all visible float panels with he autohide setting enabled. This is for
|
||||
* manually hiding floating menus or panels.
|
||||
*
|
||||
* @method hideAll
|
||||
*/
|
||||
hideAll: function() {
|
||||
FloatPanel.hideAll();
|
||||
},
|
||||
|
||||
/**
|
||||
* Closes the float panel. This will remove the float panel from page and fire the close event.
|
||||
*
|
||||
* @method close
|
||||
*/
|
||||
close: function() {
|
||||
var self = this;
|
||||
|
||||
if (!self.fire('close').isDefaultPrevented()) {
|
||||
self.remove();
|
||||
addRemove(false, self);
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the float panel from page.
|
||||
*
|
||||
* @method remove
|
||||
*/
|
||||
remove: function() {
|
||||
removeVisiblePanel(this);
|
||||
this._super();
|
||||
},
|
||||
|
||||
postRender: function() {
|
||||
var self = this;
|
||||
|
||||
if (self.settings.bodyRole) {
|
||||
this.getEl('body').setAttribute('role', self.settings.bodyRole);
|
||||
}
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Hide all visible float panels with he autohide setting enabled. This is for
|
||||
* manually hiding floating menus or panels.
|
||||
*
|
||||
* @static
|
||||
* @method hideAll
|
||||
*/
|
||||
FloatPanel.hideAll = function() {
|
||||
var i = visiblePanels.length;
|
||||
|
||||
while (i--) {
|
||||
var panel = visiblePanels[i];
|
||||
|
||||
if (panel && panel.settings.autohide) {
|
||||
panel.hide();
|
||||
visiblePanels.splice(i, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function removeVisiblePanel(panel) {
|
||||
var i;
|
||||
|
||||
i = visiblePanels.length;
|
||||
while (i--) {
|
||||
if (visiblePanels[i] === panel) {
|
||||
visiblePanels.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
i = zOrder.length;
|
||||
while (i--) {
|
||||
if (zOrder[i] === panel) {
|
||||
zOrder.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FloatPanel;
|
||||
});
|
||||
46
js/tinymce/classes/ui/FlowLayout.js
Normal file
46
js/tinymce/classes/ui/FlowLayout.js
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* FlowLayout.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This layout manager will place the controls by using the browsers native layout.
|
||||
*
|
||||
* @-x-less FlowLayout.less
|
||||
* @class tinymce.ui.FlowLayout
|
||||
* @extends tinymce.ui.Layout
|
||||
*/
|
||||
define("tinymce/ui/FlowLayout", [
|
||||
"tinymce/ui/Layout"
|
||||
], function(Layout) {
|
||||
return Layout.extend({
|
||||
Defaults: {
|
||||
containerClass: 'flow-layout',
|
||||
controlClass: 'flow-layout-item',
|
||||
endClass: 'break'
|
||||
},
|
||||
|
||||
/**
|
||||
* Recalculates the positions of the controls in the specified container.
|
||||
*
|
||||
* @method recalc
|
||||
* @param {tinymce.ui.Container} container Container instance to recalc.
|
||||
*/
|
||||
recalc: function(container) {
|
||||
container.items().filter(':visible').each(function(ctrl) {
|
||||
if (ctrl.recalc) {
|
||||
ctrl.recalc();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
isNative: function() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
157
js/tinymce/classes/ui/Form.js
Normal file
157
js/tinymce/classes/ui/Form.js
Normal file
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* Form.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class creates a form container. A form container has the ability
|
||||
* to automatically wrap items in tinymce.ui.FormItem instances.
|
||||
*
|
||||
* Each FormItem instance is a container for the label and the item.
|
||||
*
|
||||
* @example
|
||||
* tinymce.ui.Factory.create({
|
||||
* type: 'form',
|
||||
* items: [
|
||||
* {type: 'textbox', label: 'My text box'}
|
||||
* ]
|
||||
* }).renderTo(document.body);
|
||||
*
|
||||
* @class tinymce.ui.Form
|
||||
* @extends tinymce.ui.Container
|
||||
*/
|
||||
define("tinymce/ui/Form", [
|
||||
"tinymce/ui/Container",
|
||||
"tinymce/ui/FormItem",
|
||||
"tinymce/util/Tools"
|
||||
], function(Container, FormItem, Tools) {
|
||||
"use strict";
|
||||
|
||||
return Container.extend({
|
||||
Defaults: {
|
||||
containerCls: 'form',
|
||||
layout: 'flex',
|
||||
direction: 'column',
|
||||
align: 'stretch',
|
||||
flex: 1,
|
||||
padding: 20,
|
||||
labelGap: 30,
|
||||
spacing: 10,
|
||||
callbacks: {
|
||||
submit: function() {
|
||||
this.submit();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* This method gets invoked before the control is rendered.
|
||||
*
|
||||
* @method preRender
|
||||
*/
|
||||
preRender: function() {
|
||||
var self = this, items = self.items();
|
||||
|
||||
if (!self.settings.formItemDefaults) {
|
||||
self.settings.formItemDefaults = {
|
||||
layout: 'flex',
|
||||
autoResize: "overflow",
|
||||
defaults: {flex: 1}
|
||||
};
|
||||
}
|
||||
|
||||
// Wrap any labeled items in FormItems
|
||||
items.each(function(ctrl) {
|
||||
var formItem, label = ctrl.settings.label;
|
||||
|
||||
if (label) {
|
||||
formItem = new FormItem(Tools.extend({
|
||||
items: {
|
||||
type: 'label',
|
||||
id: ctrl._id + '-l',
|
||||
text: label,
|
||||
flex: 0,
|
||||
forId: ctrl._id,
|
||||
disabled: ctrl.disabled()
|
||||
}
|
||||
}, self.settings.formItemDefaults));
|
||||
|
||||
formItem.type = 'formitem';
|
||||
ctrl.aria('labelledby', ctrl._id + '-l');
|
||||
|
||||
if (typeof ctrl.settings.flex == "undefined") {
|
||||
ctrl.settings.flex = 1;
|
||||
}
|
||||
|
||||
self.replace(ctrl, formItem);
|
||||
formItem.add(ctrl);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Fires a submit event with the serialized form.
|
||||
*
|
||||
* @method submit
|
||||
* @return {Object} Event arguments object.
|
||||
*/
|
||||
submit: function() {
|
||||
return this.fire('submit', {data: this.toJSON()});
|
||||
},
|
||||
|
||||
/**
|
||||
* Post render method. Called after the control has been rendered to the target.
|
||||
*
|
||||
* @method postRender
|
||||
* @return {tinymce.ui.ComboBox} Current combobox instance.
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this;
|
||||
|
||||
self._super();
|
||||
self.fromJSON(self.settings.data);
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
self._super();
|
||||
|
||||
function recalcLabels() {
|
||||
var maxLabelWidth = 0, labels = [], i, labelGap, items;
|
||||
|
||||
if (self.settings.labelGapCalc === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.settings.labelGapCalc == "children") {
|
||||
items = self.find('formitem');
|
||||
} else {
|
||||
items = self.items();
|
||||
}
|
||||
|
||||
items.filter('formitem').each(function(item) {
|
||||
var labelCtrl = item.items()[0], labelWidth = labelCtrl.getEl().clientWidth;
|
||||
|
||||
maxLabelWidth = labelWidth > maxLabelWidth ? labelWidth : maxLabelWidth;
|
||||
labels.push(labelCtrl);
|
||||
});
|
||||
|
||||
labelGap = self.settings.labelGap || 0;
|
||||
|
||||
i = labels.length;
|
||||
while (i--) {
|
||||
labels[i].settings.minWidth = maxLabelWidth + labelGap;
|
||||
}
|
||||
}
|
||||
|
||||
self.on('show', recalcLabels);
|
||||
recalcLabels();
|
||||
}
|
||||
});
|
||||
});
|
||||
56
js/tinymce/classes/ui/FormItem.js
Normal file
56
js/tinymce/classes/ui/FormItem.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* FormItem.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is a container created by the form element with
|
||||
* a label and control item.
|
||||
*
|
||||
* @class tinymce.ui.FormItem
|
||||
* @extends tinymce.ui.Container
|
||||
* @setting {String} label Label to display for the form item.
|
||||
*/
|
||||
define("tinymce/ui/FormItem", [
|
||||
"tinymce/ui/Container"
|
||||
], function(Container) {
|
||||
"use strict";
|
||||
|
||||
return Container.extend({
|
||||
Defaults: {
|
||||
layout: 'flex',
|
||||
align: 'center',
|
||||
defaults: {
|
||||
flex: 1
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, layout = self._layout, prefix = self.classPrefix;
|
||||
|
||||
self.classes.add('formitem');
|
||||
layout.preRender(self);
|
||||
|
||||
return (
|
||||
'<div id="' + self._id + '" class="' + self.classes + '" hidefocus="1" tabindex="-1">' +
|
||||
(self.settings.title ? ('<div id="' + self._id + '-title" class="' + prefix + 'title">' +
|
||||
self.settings.title + '</div>') : '') +
|
||||
'<div id="' + self._id + '-body" class="' + self.bodyClasses + '">' +
|
||||
(self.settings.html || '') + layout.renderHtml(self) +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
535
js/tinymce/classes/ui/FormatControls.js
Normal file
535
js/tinymce/classes/ui/FormatControls.js
Normal file
@@ -0,0 +1,535 @@
|
||||
/**
|
||||
* FormatControls.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Internal class containing all TinyMCE specific control types such as
|
||||
* format listboxes, fontlist boxes, toolbar buttons etc.
|
||||
*
|
||||
* @class tinymce.ui.FormatControls
|
||||
*/
|
||||
define("tinymce/ui/FormatControls", [
|
||||
"tinymce/ui/Control",
|
||||
"tinymce/ui/Widget",
|
||||
"tinymce/ui/FloatPanel",
|
||||
"tinymce/util/Tools",
|
||||
"tinymce/EditorManager",
|
||||
"tinymce/Env"
|
||||
], function(Control, Widget, FloatPanel, Tools, EditorManager, Env) {
|
||||
var each = Tools.each;
|
||||
|
||||
EditorManager.on('AddEditor', function(e) {
|
||||
if (e.editor.rtl) {
|
||||
Control.rtl = true;
|
||||
}
|
||||
|
||||
registerControls(e.editor);
|
||||
});
|
||||
|
||||
Control.translate = function(text) {
|
||||
return EditorManager.translate(text);
|
||||
};
|
||||
|
||||
Widget.tooltips = !Env.iOS;
|
||||
|
||||
function registerControls(editor) {
|
||||
var formatMenu;
|
||||
|
||||
function createListBoxChangeHandler(items, formatName) {
|
||||
return function() {
|
||||
var self = this;
|
||||
|
||||
editor.on('nodeChange', function(e) {
|
||||
var formatter = editor.formatter;
|
||||
var value = null;
|
||||
|
||||
each(e.parents, function(node) {
|
||||
each(items, function(item) {
|
||||
if (formatName) {
|
||||
if (formatter.matchNode(node, formatName, {value: item.value})) {
|
||||
value = item.value;
|
||||
}
|
||||
} else {
|
||||
if (formatter.matchNode(node, item.value)) {
|
||||
value = item.value;
|
||||
}
|
||||
}
|
||||
|
||||
if (value) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (value) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
self.value(value);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function createFormats(formats) {
|
||||
formats = formats.replace(/;$/, '').split(';');
|
||||
|
||||
var i = formats.length;
|
||||
while (i--) {
|
||||
formats[i] = formats[i].split('=');
|
||||
}
|
||||
|
||||
return formats;
|
||||
}
|
||||
|
||||
function createFormatMenu() {
|
||||
var count = 0, newFormats = [];
|
||||
|
||||
var defaultStyleFormats = [
|
||||
{title: 'Headings', items: [
|
||||
{title: 'Heading 1', format: 'h1'},
|
||||
{title: 'Heading 2', format: 'h2'},
|
||||
{title: 'Heading 3', format: 'h3'},
|
||||
{title: 'Heading 4', format: 'h4'},
|
||||
{title: 'Heading 5', format: 'h5'},
|
||||
{title: 'Heading 6', format: 'h6'}
|
||||
]},
|
||||
|
||||
{title: 'Inline', items: [
|
||||
{title: 'Bold', icon: 'bold', format: 'bold'},
|
||||
{title: 'Italic', icon: 'italic', format: 'italic'},
|
||||
{title: 'Underline', icon: 'underline', format: 'underline'},
|
||||
{title: 'Strikethrough', icon: 'strikethrough', format: 'strikethrough'},
|
||||
{title: 'Superscript', icon: 'superscript', format: 'superscript'},
|
||||
{title: 'Subscript', icon: 'subscript', format: 'subscript'},
|
||||
{title: 'Code', icon: 'code', format: 'code'}
|
||||
]},
|
||||
|
||||
{title: 'Blocks', items: [
|
||||
{title: 'Paragraph', format: 'p'},
|
||||
{title: 'Blockquote', format: 'blockquote'},
|
||||
{title: 'Div', format: 'div'},
|
||||
{title: 'Pre', format: 'pre'}
|
||||
]},
|
||||
|
||||
{title: 'Alignment', items: [
|
||||
{title: 'Left', icon: 'alignleft', format: 'alignleft'},
|
||||
{title: 'Center', icon: 'aligncenter', format: 'aligncenter'},
|
||||
{title: 'Right', icon: 'alignright', format: 'alignright'},
|
||||
{title: 'Justify', icon: 'alignjustify', format: 'alignjustify'}
|
||||
]}
|
||||
];
|
||||
|
||||
function createMenu(formats) {
|
||||
var menu = [];
|
||||
|
||||
if (!formats) {
|
||||
return;
|
||||
}
|
||||
|
||||
each(formats, function(format) {
|
||||
var menuItem = {
|
||||
text: format.title,
|
||||
icon: format.icon
|
||||
};
|
||||
|
||||
if (format.items) {
|
||||
menuItem.menu = createMenu(format.items);
|
||||
} else {
|
||||
var formatName = format.format || "custom" + count++;
|
||||
|
||||
if (!format.format) {
|
||||
format.name = formatName;
|
||||
newFormats.push(format);
|
||||
}
|
||||
|
||||
menuItem.format = formatName;
|
||||
menuItem.cmd = format.cmd;
|
||||
}
|
||||
|
||||
menu.push(menuItem);
|
||||
});
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
function createStylesMenu() {
|
||||
var menu;
|
||||
|
||||
if (editor.settings.style_formats_merge) {
|
||||
if (editor.settings.style_formats) {
|
||||
menu = createMenu(defaultStyleFormats.concat(editor.settings.style_formats));
|
||||
} else {
|
||||
menu = createMenu(defaultStyleFormats);
|
||||
}
|
||||
} else {
|
||||
menu = createMenu(editor.settings.style_formats || defaultStyleFormats);
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
editor.on('init', function() {
|
||||
each(newFormats, function(format) {
|
||||
editor.formatter.register(format.name, format);
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
type: 'menu',
|
||||
items: createStylesMenu(),
|
||||
onPostRender: function(e) {
|
||||
editor.fire('renderFormatsMenu', {control: e.control});
|
||||
},
|
||||
itemDefaults: {
|
||||
preview: true,
|
||||
|
||||
textStyle: function() {
|
||||
if (this.settings.format) {
|
||||
return editor.formatter.getCssText(this.settings.format);
|
||||
}
|
||||
},
|
||||
|
||||
onPostRender: function() {
|
||||
var self = this;
|
||||
|
||||
self.parent().on('show', function() {
|
||||
var formatName, command;
|
||||
|
||||
formatName = self.settings.format;
|
||||
if (formatName) {
|
||||
self.disabled(!editor.formatter.canApply(formatName));
|
||||
self.active(editor.formatter.match(formatName));
|
||||
}
|
||||
|
||||
command = self.settings.cmd;
|
||||
if (command) {
|
||||
self.active(editor.queryCommandState(command));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onclick: function() {
|
||||
if (this.settings.format) {
|
||||
toggleFormat(this.settings.format);
|
||||
}
|
||||
|
||||
if (this.settings.cmd) {
|
||||
editor.execCommand(this.settings.cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
formatMenu = createFormatMenu();
|
||||
|
||||
function initOnPostRender(name) {
|
||||
return function() {
|
||||
var self = this;
|
||||
|
||||
// TODO: Fix this
|
||||
if (editor.formatter) {
|
||||
editor.formatter.formatChanged(name, function(state) {
|
||||
self.active(state);
|
||||
});
|
||||
} else {
|
||||
editor.on('init', function() {
|
||||
editor.formatter.formatChanged(name, function(state) {
|
||||
self.active(state);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Simple format controls <control/format>:<UI text>
|
||||
each({
|
||||
bold: 'Bold',
|
||||
italic: 'Italic',
|
||||
underline: 'Underline',
|
||||
strikethrough: 'Strikethrough',
|
||||
subscript: 'Subscript',
|
||||
superscript: 'Superscript'
|
||||
}, function(text, name) {
|
||||
editor.addButton(name, {
|
||||
tooltip: text,
|
||||
onPostRender: initOnPostRender(name),
|
||||
onclick: function() {
|
||||
toggleFormat(name);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Simple command controls <control>:[<UI text>,<Command>]
|
||||
each({
|
||||
outdent: ['Decrease indent', 'Outdent'],
|
||||
indent: ['Increase indent', 'Indent'],
|
||||
cut: ['Cut', 'Cut'],
|
||||
copy: ['Copy', 'Copy'],
|
||||
paste: ['Paste', 'Paste'],
|
||||
help: ['Help', 'mceHelp'],
|
||||
selectall: ['Select all', 'SelectAll'],
|
||||
removeformat: ['Clear formatting', 'RemoveFormat'],
|
||||
visualaid: ['Visual aids', 'mceToggleVisualAid'],
|
||||
newdocument: ['New document', 'mceNewDocument']
|
||||
}, function(item, name) {
|
||||
editor.addButton(name, {
|
||||
tooltip: item[0],
|
||||
cmd: item[1]
|
||||
});
|
||||
});
|
||||
|
||||
// Simple command controls with format state
|
||||
each({
|
||||
blockquote: ['Blockquote', 'mceBlockQuote'],
|
||||
numlist: ['Numbered list', 'InsertOrderedList'],
|
||||
bullist: ['Bullet list', 'InsertUnorderedList'],
|
||||
subscript: ['Subscript', 'Subscript'],
|
||||
superscript: ['Superscript', 'Superscript'],
|
||||
alignleft: ['Align left', 'JustifyLeft'],
|
||||
aligncenter: ['Align center', 'JustifyCenter'],
|
||||
alignright: ['Align right', 'JustifyRight'],
|
||||
alignjustify: ['Justify', 'JustifyFull'],
|
||||
alignnone: ['No alignment', 'JustifyNone']
|
||||
}, function(item, name) {
|
||||
editor.addButton(name, {
|
||||
tooltip: item[0],
|
||||
cmd: item[1],
|
||||
onPostRender: initOnPostRender(name)
|
||||
});
|
||||
});
|
||||
|
||||
function toggleUndoRedoState(type) {
|
||||
return function() {
|
||||
var self = this;
|
||||
|
||||
type = type == 'redo' ? 'hasRedo' : 'hasUndo';
|
||||
|
||||
function checkState() {
|
||||
return editor.undoManager ? editor.undoManager[type]() : false;
|
||||
}
|
||||
|
||||
self.disabled(!checkState());
|
||||
editor.on('Undo Redo AddUndo TypingUndo ClearUndos SwitchMode', function() {
|
||||
self.disabled(editor.readonly || !checkState());
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function toggleVisualAidState() {
|
||||
var self = this;
|
||||
|
||||
editor.on('VisualAid', function(e) {
|
||||
self.active(e.hasVisual);
|
||||
});
|
||||
|
||||
self.active(editor.hasVisual);
|
||||
}
|
||||
|
||||
editor.addButton('undo', {
|
||||
tooltip: 'Undo',
|
||||
onPostRender: toggleUndoRedoState('undo'),
|
||||
cmd: 'undo'
|
||||
});
|
||||
|
||||
editor.addButton('redo', {
|
||||
tooltip: 'Redo',
|
||||
onPostRender: toggleUndoRedoState('redo'),
|
||||
cmd: 'redo'
|
||||
});
|
||||
|
||||
editor.addMenuItem('newdocument', {
|
||||
text: 'New document',
|
||||
icon: 'newdocument',
|
||||
cmd: 'mceNewDocument'
|
||||
});
|
||||
|
||||
editor.addMenuItem('undo', {
|
||||
text: 'Undo',
|
||||
icon: 'undo',
|
||||
shortcut: 'Meta+Z',
|
||||
onPostRender: toggleUndoRedoState('undo'),
|
||||
cmd: 'undo'
|
||||
});
|
||||
|
||||
editor.addMenuItem('redo', {
|
||||
text: 'Redo',
|
||||
icon: 'redo',
|
||||
shortcut: 'Meta+Y',
|
||||
onPostRender: toggleUndoRedoState('redo'),
|
||||
cmd: 'redo'
|
||||
});
|
||||
|
||||
editor.addMenuItem('visualaid', {
|
||||
text: 'Visual aids',
|
||||
selectable: true,
|
||||
onPostRender: toggleVisualAidState,
|
||||
cmd: 'mceToggleVisualAid'
|
||||
});
|
||||
|
||||
editor.addButton('remove', {
|
||||
tooltip: 'Remove',
|
||||
icon: 'remove',
|
||||
cmd: 'Delete'
|
||||
});
|
||||
|
||||
each({
|
||||
cut: ['Cut', 'Cut', 'Meta+X'],
|
||||
copy: ['Copy', 'Copy', 'Meta+C'],
|
||||
paste: ['Paste', 'Paste', 'Meta+V'],
|
||||
selectall: ['Select all', 'SelectAll', 'Meta+A'],
|
||||
bold: ['Bold', 'Bold', 'Meta+B'],
|
||||
italic: ['Italic', 'Italic', 'Meta+I'],
|
||||
underline: ['Underline', 'Underline'],
|
||||
strikethrough: ['Strikethrough', 'Strikethrough'],
|
||||
subscript: ['Subscript', 'Subscript'],
|
||||
superscript: ['Superscript', 'Superscript'],
|
||||
removeformat: ['Clear formatting', 'RemoveFormat']
|
||||
}, function(item, name) {
|
||||
editor.addMenuItem(name, {
|
||||
text: item[0],
|
||||
icon: name,
|
||||
shortcut: item[2],
|
||||
cmd: item[1]
|
||||
});
|
||||
});
|
||||
|
||||
editor.on('mousedown', function() {
|
||||
FloatPanel.hideAll();
|
||||
});
|
||||
|
||||
function toggleFormat(fmt) {
|
||||
if (fmt.control) {
|
||||
fmt = fmt.control.value();
|
||||
}
|
||||
|
||||
if (fmt) {
|
||||
editor.execCommand('mceToggleFormat', false, fmt);
|
||||
}
|
||||
}
|
||||
|
||||
editor.addButton('styleselect', {
|
||||
type: 'menubutton',
|
||||
text: 'Formats',
|
||||
menu: formatMenu
|
||||
});
|
||||
|
||||
editor.addButton('formatselect', function() {
|
||||
var items = [], blocks = createFormats(editor.settings.block_formats ||
|
||||
'Paragraph=p;' +
|
||||
'Heading 1=h1;' +
|
||||
'Heading 2=h2;' +
|
||||
'Heading 3=h3;' +
|
||||
'Heading 4=h4;' +
|
||||
'Heading 5=h5;' +
|
||||
'Heading 6=h6;' +
|
||||
'Preformatted=pre'
|
||||
);
|
||||
|
||||
each(blocks, function(block) {
|
||||
items.push({
|
||||
text: block[0],
|
||||
value: block[1],
|
||||
textStyle: function() {
|
||||
return editor.formatter.getCssText(block[1]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
type: 'listbox',
|
||||
text: blocks[0][0],
|
||||
values: items,
|
||||
fixedWidth: true,
|
||||
onselect: toggleFormat,
|
||||
onPostRender: createListBoxChangeHandler(items)
|
||||
};
|
||||
});
|
||||
|
||||
editor.addButton('fontselect', function() {
|
||||
var defaultFontsFormats =
|
||||
'Andale Mono=andale mono,monospace;' +
|
||||
'Arial=arial,helvetica,sans-serif;' +
|
||||
'Arial Black=arial black,sans-serif;' +
|
||||
'Book Antiqua=book antiqua,palatino,serif;' +
|
||||
'Comic Sans MS=comic sans ms,sans-serif;' +
|
||||
'Courier New=courier new,courier,monospace;' +
|
||||
'Georgia=georgia,palatino,serif;' +
|
||||
'Helvetica=helvetica,arial,sans-serif;' +
|
||||
'Impact=impact,sans-serif;' +
|
||||
'Symbol=symbol;' +
|
||||
'Tahoma=tahoma,arial,helvetica,sans-serif;' +
|
||||
'Terminal=terminal,monaco,monospace;' +
|
||||
'Times New Roman=times new roman,times,serif;' +
|
||||
'Trebuchet MS=trebuchet ms,geneva,sans-serif;' +
|
||||
'Verdana=verdana,geneva,sans-serif;' +
|
||||
'Webdings=webdings;' +
|
||||
'Wingdings=wingdings,zapf dingbats';
|
||||
|
||||
var items = [], fonts = createFormats(editor.settings.font_formats || defaultFontsFormats);
|
||||
|
||||
each(fonts, function(font) {
|
||||
items.push({
|
||||
text: {raw: font[0]},
|
||||
value: font[1],
|
||||
textStyle: font[1].indexOf('dings') == -1 ? 'font-family:' + font[1] : ''
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
type: 'listbox',
|
||||
text: 'Font Family',
|
||||
tooltip: 'Font Family',
|
||||
values: items,
|
||||
fixedWidth: true,
|
||||
onPostRender: createListBoxChangeHandler(items, 'fontname'),
|
||||
onselect: function(e) {
|
||||
if (e.control.settings.value) {
|
||||
editor.execCommand('FontName', false, e.control.settings.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
editor.addButton('fontsizeselect', function() {
|
||||
var items = [], defaultFontsizeFormats = '8pt 10pt 12pt 14pt 18pt 24pt 36pt';
|
||||
var fontsize_formats = editor.settings.fontsize_formats || defaultFontsizeFormats;
|
||||
|
||||
each(fontsize_formats.split(' '), function(item) {
|
||||
var text = item, value = item;
|
||||
// Allow text=value font sizes.
|
||||
var values = item.split('=');
|
||||
if (values.length > 1) {
|
||||
text = values[0];
|
||||
value = values[1];
|
||||
}
|
||||
items.push({text: text, value: value});
|
||||
});
|
||||
|
||||
return {
|
||||
type: 'listbox',
|
||||
text: 'Font Sizes',
|
||||
tooltip: 'Font Sizes',
|
||||
values: items,
|
||||
fixedWidth: true,
|
||||
onPostRender: createListBoxChangeHandler(items, 'fontsize'),
|
||||
onclick: function(e) {
|
||||
if (e.control.settings.value) {
|
||||
editor.execCommand('FontSize', false, e.control.settings.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
editor.addMenuItem('formats', {
|
||||
text: 'Formats',
|
||||
menu: formatMenu
|
||||
});
|
||||
}
|
||||
});
|
||||
233
js/tinymce/classes/ui/GridLayout.js
Normal file
233
js/tinymce/classes/ui/GridLayout.js
Normal file
@@ -0,0 +1,233 @@
|
||||
/**
|
||||
* GridLayout.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This layout manager places controls in a grid.
|
||||
*
|
||||
* @setting {Number} spacing Spacing between controls.
|
||||
* @setting {Number} spacingH Horizontal spacing between controls.
|
||||
* @setting {Number} spacingV Vertical spacing between controls.
|
||||
* @setting {Number} columns Number of columns to use.
|
||||
* @setting {String/Array} alignH start|end|center|stretch or array of values for each column.
|
||||
* @setting {String/Array} alignV start|end|center|stretch or array of values for each column.
|
||||
* @setting {String} pack start|end
|
||||
*
|
||||
* @class tinymce.ui.GridLayout
|
||||
* @extends tinymce.ui.AbsoluteLayout
|
||||
*/
|
||||
define("tinymce/ui/GridLayout", [
|
||||
"tinymce/ui/AbsoluteLayout"
|
||||
], function(AbsoluteLayout) {
|
||||
"use strict";
|
||||
|
||||
return AbsoluteLayout.extend({
|
||||
/**
|
||||
* Recalculates the positions of the controls in the specified container.
|
||||
*
|
||||
* @method recalc
|
||||
* @param {tinymce.ui.Container} container Container instance to recalc.
|
||||
*/
|
||||
recalc: function(container) {
|
||||
var settings, rows, cols, items, contLayoutRect, width, height, rect,
|
||||
ctrlLayoutRect, ctrl, x, y, posX, posY, ctrlSettings, contPaddingBox, align, spacingH, spacingV, alignH, alignV, maxX, maxY,
|
||||
colWidths = [], rowHeights = [], ctrlMinWidth, ctrlMinHeight, availableWidth, availableHeight, reverseRows, idx;
|
||||
|
||||
// Get layout settings
|
||||
settings = container.settings;
|
||||
items = container.items().filter(':visible');
|
||||
contLayoutRect = container.layoutRect();
|
||||
cols = settings.columns || Math.ceil(Math.sqrt(items.length));
|
||||
rows = Math.ceil(items.length / cols);
|
||||
spacingH = settings.spacingH || settings.spacing || 0;
|
||||
spacingV = settings.spacingV || settings.spacing || 0;
|
||||
alignH = settings.alignH || settings.align;
|
||||
alignV = settings.alignV || settings.align;
|
||||
contPaddingBox = container.paddingBox;
|
||||
reverseRows = 'reverseRows' in settings ? settings.reverseRows : container.isRtl();
|
||||
|
||||
if (alignH && typeof alignH == "string") {
|
||||
alignH = [alignH];
|
||||
}
|
||||
|
||||
if (alignV && typeof alignV == "string") {
|
||||
alignV = [alignV];
|
||||
}
|
||||
|
||||
// Zero padd columnWidths
|
||||
for (x = 0; x < cols; x++) {
|
||||
colWidths.push(0);
|
||||
}
|
||||
|
||||
// Zero padd rowHeights
|
||||
for (y = 0; y < rows; y++) {
|
||||
rowHeights.push(0);
|
||||
}
|
||||
|
||||
// Calculate columnWidths and rowHeights
|
||||
for (y = 0; y < rows; y++) {
|
||||
for (x = 0; x < cols; x++) {
|
||||
ctrl = items[y * cols + x];
|
||||
|
||||
// Out of bounds
|
||||
if (!ctrl) {
|
||||
break;
|
||||
}
|
||||
|
||||
ctrlLayoutRect = ctrl.layoutRect();
|
||||
ctrlMinWidth = ctrlLayoutRect.minW;
|
||||
ctrlMinHeight = ctrlLayoutRect.minH;
|
||||
|
||||
colWidths[x] = ctrlMinWidth > colWidths[x] ? ctrlMinWidth : colWidths[x];
|
||||
rowHeights[y] = ctrlMinHeight > rowHeights[y] ? ctrlMinHeight : rowHeights[y];
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate maxX
|
||||
availableWidth = contLayoutRect.innerW - contPaddingBox.left - contPaddingBox.right;
|
||||
for (maxX = 0, x = 0; x < cols; x++) {
|
||||
maxX += colWidths[x] + (x > 0 ? spacingH : 0);
|
||||
availableWidth -= (x > 0 ? spacingH : 0) + colWidths[x];
|
||||
}
|
||||
|
||||
// Calculate maxY
|
||||
availableHeight = contLayoutRect.innerH - contPaddingBox.top - contPaddingBox.bottom;
|
||||
for (maxY = 0, y = 0; y < rows; y++) {
|
||||
maxY += rowHeights[y] + (y > 0 ? spacingV : 0);
|
||||
availableHeight -= (y > 0 ? spacingV : 0) + rowHeights[y];
|
||||
}
|
||||
|
||||
maxX += contPaddingBox.left + contPaddingBox.right;
|
||||
maxY += contPaddingBox.top + contPaddingBox.bottom;
|
||||
|
||||
// Calculate minW/minH
|
||||
rect = {};
|
||||
rect.minW = maxX + (contLayoutRect.w - contLayoutRect.innerW);
|
||||
rect.minH = maxY + (contLayoutRect.h - contLayoutRect.innerH);
|
||||
|
||||
rect.contentW = rect.minW - contLayoutRect.deltaW;
|
||||
rect.contentH = rect.minH - contLayoutRect.deltaH;
|
||||
rect.minW = Math.min(rect.minW, contLayoutRect.maxW);
|
||||
rect.minH = Math.min(rect.minH, contLayoutRect.maxH);
|
||||
rect.minW = Math.max(rect.minW, contLayoutRect.startMinWidth);
|
||||
rect.minH = Math.max(rect.minH, contLayoutRect.startMinHeight);
|
||||
|
||||
// Resize container container if minSize was changed
|
||||
if (contLayoutRect.autoResize && (rect.minW != contLayoutRect.minW || rect.minH != contLayoutRect.minH)) {
|
||||
rect.w = rect.minW;
|
||||
rect.h = rect.minH;
|
||||
|
||||
container.layoutRect(rect);
|
||||
this.recalc(container);
|
||||
|
||||
// Forced recalc for example if items are hidden/shown
|
||||
if (container._lastRect === null) {
|
||||
var parentCtrl = container.parent();
|
||||
if (parentCtrl) {
|
||||
parentCtrl._lastRect = null;
|
||||
parentCtrl.recalc();
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Update contentW/contentH so absEnd moves correctly
|
||||
if (contLayoutRect.autoResize) {
|
||||
rect = container.layoutRect(rect);
|
||||
rect.contentW = rect.minW - contLayoutRect.deltaW;
|
||||
rect.contentH = rect.minH - contLayoutRect.deltaH;
|
||||
}
|
||||
|
||||
var flexV;
|
||||
|
||||
if (settings.packV == 'start') {
|
||||
flexV = 0;
|
||||
} else {
|
||||
flexV = availableHeight > 0 ? Math.floor(availableHeight / rows) : 0;
|
||||
}
|
||||
|
||||
// Calculate totalFlex
|
||||
var totalFlex = 0;
|
||||
var flexWidths = settings.flexWidths;
|
||||
if (flexWidths) {
|
||||
for (x = 0; x < flexWidths.length; x++) {
|
||||
totalFlex += flexWidths[x];
|
||||
}
|
||||
} else {
|
||||
totalFlex = cols;
|
||||
}
|
||||
|
||||
// Calculate new column widths based on flex values
|
||||
var ratio = availableWidth / totalFlex;
|
||||
for (x = 0; x < cols; x++) {
|
||||
colWidths[x] += flexWidths ? flexWidths[x] * ratio : ratio;
|
||||
}
|
||||
|
||||
// Move/resize controls
|
||||
posY = contPaddingBox.top;
|
||||
for (y = 0; y < rows; y++) {
|
||||
posX = contPaddingBox.left;
|
||||
height = rowHeights[y] + flexV;
|
||||
|
||||
for (x = 0; x < cols; x++) {
|
||||
if (reverseRows) {
|
||||
idx = y * cols + cols - 1 - x;
|
||||
} else {
|
||||
idx = y * cols + x;
|
||||
}
|
||||
|
||||
ctrl = items[idx];
|
||||
|
||||
// No more controls to render then break
|
||||
if (!ctrl) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Get control settings and calculate x, y
|
||||
ctrlSettings = ctrl.settings;
|
||||
ctrlLayoutRect = ctrl.layoutRect();
|
||||
width = Math.max(colWidths[x], ctrlLayoutRect.startMinWidth);
|
||||
ctrlLayoutRect.x = posX;
|
||||
ctrlLayoutRect.y = posY;
|
||||
|
||||
// Align control horizontal
|
||||
align = ctrlSettings.alignH || (alignH ? (alignH[x] || alignH[0]) : null);
|
||||
if (align == "center") {
|
||||
ctrlLayoutRect.x = posX + (width / 2) - (ctrlLayoutRect.w / 2);
|
||||
} else if (align == "right") {
|
||||
ctrlLayoutRect.x = posX + width - ctrlLayoutRect.w;
|
||||
} else if (align == "stretch") {
|
||||
ctrlLayoutRect.w = width;
|
||||
}
|
||||
|
||||
// Align control vertical
|
||||
align = ctrlSettings.alignV || (alignV ? (alignV[x] || alignV[0]) : null);
|
||||
if (align == "center") {
|
||||
ctrlLayoutRect.y = posY + (height / 2) - (ctrlLayoutRect.h / 2);
|
||||
} else if (align == "bottom") {
|
||||
ctrlLayoutRect.y = posY + height - ctrlLayoutRect.h;
|
||||
} else if (align == "stretch") {
|
||||
ctrlLayoutRect.h = height;
|
||||
}
|
||||
|
||||
ctrl.layoutRect(ctrlLayoutRect);
|
||||
|
||||
posX += width + spacingH;
|
||||
|
||||
if (ctrl.recalc) {
|
||||
ctrl.recalc();
|
||||
}
|
||||
}
|
||||
|
||||
posY += height + spacingV;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
85
js/tinymce/classes/ui/Iframe.js
Normal file
85
js/tinymce/classes/ui/Iframe.js
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Iframe.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*jshint scripturl:true */
|
||||
|
||||
/**
|
||||
* This class creates an iframe.
|
||||
*
|
||||
* @setting {String} url Url to open in the iframe.
|
||||
*
|
||||
* @-x-less Iframe.less
|
||||
* @class tinymce.ui.Iframe
|
||||
* @extends tinymce.ui.Widget
|
||||
*/
|
||||
define("tinymce/ui/Iframe", [
|
||||
"tinymce/ui/Widget",
|
||||
"tinymce/util/Delay"
|
||||
], function(Widget, Delay) {
|
||||
"use strict";
|
||||
|
||||
return Widget.extend({
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this;
|
||||
|
||||
self.classes.add('iframe');
|
||||
self.canFocus = false;
|
||||
|
||||
/*eslint no-script-url:0 */
|
||||
return (
|
||||
'<iframe id="' + self._id + '" class="' + self.classes + '" tabindex="-1" src="' +
|
||||
(self.settings.url || "javascript:''") + '" frameborder="0"></iframe>'
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Setter for the iframe source.
|
||||
*
|
||||
* @method src
|
||||
* @param {String} src Source URL for iframe.
|
||||
*/
|
||||
src: function(src) {
|
||||
this.getEl().src = src;
|
||||
},
|
||||
|
||||
/**
|
||||
* Inner HTML for the iframe.
|
||||
*
|
||||
* @method html
|
||||
* @param {String} html HTML string to set as HTML inside the iframe.
|
||||
* @param {function} callback Optional callback to execute when the iframe body is filled with contents.
|
||||
* @return {tinymce.ui.Iframe} Current iframe control.
|
||||
*/
|
||||
html: function(html, callback) {
|
||||
var self = this, body = this.getEl().contentWindow.document.body;
|
||||
|
||||
// Wait for iframe to initialize IE 10 takes time
|
||||
if (!body) {
|
||||
Delay.setTimeout(function() {
|
||||
self.html(html);
|
||||
});
|
||||
} else {
|
||||
body.innerHTML = html;
|
||||
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
406
js/tinymce/classes/ui/KeyboardNavigation.js
Normal file
406
js/tinymce/classes/ui/KeyboardNavigation.js
Normal file
@@ -0,0 +1,406 @@
|
||||
/**
|
||||
* KeyboardNavigation.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class handles keyboard navigation of controls and elements.
|
||||
*
|
||||
* @class tinymce.ui.KeyboardNavigation
|
||||
*/
|
||||
define("tinymce/ui/KeyboardNavigation", [
|
||||
], function() {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* This class handles all keyboard navigation for WAI-ARIA support. Each root container
|
||||
* gets an instance of this class.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
return function(settings) {
|
||||
var root = settings.root, focusedElement, focusedControl;
|
||||
|
||||
function isElement(node) {
|
||||
return node && node.nodeType === 1;
|
||||
}
|
||||
|
||||
try {
|
||||
focusedElement = document.activeElement;
|
||||
} catch (ex) {
|
||||
// IE sometimes fails to return a proper element
|
||||
focusedElement = document.body;
|
||||
}
|
||||
|
||||
focusedControl = root.getParentCtrl(focusedElement);
|
||||
|
||||
/**
|
||||
* Returns the currently focused elements wai aria role of the currently
|
||||
* focused element or specified element.
|
||||
*
|
||||
* @private
|
||||
* @param {Element} elm Optional element to get role from.
|
||||
* @return {String} Role of specified element.
|
||||
*/
|
||||
function getRole(elm) {
|
||||
elm = elm || focusedElement;
|
||||
|
||||
if (isElement(elm)) {
|
||||
return elm.getAttribute('role');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the wai role of the parent element of the currently
|
||||
* focused element or specified element.
|
||||
*
|
||||
* @private
|
||||
* @param {Element} elm Optional element to get parent role from.
|
||||
* @return {String} Role of the first parent that has a role.
|
||||
*/
|
||||
function getParentRole(elm) {
|
||||
var role, parent = elm || focusedElement;
|
||||
|
||||
while ((parent = parent.parentNode)) {
|
||||
if ((role = getRole(parent))) {
|
||||
return role;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a wai aria property by name for example aria-selected.
|
||||
*
|
||||
* @private
|
||||
* @param {String} name Name of the aria property to get for example "disabled".
|
||||
* @return {String} Aria property value.
|
||||
*/
|
||||
function getAriaProp(name) {
|
||||
var elm = focusedElement;
|
||||
|
||||
if (isElement(elm)) {
|
||||
return elm.getAttribute('aria-' + name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the element a text input element or not.
|
||||
*
|
||||
* @private
|
||||
* @param {Element} elm Element to check if it's an text input element or not.
|
||||
* @return {Boolean} True/false if the element is a text element or not.
|
||||
*/
|
||||
function isTextInputElement(elm) {
|
||||
var tagName = elm.tagName.toUpperCase();
|
||||
|
||||
// Notice: since type can be "email" etc we don't check the type
|
||||
// So all input elements gets treated as text input elements
|
||||
return tagName == "INPUT" || tagName == "TEXTAREA";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true/false if the specified element can be focused or not.
|
||||
*
|
||||
* @private
|
||||
* @param {Element} elm DOM element to check if it can be focused or not.
|
||||
* @return {Boolean} True/false if the element can have focus.
|
||||
*/
|
||||
function canFocus(elm) {
|
||||
if (isTextInputElement(elm) && !elm.hidden) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (/^(button|menuitem|checkbox|tab|menuitemcheckbox|option|gridcell)$/.test(getRole(elm))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of focusable visible elements within the specified container element.
|
||||
*
|
||||
* @private
|
||||
* @param {Element} elm DOM element to find focusable elements within.
|
||||
* @return {Array} Array of focusable elements.
|
||||
*/
|
||||
function getFocusElements(elm) {
|
||||
var elements = [];
|
||||
|
||||
function collect(elm) {
|
||||
if (elm.nodeType != 1 || elm.style.display == 'none') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (canFocus(elm)) {
|
||||
elements.push(elm);
|
||||
}
|
||||
|
||||
for (var i = 0; i < elm.childNodes.length; i++) {
|
||||
collect(elm.childNodes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
collect(elm || root.getEl());
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the navigation root control for the specified control. The navigation root
|
||||
* is the control that the keyboard navigation gets scoped to for example a menubar or toolbar group.
|
||||
* It will look for parents of the specified target control or the currently focused control if this option is omitted.
|
||||
*
|
||||
* @private
|
||||
* @param {tinymce.ui.Control} targetControl Optional target control to find root of.
|
||||
* @return {tinymce.ui.Control} Navigation root control.
|
||||
*/
|
||||
function getNavigationRoot(targetControl) {
|
||||
var navigationRoot, controls;
|
||||
|
||||
targetControl = targetControl || focusedControl;
|
||||
controls = targetControl.parents().toArray();
|
||||
controls.unshift(targetControl);
|
||||
|
||||
for (var i = 0; i < controls.length; i++) {
|
||||
navigationRoot = controls[i];
|
||||
|
||||
if (navigationRoot.settings.ariaRoot) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return navigationRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Focuses the first item in the specified targetControl element or the last aria index if the
|
||||
* navigation root has the ariaRemember option enabled.
|
||||
*
|
||||
* @private
|
||||
* @param {tinymce.ui.Control} targetControl Target control to focus the first item in.
|
||||
*/
|
||||
function focusFirst(targetControl) {
|
||||
var navigationRoot = getNavigationRoot(targetControl);
|
||||
var focusElements = getFocusElements(navigationRoot.getEl());
|
||||
|
||||
if (navigationRoot.settings.ariaRemember && "lastAriaIndex" in navigationRoot) {
|
||||
moveFocusToIndex(navigationRoot.lastAriaIndex, focusElements);
|
||||
} else {
|
||||
moveFocusToIndex(0, focusElements);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the focus to the specified index within the elements list.
|
||||
* This will scope the index to the size of the element list if it changed.
|
||||
*
|
||||
* @private
|
||||
* @param {Number} idx Specified index to move to.
|
||||
* @param {Array} elements Array with dom elements to move focus within.
|
||||
* @return {Number} Input index or a changed index if it was out of range.
|
||||
*/
|
||||
function moveFocusToIndex(idx, elements) {
|
||||
if (idx < 0) {
|
||||
idx = elements.length - 1;
|
||||
} else if (idx >= elements.length) {
|
||||
idx = 0;
|
||||
}
|
||||
|
||||
if (elements[idx]) {
|
||||
elements[idx].focus();
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the focus forwards or backwards.
|
||||
*
|
||||
* @private
|
||||
* @param {Number} dir Direction to move in positive means forward, negative means backwards.
|
||||
* @param {Array} elements Optional array of elements to move within defaults to the current navigation roots elements.
|
||||
*/
|
||||
function moveFocus(dir, elements) {
|
||||
var idx = -1, navigationRoot = getNavigationRoot();
|
||||
|
||||
elements = elements || getFocusElements(navigationRoot.getEl());
|
||||
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
if (elements[i] === focusedElement) {
|
||||
idx = i;
|
||||
}
|
||||
}
|
||||
|
||||
idx += dir;
|
||||
navigationRoot.lastAriaIndex = moveFocusToIndex(idx, elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the focus to the left this is called by the left key.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function left() {
|
||||
var parentRole = getParentRole();
|
||||
|
||||
if (parentRole == "tablist") {
|
||||
moveFocus(-1, getFocusElements(focusedElement.parentNode));
|
||||
} else if (focusedControl.parent().submenu) {
|
||||
cancel();
|
||||
} else {
|
||||
moveFocus(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the focus to the right this is called by the right key.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function right() {
|
||||
var role = getRole(), parentRole = getParentRole();
|
||||
|
||||
if (parentRole == "tablist") {
|
||||
moveFocus(1, getFocusElements(focusedElement.parentNode));
|
||||
} else if (role == "menuitem" && parentRole == "menu" && getAriaProp('haspopup')) {
|
||||
enter();
|
||||
} else {
|
||||
moveFocus(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the focus to the up this is called by the up key.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function up() {
|
||||
moveFocus(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the focus to the up this is called by the down key.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function down() {
|
||||
var role = getRole(), parentRole = getParentRole();
|
||||
|
||||
if (role == "menuitem" && parentRole == "menubar") {
|
||||
enter();
|
||||
} else if (role == "button" && getAriaProp('haspopup')) {
|
||||
enter({key: 'down'});
|
||||
} else {
|
||||
moveFocus(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the focus to the next item or previous item depending on shift key.
|
||||
*
|
||||
* @private
|
||||
* @param {DOMEvent} e DOM event object.
|
||||
*/
|
||||
function tab(e) {
|
||||
var parentRole = getParentRole();
|
||||
|
||||
if (parentRole == "tablist") {
|
||||
var elm = getFocusElements(focusedControl.getEl('body'))[0];
|
||||
|
||||
if (elm) {
|
||||
elm.focus();
|
||||
}
|
||||
} else {
|
||||
moveFocus(e.shiftKey ? -1 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the cancel event on the currently focused control. This is normally done using the Esc key.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function cancel() {
|
||||
focusedControl.fire('cancel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the click event on the currently focused control. This is normally done using the Enter/Space keys.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} aria Optional aria data to pass along with the enter event.
|
||||
*/
|
||||
function enter(aria) {
|
||||
aria = aria || {};
|
||||
focusedControl.fire('click', {target: focusedElement, aria: aria});
|
||||
}
|
||||
|
||||
root.on('keydown', function(e) {
|
||||
function handleNonTabOrEscEvent(e, handler) {
|
||||
// Ignore non tab keys for text elements
|
||||
if (isTextInputElement(focusedElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (handler(e) !== false) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
if (e.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (e.keyCode) {
|
||||
case 37: // DOM_VK_LEFT
|
||||
handleNonTabOrEscEvent(e, left);
|
||||
break;
|
||||
|
||||
case 39: // DOM_VK_RIGHT
|
||||
handleNonTabOrEscEvent(e, right);
|
||||
break;
|
||||
|
||||
case 38: // DOM_VK_UP
|
||||
handleNonTabOrEscEvent(e, up);
|
||||
break;
|
||||
|
||||
case 40: // DOM_VK_DOWN
|
||||
handleNonTabOrEscEvent(e, down);
|
||||
break;
|
||||
|
||||
case 27: // DOM_VK_ESCAPE
|
||||
cancel();
|
||||
break;
|
||||
|
||||
case 14: // DOM_VK_ENTER
|
||||
case 13: // DOM_VK_RETURN
|
||||
case 32: // DOM_VK_SPACE
|
||||
handleNonTabOrEscEvent(e, enter);
|
||||
break;
|
||||
|
||||
case 9: // DOM_VK_TAB
|
||||
if (tab(e) !== false) {
|
||||
e.preventDefault();
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
root.on('focusin', function(e) {
|
||||
focusedElement = e.target;
|
||||
focusedControl = e.control;
|
||||
});
|
||||
|
||||
return {
|
||||
focusFirst: focusFirst
|
||||
};
|
||||
};
|
||||
});
|
||||
117
js/tinymce/classes/ui/Label.js
Normal file
117
js/tinymce/classes/ui/Label.js
Normal file
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* Label.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class creates a label element. A label is a simple text control
|
||||
* that can be bound to other controls.
|
||||
*
|
||||
* @-x-less Label.less
|
||||
* @class tinymce.ui.Label
|
||||
* @extends tinymce.ui.Widget
|
||||
*/
|
||||
define("tinymce/ui/Label", [
|
||||
"tinymce/ui/Widget",
|
||||
"tinymce/ui/DomUtils"
|
||||
], function(Widget, DomUtils) {
|
||||
"use strict";
|
||||
|
||||
return Widget.extend({
|
||||
/**
|
||||
* Constructs a instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
* @setting {Boolean} multiline Multiline label.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
self._super(settings);
|
||||
self.classes.add('widget').add('label');
|
||||
self.canFocus = false;
|
||||
|
||||
if (settings.multiline) {
|
||||
self.classes.add('autoscroll');
|
||||
}
|
||||
|
||||
if (settings.strong) {
|
||||
self.classes.add('strong');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the current controls layout rect.
|
||||
* This will be executed by the layout managers to determine the
|
||||
* default minWidth/minHeight etc.
|
||||
*
|
||||
* @method initLayoutRect
|
||||
* @return {Object} Layout rect instance.
|
||||
*/
|
||||
initLayoutRect: function() {
|
||||
var self = this, layoutRect = self._super();
|
||||
|
||||
if (self.settings.multiline) {
|
||||
var size = DomUtils.getSize(self.getEl());
|
||||
|
||||
// Check if the text fits within maxW if not then try word wrapping it
|
||||
if (size.width > layoutRect.maxW) {
|
||||
layoutRect.minW = layoutRect.maxW;
|
||||
self.classes.add('multiline');
|
||||
}
|
||||
|
||||
self.getEl().style.width = layoutRect.minW + 'px';
|
||||
layoutRect.startMinH = layoutRect.h = layoutRect.minH = Math.min(layoutRect.maxH, DomUtils.getSize(self.getEl()).height);
|
||||
}
|
||||
|
||||
return layoutRect;
|
||||
},
|
||||
|
||||
/**
|
||||
* Repaints the control after a layout operation.
|
||||
*
|
||||
* @method repaint
|
||||
*/
|
||||
repaint: function() {
|
||||
var self = this;
|
||||
|
||||
if (!self.settings.multiline) {
|
||||
self.getEl().style.lineHeight = self.layoutRect().h + 'px';
|
||||
}
|
||||
|
||||
return self._super();
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, forId = self.settings.forId;
|
||||
|
||||
return (
|
||||
'<label id="' + self._id + '" class="' + self.classes + '"' + (forId ? ' for="' + forId + '"' : '') + '>' +
|
||||
self.encode(self.state.get('text')) +
|
||||
'</label>'
|
||||
);
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
self.state.on('change:text', function(e) {
|
||||
self.innerHtml(self.encode(e.value));
|
||||
});
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
120
js/tinymce/classes/ui/Layout.js
Normal file
120
js/tinymce/classes/ui/Layout.js
Normal file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* Layout.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base layout manager class.
|
||||
*
|
||||
* @class tinymce.ui.Layout
|
||||
*/
|
||||
define("tinymce/ui/Layout", [
|
||||
"tinymce/util/Class",
|
||||
"tinymce/util/Tools"
|
||||
], function(Class, Tools) {
|
||||
"use strict";
|
||||
|
||||
return Class.extend({
|
||||
Defaults: {
|
||||
firstControlClass: 'first',
|
||||
lastControlClass: 'last'
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructs a layout instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
*/
|
||||
init: function(settings) {
|
||||
this.settings = Tools.extend({}, this.Defaults, settings);
|
||||
},
|
||||
|
||||
/**
|
||||
* This method gets invoked before the layout renders the controls.
|
||||
*
|
||||
* @method preRender
|
||||
* @param {tinymce.ui.Container} container Container instance to preRender.
|
||||
*/
|
||||
preRender: function(container) {
|
||||
container.bodyClasses.add(this.settings.containerClass);
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies layout classes to the container.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
applyClasses: function(items) {
|
||||
var self = this, settings = self.settings, firstClass, lastClass, firstItem, lastItem;
|
||||
|
||||
firstClass = settings.firstControlClass;
|
||||
lastClass = settings.lastControlClass;
|
||||
|
||||
items.each(function(item) {
|
||||
item.classes.remove(firstClass).remove(lastClass).add(settings.controlClass);
|
||||
|
||||
if (item.visible()) {
|
||||
if (!firstItem) {
|
||||
firstItem = item;
|
||||
}
|
||||
|
||||
lastItem = item;
|
||||
}
|
||||
});
|
||||
|
||||
if (firstItem) {
|
||||
firstItem.classes.add(firstClass);
|
||||
}
|
||||
|
||||
if (lastItem) {
|
||||
lastItem.classes.add(lastClass);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the specified container and any layout specific HTML.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @param {tinymce.ui.Container} container Container to render HTML for.
|
||||
*/
|
||||
renderHtml: function(container) {
|
||||
var self = this, html = '';
|
||||
|
||||
self.applyClasses(container.items());
|
||||
|
||||
container.items().each(function(item) {
|
||||
html += item.renderHtml();
|
||||
});
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
/**
|
||||
* Recalculates the positions of the controls in the specified container.
|
||||
*
|
||||
* @method recalc
|
||||
* @param {tinymce.ui.Container} container Container instance to recalc.
|
||||
*/
|
||||
recalc: function() {
|
||||
},
|
||||
|
||||
/**
|
||||
* This method gets invoked after the layout renders the controls.
|
||||
*
|
||||
* @method postRender
|
||||
* @param {tinymce.ui.Container} container Container instance to postRender.
|
||||
*/
|
||||
postRender: function() {
|
||||
},
|
||||
|
||||
isNative: function() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
152
js/tinymce/classes/ui/ListBox.js
Normal file
152
js/tinymce/classes/ui/ListBox.js
Normal file
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
* ListBox.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new list box control.
|
||||
*
|
||||
* @-x-less ListBox.less
|
||||
* @class tinymce.ui.ListBox
|
||||
* @extends tinymce.ui.MenuButton
|
||||
*/
|
||||
define("tinymce/ui/ListBox", [
|
||||
"tinymce/ui/MenuButton",
|
||||
"tinymce/ui/Menu"
|
||||
], function(MenuButton, Menu) {
|
||||
"use strict";
|
||||
|
||||
return MenuButton.extend({
|
||||
/**
|
||||
* Constructs a instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
* @setting {Array} values Array with values to add to list box.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this, values, selected, selectedText, lastItemCtrl;
|
||||
|
||||
function setSelected(menuValues) {
|
||||
// Try to find a selected value
|
||||
for (var i = 0; i < menuValues.length; i++) {
|
||||
selected = menuValues[i].selected || settings.value === menuValues[i].value;
|
||||
|
||||
if (selected) {
|
||||
selectedText = selectedText || menuValues[i].text;
|
||||
self.state.set('value', menuValues[i].value);
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the value has a submenu, try to find the selected values in that menu
|
||||
if (menuValues[i].menu) {
|
||||
if (setSelected(menuValues[i].menu)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self._super(settings);
|
||||
settings = self.settings;
|
||||
|
||||
self._values = values = settings.values;
|
||||
if (values) {
|
||||
if (typeof settings.value != "undefined") {
|
||||
setSelected(values);
|
||||
}
|
||||
|
||||
// Default with first item
|
||||
if (!selected && values.length > 0) {
|
||||
selectedText = values[0].text;
|
||||
self.state.set('value', values[0].value);
|
||||
}
|
||||
|
||||
self.state.set('menu', values);
|
||||
}
|
||||
|
||||
self.state.set('text', settings.text || selectedText);
|
||||
|
||||
self.classes.add('listbox');
|
||||
|
||||
self.on('select', function(e) {
|
||||
var ctrl = e.control;
|
||||
|
||||
if (lastItemCtrl) {
|
||||
e.lastControl = lastItemCtrl;
|
||||
}
|
||||
|
||||
if (settings.multiple) {
|
||||
ctrl.active(!ctrl.active());
|
||||
} else {
|
||||
self.value(e.control.value());
|
||||
}
|
||||
|
||||
lastItemCtrl = ctrl;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Getter/setter function for the control value.
|
||||
*
|
||||
* @method value
|
||||
* @param {String} [value] Value to be set.
|
||||
* @return {Boolean/tinymce.ui.ListBox} Value or self if it's a set operation.
|
||||
*/
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
function activateMenuItemsByValue(menu, value) {
|
||||
if (menu instanceof Menu) {
|
||||
menu.items().each(function(ctrl) {
|
||||
if (!ctrl.hasMenus()) {
|
||||
ctrl.active(ctrl.value() === value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getSelectedItem(menuValues, value) {
|
||||
var selectedItem;
|
||||
|
||||
if (!menuValues) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < menuValues.length; i++) {
|
||||
if (menuValues[i].value === value) {
|
||||
return menuValues[i];
|
||||
}
|
||||
|
||||
if (menuValues[i].menu) {
|
||||
selectedItem = getSelectedItem(menuValues[i].menu, value);
|
||||
if (selectedItem) {
|
||||
return selectedItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.on('show', function(e) {
|
||||
activateMenuItemsByValue(e.control, self.value());
|
||||
});
|
||||
|
||||
self.state.on('change:value', function(e) {
|
||||
var selectedItem = getSelectedItem(self.state.get('menu'), e.value);
|
||||
|
||||
if (selectedItem) {
|
||||
self.text(selectedItem.text);
|
||||
} else {
|
||||
self.text(self.settings.text);
|
||||
}
|
||||
});
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
195
js/tinymce/classes/ui/Menu.js
Normal file
195
js/tinymce/classes/ui/Menu.js
Normal file
@@ -0,0 +1,195 @@
|
||||
/**
|
||||
* Menu.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new menu.
|
||||
*
|
||||
* @-x-less Menu.less
|
||||
* @class tinymce.ui.Menu
|
||||
* @extends tinymce.ui.FloatPanel
|
||||
*/
|
||||
define("tinymce/ui/Menu", [
|
||||
"tinymce/ui/FloatPanel",
|
||||
"tinymce/ui/MenuItem",
|
||||
"tinymce/ui/Throbber",
|
||||
"tinymce/util/Tools"
|
||||
], function(FloatPanel, MenuItem, Throbber, Tools) {
|
||||
"use strict";
|
||||
|
||||
return FloatPanel.extend({
|
||||
Defaults: {
|
||||
defaultType: 'menuitem',
|
||||
border: 1,
|
||||
layout: 'stack',
|
||||
role: 'application',
|
||||
bodyRole: 'menu',
|
||||
ariaRoot: true
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructs a instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
settings.autohide = true;
|
||||
settings.constrainToViewport = true;
|
||||
|
||||
if (typeof settings.items === 'function') {
|
||||
settings.itemsFactory = settings.items;
|
||||
settings.items = [];
|
||||
}
|
||||
|
||||
if (settings.itemDefaults) {
|
||||
var items = settings.items, i = items.length;
|
||||
|
||||
while (i--) {
|
||||
items[i] = Tools.extend({}, settings.itemDefaults, items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
self._super(settings);
|
||||
self.classes.add('menu');
|
||||
},
|
||||
|
||||
/**
|
||||
* Repaints the control after a layout operation.
|
||||
*
|
||||
* @method repaint
|
||||
*/
|
||||
repaint: function() {
|
||||
this.classes.toggle('menu-align', true);
|
||||
|
||||
this._super();
|
||||
|
||||
this.getEl().style.height = '';
|
||||
this.getEl('body').style.height = '';
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Hides/closes the menu.
|
||||
*
|
||||
* @method cancel
|
||||
*/
|
||||
cancel: function() {
|
||||
var self = this;
|
||||
|
||||
self.hideAll();
|
||||
self.fire('select');
|
||||
},
|
||||
|
||||
/**
|
||||
* Loads new items from the factory items function.
|
||||
*
|
||||
* @method load
|
||||
*/
|
||||
load: function() {
|
||||
var self = this, time, factory;
|
||||
|
||||
function hideThrobber() {
|
||||
if (self.throbber) {
|
||||
self.throbber.hide();
|
||||
self.throbber = null;
|
||||
}
|
||||
}
|
||||
|
||||
factory = self.settings.itemsFactory;
|
||||
if (!factory) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!self.throbber) {
|
||||
self.throbber = new Throbber(self.getEl('body'), true);
|
||||
|
||||
if (self.items().length === 0) {
|
||||
self.throbber.show();
|
||||
self.fire('loading');
|
||||
} else {
|
||||
self.throbber.show(100, function() {
|
||||
self.items().remove();
|
||||
self.fire('loading');
|
||||
});
|
||||
}
|
||||
|
||||
self.on('hide close', hideThrobber);
|
||||
}
|
||||
|
||||
self.requestTime = time = new Date().getTime();
|
||||
|
||||
self.settings.itemsFactory(function(items) {
|
||||
if (items.length === 0) {
|
||||
self.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.requestTime !== time) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.getEl().style.width = '';
|
||||
self.getEl('body').style.width = '';
|
||||
|
||||
hideThrobber();
|
||||
self.items().remove();
|
||||
self.getEl('body').innerHTML = '';
|
||||
|
||||
self.add(items);
|
||||
self.renderNew();
|
||||
self.fire('loaded');
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide menu and all sub menus.
|
||||
*
|
||||
* @method hideAll
|
||||
*/
|
||||
hideAll: function() {
|
||||
var self = this;
|
||||
|
||||
this.find('menuitem').exec('hideMenu');
|
||||
|
||||
return self._super();
|
||||
},
|
||||
|
||||
/**
|
||||
* Invoked before the menu is rendered.
|
||||
*
|
||||
* @method preRender
|
||||
*/
|
||||
preRender: function() {
|
||||
var self = this;
|
||||
|
||||
self.items().each(function(ctrl) {
|
||||
var settings = ctrl.settings;
|
||||
|
||||
if (settings.icon || settings.image || settings.selectable) {
|
||||
self._hasIcons = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (self.settings.itemsFactory) {
|
||||
self.on('postrender', function() {
|
||||
if (self.settings.itemsFactory) {
|
||||
self.load();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
33
js/tinymce/classes/ui/MenuBar.js
Normal file
33
js/tinymce/classes/ui/MenuBar.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* MenuBar.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new menubar.
|
||||
*
|
||||
* @-x-less MenuBar.less
|
||||
* @class tinymce.ui.MenuBar
|
||||
* @extends tinymce.ui.Container
|
||||
*/
|
||||
define("tinymce/ui/MenuBar", [
|
||||
"tinymce/ui/Toolbar"
|
||||
], function(Toolbar) {
|
||||
"use strict";
|
||||
|
||||
return Toolbar.extend({
|
||||
Defaults: {
|
||||
role: 'menubar',
|
||||
containerCls: 'menubar',
|
||||
ariaRoot: true,
|
||||
defaults: {
|
||||
type: 'menubutton'
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
268
js/tinymce/classes/ui/MenuButton.js
Normal file
268
js/tinymce/classes/ui/MenuButton.js
Normal file
@@ -0,0 +1,268 @@
|
||||
/**
|
||||
* MenuButton.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new menu button.
|
||||
*
|
||||
* @-x-less MenuButton.less
|
||||
* @class tinymce.ui.MenuButton
|
||||
* @extends tinymce.ui.Button
|
||||
*/
|
||||
define("tinymce/ui/MenuButton", [
|
||||
"tinymce/ui/Button",
|
||||
"tinymce/ui/Factory",
|
||||
"tinymce/ui/MenuBar"
|
||||
], function(Button, Factory, MenuBar) {
|
||||
"use strict";
|
||||
|
||||
// TODO: Maybe add as some global function
|
||||
function isChildOf(node, parent) {
|
||||
while (node) {
|
||||
if (parent === node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
node = node.parentNode;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var MenuButton = Button.extend({
|
||||
/**
|
||||
* Constructs a instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
self._renderOpen = true;
|
||||
|
||||
self._super(settings);
|
||||
settings = self.settings;
|
||||
|
||||
self.classes.add('menubtn');
|
||||
|
||||
if (settings.fixedWidth) {
|
||||
self.classes.add('fixed-width');
|
||||
}
|
||||
|
||||
self.aria('haspopup', true);
|
||||
|
||||
self.state.set('menu', settings.menu || self.render());
|
||||
},
|
||||
|
||||
/**
|
||||
* Shows the menu for the button.
|
||||
*
|
||||
* @method showMenu
|
||||
*/
|
||||
showMenu: function() {
|
||||
var self = this, menu;
|
||||
|
||||
if (self.menu && self.menu.visible()) {
|
||||
return self.hideMenu();
|
||||
}
|
||||
|
||||
if (!self.menu) {
|
||||
menu = self.state.get('menu') || [];
|
||||
|
||||
// Is menu array then auto constuct menu control
|
||||
if (menu.length) {
|
||||
menu = {
|
||||
type: 'menu',
|
||||
items: menu
|
||||
};
|
||||
} else {
|
||||
menu.type = menu.type || 'menu';
|
||||
}
|
||||
|
||||
if (!menu.renderTo) {
|
||||
self.menu = Factory.create(menu).parent(self).renderTo();
|
||||
} else {
|
||||
self.menu = menu.parent(self).show().renderTo();
|
||||
}
|
||||
|
||||
self.fire('createmenu');
|
||||
self.menu.reflow();
|
||||
self.menu.on('cancel', function(e) {
|
||||
if (e.control.parent() === self.menu) {
|
||||
e.stopPropagation();
|
||||
self.focus();
|
||||
self.hideMenu();
|
||||
}
|
||||
});
|
||||
|
||||
// Move focus to button when a menu item is selected/clicked
|
||||
self.menu.on('select', function() {
|
||||
self.focus();
|
||||
});
|
||||
|
||||
self.menu.on('show hide', function(e) {
|
||||
if (e.control == self.menu) {
|
||||
self.activeMenu(e.type == 'show');
|
||||
}
|
||||
|
||||
self.aria('expanded', e.type == 'show');
|
||||
}).fire('show');
|
||||
}
|
||||
|
||||
self.menu.show();
|
||||
self.menu.layoutRect({w: self.layoutRect().w});
|
||||
self.menu.moveRel(self.getEl(), self.isRtl() ? ['br-tr', 'tr-br'] : ['bl-tl', 'tl-bl']);
|
||||
},
|
||||
|
||||
/**
|
||||
* Hides the menu for the button.
|
||||
*
|
||||
* @method hideMenu
|
||||
*/
|
||||
hideMenu: function() {
|
||||
var self = this;
|
||||
|
||||
if (self.menu) {
|
||||
self.menu.items().each(function(item) {
|
||||
if (item.hideMenu) {
|
||||
item.hideMenu();
|
||||
}
|
||||
});
|
||||
|
||||
self.menu.hide();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the active menu state.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
activeMenu: function(state) {
|
||||
this.classes.toggle('active', state);
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, id = self._id, prefix = self.classPrefix;
|
||||
var icon = self.settings.icon, image, text = self.state.get('text'),
|
||||
textHtml = '';
|
||||
|
||||
image = self.settings.image;
|
||||
if (image) {
|
||||
icon = 'none';
|
||||
|
||||
// Support for [high dpi, low dpi] image sources
|
||||
if (typeof image != "string") {
|
||||
image = window.getSelection ? image[0] : image[1];
|
||||
}
|
||||
|
||||
image = ' style="background-image: url(\'' + image + '\')"';
|
||||
} else {
|
||||
image = '';
|
||||
}
|
||||
|
||||
if (text) {
|
||||
self.classes.add('btn-has-text');
|
||||
textHtml = '<span class="' + prefix + 'txt">' + self.encode(text) + '</span>';
|
||||
}
|
||||
|
||||
icon = self.settings.icon ? prefix + 'ico ' + prefix + 'i-' + icon : '';
|
||||
|
||||
self.aria('role', self.parent() instanceof MenuBar ? 'menuitem' : 'button');
|
||||
|
||||
return (
|
||||
'<div id="' + id + '" class="' + self.classes + '" tabindex="-1" aria-labelledby="' + id + '">' +
|
||||
'<button id="' + id + '-open" role="presentation" type="button" tabindex="-1">' +
|
||||
(icon ? '<i class="' + icon + '"' + image + '></i>' : '') +
|
||||
textHtml +
|
||||
' <i class="' + prefix + 'caret"></i>' +
|
||||
'</button>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets invoked after the control has been rendered.
|
||||
*
|
||||
* @method postRender
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this;
|
||||
|
||||
self.on('click', function(e) {
|
||||
if (e.control === self && isChildOf(e.target, self.getEl())) {
|
||||
self.showMenu();
|
||||
|
||||
if (e.aria) {
|
||||
self.menu.items()[0].focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
self.on('mouseenter', function(e) {
|
||||
var overCtrl = e.control, parent = self.parent(), hasVisibleSiblingMenu;
|
||||
|
||||
if (overCtrl && parent && overCtrl instanceof MenuButton && overCtrl.parent() == parent) {
|
||||
parent.items().filter('MenuButton').each(function(ctrl) {
|
||||
if (ctrl.hideMenu && ctrl != overCtrl) {
|
||||
if (ctrl.menu && ctrl.menu.visible()) {
|
||||
hasVisibleSiblingMenu = true;
|
||||
}
|
||||
|
||||
ctrl.hideMenu();
|
||||
}
|
||||
});
|
||||
|
||||
if (hasVisibleSiblingMenu) {
|
||||
overCtrl.focus(); // Fix for: #5887
|
||||
overCtrl.showMenu();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return self._super();
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
self.state.on('change:menu', function() {
|
||||
if (self.menu) {
|
||||
self.menu.remove();
|
||||
}
|
||||
|
||||
self.menu = null;
|
||||
});
|
||||
|
||||
return self._super();
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the control and it's menus.
|
||||
*
|
||||
* @method remove
|
||||
*/
|
||||
remove: function() {
|
||||
this._super();
|
||||
|
||||
if (this.menu) {
|
||||
this.menu.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return MenuButton;
|
||||
});
|
||||
336
js/tinymce/classes/ui/MenuItem.js
Normal file
336
js/tinymce/classes/ui/MenuItem.js
Normal file
@@ -0,0 +1,336 @@
|
||||
/**
|
||||
* MenuItem.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new menu item.
|
||||
*
|
||||
* @-x-less MenuItem.less
|
||||
* @class tinymce.ui.MenuItem
|
||||
* @extends tinymce.ui.Control
|
||||
*/
|
||||
define("tinymce/ui/MenuItem", [
|
||||
"tinymce/ui/Widget",
|
||||
"tinymce/ui/Factory",
|
||||
"tinymce/Env",
|
||||
"tinymce/util/Delay"
|
||||
], function(Widget, Factory, Env, Delay) {
|
||||
"use strict";
|
||||
|
||||
return Widget.extend({
|
||||
Defaults: {
|
||||
border: 0,
|
||||
role: 'menuitem'
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructs a instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
* @setting {Boolean} selectable Selectable menu.
|
||||
* @setting {Array} menu Submenu array with items.
|
||||
* @setting {String} shortcut Shortcut to display for menu item. Example: Ctrl+X
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this, text;
|
||||
|
||||
self._super(settings);
|
||||
|
||||
settings = self.settings;
|
||||
|
||||
self.classes.add('menu-item');
|
||||
|
||||
if (settings.menu) {
|
||||
self.classes.add('menu-item-expand');
|
||||
}
|
||||
|
||||
if (settings.preview) {
|
||||
self.classes.add('menu-item-preview');
|
||||
}
|
||||
|
||||
text = self.state.get('text');
|
||||
if (text === '-' || text === '|') {
|
||||
self.classes.add('menu-item-sep');
|
||||
self.aria('role', 'separator');
|
||||
self.state.set('text', '-');
|
||||
}
|
||||
|
||||
if (settings.selectable) {
|
||||
self.aria('role', 'menuitemcheckbox');
|
||||
self.classes.add('menu-item-checkbox');
|
||||
settings.icon = 'selected';
|
||||
}
|
||||
|
||||
if (!settings.preview && !settings.selectable) {
|
||||
self.classes.add('menu-item-normal');
|
||||
}
|
||||
|
||||
self.on('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
if (settings.menu && !settings.ariaHideMenu) {
|
||||
self.aria('haspopup', true);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true/false if the menuitem has sub menu.
|
||||
*
|
||||
* @method hasMenus
|
||||
* @return {Boolean} True/false state if it has submenu.
|
||||
*/
|
||||
hasMenus: function() {
|
||||
return !!this.settings.menu;
|
||||
},
|
||||
|
||||
/**
|
||||
* Shows the menu for the menu item.
|
||||
*
|
||||
* @method showMenu
|
||||
*/
|
||||
showMenu: function() {
|
||||
var self = this, settings = self.settings, menu, parent = self.parent();
|
||||
|
||||
parent.items().each(function(ctrl) {
|
||||
if (ctrl !== self) {
|
||||
ctrl.hideMenu();
|
||||
}
|
||||
});
|
||||
|
||||
if (settings.menu) {
|
||||
menu = self.menu;
|
||||
|
||||
if (!menu) {
|
||||
menu = settings.menu;
|
||||
|
||||
// Is menu array then auto constuct menu control
|
||||
if (menu.length) {
|
||||
menu = {
|
||||
type: 'menu',
|
||||
items: menu
|
||||
};
|
||||
} else {
|
||||
menu.type = menu.type || 'menu';
|
||||
}
|
||||
|
||||
if (parent.settings.itemDefaults) {
|
||||
menu.itemDefaults = parent.settings.itemDefaults;
|
||||
}
|
||||
|
||||
menu = self.menu = Factory.create(menu).parent(self).renderTo();
|
||||
menu.reflow();
|
||||
menu.on('cancel', function(e) {
|
||||
e.stopPropagation();
|
||||
self.focus();
|
||||
menu.hide();
|
||||
});
|
||||
menu.on('show hide', function(e) {
|
||||
e.control.items().each(function(ctrl) {
|
||||
ctrl.active(ctrl.settings.selected);
|
||||
});
|
||||
}).fire('show');
|
||||
|
||||
menu.on('hide', function(e) {
|
||||
if (e.control === menu) {
|
||||
self.classes.remove('selected');
|
||||
}
|
||||
});
|
||||
|
||||
menu.submenu = true;
|
||||
} else {
|
||||
menu.show();
|
||||
}
|
||||
|
||||
menu._parentMenu = parent;
|
||||
|
||||
menu.classes.add('menu-sub');
|
||||
|
||||
var rel = menu.testMoveRel(
|
||||
self.getEl(),
|
||||
self.isRtl() ? ['tl-tr', 'bl-br', 'tr-tl', 'br-bl'] : ['tr-tl', 'br-bl', 'tl-tr', 'bl-br']
|
||||
);
|
||||
|
||||
menu.moveRel(self.getEl(), rel);
|
||||
menu.rel = rel;
|
||||
|
||||
rel = 'menu-sub-' + rel;
|
||||
menu.classes.remove(menu._lastRel).add(rel);
|
||||
menu._lastRel = rel;
|
||||
|
||||
self.classes.add('selected');
|
||||
self.aria('expanded', true);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Hides the menu for the menu item.
|
||||
*
|
||||
* @method hideMenu
|
||||
*/
|
||||
hideMenu: function() {
|
||||
var self = this;
|
||||
|
||||
if (self.menu) {
|
||||
self.menu.items().each(function(item) {
|
||||
if (item.hideMenu) {
|
||||
item.hideMenu();
|
||||
}
|
||||
});
|
||||
|
||||
self.menu.hide();
|
||||
self.aria('expanded', false);
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, id = self._id, settings = self.settings, prefix = self.classPrefix, text = self.encode(self.state.get('text'));
|
||||
var icon = self.settings.icon, image = '', shortcut = settings.shortcut;
|
||||
|
||||
// Converts shortcut format to Mac/PC variants
|
||||
function convertShortcut(shortcut) {
|
||||
var i, value, replace = {};
|
||||
|
||||
if (Env.mac) {
|
||||
replace = {
|
||||
alt: '⌥',
|
||||
ctrl: '⌘',
|
||||
shift: '⇧',
|
||||
meta: '⌘'
|
||||
};
|
||||
} else {
|
||||
replace = {
|
||||
meta: 'Ctrl'
|
||||
};
|
||||
}
|
||||
|
||||
shortcut = shortcut.split('+');
|
||||
|
||||
for (i = 0; i < shortcut.length; i++) {
|
||||
value = replace[shortcut[i].toLowerCase()];
|
||||
|
||||
if (value) {
|
||||
shortcut[i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return shortcut.join('+');
|
||||
}
|
||||
|
||||
if (icon) {
|
||||
self.parent().classes.add('menu-has-icons');
|
||||
}
|
||||
|
||||
if (settings.image) {
|
||||
image = ' style="background-image: url(\'' + settings.image + '\')"';
|
||||
}
|
||||
|
||||
if (shortcut) {
|
||||
shortcut = convertShortcut(shortcut);
|
||||
}
|
||||
|
||||
icon = prefix + 'ico ' + prefix + 'i-' + (self.settings.icon || 'none');
|
||||
|
||||
return (
|
||||
'<div id="' + id + '" class="' + self.classes + '" tabindex="-1">' +
|
||||
(text !== '-' ? '<i class="' + icon + '"' + image + '></i>\u00a0' : '') +
|
||||
(text !== '-' ? '<span id="' + id + '-text" class="' + prefix + 'text">' + text + '</span>' : '') +
|
||||
(shortcut ? '<div id="' + id + '-shortcut" class="' + prefix + 'menu-shortcut">' + shortcut + '</div>' : '') +
|
||||
(settings.menu ? '<div class="' + prefix + 'caret"></div>' : '') +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets invoked after the control has been rendered.
|
||||
*
|
||||
* @method postRender
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this, settings = self.settings;
|
||||
|
||||
var textStyle = settings.textStyle;
|
||||
if (typeof textStyle == "function") {
|
||||
textStyle = textStyle.call(this);
|
||||
}
|
||||
|
||||
if (textStyle) {
|
||||
var textElm = self.getEl('text');
|
||||
if (textElm) {
|
||||
textElm.setAttribute('style', textStyle);
|
||||
}
|
||||
}
|
||||
|
||||
self.on('mouseenter click', function(e) {
|
||||
if (e.control === self) {
|
||||
if (!settings.menu && e.type === 'click') {
|
||||
self.fire('select');
|
||||
|
||||
// Edge will crash if you stress it see #2660
|
||||
Delay.requestAnimationFrame(function() {
|
||||
self.parent().hideAll();
|
||||
});
|
||||
} else {
|
||||
self.showMenu();
|
||||
|
||||
if (e.aria) {
|
||||
self.menu.focus(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
self._super();
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
hover: function() {
|
||||
var self = this;
|
||||
|
||||
self.parent().items().each(function(ctrl) {
|
||||
ctrl.classes.remove('selected');
|
||||
});
|
||||
|
||||
self.classes.toggle('selected', true);
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
active: function(state) {
|
||||
if (typeof state != "undefined") {
|
||||
this.aria('checked', state);
|
||||
}
|
||||
|
||||
return this._super(state);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the control and it's menus.
|
||||
*
|
||||
* @method remove
|
||||
*/
|
||||
remove: function() {
|
||||
this._super();
|
||||
|
||||
if (this.menu) {
|
||||
this.menu.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
202
js/tinymce/classes/ui/MessageBox.js
Normal file
202
js/tinymce/classes/ui/MessageBox.js
Normal file
@@ -0,0 +1,202 @@
|
||||
/**
|
||||
* MessageBox.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used to create MessageBoxes like alerts/confirms etc.
|
||||
*
|
||||
* @class tinymce.ui.MessageBox
|
||||
* @extends tinymce.ui.FloatPanel
|
||||
*/
|
||||
define("tinymce/ui/MessageBox", [
|
||||
"tinymce/ui/Window"
|
||||
], function(Window) {
|
||||
"use strict";
|
||||
|
||||
var MessageBox = Window.extend({
|
||||
/**
|
||||
* Constructs a instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
*/
|
||||
init: function(settings) {
|
||||
settings = {
|
||||
border: 1,
|
||||
padding: 20,
|
||||
layout: 'flex',
|
||||
pack: "center",
|
||||
align: "center",
|
||||
containerCls: 'panel',
|
||||
autoScroll: true,
|
||||
buttons: {type: "button", text: "Ok", action: "ok"},
|
||||
items: {
|
||||
type: "label",
|
||||
multiline: true,
|
||||
maxWidth: 500,
|
||||
maxHeight: 200
|
||||
}
|
||||
};
|
||||
|
||||
this._super(settings);
|
||||
},
|
||||
|
||||
Statics: {
|
||||
/**
|
||||
* Ok buttons constant.
|
||||
*
|
||||
* @static
|
||||
* @final
|
||||
* @field {Number} OK
|
||||
*/
|
||||
OK: 1,
|
||||
|
||||
/**
|
||||
* Ok/cancel buttons constant.
|
||||
*
|
||||
* @static
|
||||
* @final
|
||||
* @field {Number} OK_CANCEL
|
||||
*/
|
||||
OK_CANCEL: 2,
|
||||
|
||||
/**
|
||||
* yes/no buttons constant.
|
||||
*
|
||||
* @static
|
||||
* @final
|
||||
* @field {Number} YES_NO
|
||||
*/
|
||||
YES_NO: 3,
|
||||
|
||||
/**
|
||||
* yes/no/cancel buttons constant.
|
||||
*
|
||||
* @static
|
||||
* @final
|
||||
* @field {Number} YES_NO_CANCEL
|
||||
*/
|
||||
YES_NO_CANCEL: 4,
|
||||
|
||||
/**
|
||||
* Constructs a new message box and renders it to the body element.
|
||||
*
|
||||
* @static
|
||||
* @method msgBox
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
*/
|
||||
msgBox: function(settings) {
|
||||
var buttons, callback = settings.callback || function() {};
|
||||
|
||||
function createButton(text, status, primary) {
|
||||
return {
|
||||
type: "button",
|
||||
text: text,
|
||||
subtype: primary ? 'primary' : '',
|
||||
onClick: function(e) {
|
||||
e.control.parents()[1].close();
|
||||
callback(status);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
switch (settings.buttons) {
|
||||
case MessageBox.OK_CANCEL:
|
||||
buttons = [
|
||||
createButton('Ok', true, true),
|
||||
createButton('Cancel', false)
|
||||
];
|
||||
break;
|
||||
|
||||
case MessageBox.YES_NO:
|
||||
case MessageBox.YES_NO_CANCEL:
|
||||
buttons = [
|
||||
createButton('Yes', 1, true),
|
||||
createButton('No', 0)
|
||||
];
|
||||
|
||||
if (settings.buttons == MessageBox.YES_NO_CANCEL) {
|
||||
buttons.push(createButton('Cancel', -1));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
buttons = [
|
||||
createButton('Ok', true, true)
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return new Window({
|
||||
padding: 20,
|
||||
x: settings.x,
|
||||
y: settings.y,
|
||||
minWidth: 300,
|
||||
minHeight: 100,
|
||||
layout: "flex",
|
||||
pack: "center",
|
||||
align: "center",
|
||||
buttons: buttons,
|
||||
title: settings.title,
|
||||
role: 'alertdialog',
|
||||
items: {
|
||||
type: "label",
|
||||
multiline: true,
|
||||
maxWidth: 500,
|
||||
maxHeight: 200,
|
||||
text: settings.text
|
||||
},
|
||||
onPostRender: function() {
|
||||
this.aria('describedby', this.items()[0]._id);
|
||||
},
|
||||
onClose: settings.onClose,
|
||||
onCancel: function() {
|
||||
callback(false);
|
||||
}
|
||||
}).renderTo(document.body).reflow();
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new alert dialog.
|
||||
*
|
||||
* @method alert
|
||||
* @param {Object} settings Settings for the alert dialog.
|
||||
* @param {function} [callback] Callback to execute when the user makes a choice.
|
||||
*/
|
||||
alert: function(settings, callback) {
|
||||
if (typeof settings == "string") {
|
||||
settings = {text: settings};
|
||||
}
|
||||
|
||||
settings.callback = callback;
|
||||
return MessageBox.msgBox(settings);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new confirm dialog.
|
||||
*
|
||||
* @method confirm
|
||||
* @param {Object} settings Settings for the confirm dialog.
|
||||
* @param {function} [callback] Callback to execute when the user makes a choice.
|
||||
*/
|
||||
confirm: function(settings, callback) {
|
||||
if (typeof settings == "string") {
|
||||
settings = {text: settings};
|
||||
}
|
||||
|
||||
settings.callback = callback;
|
||||
settings.buttons = MessageBox.OK_CANCEL;
|
||||
|
||||
return MessageBox.msgBox(settings);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return MessageBox;
|
||||
});
|
||||
200
js/tinymce/classes/ui/Movable.js
Normal file
200
js/tinymce/classes/ui/Movable.js
Normal file
@@ -0,0 +1,200 @@
|
||||
/**
|
||||
* Movable.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Movable mixin. Makes controls movable absolute and relative to other elements.
|
||||
*
|
||||
* @mixin tinymce.ui.Movable
|
||||
*/
|
||||
define("tinymce/ui/Movable", [
|
||||
"tinymce/ui/DomUtils"
|
||||
], function(DomUtils) {
|
||||
"use strict";
|
||||
|
||||
function calculateRelativePosition(ctrl, targetElm, rel) {
|
||||
var ctrlElm, pos, x, y, selfW, selfH, targetW, targetH, viewport, size;
|
||||
|
||||
viewport = DomUtils.getViewPort();
|
||||
|
||||
// Get pos of target
|
||||
pos = DomUtils.getPos(targetElm);
|
||||
x = pos.x;
|
||||
y = pos.y;
|
||||
|
||||
if (ctrl.state.get('fixed') && DomUtils.getRuntimeStyle(document.body, 'position') == 'static') {
|
||||
x -= viewport.x;
|
||||
y -= viewport.y;
|
||||
}
|
||||
|
||||
// Get size of self
|
||||
ctrlElm = ctrl.getEl();
|
||||
size = DomUtils.getSize(ctrlElm);
|
||||
selfW = size.width;
|
||||
selfH = size.height;
|
||||
|
||||
// Get size of target
|
||||
size = DomUtils.getSize(targetElm);
|
||||
targetW = size.width;
|
||||
targetH = size.height;
|
||||
|
||||
// Parse align string
|
||||
rel = (rel || '').split('');
|
||||
|
||||
// Target corners
|
||||
if (rel[0] === 'b') {
|
||||
y += targetH;
|
||||
}
|
||||
|
||||
if (rel[1] === 'r') {
|
||||
x += targetW;
|
||||
}
|
||||
|
||||
if (rel[0] === 'c') {
|
||||
y += Math.round(targetH / 2);
|
||||
}
|
||||
|
||||
if (rel[1] === 'c') {
|
||||
x += Math.round(targetW / 2);
|
||||
}
|
||||
|
||||
// Self corners
|
||||
if (rel[3] === 'b') {
|
||||
y -= selfH;
|
||||
}
|
||||
|
||||
if (rel[4] === 'r') {
|
||||
x -= selfW;
|
||||
}
|
||||
|
||||
if (rel[3] === 'c') {
|
||||
y -= Math.round(selfH / 2);
|
||||
}
|
||||
|
||||
if (rel[4] === 'c') {
|
||||
x -= Math.round(selfW / 2);
|
||||
}
|
||||
|
||||
return {
|
||||
x: x,
|
||||
y: y,
|
||||
w: selfW,
|
||||
h: selfH
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
/**
|
||||
* Tests various positions to get the most suitable one.
|
||||
*
|
||||
* @method testMoveRel
|
||||
* @param {DOMElement} elm Element to position against.
|
||||
* @param {Array} rels Array with relative positions.
|
||||
* @return {String} Best suitable relative position.
|
||||
*/
|
||||
testMoveRel: function(elm, rels) {
|
||||
var viewPortRect = DomUtils.getViewPort();
|
||||
|
||||
for (var i = 0; i < rels.length; i++) {
|
||||
var pos = calculateRelativePosition(this, elm, rels[i]);
|
||||
|
||||
if (this.state.get('fixed')) {
|
||||
if (pos.x > 0 && pos.x + pos.w < viewPortRect.w && pos.y > 0 && pos.y + pos.h < viewPortRect.h) {
|
||||
return rels[i];
|
||||
}
|
||||
} else {
|
||||
if (pos.x > viewPortRect.x && pos.x + pos.w < viewPortRect.w + viewPortRect.x &&
|
||||
pos.y > viewPortRect.y && pos.y + pos.h < viewPortRect.h + viewPortRect.y) {
|
||||
return rels[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rels[0];
|
||||
},
|
||||
|
||||
/**
|
||||
* Move relative to the specified element.
|
||||
*
|
||||
* @method moveRel
|
||||
* @param {Element} elm Element to move relative to.
|
||||
* @param {String} rel Relative mode. For example: br-tl.
|
||||
* @return {tinymce.ui.Control} Current control instance.
|
||||
*/
|
||||
moveRel: function(elm, rel) {
|
||||
if (typeof rel != 'string') {
|
||||
rel = this.testMoveRel(elm, rel);
|
||||
}
|
||||
|
||||
var pos = calculateRelativePosition(this, elm, rel);
|
||||
return this.moveTo(pos.x, pos.y);
|
||||
},
|
||||
|
||||
/**
|
||||
* Move by a relative x, y values.
|
||||
*
|
||||
* @method moveBy
|
||||
* @param {Number} dx Relative x position.
|
||||
* @param {Number} dy Relative y position.
|
||||
* @return {tinymce.ui.Control} Current control instance.
|
||||
*/
|
||||
moveBy: function(dx, dy) {
|
||||
var self = this, rect = self.layoutRect();
|
||||
|
||||
self.moveTo(rect.x + dx, rect.y + dy);
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Move to absolute position.
|
||||
*
|
||||
* @method moveTo
|
||||
* @param {Number} x Absolute x position.
|
||||
* @param {Number} y Absolute y position.
|
||||
* @return {tinymce.ui.Control} Current control instance.
|
||||
*/
|
||||
moveTo: function(x, y) {
|
||||
var self = this;
|
||||
|
||||
// TODO: Move this to some global class
|
||||
function constrain(value, max, size) {
|
||||
if (value < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (value + size > max) {
|
||||
value = max - size;
|
||||
return value < 0 ? 0 : value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
if (self.settings.constrainToViewport) {
|
||||
var viewPortRect = DomUtils.getViewPort(window);
|
||||
var layoutRect = self.layoutRect();
|
||||
|
||||
x = constrain(x, viewPortRect.w + viewPortRect.x, layoutRect.w);
|
||||
y = constrain(y, viewPortRect.h + viewPortRect.y, layoutRect.h);
|
||||
}
|
||||
|
||||
if (self.state.get('rendered')) {
|
||||
self.layoutRect({x: x, y: y}).repaint();
|
||||
} else {
|
||||
self.settings.x = x;
|
||||
self.settings.y = y;
|
||||
}
|
||||
|
||||
self.fire('move', {x: x, y: y});
|
||||
|
||||
return self;
|
||||
}
|
||||
};
|
||||
});
|
||||
143
js/tinymce/classes/ui/Notification.js
Normal file
143
js/tinymce/classes/ui/Notification.js
Normal file
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* Notification.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a notification instance.
|
||||
*
|
||||
* @-x-less Notification.less
|
||||
* @class tinymce.ui.Notification
|
||||
* @extends tinymce.ui.Container
|
||||
* @mixes tinymce.ui.Movable
|
||||
*/
|
||||
define("tinymce/ui/Notification", [
|
||||
"tinymce/ui/Control",
|
||||
"tinymce/ui/Movable",
|
||||
"tinymce/ui/Progress"
|
||||
], function(Control, Movable, Progress) {
|
||||
return Control.extend({
|
||||
Mixins: [Movable],
|
||||
|
||||
Defaults: {
|
||||
classes: 'widget notification'
|
||||
},
|
||||
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
self._super(settings);
|
||||
|
||||
if (settings.text) {
|
||||
self.text(settings.text);
|
||||
}
|
||||
|
||||
if (settings.icon) {
|
||||
self.icon = settings.icon;
|
||||
}
|
||||
|
||||
if (settings.color) {
|
||||
self.color = settings.color;
|
||||
}
|
||||
|
||||
if (settings.type) {
|
||||
self.classes.add('notification-' + settings.type);
|
||||
}
|
||||
|
||||
if (settings.timeout && (settings.timeout < 0 || settings.timeout > 0) && !settings.closeButton) {
|
||||
self.closeButton = false;
|
||||
} else {
|
||||
self.classes.add('has-close');
|
||||
self.closeButton = true;
|
||||
}
|
||||
|
||||
if (settings.progressBar) {
|
||||
self.progressBar = new Progress();
|
||||
}
|
||||
|
||||
self.on('click', function(e) {
|
||||
if (e.target.className.indexOf(self.classPrefix + 'close') != -1) {
|
||||
self.close();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, prefix = self.classPrefix, icon = '', closeButton = '', progressBar = '', notificationStyle = '';
|
||||
|
||||
if (self.icon) {
|
||||
icon = '<i class="' + prefix + 'ico' + ' ' + prefix + 'i-' + self.icon + '"></i>';
|
||||
}
|
||||
|
||||
if (self.color) {
|
||||
notificationStyle = ' style="background-color: ' + self.color + '"';
|
||||
}
|
||||
|
||||
if (self.closeButton) {
|
||||
closeButton = '<button type="button" class="' + prefix + 'close" aria-hidden="true">\u00d7</button>';
|
||||
}
|
||||
|
||||
if (self.progressBar) {
|
||||
progressBar = self.progressBar.renderHtml();
|
||||
}
|
||||
|
||||
return (
|
||||
'<div id="' + self._id + '" class="' + self.classes + '"' + notificationStyle + ' role="presentation">' +
|
||||
icon +
|
||||
'<div class="' + prefix + 'notification-inner">' + self.state.get('text') + '</div>' +
|
||||
progressBar +
|
||||
closeButton +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
self.state.on('change:text', function(e) {
|
||||
self.getEl().childNodes[1].innerHTML = e.value;
|
||||
});
|
||||
if (self.progressBar) {
|
||||
self.progressBar.bindStates();
|
||||
}
|
||||
return self._super();
|
||||
},
|
||||
|
||||
close: function() {
|
||||
var self = this;
|
||||
|
||||
if (!self.fire('close').isDefaultPrevented()) {
|
||||
self.remove();
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Repaints the control after a layout operation.
|
||||
*
|
||||
* @method repaint
|
||||
*/
|
||||
repaint: function() {
|
||||
var self = this, style, rect;
|
||||
|
||||
style = self.getEl().style;
|
||||
rect = self._layoutRect;
|
||||
|
||||
style.left = rect.x + 'px';
|
||||
style.top = rect.y + 'px';
|
||||
style.zIndex = 0xFFFF + 0xFFFF;
|
||||
}
|
||||
});
|
||||
});
|
||||
67
js/tinymce/classes/ui/Panel.js
Normal file
67
js/tinymce/classes/ui/Panel.js
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Panel.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new panel.
|
||||
*
|
||||
* @-x-less Panel.less
|
||||
* @class tinymce.ui.Panel
|
||||
* @extends tinymce.ui.Container
|
||||
* @mixes tinymce.ui.Scrollable
|
||||
*/
|
||||
define("tinymce/ui/Panel", [
|
||||
"tinymce/ui/Container",
|
||||
"tinymce/ui/Scrollable"
|
||||
], function(Container, Scrollable) {
|
||||
"use strict";
|
||||
|
||||
return Container.extend({
|
||||
Defaults: {
|
||||
layout: 'fit',
|
||||
containerCls: 'panel'
|
||||
},
|
||||
|
||||
Mixins: [Scrollable],
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, layout = self._layout, innerHtml = self.settings.html;
|
||||
|
||||
self.preRender();
|
||||
layout.preRender(self);
|
||||
|
||||
if (typeof innerHtml == "undefined") {
|
||||
innerHtml = (
|
||||
'<div id="' + self._id + '-body" class="' + self.bodyClasses + '">' +
|
||||
layout.renderHtml(self) +
|
||||
'</div>'
|
||||
);
|
||||
} else {
|
||||
if (typeof innerHtml == 'function') {
|
||||
innerHtml = innerHtml.call(self);
|
||||
}
|
||||
|
||||
self._hasBody = false;
|
||||
}
|
||||
|
||||
return (
|
||||
'<div id="' + self._id + '" class="' + self.classes + '" hidefocus="1" tabindex="-1" role="group">' +
|
||||
(self._preBodyHtml || '') +
|
||||
innerHtml +
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
114
js/tinymce/classes/ui/PanelButton.js
Normal file
114
js/tinymce/classes/ui/PanelButton.js
Normal file
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* PanelButton.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new panel button.
|
||||
*
|
||||
* @class tinymce.ui.PanelButton
|
||||
* @extends tinymce.ui.Button
|
||||
*/
|
||||
define("tinymce/ui/PanelButton", [
|
||||
"tinymce/ui/Button",
|
||||
"tinymce/ui/FloatPanel"
|
||||
], function(Button, FloatPanel) {
|
||||
"use strict";
|
||||
|
||||
return Button.extend({
|
||||
/**
|
||||
* Shows the panel for the button.
|
||||
*
|
||||
* @method showPanel
|
||||
*/
|
||||
showPanel: function() {
|
||||
var self = this, settings = self.settings;
|
||||
|
||||
self.active(true);
|
||||
|
||||
if (!self.panel) {
|
||||
var panelSettings = settings.panel;
|
||||
|
||||
// Wrap panel in grid layout if type if specified
|
||||
// This makes it possible to add forms or other containers directly in the panel option
|
||||
if (panelSettings.type) {
|
||||
panelSettings = {
|
||||
layout: 'grid',
|
||||
items: panelSettings
|
||||
};
|
||||
}
|
||||
|
||||
panelSettings.role = panelSettings.role || 'dialog';
|
||||
panelSettings.popover = true;
|
||||
panelSettings.autohide = true;
|
||||
panelSettings.ariaRoot = true;
|
||||
|
||||
self.panel = new FloatPanel(panelSettings).on('hide', function() {
|
||||
self.active(false);
|
||||
}).on('cancel', function(e) {
|
||||
e.stopPropagation();
|
||||
self.focus();
|
||||
self.hidePanel();
|
||||
}).parent(self).renderTo(self.getContainerElm());
|
||||
|
||||
self.panel.fire('show');
|
||||
self.panel.reflow();
|
||||
} else {
|
||||
self.panel.show();
|
||||
}
|
||||
|
||||
self.panel.moveRel(self.getEl(), settings.popoverAlign || (self.isRtl() ? ['bc-tr', 'bc-tc'] : ['bc-tl', 'bc-tc']));
|
||||
},
|
||||
|
||||
/**
|
||||
* Hides the panel for the button.
|
||||
*
|
||||
* @method hidePanel
|
||||
*/
|
||||
hidePanel: function() {
|
||||
var self = this;
|
||||
|
||||
if (self.panel) {
|
||||
self.panel.hide();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Called after the control has been rendered.
|
||||
*
|
||||
* @method postRender
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this;
|
||||
|
||||
self.aria('haspopup', true);
|
||||
|
||||
self.on('click', function(e) {
|
||||
if (e.control === self) {
|
||||
if (self.panel && self.panel.visible()) {
|
||||
self.hidePanel();
|
||||
} else {
|
||||
self.showPanel();
|
||||
self.panel.focus(!!e.aria);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return self._super();
|
||||
},
|
||||
|
||||
remove: function() {
|
||||
if (this.panel) {
|
||||
this.panel.remove();
|
||||
this.panel = null;
|
||||
}
|
||||
|
||||
return this._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
127
js/tinymce/classes/ui/Path.js
Normal file
127
js/tinymce/classes/ui/Path.js
Normal file
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* Path.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new path control.
|
||||
*
|
||||
* @-x-less Path.less
|
||||
* @class tinymce.ui.Path
|
||||
* @extends tinymce.ui.Widget
|
||||
*/
|
||||
define("tinymce/ui/Path", [
|
||||
"tinymce/ui/Widget"
|
||||
], function(Widget) {
|
||||
"use strict";
|
||||
|
||||
return Widget.extend({
|
||||
/**
|
||||
* Constructs a instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
* @setting {String} delimiter Delimiter to display between row in path.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
if (!settings.delimiter) {
|
||||
settings.delimiter = '\u00BB';
|
||||
}
|
||||
|
||||
self._super(settings);
|
||||
self.classes.add('path');
|
||||
self.canFocus = true;
|
||||
|
||||
self.on('click', function(e) {
|
||||
var index, target = e.target;
|
||||
|
||||
if ((index = target.getAttribute('data-index'))) {
|
||||
self.fire('select', {value: self.row()[index], index: index});
|
||||
}
|
||||
});
|
||||
|
||||
self.row(self.settings.row);
|
||||
},
|
||||
|
||||
/**
|
||||
* Focuses the current control.
|
||||
*
|
||||
* @method focus
|
||||
* @return {tinymce.ui.Control} Current control instance.
|
||||
*/
|
||||
focus: function() {
|
||||
var self = this;
|
||||
|
||||
self.getEl().firstChild.focus();
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets/gets the data to be used for the path.
|
||||
*
|
||||
* @method row
|
||||
* @param {Array} row Array with row name is rendered to path.
|
||||
*/
|
||||
row: function(row) {
|
||||
if (!arguments.length) {
|
||||
return this.state.get('row');
|
||||
}
|
||||
|
||||
this.state.set('row', row);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this;
|
||||
|
||||
return (
|
||||
'<div id="' + self._id + '" class="' + self.classes + '">' +
|
||||
self._getDataPathHtml(self.state.get('row')) +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
self.state.on('change:row', function(e) {
|
||||
self.innerHtml(self._getDataPathHtml(e.value));
|
||||
});
|
||||
|
||||
return self._super();
|
||||
},
|
||||
|
||||
_getDataPathHtml: function(data) {
|
||||
var self = this, parts = data || [], i, l, html = '', prefix = self.classPrefix;
|
||||
|
||||
for (i = 0, l = parts.length; i < l; i++) {
|
||||
html += (
|
||||
(i > 0 ? '<div class="' + prefix + 'divider" aria-hidden="true"> ' + self.settings.delimiter + ' </div>' : '') +
|
||||
'<div role="button" class="' + prefix + 'path-item' + (i == l - 1 ? ' ' + prefix + 'last' : '') + '" data-index="' +
|
||||
i + '" tabindex="-1" id="' + self._id + '-' + i + '" aria-level="' + i + '">' + parts[i].name + '</div>'
|
||||
);
|
||||
}
|
||||
|
||||
if (!html) {
|
||||
html = '<div class="' + prefix + 'path-item">\u00a0</div>';
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
});
|
||||
});
|
||||
81
js/tinymce/classes/ui/Progress.js
Normal file
81
js/tinymce/classes/ui/Progress.js
Normal file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Progress.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Progress control.
|
||||
*
|
||||
* @-x-less Progress.less
|
||||
* @class tinymce.ui.Progress
|
||||
* @extends tinymce.ui.Control
|
||||
*/
|
||||
define("tinymce/ui/Progress", [
|
||||
"tinymce/ui/Widget"
|
||||
], function(Widget) {
|
||||
"use strict";
|
||||
|
||||
return Widget.extend({
|
||||
Defaults: {
|
||||
value: 0
|
||||
},
|
||||
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
self._super(settings);
|
||||
self.classes.add('progress');
|
||||
|
||||
if (!self.settings.filter) {
|
||||
self.settings.filter = function(value) {
|
||||
return Math.round(value);
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
renderHtml: function() {
|
||||
var self = this, id = self._id, prefix = this.classPrefix;
|
||||
|
||||
return (
|
||||
'<div id="' + id + '" class="' + self.classes + '">' +
|
||||
'<div class="' + prefix + 'bar-container">' +
|
||||
'<div class="' + prefix + 'bar"></div>' +
|
||||
'</div>' +
|
||||
'<div class="' + prefix + 'text">0%</div>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
postRender: function() {
|
||||
var self = this;
|
||||
|
||||
self._super();
|
||||
self.value(self.settings.value);
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
function setValue(value) {
|
||||
value = self.settings.filter(value);
|
||||
self.getEl().lastChild.innerHTML = value + '%';
|
||||
self.getEl().firstChild.firstChild.style.width = value + '%';
|
||||
}
|
||||
|
||||
self.state.on('change:value', function(e) {
|
||||
setValue(e.value);
|
||||
});
|
||||
|
||||
setValue(self.state.get('value'));
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
29
js/tinymce/classes/ui/Radio.js
Normal file
29
js/tinymce/classes/ui/Radio.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Radio.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new radio button.
|
||||
*
|
||||
* @-x-less Radio.less
|
||||
* @class tinymce.ui.Radio
|
||||
* @extends tinymce.ui.Checkbox
|
||||
*/
|
||||
define("tinymce/ui/Radio", [
|
||||
"tinymce/ui/Checkbox"
|
||||
], function(Checkbox) {
|
||||
"use strict";
|
||||
|
||||
return Checkbox.extend({
|
||||
Defaults: {
|
||||
classes: "radio",
|
||||
role: "radio"
|
||||
}
|
||||
});
|
||||
});
|
||||
79
js/tinymce/classes/ui/ReflowQueue.js
Normal file
79
js/tinymce/classes/ui/ReflowQueue.js
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* ReflowQueue.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class will automatically reflow controls on the next animation frame within a few milliseconds on older browsers.
|
||||
* If the user manually reflows then the automatic reflow will be cancelled. This class is used internally when various control states
|
||||
* changes that triggers a reflow.
|
||||
*
|
||||
* @class tinymce.ui.ReflowQueue
|
||||
* @static
|
||||
*/
|
||||
define("tinymce/ui/ReflowQueue", [
|
||||
"tinymce/util/Delay"
|
||||
], function(Delay) {
|
||||
var dirtyCtrls = {}, animationFrameRequested;
|
||||
|
||||
return {
|
||||
/**
|
||||
* Adds a control to the next automatic reflow call. This is the control that had a state
|
||||
* change for example if the control was hidden/shown.
|
||||
*
|
||||
* @method add
|
||||
* @param {tinymce.ui.Control} ctrl Control to add to queue.
|
||||
*/
|
||||
add: function(ctrl) {
|
||||
var parent = ctrl.parent();
|
||||
|
||||
if (parent) {
|
||||
if (!parent._layout || parent._layout.isNative()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dirtyCtrls[parent._id]) {
|
||||
dirtyCtrls[parent._id] = parent;
|
||||
}
|
||||
|
||||
if (!animationFrameRequested) {
|
||||
animationFrameRequested = true;
|
||||
|
||||
Delay.requestAnimationFrame(function() {
|
||||
var id, ctrl;
|
||||
|
||||
animationFrameRequested = false;
|
||||
|
||||
for (id in dirtyCtrls) {
|
||||
ctrl = dirtyCtrls[id];
|
||||
|
||||
if (ctrl.state.get('rendered')) {
|
||||
ctrl.reflow();
|
||||
}
|
||||
}
|
||||
|
||||
dirtyCtrls = {};
|
||||
}, document.body);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the specified control from the automatic reflow. This will happen when for example the user
|
||||
* manually triggers a reflow.
|
||||
*
|
||||
* @method remove
|
||||
* @param {tinymce.ui.Control} ctrl Control to remove from queue.
|
||||
*/
|
||||
remove: function(ctrl) {
|
||||
if (dirtyCtrls[ctrl._id]) {
|
||||
delete dirtyCtrls[ctrl._id];
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
68
js/tinymce/classes/ui/Resizable.js
Normal file
68
js/tinymce/classes/ui/Resizable.js
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Resizable.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resizable mixin. Enables controls to be resized.
|
||||
*
|
||||
* @mixin tinymce.ui.Resizable
|
||||
*/
|
||||
define("tinymce/ui/Resizable", [
|
||||
"tinymce/ui/DomUtils"
|
||||
], function(DomUtils) {
|
||||
"use strict";
|
||||
|
||||
return {
|
||||
/**
|
||||
* Resizes the control to contents.
|
||||
*
|
||||
* @method resizeToContent
|
||||
*/
|
||||
resizeToContent: function() {
|
||||
this._layoutRect.autoResize = true;
|
||||
this._lastRect = null;
|
||||
this.reflow();
|
||||
},
|
||||
|
||||
/**
|
||||
* Resizes the control to a specific width/height.
|
||||
*
|
||||
* @method resizeTo
|
||||
* @param {Number} w Control width.
|
||||
* @param {Number} h Control height.
|
||||
* @return {tinymce.ui.Control} Current control instance.
|
||||
*/
|
||||
resizeTo: function(w, h) {
|
||||
// TODO: Fix hack
|
||||
if (w <= 1 || h <= 1) {
|
||||
var rect = DomUtils.getWindowSize();
|
||||
|
||||
w = w <= 1 ? w * rect.w : w;
|
||||
h = h <= 1 ? h * rect.h : h;
|
||||
}
|
||||
|
||||
this._layoutRect.autoResize = false;
|
||||
return this.layoutRect({minW: w, minH: h, w: w, h: h}).reflow();
|
||||
},
|
||||
|
||||
/**
|
||||
* Resizes the control to a specific relative width/height.
|
||||
*
|
||||
* @method resizeBy
|
||||
* @param {Number} dw Relative control width.
|
||||
* @param {Number} dh Relative control height.
|
||||
* @return {tinymce.ui.Control} Current control instance.
|
||||
*/
|
||||
resizeBy: function(dw, dh) {
|
||||
var self = this, rect = self.layoutRect();
|
||||
|
||||
return self.resizeTo(rect.w + dw, rect.h + dh);
|
||||
}
|
||||
};
|
||||
});
|
||||
86
js/tinymce/classes/ui/ResizeHandle.js
Normal file
86
js/tinymce/classes/ui/ResizeHandle.js
Normal file
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* ResizeHandle.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders a resize handle that fires ResizeStart, Resize and ResizeEnd events.
|
||||
*
|
||||
* @-x-less ResizeHandle.less
|
||||
* @class tinymce.ui.ResizeHandle
|
||||
* @extends tinymce.ui.Widget
|
||||
*/
|
||||
define("tinymce/ui/ResizeHandle", [
|
||||
"tinymce/ui/Widget",
|
||||
"tinymce/ui/DragHelper"
|
||||
], function(Widget, DragHelper) {
|
||||
"use strict";
|
||||
|
||||
return Widget.extend({
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, prefix = self.classPrefix;
|
||||
|
||||
self.classes.add('resizehandle');
|
||||
|
||||
if (self.settings.direction == "both") {
|
||||
self.classes.add('resizehandle-both');
|
||||
}
|
||||
|
||||
self.canFocus = false;
|
||||
|
||||
return (
|
||||
'<div id="' + self._id + '" class="' + self.classes + '">' +
|
||||
'<i class="' + prefix + 'ico ' + prefix + 'i-resize"></i>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called after the control has been rendered.
|
||||
*
|
||||
* @method postRender
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this;
|
||||
|
||||
self._super();
|
||||
|
||||
self.resizeDragHelper = new DragHelper(this._id, {
|
||||
start: function() {
|
||||
self.fire('ResizeStart');
|
||||
},
|
||||
|
||||
drag: function(e) {
|
||||
if (self.settings.direction != "both") {
|
||||
e.deltaX = 0;
|
||||
}
|
||||
|
||||
self.fire('Resize', e);
|
||||
},
|
||||
|
||||
stop: function() {
|
||||
self.fire('ResizeEnd');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
remove: function() {
|
||||
if (this.resizeDragHelper) {
|
||||
this.resizeDragHelper.destroy();
|
||||
}
|
||||
|
||||
return this._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
141
js/tinymce/classes/ui/Scrollable.js
Normal file
141
js/tinymce/classes/ui/Scrollable.js
Normal file
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* Scrollable.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This mixin makes controls scrollable using custom scrollbars.
|
||||
*
|
||||
* @-x-less Scrollable.less
|
||||
* @mixin tinymce.ui.Scrollable
|
||||
*/
|
||||
define("tinymce/ui/Scrollable", [
|
||||
"tinymce/dom/DomQuery",
|
||||
"tinymce/ui/DragHelper"
|
||||
], function($, DragHelper) {
|
||||
"use strict";
|
||||
|
||||
return {
|
||||
init: function() {
|
||||
var self = this;
|
||||
self.on('repaint', self.renderScroll);
|
||||
},
|
||||
|
||||
renderScroll: function() {
|
||||
var self = this, margin = 2;
|
||||
|
||||
function repaintScroll() {
|
||||
var hasScrollH, hasScrollV, bodyElm;
|
||||
|
||||
function repaintAxis(axisName, posName, sizeName, contentSizeName, hasScroll, ax) {
|
||||
var containerElm, scrollBarElm, scrollThumbElm;
|
||||
var containerSize, scrollSize, ratio, rect;
|
||||
var posNameLower, sizeNameLower;
|
||||
|
||||
scrollBarElm = self.getEl('scroll' + axisName);
|
||||
if (scrollBarElm) {
|
||||
posNameLower = posName.toLowerCase();
|
||||
sizeNameLower = sizeName.toLowerCase();
|
||||
|
||||
$(self.getEl('absend')).css(posNameLower, self.layoutRect()[contentSizeName] - 1);
|
||||
|
||||
if (!hasScroll) {
|
||||
$(scrollBarElm).css('display', 'none');
|
||||
return;
|
||||
}
|
||||
|
||||
$(scrollBarElm).css('display', 'block');
|
||||
containerElm = self.getEl('body');
|
||||
scrollThumbElm = self.getEl('scroll' + axisName + "t");
|
||||
containerSize = containerElm["client" + sizeName] - (margin * 2);
|
||||
containerSize -= hasScrollH && hasScrollV ? scrollBarElm["client" + ax] : 0;
|
||||
scrollSize = containerElm["scroll" + sizeName];
|
||||
ratio = containerSize / scrollSize;
|
||||
|
||||
rect = {};
|
||||
rect[posNameLower] = containerElm["offset" + posName] + margin;
|
||||
rect[sizeNameLower] = containerSize;
|
||||
$(scrollBarElm).css(rect);
|
||||
|
||||
rect = {};
|
||||
rect[posNameLower] = containerElm["scroll" + posName] * ratio;
|
||||
rect[sizeNameLower] = containerSize * ratio;
|
||||
$(scrollThumbElm).css(rect);
|
||||
}
|
||||
}
|
||||
|
||||
bodyElm = self.getEl('body');
|
||||
hasScrollH = bodyElm.scrollWidth > bodyElm.clientWidth;
|
||||
hasScrollV = bodyElm.scrollHeight > bodyElm.clientHeight;
|
||||
|
||||
repaintAxis("h", "Left", "Width", "contentW", hasScrollH, "Height");
|
||||
repaintAxis("v", "Top", "Height", "contentH", hasScrollV, "Width");
|
||||
}
|
||||
|
||||
function addScroll() {
|
||||
function addScrollAxis(axisName, posName, sizeName, deltaPosName, ax) {
|
||||
var scrollStart, axisId = self._id + '-scroll' + axisName, prefix = self.classPrefix;
|
||||
|
||||
$(self.getEl()).append(
|
||||
'<div id="' + axisId + '" class="' + prefix + 'scrollbar ' + prefix + 'scrollbar-' + axisName + '">' +
|
||||
'<div id="' + axisId + 't" class="' + prefix + 'scrollbar-thumb"></div>' +
|
||||
'</div>'
|
||||
);
|
||||
|
||||
self.draghelper = new DragHelper(axisId + 't', {
|
||||
start: function() {
|
||||
scrollStart = self.getEl('body')["scroll" + posName];
|
||||
$('#' + axisId).addClass(prefix + 'active');
|
||||
},
|
||||
|
||||
drag: function(e) {
|
||||
var ratio, hasScrollH, hasScrollV, containerSize, layoutRect = self.layoutRect();
|
||||
|
||||
hasScrollH = layoutRect.contentW > layoutRect.innerW;
|
||||
hasScrollV = layoutRect.contentH > layoutRect.innerH;
|
||||
containerSize = self.getEl('body')["client" + sizeName] - (margin * 2);
|
||||
containerSize -= hasScrollH && hasScrollV ? self.getEl('scroll' + axisName)["client" + ax] : 0;
|
||||
|
||||
ratio = containerSize / self.getEl('body')["scroll" + sizeName];
|
||||
self.getEl('body')["scroll" + posName] = scrollStart + (e["delta" + deltaPosName] / ratio);
|
||||
},
|
||||
|
||||
stop: function() {
|
||||
$('#' + axisId).removeClass(prefix + 'active');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
self.classes.add('scroll');
|
||||
|
||||
addScrollAxis("v", "Top", "Height", "Y", "Width");
|
||||
addScrollAxis("h", "Left", "Width", "X", "Height");
|
||||
}
|
||||
|
||||
if (self.settings.autoScroll) {
|
||||
if (!self._hasScroll) {
|
||||
self._hasScroll = true;
|
||||
addScroll();
|
||||
|
||||
self.on('wheel', function(e) {
|
||||
var bodyEl = self.getEl('body');
|
||||
|
||||
bodyEl.scrollLeft += (e.deltaX || 0) * 10;
|
||||
bodyEl.scrollTop += e.deltaY * 10;
|
||||
|
||||
repaintScroll();
|
||||
});
|
||||
|
||||
$(self.getEl('body')).on("scroll", repaintScroll);
|
||||
}
|
||||
|
||||
repaintScroll();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
106
js/tinymce/classes/ui/SelectBox.js
Normal file
106
js/tinymce/classes/ui/SelectBox.js
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* SelectBox.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new select box control.
|
||||
*
|
||||
* @-x-less SelectBox.less
|
||||
* @class tinymce.ui.SelectBox
|
||||
* @extends tinymce.ui.Widget
|
||||
*/
|
||||
define("tinymce/ui/SelectBox", [
|
||||
"tinymce/ui/Widget"
|
||||
], function(Widget) {
|
||||
"use strict";
|
||||
|
||||
function createOptions(options) {
|
||||
var strOptions = '';
|
||||
if (options) {
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
strOptions += '<option value="' + options[i] + '">' + options[i] + '</option>';
|
||||
}
|
||||
}
|
||||
return strOptions;
|
||||
}
|
||||
|
||||
return Widget.extend({
|
||||
Defaults: {
|
||||
classes: "selectbox",
|
||||
role: "selectbox",
|
||||
options: []
|
||||
},
|
||||
/**
|
||||
* Constructs a instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
* @setting {Array} values Array with values to add to list box.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
self._super(settings);
|
||||
|
||||
if (self.settings.size) {
|
||||
|
||||
self.size = self.settings.size;
|
||||
|
||||
}
|
||||
|
||||
if (self.settings.options) {
|
||||
self._options = self.settings.options;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Getter/setter function for the options state.
|
||||
*
|
||||
* @method options
|
||||
* @param {Array} [state] State to be set.
|
||||
* @return {Array|tinymce.ui.SelectBox} Array of string options.
|
||||
*/
|
||||
options: function(state) {
|
||||
if (!arguments.length) {
|
||||
return this.state.get('options');
|
||||
}
|
||||
|
||||
this.state.set('options', state);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
renderHtml: function() {
|
||||
var self = this, options, size = '';
|
||||
|
||||
options = createOptions(self._options);
|
||||
|
||||
if (self.size) {
|
||||
size = ' size = "' + self.size + '"';
|
||||
}
|
||||
|
||||
return (
|
||||
'<select id="' + self._id + '" class="' + self.classes + '"' + size + '>' +
|
||||
options +
|
||||
'</select>'
|
||||
);
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
self.state.on('change:options', function(e) {
|
||||
self.getEl().innerHTML = createOptions(e.value);
|
||||
});
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
369
js/tinymce/classes/ui/Selector.js
Normal file
369
js/tinymce/classes/ui/Selector.js
Normal file
@@ -0,0 +1,369 @@
|
||||
/**
|
||||
* Selector.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*eslint no-nested-ternary:0 */
|
||||
|
||||
/**
|
||||
* Selector engine, enables you to select controls by using CSS like expressions.
|
||||
* We currently only support basic CSS expressions to reduce the size of the core
|
||||
* and the ones we support should be enough for most cases.
|
||||
*
|
||||
* @example
|
||||
* Supported expressions:
|
||||
* element
|
||||
* element#name
|
||||
* element.class
|
||||
* element[attr]
|
||||
* element[attr*=value]
|
||||
* element[attr~=value]
|
||||
* element[attr!=value]
|
||||
* element[attr^=value]
|
||||
* element[attr$=value]
|
||||
* element:<state>
|
||||
* element:not(<expression>)
|
||||
* element:first
|
||||
* element:last
|
||||
* element:odd
|
||||
* element:even
|
||||
* element element
|
||||
* element > element
|
||||
*
|
||||
* @class tinymce.ui.Selector
|
||||
*/
|
||||
define("tinymce/ui/Selector", [
|
||||
"tinymce/util/Class"
|
||||
], function(Class) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Produces an array with a unique set of objects. It will not compare the values
|
||||
* but the references of the objects.
|
||||
*
|
||||
* @private
|
||||
* @method unqiue
|
||||
* @param {Array} array Array to make into an array with unique items.
|
||||
* @return {Array} Array with unique items.
|
||||
*/
|
||||
function unique(array) {
|
||||
var uniqueItems = [], i = array.length, item;
|
||||
|
||||
while (i--) {
|
||||
item = array[i];
|
||||
|
||||
if (!item.__checked) {
|
||||
uniqueItems.push(item);
|
||||
item.__checked = 1;
|
||||
}
|
||||
}
|
||||
|
||||
i = uniqueItems.length;
|
||||
while (i--) {
|
||||
delete uniqueItems[i].__checked;
|
||||
}
|
||||
|
||||
return uniqueItems;
|
||||
}
|
||||
|
||||
var expression = /^([\w\\*]+)?(?:#([\w\\]+))?(?:\.([\w\\\.]+))?(?:\[\@?([\w\\]+)([\^\$\*!~]?=)([\w\\]+)\])?(?:\:(.+))?/i;
|
||||
|
||||
/*jshint maxlen:255 */
|
||||
/*eslint max-len:0 */
|
||||
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
|
||||
whiteSpace = /^\s*|\s*$/g,
|
||||
Collection;
|
||||
|
||||
var Selector = Class.extend({
|
||||
/**
|
||||
* Constructs a new Selector instance.
|
||||
*
|
||||
* @constructor
|
||||
* @method init
|
||||
* @param {String} selector CSS like selector expression.
|
||||
*/
|
||||
init: function(selector) {
|
||||
var match = this.match;
|
||||
|
||||
function compileNameFilter(name) {
|
||||
if (name) {
|
||||
name = name.toLowerCase();
|
||||
|
||||
return function(item) {
|
||||
return name === '*' || item.type === name;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function compileIdFilter(id) {
|
||||
if (id) {
|
||||
return function(item) {
|
||||
return item._name === id;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function compileClassesFilter(classes) {
|
||||
if (classes) {
|
||||
classes = classes.split('.');
|
||||
|
||||
return function(item) {
|
||||
var i = classes.length;
|
||||
|
||||
while (i--) {
|
||||
if (!item.classes.contains(classes[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function compileAttrFilter(name, cmp, check) {
|
||||
if (name) {
|
||||
return function(item) {
|
||||
var value = item[name] ? item[name]() : '';
|
||||
|
||||
return !cmp ? !!check :
|
||||
cmp === "=" ? value === check :
|
||||
cmp === "*=" ? value.indexOf(check) >= 0 :
|
||||
cmp === "~=" ? (" " + value + " ").indexOf(" " + check + " ") >= 0 :
|
||||
cmp === "!=" ? value != check :
|
||||
cmp === "^=" ? value.indexOf(check) === 0 :
|
||||
cmp === "$=" ? value.substr(value.length - check.length) === check :
|
||||
false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function compilePsuedoFilter(name) {
|
||||
var notSelectors;
|
||||
|
||||
if (name) {
|
||||
name = /(?:not\((.+)\))|(.+)/i.exec(name);
|
||||
|
||||
if (!name[1]) {
|
||||
name = name[2];
|
||||
|
||||
return function(item, index, length) {
|
||||
return name === 'first' ? index === 0 :
|
||||
name === 'last' ? index === length - 1 :
|
||||
name === 'even' ? index % 2 === 0 :
|
||||
name === 'odd' ? index % 2 === 1 :
|
||||
item[name] ? item[name]() :
|
||||
false;
|
||||
};
|
||||
}
|
||||
|
||||
// Compile not expression
|
||||
notSelectors = parseChunks(name[1], []);
|
||||
|
||||
return function(item) {
|
||||
return !match(item, notSelectors);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function compile(selector, filters, direct) {
|
||||
var parts;
|
||||
|
||||
function add(filter) {
|
||||
if (filter) {
|
||||
filters.push(filter);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse expression into parts
|
||||
parts = expression.exec(selector.replace(whiteSpace, ''));
|
||||
|
||||
add(compileNameFilter(parts[1]));
|
||||
add(compileIdFilter(parts[2]));
|
||||
add(compileClassesFilter(parts[3]));
|
||||
add(compileAttrFilter(parts[4], parts[5], parts[6]));
|
||||
add(compilePsuedoFilter(parts[7]));
|
||||
|
||||
// Mark the filter with pseudo for performance
|
||||
filters.pseudo = !!parts[7];
|
||||
filters.direct = direct;
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
// Parser logic based on Sizzle by John Resig
|
||||
function parseChunks(selector, selectors) {
|
||||
var parts = [], extra, matches, i;
|
||||
|
||||
do {
|
||||
chunker.exec("");
|
||||
matches = chunker.exec(selector);
|
||||
|
||||
if (matches) {
|
||||
selector = matches[3];
|
||||
parts.push(matches[1]);
|
||||
|
||||
if (matches[2]) {
|
||||
extra = matches[3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (matches);
|
||||
|
||||
if (extra) {
|
||||
parseChunks(extra, selectors);
|
||||
}
|
||||
|
||||
selector = [];
|
||||
for (i = 0; i < parts.length; i++) {
|
||||
if (parts[i] != '>') {
|
||||
selector.push(compile(parts[i], [], parts[i - 1] === '>'));
|
||||
}
|
||||
}
|
||||
|
||||
selectors.push(selector);
|
||||
|
||||
return selectors;
|
||||
}
|
||||
|
||||
this._selectors = parseChunks(selector, []);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true/false if the selector matches the specified control.
|
||||
*
|
||||
* @method match
|
||||
* @param {tinymce.ui.Control} control Control to match against the selector.
|
||||
* @param {Array} selectors Optional array of selectors, mostly used internally.
|
||||
* @return {Boolean} true/false state if the control matches or not.
|
||||
*/
|
||||
match: function(control, selectors) {
|
||||
var i, l, si, sl, selector, fi, fl, filters, index, length, siblings, count, item;
|
||||
|
||||
selectors = selectors || this._selectors;
|
||||
for (i = 0, l = selectors.length; i < l; i++) {
|
||||
selector = selectors[i];
|
||||
sl = selector.length;
|
||||
item = control;
|
||||
count = 0;
|
||||
|
||||
for (si = sl - 1; si >= 0; si--) {
|
||||
filters = selector[si];
|
||||
|
||||
while (item) {
|
||||
// Find the index and length since a pseudo filter like :first needs it
|
||||
if (filters.pseudo) {
|
||||
siblings = item.parent().items();
|
||||
index = length = siblings.length;
|
||||
while (index--) {
|
||||
if (siblings[index] === item) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (fi = 0, fl = filters.length; fi < fl; fi++) {
|
||||
if (!filters[fi](item, index, length)) {
|
||||
fi = fl + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fi === fl) {
|
||||
count++;
|
||||
break;
|
||||
} else {
|
||||
// If it didn't match the right most expression then
|
||||
// break since it's no point looking at the parents
|
||||
if (si === sl - 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
item = item.parent();
|
||||
}
|
||||
}
|
||||
|
||||
// If we found all selectors then return true otherwise continue looking
|
||||
if (count === sl) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a tinymce.ui.Collection with matches of the specified selector inside the specified container.
|
||||
*
|
||||
* @method find
|
||||
* @param {tinymce.ui.Control} container Container to look for items in.
|
||||
* @return {tinymce.ui.Collection} Collection with matched elements.
|
||||
*/
|
||||
find: function(container) {
|
||||
var matches = [], i, l, selectors = this._selectors;
|
||||
|
||||
function collect(items, selector, index) {
|
||||
var i, l, fi, fl, item, filters = selector[index];
|
||||
|
||||
for (i = 0, l = items.length; i < l; i++) {
|
||||
item = items[i];
|
||||
|
||||
// Run each filter against the item
|
||||
for (fi = 0, fl = filters.length; fi < fl; fi++) {
|
||||
if (!filters[fi](item, i, l)) {
|
||||
fi = fl + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// All filters matched the item
|
||||
if (fi === fl) {
|
||||
// Matched item is on the last expression like: panel toolbar [button]
|
||||
if (index == selector.length - 1) {
|
||||
matches.push(item);
|
||||
} else {
|
||||
// Collect next expression type
|
||||
if (item.items) {
|
||||
collect(item.items(), selector, index + 1);
|
||||
}
|
||||
}
|
||||
} else if (filters.direct) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Collect child items
|
||||
if (item.items) {
|
||||
collect(item.items(), selector, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (container.items) {
|
||||
for (i = 0, l = selectors.length; i < l; i++) {
|
||||
collect(container.items(), selectors[i], 0);
|
||||
}
|
||||
|
||||
// Unique the matches if needed
|
||||
if (l > 1) {
|
||||
matches = unique(matches);
|
||||
}
|
||||
}
|
||||
|
||||
// Fix for circular reference
|
||||
if (!Collection) {
|
||||
// TODO: Fix me!
|
||||
Collection = Selector.Collection;
|
||||
}
|
||||
|
||||
return new Collection(matches);
|
||||
}
|
||||
});
|
||||
|
||||
return Selector;
|
||||
});
|
||||
161
js/tinymce/classes/ui/Slider.js
Normal file
161
js/tinymce/classes/ui/Slider.js
Normal file
@@ -0,0 +1,161 @@
|
||||
/**
|
||||
* Slider.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Slider control.
|
||||
*
|
||||
* @-x-less Slider.less
|
||||
* @class tinymce.ui.Slider
|
||||
* @extends tinymce.ui.Widget
|
||||
*/
|
||||
define("tinymce/ui/Slider", [
|
||||
"tinymce/ui/Widget",
|
||||
"tinymce/ui/DragHelper",
|
||||
"tinymce/ui/DomUtils"
|
||||
], function(Widget, DragHelper, DomUtils) {
|
||||
"use strict";
|
||||
|
||||
function constrain(value, minVal, maxVal) {
|
||||
if (value < minVal) {
|
||||
value = minVal;
|
||||
}
|
||||
|
||||
if (value > maxVal) {
|
||||
value = maxVal;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function updateSliderHandle(ctrl, value) {
|
||||
var maxHandlePos, shortSizeName, sizeName, stylePosName, styleValue;
|
||||
|
||||
if (ctrl.settings.orientation == "v") {
|
||||
stylePosName = "top";
|
||||
sizeName = "height";
|
||||
shortSizeName = "h";
|
||||
} else {
|
||||
stylePosName = "left";
|
||||
sizeName = "width";
|
||||
shortSizeName = "w";
|
||||
}
|
||||
|
||||
maxHandlePos = (ctrl.layoutRect()[shortSizeName] || 100) - DomUtils.getSize(ctrl.getEl('handle'))[sizeName];
|
||||
|
||||
styleValue = (maxHandlePos * ((value - ctrl._minValue) / (ctrl._maxValue - ctrl._minValue))) + 'px';
|
||||
ctrl.getEl('handle').style[stylePosName] = styleValue;
|
||||
ctrl.getEl('handle').style.height = ctrl.layoutRect().h + 'px';
|
||||
}
|
||||
|
||||
return Widget.extend({
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
if (!settings.previewFilter) {
|
||||
settings.previewFilter = function(value) {
|
||||
return Math.round(value * 100) / 100.0;
|
||||
};
|
||||
}
|
||||
|
||||
self._super(settings);
|
||||
self.classes.add('slider');
|
||||
|
||||
if (settings.orientation == "v") {
|
||||
self.classes.add('vertical');
|
||||
}
|
||||
|
||||
self._minValue = settings.minValue || 0;
|
||||
self._maxValue = settings.maxValue || 100;
|
||||
self._initValue = self.state.get('value');
|
||||
},
|
||||
|
||||
renderHtml: function() {
|
||||
var self = this, id = self._id, prefix = self.classPrefix;
|
||||
|
||||
return (
|
||||
'<div id="' + id + '" class="' + self.classes + '">' +
|
||||
'<div id="' + id + '-handle" class="' + prefix + 'slider-handle"></div>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
this.value(this._initValue).repaint();
|
||||
},
|
||||
|
||||
postRender: function() {
|
||||
var self = this, startPos, startHandlePos, handlePos = 0, value, minValue, maxValue, maxHandlePos;
|
||||
var screenCordName, stylePosName, sizeName, shortSizeName;
|
||||
|
||||
minValue = self._minValue;
|
||||
maxValue = self._maxValue;
|
||||
value = self.value();
|
||||
|
||||
if (self.settings.orientation == "v") {
|
||||
screenCordName = "screenY";
|
||||
stylePosName = "top";
|
||||
sizeName = "height";
|
||||
shortSizeName = "h";
|
||||
} else {
|
||||
screenCordName = "screenX";
|
||||
stylePosName = "left";
|
||||
sizeName = "width";
|
||||
shortSizeName = "w";
|
||||
}
|
||||
|
||||
self._super();
|
||||
|
||||
self._dragHelper = new DragHelper(self._id, {
|
||||
handle: self._id + "-handle",
|
||||
|
||||
start: function(e) {
|
||||
startPos = e[screenCordName];
|
||||
startHandlePos = parseInt(self.getEl('handle').style[stylePosName], 10);
|
||||
maxHandlePos = (self.layoutRect()[shortSizeName] || 100) - DomUtils.getSize(self.getEl('handle'))[sizeName];
|
||||
self.fire('dragstart', {value: value});
|
||||
},
|
||||
|
||||
drag: function(e) {
|
||||
var delta = e[screenCordName] - startPos, handleEl = self.getEl('handle');
|
||||
|
||||
handlePos = constrain(startHandlePos + delta, 0, maxHandlePos);
|
||||
handleEl.style[stylePosName] = handlePos + 'px';
|
||||
|
||||
value = minValue + (handlePos / maxHandlePos) * (maxValue - minValue);
|
||||
self.value(value);
|
||||
|
||||
self.tooltip().text('' + self.settings.previewFilter(value)).show().moveRel(handleEl, 'bc tc');
|
||||
|
||||
self.fire('drag', {value: value});
|
||||
},
|
||||
|
||||
stop: function() {
|
||||
self.tooltip().hide();
|
||||
self.fire('dragend', {value: value});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
repaint: function() {
|
||||
this._super();
|
||||
updateSliderHandle(this, this.value());
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
self.state.on('change:value', function(e) {
|
||||
updateSliderHandle(self, e.value);
|
||||
});
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
39
js/tinymce/classes/ui/Spacer.js
Normal file
39
js/tinymce/classes/ui/Spacer.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Spacer.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a spacer. This control is used in flex layouts for example.
|
||||
*
|
||||
* @-x-less Spacer.less
|
||||
* @class tinymce.ui.Spacer
|
||||
* @extends tinymce.ui.Widget
|
||||
*/
|
||||
define("tinymce/ui/Spacer", [
|
||||
"tinymce/ui/Widget"
|
||||
], function(Widget) {
|
||||
"use strict";
|
||||
|
||||
return Widget.extend({
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this;
|
||||
|
||||
self.classes.add('spacer');
|
||||
self.canFocus = false;
|
||||
|
||||
return '<div id="' + self._id + '" class="' + self.classes + '"></div>';
|
||||
}
|
||||
});
|
||||
});
|
||||
146
js/tinymce/classes/ui/SplitButton.js
Normal file
146
js/tinymce/classes/ui/SplitButton.js
Normal file
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
* SplitButton.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a split button.
|
||||
*
|
||||
* @-x-less SplitButton.less
|
||||
* @class tinymce.ui.SplitButton
|
||||
* @extends tinymce.ui.Button
|
||||
*/
|
||||
define("tinymce/ui/SplitButton", [
|
||||
"tinymce/ui/MenuButton",
|
||||
"tinymce/ui/DomUtils",
|
||||
"tinymce/dom/DomQuery"
|
||||
], function(MenuButton, DomUtils, $) {
|
||||
return MenuButton.extend({
|
||||
Defaults: {
|
||||
classes: "widget btn splitbtn",
|
||||
role: "button"
|
||||
},
|
||||
|
||||
/**
|
||||
* Repaints the control after a layout operation.
|
||||
*
|
||||
* @method repaint
|
||||
*/
|
||||
repaint: function() {
|
||||
var self = this, elm = self.getEl(), rect = self.layoutRect(), mainButtonElm, menuButtonElm;
|
||||
|
||||
self._super();
|
||||
|
||||
mainButtonElm = elm.firstChild;
|
||||
menuButtonElm = elm.lastChild;
|
||||
|
||||
$(mainButtonElm).css({
|
||||
width: rect.w - DomUtils.getSize(menuButtonElm).width,
|
||||
height: rect.h - 2
|
||||
});
|
||||
|
||||
$(menuButtonElm).css({
|
||||
height: rect.h - 2
|
||||
});
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the active menu state.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
activeMenu: function(state) {
|
||||
var self = this;
|
||||
|
||||
$(self.getEl().lastChild).toggleClass(self.classPrefix + 'active', state);
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, id = self._id, prefix = self.classPrefix, image;
|
||||
var icon = self.state.get('icon'), text = self.state.get('text'),
|
||||
textHtml = '';
|
||||
|
||||
image = self.settings.image;
|
||||
if (image) {
|
||||
icon = 'none';
|
||||
|
||||
// Support for [high dpi, low dpi] image sources
|
||||
if (typeof image != "string") {
|
||||
image = window.getSelection ? image[0] : image[1];
|
||||
}
|
||||
|
||||
image = ' style="background-image: url(\'' + image + '\')"';
|
||||
} else {
|
||||
image = '';
|
||||
}
|
||||
|
||||
icon = self.settings.icon ? prefix + 'ico ' + prefix + 'i-' + icon : '';
|
||||
|
||||
if (text) {
|
||||
self.classes.add('btn-has-text');
|
||||
textHtml = '<span class="' + prefix + 'txt">' + self.encode(text) + '</span>';
|
||||
}
|
||||
|
||||
return (
|
||||
'<div id="' + id + '" class="' + self.classes + '" role="button" tabindex="-1">' +
|
||||
'<button type="button" hidefocus="1" tabindex="-1">' +
|
||||
(icon ? '<i class="' + icon + '"' + image + '></i>' : '') +
|
||||
textHtml +
|
||||
'</button>' +
|
||||
'<button type="button" class="' + prefix + 'open" hidefocus="1" tabindex="-1">' +
|
||||
//(icon ? '<i class="' + icon + '"></i>' : '') +
|
||||
(self._menuBtnText ? (icon ? '\u00a0' : '') + self._menuBtnText : '') +
|
||||
' <i class="' + prefix + 'caret"></i>' +
|
||||
'</button>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called after the control has been rendered.
|
||||
*
|
||||
* @method postRender
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this, onClickHandler = self.settings.onclick;
|
||||
|
||||
self.on('click', function(e) {
|
||||
var node = e.target;
|
||||
|
||||
if (e.control == this) {
|
||||
// Find clicks that is on the main button
|
||||
while (node) {
|
||||
if ((e.aria && e.aria.key != 'down') || (node.nodeName == 'BUTTON' && node.className.indexOf('open') == -1)) {
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
if (onClickHandler) {
|
||||
onClickHandler.call(this, e);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
node = node.parentNode;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
delete self.settings.onclick;
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
34
js/tinymce/classes/ui/StackLayout.js
Normal file
34
js/tinymce/classes/ui/StackLayout.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* StackLayout.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This layout uses the browsers layout when the items are blocks.
|
||||
*
|
||||
* @-x-less StackLayout.less
|
||||
* @class tinymce.ui.StackLayout
|
||||
* @extends tinymce.ui.FlowLayout
|
||||
*/
|
||||
define("tinymce/ui/StackLayout", [
|
||||
"tinymce/ui/FlowLayout"
|
||||
], function(FlowLayout) {
|
||||
"use strict";
|
||||
|
||||
return FlowLayout.extend({
|
||||
Defaults: {
|
||||
containerClass: 'stack-layout',
|
||||
controlClass: 'stack-layout-item',
|
||||
endClass: 'break'
|
||||
},
|
||||
|
||||
isNative: function() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
178
js/tinymce/classes/ui/TabPanel.js
Normal file
178
js/tinymce/classes/ui/TabPanel.js
Normal file
@@ -0,0 +1,178 @@
|
||||
/**
|
||||
* TabPanel.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a tab panel control.
|
||||
*
|
||||
* @-x-less TabPanel.less
|
||||
* @class tinymce.ui.TabPanel
|
||||
* @extends tinymce.ui.Panel
|
||||
*
|
||||
* @setting {Number} activeTab Active tab index.
|
||||
*/
|
||||
define("tinymce/ui/TabPanel", [
|
||||
"tinymce/ui/Panel",
|
||||
"tinymce/dom/DomQuery",
|
||||
"tinymce/ui/DomUtils"
|
||||
], function(Panel, $, DomUtils) {
|
||||
"use strict";
|
||||
|
||||
return Panel.extend({
|
||||
Defaults: {
|
||||
layout: 'absolute',
|
||||
defaults: {
|
||||
type: 'panel'
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Activates the specified tab by index.
|
||||
*
|
||||
* @method activateTab
|
||||
* @param {Number} idx Index of the tab to activate.
|
||||
*/
|
||||
activateTab: function(idx) {
|
||||
var activeTabElm;
|
||||
|
||||
if (this.activeTabId) {
|
||||
activeTabElm = this.getEl(this.activeTabId);
|
||||
$(activeTabElm).removeClass(this.classPrefix + 'active');
|
||||
activeTabElm.setAttribute('aria-selected', "false");
|
||||
}
|
||||
|
||||
this.activeTabId = 't' + idx;
|
||||
|
||||
activeTabElm = this.getEl('t' + idx);
|
||||
activeTabElm.setAttribute('aria-selected', "true");
|
||||
$(activeTabElm).addClass(this.classPrefix + 'active');
|
||||
|
||||
this.items()[idx].show().fire('showtab');
|
||||
this.reflow();
|
||||
|
||||
this.items().each(function(item, i) {
|
||||
if (idx != i) {
|
||||
item.hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, layout = self._layout, tabsHtml = '', prefix = self.classPrefix;
|
||||
|
||||
self.preRender();
|
||||
layout.preRender(self);
|
||||
|
||||
self.items().each(function(ctrl, i) {
|
||||
var id = self._id + '-t' + i;
|
||||
|
||||
ctrl.aria('role', 'tabpanel');
|
||||
ctrl.aria('labelledby', id);
|
||||
|
||||
tabsHtml += (
|
||||
'<div id="' + id + '" class="' + prefix + 'tab" ' +
|
||||
'unselectable="on" role="tab" aria-controls="' + ctrl._id + '" aria-selected="false" tabIndex="-1">' +
|
||||
self.encode(ctrl.settings.title) +
|
||||
'</div>'
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
'<div id="' + self._id + '" class="' + self.classes + '" hidefocus="1" tabindex="-1">' +
|
||||
'<div id="' + self._id + '-head" class="' + prefix + 'tabs" role="tablist">' +
|
||||
tabsHtml +
|
||||
'</div>' +
|
||||
'<div id="' + self._id + '-body" class="' + self.bodyClasses + '">' +
|
||||
layout.renderHtml(self) +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called after the control has been rendered.
|
||||
*
|
||||
* @method postRender
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this;
|
||||
|
||||
self._super();
|
||||
|
||||
self.settings.activeTab = self.settings.activeTab || 0;
|
||||
self.activateTab(self.settings.activeTab);
|
||||
|
||||
this.on('click', function(e) {
|
||||
var targetParent = e.target.parentNode;
|
||||
|
||||
if (e.target.parentNode.id == self._id + '-head') {
|
||||
var i = targetParent.childNodes.length;
|
||||
|
||||
while (i--) {
|
||||
if (targetParent.childNodes[i] == e.target) {
|
||||
self.activateTab(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the current controls layout rect.
|
||||
* This will be executed by the layout managers to determine the
|
||||
* default minWidth/minHeight etc.
|
||||
*
|
||||
* @method initLayoutRect
|
||||
* @return {Object} Layout rect instance.
|
||||
*/
|
||||
initLayoutRect: function() {
|
||||
var self = this, rect, minW, minH;
|
||||
|
||||
minW = DomUtils.getSize(self.getEl('head')).width;
|
||||
minW = minW < 0 ? 0 : minW;
|
||||
minH = 0;
|
||||
|
||||
self.items().each(function(item) {
|
||||
minW = Math.max(minW, item.layoutRect().minW);
|
||||
minH = Math.max(minH, item.layoutRect().minH);
|
||||
});
|
||||
|
||||
self.items().each(function(ctrl) {
|
||||
ctrl.settings.x = 0;
|
||||
ctrl.settings.y = 0;
|
||||
ctrl.settings.w = minW;
|
||||
ctrl.settings.h = minH;
|
||||
|
||||
ctrl.layoutRect({
|
||||
x: 0,
|
||||
y: 0,
|
||||
w: minW,
|
||||
h: minH
|
||||
});
|
||||
});
|
||||
|
||||
var headH = DomUtils.getSize(self.getEl('head')).height;
|
||||
|
||||
self.settings.minWidth = minW;
|
||||
self.settings.minHeight = minH + headH;
|
||||
|
||||
rect = self._super();
|
||||
rect.deltaH += headH;
|
||||
rect.innerH = rect.h - rect.deltaH;
|
||||
|
||||
return rect;
|
||||
}
|
||||
});
|
||||
});
|
||||
208
js/tinymce/classes/ui/TextBox.js
Normal file
208
js/tinymce/classes/ui/TextBox.js
Normal file
@@ -0,0 +1,208 @@
|
||||
/**
|
||||
* TextBox.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new textbox.
|
||||
*
|
||||
* @-x-less TextBox.less
|
||||
* @class tinymce.ui.TextBox
|
||||
* @extends tinymce.ui.Widget
|
||||
*/
|
||||
define("tinymce/ui/TextBox", [
|
||||
"tinymce/ui/Widget"
|
||||
], function(Widget) {
|
||||
"use strict";
|
||||
|
||||
return Widget.extend({
|
||||
/**
|
||||
* Constructs a instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
* @setting {Boolean} multiline True if the textbox is a multiline control.
|
||||
* @setting {Number} maxLength Max length for the textbox.
|
||||
* @setting {Number} size Size of the textbox in characters.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
self._super(settings);
|
||||
|
||||
self.classes.add('textbox');
|
||||
|
||||
if (settings.multiline) {
|
||||
self.classes.add('multiline');
|
||||
} else {
|
||||
self.on('keydown', function(e) {
|
||||
var rootControl;
|
||||
|
||||
if (e.keyCode == 13) {
|
||||
e.preventDefault();
|
||||
|
||||
// Find root control that we can do toJSON on
|
||||
self.parents().reverse().each(function(ctrl) {
|
||||
if (ctrl.toJSON) {
|
||||
rootControl = ctrl;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Fire event on current text box with the serialized data of the whole form
|
||||
self.fire('submit', {data: rootControl.toJSON()});
|
||||
}
|
||||
});
|
||||
|
||||
self.on('keyup', function(e) {
|
||||
self.state.set('value', e.target.value);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Repaints the control after a layout operation.
|
||||
*
|
||||
* @method repaint
|
||||
*/
|
||||
repaint: function() {
|
||||
var self = this, style, rect, borderBox, borderW, borderH = 0, lastRepaintRect;
|
||||
|
||||
style = self.getEl().style;
|
||||
rect = self._layoutRect;
|
||||
lastRepaintRect = self._lastRepaintRect || {};
|
||||
|
||||
// Detect old IE 7+8 add lineHeight to align caret vertically in the middle
|
||||
var doc = document;
|
||||
if (!self.settings.multiline && doc.all && (!doc.documentMode || doc.documentMode <= 8)) {
|
||||
style.lineHeight = (rect.h - borderH) + 'px';
|
||||
}
|
||||
|
||||
borderBox = self.borderBox;
|
||||
borderW = borderBox.left + borderBox.right + 8;
|
||||
borderH = borderBox.top + borderBox.bottom + (self.settings.multiline ? 8 : 0);
|
||||
|
||||
if (rect.x !== lastRepaintRect.x) {
|
||||
style.left = rect.x + 'px';
|
||||
lastRepaintRect.x = rect.x;
|
||||
}
|
||||
|
||||
if (rect.y !== lastRepaintRect.y) {
|
||||
style.top = rect.y + 'px';
|
||||
lastRepaintRect.y = rect.y;
|
||||
}
|
||||
|
||||
if (rect.w !== lastRepaintRect.w) {
|
||||
style.width = (rect.w - borderW) + 'px';
|
||||
lastRepaintRect.w = rect.w;
|
||||
}
|
||||
|
||||
if (rect.h !== lastRepaintRect.h) {
|
||||
style.height = (rect.h - borderH) + 'px';
|
||||
lastRepaintRect.h = rect.h;
|
||||
}
|
||||
|
||||
self._lastRepaintRect = lastRepaintRect;
|
||||
self.fire('repaint', {}, false);
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, id = self._id, settings = self.settings, value = self.encode(self.state.get('value'), false), extraAttrs = '';
|
||||
|
||||
if ("spellcheck" in settings) {
|
||||
extraAttrs += ' spellcheck="' + settings.spellcheck + '"';
|
||||
}
|
||||
|
||||
if (settings.maxLength) {
|
||||
extraAttrs += ' maxlength="' + settings.maxLength + '"';
|
||||
}
|
||||
|
||||
if (settings.size) {
|
||||
extraAttrs += ' size="' + settings.size + '"';
|
||||
}
|
||||
|
||||
if (settings.subtype) {
|
||||
extraAttrs += ' type="' + settings.subtype + '"';
|
||||
}
|
||||
|
||||
if (self.disabled()) {
|
||||
extraAttrs += ' disabled="disabled"';
|
||||
}
|
||||
|
||||
if (settings.multiline) {
|
||||
return (
|
||||
'<textarea id="' + id + '" class="' + self.classes + '" ' +
|
||||
(settings.rows ? ' rows="' + settings.rows + '"' : '') +
|
||||
' hidefocus="1"' + extraAttrs + '>' + value +
|
||||
'</textarea>'
|
||||
);
|
||||
}
|
||||
|
||||
return '<input id="' + id + '" class="' + self.classes + '" value="' + value + '" hidefocus="1"' + extraAttrs + ' />';
|
||||
},
|
||||
|
||||
value: function(value) {
|
||||
if (arguments.length) {
|
||||
this.state.set('value', value);
|
||||
return this;
|
||||
}
|
||||
|
||||
// Make sure the real state is in sync
|
||||
if (this.state.get('rendered')) {
|
||||
this.state.set('value', this.getEl().value);
|
||||
}
|
||||
|
||||
return this.state.get('value');
|
||||
},
|
||||
|
||||
/**
|
||||
* Called after the control has been rendered.
|
||||
*
|
||||
* @method postRender
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this;
|
||||
|
||||
self._super();
|
||||
|
||||
self.$el.on('change', function(e) {
|
||||
self.state.set('value', e.target.value);
|
||||
self.fire('change', e);
|
||||
});
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
self.state.on('change:value', function(e) {
|
||||
if (self.getEl().value != e.value) {
|
||||
self.getEl().value = e.value;
|
||||
}
|
||||
});
|
||||
|
||||
self.state.on('change:disabled', function(e) {
|
||||
self.getEl().disabled = e.value;
|
||||
});
|
||||
|
||||
return self._super();
|
||||
},
|
||||
|
||||
remove: function() {
|
||||
this.$el.off();
|
||||
this._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
88
js/tinymce/classes/ui/Throbber.js
Normal file
88
js/tinymce/classes/ui/Throbber.js
Normal file
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* Throbber.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class enables you to display a Throbber for any element.
|
||||
*
|
||||
* @-x-less Throbber.less
|
||||
* @class tinymce.ui.Throbber
|
||||
*/
|
||||
define("tinymce/ui/Throbber", [
|
||||
"tinymce/dom/DomQuery",
|
||||
"tinymce/ui/Control",
|
||||
"tinymce/util/Delay"
|
||||
], function($, Control, Delay) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Constructs a new throbber.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Element} elm DOM Html element to display throbber in.
|
||||
* @param {Boolean} inline Optional true/false state if the throbber should be appended to end of element for infinite scroll.
|
||||
*/
|
||||
return function(elm, inline) {
|
||||
var self = this, state, classPrefix = Control.classPrefix, timer;
|
||||
|
||||
/**
|
||||
* Shows the throbber.
|
||||
*
|
||||
* @method show
|
||||
* @param {Number} [time] Time to wait before showing.
|
||||
* @param {function} [callback] Optional callback to execute when the throbber is shown.
|
||||
* @return {tinymce.ui.Throbber} Current throbber instance.
|
||||
*/
|
||||
self.show = function(time, callback) {
|
||||
function render() {
|
||||
if (state) {
|
||||
$(elm).append(
|
||||
'<div class="' + classPrefix + 'throbber' + (inline ? ' ' + classPrefix + 'throbber-inline' : '') + '"></div>'
|
||||
);
|
||||
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.hide();
|
||||
|
||||
state = true;
|
||||
|
||||
if (time) {
|
||||
timer = Delay.setTimeout(render, time);
|
||||
} else {
|
||||
render();
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
/**
|
||||
* Hides the throbber.
|
||||
*
|
||||
* @method hide
|
||||
* @return {tinymce.ui.Throbber} Current throbber instance.
|
||||
*/
|
||||
self.hide = function() {
|
||||
var child = elm.lastChild;
|
||||
|
||||
Delay.clearTimeout(timer);
|
||||
|
||||
if (child && child.className.indexOf('throbber') != -1) {
|
||||
child.parentNode.removeChild(child);
|
||||
}
|
||||
|
||||
state = false;
|
||||
|
||||
return self;
|
||||
};
|
||||
};
|
||||
});
|
||||
56
js/tinymce/classes/ui/Toolbar.js
Normal file
56
js/tinymce/classes/ui/Toolbar.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Toolbar.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new toolbar.
|
||||
*
|
||||
* @class tinymce.ui.Toolbar
|
||||
* @extends tinymce.ui.Container
|
||||
*/
|
||||
define("tinymce/ui/Toolbar", [
|
||||
"tinymce/ui/Container"
|
||||
], function(Container) {
|
||||
"use strict";
|
||||
|
||||
return Container.extend({
|
||||
Defaults: {
|
||||
role: 'toolbar',
|
||||
layout: 'flow'
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructs a instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
self._super(settings);
|
||||
self.classes.add('toolbar');
|
||||
},
|
||||
|
||||
/**
|
||||
* Called after the control has been rendered.
|
||||
*
|
||||
* @method postRender
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this;
|
||||
|
||||
self.items().each(function(ctrl) {
|
||||
ctrl.classes.add('toolbar-item');
|
||||
});
|
||||
|
||||
return self._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
73
js/tinymce/classes/ui/Tooltip.js
Normal file
73
js/tinymce/classes/ui/Tooltip.js
Normal file
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* Tooltip.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a tooltip instance.
|
||||
*
|
||||
* @-x-less ToolTip.less
|
||||
* @class tinymce.ui.ToolTip
|
||||
* @extends tinymce.ui.Control
|
||||
* @mixes tinymce.ui.Movable
|
||||
*/
|
||||
define("tinymce/ui/Tooltip", [
|
||||
"tinymce/ui/Control",
|
||||
"tinymce/ui/Movable"
|
||||
], function(Control, Movable) {
|
||||
return Control.extend({
|
||||
Mixins: [Movable],
|
||||
|
||||
Defaults: {
|
||||
classes: 'widget tooltip tooltip-n'
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, prefix = self.classPrefix;
|
||||
|
||||
return (
|
||||
'<div id="' + self._id + '" class="' + self.classes + '" role="presentation">' +
|
||||
'<div class="' + prefix + 'tooltip-arrow"></div>' +
|
||||
'<div class="' + prefix + 'tooltip-inner">' + self.encode(self.state.get('text')) + '</div>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
self.state.on('change:text', function(e) {
|
||||
self.getEl().lastChild.innerHTML = self.encode(e.value);
|
||||
});
|
||||
|
||||
return self._super();
|
||||
},
|
||||
|
||||
/**
|
||||
* Repaints the control after a layout operation.
|
||||
*
|
||||
* @method repaint
|
||||
*/
|
||||
repaint: function() {
|
||||
var self = this, style, rect;
|
||||
|
||||
style = self.getEl().style;
|
||||
rect = self._layoutRect;
|
||||
|
||||
style.left = rect.x + 'px';
|
||||
style.top = rect.y + 'px';
|
||||
style.zIndex = 0xFFFF + 0xFFFF;
|
||||
}
|
||||
});
|
||||
});
|
||||
151
js/tinymce/classes/ui/Widget.js
Normal file
151
js/tinymce/classes/ui/Widget.js
Normal file
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* Widget.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Widget base class a widget is a control that has a tooltip and some basic states.
|
||||
*
|
||||
* @class tinymce.ui.Widget
|
||||
* @extends tinymce.ui.Control
|
||||
*/
|
||||
define("tinymce/ui/Widget", [
|
||||
"tinymce/ui/Control",
|
||||
"tinymce/ui/Tooltip"
|
||||
], function(Control, Tooltip) {
|
||||
"use strict";
|
||||
|
||||
var tooltip;
|
||||
|
||||
var Widget = Control.extend({
|
||||
/**
|
||||
* Constructs a instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
* @setting {String} tooltip Tooltip text to display when hovering.
|
||||
* @setting {Boolean} autofocus True if the control should be focused when rendered.
|
||||
* @setting {String} text Text to display inside widget.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
self._super(settings);
|
||||
settings = self.settings;
|
||||
self.canFocus = true;
|
||||
|
||||
if (settings.tooltip && Widget.tooltips !== false) {
|
||||
self.on('mouseenter', function(e) {
|
||||
var tooltip = self.tooltip().moveTo(-0xFFFF);
|
||||
|
||||
if (e.control == self) {
|
||||
var rel = tooltip.text(settings.tooltip).show().testMoveRel(self.getEl(), ['bc-tc', 'bc-tl', 'bc-tr']);
|
||||
|
||||
tooltip.classes.toggle('tooltip-n', rel == 'bc-tc');
|
||||
tooltip.classes.toggle('tooltip-nw', rel == 'bc-tl');
|
||||
tooltip.classes.toggle('tooltip-ne', rel == 'bc-tr');
|
||||
|
||||
tooltip.moveRel(self.getEl(), rel);
|
||||
} else {
|
||||
tooltip.hide();
|
||||
}
|
||||
});
|
||||
|
||||
self.on('mouseleave mousedown click', function() {
|
||||
self.tooltip().hide();
|
||||
});
|
||||
}
|
||||
|
||||
self.aria('label', settings.ariaLabel || settings.tooltip);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the current tooltip instance.
|
||||
*
|
||||
* @method tooltip
|
||||
* @return {tinymce.ui.Tooltip} Tooltip instance.
|
||||
*/
|
||||
tooltip: function() {
|
||||
if (!tooltip) {
|
||||
tooltip = new Tooltip({type: 'tooltip'});
|
||||
tooltip.renderTo();
|
||||
}
|
||||
|
||||
return tooltip;
|
||||
},
|
||||
|
||||
/**
|
||||
* Called after the control has been rendered.
|
||||
*
|
||||
* @method postRender
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this, settings = self.settings;
|
||||
|
||||
self._super();
|
||||
|
||||
if (!self.parent() && (settings.width || settings.height)) {
|
||||
self.initLayoutRect();
|
||||
self.repaint();
|
||||
}
|
||||
|
||||
if (settings.autofocus) {
|
||||
self.focus();
|
||||
}
|
||||
},
|
||||
|
||||
bindStates: function() {
|
||||
var self = this;
|
||||
|
||||
function disable(state) {
|
||||
self.aria('disabled', state);
|
||||
self.classes.toggle('disabled', state);
|
||||
}
|
||||
|
||||
function active(state) {
|
||||
self.aria('pressed', state);
|
||||
self.classes.toggle('active', state);
|
||||
}
|
||||
|
||||
self.state.on('change:disabled', function(e) {
|
||||
disable(e.value);
|
||||
});
|
||||
|
||||
self.state.on('change:active', function(e) {
|
||||
active(e.value);
|
||||
});
|
||||
|
||||
if (self.state.get('disabled')) {
|
||||
disable(true);
|
||||
}
|
||||
|
||||
if (self.state.get('active')) {
|
||||
active(true);
|
||||
}
|
||||
|
||||
return self._super();
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the current control from DOM and from UI collections.
|
||||
*
|
||||
* @method remove
|
||||
* @return {tinymce.ui.Control} Current control instance.
|
||||
*/
|
||||
remove: function() {
|
||||
this._super();
|
||||
|
||||
if (tooltip) {
|
||||
tooltip.remove();
|
||||
tooltip = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return Widget;
|
||||
});
|
||||
470
js/tinymce/classes/ui/Window.js
Normal file
470
js/tinymce/classes/ui/Window.js
Normal file
@@ -0,0 +1,470 @@
|
||||
/**
|
||||
* Window.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new window.
|
||||
*
|
||||
* @-x-less Window.less
|
||||
* @class tinymce.ui.Window
|
||||
* @extends tinymce.ui.FloatPanel
|
||||
*/
|
||||
define("tinymce/ui/Window", [
|
||||
"tinymce/ui/FloatPanel",
|
||||
"tinymce/ui/Panel",
|
||||
"tinymce/ui/DomUtils",
|
||||
"tinymce/dom/DomQuery",
|
||||
"tinymce/ui/DragHelper",
|
||||
"tinymce/ui/BoxUtils",
|
||||
"tinymce/Env",
|
||||
"tinymce/util/Delay"
|
||||
], function(FloatPanel, Panel, DomUtils, $, DragHelper, BoxUtils, Env, Delay) {
|
||||
"use strict";
|
||||
|
||||
var windows = [], oldMetaValue = '';
|
||||
|
||||
function toggleFullScreenState(state) {
|
||||
var noScaleMetaValue = 'width=device-width,initial-scale=1.0,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0',
|
||||
viewport = $("meta[name=viewport]")[0],
|
||||
contentValue;
|
||||
|
||||
if (Env.overrideViewPort === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!viewport) {
|
||||
viewport = document.createElement('meta');
|
||||
viewport.setAttribute('name', 'viewport');
|
||||
document.getElementsByTagName('head')[0].appendChild(viewport);
|
||||
}
|
||||
|
||||
contentValue = viewport.getAttribute('content');
|
||||
if (contentValue && typeof oldMetaValue != 'undefined') {
|
||||
oldMetaValue = contentValue;
|
||||
}
|
||||
|
||||
viewport.setAttribute('content', state ? noScaleMetaValue : oldMetaValue);
|
||||
}
|
||||
|
||||
function toggleBodyFullScreenClasses(classPrefix) {
|
||||
for (var i = 0; i < windows.length; i++) {
|
||||
if (windows[i]._fullscreen) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$([document.documentElement, document.body]).removeClass(classPrefix + 'fullscreen');
|
||||
}
|
||||
|
||||
function handleWindowResize() {
|
||||
var lastSize = {
|
||||
w: window.innerWidth,
|
||||
h: window.innerHeight
|
||||
};
|
||||
|
||||
Delay.setInterval(function() {
|
||||
var w = window.innerWidth,
|
||||
h = window.innerHeight;
|
||||
|
||||
if (lastSize.w != w || lastSize.h != h) {
|
||||
lastSize = {
|
||||
w: w,
|
||||
h: h
|
||||
};
|
||||
|
||||
$(window).trigger('resize');
|
||||
}
|
||||
}, 100);
|
||||
|
||||
function reposition() {
|
||||
var i, rect = DomUtils.getWindowSize(), layoutRect;
|
||||
|
||||
for (i = 0; i < windows.length; i++) {
|
||||
layoutRect = windows[i].layoutRect();
|
||||
|
||||
windows[i].moveTo(
|
||||
windows[i].settings.x || Math.max(0, rect.w / 2 - layoutRect.w / 2),
|
||||
windows[i].settings.y || Math.max(0, rect.h / 2 - layoutRect.h / 2)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$(window).on('resize', reposition);
|
||||
}
|
||||
|
||||
var Window = FloatPanel.extend({
|
||||
modal: true,
|
||||
|
||||
Defaults: {
|
||||
border: 1,
|
||||
layout: 'flex',
|
||||
containerCls: 'panel',
|
||||
role: 'dialog',
|
||||
callbacks: {
|
||||
submit: function() {
|
||||
this.fire('submit', {data: this.toJSON()});
|
||||
},
|
||||
|
||||
close: function() {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructs a instance with the specified settings.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} settings Name/value object with settings.
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this;
|
||||
|
||||
self._super(settings);
|
||||
|
||||
if (self.isRtl()) {
|
||||
self.classes.add('rtl');
|
||||
}
|
||||
|
||||
self.classes.add('window');
|
||||
self.bodyClasses.add('window-body');
|
||||
self.state.set('fixed', true);
|
||||
|
||||
// Create statusbar
|
||||
if (settings.buttons) {
|
||||
self.statusbar = new Panel({
|
||||
layout: 'flex',
|
||||
border: '1 0 0 0',
|
||||
spacing: 3,
|
||||
padding: 10,
|
||||
align: 'center',
|
||||
pack: self.isRtl() ? 'start' : 'end',
|
||||
defaults: {
|
||||
type: 'button'
|
||||
},
|
||||
items: settings.buttons
|
||||
});
|
||||
|
||||
self.statusbar.classes.add('foot');
|
||||
self.statusbar.parent(self);
|
||||
}
|
||||
|
||||
self.on('click', function(e) {
|
||||
if (e.target.className.indexOf(self.classPrefix + 'close') != -1) {
|
||||
self.close();
|
||||
}
|
||||
});
|
||||
|
||||
self.on('cancel', function() {
|
||||
self.close();
|
||||
});
|
||||
|
||||
self.aria('describedby', self.describedBy || self._id + '-none');
|
||||
self.aria('label', settings.title);
|
||||
self._fullscreen = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Recalculates the positions of the controls in the current container.
|
||||
* This is invoked by the reflow method and shouldn't be called directly.
|
||||
*
|
||||
* @method recalc
|
||||
*/
|
||||
recalc: function() {
|
||||
var self = this, statusbar = self.statusbar, layoutRect, width, x, needsRecalc;
|
||||
|
||||
if (self._fullscreen) {
|
||||
self.layoutRect(DomUtils.getWindowSize());
|
||||
self.layoutRect().contentH = self.layoutRect().innerH;
|
||||
}
|
||||
|
||||
self._super();
|
||||
|
||||
layoutRect = self.layoutRect();
|
||||
|
||||
// Resize window based on title width
|
||||
if (self.settings.title && !self._fullscreen) {
|
||||
width = layoutRect.headerW;
|
||||
if (width > layoutRect.w) {
|
||||
x = layoutRect.x - Math.max(0, width / 2);
|
||||
self.layoutRect({w: width, x: x});
|
||||
needsRecalc = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Resize window based on statusbar width
|
||||
if (statusbar) {
|
||||
statusbar.layoutRect({w: self.layoutRect().innerW}).recalc();
|
||||
|
||||
width = statusbar.layoutRect().minW + layoutRect.deltaW;
|
||||
if (width > layoutRect.w) {
|
||||
x = layoutRect.x - Math.max(0, width - layoutRect.w);
|
||||
self.layoutRect({w: width, x: x});
|
||||
needsRecalc = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Recalc body and disable auto resize
|
||||
if (needsRecalc) {
|
||||
self.recalc();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the current controls layout rect.
|
||||
* This will be executed by the layout managers to determine the
|
||||
* default minWidth/minHeight etc.
|
||||
*
|
||||
* @method initLayoutRect
|
||||
* @return {Object} Layout rect instance.
|
||||
*/
|
||||
initLayoutRect: function() {
|
||||
var self = this, layoutRect = self._super(), deltaH = 0, headEl;
|
||||
|
||||
// Reserve vertical space for title
|
||||
if (self.settings.title && !self._fullscreen) {
|
||||
headEl = self.getEl('head');
|
||||
|
||||
var size = DomUtils.getSize(headEl);
|
||||
|
||||
layoutRect.headerW = size.width;
|
||||
layoutRect.headerH = size.height;
|
||||
|
||||
deltaH += layoutRect.headerH;
|
||||
}
|
||||
|
||||
// Reserve vertical space for statusbar
|
||||
if (self.statusbar) {
|
||||
deltaH += self.statusbar.layoutRect().h;
|
||||
}
|
||||
|
||||
layoutRect.deltaH += deltaH;
|
||||
layoutRect.minH += deltaH;
|
||||
//layoutRect.innerH -= deltaH;
|
||||
layoutRect.h += deltaH;
|
||||
|
||||
var rect = DomUtils.getWindowSize();
|
||||
|
||||
layoutRect.x = self.settings.x || Math.max(0, rect.w / 2 - layoutRect.w / 2);
|
||||
layoutRect.y = self.settings.y || Math.max(0, rect.h / 2 - layoutRect.h / 2);
|
||||
|
||||
return layoutRect;
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders the control as a HTML string.
|
||||
*
|
||||
* @method renderHtml
|
||||
* @return {String} HTML representing the control.
|
||||
*/
|
||||
renderHtml: function() {
|
||||
var self = this, layout = self._layout, id = self._id, prefix = self.classPrefix;
|
||||
var settings = self.settings, headerHtml = '', footerHtml = '', html = settings.html;
|
||||
|
||||
self.preRender();
|
||||
layout.preRender(self);
|
||||
|
||||
if (settings.title) {
|
||||
headerHtml = (
|
||||
'<div id="' + id + '-head" class="' + prefix + 'window-head">' +
|
||||
'<div id="' + id + '-title" class="' + prefix + 'title">' + self.encode(settings.title) + '</div>' +
|
||||
'<button type="button" class="' + prefix + 'close" aria-hidden="true">\u00d7</button>' +
|
||||
'<div id="' + id + '-dragh" class="' + prefix + 'dragh"></div>' +
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
|
||||
if (settings.url) {
|
||||
html = '<iframe src="' + settings.url + '" tabindex="-1"></iframe>';
|
||||
}
|
||||
|
||||
if (typeof html == "undefined") {
|
||||
html = layout.renderHtml(self);
|
||||
}
|
||||
|
||||
if (self.statusbar) {
|
||||
footerHtml = self.statusbar.renderHtml();
|
||||
}
|
||||
|
||||
return (
|
||||
'<div id="' + id + '" class="' + self.classes + '" hidefocus="1">' +
|
||||
'<div class="' + self.classPrefix + 'reset" role="application">' +
|
||||
headerHtml +
|
||||
'<div id="' + id + '-body" class="' + self.bodyClasses + '">' +
|
||||
html +
|
||||
'</div>' +
|
||||
footerHtml +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Switches the window fullscreen mode.
|
||||
*
|
||||
* @method fullscreen
|
||||
* @param {Boolean} state True/false state.
|
||||
* @return {tinymce.ui.Window} Current window instance.
|
||||
*/
|
||||
fullscreen: function(state) {
|
||||
var self = this, documentElement = document.documentElement, slowRendering, prefix = self.classPrefix, layoutRect;
|
||||
|
||||
if (state != self._fullscreen) {
|
||||
$(window).on('resize', function() {
|
||||
var time;
|
||||
|
||||
if (self._fullscreen) {
|
||||
// Time the layout time if it's to slow use a timeout to not hog the CPU
|
||||
if (!slowRendering) {
|
||||
time = new Date().getTime();
|
||||
|
||||
var rect = DomUtils.getWindowSize();
|
||||
self.moveTo(0, 0).resizeTo(rect.w, rect.h);
|
||||
|
||||
if ((new Date().getTime()) - time > 50) {
|
||||
slowRendering = true;
|
||||
}
|
||||
} else {
|
||||
if (!self._timer) {
|
||||
self._timer = Delay.setTimeout(function() {
|
||||
var rect = DomUtils.getWindowSize();
|
||||
self.moveTo(0, 0).resizeTo(rect.w, rect.h);
|
||||
|
||||
self._timer = 0;
|
||||
}, 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layoutRect = self.layoutRect();
|
||||
self._fullscreen = state;
|
||||
|
||||
if (!state) {
|
||||
self.borderBox = BoxUtils.parseBox(self.settings.border);
|
||||
self.getEl('head').style.display = '';
|
||||
layoutRect.deltaH += layoutRect.headerH;
|
||||
$([documentElement, document.body]).removeClass(prefix + 'fullscreen');
|
||||
self.classes.remove('fullscreen');
|
||||
self.moveTo(self._initial.x, self._initial.y).resizeTo(self._initial.w, self._initial.h);
|
||||
} else {
|
||||
self._initial = {x: layoutRect.x, y: layoutRect.y, w: layoutRect.w, h: layoutRect.h};
|
||||
|
||||
self.borderBox = BoxUtils.parseBox('0');
|
||||
self.getEl('head').style.display = 'none';
|
||||
layoutRect.deltaH -= layoutRect.headerH + 2;
|
||||
$([documentElement, document.body]).addClass(prefix + 'fullscreen');
|
||||
self.classes.add('fullscreen');
|
||||
|
||||
var rect = DomUtils.getWindowSize();
|
||||
self.moveTo(0, 0).resizeTo(rect.w, rect.h);
|
||||
}
|
||||
}
|
||||
|
||||
return self.reflow();
|
||||
},
|
||||
|
||||
/**
|
||||
* Called after the control has been rendered.
|
||||
*
|
||||
* @method postRender
|
||||
*/
|
||||
postRender: function() {
|
||||
var self = this, startPos;
|
||||
|
||||
setTimeout(function() {
|
||||
self.classes.add('in');
|
||||
}, 0);
|
||||
|
||||
self._super();
|
||||
|
||||
if (self.statusbar) {
|
||||
self.statusbar.postRender();
|
||||
}
|
||||
|
||||
self.focus();
|
||||
|
||||
this.dragHelper = new DragHelper(self._id + '-dragh', {
|
||||
start: function() {
|
||||
startPos = {
|
||||
x: self.layoutRect().x,
|
||||
y: self.layoutRect().y
|
||||
};
|
||||
},
|
||||
|
||||
drag: function(e) {
|
||||
self.moveTo(startPos.x + e.deltaX, startPos.y + e.deltaY);
|
||||
}
|
||||
});
|
||||
|
||||
self.on('submit', function(e) {
|
||||
if (!e.isDefaultPrevented()) {
|
||||
self.close();
|
||||
}
|
||||
});
|
||||
|
||||
windows.push(self);
|
||||
toggleFullScreenState(true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Fires a submit event with the serialized form.
|
||||
*
|
||||
* @method submit
|
||||
* @return {Object} Event arguments object.
|
||||
*/
|
||||
submit: function() {
|
||||
return this.fire('submit', {data: this.toJSON()});
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the current control from DOM and from UI collections.
|
||||
*
|
||||
* @method remove
|
||||
* @return {tinymce.ui.Control} Current control instance.
|
||||
*/
|
||||
remove: function() {
|
||||
var self = this, i;
|
||||
|
||||
self.dragHelper.destroy();
|
||||
self._super();
|
||||
|
||||
if (self.statusbar) {
|
||||
this.statusbar.remove();
|
||||
}
|
||||
|
||||
i = windows.length;
|
||||
while (i--) {
|
||||
if (windows[i] === self) {
|
||||
windows.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
toggleFullScreenState(windows.length > 0);
|
||||
toggleBodyFullScreenClasses(self.classPrefix);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the contentWindow object of the iframe if it exists.
|
||||
*
|
||||
* @method getContentWindow
|
||||
* @return {Window} window object or null.
|
||||
*/
|
||||
getContentWindow: function() {
|
||||
var ifr = this.getEl().getElementsByTagName('iframe')[0];
|
||||
return ifr ? ifr.contentWindow : null;
|
||||
}
|
||||
});
|
||||
|
||||
if (!Env.desktop) {
|
||||
handleWindowResize();
|
||||
}
|
||||
|
||||
return Window;
|
||||
});
|
||||
Reference in New Issue
Block a user