Changeset 1075601
- Timestamp:
- 01/26/2015 05:48:45 AM (11 years ago)
- Location:
- conditional-logic-solution/trunk
- Files:
-
- 1 added
- 11 edited
-
css/admin.css (modified) (4 diffs)
-
js/cls.js (modified) (2 diffs)
-
js/dashboard.js (modified) (1 diff)
-
js/widget.js (modified) (6 diffs)
-
lib/post.php (modified) (1 diff)
-
lib/widgets.php (modified) (5 diffs)
-
screenshot-2.png (modified) (previous)
-
screenshot-5.png (modified) (previous)
-
screenshot-6.png (added)
-
views/dashboard.php (modified) (2 diffs)
-
views/settings.php (modified) (1 diff)
-
views/widgets.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
conditional-logic-solution/trunk/css/admin.css
r1072545 r1075601 143 143 margin-bottom: 15px; 144 144 } 145 . cls-dashboard .cls-title,145 .wp-core-ui .cls-dashboard .cls-title, 146 146 .cls-widgets .cls-title, 147 147 .cls-sidebars .cls-title { … … 150 150 background-color: #fafafa; 151 151 } 152 .wp-core-ui .cls-dashboard .cls-box { 153 display: none; 154 } 152 155 .cls-wrapper .cls-icon-right, 153 156 .cls-widgets .cls-icon-right, … … 176 179 .cls-sidebars .cls-box { 177 180 margin:0; 178 padding: 15px;181 padding: 5px 15px; 179 182 border: 1px #f0f0f0 solid; 180 183 border-top: 0; 181 display: none;184 182 185 } 183 186 .cls-setting-inside { … … 264 267 margin-left: 15px; 265 268 } 269 .wp-core-ui .cls-desc { 270 padding: 15px; 271 font-size: 16px; 272 display: none; 273 } 266 274 #cls_setting_page .cls-faq-box a[href] { 267 275 color: #004E98; 268 276 } 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 269 335 @media screen and (min-width: 768px){ 270 336 .cls-right { -
conditional-logic-solution/trunk/js/cls.js
r1072545 r1075601 44 44 _save:function(){ 45 45 var form = this.$el.find('form'), params = form.serialize(), 46 icon = $('.cls-icon-loading' );46 icon = $('.cls-icon-loading', this.$el); 47 47 48 48 icon.show(); 49 $.post(CLS.ajaxurl + '?action=clssettings', params, function( ){49 $.post(CLS.ajaxurl + '?action=clssettings', params, function(res){ 50 50 icon.hide(); 51 51 }); … … 70 70 }; 71 71 var doRemove = function(){ 72 var target = $(this), cls_box = target.parents('.cls-box') ;72 var target = $(this), cls_box = target.parents('.cls-box').first(); 73 73 cls_box.remove(); 74 74 }; 75 75 var getValues = function(){ 76 76 var target = $(this), val = target.val(), 77 cls_box = target.parents('.cls-box') ,77 cls_box = target.parents('.cls-box').first(), 78 78 loader = cls_box.find('.cls-loader'), 79 79 values = cls_box.find('.cls_value'); -
conditional-logic-solution/trunk/js/dashboard.js
r1072545 r1075601 7 7 }), 8 8 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'); 10 10 boxes[isopen ? 'slideUp' : 'slideDown'](); 11 11 }, -
conditional-logic-solution/trunk/js/widget.js
r1072545 r1075601 1 1 +function($){ 2 2 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', 5 20 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 20 34 if( CLS_Widgets.sidebars && CLS_Widgets.sidebars[id] ){ 21 35 var values = CLS_Widgets.sidebars[id], … … 43 57 input.attr('name', that.cls_id + '[' + id + ']' + name); 44 58 }); 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', 52 69 cls_id: 'cls_widgets', 53 tagName: 'div',54 70 render:function(){ 55 71 var id = this.widget, that = this; … … 86 102 }); 87 103 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 88 193 if( window.CLS_Widgets ){ 89 194 CLS.data.template = window.CLS_Widgets.templates; … … 95 200 $.fn.buildWidgets = function(){ 96 201 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')}); 100 204 }); 101 205 }; 102 206 $.fn.buildSidebars = function(){ 103 207 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')}) 107 209 }); 108 210 }; … … 118 220 $('.cls-sidebars').each(function(){ 119 221 var sidebar = $(this), id = sidebar.data('sidebar'); 120 new Sidebars ({parent:sidebar, sidebar:id});222 new SidebarsUi({parent:sidebar, sidebar:id}); 121 223 }); 122 224 … … 125 227 if( number && parseInt(number) > 0 ) widget.buildWidgets(); 126 228 }); 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 } 127 253 }); 128 254 }(jQuery); -
conditional-logic-solution/trunk/lib/post.php
r1072545 r1075601 355 355 'after' => ' to <span class="cls-adder" title="Repeat"><i class="dashicons dashicons-plus-alt"></i></span>', 356 356 )); 357 357 echo '<div class="clear"><br></div>'; 358 358 basefield(array( 359 359 'type' => 'checkbox', -
conditional-logic-solution/trunk/lib/widgets.php
r1072545 r1075601 7 7 8 8 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); 10 10 } 11 11 … … 32 32 $template = $users[$pos]; 33 33 if( ( is_home() && $template == 'homepage' ) 34 || ( is_singular() && get_post_type() == 'post' && $template = 'single' ) 35 || ( is_page() && $template == 'page' ) 34 36 || ( is_archive() && $template == 'archive' ) 35 37 || ( is_category() && $template == 'category' ) … … 69 71 $this->id = 'cls_sidebars'; 70 72 } 71 if( isset( $_REQUEST['cls_widgets'] ) ){73 else if( isset( $_REQUEST['cls_widgets'] ) ){ 72 74 $this->id = 'cls_widgets'; 73 75 } 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; 75 93 } 76 94 … … 88 106 $number = $widget->number; 89 107 $values = $this->values('cls_widgets'); 108 90 109 printf('<div class="cls-widgets" data-widget="%1$s" data-number="%2$s"></div>', $widget->id, $number); ?> 91 110 … … 111 130 'homepage' => __('Home Page'), 112 131 'single' => __('Single Post'), 132 'page' => __('Pages'), 113 133 'archive' => __('Archive'), 114 134 'category' => __('Category'), -
conditional-logic-solution/trunk/views/dashboard.php
r1072545 r1075601 1 1 <script type="text/template" id="cls-dashboard"> 2 2 <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> 5 5 <div class="cls-box"> 6 6 <?php … … 16 16 'USERS' => $this->get_roles() 17 17 ), 18 'after' => '<span class=" cls-sep">is</span>',18 'after' => '<span class="dashicons dashicons-leftright"></span>', 19 19 'value' => '' 20 20 )); -
conditional-logic-solution/trunk/views/settings.php
r1072545 r1075601 232 232 </div> 233 233 <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> 234 238 <h3>Where to ...</h3> 235 239 <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 1 42 <script type="text/template" id="cls_widgets"> 2 43 <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.