jekyll-theme-mdui 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/_includes/analytics.html +8 -10
- data/_includes/disqus.html +10 -2
- data/_includes/footer.html +21 -21
- data/_includes/head.html +2 -4
- data/_includes/test.html +190 -0
- data/_layouts/category.html +11 -11
- data/_layouts/default.html +2 -1
- data/_layouts/editor.html +0 -2
- data/_layouts/post.html +0 -2
- data/assets/css/main.css +3 -0
- data/assets/css/pickerdata.css +3 -0
- data/assets/js/chips.js +2 -327
- data/assets/js/pickerdata.js +9 -2558
- data/assets/js/toc.min.js +0 -14
- metadata +3 -5
- data/search.json +0 -10
- data/sw.js +0 -48
- data/tags.json +0 -23
    
        data/assets/js/chips.js
    CHANGED
    
    | @@ -1,327 +1,2 @@ | |
| 1 | 
            -
            Materialize = {};
         | 
| 2 | 
            -
             | 
| 3 | 
            -
                function s4() {
         | 
| 4 | 
            -
                    return Math.floor((1 + Math.random()) * 65536).toString(16).substring(1)
         | 
| 5 | 
            -
                }
         | 
| 6 | 
            -
                return function () {
         | 
| 7 | 
            -
                    return s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4()
         | 
| 8 | 
            -
                }
         | 
| 9 | 
            -
            })();
         | 
| 10 | 
            -
            (function ($) {
         | 
| 11 | 
            -
              var materialChipsDefaults = {
         | 
| 12 | 
            -
                data: [],
         | 
| 13 | 
            -
                placeholder: '',
         | 
| 14 | 
            -
                secondaryPlaceholder: '',
         | 
| 15 | 
            -
                autocompleteOptions: {},
         | 
| 16 | 
            -
              };
         | 
| 17 | 
            -
             | 
| 18 | 
            -
              $(document).ready(function() {
         | 
| 19 | 
            -
                // Handle removal of static chips.
         | 
| 20 | 
            -
                $(document).on('click', '.chip .close', function(e){
         | 
| 21 | 
            -
                  var $chips = $(this).closest('.chips');
         | 
| 22 | 
            -
                  if ($chips.attr('data-initialized')) {
         | 
| 23 | 
            -
                    return;
         | 
| 24 | 
            -
                  }
         | 
| 25 | 
            -
                  $(this).closest('.chip').remove();
         | 
| 26 | 
            -
                });
         | 
| 27 | 
            -
              });
         | 
| 28 | 
            -
             | 
| 29 | 
            -
              $.fn.material_chip = function (options) {
         | 
| 30 | 
            -
                var self = this;
         | 
| 31 | 
            -
                this.$el = $(this);
         | 
| 32 | 
            -
                this.$document = $(document);
         | 
| 33 | 
            -
                this.SELS = {
         | 
| 34 | 
            -
                  CHIPS: '.chips',
         | 
| 35 | 
            -
                  CHIP: '.chip',
         | 
| 36 | 
            -
                  INPUT: 'input',
         | 
| 37 | 
            -
                  DELETE: '.material-icons',
         | 
| 38 | 
            -
                  SELECTED_CHIP: '.selected',
         | 
| 39 | 
            -
                };
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                if ('data' === options) {
         | 
| 42 | 
            -
                  return this.$el.data('chips');
         | 
| 43 | 
            -
                }
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                var curr_options = $.extend({}, materialChipsDefaults, options);
         | 
| 46 | 
            -
                self.hasAutocomplete = !$.isEmptyObject(curr_options.autocompleteOptions.data);
         | 
| 47 | 
            -
             | 
| 48 | 
            -
                // Initialize
         | 
| 49 | 
            -
                this.init = function() {
         | 
| 50 | 
            -
                  var i = 0;
         | 
| 51 | 
            -
                  var chips;
         | 
| 52 | 
            -
                  self.$el.each(function(){
         | 
| 53 | 
            -
                    var $chips = $(this);
         | 
| 54 | 
            -
                    var chipId = Materialize.guid();
         | 
| 55 | 
            -
                    self.chipId = chipId;
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                    if (!curr_options.data || !(curr_options.data instanceof Array)) {
         | 
| 58 | 
            -
                      curr_options.data = [];
         | 
| 59 | 
            -
                    }
         | 
| 60 | 
            -
                    $chips.data('chips', curr_options.data);
         | 
| 61 | 
            -
                    $chips.attr('data-index', i);
         | 
| 62 | 
            -
                    $chips.attr('data-initialized', true);
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                    if (!$chips.hasClass(self.SELS.CHIPS)) {
         | 
| 65 | 
            -
                      $chips.addClass('chips');
         | 
| 66 | 
            -
                    }
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                    self.chips($chips, chipId);
         | 
| 69 | 
            -
                    i++;
         | 
| 70 | 
            -
                  });
         | 
| 71 | 
            -
                };
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                this.handleEvents = function() {
         | 
| 74 | 
            -
                  var SELS = self.SELS;
         | 
| 75 | 
            -
             | 
| 76 | 
            -
                  self.$document.off('click.chips-focus', SELS.CHIPS).on('click.chips-focus', SELS.CHIPS, function(e){
         | 
| 77 | 
            -
                    $(e.target).find(SELS.INPUT).focus();
         | 
| 78 | 
            -
                  });
         | 
| 79 | 
            -
             | 
| 80 | 
            -
                  self.$document.off('click.chips-select', SELS.CHIP).on('click.chips-select', SELS.CHIP, function(e){
         | 
| 81 | 
            -
                    var $chip = $(e.target);
         | 
| 82 | 
            -
                    if ($chip.length) {
         | 
| 83 | 
            -
                      var wasSelected = $chip.hasClass('selected');
         | 
| 84 | 
            -
                      var $chips = $chip.closest(SELS.CHIPS);
         | 
| 85 | 
            -
                      $(SELS.CHIP).removeClass('selected');
         | 
| 86 | 
            -
             | 
| 87 | 
            -
                      if (!wasSelected) {
         | 
| 88 | 
            -
                        self.selectChip($chip.index(), $chips);
         | 
| 89 | 
            -
                      }
         | 
| 90 | 
            -
                    }
         | 
| 91 | 
            -
                  });
         | 
| 92 | 
            -
             | 
| 93 | 
            -
                  self.$document.off('keydown.chips').on('keydown.chips', function(e){
         | 
| 94 | 
            -
                    if ($(e.target).is('input, textarea')) {
         | 
| 95 | 
            -
                      return;
         | 
| 96 | 
            -
                    }
         | 
| 97 | 
            -
             | 
| 98 | 
            -
                    // delete
         | 
| 99 | 
            -
                    var $chip = self.$document.find(SELS.CHIP + SELS.SELECTED_CHIP);
         | 
| 100 | 
            -
                    var $chips = $chip.closest(SELS.CHIPS);
         | 
| 101 | 
            -
                    var length = $chip.siblings(SELS.CHIP).length;
         | 
| 102 | 
            -
                    var index;
         | 
| 103 | 
            -
             | 
| 104 | 
            -
                    if (!$chip.length) {
         | 
| 105 | 
            -
                      return;
         | 
| 106 | 
            -
                    }
         | 
| 107 | 
            -
             | 
| 108 | 
            -
                    if (e.which === 8 || e.which === 46) {
         | 
| 109 | 
            -
                      e.preventDefault();
         | 
| 110 | 
            -
             | 
| 111 | 
            -
                      index = $chip.index();
         | 
| 112 | 
            -
                      self.deleteChip(index, $chips);
         | 
| 113 | 
            -
             | 
| 114 | 
            -
                      var selectIndex = null;
         | 
| 115 | 
            -
                      if ((index + 1) < length) {
         | 
| 116 | 
            -
                        selectIndex = index;
         | 
| 117 | 
            -
                      } else if (index === length || (index + 1) === length) {
         | 
| 118 | 
            -
                        selectIndex = length - 1;
         | 
| 119 | 
            -
                      }
         | 
| 120 | 
            -
             | 
| 121 | 
            -
                      if (selectIndex < 0) selectIndex = null;
         | 
| 122 | 
            -
             | 
| 123 | 
            -
                      if (null !== selectIndex) {
         | 
| 124 | 
            -
                        self.selectChip(selectIndex, $chips);
         | 
| 125 | 
            -
                      }
         | 
| 126 | 
            -
                      if (!length) $chips.find('input').focus();
         | 
| 127 | 
            -
             | 
| 128 | 
            -
                    // left
         | 
| 129 | 
            -
                    } else if (e.which === 37) {
         | 
| 130 | 
            -
                      index = $chip.index() - 1;
         | 
| 131 | 
            -
                      if (index < 0) {
         | 
| 132 | 
            -
                        return;
         | 
| 133 | 
            -
                      }
         | 
| 134 | 
            -
                      $(SELS.CHIP).removeClass('selected');
         | 
| 135 | 
            -
                      self.selectChip(index, $chips);
         | 
| 136 | 
            -
             | 
| 137 | 
            -
                    // right
         | 
| 138 | 
            -
                    } else if (e.which === 39) {
         | 
| 139 | 
            -
                      index = $chip.index() + 1;
         | 
| 140 | 
            -
                      $(SELS.CHIP).removeClass('selected');
         | 
| 141 | 
            -
                      if (index > length) {
         | 
| 142 | 
            -
                        $chips.find('input').focus();
         | 
| 143 | 
            -
                        return;
         | 
| 144 | 
            -
                      }
         | 
| 145 | 
            -
                      self.selectChip(index, $chips);
         | 
| 146 | 
            -
                    }
         | 
| 147 | 
            -
                  });
         | 
| 148 | 
            -
             | 
| 149 | 
            -
                  self.$document.off('focusin.chips', SELS.CHIPS + ' ' + SELS.INPUT).on('focusin.chips', SELS.CHIPS + ' ' + SELS.INPUT, function(e){
         | 
| 150 | 
            -
                    var $currChips = $(e.target).closest(SELS.CHIPS);
         | 
| 151 | 
            -
                    $currChips.addClass('focus');
         | 
| 152 | 
            -
                    $currChips.siblings('label, .prefix').addClass('active');
         | 
| 153 | 
            -
                    $(SELS.CHIP).removeClass('selected');
         | 
| 154 | 
            -
                  });
         | 
| 155 | 
            -
             | 
| 156 | 
            -
                  self.$document.off('focusout.chips', SELS.CHIPS + ' ' + SELS.INPUT).on('focusout.chips', SELS.CHIPS + ' ' + SELS.INPUT, function(e){
         | 
| 157 | 
            -
                    var $currChips = $(e.target).closest(SELS.CHIPS);
         | 
| 158 | 
            -
                    $currChips.removeClass('focus');
         | 
| 159 | 
            -
             | 
| 160 | 
            -
                    // Remove active if empty
         | 
| 161 | 
            -
                    if ($currChips.data('chips') === undefined || !$currChips.data('chips').length) {
         | 
| 162 | 
            -
                      $currChips.siblings('label').removeClass('active');
         | 
| 163 | 
            -
                    }
         | 
| 164 | 
            -
                    $currChips.siblings('.prefix').removeClass('active');
         | 
| 165 | 
            -
                  });
         | 
| 166 | 
            -
             | 
| 167 | 
            -
                  self.$document.off('keydown.chips-add', SELS.CHIPS + ' ' + SELS.INPUT).on('keydown.chips-add', SELS.CHIPS + ' ' + SELS.INPUT, function(e){
         | 
| 168 | 
            -
                    var $target = $(e.target);
         | 
| 169 | 
            -
                    var $chips = $target.closest(SELS.CHIPS);
         | 
| 170 | 
            -
                    var chipsLength = $chips.children(SELS.CHIP).length;
         | 
| 171 | 
            -
             | 
| 172 | 
            -
                    // enter
         | 
| 173 | 
            -
                    if (13 === e.which) {
         | 
| 174 | 
            -
                      // Override enter if autocompleting.
         | 
| 175 | 
            -
                      if (self.hasAutocomplete &&
         | 
| 176 | 
            -
                          $chips.find('.autocomplete-content.dropdown-content').length &&
         | 
| 177 | 
            -
                          $chips.find('.autocomplete-content.dropdown-content').children().length) {
         | 
| 178 | 
            -
                        return;
         | 
| 179 | 
            -
                      }
         | 
| 180 | 
            -
             | 
| 181 | 
            -
                      e.preventDefault();
         | 
| 182 | 
            -
                      self.addChip({tag: $target.val()}, $chips);
         | 
| 183 | 
            -
                      $target.val('');
         | 
| 184 | 
            -
                      return;
         | 
| 185 | 
            -
                    }
         | 
| 186 | 
            -
             | 
| 187 | 
            -
                    // delete or left
         | 
| 188 | 
            -
                    if ((8 === e.keyCode || 37 === e.keyCode) && '' === $target.val() && chipsLength) {
         | 
| 189 | 
            -
                      e.preventDefault();
         | 
| 190 | 
            -
                      self.selectChip(chipsLength - 1, $chips);
         | 
| 191 | 
            -
                      $target.blur();
         | 
| 192 | 
            -
                      return;
         | 
| 193 | 
            -
                    }
         | 
| 194 | 
            -
                  });
         | 
| 195 | 
            -
             | 
| 196 | 
            -
                  // Click on delete icon in chip.
         | 
| 197 | 
            -
                  self.$document.off('click.chips-delete', SELS.CHIPS + ' ' + SELS.DELETE).on('click.chips-delete', SELS.CHIPS + ' ' + SELS.DELETE, function(e) {
         | 
| 198 | 
            -
                    var $target = $(e.target);
         | 
| 199 | 
            -
                    var $chips = $target.closest(SELS.CHIPS);
         | 
| 200 | 
            -
                    var $chip = $target.closest(SELS.CHIP);
         | 
| 201 | 
            -
                    e.stopPropagation();
         | 
| 202 | 
            -
                    self.deleteChip($chip.index(), $chips);
         | 
| 203 | 
            -
                    $chips.find('input').focus();
         | 
| 204 | 
            -
                  });
         | 
| 205 | 
            -
                };
         | 
| 206 | 
            -
             | 
| 207 | 
            -
                this.chips = function($chips, chipId) {
         | 
| 208 | 
            -
                  $chips.empty();
         | 
| 209 | 
            -
                  $chips.data('chips').forEach(function(elem){
         | 
| 210 | 
            -
                    $chips.append(self.renderChip(elem));
         | 
| 211 | 
            -
                  });
         | 
| 212 | 
            -
                  $chips.append($('<input id="' + chipId +'" class="input mdui-textfield-input" placeholder="">'));
         | 
| 213 | 
            -
                  self.setPlaceholder($chips);
         | 
| 214 | 
            -
             | 
| 215 | 
            -
                  // Set for attribute for label
         | 
| 216 | 
            -
                  var label = $chips.next('label');
         | 
| 217 | 
            -
                  if (label.length) {
         | 
| 218 | 
            -
                    label.attr('for', chipId);
         | 
| 219 | 
            -
             | 
| 220 | 
            -
                    if ($chips.data('chips')!== undefined && $chips.data('chips').length) {
         | 
| 221 | 
            -
                      label.addClass('active');
         | 
| 222 | 
            -
                    }
         | 
| 223 | 
            -
                  }
         | 
| 224 | 
            -
             | 
| 225 | 
            -
                  // Setup autocomplete if needed.
         | 
| 226 | 
            -
                  var input = $('#' + chipId);
         | 
| 227 | 
            -
                  if (self.hasAutocomplete) {
         | 
| 228 | 
            -
                    curr_options.autocompleteOptions.onAutocomplete = function(val) {
         | 
| 229 | 
            -
                      self.addChip({tag: val}, $chips);
         | 
| 230 | 
            -
                      input.val('');
         | 
| 231 | 
            -
                      input.focus();
         | 
| 232 | 
            -
                    }
         | 
| 233 | 
            -
                    input.autocomplete(curr_options.autocompleteOptions);
         | 
| 234 | 
            -
                  }
         | 
| 235 | 
            -
                };
         | 
| 236 | 
            -
             | 
| 237 | 
            -
                /**
         | 
| 238 | 
            -
                 * Render chip jQuery element.
         | 
| 239 | 
            -
                 * @param {Object} elem
         | 
| 240 | 
            -
                 * @return {jQuery}
         | 
| 241 | 
            -
                 */
         | 
| 242 | 
            -
                this.renderChip = function(elem) {
         | 
| 243 | 
            -
                  if (!elem.tag) return;
         | 
| 244 | 
            -
             | 
| 245 | 
            -
                  var $renderedChip = $('<div class="mdui-chip chip mdui-chip-title"></div>');
         | 
| 246 | 
            -
                  $renderedChip.text(elem.tag);
         | 
| 247 | 
            -
                  if (elem.image) {
         | 
| 248 | 
            -
                    $renderedChip.prepend($('<img />').attr('src', elem.image))
         | 
| 249 | 
            -
                  }
         | 
| 250 | 
            -
                  $renderedChip.append($('<i class="material-icons mdui-icon close">close</i>'));
         | 
| 251 | 
            -
                  return $renderedChip;
         | 
| 252 | 
            -
                };
         | 
| 253 | 
            -
             | 
| 254 | 
            -
                this.setPlaceholder = function($chips) {
         | 
| 255 | 
            -
                  if ($chips.data('chips') !== undefined && $chips.data('chips').length && curr_options.placeholder) {
         | 
| 256 | 
            -
                    $chips.find('input').prop('placeholder', curr_options.placeholder);
         | 
| 257 | 
            -
             | 
| 258 | 
            -
                  } else if (($chips.data('chips') === undefined || !$chips.data('chips').length) && curr_options.secondaryPlaceholder) {
         | 
| 259 | 
            -
                    $chips.find('input').prop('placeholder', curr_options.secondaryPlaceholder);
         | 
| 260 | 
            -
                  }
         | 
| 261 | 
            -
                };
         | 
| 262 | 
            -
             | 
| 263 | 
            -
                this.isValid = function($chips, elem) {
         | 
| 264 | 
            -
                  var chips = $chips.data('chips');
         | 
| 265 | 
            -
                  var exists = false;
         | 
| 266 | 
            -
                  for (var i=0; i < chips.length; i++) {
         | 
| 267 | 
            -
                    if (chips[i].tag === elem.tag) {
         | 
| 268 | 
            -
                        exists = true;
         | 
| 269 | 
            -
                        return;
         | 
| 270 | 
            -
                    }
         | 
| 271 | 
            -
                  }
         | 
| 272 | 
            -
                  return '' !== elem.tag && !exists;
         | 
| 273 | 
            -
                };
         | 
| 274 | 
            -
             | 
| 275 | 
            -
                this.addChip = function(elem, $chips) {
         | 
| 276 | 
            -
                  if (!self.isValid($chips, elem)) {
         | 
| 277 | 
            -
                    return;
         | 
| 278 | 
            -
                  }
         | 
| 279 | 
            -
                  var $renderedChip = self.renderChip(elem);
         | 
| 280 | 
            -
                  var newData = [];
         | 
| 281 | 
            -
                  var oldData = $chips.data('chips');
         | 
| 282 | 
            -
                  for (var i = 0; i < oldData.length; i++) {
         | 
| 283 | 
            -
                    newData.push(oldData[i]);
         | 
| 284 | 
            -
                  }
         | 
| 285 | 
            -
                  newData.push(elem);
         | 
| 286 | 
            -
             | 
| 287 | 
            -
                  $chips.data('chips', newData);
         | 
| 288 | 
            -
                  $renderedChip.insertBefore($chips.find('input'));
         | 
| 289 | 
            -
                  $chips.trigger('chip.add', elem);
         | 
| 290 | 
            -
                  self.setPlaceholder($chips);
         | 
| 291 | 
            -
                };
         | 
| 292 | 
            -
             | 
| 293 | 
            -
                this.deleteChip = function(chipIndex, $chips) {
         | 
| 294 | 
            -
                  var chip = $chips.data('chips')[chipIndex];
         | 
| 295 | 
            -
                  $chips.find('.chip').eq(chipIndex).remove();
         | 
| 296 | 
            -
             | 
| 297 | 
            -
                  var newData = [];
         | 
| 298 | 
            -
                  var oldData = $chips.data('chips');
         | 
| 299 | 
            -
                  for (var i = 0; i < oldData.length; i++) {
         | 
| 300 | 
            -
                    if (i !== chipIndex) {
         | 
| 301 | 
            -
                      newData.push(oldData[i]);
         | 
| 302 | 
            -
                    }
         | 
| 303 | 
            -
                  }
         | 
| 304 | 
            -
             | 
| 305 | 
            -
                  $chips.data('chips', newData);
         | 
| 306 | 
            -
                  $chips.trigger('chip.delete', chip);
         | 
| 307 | 
            -
                  self.setPlaceholder($chips);
         | 
| 308 | 
            -
                };
         | 
| 309 | 
            -
             | 
| 310 | 
            -
                this.selectChip = function(chipIndex, $chips) {
         | 
| 311 | 
            -
                  var $chip = $chips.find('.chip').eq(chipIndex);
         | 
| 312 | 
            -
                  if ($chip && false === $chip.hasClass('selected')) {
         | 
| 313 | 
            -
                    $chip.addClass('selected');
         | 
| 314 | 
            -
                    $chips.trigger('chip.select', $chips.data('chips')[chipIndex]);
         | 
| 315 | 
            -
                  }
         | 
| 316 | 
            -
                };
         | 
| 317 | 
            -
             | 
| 318 | 
            -
                this.getChipsElement = function(index, $chips) {
         | 
| 319 | 
            -
                  return $chips.eq(index);
         | 
| 320 | 
            -
                };
         | 
| 321 | 
            -
             | 
| 322 | 
            -
                // init
         | 
| 323 | 
            -
                this.init();
         | 
| 324 | 
            -
             | 
| 325 | 
            -
                this.handleEvents();
         | 
| 326 | 
            -
              };
         | 
| 327 | 
            -
            }( jQuery ));
         | 
| 1 | 
            +
            Materialize={};Materialize.guid=(function(){function s4(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}return function(){return s4()+s4()+"-"+s4()+"-"+s4()+"-"+s4()+"-"+s4()+s4()+s4()}})();(function($){var materialChipsDefaults={data:[],placeholder:"",secondaryPlaceholder:"",autocompleteOptions:{},};$(document).ready(function(){$(document).on("click",".chip .close",function(e){var $chips=$(this).closest(".chips");if($chips.attr("data-initialized")){return}$(this).closest(".chip").remove()})});$.fn.material_chip=function(options){var self=this;this.$el=$(this);this.$document=$(document);this.SELS={CHIPS:".chips",CHIP:".chip",INPUT:"input",DELETE:".material-icons",SELECTED_CHIP:".selected",};if("data"===options){return this.$el.data("chips")}var curr_options=$.extend({},materialChipsDefaults,options);self.hasAutocomplete=!$.isEmptyObject(curr_options.autocompleteOptions.data);this.init=function(){var i=0;var chips;self.$el.each(function(){var $chips=$(this);var chipId=Materialize.guid();self.chipId=chipId;if(!curr_options.data||!(curr_options.data instanceof Array)){curr_options.data=[]}$chips.data("chips",curr_options.data);$chips.attr("data-index",i);$chips.attr("data-initialized",true);if(!$chips.hasClass(self.SELS.CHIPS)){$chips.addClass("chips")}self.chips($chips,chipId);i++})};this.handleEvents=function(){var SELS=self.SELS;self.$document.off("click.chips-focus",SELS.CHIPS).on("click.chips-focus",SELS.CHIPS,function(e){$(e.target).find(SELS.INPUT).focus()});self.$document.off("click.chips-select",SELS.CHIP).on("click.chips-select",SELS.CHIP,function(e){var $chip=$(e.target);if($chip.length){var wasSelected=$chip.hasClass("selected");var $chips=$chip.closest(SELS.CHIPS);$(SELS.CHIP).removeClass("selected");if(!wasSelected){self.selectChip($chip.index(),$chips)}}});self.$document.off("keydown.chips").on("keydown.chips",function(e){if($(e.target).is("input, textarea")){return}var $chip=self.$document.find(SELS.CHIP+SELS.SELECTED_CHIP);var $chips=$chip.closest(SELS.CHIPS);var length=$chip.siblings(SELS.CHIP).length;var index;if(!$chip.length){return}if(e.which===8||e.which===46){e.preventDefault();index=$chip.index();self.deleteChip(index,$chips);var selectIndex=null;if((index+1)<length){selectIndex=index}else{if(index===length||(index+1)===length){selectIndex=length-1}}if(selectIndex<0){selectIndex=null}if(null!==selectIndex){self.selectChip(selectIndex,$chips)}if(!length){$chips.find("input").focus()}}else{if(e.which===37){index=$chip.index()-1;if(index<0){return}$(SELS.CHIP).removeClass("selected");self.selectChip(index,$chips)}else{if(e.which===39){index=$chip.index()+1;$(SELS.CHIP).removeClass("selected");if(index>length){$chips.find("input").focus();return}self.selectChip(index,$chips)}}}});self.$document.off("focusin.chips",SELS.CHIPS+" "+SELS.INPUT).on("focusin.chips",SELS.CHIPS+" "+SELS.INPUT,function(e){var $currChips=$(e.target).closest(SELS.CHIPS);$currChips.addClass("focus");$currChips.siblings("label, .prefix").addClass("active");$(SELS.CHIP).removeClass("selected")});self.$document.off("focusout.chips",SELS.CHIPS+" "+SELS.INPUT).on("focusout.chips",SELS.CHIPS+" "+SELS.INPUT,function(e){var $currChips=$(e.target).closest(SELS.CHIPS);$currChips.removeClass("focus");if($currChips.data("chips")===undefined||!$currChips.data("chips").length){$currChips.siblings("label").removeClass("active")}$currChips.siblings(".prefix").removeClass("active")});self.$document.off("keydown.chips-add",SELS.CHIPS+" "+SELS.INPUT).on("keydown.chips-add",SELS.CHIPS+" "+SELS.INPUT,function(e){var $target=$(e.target);var $chips=$target.closest(SELS.CHIPS);var chipsLength=$chips.children(SELS.CHIP).length;if(13===e.which){if(self.hasAutocomplete&&$chips.find(".autocomplete-content.dropdown-content").length&&$chips.find(".autocomplete-content.dropdown-content").children().length){return}e.preventDefault();self.addChip({tag:$target.val()},$chips);$target.val("");return}if((8===e.keyCode||37===e.keyCode)&&""===$target.val()&&chipsLength){e.preventDefault();self.selectChip(chipsLength-1,$chips);$target.blur();return}});self.$document.off("click.chips-delete",SELS.CHIPS+" "+SELS.DELETE).on("click.chips-delete",SELS.CHIPS+" "+SELS.DELETE,function(e){var $target=$(e.target);var $chips=$target.closest(SELS.CHIPS);var $chip=$target.closest(SELS.CHIP);e.stopPropagation();self.deleteChip($chip.index(),$chips);$chips.find("input").focus()})};this.chips=function($chips,chipId){$chips.empty();$chips.data("chips").forEach(function(elem){$chips.append(self.renderChip(elem))});$chips.append($('<input id="'+chipId+'" class="input mdui-textfield-input" placeholder="">'));self.setPlaceholder($chips);var label=$chips.next("label");if(label.length){label.attr("for",chipId);if($chips.data("chips")!==undefined&&$chips.data("chips").length){label.addClass("active")}}var input=$("#"+chipId);if(self.hasAutocomplete){curr_options.autocompleteOptions.onAutocomplete=function(val){self.addChip({tag:val},$chips);input.val("");input.focus()
         | 
| 2 | 
            +
            };input.autocomplete(curr_options.autocompleteOptions)}};this.renderChip=function(elem){if(!elem.tag){return}var $renderedChip=$('<div class="mdui-chip chip mdui-chip-title"></div>');$renderedChip.text(elem.tag);if(elem.image){$renderedChip.prepend($("<img />").attr("src",elem.image))}$renderedChip.append($('<i class="material-icons mdui-icon close">close</i>'));return $renderedChip};this.setPlaceholder=function($chips){if($chips.data("chips")!==undefined&&$chips.data("chips").length&&curr_options.placeholder){$chips.find("input").prop("placeholder",curr_options.placeholder)}else{if(($chips.data("chips")===undefined||!$chips.data("chips").length)&&curr_options.secondaryPlaceholder){$chips.find("input").prop("placeholder",curr_options.secondaryPlaceholder)}}};this.isValid=function($chips,elem){var chips=$chips.data("chips");var exists=false;for(var i=0;i<chips.length;i++){if(chips[i].tag===elem.tag){exists=true;return}}return""!==elem.tag&&!exists};this.addChip=function(elem,$chips){if(!self.isValid($chips,elem)){return}var $renderedChip=self.renderChip(elem);var newData=[];var oldData=$chips.data("chips");for(var i=0;i<oldData.length;i++){newData.push(oldData[i])}newData.push(elem);$chips.data("chips",newData);$renderedChip.insertBefore($chips.find("input"));$chips.trigger("chip.add",elem);self.setPlaceholder($chips)};this.deleteChip=function(chipIndex,$chips){var chip=$chips.data("chips")[chipIndex];$chips.find(".chip").eq(chipIndex).remove();var newData=[];var oldData=$chips.data("chips");for(var i=0;i<oldData.length;i++){if(i!==chipIndex){newData.push(oldData[i])}}$chips.data("chips",newData);$chips.trigger("chip.delete",chip);self.setPlaceholder($chips)};this.selectChip=function(chipIndex,$chips){var $chip=$chips.find(".chip").eq(chipIndex);if($chip&&false===$chip.hasClass("selected")){$chip.addClass("selected");$chips.trigger("chip.select",$chips.data("chips")[chipIndex])}};this.getChipsElement=function(index,$chips){return $chips.eq(index)};this.init();this.handleEvents()}}(jQuery));
         |