1
0
Fork 0
mirror of https://github.com/janickiy/yii2-nomer synced 2025-03-09 15:39:59 +00:00

add files to project

This commit is contained in:
janickiy 2020-02-05 06:34:26 +03:00
commit 5cac498444
3729 changed files with 836998 additions and 0 deletions

View file

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 xavierfaucon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,88 @@
# bootstrap-selectsplitter
## Presentation
Transforms a <select> containing one or more <optgroup> in two chained <select>.
This:
![image1](http://img4.hostingpics.net/pics/927121bootstrapselectsplitterimage1.png)
Becomes this:
![image2](http://img4.hostingpics.net/pics/997752bootstrapselectsplitterimage2.png)
## Demo
See the [online demo](http://jsfiddle.net/ae7fxdyy/7/).
## How to use
Create a <select> with at least one <optgroup>:
NB: each <option> of your <select> must have a unique value.
```HTML
<select data-selectsplitter-selector>
<optgroup label="Category 1">
<option value="1">Choice 1</option>
<option value="2">Choice 2</option>
<option value="3">Choice 3</option>
<option value="4">Choice 4</option>
</optgroup>
<optgroup label="Category 2">
<option value="5">Choice 5</option>
<option value="6">Choice 6</option>
<option value="7">Choice 7</option>
<option value="8">Choice 8</option>
</optgroup>
<optgroup label="Category 3">
<option value="5">Choice 9</option>
<option value="6">Choice 10</option>
<option value="7">Choice 11</option>
<option value="8">Choice 12</option>
</optgroup>
</select>
```
Add the dependency files (jQuery and Bootstrap 3 CSS):
```HTML
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="bootstrap-selectsplitter.js"></script>
```
Call the plugin:
```JavaScript
$('select[data-selectsplitter-selector]').selectsplitter();
```
## Bower
bower install bootstrap-selectsplitter
##CDN
```HTML
<script src="//cdn.jsdelivr.net/bootstrap.selectsplitter/0.1.2/bootstrap-selectsplitter.min.js"></script>
```
##Changes
0.1.3 : Resolves two issues with the plugin
- Plugin now work properly when used multiple times on the same page. ([Issue 6](https://github.com/xavierfaucon/bootstrap-selectsplitter/issues/6))
- Two jQuery selectors have been corrected. ([Issue 5](https://github.com/xavierfaucon/bootstrap-selectsplitter/issues/5))
0.1.2 : Option elements are now displayed by index ([Issue 3](https://github.com/xavierfaucon/bootstrap-selectsplitter/issues/3))
0.1.1 : Minimum "size" attribute for both select tags has been set to "2" ([Issue 1](https://github.com/xavierfaucon/bootstrap-selectsplitter/issues/1))
0.1.0 : Initial release
## Copyright and license
Copyright (C) 2015 Xavier Faucon
Licensed under the MIT license.

View file

@ -0,0 +1,202 @@
+function ($) {
'use strict';
// Minified with jscompress.com
// CLASS DEFINITION
// ===============================
// NB: only user input triggers event change on SELECT.
var SelectSplitter = function(element, options) {
this.init('selectsplitter', element, options);
};
SelectSplitter.DEFAULTS = {
template:
'<div class="row" data-selectsplitter-wrapper-selector>' +
'<div class="col-xs-12 col-sm-6">' +
'<select class="form-control" data-selectsplitter-firstselect-selector></select>' +
'</div>' +
' <!-- Add the extra clearfix for only the required viewport -->' +
'<div class="clearfix visible-xs-block"></div>' +
'<div class="col-xs-12 col-sm-6">' +
'<select class="form-control" data-selectsplitter-secondselect-selector></select>' +
'</div>' +
'</div>'
};
/* Note: Est appelé par la fonction définie en var */
SelectSplitter.prototype.init = function (type, element, options) {
// Initial variables.
var self = this;
self.type = type;
self.$element = $(element);
self.$element.hide();
self.options = $.extend( {}, SelectSplitter.DEFAULTS, options);
// Get categoryParent data from $element's OPTGROUP.
self.fullCategoryList = {};
var optgroupCount = 0;
var longestOptionCount = 0;
self.$element.find('optgroup').each(function() {
self.fullCategoryList[$(this).attr('label')] = {};
var $that = $(this);
var currentOptionCount = 0;
var temporaryFullCategoryList = {};
$(this).find('option').each(function() {
var x = $(this).attr('value');
var y = $(this).text();
temporaryFullCategoryList[$(this).index()] = {
'x': x,
'y': y
};
currentOptionCount++;
});
if (currentOptionCount > longestOptionCount) { longestOptionCount = currentOptionCount ;}
self.fullCategoryList[$that.attr('label')] = temporaryFullCategoryList;
optgroupCount++;
});
// Get OPTIONS for $firstSelect.
var optionsHtml = '';
for (var key in self.fullCategoryList) {
if (self.fullCategoryList.hasOwnProperty(key)) {
optionsHtml = optionsHtml + '<option>' + key + '</option>';
}
}
// Add template.
self.$element.after(self.options.template);
// Define selected elements.
self.$wrapper = self.$element.next('div[data-selectsplitter-wrapper-selector]'); // improved by keenthemes
self.$firstSelect = $('select[data-selectsplitter-firstselect-selector]', self.$wrapper); // improved by keenthemes
self.$secondSelect = $('select[data-selectsplitter-secondselect-selector]', self.$wrapper); // improved by keenthemes
// Define $firstSelect and $secondSelect size attribute
var selectSize = Math.max(optgroupCount, longestOptionCount, 2);
selectSize = Math.min(selectSize, 10);
self.$firstSelect.attr('size', selectSize);
self.$secondSelect.attr('size', selectSize);
// Fill $firstSelect with OPTIONS
self.$firstSelect.append(optionsHtml);
// Define events.
self.$firstSelect.on('change', $.proxy(self.updateParentCategory, self));
self.$secondSelect.on('change', $.proxy(self.updateChildCategory, self));
// Define main variables.
self.$selectedOption = '';
self.currentParentCategory = '';
self.currentChildCategory = '';
// Takes in consideration whether an option is already selected before initialization.
// Note: .val() always returns the last value if SELECT is new. Hence cannot use .val() at init.
// Note2: find(option:selected) retourne toujours une OPTION même lors du premier affichage.
if ( self.$element.find('option[selected=selected]').length) {
self.$selectedOption = self.$element.find('option[selected=selected]');
self.currentParentCategory = self.$selectedOption.closest('optgroup').attr('label');
self.currentChildCategory = self.$selectedOption.attr('value');
self.$firstSelect.find('option:contains('+ self.currentParentCategory +')').attr('selected', 'selected');
self.$firstSelect.trigger('change');
}
};
SelectSplitter.prototype.updateParentCategory = function () {
var self = this;
// Update main variables.
self.currentParentCategory = self.$firstSelect.val();
self.$secondSelect.empty();
// Définit la liste de I pour les icônes à afficher en fonction de la page.
var optionsHtml = '';
for (var key in self.fullCategoryList[self.currentParentCategory]) {
if (self.fullCategoryList[self.currentParentCategory].hasOwnProperty(key)) {
optionsHtml = optionsHtml + '<option value="' + self.fullCategoryList[self.currentParentCategory][key]['x'] + '">' +
self.fullCategoryList[self.currentParentCategory][key]['y'] +
'</option>';
}
}
self.$secondSelect.append(optionsHtml);
if ( self.$selectedOption ) {
self.$secondSelect.find( 'option[value="' + self.$selectedOption.attr('value') + '"]' ).attr('selected', 'selected');
}
};
SelectSplitter.prototype.updateChildCategory = function (event) {
var self = this;
// Update main variables.
self.currentChildCategory = $(event.target).val(); // Note: event.target returns the SELECT, hence we must use val().
// Remove selected items in $element SELECT, if any.
self.$element.find('option[selected=selected]').removeAttr('selected');
// Add selected attribute to the new selected OPTION.
self.$element.find('option[value="' + self.currentChildCategory + '"]').attr('selected', 'selected'); // Note: Adding attr also updates val().
self.$element.trigger('change'); // Required for external plugins.
self.$selectedOption = self.$element.find('option[selected=selected]');
};
SelectSplitter.prototype.destroy = function () {
var self = this;
self.$wrapper.remove();
self.$element.removeData(self.type);
self.$element.show();
};
// PLUGIN DEFINITION
// =========================
function Plugin(option) {
return this.each(function() {
var $this = $(this);
var data = $this.data('selectsplitter');
var options = typeof option === 'object' && option;
if (!data && option == 'destroy') { return; }
if (!data) { $this.data('selectsplitter', ( data = new SelectSplitter(this, options) ) ); }
if (typeof option == 'string') { data[option](); }
});
}
$.fn.selectsplitter = Plugin;
/* http://stackoverflow.com/questions/10525600/what-is-the-purpose-of-fn-foo-constructor-foo-in-twitter-bootstrap-js */
$.fn.selectsplitter.Constructor = SelectSplitter;
}(jQuery);

View file

@ -0,0 +1 @@
+function(e){"use strict";function t(t){return this.each(function(){var l=e(this),s=l.data("selectsplitter"),o="object"==typeof t&&t;(s||"destroy"!=t)&&(s||l.data("selectsplitter",s=new r(this,o)),"string"==typeof t&&s[t]())})}var r=function(e,t){this.init("selectsplitter",e,t)};r.DEFAULTS={template:'<div class="row" data-selectsplitter-wrapper-selector><div class="col-xs-12 col-sm-6"><select class="form-control" data-selectsplitter-firstselect-selector></select></div> <!-- Add the extra clearfix for only the required viewport --><div class="clearfix visible-xs-block"></div><div class="col-xs-12 col-sm-6"><select class="form-control" data-selectsplitter-secondselect-selector></select></div></div>'},r.prototype.init=function(t,l,s){var o=this;o.type=t,o.$element=e(l),o.$element.hide(),o.options=e.extend({},r.DEFAULTS,s),o.fullCategoryList={};var a=0,n=0;o.$element.find("optgroup").each(function(){o.fullCategoryList[e(this).attr("label")]={};var t=e(this),r=0,l={};e(this).find("option").each(function(){var t=e(this).attr("value"),s=e(this).text();l[e(this).index()]={x:t,y:s},r++}),r>n&&(n=r),o.fullCategoryList[t.attr("label")]=l,a++});var i="";for(var c in o.fullCategoryList)o.fullCategoryList.hasOwnProperty(c)&&(i=i+"<option>"+c+"</option>");o.$element.after(o.options.template),o.$wrapper=o.$element.next("div[data-selectsplitter-wrapper-selector]"),o.$firstSelect=e("select[data-selectsplitter-firstselect-selector]",o.$wrapper),o.$secondSelect=e("select[data-selectsplitter-secondselect-selector]",o.$wrapper);var d=Math.max(a,n,2);d=Math.min(d,10),o.$firstSelect.attr("size",d),o.$secondSelect.attr("size",d),o.$firstSelect.append(i),o.$firstSelect.on("change",e.proxy(o.updateParentCategory,o)),o.$secondSelect.on("change",e.proxy(o.updateChildCategory,o)),o.$selectedOption="",o.currentParentCategory="",o.currentChildCategory="",o.$element.find("option[selected=selected]").length&&(o.$selectedOption=o.$element.find("option[selected=selected]"),o.currentParentCategory=o.$selectedOption.closest("optgroup").attr("label"),o.currentChildCategory=o.$selectedOption.attr("value"),o.$firstSelect.find("option:contains("+o.currentParentCategory+")").attr("selected","selected"),o.$firstSelect.trigger("change"))},r.prototype.updateParentCategory=function(){var e=this;e.currentParentCategory=e.$firstSelect.val(),e.$secondSelect.empty();var t="";for(var r in e.fullCategoryList[e.currentParentCategory])e.fullCategoryList[e.currentParentCategory].hasOwnProperty(r)&&(t=t+'<option value="'+e.fullCategoryList[e.currentParentCategory][r].x+'">'+e.fullCategoryList[e.currentParentCategory][r].y+"</option>");e.$secondSelect.append(t),e.$selectedOption&&e.$secondSelect.find('option[value="'+e.$selectedOption.attr("value")+'"]').attr("selected","selected")},r.prototype.updateChildCategory=function(t){var r=this;r.currentChildCategory=e(t.target).val(),r.$element.find("option[selected=selected]").removeAttr("selected"),r.$element.find('option[value="'+r.currentChildCategory+'"]').attr("selected","selected"),r.$element.trigger("change"),r.$selectedOption=r.$element.find("option[selected=selected]")},r.prototype.destroy=function(){var e=this;e.$wrapper.remove(),e.$element.removeData(e.type),e.$element.show()},e.fn.selectsplitter=t,e.fn.selectsplitter.Constructor=r}(jQuery);