catthr
2/24/2016 - 3:26 PM

Изменения исходников OctoberCMS octobercms filter

Изменения исходников OctoberCMS octobercms filter

  1. Исправлен баг с фильтром october.filter.js
  2. Дополнен стандартный виджет фильтра:
    • изменен october.filter.js ( => modules/system/assets/ui/js/filter.js )
    • изменены стили controls.css ( => modules/system/assets/ui/storm.css 2562 line)
    • добавлен partial _scope.input
    • изменен filter.php

Компиляция ассетов php artisan october:util compile assets

Как использовать:

price_from:
    label: Цена, от
    conditions: buy_price >= (:filtered)
    type: input
    cssClass: small
<div
    class="filter-scope input"
    data-scope-name="<?= $scope->scopeName ?>">
    <?= e(trans($scope->label)) ?> <input style="<?= $scope->cssClass=='small'? 'width: 60px;' : ''?>" type="text" id="<?= $scope->getId() ?>" value="<?= $scope->value ?>"/>
</div>
/* 325 line, modules/backend/assets/css */
.control-filter > .filter-scope.input:after{content:''}

/* filter.less, line 77 */
&.input {
            &:after {
              content: ''
            }
        }
// module/backend/widgets

switch ($scope->type) {
           ...

            case 'input':
                $this->setScopeValue($scope, post('value'));
                break;
        }
 inArrayFunc = function(elem, array, testFunc) {
                    var i = array.length
                    do { if (i-- === 0) return false } while (!testFunc(array[i], elem))
                    return true
                }
 FilterWidget.prototype.init = function() { 
   ...
   this.$el.on('blur', '.filter-scope input[type="text"]', function(){
            var value = $(this).val(),
                $scope = $(this).closest('.filter-scope'),
                scopeName = $scope.data('scope-name')

            self.scopeValues[scopeName] = value
            self.findByValue(scopeName, value)
        })
        
 }
 
 // новый метод
    FilterWidget.prototype.findByValue = function(scopeName, value) {
        var $form = this.$el.closest('form'),
            data = {
                scopeName: scopeName,
                value: value
            }

        $.oc.stripeLoadIndicator.show()
        $form.request(this.options.updateHandler, {
            data: data
        }).always(function(){
            $.oc.stripeLoadIndicator.hide()
        })
    }