Plugin Directory

Changeset 1075601


Ignore:
Timestamp:
01/26/2015 05:48:45 AM (11 years ago)
Author:
irenem
Message:

Fixed cls sidebar ui.
Fixed cls sidebar widget.
Fixed multi instances on ui.

Location:
conditional-logic-solution/trunk
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • conditional-logic-solution/trunk/css/admin.css

    r1072545 r1075601  
    143143    margin-bottom: 15px;
    144144}
    145 .cls-dashboard .cls-title,
     145.wp-core-ui .cls-dashboard .cls-title,
    146146.cls-widgets .cls-title,
    147147.cls-sidebars .cls-title {
     
    150150    background-color: #fafafa;
    151151}
     152.wp-core-ui .cls-dashboard .cls-box {
     153    display: none;
     154}
    152155.cls-wrapper .cls-icon-right,
    153156.cls-widgets .cls-icon-right,
     
    176179.cls-sidebars .cls-box {
    177180    margin:0;
    178     padding: 15px;
     181    padding: 5px 15px;
    179182    border: 1px #f0f0f0 solid;
    180183    border-top: 0;
    181     display: none;
     184   
    182185}
    183186.cls-setting-inside {
     
    264267    margin-left: 15px;
    265268}
     269.wp-core-ui .cls-desc {
     270    padding: 15px;
     271    font-size: 16px;
     272    display: none;
     273}
    266274#cls_setting_page .cls-faq-box a[href] {
    267275    color: #004E98;
    268276}
     277.cls-info-box {
     278    max-width: 250px;
     279}
     280/* Test */
     281.wp-core-ui .cls-ui-icon {
     282    position: absolute;
     283    right:0;
     284    top: 40px;
     285    border: 3px green solid;
     286    border-width: 0 0 0 3px;
     287    width: 40px;
     288    height: 30px;
     289    background: rgba(0, 0, 0, 0.1) url(imgs/logo.png) no-repeat center center;
     290    background-size: 90% 70%;
     291    cursor: pointer;
     292}
     293.wp-core-ui .cls-ui-icon-open {
     294    width: 100%;
     295    z-index: 99;
     296    background: #fff;
     297}
     298.wp-core-ui .cls-field-box {
     299    position: relative;
     300    border: 1px #ddd solid;
     301    margin: -20px 0 0 0;
     302    padding: 15px 10px;
     303    border-left: 3px green solid;
     304}
     305.wp-core-ui .bf-half {
     306    position: relative;
     307    float: left;
     308    width: 50%;
     309    -moz-box-sizing: border-box;
     310    box-sizing: border-box;
     311}
     312.wp-core-ui .cls-field-box select {
     313   width: 80%;
     314}
     315.wp-core-ui .cls-field-box .cls-box {
     316    margin: 0;
     317    padding: 0;
     318    border: 0;
     319}
     320.wp-core-ui .cls-widget-area {
     321    margin: 0;
     322    border: 0;
     323    background: #eee;
     324}
     325.wp-core-ui .cls-widget-area .cls-adder,
     326.wp-core-ui .cls-widget-area .cls-remove {
     327    position: absolute;
     328    right: -20px;
     329    top: -10px;
     330}
     331.wp-core-ui .cls-field-box .description {
     332    font-size: 16px;
     333}
     334
    269335@media screen and (min-width: 768px){
    270336    .cls-right {
  • conditional-logic-solution/trunk/js/cls.js

    r1072545 r1075601  
    4444                _save:function(){
    4545                        var form = this.$el.find('form'), params = form.serialize(),
    46                                 icon = $('.cls-icon-loading');
     46                                icon = $('.cls-icon-loading', this.$el);
    4747                               
    4848                        icon.show();
    49                         $.post(CLS.ajaxurl + '?action=clssettings', params, function(){
     49                        $.post(CLS.ajaxurl + '?action=clssettings', params, function(res){
    5050                                icon.hide();
    5151                                });
     
    7070        };
    7171        var doRemove = function(){
    72                 var target = $(this), cls_box = target.parents('.cls-box');
     72                var target = $(this), cls_box = target.parents('.cls-box').first();
    7373                cls_box.remove();
    7474        };
    7575        var getValues = function(){
    7676                var target = $(this), val = target.val(),
    77                 cls_box = target.parents('.cls-box'),
     77                cls_box = target.parents('.cls-box').first(),
    7878                loader = cls_box.find('.cls-loader'),
    7979                values = cls_box.find('.cls_value');
  • conditional-logic-solution/trunk/js/dashboard.js

    r1072545 r1075601  
    77                }),
    88                toggleBoxes:function(ev){
    9                         var boxes = this.$el.find('.cls-box'), isopen = boxes.is(':visible');
     9                        var boxes = this.$el.find('.cls-box, .cls-desc'), isopen = boxes.is(':visible');
    1010                        boxes[isopen ? 'slideUp' : 'slideDown']();
    1111                },
  • conditional-logic-solution/trunk/js/widget.js

    r1072545 r1075601  
    11+function($){
    22        var Views = CLS.views,
    3         Sidebars = Views.extend({
    4                 template_id: 'cls_widgets',
     3       
     4        SidebarsUi = Views.extend({
     5                template_id: 'cls_ui_widgets',
     6                tagName: 'form',
     7                save:function(){},
     8                render:function(){
     9                        // Do not add CLS to inactive widgets
     10                        if( this.parent.parent().is('#wp_inactive_widgets' )) return;
     11                       
     12                        Views.prototype.render.apply(this);
     13                        this.$el.attr('method', 'post');
     14                }
     15        }),
     16       
     17        SidebarForm = Views.extend({
     18                template_id: 'cls_widget_fields',
     19                className: 'cls-field-box',
    520                cls_id: 'cls_sidebars',
    6                 tagName: 'form',
    7                 className: 'cls-sidebars',
    8                 events: _.extend(Views.prototype.events, {
    9                         'click .cls-title' : 'toggleBoxes'
    10                 }),
    11                 toggleBoxes:function(ev){
    12                         var boxes = this.$el.find('.cls-box'), isopen = boxes.is(':visible');
    13                         boxes[isopen ? 'slideUp' : 'slideDown']();
    14                 },
    15                 render:function(){
    16                         this.$el.attr('method', 'post');
    17                         Views.prototype.render.apply(this);
    18                         var id = this.sidebar, that = this;
    19                        
     21               
     22                save:function(){
     23                        var params = this.$el.parent().serialize(), icon = $('.cls-icon-loading');
     24                        icon.show();
     25                        $.post(CLS.ajaxurl + '?action=clssettings', params, function(res){
     26                                icon.hide();
     27                                });
     28                },
     29                render:function(){
     30                        Views.prototype.render.apply(this);
     31                       
     32                        var that = this, id = this.sidebar;
     33                       
    2034                        if( CLS_Widgets.sidebars && CLS_Widgets.sidebars[id] ){
    2135                                var values = CLS_Widgets.sidebars[id],
     
    4357                                input.attr('name', that.cls_id + '[' + id + ']' + name);
    4458                        });
    45                 },
    46                 save:function(){
    47                         var params = this.$el.serialize();
    48                         $.post(CLS.ajaxurl + '?action=clssettings', params);
    49                 }
    50         }),
    51         Widgets = Sidebars.extend({
     59                }
     60        }),
     61       
     62        WidgetsUi = Views.extend({
     63                template_id: 'cls_ui_widget',
     64                save:function(){}
     65        }),
     66       
     67        WidgetsForm = SidebarForm.extend({
     68                className: 'cls-field-box cls-widget-area',
    5269                cls_id: 'cls_widgets',
    53                 tagName: 'div',
    5470                render:function(){
    5571                        var id = this.widget, that = this;
     
    86102        });
    87103       
     104        /*
     105       
     106        Sidebars = Views.extend({
     107                template_id: 'cls_widgets',
     108                cls_id: 'cls_sidebars',
     109                tagName: 'form',
     110                className: 'cls-sidebars',
     111                events: _.extend(Views.prototype.events, {
     112                        'click .cls-title' : 'toggleBoxes'
     113                }),
     114                toggleBoxes:function(ev){
     115                        var boxes = this.$el.find('.cls-box'), isopen = boxes.is(':visible');
     116                        boxes[isopen ? 'slideUp' : 'slideDown']();
     117                },
     118                render:function(){
     119                        this.$el.attr('method', 'post');
     120                        Views.prototype.render.apply(this);
     121                        var id = this.sidebar, that = this;
     122                       
     123                        if( CLS_Widgets.sidebars && CLS_Widgets.sidebars[id] ){
     124                                var values = CLS_Widgets.sidebars[id],
     125                                bf1 = this.$el.find('.cls-box'),
     126                                add = bf1.find('.cls-adder');
     127                                var type = values.type, value = values.user;
     128                               
     129                                if( value ){
     130                                        _.each(type, function(v, i){
     131                                                if( i > 0 ){
     132                                                        add.trigger('click')
     133                                                }
     134                                                var cls_box = this.$el.find('.cls-box:eq(' + i + ')'),
     135                                                        input_type = cls_box.find('[name*="type"]'),
     136                                                        input_value = cls_box.find('[name*="user"]');
     137                                                input_type.val(v);
     138                                                input_type.trigger('change');
     139                                                input_value.val(value[i]);
     140                                        }, this);
     141                                }
     142                        }
     143                       
     144                        this.$el.find('[name]').each(function(){
     145                                var input = $(this), name = input.attr('name');                       
     146                                input.attr('name', that.cls_id + '[' + id + ']' + name);
     147                        });
     148                },
     149                save:function(){
     150                        var params = this.$el.serialize();
     151                        $.post(CLS.ajaxurl + '?action=clssettings', params);
     152                }
     153        }),
     154        Widgets = Sidebars.extend({
     155                cls_id: 'cls_widgets',
     156                tagName: 'div',
     157                render:function(){
     158                        var id = this.widget, that = this;
     159                       
     160                        Views.prototype.render.apply(this);
     161                        if( CLS_Widgets.widgets && CLS_Widgets.widgets[id] ){
     162                                var values = CLS_Widgets.widgets[id],
     163                                bf1 = this.$el.find('.cls-box'),
     164                                add = bf1.find('.cls-adder');
     165                                var type = values.type, value = values.user;
     166                               
     167                                _.each(type, function(v, i){
     168                                        if( i > 0 ){
     169                                                add.trigger('click')
     170                                        }
     171                                        var cls_box = this.$el.find('.cls-box:eq(' + i + ')'),
     172                                                input_type = cls_box.find('[name*="type"]'),
     173                                                input_value = cls_box.find('[name*="user"]');
     174                                        input_type.val(v);
     175                                        input_type.trigger('change');
     176                                        input_value.val(value[i]);
     177                                }, this);
     178                        }
     179                       
     180                        this.$el.find('[name]').each(function(){
     181                                var input = $(this), name = input.attr('name');                       
     182                                input.attr('name', that.cls_id + '[' + id + ']' + name);
     183                        });
     184                },
     185                save:function(){
     186                        var form = this.$el.parents('form').first(), params = form.serialize();
     187                        $.post(CLS.ajaxurl + '?action=clssettings', params);
     188                }
     189        });
     190       
     191        */
     192       
    88193        if( window.CLS_Widgets ){
    89194                CLS.data.template = window.CLS_Widgets.templates;
     
    95200        $.fn.buildWidgets = function(){
    96201                return this.each(function(){
    97                         var widget = $(this), clone = widget.empty().clone(false);
    98                         widget.replaceWith(clone);
    99                         new Widgets({el:clone, widget:widget.data('widget')});
     202                        var widget = $(this);
     203                        new WidgetsUi({el:widget, widget:widget.data('widget')});
    100204                });
    101205        };
    102206        $.fn.buildSidebars = function(){
    103207                return this.each(function(){
    104                         var widget = $(this), clone = widget.empty().clone(false);
    105                         widget.replaceWith(clone);
    106                         new Sidebars({parent:widget, sidebar:widget.data('sidebar')});
     208                        new SidebarsUi({parent:widget, sidebar:widget.data('sidebar')})
    107209                });
    108210        };
     
    118220                $('.cls-sidebars').each(function(){
    119221                        var sidebar = $(this), id = sidebar.data('sidebar');
    120                         new Sidebars({parent:sidebar, sidebar:id});
     222                        new SidebarsUi({parent:sidebar, sidebar:id});
    121223                });
    122224               
     
    125227                        if( number && parseInt(number) > 0 )  widget.buildWidgets();
    126228                });
     229        })
     230        .on('click.data-api', '.cls-ui-icon', function(){
     231                var icon = $(this), div = icon.parent(), has_cls = div.find('.cls-field-box'), isopen;
     232               
     233                if( has_cls.length > 0 ){
     234                        isopen = has_cls.is(':visible');
     235                        has_cls[ isopen ? 'hide' : 'show']();
     236                }
     237                else {
     238                        new SidebarForm({parent:div, sidebar:div.parent().data('sidebar')});
     239                }
     240        })
     241        .on('click.data-api', '.cls-title', function(){
     242                var icon = $(this), div = icon.parent(), has_cls = div.find('.cls-field-box'), isopen;
     243               
     244                if( div.parents('#wp_inactive_widgets').length > 0 ) return;
     245               
     246                if( has_cls.length > 0 ){
     247                        isopen = has_cls.is(':visible');
     248                        has_cls[ isopen ? 'hide' : 'show']();
     249                }
     250                else {
     251                        new WidgetsForm({parent:div, widget:div.data('widget')});
     252                }
    127253        });
    128254}(jQuery);
  • conditional-logic-solution/trunk/lib/post.php

    r1072545 r1075601  
    355355                                'after' => ' to <span class="cls-adder" title="Repeat"><i class="dashicons dashicons-plus-alt"></i></span>',
    356356                        ));
    357                        
     357                        echo '<div class="clear"><br></div>';
    358358                        basefield(array(
    359359                                'type' => 'checkbox',
  • conditional-logic-solution/trunk/lib/widgets.php

    r1072545 r1075601  
    77               
    88                if( is_admin() ){
    9                         add_action( 'dynamic_sidebar_after', array($this, 'before_sidebar'), 999);
     9                        add_action( 'dynamic_sidebar_before', array($this, 'before_sidebar'), 999);
    1010                }
    1111               
     
    3232                                $template = $users[$pos];
    3333                                if( ( is_home() && $template == 'homepage' )
     34                                   || ( is_singular() && get_post_type() == 'post' && $template = 'single' )
     35                                   || ( is_page() && $template == 'page' )
    3436                                   || ( is_archive() && $template == 'archive' )
    3537                                   || ( is_category() && $template == 'category' )
     
    6971                        $this->id = 'cls_sidebars';
    7072                }
    71                 if( isset( $_REQUEST['cls_widgets'] ) ){
     73                else if( isset( $_REQUEST['cls_widgets'] ) ){
    7274                        $this->id = 'cls_widgets';
    7375                }
    74                 parent::save_settings();
     76                $values = $this->values( $this->id );
     77                $req = $_REQUEST[$this->id];
     78               
     79                foreach( (array) $req as $key => $value ){
     80                        if( isset( $values[$key] ) ){
     81                                if( empty( $value ) ) unset( $values[$key] );
     82                                else {
     83                                        $values[$key] = $value;
     84                                }
     85                        }
     86                        else {
     87                                $values[$key] = $value;
     88                        }
     89                }
     90               
     91                update_option( $this->id, $values);
     92                return $value;
    7593        }
    7694       
     
    88106                $number = $widget->number;
    89107                $values = $this->values('cls_widgets');
     108               
    90109                printf('<div class="cls-widgets" data-widget="%1$s" data-number="%2$s"></div>', $widget->id, $number); ?>
    91110                       
     
    111130                        'homepage' => __('Home Page'),
    112131                        'single' => __('Single Post'),
     132                        'page' => __('Pages'),
    113133                        'archive' => __('Archive'),
    114134                        'category' => __('Category'),
  • conditional-logic-solution/trunk/views/dashboard.php

    r1072545 r1075601  
    11<script type="text/template" id="cls-dashboard">
    22<form method="post" class="cls-wrapper cls-dashboard">       
    3     <h3 class="cls-title cls-green">Keep this hidden if ... <span class="cls-icon-right"><small class="dashicons dashicons-admin-generic"></small></span></h3>
    4     <span class="cls-icon-loading"></span>
     3    <h3 class="cls-title cls-green">Conditional Logic Solution <span class="cls-icon-right"><small class="dashicons dashicons-admin-generic"></small></span></h3>
     4    <p class="cls-desc description">Keep this hidden if... <span class="cls-icon-loading"></span></p>
    55    <div class="cls-box">
    66        <?php
     
    1616                'USERS' => $this->get_roles()
    1717            ),
    18             'after' => '<span class="cls-sep">is</span>',
     18            'after' => '<span class="dashicons dashicons-leftright"></span>',
    1919            'value' => ''
    2020        ));
  • conditional-logic-solution/trunk/views/settings.php

    r1072545 r1075601  
    232232        </div>
    233233        <div id="cls-faqs" class="cls-tab-content">
     234            <div class="cls-info-box pull-right">
     235                <h3>Need more?</h3>
     236                <p class="">If you think CLS is not enough do send your request right <a href="" target="_blank">here</a>.</p>
     237            </div>
    234238            <h3>Where to ...</h3>
    235239            <div class="cls-faq-box">
  • conditional-logic-solution/trunk/views/widgets.php

    r1072545 r1075601  
     1<script type="text/template" id="cls_ui_widgets">
     2    <span class="cls-ui-icon"></span>
     3</script>
     4<script type="text/template" id="cls_ui_widget">
     5    <h3 class="cls-title cls-green">Conditional Logic Solution <span class="cls-icon-right"><small class="dashicons dashicons-admin-generic"></small></span> </h3>
     6</script>
     7<script type="text/template" id="cls_widget_fields">
     8    <p class="description">Keep this hidden if... <span class="cls-icon-loading"></span></p>
     9    <div class="cls-box">
     10    <?php
     11        $roles = array();
     12        echo '<div class="bf-half">';
     13            basefield(array(
     14                'type' => 'select',
     15                'class' => 'cls_select',
     16                'name' => '[type][]',
     17                'choices' => array(
     18                    '' => 'Select',
     19                    'role' => __('User Group'),
     20                    'template' => __('Current Page Template'),
     21                    'User' =>  $this->get_roles()
     22                ),
     23                'after' => '<span class="dashicons dashicons-leftright"></span>'
     24               // 'after' => '<span class="dashicons dashicons-leftright cls-sep"></span>' //'<span class="cls-sep">is</span>'
     25            ));
     26        echo '</div>';
     27        echo '<div class="bf-half">';
     28            basefield(array(
     29                'type' => 'select',
     30                'class' => 'cls_value',
     31                'name' => '[user][]',
     32                'choices' => array('' => ' '),
     33                //'choices' => array_merge(array('' => '' ), $this->get_roles()),
     34                'after' => '<span class="cls-loader"></span> <span class="cls-adder" title="Repeat"><i class="dashicons dashicons-plus-alt"></i></span>'
     35            ));
     36        echo '</div>';
     37        ?>
     38    <div class="clear"></div>
     39    </div>
     40</script>
     41
    142<script type="text/template" id="cls_widgets">
    243    <h3 class="cls-title cls-green">Keep this hidden if ... <span class="cls-icon-right"><small class="dashicons dashicons-admin-generic"></small></span> <span class="cls-icon-loading"></span> </h3>
Note: See TracChangeset for help on using the changeset viewer.