Restore select2 input functionality after Bootstrap 5 cleanup
- Restored select2 input type from earlier commit d4adf5e^ - Added select2 import to bootstrap5-editable.js bundle - Updated demo with select2 example (requires select2 library) - Enhanced README.md with comprehensive select2 documentation - Includes support for static sources, AJAX sources, and advanced configuration - Select2 library must be included separately (not bundled)
This commit is contained in:
81
README.md
81
README.md
@@ -10,6 +10,7 @@ This project was created when we needed a **drop-in replacement** for x-editable
|
|||||||
- **Bootstrap 5** compatibility
|
- **Bootstrap 5** compatibility
|
||||||
- **jQuery** support maintained
|
- **jQuery** support maintained
|
||||||
- **Select dropdowns** - fully functional
|
- **Select dropdowns** - fully functional
|
||||||
|
- **Select2 support** - advanced select with search/ajax
|
||||||
- **Date pickers** - using bootstrap-datepicker
|
- **Date pickers** - using bootstrap-datepicker
|
||||||
- **Drop-in replacement** - minimal code changes needed
|
- **Drop-in replacement** - minimal code changes needed
|
||||||
- **Streamlined codebase** - Bootstrap 5 only, legacy code removed
|
- **Streamlined codebase** - Bootstrap 5 only, legacy code removed
|
||||||
@@ -28,6 +29,7 @@ php -S 0.0.0.0:8000
|
|||||||
|
|
||||||
The demo showcases:
|
The demo showcases:
|
||||||
- Select inputs with AJAX and static data sources
|
- Select inputs with AJAX and static data sources
|
||||||
|
- Select2 inputs with search functionality (requires select2 library)
|
||||||
- Date picker functionality
|
- Date picker functionality
|
||||||
- Basic in-place editing
|
- Basic in-place editing
|
||||||
|
|
||||||
@@ -40,10 +42,10 @@ npm install x-editable-bootstrap5
|
|||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
|
|
||||||
This library requires:
|
This library automatically installs and requires:
|
||||||
- **Bootstrap 5** (CSS and JS)
|
- **Bootstrap 5** (CSS and JS)
|
||||||
- **jQuery 3.x**
|
- **jQuery 3.x**
|
||||||
- **bootstrap-datepicker** (for date inputs)
|
- **bootstrap-datepicker** (for date inputs - included as dependency)
|
||||||
|
|
||||||
### Quick Start
|
### Quick Start
|
||||||
|
|
||||||
@@ -56,6 +58,9 @@ This library requires:
|
|||||||
<!-- jQuery -->
|
<!-- jQuery -->
|
||||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Bootstrap Icons -->
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
|
||||||
|
|
||||||
<!-- Bootstrap Datepicker -->
|
<!-- Bootstrap Datepicker -->
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/css/bootstrap-datepicker.min.css" rel="stylesheet">
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/css/bootstrap-datepicker.min.css" rel="stylesheet">
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/js/bootstrap-datepicker.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/js/bootstrap-datepicker.min.js"></script>
|
||||||
@@ -65,6 +70,17 @@ This library requires:
|
|||||||
<script src="dist/bootstrap5-editable/js/bootstrap-editable.js"></script>
|
<script src="dist/bootstrap5-editable/js/bootstrap-editable.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Or using npm/webpack:**
|
||||||
|
```javascript
|
||||||
|
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||||
|
import 'bootstrap/dist/js/bootstrap.bundle.min.js';
|
||||||
|
import 'bootstrap-icons/font/bootstrap-icons.css';
|
||||||
|
import 'bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css';
|
||||||
|
import 'bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js';
|
||||||
|
import 'x-editable-bootstrap5/dist/bootstrap5-editable/css/bootstrap-editable.css';
|
||||||
|
import 'x-editable-bootstrap5/dist/bootstrap5-editable/js/bootstrap-editable.js';
|
||||||
|
```
|
||||||
|
|
||||||
2. **Initialize editable elements:**
|
2. **Initialize editable elements:**
|
||||||
```javascript
|
```javascript
|
||||||
$('#my-editable').editable({
|
$('#my-editable').editable({
|
||||||
@@ -77,14 +93,69 @@ $('#my-editable').editable({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Select2 Support
|
||||||
|
|
||||||
|
This library includes built-in support for Select2 inputs, providing enhanced select functionality with search, AJAX loading, and more.
|
||||||
|
|
||||||
|
**Note:** You need to include the Select2 library separately, as it's not bundled with x-editable.
|
||||||
|
|
||||||
|
### Quick Select2 Setup
|
||||||
|
|
||||||
|
1. **Include Select2 library:**
|
||||||
|
```html
|
||||||
|
<!-- Select2 CSS -->
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||||
|
<!-- Select2 JS -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Use select2 type in your editable:**
|
||||||
|
```javascript
|
||||||
|
$('#my-select2').editable({
|
||||||
|
type: 'select2',
|
||||||
|
source: [
|
||||||
|
{id: 'us', text: 'United States'},
|
||||||
|
{id: 'gb', text: 'Great Britain'},
|
||||||
|
{id: 'de', text: 'Germany'}
|
||||||
|
],
|
||||||
|
select2: {
|
||||||
|
placeholder: 'Select Country',
|
||||||
|
allowClear: true
|
||||||
|
},
|
||||||
|
url: '/update-endpoint'
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Select2 with AJAX
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
$('#ajax-select2').editable({
|
||||||
|
type: 'select2',
|
||||||
|
select2: {
|
||||||
|
placeholder: 'Search countries...',
|
||||||
|
minimumInputLength: 2,
|
||||||
|
ajax: {
|
||||||
|
url: '/search-countries',
|
||||||
|
dataType: 'json',
|
||||||
|
data: function (term) {
|
||||||
|
return { query: term };
|
||||||
|
},
|
||||||
|
results: function (data) {
|
||||||
|
return { results: data };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
url: '/update-endpoint'
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## Migration from Bootstrap 3
|
## Migration from Bootstrap 3
|
||||||
|
|
||||||
If you're migrating from the original x-editable:
|
If you're migrating from the original x-editable:
|
||||||
|
|
||||||
1. **Update Bootstrap** to version 5
|
1. **Update Bootstrap** to version 5
|
||||||
2. **Add bootstrap-datepicker** dependency (no longer bundled)
|
2. **Replace x-editable files** with this Bootstrap 5 version (bootstrap-datepicker included as dependency)
|
||||||
3. **Replace x-editable files** with this Bootstrap 5 version
|
3. **Update CSS classes** if using custom styling (Bootstrap 3 → 5 changes)
|
||||||
4. **Update CSS classes** if using custom styling (Bootstrap 3 → 5 changes)
|
|
||||||
|
|
||||||
The JavaScript API remains largely the same, making it a true drop-in replacement.
|
The JavaScript API remains largely the same, making it a true drop-in replacement.
|
||||||
|
|
||||||
|
26
demo/demo.js
26
demo/demo.js
@@ -70,4 +70,30 @@ $(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Note: This would require select2 library to be loaded
|
||||||
|
// $('#select2-test').editable({
|
||||||
|
// type: 'select2',
|
||||||
|
// url: 'demo/demo.php',
|
||||||
|
// source: [
|
||||||
|
// {id: 'us', text: 'United States'},
|
||||||
|
// {id: 'gb', text: 'Great Britain'},
|
||||||
|
// {id: 'ru', text: 'Russia'},
|
||||||
|
// {id: 'de', text: 'Germany'},
|
||||||
|
// {id: 'fr', text: 'France'},
|
||||||
|
// {id: 'es', text: 'Spain'},
|
||||||
|
// {id: 'it', text: 'Italy'}
|
||||||
|
// ],
|
||||||
|
// value: 'us',
|
||||||
|
// select2: {
|
||||||
|
// placeholder: 'Select Country',
|
||||||
|
// allowClear: true
|
||||||
|
// },
|
||||||
|
// success: function(response, newValue) {
|
||||||
|
// console.log('Select2 success:', newValue);
|
||||||
|
// },
|
||||||
|
// error: function(response) {
|
||||||
|
// console.log('Select2 error:', response);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@@ -63,6 +63,22 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h3>Test X-Editable Select2</h3>
|
||||||
|
<p>Click to select from a larger list with search (Note: Requires select2 library):</p>
|
||||||
|
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
id="select2-test"
|
||||||
|
class="editable editable-click"
|
||||||
|
data-type="select2"
|
||||||
|
data-pk="104"
|
||||||
|
data-title="Select Country"
|
||||||
|
>
|
||||||
|
Click to select country
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
23
dist/README.md
vendored
23
dist/README.md
vendored
@@ -40,10 +40,10 @@ npm install x-editable-bootstrap5
|
|||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
|
|
||||||
This library requires:
|
This library automatically installs and requires:
|
||||||
- **Bootstrap 5** (CSS and JS)
|
- **Bootstrap 5** (CSS and JS)
|
||||||
- **jQuery 3.x**
|
- **jQuery 3.x**
|
||||||
- **bootstrap-datepicker** (for date inputs)
|
- **bootstrap-datepicker** (for date inputs - included as dependency)
|
||||||
|
|
||||||
### Quick Start
|
### Quick Start
|
||||||
|
|
||||||
@@ -56,6 +56,9 @@ This library requires:
|
|||||||
<!-- jQuery -->
|
<!-- jQuery -->
|
||||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Bootstrap Icons -->
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
|
||||||
|
|
||||||
<!-- Bootstrap Datepicker -->
|
<!-- Bootstrap Datepicker -->
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/css/bootstrap-datepicker.min.css" rel="stylesheet">
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/css/bootstrap-datepicker.min.css" rel="stylesheet">
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/js/bootstrap-datepicker.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/js/bootstrap-datepicker.min.js"></script>
|
||||||
@@ -65,6 +68,17 @@ This library requires:
|
|||||||
<script src="dist/bootstrap5-editable/js/bootstrap-editable.js"></script>
|
<script src="dist/bootstrap5-editable/js/bootstrap-editable.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Or using npm/webpack:**
|
||||||
|
```javascript
|
||||||
|
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||||
|
import 'bootstrap/dist/js/bootstrap.bundle.min.js';
|
||||||
|
import 'bootstrap-icons/font/bootstrap-icons.css';
|
||||||
|
import 'bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css';
|
||||||
|
import 'bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js';
|
||||||
|
import 'x-editable-bootstrap5/dist/bootstrap5-editable/css/bootstrap-editable.css';
|
||||||
|
import 'x-editable-bootstrap5/dist/bootstrap5-editable/js/bootstrap-editable.js';
|
||||||
|
```
|
||||||
|
|
||||||
2. **Initialize editable elements:**
|
2. **Initialize editable elements:**
|
||||||
```javascript
|
```javascript
|
||||||
$('#my-editable').editable({
|
$('#my-editable').editable({
|
||||||
@@ -82,9 +96,8 @@ $('#my-editable').editable({
|
|||||||
If you're migrating from the original x-editable:
|
If you're migrating from the original x-editable:
|
||||||
|
|
||||||
1. **Update Bootstrap** to version 5
|
1. **Update Bootstrap** to version 5
|
||||||
2. **Add bootstrap-datepicker** dependency (no longer bundled)
|
2. **Replace x-editable files** with this Bootstrap 5 version (bootstrap-datepicker included as dependency)
|
||||||
3. **Replace x-editable files** with this Bootstrap 5 version
|
3. **Update CSS classes** if using custom styling (Bootstrap 3 → 5 changes)
|
||||||
4. **Update CSS classes** if using custom styling (Bootstrap 3 → 5 changes)
|
|
||||||
|
|
||||||
The JavaScript API remains largely the same, making it a true drop-in replacement.
|
The JavaScript API remains largely the same, making it a true drop-in replacement.
|
||||||
|
|
||||||
|
2
dist/app.js
vendored
2
dist/app.js
vendored
File diff suppressed because one or more lines are too long
303
dist/app.js.LICENSE.txt
vendored
303
dist/app.js.LICENSE.txt
vendored
@@ -21,7 +21,302 @@
|
|||||||
* Date: 2023-08-28T13:37Z
|
* Date: 2023-08-28T13:37Z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! X-editable Bootstrap 5 - v25.0.4
|
/*!****************************!*\
|
||||||
* A maintained fork of x-editable for Bootstrap 5 support.
|
!*** ./src/inputs/list.js ***!
|
||||||
* https://git.24unix.net/tracer/x-editable
|
\****************************/
|
||||||
* Copyright (c) 2025 Micha Espey; Licensed MIT */
|
|
||||||
|
/*!****************************!*\
|
||||||
|
!*** ./src/inputs/text.js ***!
|
||||||
|
\****************************/
|
||||||
|
|
||||||
|
/*!******************************!*\
|
||||||
|
!*** ./src/inputs/select.js ***!
|
||||||
|
\******************************/
|
||||||
|
|
||||||
|
/*!********************************!*\
|
||||||
|
!*** ./src/inputs/abstract.js ***!
|
||||||
|
\********************************/
|
||||||
|
|
||||||
|
/*!********************************!*\
|
||||||
|
!*** ./src/inputs/textarea.js ***!
|
||||||
|
\********************************/
|
||||||
|
|
||||||
|
/*!*********************************!*\
|
||||||
|
!*** ./src/inputs/date/date.js ***!
|
||||||
|
\*********************************/
|
||||||
|
|
||||||
|
/*!************************************!*\
|
||||||
|
!*** ./src/bootstrap5-editable.js ***!
|
||||||
|
\************************************/
|
||||||
|
|
||||||
|
/*!**************************************!*\
|
||||||
|
!*** ./src/inputs/date/datefield.js ***!
|
||||||
|
\**************************************/
|
||||||
|
|
||||||
|
/*!*****************************************!*\
|
||||||
|
!*** ./src/element/editable-element.js ***!
|
||||||
|
\*****************************************/
|
||||||
|
|
||||||
|
/*!*******************************************!*\
|
||||||
|
!*** ./src/containers/editable-inline.js ***!
|
||||||
|
\*******************************************/
|
||||||
|
|
||||||
|
/*!********************************************!*\
|
||||||
|
!*** ./node_modules/jquery/dist/jquery.js ***!
|
||||||
|
\********************************************/
|
||||||
|
|
||||||
|
/*!********************************************!*\
|
||||||
|
!*** ./src/editable-form/editable-form.js ***!
|
||||||
|
\********************************************/
|
||||||
|
|
||||||
|
/*!*********************************************!*\
|
||||||
|
!*** ./src/containers/editable-popover5.js ***!
|
||||||
|
\*********************************************/
|
||||||
|
|
||||||
|
/*!**********************************************!*\
|
||||||
|
!*** ./src/containers/editable-container.js ***!
|
||||||
|
\**********************************************/
|
||||||
|
|
||||||
|
/*!**************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/enums.js ***!
|
||||||
|
\**************************************************/
|
||||||
|
|
||||||
|
/*!**************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/index.js ***!
|
||||||
|
\**************************************************/
|
||||||
|
|
||||||
|
/*!**************************************************!*\
|
||||||
|
!*** ./src/editable-form/editable-form-utils.js ***!
|
||||||
|
\**************************************************/
|
||||||
|
|
||||||
|
/*!***************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/popper.js ***!
|
||||||
|
\***************************************************/
|
||||||
|
|
||||||
|
/*!*******************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/math.js ***!
|
||||||
|
\*******************************************************/
|
||||||
|
|
||||||
|
/*!*******************************************************!*\
|
||||||
|
!*** ./src/editable-form/editable-form-bootstrap5.js ***!
|
||||||
|
\*******************************************************/
|
||||||
|
|
||||||
|
/*!********************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/popper-lite.js ***!
|
||||||
|
\********************************************************/
|
||||||
|
|
||||||
|
/*!*********************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/createPopper.js ***!
|
||||||
|
\*********************************************************/
|
||||||
|
|
||||||
|
/*!*********************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/within.js ***!
|
||||||
|
\*********************************************************/
|
||||||
|
|
||||||
|
/*!*********************************************************!*\
|
||||||
|
!*** ./node_modules/bootstrap/dist/js/bootstrap.esm.js ***!
|
||||||
|
\*********************************************************/
|
||||||
|
|
||||||
|
/*!***********************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/modifiers/flip.js ***!
|
||||||
|
\***********************************************************/
|
||||||
|
|
||||||
|
/*!***********************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/modifiers/hide.js ***!
|
||||||
|
\***********************************************************/
|
||||||
|
|
||||||
|
/*!***********************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/debounce.js ***!
|
||||||
|
\***********************************************************/
|
||||||
|
|
||||||
|
/*!************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/modifiers/arrow.js ***!
|
||||||
|
\************************************************************/
|
||||||
|
|
||||||
|
/*!************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/modifiers/index.js ***!
|
||||||
|
\************************************************************/
|
||||||
|
|
||||||
|
/*!************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/userAgent.js ***!
|
||||||
|
\************************************************************/
|
||||||
|
|
||||||
|
/*!*************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/modifiers/offset.js ***!
|
||||||
|
\*************************************************************/
|
||||||
|
|
||||||
|
/*!*************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/getAltAxis.js ***!
|
||||||
|
\*************************************************************/
|
||||||
|
|
||||||
|
/*!**************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/mergeByName.js ***!
|
||||||
|
\**************************************************************/
|
||||||
|
|
||||||
|
/*!***************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/contains.js ***!
|
||||||
|
\***************************************************************/
|
||||||
|
|
||||||
|
/*!***************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/getVariation.js ***!
|
||||||
|
\***************************************************************/
|
||||||
|
|
||||||
|
/*!****************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getWindow.js ***!
|
||||||
|
\****************************************************************/
|
||||||
|
|
||||||
|
/*!*****************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js ***!
|
||||||
|
\*****************************************************************/
|
||||||
|
|
||||||
|
/*!*****************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/computeOffsets.js ***!
|
||||||
|
\*****************************************************************/
|
||||||
|
|
||||||
|
/*!*****************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/detectOverflow.js ***!
|
||||||
|
\*****************************************************************/
|
||||||
|
|
||||||
|
/*!*****************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/orderModifiers.js ***!
|
||||||
|
\*****************************************************************/
|
||||||
|
|
||||||
|
/*!******************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getNodeName.js ***!
|
||||||
|
\******************************************************************/
|
||||||
|
|
||||||
|
/*!******************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/modifiers/applyStyles.js ***!
|
||||||
|
\******************************************************************/
|
||||||
|
|
||||||
|
/*!******************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/expandToHashMap.js ***!
|
||||||
|
\******************************************************************/
|
||||||
|
|
||||||
|
/*!*******************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/getBasePlacement.js ***!
|
||||||
|
\*******************************************************************/
|
||||||
|
|
||||||
|
/*!*******************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/rectToClientRect.js ***!
|
||||||
|
\*******************************************************************/
|
||||||
|
|
||||||
|
/*!********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js ***!
|
||||||
|
\********************************************************************/
|
||||||
|
|
||||||
|
/*!********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js ***!
|
||||||
|
\********************************************************************/
|
||||||
|
|
||||||
|
/*!********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getParentNode.js ***!
|
||||||
|
\********************************************************************/
|
||||||
|
|
||||||
|
/*!********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/modifiers/computeStyles.js ***!
|
||||||
|
\********************************************************************/
|
||||||
|
|
||||||
|
/*!********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/modifiers/popperOffsets.js ***!
|
||||||
|
\********************************************************************/
|
||||||
|
|
||||||
|
/*!*********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js ***!
|
||||||
|
\*********************************************************************/
|
||||||
|
|
||||||
|
/*!*********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/isTableElement.js ***!
|
||||||
|
\*********************************************************************/
|
||||||
|
|
||||||
|
/*!*********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/modifiers/eventListeners.js ***!
|
||||||
|
\*********************************************************************/
|
||||||
|
|
||||||
|
/*!*********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/getFreshSideObject.js ***!
|
||||||
|
\*********************************************************************/
|
||||||
|
|
||||||
|
/*!*********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/mergePaddingObject.js ***!
|
||||||
|
\*********************************************************************/
|
||||||
|
|
||||||
|
/*!**********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js ***!
|
||||||
|
\**********************************************************************/
|
||||||
|
|
||||||
|
/*!**********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js ***!
|
||||||
|
\**********************************************************************/
|
||||||
|
|
||||||
|
/*!**********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js ***!
|
||||||
|
\**********************************************************************/
|
||||||
|
|
||||||
|
/*!**********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js ***!
|
||||||
|
\**********************************************************************/
|
||||||
|
|
||||||
|
/*!**********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js ***!
|
||||||
|
\**********************************************************************/
|
||||||
|
|
||||||
|
/*!**********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js ***!
|
||||||
|
\**********************************************************************/
|
||||||
|
|
||||||
|
/*!**********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/modifiers/preventOverflow.js ***!
|
||||||
|
\**********************************************************************/
|
||||||
|
|
||||||
|
/*!***********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js ***!
|
||||||
|
\***********************************************************************/
|
||||||
|
|
||||||
|
/*!***********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js ***!
|
||||||
|
\***********************************************************************/
|
||||||
|
|
||||||
|
/*!***********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js ***!
|
||||||
|
\***********************************************************************/
|
||||||
|
|
||||||
|
/*!***********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js ***!
|
||||||
|
\***********************************************************************/
|
||||||
|
|
||||||
|
/*!***********************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/getOppositePlacement.js ***!
|
||||||
|
\***********************************************************************/
|
||||||
|
|
||||||
|
/*!************************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js ***!
|
||||||
|
\************************************************************************/
|
||||||
|
|
||||||
|
/*!*************************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js ***!
|
||||||
|
\*************************************************************************/
|
||||||
|
|
||||||
|
/*!**************************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js ***!
|
||||||
|
\**************************************************************************/
|
||||||
|
|
||||||
|
/*!***************************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js ***!
|
||||||
|
\***************************************************************************/
|
||||||
|
|
||||||
|
/*!***************************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js ***!
|
||||||
|
\***************************************************************************/
|
||||||
|
|
||||||
|
/*!***************************************************************************!*\
|
||||||
|
!*** ./node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.js ***!
|
||||||
|
\***************************************************************************/
|
||||||
|
|
||||||
|
/*!****************************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js ***!
|
||||||
|
\****************************************************************************/
|
||||||
|
|
||||||
|
/*!********************************************************************************!*\
|
||||||
|
!*** ./node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js ***!
|
||||||
|
\********************************************************************************/
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/*! X-editable Bootstrap 5 - v25.0.4
|
/*! X-editable Bootstrap 5 - v25.0.5
|
||||||
* A maintained fork of x-editable for Bootstrap 5 support.
|
* A maintained fork of x-editable for Bootstrap 5 support.
|
||||||
* https://git.24unix.net/tracer/x-editable
|
* https://git.24unix.net/tracer/x-editable
|
||||||
* Copyright (c) 2025 Micha Espey; Licensed MIT */
|
* Copyright (c) 2025 Micha Espey; Licensed MIT */
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
|||||||
/*! X-editable Bootstrap 5 - v25.0.4
|
/*! X-editable Bootstrap 5 - v25.0.5
|
||||||
* A maintained fork of x-editable for Bootstrap 5 support.
|
* A maintained fork of x-editable for Bootstrap 5 support.
|
||||||
* https://git.24unix.net/tracer/x-editable
|
* https://git.24unix.net/tracer/x-editable
|
||||||
* Copyright (c) 2025 Micha Espey; Licensed MIT */
|
* Copyright (c) 2025 Micha Espey; Licensed MIT */
|
||||||
|
1
src/bootstrap5-editable.js
vendored
1
src/bootstrap5-editable.js
vendored
@@ -19,6 +19,7 @@ import "./inputs/list.js";
|
|||||||
import "./inputs/text.js";
|
import "./inputs/text.js";
|
||||||
import "./inputs/textarea.js";
|
import "./inputs/textarea.js";
|
||||||
import "./inputs/select.js";
|
import "./inputs/select.js";
|
||||||
|
import "./inputs/select2/select2.js";
|
||||||
|
|
||||||
// Date input (now uses npm bootstrap-datepicker)
|
// Date input (now uses npm bootstrap-datepicker)
|
||||||
import "./inputs/date/date.js";
|
import "./inputs/date/date.js";
|
||||||
|
87
src/inputs/select2/lib/select2-bootstrap.css
vendored
Normal file
87
src/inputs/select2/lib/select2-bootstrap.css
vendored
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
.form-control .select2-choice {
|
||||||
|
border: 0;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control .select2-choice .select2-arrow {
|
||||||
|
border-radius: 0 2px 2px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control.select2-container {
|
||||||
|
height: auto !important;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control.select2-container.select2-dropdown-open {
|
||||||
|
border-color: #5897FB;
|
||||||
|
border-radius: 3px 3px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control .select2-container.select2-dropdown-open .select2-choices {
|
||||||
|
border-radius: 3px 3px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control.select2-container .select2-choices {
|
||||||
|
border: 0 !important;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-group.warning .select2-container .select2-choice,
|
||||||
|
.control-group.warning .select2-container .select2-choices,
|
||||||
|
.control-group.warning .select2-container-active .select2-choice,
|
||||||
|
.control-group.warning .select2-container-active .select2-choices,
|
||||||
|
.control-group.warning .select2-dropdown-open.select2-drop-above .select2-choice,
|
||||||
|
.control-group.warning .select2-dropdown-open.select2-drop-above .select2-choices,
|
||||||
|
.control-group.warning .select2-container-multi.select2-container-active .select2-choices {
|
||||||
|
border: 1px solid #C09853 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-group.warning .select2-container .select2-choice div {
|
||||||
|
border-left: 1px solid #C09853 !important;
|
||||||
|
background: #FCF8E3 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-group.error .select2-container .select2-choice,
|
||||||
|
.control-group.error .select2-container .select2-choices,
|
||||||
|
.control-group.error .select2-container-active .select2-choice,
|
||||||
|
.control-group.error .select2-container-active .select2-choices,
|
||||||
|
.control-group.error .select2-dropdown-open.select2-drop-above .select2-choice,
|
||||||
|
.control-group.error .select2-dropdown-open.select2-drop-above .select2-choices,
|
||||||
|
.control-group.error .select2-container-multi.select2-container-active .select2-choices {
|
||||||
|
border: 1px solid #B94A48 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-group.error .select2-container .select2-choice div {
|
||||||
|
border-left: 1px solid #B94A48 !important;
|
||||||
|
background: #F2DEDE !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-group.info .select2-container .select2-choice,
|
||||||
|
.control-group.info .select2-container .select2-choices,
|
||||||
|
.control-group.info .select2-container-active .select2-choice,
|
||||||
|
.control-group.info .select2-container-active .select2-choices,
|
||||||
|
.control-group.info .select2-dropdown-open.select2-drop-above .select2-choice,
|
||||||
|
.control-group.info .select2-dropdown-open.select2-drop-above .select2-choices,
|
||||||
|
.control-group.info .select2-container-multi.select2-container-active .select2-choices {
|
||||||
|
border: 1px solid #3A87AD !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-group.info .select2-container .select2-choice div {
|
||||||
|
border-left: 1px solid #3A87AD !important;
|
||||||
|
background: #D9EDF7 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-group.success .select2-container .select2-choice,
|
||||||
|
.control-group.success .select2-container .select2-choices,
|
||||||
|
.control-group.success .select2-container-active .select2-choice,
|
||||||
|
.control-group.success .select2-container-active .select2-choices,
|
||||||
|
.control-group.success .select2-dropdown-open.select2-drop-above .select2-choice,
|
||||||
|
.control-group.success .select2-dropdown-open.select2-drop-above .select2-choices,
|
||||||
|
.control-group.success .select2-container-multi.select2-container-active .select2-choices {
|
||||||
|
border: 1px solid #468847 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-group.success .select2-container .select2-choice div {
|
||||||
|
border-left: 1px solid #468847 !important;
|
||||||
|
background: #DFF0D8 !important;
|
||||||
|
}
|
BIN
src/inputs/select2/lib/select2-spinner.gif
Normal file
BIN
src/inputs/select2/lib/select2-spinner.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
615
src/inputs/select2/lib/select2.css
vendored
Normal file
615
src/inputs/select2/lib/select2.css
vendored
Normal file
@@ -0,0 +1,615 @@
|
|||||||
|
/*
|
||||||
|
Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
|
||||||
|
*/
|
||||||
|
.select2-container {
|
||||||
|
margin: 0;
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
/* inline-block for ie7 */
|
||||||
|
zoom: 1;
|
||||||
|
*display: inline;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container,
|
||||||
|
.select2-drop,
|
||||||
|
.select2-search,
|
||||||
|
.select2-search input {
|
||||||
|
/*
|
||||||
|
Force border-box so that % widths fit the parent
|
||||||
|
container without overlap because of margin/padding.
|
||||||
|
|
||||||
|
More Info : http://www.quirksmode.org/css/box.html
|
||||||
|
*/
|
||||||
|
-webkit-box-sizing: border-box; /* webkit */
|
||||||
|
-moz-box-sizing: border-box; /* firefox */
|
||||||
|
box-sizing: border-box; /* css3 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container .select2-choice {
|
||||||
|
display: block;
|
||||||
|
height: 26px;
|
||||||
|
padding: 0 0 0 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
border: 1px solid #aaa;
|
||||||
|
white-space: nowrap;
|
||||||
|
line-height: 26px;
|
||||||
|
color: #444;
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
border-radius: 4px;
|
||||||
|
|
||||||
|
background-clip: padding-box;
|
||||||
|
|
||||||
|
-webkit-touch-callout: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
background-color: #fff;
|
||||||
|
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff));
|
||||||
|
background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%);
|
||||||
|
background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%);
|
||||||
|
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0);
|
||||||
|
background-image: linear-gradient(top, #fff 0%, #eee 50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container.select2-drop-above .select2-choice {
|
||||||
|
border-bottom-color: #aaa;
|
||||||
|
|
||||||
|
border-radius: 0 0 4px 4px;
|
||||||
|
|
||||||
|
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff));
|
||||||
|
background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%);
|
||||||
|
background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%);
|
||||||
|
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);
|
||||||
|
background-image: linear-gradient(top, #eee 0%, #fff 90%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container.select2-allowclear .select2-choice .select2-chosen {
|
||||||
|
margin-right: 42px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container .select2-choice > .select2-chosen {
|
||||||
|
margin-right: 26px;
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container .select2-choice abbr {
|
||||||
|
display: none;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
position: absolute;
|
||||||
|
right: 24px;
|
||||||
|
top: 8px;
|
||||||
|
|
||||||
|
font-size: 1px;
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
border: 0;
|
||||||
|
background: url('select2.png') right top no-repeat;
|
||||||
|
cursor: pointer;
|
||||||
|
outline: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container.select2-allowclear .select2-choice abbr {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container .select2-choice abbr:hover {
|
||||||
|
background-position: right -11px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-drop-mask {
|
||||||
|
border: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
min-height: 100%;
|
||||||
|
min-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
width: auto;
|
||||||
|
opacity: 0;
|
||||||
|
z-index: 9998;
|
||||||
|
/* styles required for IE to work */
|
||||||
|
background-color: #fff;
|
||||||
|
filter: alpha(opacity=0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-drop {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: -1px;
|
||||||
|
position: absolute;
|
||||||
|
z-index: 9999;
|
||||||
|
top: 100%;
|
||||||
|
|
||||||
|
background: #fff;
|
||||||
|
color: #000;
|
||||||
|
border: 1px solid #aaa;
|
||||||
|
border-top: 0;
|
||||||
|
|
||||||
|
border-radius: 0 0 4px 4px;
|
||||||
|
|
||||||
|
-webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
|
||||||
|
box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-drop-auto-width {
|
||||||
|
border-top: 1px solid #aaa;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-drop-auto-width .select2-search {
|
||||||
|
padding-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-drop.select2-drop-above {
|
||||||
|
margin-top: 1px;
|
||||||
|
border-top: 1px solid #aaa;
|
||||||
|
border-bottom: 0;
|
||||||
|
|
||||||
|
border-radius: 4px 4px 0 0;
|
||||||
|
|
||||||
|
-webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
|
||||||
|
box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-drop-active {
|
||||||
|
border: 1px solid #5897fb;
|
||||||
|
border-top: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-drop.select2-drop-above.select2-drop-active {
|
||||||
|
border-top: 1px solid #5897fb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container .select2-choice .select2-arrow {
|
||||||
|
display: inline-block;
|
||||||
|
width: 18px;
|
||||||
|
height: 100%;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
|
||||||
|
border-left: 1px solid #aaa;
|
||||||
|
border-radius: 0 4px 4px 0;
|
||||||
|
|
||||||
|
background-clip: padding-box;
|
||||||
|
|
||||||
|
background: #ccc;
|
||||||
|
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
|
||||||
|
background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
|
||||||
|
background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
|
||||||
|
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0);
|
||||||
|
background-image: linear-gradient(top, #ccc 0%, #eee 60%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container .select2-choice .select2-arrow b {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: url('select2.png') no-repeat 0 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-search {
|
||||||
|
display: inline-block;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 26px;
|
||||||
|
margin: 0;
|
||||||
|
padding-left: 4px;
|
||||||
|
padding-right: 4px;
|
||||||
|
|
||||||
|
position: relative;
|
||||||
|
z-index: 10000;
|
||||||
|
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-search input {
|
||||||
|
width: 100%;
|
||||||
|
height: auto !important;
|
||||||
|
min-height: 26px;
|
||||||
|
padding: 4px 20px 4px 5px;
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
|
outline: 0;
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: 1em;
|
||||||
|
|
||||||
|
border: 1px solid #aaa;
|
||||||
|
border-radius: 0;
|
||||||
|
|
||||||
|
-webkit-box-shadow: none;
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
background: #fff url('select2.png') no-repeat 100% -22px;
|
||||||
|
background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
|
||||||
|
background: url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
|
||||||
|
background: url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
|
||||||
|
background: url('select2.png') no-repeat 100% -22px, linear-gradient(top, #fff 85%, #eee 99%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-drop.select2-drop-above .select2-search input {
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-search input.select2-active {
|
||||||
|
background: #fff url('select2-spinner.gif') no-repeat 100%;
|
||||||
|
background: url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
|
||||||
|
background: url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
|
||||||
|
background: url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
|
||||||
|
background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(top, #fff 85%, #eee 99%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container-active .select2-choice,
|
||||||
|
.select2-container-active .select2-choices {
|
||||||
|
border: 1px solid #5897fb;
|
||||||
|
outline: none;
|
||||||
|
|
||||||
|
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
|
||||||
|
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-dropdown-open .select2-choice {
|
||||||
|
border-bottom-color: transparent;
|
||||||
|
-webkit-box-shadow: 0 1px 0 #fff inset;
|
||||||
|
box-shadow: 0 1px 0 #fff inset;
|
||||||
|
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
|
||||||
|
background-color: #eee;
|
||||||
|
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee));
|
||||||
|
background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%);
|
||||||
|
background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%);
|
||||||
|
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
|
||||||
|
background-image: linear-gradient(top, #fff 0%, #eee 50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-dropdown-open.select2-drop-above .select2-choice,
|
||||||
|
.select2-dropdown-open.select2-drop-above .select2-choices {
|
||||||
|
border: 1px solid #5897fb;
|
||||||
|
border-top-color: transparent;
|
||||||
|
|
||||||
|
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee));
|
||||||
|
background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%);
|
||||||
|
background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%);
|
||||||
|
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
|
||||||
|
background-image: linear-gradient(bottom, #fff 0%, #eee 50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-dropdown-open .select2-choice .select2-arrow {
|
||||||
|
background: transparent;
|
||||||
|
border-left: none;
|
||||||
|
filter: none;
|
||||||
|
}
|
||||||
|
.select2-dropdown-open .select2-choice .select2-arrow b {
|
||||||
|
background-position: -18px 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* results */
|
||||||
|
.select2-results {
|
||||||
|
max-height: 200px;
|
||||||
|
padding: 0 0 0 4px;
|
||||||
|
margin: 4px 4px 4px 0;
|
||||||
|
position: relative;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: auto;
|
||||||
|
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-results ul.select2-result-sub {
|
||||||
|
margin: 0;
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-results ul.select2-result-sub > li .select2-result-label { padding-left: 20px }
|
||||||
|
.select2-results ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 40px }
|
||||||
|
.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 60px }
|
||||||
|
.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 80px }
|
||||||
|
.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 100px }
|
||||||
|
.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 110px }
|
||||||
|
.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 120px }
|
||||||
|
|
||||||
|
.select2-results li {
|
||||||
|
list-style: none;
|
||||||
|
display: list-item;
|
||||||
|
background-image: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-results li.select2-result-with-children > .select2-result-label {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-results .select2-result-label {
|
||||||
|
padding: 3px 7px 4px;
|
||||||
|
margin: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
min-height: 1em;
|
||||||
|
|
||||||
|
-webkit-touch-callout: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-results .select2-highlighted {
|
||||||
|
background: #3875d7;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-results li em {
|
||||||
|
background: #feffde;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-results .select2-highlighted em {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-results .select2-highlighted ul {
|
||||||
|
background: #fff;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.select2-results .select2-no-results,
|
||||||
|
.select2-results .select2-searching,
|
||||||
|
.select2-results .select2-selection-limit {
|
||||||
|
background: #f4f4f4;
|
||||||
|
display: list-item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
disabled look for disabled choices in the results dropdown
|
||||||
|
*/
|
||||||
|
.select2-results .select2-disabled.select2-highlighted {
|
||||||
|
color: #666;
|
||||||
|
background: #f4f4f4;
|
||||||
|
display: list-item;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
.select2-results .select2-disabled {
|
||||||
|
background: #f4f4f4;
|
||||||
|
display: list-item;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-results .select2-selected {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-more-results.select2-active {
|
||||||
|
background: #f4f4f4 url('select2-spinner.gif') no-repeat 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-more-results {
|
||||||
|
background: #f4f4f4;
|
||||||
|
display: list-item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* disabled styles */
|
||||||
|
|
||||||
|
.select2-container.select2-container-disabled .select2-choice {
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
background-image: none;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container.select2-container-disabled .select2-choice .select2-arrow {
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
background-image: none;
|
||||||
|
border-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container.select2-container-disabled .select2-choice abbr {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* multiselect */
|
||||||
|
|
||||||
|
.select2-container-multi .select2-choices {
|
||||||
|
height: auto !important;
|
||||||
|
height: 1%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
border: 1px solid #aaa;
|
||||||
|
cursor: text;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
background-color: #fff;
|
||||||
|
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff));
|
||||||
|
background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%);
|
||||||
|
background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%);
|
||||||
|
background-image: linear-gradient(top, #eee 1%, #fff 15%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-locked {
|
||||||
|
padding: 3px 5px 3px 5px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container-multi .select2-choices {
|
||||||
|
min-height: 26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container-multi.select2-container-active .select2-choices {
|
||||||
|
border: 1px solid #5897fb;
|
||||||
|
outline: none;
|
||||||
|
|
||||||
|
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
|
||||||
|
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
|
||||||
|
}
|
||||||
|
.select2-container-multi .select2-choices li {
|
||||||
|
float: left;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
.select2-container-multi .select2-choices .select2-search-field {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container-multi .select2-choices .select2-search-field input {
|
||||||
|
padding: 5px;
|
||||||
|
margin: 1px 0;
|
||||||
|
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: 100%;
|
||||||
|
color: #666;
|
||||||
|
outline: 0;
|
||||||
|
border: 0;
|
||||||
|
-webkit-box-shadow: none;
|
||||||
|
box-shadow: none;
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container-multi .select2-choices .select2-search-field input.select2-active {
|
||||||
|
background: #fff url('select2-spinner.gif') no-repeat 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-default {
|
||||||
|
color: #999 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container-multi .select2-choices .select2-search-choice {
|
||||||
|
padding: 3px 5px 3px 18px;
|
||||||
|
margin: 3px 0 3px 5px;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
line-height: 13px;
|
||||||
|
color: #333;
|
||||||
|
cursor: default;
|
||||||
|
border: 1px solid #aaaaaa;
|
||||||
|
|
||||||
|
border-radius: 3px;
|
||||||
|
|
||||||
|
-webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
|
||||||
|
box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
|
||||||
|
|
||||||
|
background-clip: padding-box;
|
||||||
|
|
||||||
|
-webkit-touch-callout: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
background-color: #e4e4e4;
|
||||||
|
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0);
|
||||||
|
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
|
||||||
|
background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
|
||||||
|
background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
|
||||||
|
background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
|
||||||
|
}
|
||||||
|
.select2-container-multi .select2-choices .select2-search-choice .select2-chosen {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
.select2-container-multi .select2-choices .select2-search-choice-focus {
|
||||||
|
background: #d4d4d4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-search-choice-close {
|
||||||
|
display: block;
|
||||||
|
width: 12px;
|
||||||
|
height: 13px;
|
||||||
|
position: absolute;
|
||||||
|
right: 3px;
|
||||||
|
top: 4px;
|
||||||
|
|
||||||
|
font-size: 1px;
|
||||||
|
outline: none;
|
||||||
|
background: url('select2.png') right top no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container-multi .select2-search-choice-close {
|
||||||
|
left: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover {
|
||||||
|
background-position: right -11px;
|
||||||
|
}
|
||||||
|
.select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close {
|
||||||
|
background-position: right -11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* disabled styles */
|
||||||
|
.select2-container-multi.select2-container-disabled .select2-choices {
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
background-image: none;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice {
|
||||||
|
padding: 3px 5px 3px 5px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
background-image: none;
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close { display: none;
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
/* end multiselect */
|
||||||
|
|
||||||
|
|
||||||
|
.select2-result-selectable .select2-match,
|
||||||
|
.select2-result-unselectable .select2-match {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-offscreen, .select2-offscreen:focus {
|
||||||
|
clip: rect(0 0 0 0) !important;
|
||||||
|
width: 1px !important;
|
||||||
|
height: 1px !important;
|
||||||
|
border: 0 !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
padding: 0 !important;
|
||||||
|
overflow: hidden !important;
|
||||||
|
position: absolute !important;
|
||||||
|
outline: 0 !important;
|
||||||
|
left: 0px !important;
|
||||||
|
top: 0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-display-none {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-measure-scrollbar {
|
||||||
|
position: absolute;
|
||||||
|
top: -10000px;
|
||||||
|
left: -10000px;
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
overflow: scroll;
|
||||||
|
}
|
||||||
|
/* Retina-ize icons */
|
||||||
|
|
||||||
|
@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) {
|
||||||
|
.select2-search input, .select2-search-choice-close, .select2-container .select2-choice abbr, .select2-container .select2-choice .select2-arrow b {
|
||||||
|
background-image: url('select2x2.png') !important;
|
||||||
|
background-repeat: no-repeat !important;
|
||||||
|
background-size: 60px 40px !important;
|
||||||
|
}
|
||||||
|
.select2-search input {
|
||||||
|
background-position: 100% -21px !important;
|
||||||
|
}
|
||||||
|
}
|
3251
src/inputs/select2/lib/select2.js
vendored
Normal file
3251
src/inputs/select2/lib/select2.js
vendored
Normal file
File diff suppressed because one or more lines are too long
22
src/inputs/select2/lib/select2.min.js
vendored
Normal file
22
src/inputs/select2/lib/select2.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
src/inputs/select2/lib/select2.png
Normal file
BIN
src/inputs/select2/lib/select2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 613 B |
BIN
src/inputs/select2/lib/select2x2.png
Normal file
BIN
src/inputs/select2/lib/select2x2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 845 B |
350
src/inputs/select2/select2.js
vendored
Normal file
350
src/inputs/select2/select2.js
vendored
Normal file
@@ -0,0 +1,350 @@
|
|||||||
|
/**
|
||||||
|
Select2 input. Based on amazing work of Igor Vaynberg https://github.com/ivaynberg/select2.
|
||||||
|
Please see [original select2 docs](http://ivaynberg.github.com/select2) for detailed description and options.
|
||||||
|
|
||||||
|
You should manually download and include select2 distributive:
|
||||||
|
|
||||||
|
<link href="select2/select2.css" rel="stylesheet" type="text/css"></link>
|
||||||
|
<script src="select2/select2.js"></script>
|
||||||
|
|
||||||
|
To make it **bootstrap-styled** you can use css from [here](https://github.com/t0m/select2-bootstrap-css):
|
||||||
|
|
||||||
|
<link href="select2-bootstrap.css" rel="stylesheet" type="text/css"></link>
|
||||||
|
|
||||||
|
**Note:** currently `autotext` feature does not work for select2 with `ajax` remote source.
|
||||||
|
You need initially put both `data-value` and element's text youself:
|
||||||
|
|
||||||
|
<a href="#" data-type="select2" data-value="1">Text1</a>
|
||||||
|
|
||||||
|
|
||||||
|
@class select2
|
||||||
|
@extends abstractinput
|
||||||
|
@since 1.4.1
|
||||||
|
@final
|
||||||
|
@example
|
||||||
|
<a href="#" id="country" data-type="select2" data-pk="1" data-value="ru" data-url="/post" data-title="Select country"></a>
|
||||||
|
<script>
|
||||||
|
$(function(){
|
||||||
|
//local source
|
||||||
|
$('#country').editable({
|
||||||
|
source: [
|
||||||
|
{id: 'gb', text: 'Great Britain'},
|
||||||
|
{id: 'us', text: 'United States'},
|
||||||
|
{id: 'ru', text: 'Russia'}
|
||||||
|
],
|
||||||
|
select2: {
|
||||||
|
multiple: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//remote source (simple)
|
||||||
|
$('#country').editable({
|
||||||
|
source: '/getCountries',
|
||||||
|
select2: {
|
||||||
|
placeholder: 'Select Country',
|
||||||
|
minimumInputLength: 1
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//remote source (advanced)
|
||||||
|
$('#country').editable({
|
||||||
|
select2: {
|
||||||
|
placeholder: 'Select Country',
|
||||||
|
allowClear: true,
|
||||||
|
minimumInputLength: 3,
|
||||||
|
id: function (item) {
|
||||||
|
return item.CountryId;
|
||||||
|
},
|
||||||
|
ajax: {
|
||||||
|
url: '/getCountries',
|
||||||
|
dataType: 'json',
|
||||||
|
data: function (term, page) {
|
||||||
|
return { query: term };
|
||||||
|
},
|
||||||
|
results: function (data, page) {
|
||||||
|
return { results: data };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
formatResult: function (item) {
|
||||||
|
return item.CountryName;
|
||||||
|
},
|
||||||
|
formatSelection: function (item) {
|
||||||
|
return item.CountryName;
|
||||||
|
},
|
||||||
|
initSelection: function (element, callback) {
|
||||||
|
return $.get('/getCountryById', { query: element.val() }, function (data) {
|
||||||
|
callback(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
**/
|
||||||
|
(function ($) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var Constructor = function (options) {
|
||||||
|
this.init('select2', options, Constructor.defaults);
|
||||||
|
|
||||||
|
options.select2 = options.select2 || {};
|
||||||
|
|
||||||
|
this.sourceData = null;
|
||||||
|
|
||||||
|
//placeholder
|
||||||
|
if(options.placeholder) {
|
||||||
|
options.select2.placeholder = options.placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if not `tags` mode, use source
|
||||||
|
if(!options.select2.tags && options.source) {
|
||||||
|
var source = options.source;
|
||||||
|
//if source is function, call it (once!)
|
||||||
|
if (typeof (options.source) === 'function') {
|
||||||
|
source = options.source.call(options.scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof source === 'string') {
|
||||||
|
options.select2.ajax = options.select2.ajax || {};
|
||||||
|
//some default ajax params
|
||||||
|
if(!options.select2.ajax.data) {
|
||||||
|
options.select2.ajax.data = function(term) {return { query:term };};
|
||||||
|
}
|
||||||
|
if(!options.select2.ajax.results) {
|
||||||
|
options.select2.ajax.results = function(data) { return {results:data };};
|
||||||
|
}
|
||||||
|
options.select2.ajax.url = source;
|
||||||
|
} else {
|
||||||
|
//check format and convert x-editable format to select2 format (if needed)
|
||||||
|
this.sourceData = this.convertSource(source);
|
||||||
|
options.select2.data = this.sourceData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//overriding objects in config (as by default jQuery extend() is not recursive)
|
||||||
|
this.options.select2 = $.extend({}, Constructor.defaults.select2, options.select2);
|
||||||
|
|
||||||
|
//detect whether it is multi-valued
|
||||||
|
this.isMultiple = this.options.select2.tags || this.options.select2.multiple;
|
||||||
|
this.isRemote = ('ajax' in this.options.select2);
|
||||||
|
|
||||||
|
//store function returning ID of item
|
||||||
|
//should be here as used inautotext for local source
|
||||||
|
this.idFunc = this.options.select2.id;
|
||||||
|
if (typeof(this.idFunc) !== "function") {
|
||||||
|
var idKey = this.idFunc || 'id';
|
||||||
|
this.idFunc = function (e) { return e[idKey]; };
|
||||||
|
}
|
||||||
|
|
||||||
|
//store function that renders text in select2
|
||||||
|
this.formatSelection = this.options.select2.formatSelection;
|
||||||
|
if (typeof(this.formatSelection) !== "function") {
|
||||||
|
this.formatSelection = function (e) { return e.text; };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.editableutils.inherit(Constructor, $.fn.editabletypes.abstractinput);
|
||||||
|
|
||||||
|
$.extend(Constructor.prototype, {
|
||||||
|
render: function() {
|
||||||
|
this.setClass();
|
||||||
|
|
||||||
|
//can not apply select2 here as it calls initSelection
|
||||||
|
//over input that does not have correct value yet.
|
||||||
|
//apply select2 only in value2input
|
||||||
|
//this.$input.select2(this.options.select2);
|
||||||
|
|
||||||
|
//when data is loaded via ajax, we need to know when it's done to populate listData
|
||||||
|
if(this.isRemote) {
|
||||||
|
//listen to loaded event to populate data
|
||||||
|
this.$input.on('select2-loaded', $.proxy(function(e) {
|
||||||
|
this.sourceData = e.items.results;
|
||||||
|
}, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
//trigger resize of editableform to re-position container in multi-valued mode
|
||||||
|
if(this.isMultiple) {
|
||||||
|
this.$input.on('change', function() {
|
||||||
|
$(this).closest('form').parent().triggerHandler('resize');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
value2html: function(value, element) {
|
||||||
|
var text = '', data,
|
||||||
|
that = this;
|
||||||
|
|
||||||
|
if(this.options.select2.tags) { //in tags mode just assign value
|
||||||
|
data = value;
|
||||||
|
//data = $.fn.editableutils.itemsByValue(value, this.options.select2.tags, this.idFunc);
|
||||||
|
} else if(this.sourceData) {
|
||||||
|
data = $.fn.editableutils.itemsByValue(value, this.sourceData, this.idFunc);
|
||||||
|
} else {
|
||||||
|
//can not get list of possible values
|
||||||
|
//(e.g. autotext for select2 with ajax source)
|
||||||
|
}
|
||||||
|
|
||||||
|
//data may be array (when multiple values allowed)
|
||||||
|
if(Array.isArray(data)) {
|
||||||
|
//collect selected data and show with separator
|
||||||
|
text = [];
|
||||||
|
$.each(data, function(k, v){
|
||||||
|
text.push(v && typeof v === 'object' ? that.formatSelection(v) : v);
|
||||||
|
});
|
||||||
|
} else if(data) {
|
||||||
|
text = that.formatSelection(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
text = Array.isArray(text) ? text.join(this.options.viewseparator) : text;
|
||||||
|
|
||||||
|
//$(element).text(text);
|
||||||
|
Constructor.superclass.value2html.call(this, text, element);
|
||||||
|
},
|
||||||
|
|
||||||
|
html2value: function(html) {
|
||||||
|
return this.options.select2.tags ? this.str2value(html, this.options.viewseparator) : null;
|
||||||
|
},
|
||||||
|
|
||||||
|
value2input: function(value) {
|
||||||
|
// if value array => join it anyway
|
||||||
|
if(Array.isArray(value)) {
|
||||||
|
value = value.join(this.getSeparator());
|
||||||
|
}
|
||||||
|
|
||||||
|
//for remote source just set value, text is updated by initSelection
|
||||||
|
if(!this.$input.data('select2')) {
|
||||||
|
this.$input.val(value);
|
||||||
|
this.$input.select2(this.options.select2);
|
||||||
|
} else {
|
||||||
|
//second argument needed to separate initial change from user's click (for autosubmit)
|
||||||
|
this.$input.val(value).trigger('change', true);
|
||||||
|
|
||||||
|
//Uncaught Error: cannot call val() if initSelection() is not defined
|
||||||
|
//this.$input.select2('val', value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if defined remote source AND no multiple mode AND no user's initSelection provided -->
|
||||||
|
// we should somehow get text for provided id.
|
||||||
|
// The solution is to use element's text as text for that id (exclude empty)
|
||||||
|
if(this.isRemote && !this.isMultiple && !this.options.select2.initSelection) {
|
||||||
|
// customId and customText are methods to extract `id` and `text` from data object
|
||||||
|
// we can use this workaround only if user did not define these methods
|
||||||
|
// otherwise we cant construct data object
|
||||||
|
var customId = this.options.select2.id,
|
||||||
|
customText = this.options.select2.formatSelection;
|
||||||
|
|
||||||
|
if(!customId && !customText) {
|
||||||
|
var $el = $(this.options.scope);
|
||||||
|
if (!$el.data('editable').isEmpty) {
|
||||||
|
var data = {id: value, text: $el.text()};
|
||||||
|
this.$input.select2('data', data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
input2value: function() {
|
||||||
|
return this.$input.select2('val');
|
||||||
|
},
|
||||||
|
|
||||||
|
str2value: function(str, separator) {
|
||||||
|
if(typeof str !== 'string' || !this.isMultiple) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
separator = separator || this.getSeparator();
|
||||||
|
|
||||||
|
var val, i, l;
|
||||||
|
|
||||||
|
if (str === null || str.length < 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
val = str.split(separator);
|
||||||
|
for (i = 0, l = val.length; i < l; i = i + 1) {
|
||||||
|
val[i] = val[i].trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
},
|
||||||
|
|
||||||
|
autosubmit: function() {
|
||||||
|
this.$input.on('change', function(e, isInitial){
|
||||||
|
if(!isInitial) {
|
||||||
|
$(this).closest('form').submit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
getSeparator: function() {
|
||||||
|
return this.options.select2.separator || $.fn.select2.defaults.separator;
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
Converts source from x-editable format: {value: 1, text: "1"} to
|
||||||
|
select2 format: {id: 1, text: "1"}
|
||||||
|
*/
|
||||||
|
convertSource: function(source) {
|
||||||
|
if(Array.isArray(source) && source.length && source[0].value !== undefined) {
|
||||||
|
for(var i = 0; i<source.length; i++) {
|
||||||
|
if(source[i].value !== undefined) {
|
||||||
|
source[i].id = source[i].value;
|
||||||
|
delete source[i].value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return source;
|
||||||
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
if(this.$input) {
|
||||||
|
if(this.$input.data('select2')) {
|
||||||
|
this.$input.select2('destroy');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Constructor.defaults = $.extend({}, $.fn.editabletypes.abstractinput.defaults, {
|
||||||
|
/**
|
||||||
|
@property tpl
|
||||||
|
@default <input type="hidden">
|
||||||
|
**/
|
||||||
|
tpl:'<input type="hidden">',
|
||||||
|
/**
|
||||||
|
Configuration of select2. [Full list of options](http://ivaynberg.github.com/select2).
|
||||||
|
|
||||||
|
@property select2
|
||||||
|
@type object
|
||||||
|
@default null
|
||||||
|
**/
|
||||||
|
select2: null,
|
||||||
|
/**
|
||||||
|
Placeholder attribute of select
|
||||||
|
|
||||||
|
@property placeholder
|
||||||
|
@type string
|
||||||
|
@default null
|
||||||
|
**/
|
||||||
|
placeholder: null,
|
||||||
|
/**
|
||||||
|
Source data for select. It will be assigned to select2 `data` property and kept here just for convenience.
|
||||||
|
Please note, that format is different from simple `select` input: use 'id' instead of 'value'.
|
||||||
|
E.g. `[{id: 1, text: "text1"}, {id: 2, text: "text2"}, ...]`.
|
||||||
|
|
||||||
|
@property source
|
||||||
|
@type array|string|function
|
||||||
|
@default null
|
||||||
|
**/
|
||||||
|
source: null,
|
||||||
|
/**
|
||||||
|
Separator used to display tags.
|
||||||
|
|
||||||
|
@property viewseparator
|
||||||
|
@type string
|
||||||
|
@default ', '
|
||||||
|
**/
|
||||||
|
viewseparator: ', '
|
||||||
|
});
|
||||||
|
|
||||||
|
$.fn.editabletypes.select2 = Constructor;
|
||||||
|
|
||||||
|
}(window.jQuery));
|
@@ -46,8 +46,7 @@ module.exports = [
|
|||||||
new CopyWebpackPlugin({
|
new CopyWebpackPlugin({
|
||||||
patterns: [
|
patterns: [
|
||||||
{ from: "src/editable-form/editable-form.css", to: path.resolve(__dirname, "dist/bootstrap5-editable/css") },
|
{ from: "src/editable-form/editable-form.css", to: path.resolve(__dirname, "dist/bootstrap5-editable/css") },
|
||||||
{ from: "node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css", to: path.resolve(__dirname, "dist/bootstrap5-editable/css") },
|
{ from: "node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css", to: path.resolve(__dirname, "dist/bootstrap5-editable/css") }
|
||||||
{ from: "node_modules/bootstrap-icons/font/fonts", to: path.resolve(__dirname, "dist/fonts") }
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user