var expression = /^([\w\\*]+)?(?:#([\w\-\\]+))?(?:\.([\w\\\.]+))?(?:\[\@?([\w\\]+)([\^\$\*!~]?=)([\w\\]+)\])?(?:\:(.+))?/i;
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g;
var whiteSpace = /^\s*|\s*$/g;
var Selector = global$8.extend({
init: function (selector) {
function compileNameFilter(name) {
name = name.toLowerCase();
return name === '*' || item.type === name;
function compileIdFilter(id) {
return item._name === id;
function compileClassesFilter(classes) {
classes = classes.split('.');
if (!item.classes.contains(classes[i])) {
function compileAttrFilter(name, cmp, check) {
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) {
name = /(?:not\((.+)\))|(.+)/i.exec(name);
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;
notSelectors = parseChunks(name[1], []);
return !match(item, notSelectors);
function compile(selector, filters, direct) {
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]));
filters.pseudo = !!parts[7];
function parseChunks(selector, selectors) {
matches = chunker.exec(selector);
parseChunks(extra, selectors);
for (i = 0; i < parts.length; i++) {
selector.push(compile(parts[i], [], parts[i - 1] === '>'));
selectors.push(selector);
this._selectors = parseChunks(selector, []);
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++) {
for (si = sl - 1; si >= 0; si--) {
siblings = item.parent().items();
index = length = siblings.length;
if (siblings[index] === item) {
for (fi = 0, fl = filters.length; fi < fl; fi++) {
if (!filters[fi](item, index, length)) {
find: function (container) {
var selectors = this._selectors;
function collect(items, selector, index) {
var filters = selector[index];
for (i = 0, l = items.length; i < l; i++) {
for (fi = 0, fl = filters.length; fi < fl; fi++) {
if (!filters[fi](item, i, l)) {
if (index === selector.length - 1) {
collect(item.items(), selector, index + 1);
} else if (filters.direct) {
collect(item.items(), selector, index);
for (i = 0, l = selectors.length; i < l; i++) {
collect(container.items(), selectors[i], 0);
matches = unique(matches);
Collection = Selector.Collection;
return new Collection(matches);
var push = Array.prototype.push, slice = Array.prototype.slice;
if (!global$4.isArray(items)) {
if (items instanceof Collection$1) {
self.add(items.toArray());
for (i = self.length; i < len; i++) {
filter: function (selector) {
if (typeof selector === 'string') {
selector = new Selector(selector);
match = function (item) {
return selector.match(item);
for (i = 0, l = self.length; i < l; i++) {
return new Collection$1(matches);
return new Collection$1(slice.apply(this, arguments));
return index === -1 ? this.slice(index) : this.slice(index, +index + 1);
each: function (callback) {
global$4.each(this, callback);
return global$4.toArray(this);
indexOf: function (ctrl) {
return new Collection$1(global$4.toArray(this).reverse());
hasClass: function (cls) {
return this[0] ? this[0].classes.contains(cls) : false;
prop: function (name, value) {
if (value !== undefined) {
self.each(function (item) {
if (item && item[name]) {
var self = this, args = global$4.toArray(arguments).slice(1);
self.each(function (item) {
item[name].apply(item, args);
addClass: function (cls) {
return this.each(function (item) {
removeClass: function (cls) {
return this.each(function (item) {
item.classes.remove(cls);
global$4.each('fire on off show hide append prepend before after reflow'.split(' '), function (name) {
proto[name] = function () {
var args = global$4.toArray(arguments);
this.each(function (ctrl) {
ctrl[name].apply(ctrl, args);
global$4.each('text name disabled active selected checked visible parent value data'.split(' '), function (name) {
proto[name] = function (value) {
return this.prop(name, value);
Collection$1 = global$8.extend(proto);
Selector.Collection = Collection$1;
var Collection$2 = Collection$1;
var Binding = function (settings) {
this.create = settings.create;
Binding.create = function (model, name) {
create: function (otherModel, otherName) {
var fromSelfToOther = function (e) {
otherModel.set(otherName, e.value);
var fromOtherToSelf = function (e) {
model.set(name, e.value);
otherModel.on('change:' + otherName, fromOtherToSelf);
model.on('change:' + name, fromSelfToOther);
bindings = otherModel._bindings;
bindings = otherModel._bindings = [];
otherModel.on('destroy', function () {
bindings.push(function () {
model.off('change:' + name, fromSelfToOther);
var global$a = tinymce.util.Tools.resolve('tinymce.util.Observable');
return node.nodeType > 0;
if (a === null || b === null) {
if (typeof a !== 'object' || typeof b !== 'object') {
if (global$4.isArray(b)) {
if (a.length !== b.length) {
if (!isEqual(a[k], b[k])) {
if (isNode(a) || isNode(b)) {
if (!isEqual(a[k], b[k])) {
if (!checked[k] && !isEqual(a[k], b[k])) {
var ObservableObject = global$8.extend({
if (value instanceof Binding) {
data[name] = value.create(this, name);
set: function (name, value) {
var oldValue = this.data[name];
if (value instanceof Binding) {
value = value.create(this, name);
if (typeof name === 'object') {
this.set(key, name[key]);
if (!isEqual(oldValue, value)) {
this.fire('change:' + name, args);
this.fire('change', args);
return name in this.data;
return Binding.create(this, name);
var dirtyCtrls = {}, animationFrameRequested;
var parent = ctrl.parent();
if (!parent._layout || parent._layout.isNative()) {
if (!dirtyCtrls[parent._id]) {
dirtyCtrls[parent._id] = parent;
if (!animationFrameRequested) {
animationFrameRequested = true;
global$3.requestAnimationFrame(function () {
animationFrameRequested = false;
if (ctrl.state.get('rendered')) {
}, domGlobals.document.body);
remove: function (ctrl) {
if (dirtyCtrls[ctrl._id]) {
delete dirtyCtrls[ctrl._id];