function tokenizer(params, options, selectCallback) {
        /**
         * Tokenises input and detects when a tag has been completed
         */
        if (!options.get('quotedTags')) {
            // If not quoting tags, use the default tokenizer
            return Tokenizer.prototype.tokenizer.call(
                this, this, params, options, selectCallback
            );
        }

        // Parse with raw
        var term = params.term,
            parsed = Tagulous.parseTags(term, options.get('spaceDelimiter'), true),
            tags = parsed[0],
            raws = parsed[1],
            lastRaw = raws.slice(-1)[0],
            i
        ;

        if (!tags.length) {
            return {term: term};
        }

        // Check for incomplete partial tag
        // If more than one tag then raw was pasted - assume all complete
        if (lastRaw === null && tags.length < 2) {
          // Last tag wasn't completed - return it to input
          tags.pop();
          raws.pop();

          lastRaw = raws.slice(-1)[0];
        }

        for (i=0; i<tags.length; i++) {
          selectCallback({
            id: tags[i],
            text: tags[i]
          })
        }

        // Return whatever was left after the last completed tag was parsed
        return {
          term: (lastRaw === undefined) ? term : lastRaw
        };
    }
/**
     * Add tokenizer to parse tags consistently between backend and frontend
     */
Add tokenizer to parse tags consistently between backend and frontend
Add tokenizer to parse tags consistently between backend and frontend
function tokenizer(params, options, selectCallback) {
        if (!options.get('quotedTags')) {
            return Tokenizer.prototype.tokenizer.call(
                this, this, params, options, selectCallback
            );
        }
        var term = params.term,
            parsed = Tagulous.parseTags(term, options.get('spaceDelimiter'), true),
            tags = parsed[0],
            raws = parsed[1],
            lastRaw = raws.slice(-1)[0],
            i
        ;
        if (!tags.length) {
            return {term: term};
        }
        if (lastRaw === null && tags.length < 2) {
          tags.pop();
          raws.pop();
          lastRaw = raws.slice(-1)[0];
        }
        for (i=0; i<tags.length; i++) {
          selectCallback({
            id: tags[i],
            text: tags[i]
          })
        }
        return {
          term: (lastRaw === undefined) ? term : lastRaw
        };
    }
function tokenizer ( params , options , selectCallback ) { if ( ! options . get ( 'quotedTags' ) ) { return Tokenizer . prototype . tokenizer . call ( this , this , params , options , selectCallback ) ; } var term = params . term , parsed = Tagulous . parseTags ( term , options . get ( 'spaceDelimiter' ) , true ) , tags = parsed [ 0 ] , raws = parsed [ 1 ] , lastRaw = raws . slice ( - 1 ) [ 0 ] , i ; if ( ! tags . length ) { return { term : term } ; } if ( lastRaw === null && tags . length < 2 ) { tags . pop ( ) ; raws . pop ( ) ; lastRaw = raws . slice ( - 1 ) [ 0 ] ; } for ( i = 0 ; i < tags . length ; i ++ ) { selectCallback ( { id : tags [ i ] , text : tags [ i ] } ) } return { term : ( lastRaw === undefined ) ? term : lastRaw } ; }
Add tokenizer to parse tags consistently between backend and frontend
Add tokenizer to parse tags consistently between backend and frontend
/**
         * Tokenises input and detects when a tag has been completed
         */ // If not quoting tags, use the default tokenizer // Parse with raw // Check for incomplete partial tag // If more than one tag then raw was pasted - assume all complete // Last tag wasn't completed - return it to input // Return whatever was left after the last completed tag was parsed