Content Aware Sidebars – Unlimited Widget Areas - Version 3.7.4

Version Description

View Release Notes

  • Added: UI improvements
  • Fixed: some conditions could not be added on legacy php versions
  • Updated: wp-content-aware-engine
  • Updated: freemius sdk
Download this release

Release Info

Developer intoxstudio
Plugin Icon 128x128 Content Aware Sidebars – Unlimited Widget Areas
Version 3.7.4
Comparing to
See all releases

Code changes from version 3.7.3 to 3.7.4

admin/sidebar-edit.php CHANGED
@@ -72,11 +72,18 @@ final class CAS_Sidebar_Edit extends CAS_Admin {
72
  */
73
  public function add_to_module_list($list) {
74
  if(get_post_type() == CAS_App::TYPE_SIDEBAR) {
75
- $list[''] = array(
76
  'name' =>__('URLs (Pro Feature)','content-aware-sidebars'),
77
  'placeholder' => '',
78
  'default_value' => ''
79
  );
 
 
 
 
 
 
 
80
  }
81
  return $list;
82
  }
@@ -90,7 +97,7 @@ final class CAS_Sidebar_Edit extends CAS_Admin {
90
  */
91
  public function show_description($post_type) {
92
  if($post_type == CAS_App::TYPE_SIDEBAR) {
93
- _e('Display this sidebar only on content that meets the following conditions:','content-aware-sidebars');
94
  echo '<p></p>';
95
  }
96
  }
72
  */
73
  public function add_to_module_list($list) {
74
  if(get_post_type() == CAS_App::TYPE_SIDEBAR) {
75
+ $list[] = array(
76
  'name' =>__('URLs (Pro Feature)','content-aware-sidebars'),
77
  'placeholder' => '',
78
  'default_value' => ''
79
  );
80
+ if(function_exists('bp_is_active')) {
81
+ $list[] = array(
82
+ 'name' =>__('BuddyPress Groups (Pro Feature)','content-aware-sidebars'),
83
+ 'placeholder' => '',
84
+ 'default_value' => ''
85
+ );
86
+ }
87
  }
88
  return $list;
89
  }
97
  */
98
  public function show_description($post_type) {
99
  if($post_type == CAS_App::TYPE_SIDEBAR) {
100
+ _e('Where do you want to show it?','content-aware-sidebars');
101
  echo '<p></p>';
102
  }
103
  }
app.php CHANGED
@@ -15,7 +15,7 @@ final class CAS_App {
15
  /**
16
  * Plugin version
17
  */
18
- const PLUGIN_VERSION = '3.7.3';
19
 
20
  /**
21
  * Prefix for sidebar id
15
  /**
16
  * Plugin version
17
  */
18
+ const PLUGIN_VERSION = '3.7.4';
19
 
20
  /**
21
  * Prefix for sidebar id
cas_uninstall.php CHANGED
@@ -10,9 +10,9 @@ if (!defined('ABSPATH')) {
10
  exit;
11
  }
12
 
13
- // if(!defined('WP_UNINSTALL_PLUGIN')) {
14
- // exit();
15
- // }
16
 
17
  global $wpdb;
18
 
@@ -38,4 +38,4 @@ foreach ($sidebars as $sidebar) {
38
  }
39
 
40
  // Remove user meta
41
- $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN('metaboxhidden_sidebar','closedpostboxes_sidebar','managesidebarcolumnshidden','".$wpdb->prefix."_ca_cas_tour')");
10
  exit;
11
  }
12
 
13
+ if(!(defined('WP_UNINSTALL_PLUGIN') || defined('WP_FS__UNINSTALL_MODE'))) {
14
+ exit();
15
+ }
16
 
17
  global $wpdb;
18
 
38
  }
39
 
40
  // Remove user meta
41
+ $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN('metaboxhidden_sidebar','closedpostboxes_sidebar','managesidebarcolumnshidden','{$wpdb->prefix}_ca_cas_tour')");
changelog.txt CHANGED
@@ -1,3 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  = 3.2.4 =
2
 
3
  * Added: infinite scroll for content in sidebar editor
1
+ = 3.3.3 =
2
+
3
+ * Added: counter-measure against plugins that add buggy scripts
4
+ * Fixed: saving sidebars in quick select would in some cases trigger warning
5
+
6
+ **Pro Plan:**
7
+
8
+ * Fixed: include draft sidebars when syncing widgets across themes
9
+
10
+ = 3.3.2 =
11
+
12
+ * Fixed: markup in quick select could in some cases be malformed
13
+ * Fixed: warning when saving sidebar
14
+
15
+ = 3.3.1 =
16
+
17
+ * Added: ux design improvements
18
+ * Added: ability to add more sidebars in quick select
19
+ * Added: toggle to display more than 3 sidebar input fields in quick select
20
+ * Added: select2 dropdowns updated to 4.0.3 on sidebar edit screen
21
+ * Added: re-enabled info box on sidebar edit screen
22
+ * Added: freemius sdk updated
23
+ * Fixed: decoding of taxonomy term names in conditions
24
+ * Fixed: order of content in conditions dropdowns
25
+ * Fixed: yoast seo compatibility on post edit screens
26
+ * Fixed: negated post conditions were included in sidebar quick select
27
+ * Removed: upgrade box on sidebar edit screen
28
+
29
+ **Pro Plan:**
30
+
31
+ * Fixed: improved widget revision ux
32
+ * Fixed: select dates would in some cases not be displayed correct in conditions
33
+ * Fixed: widget revisions could in some cases contain wrong or malformed data
34
+ * Fixed: backwards compat in widget revision ui for versions before wp4.5
35
+
36
+ = 3.3 =
37
+
38
+ * Added: manage widgets for draft sidebars
39
+ * Added: quick select and create sidebars on post type editor screen
40
+ * Added: ability to add widgets to draft sidebars
41
+ * Added: expand/collapse all sidebars on widgets screen
42
+ * Added: view sidebar status on widgets screen
43
+ * Added: order sidebars by title on widgets screen
44
+ * Added: dialog on unsaved condition changes in sidebar editor
45
+ * Added: ux design improvements
46
+ * Added: more focus on pro features, upgrade box moved to bottom
47
+ * Fixed: error in wpml config (props Chouby)
48
+ * Fixed: updated review notice description
49
+ * Fixed: select2 dropdowns styling more robust to external changes
50
+ * Fixed: minor performance improvements
51
+
52
+ **Pro Plan:**
53
+
54
+ * Added: set sidebars to published or draft on widgets screen
55
+
56
  = 3.2.4 =
57
 
58
  * Added: infinite scroll for content in sidebar editor
content-aware-sidebars.php CHANGED
@@ -9,7 +9,7 @@
9
  Plugin Name: Content Aware Sidebars
10
  Plugin URI: https://dev.institute/wordpress-sidebars/
11
  Description: Unlimited custom sidebars and widget areas for any post, page, category etc.
12
- Version: 3.7.3
13
  Author: Joachim Jensen
14
  Author URI: https://dev.institute
15
  Text Domain: content-aware-sidebars
@@ -17,7 +17,7 @@ Domain Path: /lang/
17
  License: GPLv3
18
 
19
  Content Aware Sidebars Plugin
20
- Copyright (C) 2011-2017 Joachim Jensen - jv@intox.dk
21
 
22
  This program is free software: you can redistribute it and/or modify
23
  it under the terms of the GNU General Public License as published by
9
  Plugin Name: Content Aware Sidebars
10
  Plugin URI: https://dev.institute/wordpress-sidebars/
11
  Description: Unlimited custom sidebars and widget areas for any post, page, category etc.
12
+ Version: 3.7.4
13
  Author: Joachim Jensen
14
  Author URI: https://dev.institute
15
  Text Domain: content-aware-sidebars
17
  License: GPLv3
18
 
19
  Content Aware Sidebars Plugin
20
+ Copyright (C) 2011-2018 Joachim Jensen - jv@intox.dk
21
 
22
  This program is free software: you can redistribute it and/or modify
23
  it under the terms of the GNU General Public License as published by
css/icon.png CHANGED
Binary file
gulpfile.js CHANGED
@@ -4,6 +4,8 @@ const less = require('gulp-less');
4
  const uglify = require('gulp-uglify');
5
  const rename = require("gulp-rename");
6
  const zip = require("gulp-zip");
 
 
7
 
8
  gulp.task('less', function (done) {
9
  return gulp.src('css/style.less')
@@ -35,11 +37,23 @@ gulp.task('uglify', function () {
35
  });
36
 
37
  gulp.task('zip', function() {
38
- return gulp.src(['**','!build{,/**}','!**/node_modules{,/**}'],{base:'../'})
39
  .pipe(zip('content-aware-sidebars.zip'))
40
  .pipe(gulp.dest('build'));
41
  });
42
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  gulp.task('watch', function() {
44
  gulp.watch('css/style.less', gulp.parallel('less'));
45
  gulp.watch(['js/*.js','!js/*.min.js'], gulp.parallel('uglify'));
4
  const uglify = require('gulp-uglify');
5
  const rename = require("gulp-rename");
6
  const zip = require("gulp-zip");
7
+ const freemius = require("gulp-freemius-deploy");
8
+ const fs_config = require( './fs-config.json' );
9
 
10
  gulp.task('less', function (done) {
11
  return gulp.src('css/style.less')
37
  });
38
 
39
  gulp.task('zip', function() {
40
+ return gulp.src(['**','!fs-config.json','!**/*.less','!build{,/**}','!**/node_modules{,/**}'],{base:'../'})
41
  .pipe(zip('content-aware-sidebars.zip'))
42
  .pipe(gulp.dest('build'));
43
  });
44
 
45
+ gulp.task('freemius', function() {
46
+ return freemius( gulp, {
47
+ developer_id : fs_config.developer_id,
48
+ plugin_id : fs_config.plugin_id,
49
+ public_key : fs_config.public_key,
50
+ secret_key : fs_config.secret_key,
51
+ zip_name : 'content-aware-sidebars.zip',
52
+ zip_path : 'build/',
53
+ add_contributor: true
54
+ });
55
+ });
56
+
57
  gulp.task('watch', function() {
58
  gulp.watch('css/style.less', gulp.parallel('less'));
59
  gulp.watch(['js/*.js','!js/*.min.js'], gulp.parallel('uglify'));
lib/freemius/assets/img/content-aware-sidebars.png CHANGED
Binary file
lib/freemius/includes/class-freemius.php CHANGED
@@ -773,8 +773,7 @@
773
  */
774
  if ( empty( $this->_storage->was_plugin_loaded ) ) {
775
  if ( $this->is_plugin() &&
776
- $this->is_activation_mode( false ) &&
777
- 0 == did_action( 'plugins_loaded' )
778
  ) {
779
  add_action( 'plugins_loaded', array( &$this, '_plugins_loaded' ) );
780
  } else {
773
  */
774
  if ( empty( $this->_storage->was_plugin_loaded ) ) {
775
  if ( $this->is_plugin() &&
776
+ $this->is_activation_mode( false )
 
777
  ) {
778
  add_action( 'plugins_loaded', array( &$this, '_plugins_loaded' ) );
779
  } else {
lib/freemius/start.php CHANGED
@@ -15,7 +15,7 @@
15
  *
16
  * @var string
17
  */
18
- $this_sdk_version = '1.2.4';
19
 
20
  #region SDK Selection Logic --------------------------------------------------------------------
21
 
15
  *
16
  * @var string
17
  */
18
+ $this_sdk_version = '1.2.4.1';
19
 
20
  #region SDK Selection Logic --------------------------------------------------------------------
21
 
lib/wp-content-aware-engine/assets/css/condition_groups.css CHANGED
@@ -3,4 +3,4 @@
3
  * @author Joachim Jensen <jv@intox.dk>
4
  * @license GPLv3
5
  * @copyright 2018 by Joachim Jensen
6
- */.wpca-pull-left{float:left}.rtl .wpca-pull-left,.wpca-pull-right{float:right}.rtl .wpca-pull-right{float:left}.wpca-alert{position:fixed;top:0;font-weight:700;color:#fff;font-size:1.3em;width:100%}.wpca-alert .wpca-error,.wpca-alert .wpca-success{box-sizing:border-box;text-align:center;box-shadow:0 1px 4px rgba(0,0,0,.3),inset 0 0 0 3px rgba(0,0,0,.1);padding:18px 30px}.wpca-alert .wpca-success{background-color:#46b450}.wpca-alert .wpca-error{background-color:#ff7058}@media (min-width:601px){.wpca-alert{width:auto;top:auto;bottom:30px;right:30px}.wpca-error,.wpca-success{min-width:320px;position:relative;border-radius:40px}.rtl .wpca-alert{left:30px;right:auto}}#cas-groups{padding:6px 0 0}#cas-groups>ul{position:relative;margin:0;transition:all 1s ease;max-height:9999px;height:auto}.cas-group-body{-ms-box-sizing:border-box;box-sizing:border-box;border-width:1px;border-style:solid;border-color:#cfcfcf;padding:4px;background-color:#f1f1f1;overflow:hidden;position:relative;margin-bottom:0;border-radius:2px;box-shadow:0 1px 1px rgba(0,0,0,.08)}.cas-group-body .cas-group-cell{padding:10px;border-radius:2px;background-color:#fff;border:1px solid #cfcfcf}.cas-group-body .cas-group-actions{padding:5px 0 0}.cas-group-body .cas-group-options{overflow:hidden;margin:0}.cas-group-body .cas-group-options li{overflow:hidden;margin:0;padding:8px 5px;border-bottom:#ddd 1px solid}.cas-group-single{margin:0}.cas-group-single:first-of-type>.cas-group-sep{display:none}.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate{display:table}.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate .wpca-sep-or,.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate:before{display:none}.cas-group-sep.wpca-group-negate .wpca-sep-not{display:inline}.cas-group-sep{display:table;margin:0 auto;color:#aaa;text-transform:uppercase;font-size:.9em;font-weight:700;line-height:1.1em;clear:both;direction:ltr}.cas-group-sep:after,.cas-group-sep:before{position:relative;display:block;content:'';width:2px;height:8px;margin:0 auto;background-color:#cfcfcf}.cas-group-sep .wpca-sep-not{display:none}.cas-group-body .cas-group-sep{display:block;overflow:hidden;text-align:center;margin:5px -10px}.cas-group-body .cas-group-sep:after,.cas-group-body .cas-group-sep:before{background-color:transparent;border-top:1px solid #DFDFDF;border-bottom:1px solid #DFDFDF;content:"";display:inline-block;height:.15em;position:relative;vertical-align:middle;width:50%;margin-bottom:.15em}.cas-group-body .cas-group-sep:before{right:.5em;margin-left:-50%}.cas-group-body .cas-group-sep:after{left:.5em;margin-right:-50%}.cas-group-label{font-weight:700;margin:0 0 6px}.wpca-condition-remove{cursor:pointer;margin:0 8px 0 0;color:#aaa;transition:color .3s ease}.wpca-condition-remove:hover{color:#444}.cas-group-new{position:relative;background-color:#fff;border:1px solid #e9e9e9;border-radius:2px;box-shadow:0 0 0 4px #f9f9f9 inset,0 1px 1px rgba(0,0,0,.08);padding:15px;margin-bottom:10px;transition:all .5s ease}.cas-group-new:hover{border-color:#cfcfcf;box-shadow:0 0 0 4px #f1f1f1 inset,0 1px 1px rgba(0,0,0,.08)}label.cae-toggle input{display:none}label.cae-toggle .cae-toggle-bar{overflow:hidden;cursor:pointer;position:relative;padding-right:34px;height:22px;line-height:22px;display:inline-block;vertical-align:middle}label.cae-toggle .cae-toggle-bar:before{top:0;right:0;position:absolute;display:inline-block;width:34px;content:"";padding:0;height:inherit;line-height:inherit;border-radius:22px;background-color:#bbb;box-shadow:0 0 2px rgba(0,0,0,.2) inset;transition:background-color .2s ease-in}label.cae-toggle .cae-toggle-bar:after{content:"";display:block;width:18px;height:18px;margin:0;background:#FFF;position:absolute;top:2px;right:14px;border-radius:22px;transition:right .2s ease-in 0s;box-shadow:0 1px 2px rgba(0,0,0,.2)}label.cae-toggle input:checked+.cae-toggle-bar:before{background-color:#7ad03a}label.cae-toggle input:checked+.cae-toggle-bar:after{right:2px}@media (min-width:783px){#cas-groups .button-small .dashicons{font-size:14px;height:14px;width:14px;vertical-align:text-top}}@media (min-width:1041px){#cas-groups{padding:10px 0 0}.cas-group-label{float:left;width:220;margin:5px 0 0}.cas-group-input{margin-left:221px}.cas-group-body .cas-group-options li{padding:8px 10%}.rtl .cas-group-label{float:right}.rtl .cas-group-input{margin-right:221px;margin-left:auto}}.select2-container--wpca.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container--wpca.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none;background-color:#fff;border:1px solid #ddd;border-radius:none}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#444;line-height:28px}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__clear{position:relative;cursor:pointer;float:right;font-weight:700}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent;border-style:solid;border-width:5px 4px 0;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--single .select2-selection__clear{float:left}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--wpca.select2-container.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888;border-width:0 4px 5px}.select2-container--wpca.select2-container .select2-selection--multiple{background-color:#fff;color:#444;border:1px solid #ddd;cursor:text;box-sizing:border-box;display:block;min-height:32px;line-height:1;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;box-sizing:border-box;list-style:none;margin:0;padding:0 5px 3px;width:100%}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:700;margin-top:5px;margin-right:10px}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__choice{background-color:#bfe7f1;color:#23282d;border:1px solid #439eb4;border-radius:2px;cursor:default;float:left;margin:4px 4px 0 0;padding:2px 6px 4px;max-width:100%;overflow:hidden;text-overflow:ellipsis;box-sizing:border-box;box-shadow:0 1px 0 0 rgba(255,255,255,.9) inset,0 1px 1px rgba(0,0,0,.1)}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__choice__remove{color:#439eb4;cursor:pointer;font-size:16px;display:inline-block;font-weight:700;margin-right:6px}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__choice__remove:hover{color:#444}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-search--inline,.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__choice,.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__placeholder{float:right}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__choice{margin:4px 0 0 4px}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--wpca.select2-container.select2-container--focus .select2-selection--multiple{border:1px solid #5b9dd9;background-color:#fafafa;outline:0}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--wpca.select2-container .select2-dropdown{background-color:#fff;border:1px solid #5b9dd9;border-radius:none;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-container--wpca.select2-container--open .select2-dropdown--below,.select2-container--wpca.select2-container--open.select2-container--above .select2-selection--multiple,.select2-container--wpca.select2-container--open.select2-container--above .select2-selection--single{border-top-left-radius:0;border-top-right-radius:0;border-top:none}.select2-container--wpca.select2-container--open .select2-dropdown--above,.select2-container--wpca.select2-container--open.select2-container--below .select2-selection--multiple,.select2-container--wpca.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-1{padding-left:10px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-2{padding-left:20px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-3{padding-left:30px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-4{padding-left:40px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-5{padding-left:50px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-6{padding-left:60px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-7{padding-left:70px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-8{padding-left:80px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-9{padding-left:90px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-10{padding-left:100px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-1{padding-right:10px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-2{padding-right:20px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-3{padding-right:30px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-4{padding-right:40px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-5{padding-right:50px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-6{padding-right:60px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-7{padding-right:70px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-8{padding-right:80px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-9{padding-right:90px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-10{padding-right:100px}.select2-container--wpca.select2-container .select2-results{display:block}.select2-container--wpca.select2-container .select2-results__options{list-style:none;margin:0;padding:0}.select2-container--wpca.select2-container .select2-results__option{padding:6px;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}.select2-container--wpca.select2-container .select2-results__option[aria-selected]{cursor:pointer}.select2-container--wpca.select2-container--open .select2-dropdown{left:0}.select2-container--wpca .select2-search--dropdown{display:block;padding:4px}.select2-container--wpca .select2-results>.select2-results__options[aria-multiselectable] .select2-results__option[aria-selected=true],.select2-container--wpca .select2-search--dropdown.select2-search--hide{display:none}.select2-container--wpca .select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box;border:1px solid #5b9dd9}.select2-container--wpca .select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-container--wpca .select2-search--inline{float:left;width:auto;margin:0;z-index:1030}.select2-container--wpca .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;font-family:inherit;margin:6px 0 0;padding:0;background:0 0!important;min-height:auto;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--wpca .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-container--wpca .select2-search--inline .select2-search__field:not([placeholder='']){width:100%!important;margin-right:9999px}.select2-container--wpca[dir=rtl] .select2-search--inline .select2-search__field:not([placeholder='']){margin-left:9999px;margin-right:auto}.select2-container--wpca .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--wpca .select2-results__option[role=group]{padding:0}.select2-container--wpca .select2-results__option[aria-disabled=true]{color:#999}.select2-container--wpca .select2-results__option[aria-selected=true]{background-color:#eee}.select2-container--wpca .select2-results__option .select2-results__option{padding-left:20px}.select2-container--wpca .select2-results__option--highlighted[aria-selected][aria-selected=false]{background-color:#5897fb;color:#fff}.select2-container--wpca .select2-results__group{cursor:default;display:block;padding:6px}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0!important;clip:rect(0 0 0 0)!important;height:1px!important;margin:-1px!important;overflow:hidden!important;padding:0!important;position:absolute!important;width:1px!important}
3
  * @author Joachim Jensen <jv@intox.dk>
4
  * @license GPLv3
5
  * @copyright 2018 by Joachim Jensen
6
+ */.wpca-pull-left{float:left}.rtl .wpca-pull-left,.wpca-pull-right{float:right}.rtl .wpca-pull-right{float:left}.wpca-alert{position:fixed;top:0;font-weight:700;color:#fff;font-size:1.3em;width:100%}.wpca-alert .wpca-error,.wpca-alert .wpca-success{box-sizing:border-box;text-align:center;box-shadow:0 1px 4px rgba(0,0,0,.3),inset 0 0 0 3px rgba(0,0,0,.1);padding:18px 30px}.wpca-alert .wpca-success{background-color:#46b450}.wpca-alert .wpca-error{background-color:#ff7058}@media (min-width:601px){.wpca-alert{width:auto;top:auto;bottom:30px;right:30px}.wpca-error,.wpca-success{min-width:320px;position:relative;border-radius:40px}.rtl .wpca-alert{left:30px;right:auto}}#cas-groups{padding:6px 0 0}#cas-groups>ul{position:relative;margin:0;transition:all 1s ease;max-height:9999px;height:auto}.cas-group-body{box-sizing:border-box;border-width:1px;border-style:solid;border-color:#ccc;background-color:#f1f1f1;overflow:hidden;position:relative;margin-bottom:0;border-radius:2px;box-shadow:0 1px 2px 1px rgba(0,0,0,.08)}.cas-group-body .cas-group-cell{padding:10px;background-color:#fff;border-bottom:1px solid #ccc}.cas-group-body .cas-group-actions{padding:5px;overflow:hidden}.cas-group-body .cas-group-options{overflow:hidden;margin:0}.cas-group-body .cas-group-options li{overflow:hidden;margin:0;padding:8px 5px;border-bottom:#ddd 1px solid}.cas-group-single{margin:0}.wpca-group-description{color:#fff}.wpca-group-description span{float:left;margin:4px 4px 0 0;padding:4px 8px 6px;background-color:#59A9FD;border-radius:20px}.cas-group-single:first-of-type>.cas-group-sep{display:none}.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate{display:table}.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate .wpca-sep-or-not,.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate:before{display:none}.cas-group-single:first-of-type>.cas-group-sep.wpca-group-negate .wpca-sep-not{display:inline-block}.cas-group-sep.wpca-group-negate .wpca-sep-or{display:none}.cas-group-sep.wpca-group-negate .wpca-sep-or-not{display:inline-block}.cas-group-sep{display:table;margin:0 auto;color:#fff;text-transform:uppercase;font-size:.8em;font-weight:700;line-height:1;clear:both;direction:ltr}.cas-group-sep:after,.cas-group-sep:before{position:relative;display:block;content:'';width:2px;height:8px;margin:0 auto;background-color:#ccc}.cas-group-sep .wpca-sep-not,.cas-group-sep .wpca-sep-or-not{display:none}.cas-group-sep span{background:#777;display:inline-block;padding:3px 5px;border-radius:3px;vertical-align:middle}.cas-group-body .cas-group-sep{display:block;overflow:hidden;text-align:center;margin:5px -10px}.cas-group-body .cas-group-sep:after,.cas-group-body .cas-group-sep:before{background-color:transparent;border-top:1px solid #eee;content:"";display:inline-block;height:1px;position:relative;vertical-align:middle;width:50%}.cas-group-body .cas-group-sep:before{right:0;margin-left:-50%}.cas-group-body .cas-group-sep:after{left:0;margin-right:-50%}.cas-group-label{font-weight:700;margin:0 0 6px}.wpca-condition-remove{cursor:pointer;margin:0 8px 0 0;color:#aaa;transition:color .3s ease}.wpca-condition-remove:hover{color:#444}.cas-group-new{position:relative;background-color:#fff;border:1px solid #e9e9e9;border-radius:2px;box-shadow:0 0 0 4px #f9f9f9 inset,0 1px 1px rgba(0,0,0,.08);padding:15px;margin-bottom:10px;transition:all .5s ease}.cas-group-new:hover{border-color:#ccc;box-shadow:0 0 0 4px #f1f1f1 inset,0 1px 1px rgba(0,0,0,.08)}label.cae-toggle input{display:none}label.cae-toggle .cae-toggle-bar{overflow:hidden;cursor:pointer;position:relative;padding-right:34px;height:22px;line-height:22px;display:inline-block;vertical-align:middle}label.cae-toggle .cae-toggle-bar:before{top:0;right:0;position:absolute;display:inline-block;width:34px;content:"";padding:0;height:inherit;line-height:inherit;border-radius:22px;background-color:#bbb;box-shadow:0 0 2px rgba(0,0,0,.2) inset;transition:background-color .2s ease-in}label.cae-toggle .cae-toggle-bar:after{content:"";display:block;width:18px;height:18px;margin:0;background:#FFF;position:absolute;top:2px;right:14px;border-radius:22px;transition:right .2s ease-in 0s;box-shadow:0 1px 2px rgba(0,0,0,.2)}label.cae-toggle input:checked+.cae-toggle-bar:before{background-color:#7ad03a}label.cae-toggle input:checked+.cae-toggle-bar:after{right:2px}@media (min-width:783px){#cas-groups .button-small .dashicons{font-size:14px;height:14px;width:14px;vertical-align:text-top}}@media (min-width:1041px){.cas-group-label{float:left;width:220px;margin:5px 0 0}.wpca-group-description{float:left}.cas-group-input{margin-left:221px;white-space:nowrap;overflow:hidden}.cas-group-body .cas-group-options li{padding:8px 10%}.rtl .cas-group-label{float:right}.rtl .cas-group-input{margin-right:221px;margin-left:auto}}.select2-container--wpca.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container--wpca.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none;background-color:#fff;border:1px solid #ddd;border-radius:none}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#444;line-height:28px}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__clear{position:relative;cursor:pointer;float:right;font-weight:700}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--wpca.select2-container .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent;border-style:solid;border-width:5px 4px 0;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--single .select2-selection__clear{float:left}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--wpca.select2-container.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888;border-width:0 4px 5px}.select2-container--wpca.select2-container .select2-selection--multiple{background-color:#fff;color:#444;border:1px solid #ddd;cursor:text;box-sizing:border-box;display:block;min-height:32px;line-height:1;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;box-sizing:border-box;list-style:none;margin:0;padding:0 5px 3px;width:100%}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:700;margin-top:5px;margin-right:10px}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__choice{background-color:#bfe7f1;color:#23282d;border:1px solid #439eb4;border-radius:2px;cursor:default;float:left;margin:4px 4px 0 0;padding:2px 6px 4px;max-width:100%;overflow:hidden;text-overflow:ellipsis;box-sizing:border-box;box-shadow:0 1px 0 0 rgba(255,255,255,.9) inset,0 1px 1px rgba(0,0,0,.1)}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__choice__remove{color:#439eb4;cursor:pointer;font-size:16px;display:inline-block;font-weight:700;margin-right:6px}.select2-container--wpca.select2-container .select2-selection--multiple .select2-selection__choice__remove:hover{color:#444}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-search--inline,.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__choice,.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__placeholder{float:right}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__choice{margin:4px 0 0 4px}.select2-container--wpca.select2-container[dir=rtl] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--wpca.select2-container.select2-container--focus .select2-selection--multiple{border:1px solid #5b9dd9;background-color:#fafafa;outline:0}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--wpca.select2-container.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--wpca.select2-container .select2-dropdown{background-color:#fff;border:1px solid #5b9dd9;border-radius:none;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-container--wpca.select2-container--open .select2-dropdown--below,.select2-container--wpca.select2-container--open.select2-container--above .select2-selection--multiple,.select2-container--wpca.select2-container--open.select2-container--above .select2-selection--single{border-top-left-radius:0;border-top-right-radius:0;border-top:none}.select2-container--wpca.select2-container--open .select2-dropdown--above,.select2-container--wpca.select2-container--open.select2-container--below .select2-selection--multiple,.select2-container--wpca.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-1{padding-left:10px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-2{padding-left:20px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-3{padding-left:30px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-4{padding-left:40px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-5{padding-left:50px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-6{padding-left:60px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-7{padding-left:70px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-8{padding-left:80px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-9{padding-left:90px}.select2-container--wpca.select2-container .select2-dropdown .wpca-level-10{padding-left:100px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-1{padding-right:10px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-2{padding-right:20px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-3{padding-right:30px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-4{padding-right:40px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-5{padding-right:50px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-6{padding-right:60px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-7{padding-right:70px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-8{padding-right:80px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-9{padding-right:90px}.select2-container--wpca.select2-container .select2-dropdown[dir=rtl] .wpca-level-10{padding-right:100px}.select2-container--wpca.select2-container .select2-results{display:block}.select2-container--wpca.select2-container .select2-results__options{list-style:none;margin:0;padding:0}.select2-container--wpca.select2-container .select2-results__option{padding:6px;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}.select2-container--wpca.select2-container .select2-results__option[aria-selected]{cursor:pointer}.select2-container--wpca.select2-container--open .select2-dropdown{left:0}.select2-container--wpca .select2-search--dropdown{display:block;padding:4px}.select2-container--wpca .select2-results>.select2-results__options[aria-multiselectable] .select2-results__option[aria-selected=true],.select2-container--wpca .select2-search--dropdown.select2-search--hide{display:none}.select2-container--wpca .select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box;border:1px solid #5b9dd9}.select2-container--wpca .select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-container--wpca .select2-search--inline{float:left;width:auto;margin:0;z-index:1030}.select2-container--wpca .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;font-family:inherit;margin:6px 0 0;padding:0;background:0 0!important;min-height:auto;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--wpca .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-container--wpca .select2-search--inline .select2-search__field:not([placeholder='']){width:100%!important;margin-right:9999px}.select2-container--wpca[dir=rtl] .select2-search--inline .select2-search__field:not([placeholder='']){margin-left:9999px;margin-right:auto}.select2-container--wpca .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--wpca .select2-results__option[role=group]{padding:0}.select2-container--wpca .select2-results__option[aria-disabled=true]{color:#999}.select2-container--wpca .select2-results__option[aria-selected=true]{background-color:#eee}.select2-container--wpca .select2-results__option .select2-results__option{padding-left:20px}.select2-container--wpca .select2-results__option--highlighted[aria-selected][aria-selected=false]{background-color:#5897fb;color:#fff}.select2-container--wpca .select2-results__group{cursor:default;display:block;padding:6px}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0!important;clip:rect(0 0 0 0)!important;height:1px!important;margin:-1px!important;overflow:hidden!important;padding:0!important;position:absolute!important;width:1px!important}
lib/wp-content-aware-engine/assets/js/condition_groups.js CHANGED
@@ -5,10 +5,6 @@
5
  * @copyright 2018 by Joachim Jensen
6
  */
7
 
8
- /**
9
- * Namespace
10
- * @type {Object}
11
- */
12
  var CAE = CAE || {};
13
 
14
  (function($, CAE) {
@@ -18,513 +14,476 @@ var CAE = CAE || {};
18
  views: {}
19
  };
20
 
21
- /**
22
- * Backbone Models
23
- *
24
- * @type {Object}
25
- */
26
- CAE.Models = {
27
-
28
- Alert: Backbone.Model.extend({
29
- defaults: {
30
- text : "",
31
- success : true
32
- },
33
- sync: function () { return false; },
34
- url: "",
35
- reset: function() {
36
- this.set(this.defaults);
37
- }
38
- }),
39
 
40
- Condition: Backbone.Model.extend({
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  //backbone.trackit
42
- unsaved: {
43
- prompt: WPCA.unsaved,
44
- unloadWindowPrompt: true
45
- },
46
- defaults : {
47
- 'module' : null,
48
- 'label' : '',
49
- 'placeholder' : '',
50
- 'values' : [],
51
- 'default_value': null
52
- },
53
- initialize: function() {
54
- //backbone.trackit
55
- this.startTracking();
56
- this.on("destroy",this.stopTracking,this);
57
- },
58
- sync: function () { return false; },
59
- url: ""
60
- }),
61
 
62
- Group: Backbone.Model.extend({
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  //backbone.trackit
64
- unsaved: {
65
- prompt: WPCA.unsaved,
66
- unloadWindowPrompt: true
67
- },
68
- //TODO: remove function
69
- defaults: function() {
70
- var defaults = WPCA.meta_default;
71
- defaults.id = null;
72
- defaults.status = 'publish';
73
- defaults.exposure = 1;
74
- return defaults;
75
- },
76
- initialize: function() {
77
- //backbone.trackit
78
- this.startTracking();
79
- this.on("destroy",this.stopTracking,this);
80
 
81
- if(!this.conditions) {
82
- this.conditions = new CAE.Models.ConditionCollection();
83
- }
84
- },
85
- parse: function(response) {
86
- if (_.has(response, "conditions")) {
87
- var list = [];
88
- for(var key in response.conditions) {
89
- if(response.conditions.hasOwnProperty(key)) {
90
- var values = [],
91
- model = response.conditions[key];
92
- for(var key2 in model.data) {
93
- if(model.data.hasOwnProperty(key2)) {
94
- values.push({
95
- text: model.data[key2],
96
- id: key2
97
- });
98
- }
99
  }
100
- list.push({
101
- label : model.label,
102
- placeholder: model.placeholder,
103
- module : key,
104
- values : values,
105
- default_value : model.default_value
106
- });
107
  }
 
 
 
 
108
  }
109
- this.conditions = new CAE.Models.ConditionCollection(
110
- list
111
- );
112
- delete response.conditions;
113
  }
114
- return response;
115
- },
116
- sync: function () { return false; },
117
- url : ""
118
- }),
119
-
120
- GroupCollection: Backbone.Collection.extend({
121
- model: function(attrs,options){
122
- return new CAE.Models.Group(attrs,options);
123
- },
124
- parse: function(response) {
125
- return response;
126
  }
127
- }),
 
 
 
 
 
128
 
129
- ConditionCollection: Backbone.Collection.extend({
130
- model: function(attrs,options){
131
- return new CAE.Models.Condition(attrs,options);
132
- }
133
- })
134
- };
135
 
136
- /**
137
- * Backbone.Epoxy.View.
138
- *
139
- * @type {Object}
140
- */
141
- CAE.Views = {
142
-
143
- /**
144
- * Alert handler
145
- * @author Joachim Jensen <jv@intox.dk>
146
- * @version 1.0
147
- */
148
- Alert: Backbone.Epoxy.View.extend({
149
- bindings: "data-vm", //wp conflict with data-bind
150
- tagName: 'div',
151
- className: 'wpca-alert',
152
- template: '<div data-vm="classes:{\'wpca-success\':success,\'wpca-error\':not(success)},text:text"></div>',
153
- timer: 4000,
154
- success: function(text) {
155
- this.model.set({
156
- text: text,
157
- success: true
158
- });
159
- },
160
- failure: function(text) {
161
- this.model.set({
162
- text: text,
163
- success: false
164
- });
165
- },
166
- dismiss: function() {
 
 
 
 
 
 
167
  var self = this;
168
- this.$el.fadeOut('slow',function() {
169
- self.model.reset();
170
- });
171
- },
172
- initialize: function() {
173
- this.listenTo(this.model, "change:text", this.show);
174
- this.$el.appendTo('body').hide().html(this.template);
175
- },
176
- show: function() {
177
- if(this.model.get('text') !== "") {
178
- this.$el.fadeIn('slow');
179
- var self = this;
180
- setTimeout(function() {
181
- self.dismiss();
182
- },this.timer);
183
- }
184
  }
185
- }),
186
-
187
- Condition: Backbone.Epoxy.View.extend({
188
- bindings: "data-vm", //wp conflict with data-bind
189
- model: CAE.Models.Condition,
190
- tagName: "div",
191
- className: "cas-condition",
192
- templateName: '#wpca-template-condition',
193
- events: {
194
- "click .js-wpca-condition-remove": "removeModel"
195
- },
196
- initialize: function() {
197
- this.listenTo( this.model, 'destroy', this.remove );
198
- var $template = $(this.templateName);
199
- if($template.length) {
200
- this.template = $template.html();
201
- this.$el.append(this.template);
202
- this.createSuggestInput();
203
- } else {
204
- this.model.destroy();
205
- }
206
- },
207
- removeModel: function(e) {
208
- console.log("cond view: removes condition model");
209
- var that = this;
210
- this.$el.slideUp(300,function() {
211
- that.model.destroy();
212
- console.log("cond view: condition model removed");
213
- });
214
- },
215
- createSuggestInput: function() {
216
- var $elem = this.$el.find(".js-wpca-suggest");
217
- if(!$elem.length) {
218
- return;
219
- }
220
- var model = this.model,
221
- data = this.model.get("values"),
222
- //some post type/taxonomy translations use special entities
223
- //todo:consider decoding in backend
224
- placeholder = $('<div></div>').html(model.get('placeholder')).text();
225
-
226
- $elem.select2({
227
- more: true,
228
- cachedResults: {},
229
- quietMillis: 400,
230
- searchTimer: null,
231
- type:model.get('module'),
232
- theme:'wpca',
233
- dir:WPCA.text_direction,
234
- placeholder:placeholder,
235
- minimumInputLength: 0,
236
- closeOnSelect: true,//false not working properly when hiding selected
237
- width:"100%",
238
- language: {
239
- noResults:function(){
240
- return WPCA.noResults;
241
- },
242
- searching: function(){
243
- return WPCA.searching+'...';
244
- },
245
- loadingMore: function() {
246
- return WPCA.loadingMore+'...';
247
- }
248
- },
249
- nextSearchTerm: function(selected, currentTerm) {
250
- return currentTerm;
251
  },
252
- templateResult: function(item) {
253
- if(!item.level) {
254
- return item.text;
255
- }
256
- return $('<span class="wpca-level-'+item.level+'">'+item.text+'</span>');
257
  },
258
- data: data,
259
- dataAdapter: wpca_admin.wpcaDataAdapter,
260
- ajax:{}
261
- })
262
- .on("select2:selecting",function(e) {
263
- $elem.data("forceOpen",true);
264
- })
265
- .on("select2:closing",function(e) {
266
- if($elem.data("forceOpen")) {
267
- e.preventDefault();
268
- $elem.data("forceOpen",false);
269
  }
270
- });
271
-
272
- //data is set, now set selected
273
- if(data.length) {
274
- $elem.val(_.map(data,function(obj) {
275
- return obj.id;
276
- })).trigger('change');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  }
 
278
 
279
- $elem.on("change", function(e) {
280
- //fix for closeOnSelect
281
- //$elem.resize();
282
- console.log("select2 change");
283
- var values = $elem.select2("data");
284
- model.set("values",values);
285
- });
286
  }
287
- }),
288
-
289
- Group: Backbone.Epoxy.View.extend({
290
- bindings: "data-vm", //wp conflict with data-bind
291
- model: CAE.Models.Group,
292
- tagName: "li",
293
- className: "cas-group-single",
294
- template: $('#wpca-template-group').html(),
295
- itemView: function(obj) {
296
- if(CAE.Views[obj.model.get("module")]) {
297
- var condition = new CAE.Views[obj.model.get("module")](obj);
298
- } else {
299
- var condition = new CAE.Views.Condition(obj);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
  }
301
- return condition;
302
  },
303
- events: {
304
- "change .js-wpca-add-and": "addConditionModel",
305
- "click .js-wpca-save-group": "saveGroup",
306
- "click .js-wpca-options": "showOptions"
307
- },
308
- computeds: {
309
- statusNegated: {
310
- deps: ["status"],
311
- get: function( status ) {
312
- return status == 'negated';
313
- },
314
- set: function( bool ) {
315
- var valid = bool ? 'negated' : 'publish';
316
- this.setBinding("status", valid);
317
- }
318
  },
319
- //ensure exposure number and state
320
- exposureSingular: {
321
- deps: ["exposure"],
322
- get: function(exposure) {
323
- return exposure <= 1;
324
- },
325
- set: function( bool ) {
326
- var isArchive = this.getBinding('exposureArchive'),
327
- val = !(bool && isArchive) ? 2 : (isArchive ? 1 : 0);
328
- this.setBinding("exposure",val);
329
- }
330
- },
331
- exposureArchive: {
332
- deps: ["exposure"],
333
- get: function(exposure) {
334
- return exposure >= 1;
335
- },
336
- set: function( bool ) {
337
- var isSingular = this.getBinding('exposureSingular'),
338
- val = !(bool && isSingular) ? 0 : (isSingular ? 1 : 2);
339
- this.setBinding("exposure",val);
340
- }
341
  }
342
  },
343
- bindingFilters: {
344
- //epoxy integer filter seems broken
345
- int: {
346
- get: function( value ) {
347
- return value ? 1 : 0;
348
- },
349
- set: function( value ) {
350
- return value ? 1 : 0;
351
- }
352
  }
353
- },
354
- initialize: function() {
355
- this.collection = this.model.conditions;
356
- this.$el.hide().html(this.template).fadeIn(300);
357
- this.listenTo( this.model, 'destroy', this.remove );
358
- this.listenTo( this.model, 'unsavedChanges', this.saveChanges);
359
- this.listenTo( this.model.conditions, 'unsavedChanges', this.saveChanges);
360
- this.listenTo( this.model.conditions, 'add remove', this.saveAddRemove);
361
- },
362
- showOptions: function(e) {
363
- $(e.delegateTarget).find('.cas-group-options').slideToggle(200);
364
- $(e.currentTarget).toggleClass('active');
365
- },
366
- saveChanges: function(hasChanges, unsavedAttrs) {
367
- if(hasChanges) {
368
- console.log("group view: has changes");
369
- AutoSaver.start(this);
370
- } else {
371
- AutoSaver.clear(this);
372
  }
373
- },
374
- saveAddRemove: function(model, collection, options) {
375
- console.log("group view: a condition was added or removed");
376
- if(collection.length) {
377
- if(options.add) {
378
- //save only on default value
379
- if(model.get('default_value') !== '') {
380
- AutoSaver.start(this);
381
- }
382
- } else if(this.model.get("id")) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  AutoSaver.start(this);
384
  }
 
 
 
 
 
 
 
 
 
385
  } else {
386
- AutoSaver.clear(this);
387
- if(this.model.get("id")) {
388
- //at this point, we could skip save request
389
- //and add a faster delete request
390
- this.saveGroup();
391
- } else {
392
- this.removeModel();
393
- }
394
  }
395
- },
396
- addConditionModel: function(e) {
397
- var $select = $(e.currentTarget);
398
- if(!!$select.val() && !this.model.conditions.findWhere({module:$select.val()})) {
399
- var $selected = $select.children(":selected");
400
- var condition = new CAE.Models.Condition({
401
- module: $select.val(),
402
- label: $selected.text(),
403
- placeholder: $selected.data('placeholder'),
404
- default_value: $selected.data('default')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
405
  });
406
- this.model.conditions.add(condition);
 
407
  }
408
- $select.val(0).blur();
409
- },
410
- removeModel: function() {
411
- var that = this;
412
- console.log("group view: group model removing");
413
- this.$el.slideUp(400,function() {
414
- that.model.destroy();
415
- console.log("group view: group model removed");
416
- });
417
- },
418
- saveGroup: function(e) {
419
- console.log("group view: save");
420
- var $spinner = this.$el.find('.spinner'),
421
- $save = this.$el.find('.js-wpca-save-group'),
422
- self = this;
423
-
424
- $save.attr("disabled",true);
425
- $spinner.addClass('is-active');
426
-
427
- var data = _.clone(this.model.attributes);
428
- data.action = "wpca/add-rule";
429
- data.token = wpca_admin.nonce;
430
- data.current_id = wpca_admin.sidebarID;
431
- data.post_type = WPCA.post_type;
432
- data.conditions = {};
433
-
434
- this.model.conditions.each(function(model) {
435
- if(model.get('values').length) {
436
- data.conditions[model.get('module')] = model.get('values').map(function(model) {
437
- return model.id;
438
- });
439
- } else if(model.get('default_value') !== '') {
440
- data.conditions[model.get('module')] = [model.get('default_value')];
441
- }
442
- });
443
 
444
- $.ajax({
445
- url: ajaxurl,
446
- data:data,
447
- dataType: 'JSON',
448
- type: 'POST',
449
- success:function(response){
450
 
451
- console.log("group view: saved");
452
 
453
- wpca_admin.alert.success(response.message);
454
 
455
- if(response.removed) {
456
- self.removeModel();
457
- }
458
- else if(response.new_post_id) {
459
- self.model.set("id",response.new_post_id,{silent:true});
460
- }
461
 
462
- if(!response.removed) {
463
- $save.hide();
464
- $spinner.removeClass('is-active');
465
- //backbone.trackit
466
- self.model.restartTracking();
467
- self.model.conditions.each(function(model) {
468
- model.restartTracking();
469
- });
470
- }
471
- },
472
- error: function(xhr, desc, e) {
473
- $save.attr("disabled",false).show();
474
  $spinner.removeClass('is-active');
475
- wpca_admin.alert.failure(xhr.responseText);
 
 
 
 
476
  }
477
- });
478
- },
479
- slideRemove: function() {
480
- console.log("group view: group model was destroyed");
481
- this.$el.slideUp(400,function() {
482
- this.remove();
483
- });
484
- }
485
- }),
486
-
487
- GroupCollection: Backbone.Epoxy.View.extend({
488
- bindings: "data-vm", //wp conflict with data-bind
489
- el: "#cas-groups",
490
- collection: CAE.Models.GroupCollection,
491
- events: {
492
- "change .js-wpca-add-or": "addGroupModel",
493
- "click .js-wpca-save": "saveAll"
494
- },
495
- itemView: function(obj) {
496
- return new CAE.Views.Group(obj);
497
- },
498
- addGroupModel: function(e) {
499
- var $select = $(e.currentTarget);
500
-
501
- if(!!$select.val()) {
502
- var group = new CAE.Models.Group();
503
- var $selected = $select.children(":selected");
504
- var condition = new CAE.Models.Condition({
505
- module: $select.val(),
506
- label: $selected.text(),
507
- placeholder: $selected.data('placeholder'),
508
- default_value: $selected.data('default')
509
- });
510
- this.collection.add(group);
511
- group.conditions.add(condition);
512
  }
 
 
 
 
 
 
 
 
 
513
 
514
- $select.val(0).blur();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
  }
516
- })
517
- };
518
-
519
- // window.addEventListener("beforeunload", function (e) {
520
- // if (!wpca_admin.hasUnsavedChanges()) {
521
- // return;
522
- // }
523
 
524
- // (e || window.event).returnValue = WPCA.unsaved; //Gecko + IE
525
- // return WPCA.unsaved; //Webkit, Safari, Chrome
526
- // });
527
- //
528
 
529
  //remove tag completely on backspace
530
  $.fn.select2.amd.require(['select2/selection/search'], function (Search) {
@@ -555,7 +514,7 @@ var CAE = CAE || {};
555
 
556
  WPCADataAdapter.prototype.query = function (params, callback) {
557
 
558
- params['term'] = params.term || '';
559
 
560
  var self = this.options.options,
561
  cachedData = self.cachedResults[params.term],
@@ -589,43 +548,16 @@ var CAE = CAE || {};
589
  dataType: 'JSON',
590
  type: 'POST',
591
  success: function(data) {
592
- var results = data;
593
- var more = true;
594
- // for (var key in data) {
595
- // if (data.hasOwnProperty(key)) {
596
- // results.push({
597
- // id:key,
598
- // text:data[key]
599
- // });
600
- // }
601
- // }
602
- // var length = data.length,
603
- // i = 0;
604
- // for(i; i < length; i++) {
605
- // results.push({
606
- // id: data[i].id,
607
- // text: data[i].title
608
- // });
609
- // }
610
- if(results.length < 20) {
611
- more = false;
612
- }
613
- if(cachedData) {
614
- self.cachedResults[params.term] = {
615
- page: page,
616
- more: more,
617
- items: self.cachedResults[params.term].items.concat(results)
618
- };
619
- } else {
620
- self.cachedResults[params.term] = {
621
- page: page,
622
- items: results,
623
- more: more
624
- };
625
- }
626
 
627
  callback({
628
- results: results,
629
  pagination: {
630
  more:more
631
  }
5
  * @copyright 2018 by Joachim Jensen
6
  */
7
 
 
 
 
 
8
  var CAE = CAE || {};
9
 
10
  (function($, CAE) {
14
  views: {}
15
  };
16
 
17
+ CAE.Models = {};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
+ CAE.Models.Alert = Backbone.Model.extend({
20
+ defaults: {
21
+ text : "",
22
+ success : true
23
+ },
24
+ sync: function () { return false; },
25
+ url: "",
26
+ reset: function() {
27
+ this.set(this.defaults);
28
+ }
29
+ });
30
+
31
+ CAE.Models.Condition = Backbone.Model.extend({
32
+ //backbone.trackit
33
+ unsaved: {
34
+ prompt: WPCA.unsaved,
35
+ unloadWindowPrompt: true
36
+ },
37
+ defaults : {
38
+ 'module' : null,
39
+ 'label' : '',
40
+ 'placeholder' : '',
41
+ 'values' : [],
42
+ 'default_value': null
43
+ },
44
+ initialize: function() {
45
  //backbone.trackit
46
+ this.startTracking();
47
+ this.on("destroy",this.stopTracking,this);
48
+ },
49
+ sync: function () { return false; },
50
+ url: ""
51
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
+ CAE.Models.Group = Backbone.Model.extend({
54
+ //backbone.trackit
55
+ unsaved: {
56
+ prompt: WPCA.unsaved,
57
+ unloadWindowPrompt: true
58
+ },
59
+ //TODO: remove function
60
+ defaults: function() {
61
+ var defaults = WPCA.meta_default;
62
+ defaults.id = null;
63
+ defaults.status = 'publish';
64
+ defaults.exposure = 1;
65
+ return defaults;
66
+ },
67
+ initialize: function() {
68
  //backbone.trackit
69
+ this.startTracking();
70
+ this.on("destroy",this.stopTracking,this);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
+ if(!this.conditions) {
73
+ this.conditions = new CAE.Models.ConditionCollection();
74
+ }
75
+ },
76
+ parse: function(response) {
77
+ var list = [];
78
+ if (_.has(response, "conditions")) {
79
+ for(var key in response.conditions) {
80
+ if(response.conditions.hasOwnProperty(key)) {
81
+ var values = [],
82
+ model = response.conditions[key];
83
+ for(var key2 in model.data) {
84
+ if(model.data.hasOwnProperty(key2)) {
85
+ values.push({
86
+ text: model.data[key2],
87
+ id: key2
88
+ });
 
89
  }
 
 
 
 
 
 
 
90
  }
91
+ delete model.data;
92
+ model.module = key;
93
+ model.values = values;
94
+ list.push(model);
95
  }
 
 
 
 
96
  }
97
+ delete response.conditions;
 
 
 
 
 
 
 
 
 
 
 
98
  }
99
+ this.conditions = new CAE.Models.ConditionCollection(list);
100
+ return response;
101
+ },
102
+ sync: function () { return false; },
103
+ url : ""
104
+ });
105
 
106
+ CAE.Models.GroupCollection = Backbone.Collection.extend({
107
+ model: CAE.Models.Group,
108
+ parse: function(response) {
109
+ return response;
110
+ }
111
+ });
112
 
113
+ CAE.Models.ConditionCollection = Backbone.Collection.extend({
114
+ model: CAE.Models.Condition
115
+ });
116
+
117
+ CAE.Views = {};
118
+
119
+ CAE.Views.Alert = Backbone.Epoxy.View.extend({
120
+ bindings: "data-vm", //wp conflict with data-bind
121
+ tagName: 'div',
122
+ className: 'wpca-alert',
123
+ template: '<div data-vm="classes:{\'wpca-success\':success,\'wpca-error\':not(success)},text:text"></div>',
124
+ timer: 4000,
125
+ success: function(text) {
126
+ this.model.set({
127
+ text: text,
128
+ success: true
129
+ });
130
+ },
131
+ failure: function(text) {
132
+ this.model.set({
133
+ text: text,
134
+ success: false
135
+ });
136
+ },
137
+ dismiss: function() {
138
+ var self = this;
139
+ this.$el.fadeOut('slow',function() {
140
+ self.model.reset();
141
+ });
142
+ },
143
+ initialize: function() {
144
+ this.listenTo(this.model, "change:text", this.show);
145
+ this.$el.appendTo('body').hide().html(this.template);
146
+ },
147
+ show: function() {
148
+ if(this.model.get('text') !== "") {
149
+ this.$el.fadeIn('slow');
150
  var self = this;
151
+ setTimeout(function() {
152
+ self.dismiss();
153
+ },this.timer);
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  }
155
+ }
156
+ });
157
+
158
+ CAE.Views.Condition = Backbone.Epoxy.View.extend({
159
+ bindings: "data-vm", //wp conflict with data-bind
160
+ model: CAE.Models.Condition,
161
+ tagName: "div",
162
+ className: "cas-condition",
163
+ templateName: '#wpca-template-condition',
164
+ events: {
165
+ "click .js-wpca-condition-remove": "removeModel"
166
+ },
167
+ initialize: function() {
168
+ this.listenTo( this.model, 'destroy', this.remove );
169
+ var $template = $(this.templateName);
170
+ if($template.length) {
171
+ this.template = $template.html();
172
+ this.$el.append(this.template);
173
+ this.createSuggestInput();
174
+ } else {
175
+ this.model.destroy();
176
+ }
177
+ },
178
+ removeModel: function(e) {
179
+ console.log("cond view: removes condition model");
180
+ var that = this;
181
+ this.$el.slideUp(300,function() {
182
+ that.model.destroy();
183
+ console.log("cond view: condition model removed");
184
+ });
185
+ },
186
+ createSuggestInput: function() {
187
+ var $elem = this.$el.find(".js-wpca-suggest");
188
+ if(!$elem.length) {
189
+ return;
190
+ }
191
+ var model = this.model,
192
+ data = this.model.get("values"),
193
+ //some post type/taxonomy translations use special entities
194
+ //todo:consider decoding in backend
195
+ placeholder = $('<div></div>').html(model.get('placeholder')).text();
196
+
197
+ $elem.select2({
198
+ cachedResults: {},
199
+ quietMillis: 400,
200
+ searchTimer: null,
201
+ type:model.get('module'),
202
+ theme:'wpca',
203
+ dir:WPCA.text_direction,
204
+ placeholder:placeholder,
205
+ minimumInputLength: 0,
206
+ closeOnSelect: true,//false not working properly when hiding selected
207
+ width:"100%",
208
+ language: {
209
+ noResults:function(){
210
+ return WPCA.noResults;
 
 
 
 
 
 
 
 
 
 
211
  },
212
+ searching: function(){
213
+ return WPCA.searching+'...';
 
 
 
214
  },
215
+ loadingMore: function() {
216
+ return WPCA.loadingMore+'...';
 
 
 
 
 
 
 
 
 
217
  }
218
+ },
219
+ nextSearchTerm: function(selected, currentTerm) {
220
+ return currentTerm;
221
+ },
222
+ templateResult: function(item) {
223
+ if(!item.level) {
224
+ return item.text;
225
+ }
226
+ return $('<span class="wpca-level-'+item.level+'">'+item.text+'</span>');
227
+ },
228
+ data: data,
229
+ dataAdapter: wpca_admin.wpcaDataAdapter,
230
+ ajax:{}
231
+ })
232
+ .on("select2:selecting",function(e) {
233
+ $elem.data("forceOpen",true);
234
+ })
235
+ .on("select2:closing",function(e) {
236
+ if($elem.data("forceOpen")) {
237
+ e.preventDefault();
238
+ $elem.data("forceOpen",false);
239
  }
240
+ });
241
 
242
+ //data is set, now set selected
243
+ if(data.length) {
244
+ $elem.val(_.map(data,function(obj) {
245
+ return obj.id;
246
+ })).trigger('change');
 
 
247
  }
248
+
249
+ $elem.on("change", function(e) {
250
+ //fix for closeOnSelect
251
+ //$elem.resize();
252
+ console.log("select2 change");
253
+ var values = $elem.select2("data");
254
+ model.set("values",values);
255
+ });
256
+ }
257
+ });
258
+
259
+ CAE.Views.Group = Backbone.Epoxy.View.extend({
260
+ bindings: "data-vm", //wp conflict with data-bind
261
+ model: CAE.Models.Group,
262
+ tagName: "li",
263
+ className: "cas-group-single",
264
+ template: $('#wpca-template-group').html(),
265
+ itemView: function(obj) {
266
+ if(CAE.Views[obj.model.get("module")]) {
267
+ var condition = new CAE.Views[obj.model.get("module")](obj);
268
+ } else {
269
+ var condition = new CAE.Views.Condition(obj);
270
+ }
271
+ return condition;
272
+ },
273
+ events: {
274
+ "change .js-wpca-add-and": "addConditionModel",
275
+ "click .js-wpca-save-group": "saveGroup",
276
+ "click .js-wpca-options": "showOptions"
277
+ },
278
+ computeds: {
279
+ statusNegated: {
280
+ deps: ["status"],
281
+ get: function( status ) {
282
+ return status == 'negated';
283
+ },
284
+ set: function( bool ) {
285
+ var valid = bool ? 'negated' : 'publish';
286
+ this.setBinding("status", valid);
287
  }
 
288
  },
289
+ //ensure exposure number and state
290
+ exposureSingular: {
291
+ deps: ["exposure"],
292
+ get: function(exposure) {
293
+ return exposure <= 1;
 
 
 
 
 
 
 
 
 
 
294
  },
295
+ set: function( bool ) {
296
+ var isArchive = this.getBinding('exposureArchive'),
297
+ val = !(bool && isArchive) ? 2 : (isArchive ? 1 : 0);
298
+ this.setBinding("exposure",val);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  }
300
  },
301
+ exposureArchive: {
302
+ deps: ["exposure"],
303
+ get: function(exposure) {
304
+ return exposure >= 1;
305
+ },
306
+ set: function( bool ) {
307
+ var isSingular = this.getBinding('exposureSingular'),
308
+ val = !(bool && isSingular) ? 0 : (isSingular ? 1 : 2);
309
+ this.setBinding("exposure",val);
310
  }
311
+ }
312
+ },
313
+ bindingFilters: {
314
+ //epoxy integer filter seems broken
315
+ int: {
316
+ get: function( value ) {
317
+ return value ? 1 : 0;
318
+ },
319
+ set: function( value ) {
320
+ return value ? 1 : 0;
 
 
 
 
 
 
 
 
 
321
  }
322
+ }
323
+ },
324
+ initialize: function() {
325
+ this.collection = this.model.conditions;
326
+ this.$el.hide().html(this.template).fadeIn(300);
327
+ this.listenTo( this.model, 'destroy', this.remove );
328
+ this.listenTo( this.model, 'unsavedChanges', this.saveChanges);
329
+ this.listenTo( this.model.conditions, 'unsavedChanges', this.saveChanges);
330
+ this.listenTo( this.model.conditions, 'add remove', this.saveAddRemove);
331
+ },
332
+ showOptions: function(e) {
333
+ $(e.delegateTarget).find('.cas-group-options').slideToggle(200);
334
+ $(e.currentTarget).toggleClass('active');
335
+ },
336
+ saveChanges: function(hasChanges, unsavedAttrs) {
337
+ if(hasChanges) {
338
+ console.log("group view: has changes");
339
+ AutoSaver.start(this);
340
+ } else {
341
+ AutoSaver.clear(this);
342
+ }
343
+ },
344
+ saveAddRemove: function(model, collection, options) {
345
+ console.log("group view: a condition was added or removed");
346
+ if(collection.length) {
347
+ if(options.add) {
348
+ //save only on default value
349
+ if(model.get('default_value') !== '') {
350
  AutoSaver.start(this);
351
  }
352
+ } else if(this.model.get("id")) {
353
+ AutoSaver.start(this);
354
+ }
355
+ } else {
356
+ AutoSaver.clear(this);
357
+ if(this.model.get("id")) {
358
+ //at this point, we could skip save request
359
+ //and add a faster delete request
360
+ this.saveGroup();
361
  } else {
362
+ this.removeModel();
 
 
 
 
 
 
 
363
  }
364
+ }
365
+ },
366
+ addConditionModel: function(e) {
367
+ var $select = $(e.currentTarget);
368
+ if(!!$select.val() && isNaN($select.val()) && !this.model.conditions.findWhere({module:$select.val()})) {
369
+ var $selected = $select.children(":selected");
370
+ var condition = new CAE.Models.Condition({
371
+ module: $select.val(),
372
+ label: $selected.text(),
373
+ placeholder: $selected.data('placeholder'),
374
+ default_value: $selected.data('default')
375
+ });
376
+ this.model.conditions.add(condition);
377
+ }
378
+ $select.val(-1).blur();
379
+ },
380
+ removeModel: function() {
381
+ var that = this;
382
+ console.log("group view: group model removing");
383
+ this.$el.slideUp(400,function() {
384
+ that.model.destroy();
385
+ console.log("group view: group model removed");
386
+ });
387
+ },
388
+ saveGroup: function(e) {
389
+ console.log("group view: save");
390
+ var $spinner = this.$el.find('.spinner'),
391
+ $save = this.$el.find('.js-wpca-save-group'),
392
+ self = this;
393
+
394
+ $save.attr("disabled",true);
395
+ $spinner.addClass('is-active');
396
+
397
+ var data = _.clone(this.model.attributes);
398
+ data.action = "wpca/add-rule";
399
+ data.token = wpca_admin.nonce;
400
+ data.current_id = wpca_admin.sidebarID;
401
+ data.post_type = WPCA.post_type;
402
+ data.conditions = {};
403
+
404
+ this.model.conditions.each(function(model) {
405
+ if(model.get('values').length) {
406
+ data.conditions[model.get('module')] = model.get('values').map(function(model) {
407
+ return model.id;
408
  });
409
+ } else if(model.get('default_value') !== '') {
410
+ data.conditions[model.get('module')] = [model.get('default_value')];
411
  }
412
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
 
414
+ $.ajax({
415
+ url: ajaxurl,
416
+ data:data,
417
+ dataType: 'JSON',
418
+ type: 'POST',
419
+ success:function(response){
420
 
421
+ console.log("group view: saved");
422
 
423
+ wpca_admin.alert.success(response.message);
424
 
425
+ if(response.removed) {
426
+ self.removeModel();
427
+ }
428
+ else if(response.new_post_id) {
429
+ self.model.set("id",response.new_post_id,{silent:true});
430
+ }
431
 
432
+ if(!response.removed) {
433
+ $save.hide();
 
 
 
 
 
 
 
 
 
 
434
  $spinner.removeClass('is-active');
435
+ //backbone.trackit
436
+ self.model.restartTracking();
437
+ self.model.conditions.each(function(model) {
438
+ model.restartTracking();
439
+ });
440
  }
441
+ },
442
+ error: function(xhr, desc, e) {
443
+ $save.attr("disabled",false).show();
444
+ $spinner.removeClass('is-active');
445
+ wpca_admin.alert.failure(xhr.responseText);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
  }
447
+ });
448
+ },
449
+ slideRemove: function() {
450
+ console.log("group view: group model was destroyed");
451
+ this.$el.slideUp(400,function() {
452
+ this.remove();
453
+ });
454
+ }
455
+ });
456
 
457
+ CAE.Views.GroupCollection = Backbone.Epoxy.View.extend({
458
+ bindings: "data-vm", //wp conflict with data-bind
459
+ el: "#cas-groups",
460
+ collection: CAE.Models.GroupCollection,
461
+ events: {
462
+ "change .js-wpca-add-or": "addGroupModel",
463
+ "click .js-wpca-save": "saveAll"
464
+ },
465
+ itemView: function(obj) {
466
+ return new CAE.Views.Group(obj);
467
+ },
468
+ addGroupModel: function(e) {
469
+ var $select = $(e.currentTarget);
470
+
471
+ if(!!$select.val() && isNaN($select.val())) {
472
+ var group = new CAE.Models.Group();
473
+ var $selected = $select.children(":selected");
474
+ var condition = new CAE.Models.Condition({
475
+ module: $select.val(),
476
+ label: $selected.text(),
477
+ placeholder: $selected.data('placeholder'),
478
+ default_value: $selected.data('default')
479
+ });
480
+ this.collection.add(group);
481
+ group.conditions.add(condition);
482
  }
 
 
 
 
 
 
 
483
 
484
+ $select.val(-1).blur();
485
+ }
486
+ });
 
487
 
488
  //remove tag completely on backspace
489
  $.fn.select2.amd.require(['select2/selection/search'], function (Search) {
514
 
515
  WPCADataAdapter.prototype.query = function (params, callback) {
516
 
517
+ params.term = params.term || '';
518
 
519
  var self = this.options.options,
520
  cachedData = self.cachedResults[params.term],
548
  dataType: 'JSON',
549
  type: 'POST',
550
  success: function(data) {
551
+ var more = !(data.length < 20);
552
+
553
+ self.cachedResults[params.term] = {
554
+ page: page,
555
+ more: more,
556
+ items: cachedData ? self.cachedResults[params.term].items.concat(data) : data
557
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
558
 
559
  callback({
560
+ results: data,
561
  pagination: {
562
  more:more
563
  }
lib/wp-content-aware-engine/assets/js/condition_groups.min.js CHANGED
@@ -4,4 +4,4 @@
4
  * @license GPLv3
5
  * @copyright 2018 by Joachim Jensen
6
  */
7
- var CAE=CAE||{};!function(a,b){"use strict";b.settings={views:{}},b.Models={Alert:Backbone.Model.extend({defaults:{text:"",success:!0},sync:function(){return!1},url:"",reset:function(){this.set(this.defaults)}}),Condition:Backbone.Model.extend({unsaved:{prompt:WPCA.unsaved,unloadWindowPrompt:!0},defaults:{module:null,label:"",placeholder:"",values:[],default_value:null},initialize:function(){this.startTracking(),this.on("destroy",this.stopTracking,this)},sync:function(){return!1},url:""}),Group:Backbone.Model.extend({unsaved:{prompt:WPCA.unsaved,unloadWindowPrompt:!0},defaults:function(){var a=WPCA.meta_default;return a.id=null,a.status="publish",a.exposure=1,a},initialize:function(){this.startTracking(),this.on("destroy",this.stopTracking,this),this.conditions||(this.conditions=new b.Models.ConditionCollection)},parse:function(a){if(_.has(a,"conditions")){var c=[];for(var d in a.conditions)if(a.conditions.hasOwnProperty(d)){var e=[],f=a.conditions[d];for(var g in f.data)f.data.hasOwnProperty(g)&&e.push({text:f.data[g],id:g});c.push({label:f.label,placeholder:f.placeholder,module:d,values:e,default_value:f.default_value})}this.conditions=new b.Models.ConditionCollection(c),delete a.conditions}return a},sync:function(){return!1},url:""}),GroupCollection:Backbone.Collection.extend({model:function(a,c){return new b.Models.Group(a,c)},parse:function(a){return a}}),ConditionCollection:Backbone.Collection.extend({model:function(a,c){return new b.Models.Condition(a,c)}})},b.Views={Alert:Backbone.Epoxy.View.extend({bindings:"data-vm",tagName:"div",className:"wpca-alert",template:"<div data-vm=\"classes:{'wpca-success':success,'wpca-error':not(success)},text:text\"></div>",timer:4e3,success:function(a){this.model.set({text:a,success:!0})},failure:function(a){this.model.set({text:a,success:!1})},dismiss:function(){var a=this;this.$el.fadeOut("slow",function(){a.model.reset()})},initialize:function(){this.listenTo(this.model,"change:text",this.show),this.$el.appendTo("body").hide().html(this.template)},show:function(){if(""!==this.model.get("text")){this.$el.fadeIn("slow");var a=this;setTimeout(function(){a.dismiss()},this.timer)}}}),Condition:Backbone.Epoxy.View.extend({bindings:"data-vm",model:b.Models.Condition,tagName:"div",className:"cas-condition",templateName:"#wpca-template-condition",events:{"click .js-wpca-condition-remove":"removeModel"},initialize:function(){this.listenTo(this.model,"destroy",this.remove);var b=a(this.templateName);b.length?(this.template=b.html(),this.$el.append(this.template),this.createSuggestInput()):this.model.destroy()},removeModel:function(a){var b=this;this.$el.slideUp(300,function(){b.model.destroy()})},createSuggestInput:function(){var b=this.$el.find(".js-wpca-suggest");if(b.length){var c=this.model,e=this.model.get("values"),f=a("<div></div>").html(c.get("placeholder")).text();b.select2({more:!0,cachedResults:{},quietMillis:400,searchTimer:null,type:c.get("module"),theme:"wpca",dir:WPCA.text_direction,placeholder:f,minimumInputLength:0,closeOnSelect:!0,width:"100%",language:{noResults:function(){return WPCA.noResults},searching:function(){return WPCA.searching+"..."},loadingMore:function(){return WPCA.loadingMore+"..."}},nextSearchTerm:function(a,b){return b},templateResult:function(b){return b.level?a('<span class="wpca-level-'+b.level+'">'+b.text+"</span>"):b.text},data:e,dataAdapter:d.wpcaDataAdapter,ajax:{}}).on("select2:selecting",function(a){b.data("forceOpen",!0)}).on("select2:closing",function(a){b.data("forceOpen")&&(a.preventDefault(),b.data("forceOpen",!1))}),e.length&&b.val(_.map(e,function(a){return a.id})).trigger("change"),b.on("change",function(a){var d=b.select2("data");c.set("values",d)})}}}),Group:Backbone.Epoxy.View.extend({bindings:"data-vm",model:b.Models.Group,tagName:"li",className:"cas-group-single",template:a("#wpca-template-group").html(),itemView:function(a){if(b.Views[a.model.get("module")])var c=new(b.Views[a.model.get("module")])(a);else var c=new b.Views.Condition(a);return c},events:{"change .js-wpca-add-and":"addConditionModel","click .js-wpca-save-group":"saveGroup","click .js-wpca-options":"showOptions"},computeds:{statusNegated:{deps:["status"],get:function(a){return"negated"==a},set:function(a){var b=a?"negated":"publish";this.setBinding("status",b)}},exposureSingular:{deps:["exposure"],get:function(a){return a<=1},set:function(a){var b=this.getBinding("exposureArchive"),c=a&&b?b?1:0:2;this.setBinding("exposure",c)}},exposureArchive:{deps:["exposure"],get:function(a){return a>=1},set:function(a){var b=this.getBinding("exposureSingular"),c=a&&b?b?1:2:0;this.setBinding("exposure",c)}}},bindingFilters:{int:{get:function(a){return a?1:0},set:function(a){return a?1:0}}},initialize:function(){this.collection=this.model.conditions,this.$el.hide().html(this.template).fadeIn(300),this.listenTo(this.model,"destroy",this.remove),this.listenTo(this.model,"unsavedChanges",this.saveChanges),this.listenTo(this.model.conditions,"unsavedChanges",this.saveChanges),this.listenTo(this.model.conditions,"add remove",this.saveAddRemove)},showOptions:function(b){a(b.delegateTarget).find(".cas-group-options").slideToggle(200),a(b.currentTarget).toggleClass("active")},saveChanges:function(a,b){a?c.start(this):c.clear(this)},saveAddRemove:function(a,b,d){b.length?d.add?""!==a.get("default_value")&&c.start(this):this.model.get("id")&&c.start(this):(c.clear(this),this.model.get("id")?this.saveGroup():this.removeModel())},addConditionModel:function(c){var d=a(c.currentTarget);if(d.val()&&!this.model.conditions.findWhere({module:d.val()})){var e=d.children(":selected"),f=new b.Models.Condition({module:d.val(),label:e.text(),placeholder:e.data("placeholder"),default_value:e.data("default")});this.model.conditions.add(f)}d.val(0).blur()},removeModel:function(){var a=this;this.$el.slideUp(400,function(){a.model.destroy()})},saveGroup:function(b){var c=this.$el.find(".spinner"),e=this.$el.find(".js-wpca-save-group"),f=this;e.attr("disabled",!0),c.addClass("is-active");var g=_.clone(this.model.attributes);g.action="wpca/add-rule",g.token=d.nonce,g.current_id=d.sidebarID,g.post_type=WPCA.post_type,g.conditions={},this.model.conditions.each(function(a){a.get("values").length?g.conditions[a.get("module")]=a.get("values").map(function(a){return a.id}):""!==a.get("default_value")&&(g.conditions[a.get("module")]=[a.get("default_value")])}),a.ajax({url:ajaxurl,data:g,dataType:"JSON",type:"POST",success:function(a){d.alert.success(a.message),a.removed?f.removeModel():a.new_post_id&&f.model.set("id",a.new_post_id,{silent:!0}),a.removed||(e.hide(),c.removeClass("is-active"),f.model.restartTracking(),f.model.conditions.each(function(a){a.restartTracking()}))},error:function(a,b,f){e.attr("disabled",!1).show(),c.removeClass("is-active"),d.alert.failure(a.responseText)}})},slideRemove:function(){this.$el.slideUp(400,function(){this.remove()})}}),GroupCollection:Backbone.Epoxy.View.extend({bindings:"data-vm",el:"#cas-groups",collection:b.Models.GroupCollection,events:{"change .js-wpca-add-or":"addGroupModel","click .js-wpca-save":"saveAll"},itemView:function(a){return new b.Views.Group(a)},addGroupModel:function(c){var d=a(c.currentTarget);if(d.val()){var e=new b.Models.Group,f=d.children(":selected"),g=new b.Models.Condition({module:d.val(),label:f.text(),placeholder:f.data("placeholder"),default_value:f.data("default")});this.collection.add(e),e.conditions.add(g)}d.val(0).blur()}})},a.fn.select2.amd.require(["select2/selection/search"],function(a){a.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.$search.val(""),this.handleSearch()}},null,!0),a.fn.select2.amd.require(["select2/results"],function(a){a.prototype.ensureHighlightVisible=function(){this.$results.resize()}},null,!0),a.fn.select2.amd.define("select2/data/wpcaAdapter",["select2/data/array","select2/utils"],function(b,c){function e(a,b){e.__super__.constructor.call(this,a,b)}return c.Extend(e,b),e.prototype.query=function(b,c){b.term=b.term||"";var e=this.options.options,f=e.cachedResults[b.term],g=b.page||1;if(f&&f.page>=g){if(!(g>1))return void c({results:f.items,pagination:{more:f.more}});g=f.page}clearTimeout(e.searchTimer),e.searchTimer=setTimeout(function(){a.ajax({url:ajaxurl,data:{search:b.term,paged:g,action:"wpca/module/"+e.type,sidebar_id:d.sidebarID,nonce:d.nonce},dataType:"JSON",type:"POST",success:function(a){var d=a,h=!0;d.length<20&&(h=!1),e.cachedResults[b.term]=f?{page:g,more:h,items:e.cachedResults[b.term].items.concat(d)}:{page:g,items:d,more:h},c({results:d,pagination:{more:h}})}})},e.quietMillis)},e});var c={treshold:2e3,timerQueue:{},start:function(a){this.clear(a);var b=this;this.timerQueue[a.cid]=window.setTimeout(function(){b.set(a)},this.treshold)},set:function(a){a.saveGroup()},clear:function(a){a&&this.timerQueue[a.cid]&&window.clearInterval(this.timerQueue[a.cid])}},d={nonce:a("#_ca_nonce").val(),sidebarID:a("#post_ID").val(),alert:null,wpcaDataAdapter:a.fn.select2.amd.require("select2/data/wpcaAdapter"),init:function(){this.alert=new b.Views.Alert({model:new b.Models.Alert}),b.conditionGroups=new b.Views.GroupCollection({collection:new b.Models.GroupCollection(WPCA.groups,{parse:!0})})}};a(document).ready(function(){d.init()})}(jQuery,CAE);
4
  * @license GPLv3
5
  * @copyright 2018 by Joachim Jensen
6
  */
7
+ var CAE=CAE||{};!function(a,b){"use strict";b.settings={views:{}},b.Models={},b.Models.Alert=Backbone.Model.extend({defaults:{text:"",success:!0},sync:function(){return!1},url:"",reset:function(){this.set(this.defaults)}}),b.Models.Condition=Backbone.Model.extend({unsaved:{prompt:WPCA.unsaved,unloadWindowPrompt:!0},defaults:{module:null,label:"",placeholder:"",values:[],default_value:null},initialize:function(){this.startTracking(),this.on("destroy",this.stopTracking,this)},sync:function(){return!1},url:""}),b.Models.Group=Backbone.Model.extend({unsaved:{prompt:WPCA.unsaved,unloadWindowPrompt:!0},defaults:function(){var a=WPCA.meta_default;return a.id=null,a.status="publish",a.exposure=1,a},initialize:function(){this.startTracking(),this.on("destroy",this.stopTracking,this),this.conditions||(this.conditions=new b.Models.ConditionCollection)},parse:function(a){var c=[];if(_.has(a,"conditions")){for(var d in a.conditions)if(a.conditions.hasOwnProperty(d)){var e=[],f=a.conditions[d];for(var g in f.data)f.data.hasOwnProperty(g)&&e.push({text:f.data[g],id:g});delete f.data,f.module=d,f.values=e,c.push(f)}delete a.conditions}return this.conditions=new b.Models.ConditionCollection(c),a},sync:function(){return!1},url:""}),b.Models.GroupCollection=Backbone.Collection.extend({model:b.Models.Group,parse:function(a){return a}}),b.Models.ConditionCollection=Backbone.Collection.extend({model:b.Models.Condition}),b.Views={},b.Views.Alert=Backbone.Epoxy.View.extend({bindings:"data-vm",tagName:"div",className:"wpca-alert",template:"<div data-vm=\"classes:{'wpca-success':success,'wpca-error':not(success)},text:text\"></div>",timer:4e3,success:function(a){this.model.set({text:a,success:!0})},failure:function(a){this.model.set({text:a,success:!1})},dismiss:function(){var a=this;this.$el.fadeOut("slow",function(){a.model.reset()})},initialize:function(){this.listenTo(this.model,"change:text",this.show),this.$el.appendTo("body").hide().html(this.template)},show:function(){if(""!==this.model.get("text")){this.$el.fadeIn("slow");var a=this;setTimeout(function(){a.dismiss()},this.timer)}}}),b.Views.Condition=Backbone.Epoxy.View.extend({bindings:"data-vm",model:b.Models.Condition,tagName:"div",className:"cas-condition",templateName:"#wpca-template-condition",events:{"click .js-wpca-condition-remove":"removeModel"},initialize:function(){this.listenTo(this.model,"destroy",this.remove);var b=a(this.templateName);b.length?(this.template=b.html(),this.$el.append(this.template),this.createSuggestInput()):this.model.destroy()},removeModel:function(a){var b=this;this.$el.slideUp(300,function(){b.model.destroy()})},createSuggestInput:function(){var b=this.$el.find(".js-wpca-suggest");if(b.length){var c=this.model,e=this.model.get("values"),f=a("<div></div>").html(c.get("placeholder")).text();b.select2({cachedResults:{},quietMillis:400,searchTimer:null,type:c.get("module"),theme:"wpca",dir:WPCA.text_direction,placeholder:f,minimumInputLength:0,closeOnSelect:!0,width:"100%",language:{noResults:function(){return WPCA.noResults},searching:function(){return WPCA.searching+"..."},loadingMore:function(){return WPCA.loadingMore+"..."}},nextSearchTerm:function(a,b){return b},templateResult:function(b){return b.level?a('<span class="wpca-level-'+b.level+'">'+b.text+"</span>"):b.text},data:e,dataAdapter:d.wpcaDataAdapter,ajax:{}}).on("select2:selecting",function(a){b.data("forceOpen",!0)}).on("select2:closing",function(a){b.data("forceOpen")&&(a.preventDefault(),b.data("forceOpen",!1))}),e.length&&b.val(_.map(e,function(a){return a.id})).trigger("change"),b.on("change",function(a){var d=b.select2("data");c.set("values",d)})}}}),b.Views.Group=Backbone.Epoxy.View.extend({bindings:"data-vm",model:b.Models.Group,tagName:"li",className:"cas-group-single",template:a("#wpca-template-group").html(),itemView:function(a){if(b.Views[a.model.get("module")])var c=new(b.Views[a.model.get("module")])(a);else var c=new b.Views.Condition(a);return c},events:{"change .js-wpca-add-and":"addConditionModel","click .js-wpca-save-group":"saveGroup","click .js-wpca-options":"showOptions"},computeds:{statusNegated:{deps:["status"],get:function(a){return"negated"==a},set:function(a){var b=a?"negated":"publish";this.setBinding("status",b)}},exposureSingular:{deps:["exposure"],get:function(a){return a<=1},set:function(a){var b=this.getBinding("exposureArchive"),c=a&&b?b?1:0:2;this.setBinding("exposure",c)}},exposureArchive:{deps:["exposure"],get:function(a){return a>=1},set:function(a){var b=this.getBinding("exposureSingular"),c=a&&b?b?1:2:0;this.setBinding("exposure",c)}}},bindingFilters:{int:{get:function(a){return a?1:0},set:function(a){return a?1:0}}},initialize:function(){this.collection=this.model.conditions,this.$el.hide().html(this.template).fadeIn(300),this.listenTo(this.model,"destroy",this.remove),this.listenTo(this.model,"unsavedChanges",this.saveChanges),this.listenTo(this.model.conditions,"unsavedChanges",this.saveChanges),this.listenTo(this.model.conditions,"add remove",this.saveAddRemove)},showOptions:function(b){a(b.delegateTarget).find(".cas-group-options").slideToggle(200),a(b.currentTarget).toggleClass("active")},saveChanges:function(a,b){a?c.start(this):c.clear(this)},saveAddRemove:function(a,b,d){b.length?d.add?""!==a.get("default_value")&&c.start(this):this.model.get("id")&&c.start(this):(c.clear(this),this.model.get("id")?this.saveGroup():this.removeModel())},addConditionModel:function(c){var d=a(c.currentTarget);if(d.val()&&isNaN(d.val())&&!this.model.conditions.findWhere({module:d.val()})){var e=d.children(":selected"),f=new b.Models.Condition({module:d.val(),label:e.text(),placeholder:e.data("placeholder"),default_value:e.data("default")});this.model.conditions.add(f)}d.val(-1).blur()},removeModel:function(){var a=this;this.$el.slideUp(400,function(){a.model.destroy()})},saveGroup:function(b){var c=this.$el.find(".spinner"),e=this.$el.find(".js-wpca-save-group"),f=this;e.attr("disabled",!0),c.addClass("is-active");var g=_.clone(this.model.attributes);g.action="wpca/add-rule",g.token=d.nonce,g.current_id=d.sidebarID,g.post_type=WPCA.post_type,g.conditions={},this.model.conditions.each(function(a){a.get("values").length?g.conditions[a.get("module")]=a.get("values").map(function(a){return a.id}):""!==a.get("default_value")&&(g.conditions[a.get("module")]=[a.get("default_value")])}),a.ajax({url:ajaxurl,data:g,dataType:"JSON",type:"POST",success:function(a){d.alert.success(a.message),a.removed?f.removeModel():a.new_post_id&&f.model.set("id",a.new_post_id,{silent:!0}),a.removed||(e.hide(),c.removeClass("is-active"),f.model.restartTracking(),f.model.conditions.each(function(a){a.restartTracking()}))},error:function(a,b,f){e.attr("disabled",!1).show(),c.removeClass("is-active"),d.alert.failure(a.responseText)}})},slideRemove:function(){this.$el.slideUp(400,function(){this.remove()})}}),b.Views.GroupCollection=Backbone.Epoxy.View.extend({bindings:"data-vm",el:"#cas-groups",collection:b.Models.GroupCollection,events:{"change .js-wpca-add-or":"addGroupModel","click .js-wpca-save":"saveAll"},itemView:function(a){return new b.Views.Group(a)},addGroupModel:function(c){var d=a(c.currentTarget);if(d.val()&&isNaN(d.val())){var e=new b.Models.Group,f=d.children(":selected"),g=new b.Models.Condition({module:d.val(),label:f.text(),placeholder:f.data("placeholder"),default_value:f.data("default")});this.collection.add(e),e.conditions.add(g)}d.val(-1).blur()}}),a.fn.select2.amd.require(["select2/selection/search"],function(a){a.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.$search.val(""),this.handleSearch()}},null,!0),a.fn.select2.amd.require(["select2/results"],function(a){a.prototype.ensureHighlightVisible=function(){this.$results.resize()}},null,!0),a.fn.select2.amd.define("select2/data/wpcaAdapter",["select2/data/array","select2/utils"],function(b,c){function e(a,b){e.__super__.constructor.call(this,a,b)}return c.Extend(e,b),e.prototype.query=function(b,c){b.term=b.term||"";var e=this.options.options,f=e.cachedResults[b.term],g=b.page||1;if(f&&f.page>=g){if(!(g>1))return void c({results:f.items,pagination:{more:f.more}});g=f.page}clearTimeout(e.searchTimer),e.searchTimer=setTimeout(function(){a.ajax({url:ajaxurl,data:{search:b.term,paged:g,action:"wpca/module/"+e.type,sidebar_id:d.sidebarID,nonce:d.nonce},dataType:"JSON",type:"POST",success:function(a){var d=!(a.length<20);e.cachedResults[b.term]={page:g,more:d,items:f?e.cachedResults[b.term].items.concat(a):a},c({results:a,pagination:{more:d}})}})},e.quietMillis)},e});var c={treshold:2e3,timerQueue:{},start:function(a){this.clear(a);var b=this;this.timerQueue[a.cid]=window.setTimeout(function(){b.set(a)},this.treshold)},set:function(a){a.saveGroup()},clear:function(a){a&&this.timerQueue[a.cid]&&window.clearInterval(this.timerQueue[a.cid])}},d={nonce:a("#_ca_nonce").val(),sidebarID:a("#post_ID").val(),alert:null,wpcaDataAdapter:a.fn.select2.amd.require("select2/data/wpcaAdapter"),init:function(){this.alert=new b.Views.Alert({model:new b.Models.Alert}),b.conditionGroups=new b.Views.GroupCollection({collection:new b.Models.GroupCollection(WPCA.groups,{parse:!0})})}};a(document).ready(function(){d.init()})}(jQuery,CAE);
lib/wp-content-aware-engine/bootstrap.php CHANGED
@@ -14,7 +14,7 @@ if (!defined('ABSPATH')) {
14
  * Version of this WPCA
15
  * @var string
16
  */
17
- $this_wpca_version = '4.2.2';
18
 
19
  /**
20
  * Class to make sure the latest
14
  * Version of this WPCA
15
  * @var string
16
  */
17
+ $this_wpca_version = '4.3';
18
 
19
  /**
20
  * Class to make sure the latest
lib/wp-content-aware-engine/core.php CHANGED
@@ -440,6 +440,7 @@ if(!class_exists('WPCACore')) {
440
  foreach (self::$type_manager->get($post->post_type)->get_all() as $module) {
441
  $options = $module->list_module($options);
442
  }
 
443
  $post_type_obj = get_post_type_object($post->post_type);
444
 
445
  $template = WPCAView::make('condition_options');
@@ -447,7 +448,7 @@ if(!class_exists('WPCACore')) {
447
 
448
  $template = WPCAView::make('group_template',array(
449
  'post_type'=> $post->post_type,
450
- 'options' => apply_filters('wpca/modules/list',$options)
451
  ));
452
  add_action('admin_footer',array($template,'render'));
453
 
440
  foreach (self::$type_manager->get($post->post_type)->get_all() as $module) {
441
  $options = $module->list_module($options);
442
  }
443
+ $options = apply_filters('wpca/modules/list',$options);
444
  $post_type_obj = get_post_type_object($post->post_type);
445
 
446
  $template = WPCAView::make('condition_options');
448
 
449
  $template = WPCAView::make('group_template',array(
450
  'post_type'=> $post->post_type,
451
+ 'options' => $options
452
  ));
453
  add_action('admin_footer',array($template,'render'));
454
 
lib/wp-content-aware-engine/module/base.php CHANGED
@@ -260,7 +260,7 @@ abstract class WPCAModule_Base {
260
  //todo: fix in each module
261
  $fix_response = array();
262
  foreach ($response as $id => $title) {
263
- if(!isset($title['id'])) {
264
  $fix_response[] = array(
265
  'id' => $id,
266
  'text' => $title
260
  //todo: fix in each module
261
  $fix_response = array();
262
  foreach ($response as $id => $title) {
263
+ if(!is_array($title)) {
264
  $fix_response[] = array(
265
  'id' => $id,
266
  'text' => $title
lib/wp-content-aware-engine/module/post_type.php CHANGED
@@ -233,9 +233,20 @@ class WPCAModule_post_type extends WPCAModule_Base {
233
 
234
  if($data || isset($lookup[$post_type])) {
235
 
236
- $placeholder = $post_type_obj->has_archive ? '/'.sprintf(__('%s Archives',WPCA_DOMAIN),$post_type_obj->labels->singular_name) : '';
237
- $placeholder = $post_type == 'post' ? '/'.__('Blog Page',WPCA_DOMAIN) : $placeholder;
238
- $placeholder = $post_type_obj->labels->all_items.$placeholder;
 
 
 
 
 
 
 
 
 
 
 
239
 
240
  $group_data[$this->id.'-'.$post_type] = array(
241
  'label' => $post_type_obj->label,
@@ -322,9 +333,22 @@ class WPCAModule_post_type extends WPCAModule_Base {
322
  public function list_module($list) {
323
  foreach($this->post_types() as $post_type) {
324
  $post_type_obj = get_post_type_object($post_type);
325
- $placeholder = $post_type_obj->has_archive ? '/'.sprintf(__('%s Archives',WPCA_DOMAIN),$post_type_obj->labels->singular_name) : '';
326
- $placeholder = $post_type == 'post' ? '/'.__('Blog Page',WPCA_DOMAIN) : $placeholder;
327
- $placeholder = $post_type_obj->labels->all_items.$placeholder;
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  $list[$this->id.'-'.$post_type] = array(
329
  'name' => $post_type_obj->label,
330
  'placeholder' => $placeholder,
233
 
234
  if($data || isset($lookup[$post_type])) {
235
 
236
+ $placeholder = $post_type_obj->labels->all_items;
237
+ switch($post_type) {
238
+ case 'post':
239
+ $placeholder .= ' / '.__('Blog Page',WPCA_DOMAIN);
240
+ break;
241
+ case 'product':
242
+ $placeholder .= ' / '.__('Shop Page',WPCA_DOMAIN);
243
+ break;
244
+ default:
245
+ if($post_type_obj->has_archive) {
246
+ $placeholder .= ' / '.sprintf(__('%s Archives',WPCA_DOMAIN),$post_type_obj->labels->singular_name);
247
+ }
248
+ break;
249
+ }
250
 
251
  $group_data[$this->id.'-'.$post_type] = array(
252
  'label' => $post_type_obj->label,
333
  public function list_module($list) {
334
  foreach($this->post_types() as $post_type) {
335
  $post_type_obj = get_post_type_object($post_type);
336
+
337
+ $placeholder = $post_type_obj->labels->all_items;
338
+ switch($post_type) {
339
+ case 'post':
340
+ $placeholder .= ' / '.__('Blog Page',WPCA_DOMAIN);
341
+ break;
342
+ case 'product':
343
+ $placeholder .= ' / '.__('Shop Page',WPCA_DOMAIN);
344
+ break;
345
+ default:
346
+ if($post_type_obj->has_archive) {
347
+ $placeholder .= ' / '.sprintf(__('%s Archives',WPCA_DOMAIN),$post_type_obj->labels->singular_name);
348
+ }
349
+ break;
350
+ }
351
+
352
  $list[$this->id.'-'.$post_type] = array(
353
  'name' => $post_type_obj->label,
354
  'placeholder' => $placeholder,
lib/wp-content-aware-engine/view/condition_template.php CHANGED
@@ -14,5 +14,5 @@
14
  <div class="cas-group-input">
15
  <select class="js-wpca-suggest" multiple="multiple"></select>
16
  </div>
17
- <div class="cas-group-sep"><?php _e('And',WPCA_DOMAIN); ?></div>
18
  </script>
14
  <div class="cas-group-input">
15
  <select class="js-wpca-suggest" multiple="multiple"></select>
16
  </div>
17
+ <div class="cas-group-sep"><span><?php _e('And',WPCA_DOMAIN); ?></span></div>
18
  </script>
lib/wp-content-aware-engine/view/group_template.php CHANGED
@@ -10,13 +10,14 @@
10
  <div class="cas-group-sep" data-vm="classes:{'wpca-group-negate': statusNegated}">
11
  <span class="wpca-sep-or"><?php _e('Or',WPCA_DOMAIN); ?></span>
12
  <span class="wpca-sep-not"><?php _e('Not',WPCA_DOMAIN); ?></span>
 
13
  </div>
14
  <div class="cas-group-body">
15
  <div class="cas-group-cell">
16
  <div class="cas-content" data-vm="collection:$collection"></div>
17
  <div>
18
  <select class="js-wpca-add-and">
19
- <option value="0">-- <?php _e('Select content type',WPCA_DOMAIN); ?> --</option>
20
  <?php
21
  foreach ($options as $key => $value) {
22
  echo '<option data-placeholder="'.$value['placeholder'].'" data-default="'.$value['default_value'].'" value="'.$key.'">'.$value['name'].'</option>';
10
  <div class="cas-group-sep" data-vm="classes:{'wpca-group-negate': statusNegated}">
11
  <span class="wpca-sep-or"><?php _e('Or',WPCA_DOMAIN); ?></span>
12
  <span class="wpca-sep-not"><?php _e('Not',WPCA_DOMAIN); ?></span>
13
+ <span class="wpca-sep-or-not"><?php _e('Or not',WPCA_DOMAIN); ?></span>
14
  </div>
15
  <div class="cas-group-body">
16
  <div class="cas-group-cell">
17
  <div class="cas-content" data-vm="collection:$collection"></div>
18
  <div>
19
  <select class="js-wpca-add-and">
20
+ <option value="-1">-- <?php _e('Select content type',WPCA_DOMAIN); ?> --</option>
21
  <?php
22
  foreach ($options as $key => $value) {
23
  echo '<option data-placeholder="'.$value['placeholder'].'" data-default="'.$value['default_value'].'" value="'.$key.'">'.$value['name'].'</option>';
lib/wp-content-aware-engine/view/meta_box.php CHANGED
@@ -11,11 +11,11 @@
11
  <?php do_action('wpca/meta_box/before',$post_type); ?>
12
  <ul data-vm="collection:$collection"></ul>
13
  <div class="cas-group-sep" data-vm="toggle:length($collection)">
14
- <?php _e('Or',WPCA_DOMAIN); ?>
15
  </div>
16
  <div class="cas-group-new">
17
  <select class="js-wpca-add-or">
18
- <option value="0">-- <?php _e('Select content type',WPCA_DOMAIN); ?> --</option>
19
  <?php
20
  foreach ($options as $key => $value) {
21
  echo '<option data-placeholder="'.$value['placeholder'].'" data-default="'.$value['default_value'].'" value="'.$key.'">'.$value['name'].'</option>';
11
  <?php do_action('wpca/meta_box/before',$post_type); ?>
12
  <ul data-vm="collection:$collection"></ul>
13
  <div class="cas-group-sep" data-vm="toggle:length($collection)">
14
+ <span><?php _e('Or',WPCA_DOMAIN); ?></span>
15
  </div>
16
  <div class="cas-group-new">
17
  <select class="js-wpca-add-or">
18
+ <option value="-1">-- <?php _e('Select content type',WPCA_DOMAIN); ?> --</option>
19
  <?php
20
  foreach ($options as $key => $value) {
21
  echo '<option data-placeholder="'.$value['placeholder'].'" data-default="'.$value['default_value'].'" value="'.$key.'">'.$value['name'].'</option>';
package.json CHANGED
@@ -13,6 +13,7 @@
13
  "homepage": "https://github.com/intoxstudio/content-aware-sidebars",
14
  "devDependencies": {
15
  "gulp": "^4.0.0",
 
16
  "gulp-less": "^3.4.0",
17
  "gulp-rename": "^1.2.2",
18
  "gulp-uglify": "^3.0.0",
13
  "homepage": "https://github.com/intoxstudio/content-aware-sidebars",
14
  "devDependencies": {
15
  "gulp": "^4.0.0",
16
+ "gulp-freemius-deploy": "^1.0.10",
17
  "gulp-less": "^3.4.0",
18
  "gulp-rename": "^1.2.2",
19
  "gulp-uglify": "^3.0.0",
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: custom sidebars, sidebar, hide sidebar, display widgets, widget, bbpress,
5
  Requires at least: 4.1
6
  Requires PHP: 5.2.4
7
  Tested up to: 4.9
8
- Stable tag: 3.7.3
9
  License: GPLv3
10
 
11
  Display widget areas and custom sidebars on any post, page, category etc. Supports bbPress, BuddyPress, WooCommerce, WPML, and more.
@@ -30,9 +30,9 @@ Sidebar Visibility lets you elegantly hide any widget area for logged-out users.
30
 
31
  ####The Most User-friendly Widget Manager
32
 
33
- If you have more than just a few widgets and widget areas, you will love the Enhanced Widget Manager. When adding new widgets to sidebars, Live Search will find widgets in seconds, and the smart split-screen gives you a much better overview.
34
 
35
- 1-Click Sidebar Activation&copy; lets you activate or deactivate a widget areas instantly.
36
 
37
  ####Show or Hide Sidebars on Any Page (Yes, any)
38
 
@@ -51,7 +51,7 @@ Display your widget areas on any of these conditions:
51
  * Front Page, Search Results, 404 Not Found Page
52
  * bbPress Profiles, Forums & Topics
53
  * BuddyPress Profile Sections
54
- * Languages (qTranslate X, Polylang, Transposh, WPML)
55
  * Pods Pages
56
  * **Any Combination of Above**
57
 
@@ -161,10 +161,17 @@ Of course! Check out the links below:
161
 
162
  == Changelog ==
163
 
164
- = 3.7.3 =
165
 
166
  [View Release Notes](https://dev.institute/blog/design-insert-widget-areas-content-aware-sidebars-3-7/?utm_source=readme&utm_medium=referral&utm_content=changelog&utm_campaign=cas)
167
 
 
 
 
 
 
 
 
168
  * Updated: freemius sdk
169
 
170
  = 3.7.2 =
@@ -335,59 +342,4 @@ Fixed: url condition could in some cases not be set
335
  * Fixed: bug when adding url and date conditions
336
  * Fixed: bug with license activation if user had opted out of freemius
337
 
338
- = 3.3.3 =
339
-
340
- * Added: counter-measure against plugins that add buggy scripts
341
- * Fixed: saving sidebars in quick select would in some cases trigger warning
342
-
343
- **Pro Plan:**
344
-
345
- * Fixed: include draft sidebars when syncing widgets across themes
346
-
347
- = 3.3.2 =
348
-
349
- * Fixed: markup in quick select could in some cases be malformed
350
- * Fixed: warning when saving sidebar
351
-
352
- = 3.3.1 =
353
-
354
- * Added: ux design improvements
355
- * Added: ability to add more sidebars in quick select
356
- * Added: toggle to display more than 3 sidebar input fields in quick select
357
- * Added: select2 dropdowns updated to 4.0.3 on sidebar edit screen
358
- * Added: re-enabled info box on sidebar edit screen
359
- * Added: freemius sdk updated
360
- * Fixed: decoding of taxonomy term names in conditions
361
- * Fixed: order of content in conditions dropdowns
362
- * Fixed: yoast seo compatibility on post edit screens
363
- * Fixed: negated post conditions were included in sidebar quick select
364
- * Removed: upgrade box on sidebar edit screen
365
-
366
- **Pro Plan:**
367
-
368
- * Fixed: improved widget revision ux
369
- * Fixed: select dates would in some cases not be displayed correct in conditions
370
- * Fixed: widget revisions could in some cases contain wrong or malformed data
371
- * Fixed: backwards compat in widget revision ui for versions before wp4.5
372
-
373
- = 3.3 =
374
-
375
- * Added: manage widgets for draft sidebars
376
- * Added: quick select and create sidebars on post type editor screen
377
- * Added: ability to add widgets to draft sidebars
378
- * Added: expand/collapse all sidebars on widgets screen
379
- * Added: view sidebar status on widgets screen
380
- * Added: order sidebars by title on widgets screen
381
- * Added: dialog on unsaved condition changes in sidebar editor
382
- * Added: ux design improvements
383
- * Added: more focus on pro features, upgrade box moved to bottom
384
- * Fixed: error in wpml config (props Chouby)
385
- * Fixed: updated review notice description
386
- * Fixed: select2 dropdowns styling more robust to external changes
387
- * Fixed: minor performance improvements
388
-
389
- **Pro Plan:**
390
-
391
- * Added: set sidebars to published or draft on widgets screen
392
-
393
  See changelog.txt for previous changes.
5
  Requires at least: 4.1
6
  Requires PHP: 5.2.4
7
  Tested up to: 4.9
8
+ Stable tag: 3.7.4
9
  License: GPLv3
10
 
11
  Display widget areas and custom sidebars on any post, page, category etc. Supports bbPress, BuddyPress, WooCommerce, WPML, and more.
30
 
31
  ####The Most User-friendly Widget Manager
32
 
33
+ If you have more than just a few widgets and widget areas, you will love the Enhanced Widget Manager. When adding new widgets to sidebars, Live Search will find widgets in seconds, and the smart split-screen gives you a much better overview of your widget options.
34
 
35
+ 1-Click Sidebar Activation&copy; lets you activate or deactivate widget areas instantly.
36
 
37
  ####Show or Hide Sidebars on Any Page (Yes, any)
38
 
51
  * Front Page, Search Results, 404 Not Found Page
52
  * bbPress Profiles, Forums & Topics
53
  * BuddyPress Profile Sections
54
+ * Languages (WPML, Polylang, qTranslate X, Transposh)
55
  * Pods Pages
56
  * **Any Combination of Above**
57
 
161
 
162
  == Changelog ==
163
 
164
+ = 3.7.4 =
165
 
166
  [View Release Notes](https://dev.institute/blog/design-insert-widget-areas-content-aware-sidebars-3-7/?utm_source=readme&utm_medium=referral&utm_content=changelog&utm_campaign=cas)
167
 
168
+ * Added: UI improvements
169
+ * Fixed: some conditions could not be added on legacy php versions
170
+ * Updated: wp-content-aware-engine
171
+ * Updated: freemius sdk
172
+
173
+ = 3.7.3 =
174
+
175
  * Updated: freemius sdk
176
 
177
  = 3.7.2 =
342
  * Fixed: bug when adding url and date conditions
343
  * Fixed: bug with license activation if user had opted out of freemius
344
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
  See changelog.txt for previous changes.
view/conditions_after.php CHANGED
@@ -15,7 +15,7 @@ $url = 'https://dev.institute/wordpress-sidebars/pricing/?utm_source=plugin&utm_
15
  </div>
16
  <div style="line-height:24px;">
17
  <span class="cas-heart">❤</span>
18
- <?php printf(__('Like it? %1$sGet the Business Plan today for less than %2$s per site!%3$s','content-aware-sidebars'),'<b><a target="_blank" href="'.esc_url($url).'">','$24','</a></b>'); ?>
19
  </div>
20
  </div>
21
 
15
  </div>
16
  <div style="line-height:24px;">
17
  <span class="cas-heart">❤</span>
18
+ <?php printf(__('Like it? %1$sGet the Business Plan today for less than %2$s per site!%3$s','content-aware-sidebars'),'<b><a target="_blank" href="'.esc_url($url).'">','$20','</a></b>'); ?>
19
  </div>
20
  </div>
21
 
view/meta_box_support.php CHANGED
@@ -11,7 +11,7 @@ $locale = get_locale();
11
  <div style="overflow:hidden;">
12
  <ul>
13
  <li><a href="https://dev.institute/docs/content-aware-sidebars/getting-started/?utm_source=plugin&amp;utm_medium=referral&amp;utm_content=info-box&amp;utm_campaign=cas" target="_blank"><?php _e('Get Started','content-aware-sidebars'); ?></a></li>
14
- <li><a href="https://dev.institute/docs/content-aware-sidebars/sidebar-conditions/?utm_source=plugin&amp;utm_medium=referral&amp;utm_content=info-box&amp;utm_campaign=cas" target="_blank"><?php _e('Sidebar not displayed where expected?','content-aware-sidebars'); ?></a></li>
15
  <li><a href="https://dev.institute/docs/content-aware-sidebars/?utm_source=plugin&amp;utm_medium=referral&amp;utm_content=info-box&amp;utm_campaign=cas" target="_blank"><?php _e('Documentation & FAQ','content-aware-sidebars'); ?></a></li>
16
  <!--<li><a href="<?php echo esc_url(cas_fs()->get_upgrade_url()); ?>"><?php _e('Priority Email Support','content-aware-sidebars'); ?></a></li>-->
17
  <li><a href="https://wordpress.org/support/plugin/content-aware-sidebars/" target="_blank"><?php _e('Forum Support','content-aware-sidebars'); ?></a></li>
11
  <div style="overflow:hidden;">
12
  <ul>
13
  <li><a href="https://dev.institute/docs/content-aware-sidebars/getting-started/?utm_source=plugin&amp;utm_medium=referral&amp;utm_content=info-box&amp;utm_campaign=cas" target="_blank"><?php _e('Get Started','content-aware-sidebars'); ?></a></li>
14
+ <li><a href="https://dev.institute/docs/content-aware-sidebars/getting-started/display-sidebar-advanced/?utm_source=plugin&amp;utm_medium=referral&amp;utm_content=info-box&amp;utm_campaign=cas" target="_blank"><?php _e('Sidebar not displayed where expected?','content-aware-sidebars'); ?></a></li>
15
  <li><a href="https://dev.institute/docs/content-aware-sidebars/?utm_source=plugin&amp;utm_medium=referral&amp;utm_content=info-box&amp;utm_campaign=cas" target="_blank"><?php _e('Documentation & FAQ','content-aware-sidebars'); ?></a></li>
16
  <!--<li><a href="<?php echo esc_url(cas_fs()->get_upgrade_url()); ?>"><?php _e('Priority Email Support','content-aware-sidebars'); ?></a></li>-->
17
  <li><a href="https://wordpress.org/support/plugin/content-aware-sidebars/" target="_blank"><?php _e('Forum Support','content-aware-sidebars'); ?></a></li>