annotate query_builder/bootstrap-select/dist/js/bootstrap-select.js @ 26:22be4ea663a7

Trying to work out having json request from neo4j display properly in drop down selectize box
author arussell
date Tue, 01 Dec 2015 02:07:13 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1 /*!
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
2 * Bootstrap-select v1.7.2 (http://silviomoreto.github.io/bootstrap-select)
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
3 *
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
4 * Copyright 2013-2015 bootstrap-select
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
5 * Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE)
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
6 */
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
7
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
8 (function (root, factory) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
9 if (typeof define === 'function' && define.amd) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
10 // AMD. Register as an anonymous module unless amdModuleId is set
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
11 define(["jquery"], function (a0) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
12 return (factory(a0));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
13 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
14 } else if (typeof exports === 'object') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
15 // Node. Does not work with strict CommonJS, but
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
16 // only CommonJS-like environments that support module.exports,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
17 // like Node.
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
18 module.exports = factory(require("jquery"));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
19 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
20 factory(jQuery);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
21 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
22 }(this, function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
23
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
24 (function ($) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
25 'use strict';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
26
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
27 //<editor-fold desc="Shims">
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
28 if (!String.prototype.includes) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
29 (function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
30 'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
31 var toString = {}.toString;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
32 var defineProperty = (function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
33 // IE 8 only supports `Object.defineProperty` on DOM elements
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
34 try {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
35 var object = {};
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
36 var $defineProperty = Object.defineProperty;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
37 var result = $defineProperty(object, object, object) && $defineProperty;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
38 } catch (error) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
39 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
40 return result;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
41 }());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
42 var indexOf = ''.indexOf;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
43 var includes = function (search) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
44 if (this == null) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
45 throw TypeError();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
46 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
47 var string = String(this);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
48 if (search && toString.call(search) == '[object RegExp]') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
49 throw TypeError();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
50 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
51 var stringLength = string.length;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
52 var searchString = String(search);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
53 var searchLength = searchString.length;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
54 var position = arguments.length > 1 ? arguments[1] : undefined;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
55 // `ToInteger`
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
56 var pos = position ? Number(position) : 0;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
57 if (pos != pos) { // better `isNaN`
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
58 pos = 0;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
59 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
60 var start = Math.min(Math.max(pos, 0), stringLength);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
61 // Avoid the `indexOf` call if no match is possible
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
62 if (searchLength + start > stringLength) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
63 return false;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
64 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
65 return indexOf.call(string, searchString, pos) != -1;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
66 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
67 if (defineProperty) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
68 defineProperty(String.prototype, 'includes', {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
69 'value': includes,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
70 'configurable': true,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
71 'writable': true
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
72 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
73 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
74 String.prototype.includes = includes;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
75 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
76 }());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
77 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
78
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
79 if (!String.prototype.startsWith) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
80 (function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
81 'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
82 var defineProperty = (function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
83 // IE 8 only supports `Object.defineProperty` on DOM elements
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
84 try {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
85 var object = {};
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
86 var $defineProperty = Object.defineProperty;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
87 var result = $defineProperty(object, object, object) && $defineProperty;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
88 } catch (error) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
89 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
90 return result;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
91 }());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
92 var toString = {}.toString;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
93 var startsWith = function (search) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
94 if (this == null) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
95 throw TypeError();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
96 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
97 var string = String(this);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
98 if (search && toString.call(search) == '[object RegExp]') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
99 throw TypeError();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
100 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
101 var stringLength = string.length;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
102 var searchString = String(search);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
103 var searchLength = searchString.length;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
104 var position = arguments.length > 1 ? arguments[1] : undefined;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
105 // `ToInteger`
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
106 var pos = position ? Number(position) : 0;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
107 if (pos != pos) { // better `isNaN`
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
108 pos = 0;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
109 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
110 var start = Math.min(Math.max(pos, 0), stringLength);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
111 // Avoid the `indexOf` call if no match is possible
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
112 if (searchLength + start > stringLength) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
113 return false;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
114 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
115 var index = -1;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
116 while (++index < searchLength) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
117 if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
118 return false;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
119 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
120 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
121 return true;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
122 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
123 if (defineProperty) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
124 defineProperty(String.prototype, 'startsWith', {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
125 'value': startsWith,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
126 'configurable': true,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
127 'writable': true
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
128 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
129 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
130 String.prototype.startsWith = startsWith;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
131 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
132 }());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
133 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
134
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
135 if (!Object.keys) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
136 Object.keys = function (
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
137 o, // object
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
138 k, // key
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
139 r // result array
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
140 ){
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
141 // initialize object and result
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
142 r=[];
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
143 // iterate over object keys
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
144 for (k in o)
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
145 // fill result array with non-prototypical keys
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
146 r.hasOwnProperty.call(o, k) && r.push(k);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
147 // return result
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
148 return r
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
149 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
150 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
151 //</editor-fold>
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
152
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
153 // Case insensitive contains search
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
154 $.expr[':'].icontains = function (obj, index, meta) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
155 var $obj = $(obj);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
156 var haystack = ($obj.data('tokens') || $obj.text()).toUpperCase();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
157 return haystack.includes(meta[3].toUpperCase());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
158 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
159
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
160 // Case insensitive begins search
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
161 $.expr[':'].ibegins = function (obj, index, meta) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
162 var $obj = $(obj);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
163 var haystack = ($obj.data('tokens') || $obj.text()).toUpperCase();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
164 return haystack.startsWith(meta[3].toUpperCase());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
165 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
166
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
167 // Case and accent insensitive contains search
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
168 $.expr[':'].aicontains = function (obj, index, meta) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
169 var $obj = $(obj);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
170 var haystack = ($obj.data('tokens') || $obj.data('normalizedText') || $obj.text()).toUpperCase();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
171 return haystack.includes(meta[3].toUpperCase());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
172 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
173
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
174 // Case and accent insensitive begins search
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
175 $.expr[':'].aibegins = function (obj, index, meta) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
176 var $obj = $(obj);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
177 var haystack = ($obj.data('tokens') || $obj.data('normalizedText') || $obj.text()).toUpperCase();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
178 return haystack.startsWith(meta[3].toUpperCase());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
179 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
180
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
181 /**
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
182 * Remove all diatrics from the given text.
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
183 * @access private
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
184 * @param {String} text
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
185 * @returns {String}
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
186 */
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
187 function normalizeToBase(text) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
188 var rExps = [
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
189 {re: /[\xC0-\xC6]/g, ch: "A"},
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
190 {re: /[\xE0-\xE6]/g, ch: "a"},
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
191 {re: /[\xC8-\xCB]/g, ch: "E"},
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
192 {re: /[\xE8-\xEB]/g, ch: "e"},
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
193 {re: /[\xCC-\xCF]/g, ch: "I"},
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
194 {re: /[\xEC-\xEF]/g, ch: "i"},
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
195 {re: /[\xD2-\xD6]/g, ch: "O"},
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
196 {re: /[\xF2-\xF6]/g, ch: "o"},
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
197 {re: /[\xD9-\xDC]/g, ch: "U"},
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
198 {re: /[\xF9-\xFC]/g, ch: "u"},
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
199 {re: /[\xC7-\xE7]/g, ch: "c"},
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
200 {re: /[\xD1]/g, ch: "N"},
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
201 {re: /[\xF1]/g, ch: "n"}
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
202 ];
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
203 $.each(rExps, function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
204 text = text.replace(this.re, this.ch);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
205 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
206 return text;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
207 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
208
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
209
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
210 function htmlEscape(html) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
211 var escapeMap = {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
212 '&': '&amp;',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
213 '<': '&lt;',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
214 '>': '&gt;',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
215 '"': '&quot;',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
216 "'": '&#x27;',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
217 '`': '&#x60;'
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
218 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
219 var source = '(?:' + Object.keys(escapeMap).join('|') + ')',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
220 testRegexp = new RegExp(source),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
221 replaceRegexp = new RegExp(source, 'g'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
222 string = html == null ? '' : '' + html;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
223 return testRegexp.test(string) ? string.replace(replaceRegexp, function (match) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
224 return escapeMap[match];
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
225 }) : string;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
226 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
227
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
228 var Selectpicker = function (element, options, e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
229 if (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
230 e.stopPropagation();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
231 e.preventDefault();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
232 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
233
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
234 this.$element = $(element);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
235 this.$newElement = null;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
236 this.$button = null;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
237 this.$menu = null;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
238 this.$lis = null;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
239 this.options = options;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
240
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
241 // If we have no title yet, try to pull it from the html title attribute (jQuery doesnt' pick it up as it's not a
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
242 // data-attribute)
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
243 if (this.options.title === null) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
244 this.options.title = this.$element.attr('title');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
245 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
246
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
247 //Expose public methods
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
248 this.val = Selectpicker.prototype.val;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
249 this.render = Selectpicker.prototype.render;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
250 this.refresh = Selectpicker.prototype.refresh;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
251 this.setStyle = Selectpicker.prototype.setStyle;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
252 this.selectAll = Selectpicker.prototype.selectAll;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
253 this.deselectAll = Selectpicker.prototype.deselectAll;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
254 this.destroy = Selectpicker.prototype.remove;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
255 this.remove = Selectpicker.prototype.remove;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
256 this.show = Selectpicker.prototype.show;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
257 this.hide = Selectpicker.prototype.hide;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
258
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
259 this.init();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
260 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
261
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
262 Selectpicker.VERSION = '1.7.2';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
263
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
264 // part of this is duplicated in i18n/defaults-en_US.js. Make sure to update both.
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
265 Selectpicker.DEFAULTS = {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
266 noneSelectedText: 'Nothing selected',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
267 noneResultsText: 'No results matched {0}',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
268 countSelectedText: function (numSelected, numTotal) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
269 return (numSelected == 1) ? "{0} item selected" : "{0} items selected";
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
270 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
271 maxOptionsText: function (numAll, numGroup) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
272 return [
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
273 (numAll == 1) ? 'Limit reached ({n} item max)' : 'Limit reached ({n} items max)',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
274 (numGroup == 1) ? 'Group limit reached ({n} item max)' : 'Group limit reached ({n} items max)'
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
275 ];
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
276 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
277 selectAllText: 'Select All',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
278 deselectAllText: 'Deselect All',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
279 doneButton: false,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
280 doneButtonText: 'Close',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
281 multipleSeparator: ', ',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
282 styleBase: 'btn',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
283 style: 'btn-default',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
284 size: 'auto',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
285 title: null,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
286 selectedTextFormat: 'values',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
287 width: false,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
288 container: false,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
289 hideDisabled: false,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
290 showSubtext: false,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
291 showIcon: true,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
292 showContent: true,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
293 dropupAuto: true,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
294 header: false,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
295 liveSearch: false,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
296 liveSearchPlaceholder: null,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
297 liveSearchNormalize: false,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
298 liveSearchStyle: 'contains',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
299 actionsBox: false,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
300 iconBase: 'glyphicon',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
301 tickIcon: 'glyphicon-ok',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
302 maxOptions: false,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
303 mobile: false,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
304 selectOnTab: false,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
305 dropdownAlignRight: false
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
306 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
307
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
308 Selectpicker.prototype = {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
309
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
310 constructor: Selectpicker,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
311
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
312 init: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
313 var that = this,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
314 id = this.$element.attr('id');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
315
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
316 this.$element.addClass('bs-select-hidden');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
317 // store originalIndex (key) and newIndex (value) in this.liObj for fast accessibility
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
318 // allows us to do this.$lis.eq(that.liObj[index]) instead of this.$lis.filter('[data-original-index="' + index + '"]')
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
319 this.liObj = {};
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
320 this.multiple = this.$element.prop('multiple');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
321 this.autofocus = this.$element.prop('autofocus');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
322 this.$newElement = this.createView();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
323 this.$element.after(this.$newElement);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
324 this.$button = this.$newElement.children('button');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
325 this.$menu = this.$newElement.children('.dropdown-menu');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
326 this.$menuInner = this.$menu.children('.inner');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
327 this.$searchbox = this.$menu.find('input');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
328
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
329 if (this.options.dropdownAlignRight)
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
330 this.$menu.addClass('dropdown-menu-right');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
331
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
332 if (typeof id !== 'undefined') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
333 this.$button.attr('data-id', id);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
334 $('label[for="' + id + '"]').click(function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
335 e.preventDefault();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
336 that.$button.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
337 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
338 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
339
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
340 this.checkDisabled();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
341 this.clickListener();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
342 if (this.options.liveSearch) this.liveSearchListener();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
343 this.render();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
344 this.setStyle();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
345 this.setWidth();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
346 if (this.options.container) this.selectPosition();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
347 this.$menu.data('this', this);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
348 this.$newElement.data('this', this);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
349 if (this.options.mobile) this.mobile();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
350
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
351 this.$newElement.on('hide.bs.dropdown', function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
352 that.$element.trigger('hide.bs.select', e);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
353 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
354
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
355 this.$newElement.on('hidden.bs.dropdown', function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
356 that.$element.trigger('hidden.bs.select', e);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
357 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
358
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
359 this.$newElement.on('show.bs.dropdown', function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
360 that.$element.trigger('show.bs.select', e);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
361 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
362
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
363 this.$newElement.on('shown.bs.dropdown', function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
364 that.$element.trigger('shown.bs.select', e);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
365 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
366
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
367 setTimeout(function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
368 that.$element.trigger('loaded.bs.select');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
369 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
370 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
371
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
372 createDropdown: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
373 // Options
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
374 // If we are multiple, then add the show-tick class by default
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
375 var multiple = this.multiple ? ' show-tick' : '',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
376 inputGroup = this.$element.parent().hasClass('input-group') ? ' input-group-btn' : '',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
377 autofocus = this.autofocus ? ' autofocus' : '';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
378 // Elements
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
379 var header = this.options.header ? '<div class="popover-title"><button type="button" class="close" aria-hidden="true">&times;</button>' + this.options.header + '</div>' : '';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
380 var searchbox = this.options.liveSearch ?
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
381 '<div class="bs-searchbox">' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
382 '<input type="text" class="form-control" autocomplete="off"' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
383 (null === this.options.liveSearchPlaceholder ? '' : ' placeholder="' + htmlEscape(this.options.liveSearchPlaceholder) + '"') + '>' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
384 '</div>'
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
385 : '';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
386 var actionsbox = this.multiple && this.options.actionsBox ?
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
387 '<div class="bs-actionsbox">' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
388 '<div class="btn-group btn-group-sm btn-block">' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
389 '<button type="button" class="actions-btn bs-select-all btn btn-default">' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
390 this.options.selectAllText +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
391 '</button>' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
392 '<button type="button" class="actions-btn bs-deselect-all btn btn-default">' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
393 this.options.deselectAllText +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
394 '</button>' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
395 '</div>' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
396 '</div>'
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
397 : '';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
398 var donebutton = this.multiple && this.options.doneButton ?
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
399 '<div class="bs-donebutton">' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
400 '<div class="btn-group btn-block">' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
401 '<button type="button" class="btn btn-sm btn-default">' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
402 this.options.doneButtonText +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
403 '</button>' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
404 '</div>' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
405 '</div>'
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
406 : '';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
407 var drop =
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
408 '<div class="btn-group bootstrap-select' + multiple + inputGroup + '">' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
409 '<button type="button" class="' + this.options.styleBase + ' dropdown-toggle" data-toggle="dropdown"' + autofocus + '>' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
410 '<span class="filter-option pull-left"></span>&nbsp;' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
411 '<span class="caret"></span>' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
412 '</button>' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
413 '<div class="dropdown-menu open">' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
414 header +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
415 searchbox +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
416 actionsbox +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
417 '<ul class="dropdown-menu inner" role="menu">' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
418 '</ul>' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
419 donebutton +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
420 '</div>' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
421 '</div>';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
422
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
423 return $(drop);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
424 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
425
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
426 createView: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
427 var $drop = this.createDropdown(),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
428 li = this.createLi();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
429
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
430 $drop.find('ul')[0].innerHTML = li;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
431 return $drop;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
432 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
433
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
434 reloadLi: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
435 //Remove all children.
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
436 this.destroyLi();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
437 //Re build
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
438 var li = this.createLi();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
439 this.$menuInner[0].innerHTML = li;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
440 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
441
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
442 destroyLi: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
443 this.$menu.find('li').remove();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
444 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
445
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
446 createLi: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
447 var that = this,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
448 _li = [],
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
449 optID = 0,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
450 titleOption = document.createElement('option'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
451 liIndex = -1; // increment liIndex whenever a new <li> element is created to ensure liObj is correct
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
452
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
453 // Helper functions
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
454 /**
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
455 * @param content
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
456 * @param [index]
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
457 * @param [classes]
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
458 * @param [optgroup]
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
459 * @returns {string}
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
460 */
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
461 var generateLI = function (content, index, classes, optgroup) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
462 return '<li' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
463 ((typeof classes !== 'undefined' & '' !== classes) ? ' class="' + classes + '"' : '') +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
464 ((typeof index !== 'undefined' & null !== index) ? ' data-original-index="' + index + '"' : '') +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
465 ((typeof optgroup !== 'undefined' & null !== optgroup) ? 'data-optgroup="' + optgroup + '"' : '') +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
466 '>' + content + '</li>';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
467 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
468
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
469 /**
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
470 * @param text
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
471 * @param [classes]
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
472 * @param [inline]
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
473 * @param [tokens]
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
474 * @returns {string}
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
475 */
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
476 var generateA = function (text, classes, inline, tokens) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
477 return '<a tabindex="0"' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
478 (typeof classes !== 'undefined' ? ' class="' + classes + '"' : '') +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
479 (typeof inline !== 'undefined' ? ' style="' + inline + '"' : '') +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
480 (that.options.liveSearchNormalize ? ' data-normalized-text="' + normalizeToBase(htmlEscape(text)) + '"' : '') +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
481 (typeof tokens !== 'undefined' || tokens !== null ? ' data-tokens="' + tokens + '"' : '') +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
482 '>' + text +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
483 '<span class="' + that.options.iconBase + ' ' + that.options.tickIcon + ' check-mark"></span>' +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
484 '</a>';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
485 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
486
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
487 if (this.options.title && !this.multiple) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
488 // this option doesn't create a new <li> element, but does add a new option, so liIndex is decreased
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
489 // since liObj is recalculated on every refresh, liIndex needs to be decreased even if the titleOption is already appended
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
490 liIndex--;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
491
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
492 if (!this.$element.find('.bs-title-option').length) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
493 // Use native JS to prepend option (faster)
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
494 var element = this.$element[0];
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
495 titleOption.className = 'bs-title-option';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
496 titleOption.appendChild(document.createTextNode(this.options.title));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
497 titleOption.value = '';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
498 element.insertBefore(titleOption, element.firstChild);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
499 // Check if selected attribute is already set on an option. If not, select the titleOption option.
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
500 if (element.options[element.selectedIndex].getAttribute('selected') === null) titleOption.selected = true;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
501 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
502 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
503
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
504 this.$element.find('option').each(function (index) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
505 var $this = $(this);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
506
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
507 liIndex++;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
508
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
509 if ($this.hasClass('bs-title-option')) return;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
510
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
511 // Get the class and text for the option
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
512 var optionClass = this.className || '',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
513 inline = this.style.cssText,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
514 text = $this.data('content') ? $this.data('content') : $this.html(),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
515 tokens = $this.data('tokens') ? $this.data('tokens') : null,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
516 subtext = typeof $this.data('subtext') !== 'undefined' ? '<small class="text-muted">' + $this.data('subtext') + '</small>' : '',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
517 icon = typeof $this.data('icon') !== 'undefined' ? '<span class="' + that.options.iconBase + ' ' + $this.data('icon') + '"></span> ' : '',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
518 isDisabled = this.disabled || this.parentElement.tagName === 'OPTGROUP' && this.parentElement.disabled;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
519
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
520 if (icon !== '' && isDisabled) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
521 icon = '<span>' + icon + '</span>';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
522 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
523
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
524 if (that.options.hideDisabled && isDisabled) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
525 liIndex--;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
526 return;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
527 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
528
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
529 if (!$this.data('content')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
530 // Prepend any icon and append any subtext to the main text.
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
531 text = icon + '<span class="text">' + text + subtext + '</span>';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
532 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
533
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
534 if (this.parentElement.tagName === 'OPTGROUP' && $this.data('divider') !== true) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
535 if ($this.index() === 0) { // Is it the first option of the optgroup?
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
536 optID += 1;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
537
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
538 // Get the opt group label
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
539 var label = this.parentElement.label,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
540 labelSubtext = typeof $this.parent().data('subtext') !== 'undefined' ? '<small class="text-muted">' + $this.parent().data('subtext') + '</small>' : '',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
541 labelIcon = $this.parent().data('icon') ? '<span class="' + that.options.iconBase + ' ' + $this.parent().data('icon') + '"></span> ' : '',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
542 optGroupClass = ' ' + this.parentElement.className || '';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
543
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
544 label = labelIcon + '<span class="text">' + label + labelSubtext + '</span>';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
545
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
546 if (index !== 0 && _li.length > 0) { // Is it NOT the first option of the select && are there elements in the dropdown?
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
547 liIndex++;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
548 _li.push(generateLI('', null, 'divider', optID + 'div'));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
549 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
550 liIndex++;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
551 _li.push(generateLI(label, null, 'dropdown-header' + optGroupClass, optID));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
552 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
553 _li.push(generateLI(generateA(text, 'opt ' + optionClass + optGroupClass, inline, tokens), index, '', optID));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
554 } else if ($this.data('divider') === true) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
555 _li.push(generateLI('', index, 'divider'));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
556 } else if ($this.data('hidden') === true) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
557 _li.push(generateLI(generateA(text, optionClass, inline, tokens), index, 'hidden is-hidden'));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
558 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
559 if (this.previousElementSibling && this.previousElementSibling.tagName === 'OPTGROUP') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
560 liIndex++;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
561 _li.push(generateLI('', null, 'divider', optID + 'div'));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
562 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
563 _li.push(generateLI(generateA(text, optionClass, inline, tokens), index));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
564 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
565
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
566 that.liObj[index] = liIndex;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
567 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
568
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
569 //If we are not multiple, we don't have a selected item, and we don't have a title, select the first element so something is set in the button
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
570 if (!this.multiple && this.$element.find('option:selected').length === 0 && !this.options.title) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
571 this.$element.find('option').eq(0).prop('selected', true).attr('selected', 'selected');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
572 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
573
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
574 return _li.join('');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
575 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
576
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
577 findLis: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
578 if (this.$lis == null) this.$lis = this.$menu.find('li');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
579 return this.$lis;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
580 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
581
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
582 /**
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
583 * @param [updateLi] defaults to true
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
584 */
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
585 render: function (updateLi) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
586 var that = this,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
587 notDisabled;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
588
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
589 //Update the LI to match the SELECT
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
590 if (updateLi !== false) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
591 this.$element.find('option').each(function (index) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
592 var $lis = that.findLis().eq(that.liObj[index]);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
593
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
594 that.setDisabled(index, this.disabled || this.parentElement.tagName === 'OPTGROUP' && this.parentElement.disabled, $lis);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
595 that.setSelected(index, this.selected, $lis);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
596 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
597 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
598
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
599 this.tabIndex();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
600
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
601 var selectedItems = this.$element.find('option').map(function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
602 if (this.selected) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
603 if (that.options.hideDisabled && (this.disabled || this.parentElement.tagName === 'OPTGROUP' && this.parentElement.disabled)) return false;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
604
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
605 var $this = $(this),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
606 icon = $this.data('icon') && that.options.showIcon ? '<i class="' + that.options.iconBase + ' ' + $this.data('icon') + '"></i> ' : '',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
607 subtext;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
608
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
609 if (that.options.showSubtext && $this.data('subtext') && !that.multiple) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
610 subtext = ' <small class="text-muted">' + $this.data('subtext') + '</small>';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
611 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
612 subtext = '';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
613 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
614 if (typeof $this.attr('title') !== 'undefined') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
615 return $this.attr('title');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
616 } else if ($this.data('content') && that.options.showContent) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
617 return $this.data('content');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
618 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
619 return icon + $this.html() + subtext;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
620 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
621 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
622 }).toArray();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
623
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
624 //Fixes issue in IE10 occurring when no default option is selected and at least one option is disabled
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
625 //Convert all the values into a comma delimited string
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
626 var title = !this.multiple ? selectedItems[0] : selectedItems.join(this.options.multipleSeparator);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
627
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
628 //If this is multi select, and the selectText type is count, the show 1 of 2 selected etc..
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
629 if (this.multiple && this.options.selectedTextFormat.indexOf('count') > -1) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
630 var max = this.options.selectedTextFormat.split('>');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
631 if ((max.length > 1 && selectedItems.length > max[1]) || (max.length == 1 && selectedItems.length >= 2)) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
632 notDisabled = this.options.hideDisabled ? ', [disabled]' : '';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
633 var totalCount = this.$element.find('option').not('[data-divider="true"], [data-hidden="true"]' + notDisabled).length,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
634 tr8nText = (typeof this.options.countSelectedText === 'function') ? this.options.countSelectedText(selectedItems.length, totalCount) : this.options.countSelectedText;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
635 title = tr8nText.replace('{0}', selectedItems.length.toString()).replace('{1}', totalCount.toString());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
636 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
637 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
638
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
639 if (this.options.title == undefined) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
640 this.options.title = this.$element.attr('title');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
641 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
642
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
643 if (this.options.selectedTextFormat == 'static') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
644 title = this.options.title;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
645 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
646
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
647 //If we dont have a title, then use the default, or if nothing is set at all, use the not selected text
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
648 if (!title) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
649 title = typeof this.options.title !== 'undefined' ? this.options.title : this.options.noneSelectedText;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
650 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
651
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
652 //strip all html-tags and trim the result
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
653 this.$button.attr('title', $.trim(title.replace(/<[^>]*>?/g, '')));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
654 this.$button.children('.filter-option').html(title);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
655
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
656 this.$element.trigger('rendered.bs.select');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
657 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
658
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
659 /**
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
660 * @param [style]
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
661 * @param [status]
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
662 */
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
663 setStyle: function (style, status) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
664 if (this.$element.attr('class')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
665 this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi, ''));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
666 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
667
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
668 var buttonClass = style ? style : this.options.style;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
669
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
670 if (status == 'add') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
671 this.$button.addClass(buttonClass);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
672 } else if (status == 'remove') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
673 this.$button.removeClass(buttonClass);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
674 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
675 this.$button.removeClass(this.options.style);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
676 this.$button.addClass(buttonClass);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
677 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
678 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
679
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
680 liHeight: function (refresh) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
681 if (!refresh && (this.options.size === false || this.sizeInfo)) return;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
682
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
683 var newElement = document.createElement('div'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
684 menu = document.createElement('div'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
685 menuInner = document.createElement('ul'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
686 divider = document.createElement('li'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
687 li = document.createElement('li'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
688 a = document.createElement('a'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
689 text = document.createElement('span'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
690 header = this.options.header ? this.$menu.find('.popover-title')[0].cloneNode(true) : null,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
691 search = this.options.liveSearch ? document.createElement('div') : null,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
692 actions = this.options.actionsBox && this.multiple ? this.$menu.find('.bs-actionsbox')[0].cloneNode(true) : null,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
693 doneButton = this.options.doneButton && this.multiple ? this.$menu.find('.bs-donebutton')[0].cloneNode(true) : null;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
694
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
695 text.className = 'text';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
696 newElement.className = this.$menu[0].parentNode.className + ' open';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
697 menu.className = 'dropdown-menu open';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
698 menuInner.className = 'dropdown-menu inner';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
699 divider.className = 'divider';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
700
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
701 text.appendChild(document.createTextNode('Inner text'));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
702 a.appendChild(text);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
703 li.appendChild(a);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
704 menuInner.appendChild(li);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
705 menuInner.appendChild(divider);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
706 if (header) menu.appendChild(header);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
707 if (search) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
708 // create a span instead of input as creating an input element is slower
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
709 var input = document.createElement('span');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
710 search.className = 'bs-searchbox';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
711 input.className = 'form-control';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
712 search.appendChild(input);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
713 menu.appendChild(search);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
714 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
715 if (actions) menu.appendChild(actions);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
716 menu.appendChild(menuInner);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
717 if (doneButton) menu.appendChild(doneButton);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
718 newElement.appendChild(menu);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
719
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
720 document.body.appendChild(newElement);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
721
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
722 var liHeight = a.offsetHeight,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
723 headerHeight = header ? header.offsetHeight : 0,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
724 searchHeight = search ? search.offsetHeight : 0,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
725 actionsHeight = actions ? actions.offsetHeight : 0,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
726 doneButtonHeight = doneButton ? doneButton.offsetHeight : 0,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
727 dividerHeight = $(divider).outerHeight(true),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
728 // fall back to jQuery if getComputedStyle is not supported
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
729 menuStyle = getComputedStyle ? getComputedStyle(menu) : false,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
730 $menu = menuStyle ? $(menu) : null,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
731 menuPadding = parseInt(menuStyle ? menuStyle.paddingTop : $menu.css('paddingTop')) +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
732 parseInt(menuStyle ? menuStyle.paddingBottom : $menu.css('paddingBottom')) +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
733 parseInt(menuStyle ? menuStyle.borderTopWidth : $menu.css('borderTopWidth')) +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
734 parseInt(menuStyle ? menuStyle.borderBottomWidth : $menu.css('borderBottomWidth')),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
735 menuExtras = menuPadding +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
736 parseInt(menuStyle ? menuStyle.marginTop : $menu.css('marginTop')) +
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
737 parseInt(menuStyle ? menuStyle.marginBottom : $menu.css('marginBottom')) + 2;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
738
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
739 document.body.removeChild(newElement);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
740
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
741 this.sizeInfo = {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
742 liHeight: liHeight,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
743 headerHeight: headerHeight,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
744 searchHeight: searchHeight,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
745 actionsHeight: actionsHeight,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
746 doneButtonHeight: doneButtonHeight,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
747 dividerHeight: dividerHeight,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
748 menuPadding: menuPadding,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
749 menuExtras: menuExtras
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
750 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
751 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
752
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
753 setSize: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
754 this.findLis();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
755 this.liHeight();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
756 var that = this,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
757 $menu = this.$menu,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
758 $menuInner = this.$menuInner,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
759 $window = $(window),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
760 selectHeight = this.$newElement[0].offsetHeight,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
761 liHeight = this.sizeInfo['liHeight'],
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
762 headerHeight = this.sizeInfo['headerHeight'],
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
763 searchHeight = this.sizeInfo['searchHeight'],
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
764 actionsHeight = this.sizeInfo['actionsHeight'],
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
765 doneButtonHeight = this.sizeInfo['doneButtonHeight'],
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
766 divHeight = this.sizeInfo['dividerHeight'],
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
767 menuPadding = this.sizeInfo['menuPadding'],
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
768 menuExtras = this.sizeInfo['menuExtras'],
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
769 notDisabled = this.options.hideDisabled ? '.disabled' : '',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
770 menuHeight,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
771 getHeight,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
772 selectOffsetTop,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
773 selectOffsetBot,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
774 posVert = function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
775 selectOffsetTop = that.$newElement.offset().top - $window.scrollTop();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
776 selectOffsetBot = $window.height() - selectOffsetTop - selectHeight;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
777 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
778
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
779 posVert();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
780
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
781 if (this.options.header) $menu.css('padding-top', 0);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
782
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
783 if (this.options.size === 'auto') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
784 var getSize = function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
785 var minHeight,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
786 hasClass = function (className, include) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
787 return function (element) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
788 if (include) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
789 return (element.classList ? element.classList.contains(className) : $(element).hasClass(className));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
790 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
791 return !(element.classList ? element.classList.contains(className) : $(element).hasClass(className));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
792 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
793 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
794 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
795 lis = that.$menuInner[0].getElementsByTagName('li'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
796 lisVisible = Array.prototype.filter ? Array.prototype.filter.call(lis, hasClass('hidden', false)) : that.$lis.not('.hidden'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
797 optGroup = Array.prototype.filter ? Array.prototype.filter.call(lisVisible, hasClass('dropdown-header', true)) : lisVisible.filter('.dropdown-header');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
798
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
799 posVert();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
800 menuHeight = selectOffsetBot - menuExtras;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
801
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
802 if (that.options.container) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
803 if (!$menu.data('height')) $menu.data('height', $menu.height());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
804 getHeight = $menu.data('height');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
805 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
806 getHeight = $menu.height();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
807 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
808
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
809 if (that.options.dropupAuto) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
810 that.$newElement.toggleClass('dropup', selectOffsetTop > selectOffsetBot && (menuHeight - menuExtras) < getHeight);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
811 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
812 if (that.$newElement.hasClass('dropup')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
813 menuHeight = selectOffsetTop - menuExtras;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
814 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
815
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
816 if ((lisVisible.length + optGroup.length) > 3) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
817 minHeight = liHeight * 3 + menuExtras - 2;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
818 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
819 minHeight = 0;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
820 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
821
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
822 $menu.css({
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
823 'max-height': menuHeight + 'px',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
824 'overflow': 'hidden',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
825 'min-height': minHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight + 'px'
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
826 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
827 $menuInner.css({
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
828 'max-height': menuHeight - headerHeight - searchHeight - actionsHeight - doneButtonHeight - menuPadding + 'px',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
829 'overflow-y': 'auto',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
830 'min-height': Math.max(minHeight - menuPadding, 0) + 'px'
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
831 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
832 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
833 getSize();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
834 this.$searchbox.off('input.getSize propertychange.getSize').on('input.getSize propertychange.getSize', getSize);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
835 $window.off('resize.getSize scroll.getSize').on('resize.getSize scroll.getSize', getSize);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
836 } else if (this.options.size && this.options.size != 'auto' && this.$lis.not(notDisabled).length > this.options.size) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
837 var optIndex = this.$lis.not('.divider').not(notDisabled).children().slice(0, this.options.size).last().parent().index(),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
838 divLength = this.$lis.slice(0, optIndex + 1).filter('.divider').length;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
839 menuHeight = liHeight * this.options.size + divLength * divHeight + menuPadding;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
840
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
841 if (that.options.container) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
842 if (!$menu.data('height')) $menu.data('height', $menu.height());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
843 getHeight = $menu.data('height');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
844 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
845 getHeight = $menu.height();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
846 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
847
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
848 if (that.options.dropupAuto) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
849 //noinspection JSUnusedAssignment
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
850 this.$newElement.toggleClass('dropup', selectOffsetTop > selectOffsetBot && (menuHeight - menuExtras) < getHeight);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
851 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
852 $menu.css({
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
853 'max-height': menuHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight + 'px',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
854 'overflow': 'hidden',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
855 'min-height': ''
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
856 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
857 $menuInner.css({
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
858 'max-height': menuHeight - menuPadding + 'px',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
859 'overflow-y': 'auto',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
860 'min-height': ''
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
861 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
862 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
863 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
864
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
865 setWidth: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
866 if (this.options.width === 'auto') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
867 this.$menu.css('min-width', '0');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
868
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
869 // Get correct width if element is hidden
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
870 var $selectClone = this.$menu.parent().clone().appendTo('body'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
871 $selectClone2 = this.options.container ? this.$newElement.clone().appendTo('body') : $selectClone,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
872 ulWidth = $selectClone.children('.dropdown-menu').outerWidth(),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
873 btnWidth = $selectClone2.css('width', 'auto').children('button').outerWidth();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
874
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
875 $selectClone.remove();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
876 $selectClone2.remove();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
877
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
878 // Set width to whatever's larger, button title or longest option
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
879 this.$newElement.css('width', Math.max(ulWidth, btnWidth) + 'px');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
880 } else if (this.options.width === 'fit') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
881 // Remove inline min-width so width can be changed from 'auto'
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
882 this.$menu.css('min-width', '');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
883 this.$newElement.css('width', '').addClass('fit-width');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
884 } else if (this.options.width) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
885 // Remove inline min-width so width can be changed from 'auto'
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
886 this.$menu.css('min-width', '');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
887 this.$newElement.css('width', this.options.width);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
888 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
889 // Remove inline min-width/width so width can be changed
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
890 this.$menu.css('min-width', '');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
891 this.$newElement.css('width', '');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
892 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
893 // Remove fit-width class if width is changed programmatically
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
894 if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
895 this.$newElement.removeClass('fit-width');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
896 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
897 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
898
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
899 selectPosition: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
900 var that = this,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
901 drop = '<div />',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
902 $drop = $(drop),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
903 pos,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
904 actualHeight,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
905 getPlacement = function ($element) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
906 $drop.addClass($element.attr('class').replace(/form-control|fit-width/gi, '')).toggleClass('dropup', $element.hasClass('dropup'));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
907 pos = $element.offset();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
908 actualHeight = $element.hasClass('dropup') ? 0 : $element[0].offsetHeight;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
909 $drop.css({
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
910 'top': pos.top + actualHeight,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
911 'left': pos.left,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
912 'width': $element[0].offsetWidth,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
913 'position': 'absolute'
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
914 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
915 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
916
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
917 this.$newElement.on('click', function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
918 if (that.isDisabled()) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
919 return;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
920 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
921 getPlacement($(this));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
922 $drop.appendTo(that.options.container);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
923 $drop.toggleClass('open', !$(this).hasClass('open'));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
924 $drop.append(that.$menu);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
925 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
926
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
927 $(window).on('resize scroll', function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
928 getPlacement(that.$newElement);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
929 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
930
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
931 this.$element.on('hide.bs.select', function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
932 that.$menu.data('height', that.$menu.height());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
933 $drop.detach();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
934 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
935 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
936
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
937 setSelected: function (index, selected, $lis) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
938 if (!$lis) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
939 var $lis = this.findLis().eq(this.liObj[index]);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
940 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
941
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
942 $lis.toggleClass('selected', selected);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
943 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
944
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
945 setDisabled: function (index, disabled, $lis) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
946 if (!$lis) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
947 var $lis = this.findLis().eq(this.liObj[index]);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
948 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
949
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
950 if (disabled) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
951 $lis.addClass('disabled').children('a').attr('href', '#').attr('tabindex', -1);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
952 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
953 $lis.removeClass('disabled').children('a').removeAttr('href').attr('tabindex', 0);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
954 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
955 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
956
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
957 isDisabled: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
958 return this.$element[0].disabled;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
959 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
960
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
961 checkDisabled: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
962 var that = this;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
963
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
964 if (this.isDisabled()) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
965 this.$newElement.addClass('disabled');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
966 this.$button.addClass('disabled').attr('tabindex', -1);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
967 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
968 if (this.$button.hasClass('disabled')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
969 this.$newElement.removeClass('disabled');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
970 this.$button.removeClass('disabled');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
971 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
972
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
973 if (this.$button.attr('tabindex') == -1 && !this.$element.data('tabindex')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
974 this.$button.removeAttr('tabindex');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
975 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
976 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
977
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
978 this.$button.click(function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
979 return !that.isDisabled();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
980 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
981 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
982
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
983 tabIndex: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
984 if (this.$element.is('[tabindex]')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
985 this.$element.data('tabindex', this.$element.attr('tabindex'));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
986 this.$button.attr('tabindex', this.$element.data('tabindex'));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
987 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
988 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
989
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
990 clickListener: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
991 var that = this,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
992 $document = $(document);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
993
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
994 this.$newElement.on('touchstart.dropdown', '.dropdown-menu', function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
995 e.stopPropagation();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
996 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
997
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
998 $document.data('spaceSelect', false);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
999
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1000 this.$button.on('keyup', function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1001 if (/(32)/.test(e.keyCode.toString(10)) && $document.data('spaceSelect')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1002 e.preventDefault();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1003 $document.data('spaceSelect', false);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1004 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1005 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1006
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1007 this.$newElement.on('click', function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1008 that.setSize();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1009 that.$element.on('shown.bs.select', function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1010 if (!that.options.liveSearch && !that.multiple) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1011 that.$menu.find('.selected a').focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1012 } else if (!that.multiple) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1013 var selectedIndex = that.liObj[that.$element[0].selectedIndex];
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1014
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1015 if (typeof selectedIndex !== 'number') return;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1016
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1017 // scroll to selected option
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1018 var offset = that.$lis.eq(selectedIndex)[0].offsetTop - that.$menuInner[0].offsetTop;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1019 offset = offset - that.$menuInner[0].offsetHeight/2 + that.sizeInfo.liHeight/2;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1020 that.$menuInner[0].scrollTop = offset;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1021 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1022 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1023 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1024
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1025 this.$menu.on('click', 'li a', function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1026 var $this = $(this),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1027 clickedIndex = $this.parent().data('originalIndex'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1028 prevValue = that.$element.val(),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1029 prevIndex = that.$element.prop('selectedIndex');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1030
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1031 // Don't close on multi choice menu
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1032 if (that.multiple) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1033 e.stopPropagation();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1034 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1035
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1036 e.preventDefault();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1037
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1038 //Don't run if we have been disabled
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1039 if (!that.isDisabled() && !$this.parent().hasClass('disabled')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1040 var $options = that.$element.find('option'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1041 $option = $options.eq(clickedIndex),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1042 state = $option.prop('selected'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1043 $optgroup = $option.parent('optgroup'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1044 maxOptions = that.options.maxOptions,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1045 maxOptionsGrp = $optgroup.data('maxOptions') || false;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1046
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1047 if (!that.multiple) { // Deselect all others if not multi select box
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1048 $options.prop('selected', false);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1049 $option.prop('selected', true);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1050 that.$menu.find('.selected').removeClass('selected');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1051 that.setSelected(clickedIndex, true);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1052 } else { // Toggle the one we have chosen if we are multi select.
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1053 $option.prop('selected', !state);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1054 that.setSelected(clickedIndex, !state);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1055 $this.blur();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1056
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1057 if (maxOptions !== false || maxOptionsGrp !== false) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1058 var maxReached = maxOptions < $options.filter(':selected').length,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1059 maxReachedGrp = maxOptionsGrp < $optgroup.find('option:selected').length;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1060
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1061 if ((maxOptions && maxReached) || (maxOptionsGrp && maxReachedGrp)) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1062 if (maxOptions && maxOptions == 1) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1063 $options.prop('selected', false);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1064 $option.prop('selected', true);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1065 that.$menu.find('.selected').removeClass('selected');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1066 that.setSelected(clickedIndex, true);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1067 } else if (maxOptionsGrp && maxOptionsGrp == 1) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1068 $optgroup.find('option:selected').prop('selected', false);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1069 $option.prop('selected', true);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1070 var optgroupID = $this.parent().data('optgroup');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1071 that.$menu.find('[data-optgroup="' + optgroupID + '"]').removeClass('selected');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1072 that.setSelected(clickedIndex, true);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1073 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1074 var maxOptionsArr = (typeof that.options.maxOptionsText === 'function') ?
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1075 that.options.maxOptionsText(maxOptions, maxOptionsGrp) : that.options.maxOptionsText,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1076 maxTxt = maxOptionsArr[0].replace('{n}', maxOptions),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1077 maxTxtGrp = maxOptionsArr[1].replace('{n}', maxOptionsGrp),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1078 $notify = $('<div class="notify"></div>');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1079 // If {var} is set in array, replace it
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1080 /** @deprecated */
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1081 if (maxOptionsArr[2]) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1082 maxTxt = maxTxt.replace('{var}', maxOptionsArr[2][maxOptions > 1 ? 0 : 1]);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1083 maxTxtGrp = maxTxtGrp.replace('{var}', maxOptionsArr[2][maxOptionsGrp > 1 ? 0 : 1]);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1084 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1085
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1086 $option.prop('selected', false);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1087
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1088 that.$menu.append($notify);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1089
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1090 if (maxOptions && maxReached) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1091 $notify.append($('<div>' + maxTxt + '</div>'));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1092 that.$element.trigger('maxReached.bs.select');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1093 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1094
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1095 if (maxOptionsGrp && maxReachedGrp) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1096 $notify.append($('<div>' + maxTxtGrp + '</div>'));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1097 that.$element.trigger('maxReachedGrp.bs.select');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1098 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1099
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1100 setTimeout(function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1101 that.setSelected(clickedIndex, false);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1102 }, 10);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1103
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1104 $notify.delay(750).fadeOut(300, function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1105 $(this).remove();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1106 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1107 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1108 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1109 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1110 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1111
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1112 if (!that.multiple) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1113 that.$button.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1114 } else if (that.options.liveSearch) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1115 that.$searchbox.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1116 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1117
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1118 // Trigger select 'change'
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1119 if ((prevValue != that.$element.val() && that.multiple) || (prevIndex != that.$element.prop('selectedIndex') && !that.multiple)) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1120 that.$element.change();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1121 // $option.prop('selected') is current option state (selected/unselected). state is previous option state.
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1122 that.$element.trigger('changed.bs.select', [clickedIndex, $option.prop('selected'), state]);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1123 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1124 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1125 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1126
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1127 this.$menu.on('click', 'li.disabled a, .popover-title, .popover-title :not(.close)', function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1128 if (e.currentTarget == this) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1129 e.preventDefault();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1130 e.stopPropagation();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1131 if (that.options.liveSearch && !$(e.target).hasClass('close')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1132 that.$searchbox.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1133 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1134 that.$button.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1135 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1136 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1137 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1138
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1139 this.$menu.on('click', 'li.divider, li.dropdown-header', function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1140 e.preventDefault();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1141 e.stopPropagation();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1142 if (that.options.liveSearch) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1143 that.$searchbox.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1144 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1145 that.$button.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1146 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1147 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1148
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1149 this.$menu.on('click', '.popover-title .close', function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1150 that.$button.click();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1151 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1152
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1153 this.$searchbox.on('click', function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1154 e.stopPropagation();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1155 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1156
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1157 this.$menu.on('click', '.actions-btn', function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1158 if (that.options.liveSearch) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1159 that.$searchbox.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1160 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1161 that.$button.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1162 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1163
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1164 e.preventDefault();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1165 e.stopPropagation();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1166
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1167 if ($(this).hasClass('bs-select-all')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1168 that.selectAll();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1169 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1170 that.deselectAll();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1171 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1172 that.$element.change();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1173 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1174
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1175 this.$element.change(function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1176 that.render(false);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1177 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1178 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1179
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1180 liveSearchListener: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1181 var that = this,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1182 $no_results = $('<li class="no-results"></li>');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1183
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1184 this.$newElement.on('click.dropdown.data-api touchstart.dropdown.data-api', function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1185 that.$menuInner.find('.active').removeClass('active');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1186 if (!!that.$searchbox.val()) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1187 that.$searchbox.val('');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1188 that.$lis.not('.is-hidden').removeClass('hidden');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1189 if (!!$no_results.parent().length) $no_results.remove();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1190 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1191 if (!that.multiple) that.$menuInner.find('.selected').addClass('active');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1192 setTimeout(function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1193 that.$searchbox.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1194 }, 10);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1195 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1196
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1197 this.$searchbox.on('click.dropdown.data-api focus.dropdown.data-api touchend.dropdown.data-api', function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1198 e.stopPropagation();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1199 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1200
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1201 this.$searchbox.on('input propertychange', function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1202 if (that.$searchbox.val()) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1203 var $searchBase = that.$lis.not('.is-hidden').removeClass('hidden').children('a');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1204 if (that.options.liveSearchNormalize) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1205 $searchBase = $searchBase.not(':a' + that._searchStyle() + '(' + normalizeToBase(that.$searchbox.val()) + ')');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1206 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1207 $searchBase = $searchBase.not(':' + that._searchStyle() + '(' + that.$searchbox.val() + ')');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1208 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1209 $searchBase.parent().addClass('hidden');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1210
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1211 that.$lis.filter('.dropdown-header').each(function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1212 var $this = $(this),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1213 optgroup = $this.data('optgroup');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1214
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1215 if (that.$lis.filter('[data-optgroup=' + optgroup + ']').not($this).not('.hidden').length === 0) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1216 $this.addClass('hidden');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1217 that.$lis.filter('[data-optgroup=' + optgroup + 'div]').addClass('hidden');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1218 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1219 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1220
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1221 var $lisVisible = that.$lis.not('.hidden');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1222
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1223 // hide divider if first or last visible, or if followed by another divider
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1224 $lisVisible.each(function (index) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1225 var $this = $(this);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1226
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1227 if ($this.hasClass('divider') && (
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1228 $this.index() === $lisVisible.eq(0).index() ||
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1229 $this.index() === $lisVisible.last().index() ||
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1230 $lisVisible.eq(index + 1).hasClass('divider'))) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1231 $this.addClass('hidden');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1232 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1233 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1234
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1235 if (!that.$lis.not('.hidden, .no-results').length) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1236 if (!!$no_results.parent().length) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1237 $no_results.remove();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1238 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1239 $no_results.html(that.options.noneResultsText.replace('{0}', '"' + htmlEscape(that.$searchbox.val()) + '"')).show();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1240 that.$menuInner.append($no_results);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1241 } else if (!!$no_results.parent().length) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1242 $no_results.remove();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1243 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1244
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1245 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1246 that.$lis.not('.is-hidden').removeClass('hidden');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1247 if (!!$no_results.parent().length) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1248 $no_results.remove();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1249 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1250 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1251
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1252 that.$lis.filter('.active').removeClass('active');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1253 that.$lis.not('.hidden, .divider, .dropdown-header').eq(0).addClass('active').children('a').focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1254 $(this).focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1255 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1256 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1257
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1258 _searchStyle: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1259 var style = 'icontains';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1260 switch (this.options.liveSearchStyle) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1261 case 'begins':
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1262 case 'startsWith':
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1263 style = 'ibegins';
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1264 break;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1265 case 'contains':
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1266 default:
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1267 break; //no need to change the default
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1268 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1269
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1270 return style;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1271 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1272
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1273 val: function (value) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1274 if (typeof value !== 'undefined') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1275 this.$element.val(value);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1276 this.render();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1277
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1278 return this.$element;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1279 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1280 return this.$element.val();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1281 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1282 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1283
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1284 selectAll: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1285 this.findLis();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1286 this.$element.find('option:enabled').not('[data-divider], [data-hidden]').prop('selected', true);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1287 this.$lis.not('.divider, .dropdown-header, .disabled, .hidden').addClass('selected');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1288 this.render(false);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1289 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1290
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1291 deselectAll: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1292 this.findLis();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1293 this.$element.find('option:enabled').not('[data-divider], [data-hidden]').prop('selected', false);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1294 this.$lis.not('.divider, .dropdown-header, .disabled, .hidden').removeClass('selected');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1295 this.render(false);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1296 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1297
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1298 keydown: function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1299 var $this = $(this),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1300 $parent = $this.is('input') ? $this.parent().parent() : $this.parent(),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1301 $items,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1302 that = $parent.data('this'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1303 index,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1304 next,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1305 first,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1306 last,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1307 prev,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1308 nextPrev,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1309 prevIndex,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1310 isActive,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1311 selector = ':not(.disabled, .hidden, .dropdown-header, .divider)',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1312 keyCodeMap = {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1313 32: ' ',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1314 48: '0',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1315 49: '1',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1316 50: '2',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1317 51: '3',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1318 52: '4',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1319 53: '5',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1320 54: '6',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1321 55: '7',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1322 56: '8',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1323 57: '9',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1324 59: ';',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1325 65: 'a',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1326 66: 'b',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1327 67: 'c',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1328 68: 'd',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1329 69: 'e',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1330 70: 'f',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1331 71: 'g',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1332 72: 'h',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1333 73: 'i',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1334 74: 'j',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1335 75: 'k',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1336 76: 'l',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1337 77: 'm',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1338 78: 'n',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1339 79: 'o',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1340 80: 'p',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1341 81: 'q',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1342 82: 'r',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1343 83: 's',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1344 84: 't',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1345 85: 'u',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1346 86: 'v',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1347 87: 'w',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1348 88: 'x',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1349 89: 'y',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1350 90: 'z',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1351 96: '0',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1352 97: '1',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1353 98: '2',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1354 99: '3',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1355 100: '4',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1356 101: '5',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1357 102: '6',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1358 103: '7',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1359 104: '8',
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1360 105: '9'
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1361 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1362
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1363 if (that.options.liveSearch) $parent = $this.parent().parent();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1364
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1365 if (that.options.container) $parent = that.$menu;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1366
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1367 $items = $('[role=menu] li a', $parent);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1368
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1369 isActive = that.$menu.parent().hasClass('open');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1370
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1371 if (!isActive && (e.keyCode >= 48 && e.keyCode <= 57 || event.keyCode >= 65 && event.keyCode <= 90)) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1372 if (!that.options.container) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1373 that.setSize();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1374 that.$menu.parent().addClass('open');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1375 isActive = true;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1376 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1377 that.$newElement.trigger('click');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1378 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1379 that.$searchbox.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1380 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1381
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1382 if (that.options.liveSearch) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1383 if (/(^9$|27)/.test(e.keyCode.toString(10)) && isActive && that.$menu.find('.active').length === 0) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1384 e.preventDefault();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1385 that.$menu.parent().removeClass('open');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1386 if (that.options.container) that.$newElement.removeClass('open');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1387 that.$button.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1388 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1389 // $items contains li elements when liveSearch is enabled
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1390 $items = $('[role=menu] li:not(.disabled, .hidden, .dropdown-header, .divider)', $parent);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1391 if (!$this.val() && !/(38|40)/.test(e.keyCode.toString(10))) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1392 if ($items.filter('.active').length === 0) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1393 $items = that.$newElement.find('li');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1394 if (that.options.liveSearchNormalize) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1395 $items = $items.filter(':a' + that._searchStyle() + '(' + normalizeToBase(keyCodeMap[e.keyCode]) + ')');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1396 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1397 $items = $items.filter(':' + that._searchStyle() + '(' + keyCodeMap[e.keyCode] + ')');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1398 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1399 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1400 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1401 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1402
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1403 if (!$items.length) return;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1404
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1405 if (/(38|40)/.test(e.keyCode.toString(10))) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1406 index = $items.index($items.filter(':focus'));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1407 first = $items.parent(selector).first().data('originalIndex');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1408 last = $items.parent(selector).last().data('originalIndex');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1409 next = $items.eq(index).parent().nextAll(selector).eq(0).data('originalIndex');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1410 prev = $items.eq(index).parent().prevAll(selector).eq(0).data('originalIndex');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1411 nextPrev = $items.eq(next).parent().prevAll(selector).eq(0).data('originalIndex');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1412
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1413 if (that.options.liveSearch) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1414 $items.each(function (i) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1415 if (!$(this).hasClass('disabled')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1416 $(this).data('index', i);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1417 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1418 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1419 index = $items.index($items.filter('.active'));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1420 first = $items.first().data('index');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1421 last = $items.last().data('index');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1422 next = $items.eq(index).nextAll().eq(0).data('index');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1423 prev = $items.eq(index).prevAll().eq(0).data('index');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1424 nextPrev = $items.eq(next).prevAll().eq(0).data('index');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1425 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1426
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1427 prevIndex = $this.data('prevIndex');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1428
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1429 if (e.keyCode == 38) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1430 if (that.options.liveSearch) index -= 1;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1431 if (index != nextPrev && index > prev) index = prev;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1432 if (index < first) index = first;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1433 if (index == prevIndex) index = last;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1434 } else if (e.keyCode == 40) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1435 if (that.options.liveSearch) index += 1;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1436 if (index == -1) index = 0;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1437 if (index != nextPrev && index < next) index = next;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1438 if (index > last) index = last;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1439 if (index == prevIndex) index = first;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1440 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1441
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1442 $this.data('prevIndex', index);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1443
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1444 if (!that.options.liveSearch) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1445 $items.eq(index).focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1446 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1447 e.preventDefault();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1448 if (!$this.hasClass('dropdown-toggle')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1449 $items.removeClass('active').eq(index).addClass('active').children('a').focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1450 $this.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1451 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1452 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1453
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1454 } else if (!$this.is('input')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1455 var keyIndex = [],
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1456 count,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1457 prevKey;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1458
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1459 $items.each(function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1460 if (!$(this).parent().hasClass('disabled')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1461 if ($.trim($(this).text().toLowerCase()).substring(0, 1) == keyCodeMap[e.keyCode]) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1462 keyIndex.push($(this).parent().index());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1463 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1464 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1465 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1466
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1467 count = $(document).data('keycount');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1468 count++;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1469 $(document).data('keycount', count);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1470
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1471 prevKey = $.trim($(':focus').text().toLowerCase()).substring(0, 1);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1472
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1473 if (prevKey != keyCodeMap[e.keyCode]) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1474 count = 1;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1475 $(document).data('keycount', count);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1476 } else if (count >= keyIndex.length) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1477 $(document).data('keycount', 0);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1478 if (count > keyIndex.length) count = 1;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1479 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1480
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1481 $items.eq(keyIndex[count - 1]).focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1482 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1483
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1484 // Select focused option if "Enter", "Spacebar" or "Tab" (when selectOnTab is true) are pressed inside the menu.
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1485 if ((/(13|32)/.test(e.keyCode.toString(10)) || (/(^9$)/.test(e.keyCode.toString(10)) && that.options.selectOnTab)) && isActive) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1486 if (!/(32)/.test(e.keyCode.toString(10))) e.preventDefault();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1487 if (!that.options.liveSearch) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1488 var elem = $(':focus');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1489 elem.click();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1490 // Bring back focus for multiselects
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1491 elem.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1492 // Prevent screen from scrolling if the user hit the spacebar
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1493 e.preventDefault();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1494 // Fixes spacebar selection of dropdown items in FF & IE
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1495 $(document).data('spaceSelect', true);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1496 } else if (!/(32)/.test(e.keyCode.toString(10))) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1497 that.$menu.find('.active a').click();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1498 $this.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1499 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1500 $(document).data('keycount', 0);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1501 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1502
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1503 if ((/(^9$|27)/.test(e.keyCode.toString(10)) && isActive && (that.multiple || that.options.liveSearch)) || (/(27)/.test(e.keyCode.toString(10)) && !isActive)) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1504 that.$menu.parent().removeClass('open');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1505 if (that.options.container) that.$newElement.removeClass('open');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1506 that.$button.focus();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1507 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1508 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1509
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1510 mobile: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1511 this.$element.addClass('mobile-device').appendTo(this.$newElement);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1512 if (this.options.container) this.$menu.hide();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1513 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1514
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1515 refresh: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1516 this.$lis = null;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1517 this.reloadLi();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1518 this.render();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1519 this.checkDisabled();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1520 this.liHeight(true);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1521 this.setStyle();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1522 this.setWidth();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1523 if (this.$lis) this.$searchbox.trigger('propertychange');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1524
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1525 this.$element.trigger('refreshed.bs.select');
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1526 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1527
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1528 hide: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1529 this.$newElement.hide();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1530 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1531
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1532 show: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1533 this.$newElement.show();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1534 },
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1535
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1536 remove: function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1537 this.$newElement.remove();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1538 this.$element.remove();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1539 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1540 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1541
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1542 // SELECTPICKER PLUGIN DEFINITION
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1543 // ==============================
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1544 function Plugin(option, event) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1545 // get the args of the outer function..
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1546 var args = arguments;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1547 // The arguments of the function are explicitly re-defined from the argument list, because the shift causes them
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1548 // to get lost/corrupted in android 2.3 and IE9 #715 #775
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1549 var _option = option,
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1550 _event = event;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1551 [].shift.apply(args);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1552
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1553 var value;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1554 var chain = this.each(function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1555 var $this = $(this);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1556 if ($this.is('select')) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1557 var data = $this.data('selectpicker'),
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1558 options = typeof _option == 'object' && _option;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1559
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1560 if (!data) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1561 var config = $.extend({}, Selectpicker.DEFAULTS, $.fn.selectpicker.defaults || {}, $this.data(), options);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1562 $this.data('selectpicker', (data = new Selectpicker(this, config, _event)));
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1563 } else if (options) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1564 for (var i in options) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1565 if (options.hasOwnProperty(i)) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1566 data.options[i] = options[i];
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1567 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1568 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1569 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1570
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1571 if (typeof _option == 'string') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1572 if (data[_option] instanceof Function) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1573 value = data[_option].apply(data, args);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1574 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1575 value = data.options[_option];
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1576 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1577 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1578 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1579 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1580
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1581 if (typeof value !== 'undefined') {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1582 //noinspection JSUnusedAssignment
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1583 return value;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1584 } else {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1585 return chain;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1586 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1587 }
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1588
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1589 var old = $.fn.selectpicker;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1590 $.fn.selectpicker = Plugin;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1591 $.fn.selectpicker.Constructor = Selectpicker;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1592
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1593 // SELECTPICKER NO CONFLICT
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1594 // ========================
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1595 $.fn.selectpicker.noConflict = function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1596 $.fn.selectpicker = old;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1597 return this;
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1598 };
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1599
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1600 $(document)
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1601 .data('keycount', 0)
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1602 .on('keydown', '.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role="menu"], .bs-searchbox input', Selectpicker.prototype.keydown)
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1603 .on('focusin.modal', '.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role="menu"], .bs-searchbox input', function (e) {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1604 e.stopPropagation();
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1605 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1606
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1607 // SELECTPICKER DATA-API
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1608 // =====================
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1609 $(window).on('load.bs.select.data-api', function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1610 $('.selectpicker').each(function () {
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1611 var $selectpicker = $(this);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1612 Plugin.call($selectpicker, $selectpicker.data());
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1613 })
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1614 });
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1615 })(jQuery);
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1616
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1617
22be4ea663a7 Trying to work out having json request from neo4j display properly in drop down selectize box
arussell
parents:
diff changeset
1618 }));