function read() {
    const TLS_CERT = process.env.TLS_CERT;
    const TLS_KEY = process.env.TLS_KEY;
    const TLS_CA = process.env.TLS_CA;
    const tls_cert = readOpt("--tls-cert");
    const tls_key = readOpt("--tls-key");
    const tls_ca = readOpt("--tls-ca");
    const result = {};

    if (tls_cert) {
        if (tls_key) {
            result.cert = readFile(tls_cert);
            result.key = readFile(tls_key);

            if (tls_ca) {
                result.ca = readFile(tls_ca);
            }
        } else {
            result.pfx = readFile(tls_cert);
        }
    } else if (TLS_CERT) {
        if (TLS_KEY) {
            result.cert = readFile(TLS_CERT);
            result.key = readFile(TLS_KEY);

            if (TLS_CA) {
                result.ca = readFile(TLS_CA);
            }
        } else {
            result.pfx = readFile(TLS_CERT);
        }
    }

    return Promise.all(keys(result).map(key => result[key].then(data => {
        return result[key] = data;
    }))).then(() => result);
}

function read ( ) { const TLS_CERT = process . env . TLS_CERT ; const TLS_KEY = process . env . TLS_KEY ; const TLS_CA = process . env . TLS_CA ; const tls_cert = readOpt ( "--tls-cert" ) ; const tls_key = readOpt ( "--tls-key" ) ; const tls_ca = readOpt ( "--tls-ca" ) ; const result = { } ; if ( tls_cert ) { if ( tls_key ) { result . cert = readFile ( tls_cert ) ; result . key = readFile ( tls_key ) ; if ( tls_ca ) { result . ca = readFile ( tls_ca ) ; } } else { result . pfx = readFile ( tls_cert ) ; } } else if ( TLS_CERT ) { if ( TLS_KEY ) { result . cert = readFile ( TLS_CERT ) ; result . key = readFile ( TLS_KEY ) ; if ( TLS_CA ) { result . ca = readFile ( TLS_CA ) ; } } else { result . pfx = readFile ( TLS_CERT ) ; } } return Promise . all ( keys ( result ) . map ( key => result [ key ] . then ( data => { return result [ key ] = data ; } ) ) ) . then ( ( ) => result ) ; }

Read TLS options from filesystem asynchronously.  Paths are read from CLI
options or environment variables.
@returns {Promise}

Read TLS options from filesystem asynchronously . Paths are read from CLI options or environment variables .


function readOpt(option) {
    const prefix = `${option}=`;

    for (let i = 0, len = process.argv.length, arg; i < len; i++) {
        arg = process.argv[i];

        if (arg === option) {
            return process.argv[i+1];
        } else if (arg.indexOf(prefix) === 0) {
            return arg.substr(prefix.length);
        }
    }
}

function readOpt ( option ) { const prefix = ` ${ option } ` ; for ( let i = 0 , len = process . argv . length , arg ; i < len ; i ++ ) { arg = process . argv [ i ] ; if ( arg === option ) { return process . argv [ i + 1 ] ; } else if ( arg . indexOf ( prefix ) === 0 ) { return arg . substr ( prefix . length ) ; } } }

Read long-option value from CLI arguments.
@param {string} option
@returns {string}

Read long - option value from CLI arguments .


function(target) {
        var me = this,
            anims = [],
            timeline = me.timeline,
            ln = timeline.length,
            anim, easing, damper, attrs, i;

        if (me.fireEvent('beforeanimate', me) !== false) {
            for (i = 0; i < ln; i++) {
                anim = timeline[i];
                attrs = anim.attrs;
                easing = attrs.easing || me.easing;
                damper = attrs.damper || me.damper;
                delete attrs.easing;
                delete attrs.damper;
                anim = new Ext.fx.Anim({
                    target: target,
                    easing: easing,
                    damper: damper,
                    duration: anim.duration,
                    paused: true,
                    to: attrs
                });
                anims.push(anim);
            }
            me.animations = anims;
            me.target = anim.target;
            for (i = 0; i < ln - 1; i++) {
                anim = anims[i];
                anim.nextAnim = anims[i + 1];
                anim.on('afteranimate', function() {
                    this.nextAnim.paused = false;
                });
                anim.on('afteranimate', function() {
                    this.fireEvent('keyframe', this, ++this.keyframeStep);
                }, me);
            }
            anims[ln - 1].on('afteranimate', function() {
                this.lastFrame();
            }, me);
        }
    }

function ( target ) { var me = this , anims = [ ] , timeline = me . timeline , ln = timeline . length , anim , easing , damper , attrs , i ; if ( me . fireEvent ( 'beforeanimate' , me ) !== false ) { for ( i = 0 ; i < ln ; i ++ ) { anim = timeline [ i ] ; attrs = anim . attrs ; easing = attrs . easing || me . easing ; damper = attrs . damper || me . damper ; delete attrs . easing ; delete attrs . damper ; anim = new Ext . fx . Anim ( { target : target , easing : easing , damper : damper , duration : anim . duration , paused : true , to : attrs } ) ; anims . push ( anim ) ; } me . animations = anims ; me . target = anim . target ; for ( i = 0 ; i < ln - 1 ; i ++ ) { anim = anims [ i ] ; anim . nextAnim = anims [ i + 1 ] ; anim . on ( 'afteranimate' , function ( ) { this . nextAnim . paused = false ; } ) ; anim . on ( 'afteranimate' , function ( ) { this . fireEvent ( 'keyframe' , this , ++ this . keyframeStep ) ; } , me ) ; } anims [ ln - 1 ] . on ( 'afteranimate' , function ( ) { this . lastFrame ( ) ; } , me ) ; } }

Applies animation to the Ext.fx.target
@private
@param target
@type String/Object

Applies animation to the Ext . fx . target


function() {
        var me = this,
            chart = me.chart,
            store = chart.getChartStore(),
            data = store.data.items,
            count = me.getRecordCount(),
            i, ln, record,
            min, max,
            xField = me.xField,
            xValue;

        if (count > 0) {
            min = Infinity;
            max = -min;

            for (i = 0, ln = data.length; i < ln; i++) {
                record = data[i];
                xValue = record.get(xField);
                if (xValue > max) {
                    max = xValue;
                }
                if (xValue < min) {
                    min = xValue;
                }
            }

            // If we made no progress, treat it like a category axis
            if (min == Infinity) {
                min = 0;
            }

            if (max == -Infinity) {
                max = count - 1;
            }
        } else {
            min = max = 0;
        }
        return [min, max];
    }

Calculate the min and max values for this series's xField.
@return {Array} [min, max]

Calculate the min and max values for this series s xField .


function(title) {
        var me = this,
            titleCmp = me.titleCmp;

        me.title = title;
        if (titleCmp.rendered) {
            titleCmp.textEl.update(me.title || ' ');
            titleCmp.updateLayout();
        } else {
            me.titleCmp.on({
                render: function() {
                    me.setTitle(title);
                },
                single: true
            });
        }
    }

function ( title ) { var me = this , titleCmp = me . titleCmp ; me . title = title ; if ( titleCmp . rendered ) { titleCmp . textEl . update ( me . title || ' ' ) ; titleCmp . updateLayout ( ) ; } else { me . titleCmp . on ( { render : function ( ) { me . setTitle ( title ) ; } , single : true } ) ; } }

Sets the title of the header.
@param {String} title The title to be set


function(cls) {
        var me = this,
            isEmpty = !cls || !cls.length,
            iconCmp = me.iconCmp;

        me.iconCls = cls;
        if (!me.iconCmp && !isEmpty) {
            me.initIconCmp();
            me.insert(0, me.iconCmp);
        } else if (iconCmp) {
            if (isEmpty) {
                me.iconCmp.destroy();
                delete me.iconCmp;
            } else {
                iconCmp.removeCls(iconCmp.iconCls);
                iconCmp.addCls(cls);
                iconCmp.iconCls = cls;
            }
        }
    }

function ( cls ) { var me = this , isEmpty = ! cls || ! cls . length , iconCmp = me . iconCmp ; me . iconCls = cls ; if ( ! me . iconCmp && ! isEmpty ) { me . initIconCmp ( ) ; me . insert ( 0 , me . iconCmp ) ; } else if ( iconCmp ) { if ( isEmpty ) { me . iconCmp . destroy ( ) ; delete me . iconCmp ; } else { iconCmp . removeCls ( iconCmp . iconCls ) ; iconCmp . addCls ( cls ) ; iconCmp . iconCls = cls ; } } }

Sets the CSS class that provides the icon image for this header.  This method will replace any existing
icon class if one has already been set.
@param {String} cls The new CSS class name

Sets the CSS class that provides the icon image for this header . This method will replace any existing icon class if one has already been set .


function(icon) {
        var me = this,
            isEmpty = !icon || !icon.length,
            iconCmp = me.iconCmp;

        me.icon = icon;
        if (!me.iconCmp && !isEmpty) {
            me.initIconCmp();
            me.insert(0, me.iconCmp);
        } else if (iconCmp) {
            if (isEmpty) {
                me.iconCmp.destroy();
                delete me.iconCmp;
            } else {
                iconCmp.setSrc(me.icon);
            }
        }
    }

function ( icon ) { var me = this , isEmpty = ! icon || ! icon . length , iconCmp = me . iconCmp ; me . icon = icon ; if ( ! me . iconCmp && ! isEmpty ) { me . initIconCmp ( ) ; me . insert ( 0 , me . iconCmp ) ; } else if ( iconCmp ) { if ( isEmpty ) { me . iconCmp . destroy ( ) ; delete me . iconCmp ; } else { iconCmp . setSrc ( me . icon ) ; } } }

Sets the image path that provides the icon image for this header.  This method will replace any existing
icon if one has already been set.
@param {String} icon The new icon path

Sets the image path that provides the icon image for this header . This method will replace any existing icon if one has already been set .


function(glyph) {
        var me = this,
            iconCmp = me.iconCmp;

        if (!me.iconCmp) {
            me.initIconCmp();
            me.insert(0, me.iconCmp);
        } else if (iconCmp) {
            if (glyph) {
                me.iconCmp.setGlyph(glyph);
            } else {
                me.iconCmp.destroy();
                delete me.iconCmp;
            }
        }
    }

function ( glyph ) { var me = this , iconCmp = me . iconCmp ; if ( ! me . iconCmp ) { me . initIconCmp ( ) ; me . insert ( 0 , me . iconCmp ) ; } else if ( iconCmp ) { if ( glyph ) { me . iconCmp . setGlyph ( glyph ) ; } else { me . iconCmp . destroy ( ) ; delete me . iconCmp ; } } }

Sets glyph that provides the icon image for this header.  This method will replace any existing
glyph if one has already been set.
@param {Number/String} glyph the numeric charCode or string charCode/font-family.
This parameter expects a format consistent with that of {@link #glyph}

Sets glyph that provides the icon image for this header . This method will replace any existing glyph if one has already been set .


function (item, checked) {
        var value = [];
        this.items.each(function(item){
            if (item.checked) {
                value.push(item.value);
            }
        });
        this.selected = value;

        this.fireEvent('checkchange', item, checked);
    }

function ( item , checked ) { var value = [ ] ; this . items . each ( function ( item ) { if ( item . checked ) { value . push ( item . value ) ; } } ) ; this . selected = value ; this . fireEvent ( 'checkchange' , item , checked ) ; }

Handler for the 'checkchange' event from an check item in this menu
@param {Object} item Ext.menu.CheckItem
@param {Object} checked The checked value that was set

Handler for the checkchange event from an check item in this menu


function isType (type, val) {
  return (type == Any)
      || (type == Object && is.object(val))
      || (type == Function && is.function(val))
      || (type == String && is.string(val))
      || (type == Error && is.error(val))
      || (type == Number && is.number(val))
      || (type == Array && is.array(val))
      || (type == Boolean && is.boolean(val))
      || (type == RegExp && is.regExp(val))
      || (type == Date && is.date(val))
      || (type == null && is.nullOrUndefined(val))
      || (val instanceof type)
}

function isType ( type , val ) { return ( type == Any ) || ( type == Object && is . object ( val ) ) || ( type == Function && is . function ( val ) ) || ( type == String && is . string ( val ) ) || ( type == Error && is . error ( val ) ) || ( type == Number && is . number ( val ) ) || ( type == Array && is . array ( val ) ) || ( type == Boolean && is . boolean ( val ) ) || ( type == RegExp && is . regExp ( val ) ) || ( type == Date && is . date ( val ) ) || ( type == null && is . nullOrUndefined ( val ) ) || ( val instanceof type ) }


function findMorph (args, morphs) {
  for (var i = 0; i < morphs.length; i++) {
    var sig = morphs[i].sig

    if (args.length == sig.length) {
      var matched = true

      for (var j = 0; j < sig.length; j++) {
        if (!isType(sig[j], args[j])) {
          matched = false
          break
        }
      }

      if (matched) {
        return morphs[i]
      }
    }
  }
  throw new Error('No matching function signature')
}

function
findMorph
(
args
,
morphs
)
{
for
(
var
i
=
0
;
i
<
morphs
.
length
;
i
++
)
{
var
sig
=
morphs
[
i
]
.
sig
if
(
args
.
length
==
sig
.
length
)
{
var
matched
=
true
for
(
var
j
=
0
;
j
<
sig
.
length
;
j
++
)
{
if
(
!
isType
(
sig
[
j
]
,
args
[
j
]
)
)
{
matched
=
false
break
}
}
if
(
matched
)
{
return
morphs
[
i
]
}
}
}
throw
new
Error
(
'No matching function signature'
)
}


function generateAssignStateOutOfFinally(enclosingFinally, destination) {
  var finallyState = enclosingFinally.finallyState;
  // $ctx.state = finallyState;
  // $fallThrough = destination;
  return createStatementList(
      createAssignStateStatement(finallyState),
      parseStatement `$ctx.finallyFallThrough = ${destination}`);
}

function
generateAssignStateOutOfFinally
(
enclosingFinally
,
destination
)
{
var
finallyState
=
enclosingFinally
.
finallyState
;
// $ctx.state = finallyState;
// $fallThrough = destination;
return
createStatementList
(
createAssignStateStatement
(
finallyState
)
,
parseStatement
`
${
destination
}
`
)
;
}

Generate code for a jump out of a finally block.
@param {FinallyState} enclosingFinally
@param {number} destination
@return {Array.<ParseTree>}

Generate code for a jump out of a finally block .


function directory_path () {
      pending++
      readdir(entry, (err, children) => {
        if (err) return done(err)

        // Push children into pipeline, order is not important
        for (var i = children.length; i--;) {
          if (path !== null && base !== null) {
            files.push({ base, path: join(path, children[i]) })
          } else if (path !== null) {
            files.push({ base: null, path: join(path, children[i]) })
          } else {
            files.push({ base, path: children[i] })
          }
        }

        // Filter directory out of pipeline after adding children files
        pending--
        done(null, null)
      })
    }

If path is directory, read their children and push more onto `paths` This is the recursive operation that creates more file in the pipeline

If path is directory read their children and push more onto paths This is the recursive operation that creates more file in the pipeline


function file_path () {
      pending++
      for (var i = globs.length; i--;) {
        const glob = globs[i]
        const glob_full = glob.glob
        const glob_base = glob.base
        const glob_negated = glob.negated
        const glob_pattern = glob.pattern
        if (entry === glob_full || mm.isMatch(entry, glob_pattern, ALLOW)) {
          return done(null, file)
        }
      }

      // Did not match globs
      pending--
      done(null, null)
    }

function
file_path
(
)
{
pending
++
for
(
var
i
=
globs
.
length
;
i
;
)
{
const
glob
=
globs
[
i
]
const
glob_full
=
glob
.
glob
const
glob_base
=
glob
.
base
const
glob_negated
=
glob
.
negated
const
glob_pattern
=
glob
.
pattern
if
(
entry
===
glob_full
||
mm
.
isMatch
(
entry
,
glob_pattern
,
ALLOW
)
)
{
return
done
(
,
file
)
}
}
// Did not match globs
pending
done
(
,
)
}


function extend(a, b, noClone) { // A extends B
  a = a || {};

  if(typeof a !== 'object' || typeof a.length !== 'undefined'){
    return b;
  }

  if(typeof b !== 'object'){
    return b;
  }

  if(!noClone){
    a = clone(a);
  }

  var bk = Object.keys(b);
  for(var i = 0, c = bk.length; i < c; i++){
    var key = bk[i];
    if (!a.hasOwnProperty(key) || !(typeof b[key] === 'object' && typeof b[key].length === 'undefined') && typeof b[key] !== 'function') { // Simple types
      a[key] = b[key];
    } else { // Complex types
      a[key] = extend(a[key], b[key]);
    }
  }

  return a;
}

function
extend
(
a
,
b
,
noClone
)
{
// A extends B
a
=
a
||
{
}
;
if
(
typeof
a
!==
'object'
||
typeof
a
.
length
!==
'undefined'
)
{
return
b
;
}
if
(
typeof
b
!==
'object'
)
{
return
b
;
}
if
(
!
noClone
)
{
a
=
clone
(
a
)
;
}
var
bk
=
Object
.
keys
(
b
)
;
for
(
var
i
=
0
,
c
=
bk
.
length
;
i
<
c
;
i
++
)
{
var
key
=
bk
[
i
]
;
if
(
!
a
.
hasOwnProperty
(
key
)
||
!
(
typeof
b
[
key
]
===
'object'
&&
typeof
b
[
key
]
.
length
===
'undefined'
)
&&
typeof
b
[
key
]
!==
'function'
)
{
// Simple types
a
[
key
]
=
b
[
key
]
;
}
else
{
// Complex types
a
[
key
]
=
extend
(
a
[
key
]
,
b
[
key
]
)
;
}
}
return
a
;
}

A extends B

util.inherits works only with objects derived from Object

@return {Object} Extended object


function clone(o){
  var c = {};
  var h = Object.keys(o);
  for(var i = 0, co = h.length; i < co; i++){
    c[h[i]] = o[h[i]];
  }
  return c;
}

function clone ( o ) { var c = { } ; var h = Object . keys ( o ) ; for ( var i = 0 , co = h . length ; i < co ; i ++ ) { c [ h [ i ] ] = o [ h [ i ] ] ; } return c ; }

Function for creating a clone of an object

@param o {Object}  object to clone
@return {Object}


function fixPath(string){
  if(string.length < 1){
    return string;
  }

  if(string.charAt(string.length-1) !== path.sep){
    string += path.sep;
  }
  return string;
}

function fixPath ( string ) { if ( string . length < 1 ) { return string ; } if ( string . charAt ( string . length - 1 ) !== path . sep ) { string += path . sep ; } return string ; }

Function for appending path.sep to the end of string if necessary

@param string {String}
@return {String}

Function for appending path . sep to the end of string if necessary


function stringify(string, params, noError) {
  var arr = string.split(':');
  var param;
  for(var i = 0, c = arr.length; i < c; i++) {
    param = arr[i];
    if(i % 2){
      if(!(typeof params[param] === 'string' || typeof params[param] === 'number')){
        if(!noError){
          throw new Error('Variable ' + param + ' not defined');
        }
      } else {
        arr[i] = params[param];
      }
    }
  }
  return arr.join('');
}

function
stringify
(
string
,
params
,
noError
)
{
var
arr
=
string
.
split
(
':'
)
;
var
param
;
for
(
var
i
=
0
,
c
=
arr
.
length
;
i
<
c
;
i
++
)
{
param
=
arr
[
i
]
;
if
(
i
%
2
)
{
if
(
!
(
typeof
params
[
param
]
===
'string'
||
typeof
params
[
param
]
===
'number'
)
)
{
if
(
!
noError
)
{
throw
new
Error
(
'Variable '
+
param
+
' not defined'
)
;
}
}
else
{
arr
[
i
]
=
params
[
param
]
;
}
}
}
return
arr
.
join
(
''
)
;
}

Function for replacing paramteres in a string with variables

@param string  {String} string with placeholders
@param params  {Object} object containing parameters
@param noError {Boolean} wheter to break on missing or corrupt values
@return {String}


function cleanCallback(errorCallback, callback){
  var self = this || {};
  if(!callback){
    return function(err){ // remove other variables
      if(err && self.log){
        self.log('error',err);
      }
      errorCallback(err);
    }
  }

  return function(err){
    if(err){
      if(self.log){
        self.log('error',err);
      }
      errorCallback(err);
      return;
    }
    callback.apply(callback, Array.prototype.slice.call(arguments,1));
  }
}

function
cleanCallback
(
errorCallback
,
callback
)
{
var
self
=
this
||
{
}
;
if
(
!
callback
)
{
return
function
(
err
)
{
// remove other variables
if
(
err
&&
self
.
log
)
{
self
.
log
(
'error'
,
err
)
;
}
errorCallback
(
err
)
;
}
}
return
function
(
err
)
{
if
(
err
)
{
if
(
self
.
log
)
{
self
.
log
(
'error'
,
err
)
;
}
errorCallback
(
err
)
;
return
;
}
callback
.
apply
(
callback
,
Array
.
prototype
.
slice
.
call
(
arguments
,
1
)
)
;
}
}

Function for wraping callback to handle errors

@param {Function} errorCallback callback used upon error
@param {Function} [callback] callback used when no error


function iterateElements(array) {
  var index = 0;
  var rv = {};
  rv[Symbol.iterator] = {
      next() {
        if (index < array.length)
          return {value: array[index++], done: false};
        return {done: true};
      }
    }
  }

function iterateElements ( array ) { var index = 0 ; var rv = { } ; rv [ Symbol . iterator ] = { next ( ) { if ( index < array . length ) return { value : array [ index ++ ] , done : false } ; return { done : true } ; } } }

Example 1. Writing an iterator over an array

Example 1 . Writing an iterator over an array


function(fo,clear)
    {
        this.filters = fo;

        if(this.filters && this.filterFields)
        {
            //Delete filters that doesn't match with any field
            for(var fn in this.filters)
            {
                if(!this.filterFields[fn])
                    delete this.filters[fn];
            }

            for(var fn in this.filterFields)
            {
                var field = this.filterFields[fn];
                var value = this.filters[field.filterName];
                if(Ext.isEmpty(value))
                {
                    if(clear)
                        this.setFieldValue(field, '');
                }
                else
                    this.setFieldValue(field, value);
            }
        }
    }

Sets filter values by values specified into fo.
@param {Object} fo Object with attributes filterName = value
@param {Boolean} clear If current values must be cleared. Default = false

Sets filter values by values specified into fo .


function GedcomXDate(str) {

  if(str == '') {
    throw new Error('Invalid Date');
  }

  if(str.charAt(0) == 'R') {
    return new Recurring(str);
  } else if(/\//.test(str)) {
    return new Range(str);
  } else if(str.charAt(0) == 'A') {
    return new Approximate(str);
  } else {
    return new Simple(str);
  }
}

function
GedcomXDate
(
str
)
{
if
(
str
==
''
)
{
throw
new
Error
(
'Invalid Date'
)
;
}
if
(
str
.
charAt
(
0
)
==
'R'
)
{
return
new
Recurring
(
str
)
;
}
else
if
(
/
\/
/
.
test
(
str
)
)
{
return
new
Range
(
str
)
;
}
else
if
(
str
.
charAt
(
0
)
==
'A'
)
{
return
new
Approximate
(
str
)
;
}
else
{
return
new
Simple
(
str
)
;
}
}

A GedcomX Date.
This will parse the passed in string and return
the appropriate GedcomX Date object.

A GedcomX Date . This will parse the passed in string and return the appropriate GedcomX Date object .


function(toClose) {
        var me = this;
        if (toClose.active && me.items.getCount() > 1) {
            return (me.previousTab && me.previousTab !== toClose && !me.previousTab.disabled) ? me.previousTab : (toClose.next('tab[disabled=false]') || toClose.prev('tab[disabled=false]'));
        }
    }

function ( toClose ) { var me = this ; if ( toClose . active && me . items . getCount ( ) > 1 ) { return ( me . previousTab && me . previousTab !== toClose && ! me . previousTab . disabled ) ? me . previousTab : ( toClose . next ( 'tab[disabled=false]' ) || toClose . prev ( 'tab[disabled=false]' ) ) ; } }

private - used by TabPanel too. Works out the next tab to activate when one tab is closed.

private - used by TabPanel too . Works out the next tab to activate when one tab is closed .


function (autoRender, config) {
            if (!tip) {
                if (!Ext.isReady) {
                    Ext.onReady(function(){
                        Ext.tip.QuickTipManager.init(autoRender, config);
                    });
                    return;
                }

                var tipConfig = Ext.apply({ disabled: disabled, id: 'ext-quicktips-tip' }, config),
                    className = tipConfig.className,
                    xtype = tipConfig.xtype;

                if (className) {
                    delete tipConfig.className;
                } else if (xtype) {
                    className = 'widget.' + xtype;
                    delete tipConfig.xtype;
                }

                if (autoRender !== false) {
                    tipConfig.renderTo = document.body;

                    //<debug>
                    if (tipConfig.renderTo.tagName.toUpperCase() != 'BODY') { // e.g., == 'FRAMESET'
                        Ext.Error.raise({
                            sourceClass: 'Ext.tip.QuickTipManager',
                            sourceMethod: 'init',
                            msg: 'Cannot init QuickTipManager: no document body'
                        });
                    }
                    //</debug>
                }

                tip = Ext.create(className || 'Ext.tip.QuickTip', tipConfig);

                // private.
                // Need a globally accessble way of testing whether QuickTipsManager is both loaded AND initialized.
                Ext.quickTipsActive = true;
            }
        }

Initializes the global QuickTips instance and prepare any quick tips.
@param {Boolean} [autoRender=true] True to render the QuickTips container
immediately to preload images.
@param {Object} [config] config object for the created QuickTip. By
default, the {@link Ext.tip.QuickTip QuickTip} class is instantiated, but this can
be changed by supplying an xtype property or a className property in this object.
All other properties on this object are configuration for the created component.

Initializes the global QuickTips instance and prepare any quick tips .


function(el, id) {
        var me = this,
            childEls = me.getChildEls(),
            baseId, childName, i, selector, value;

        baseId = (id || me.id) + '-';
        for (i = childEls.length; i--; ) {
            childName = childEls[i];

            if (typeof childName == 'string') {
                // We don't use Ext.get because that is 3x (or more) slower on IE6-8. Since
                // we know the el's are children of our el we use getById instead:
                value = el.getById(baseId + childName);
            } else {
                if ((selector = childName.select)) {
                    value = Ext.select(selector, true, el.dom); // a CompositeElement
                } else if ((selector = childName.selectNode)) {
                    value = Ext.get(Ext.DomQuery.selectNode(selector, el.dom));
                } else {
                    // see above re:getById...
                    value = el.getById(childName.id || (baseId + childName.itemId));
                }

                childName = childName.name;
            }

            me[childName] = value;
        }
    }

Sets references to elements inside the component.
@private

Sets references to elements inside the component .


function (testFn) {
        var me = this,
            old = me.getChildEls(),
            keepers = (me.childEls = []),
            n, i, cel;

        for (i = 0, n = old.length; i < n; ++i) {
            cel = old[i];
            if (!testFn(cel)) {
                keepers.push(cel);
            }
        }
    }

function ( testFn ) { var me = this , old = me . getChildEls ( ) , keepers = ( me . childEls = [ ] ) , n , i , cel ; for ( i = 0 , n = old . length ; i < n ; ++ i ) { cel = old [ i ] ; if ( ! testFn ( cel ) ) { keepers . push ( cel ) ; } } }

Removes items in the childEls array based on the return value of a supplied test
function. The function is called with a entry in childEls and if the test function
return true, that entry is removed. If false, that entry is kept.

@param {Function} testFn The test function.

Removes items in the childEls array based on the return value of a supplied test function . The function is called with a entry in childEls and if the test function return true that entry is removed . If false that entry is kept .


function multiFieldSort(array, sortBy) {
	array.sort((a, b) => {
		for (let field of sortBy) {
			let reverse = field[0] === '-';
			if (reverse) {
				field = field.slice(1);
			}
			let valueA = getPath(a, field);
			let valueB = getPath(b, field);
			if (reverse) {
				if (valueA > valueB) return -1;
				else if (valueA < valueB) return 1;
			} else {
				if (valueA > valueB) return 1;
				else if (valueA < valueB) return -1;
			}
		}
		return 0;
	});
	return array;
}

function multiFieldSort ( array , sortBy ) { array . sort ( ( a , b ) => { for ( let field of sortBy ) { let reverse = field [ 0 ] === '-' ; if ( reverse ) { field = field . slice ( 1 ) ; } let valueA = getPath ( a , field ) ; let valueB = getPath ( b , field ) ; if ( reverse ) { if ( valueA > valueB ) return - 1 ; else if ( valueA < valueB ) return 1 ; } else { if ( valueA > valueB ) return 1 ; else if ( valueA < valueB ) return - 1 ; } } return 0 ; } ) ; return array ; }

This function sorts an array by multiple fields.

@method multiFieldSort
@param {Object[]} array - Array of objects to sort
@param {String[]} sortBy - Array of field names (optionally prefixed with '-')
@return {Object[]} - The input array.  It is also sorted in-place.

This function sorts an array by multiple fields .


function protect_split(separator, str) {
		var sep = '######';

		var string = false;
		var nb_brackets = 0;
		var new_str = "";
		for (var i = 0 ; i < str.length ; i++) {
			if (!string && /['"`]/.test(str[i])) string = str[i];
			else if (string && str[i] == string) string = false;
			else if (!string && str[i] == '(') nb_brackets ++;
			else if (!string && str[i] == ')') nb_brackets --;

			if (str[i] == separator && (nb_brackets > 0 || string)) new_str += sep;
			else new_str += str[i];
		}
		str = new_str;

		str = str.split(separator);
		str = str.map(function (item) {
			return trim(item.replace(new RegExp(sep, 'g'), separator));
		});

		return str;
	}

function protect_split ( separator , str ) { var sep = '######' ; var string = false ; var nb_brackets = 0 ; var new_str = "" ; for ( var i = 0 ; i < str . length ; i ++ ) { if ( ! string && / ['"`] / . test ( str [ i ] ) ) string = str [ i ] ; else if ( string && str [ i ] == string ) string = false ; else if ( ! string && str [ i ] == '(' ) nb_brackets ++ ; else if ( ! string && str [ i ] == ')' ) nb_brackets -- ; if ( str [ i ] == separator && ( nb_brackets > 0 || string ) ) new_str += sep ; else new_str += str [ i ] ; } str = new_str ; str = str . split ( separator ) ; str = str . map ( function ( item ) { return trim ( item . replace ( new RegExp ( sep , 'g' ) , separator ) ) ; } ) ; return str ; }

Split a string using a separator, only if this separator isn't beetween brackets

Split a string using a separator only if this separator isn t beetween brackets


function () {
			if (/\w/.test(this.currentChar)) return this.readWord();
			if (/["'`]/.test(this.currentChar)) return this.readString();
			if (/[()]/.test(this.currentChar)) return this.readGroupSymbol();
			if (/[!=<>]/.test(this.currentChar)) return this.readOperator();

			if (this.currentChar === "") return {type: 'eot', value: ''};
			else {
				this.readNextChar();
				return {type: 'empty', value: ''};
			}
		}

function ( ) { if ( / \w / . test ( this . currentChar ) ) return this . readWord ( ) ; if ( / ["'`] / . test ( this . currentChar ) ) return this . readString ( ) ; if ( / [()] / . test ( this . currentChar ) ) return this . readGroupSymbol ( ) ; if ( / [!=<>] / . test ( this . currentChar ) ) return this . readOperator ( ) ; if ( this . currentChar === "" ) return { type : 'eot' , value : '' } ; else { this . readNextChar ( ) ; return { type : 'empty' , value : '' } ; } }


function () {
			var astNode = "";

			// If this is a word/string, return its value
			if (this.currentToken.type == 'word' || this.currentToken.type == 'string') {
				astNode = this.currentToken.value;
				this.readNextToken();
			}
			// If this is a group, skip brackets and parse the inside
			else if (this.currentToken.type == 'group') {
				this.readNextToken();
				astNode = this.parseExpressionsRecursively();
				this.readNextToken();
			}

			return astNode;
		}


function diffText(a,b){
	var changes = []
	var text = a
	while(text !== b){
		var c = partiallyDiffText(text,b)
		if(c.type === 'add'){
			text = text.substr(0,c.index)+c.value+text.substr(c.index)
		}else{
			text = text.substr(0,c.index)+text.substr(c.index+c.many)
		}
		changes.push(c)
	}

	return changes
}

function diffText ( a , b ) { var changes = [ ] var text = a while ( text !== b ) { var c = partiallyDiffText ( text , b ) if ( c . type === 'add' ) { text = text . substr ( 0 , c . index ) + c . value + text . substr ( c . index ) } else { text = text . substr ( 0 , c . index ) + text . substr ( c . index + c . many ) } changes . push ( c ) } return changes }

produces one or two changes that succinctly describe the changes to the text


function(store, initial){
        var me = this;
        me.mixins.bindable.bindStore.apply(me, arguments);
        if(me.store && !initial) {
            me.refresh();
        }
    }

function ( store , initial ) { var me = this ; me . mixins . bindable . bindStore . apply ( me , arguments ) ; if ( me . store && ! initial ) { me . refresh ( ) ; } }


function(suppressEvent) {
        var me = this,
            selections = me.store.getRange(),
            i = 0,
            len = selections.length,
            start = me.getSelection().length;

        me.bulkChange = true;
        for (; i < len; i++) {
            me.doSelect(selections[i], true, suppressEvent);
        }
        delete me.bulkChange;
        // fire selection change only if the number of selections differs
        me.maybeFireSelectionChange(me.getSelection().length !== start);
    }

Selects all records in the view.
@param {Boolean} suppressEvent True to suppress any select events


function(record, e, keepExisting) {
        var me = this,
            isSelected = me.isSelected(record);

        switch (me.selectionMode) {
            case 'MULTI':
                if (e.shiftKey && me.selectionStart) {
                    me.selectRange(me.selectionStart, record, e.ctrlKey);
                } else if (e.ctrlKey && isSelected) {
                    me.doDeselect(record, false);
                } else if (e.ctrlKey) {
                    me.doSelect(record, true, false);
                } else if (isSelected && !e.shiftKey && !e.ctrlKey && me.selected.getCount() > 1) {
                    me.doSelect(record, keepExisting, false);
                } else if (!isSelected) {
                    me.doSelect(record, false);
                }
                break;
            case 'SIMPLE':
                if (isSelected) {
                    me.doDeselect(record);
                } else {
                    me.doSelect(record, true);
                }
                break;
            case 'SINGLE':
                // if allowDeselect is on and this record isSelected, deselect it
                if (me.allowDeselect && isSelected) {
                    me.doDeselect(record);
                // select the record and do NOT maintain existing selections
                } else {
                    me.doSelect(record, false);
                }
                break;
        }

        // selectionStart is a start point for shift/mousedown to create a range from.
        // If the mousedowned record was not already selected, then it becomes the
        // start of any range created from now on.
        // If we drop to no records selected, then there is no range start any more.
        if (!e.shiftKey) {
            if (me.isSelected(record)) {
                me.selectionStart = record;
            } else {
                me.selectionStart = null;
            }
        }
    }

Provides differentiation of logic between MULTI, SIMPLE and SINGLE selection modes. Requires that an event be passed so that we can know if user held ctrl or shift.

Provides differentiation of logic between MULTI SIMPLE and SINGLE selection modes . Requires that an event be passed so that we can know if user held ctrl or shift .


function(e, record) {
        var me = this,
            recIdx,
            fromIdx,
            isSelected = me.isSelected(record),
            from = (me.selectionStart && me.isSelected(me.lastFocused)) ? me.selectionStart : (me.selectionStart = me.lastFocused),
            key = e.getCharCode(),
            isSpace = key === e.SPACE,
            direction = key === e.UP || key === e.PAGE_UP ? 'up' : (key === e.DOWN || key === e.DOWN ? 'down' : null);

        switch (me.selectionMode) {
            case 'MULTI':

                if (isSpace) {
                    // SHIFT+SPACE, select range
                    if (e.shiftKey) {
                        me.selectRange(from, record, e.ctrlKey);
                    } else {
                        // SPACE pessed on a selected item: deselect but leave it focused.
                        // e.ctrlKey means "keep existing"
                        if (isSelected) {
                            me.doDeselect(record, e.ctrlKey);

                            // This record is already focused. To get the focus effect put on it (as opposed to selected)
                            // we have to focus null first.
                            me.setLastFocused(null);
                            me.setLastFocused(record);
                        }
                        // SPACE on an unselected item: select it
                        else {
                            me.doSelect(record, e.ctrlKey);
                        }
                    }
                }

                // SHIFT-navigate selects intervening rows from the last selected (or last focused) item and target item
                else if (e.shiftKey && from) {

                    // If we are going back *into* the selected range, we deselect.
                    fromIdx = me.store.indexOf(from);
                    recIdx = me.store.indexOf(record);

                    // If we are heading back TOWARDS the start rec - deselect skipped range...
                    if (direction === 'up' && fromIdx <= recIdx) {
                        me.deselectRange(me.lastFocused, recIdx + 1);
                    }
                    else if (direction === 'down' && fromIdx >= recIdx) {
                        me.deselectRange(me.lastFocused, recIdx - 1);
                    }

                    // If we are heading AWAY from start point, or no CTRL key, so just select the range and let the CTRL control "keepExisting"...
                    else if (from !== record) {
                        me.selectRange(from, record, e.ctrlKey);
                    }
                    me.lastSelected = record;
                    me.setLastFocused(record);
                }

                // CTRL-navigate onto a selected item just focuses it
                else if (e.ctrlKey && isSelected) {
                    me.setLastFocused(record);
                }

                // CTRL-navigate, just move focus
                else if (e.ctrlKey) {
                    me.setLastFocused(record);
                }

                // Just navigation - select the target
                else {
                    me.doSelect(record, false);
                }
                break;
            case 'SIMPLE':
                if (isSelected) {
                    me.doDeselect(record);
                } else {
                    me.doSelect(record, true);
                }
                break;
            case 'SINGLE':
                // Space hit
                if (isSpace) {
                    if (isSelected) {
                        me.doDeselect(record);
                        me.setLastFocused(record);
                    } else {
                        me.doSelect(record);
                    }
                }

                // CTRL-navigation: just move focus
                else if (e.ctrlKey) {
                    me.setLastFocused(record);
                }

                // if allowDeselect is on and this record isSelected, deselect it
                else if (me.allowDeselect && isSelected) {
                    me.doDeselect(record);
                }

                // select the record and do NOT maintain existing selections
                else {
                    me.doSelect(record, false);
                }
                break;
        }

        // selectionStart is a start point for shift/mousedown to create a range from.
        // If the mousedowned record was not already selected, then it becomes the
        // start of any range created from now on.
        // If we drop to no records selected, then there is no range start any more.
        if (!e.shiftKey) {
            if (me.isSelected(record)) {
                me.selectionStart = record;
            }
        }
    }

Private Called after a new record has been navigated to by a keystroke. Event is passed so that shift and ctrl can be handled.

Private Called after a new record has been navigated to by a keystroke . Event is passed so that shift and ctrl can be handled .


function(fireEvent) {
        var me = this;
        if (fireEvent && !me.bulkChange) {
            me.fireEvent('selectionchange', me, me.getSelection());
        }
    }

function ( fireEvent ) { var me = this ; if ( fireEvent && ! me . bulkChange ) { me . fireEvent ( 'selectionchange' , me , me . getSelection ( ) ) ; } }

fire selection change as long as true is not passed into maybeFireSelectionChange


function(record) {
        record = Ext.isNumber(record) ? this.store.getAt(record) : record;
        return this.selected.contains(record);
    }

function ( record ) { record = Ext . isNumber ( record ) ? this . store . getAt ( record ) : record ; return this . selected . contains ( record ) ; }

Returns true if the specified row is selected.
@param {Ext.data.Model/Number} record The record or index of the record to check
@return {Boolean}

Returns true if the specified row is selected .


function(store, records, indexes, isMove) {
        var me = this;

        // If the selection start point is among records being removed, we no longer have a selection start point.
        if (me.selectionStart && Ext.Array.contains(records, me.selectionStart)) {
            me.selectionStart = null;
        }

        if (isMove || me.locked || !me.pruneRemoved) {
            return;
        }
        me.deselectDeletedRecords(records);
    }

prune records from the SelectionModel if they were selected at the time they were removed.

prune records from the SelectionModel if they were selected at the time they were removed .


function deployRules({client, rules, secret}) {
  const lastRequest = rulesRequests.get(client.projectId);

  return Promise.resolve(lastRequest).then(oldRulesHash => {
    const newRuleHash = hash(rules);

    if (oldRulesHash === newRuleHash) {
      return oldRulesHash;
    }

    const request = client.rules({rules, secret});

    rulesRequests.set(client.projectId, request.then(
      () => newRuleHash,
      () => oldRulesHash
    ));

    return request;
  });
}

function deployRules ( { client , rules , secret } ) { const lastRequest = rulesRequests . get ( client . projectId ) ; return Promise . resolve ( lastRequest ) . then ( oldRulesHash => { const newRuleHash = hash ( rules ) ; if ( oldRulesHash === newRuleHash ) { return oldRulesHash ; } const request = client . rules ( { rules , secret } ) ; rulesRequests . set ( client . projectId , request . then ( ( ) => newRuleHash , ( ) => oldRulesHash ) ) ; return request ; } ) ; }

Deploy rules for a database project.

It deploy the rules only if the previous deployed rules were different.

@param  {object}     options          Request options
@param  {RestClient} options.client   Client
@param  {object}     options.rules    Rules to deploy
@param  {string}     options.secret   Secret to authenticate the request
@return {Promise<void,Error>}


function lock(client, sequence) {
  const lastSequence = sequences.get(client.projectId);

  return Promise.resolve(lastSequence).then(() => {
    const result = sequence();

    sequences.set(client.projectId, result.then(noop, noop));

    return result;
  });
}

function lock ( client , sequence ) { const lastSequence = sequences . get ( client . projectId ) ; return Promise . resolve ( lastSequence ) . then ( ( ) => { const result = sequence ( ) ; sequences . set ( client . projectId , result . then ( noop , noop ) ) ; return result ; } ) ; }

Run a sequence once the previous sequence for that project id ends.

@param  {{projectId: string}}             client   Rest client
@param  {function(): Promise<void,Error>} sequence Sequence to run
@return {Promise<void,Error>}

Run a sequence once the previous sequence for that project id ends .


function () {
        var renderData = this.callParent();

        if (this.owner.getHierarchyState().rtl) {
            renderData.innerCtCls =
                (renderData.innerCtCls || '') + ' ' + Ext.baseCSSPrefix + 'rtl';
        }

        return renderData;
    }

function
(
)
{
var
renderData
=
this
.
callParent
(
)
;
if
(
this
.
owner
.
getHierarchyState
(
)
.
rtl
)
{
renderData
.
innerCtCls
=
(
renderData
.
innerCtCls
||
''
)
+
' '
+
Ext
.
baseCSSPrefix
+
'rtl'
;
}
return
renderData
;
}

Override to put the RTL class onto the innerCt so that columns can have a rule which switches float direction


function(o) {
        var me = this;

        o.un({
            scope: me,
            mousedown: me.onMouseDown,
            mouseup: me.onMouseUp,
            mouseover: me.onMouseOver,
            mouseout: me.onMouseOut,
            click: me.onClick
        });
        return me.callParent(arguments);
    }

function ( o ) { var me = this ; o . un ( { scope : me , mousedown : me . onMouseDown , mouseup : me . onMouseUp , mouseover : me . onMouseOver , mouseout : me . onMouseOut , click : me . onClick } ) ; return me . callParent ( arguments ) ; }


function(redraw) {
        var i = 0,
            items = this.items,
            len = this.length;

        for (; i < len; i++) {
            items[i].hide(redraw);
        }
        return this;
    }

function ( redraw ) { var i = 0 , items = this . items , len = this . length ; for ( ; i < len ; i ++ ) { items [ i ] . hide ( redraw ) ; } return this ; }

Hides all sprites. If `true` is passed then a redraw will be forced for each sprite.
@param {Boolean} redraw Flag to immediately draw the change.
@return {Ext.draw.CompositeSprite} this

Hides all sprites . If true is passed then a redraw will be forced for each sprite .


function(redraw) {
        var i = 0,
            items = this.items,
            len = this.length;

        for (; i < len; i++) {
            items[i].show(redraw);
        }
        return this;
    }

function ( redraw ) { var i = 0 , items = this . items , len = this . length ; for ( ; i < len ; i ++ ) { items [ i ] . show ( redraw ) ; } return this ; }

Shows all sprites. If `true` is passed then a redraw will be forced for each sprite.
@param {Boolean} redraw Flag to immediately draw the change.
@return {Ext.draw.CompositeSprite} this

Shows all sprites . If true is passed then a redraw will be forced for each sprite .


function() {
        var me = this,
            i = 0,
            items = me.items,
            surface = me.getSurface(),
            len = me.length;

        if (surface) {
            for (; i < len; i++) {
                surface.renderItem(items[i]);
            }
        }
        return me;
    }

function ( ) { var me = this , i = 0 , items = me . items , surface = me . getSurface ( ) , len = me . length ; if ( surface ) { for ( ; i < len ; i ++ ) { surface . renderItem ( items [ i ] ) ; } } return me ; }


function(obj) {
        var i = 0,
            items = this.items,
            len = this.length,
            item, el;

        for (; i < len; i++) {
            item = items[i];
            el = item.el;
            if (el) {
                el.setStyle(obj);
            }
        }
    }

function ( obj ) { var i = 0 , items = this . items , len = this . length , item , el ; for ( ; i < len ; i ++ ) { item = items [ i ] ; el = item . el ; if ( el ) { el . setStyle ( obj ) ; } } }

Sets style for all sprites.
@param {String} style CSS Style definition.


function(obj) {
        var i = 0,
            items = this.items,
            surface = this.getSurface(),
            len = this.length;

        if (surface) {
            for (; i < len; i++) {
                surface.addCls(items[i], obj);
            }
        }
    }

function ( obj ) { var i = 0 , items = this . items , surface = this . getSurface ( ) , len = this . length ; if ( surface ) { for ( ; i < len ; i ++ ) { surface . addCls ( items [ i ] , obj ) ; } } }

Adds class to all sprites.
@param {String} cls CSS class name


function(obj) {
        var i = 0,
            items = this.items,
            surface = this.getSurface(),
            len = this.length;

        if (surface) {
            for (; i < len; i++) {
                surface.removeCls(items[i], obj);
            }
        }
    }

function ( obj ) { var i = 0 , items = this . items , surface = this . getSurface ( ) , len = this . length ; if ( surface ) { for ( ; i < len ; i ++ ) { surface . removeCls ( items [ i ] , obj ) ; } } }

Removes class from all sprites.
@param {String} cls CSS class name


function(){
        var me = this,
            surface = me.getSurface(),
            destroySprites = me.autoDestroy,
            item;

        if (surface) {
            while (me.getCount() > 0) {
                item = me.first();
                me.remove(item);
                surface.remove(item, destroySprites);
            }
        }
        me.clearListeners();
    }

function ( ) { var me = this , surface = me . getSurface ( ) , destroySprites = me . autoDestroy , item ; if ( surface ) { while ( me . getCount ( ) > 0 ) { item = me . first ( ) ; me . remove ( item ) ; surface . remove ( item , destroySprites ) ; } } me . clearListeners ( ) ; }


function(config){
        var me = this,
            o, key, value;

        me.copyLegacyObject(config, me.customRenderers, 'renderer');
        me.copyLegacyObject(config, me.customEditors, 'editor');
        me.copyLegacyObject(config, me.propertyNames, 'displayName');

        //<debug>
        // exclude types since it's new
        if (me.customRenderers || me.customEditors || me.propertyNames) {
            if (Ext.global.console && Ext.global.console.warn) {
                Ext.global.console.warn(this.$className, 'customRenderers, customEditors & propertyNames have been consolidated into a new config, see "sourceConfig". These configurations will be deprecated.');
            }
        }
        //</debug>
    }


function(pos, direction, e, preventWrap, verifierFn, scope) {
        if (direction == 'left') {
            direction = 'up';
        } else if (direction == 'right') {
            direction = 'down';
        }
        pos = Ext.view.Table.prototype.walkCells.call(this, pos, direction, e, preventWrap, verifierFn, scope);
        if (pos && !pos.column) {
            pos.column = 1;
        }
        return pos;
    }

function ( pos , direction , e , preventWrap , verifierFn , scope ) { if ( direction == 'left' ) { direction = 'up' ; } else if ( direction == 'right' ) { direction = 'down' ; } pos = Ext . view . Table . prototype . walkCells . call ( this , pos , direction , e , preventWrap , verifierFn , scope ) ; if ( pos && ! pos . column ) { pos . column = 1 ; } return pos ; }

Custom implementation of walkCells which only goes up and down.

Custom implementation of walkCells which only goes up and down .


function init() {
	tinyMCEPopup.resizeToInnerSize();
	var inst = tinyMCEPopup.editor;
	var dom = inst.dom;
	var elm = inst.selection.getNode();
	var f = document.forms[0];
	var onclick = dom.getAttrib(elm, 'onclick');

	setFormValue('title', dom.getAttrib(elm, 'title'));
	setFormValue('id', dom.getAttrib(elm, 'id'));
	setFormValue('style', dom.getAttrib(elm, "style"));
	setFormValue('dir', dom.getAttrib(elm, 'dir'));
	setFormValue('lang', dom.getAttrib(elm, 'lang'));
	setFormValue('tabindex', dom.getAttrib(elm, 'tabindex', typeof(elm.tabindex) != "undefined" ? elm.tabindex : ""));
	setFormValue('accesskey', dom.getAttrib(elm, 'accesskey', typeof(elm.accesskey) != "undefined" ? elm.accesskey : ""));
	setFormValue('onfocus', dom.getAttrib(elm, 'onfocus'));
	setFormValue('onblur', dom.getAttrib(elm, 'onblur'));
	setFormValue('onclick', onclick);
	setFormValue('ondblclick', dom.getAttrib(elm, 'ondblclick'));
	setFormValue('onmousedown', dom.getAttrib(elm, 'onmousedown'));
	setFormValue('onmouseup', dom.getAttrib(elm, 'onmouseup'));
	setFormValue('onmouseover', dom.getAttrib(elm, 'onmouseover'));
	setFormValue('onmousemove', dom.getAttrib(elm, 'onmousemove'));
	setFormValue('onmouseout', dom.getAttrib(elm, 'onmouseout'));
	setFormValue('onkeypress', dom.getAttrib(elm, 'onkeypress'));
	setFormValue('onkeydown', dom.getAttrib(elm, 'onkeydown'));
	setFormValue('onkeyup', dom.getAttrib(elm, 'onkeyup'));
	className = dom.getAttrib(elm, 'class');

	addClassesToList('classlist', 'advlink_styles');
	selectByValue(f, 'classlist', className, true);

	TinyMCE_EditableSelects.init();
}

function init ( ) { tinyMCEPopup . resizeToInnerSize ( ) ; var inst = tinyMCEPopup . editor ; var dom = inst . dom ; var elm = inst . selection . getNode ( ) ; var f = document . forms [ 0 ] ; var onclick = dom . getAttrib ( elm , 'onclick' ) ; setFormValue ( 'title' , dom . getAttrib ( elm , 'title' ) ) ; setFormValue ( 'id' , dom . getAttrib ( elm , 'id' ) ) ; setFormValue ( 'style' , dom . getAttrib ( elm , "style" ) ) ; setFormValue ( 'dir' , dom . getAttrib ( elm , 'dir' ) ) ; setFormValue ( 'lang' , dom . getAttrib ( elm , 'lang' ) ) ; setFormValue ( 'tabindex' , dom . getAttrib ( elm , 'tabindex' , typeof ( elm . tabindex ) != "undefined" ? elm . tabindex : "" ) ) ; setFormValue ( 'accesskey' , dom . getAttrib ( elm , 'accesskey' , typeof ( elm . accesskey ) != "undefined" ? elm . accesskey : "" ) ) ; setFormValue ( 'onfocus' , dom . getAttrib ( elm , 'onfocus' ) ) ; setFormValue ( 'onblur' , dom . getAttrib ( elm , 'onblur' ) ) ; setFormValue ( 'onclick' , onclick ) ; setFormValue ( 'ondblclick' , dom . getAttrib ( elm , 'ondblclick' ) ) ; setFormValue ( 'onmousedown' , dom . getAttrib ( elm , 'onmousedown' ) ) ; setFormValue ( 'onmouseup' , dom . getAttrib ( elm , 'onmouseup' ) ) ; setFormValue ( 'onmouseover' , dom . getAttrib ( elm , 'onmouseover' ) ) ; setFormValue ( 'onmousemove' , dom . getAttrib ( elm , 'onmousemove' ) ) ; setFormValue ( 'onmouseout' , dom . getAttrib ( elm , 'onmouseout' ) ) ; setFormValue ( 'onkeypress' , dom . getAttrib ( elm , 'onkeypress' ) ) ; setFormValue ( 'onkeydown' , dom . getAttrib ( elm , 'onkeydown' ) ) ; setFormValue ( 'onkeyup' , dom . getAttrib ( elm , 'onkeyup' ) ) ; className = dom . getAttrib ( elm , 'class' ) ; addClassesToList ( 'classlist' , 'advlink_styles' ) ; selectByValue ( f , 'classlist' , className , true ) ; TinyMCE_EditableSelects . init ( ) ; }

attributes.js

Copyright 2009, Moxiecode Systems AB
Released under LGPL License.

License: http://tinymce.moxiecode.com/license
Contributing: http://tinymce.moxiecode.com/contributing


function(columns) {
        var i,
            len = columns.length,
            column;

        for (i = 0; i < len; i++) {
            column = columns[i];
            if (!column.processed && column.locked) {
                return true;
            }
        }
    }

function ( columns ) { var i , len = columns . length , column ; for ( i = 0 ; i < len ; i ++ ) { column = columns [ i ] ; if ( ! column . processed && column . locked ) { return true ; } } }

Private. Determine if there are any columns with a locked configuration option

Private . Determine if there are any columns with a locked configuration option


function(headerCt, header, colsToMove, fromIdx, toIdx) {
        var me = this;

        // If there are Features or Plugins which create DOM which must match column order, they set the optimizedColumnMove flag to false.
        // In this case we must refresh the view on column move.
        if (me.optimizedColumnMove === false) {
            me.view.refresh();
        }

        // Simplest case for default DOM structure is just to swap the columns round in the view.
        else {
            me.view.moveColumn(fromIdx, toIdx, colsToMove);
        }
        me.delayScroll();
    }


function() {
        var me = this;
        return me.lhsMarker || (me.lhsMarker = Ext.DomHelper.append(me.el, {
            cls: me.resizeMarkerCls
        }, true));
    }

function ( ) { var me = this ; return me . lhsMarker || ( me . lhsMarker = Ext . DomHelper . append ( me . el , { cls : me . resizeMarkerCls } , true ) ) ; }

Gets left hand side marker for header resizing.
@private

Gets left hand side marker for header resizing .


function() {
            var animateWithClass = this.animateClearButton && this.animateWithCss3;
            this.clearButtonEl = this.textField.bodyEl.createChild({
                tag: 'div',
                cls: this.clearButtonCls
            });
            if(this.animateClearButton) {
                this.animateWithCss3 = this.supportsCssTransition(this.clearButtonEl);
            }
            if(this.animateWithCss3) {
                this.clearButtonEl.addCls(this.clearButtonCls + '-off');
            }
            else {
                this.clearButtonEl.setStyle('visibility', 'hidden');
            }
        }

function ( ) { var animateWithClass = this . animateClearButton && this . animateWithCss3 ; this . clearButtonEl = this . textField . bodyEl . createChild ( { tag : 'div' , cls : this . clearButtonCls } ) ; if ( this . animateClearButton ) { this . animateWithCss3 = this . supportsCssTransition ( this . clearButtonEl ) ; } if ( this . animateWithCss3 ) { this . clearButtonEl . addCls ( this . clearButtonCls + '-off' ) ; } else { this . clearButtonEl . setStyle ( 'visibility' , 'hidden' ) ; } }

Creates the Element and DOM for the clear button


function(el) {
            var styles = ['transitionProperty', 'WebkitTransitionProperty', 'MozTransitionProperty',
                          'OTransitionProperty', 'msTransitionProperty', 'KhtmlTransitionProperty'];

            var style = el.dom.style;
            for(var i = 0, length = styles.length; i < length; ++i) {
                if(style[styles[i]] !== 'undefined') {
                    // Supported property will result in empty string
                    return true;
                }
            }
            return false;
        }

Returns true iff the browser supports CSS 3 transitions
@param el an element that is checked for support of the "transition" CSS property (considering any
vendor prefixes)


function() {
            if (!this.clearOnEscape) {
                return;
            }

            // Using a KeyMap did not work: ESC is swallowed by combo box and date field before it reaches our own KeyMap
            this.textField.inputEl.on('keydown',
                function(e) {
                    if (e.getKey() == Ext.EventObject.ESC) {
                        if (this.textField.isExpanded) {
                            // Let combo box or date field first remove the popup
                            return;
                        }
                        // No idea why the defer is necessary, but otherwise the call to setValue('') is ignored

						// 2011-11-30 Ing. Leonardo D'Onofrio leonardo_donofrio at hotmail.com
						if (this.textField.clearValue) {
							Ext.Function.defer(this.textField.clearValue, 1, this.textField);
						} else {
							Ext.Function.defer(this.textField.setValue, 1, this.textField, ['']);
						}
                        // end Ing. Leonardo D'Onofrio
						e.stopEvent();
                    }
                },
                this);
        }

If config option "clearOnEscape" is true, then add a key listener that will clear this field

If config option clearOnEscape is true then add a key listener that will clear this field


function() {
            var clearButtonEl = this.clearButtonEl;
            if (!clearButtonEl) {
                return;
            }
            var right = 0;
            if (this.fieldHasScrollBar()) {
                right += Ext.getScrollBarWidth();
            }
            if (this.textField.triggerWrap) {
                right += this.textField.getTriggerWidth();
            }
            clearButtonEl.alignTo(this.textField.bodyEl, 'tr-tr', [-1 * (right + 3), 5]);
        }

function ( ) { var clearButtonEl = this . clearButtonEl ; if ( ! clearButtonEl ) { return ; } var right = 0 ; if ( this . fieldHasScrollBar ( ) ) { right += Ext . getScrollBarWidth ( ) ; } if ( this . textField . triggerWrap ) { right += this . textField . getTriggerWidth ( ) ; } clearButtonEl . alignTo ( this . textField . bodyEl , 'tr-tr' , [ - 1 * ( right + 3 ) , 5 ] ) ; }

Repositions the clear button element based on the textfield.inputEl element
@private
 /* FIX FOR 4.1 /*
repositionClearButton: function() {
var clearButtonEl = this.clearButtonEl;
if (!clearButtonEl) {
return;
}
var clearButtonPosition = this.calculateClearButtonPosition(this.textField);
clearButtonEl.dom.style.right = clearButtonPosition.right + 'px';
clearButtonEl.dom.style.top = clearButtonPosition.top + 'px';
},

Repositions the clear button element based on the textfield . inputEl element


function() {
            if (!this.isTextArea) {
                return false;
            }

            var inputEl = this.textField.inputEl;
            var overflowY = inputEl.getStyle('overflow-y');
            if (overflowY == 'hidden' || overflowY == 'visible') {
                return false;
            }
            if (overflowY == 'scroll') {
                return true;
            }
            //noinspection RedundantIfStatementJS
            if (inputEl.dom.scrollHeight <= inputEl.dom.clientHeight) {
                return false;
            }
            return true;
        }

function
(
)
{
if
(
!
this
.
isTextArea
)
{
return
false
;
}
var
inputEl
=
this
.
textField
.
inputEl
;
var
overflowY
=
inputEl
.
getStyle
(
'overflow-y'
)
;
if
(
overflowY
==
'hidden'
||
overflowY
==
'visible'
)
{
return
false
;
}
if
(
overflowY
==
'scroll'
)
{
return
true
;
}
//noinspection RedundantIfStatementJS
if
(
inputEl
.
dom
.
scrollHeight
<=
inputEl
.
dom
.
clientHeight
)
{
return
false
;
}
return
true
;
}

Checks if the field we are attached to currently has a scrollbar


function() {
            if (this.hideClearButtonWhenEmpty && Ext.isEmpty(this.textField.getValue())) {
                return false;
            }

            var clearButtonEl = this.clearButtonEl;
            //noinspection RedundantIfStatementJS
            if (this.hideClearButtonWhenMouseOut
                && !clearButtonEl.hasCls(this.clearButtonCls + '-mouse-over-button')
                && !clearButtonEl.hasCls(this.clearButtonCls + '-mouse-over-input')) {
                return false;
            }

            return true;
        }

function
(
)
{
if
(
this
.
hideClearButtonWhenEmpty
&&
Ext
.
isEmpty
(
this
.
textField
.
getValue
(
)
)
)
{
return
false
;
}
var
clearButtonEl
=
this
.
clearButtonEl
;
//noinspection RedundantIfStatementJS
if
(
this
.
hideClearButtonWhenMouseOut
&&
!
clearButtonEl
.
hasCls
(
this
.
clearButtonCls
+
'-mouse-over-button'
)
&&
!
clearButtonEl
.
hasCls
(
this
.
clearButtonCls
+
'-mouse-over-input'
)
)
{
return
false
;
}
return
true
;
}

Checks config options and current mouse status to determine if the clear button should be visible.

Checks config options and current mouse status to determine if the clear button should be visible .


function() {
            var oldVisible = this.isButtonCurrentlyVisible();
            var newVisible = this.shouldButtonBeVisible();

            var clearButtonEl = this.clearButtonEl;
            if (oldVisible != newVisible) {
                if(this.animateClearButton && this.animateWithCss3) {
                    this.clearButtonEl.removeCls(this.clearButtonCls + (oldVisible ? '-on' : '-off'));
                    clearButtonEl.addCls(this.clearButtonCls + (newVisible ? '-on' : '-off'));
                }
                else {
                    clearButtonEl.stopAnimation();
                    clearButtonEl.setVisible(newVisible, this.animateClearButton);
                }

                // Set background-color of clearButton to same as field's background-color (for those browsers/cases
                // where the padding-right (see below) does not work)
                clearButtonEl.setStyle('background-color', this.textField.inputEl.getStyle('background-color'));

                // Adjust padding-right of the input tag to make room for the button
                // IE (up to v9) just ignores this and Gecko handles padding incorrectly with  textarea scrollbars
                if (!(this.isTextArea && Ext.isGecko) && !Ext.isIE) {
                    // See https://bugzilla.mozilla.org/show_bug.cgi?id=157846
                    var deltaPaddingRight = clearButtonEl.getWidth() - this.clearButtonEl.getMargin('l');
                    var currentPaddingRight = this.textField.inputEl.getPadding('r');
                    var factor = (newVisible ? +1 : -1);
                    this.textField.inputEl.dom.style.paddingRight = (currentPaddingRight + factor * deltaPaddingRight) + 'px';
                }
            }
        }

Called after any event that may influence the clear button visibility.

Called after any event that may influence the clear button visibility .


function quit(message, line, chr) {
        var percentage = Math.floor((line / lines.length) * 100);

        throw {
            name: 'JSHintError',
            line: line,
            character: chr,
            message: message + " (" + percentage + "% scanned).",
            raw: message
        };
    }

function
quit
(
message
,
line
,
chr
)
{
var
percentage
=
Math
.
floor
(
(
line
/
lines
.
length
)
*
100
)
;
throw
{
name
:
'JSHintError'
,
line
:
line
,
character
:
chr
,
message
:
message
+
" ("
+
percentage
+
"% scanned)."
,
raw
:
message
}
;
}


function saveProperty(name, token) {
                if (props[name] && is_own(props, name))
                    warning("Duplicate member '{a}'.", nexttoken, i);
                else
                    props[name] = {};

                props[name].basic = true;
                props[name].basicToken = token;
            }

function
saveProperty
(
name
,
token
)
{
if
(
props
[
name
]
&&
is_own
(
props
,
name
)
)
warning
(
"Duplicate member '{a}'."
,
nexttoken
,
i
)
;
else
props
[
name
]
=
{
}
;
props
[
name
]
.
basic
=
true
;
props
[
name
]
.
basicToken
=
token
;
}


function makePow(left, prev) {
  if (left.isEmpty()) {
    return prev;
  }
  const elem = left.first();
  return makePow(
    left.remove(elem),
    prev.union(prev.map(e => e.add(elem)))
  );
}

function makePow ( left , prev ) { if ( left . isEmpty ( ) ) { return prev ; } const elem = left . first ( ) ; return makePow ( left . remove ( elem ) , prev . union ( prev . map ( e => e . add ( elem ) ) ) ) ; }

tail recursive helper without sanity checks


Private methods HTML -> BBCode in PunBB dialect

Private methods HTML - > BBCode in PunBB dialect


function (childContext, axis) {
        var collapseTarget = childContext.collapseTarget,
            setSizeMethod = 'set' + axis.sizePropCap,
            sizeProp = axis.sizeProp,
            childMarginSize = childContext.getMarginInfo()[sizeProp],
            region, isBegin, flex, pos, size;

        if (collapseTarget) { // if (splitter)
            region = collapseTarget.region;
        } else {
            region = childContext.region;
            flex = childContext.flex;
        }

        isBegin = region == axis.borderBegin;

        if (!isBegin && region != axis.borderEnd) {
            // a north/south region on the horizontal axis or an east/west region on the
            // vertical axis: stretch to fill remaining space:
            childContext[setSizeMethod](axis.end - axis.begin - childMarginSize);
            pos = axis.begin;
        } else {
            if (flex) {
                size = Math.ceil(axis.flexSpace * (flex / axis.totalFlex));
                size = childContext[setSizeMethod](size);
            } else if (childContext.percentage) {
                // Like getProp but without registering a dependency - we calculated the size, we don't depend on it
                size = childContext.peek(sizeProp);
            } else {
                size = childContext.getProp(sizeProp);
            }

            size += childMarginSize;

            if (isBegin) {
                pos = axis.begin;
                axis.begin += size;
            } else {
                axis.end = pos = axis.end - size;
            }
        }

        childContext.layoutPos[axis.posProp] = pos;
    }

Performs the calculations for a region on a specified axis.
@private

Performs the calculations for a region on a specified axis .


function (ownerContext, axis) {
        var size = axis.end - axis.begin,
            center = ownerContext.centerRegion;

        if (center) {
            center['set' + axis.sizePropCap](size - center.getMarginInfo()[axis.sizeProp]);
            center.layoutPos[axis.posProp] = axis.begin;
        }

        return Ext.isNumber(size) ? 1 : 0;
    }

function ( ownerContext , axis ) { var size = axis . end - axis . begin , center = ownerContext . centerRegion ; if ( center ) { center [ 'set' + axis . sizePropCap ] ( size - center . getMarginInfo ( ) [ axis . sizeProp ] ) ; center . layoutPos [ axis . posProp ] = axis . begin ; } return Ext . isNumber ( size ) ? 1 : 0 ; }

Finishes the calculations on an axis. This basically just assigns the remaining
space to the center region.
@private

Finishes the calculations on an axis . This basically just assigns the remaining space to the center region .


function (childItems) {
        var length = childItems.length,
            index, childContext;

        for (index = 0; index < length; ++index) {
            childContext = childItems[index];

            childContext.setProp('x', childContext.layoutPos.x + childContext.marginInfo.left);
            childContext.setProp('y', childContext.layoutPos.y + childContext.marginInfo.top);
        }
    }

function ( childItems ) { var length = childItems . length , index , childContext ; for ( index = 0 ; index < length ; ++ index ) { childContext = childItems [ index ] ; childContext . setProp ( 'x' , childContext . layoutPos . x + childContext . marginInfo . left ) ; childContext . setProp ( 'y' , childContext . layoutPos . y + childContext . marginInfo . top ) ; } }

Finishes by setting the positions on the child items.
@private

Finishes by setting the positions on the child items .


function Duration(str) {

  // There must be at least a P
  if(str.length < 1 || str.charAt(0) != 'P') {
    throw new Error('Invalid Duration');
  }

  var duration = str.substr(1);

  if(duration.length < 1) {
    throw new Error('Invalid Duration');
  }

  // 5.3.2 allows for NON normalized durations
  // We assume that if there is a space, it is non-normalized
  if(/\s/.test(duration)) {
    throw new Error('Non normalized durations not implemented');
    //this._parseNonNormalized(duration);
  } else {
    this._parseNormalized(duration);
  }

}


function () {
        var result = {},
            fields = this.fields,
            key, field;

        for (key in fields) {
            if (fields.hasOwnProperty(key)) {
                field = fields[key];
                if (field.isValid() && field.getValue() !== null) {
                    result[key] = field.getValue();
                }
            }
        }
        return result;
    }

function ( ) { var result = { } , fields = this . fields , key , field ; for ( key in fields ) { if ( fields . hasOwnProperty ( key ) ) { field = fields [ key ] ; if ( field . isValid ( ) && field . getValue ( ) !== null ) { result [ key ] = field . getValue ( ) ; } } } return result ; }

Get and return the value of the filter.
@return {String} The value of this filter

Get and return the value of the filter .


function (data) {
        var me = this,
            fields = me.fields,
            key,
            field;

        for (key in fields) {
            if (fields.hasOwnProperty(key)) {
                // Prevent field's change event from tiggering a Store filter. The final upate event will do that
                field =fields[key];
                field.suspendEvents();
                field.setValue(key in data ? data[key] : '');
                field.resumeEvents();
            }
        }

        // Trigger the filering of the Store
        me.fireEvent('update', me);
    }

Set the value of this menu and fires the 'update' event.
@param {Object} data The data to assign to this menu

Set the value of this menu and fires the update event .


function ensureDefault(val, def) {
    if ((util_1.isNullOrUndefined(val) || val === '') && !chek_1.isUndefined(def))
        return def;
    return val;
}

function ensureDefault ( val , def ) { if ( ( util_1 . isNullOrUndefined ( val ) || val === '' ) && ! chek_1 . isUndefined ( def ) ) return def ; return val ; }

Ensures a default value when current is undefined.

@param val the current value.
@param def the default value.

Ensures a default value when current is undefined .


function isLikeNumber(val) {
    return constants_1.LIKE_HEX_NUMBER.test(val) ||
        constants_1.LIKE_NUMBER.test(val);
}

function isLikeNumber ( val ) { return constants_1 . LIKE_HEX_NUMBER . test ( val ) || constants_1 . LIKE_NUMBER . test ( val ) ; }

Checks if value is number like.

@param val the value to inspect.


function (val) {
        val = ensureDefault(val, constants_1.DEFAULT_TYPE_VALUES.boolean);
        return Boolean(/^false$/i.test(val) ? false : val);
    }

function ( val ) { val = ensureDefault ( val , constants_1 . DEFAULT_TYPE_VALUES . boolean ) ; return Boolean ( / ^false$ / i . test ( val ) ? false : val ) ; }

Converts type to a boolean.

@param val the value to convert.


function (val) {
        val = ensureDefault(val, constants_1.DEFAULT_TYPE_VALUES.array);
        if (!Array.isArray(val))
            val = [val];
        return val;
    }

function ( val ) { val = ensureDefault ( val , constants_1 . DEFAULT_TYPE_VALUES . array ) ; if ( ! Array . isArray ( val ) ) val = [ val ] ; return val ; }

Converts type to an array.

@param val the value to convert.


function toCamelcase(val, strict) {
    if (strict === void 0) { strict = true; }
    if (!strict || !/\S+\.[^\.]\S+/.test(val))
        return chek_1.camelcase(val);
    return val;
}

function toCamelcase ( val , strict ) { if ( strict === void 0 ) { strict = true ; } if ( ! strict || ! / \S+\.[^\.]\S+ / . test ( val ) ) return chek_1 . camelcase ( val ) ; return val ; }

Camelize string, ignore dot notation strings when strict.

@param val the value to camelize
@param strict when true dot notation values ignored.

Camelize string ignore dot notation strings when strict .


function expandArgs(val, match, safe) {
    if (Array.isArray(val))
        return val.slice(0); // always slice to clone.
    match = match || ['"', "'"];
    safe = safe || ['[', ']', '<', '>'];
    function replacer(p, c) {
        p.a[p.a.length - 1] += c.replace(/\\(.)/, '$1');
    }
    var all = safe.concat(match);
    var result = val.match(/\\?.|^$/g).reduce(function (p, c) {
        if (~all.indexOf(c)) {
            p.quote ^= 1;
            if (~safe.indexOf(c))
                replacer(p, c);
        }
        else if (!p.quote && c === ' ')
            p.a.push('');
        else
            replacer(p, c);
        return p;
    }, { a: [''], e: false }).a;
    return result;
}

function
expandArgs
(
val
,
match
,
safe
)
{
if
(
Array
.
isArray
(
val
)
)
return
val
.
slice
(
0
)
;
// always slice to clone.
match
=
match
||
[
'"'
,
"'"
]
;
safe
=
safe
||
[
'['
,
']'
,
'<'
,
'>'
]
;
function
replacer
(
p
,
c
)
{
p
.
a
[
p
.
a
.
length
1
]
+=
c
.
replace
(
/
\\(.)
/
,
'$1'
)
;
}
var
all
=
safe
.
concat
(
match
)
;
var
result
=
val
.
match
(
/
\\?.|^$
/
g
)
.
reduce
(
function
(
p
,
c
)
{
if
(
~
all
.
indexOf
(
c
)
)
{
p
.
quote
^=
1
;
if
(
~
safe
.
indexOf
(
c
)
)
replacer
(
p
,
c
)
;
}
else
if
(
!
p
.
quote
&&
c
===
' '
)
p
.
a
.
push
(
''
)
;
else
replacer
(
p
,
c
)
;
return
p
;
}
,
{
a
:
[
''
]
,
e
:
false
}
)
.
a
;
return
result
;
}

Expand argument string into an array respecting space between special characters.

NOTE: use \\ to escape inner quotes.

@example 'install --dir "/some/path" -f' >> ['install', '--dir', '/some/path', '-f']

@param val the arg string to split to array.
@param match chars when matched ignore spaces withing these chars.
@param safe same as match except these chars will be included in result.

Expand argument string into an array respecting space between special characters .


function expandOptions(val, allowValues) {
    val = val || [];
    var trail = [];
    return val.reduce(function (a, c) {
        if (!constants_1.FLAG_SHORT.test(c) || constants_1.FLAG_COUNT.test(c))
            return a.concat(c);
        var split = c.slice(1).split('').map(function (n) { return "-" + n; });
        if (allowValues)
            return a.concat(split);
        trail = trail.concat(split); // shift to end can't have values.
        return a;
    }, []).concat(trail);
}

function
expandOptions
(
val
,
allowValues
)
{
val
=
val
||
[
]
;
var
trail
=
[
]
;
return
val
.
reduce
(
function
(
a
,
c
)
{
if
(
!
constants_1
.
FLAG_SHORT
.
test
(
c
)
||
constants_1
.
FLAG_COUNT
.
test
(
c
)
)
return
a
.
concat
(
c
)
;
var
split
=
c
.
slice
(
1
)
.
split
(
''
)
.
map
(
function
(
n
)
{
return
"-"
+
n
;
}
)
;
if
(
allowValues
)
return
a
.
concat
(
split
)
;
trail
=
trail
.
concat
(
split
)
;
// shift to end can't have values.
return
a
;
}
,
[
]
)
.
concat
(
trail
)
;
}

Expands options arguments into multiple singular arguments.

@example [-abc] becomes [-a, '-b', '-c']

@param val the value to be expanded.
@param allowValues when true short flag groups can have values.

Expands options arguments into multiple singular arguments .


function isNegateFlag(val, negate) {
    negate = escape(negate || constants_1.NEGATE_CHAR);
    return (new RegExp('^--' + negate)).test(val);
}

function isNegateFlag ( val , negate ) { negate = escape ( negate || constants_1 . NEGATE_CHAR ) ; return ( new RegExp ( '^--' + negate ) ) . test ( val ) ; }

Checks if flag is that of negation.

@example --no-force >> true
@example --force >> false

@param val the value to inspect.
@param negate the negation char to check if exists.


function isArgVariadic(val, variadic) {
    variadic = variadic || constants_1.VARIADIC_CHAR;
    return isArg(val)
        && (val.endsWith(variadic + ']')
            || val.endsWith(variadic + '>'));
}

function isArgVariadic ( val , variadic ) { variadic = variadic || constants_1 . VARIADIC_CHAR ; return isArg ( val ) && ( val . endsWith ( variadic + ']' ) || val . endsWith ( variadic + '>' ) ) ; }

Checks if an argument contains variadic characters.

@example [arg...] >> true

@param val the value to be inspected.
@param variadic the variadic char to check if exists.

Checks if an argument contains variadic characters .


function isArgVariadicRequired(val, variadic) {
    variadic = variadic || constants_1.VARIADIC_CHAR;
    return isArgRequired(val) && val.endsWith(variadic + '>');
}

function isArgVariadicRequired ( val , variadic ) { variadic = variadic || constants_1 . VARIADIC_CHAR ; return isArgRequired ( val ) && val . endsWith ( variadic + '>' ) ; }

Checks if an argument is variadic and also contains required tokens.

@example <arg...> >> true

@param val the value to inspect.
@param variadic the char representing variadic arguments.

Checks if an argument is variadic and also contains required tokens .


function stripFlag(val, negate) {
    negate = escape(negate || constants_1.NEGATE_CHAR);
    return (val || '').replace(new RegExp('^--?(' + negate + ')?'), '');
}

function stripFlag ( val , negate ) { negate = escape ( negate || constants_1 . NEGATE_CHAR ) ; return ( val || '' ) . replace ( new RegExp ( '^--?(' + negate + ')?' ) , '' ) ; }

Strips a flag of all tokens.

@example --user.name >> user.name
@example --no-force >> force (removes negation also)

@param val the value containing flag tokens to be stripped.
@param negate the negation char defined in options.


function stripNegate(val, negate) {
    negate = escape(negate || constants_1.NEGATE_CHAR);
    var exp = new RegExp('^' + negate);
    return val.replace(exp, '');
}

function stripNegate ( val , negate ) { negate = escape ( negate || constants_1 . NEGATE_CHAR ) ; var exp = new RegExp ( '^' + negate ) ; return val . replace ( exp , '' ) ; }

Strips negate chars from flag.

@param val the value to be stripped.
@param negate the characters denoting negate.


function stripVariadic(val, variadic) {
    variadic = escape(variadic || constants_1.VARIADIC_CHAR);
    var exp = new RegExp(variadic + '$');
    return val.replace(exp, '');
}

function stripVariadic ( val , variadic ) { variadic = escape ( variadic || constants_1 . VARIADIC_CHAR ) ; var exp = new RegExp ( variadic + '$' ) ; return val . replace ( exp , '' ) ; }

Strips variadic chars from flag.

@param val the value to be stripped.
@param negate the characters denoting variadic.


function stripTokens(val, negate, variadic) {
    variadic = escape(variadic || constants_1.VARIADIC_CHAR);
    negate = escape(negate || constants_1.NEGATE_CHAR);
    var argExp = new RegExp(['<', '>', '\\[', '\\]'].join('|'), 'g');
    var noExp = new RegExp('^' + negate);
    var variExp = new RegExp(variadic + '$');
    return expandArgs(val)
        .map(function (v) {
        v = v
            .replace(constants_1.FLAG_EXP, '')
            .replace(noExp, '')
            .replace(argExp, '')
            .replace(variExp, '');
        return v;
    }).join(' ');
}

function
stripTokens
(
val
,
negate
,
variadic
)
{
variadic
=
escape
(
variadic
||
constants_1
.
VARIADIC_CHAR
)
;
negate
=
escape
(
negate
||
constants_1
.
NEGATE_CHAR
)
;
var
argExp
=
new
RegExp
(
[
'<'
,
'>'
,
'\\['
,
'\\]'
]
.
join
(
'|'
)
,
'g'
)
;
var
noExp
=
new
RegExp
(
'^'
+
negate
)
;
var
variExp
=
new
RegExp
(
variadic
+
'$'
)
;
return
expandArgs
(
val
)
.
map
(
function
(
v
)
{
v
=
v
.
replace
(
constants_1
.
FLAG_EXP
,
''
)
.
replace
(
noExp
,
''
)
.
replace
(
argExp
,
''
)
.
replace
(
variExp
,
''
)
;
return
v
;
}
)
.
join
(
' '
)
;
}

Strips all tokens from string.

@example 'install <dir> [filename]' >> 'install dir filename'

@param val the val containing tokens to be stripped.
@param negate the negation char used.
@param variadic the variadic char used.


function(item) {
        if (!item) {
            return;
        }

        var me = this,
            sprite = item.sprite,
            opts = Ext.merge({}, me.highlightCfg, me.highlight),
            surface = me.chart.surface,
            animate = me.chart.animate,
            p, from, to, pi;

        if (!me.highlight || !sprite || sprite._highlighted) {
            return;
        }
        if (sprite._anim) {
            sprite._anim.paused = true;
        }
        sprite._highlighted = true;
        if (!sprite._defaults) {
            sprite._defaults = Ext.apply({}, sprite.attr);
            from = {};
            to = {};
            // TODO: Clean up code below.
            for (p in opts) {
                if (! (p in sprite._defaults)) {
                    sprite._defaults[p] = surface.availableAttrs[p];
                }
                from[p] = sprite._defaults[p];
                to[p] = opts[p];
                if (Ext.isObject(opts[p])) {
                    from[p] = {};
                    to[p] = {};
                    Ext.apply(sprite._defaults[p], sprite.attr[p]);
                    Ext.apply(from[p], sprite._defaults[p]);
                    for (pi in sprite._defaults[p]) {
                        if (! (pi in opts[p])) {
                            to[p][pi] = from[p][pi];
                        } else {
                            to[p][pi] = opts[p][pi];
                        }
                    }
                    for (pi in opts[p]) {
                        if (! (pi in to[p])) {
                            to[p][pi] = opts[p][pi];
                        }
                    }
                }
            }
            sprite._from = from;
            sprite._to = to;
            sprite._endStyle = to;
        }
        if (animate) {
            sprite._anim = new Ext.fx.Anim({
                target: sprite,
                from: sprite._from,
                to: sprite._to,
                duration: 150
            });
        } else {
            sprite.setAttributes(sprite._to, true);
        }
    }

function
(
item
)
{
if
(
!
item
)
{
return
;
}
var
me
=
this
,
sprite
=
item
.
sprite
,
opts
=
Ext
.
merge
(
{
}
,
me
.
highlightCfg
,
me
.
highlight
)
,
surface
=
me
.
chart
.
surface
,
animate
=
me
.
chart
.
animate
,
p
,
from
,
to
,
pi
;
if
(
!
me
.
highlight
||
!
sprite
||
sprite
.
_highlighted
)
{
return
;
}
if
(
sprite
.
_anim
)
{
sprite
.
_anim
.
paused
=
true
;
}
sprite
.
_highlighted
=
true
;
if
(
!
sprite
.
_defaults
)
{
sprite
.
_defaults
=
Ext
.
apply
(
{
}
,
sprite
.
attr
)
;
from
=
{
}
;
to
=
{
}
;
// TODO: Clean up code below.
for
(
p
in
opts
)
{
if
(
!
(
p
in
sprite
.
_defaults
)
)
{
sprite
.
_defaults
[
p
]
=
surface
.
availableAttrs
[
p
]
;
}
from
[
p
]
=
sprite
.
_defaults
[
p
]
;
to
[
p
]
=
opts
[
p
]
;
if
(
Ext
.
isObject
(
opts
[
p
]
)
)
{
from
[
p
]
=
{
}
;
to
[
p
]
=
{
}
;
Ext
.
apply
(
sprite
.
_defaults
[
p
]
,
sprite
.
attr
[
p
]
)
;
Ext
.
apply
(
from
[
p
]
,
sprite
.
_defaults
[
p
]
)
;
for
(
pi
in
sprite
.
_defaults
[
p
]
)
{
if
(
!
(
pi
in
opts
[
p
]
)
)
{
to
[
p
]
[
pi
]
=
from
[
p
]
[
pi
]
;
}
else
{
to
[
p
]
[
pi
]
=
opts
[
p
]
[
pi
]
;
}
}
for
(
pi
in
opts
[
p
]
)
{
if
(
!
(
pi
in
to
[
p
]
)
)
{
to
[
p
]
[
pi
]
=
opts
[
p
]
[
pi
]
;
}
}
}
}
sprite
.
_from
=
from
;
sprite
.
_to
=
to
;
sprite
.
_endStyle
=
to
;
}
if
(
animate
)
{
sprite
.
_anim
=
new
Ext
.
fx
.
Anim
(
{
target
:
sprite
,
from
:
sprite
.
_from
,
to
:
sprite
.
_to
,
duration
:
150
}
)
;
}
else
{
sprite
.
setAttributes
(
sprite
.
_to
,
true
)
;
}
}

Highlight the given series item.
@param {Object} item Info about the item; same format as returned by #getItemForPoint.


function() {
        if (!this.highlight || !this.items) {
            return;
        }

        var me = this,
            items = me.items,
            len = items.length,
            opts = Ext.merge({}, me.highlightCfg, me.highlight),
            animate = me.chart.animate,
            i = 0,
            obj, p, sprite;
        for (; i < len; i++) {
            if (!items[i]) {
                continue;
            }
            sprite = items[i].sprite;
            if (sprite && sprite._highlighted) {
                if (sprite._anim) {
                    sprite._anim.paused = true;
                }
                obj = {};
                for (p in opts) {
                    if (Ext.isObject(sprite._defaults[p])) {
                        obj[p] = Ext.apply({}, sprite._defaults[p]);
                    }
                    else {
                        obj[p] = sprite._defaults[p];
                    }
                }
                if (animate) {
                    //sprite._to = obj;
                    sprite._endStyle = obj;
                    sprite._anim = new Ext.fx.Anim({
                        target: sprite,
                        to: obj,
                        duration: 150
                    });
                }
                else {
                    sprite.setAttributes(obj, true);
                }
                delete sprite._highlighted;
                //delete sprite._defaults;
            }
        }
    }

function
(
)
{
if
(
!
this
.
highlight
||
!
this
.
items
)
{
return
;
}
var
me
=
this
,
items
=
me
.
items
,
len
=
items
.
length
,
opts
=
Ext
.
merge
(
{
}
,
me
.
highlightCfg
,
me
.
highlight
)
,
animate
=
me
.
chart
.
animate
,
i
=
0
,
obj
,
p
,
sprite
;
for
(
;
i
<
len
;
i
++
)
{
if
(
!
items
[
i
]
)
{
continue
;
}
sprite
=
items
[
i
]
.
sprite
;
if
(
sprite
&&
sprite
.
_highlighted
)
{
if
(
sprite
.
_anim
)
{
sprite
.
_anim
.
paused
=
true
;
}
obj
=
{
}
;
for
(
p
in
opts
)
{
if
(
Ext
.
isObject
(
sprite
.
_defaults
[
p
]
)
)
{
obj
[
p
]
=
Ext
.
apply
(
{
}
,
sprite
.
_defaults
[
p
]
)
;
}
else
{
obj
[
p
]
=
sprite
.
_defaults
[
p
]
;
}
}
if
(
animate
)
{
//sprite._to = obj;
sprite
.
_endStyle
=
obj
;
sprite
.
_anim
=
new
Ext
.
fx
.
Anim
(
{
target
:
sprite
,
to
:
obj
,
duration
:
150
}
)
;
}
else
{
sprite
.
setAttributes
(
obj
,
true
)
;
}
delete
sprite
.
_highlighted
;
//delete sprite._defaults;
}
}
}


function(component, selector) {
            if (!selector) {
                return true;
            }
            var selectors = selector.split(','),
                length = selectors.length,
                i = 0,
                query;

            for (; i < length; i++) {
                selector = Ext.String.trim(selectors[i]);
                query = this.cache[selector] || (this.cache[selector] = this.parse(selector));
                if (query.is(component)) {
                    return true;
                }
            }
            return false;
        }

function ( component , selector ) { if ( ! selector ) { return true ; } var selectors = selector . split ( ',' ) , length = selectors . length , i = 0 , query ; for ( ; i < length ; i ++ ) { selector = Ext . String . trim ( selectors [ i ] ) ; query = this . cache [ selector ] || ( this . cache [ selector ] = this . parse ( selector ) ) ; if ( query . is ( component ) ) { return true ; } } return false ; }

Tests whether the passed Component matches the selector string.
@param {Ext.Component} component The Component to test
@param {String} selector The selector string to test against.
@return {Boolean} True if the Component matches the selector.
@member Ext.ComponentQuery

Tests whether the passed Component matches the selector string .


async function getVinylFile(filePath, options) {
	if (!isString(filePath)) {
		if (!options.lookup.has(filePath.path)) options.lookup.set(filePath.path, filePath);
		return filePath;
	}
	if (options.lookup.has(filePath)) return options.lookup.get(filePath);
	return createVinylFile(filePath, options);
}

async function getVinylFile ( filePath , options ) { if ( ! isString ( filePath ) ) { if ( ! options . lookup . has ( filePath . path ) ) options . lookup . set ( filePath . path , filePath ) ; return filePath ; } if ( options . lookup . has ( filePath ) ) return options . lookup . get ( filePath ) ; return createVinylFile ( filePath , options ) ; }

Get a new vinyl-file for the given path, with given options. If already a vinyl-file,just return it.

@param {string|VinylFile} filePath		The path to load from.
@param {Object}options					Options object.
@returns  {VinylFile}					The vinyl-file object.

Get a new vinyl - file for the given path with given options . If already a vinyl - file just return it .


async function createVinylFile(filePath, options) {
	options.lookup.set(filePath, vinylFile.read(filePath, options));
	if (options.debugVcjd) debug(`Reading contents of: ${filePath}`);
	return await options.lookup.get(filePath);
}

async function createVinylFile ( filePath , options ) { options . lookup . set ( filePath , vinylFile . read ( filePath , options ) ) ; if ( options . debugVcjd ) debug ( ` ${ filePath } ` ) ; return await options . lookup . get ( filePath ) ; }

Create a new vinyl-file for the given path, with given options.

@param {string} filePath		The path to load from.
@param {Object}options		Options object.
@returns  {VinylFile}		New vinyl-file object.

Create a new vinyl - file for the given path with given options .


function getVinylFiles(files, options) {
	return Promise.all(files.map(file=>getVinylFile(file, options)));
}

function getVinylFiles ( files , options ) { return Promise . all ( files . map ( file => getVinylFile ( file , options ) ) ) ; }

Get vinyl-files for each of the given file paths.

@param {Array.<string|VinylFile} files		Files to get for.
@param {Object} options						Options object.
@returns {Promise.<VinylFile[]>}				The results.

Get vinyl - files for each of the given file paths .


async function resolveModule(moduleId, options, root=options.base) {
	if (options.lookup.has(moduleId)) return options.lookup.get(moduleId);
	const absolutePath = await options.resolver(moduleId, root);
	if (options.mapper.hasOwnProperty(absolutePath)) return options.mapper[absolutePath];
	if (options.lookup.has(absolutePath)) return options.lookup.get(absolutePath);
	return absolutePath;
}

async function resolveModule ( moduleId , options , root = options . base ) { if ( options . lookup . has ( moduleId ) ) return options . lookup . get ( moduleId ) ; const absolutePath = await options . resolver ( moduleId , root ) ; if ( options . mapper . hasOwnProperty ( absolutePath ) ) return options . mapper [ absolutePath ] ; if ( options . lookup . has ( absolutePath ) ) return options . lookup . get ( absolutePath ) ; return absolutePath ; }

Resolve the path for the given module-id.

@param {string} moduleId					Module to resolve for.
@param {Object} options					Options object.
@param {string} [root=options.base]		Base of path.
@returns {Promise.<string>}				The resolved path.

Resolve the path for the given module - id .


function getRequires(file, options) {
	return [...fileRequires(file, options)].map(async (moduleId)=>{
		if (options.internalOnly && (moduleId.charAt(0) !== '.') && (moduleId.charAt(0) !== '/')) {
			if (options.mapper[moduleId] !== true) return undefined;
		}

		if (options.mapper.hasOwnProperty(moduleId) && !(options.internalOnly && (options.mapper[moduleId] === true))) {
			if (options.mapper[moduleId]) return resolveModule(options.mapper[moduleId], options);
			return undefined;
		}
		return resolveModule(moduleId, options, path.dirname(file.path));
	});
}

function getRequires ( file , options ) { return [ ... fileRequires ( file , options ) ] . map ( async ( moduleId ) => { if ( options . internalOnly && ( moduleId . charAt ( 0 ) !== '.' ) && ( moduleId . charAt ( 0 ) !== '/' ) ) { if ( options . mapper [ moduleId ] !== true ) return undefined ; } if ( options . mapper . hasOwnProperty ( moduleId ) && ! ( options . internalOnly && ( options . mapper [ moduleId ] === true ) ) ) { if ( options . mapper [ moduleId ] ) return resolveModule ( options . mapper [ moduleId ] , options ) ; return undefined ; } return resolveModule ( moduleId , options , path . dirname ( file . path ) ) ; } ) ; }

Get all the require paths for a given file.

@param {VinylFile} file		File to get for.
@param {Object} options		Options object.
@returns {Array.<string>}	Dependency paths.

Get all the require paths for a given file .


function filterDuplicateFiles() {
	const lookup = new Map();

	return value=>{
		if (lookup.has(value)) return false;
		return lookup.set(value, true);
	}
}

function filterDuplicateFiles ( ) { const lookup = new Map ( ) ; return value => { if ( lookup . has ( value ) ) return false ; return lookup . set ( value , true ) ; } }

Filter-out any files that are already loaded.

@returns {Function}		Filter function to track duplicates (for use in Array.prototype.filter()).

Filter - out any files that are already loaded .


async function getFiles(paths, options) {
	const files = (await getVinylFiles(paths, options))
		.map(file=>[file, ...getRequires(file, options)]);
	return (await promiseFlatten(files)).filter(file=>file).filter(filterDuplicateFiles());
}

async function getFiles ( paths , options ) { const files = ( await getVinylFiles ( paths , options ) ) . map ( file => [ file , ... getRequires ( file , options ) ] ) ; return ( await promiseFlatten ( files ) ) . filter ( file => file ) . filter ( filterDuplicateFiles ( ) ) ; }

Get all files and their dependencies on given path.

@param {string} paths							Path to get from.
@param {Object} options							Options object.
@returns {Promise.<VinylFile[]|string[]>}		The found files.

Get all files and their dependencies on given path .


async function getAllFiles(file, options) {
	let files = await getFiles([file], options);
	while (hasUnloaded(files)) files = await getFiles(files, options);
	return files;
}

async function getAllFiles ( file , options ) { let files = await getFiles ( [ file ] , options ) ; while ( hasUnloaded ( files ) ) files = await getFiles ( files , options ) ; return files ; }

Get input file and its dependencies.

@param {VinylFile|string} file		File to get for.
@param {Object} options				Options object.
@returns {Promise.<VinylFile[]>}		Vinyl files found.


function srcFilePusher(options) {
	return through.obj(function(file, encoding, done) {
		getAllFiles(file, options).then(files=>{
			files.forEach(file=>this.push(file));
			done();
		}, err=>{});
	})
}

function srcFilePusher ( options ) { return through . obj ( function ( file , encoding , done ) { getAllFiles ( file , options ) . then ( files => { files . forEach ( file => this . push ( file ) ) ; done ( ) ; } , err => { } ) ; } ) }

Push Vinyl files into object stream.

@param {Object} options		Options object.


function createResolver(options) {
	return (moduleId, base)=>new Promise((resolve, reject)=>{
		const resolver = new Resolver(options.resolver?options.resolver:{});
		resolver.resolve(moduleId, base, (err, absolutePath)=>{
			if (err) {
				if (options.debugVcjd) debug(`Could not resolve path to module: ${moduleId}\n\tfrom base: ${base}`);
				return reject(err);
			}
			if (options.debugVcjd) debug(`Resolved module: ${moduleId}:\n\tfrom base: ${base}\n\t:is: ${base}`);
			return resolve(absolutePath);
		});
	})
}

function createResolver ( options ) { return ( moduleId , base ) => new Promise ( ( resolve , reject ) => { const resolver = new Resolver ( options . resolver ? options . resolver : { } ) ; resolver . resolve ( moduleId , base , ( err , absolutePath ) => { if ( err ) { if ( options . debugVcjd ) debug ( ` ${ moduleId } \n \t ${ base } ` ) ; return reject ( err ) ; } if ( options . debugVcjd ) debug ( ` ${ moduleId } \n \t ${ base } \n \t ${ base } ` ) ; return resolve ( absolutePath ) ; } ) ; } ) }

Create a async-resolver from the given options and return as promise-wrapped function.

@param {Object} options				Options object.
@returns {Function.<Promise>}		Resolver function.

Create a async - resolver from the given options and return as promise - wrapped function .