3 * https://github.com/ExactTarget/fuelux
5 * Copyright (c) 2012 ExactTarget
6 * Licensed under the MIT license.
9 define(['require','jquery'],function(require) {
11 var $ = require('jquery');
14 // PILLBOX CONSTRUCTOR AND PROTOTYPE
16 var Pillbox = function (element, options) {
17 this.$element = $(element);
18 this.options = $.extend({}, $.fn.pillbox.defaults, options);
19 this.$element.on('click', 'li', $.proxy(this.itemclicked, this));
26 return this.$element.find('li').map(function() {
28 return $.extend({ text: $this.text() }, $this.data());
32 itemclicked: function (e) {
33 $(e.currentTarget).remove();
39 // PILLBOX PLUGIN DEFINITION
41 $.fn.pillbox = function (option) {
44 var $set = this.each(function () {
46 var data = $this.data('pillbox');
47 var options = typeof option === 'object' && option;
49 if (!data) $this.data('pillbox', (data = new Pillbox(this, options)));
50 if (typeof option === 'string') methodReturn = data[option]();
53 return (methodReturn === undefined) ? $set : methodReturn;
56 $.fn.pillbox.defaults = {};
58 $.fn.pillbox.Constructor = Pillbox;
64 $('body').on('mousedown.pillbox.data-api', '.pillbox', function (e) {
66 if ($this.data('pillbox')) return;
67 $this.pillbox($this.data());