ru-se.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

sb-group-button-control.js (2547B)


      1 wp.customize.controlConstructor['sidebar-button-group'] = wp.customize.Control.extend({
      2     ready: function () {
      3         var control = this;
      4         var components = this.params.choices;
      5         var popupId = this.params.popup;
      6         var in_row_with = this.params.in_row_with || [];
      7 
      8         control.container.find('#group_customize-button-' + popupId).click(function () {
      9 
     10             if (window.CP_Customizer) {
     11                 CP_Customizer.openRightSidebar(popupId);
     12             } else {
     13                 Materialis.openRightSidebar(popupId);
     14             }
     15         });
     16 
     17         control.container.find('#' + popupId + '-popup > ul').on('focus', function (event) {
     18             return false;
     19         });
     20 
     21         wp.customize.bind('pane-contents-reflowed', function () {
     22 
     23             var holder = control.container.find('#' + popupId + '-popup > ul');
     24 
     25 
     26             var controls = [];
     27 
     28 
     29             _.each(components, function (c) {
     30                 var _c = wp.customize.control(c);
     31                 if (_c) {
     32                     controls.push(_c);
     33                 }
     34             });
     35 
     36             /*
     37             controls = _.sortBy(controls, function(c) {
     38                 return c.priority();
     39             });
     40            */
     41 
     42 
     43             _.each(controls, function (c) {
     44                 holder.append(c.container);
     45             });
     46 
     47 
     48             if (in_row_with && in_row_with.length) {
     49                 _.each(in_row_with, function (c) {
     50                     control.container.css({
     51                         "width": "calc(35% - 6px)",
     52                         "clear": "right",
     53                         "float": "right",
     54                     });
     55 
     56                     var ct = wp.customize.control(c);
     57                     if (ct) {
     58                         ct.container.css({
     59                             "width": "auto",
     60                             "max-width": "calc(65% - 6px)"
     61                         })
     62                     }
     63                 })
     64             }
     65 
     66             var hasActiveItems = control.params.choices.map(function (setting) {
     67                 return wp.customize.control(setting) ? wp.customize.control(setting).active() : false;
     68             }).reduce(function (a, b) {
     69                 return a || b
     70             });
     71 
     72             if (control.params.always_active) {
     73                 return;
     74             }
     75 
     76             if (control.active()) {
     77                 if (hasActiveItems) {
     78                     control.activate();
     79                 } else {
     80                     control.deactivate();
     81                 }
     82             }
     83         });
     84     }
     85 });