-
Notifications
You must be signed in to change notification settings - Fork 13
/
backgrid-select2-cell.min.js
49 lines (44 loc) · 2.37 KB
/
backgrid-select2-cell.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
backgrid-select2-cell
http://github.com/wyuenho/backgrid
Copyright (c) 2013-present Cloudflare, Inc and contributors
Licensed under the MIT @license.
*/
!function(a,b){"function"==typeof define&&define.amd?
// AMD
define(["underscore","backgrid"],b):"object"==typeof exports?(
// CommonJS
require("select2"),module.exports=b(require("underscore"),require("backgrid"))):
// Browser globals
b(a._,a.Backgrid)}(this,function(a,b){"use strict";var c={},d=c.Select2CellEditor=b.Extension.Select2CellEditor=b.SelectCellEditor.extend({/** @property */
events:{change:"save"},/** @property */
select2Options:{openOnEnter:!1},initialize:function(){b.SelectCellEditor.prototype.initialize.apply(this,arguments),this.close=a.bind(this.close,this)},/**
Sets the options for `select2`. Called by the parent Select2Cell during
edit mode.
*/
setSelect2Options:function(b){this.select2Options=a.extend(b||{})},/**
Renders a `select2` select box instead of the default `<select>` HTML
element using the supplied options from #select2Options.
@chainable
*/
render:function(){return b.SelectCellEditor.prototype.render.apply(this,arguments),this.$el.select2(this.select2Options),this},/**
Attach event handlers to the select2 box and focus it.
*/
postRender:function(){var a=this;a.$el.on("select2:close",function(b){b.type="blur",a.close(b)}).select2("focus")},remove:function(){return this.$el.select2("destroy"),b.SelectCellEditor.prototype.remove.apply(this,arguments)}});/**
Select2Cell is a cell class that renders a `select2` select box during edit
mode.
@class Backgrid.Extension.Select2Cell
@extends Backgrid.SelectCell
*/
return c.Select2Cell=b.Extension.Select2Cell=b.SelectCell.extend({/** @property */
className:"select2-cell",/** @property */
editor:d,/** @property */
select2Options:null,/**
Initializer.
@param {Object} options
@param {Backbone.Model} options.model
@param {Backgrid.Column} options.column
@param {Object} [options.select2Options]
@throws {TypeError} If `optionsValues` is undefined.
*/
initialize:function(a){b.SelectCell.prototype.initialize.apply(this,arguments),this.select2Options=a.select2Options||this.select2Options,this.listenTo(this.model,"backgrid:edit",function(a,b,c,d){b.get("name")==this.column.get("name")&&d.setSelect2Options(this.select2Options)})}}),c});