Simple tag editor

Widget to insert/delete tags that matches a specific pattern. The box can auto-resizes as more tags are added.

by FernandoTen

HTML

<div style="margin-left: auto; margin-right: auto; width: 400px;">		
			<span style='color: #333; font-size: medium'>
				Tags [a-z A-Z 0-9 # + . -]
			</span>
	
			<div class='tags_container' id='tag1'>	
				<span class='tags_queue'></span>	
				<input type='text' class='tags_input' />
			</div>
			<br>
			<div class='tags_container' id='tag2'>	
				<span class='tags_queue'></span>	
				<input type='text' class='tags_input' />
			</div>
		</div>

JavaScript

(function($) {

      $.fn.getTags = function(){
            return this.find('.tags_queue span').contents().filter(function(){return this.nodeType === 3;}) 
     }

     $.fn.tagme = function(options) {

        var left = 37;
        var right = 39;
        var del = 8;
        var space = 32;
        var comma = 188;
       
        /* Settings */
       var settings = $.extend(true, {
            tagNormalStyle:{
                backgroundColor: 'black',
                color: 'white',
                marginLeft: '5px',
                marginTop: '5px',
                padding: '5px',
                float: 'left',
                borderRadius: '5px'
            },
            tagSelectedStyle:{
                backgroundColor: 'orange',
                color: 'black',
            },
            tagHoveredStyle:{
                backgroundColor: '#222',
                color: 'white'
            },
            closeTagNormalStyle:{
                cursor: 'auto'
            },
            closeTagHoveredStyle:{
                cursor:'pointer'
            },
            inputStyle:{
                border: 'none',
                outline: 'none',
                backgroundColor: 'transparent',
                height: '30px',   
                marginTop: '2px',
                paddingLeft: '5px'
            },
            tagsContainerStyle:{
                border: '1px solid #ccc',
                paddingBottom: '5px',
                borderRadius: '5px',
                backgroundColor: 'white',
                overflow: 'hidden'
            },
            tagsQueueStyle:{
                marginRight: '5px',
                verticalAlign: 'middle',
            },
            rexp: /[^a-zA-Z0-9#+\.\-]/,
            minLen: 3, 
            maxLen: 15,
            beforeAdd: null,
            afterAdd: null,
            beforeRemove: null,
            afterRemove: null
        }, options);

        this.each( function() {
        
        var current_tag =...