/*
Initialize items of combos. Handles `firstItem` option
961814
function(key) {
      var values = [], relTime;

      if(this.options.firstItem === 'name') {
        //need both to support moment ver < 2 and  >= 2
        relTime = moment.relativeTime || moment.langData()._relativeTime; 
        var header = typeof relTime[key] === 'function' ? relTime[key](1, true, key, false) : relTime[key];
        //take last entry (see momentjs lang files structure) 
        header = header.split(' ').reverse()[0];                
        values.push(['', header]);
      } else if(this.options.firstItem === 'empty') {
        values.push(['', '']);
      }
      return values;
    }
1336537
function (items, options) {


            options = options || {};
            _.defaults(options, {silent: false, index: this.$items.length});

            var index = options.index;

            if (!_.isArray(items)) {
                items = [items];
            }
            var item, itemIndex;
            for (var i = 0; i < items.length; i++) {
                item = items[i];
                if (item instanceof Bindable) {
                    item.bind('change', this._onItemChange, this);
                    item.bind('*', this._onItemEvent, this);
                }
                itemIndex = index + i;
                if (_.isUndefined(this.$items[itemIndex]) || itemIndex >= this.$items.length) {
                    this.$items[itemIndex] = item;
                } else {
                    this.$items.splice(itemIndex, 0, item);
                }
                if (options.silent !== true) {
                    this.trigger('add', {item: item, index: itemIndex});
                }
            }
        }
143856
function (options)
        {
            var self = this;

            self.options = $.extend({}, defaultOptions, options);
            // When itemValue is set, freeInput should always be false

            if (self.objectItems)
            {
                if (self.options.freeInput === true)
                {
                    self.options.freeInput = true;
                }
                else{
                    self.options.freeInput = false
                }
            }

            makeOptionItemFunction(self.options, 'itemValue');
            makeOptionItemFunction(self.options, 'itemText');
            makeOptionFunction(self.options, 'tagClass');

            // Typeahead.js
            if (self.options.typeaheadjs)
            {
                var typeaheadConfig   = null;
                var typeaheadDatasets = {};

                // Determine if main configurations were passed or simply a dataset
                var typeaheadjs = self.options.typeaheadjs;
                if ($.isArray(typeaheadjs))
                {
                    typeaheadConfig   = typeaheadjs[0];
                    typeaheadDatasets = typeaheadjs[1];
                }
                else
                {
                    typeaheadDatasets = typeaheadjs;
                }

                self.$input.typeahead(typeaheadConfig, typeaheadDatasets).on('typeahead:selected', $.proxy(function (obj, datum)
                {
                    if (typeaheadDatasets.valueKey)
                    {
                        self.add(datum[typeaheadDatasets.valueKey]);
                    }
                    else
                    {
                        self.add(datum);
                    }
                    self.$input.typeahead('val', '');
                }, self));
            }

            self.$container.on('click', $.proxy(function (event)
            {
                if (!self.$element.attr('disabled'))
                {
                    self.$input.removeAttr('disabled');
                }
                self.$input.focus();
            }, self));

            if (self.options.addOnBlur && self.options.freeInput)
            {
                self.$input.on('focusout', $.proxy(function (event)
                {
                    self.add(self.$input.val());
                    self.$input.val('');

                }, self));
            }

            self.$container.on('keydown', 'input', $.proxy(function (event)
            {
                var $input        = $(event.target),
                    $inputWrapper = self.findInputWrapper();

                if (self.$element.attr('disabled'))
                {
                    self.$input.attr('disabled', 'disabled');
                    return;
                }

                switch (event.which)
                {
                    // BACKSPACE
                    case 8:
                        if (self.options.deleteTagsOnBackspace && doGetCaretPosition($input[0]) === 0)
                        {
                            var prev = $inputWrapper.prev();
                            if (prev)
                            {
                                self.remove(prev.data('item'));
                            }
                        }
                        break;

                    // DELETE
                    case 46:
                        if (self.options.deleteTagsOnDeleteKey && doGetCaretPosition($input[0]) === 0)
                        {
                            var next = $inputWrapper.next();
                            if (next)
                            {
                                self.remove(next.data('item'));
                            }
                        }
                        break;

                    // LEFT ARROW
                    case 37:
                        // Try to move the input before the previous tag
                        var $prevTag = $inputWrapper.prev();
                        if (self.options.MoveTagOnLeftArrow && $input.val().length === 0 && $prevTag[0])
                        {
                            $prevTag.before($inputWrapper);
                            $input.focus();
                        }
                        break;
                    // RIGHT ARROW
                    case 39:
                        // Try to move the input after the next tag
                        var $nextTag = $inputWrapper.next();
                        if (self.options.MoveTagOnRightArrow && $input.val().length === 0 && $nextTag[0])
                        {
                            $nextTag.after($inputWrapper);
                            $input.focus();
                        }
                        break;
                    default:
                    // ignore
                }

                // Reset internal input's size
                var textLength = $input.val().length,
                    wordSpace  = Math.ceil(textLength / 5),
                    size       = textLength + wordSpace + 1;
                $input.attr('size', Math.max(this.inputSize, $input.val().length));
            }, self));

            self.$container.on('keydown', 'input', $.proxy(function (event)
            {
                var $input = $(event.target);

                if (self.$element.attr('disabled'))
                {
                    self.$input.attr('disabled', 'disabled');
                    return;
                }

                var text             = $input.val(),
                    maxLengthReached = self.options.maxChars && text.length >= self.options.maxChars;

                // If not text is entered and tab event is fired shouldn't prevent the default behavior
                if (self.options.allowTabOnEmpty && isEmpty(text) && event.which === tabKey) 
                {
                    return;
                }

                if (self.options.freeInput && (keyCombinationInList(event, self.options.confirmKeys) || maxLengthReached))
                {
                    self.add(maxLengthReached ? text.substr(0, self.options.maxChars) : text);
                    $input.val('');
                    (self.$input.typeahead) && self.$input.typeahead("val","");
                    event.preventDefault();
                }

                // Reset internal input's size
                var textLength = $input.val().length,
                    wordSpace  = Math.ceil(textLength / 5),
                    size      = textLength + wordSpace + 1;
                $input.attr('size', Math.max(this.inputSize, $input.val().length));
            }, self));

            // Remove icon clicked
            self.$container.on('click', '[data-role=remove]', $.proxy(function (event)
            {
                if (self.$element.attr('disabled'))
                {
                    return;
                }
                self.remove($(event.target).closest('.chip').data('item'));
            }, self));

            // Only add existing value as tags when using strings as tags
            if (self.options.itemValue === defaultOptions.itemValue)
            {
                if (self.$element[0].tagName === 'INPUT')
                {
                    self.add(self.$element.val());
                }
            }
        }
582421
protected void initExportObject() {

        try {
            if (CmsStringUtil.isEmpty(getParamAction()) || CmsDialog.DIALOG_INITIAL.equals(getParamAction())) {
                // create a new list
                m_reasons = new HashMap();
            } else {
                Map objects = (Map)getSettings().getDialogObject();
                if (objects == null) {
                    // using hashtable as most efficient version of a synchronized map
                    objects = new Hashtable();
                    getSettings().setDialogObject(objects);
                }
                m_reasons = (Map)objects.get(getClass().getName());
            }
        } catch (Exception e) {
            // create a new list
            m_reasons = new HashMap();
        }
    }
1186128
function() {
			var key, fn, callbacks = {
				'initialize'      : 'onInitialize',
				'change'          : 'onChange',
				'item_add'        : 'onItemAdd',
				'item_remove'     : 'onItemRemove',
				'clear'           : 'onClear',
				'option_add'      : 'onOptionAdd',
				'option_remove'   : 'onOptionRemove',
				'option_clear'    : 'onOptionClear',
				'optgroup_add'    : 'onOptionGroupAdd',
				'optgroup_remove' : 'onOptionGroupRemove',
				'optgroup_clear'  : 'onOptionGroupClear',
				'dropdown_open'   : 'onDropdownOpen',
				'dropdown_close'  : 'onDropdownClose',
				'type'            : 'onType',
				'load'            : 'onLoad',
				'focus'           : 'onFocus',
				'blur'            : 'onBlur'
			};
	
			for (key in callbacks) {
				if (callbacks.hasOwnProperty(key)) {
					fn = this.settings[callbacks[key]];
					if (fn) this.on(key, fn);
				}
			}
		}
91432
function PriorityQueue(initialItems) {

  var self = this;
  MinHeap.call(this, function (a, b) {
    return self.priority(a) < self.priority(b) ? -1 : 1;
  });

  this._priority = {};

  initialItems = initialItems || {};
  Object.keys(initialItems).forEach(function (item) {
    self.insert(item, initialItems[item]);
  });
}
463821
function ItemsItem() {
    /**
     * The id value
     * @member
     */
    this.id = null;
    /**
     * The sku value
     * @member
     */
    this.sku = null;
    /**
     * The title value
     * @member
     */
    this.title = null;
    /**
     * The quantity value
     * @member
     */
    this.quantity = null;
    /**
     * The price value
     * @member
     */
    this.price = null;
    /**
     * The formattedPrice value
     * @member
     */
    this.formattedPrice = null;
    /**
     * The currency value
     * @member
     */
    this.currency = null;
    /**
     * The productLink value
     * @member
     */
    this.productLink = null;
    /**
     * The weight value
     * @member
     */
    this.weight = null;
    /**
     * The formattedWeight value
     * @member
     */
    this.formattedWeight = null;
    /**
     * The media of value
     * @member
     * @type { Media }
     */
    this.media = Object.create(Media.prototype);

}
1242882
private void initializeCheckedItems() {
        if (checkedItems != null) {
            for (int i = 0; i < checkedItems.length; i++) {
                adapter.setItemChecked(i, checkedItems[i]);
            }
        }
    }
1007196
function(item, collection, options){
    this.closeEmptyView();
    var ItemView = this.getItemView(item);
    var index = this.collection.indexOf(item);
    this.addItemView(item, ItemView, index);
  }
86649
protected function initialize()
    {
        $itemData = $this->getItemData();

        $itemsMerged = array();
        foreach ($itemData as $key => $itemOptions)
        {
            $itemsMerged[$key] = array_merge($this->defaults, $itemOptions);

            if (isset($itemsMerged[$key]['children']['.defaults']))
            {
                $itemsMerged[$key]['children']['.defaults'] = array_merge($this->defaults, $itemsMerged[$key]['children']['.defaults']);
            }
            else
            {
                $itemsMerged[$key]['children']['.defaults'] = $this->defaults;
            }
        }

        $this->baseItem = $this->createItem('', array(
            'title' => '',
            'item_class' => 'C33s\MenuBundle\Item\MenuItem',
            'children' => $itemsMerged,
        ));
    }
1314919
private function calculateFirstItemOnPage()
    {
        // When an offset is used, increase the first item with 1
        $offsetItem = $this->getOffset() !== 0 ? 1 : 0;

        // When there are a total amount of items and the offset is zero, increase 1
        if ($this->getTotalItems() !== 0 && $offsetItem === 0) {
            $offsetItem = 1;
        }

        // Determine the first item on the page
        $firstItem = $this->getOffset() + $offsetItem;

        $this->setFirstItemOnPage((int)$firstItem);
    }
1047472
def initialize(self, data):
        
        for item in data:
            if hasattr(self, item):
                setattr(self, item, data[item])
861678
def initialize(self, maxsize, history=None):
        ''''''
        super().__init__()

        self.maxsize = int(maxsize)
        self.history = deque(maxlen=self.maxsize)  # Preserves order history

        # If `items` are specified, then initialize with them
        if history is not None:
            for key, value in history:
                self.insert(key, value)
308567
def initialize_view(self):
        """"""
        self.clear()
        self.item_depth = 0   # To be use for collapsing/expanding one level
        self.item_list = []  # To be use for collapsing/expanding one level
        self.items_to_be_shown = {}
        self.current_view_depth = 0
473349
public function init()
	{
		if($this->itemView===null)
			throw new CException(Yii::t('zii','The property "itemView" cannot be empty.'));
		parent::init();

		if(!isset($this->htmlOptions['class']))
			$this->htmlOptions['class']='list-view';

		if($this->baseScriptUrl===null)
			$this->baseScriptUrl=Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('zii.widgets.assets')).'/listview';

		if($this->cssFile!==false)
		{
			if($this->cssFile===null)
				$this->cssFile=$this->baseScriptUrl.'/styles.css';
			Yii::app()->getClientScript()->registerCssFile($this->cssFile);
		}
	}
1221174
function () {
            this.$Element.initWidget.call(this);
            this.setOptions();

            var newIndex = this.getSelectedIndexFromBindings();
            if (newIndex != null) {
                this._domElt.selectedIndex = newIndex;
            }
            this.initDisabledWidgetAttribute();

            this.__updateDataModel();
        }
628991
public function init()
    {
        parent::init();

        $this->addItems($this->items());

        if (($add = $this->getAdd()) !== null) {
            $this->addMenus($add);
        }

        if (($merge = $this->getMerge()) !== null) {
            $this->mergeMenus($merge);
        }
    }