function(form, url, params, options) {
        form = Ext.getDom(form);
        options = options || {};

        var id = Ext.id(),
            frame = document.createElement('iframe'),
            hiddens = [],
            encoding = 'multipart/form-data',
            buf = {
                target: form.target,
                method: form.method,
                encoding: form.encoding,
                enctype: form.enctype,
                action: form.action
            },
            addField = function(name, value) {
                hiddenItem = document.createElement('input');
                Ext.fly(hiddenItem).set({
                    type: 'hidden',
                    value: value,
                    name: name
                });
                form.appendChild(hiddenItem);
                hiddens.push(hiddenItem);
            },
            hiddenItem, obj, value, name, vLen, v, hLen, h;

        /*
         * Originally this behaviour was modified for Opera 10 to apply the secure URL after
         * the frame had been added to the document. It seems this has since been corrected in
         * Opera so the behaviour has been reverted, the URL will be set before being added.
         */
        Ext.fly(frame).set({
            id: id,
            name: id,
            cls: Ext.baseCSSPrefix + 'hide-display',
            src: Ext.SSL_SECURE_URL
        });

        document.body.appendChild(frame);

        // This is required so that IE doesn't pop the response up in a new window.
        if (document.frames) {
            document.frames[id].name = id;
        }

        Ext.fly(form).set({
            target: id,
            method: 'POST',
            enctype: encoding,
            encoding: encoding,
            action: url || buf.action
        });

        // add dynamic params
        if (params) {
            obj = Ext.Object.fromQueryString(params) || {};

            for (name in obj) {
                if (obj.hasOwnProperty(name)) {
                    value = obj[name];
                    if (Ext.isArray(value)) {
                        vLen = value.length;
                        for (v = 0; v < vLen; v++) {
                            addField(name, value[v]);
                        }
                    } else {
                        addField(name, value);
                    }
                }
            }
        }

        Ext.fly(frame).on('load', Ext.Function.bind(this.onUploadComplete, this, [frame, options]), null, {single: !Ext.isOpera});
        form.submit();

        Ext.fly(form).set(buf);

        hLen = hiddens.length;

        for (h = 0; h < hLen; h++) {
            Ext.removeNode(hiddens[h]);
        }
    }

Uploads a form using a hidden iframe.
@param {String/HTMLElement/Ext.Element} form The form to upload
@param {String} url The url to post to
@param {String} params Any extra parameters to pass
@param {Object} options The initial options


function(options) {
        var form = this.getForm(options);
        if (form) {
            return (options.isUpload || (/multipart\/form-data/i).test(form.getAttribute('enctype')));
        }
        return false;
    }

function ( options ) { var form = this . getForm ( options ) ; if ( form ) { return ( options . isUpload || ( / multipart\/form-data / i ) . test ( form . getAttribute ( 'enctype' ) ) ) ; } return false ; }

Detects whether the form is intended to be used for an upload.
@private

Detects whether the form is intended to be used for an upload .


function(options, url) {
        var form = this.getForm(options);
        if (form) {
            url = url || form.action;
        }
        return url;
    }

function ( options , url ) { var form = this . getForm ( options ) ; if ( form ) { url = url || form . action ; } return url ; }

Template method for overriding url
@template
@private
@param {Object} options
@param {String} url
@return {String} The modified url


function(options, params) {
        var form = this.getForm(options),
            serializedForm;
        if (form && !this.isFormUpload(options)) {
            serializedForm = Ext.Element.serializeForm(form);
            params = params ? (params + '&' + serializedForm) : serializedForm;
        }
        return params;
    }

function ( options , params ) { var form = this . getForm ( options ) , serializedForm ; if ( form && ! this . isFormUpload ( options ) ) { serializedForm = Ext . Element . serializeForm ( form ) ; params = params ? ( params + '&' + serializedForm ) : serializedForm ; } return params ; }

Template method for overriding params
@template
@private
@param {Object} options
@param {String} params
@return {String} The modified params


function(request) {
        if (!request) {
            request = this.getLatest();
        }
        if (!(request && request.xhr)) {
            return false;
        }
        // if there is a connection and readyState is not 0 or 4, or in case of BinaryXHR, not 4
        var state = request.xhr.readyState;
        return ((request.xhr instanceof Ext.data.flash.BinaryXhr) && state != 4) || !(state === 0 || state == 4);
    }

Determines whether this object has a request outstanding.
@param {Object} [request] Defaults to the last transaction
@return {Boolean} True if there is an outstanding request.

Determines whether this object has a request outstanding .


function(request) {
        var me = this,
            xhr;

        if (!request) {
            request = me.getLatest();
        }

        if (request && me.isLoading(request)) {
            /*
             * Clear out the onreadystatechange here, this allows us
             * greater control, the browser may/may not fire the function
             * depending on a series of conditions.
             */
            xhr = request.xhr;
            try {
                xhr.onreadystatechange = null;
            } catch (e) {
                // Setting onreadystatechange to null can cause problems in IE, see
                // http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_a_1.html
                xhr.onreadystatechange = Ext.emptyFn;
            }
            xhr.abort();
            me.clearTimeout(request);
            if (!request.timedout) {
                request.aborted = true;
            }
            me.onComplete(request);
            me.cleanup(request);
        }
    }

Aborts an active request.
@param {Object} [request] Defaults to the last request


function(){
        var requests = this.requests,
            id;

        for (id in requests) {
            if (requests.hasOwnProperty(id)) {
                this.abort(requests[id]);
            }
        }
    }

function ( ) { var requests = this . requests , id ; for ( id in requests ) { if ( requests . hasOwnProperty ( id ) ) { this . abort ( requests [ id ] ) ; } } }


function(request, xdrResult) {
        var me = this;

        // Using CORS with IE doesn't support readyState so we fake it
        if ((request.xhr && request.xhr.readyState == 4) || me.isXdr) {
            me.clearTimeout(request);
            me.onComplete(request, xdrResult);
            me.cleanup(request);
            Ext.EventManager.idleEvent.fire();
        }
    }

Fires when the state of the xhr changes
@private
@param {Object} request The request


function(request, xdrResult) {
        var me = this,
            options = request.options,
            result,
            success,
            response;

        try {
            result = me.parseStatus(request.xhr.status);
        } catch (e) {
            // in some browsers we can't access the status if the readyState is not 4, so the request has failed
            result = {
                success : false,
                isException : false
            };

        }
        success = me.isXdr ? xdrResult : result.success;

        if (success) {
            response = me.createResponse(request);
            me.fireEvent('requestcomplete', me, response, options);
            Ext.callback(options.success, options.scope, [response, options]);
        } else {
            if (result.isException || request.aborted || request.timedout) {
                response = me.createException(request);
            } else {
                response = me.createResponse(request);
            }
            me.fireEvent('requestexception', me, response, options);
            Ext.callback(options.failure, options.scope, [response, options]);
        }
        Ext.callback(options.callback, options.scope, [options, success, response]);
        delete me.requests[request.id];
        return response;
    }

To be called when the request has come back from the server
@private
@param {Object} request
@return {Object} The response


function(status) {
        // see: https://prototype.lighthouseapp.com/projects/8886/tickets/129-ie-mangles-http-response-status-code-204-to-1223
        status = status == 1223 ? 204 : status;

        var success = (status >= 200 && status < 300) || status == 304,
            isException = false;

        if (!success) {
            switch (status) {
                case 12002:
                case 12029:
                case 12030:
                case 12031:
                case 12152:
                case 13030:
                    isException = true;
                    break;
            }
        }
        return {
            success: success,
            isException: isException
        };
    }

Checks if the response status was successful
@param {Number} status The status code
@return {Object} An object containing success/status state


function(request) {
        return {
            request : request,
            requestId : request.id,
            status : request.aborted ? -1 : 0,
            statusText : request.aborted ? 'transaction aborted' : 'communication failure',
            aborted: request.aborted,
            timedout: request.timedout
        };
    }

function
(
request
)
{
return
{
request
:
request
,
requestId
:
request
.
id
,
status
:
request
.
aborted
1
:
0
,
statusText
:
request
.
aborted
'transaction aborted'
:
'communication failure'
,
aborted
:
request
.
aborted
,
timedout
:
request
.
timedout
}
;
}

Creates the exception object
@private
@param {Object} request


function() {
        var scriptTag = document.createElement('script');
        scriptTag.type = 'text/vbscript';
        scriptTag.text = [
            'Function getIEByteArray(byteArray, out)',
                'Dim len, i',
                'len = LenB(byteArray)',
                'For i = 1 to len',
                    'out.push(AscB(MidB(byteArray, i, 1)))',
                'Next',
            'End Function'
        ].join('\n');
        Ext.getHead().dom.appendChild(scriptTag);
        this.self.vbScriptInjected = true;
    }

Injects a vbscript tag containing a 'getIEByteArray' method for reading
binary data from an xhr response in IE8 and below.
@private

Injects a vbscript tag containing a getIEByteArray method for reading binary data from an xhr response in IE8 and below .


function daysInMonth(month, year) {
  switch(month) {
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
      return 31;
    case 4:
    case 6:
    case 9:
    case 11:
      return 30;
    case 2:
      var leapyear;
      if(year % 4 != 0) {
        leapyear = false;
      } else if(year % 100 != 0) {
        leapyear = true;
      } else if(year % 400 != 0) {
        leapyear = false;
      } else {
        leapyear = true;
      }
      if(leapyear) {
        return 29;
      } else {
        return 28;
      }
    default:
      throw new Error('Unknown Month');
  }
}

function
daysInMonth
(
month
,
year
)
{
switch
(
month
)
{
case
1
:
case
3
:
case
5
:
case
7
:
case
8
:
case
10
:
case
12
:
return
31
;
case
4
:
case
6
:
case
9
:
case
11
:
return
30
;
case
2
:
var
leapyear
;
if
(
year
%
4
!=
0
)
{
leapyear
=
false
;
}
else
if
(
year
%
100
!=
0
)
{
leapyear
=
true
;
}
else
if
(
year
%
400
!=
0
)
{
leapyear
=
false
;
}
else
{
leapyear
=
true
;
}
if
(
leapyear
)
{
return
29
;
}
else
{
return
28
;
}
default
:
throw
new
Error
(
'Unknown Month'
)
;
}
}

Return the number of days in a month,
taking leapyear into account.

Return the number of days in a month taking leapyear into account .


function setDefaults() {
    // sequence: generate a random 3-byte integer initial value for the sequence counter
    if (seq === undefined)
        seq = ~~(Math.random() * 0xffffff)

    // processId: 2-byte integer derived from the PID assigned by the OS
    if (pid === undefined)
        pid = process.pid % 0xffff

    // machineId: first three bytes of the md5 hash calculated from OS hostname
    if (mid === undefined)
        mid = crypto.createHash('md5')
                    .update(os.hostname())
                    .digest()
                    .slice(0, 3)
                    .readUIntBE(0, 3)

    // reset the counter
    // (if `mid` or `pid` changes then previously allocated ids in the current second are freed)
    ctr = 0

    // `unique` is the fixed-length composition of `mid` and `pid`
    unique = pad(mid, 6, 16) + pad(pid, 4, 16)

    // calculate the initial sequence prefix
    seqpref = pad(~~(seq / 16), 5, 16)
}


function getTimestamp() {
    // use `Math.floor()` here to avoid the "Unix Millennium Bug"
    var now = Math.floor(Date.now() / 1000)

    // it's another second since the last id were created,
    // so we need to regenerate the timestamp
    if (time !== now) {
        ctr       = 0
        timestamp = pad(time = now, 8, 16)
    }
    // Since changing parts of an identifier are the timestamp and
    // the sequence; the count of maximum allocatable ids in a second
    // is limited by the sequence size (3-bytes = about 16 million).
    // Otherwise uniqueness is not guaranteed.
    else
        assert(++ctr < 0x1000000, 'more than 16 million ids generated in 1 second')

    return timestamp
}

Calculate the current timestamp if needed,
otherwise return the last cached one.

@return {string}

Calculate the current timestamp if needed otherwise return the last cached one .


function getSequence() {
    var mod = ++seq % 16

    // reset counter
    if (seq > 0xffffff)
        seq = mod = 0

    // If counter is divisible by 16 then
    // the sequence prefix should be regenerated.
    // Otherwise only the last digit changed,
    // so we don't need to update the prefix.
    if (!mod)
        seqpref = pad(~~(seq / 16), 5, 16)

    return seqpref + digits[ mod ]
}

Increase or reset sequence counter and recalculate prefix when needed.

@return {string}

Increase or reset sequence counter and recalculate prefix when needed .


function assertRange(name, val, max) {
    assert.equal(typeof val, 'number', name + ' must be a number')
    assert(!isNaN(val), 'number', name + ' must be a number')

    if (val > max)
        throw new RangeError(name + ' must be lower than ' + max + ', but is ' + val)
    else if (val < 0)
        throw new RangeError(name + ' must be greater than or equal to zero, but is ' + val)
    else if (val % 1)
        throw new RangeError(name + ' must be an integer')
}

Assert a configurable value.

@param {string} name
@param {number} val
@param {number} max


function proceedToFetch(loader, load, p) {
      proceedToTranslate(loader, load,
        p
        // 15.2.4.4.1 CallFetch
        .then(function(address) {
          if (load.linkSets.length == 0)
            return;
          load.address = address;

          return loader.loaderObj.fetch({ name: load.name, metadata: load.metadata, address: address });
        })
      );
    }

function
proceedToFetch
(
loader
,
load
,
p
)
{
proceedToTranslate
(
loader
,
load
,
p
// 15.2.4.4.1 CallFetch
.
then
(
function
(
address
)
{
if
(
load
.
linkSets
.
length
==
0
)
return
;
load
.
address
=
address
;
return
loader
.
loaderObj
.
fetch
(
{
name
:
load
.
name
,
metadata
:
load
.
metadata
,
address
:
address
}
)
;
}
)
)
;
}


function asyncStartLoadPartwayThrough(stepState) {
      return function(resolve, reject) {
        var loader = stepState.loader;
        var name = stepState.moduleName;
        var step = stepState.step;

        if (loader.modules[name])
          throw new TypeError('"' + name + '" already exists in the module table');

        // NB this still seems wrong for LoadModule as we may load a dependency
        // of another module directly before it has finished loading.
        for (var i = 0, l = loader.loads.length; i < l; i++)
          if (loader.loads[i].name == name)
            throw new TypeError('"' + name + '" already loading');

        var load = createLoad(name);

        load.metadata = stepState.moduleMetadata;

        var linkSet = createLinkSet(loader, load);

        loader.loads.push(load);

        resolve(linkSet.done);

        if (step == 'locate')
          proceedToLocate(loader, load);

        else if (step == 'fetch')
          proceedToFetch(loader, load, Promise.resolve(stepState.moduleAddress));

        else {
          console.assert(step == 'translate', 'translate step');
          load.address = stepState.moduleAddress;
          proceedToTranslate(loader, load, Promise.resolve(stepState.moduleSource));
        }
      }
    }

15.2.4.7 PromiseOfStartLoadPartwayThrough absorbed into calling functions 15.2.4.7.1


function updateLinkSetOnLoad(linkSet, load) {
      console.assert(load.status == 'loaded' || load.status == 'linked', 'loaded or linked');

      // console.log('update linkset on load ' + load.name);
      // snapshot(linkSet.loader);

      linkSet.loadingCount--;

      if (linkSet.loadingCount > 0)
        return;

      var startingLoad = linkSet.loads[0];
      try {
        link(linkSet);
      }
      catch(exc) {
        return linkSetFailed(linkSet, exc);
      }

      console.assert(linkSet.loads.length == 0, 'loads cleared');

      linkSet.resolve(startingLoad);
    }


function finishLoad(loader, load) {
      // if not anonymous, add to the module table
      if (load.name) {
        console.assert(!loader.modules[load.name], 'load not in module table');
        loader.modules[load.name] = load.module;
      }
      var loadIndex = indexOf.call(loader.loads, load);
      if (loadIndex != -1)
        loader.loads.splice(loadIndex, 1);
      for (var i = 0, l = load.linkSets.length; i < l; i++) {
        loadIndex = indexOf.call(load.linkSets[i].loads, load);
        if (loadIndex != -1)
          load.linkSets[i].loads.splice(loadIndex, 1);
      }
      load.linkSets.splice(0, load.linkSets.length);
    }


function link(linkSet) {

      var loader = linkSet.loader;

      // console.log('linking {' + logloads(loads) + '}');
      // snapshot(loader);

      // 15.2.5.3.1 LinkageGroups alternative implementation

      // build all the groups
      // because the first load represents the top of the tree
      // for a given linkset, we can work down from there
      var groups = [];
      var startingLoad = linkSet.loads[0];
      startingLoad.groupIndex = 0;
      buildLinkageGroups(startingLoad, linkSet.loads, groups, loader);

      // determine the kind of the bottom group
      var curGroupDeclarative = (startingLoad.kind == 'declarative') == groups.length % 2;

      // run through the groups from bottom to top
      for (var i = groups.length - 1; i >= 0; i--) {
        var group = groups[i];
        for (var j = 0; j < group.length; j++) {
          var load = group[j];

          // 15.2.5.5 LinkDeclarativeModules adjusted
          if (curGroupDeclarative) {
            linkDeclarativeModule(load, linkSet.loads, loader);
          }
          // 15.2.5.6 LinkDynamicModules adjusted
          else {
            var module = load.execute();
            if (!(module.__esModule))
              throw new TypeError('Execution must define a Module instance');
            load.module = {
              module: module
            };
            load.status = 'linked';
          }
          finishLoad(loader, load);
        }

        // alternative current kind for next loop
        curGroupDeclarative = !curGroupDeclarative;
      }
    }


function linkDeclarativeModule(load, loads, loader) {
      // only link if already not already started linking (stops at circular)
      if (load.module)
        return;

      // declare the module with an empty depMap
      var depMap = [];
      var sys = __global.System;
      __global.System = loader;
      var registryEntry = load.declare.call(__global, depMap);

      __global.System = sys;

      var moduleDependencies = [];

      // module is just a plain object, until we evaluate it
      var module = registryEntry.exports;

      console.assert(!load.module, 'Load module already declared!');

      load.module = {
        name: load.name,
        dependencies: moduleDependencies,
        execute: registryEntry.execute,
        exports: module,
        evaluated: false
      };

      // now link all the module dependencies
      // amending the depMap as we go
      for (var i = 0; i < load.dependencies.length; i++) {
        var depName = load.dependencies[i].value;
        var depModule;
        // if dependency already a module, use that
        if (loader.modules[depName]) {
          depModule = loader.modules[depName];
        }
        // otherwise we need to link the dependency
        else {
          for (var j = 0; j < loads.length; j++) {
            if (loads[j].name != depName)
              continue;

            linkDeclarativeModule(loads[j], loads, loader);

            depModule = loads[j].exports || loads[j].module;
          }
        }

        console.assert(depModule, 'Dependency module not found!');
        console.assert(depModule.exports, 'Dependency module not found!');

        if (registryEntry.exportStar && indexOf.call(registryEntry.exportStar, load.dependencies[i].key) != -1) {
          // we are exporting * from this dependency
          (function(depModuleModule) {
            for (var p in depModuleModule) (function(p) {
              // if the property is already defined throw?
              defineProperty(module, p, {
                enumerable: true,
                get: function() {
                  return depModuleModule[p];
                },
                set: function(value) {
                  depModuleModule[p] = value;
                }
              });
            })(p);
          })(depModule.exports);
        }

        moduleDependencies.push(depModule);
        depMap[i] = depModule.exports;
      }

      load.status = 'linked';
    }


function() {
        var me = this,
            view = me.view;

        view.on({
            scope: me,
            groupclick: me.onGroupClick
        });

        if (me.enableGroupingMenu) {
            me.injectGroupingMenu();
        }

        me.pruneGroupedHeader();

        me.lastGroupField = me.getGroupField();
        me.block();
        me.onGroupChange();
        me.unblock();
    }

function ( ) { var me = this , view = me . view ; view . on ( { scope : me , groupclick : me . onGroupClick } ) ; if ( me . enableGroupingMenu ) { me . injectGroupingMenu ( ) ; } me . pruneGroupedHeader ( ) ; me . lastGroupField = me . getGroupField ( ) ; me . block ( ) ; me . onGroupChange ( ) ; me . unblock ( ) ; }


function(menuItem, e) {
        var me = this,
            menu = menuItem.parentMenu,
            hdr  = menu.activeHeader,
            view = me.view,
            store = view.store;

        delete me.lastGroupIndex;
        me.block();
        me.enable();
        store.group(hdr.dataIndex);
        me.pruneGroupedHeader();
        me.unblock();
        me.refreshIf();
    }

function ( menuItem , e ) { var me = this , menu = menuItem . parentMenu , hdr = menu . activeHeader , view = me . view , store = view . store ; delete me . lastGroupIndex ; me . block ( ) ; me . enable ( ) ; store . group ( hdr . dataIndex ) ; me . pruneGroupedHeader ( ) ; me . unblock ( ) ; me . refreshIf ( ) ; }

Group by the header the user has clicked on.
@private

Group by the header the user has clicked on .


function() {
        var me = this,
            header = me.getGroupedHeader();

        if (me.hideGroupedHeader && header) {
            Ext.suspendLayouts();
            if (me.prunedHeader && me.prunedHeader !== header) {
                me.prunedHeader.show();
            }
            me.prunedHeader = header;
            header.hide();
            Ext.resumeLayouts(true);
        }
    }

function ( ) { var me = this , header = me . getGroupedHeader ( ) ; if ( me . hideGroupedHeader && header ) { Ext . suspendLayouts ( ) ; if ( me . prunedHeader && me . prunedHeader !== header ) { me . prunedHeader . show ( ) ; } me . prunedHeader = header ; header . hide ( ) ; Ext . resumeLayouts ( true ) ; } }

Prunes the grouped header from the header container
@private


function(dataIndex){
        var view = this.view,
            header = view.headerCt.down('gridcolumn[dataIndex=' + dataIndex + ']'),
            menu = view.headerCt.getMenu();

        return header ? menu.down('menuitem[headerId='+ header.id +']') : null;
    }

function ( dataIndex ) { var view = this . view , header = view . headerCt . down ( 'gridcolumn[dataIndex=' + dataIndex + ']' ) , menu = view . headerCt . getMenu ( ) ; return header ? menu . down ( 'menuitem[headerId=' + header . id + ']' ) : null ; }

Gets the related menu item for a dataIndex
@private
@return {Ext.grid.header.Container} The header


function process(o, force_rich) {
				var dom = ed.dom, rng;

				// Execute pre process handlers
				t.onPreProcess.dispatch(t, o);

				// Create DOM structure
				o.node = dom.create('div', 0, o.content);

				// If pasting inside the same element and the contents is only one block
				// remove the block and keep the text since Firefox will copy parts of pre and h1-h6 as a pre element
				if (tinymce.isGecko) {
					rng = ed.selection.getRng(true);
					if (rng.startContainer == rng.endContainer && rng.startContainer.nodeType == 3) {
						// Is only one block node and it doesn't contain word stuff
						if (o.node.childNodes.length === 1 && /^(p|h[1-6]|pre)$/i.test(o.node.firstChild.nodeName) && o.content.indexOf('__MCE_ITEM__') === -1)
							dom.remove(o.node.firstChild, true);
					}
				}

				// Execute post process handlers
				t.onPostProcess.dispatch(t, o);

				// Serialize content
				o.content = ed.serializer.serialize(o.node, {getInner : 1, forced_root_block : ''});

				// Plain text option active?
				if ((!force_rich) && (ed.pasteAsPlainText)) {
					t._insertPlainText(o.content);

					if (!getParam(ed, "paste_text_sticky")) {
						ed.pasteAsPlainText = false;
						ed.controlManager.setActive("pastetext", false);
					}
				} else {
					t._insert(o.content);
				}
			}

This function executes the process handlers and inserts the contents force_rich overrides plain text mode set by user, important for pasting with execCommand

This function executes the process handlers and inserts the contents force_rich overrides plain text mode set by user important for pasting with execCommand


function grabContent(e) {
				var n, or, rng, oldRng, sel = ed.selection, dom = ed.dom, body = ed.getBody(), posY, textContent;

				// Check if browser supports direct plaintext access
				if (e.clipboardData || dom.doc.dataTransfer) {
					textContent = (e.clipboardData || dom.doc.dataTransfer).getData('Text');

					if (ed.pasteAsPlainText) {
						e.preventDefault();
						process({content : dom.encode(textContent).replace(/\r?\n/g, '
')});
						return;
					}
				}

				if (dom.get('_mcePaste'))
					return;

				// Create container to paste into
				n = dom.add(body, 'div', {id : '_mcePaste', 'class' : 'mcePaste', 'data-mce-bogus' : '1'}, '\uFEFF\uFEFF');

				// If contentEditable mode we need to find out the position of the closest element
				if (body != ed.getDoc().body)
					posY = dom.getPos(ed.selection.getStart(), body).y;
				else
					posY = body.scrollTop + dom.getViewPort(ed.getWin()).y;

				// Styles needs to be applied after the element is added to the document since WebKit will otherwise remove all styles
				// If also needs to be in view on IE or the paste would fail
				dom.setStyles(n, {
					position : 'absolute',
					left : tinymce.isGecko ? -40 : 0, // Need to move it out of site on Gecko since it will othewise display a ghost resize rect for the div
					top : posY - 25,
					width : 1,
					height : 1,
					overflow : 'hidden'
				});

				if (tinymce.isIE) {
					// Store away the old range
					oldRng = sel.getRng();

					// Select the container
					rng = dom.doc.body.createTextRange();
					rng.moveToElementText(n);
					rng.execCommand('Paste');

					// Remove container
					dom.remove(n);

					// Check if the contents was changed, if it wasn't then clipboard extraction failed probably due
					// to IE security settings so we pass the junk though better than nothing right
					if (n.innerHTML === '\uFEFF\uFEFF') {
						ed.execCommand('mcePasteWord');
						e.preventDefault();
						return;
					}

					// Restore the old range and clear the contents before pasting
					sel.setRng(oldRng);
					sel.setContent('');

					// For some odd reason we need to detach the the mceInsertContent call from the paste event
					// It's like IE has a reference to the parent element that you paste in and the selection gets messed up
					// when it tries to restore the selection
					setTimeout(function() {
						// Process contents
						process({content : n.innerHTML});
					}, 0);

					// Block the real paste event
					return tinymce.dom.Event.cancel(e);
				} else {
					function block(e) {
						e.preventDefault();
					};

					// Block mousedown and click to prevent selection change
					dom.bind(ed.getDoc(), 'mousedown', block);
					dom.bind(ed.getDoc(), 'keydown', block);

					or = ed.selection.getRng();

					// Move select contents inside DIV
					n = n.firstChild;
					rng = ed.getDoc().createRange();
					rng.setStart(n, 0);
					rng.setEnd(n, 2);
					sel.setRng(rng);

					// Wait a while and grab the pasted contents
					window.setTimeout(function() {
						var h = '', nl;

						// Paste divs duplicated in paste divs seems to happen when you paste plain text so lets first look for that broken behavior in WebKit
						if (!dom.select('div.mcePaste > div.mcePaste').length) {
							nl = dom.select('div.mcePaste');

							// WebKit will split the div into multiple ones so this will loop through then all and join them to get the whole HTML string
							each(nl, function(n) {
								var child = n.firstChild;

								// WebKit inserts a DIV container with lots of odd styles
								if (child && child.nodeName == 'DIV' && child.style.marginTop && child.style.backgroundColor) {
									dom.remove(child, 1);
								}

								// Remove apply style spans
								each(dom.select('span.Apple-style-span', n), function(n) {
									dom.remove(n, 1);
								});

								// Remove bogus br elements
								each(dom.select('br[data-mce-bogus]', n), function(n) {
									dom.remove(n);
								});

								// WebKit will make a copy of the DIV for each line of plain text pasted and insert them into the DIV
								if (n.parentNode.className != 'mcePaste')
									h += n.innerHTML;
							});
						} else {
							// Found WebKit weirdness so force the content into paragraphs this seems to happen when you paste plain text from Nodepad etc
							// So this logic will replace double enter with paragraphs and single enter with br so it kind of looks the same
							h = '
' + dom.encode(textContent).replace(/\r?\n\r?\n/g, '

').replace(/\r?\n/g, '
') + '
';
						}

						// Remove the nodes
						each(dom.select('div.mcePaste'), function(n) {
							dom.remove(n);
						});

						// Restore the old selection
						if (or)
							sel.setRng(or);

						process({content : h});

						// Unblock events ones we got the contents
						dom.unbind(ed.getDoc(), 'mousedown', block);
						dom.unbind(ed.getDoc(), 'keydown', block);
					}, 0);
				}
			}

This function grabs the contents from the clipboard by adding a hidden div and placing the caret inside it and after the browser paste is done it grabs that contents and processes that


function(pl, o) {
			var t = this, ed = t.editor, dom = ed.dom, styleProps;

			if (ed.settings.paste_enable_default_filters == false) {
				return;
			}

			if (o.wordContent) {
				// Remove named anchors or TOC links
				each(dom.select('a', o.node), function(a) {
					if (!a.href || a.href.indexOf('#_Toc') != -1)
						dom.remove(a, 1);
				});

				if (getParam(ed, "paste_convert_middot_lists")) {
					t._convertLists(pl, o);
				}

				// Process styles
				styleProps = getParam(ed, "paste_retain_style_properties"); // retained properties

				// Process only if a string was specified and not equal to "all" or "*"
				if ((tinymce.is(styleProps, "string")) && (styleProps !== "all") && (styleProps !== "*")) {
					styleProps = tinymce.explode(styleProps.replace(/^none$/i, ""));

					// Retains some style properties
					each(dom.select('*', o.node), function(el) {
						var newStyle = {}, npc = 0, i, sp, sv;

						// Store a subset of the existing styles
						if (styleProps) {
							for (i = 0; i < styleProps.length; i++) {
								sp = styleProps[i];
								sv = dom.getStyle(el, sp);

								if (sv) {
									newStyle[sp] = sv;
									npc++;
								}
							}
						}

						// Remove all of the existing styles
						dom.setAttrib(el, 'style', '');

						if (styleProps && npc > 0)
							dom.setStyles(el, newStyle); // Add back the stored subset of styles
						else // Remove empty span tags that do not have class attributes
							if (el.nodeName == 'SPAN' && !el.className)
								dom.remove(el, true);
					});
				}
			}

			// Remove all style information or only specifically on WebKit to avoid the style bug on that browser
			if (getParam(ed, "paste_remove_styles") || (getParam(ed, "paste_remove_styles_if_webkit") && tinymce.isWebKit)) {
				each(dom.select('*[style]', o.node), function(el) {
					el.removeAttribute('style');
					el.removeAttribute('data-mce-style');
				});
			} else {
				if (tinymce.isWebKit) {
					// We need to compress the styles on WebKit since if you paste  it will become
					// Removing the mce_style that contains the real value will force the Serializer engine to compress the styles
					each(dom.select('*', o.node), function(el) {
						el.removeAttribute('data-mce-style');
					});
				}
			}
		}


function(h, skip_undo) {
			var ed = this.editor, r = ed.selection.getRng();

			// First delete the contents seems to work better on WebKit when the selection spans multiple list items or multiple table cells.
			if (!ed.selection.isCollapsed() && r.startContainer != r.endContainer)
				ed.getDoc().execCommand('Delete', false, null);

			ed.execCommand('mceInsertContent', false, h, {skip_undo : skip_undo});
		}

Inserts the specified contents at the caret position.

Inserts the specified contents at the caret position .


function() {
			var t = this, ed = t.editor;

			// Register command(s) for backwards compatibility
			ed.addCommand("mcePasteWord", function() {
				ed.windowManager.open({
					file: t.url + "/pasteword.htm",
					width: parseInt(getParam(ed, "paste_dialog_width")),
					height: parseInt(getParam(ed, "paste_dialog_height")),
					inline: 1
				});
			});

			if (getParam(ed, "paste_text_use_dialog")) {
				ed.addCommand("mcePasteText", function() {
					ed.windowManager.open({
						file : t.url + "/pastetext.htm",
						width: parseInt(getParam(ed, "paste_dialog_width")),
						height: parseInt(getParam(ed, "paste_dialog_height")),
						inline : 1
					});
				});
			}

			// Register button for backwards compatibility
			ed.addButton("pasteword", {title : "paste.paste_word_desc", cmd : "mcePasteWord"});
		}

This method will open the old style paste dialogs. Some users might want the old behavior but still use the new cleanup engine.

This method will open the old style paste dialogs . Some users might want the old behavior but still use the new cleanup engine .


function manager(map, key) {
  if (!(key instanceof Object)) {
    throw new TypeError('Key must be an object')
  }

  let contents = map.get(key)

  if (!contents) {
    map.set(key, contents = {})
  }

  return contents
}

function
manager
(
map
,
key
)
{
if
(
!
(
key
instanceof
Object
)
)
{
throw
new
TypeError
(
'Key must be an object'
)
}
let
contents
=
map
.
get
(
key
)
if
(
!
contents
)
{
map
.
set
(
key
,
contents
=
{
}
)
}
return
contents
}

Local scope manager

Use this function to assign private properties related to your objects / class instances.

@param   {WeakMap} map     The WeakMap to which the private scope objects should be saved.
You should not provide this parameter - it is bound automatically for
you. Just use the key below.
@param   {Object}  key     The key with which to associate this scope
@return  {Object}          Object which can be used to assign properties to


function end() {
        var transformed;
        if (ignore.some(minimatch.bind(null, file))) {
            var compiled = coffee.compile(data, {
                sourceMap: true,
                generatedFile: file,
                inline: true,
                bare: options.bare,
                literate: isLiterate(file)
            });
            transformed = compiled.js;
        }
        else {
            var instrumented = instrumentor.instrumentCoffee(file, data);
            var js = options.noInit ? instrumented.js : instrumented.init + instrumented.js;
            transformed = js;
        }
        this.queue(transformed);
        this.queue(null);
    }

function end ( ) { var transformed ; if ( ignore . some ( minimatch . bind ( null , file ) ) ) { var compiled = coffee . compile ( data , { sourceMap : true , generatedFile : file , inline : true , bare : options . bare , literate : isLiterate ( file ) } ) ; transformed = compiled . js ; } else { var instrumented = instrumentor . instrumentCoffee ( file , data ) ; var js = options . noInit ? instrumented . js : instrumented . init + instrumented . js ; transformed = js ; } this . queue ( transformed ) ; this . queue ( null ) ; }

If in the list of ignored paths, don't instrument, just coffeeify. We do this here instead of in
coffee-coverage, as coffee-coverage works on the file system. Since we are getting piped the files,
we bypass coffee-coverage's filesystem code.

else instrument and coffeeify (which is done by coffee-coverage)

If in the list of ignored paths don t instrument just coffeeify . We do this here instead of in coffee - coverage as coffee - coverage works on the file system . Since we are getting piped the files we bypass coffee - coverage s filesystem code .


function(view, initial){
        var me = this,
            checkbox = me.injectCheckbox,
            headerCt = view.headerCt;

        // Preserve behaviour of false, but not clear why that would ever be done.
        if (checkbox !== false) {
            if (checkbox == 'first') {
                checkbox = 0;
            } else if (checkbox == 'last') {
                checkbox = headerCt.getColumnCount();
            }
            Ext.suspendLayouts();
            if (view.getStore().buffered) {
                me.showHeaderCheckbox = false;
            }
            headerCt.add(checkbox,  me.getHeaderConfig());
            Ext.resumeLayouts();
        }

        if (initial !== true) {
            view.refresh();
        }
    }

Add the header checkbox to the header row
@private
@param {Boolean} initial True if we're binding for the first time.


function(isChecked) {
        var view     = this.views[0],
            headerCt = view.headerCt,
            checkHd  = headerCt.child('gridcolumn[isCheckerHd]'),
            cls = this.checkerOnCls;

        if (checkHd) {
            if (isChecked) {
                checkHd.addCls(cls);
            } else {
                checkHd.removeCls(cls);
            }
        }
    }

function ( isChecked ) { var view = this . views [ 0 ] , headerCt = view . headerCt , checkHd = headerCt . child ( 'gridcolumn[isCheckerHd]' ) , cls = this . checkerOnCls ; if ( checkHd ) { if ( isChecked ) { checkHd . addCls ( cls ) ; } else { checkHd . removeCls ( cls ) ; } } }

Toggle the ui header between checked and unchecked state.
@param {Boolean} isChecked
@private

Toggle the ui header between checked and unchecked state .


function(headerCt, header, e) {
        if (header.isCheckerHd) {
            e.stopEvent();
            var me = this,
                isChecked = header.el.hasCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');

            // Prevent focus changes on the view, since we're selecting/deselecting all records
            me.preventFocus = true;
            if (isChecked) {
                me.deselectAll();
            } else {
                me.selectAll();
            }
            delete me.preventFocus;
        }
    }

Toggle between selecting all and deselecting all when clicking on
a checkbox header.

Toggle between selecting all and deselecting all when clicking on a checkbox header .


function() {
        var me = this,
            showCheck = me.showHeaderCheckbox !== false;

        return {
            isCheckerHd: showCheck,
            text : ' ',
            width: me.headerWidth,
            sortable: false,
            draggable: false,
            resizable: false,
            hideable: false,
            menuDisabled: true,
            dataIndex: '',
            cls: showCheck ? Ext.baseCSSPrefix + 'column-header-checkbox ' : '',
            renderer: Ext.Function.bind(me.renderer, me),
            editRenderer: me.editRenderer || me.renderEmpty,
            locked: me.hasLockedHeader()
        };
    }

function
(
)
{
var
me
=
this
,
showCheck
=
me
.
showHeaderCheckbox
!==
false
;
return
{
isCheckerHd
:
showCheck
,
text
:
' '
,
width
:
me
.
headerWidth
,
sortable
:
false
,
draggable
:
false
,
resizable
:
false
,
hideable
:
false
,
menuDisabled
:
true
,
dataIndex
:
''
,
cls
:
showCheck
Ext
.
baseCSSPrefix
+
'column-header-checkbox '
:
''
,
renderer
:
Ext
.
Function
.
bind
(
me
.
renderer
,
me
)
,
editRenderer
:
me
.
editRenderer
||
me
.
renderEmpty
,
locked
:
me
.
hasLockedHeader
(
)
}
;
}

Retrieve a configuration to be used in a HeaderContainer.
This should be used when injectCheckbox is set to false.

Retrieve a configuration to be used in a HeaderContainer . This should be used when injectCheckbox is set to false .


function(list) {
        var store = list.getStore();

        return Ext.Array.sort(list.getSelectionModel().getSelection(), function(a, b) {
            a = store.indexOf(a);
            b = store.indexOf(b);

            if (a < b) {
                return -1;
            } else if (a > b) {
                return 1;
            }
            return 0;
        });
    }

function ( list ) { var store = list . getStore ( ) ; return Ext . Array . sort ( list . getSelectionModel ( ) . getSelection ( ) , function ( a , b ) { a = store . indexOf ( a ) ; b = store . indexOf ( b ) ; if ( a < b ) { return - 1 ; } else if ( a > b ) { return 1 ; } return 0 ; } ) ; }

Get the selected records from the specified list.

Records will be returned *in store order*, not in order of selection.
@param {Ext.view.BoundList} list The list to read selections from.
@return {Ext.data.Model[]} The selected records in store order.

Get the selected records from the specified list .


function() {
        var me = this;
        me.mixins.field.setValue.call(me, me.setupValue(me.toField.store.getRange()));
    }

function ( ) { var me = this ; me . mixins . field . setValue . call ( me , me . setupValue ( me . toField . store . getRange ( ) ) ) ; }

Synchronizes the submit value with the current state of the toStore


function () {
        var me = this, cfg = {
            app: me,
            taskbarConfig: me.getTaskbarConfig()
        };

        Ext.apply(cfg, me.desktopConfig);
        return cfg;
    }

function ( ) { var me = this , cfg = { app : me , taskbarConfig : me . getTaskbarConfig ( ) } ; Ext . apply ( cfg , me . desktopConfig ) ; return cfg ; }

This method returns the configuration object for the Desktop object. A derived
class can override this method, call the base version to build the config and
then modify the returned object before returning it.

This method returns the configuration object for the Desktop object . A derived class can override this method call the base version to build the config and then modify the returned object before returning it .


function () {
        var me = this,
            cfg = {
                app: me,
                menu: []
            },
            launcher;

        Ext.apply(cfg, me.startConfig);

        Ext.each(me.modules, function (module) {
            launcher = module.launcher;
            if (launcher) {
                launcher.handler = launcher.handler || Ext.bind(me.createWindow, me, [module]);
                cfg.menu.push(module.launcher);
            }
        });

        return cfg;
    }

function ( ) { var me = this , cfg = { app : me , menu : [ ] } , launcher ; Ext . apply ( cfg , me . startConfig ) ; Ext . each ( me . modules , function ( module ) { launcher = module . launcher ; if ( launcher ) { launcher . handler = launcher . handler || Ext . bind ( me . createWindow , me , [ module ] ) ; cfg . menu . push ( module . launcher ) ; } } ) ; return cfg ; }

This method returns the configuration object for the Start Button. A derived
class can override this method, call the base version to build the config and
then modify the returned object before returning it.

This method returns the configuration object for the Start Button . A derived class can override this method call the base version to build the config and then modify the returned object before returning it .


function () {
        var me = this, cfg = {
            app: me,
            startConfig: me.getStartConfig()
        };

        Ext.apply(cfg, me.taskbarConfig);
        return cfg;
    }

function ( ) { var me = this , cfg = { app : me , startConfig : me . getStartConfig ( ) } ; Ext . apply ( cfg , me . taskbarConfig ) ; return cfg ; }

This method returns the configuration object for the TaskBar. A derived class
can override this method, call the base version to build the config and then
modify the returned object before returning it.

This method returns the configuration object for the TaskBar . A derived class can override this method call the base version to build the config and then modify the returned object before returning it .


function(id, lastEditId, readyCb){
					//console.log('adding view task: ' + id + ' ' + lastEditId + ' ' + new Error().stack)
					addViewTasks.push({id: id, lastEditId: lastEditId, cb: readyCb})
					if(!hasViews){
						poll()
					}
					hasViews = true
				}

changes before lastEditId will already be known to the client


function(array, fn, scope, reverse) {
            array = ExtArray.from(array);

            var i,
                ln = array.length;

            if (reverse !== true) {
                for (i = 0; i < ln; i++) {
                    if (fn.call(scope || array[i], array[i], i, array) === false) {
                        return i;
                    }
                }
            }
            else {
                for (i = ln - 1; i > -1; i--) {
                    if (fn.call(scope || array[i], array[i], i, array) === false) {
                        return i;
                    }
                }
            }

            return true;
        }

function ( array , fn , scope , reverse ) { array = ExtArray . from ( array ) ; var i , ln = array . length ; if ( reverse !== true ) { for ( i = 0 ; i < ln ; i ++ ) { if ( fn . call ( scope || array [ i ] , array [ i ] , i , array ) === false ) { return i ; } } } else { for ( i = ln - 1 ; i > - 1 ; i -- ) { if ( fn . call ( scope || array [ i ] , array [ i ] , i , array ) === false ) { return i ; } } } return true ; }

Iterates an array or an iterable value and invoke the given callback function for each item.

var countries = ['Vietnam', 'Singapore', 'United States', 'Russia'];

Ext.Array.each(countries, function(name, index, countriesItSelf) {
console.log(name);
});

var sum = function() {
var sum = 0;

Ext.Array.each(arguments, function(value) {
sum += value;
});

return sum;
};

sum(1, 2, 3); // returns 6

The iteration can be stopped by returning false in the function callback.

Ext.Array.each(countries, function(name, index, countriesItSelf) {
if (name === 'Singapore') {
return false; // break here
}
});

{@link Ext#each Ext.each} is alias for {@link Ext.Array#each Ext.Array.each}

@param {Array/NodeList/Object} iterable The value to be iterated. If this
argument is not iterable, the callback function is called once.
@param {Function} fn The callback function. If it returns false, the iteration stops and this method returns
the current `index`.
@param {Object} fn.item The item at the current `index` in the passed `array`
@param {Number} fn.index The current `index` within the `array`
@param {Array} fn.allItems The `array` itself which was passed as the first argument
@param {Boolean} fn.return Return false to stop iteration.
@param {Object} scope (Optional) The scope (`this` reference) in which the specified function is executed.
@param {Boolean} reverse (Optional) Reverse the iteration order (loop from the end to the beginning)
Defaults false
@return {Boolean} See description for the `fn` parameter.

Iterates an array or an iterable value and invoke the given callback function for each item .


function(array) {
            var clone = [],
                i = 0,
                ln = array.length,
                item;

            for (; i < ln; i++) {
                item = array[i];

                if (ExtArray.indexOf(clone, item) === -1) {
                    clone.push(item);
                }
            }

            return clone;
        }

function ( array ) { var clone = [ ] , i = 0 , ln = array . length , item ; for ( ; i < ln ; i ++ ) { item = array [ i ] ; if ( ExtArray . indexOf ( clone , item ) === - 1 ) { clone . push ( item ) ; } } return clone ; }

Returns a new array with unique items

@param {Array} array
@return {Array} results


function(array, fn, scope) {
            var i = 0,
                len = array.length;

            for (; i < len; i++) {
                if (fn.call(scope || array, array[i], i)) {
                    return array[i];
                }
            }
            return null;
        }

function ( array , fn , scope ) { var i = 0 , len = array . length ; for ( ; i < len ; i ++ ) { if ( fn . call ( scope || array , array [ i ] , i ) ) { return array [ i ] ; } } return null ; }

Returns the first item in the array which elicits a true return value from the
passed selection function.
@param {Array} array The array to search
@param {Function} fn The selection function to execute for each item.
@param {Mixed} fn.item The array item.
@param {String} fn.index The index of the array item.
@param {Object} scope (optional) The scope (this reference) in which the
function is executed. Defaults to the array
@return {Object} The first item in the array which returned true from the selection
function, or null if none was found.

Returns the first item in the array which elicits a true return value from the passed selection function .


function(array, item) {
            var index = ExtArray.indexOf(array, item);

            if (index !== -1) {
                erase(array, index, 1);
            }

            return array;
        }

function ( array , item ) { var index = ExtArray . indexOf ( array , item ) ; if ( index !== - 1 ) { erase ( array , index , 1 ) ; } return array ; }

Removes the specified item from the array if it exists

@param {Array} array The array
@param {Object} item The item to remove
@return {Array} The passed array itself


function() {
            var args = slice.call(arguments),
                array = [],
                i, ln;

            for (i = 0, ln = args.length; i < ln; i++) {
                array = array.concat(args[i]);
            }

            return ExtArray.unique(array);
        }

function ( ) { var args = slice . call ( arguments ) , array = [ ] , i , ln ; for ( i = 0 , ln = args . length ; i < ln ; i ++ ) { array = array . concat ( args [ i ] ) ; } return ExtArray . unique ( array ) ; }

Merge multiple arrays into one with unique items.

{@link Ext.Array#union} is alias for {@link Ext.Array#merge}

@param {Array} array1
@param {Array} array2
@param {Array} etc
@return {Array} merged

Merge multiple arrays into one with unique items .


function() {
            var intersection = [],
                arrays = slice.call(arguments),
                arraysLength,
                array,
                arrayLength,
                minArray,
                minArrayIndex,
                minArrayCandidate,
                minArrayLength,
                element,
                elementCandidate,
                elementCount,
                i, j, k;

            if (!arrays.length) {
                return intersection;
            }

            // Find the smallest array
            arraysLength = arrays.length;
            for (i = minArrayIndex = 0; i < arraysLength; i++) {
                minArrayCandidate = arrays[i];
                if (!minArray || minArrayCandidate.length < minArray.length) {
                    minArray = minArrayCandidate;
                    minArrayIndex = i;
                }
            }

            minArray = ExtArray.unique(minArray);
            erase(arrays, minArrayIndex, 1);

            // Use the smallest unique'd array as the anchor loop. If the other array(s) do contain
            // an item in the small array, we're likely to find it before reaching the end
            // of the inner loop and can terminate the search early.
            minArrayLength = minArray.length;
            arraysLength = arrays.length;
            for (i = 0; i < minArrayLength; i++) {
                element = minArray[i];
                elementCount = 0;

                for (j = 0; j < arraysLength; j++) {
                    array = arrays[j];
                    arrayLength = array.length;
                    for (k = 0; k < arrayLength; k++) {
                        elementCandidate = array[k];
                        if (element === elementCandidate) {
                            elementCount++;
                            break;
                        }
                    }
                }

                if (elementCount === arraysLength) {
                    intersection.push(element);
                }
            }

            return intersection;
        }

Merge multiple arrays into one with unique items that exist in all of the arrays.

@param {Array} array1
@param {Array} array2
@param {Array} etc
@return {Array} intersect

Merge multiple arrays into one with unique items that exist in all of the arrays .


function(arrayA, arrayB) {
            var clone = slice.call(arrayA),
                ln = clone.length,
                i, j, lnB;

            for (i = 0,lnB = arrayB.length; i < lnB; i++) {
                for (j = 0; j < ln; j++) {
                    if (clone[j] === arrayB[i]) {
                        erase(clone, j, 1);
                        j--;
                        ln--;
                    }
                }
            }

            return clone;
        }

function ( arrayA , arrayB ) { var clone = slice . call ( arrayA ) , ln = clone . length , i , j , lnB ; for ( i = 0 , lnB = arrayB . length ; i < lnB ; i ++ ) { for ( j = 0 ; j < ln ; j ++ ) { if ( clone [ j ] === arrayB [ i ] ) { erase ( clone , j , 1 ) ; j -- ; ln -- ; } } } return clone ; }

Perform a set difference A-B by subtracting all items in array B from array A.

@param {Array} arrayA
@param {Array} arrayB
@return {Array} difference

Perform a set difference A - B by subtracting all items in array B from array A .


function (array, begin, end) {
                // After tested for IE 6, the one below is of the best performance
                // see http://jsperf.com/slice-fix
                if (typeof begin === 'undefined') {
                    return slice.call(array);
                }
                if (typeof end === 'undefined') {
                    return slice.call(array, begin);
                }
                return slice.call(array, begin, end);
            }

at least IE6 uses arguments.length for variadic signature

at least IE6 uses arguments . length for variadic signature


function(array) {
            var worker = [];

            function rFlatten(a) {
                var i, ln, v;

                for (i = 0, ln = a.length; i < ln; i++) {
                    v = a[i];

                    if (Ext.isArray(v)) {
                        rFlatten(v);
                    } else {
                        worker.push(v);
                    }
                }

                return worker;
            }

            return rFlatten(array);
        }

function ( array ) { var worker = [ ] ; function rFlatten ( a ) { var i , ln , v ; for ( i = 0 , ln = a . length ; i < ln ; i ++ ) { v = a [ i ] ; if ( Ext . isArray ( v ) ) { rFlatten ( v ) ; } else { worker . push ( v ) ; } } return worker ; } return rFlatten ( array ) ; }

Recursively flattens into 1-d Array. Injects Arrays inline.

@param {Array} array The array to flatten
@return {Array} The 1-d array.

Recursively flattens into 1 - d Array . Injects Arrays inline .


function(array, comparisonFn) {
            var min = array[0],
                i, ln, item;

            for (i = 0, ln = array.length; i < ln; i++) {
                item = array[i];

                if (comparisonFn) {
                    if (comparisonFn(min, item) === 1) {
                        min = item;
                    }
                }
                else {
                    if (item < min) {
                        min = item;
                    }
                }
            }

            return min;
        }

function ( array , comparisonFn ) { var min = array [ 0 ] , i , ln , item ; for ( i = 0 , ln = array . length ; i < ln ; i ++ ) { item = array [ i ] ; if ( comparisonFn ) { if ( comparisonFn ( min , item ) === 1 ) { min = item ; } } else { if ( item < min ) { min = item ; } } } return min ; }

Returns the minimum value in the Array.

@param {Array/NodeList} array The Array from which to select the minimum value.
@param {Function} comparisonFn (optional) a function to perform the comparision which determines minimization.
If omitted the "<" operator will be used. Note: gt = 1; eq = 0; lt = -1
@param {Mixed} comparisonFn.min Current minimum value.
@param {Mixed} comparisonFn.item The value to compare with the current minimum.
@return {Object} minValue The minimum value

Returns the minimum value in the Array .


function(array) {
            var sum = 0,
                i, ln, item;

            for (i = 0,ln = array.length; i < ln; i++) {
                item = array[i];

                sum += item;
            }

            return sum;
        }

function ( array ) { var sum = 0 , i , ln , item ; for ( i = 0 , ln = array . length ; i < ln ; i ++ ) { item = array [ i ] ; sum += item ; } return sum ; }

Calculates the sum of all items in the given array.

@param {Array} array The Array to calculate the sum value of.
@return {Number} The sum.

Calculates the sum of all items in the given array .


function(array) {
            var len = arguments.length,
                i = 1,
                newItem;

            if (array === undefined) {
                array = [];
            } else if (!Ext.isArray(array)) {
                array = [array];
            }
            for (; i < len; i++) {
                newItem = arguments[i];
                Array.prototype.push[Ext.isIterable(newItem) ? 'apply' : 'call'](array, newItem);
            }
            return array;
        }

function ( array ) { var len = arguments . length , i = 1 , newItem ; if ( array === undefined ) { array = [ ] ; } else if ( ! Ext . isArray ( array ) ) { array = [ array ] ; } for ( ; i < len ; i ++ ) { newItem = arguments [ i ] ; Array . prototype . push [ Ext . isIterable ( newItem ) ? 'apply' : 'call' ] ( array , newItem ) ; } return array ; }

Pushes new items onto the end of an Array.

Passed parameters may be single items, or arrays of items. If an Array is found in the argument list, all its
elements are pushed into the end of the target Array.

@param {Array} target The Array onto which to push new items
@param {Object...} elements The elements to add to the array. Each parameter may
be an Array, in which case all the elements of that Array will be pushed into the end of the
destination Array.
@return {Array} An array containing all the new items push onto the end.

Pushes new items onto the end of an Array .


function (xpath) {
        var me = this,
            parts = xpath.split('/'),
            regex = me.tagPathRegEx,
            i, n, m, count, tag, child,
            el = me.attachTo.document;

        el = (parts[0] == '~') ? el.body
                    : el.getElementById(parts[0].substring(1)); // remove '#'

        for (i = 1, n = parts.length; el && i < n; ++i) {
            m = regex.exec(parts[i]);
            count = m[2] ? parseInt(m[2], 10) : 1;
            tag = m[1].toUpperCase();

            for (child = el.firstChild; child; child = child.nextSibling) {
                if (child.tagName == tag) {
                    if (count == 1) {
                        break;
                    }
                    --count;
                }
            }

            el = child;
        }

        return el;
    }

function
(
xpath
)
{
var
me
=
this
,
parts
=
xpath
.
split
(
'/'
)
,
regex
=
me
.
tagPathRegEx
,
i
,
n
,
m
,
count
,
tag
,
child
,
el
=
me
.
attachTo
.
document
;
el
=
(
parts
[
0
]
==
'~'
)
el
.
body
:
el
.
getElementById
(
parts
[
0
]
.
substring
(
1
)
)
;
// remove '#'
for
(
i
=
1
,
n
=
parts
.
length
;
el
&&
i
<
n
;
++
i
)
{
m
=
regex
.
exec
(
parts
[
i
]
)
;
count
=
m
[
2
]
parseInt
(
m
[
2
]
,
10
)
:
1
;
tag
=
m
[
1
]
.
toUpperCase
(
)
;
for
(
child
=
el
.
firstChild
;
child
;
child
=
child
.
nextSibling
)
{
if
(
child
.
tagName
==
tag
)
{
if
(
count
==
1
)
{
break
;
}
count
;
}
}
el
=
child
;
}
return
el
;
}

Returns the element given is XPath-like description.
@param {String} xpath The XPath-like description of the element.
@return {HTMLElement}

Returns the element given is XPath - like description .


function (eventDescriptor) {
        var me = this,
            index = ++me.queueIndex;

        // keyframe events are inserted after a keyFrameEvent is played.
        if (me.keyFrameEvents[eventDescriptor.type]) {
            Ext.Array.insert(me.eventQueue, index, [
                { keyframe: true, ts: eventDescriptor.ts }
            ]);
        }
    }

This method is called after an event has been played to prepare for the next event.
@param {Object} eventDescriptor The descriptor of the event just played.

This method is called after an event has been played to prepare for the next event .


function (eventDescriptor) {
        var me = this;

        // only fire keyframe event (and setup the eventDescriptor) once...
        if (!eventDescriptor.defer) {
            me.makeToken(eventDescriptor, 'done');
            me.fireEvent('keyframe', me, eventDescriptor);
        }

        return eventDescriptor.done;
    }

This method is called when a keyframe is reached. This will fire the keyframe event.
If the keyframe has been handled, true is returned. Otherwise, false is returned.
@param {Object} eventDescriptor The event descriptor of the keyframe.
@return {Boolean} True if the keyframe was handled, false if not.

This method is called when a keyframe is reached . This will fire the keyframe event . If the keyframe has been handled true is returned . Otherwise false is returned .


function getNonEditableParent(node) {
			var state;

			while (node) {
				state = getContentEditable(node);
				if (state) {
					return state  === "false" ? node : null;
				}

				node = node.parentNode;
			}
		}

function getNonEditableParent ( node ) { var state ; while ( node ) { state = getContentEditable ( node ) ; if ( state ) { return state === "false" ? node : null ; } node = node . parentNode ; } }

Returns the noneditable parent or null if there is a editable before it or if it wasn't found

Returns the noneditable parent or null if there is a editable before it or if it wasn t found


function removeCaretContainer(caretContainer) {
			var child, currentCaretContainer, lastContainer;

			if (caretContainer) {
					rng = selection.getRng(true);
					rng.setStartBefore(caretContainer);
					rng.setEndBefore(caretContainer);

					child = findFirstTextNode(caretContainer);
					if (child && child.nodeValue.charAt(0) == invisibleChar) {
						child = child.deleteData(0, 1);
					}

					dom.remove(caretContainer, true);

					selection.setRng(rng);
			} else {
				currentCaretContainer = getParentCaretContainer(selection.getStart());
				while ((caretContainer = dom.get(caretContainerId)) && caretContainer !== lastContainer) {
					if (currentCaretContainer !== caretContainer) {
						child = findFirstTextNode(caretContainer);
						if (child && child.nodeValue.charAt(0) == invisibleChar) {
							child = child.deleteData(0, 1);
						}

						dom.remove(caretContainer, true);
					}

					lastContainer = caretContainer;
				}
			}
		}

function removeCaretContainer ( caretContainer ) { var child , currentCaretContainer , lastContainer ; if ( caretContainer ) { rng = selection . getRng ( true ) ; rng . setStartBefore ( caretContainer ) ; rng . setEndBefore ( caretContainer ) ; child = findFirstTextNode ( caretContainer ) ; if ( child && child . nodeValue . charAt ( 0 ) == invisibleChar ) { child = child . deleteData ( 0 , 1 ) ; } dom . remove ( caretContainer , true ) ; selection . setRng ( rng ) ; } else { currentCaretContainer = getParentCaretContainer ( selection . getStart ( ) ) ; while ( ( caretContainer = dom . get ( caretContainerId ) ) && caretContainer !== lastContainer ) { if ( currentCaretContainer !== caretContainer ) { child = findFirstTextNode ( caretContainer ) ; if ( child && child . nodeValue . charAt ( 0 ) == invisibleChar ) { child = child . deleteData ( 0 , 1 ) ; } dom . remove ( caretContainer , true ) ; } lastContainer = caretContainer ; } } }

Removes any caret container except the one we might be in


function moveSelection() {
			var nonEditableStart, nonEditableEnd, isCollapsed, rng, element;

			// Checks if there is any contents to the left/right side of caret returns the noneditable element or any editable element if it finds one inside
			function hasSideContent(element, left) {
				var container, offset, walker, node, len;

				container = rng.startContainer;
				offset = rng.startOffset;

				// If endpoint is in middle of text node then expand to beginning/end of element
				if (container.nodeType == 3) {
					len = container.nodeValue.length;
					if ((offset > 0 && offset < len) || (left ? offset == len : offset == 0)) {
						return;
					}
				} else {
					// Can we resolve the node by index
					if (offset < container.childNodes.length) {
						// Browser represents caret position as the offset at the start of an element. When moving right
						// this is the element we are moving into so we consider our container to be child node at offset-1
						var pos = !left && offset > 0 ? offset-1 : offset;
						container = container.childNodes[pos];
						if (container.hasChildNodes()) {
							container = container.firstChild;
						}
					} else {
						// If not then the caret is at the last position in it's container and the caret container should be inserted after the noneditable element
						return !left ? element : null;
					}
				}

				// Walk left/right to look for contents
				walker = new TreeWalker(container, element);
				while (node = walker[left ? 'prev' : 'next']()) {
					if (node.nodeType === 3 && node.nodeValue.length > 0) {
						return;
					} else if (getContentEditable(node) === "true") {
						// Found contentEditable=true element return this one to we can move the caret inside it
						return node;
					}
				}

				return element;
			};

			// Remove any existing caret containers
			removeCaretContainer();

			// Get noneditable start/end elements
			isCollapsed = selection.isCollapsed();
			nonEditableStart = getNonEditableParent(selection.getStart());
			nonEditableEnd = getNonEditableParent(selection.getEnd());

			// Is any fo the range endpoints noneditable
			if (nonEditableStart || nonEditableEnd) {
				rng = selection.getRng(true);

				// If it's a caret selection then look left/right to see if we need to move the caret out side or expand
				if (isCollapsed) {
					nonEditableStart = nonEditableStart || nonEditableEnd;
					var start = selection.getStart();
					if (element = hasSideContent(nonEditableStart, true)) {
						// We have no contents to the left of the caret then insert a caret container before the noneditable element
						insertCaretContainerOrExpandToBlock(element, true);
					} else if (element = hasSideContent(nonEditableStart, false)) {
						// We have no contents to the right of the caret then insert a caret container after the noneditable element
						insertCaretContainerOrExpandToBlock(element, false);
					} else {
						// We are in the middle of a noneditable so expand to select it
						selection.select(nonEditableStart);
					}
				} else {
					rng = selection.getRng(true);

					// Expand selection to include start non editable element
					if (nonEditableStart) {
						rng.setStartBefore(nonEditableStart);
					}

					// Expand selection to include end non editable element
					if (nonEditableEnd) {
						rng.setEndAfter(nonEditableEnd);
					}

					selection.setRng(rng);
				}
			}
		}

Modifies the selection to include contentEditable false elements or insert caret containers


function convertRegExpsToNonEditable(ed, args) {
				var i = nonEditableRegExps.length, content = args.content, cls = tinymce.trim(nonEditClass);

				// Don't replace the variables when raw is used for example on undo/redo
				if (args.format == "raw") {
					return;
				}

				while (i--) {
					content = content.replace(nonEditableRegExps[i], function(match) {
						var args = arguments, index = args[args.length - 2];

						// Is value inside an attribute then don't replace
						if (index > 0 && content.charAt(index - 1) == '"') {
							return match;
						}

						return '' + ed.dom.encode(typeof(args[1]) === "string" ? args[1] : args[0]) + '';
					});
				}

				args.content = content;
			}

Converts configured regexps to noneditable span items


function setupLogger(name, cfg) {
  assume(name).is.a('string');
  if (cfg) {
    assume(cfg).is.an('object');
    assume(cfg).not.includes('name');
  } else {
    cfg = {};
  }
  cfg.name = name;

  // Sometimes, just make it easy to have everything show the file and line
  // number.  This is supposed to be quite slow, so the name is what it is to
  // make it impossible to claim you didn't know it made things slow
  if (process.env.FORCE_LOG_LINE_NUMBERS_AND_BE_SLOW === '1') {
    cfg.src = true;
  }

  // We want to be able to override whatever the library or application has
  // specified by changing only an evironment variable.
  let envLevel = parseEnvironment(process.env.LOG_LEVEL, cfg);
  let oldLevel = cfg.level;
  cfg.level = envLevel;

  cfg.serializers = {
    err: bunyan.stdSerializers.err,
  };

  let logger = bunyan.createLogger(cfg);

  // But let's make it clear that we did this by logging
  if (oldLevel) {
    if (oldLevel !== envLevel) {
      logger.warn({
        requested: oldLevel,
        used: envLevel,
      }, 'using log level from environment instead of code');
    }
  }

  assume(logger).does.not.include('debugCompat');
  logger.debugCompat = makeCompat(logger);
  return logger;
}

Create a root logger with the name given by name.  The object returned from
this function is a root logger.  The design is that each service, component
or library will use a single root logger object that's initialised a single
time.

A configuration can be passed in as the second parameter.  This object must
be a valid bunyan logging configuration.

Create a root logger with the name given by name . The object returned from this function is a root logger . The design is that each service component or library will use a single root logger object that s initialised a single time .


function makeCompat(logger) {
  return function(name) {
    return function(...x) {
      assume(x).is.an('array');
      assume(x.length).greaterThan(0);
      let msg = util.format.apply(null, x);
      let level = 'warn';
      let msgObj = {
        dbgname: name,
        dbgcmpt: true,
      };
      if (msg.match(/\[alert-operator\]/)) {
        level = 'fatal';
        msgObj.alert = true;
      }
      logger[level].call(logger, msgObj, msg);
    };
  };
}

function makeCompat ( logger ) { return function ( name ) { return function ( ... x ) { assume ( x ) . is . an ( 'array' ) ; assume ( x . length ) . greaterThan ( 0 ) ; let msg = util . format . apply ( null , x ) ; let level = 'warn' ; let msgObj = { dbgname : name , dbgcmpt : true , } ; if ( msg . match ( / \[alert-operator\] / ) ) { level = 'fatal' ; msgObj . alert = true ; } logger [ level ] . call ( logger , msgObj , msg ) ; } ; } ; }

In order to ease the transition from using the debug module for logging to
using this library, we have a function that allows the root logger to expose
an api similar to the debug module.  The first returned function takes a
name to use as the debug name and returns a function which accepts log
messages.  The log messages can use util.format formatting to produce
desired output.

This method does not inspect the debug module's DEBUG environment variable
although that would be a good idea.

In order to ease the transition from using the debug module for logging to using this library we have a function that allows the root logger to expose an api similar to the debug module . The first returned function takes a name to use as the debug name and returns a function which accepts log messages . The log messages can use util . format formatting to produce desired output .


function(height) {
        var me = this,
            isNum = (typeof height == "number");

        if (isNum && me.autoBoxAdjust && !me.isBorderBox()) {
            height -= (me.getBorderWidth("tb") + me.getPadding("tb"));
        }
        return (isNum && height < 0) ? 0 : height;
    }

function ( height ) { var me = this , isNum = ( typeof height == "number" ) ; if ( isNum && me . autoBoxAdjust && ! me . isBorderBox ( ) ) { height -= ( me . getBorderWidth ( "tb" ) + me . getPadding ( "tb" ) ) ; } return ( isNum && height < 0 ) ? 0 : height ; }


function(opacity, animate) {
        var me = this;

        if (!me.dom) {
            return me;
        }

        if (!animate || !me.anim) {
            me.setStyle('opacity', opacity);
        }
        else {
            if (typeof animate != 'object') {
                animate = {
                    duration: 350,
                    easing: 'ease-in'
                };
            }

            me.animate(Ext.applyIf({
                to: {
                    opacity: opacity
                }
            }, animate));
        }
        return me;
    }

function ( opacity , animate ) { var me = this ; if ( ! me . dom ) { return me ; } if ( ! animate || ! me . anim ) { me . setStyle ( 'opacity' , opacity ) ; } else { if ( typeof animate != 'object' ) { animate = { duration : 350 , easing : 'ease-in' } ; } me . animate ( Ext . applyIf ( { to : { opacity : opacity } } , animate ) ) ; } return me ; }

Set the opacity of the element
@param {Number} opacity The new opacity. 0 = transparent, .5 = 50% visibile, 1 = fully visible, etc
@param {Boolean/Object} [animate] a standard Element animation config object or `true` for
the default animation (`{duration: 350, easing: 'easeIn'}`)
@return {Ext.dom.Element} this


function(className, testFn, scope) {
        var me = this,
            dom = me.dom,
            hasTest = Ext.isFunction(testFn);

        me.hover(
            function() {
                if (hasTest && testFn.call(scope || me, me) === false) {
                    return;
                }
                Ext.fly(dom, INTERNAL).addCls(className);
            },
            function() {
                Ext.fly(dom, INTERNAL).removeCls(className);
            }
        );
        return me;
    }

function ( className , testFn , scope ) { var me = this , dom = me . dom , hasTest = Ext . isFunction ( testFn ) ; me . hover ( function ( ) { if ( hasTest && testFn . call ( scope || me , me ) === false ) { return ; } Ext . fly ( dom , INTERNAL ) . addCls ( className ) ; } , function ( ) { Ext . fly ( dom , INTERNAL ) . removeCls ( className ) ; } ) ; return me ; }

Sets up event handlers to add and remove a css class when the mouse is over this element
@param {String} className The class to add
@param {Function} [testFn] A test function to execute before adding the class. The passed parameter
will be the Element instance. If this functions returns false, the class will not be added.
@param {Object} [scope] The scope to execute the testFn in.
@return {Ext.dom.Element} this


function init(type) {  // {{{2
  O.ui.updateHistory();

  O.inherited(this)('html5-dialog' + (type ? '-' + type : ''));

  this.appendTo(document.body);

  O.ui.newHistory();
  this.lastHistory = O.ui.lastHistory;

  this.hook();

  this.type = type;

  if (! O.ui.dialogs) {
    O.ui.dialogs = [];
  }
  O.ui.dialogs.push(this);

  this.on('removed', removed.bind(this));
  this.on('closed', closed.bind(this));
}

function
init
(
type
)
{
// {{{2
O
.
ui
.
updateHistory
(
)
;
O
.
inherited
(
this
)
(
'html5-dialog'
+
(
type
'-'
+
type
:
''
)
)
;
this
.
appendTo
(
document
.
body
)
;
O
.
ui
.
newHistory
(
)
;
this
.
lastHistory
=
O
.
ui
.
lastHistory
;
this
.
hook
(
)
;
this
.
type
=
type
;
if
(
!
O
.
ui
.
dialogs
)
{
O
.
ui
.
dialogs
=
[
]
;
}
O
.
ui
.
dialogs
.
push
(
this
)
;
this
.
on
(
'removed'
,
removed
.
bind
(
this
)
)
;
this
.
on
(
'closed'
,
closed
.
bind
(
this
)
)
;
}


function(e, target) {
        var me = this,
            item, record;

        if (Ext.fly(target).hasCls(me.labelSelector) && !me.editing && !e.ctrlKey && !e.shiftKey) {
            e.stopEvent();
            item = me.view.findItemByChild(target);
            record = me.view.store.getAt(me.view.indexOf(item));
            me.startEdit(target, record.data[me.dataIndex]);
            me.activeRecord = record;
        } else if (me.editing) {
            me.field.blur();
            e.preventDefault();
        }
    }

function ( e , target ) { var me = this , item , record ; if ( Ext . fly ( target ) . hasCls ( me . labelSelector ) && ! me . editing && ! e . ctrlKey && ! e . shiftKey ) { e . stopEvent ( ) ; item = me . view . findItemByChild ( target ) ; record = me . view . store . getAt ( me . view . indexOf ( item ) ) ; me . startEdit ( target , record . data [ me . dataIndex ] ) ; me . activeRecord = record ; } else if ( me . editing ) { me . field . blur ( ) ; e . preventDefault ( ) ; } }


function(dir) {

        var cmd = path.normalize(config.bin);

        if (config.jdependChart !== undefined) {
            cmd += ' --jdepend-chart=' + config.jdependChart;
        }

        if (config.jdependXml !== undefined) {
            cmd += ' --jdepend-xml=' + config.jdependXml;
        }

        if (config.overviewPyramid !== undefined) {
            cmd += ' --overview-pyramid=' + config.overviewPyramid;
        }

        if (config.summaryXml !== undefined) {
            cmd += ' --summary-xml=' + config.summaryXml;
        }

        if (config.coderankMode !== undefined) {
            cmd += ' --coderank-mode=' + config.coderankMode;
        }

        if (config.coverageReport !== undefined) {
            cmd += ' --coverage-report=' + config.coverageReport;
        }

        if (config.configuration !== undefined) {
            cmd += ' --configuration=' + config.configuration;
        }

        if (config.ignoreDirectories !== undefined) {
            cmd += ' --ignore=' + config.ignoreDirectories;
        }

        if (config.debug) {
            cmd += ' --debug ';
        }

        return cmd;
    }

function
(
dir
)
{
var
cmd
=
path
.
normalize
(
config
.
bin
)
;
if
(
config
.
jdependChart
!==
undefined
)
{
cmd
+=
' --jdepend-chart='
+
config
.
jdependChart
;
}
if
(
config
.
jdependXml
!==
undefined
)
{
cmd
+=
' --jdepend-xml='
+
config
.
jdependXml
;
}
if
(
config
.
overviewPyramid
!==
undefined
)
{
cmd
+=
' --overview-pyramid='
+
config
.
overviewPyramid
;
}
if
(
config
.
summaryXml
!==
undefined
)
{
cmd
+=
' --summary-xml='
+
config
.
summaryXml
;
}
if
(
config
.
coderankMode
!==
undefined
)
{
cmd
+=
' --coderank-mode='
+
config
.
coderankMode
;
}
if
(
config
.
coverageReport
!==
undefined
)
{
cmd
+=
' --coverage-report='
+
config
.
coverageReport
;
}
if
(
config
.
configuration
!==
undefined
)
{
cmd
+=
' --configuration='
+
config
.
configuration
;
}
if
(
config
.
ignoreDirectories
!==
undefined
)
{
cmd
+=
' --ignore='
+
config
.
ignoreDirectories
;
}
if
(
config
.
debug
)
{
cmd
+=
' --debug '
;
}
return
cmd
;
}


function canonicalMd5(md5) {
  if (md5) {
    if (Buffer.isBuffer(md5))
      md5 = md5.toString('base64')
    else if (md5 && md5.match(/^md5-/))
      md5 = md5.replace(/^md5-/, '')

    if (md5.length === 32)
      md5 = new Buffer(md5, 'hex').toString('base64')
  }
  return md5
}

function canonicalMd5 ( md5 ) { if ( md5 ) { if ( Buffer . isBuffer ( md5 ) ) md5 = md5 . toString ( 'base64' ) else if ( md5 && md5 . match ( / ^md5- / ) ) md5 = md5 . replace ( / ^md5- / , '' ) if ( md5 . length === 32 ) md5 = new Buffer ( md5 , 'hex' ) . toString ( 'base64' ) } return md5 }

File class Because of toString = this.name, it can be used interchangeably as a string key, and also as the object represented by that

File class Because of toString = this . name it can be used interchangeably as a string key and also as the object represented by that


function() {
        var me = this;
        if (me.fireEvent('beforedestroy', me) !== false) {
            me.remove();
            me.surface.onDestroy(me);
            me.clearListeners();
            me.fireEvent('destroy');
        }
    }

function ( ) { var me = this ; if ( me . fireEvent ( 'beforedestroy' , me ) !== false ) { me . remove ( ) ; me . surface . onDestroy ( me ) ; me . clearListeners ( ) ; me . fireEvent ( 'destroy' ) ; } }

Removes the sprite and clears all listeners.

Removes the sprite and clears all listeners .


function (options) {
	this.astStack = new ASTStack();
	this.tags = options.customTags;
	this.raw = '';
	this.disableParseTag = false;
	this.line = 1;
	this.lineStart = 0;
	this.position = 0;
	this.parseTagStack = [];
	this.forItems = [];
	this.tablerowItems = [];
	this.forItems.test = this.tablerowItems.test = function (name) {
		var name = name.split('.')[0];
		return this.indexOf(name) === -1 ? false : true;
	};
}

function ( options ) { this . astStack = new ASTStack ( ) ; this . tags = options . customTags ; this . raw = '' ; this . disableParseTag = false ; this . line = 1 ; this . lineStart = 0 ; this . position = 0 ; this . parseTagStack = [ ] ; this . forItems = [ ] ; this . tablerowItems = [ ] ; this . forItems . test = this . tablerowItems . test = function ( name ) { var name = name . split ( '.' ) [ 0 ] ; return this . indexOf ( name ) === - 1 ? false : true ; } ; }

Parser context object

@param {Object} options


function join_plugins(plugins) {
	debug.assert(plugins).is('array');
	debug.assert( ARRAY(plugins).every(is.func) ).equals(true);

	return function join_plugins_(req, res, next) {
		var queue = [].concat(plugins);

		function do_iteration_() {
			if(queue.length === 0) {
				next();
				return;
			}
			var plugin = queue.shift();
			debug.assert(plugin).is('function');
			plugin(req, res, function plugin_wrapper(err) {
				if(err) {
					next(err);
					return;
				}
				do_iteration_();
			});
		}

		function do_iteration() {
			try {
				do_iteration_();
			} catch(err) {
				next(err);
				return;
			}
		}

		do_iteration();
	};
}

function join_plugins ( plugins ) { debug . assert ( plugins ) . is ( 'array' ) ; debug . assert ( ARRAY ( plugins ) . every ( is . func ) ) . equals ( true ) ; return function join_plugins_ ( req , res , next ) { var queue = [ ] . concat ( plugins ) ; function do_iteration_ ( ) { if ( queue . length === 0 ) { next ( ) ; return ; } var plugin = queue . shift ( ) ; debug . assert ( plugin ) . is ( 'function' ) ; plugin ( req , res , function plugin_wrapper ( err ) { if ( err ) { next ( err ) ; return ; } do_iteration_ ( ) ; } ) ; } function do_iteration ( ) { try { do_iteration_ ( ) ; } catch ( err ) { next ( err ) ; return ; } } do_iteration ( ) ; } ; }


function setup_member(context, k) {
	var handler;
	var routes = context.routes;
	var opts = context.opts;
	var middleware = context.middleware;
	var app = context.app;
	var target = context.target;
	var loop_counter = context.loop_counter;
	var v = routes[k];
	var v_is_function = is.func(v) ? true : false;

	// Special methods
	if(_special_methods.indexOf(k) >= 0) {
		handler = v_is_function ? v : FUNCTION(do_send).curry(opts, v);
		if(middleware.length === 0) {
			app[_express_methods[k]](target, build_request(opts, handler) );
		} else if(k === 'USE') {
			//debug.log('target = ', target);
			//debug.log('k = ', k);
			//debug.log('_express_methods[', k,'] = ', _express_methods[k]);

			app[_express_methods[k]](target, join_plugins( [fix_for_missing_req_route(target, 'use')].concat(middleware).concat([build_request(opts, handler)]) ) );
		} else {
			app[_express_methods[k]](target, fix_for_missing_req_route(target, (''+k).toLowerCase() ), middleware, build_request(opts, handler));
		}
		return;
	}

	// Functions
	if(process.env.DEBUG_NOR_EXPRESS) {
		debug.log( /*(req.id ? '['+req.id+'] ' : '') + */ 'target = ', target);
		debug.log( /*(req.id ? '['+req.id+'] ' : '') + */ 'k = ', k);
	}

	var new_target = (target==='/') ? ('/' + k) : (target + '/' + k);
	var new_route = ROUTES.parse(v);
	ROUTES.setup(app, new_route, new_target, merge(opts, {'loop_counter': loop_counter+1}));
}


function accept_multi(filename, state) {
	state = state || {};
	debug.assert(filename).is('string');
	debug.assert(state).is('object');
	if(state.directory) { return accept_dir(filename, state); }
	if(state.file) { return accept_file(filename, state); }
	return;
}

function accept_multi ( filename , state ) { state = state || { } ; debug . assert ( filename ) . is ( 'string' ) ; debug . assert ( state ) . is ( 'object' ) ; if ( state . directory ) { return accept_dir ( filename , state ) ; } if ( state . file ) { return accept_file ( filename , state ) ; } return ; }

Returns true if file or directory should be ignored


function makeDefine(mapping, id) {
  var require = function(id) { return mapping[id]; };
  var exports = mapping[id] = {};
  var module = null; // Unused arg. Included for completeness.
  return function(factory) {
    factory(require, exports, module);
  };
}

The official 'source-map' requires a 'define' function that matches the CommonJS module specification. Since it only uses a subset of that functionality, we cheat here and only provide that minimum subset.
@param {Object} mapping Maps between module ids and exports.
@param {string} id A module id.
@return {Function} A 'define' function that initializes |mapping[id]| with
the exports from |factory|.

The official source - map requires a define function that matches the CommonJS module specification . Since it only uses a subset of that functionality we cheat here and only provide that minimum subset .


function(root, action) {
        var parts, ns, i, l;

        root  = root || Ext.global;
        parts = action.toString().split('.');

        for (i = 0, l = parts.length; i < l; i++) {
            ns   = parts[i];
            root = root[ns];

            if (typeof root === 'undefined') {
                return root;
            }
        }

        return root;
    }

function ( root , action ) { var parts , ns , i , l ; root = root || Ext . global ; parts = action . toString ( ) . split ( '.' ) ; for ( i = 0 , l = parts . length ; i < l ; i ++ ) { ns = parts [ i ] ; root = root [ ns ] ; if ( typeof root === 'undefined' ) { return root ; } } return root ; }

Get nested namespace by property.

@private


function() {
        var me = this,
            actions = me.actions,
            namespace = me.namespace,
            action, cls, methods, i, len, method;

        for (action in actions) {
            if (actions.hasOwnProperty(action)) {
                if (me.disableNestedActions) {
                    cls = namespace[action];

                    if (!cls) {
                        cls = namespace[action] = {};
                    }
                }
                else {
                    cls = me.getNamespace(namespace, action);

                    if (!cls) {
                        cls = me.createNamespaces(namespace, action);
                    }
                }

                methods = actions[action];

                for (i = 0, len = methods.length; i < len; ++i) {
                    method = new Ext.direct.RemotingMethod(methods[i]);
                    cls[method.name] = me.createHandler(action, method);
                }
            }
        }
    }

function ( ) { var me = this , actions = me . actions , namespace = me . namespace , action , cls , methods , i , len , method ; for ( action in actions ) { if ( actions . hasOwnProperty ( action ) ) { if ( me . disableNestedActions ) { cls = namespace [ action ] ; if ( ! cls ) { cls = namespace [ action ] = { } ; } } else { cls = me . getNamespace ( namespace , action ) ; if ( ! cls ) { cls = me . createNamespaces ( namespace , action ) ; } } methods = actions [ action ] ; for ( i = 0 , len = methods . length ; i < len ; ++ i ) { method = new Ext . direct . RemotingMethod ( methods [ i ] ) ; cls [ method . name ] = me . createHandler ( action , method ) ; } } } }


function(action, method) {
        var me = this,
            slice = Array.prototype.slice,
            handler;

        if (!method.formHandler) {
            handler = function() {
                me.configureRequest(action, method, slice.call(arguments, 0));
            };
        }
        else {
            handler = function(form, callback, scope) {
                me.configureFormRequest(action, method, form, callback, scope);
            };
        }

        handler.directCfg = {
            action: action,
            method: method
        };

        return handler;
    }

function ( action , method ) { var me = this , slice = Array . prototype . slice , handler ; if ( ! method . formHandler ) { handler = function ( ) { me . configureRequest ( action , method , slice . call ( arguments , 0 ) ) ; } ; } else { handler = function ( form , callback , scope ) { me . configureFormRequest ( action , method , form , callback , scope ) ; } ; } handler . directCfg = { action : action , method : method } ; return handler ; }

Create a handler function for a direct call.

@param {String} action The action the call is for
@param {Object} method The details of the method

@return {Function} A JS function that will kick off the call

@private

Create a handler function for a direct call .


function(transaction, event) {
        var success = !!event.status,
            funcName = success ? 'success' : 'failure',
            callback, options, result;

        if (transaction && transaction.callback) {
            callback = transaction.callback;
            options  = transaction.callbackOptions;
            result   = typeof event.result !== 'undefined' ? event.result : event.data;

            if (Ext.isFunction(callback)) {
                callback(result, event, success, options);
            }
            else {
                Ext.callback(callback[funcName], callback.scope, [result, event, success, options]);
                Ext.callback(callback.callback,  callback.scope, [result, event, success, options]);
            }
        }
    }

function ( transaction , event ) { var success = ! ! event . status , funcName = success ? 'success' : 'failure' , callback , options , result ; if ( transaction && transaction . callback ) { callback = transaction . callback ; options = transaction . callbackOptions ; result = typeof event . result !== 'undefined' ? event . result : event . data ; if ( Ext . isFunction ( callback ) ) { callback ( result , event , success , options ) ; } else { Ext . callback ( callback [ funcName ] , callback . scope , [ result , event , success , options ] ) ; Ext . callback ( callback . callback , callback . scope , [ result , event , success , options ] ) ; } } }

Run any callbacks related to the transaction.

@param {Ext.direct.Transaction} transaction The transaction
@param {Ext.direct.Event} event The event

@private

Run any callbacks related to the transaction .


function(options, success, response) {
        var me = this,
            i, len, events, event, transaction, transactions;

        if (success) {
            events = me.createEvents(response);

            for (i = 0, len = events.length; i < len; ++i) {
                event = events[i];
                transaction = me.getTransaction(event);
                me.fireEvent('data', me, event);

                if (transaction && me.fireEvent('beforecallback', me, event, transaction) !== false) {
                    me.runCallback(transaction, event, true);
                    Ext.direct.Manager.removeTransaction(transaction);
                }
            }
        }
        else {
            transactions = [].concat(options.transaction);

            for (i = 0, len = transactions.length; i < len; ++i) {
                transaction = me.getTransaction(transactions[i]);

                if (transaction && transaction.retryCount < me.maxRetries) {
                    transaction.retry();
                }
                else {
                    event = new Ext.direct.ExceptionEvent({
                        data: null,
                        transaction: transaction,
                        code: Ext.direct.Manager.exceptions.TRANSPORT,
                        message: 'Unable to connect to the server.',
                        xhr: response
                    });

                    me.fireEvent('data', me, event);

                    if (transaction && me.fireEvent('beforecallback', me, transaction) !== false) {
                        me.runCallback(transaction, event, false);
                        Ext.direct.Manager.removeTransaction(transaction);
                    }
                }
            }
        }
    }

function
(
options
,
success
,
response
)
{
var
me
=
this
,
i
,
len
,
events
,
event
,
transaction
,
transactions
;
if
(
success
)
{
events
=
me
.
createEvents
(
response
)
;
for
(
i
=
0
,
len
=
events
.
length
;
i
<
len
;
++
i
)
{
event
=
events
[
i
]
;
transaction
=
me
.
getTransaction
(
event
)
;
me
.
fireEvent
(
'data'
,
me
,
event
)
;
if
(
transaction
&&
me
.
fireEvent
(
'beforecallback'
,
me
,
event
,
transaction
)
!==
false
)
{
me
.
runCallback
(
transaction
,
event
,
true
)
;
Ext
.
direct
.
Manager
.
removeTransaction
(
transaction
)
;
}
}
}
else
{
transactions
=
[
]
.
concat
(
options
.
transaction
)
;
for
(
i
=
0
,
len
=
transactions
.
length
;
i
<
len
;
++
i
)
{
transaction
=
me
.
getTransaction
(
transactions
[
i
]
)
;
if
(
transaction
&&
transaction
.
retryCount
<
me
.
maxRetries
)
{
transaction
.
retry
(
)
;
}
else
{
event
=
new
Ext
.
direct
.
ExceptionEvent
(
{
data
:
,
transaction
:
transaction
,
code
:
Ext
.
direct
.
Manager
.
exceptions
.
TRANSPORT
,
message
:
'Unable to connect to the server.'
,
xhr
:
response
}
)
;
me
.
fireEvent
(
'data'
,
me
,
event
)
;
if
(
transaction
&&
me
.
fireEvent
(
'beforecallback'
,
me
,
transaction
)
!==
false
)
{
me
.
runCallback
(
transaction
,
event
,
false
)
;
Ext
.
direct
.
Manager
.
removeTransaction
(
transaction
)
;
}
}
}
}
}

React to the ajax request being completed

@private


function(options) {
        return options && options.tid ? Ext.direct.Manager.getTransaction(options.tid) : null;
    }

function ( options ) { return options && options . tid ? Ext . direct . Manager . getTransaction ( options . tid ) : null ; }

Get transaction from XHR options

@param {Object} options The options sent to the Ajax request

@return {Ext.direct.Transaction} The transaction, null if not found

@private


function(action, method, args) {
        var me = this,
            callData, data, callback, scope, opts, transaction, params;

        callData = method.getCallData(args);
        data     = callData.data;
        callback = callData.callback;
        scope    = callData.scope;
        opts     = callData.options || {};

        params = Ext.apply({}, {
            provider: me,
            args: args,
            action: action,
            method: method.name,
            data: data,
            callbackOptions: opts,
            callback: scope && Ext.isFunction(callback) ? Ext.Function.bind(callback, scope) : callback
        });

        if (opts.timeout) {
            Ext.applyIf(params, {
                timeout: opts.timeout
            });
        };

        transaction = new Ext.direct.Transaction(params);

        if (me.fireEvent('beforecall', me, transaction, method) !== false) {
            Ext.direct.Manager.addTransaction(transaction);
            me.queueTransaction(transaction);
            me.fireEvent('call', me, transaction, method);
        }
    }

function ( action , method , args ) { var me = this , callData , data , callback , scope , opts , transaction , params ; callData = method . getCallData ( args ) ; data = callData . data ; callback = callData . callback ; scope = callData . scope ; opts = callData . options || { } ; params = Ext . apply ( { } , { provider : me , args : args , action : action , method : method . name , data : data , callbackOptions : opts , callback : scope && Ext . isFunction ( callback ) ? Ext . Function . bind ( callback , scope ) : callback } ) ; if ( opts . timeout ) { Ext . applyIf ( params , { timeout : opts . timeout } ) ; } ; transaction = new Ext . direct . Transaction ( params ) ; if ( me . fireEvent ( 'beforecall' , me , transaction , method ) !== false ) { Ext . direct . Manager . addTransaction ( transaction ) ; me . queueTransaction ( transaction ) ; me . fireEvent ( 'call' , me , transaction , method ) ; } }

Configure a direct request

@param {String} action The action being executed
@param {Object} method The being executed

@private