/** * tinymce.js * * Copyright 2009, Moxiecode Systems AB * Released under LGPL License. * * License: http://tinymce.moxiecode.com/license * Contributing: http://tinymce.moxiecode.com/contributing */ (function(win) { var whiteSpaceRe = /^\s*|\s*$/g, undefined; /** * Core namespace with core functionality for the TinyMCE API all sub classes will be added to this namespace/object. * * @static * @class tinymce * @example * // Using each method * tinymce.each([1, 2, 3], function(v, i) { * console.log(i + '=' + v); * }); * * // Checking for a specific browser * if (tinymce.isIE) * console.log("IE"); */ var tinymce = { /** * Major version of TinyMCE build. * * @property majorVersion * @type String */ majorVersion : '@@tinymce_major_version@@', /** * Major version of TinyMCE build. * * @property minorVersion * @type String */ minorVersion : '@@tinymce_minor_version@@', /** * Release date of TinyMCE build. * * @property minorVersion * @type String */ releaseDate : '@@tinymce_release_date@@', /** * Initializes the TinyMCE global namespace this will setup browser detection and figure out where TinyMCE is running from. */ _init : function() { var t = this, d = document, na = navigator, ua = na.userAgent, i, nl, n, base, p, v; /** * Constant that is true if the browser is Opera. * * @property isOpera * @type Boolean * @final */ t.isOpera = win.opera && opera.buildNumber; /** * Constant that is true if the browser is WebKit (Safari/Chrome). * * @property isWebKit * @type Boolean * @final */ t.isWebKit = /WebKit/.test(ua); /** * Constant that is true if the browser is IE. * * @property isIE * @type Boolean * @final */ t.isIE = !t.isWebKit && !t.isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(na.appName); /** * Constant that is true if the browser is IE 6 or older. * * @property isIE6 * @type Boolean * @final */ t.isIE6 = t.isIE && /MSIE [56]/.test(ua); /** * Constant that is true if the browser is Gecko. * * @property isGecko * @type Boolean * @final */ t.isGecko = !t.isWebKit && /Gecko/.test(ua); /** * Constant that is true if the os is Mac OS. * * @property isMac * @type Boolean * @final */ t.isMac = ua.indexOf('Mac') != -1; /** * Constant that is true if the runtime is Adobe Air. * * @property isAir * @type Boolean * @final */ t.isAir = /adobeair/i.test(ua); /** * Constant that tells if the current browser is an iPhone or iPad. * * @property isIDevice * @type Boolean * @final */ t.isIDevice = /(iPad|iPhone)/.test(ua); // TinyMCE .NET webcontrol might be setting the values for TinyMCE if (win.tinyMCEPreInit) { t.suffix = tinyMCEPreInit.suffix; t.baseURL = tinyMCEPreInit.base; t.query = tinyMCEPreInit.query; return; } // Get suffix and base t.suffix = ''; // If base element found, add that infront of baseURL nl = d.getElementsByTagName('base'); for (i=0; i : s = /^((static) )?([\w.]+)(:([\w.]+))?/.exec(s); cn = s[3].match(/(^|\.)(\w+)$/i)[2]; // Class name // Create namespace for new class ns = t.createNS(s[3].replace(/\.\w+$/, '')); // Class already exists if (ns[cn]) return; // Make pure static class if (s[2] == 'static') { ns[cn] = p; if (this.onCreate) this.onCreate(s[2], s[3], ns[cn]); return; } // Create default constructor if (!p[cn]) { p[cn] = function() {}; de = 1; } // Add constructor and methods ns[cn] = p[cn]; t.extend(ns[cn].prototype, p); // Extend if (s[5]) { sp = t.resolve(s[5]).prototype; scn = s[5].match(/\.(\w+)$/i)[1]; // Class name // Extend constructor c = ns[cn]; if (de) { // Add passthrough constructor ns[cn] = function() { return sp[scn].apply(this, arguments); }; } else { // Add inherit constructor ns[cn] = function() { this.parent = sp[scn]; return c.apply(this, arguments); }; } ns[cn].prototype[cn] = ns[cn]; // Add super methods t.each(sp, function(f, n) { ns[cn].prototype[n] = sp[n]; }); // Add overridden methods t.each(p, function(f, n) { // Extend methods if needed if (sp[n]) { ns[cn].prototype[n] = function() { this.parent = sp[n]; return f.apply(this, arguments); }; } else { if (n != cn) ns[cn].prototype[n] = f; } }); } // Add static methods t.each(p['static'], function(f, n) { ns[cn][n] = f; }); if (this.onCreate) this.onCreate(s[2], s[3], ns[cn].prototype); }, /** * Executed the specified function for each item in a object tree. * * @method walk * @param {Object} o Object tree to walk though. * @param {function} f Function to call for each item. * @param {String} n Optional name of collection inside the objects to walk for example childNodes. * @param {String} s Optional scope to execute the function in. */ walk : function(o, f, n, s) { s = s || this; if (o) { if (n) o = o[n]; tinymce.each(o, function(o, i) { if (f.call(s, o, i, n) === false) return false; tinymce.walk(o, f, n, s); }); } }, /** * Creates a namespace on a specific object. * * @method createNS * @param {String} n Namespace to create for example a.b.c.d. * @param {Object} o Optional object to add namespace to, defaults to window. * @return {Object} New namespace object the last item in path. */ createNS : function(n, o) { var i, v; o = o || win; n = n.split('.'); for (i=0; i