SourceCode/jiouosdp/bstrap/bootstrap.autocomplete.js

(开头部分) 7KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

!function($){
 /* 基于Bootstrap Typeahead改造而来的自动完成插件
  * Author:F.L.F
  * Site: http://digdata.me
  * ================================= */

  var Autocomplete = function (element, options) {
    this.$element = $(element)
    this.options = $.extend({}, $.fn.autocomplete.defaults, options)
    this.sorter = this.options.sorter || this.sorter
    this.highlighter = this.options.highlighter || this.highlighter
    this.updater = this.options.updater || this.updater
    this.source = this.options.source
    this.$menu = $(this.options.menu)
    this.shown = false
	this.formatItem = this.options.formatItem || this.formatItem
	this.setValue = this.options.setValue || this.setValue
    this.listen()
  }

  Autocomplete.prototype = {

    constructor: Autocomplete
  , processObj:0
  , formatItem:function(item){
		return item.toString();
	}
  , setValue:function(item){
		return {"data-value":item.toString(),"real-value":item.toString()};
    }
  
  , select: function () {
      var val = this.$menu.find('.active').attr('data-value')
	  var realVal = this.$menu.find('.active').attr('real-value')
      this.$element
        .val(this.updater(val)).attr("real-value",realVal)
        .change()
      return this.hide()
    }

  , updater: function (item) {
      return item
    }

  , show: function () {
      var pos = $.extend({}, this.$element.position(), {
        height: this.$element[0].offsetHeight
      })

      this.$menu
        .insertAfter(this.$element)
        .css({
          top: pos.top + pos.height
        , left: pos.left
        })
        .show()

      this.shown = true
      return this
    }
后面还有 246 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。