SiteOrigin Widgets Bundle - Version 1.13.0

Version Description

  • 13 September 2018 =
  • SiteOrigin Widgets Gutenberg block!
  • Google Map: Prevent script from running further if no map canvas elements found.
  • Removed style to set p margins to zero.
  • Check that fallback image for static maps is not an empty string before attempting to use it.
  • TinyMCE: Ensure target is one of the editor tabs when switching modes.
  • Set values for repeaters which are direct children of section fields.
  • Prevent unselected radio input state emitters from affecting form states, when form values are set programmatically.
  • Plugin Action Links: Check if edit link is present before removal.
  • Social Media Buttons: Added Phone and Angelist. Changed email title text.
  • Metabox manager: Set empty post meta string value to array. Ensure metabox widget form values are saved when saving drafts too.
Download this release

Release Info

Developer gpriday
Plugin Icon 128x128 SiteOrigin Widgets Bundle
Version 1.13.0
Comparing to
See all releases

Code changes from version 1.12.1 to 1.13.0

base/base.php CHANGED
@@ -12,6 +12,7 @@ include plugin_dir_path(__FILE__).'inc/attachments.php';
12
  include plugin_dir_path(__FILE__).'inc/actions.php';
13
  include plugin_dir_path(__FILE__).'inc/shortcode.php';
14
  include plugin_dir_path(__FILE__).'inc/video.php';
 
15
 
16
  /**
17
  * @param $css
12
  include plugin_dir_path(__FILE__).'inc/actions.php';
13
  include plugin_dir_path(__FILE__).'inc/shortcode.php';
14
  include plugin_dir_path(__FILE__).'inc/video.php';
15
+ include plugin_dir_path(__FILE__).'inc/routes/sowb-rest-routes.php';
16
 
17
  /**
18
  * @param $css
base/css/admin.css CHANGED
@@ -45,14 +45,14 @@
45
  .siteorigin-widget-form .siteorigin-widget-field {
46
  margin: 1em 0;
47
  }
48
- .siteorigin-widget-form .siteorigin-widget-field label {
49
  display: block;
50
  margin-bottom: 3px;
51
  }
52
- .siteorigin-widget-form .siteorigin-widget-field label.siteorigin-widget-field-label {
53
  font-weight: bold;
54
  }
55
- .siteorigin-widget-form .siteorigin-widget-field label.so-checkbox-label {
56
  -webkit-user-select: none;
57
  -moz-user-select: none;
58
  -ms-user-select: none;
@@ -591,3 +591,46 @@
591
  background-size: cover;
592
  background-image: url("img/bundle-icon.png");
593
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  .siteorigin-widget-form .siteorigin-widget-field {
46
  margin: 1em 0;
47
  }
48
+ .siteorigin-widget-form .siteorigin-widget-field > label {
49
  display: block;
50
  margin-bottom: 3px;
51
  }
52
+ .siteorigin-widget-form .siteorigin-widget-field > label.siteorigin-widget-field-label {
53
  font-weight: bold;
54
  }
55
+ .siteorigin-widget-form .siteorigin-widget-field > label.so-checkbox-label {
56
  -webkit-user-select: none;
57
  -moz-user-select: none;
58
  -ms-user-select: none;
591
  background-size: cover;
592
  background-image: url("img/bundle-icon.png");
593
  }
594
+ .widget-icon.so-widget-icon.so-gutenberg-icon {
595
+ width: 20px;
596
+ height: 20px;
597
+ display: inline-block;
598
+ }
599
+ .gutenberg__editor .so-widget-placeholder > .components-placeholder__label {
600
+ background: url("img/bundle-icon.png") no-repeat left;
601
+ background-size: 20px;
602
+ padding-left: 25px;
603
+ }
604
+ .gutenberg__editor .so-widget-placeholder > .components-placeholder__fieldset {
605
+ max-width: unset;
606
+ }
607
+ .gutenberg__editor .so-widget-placeholder > .components-placeholder__fieldset .so-widget-gutenberg-container {
608
+ width: 100%;
609
+ }
610
+ .gutenberg__editor .so-widget-placeholder > .components-placeholder__fieldset .so-widget-gutenberg-container .siteorigin-widget-form.siteorigin-widget-form-main {
611
+ min-width: unset;
612
+ }
613
+ .gutenberg__editor .siteorigin-widget-form .siteorigin-widget-field {
614
+ text-align: left;
615
+ }
616
+ .gutenberg__editor .siteorigin-widget-form .siteorigin-widget-field input {
617
+ padding: 3px 5px;
618
+ }
619
+ .gutenberg__editor .siteorigin-widget-form .siteorigin-widget-field.siteorigin-widget-field-type-autocomplete .select-content-button,
620
+ .gutenberg__editor .siteorigin-widget-form .siteorigin-widget-field.siteorigin-widget-field-type-link .select-content-button {
621
+ box-shadow: unset;
622
+ font-size: 13px;
623
+ height: 28px;
624
+ }
625
+ .gutenberg__editor .siteorigin-widget-form .siteorigin-widget-field.siteorigin-widget-field-type-icon .siteorigin-widget-icon-selector-current {
626
+ height: 37px;
627
+ }
628
+ .gutenberg__editor .siteorigin-widget-form .siteorigin-widget-field.siteorigin-widget-field-type-tinymce .wp-switch-editor {
629
+ box-sizing: content-box;
630
+ }
631
+ .gutenberg__editor .so-widget-gutenberg-preview-container .so-widgets-spinner-container {
632
+ text-align: center;
633
+ }
634
+ .gutenberg__editor .so-widget-gutenberg-preview-container .so-widgets-spinner-container > span {
635
+ display: inline-block;
636
+ }
base/inc/actions.php CHANGED
@@ -51,7 +51,6 @@ function siteorigin_widget_preview_widget_action() {
51
  <?php
52
  wp_print_scripts();
53
  wp_print_styles();
54
- siteorigin_widget_print_styles();
55
  ?>
56
  </head>
57
  <body>
51
  <?php
52
  wp_print_scripts();
53
  wp_print_styles();
 
54
  ?>
55
  </head>
56
  <body>
base/inc/fields/js/tinymce-field.js CHANGED
@@ -6,7 +6,12 @@
6
  if ( $field.data( 'initialized' ) ) {
7
  return;
8
  }
9
-
 
 
 
 
 
10
  var $container = $field.find( '.siteorigin-widget-tinymce-container' );
11
  var settings = $container.data( 'editorSettings' );
12
  var $wpautopToggleField;
@@ -20,7 +25,8 @@
20
  var setupEditor = function ( editor ) {
21
  editor.on( 'change',
22
  function () {
23
- window.tinymce.get( id ).save();
 
24
  $textarea.trigger( 'change' );
25
  }
26
  );
@@ -51,16 +57,16 @@
51
  }
52
  } );
53
 
54
- wp.editor.remove( id );
55
-
56
  // Wait for textarea to be visible before initialization.
57
  if ( $textarea.is( ':visible' ) ) {
58
- wp.editor.initialize( id, settings );
59
  }
60
  else {
61
  var intervalId = setInterval( function () {
62
  if ( $textarea.is( ':visible' ) ) {
63
- wp.editor.initialize( id, settings );
64
  clearInterval( intervalId );
65
  }
66
  }, 500);
@@ -68,11 +74,14 @@
68
 
69
  $field.on( 'click', function ( event ) {
70
  var $target = $( event.target );
 
 
 
71
  var mode = $target.hasClass( 'switch-tmce' ) ? 'tmce' : 'html';
72
  if ( mode === 'tmce' ) {
73
  var editor = window.tinymce.get( id );
74
  // Quick bit of sanitization to prevent catastrophic backtracking in TinyMCE HTML parser regex
75
- if ( $target.hasClass( 'wp-switch-editor' ) && editor !== null ) {
76
  var content = $textarea.val();
77
  if ( content.search( '<' ) !== -1 && content.search( '>' ) === -1) {
78
  content = content.replace( /</g, '' );
6
  if ( $field.data( 'initialized' ) ) {
7
  return;
8
  }
9
+
10
+ var inGutenberg = $( 'body' ).is( '.gutenberg-editor-page' );
11
+ var wpEditor = inGutenberg ? wp.oldEditor : wp.editor;
12
+ wp.editor.autop = wpEditor.autop;
13
+ wp.editor.removep = wpEditor.removep;
14
+
15
  var $container = $field.find( '.siteorigin-widget-tinymce-container' );
16
  var settings = $container.data( 'editorSettings' );
17
  var $wpautopToggleField;
25
  var setupEditor = function ( editor ) {
26
  editor.on( 'change',
27
  function () {
28
+ var ed = window.tinymce.get( id );
29
+ ed.save();
30
  $textarea.trigger( 'change' );
31
  }
32
  );
57
  }
58
  } );
59
 
60
+ wpEditor.remove( id );
61
+ window.tinymce.EditorManager.overrideDefaults( { base_url: settings.baseURL, suffix: settings.suffix } );
62
  // Wait for textarea to be visible before initialization.
63
  if ( $textarea.is( ':visible' ) ) {
64
+ wpEditor.initialize( id, settings );
65
  }
66
  else {
67
  var intervalId = setInterval( function () {
68
  if ( $textarea.is( ':visible' ) ) {
69
+ wpEditor.initialize( id, settings );
70
  clearInterval( intervalId );
71
  }
72
  }, 500);
74
 
75
  $field.on( 'click', function ( event ) {
76
  var $target = $( event.target );
77
+ if ( ! $target.is( 'wp-switch-editor' ) ) {
78
+ return;
79
+ }
80
  var mode = $target.hasClass( 'switch-tmce' ) ? 'tmce' : 'html';
81
  if ( mode === 'tmce' ) {
82
  var editor = window.tinymce.get( id );
83
  // Quick bit of sanitization to prevent catastrophic backtracking in TinyMCE HTML parser regex
84
+ if ( editor !== null ) {
85
  var content = $textarea.val();
86
  if ( content.search( '<' ) !== -1 && content.search( '>' ) === -1) {
87
  content = content.replace( /</g, '' );
base/inc/fields/js/tinymce-field.min.js CHANGED
@@ -1 +1 @@
1
- !function(i){var e=function(e){if(!e.data("initialized")){var t,n=e.find(".siteorigin-widget-tinymce-container"),o=n.data("editorSettings");if(o.wpautopToggleField){var r=n.closest(".siteorigin-widget-form");t=r.find(o.wpautopToggleField),o.tinymce.wpautop=t.is(":checked")}var d=n.find("textarea"),s=d.attr("id"),a=function(i){i.on("change",function(){window.tinymce.get(s).save(),d.trigger("change")}),t&&(t.off("change"),t.on("change",function(){wp.editor.remove(s),o.tinymce.wpautop=t.is(":checked"),wp.editor.initialize(s,o)}))};if(o.tinymce&&(o.tinymce=i.extend({},o.tinymce,{selector:"#"+s,setup:a})),i(document).on("wp-before-tinymce-init",function(i,t){if(t.selector===o.tinymce.selector){var r=n.data("mediaButtons");e.find(".wp-editor-tabs").before(r.html)}}),i(document).on("tinymce-editor-setup",function(){e.find(".wp-editor-wrap").hasClass(o.selectedEditor+"-active")||setTimeout(function(){window.switchEditors.go(s)},10)}),wp.editor.remove(s),d.is(":visible"))wp.editor.initialize(s,o);else var c=setInterval(function(){d.is(":visible")&&(wp.editor.initialize(s,o),clearInterval(c))},500);e.on("click",function(t){var n=i(t.target),r=n.hasClass("switch-tmce")?"tmce":"html";if("tmce"===r){var a=window.tinymce.get(s);if(n.hasClass("wp-switch-editor")&&null!==a){var c=d.val();-1!==c.search("<")&&-1===c.search(">")&&(c=c.replace(/</g,""),d.val(c)),a.setContent(window.switchEditors.wpautop(c))}}o.selectedEditor=r,e.find(".siteorigin-widget-tinymce-selected-editor").val(r)}),e.data("initialized",!0)}};i(document).on("sowsetupformfield",".siteorigin-widget-field-type-tinymce",function(){var t=i(this),n=t.closest(".siteorigin-widget-field-repeater-item-form");n.length>0?n.is(":visible")?e(t):n.on("slideToggleOpenComplete",function(){n.is(":visible")&&(e(t),n.off("slideToggleOpenComplete"))}):e(t)}),i(document).on("sortstop",function(t,n){var o;o=n.item.is(".siteorigin-widget-field-repeater-item")?n.item.find("> .siteorigin-widget-field-repeater-item-form"):n.item.find(".siteorigin-widget-form"),o.find(".siteorigin-widget-field-type-tinymce").each(function(){i(this).data("initialized",null),e(i(this))})})}(jQuery);
1
+ !function(i){var e=function(e){if(!e.data("initialized")){var t=i("body").is(".gutenberg-editor-page"),n=t?wp.oldEditor:wp.editor;wp.editor.autop=n.autop,wp.editor.removep=n.removep;var o,r=e.find(".siteorigin-widget-tinymce-container"),d=r.data("editorSettings");if(d.wpautopToggleField){var a=r.closest(".siteorigin-widget-form");o=a.find(d.wpautopToggleField),d.tinymce.wpautop=o.is(":checked")}var s=r.find("textarea"),c=s.attr("id"),l=function(i){i.on("change",function(){window.tinymce.get(c).save(),s.trigger("change")}),o&&(o.off("change"),o.on("change",function(){wp.editor.remove(c),d.tinymce.wpautop=o.is(":checked"),wp.editor.initialize(c,d)}))};if(d.tinymce&&(d.tinymce=i.extend({},d.tinymce,{selector:"#"+c,setup:l})),i(document).on("wp-before-tinymce-init",function(i,t){if(t.selector===d.tinymce.selector){var n=r.data("mediaButtons");e.find(".wp-editor-tabs").before(n.html)}}),i(document).on("tinymce-editor-setup",function(){e.find(".wp-editor-wrap").hasClass(d.selectedEditor+"-active")||setTimeout(function(){window.switchEditors.go(c)},10)}),n.remove(c),window.tinymce.EditorManager.overrideDefaults({base_url:d.baseURL,suffix:d.suffix}),s.is(":visible"))n.initialize(c,d);else var f=setInterval(function(){s.is(":visible")&&(n.initialize(c,d),clearInterval(f))},500);e.on("click",function(t){var n=i(t.target);if(n.is("wp-switch-editor")){var o=n.hasClass("switch-tmce")?"tmce":"html";if("tmce"===o){var r=window.tinymce.get(c);if(null!==r){var a=s.val();-1!==a.search("<")&&-1===a.search(">")&&(a=a.replace(/</g,""),s.val(a)),r.setContent(window.switchEditors.wpautop(a))}}d.selectedEditor=o,e.find(".siteorigin-widget-tinymce-selected-editor").val(o)}}),e.data("initialized",!0)}};i(document).on("sowsetupformfield",".siteorigin-widget-field-type-tinymce",function(){var t=i(this),n=t.closest(".siteorigin-widget-field-repeater-item-form");n.length>0?n.is(":visible")?e(t):n.on("slideToggleOpenComplete",function(){n.is(":visible")&&(e(t),n.off("slideToggleOpenComplete"))}):e(t)}),i(document).on("sortstop",function(t,n){var o;o=n.item.is(".siteorigin-widget-field-repeater-item")?n.item.find("> .siteorigin-widget-field-repeater-item-form"):n.item.find(".siteorigin-widget-form"),o.find(".siteorigin-widget-field-type-tinymce").each(function(){i(this).data("initialized",null),e(i(this))})})}(jQuery);
base/inc/fields/tinymce.class.php CHANGED
@@ -415,6 +415,12 @@ class SiteOrigin_Widget_Field_TinyMCE extends SiteOrigin_Widget_Field_Text_Input
415
  $value = preg_replace( '%</textarea%i', '&lt;/textarea', $value );
416
  }
417
 
 
 
 
 
 
 
418
  ?><div class="siteorigin-widget-tinymce-container"
419
  <?php if ( ! empty( $media_buttons ) ) : ?>
420
  data-media-buttons="<?php echo esc_attr( json_encode( array( 'html' => $media_buttons ) ) ) ?>"
415
  $value = preg_replace( '%</textarea%i', '&lt;/textarea', $value );
416
  }
417
 
418
+
419
+ $media_buttons = $this->render_media_buttons( $this->element_id );
420
+
421
+ $settings['baseURL'] = includes_url( 'js/tinymce' );
422
+ $settings['suffix'] = SCRIPT_DEBUG ? '' : '.min';
423
+
424
  ?><div class="siteorigin-widget-tinymce-container"
425
  <?php if ( ! empty( $media_buttons ) ) : ?>
426
  data-media-buttons="<?php echo esc_attr( json_encode( array( 'html' => $media_buttons ) ) ) ?>"
base/inc/meta-box-manager.php CHANGED
@@ -1,169 +1,172 @@
1
- <?php
2
-
3
- class SiteOrigin_Widget_Meta_Box_Manager extends SiteOrigin_Widget {
4
-
5
- const POST_META_KEY = 'siteorigin-widgets-post-meta';
6
-
7
- /**
8
- * @var array Fields which have been added for each widget.
9
- */
10
- private $widget_form_fields;
11
-
12
- /**
13
- * @var array Post types for which fields have been added.
14
- */
15
- private $post_types;
16
-
17
- /**
18
- * Get the single instance.
19
- *
20
- * @return SiteOrigin_Widget_Meta_Box_Manager
21
- */
22
- static function single(){
23
- static $single = false;
24
- if( empty($single) ) $single = new SiteOrigin_Widget_Meta_Box_Manager();
25
-
26
- return $single;
27
- }
28
-
29
- /**
30
- * Private
31
- */
32
- public function __construct() {
33
- parent::__construct(
34
- 'sow-meta-box-manager',
35
- __('SiteOrigin Meta Box Manager', 'so-widgets-bundle'),
36
- array(
37
- 'has_preview' => false,
38
- 'help' => false
39
- ),
40
- array(),
41
- array()
42
- );
43
- }
44
-
45
- function initialize() {
46
- // Initialize number for field name attributes.
47
- $this->number = 1;
48
- $this->post_types = array();
49
- $this->widget_form_fields = array();
50
-
51
- add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
52
- add_action( 'save_post', array( $this, 'save_widget_post_meta' ), 10, 3 );
53
- }
54
-
55
- /**
56
- * This handles the 'add_meta_boxes' action. It merges widget fields into the form_options array before adding the
57
- * meta box
58
- *
59
- * @param $post_type
60
- */
61
- public function add_meta_boxes( $post_type ) {
62
-
63
- $this->form_options = array();
64
- foreach ( $this->widget_form_fields as $widget_id => $post_type_form_fields ) {
65
- foreach( $post_type_form_fields as $form_fields ) {
66
- if ( in_array( 'all', $form_fields['post_types'] ) || in_array( $post_type, $form_fields['post_types'] ) ) {
67
- foreach ( $form_fields['fields'] as $field_name => $field ) {
68
- $this->form_options[$widget_id . '_' . $field_name] = $field;
69
- }
70
- }
71
- }
72
- }
73
-
74
- if ( ! empty( $this->form_options ) ) {
75
- add_meta_box(
76
- 'siteorigin-widgets-meta-box',
77
- __( 'Widgets Bundle Post Meta Data', 'so-widgets-bundle' ),
78
- array( $this, 'render_widgets_meta_box' ),
79
- $post_type,
80
- 'advanced'
81
- );
82
-
83
- }
84
- }
85
-
86
- /**
87
- * This is the callback used by add_meta_box to render the widgets meta box form and enqueue any necessary scripts.
88
- *
89
- * @param $post
90
- */
91
- public function render_widgets_meta_box( $post ) {
92
- wp_enqueue_script(
93
- 'sow-meta-box-manager-js',
94
- plugin_dir_url(SOW_BUNDLE_BASE_FILE).'base/js/meta-box-manager' . SOW_BUNDLE_JS_SUFFIX . '.js',
95
- array( 'jquery' ),
96
- SOW_BUNDLE_VERSION,
97
- true
98
- );
99
- $widget_post_meta = get_post_meta( $post->ID, self::POST_META_KEY, true );
100
- $this->form( $widget_post_meta );
101
- ?><input type="hidden" id="widget_post_meta" name="widget_post_meta"> <?php
102
- wp_nonce_field( 'widget_post_meta_save', '_widget_post_meta_nonce' );
103
- }
104
-
105
- /**
106
- * This method should be called by any widgets that want to be able to store post meta data. It may be called
107
- * multiple times by a widget and the additional fields for a widget will be appended and rendered.
108
- *
109
- * @param string $widget_id Base id of the widget adding the fields.
110
- * @param array $fields The fields to add.
111
- * @param string|array $post_types A post type string, 'all' or an array of post types
112
- */
113
- public function append_to_form( $widget_id, $fields, $post_types = 'all' ) {
114
- if( empty( $fields ) || empty( $post_types ) ) return;
115
-
116
- if( $post_types == 'all' ) {
117
- $post_types = array( 'all' );
118
- }
119
-
120
- foreach( $post_types as $post_type ) {
121
- if( !in_array( $post_type, $this->post_types ) ) {
122
- $this->post_types[] = $post_type;
123
- }
124
- }
125
-
126
- if( ! isset( $this->widget_form_fields[$widget_id] ) ) {
127
- $this->widget_form_fields[$widget_id] = array();
128
- }
129
-
130
- $this->widget_form_fields[$widget_id][] = array(
131
- 'post_types' => $post_types,
132
- 'fields' => $fields
133
- );
134
- }
135
-
136
- /**
137
- * This handles the 'save_post' action. It checks for a nonce, checks user permissions, and filters the input data
138
- * and decodes it from the JSON format before storing it in the post's meta data.
139
- *
140
- * @param $post_id
141
- */
142
- public function save_widget_post_meta( $post_id ) {
143
- if ( empty( $_POST['_widget_post_meta_nonce'] ) || !wp_verify_nonce( $_POST['_widget_post_meta_nonce'], 'widget_post_meta_save' ) ) return;
144
- if ( !current_user_can( 'edit_post', $post_id ) ) return;
145
-
146
- $widget_post_meta = isset( $_POST['widget_post_meta'] ) ? stripslashes_deep( $_POST['widget_post_meta'] ) : '';
147
- $widget_post_meta = json_decode( $widget_post_meta, true);
148
-
149
- update_post_meta( $post_id, self::POST_META_KEY, $widget_post_meta );
150
-
151
- }
152
-
153
- /**
154
- * This function is used to retrieve a widget's post meta data.
155
- *
156
- * @param $post_id string The id of the post for which the meta data is stored.
157
- * @param $widget_id string The id of the widget for which the meta data is stored.
158
- * @param $meta_key string The key of the meta data value which is to be retrieved.
159
- *
160
- * @return mixed An empty string if the meta data is not found, else the meta data in whatever format it was stored.
161
- */
162
- public function get_widget_post_meta( $post_id, $widget_id, $meta_key ) {
163
- $widget_post_meta = get_post_meta( $post_id, self::POST_META_KEY, true );
164
- if( empty( $widget_post_meta ) ) return '';
165
- $widget_post_meta_field = $widget_id . '_' . $meta_key;
166
- if( ! isset( $widget_post_meta[$widget_post_meta_field] ) ) return '';
167
- return $widget_post_meta[$widget_post_meta_field];
168
- }
169
- }
 
 
 
1
+ <?php
2
+
3
+ class SiteOrigin_Widget_Meta_Box_Manager extends SiteOrigin_Widget {
4
+
5
+ const POST_META_KEY = 'siteorigin-widgets-post-meta';
6
+
7
+ /**
8
+ * @var array Fields which have been added for each widget.
9
+ */
10
+ private $widget_form_fields;
11
+
12
+ /**
13
+ * @var array Post types for which fields have been added.
14
+ */
15
+ private $post_types;
16
+
17
+ /**
18
+ * Get the single instance.
19
+ *
20
+ * @return SiteOrigin_Widget_Meta_Box_Manager
21
+ */
22
+ static function single(){
23
+ static $single = false;
24
+ if( empty($single) ) $single = new SiteOrigin_Widget_Meta_Box_Manager();
25
+
26
+ return $single;
27
+ }
28
+
29
+ /**
30
+ * Private
31
+ */
32
+ public function __construct() {
33
+ parent::__construct(
34
+ 'sow-meta-box-manager',
35
+ __('SiteOrigin Meta Box Manager', 'so-widgets-bundle'),
36
+ array(
37
+ 'has_preview' => false,
38
+ 'help' => false
39
+ ),
40
+ array(),
41
+ array()
42
+ );
43
+ }
44
+
45
+ function initialize() {
46
+ // Initialize number for field name attributes.
47
+ $this->number = 1;
48
+ $this->post_types = array();
49
+ $this->widget_form_fields = array();
50
+
51
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
52
+ add_action( 'save_post', array( $this, 'save_widget_post_meta' ), 10, 3 );
53
+ }
54
+
55
+ /**
56
+ * This handles the 'add_meta_boxes' action. It merges widget fields into the form_options array before adding the
57
+ * meta box
58
+ *
59
+ * @param $post_type
60
+ */
61
+ public function add_meta_boxes( $post_type ) {
62
+
63
+ $this->form_options = array();
64
+ foreach ( $this->widget_form_fields as $widget_id => $post_type_form_fields ) {
65
+ foreach( $post_type_form_fields as $form_fields ) {
66
+ if ( in_array( 'all', $form_fields['post_types'] ) || in_array( $post_type, $form_fields['post_types'] ) ) {
67
+ foreach ( $form_fields['fields'] as $field_name => $field ) {
68
+ $this->form_options[$widget_id . '_' . $field_name] = $field;
69
+ }
70
+ }
71
+ }
72
+ }
73
+
74
+ if ( ! empty( $this->form_options ) ) {
75
+ add_meta_box(
76
+ 'siteorigin-widgets-meta-box',
77
+ __( 'Widgets Bundle Post Meta Data', 'so-widgets-bundle' ),
78
+ array( $this, 'render_widgets_meta_box' ),
79
+ $post_type,
80
+ 'advanced'
81
+ );
82
+
83
+ }
84
+ }
85
+
86
+ /**
87
+ * This is the callback used by add_meta_box to render the widgets meta box form and enqueue any necessary scripts.
88
+ *
89
+ * @param $post
90
+ */
91
+ public function render_widgets_meta_box( $post ) {
92
+ wp_enqueue_script(
93
+ 'sow-meta-box-manager-js',
94
+ plugin_dir_url(SOW_BUNDLE_BASE_FILE).'base/js/meta-box-manager' . SOW_BUNDLE_JS_SUFFIX . '.js',
95
+ array( 'jquery' ),
96
+ SOW_BUNDLE_VERSION,
97
+ true
98
+ );
99
+ $widget_post_meta = get_post_meta( $post->ID, self::POST_META_KEY, true );
100
+ if ( empty( $widget_post_meta ) ) {
101
+ $widget_post_meta = array();
102
+ }
103
+ $this->form( $widget_post_meta );
104
+ ?><input type="hidden" id="widget_post_meta" name="widget_post_meta"> <?php
105
+ wp_nonce_field( 'widget_post_meta_save', '_widget_post_meta_nonce' );
106
+ }
107
+
108
+ /**
109
+ * This method should be called by any widgets that want to be able to store post meta data. It may be called
110
+ * multiple times by a widget and the additional fields for a widget will be appended and rendered.
111
+ *
112
+ * @param string $widget_id Base id of the widget adding the fields.
113
+ * @param array $fields The fields to add.
114
+ * @param string|array $post_types A post type string, 'all' or an array of post types
115
+ */
116
+ public function append_to_form( $widget_id, $fields, $post_types = 'all' ) {
117
+ if( empty( $fields ) || empty( $post_types ) ) return;
118
+
119
+ if( $post_types == 'all' ) {
120
+ $post_types = array( 'all' );
121
+ }
122
+
123
+ foreach( $post_types as $post_type ) {
124
+ if( !in_array( $post_type, $this->post_types ) ) {
125
+ $this->post_types[] = $post_type;
126
+ }
127
+ }
128
+
129
+ if( ! isset( $this->widget_form_fields[$widget_id] ) ) {
130
+ $this->widget_form_fields[$widget_id] = array();
131
+ }
132
+
133
+ $this->widget_form_fields[$widget_id][] = array(
134
+ 'post_types' => $post_types,
135
+ 'fields' => $fields
136
+ );
137
+ }
138
+
139
+ /**
140
+ * This handles the 'save_post' action. It checks for a nonce, checks user permissions, and filters the input data
141
+ * and decodes it from the JSON format before storing it in the post's meta data.
142
+ *
143
+ * @param $post_id
144
+ */
145
+ public function save_widget_post_meta( $post_id ) {
146
+ if ( empty( $_POST['_widget_post_meta_nonce'] ) || !wp_verify_nonce( $_POST['_widget_post_meta_nonce'], 'widget_post_meta_save' ) ) return;
147
+ if ( !current_user_can( 'edit_post', $post_id ) ) return;
148
+
149
+ $widget_post_meta = isset( $_POST['widget_post_meta'] ) ? stripslashes_deep( $_POST['widget_post_meta'] ) : '';
150
+ $widget_post_meta = json_decode( $widget_post_meta, true);
151
+
152
+ update_post_meta( $post_id, self::POST_META_KEY, $widget_post_meta );
153
+
154
+ }
155
+
156
+ /**
157
+ * This function is used to retrieve a widget's post meta data.
158
+ *
159
+ * @param $post_id string The id of the post for which the meta data is stored.
160
+ * @param $widget_id string The id of the widget for which the meta data is stored.
161
+ * @param $meta_key string The key of the meta data value which is to be retrieved.
162
+ *
163
+ * @return mixed An empty string if the meta data is not found, else the meta data in whatever format it was stored.
164
+ */
165
+ public function get_widget_post_meta( $post_id, $widget_id, $meta_key ) {
166
+ $widget_post_meta = get_post_meta( $post_id, self::POST_META_KEY, true );
167
+ if( empty( $widget_post_meta ) ) return '';
168
+ $widget_post_meta_field = $widget_id . '_' . $meta_key;
169
+ if( ! isset( $widget_post_meta[$widget_post_meta_field] ) ) return '';
170
+ return $widget_post_meta[$widget_post_meta_field];
171
+ }
172
+ }
base/inc/routes/siteorigin-widgets-resource.class.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Resource for SiteOrigin widgets.
4
+ */
5
+
6
+ class SiteOrigin_Widgets_Resource extends WP_REST_Controller {
7
+
8
+ /**
9
+ * @var SiteOrigin_Widgets_Widget_Manager
10
+ */
11
+ private $widgets_manager;
12
+
13
+ public function __construct() {
14
+ $this->widgets_manager = SiteOrigin_Widgets_Widget_Manager::single();
15
+ }
16
+
17
+ public function register_routes() {
18
+ $version = '1';
19
+ $namespace = 'sowb/v' . $version;
20
+ $resource = 'widgets';
21
+
22
+ register_rest_route( $namespace, '/' . $resource, array(
23
+ 'methods' => WP_REST_Server::READABLE,
24
+ 'callback' => array( $this, 'get_widgets'),
25
+ 'permission_callback' => array( $this, 'permissions_check' ),
26
+ ) );
27
+
28
+ $subresource = 'forms';
29
+ register_rest_route( $namespace, '/' . $resource . '/' . $subresource, array(
30
+ 'methods' => WP_REST_Server::READABLE,
31
+ 'callback' => array( $this, 'get_widget_form'),
32
+ 'args' => array(
33
+ 'widgetClass' => array(
34
+ 'validate_callback' => array( $this, 'validate_widget_class'),
35
+ ),
36
+ ),
37
+ 'permission_callback' => array( $this, 'permissions_check' ),
38
+ ) );
39
+
40
+ $subresource = 'previews';
41
+ register_rest_route( $namespace, '/' . $resource . '/' . $subresource, array(
42
+ 'methods' => WP_REST_Server::READABLE,
43
+ 'callback' => array( $this, 'get_widget_preview'),
44
+ 'args' => array(
45
+ 'widgetClass' => array(
46
+ 'validate_callback' => array( $this, 'validate_widget_class'),
47
+ ),
48
+ 'widgetData' => array(
49
+ 'validate_callback' => array( $this, 'validate_widget_data'),
50
+ ),
51
+ ),
52
+ 'permission_callback' => array( $this, 'permissions_check' ),
53
+ ) );
54
+ }
55
+
56
+ /**
57
+ * Get the collection of widgets.
58
+ *
59
+ * @param WP_REST_Request $request
60
+ *
61
+ * @return WP_Error|WP_REST_Response
62
+ */
63
+ public function get_widgets( $request ) {
64
+ global $wp_widget_factory;
65
+ $so_widgets = array();
66
+ foreach ( $wp_widget_factory->widgets as $class => $widget_obj ) {
67
+ if ( ! empty( $widget_obj ) && is_object( $widget_obj ) && is_subclass_of( $widget_obj, 'SiteOrigin_Widget' ) ) {
68
+ $so_widgets[] = array(
69
+ 'name' => preg_replace( '/^SiteOrigin /', '', $widget_obj->name ),
70
+ 'class' => $class,
71
+ );
72
+ }
73
+ }
74
+
75
+ return rest_ensure_response( $so_widgets );
76
+ }
77
+
78
+ /**
79
+ *
80
+ * @param WP_REST_Request $request Request.
81
+ * @return true|WP_Error True if the request has read access, WP_Error object otherwise.
82
+ */
83
+ public function permissions_check( $request ) {
84
+
85
+ if ( ! current_user_can( 'edit_posts' ) ) {
86
+ $status_code = rest_authorization_required_code();
87
+ return new WP_Error(
88
+ $status_code,
89
+ __( '', 'so-widgets-bundle' ),
90
+ array(
91
+ 'status' => $status_code,
92
+ )
93
+ );
94
+ }
95
+
96
+ return true;
97
+ }
98
+
99
+ /**
100
+ * Validate passed in widgetClass arg only contains alphanumeric and underscores.
101
+ *
102
+ * @param $param
103
+ * @param $request
104
+ * @param $key
105
+ *
106
+ * @return bool
107
+ */
108
+ function validate_widget_class( $param, $request, $key ) {
109
+ return preg_match( '/\w+/', $param ) == 1;
110
+ }
111
+
112
+ /**
113
+ * Get the collection of widgets.
114
+ *
115
+ * @param WP_REST_Request $request
116
+ *
117
+ * @return WP_Error|WP_REST_Response
118
+ */
119
+ public function get_widget_form( $request ) {
120
+ $widget_class = $request['widgetClass'];
121
+
122
+ global $wp_widget_factory;
123
+
124
+ $widget = ! empty( $wp_widget_factory->widgets[ $widget_class ] ) ? $wp_widget_factory->widgets[ $widget_class ] : false;
125
+
126
+ if ( ! empty( $widget ) && is_object( $widget ) && is_subclass_of( $widget, 'SiteOrigin_Widget' ) ) {
127
+ ob_start();
128
+ /* @var $widget SiteOrigin_Widget */
129
+ $widget->form( array() );
130
+ $widget_form = ob_get_clean();
131
+ } else {
132
+ $widget_form = new WP_Error( '', 'Invalid widget class.' );
133
+ }
134
+
135
+ return rest_ensure_response( $widget_form );
136
+ }
137
+
138
+ /**
139
+ * For now widget data is validated in the below `get_widget_preview` function.
140
+ * Leaving this here for possible later implementation.
141
+ *
142
+ * @param $param
143
+ * @param $request
144
+ * @param $key
145
+ *
146
+ * @return bool
147
+ */
148
+ function validate_widget_data( $param, $request, $key ) {
149
+ return true;
150
+ }
151
+
152
+ /**
153
+ * Get the collection of widgets.
154
+ *
155
+ * @param WP_REST_Request $request
156
+ *
157
+ * @return WP_Error|WP_REST_Response
158
+ */
159
+ public function get_widget_preview( $request ) {
160
+ $widget_class = $request['widgetClass'];
161
+ $widget_data = $request['widgetData'];
162
+
163
+ global $wp_widget_factory;
164
+
165
+ $widget = ! empty( $wp_widget_factory->widgets[ $widget_class ] ) ? $wp_widget_factory->widgets[ $widget_class ] : false;
166
+ // This ensures styles are added inline.
167
+ add_filter( 'siteorigin_widgets_is_preview', '__return_true' );
168
+
169
+ if ( ! empty( $widget ) && is_object( $widget ) && is_subclass_of( $widget, 'SiteOrigin_Widget' ) ) {
170
+ ob_start();
171
+ /* @var $widget SiteOrigin_Widget */
172
+ $instance = $widget->update( $widget_data, $widget_data );
173
+ $widget->widget( array(), $instance );
174
+ $rendered_widget = ob_get_clean();
175
+ } else {
176
+ $rendered_widget = new WP_Error( '', 'Invalid widget class.' );
177
+ }
178
+
179
+ return rest_ensure_response( $rendered_widget );
180
+ }
181
+ }
base/inc/routes/sowb-rest-routes.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Handles registering Widgets Bundle custom REST endpoints.
5
+ *
6
+ * Class SiteOrigin_Widgets_Rest_Routes
7
+ */
8
+
9
+ class SiteOrigin_Widgets_Rest_Routes {
10
+
11
+ function __construct() {
12
+
13
+ global $wp_version;
14
+ if ( version_compare( $wp_version, '4.7', '>=' ) && class_exists( 'WP_REST_Controller' ) ) {
15
+ include plugin_dir_path(__FILE__).'siteorigin-widgets-resource.class.php';
16
+ add_action( 'rest_api_init', array( $this, 'register_rest_routes') );
17
+ }
18
+ }
19
+
20
+ /**
21
+ * Singleton
22
+ *
23
+ * @return SiteOrigin_Widgets_Rest_Routes
24
+ */
25
+ static function single() {
26
+ static $single;
27
+
28
+ if( empty($single) ) {
29
+ $single = new self();
30
+ }
31
+
32
+ return $single;
33
+ }
34
+
35
+ /**
36
+ * Register all our REST resources.
37
+ */
38
+ function register_rest_routes() {
39
+ $resources = array(
40
+ new SiteOrigin_Widgets_Resource(),
41
+ );
42
+
43
+ foreach ( $resources as $resource ) {
44
+ /* @var WP_REST_Controller $resource */
45
+ $resource->register_routes();
46
+ }
47
+ }
48
+
49
+ }
50
+ SiteOrigin_Widgets_Rest_Routes::single();
base/inc/widget-manager.class.php CHANGED
@@ -122,6 +122,15 @@ class SiteOrigin_Widgets_Widget_Manager {
122
  }
123
  return false;
124
  }
 
 
 
 
 
 
 
 
 
125
  }
126
  SiteOrigin_Widgets_Widget_Manager::single();
127
 
122
  }
123
  return false;
124
  }
125
+
126
+ /**
127
+ * Get the list of registered widgets.
128
+ *
129
+ * @return array
130
+ */
131
+ function get_registered_widgets() {
132
+ return $this->registered;
133
+ }
134
  }
135
  SiteOrigin_Widgets_Widget_Manager::single();
136
 
base/js/admin.js CHANGED
@@ -166,43 +166,45 @@ var sowbForms = window.sowbForms || {};
166
  $teaser.remove();
167
  });
168
  });
169
-
170
- var _sow_form_id = $el.find( '> .siteorigin-widgets-form-id' ).val();
171
- var $timestampField = $el.find( '> .siteorigin-widgets-form-timestamp' );
172
- var _sow_form_timestamp = parseInt( $timestampField.val() || 0 );
173
- var data = JSON.parse( sessionStorage.getItem( _sow_form_id ) );
174
- if ( data ) {
175
- if ( data['_sow_form_timestamp'] > _sow_form_timestamp ) {
176
- var $newerNotification = $( '<div class="siteorigin-widget-form-notification">' +
177
- '<span>' + soWidgets.backup.newerVersion + '</span>' +
178
- '<a class="button button-small so-backup-restore">' + soWidgets.backup.restore + '</a>' +
179
- '<a class="button button-small so-backup-dismiss">' + soWidgets.backup.dismiss + '</a>' +
180
- '<div><small>' + soWidgets.backup.replaceWarning + '</small></div>' +
181
- '</div>' );
182
- $el.prepend( $newerNotification );
183
-
184
- $newerNotification.find( '.so-backup-restore' ).click( function () {
185
- sowbForms.setWidgetFormValues( $mainForm, data );
186
- $newerNotification.slideUp( 'fast', function () {
187
- $newerNotification.remove();
 
 
 
188
  } );
189
- } );
190
- $newerNotification.find( '.so-backup-dismiss' ).click( function () {
191
- $newerNotification.slideUp( 'fast', function () {
192
- sessionStorage.removeItem( _sow_form_id );
193
- $newerNotification.remove();
194
  } );
195
- } );
196
- } else {
197
- sessionStorage.removeItem( _sow_form_id );
198
  }
 
 
 
 
 
199
  }
200
-
201
- $el.change( function () {
202
- $timestampField.val( new Date().getTime() );
203
- var data = sowbForms.getWidgetFormValues( $el );
204
- sessionStorage.setItem( _sow_form_id, JSON.stringify( data ) );
205
- } );
206
  }
207
  else {
208
  $mainForm = $el.closest('.siteorigin-widget-form-main');
@@ -355,6 +357,7 @@ var sowbForms = window.sowbForms || {};
355
  e.preventDefault();
356
  var $li = $(this);
357
  $$.find('input.siteorigin-widget-input').val('post: ' + $li.data('value'));
 
358
  $$.find('.existing-content-selector').toggle();
359
  });
360
 
@@ -396,6 +399,11 @@ var sowbForms = window.sowbForms || {};
396
  // Skip if the function doesn't exist, or it starts with an underscore (internal functions).
397
  return currentStates;
398
  }
 
 
 
 
 
399
 
400
  // Check if this is inside a repeater
401
  var repeaterIndex = sowbForms.getContainerFieldId( $$, 'repeater', '.siteorigin-widget-field-repeater-item' );
@@ -436,7 +444,7 @@ var sowbForms = window.sowbForms || {};
436
  formStates = {'default': ''};
437
  }
438
  for (var k in states) {
439
- if (typeof formStates[k] === 'undefined' || states[k] !== formStates[k]) {
440
  // If the state is different from the original formStates, then trigger a state change
441
  formStates[k] = states[k];
442
  $mainForm.trigger('sowstatechange', [k, states[k]]);
@@ -991,6 +999,19 @@ var sowbForms = window.sowbForms || {};
991
  } else {
992
  return;
993
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
994
  } else if ( $$.prop( 'tagName' ) === 'SELECT' ) {
995
  var selected = $$.find( 'option:selected' );
996
  if ( selected.length === 1 ) {
@@ -1042,20 +1063,40 @@ var sowbForms = window.sowbForms || {};
1042
  * @param data The data from which to set the widget form field values.
1043
  * @param skipMissingValues If `true`, this will skip form fields for which the data values are missing.
1044
  * If `false`, the form fields will be cleared. Default is `false`.
 
1045
  */
1046
- sowbForms.setWidgetFormValues = function (formContainer, data, skipMissingValues) {
1047
  skipMissingValues = skipMissingValues || false;
 
1048
  // First check if this form has any repeaters.
1049
  var depth = 0;
1050
  var updateRepeaterChildren = function ( formParent, formData ) {
1051
  if ( ++depth === 10 ) {
 
1052
  return;
1053
  }
1054
  // Only direct child fields which are repeaters.
1055
- formParent.find( '> .siteorigin-widget-field-type-repeater' ).each( function () {
1056
- var $repeater = $( this ).find( '> .siteorigin-widget-field-repeater' );
 
 
1057
  var repeaterName = $repeater.data( 'repeaterName' );
1058
  var repeaterData = formData.hasOwnProperty( repeaterName ) ? formData[ repeaterName ] : null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1059
  if ( ! repeaterData || ! Array.isArray( repeaterData ) ) {
1060
  return;
1061
  }
@@ -1087,6 +1128,7 @@ var sowbForms = window.sowbForms || {};
1087
  );
1088
  }
1089
  } );
 
1090
  };
1091
 
1092
  updateRepeaterChildren(formContainer, data);
@@ -1141,8 +1183,14 @@ var sowbForms = window.sowbForms || {};
1141
  editor = tinyMCE.get( $$.attr( 'id' ) );
1142
  }
1143
 
1144
- if ( editor !== null && typeof( editor.getContent ) === "function" && ! editor.isHidden() ) {
1145
- editor.setContent( value );
 
 
 
 
 
 
1146
  }
1147
  else {
1148
  $$.val( value );
@@ -1151,9 +1199,10 @@ var sowbForms = window.sowbForms || {};
1151
  else {
1152
  $$.val( value );
1153
  }
1154
-
1155
- $$.trigger( 'change' );
1156
-
 
1157
  });
1158
  };
1159
 
@@ -1164,13 +1213,20 @@ var sowbForms = window.sowbForms || {};
1164
  $$.sowSetupForm();
1165
  }, 200);
1166
  });
1167
-
1168
- if ( $('body').hasClass('wp-customizer') ) {
1169
  // Setup new widgets when they're added in the customizer interface
1170
  $(document).on('widget-added', function (e, widget) {
1171
  widget.find('.siteorigin-widget-form').sowSetupForm();
1172
  });
1173
  }
 
 
 
 
 
 
 
1174
 
1175
  $( document ).on( 'open_dialog', function ( e, dialog ) {
1176
  // When we open a Page Builder edit widget dialog
166
  $teaser.remove();
167
  });
168
  });
169
+
170
+
171
+ if ( ! $el.data( 'backupDisabled' ) ) {
172
+ var _sow_form_id = $el.find( '> .siteorigin-widgets-form-id' ).val();
173
+ var $timestampField = $el.find( '> .siteorigin-widgets-form-timestamp' );
174
+ var _sow_form_timestamp = parseInt( $timestampField.val() || 0 );
175
+ var data = JSON.parse( sessionStorage.getItem( _sow_form_id ) );
176
+ if ( data ) {
177
+ if ( data['_sow_form_timestamp'] > _sow_form_timestamp ) {
178
+ var $newerNotification = $( '<div class="siteorigin-widget-form-notification">' +
179
+ '<span>' + soWidgets.backup.newerVersion + '</span>' +
180
+ '<a class="button button-small so-backup-restore">' + soWidgets.backup.restore + '</a>' +
181
+ '<a class="button button-small so-backup-dismiss">' + soWidgets.backup.dismiss + '</a>' +
182
+ '<div><small>' + soWidgets.backup.replaceWarning + '</small></div>' +
183
+ '</div>' );
184
+ $el.prepend( $newerNotification );
185
+
186
+ $newerNotification.find( '.so-backup-restore' ).click( function () {
187
+ sowbForms.setWidgetFormValues( $mainForm, data );
188
+ $newerNotification.slideUp( 'fast', function () {
189
+ $newerNotification.remove();
190
+ } );
191
  } );
192
+ $newerNotification.find( '.so-backup-dismiss' ).click( function () {
193
+ $newerNotification.slideUp( 'fast', function () {
194
+ sessionStorage.removeItem( _sow_form_id );
195
+ $newerNotification.remove();
196
+ } );
197
  } );
198
+ } else {
199
+ sessionStorage.removeItem( _sow_form_id );
200
+ }
201
  }
202
+ $el.change( function () {
203
+ $timestampField.val( new Date().getTime() );
204
+ var data = sowbForms.getWidgetFormValues( $el );
205
+ sessionStorage.setItem( _sow_form_id, JSON.stringify( data ) );
206
+ } );
207
  }
 
 
 
 
 
 
208
  }
209
  else {
210
  $mainForm = $el.closest('.siteorigin-widget-form-main');
357
  e.preventDefault();
358
  var $li = $(this);
359
  $$.find('input.siteorigin-widget-input').val('post: ' + $li.data('value'));
360
+ $$.change();
361
  $$.find('.existing-content-selector').toggle();
362
  });
363
 
399
  // Skip if the function doesn't exist, or it starts with an underscore (internal functions).
400
  return currentStates;
401
  }
402
+
403
+ // Skip if this is an unselected radio input.
404
+ if ( $$.is( '[type="radio"]' ) && !$$.is( ':checked' ) ) {
405
+ return currentStates;
406
+ }
407
 
408
  // Check if this is inside a repeater
409
  var repeaterIndex = sowbForms.getContainerFieldId( $$, 'repeater', '.siteorigin-widget-field-repeater-item' );
444
  formStates = {'default': ''};
445
  }
446
  for (var k in states) {
447
+ if ( typeof formStates[k] === 'undefined' || states[k] !== formStates[k] ) {
448
  // If the state is different from the original formStates, then trigger a state change
449
  formStates[k] = states[k];
450
  $mainForm.trigger('sowstatechange', [k, states[k]]);
999
  } else {
1000
  return;
1001
  }
1002
+ } else if ( $$.prop( 'tagName' ) === 'TEXTAREA' && $$.hasClass( 'wp-editor-area' ) ) {
1003
+ // This is a TinyMCE editor, so we'll use the tinyMCE object to get the content
1004
+ var editor = null;
1005
+ if ( typeof tinyMCE !== 'undefined' ) {
1006
+ editor = tinyMCE.get( $$.attr( 'id' ) );
1007
+ }
1008
+
1009
+ if ( editor !== null && typeof( editor.getContent ) === "function" && !editor.isHidden() ) {
1010
+ fieldValue = editor.getContent();
1011
+ }
1012
+ else {
1013
+ fieldValue = $$.val();
1014
+ }
1015
  } else if ( $$.prop( 'tagName' ) === 'SELECT' ) {
1016
  var selected = $$.find( 'option:selected' );
1017
  if ( selected.length === 1 ) {
1063
  * @param data The data from which to set the widget form field values.
1064
  * @param skipMissingValues If `true`, this will skip form fields for which the data values are missing.
1065
  * If `false`, the form fields will be cleared. Default is `false`.
1066
+ * @param triggerChange If `true`, trigger a 'change' event on each element after it's value is set. Default is `true`.
1067
  */
1068
+ sowbForms.setWidgetFormValues = function (formContainer, data, skipMissingValues, triggerChange) {
1069
  skipMissingValues = skipMissingValues || false;
1070
+ triggerChange = (typeof triggerChange !== 'undefined' && triggerChange) || typeof triggerChange === 'undefined';
1071
  // First check if this form has any repeaters.
1072
  var depth = 0;
1073
  var updateRepeaterChildren = function ( formParent, formData ) {
1074
  if ( ++depth === 10 ) {
1075
+ --depth;
1076
  return;
1077
  }
1078
  // Only direct child fields which are repeaters.
1079
+ formParent.find( '> .siteorigin-widget-field-type-repeater,> .siteorigin-widget-field-type-section > .siteorigin-widget-section > .siteorigin-widget-field-type-repeater' )
1080
+ .each( function ( index, element ) {
1081
+ var $this = $( this );
1082
+ var $repeater = $this.find( '> .siteorigin-widget-field-repeater' );
1083
  var repeaterName = $repeater.data( 'repeaterName' );
1084
  var repeaterData = formData.hasOwnProperty( repeaterName ) ? formData[ repeaterName ] : null;
1085
+ var isInSection = $this.parent().is( '.siteorigin-widget-section' );
1086
+ if ( isInSection ) {
1087
+ var elementName = $repeater.data( 'element-name' );
1088
+ // Get rid of any index placeholders
1089
+ elementName = elementName.replace(/\[#.*?#\]/g, '');
1090
+ var variablePath = /[a-zA-Z0-9\-]+(?:\[c?[0-9]+\])?\[(.*)\]/.exec(elementName)[1];
1091
+ var variablePathParts = variablePath.split('][');
1092
+ var elementVars = variablePathParts.length ? formData : null;
1093
+ while (variablePathParts.length) {
1094
+ var key = variablePathParts.shift();
1095
+ elementVars = elementVars.hasOwnProperty( key ) ? elementVars[ key ] : elementVars;
1096
+ }
1097
+ repeaterData = elementVars;
1098
+ }
1099
+
1100
  if ( ! repeaterData || ! Array.isArray( repeaterData ) ) {
1101
  return;
1102
  }
1128
  );
1129
  }
1130
  } );
1131
+ --depth;
1132
  };
1133
 
1134
  updateRepeaterChildren(formContainer, data);
1183
  editor = tinyMCE.get( $$.attr( 'id' ) );
1184
  }
1185
 
1186
+ if ( editor !== null && typeof( editor.setContent ) === "function" && ! editor.isHidden() && $$.parent().is( ':visible' ) ) {
1187
+ if ( editor.initialized ) {
1188
+ editor.setContent( value );
1189
+ } else {
1190
+ editor.on('init', function () {
1191
+ editor.setContent( value );
1192
+ });
1193
+ }
1194
  }
1195
  else {
1196
  $$.val( value );
1199
  else {
1200
  $$.val( value );
1201
  }
1202
+
1203
+ if ( triggerChange ) {
1204
+ $$.trigger( 'change' );
1205
+ }
1206
  });
1207
  };
1208
 
1213
  $$.sowSetupForm();
1214
  }, 200);
1215
  });
1216
+ var $body = $( 'body' );
1217
+ if ( $body.hasClass('wp-customizer') ) {
1218
  // Setup new widgets when they're added in the customizer interface
1219
  $(document).on('widget-added', function (e, widget) {
1220
  widget.find('.siteorigin-widget-form').sowSetupForm();
1221
  });
1222
  }
1223
+
1224
+ if ( $body.hasClass('gutenberg-editor-page') ) {
1225
+ // Setup new widgets when they're added in the customizer interface
1226
+ $(document).on('panels_setup_preview', function () {
1227
+ $( sowb ).trigger( 'setup_widgets' );
1228
+ });
1229
+ }
1230
 
1231
  $( document ).on( 'open_dialog', function ( e, dialog ) {
1232
  // When we open a Page Builder edit widget dialog
base/js/admin.min.js CHANGED
@@ -1 +1 @@
1
- var sowbForms=window.sowbForms||{};!function(e){e.fn.sowSetupForm=function(){return e(this).each(function(i,t){var r,n=e(t),a=!0,s=e("body"),o=n.find("input[name]");if(o.length&&-1!==o.attr("name").indexOf("__i__"))return this;if(n.is(".siteorigin-widget-form-main")){if(!0===n.data("sow-form-setup"))return!0;if(s.hasClass("widgets-php")&&!n.is(":visible")&&0===n.closest(".panel-dialog").length)return!0;n.on("sowstatechange",function(i,t,r){n.find("[data-state-handler]").each(function(){var i=e(this),n=e.extend({},i.data("state-handler"),a?i.data("state-handler-initial"):{});if(0===Object.keys(n).length)return!0;var s,o,d,l,g,f,c={},p=sowbForms.getContainerFieldId(i,"repeater",".siteorigin-widget-field-repeater-item");if(!1!==p){var u={};for(var m in n)u[m.replace("{$repeater}",p)]=n[m];n=u}var w=sowbForms.getContainerFieldId(i,"widget",".siteorigin-widget-widget");if(!1!==w){var v={};for(var h in n){var b=h.match(/_else\[(.*)\]|(.*)\[(.*)\]/),y="";y=b&&b.length&&void 0===b[1]?b[2]+"_"+w+"["+b[3]+"]":"_else["+b[1]+"_"+w+"]",v[y]=n[h]}n=v}for(var F in n)if(g=!1,null!==(s=F.match(/^([a-zA-Z0-9_-]+)(\[([a-zA-Z0-9_\-,]+)\])?(\[\])?$/))){if(o={group:"default",name:"",multi:!1},void 0!==s[2]?(o.group=s[1],o.name=s[3]):o.name=s[0],o.multi=void 0!==s[4],"_else"===o.group)o.group=o.name,o.name="",g=o.group===t&&void 0===c[o.group];else{f=o.name.split(",").map(function(e){return e.trim()});for(var k=0;k<f.length&&!(g=o.group===t&&f[k]===r);k++);}if(g){d=n[F],o.multi||(d=[d]);for(var k=0;k<d.length;k++)l=void 0!==d[k][1]&&Boolean(d[k][1])?i.find(d[k][1]):i,l[d[k][0]].apply(l,void 0!==d[k][2]?d[k][2]:[]);c[o.group]=!0}}})}),n.sowSetupPreview(),r=n;var d=n.find(".siteorigin-widget-teaser");d.find(".dashicons-dismiss").click(function(){var i=e(this);e.get(i.data("dismiss-url")),d.slideUp("normal",function(){d.remove()})});var l=n.find("> .siteorigin-widgets-form-id").val(),g=n.find("> .siteorigin-widgets-form-timestamp"),f=parseInt(g.val()||0),c=JSON.parse(sessionStorage.getItem(l));if(c)if(c._sow_form_timestamp>f){var p=e('<div class="siteorigin-widget-form-notification"><span>'+soWidgets.backup.newerVersion+'</span><a class="button button-small so-backup-restore">'+soWidgets.backup.restore+'</a><a class="button button-small so-backup-dismiss">'+soWidgets.backup.dismiss+"</a><div><small>"+soWidgets.backup.replaceWarning+"</small></div></div>");n.prepend(p),p.find(".so-backup-restore").click(function(){sowbForms.setWidgetFormValues(r,c),p.slideUp("fast",function(){p.remove()})}),p.find(".so-backup-dismiss").click(function(){p.slideUp("fast",function(){sessionStorage.removeItem(l),p.remove()})})}else sessionStorage.removeItem(l);n.change(function(){g.val((new Date).getTime());var e=sowbForms.getWidgetFormValues(n);sessionStorage.setItem(l,JSON.stringify(e))})}else r=n.closest(".siteorigin-widget-form-main");r.find("> .siteorigin-widgets-form-id").val();var u=n.find("> .siteorigin-widget-field");u.find("> .siteorigin-widget-section").sowSetupForm();var m=u.find("> .siteorigin-widget-widget");m.find("> .siteorigin-widget-section").sowSetupForm(),m.filter(":not(:has(> .siteorigin-widget-section))").sowSetupForm(),u.find(".siteorigin-widget-input").each(function(i,t){null===e(t).data("original-name")&&e(t).data("original-name",e(t).attr("name"))}),u.find("> .siteorigin-widget-field-repeater").sowSetupRepeater(),n.find(".siteorigin-widget-field-repeater-item").sowSetupRepeaterItems(),u.find("> .siteorigin-widget-input-color").each(function(){var i=e(this),t={change:function(i,t){setTimeout(function(){e(i.target).trigger("change")},100)}};i.data("defaultColor")&&(t.defaultColor=i.data("defaultColor")),i.wpColorPicker(t)});var w=function(){e(this).toggleClass("siteorigin-widget-section-visible"),e(this).parent().find("> .siteorigin-widget-section, > .siteorigin-widget-widget > .siteorigin-widget-section").slideToggle("fast",function(){if(e(window).resize(),e(this).find("> .siteorigin-widget-field-container-state").val(e(this).is(":visible")?"open":"closed"),e(this).is(":visible")){e(this).find("> .siteorigin-widget-field").trigger("sowsetupformfield")}})};u.filter(".siteorigin-widget-field-type-widget, .siteorigin-widget-field-type-section").find("> label").click(w),u.filter(".siteorigin-widget-field-type-posts").find(".posts-container-label-wrapper").click(w),u.filter(".siteorigin-widget-field-type-slider").each(function(){var i=e(this),t=i.find('input[type="number"]'),r=i.find(".siteorigin-widget-value-slider");r.slider({max:parseFloat(t.attr("max")),min:parseFloat(t.attr("min")),step:parseFloat(t.attr("step")),value:parseFloat(t.val()),slide:function(e,i){t.val(parseFloat(i.value)),t.trigger("change")},change:function(e,t){i.find(".siteorigin-widget-slider-value").html(t.value)}}),t.change(function(e,i){i&&i.silent||r.slider("value",parseFloat(t.val()))})}),u.filter(".siteorigin-widget-field-type-link").each(function(){var i=e(this),t=null,r=function(){null!==t&&t.abort();var r=i.find(".content-text-search"),n=r.val(),a=r.data("postTypes"),s=i.find("ul.posts").empty().addClass("loading");e.get(soWidgets.ajaxurl,{action:"so_widgets_search_posts",query:n,postTypes:a},function(i){for(var t=0;t<i.length;t++)""===i[t].label&&(i[t].label="&nbsp;"),s.append(e("<li>").addClass("post").html(i[t].label+"<span>("+i[t].type+")</span>").data(i[t]));s.removeClass("loading")})};i.find(".select-content-button, .button-close").click(function(t){t.preventDefault(),e(this).blur();var n=i.find(".existing-content-selector");n.toggle(),n.is(":visible")&&0===n.find("ul.posts li").length&&r()}),i.on("click",".posts li",function(t){t.preventDefault();var r=e(this);i.find("input.siteorigin-widget-input").val("post: "+r.data("value")),i.find(".existing-content-selector").toggle()});var n=null;i.find(".content-text-search").keyup(function(){null!==n&&clearTimeout(n),n=setTimeout(function(){r()},500)})}),void 0!==jQuery.fn.soPanelsSetupBuilderWidget&&u.filter(".siteorigin-widget-field-type-builder").each(function(){e(this).find("> .siteorigin-page-builder-field").each(function(){var i=e(this);i.soPanelsSetupBuilderWidget({builderType:i.data("type")})})});var v=function(){var i=e(this),t=i.closest("[data-state-emitter]").data("state-emitter");if(void 0!==t){var n={default:""};void 0===t.length&&(t=[t]);for(var a=0;a<t.length;a++)n=function(t,r){if(void 0===sowEmitters[t.callback]||"_"===t.callback.substr(0,1))return r;var n=sowbForms.getContainerFieldId(i,"repeater",".siteorigin-widget-field-repeater-item");!1!==n&&(t.args=t.args.map(function(e){return e.replace("{$repeater}",n)}));var a=sowbForms.getContainerFieldId(i,"widget",".siteorigin-widget-widget");!1===a||t.hasOwnProperty("widgetFieldId")||(t.widgetFieldId=a,t.args=t.args.map(function(e){return e+"_"+a}));var s=i.is('[type="checkbox"]')?i.is(":checked"):i.val();return e.extend(r,sowEmitters[t.callback](s,t.args))}(t[a],n);var s=r.data("states");void 0===s&&(s={default:""});for(var o in n)void 0!==s[o]&&n[o]===s[o]||(s[o]=n[o],r.trigger("sowstatechange",[o,n[o]]));r.data("states",s)}};u.filter("[data-state-emitter]").each(function(){var i=e(this).find(".siteorigin-widget-input");i.on("keyup change",v),i.each(function(){var i=e(this);i.is(":radio")?i.is(":checked")&&v.call(i[0]):v.call(i[0])})}),n.trigger("sowsetupform",u).data("sow-form-setup",!0),u.trigger("sowsetupformfield"),n.find(".siteorigin-widget-field-repeater-item").trigger("updateFieldPositions"),(s.hasClass("wp-customizer")||s.hasClass("widgets-php"))&&n.closest(".ui-sortable").on("sortstop",function(e,i){i.item.find(".siteorigin-widget-form").find("> .siteorigin-widget-field").trigger("sowsetupformfield")}),a=!1})},e.fn.sowSetupPreview=function(){var i=e(this);i.siblings(".siteorigin-widget-preview").find("> a").click(function(t){t.preventDefault();var r=sowbForms.getWidgetFormValues(i),n=e(e("#so-widgets-bundle-tpl-preview-dialog").html().trim()).appendTo("body");n.find('input[name="data"]').val(JSON.stringify(r)),n.find('input[name="class"]').val(i.data("class")),n.find("iframe").on("load",function(){e(this).css("visibility","visible")}),n.find("form").submit(),n.find(".close").click(function(){n.remove()})})},e.fn.sowSetupRepeater=function(){return e(this).each(function(i,t){var r=e(t),n=r.find(".siteorigin-widget-field-repeater-items"),a=r.data("repeater-name");n.bind("updateFieldPositions",function(){var i=e(this),t=i.find("> .siteorigin-widget-field-repeater-item");t.each(function(i,t){e(t).find(".siteorigin-widget-input").each(function(t,r){var n=e(r).data("repeater-positions");void 0===n&&(n={}),n[a]=i,e(r).data("repeater-positions",n)})}),i.find(".siteorigin-widget-input").each(function(i,t){var r=e(t),n=r.data("repeater-positions");if(void 0!==n){var a=r.attr("data-original-name");if(a||(r.attr("data-original-name",r.attr("name")),a=r.attr("name")),!a)return;if(n)for(var s in n)a=a.replace("#"+s+"#",n[s]);r.attr("name",a)}}),i.data("initialSetup")||(i.find(".siteorigin-widget-input").each(function(i,t){var r=e(t);r.prop("checked",r.prop("defaultChecked"))}),i.data("initialSetup",!0));var n=r.data("scroll-count")?parseInt(r.data("scroll-count")):0;if(n>0&&t.length>n){var s=t.first().outerHeight();i.css("max-height",s*n).css("overflow","auto")}else i.css("max-height","").css("overflow","")}),n.sortable({handle:".siteorigin-widget-field-repeater-item-top",items:"> .siteorigin-widget-field-repeater-item",update:function(){n.find('input[type="radio"].siteorigin-widget-input').attr("name",""),n.trigger("updateFieldPositions"),r.trigger("change")},sortstop:function(i,t){if(t.item.is(".siteorigin-widget-field-repeater-item"))t.item.find("> .siteorigin-widget-field-repeater-item-form").each(function(){e(this).find("> .siteorigin-widget-field").trigger("sowsetupformfield")});else{t.item.find(".siteorigin-widget-form").find("> .siteorigin-widget-field").trigger("sowsetupformfield")}r.trigger("change")}}),n.trigger("updateFieldPositions"),r.find("> .siteorigin-widget-field-repeater-add").disableSelection().click(function(i){i.preventDefault(),r.closest(".siteorigin-widget-field-repeater").sowAddRepeaterItem().find("> .siteorigin-widget-field-repeater-items").slideDown("fast",function(){e(window).resize()})}),r.find("> .siteorigin-widget-field-repeater-top > .siteorigin-widget-field-repeater-expand").click(function(i){i.preventDefault(),r.closest(".siteorigin-widget-field-repeater").find("> .siteorigin-widget-field-repeateritems-").slideToggle("fast",function(){e(window).resize()})})})},e.fn.sowAddRepeaterItem=function(){return e(this).each(function(i,t){var r=e(t),n=r.find("> .siteorigin-widget-field-repeater-items").children().length+1,a=e("<div>"+r.find("> .siteorigin-widget-field-repeater-item-html").html()+"</div>");a.find(".siteorigin-widget-input[data-name]").each(function(){var i=e(this);0===i.closest(".siteorigin-widget-field-repeater-item-html").length&&i.attr("name",e(this).data("name"))});var s=a.html().replace(/_id_/g,n),o=void 0!==r.attr("readonly"),d=e('<div class="siteorigin-widget-field-repeater-item ui-draggable" />').append(e('<div class="siteorigin-widget-field-repeater-item-top" />').append(e('<div class="siteorigin-widget-field-expand" />')).append(o?"":e('<div class="siteorigin-widget-field-copy" />')).append(o?"":e('<div class="siteorigin-widget-field-remove" />')).append(e("<h4 />").html(r.data("item-name")))).append(e('<div class="siteorigin-widget-field-repeater-item-form" />').html(s));r.find("> .siteorigin-widget-field-repeater-items").append(d).sortable("refresh").trigger("updateFieldPositions"),d.sowSetupRepeaterItems(),d.hide().slideDown("fast",function(){e(window).resize()}),r.trigger("change")})},e.fn.sowRemoveRepeaterItem=function(){return e(this).each(function(i,t){var r=e(this).closest(".siteorigin-widget-field-repeater-items");e(this).remove(),r.sortable("refresh").trigger("updateFieldPositions"),e(t).trigger("change")})},e.fn.sowSetupRepeaterItems=function(){return e(this).each(function(i,t){var r=e(t);if(void 0===r.data("sowrepeater-actions-setup")){var n=r.closest(".siteorigin-widget-field-repeater"),a=r.find("> .siteorigin-widget-field-repeater-item-top"),s=n.data("item-label");if(s&&s.selector){var o=function(){var e=s.hasOwnProperty("valueMethod")&&s.valueMethod?s.valueMethod:"val",i=r.find(s.selector)[e]();i&&(i.length>80&&(i=i.substr(0,79)+"..."),a.find("h4").text(i))};o();var d=s.hasOwnProperty("updateEvent")&&s.updateEvent?s.updateEvent:"change";r.bind(d,o)}a.click(function(i){"siteorigin-widget-field-remove"!==i.target.className&&"siteorigin-widget-field-copy"!==i.target.className&&(i.preventDefault(),e(this).closest(".siteorigin-widget-field-repeater-item").find(".siteorigin-widget-field-repeater-item-form").eq(0).slideToggle("fast",function(){if(e(window).resize(),e(this).is(":visible")){e(this).trigger("slideToggleOpenComplete");e(this).find("> .siteorigin-widget-field").trigger("sowsetupformfield")}else e(this).trigger("slideToggleCloseComplete")}))}),a.find(".siteorigin-widget-field-remove").click(function(i,t){i.preventDefault();var n=e(this).closest(".siteorigin-widget-field-repeater-items"),a=e(this).closest(".siteorigin-widget-field-repeater-item"),s=function(){a.remove(),n.sortable("refresh").trigger("updateFieldPositions"),e(window).resize()};t&&t.silent?s():confirm(soWidgets.sure)&&a.slideUp("fast",s),r.trigger("change")}),a.find(".siteorigin-widget-field-copy").click(function(i){i.preventDefault();var t=e(this).closest(".siteorigin-widget-form-main"),n=e(this).closest(".siteorigin-widget-field-repeater-item"),a=n.clone(),s=n.closest(".siteorigin-widget-field-repeater-items"),o=s.children().length,d={};a.find("*[name]").each(function(){var i=e(this),s=i.attr("id"),l=i.attr("name");if(i.is("textarea")&&i.parent().is(".wp-editor-container")&&"undefined"!=typeof tinymce){i.parent().empty().append(i),i.css("display","");var g=tinymce.get(s);g&&i.val(g.getContent())}else if(i.is(".wp-color-picker")){var f=i.closest(".wp-picker-container"),c=i.closest(".siteorigin-widget-field");f.remove(),c.append(i.remove())}else{var p=s?n.find("#"+s):n.find('[name="'+l+'"]');p.length&&null!=p.val()&&i.val(p.val())}if(s){var u,m,w;if(i.is('[type="radio"]')){m=s.replace(/-\d+-\d+$/,"");var v=s.replace(/-\d+$/,"");if(!d[m]){var h={};d[m]=t.find(".siteorigin-widget-input[id^="+m+"]").not("[id*=_id_]").filter(function(i,t){var r=e(t).attr("name");return!h[r]&&(h[r]=!0,!0)}).length+1}var b=m+"-"+d[m];w=b+s.match(/-\d+$/)[0],a.find("label[for="+v+"]").attr("for",b)}else u=new RegExp("-\\d+$"),m=s.replace(u,""),d[m]||(d[m]=t.find(".siteorigin-widget-input[id^="+m+"]").not("[id*=_id_]").length+1),w=m+"-"+d[m]++;if(i.attr("id",w),i.is(".wp-editor-area")){var y=i.closest(".siteorigin-widget-tinymce-container"),F=y.data("media-buttons");if(F&&F.html){var u=new RegExp(s,"g");F.html=F.html.replace(u,w),y.data("media-buttons",F)}}a.find("label[for="+s+"]").attr("for",w),a.find("[id*="+s+"]").each(function(){var i=e(this).attr("id"),t=i.replace(s,w);e(this).attr("id",t)}),"undefined"!=typeof tinymce&&tinymce.get(w)&&tinymce.get(w).remove()}var k=n.parents(".siteorigin-widget-field-repeater").length,_=e("body");(_.hasClass("wp-customizer")||_.hasClass("widgets-php"))&&0===r.closest(".panel-dialog").length&&(k+=1);var C=l.replace(new RegExp("((?:.*?\\[\\d+\\]){"+(k-1).toString()+"})?(.*?\\[)\\d+(\\])"),"$1$2"+o.toString()+"$3");i.attr("name",C),i.data("original-name",C)}),s.append(a).sortable("refresh").trigger("updateFieldPositions"),a.sowSetupRepeaterItems(),a.hide().slideDown("fast",function(){e(window).resize()}),r.trigger("change")}),r.find("> .siteorigin-widget-field-repeater-item-form").sowSetupForm(),r.data("sowrepeater-actions-setup",!0)}})},sowbForms.getContainerFieldId=function(e,i,t){var r=i+"FieldId";this.hasOwnProperty(r)||(this[r]=1);var n=e.closest(t);if(n.length){var a=n.data("field-id");return void 0===a&&(a=this[r]++),n.data("field-id",a),a}return!1},sowbForms.getWidgetFieldVariable=function(e,i,t){var r=window.sow_field_javascript_variables[e];i=i.replace(/\[#.*?#\]/g,"");for(var n=/[a-zA-Z0-9\-]+(?:\[c?[0-9]+\])?\[(.*)\]/.exec(i)[1],a=n.split("]["),s=a.length?r:null;a.length;)s=s[a.shift()];return s[t]},sowbForms.fetchWidgetVariable=function(i,t,r){window.sowVars=window.sowVars||{},void 0===window.sowVars[t]?e.post(soWidgets.ajaxurl,{action:"sow_get_javascript_variables",widget:t,key:i},function(e){window.sowVars[t]=e,r(window.sowVars[t][i])}):r(window.sowVars[t][i])},sowbForms.getWidgetFormValues=function(i){if(_.isUndefined(i))return null;var t={};return i.find("*[name]").each(function(){var i=e(this);try{var r=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(_.isEmpty(r))return!0;r=r[1];var n=r.split("][");n=n.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});var a=t,s=null,o=_.isString(i.attr("type"))?i.attr("type").toLowerCase():null;if("checkbox"===o)s=!!i.is(":checked")&&(""===i.val()||i.val());else if("radio"===o){if(!i.is(":checked"))return;s=i.val()}else if("SELECT"===i.prop("tagName")){var d=i.find("option:selected");1===d.length?s=i.find("option:selected").val():d.length>1&&(s=_.map(i.find("option:selected"),function(i,t){return e(i).val()}))}else s=i.val();for(var l=0;l<n.length;l++)l===n.length-1?""===n[l]?a.push(s):a[n[l]]=s:(_.isUndefined(a[n[l]])&&(_.isNumber(n[l+1])||""===n[l+1]?a[n[l]]=[]:a[n[l]]={}),a=a[n[l]])}catch(e){console.error("Field ["+i.attr("name")+"] could not be processed and was skipped - "+e.message)}}),t},sowbForms.setWidgetFormValues=function(i,t,r){r=r||!1;var n=0,a=function(i,t){10!=++n&&i.find("> .siteorigin-widget-field-type-repeater").each(function(){var i=e(this).find("> .siteorigin-widget-field-repeater"),n=i.data("repeaterName"),s=t.hasOwnProperty(n)?t[n]:null;if(s&&Array.isArray(s)){var o=i.find("> .siteorigin-widget-field-repeater-items > .siteorigin-widget-field-repeater-item"),d=s.length,l=o.length;if(d>l)for(var g=0;g<d-l;g++)i.find("> .siteorigin-widget-field-repeater-add").click();else if(!r&&d<l)for(var f=d;f<l;f++){var c=e(o.eq(f));c.find("> .siteorigin-widget-field-repeater-item-top").find(".siteorigin-widget-field-remove").trigger("click",{silent:!0})}o=i.find("> .siteorigin-widget-field-repeater-items > .siteorigin-widget-field-repeater-item");for(var p=0;p<o.length;p++)o.eq(p).find("> .siteorigin-widget-field-repeater-item-form"),a(o.eq(p).find("> .siteorigin-widget-field-repeater-item-form"),s[p])}})};a(i,t),i.find("*[name]").each(function(){var i=e(this),n=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(void 0===n||null===n)return!0;n=n[1];var a=n.split("][");a=a.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});for(var s,o=t,d=0;d<a.length;d++){if(!o.hasOwnProperty(a[d])){if(r)return!0;break}d===a.length-1?s=o[a[d]]:o=o[a[d]]}if("checkbox"===i.attr("type"))i.prop("checked",s);else if("radio"===i.attr("type"))i.prop("checked",s===i.val());else if("TEXTAREA"===i.prop("tagName")&&i.hasClass("wp-editor-area")){var l=null;"undefined"!=typeof tinyMCE&&(l=tinyMCE.get(i.attr("id"))),null===l||"function"!=typeof l.getContent||l.isHidden()?i.val(s):l.setContent(s)}else i.val(s);i.trigger("change")})},e(".widgets-holder-wrap").on("click",".widget:has(.siteorigin-widget-form-main) .widget-top",function(){var i=e(this).closest(".widget").find(".siteorigin-widget-form-main");setTimeout(function(){i.sowSetupForm()},200)}),e("body").hasClass("wp-customizer")&&e(document).on("widget-added",function(e,i){i.find(".siteorigin-widget-form").sowSetupForm()}),e(document).on("open_dialog",function(i,t){if(t.$el.find(".so-panels-dialog").is(".so-panels-dialog-edit-widget")){e(i.target).find(".siteorigin-widget-form-main").find("> .siteorigin-widget-field").trigger("sowsetupformfield")}}),e(function(){e(document).trigger("sowadminloaded")})}(jQuery);var sowEmitters={_match:function(e,i){void 0===i&&(i=".*");var t=new RegExp("^([a-zA-Z0-9_-]+)(\\[([a-zA-Z0-9_-]+)\\])? *: *("+i+") *$"),r=t.exec(e);if(null===r)return!1;var n="",a="default";return void 0!==r[3]?(a=r[1],n=r[3]):n=r[1],{match:r[4].trim(),group:a,state:n}},_checker:function(e,i,t,r){var n={};void 0===i.length&&(i=[i]);for(var a,s=0;s<i.length;s++)!1!==(a=sowEmitters._match(i[s],t))&&("_true"===a.match||r(e,i,a.match))&&(n[a.group]=a.state);return n},select:function(e,i){void 0===i.length&&(i=[i]);for(var t={},r=0;r<i.length;r++)""===i[r]&&(i[r]="default"),t[i[r]]=e;return t},conditional:function(val,args){return sowEmitters._checker(val,args,"[^;{}]*",function(val,args,match){return eval(match)})},in:function(e,i){return sowEmitters._checker(e,i,"[^;{}]*",function(e,i,t){return-1!==t.split(",").map(function(e){return e.trim()}).indexOf(e)})}};window.sowbForms=sowbForms;
1
+ var sowbForms=window.sowbForms||{};!function(e){e.fn.sowSetupForm=function(){return e(this).each(function(i,t){var r,n=e(t),a=!0,s=e("body"),o=n.find("input[name]");if(o.length&&-1!==o.attr("name").indexOf("__i__"))return this;if(n.is(".siteorigin-widget-form-main")){if(!0===n.data("sow-form-setup"))return!0;if(s.hasClass("widgets-php")&&!n.is(":visible")&&0===n.closest(".panel-dialog").length)return!0;n.on("sowstatechange",function(i,t,r){n.find("[data-state-handler]").each(function(){var i=e(this),n=e.extend({},i.data("state-handler"),a?i.data("state-handler-initial"):{});if(0===Object.keys(n).length)return!0;var s,o,d,l,g,f,c={},p=sowbForms.getContainerFieldId(i,"repeater",".siteorigin-widget-field-repeater-item");if(!1!==p){var u={};for(var m in n)u[m.replace("{$repeater}",p)]=n[m];n=u}var w=sowbForms.getContainerFieldId(i,"widget",".siteorigin-widget-widget");if(!1!==w){var v={};for(var h in n){var b=h.match(/_else\[(.*)\]|(.*)\[(.*)\]/),y="";y=b&&b.length&&void 0===b[1]?b[2]+"_"+w+"["+b[3]+"]":"_else["+b[1]+"_"+w+"]",v[y]=n[h]}n=v}for(var F in n)if(g=!1,null!==(s=F.match(/^([a-zA-Z0-9_-]+)(\[([a-zA-Z0-9_\-,]+)\])?(\[\])?$/))){if(o={group:"default",name:"",multi:!1},void 0!==s[2]?(o.group=s[1],o.name=s[3]):o.name=s[0],o.multi=void 0!==s[4],"_else"===o.group)o.group=o.name,o.name="",g=o.group===t&&void 0===c[o.group];else{f=o.name.split(",").map(function(e){return e.trim()});for(var k=0;k<f.length&&!(g=o.group===t&&f[k]===r);k++);}if(g){d=n[F],o.multi||(d=[d]);for(var k=0;k<d.length;k++)l=void 0!==d[k][1]&&Boolean(d[k][1])?i.find(d[k][1]):i,l[d[k][0]].apply(l,void 0!==d[k][2]?d[k][2]:[]);c[o.group]=!0}}})}),n.sowSetupPreview(),r=n;var d=n.find(".siteorigin-widget-teaser");if(d.find(".dashicons-dismiss").click(function(){var i=e(this);e.get(i.data("dismiss-url")),d.slideUp("normal",function(){d.remove()})}),!n.data("backupDisabled")){var l=n.find("> .siteorigin-widgets-form-id").val(),g=n.find("> .siteorigin-widgets-form-timestamp"),f=parseInt(g.val()||0),c=JSON.parse(sessionStorage.getItem(l));if(c)if(c._sow_form_timestamp>f){var p=e('<div class="siteorigin-widget-form-notification"><span>'+soWidgets.backup.newerVersion+'</span><a class="button button-small so-backup-restore">'+soWidgets.backup.restore+'</a><a class="button button-small so-backup-dismiss">'+soWidgets.backup.dismiss+"</a><div><small>"+soWidgets.backup.replaceWarning+"</small></div></div>");n.prepend(p),p.find(".so-backup-restore").click(function(){sowbForms.setWidgetFormValues(r,c),p.slideUp("fast",function(){p.remove()})}),p.find(".so-backup-dismiss").click(function(){p.slideUp("fast",function(){sessionStorage.removeItem(l),p.remove()})})}else sessionStorage.removeItem(l);n.change(function(){g.val((new Date).getTime());var e=sowbForms.getWidgetFormValues(n);sessionStorage.setItem(l,JSON.stringify(e))})}}else r=n.closest(".siteorigin-widget-form-main");r.find("> .siteorigin-widgets-form-id").val();var u=n.find("> .siteorigin-widget-field");u.find("> .siteorigin-widget-section").sowSetupForm();var m=u.find("> .siteorigin-widget-widget");m.find("> .siteorigin-widget-section").sowSetupForm(),m.filter(":not(:has(> .siteorigin-widget-section))").sowSetupForm(),u.find(".siteorigin-widget-input").each(function(i,t){null===e(t).data("original-name")&&e(t).data("original-name",e(t).attr("name"))}),u.find("> .siteorigin-widget-field-repeater").sowSetupRepeater(),n.find(".siteorigin-widget-field-repeater-item").sowSetupRepeaterItems(),u.find("> .siteorigin-widget-input-color").each(function(){var i=e(this),t={change:function(i,t){setTimeout(function(){e(i.target).trigger("change")},100)}};i.data("defaultColor")&&(t.defaultColor=i.data("defaultColor")),i.wpColorPicker(t)});var w=function(){e(this).toggleClass("siteorigin-widget-section-visible"),e(this).parent().find("> .siteorigin-widget-section, > .siteorigin-widget-widget > .siteorigin-widget-section").slideToggle("fast",function(){if(e(window).resize(),e(this).find("> .siteorigin-widget-field-container-state").val(e(this).is(":visible")?"open":"closed"),e(this).is(":visible")){e(this).find("> .siteorigin-widget-field").trigger("sowsetupformfield")}})};u.filter(".siteorigin-widget-field-type-widget, .siteorigin-widget-field-type-section").find("> label").click(w),u.filter(".siteorigin-widget-field-type-posts").find(".posts-container-label-wrapper").click(w),u.filter(".siteorigin-widget-field-type-slider").each(function(){var i=e(this),t=i.find('input[type="number"]'),r=i.find(".siteorigin-widget-value-slider");r.slider({max:parseFloat(t.attr("max")),min:parseFloat(t.attr("min")),step:parseFloat(t.attr("step")),value:parseFloat(t.val()),slide:function(e,i){t.val(parseFloat(i.value)),t.trigger("change")},change:function(e,t){i.find(".siteorigin-widget-slider-value").html(t.value)}}),t.change(function(e,i){i&&i.silent||r.slider("value",parseFloat(t.val()))})}),u.filter(".siteorigin-widget-field-type-link").each(function(){var i=e(this),t=null,r=function(){null!==t&&t.abort();var r=i.find(".content-text-search"),n=r.val(),a=r.data("postTypes"),s=i.find("ul.posts").empty().addClass("loading");e.get(soWidgets.ajaxurl,{action:"so_widgets_search_posts",query:n,postTypes:a},function(i){for(var t=0;t<i.length;t++)""===i[t].label&&(i[t].label="&nbsp;"),s.append(e("<li>").addClass("post").html(i[t].label+"<span>("+i[t].type+")</span>").data(i[t]));s.removeClass("loading")})};i.find(".select-content-button, .button-close").click(function(t){t.preventDefault(),e(this).blur();var n=i.find(".existing-content-selector");n.toggle(),n.is(":visible")&&0===n.find("ul.posts li").length&&r()}),i.on("click",".posts li",function(t){t.preventDefault();var r=e(this);i.find("input.siteorigin-widget-input").val("post: "+r.data("value")),i.change(),i.find(".existing-content-selector").toggle()});var n=null;i.find(".content-text-search").keyup(function(){null!==n&&clearTimeout(n),n=setTimeout(function(){r()},500)})}),void 0!==jQuery.fn.soPanelsSetupBuilderWidget&&u.filter(".siteorigin-widget-field-type-builder").each(function(){e(this).find("> .siteorigin-page-builder-field").each(function(){var i=e(this);i.soPanelsSetupBuilderWidget({builderType:i.data("type")})})});var v=function(){var i=e(this),t=i.closest("[data-state-emitter]").data("state-emitter");if(void 0!==t){var n={default:""};void 0===t.length&&(t=[t]);for(var a=0;a<t.length;a++)n=function(t,r){if(void 0===sowEmitters[t.callback]||"_"===t.callback.substr(0,1))return r;if(i.is('[type="radio"]')&&!i.is(":checked"))return r;var n=sowbForms.getContainerFieldId(i,"repeater",".siteorigin-widget-field-repeater-item");!1!==n&&(t.args=t.args.map(function(e){return e.replace("{$repeater}",n)}));var a=sowbForms.getContainerFieldId(i,"widget",".siteorigin-widget-widget");!1===a||t.hasOwnProperty("widgetFieldId")||(t.widgetFieldId=a,t.args=t.args.map(function(e){return e+"_"+a}));var s=i.is('[type="checkbox"]')?i.is(":checked"):i.val();return e.extend(r,sowEmitters[t.callback](s,t.args))}(t[a],n);var s=r.data("states");void 0===s&&(s={default:""});for(var o in n)void 0!==s[o]&&n[o]===s[o]||(s[o]=n[o],r.trigger("sowstatechange",[o,n[o]]));r.data("states",s)}};u.filter("[data-state-emitter]").each(function(){var i=e(this).find(".siteorigin-widget-input");i.on("keyup change",v),i.each(function(){var i=e(this);i.is(":radio")?i.is(":checked")&&v.call(i[0]):v.call(i[0])})}),n.trigger("sowsetupform",u).data("sow-form-setup",!0),u.trigger("sowsetupformfield"),n.find(".siteorigin-widget-field-repeater-item").trigger("updateFieldPositions"),(s.hasClass("wp-customizer")||s.hasClass("widgets-php"))&&n.closest(".ui-sortable").on("sortstop",function(e,i){i.item.find(".siteorigin-widget-form").find("> .siteorigin-widget-field").trigger("sowsetupformfield")}),a=!1})},e.fn.sowSetupPreview=function(){var i=e(this);i.siblings(".siteorigin-widget-preview").find("> a").click(function(t){t.preventDefault();var r=sowbForms.getWidgetFormValues(i),n=e(e("#so-widgets-bundle-tpl-preview-dialog").html().trim()).appendTo("body");n.find('input[name="data"]').val(JSON.stringify(r)),n.find('input[name="class"]').val(i.data("class")),n.find("iframe").on("load",function(){e(this).css("visibility","visible")}),n.find("form").submit(),n.find(".close").click(function(){n.remove()})})},e.fn.sowSetupRepeater=function(){return e(this).each(function(i,t){var r=e(t),n=r.find(".siteorigin-widget-field-repeater-items"),a=r.data("repeater-name");n.bind("updateFieldPositions",function(){var i=e(this),t=i.find("> .siteorigin-widget-field-repeater-item");t.each(function(i,t){e(t).find(".siteorigin-widget-input").each(function(t,r){var n=e(r).data("repeater-positions");void 0===n&&(n={}),n[a]=i,e(r).data("repeater-positions",n)})}),i.find(".siteorigin-widget-input").each(function(i,t){var r=e(t),n=r.data("repeater-positions");if(void 0!==n){var a=r.attr("data-original-name");if(a||(r.attr("data-original-name",r.attr("name")),a=r.attr("name")),!a)return;if(n)for(var s in n)a=a.replace("#"+s+"#",n[s]);r.attr("name",a)}}),i.data("initialSetup")||(i.find(".siteorigin-widget-input").each(function(i,t){var r=e(t);r.prop("checked",r.prop("defaultChecked"))}),i.data("initialSetup",!0));var n=r.data("scroll-count")?parseInt(r.data("scroll-count")):0;if(n>0&&t.length>n){var s=t.first().outerHeight();i.css("max-height",s*n).css("overflow","auto")}else i.css("max-height","").css("overflow","")}),n.sortable({handle:".siteorigin-widget-field-repeater-item-top",items:"> .siteorigin-widget-field-repeater-item",update:function(){n.find('input[type="radio"].siteorigin-widget-input').attr("name",""),n.trigger("updateFieldPositions"),r.trigger("change")},sortstop:function(i,t){if(t.item.is(".siteorigin-widget-field-repeater-item"))t.item.find("> .siteorigin-widget-field-repeater-item-form").each(function(){e(this).find("> .siteorigin-widget-field").trigger("sowsetupformfield")});else{t.item.find(".siteorigin-widget-form").find("> .siteorigin-widget-field").trigger("sowsetupformfield")}r.trigger("change")}}),n.trigger("updateFieldPositions"),r.find("> .siteorigin-widget-field-repeater-add").disableSelection().click(function(i){i.preventDefault(),r.closest(".siteorigin-widget-field-repeater").sowAddRepeaterItem().find("> .siteorigin-widget-field-repeater-items").slideDown("fast",function(){e(window).resize()})}),r.find("> .siteorigin-widget-field-repeater-top > .siteorigin-widget-field-repeater-expand").click(function(i){i.preventDefault(),r.closest(".siteorigin-widget-field-repeater").find("> .siteorigin-widget-field-repeateritems-").slideToggle("fast",function(){e(window).resize()})})})},e.fn.sowAddRepeaterItem=function(){return e(this).each(function(i,t){var r=e(t),n=r.find("> .siteorigin-widget-field-repeater-items").children().length+1,a=e("<div>"+r.find("> .siteorigin-widget-field-repeater-item-html").html()+"</div>");a.find(".siteorigin-widget-input[data-name]").each(function(){var i=e(this);0===i.closest(".siteorigin-widget-field-repeater-item-html").length&&i.attr("name",e(this).data("name"))});var s=a.html().replace(/_id_/g,n),o=void 0!==r.attr("readonly"),d=e('<div class="siteorigin-widget-field-repeater-item ui-draggable" />').append(e('<div class="siteorigin-widget-field-repeater-item-top" />').append(e('<div class="siteorigin-widget-field-expand" />')).append(o?"":e('<div class="siteorigin-widget-field-copy" />')).append(o?"":e('<div class="siteorigin-widget-field-remove" />')).append(e("<h4 />").html(r.data("item-name")))).append(e('<div class="siteorigin-widget-field-repeater-item-form" />').html(s));r.find("> .siteorigin-widget-field-repeater-items").append(d).sortable("refresh").trigger("updateFieldPositions"),d.sowSetupRepeaterItems(),d.hide().slideDown("fast",function(){e(window).resize()}),r.trigger("change")})},e.fn.sowRemoveRepeaterItem=function(){return e(this).each(function(i,t){var r=e(this).closest(".siteorigin-widget-field-repeater-items");e(this).remove(),r.sortable("refresh").trigger("updateFieldPositions"),e(t).trigger("change")})},e.fn.sowSetupRepeaterItems=function(){return e(this).each(function(i,t){var r=e(t);if(void 0===r.data("sowrepeater-actions-setup")){var n=r.closest(".siteorigin-widget-field-repeater"),a=r.find("> .siteorigin-widget-field-repeater-item-top"),s=n.data("item-label");if(s&&s.selector){var o=function(){var e=s.hasOwnProperty("valueMethod")&&s.valueMethod?s.valueMethod:"val",i=r.find(s.selector)[e]();i&&(i.length>80&&(i=i.substr(0,79)+"..."),a.find("h4").text(i))};o();var d=s.hasOwnProperty("updateEvent")&&s.updateEvent?s.updateEvent:"change";r.bind(d,o)}a.click(function(i){"siteorigin-widget-field-remove"!==i.target.className&&"siteorigin-widget-field-copy"!==i.target.className&&(i.preventDefault(),e(this).closest(".siteorigin-widget-field-repeater-item").find(".siteorigin-widget-field-repeater-item-form").eq(0).slideToggle("fast",function(){if(e(window).resize(),e(this).is(":visible")){e(this).trigger("slideToggleOpenComplete");e(this).find("> .siteorigin-widget-field").trigger("sowsetupformfield")}else e(this).trigger("slideToggleCloseComplete")}))}),a.find(".siteorigin-widget-field-remove").click(function(i,t){i.preventDefault();var n=e(this).closest(".siteorigin-widget-field-repeater-items"),a=e(this).closest(".siteorigin-widget-field-repeater-item"),s=function(){a.remove(),n.sortable("refresh").trigger("updateFieldPositions"),e(window).resize()};t&&t.silent?s():confirm(soWidgets.sure)&&a.slideUp("fast",s),r.trigger("change")}),a.find(".siteorigin-widget-field-copy").click(function(i){i.preventDefault();var t=e(this).closest(".siteorigin-widget-form-main"),n=e(this).closest(".siteorigin-widget-field-repeater-item"),a=n.clone(),s=n.closest(".siteorigin-widget-field-repeater-items"),o=s.children().length,d={};a.find("*[name]").each(function(){var i=e(this),s=i.attr("id"),l=i.attr("name");if(i.is("textarea")&&i.parent().is(".wp-editor-container")&&"undefined"!=typeof tinymce){i.parent().empty().append(i),i.css("display","");var g=tinymce.get(s);g&&i.val(g.getContent())}else if(i.is(".wp-color-picker")){var f=i.closest(".wp-picker-container"),c=i.closest(".siteorigin-widget-field");f.remove(),c.append(i.remove())}else{var p=s?n.find("#"+s):n.find('[name="'+l+'"]');p.length&&null!=p.val()&&i.val(p.val())}if(s){var u,m,w;if(i.is('[type="radio"]')){m=s.replace(/-\d+-\d+$/,"");var v=s.replace(/-\d+$/,"");if(!d[m]){var h={};d[m]=t.find(".siteorigin-widget-input[id^="+m+"]").not("[id*=_id_]").filter(function(i,t){var r=e(t).attr("name");return!h[r]&&(h[r]=!0,!0)}).length+1}var b=m+"-"+d[m];w=b+s.match(/-\d+$/)[0],a.find("label[for="+v+"]").attr("for",b)}else u=new RegExp("-\\d+$"),m=s.replace(u,""),d[m]||(d[m]=t.find(".siteorigin-widget-input[id^="+m+"]").not("[id*=_id_]").length+1),w=m+"-"+d[m]++;if(i.attr("id",w),i.is(".wp-editor-area")){var y=i.closest(".siteorigin-widget-tinymce-container"),F=y.data("media-buttons");if(F&&F.html){var u=new RegExp(s,"g");F.html=F.html.replace(u,w),y.data("media-buttons",F)}}a.find("label[for="+s+"]").attr("for",w),a.find("[id*="+s+"]").each(function(){var i=e(this).attr("id"),t=i.replace(s,w);e(this).attr("id",t)}),"undefined"!=typeof tinymce&&tinymce.get(w)&&tinymce.get(w).remove()}var k=n.parents(".siteorigin-widget-field-repeater").length,_=e("body");(_.hasClass("wp-customizer")||_.hasClass("widgets-php"))&&0===r.closest(".panel-dialog").length&&(k+=1);var C=l.replace(new RegExp("((?:.*?\\[\\d+\\]){"+(k-1).toString()+"})?(.*?\\[)\\d+(\\])"),"$1$2"+o.toString()+"$3");i.attr("name",C),i.data("original-name",C)}),s.append(a).sortable("refresh").trigger("updateFieldPositions"),a.sowSetupRepeaterItems(),a.hide().slideDown("fast",function(){e(window).resize()}),r.trigger("change")}),r.find("> .siteorigin-widget-field-repeater-item-form").sowSetupForm(),r.data("sowrepeater-actions-setup",!0)}})},sowbForms.getContainerFieldId=function(e,i,t){var r=i+"FieldId";this.hasOwnProperty(r)||(this[r]=1);var n=e.closest(t);if(n.length){var a=n.data("field-id");return void 0===a&&(a=this[r]++),n.data("field-id",a),a}return!1},sowbForms.getWidgetFieldVariable=function(e,i,t){var r=window.sow_field_javascript_variables[e];i=i.replace(/\[#.*?#\]/g,"");for(var n=/[a-zA-Z0-9\-]+(?:\[c?[0-9]+\])?\[(.*)\]/.exec(i)[1],a=n.split("]["),s=a.length?r:null;a.length;)s=s[a.shift()];return s[t]},sowbForms.fetchWidgetVariable=function(i,t,r){window.sowVars=window.sowVars||{},void 0===window.sowVars[t]?e.post(soWidgets.ajaxurl,{action:"sow_get_javascript_variables",widget:t,key:i},function(e){window.sowVars[t]=e,r(window.sowVars[t][i])}):r(window.sowVars[t][i])},sowbForms.getWidgetFormValues=function(i){if(_.isUndefined(i))return null;var t={};return i.find("*[name]").each(function(){var i=e(this);try{var r=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(_.isEmpty(r))return!0;r=r[1];var n=r.split("][");n=n.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});var a=t,s=null,o=_.isString(i.attr("type"))?i.attr("type").toLowerCase():null;if("checkbox"===o)s=!!i.is(":checked")&&(""===i.val()||i.val());else if("radio"===o){if(!i.is(":checked"))return;s=i.val()}else if("TEXTAREA"===i.prop("tagName")&&i.hasClass("wp-editor-area")){var d=null;"undefined"!=typeof tinyMCE&&(d=tinyMCE.get(i.attr("id"))),s=null===d||"function"!=typeof d.getContent||d.isHidden()?i.val():d.getContent()}else if("SELECT"===i.prop("tagName")){var l=i.find("option:selected");1===l.length?s=i.find("option:selected").val():l.length>1&&(s=_.map(i.find("option:selected"),function(i,t){return e(i).val()}))}else s=i.val();for(var g=0;g<n.length;g++)g===n.length-1?""===n[g]?a.push(s):a[n[g]]=s:(_.isUndefined(a[n[g]])&&(_.isNumber(n[g+1])||""===n[g+1]?a[n[g]]=[]:a[n[g]]={}),a=a[n[g]])}catch(e){console.error("Field ["+i.attr("name")+"] could not be processed and was skipped - "+e.message)}}),t},sowbForms.setWidgetFormValues=function(i,t,r,n){r=r||!1,n=void 0!==n&&n||void 0===n;var a=0,s=function(i,t){if(10==++a)return void--a;i.find("> .siteorigin-widget-field-type-repeater,> .siteorigin-widget-field-type-section > .siteorigin-widget-section > .siteorigin-widget-field-type-repeater").each(function(i,n){var a=e(this),o=a.find("> .siteorigin-widget-field-repeater"),d=o.data("repeaterName"),l=t.hasOwnProperty(d)?t[d]:null;if(a.parent().is(".siteorigin-widget-section")){var g=o.data("element-name");g=g.replace(/\[#.*?#\]/g,"");for(var f=/[a-zA-Z0-9\-]+(?:\[c?[0-9]+\])?\[(.*)\]/.exec(g)[1],c=f.split("]["),p=c.length?t:null;c.length;){var u=c.shift();p=p.hasOwnProperty(u)?p[u]:p}l=p}if(l&&Array.isArray(l)){var m=o.find("> .siteorigin-widget-field-repeater-items > .siteorigin-widget-field-repeater-item"),w=l.length,v=m.length;if(w>v)for(var h=0;h<w-v;h++)o.find("> .siteorigin-widget-field-repeater-add").click();else if(!r&&w<v)for(var b=w;b<v;b++){var y=e(m.eq(b));y.find("> .siteorigin-widget-field-repeater-item-top").find(".siteorigin-widget-field-remove").trigger("click",{silent:!0})}m=o.find("> .siteorigin-widget-field-repeater-items > .siteorigin-widget-field-repeater-item");for(var F=0;F<m.length;F++)m.eq(F).find("> .siteorigin-widget-field-repeater-item-form"),s(m.eq(F).find("> .siteorigin-widget-field-repeater-item-form"),l[F])}}),--a};s(i,t),i.find("*[name]").each(function(){var i=e(this),a=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(void 0===a||null===a)return!0;a=a[1];var s=a.split("][");s=s.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});for(var o,d=t,l=0;l<s.length;l++){if(!d.hasOwnProperty(s[l])){if(r)return!0;break}l===s.length-1?o=d[s[l]]:d=d[s[l]]}if("checkbox"===i.attr("type"))i.prop("checked",o);else if("radio"===i.attr("type"))i.prop("checked",o===i.val());else if("TEXTAREA"===i.prop("tagName")&&i.hasClass("wp-editor-area")){var g=null;"undefined"!=typeof tinyMCE&&(g=tinyMCE.get(i.attr("id"))),null!==g&&"function"==typeof g.setContent&&!g.isHidden()&&i.parent().is(":visible")?g.initialized?g.setContent(o):g.on("init",function(){g.setContent(o)}):i.val(o)}else i.val(o);n&&i.trigger("change")})},e(".widgets-holder-wrap").on("click",".widget:has(.siteorigin-widget-form-main) .widget-top",function(){var i=e(this).closest(".widget").find(".siteorigin-widget-form-main");setTimeout(function(){i.sowSetupForm()},200)});var i=e("body");i.hasClass("wp-customizer")&&e(document).on("widget-added",function(e,i){i.find(".siteorigin-widget-form").sowSetupForm()}),i.hasClass("gutenberg-editor-page")&&e(document).on("panels_setup_preview",function(){e(sowb).trigger("setup_widgets")}),e(document).on("open_dialog",function(i,t){if(t.$el.find(".so-panels-dialog").is(".so-panels-dialog-edit-widget")){e(i.target).find(".siteorigin-widget-form-main").find("> .siteorigin-widget-field").trigger("sowsetupformfield")}}),e(function(){e(document).trigger("sowadminloaded")})}(jQuery);var sowEmitters={_match:function(e,i){void 0===i&&(i=".*");var t=new RegExp("^([a-zA-Z0-9_-]+)(\\[([a-zA-Z0-9_-]+)\\])? *: *("+i+") *$"),r=t.exec(e);if(null===r)return!1;var n="",a="default";return void 0!==r[3]?(a=r[1],n=r[3]):n=r[1],{match:r[4].trim(),group:a,state:n}},_checker:function(e,i,t,r){var n={};void 0===i.length&&(i=[i]);for(var a,s=0;s<i.length;s++)!1!==(a=sowEmitters._match(i[s],t))&&("_true"===a.match||r(e,i,a.match))&&(n[a.group]=a.state);return n},select:function(e,i){void 0===i.length&&(i=[i]);for(var t={},r=0;r<i.length;r++)""===i[r]&&(i[r]="default"),t[i[r]]=e;return t},conditional:function(val,args){return sowEmitters._checker(val,args,"[^;{}]*",function(val,args,match){return eval(match)})},in:function(e,i){return sowEmitters._checker(e,i,"[^;{}]*",function(e,i,t){return-1!==t.split(",").map(function(e){return e.trim()}).indexOf(e)})}};window.sowbForms=sowbForms;
base/js/meta-box-manager.js CHANGED
@@ -1,63 +1,13 @@
1
- /* globals jQuery */
2
-
3
- //Catch Update button click and transform widgets post meta data before event is propagated.
4
- (function ($) {
5
- $('#publish').click(
6
- function (event) {
7
- var data = {};
8
- var $el = $('#siteorigin-widgets-meta-box');
9
- // This uses the exact same code to extract the model from the view as in the admin.js so could do with some refactoring.
10
- $el.find('*[name]').each(function () {
11
- var $$ = $(this);
12
- var name = /[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec($$.attr('name'));
13
-
14
- if (!name) {
15
- return;
16
- }
17
-
18
- name = name[1];
19
- var parts = name.split('][');
20
-
21
- // Make sure we either have numbers or strings
22
- parts = parts.map(function (e) {
23
- if (!isNaN(parseFloat(e)) && isFinite(e)) {
24
- return parseInt(e);
25
- }
26
- else {
27
- return e;
28
- }
29
- });
30
-
31
- var sub = data;
32
- for (var i = 0; i < parts.length; i++) {
33
- if (i === parts.length - 1) {
34
- // This is the end, so we need to store the actual field value here
35
- if ($$.attr('type') === 'checkbox') {
36
- if ($$.is(':checked')) {
37
- sub[parts[i]] = $$.val() !== '' ? $$.val() : true;
38
- } else {
39
- sub[parts[i]] = false;
40
- }
41
- }
42
- else if ($$.attr('type') === 'radio') {
43
- if ($$.is(':checked')) {
44
- sub[parts[i]] = $$.val() !== '' ? $$.val() : true;
45
- }
46
- }
47
- else {
48
- sub[parts[i]] = $$.val();
49
- }
50
- }
51
- else {
52
- if (typeof sub[parts[i]] === 'undefined') {
53
- sub[parts[i]] = {};
54
- }
55
- // Go deeper into the data and continue
56
- sub = sub[parts[i]];
57
- }
58
- }
59
- });
60
- $el.find('input[name="widget_post_meta"]').val(JSON.stringify(data));
61
- }
62
- );
63
- })(jQuery);
1
+ /* globals jQuery, sowbForms */
2
+
3
+ //Catch Update button click and transform widgets post meta data before event is propagated.
4
+ (function ($) {
5
+ $('#post').on( 'submit',
6
+ function ( event ) {
7
+ var $el = $( '#siteorigin-widgets-meta-box' );
8
+ var data = sowbForms.getWidgetFormValues( $el );
9
+
10
+ $el.find( 'input[name="widget_post_meta"]' ).val( JSON.stringify( data ) );
11
+ }
12
+ );
13
+ })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
base/js/meta-box-manager.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){t("#publish").click(function(a){var i={},e=t("#siteorigin-widgets-meta-box");e.find("*[name]").each(function(){var a=t(this),e=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(a.attr("name"));if(e){e=e[1];var n=e.split("][");n=n.map(function(t){return!isNaN(parseFloat(t))&&isFinite(t)?parseInt(t):t});for(var r=i,c=0;c<n.length;c++)c===n.length-1?"checkbox"===a.attr("type")?a.is(":checked")?r[n[c]]=""===a.val()||a.val():r[n[c]]=!1:"radio"===a.attr("type")?a.is(":checked")&&(r[n[c]]=""===a.val()||a.val()):r[n[c]]=a.val():(void 0===r[n[c]]&&(r[n[c]]={}),r=r[n[c]])}}),e.find('input[name="widget_post_meta"]').val(JSON.stringify(i))})}(jQuery);
1
+ !function(t){t("#post").on("submit",function(i){var e=t("#siteorigin-widgets-meta-box"),n=sowbForms.getWidgetFormValues(e);e.find('input[name="widget_post_meta"]').val(JSON.stringify(n))})}(jQuery);
base/siteorigin-widget.class.php CHANGED
@@ -237,6 +237,11 @@ abstract class SiteOrigin_Widget extends WP_Widget {
237
  echo '</div>';
238
  echo $args['after_widget'];
239
  do_action( 'siteorigin_widgets_after_widget_' . $this->id_base, $instance, $this );
 
 
 
 
 
240
  }
241
 
242
  private function get_wrapper_data( $instance ) {
@@ -1314,10 +1319,11 @@ abstract class SiteOrigin_Widget extends WP_Widget {
1314
 
1315
  // Check if the general request is a preview
1316
  $is_preview =
1317
- is_preview() || // is this a standard preview
1318
- $this->is_customize_preview() || // Is this a customizer preview
1319
- !empty( $_GET['siteorigin_panels_live_editor'] ) || // Is this a Page Builder live editor request
1320
- ( !empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'so_panels_builder_content' ); // Is this a Page Builder content ajax request
 
1321
 
1322
  return apply_filters( 'siteorigin_widgets_is_preview', $is_preview, $this );
1323
  }
237
  echo '</div>';
238
  echo $args['after_widget'];
239
  do_action( 'siteorigin_widgets_after_widget_' . $this->id_base, $instance, $this );
240
+
241
+ if ( $this->is_preview( $instance ) ) {
242
+ // print inline styles if we're preview the widget.
243
+ siteorigin_widget_print_styles();
244
+ }
245
  }
246
 
247
  private function get_wrapper_data( $instance ) {
1319
 
1320
  // Check if the general request is a preview
1321
  $is_preview =
1322
+ is_preview() || // Is this a standard preview
1323
+ $this->is_customize_preview() || // Is this a customizer preview
1324
+ !empty( $_GET['siteorigin_panels_live_editor'] ) || // Is this a Page Builder live editor request
1325
+ ( !empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'so_panels_builder_content' ) || // Is this a Page Builder content ajax request
1326
+ ! empty( $GLOBALS[ 'SITEORIGIN_PANELS_PREVIEW_RENDER' ] ); // Is this a Page Builder preview render.
1327
 
1328
  return apply_filters( 'siteorigin_widgets_is_preview', $is_preview, $this );
1329
  }
compat/compat.php CHANGED
@@ -21,6 +21,10 @@ class SiteOrigin_Widgets_Bundle_Compatibility {
21
  if ( ! empty( $builder ) ) {
22
  require_once $builder['file_path'];
23
  }
 
 
 
 
24
  }
25
 
26
  function get_active_builder() {
21
  if ( ! empty( $builder ) ) {
22
  require_once $builder['file_path'];
23
  }
24
+
25
+ if ( function_exists( 'register_block_type' ) ) {
26
+ require_once plugin_dir_path( __FILE__ ) . 'gutenberg/gutenberg.php';
27
+ }
28
  }
29
 
30
  function get_active_builder() {
compat/elementor/elementor.php CHANGED
@@ -101,14 +101,6 @@ class SiteOrigin_Widgets_Bundle_Elementor {
101
 
102
  function ajax_render_widget_preview() {
103
  add_filter( 'siteorigin_widgets_is_preview', '__return_true' );
104
- add_filter( 'elementor/widget/render_content', array( $this, 'render_widget_preview' ) );
105
- }
106
-
107
- function render_widget_preview( $widget_output ) {
108
-
109
- siteorigin_widget_print_styles();
110
-
111
- return $widget_output;
112
  }
113
 
114
  function ajax_render_widget_form() {
101
 
102
  function ajax_render_widget_preview() {
103
  add_filter( 'siteorigin_widgets_is_preview', '__return_true' );
 
 
 
 
 
 
 
 
104
  }
105
 
106
  function ajax_render_widget_form() {
compat/gutenberg/gutenberg.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SiteOrigin_Widgets_Bundle_Gutenberg_Block {
4
+ /**
5
+ * Get the singleton instance
6
+ *
7
+ * @return SiteOrigin_Widgets_Bundle_Gutenberg_Block
8
+ */
9
+ public static function single() {
10
+ static $single;
11
+
12
+ return empty( $single ) ? $single = new self() : $single;
13
+ }
14
+
15
+ public function __construct() {
16
+ add_action( 'init', array( $this, 'register_widget_block' ) );
17
+ add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_widget_block_editor_assets' ) );
18
+ }
19
+
20
+ public function register_widget_block() {
21
+ register_block_type( 'sowb/widget-block', array(
22
+ 'render_callback' => array( $this, 'render_widget_block' ),
23
+ ) );
24
+ }
25
+
26
+ public function enqueue_widget_block_editor_assets() {
27
+ wp_enqueue_script(
28
+ 'sowb-widget-block',
29
+ plugins_url( 'widget-block' . SOW_BUNDLE_JS_SUFFIX . '.js', __FILE__ ),
30
+ array( 'wp-editor', 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-compose' ),
31
+ SOW_BUNDLE_VERSION
32
+ );
33
+ wp_localize_script(
34
+ 'sowb-widget-block',
35
+ 'sowbGutenbergAdmin',
36
+ array(
37
+ 'restUrl' => esc_url_raw( rest_url() ),
38
+ 'nonce' => wp_create_nonce( 'wp_rest' ),
39
+ )
40
+ );
41
+
42
+ $so_widgets_bundle = SiteOrigin_Widgets_Bundle::single();
43
+ // This is to ensure necessary scripts can be enqueued for previews.
44
+ $so_widgets_bundle->register_general_scripts();
45
+
46
+ global $wp_widget_factory;
47
+
48
+ foreach ( $wp_widget_factory->widgets as $class => $widget_obj ) {
49
+ if ( ! empty( $widget_obj ) && is_object( $widget_obj ) && is_subclass_of( $widget_obj, 'SiteOrigin_Widget' ) ) {
50
+ /* @var $widget_obj SiteOrigin_Widget */
51
+ ob_start();
52
+ $widget_obj->form( array() );
53
+ // Enqueue scripts for previews.
54
+ $widget_obj->widget( array(), array() );
55
+ ob_clean();
56
+ }
57
+ }
58
+ }
59
+
60
+ public function render_widget_block( $attributes ) {
61
+ if ( empty( $attributes['widgetClass'] ) ) {
62
+ return '<div>'.
63
+ __( 'You need to select a widget type before you\'ll see anything here. :)', 'so-widgets-bundle' ) .
64
+ '</div>';
65
+ }
66
+
67
+ $widget_class = $attributes['widgetClass'];
68
+
69
+ global $wp_widget_factory;
70
+
71
+ $widget = ! empty( $wp_widget_factory->widgets[ $widget_class ] ) ? $wp_widget_factory->widgets[ $widget_class ] : false;
72
+
73
+ $instance = $attributes['widgetData'];
74
+
75
+ if ( ! empty( $widget ) && is_object( $widget ) && is_subclass_of( $widget, 'SiteOrigin_Widget' ) ) {
76
+ ob_start();
77
+ /* @var $widget SiteOrigin_Widget */
78
+ $instance = $widget->update( $instance, $instance );
79
+ $widget->widget( array(), $instance );
80
+ $rendered_widget = ob_get_clean();
81
+ } else {
82
+ $rendered_widget = new WP_Error( '', 'Invalid widget class.' );
83
+ }
84
+ return $rendered_widget;
85
+ }
86
+ }
87
+
88
+ SiteOrigin_Widgets_Bundle_Gutenberg_Block::single();
compat/gutenberg/widget-block.js ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ( function ( editor, blocks, i18n, element, components, compose ) {
2
+
3
+ var el = element.createElement;
4
+ var registerBlockType = blocks.registerBlockType;
5
+ var BlockControls = editor.BlockControls;
6
+ var SelectControl = components.SelectControl;
7
+ var withState = compose.withState;
8
+ var Toolbar = components.Toolbar;
9
+ var IconButton = components.IconButton;
10
+ var Placeholder = components.Placeholder;
11
+ var Spinner = components.Spinner;
12
+ var __ = i18n.__;
13
+
14
+ registerBlockType( 'sowb/widget-block', {
15
+ title: __( 'SiteOrigin Widget' ),
16
+
17
+ description: __( 'Select a SiteOrigin widget from the dropdown.' ),
18
+
19
+ icon: function() {
20
+ return el(
21
+ 'span',
22
+ {
23
+ className: 'widget-icon so-widget-icon so-gutenberg-icon'
24
+ }
25
+ )
26
+ },
27
+
28
+ category: 'widgets',
29
+
30
+ supports: {
31
+ html: false,
32
+ },
33
+
34
+ attributes: {
35
+ widgetClass: {
36
+ type: 'string',
37
+ },
38
+ widgetData: {
39
+ type: 'object',
40
+ }
41
+ },
42
+
43
+ edit: withState( {
44
+ loadingWidgets: true,
45
+ editing: false,
46
+ formInitialized: false,
47
+ previewInitialized: false,
48
+ widgets: null,
49
+ widgetFormHtml: '',
50
+ widgetPreviewHtml: '',
51
+ } )( function ( props ) {
52
+
53
+ if ( props.loadingWidgets ) {
54
+ $.get( {
55
+ url: sowbGutenbergAdmin.restUrl + 'sowb/v1/widgets',
56
+ beforeSend: function ( xhr ) {
57
+ xhr.setRequestHeader( 'X-WP-Nonce', sowbGutenbergAdmin.nonce );
58
+ }
59
+ } )
60
+ .then( function( widgets ) {
61
+ var newState = { widgets: widgets, loadingWidgets: false };
62
+ if ( !props.attributes.widgetClass ) {
63
+ newState.editing = true;
64
+ }
65
+ props.setState( newState );
66
+ } );
67
+ }
68
+
69
+ function onWidgetClassChange( newWidgetClass ) {
70
+ if ( newWidgetClass !== '' ) {
71
+ props.setAttributes( { widgetClass: newWidgetClass, widgetData: null } );
72
+ props.setState( { widgetFormHtml: null, formInitialized: false, widgetPreviewHtml: null, previewInitialized: false } );
73
+ }
74
+ }
75
+
76
+ function switchToEditing() {
77
+ props.setState( { editing: true, formInitialized: false } );
78
+ }
79
+
80
+ function switchToPreview() {
81
+ props.setState( { editing: false, previewInitialized: false } );
82
+ }
83
+
84
+ function setupWidgetForm( formContainer ) {
85
+ var $mainForm = $( formContainer ).find( '.siteorigin-widget-form-main' );
86
+ if ( $mainForm.length > 0 && ! props.formInitialized ) {
87
+ var $previewContainer = $mainForm.siblings('.siteorigin-widget-preview');
88
+ $previewContainer.find( '> a' ).on( 'click', function ( event ) {
89
+ event.stopImmediatePropagation();
90
+ switchToPreview();
91
+ } );
92
+ $mainForm.data( 'backupDisabled', true );
93
+ $mainForm.sowSetupForm();
94
+ if ( props.attributes.widgetData ) {
95
+ // If we call `setWidgetFormValues` with the last parameter ( `triggerChange` ) set to false,
96
+ // it won't show the correct values for some fields e.g. color and media fields.
97
+ sowbForms.setWidgetFormValues( $mainForm, props.attributes.widgetData );
98
+ } else {
99
+ props.setAttributes( { widgetData: sowbForms.getWidgetFormValues( $mainForm ) } );
100
+ }
101
+ $mainForm.on( 'change', function () {
102
+ props.setAttributes( { widgetData: sowbForms.getWidgetFormValues( $mainForm ) } );
103
+ props.setState( { widgetPreviewHtml: null, previewInitialized: false } );
104
+ } );
105
+ props.setState( { formInitialized: true } );
106
+ }
107
+ }
108
+
109
+ function setupWidgetPreview() {
110
+ if ( ! props.previewInitialized ) {
111
+ $( window.sowb ).trigger( 'setup_widgets' );
112
+ props.setState( { previewInitialized: true } );
113
+ }
114
+ }
115
+
116
+ if ( props.editing ) {
117
+ var widgetsOptions = [];
118
+ if ( props.widgets ) {
119
+ props.widgets.sort( function ( a, b ) {
120
+ if ( a.name < b.name ) {
121
+ return -1;
122
+ } else if ( a.name > b.name ) {
123
+ return 1;
124
+ }
125
+ return 0;
126
+ } );
127
+ widgetsOptions = props.widgets.map( function ( widget ) {
128
+ return { value: widget.class, label: widget.name };
129
+ } );
130
+ widgetsOptions.unshift( { value: '', label: __( 'Select widget type' ) } );
131
+ }
132
+
133
+ var loadingWidgetForm = props.attributes.widgetClass && !props.widgetFormHtml;
134
+ if ( loadingWidgetForm ) {
135
+ $.get( {
136
+ url: sowbGutenbergAdmin.restUrl + 'sowb/v1/widgets/forms',
137
+ beforeSend: function ( xhr ) {
138
+ xhr.setRequestHeader( 'X-WP-Nonce', sowbGutenbergAdmin.nonce );
139
+ },
140
+ data: {
141
+ widgetClass: props.attributes.widgetClass
142
+ }
143
+ } )
144
+ .then( function( widgetForm ) {
145
+ props.setState( { widgetFormHtml: widgetForm } );
146
+ } );
147
+ }
148
+
149
+ var widgetForm = props.widgetFormHtml ? props.widgetFormHtml : '';
150
+
151
+ return [
152
+ !! widgetForm && el(
153
+ BlockControls,
154
+ { key: 'controls' },
155
+ el(
156
+ Toolbar,
157
+ null,
158
+ el(
159
+ IconButton,
160
+ {
161
+ className: 'components-icon-button components-toolbar__control',
162
+ label: __( 'Preview widget.' ),
163
+ onClick: switchToPreview,
164
+ icon: 'visibility'
165
+ }
166
+ )
167
+ )
168
+ ),
169
+ el(
170
+ Placeholder,
171
+ {
172
+ key: 'placeholder',
173
+ className: 'so-widget-placeholder',
174
+ label: __( 'SiteOrigin Widget' ),
175
+ instructions: __( 'Select the type of widget you want to use:' )
176
+ },
177
+ ( props.loadingWidgets || loadingWidgetForm ?
178
+ el( Spinner ) :
179
+ el(
180
+ 'div',
181
+ { className: 'so-widget-gutenberg-container' },
182
+ el(
183
+ SelectControl,
184
+ {
185
+ options: widgetsOptions,
186
+ value: props.attributes.widgetClass,
187
+ onChange: onWidgetClassChange,
188
+ }
189
+ ),
190
+ el( 'div', {
191
+ className: 'so-widget-gutenberg-form-container',
192
+ dangerouslySetInnerHTML: { __html: widgetForm },
193
+ ref: setupWidgetForm,
194
+ } )
195
+ )
196
+ )
197
+ )
198
+ ];
199
+ } else {
200
+
201
+ var loadingWidgetPreview = !props.editing && !props.widgetPreviewHtml;
202
+ if ( loadingWidgetPreview ) {
203
+ $.get( {
204
+ url: sowbGutenbergAdmin.restUrl + 'sowb/v1/widgets/previews',
205
+ beforeSend: function ( xhr ) {
206
+ xhr.setRequestHeader( 'X-WP-Nonce', sowbGutenbergAdmin.nonce );
207
+ },
208
+ data: {
209
+ widgetClass: props.attributes.widgetClass,
210
+ widgetData: props.attributes.widgetData || {}
211
+ }
212
+ } )
213
+ .then( function( widgetPreview ) {
214
+ props.setState( { widgetPreviewHtml: widgetPreview } );
215
+ } );
216
+ }
217
+ var widgetPreview = props.widgetPreviewHtml ? props.widgetPreviewHtml : '';
218
+ return [
219
+ el(
220
+ BlockControls,
221
+ { key: 'controls' },
222
+ el(
223
+ Toolbar,
224
+ null,
225
+ el(
226
+ IconButton,
227
+ {
228
+ className: 'components-icon-button components-toolbar__control',
229
+ label: __( 'Edit widget.' ),
230
+ onClick: switchToEditing,
231
+ icon: 'edit'
232
+ }
233
+ )
234
+ )
235
+ ),
236
+ el(
237
+ 'div',
238
+ {
239
+ key: 'preview',
240
+ className: 'so-widget-gutenberg-preview-container'
241
+ },
242
+ ( loadingWidgetPreview ?
243
+ el( 'div', {
244
+ className: 'so-widgets-spinner-container'
245
+ },
246
+ el(
247
+ 'span',
248
+ null,
249
+ el( Spinner )
250
+ )
251
+ ) :
252
+ el( 'div', {
253
+ dangerouslySetInnerHTML: { __html: widgetPreview },
254
+ ref: setupWidgetPreview,
255
+ } )
256
+ )
257
+ )
258
+ ];
259
+ }
260
+ } ),
261
+
262
+ save: function () {
263
+ // Render in PHP
264
+ return null;
265
+ }
266
+ } );
267
+ } )( window.wp.editor, window.wp.blocks, window.wp.i18n, window.wp.element, window.wp.components, window.wp.compose );
compat/gutenberg/widget-block.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e,t,i,n,o,s){var r=n.createElement,a=t.registerBlockType,d=e.BlockControls,l=o.SelectControl,w=s.withState,g=o.Toolbar,u=o.IconButton,c=o.Placeholder,m=o.Spinner,b=i.__;a("sowb/widget-block",{title:b("SiteOrigin Widget"),description:b("Select a SiteOrigin widget from the dropdown."),icon:function(){return r("span",{className:"widget-icon so-widget-icon so-gutenberg-icon"})},category:"widgets",supports:{html:!1},attributes:{widgetClass:{type:"string"},widgetData:{type:"object"}},edit:w({loadingWidgets:!0,editing:!1,formInitialized:!1,previewInitialized:!1,widgets:null,widgetFormHtml:"",widgetPreviewHtml:""})(function(e){function t(t){""!==t&&(e.setAttributes({widgetClass:t,widgetData:null}),e.setState({widgetFormHtml:null,formInitialized:!1,widgetPreviewHtml:null,previewInitialized:!1}))}function i(){e.setState({editing:!0,formInitialized:!1})}function n(){e.setState({editing:!1,previewInitialized:!1})}function o(t){var i=$(t).find(".siteorigin-widget-form-main");if(i.length>0&&!e.formInitialized){i.siblings(".siteorigin-widget-preview").find("> a").on("click",function(e){e.stopImmediatePropagation(),n()}),i.data("backupDisabled",!0),i.sowSetupForm(),e.attributes.widgetData?sowbForms.setWidgetFormValues(i,e.attributes.widgetData):e.setAttributes({widgetData:sowbForms.getWidgetFormValues(i)}),i.on("change",function(){e.setAttributes({widgetData:sowbForms.getWidgetFormValues(i)}),e.setState({widgetPreviewHtml:null,previewInitialized:!1})}),e.setState({formInitialized:!0})}}function s(){e.previewInitialized||($(window.sowb).trigger("setup_widgets"),e.setState({previewInitialized:!0}))}if(e.loadingWidgets&&$.get({url:sowbGutenbergAdmin.restUrl+"sowb/v1/widgets",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",sowbGutenbergAdmin.nonce)}}).then(function(t){var i={widgets:t,loadingWidgets:!1};e.attributes.widgetClass||(i.editing=!0),e.setState(i)}),e.editing){var a=[];e.widgets&&(e.widgets.sort(function(e,t){return e.name<t.name?-1:e.name>t.name?1:0}),a=e.widgets.map(function(e){return{value:e.class,label:e.name}}),a.unshift({value:"",label:b("Select widget type")}));var w=e.attributes.widgetClass&&!e.widgetFormHtml;w&&$.get({url:sowbGutenbergAdmin.restUrl+"sowb/v1/widgets/forms",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",sowbGutenbergAdmin.nonce)},data:{widgetClass:e.attributes.widgetClass}}).then(function(t){e.setState({widgetFormHtml:t})});var p=e.widgetFormHtml?e.widgetFormHtml:"";return[!!p&&r(d,{key:"controls"},r(g,null,r(u,{className:"components-icon-button components-toolbar__control",label:b("Preview widget."),onClick:n,icon:"visibility"}))),r(c,{key:"placeholder",className:"so-widget-placeholder",label:b("SiteOrigin Widget"),instructions:b("Select the type of widget you want to use:")},e.loadingWidgets||w?r(m):r("div",{className:"so-widget-gutenberg-container"},r(l,{options:a,value:e.attributes.widgetClass,onChange:t}),r("div",{className:"so-widget-gutenberg-form-container",dangerouslySetInnerHTML:{__html:p},ref:o})))]}var f=!e.editing&&!e.widgetPreviewHtml;f&&$.get({url:sowbGutenbergAdmin.restUrl+"sowb/v1/widgets/previews",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",sowbGutenbergAdmin.nonce)},data:{widgetClass:e.attributes.widgetClass,widgetData:e.attributes.widgetData||{}}}).then(function(t){e.setState({widgetPreviewHtml:t})});var v=e.widgetPreviewHtml?e.widgetPreviewHtml:"";return[r(d,{key:"controls"},r(g,null,r(u,{className:"components-icon-button components-toolbar__control",label:b("Edit widget."),onClick:i,icon:"edit"}))),r("div",{key:"preview",className:"so-widget-gutenberg-preview-container"},f?r("div",{className:"so-widgets-spinner-container"},r("span",null,r(m))):r("div",{dangerouslySetInnerHTML:{__html:v},ref:s}))]}),save:function(){return null}})}(window.wp.editor,window.wp.blocks,window.wp.i18n,window.wp.element,window.wp.components,window.wp.compose);
js/slider/jquery.slider.js CHANGED
@@ -70,6 +70,12 @@ jQuery( function($){
70
 
71
  $('.sow-slider-images').each(function(){
72
  var $$ = $(this);
 
 
 
 
 
 
73
  var $p = $$.siblings('.sow-slider-pagination');
74
  var $base = $$.closest('.sow-slider-base');
75
  var $n = $base.find('.sow-slide-nav');
@@ -256,6 +262,8 @@ jQuery( function($){
256
  if(images.length === 0) {
257
  setupSlider();
258
  }
 
 
259
  });
260
  };
261
  sowb.setupSliders();
70
 
71
  $('.sow-slider-images').each(function(){
72
  var $$ = $(this);
73
+
74
+
75
+ if ( $$.data( 'initialized' ) ) {
76
+ return $$;
77
+ }
78
+
79
  var $p = $$.siblings('.sow-slider-pagination');
80
  var $base = $$.closest('.sow-slider-base');
81
  var $n = $base.find('.sow-slide-nav');
262
  if(images.length === 0) {
263
  setupSlider();
264
  }
265
+
266
+ $$.data( 'initialized', true );
267
  });
268
  };
269
  sowb.setupSliders();
js/slider/jquery.slider.min.js CHANGED
@@ -1 +1 @@
1
- var sowb=window.sowb||{};sowb.SiteOriginSlider=function(e){return{playSlideVideo:function(i){e(i).find("video").each(function(){void 0!==this.play&&this.play()})},pauseSlideVideo:function(i){e(i).find("video").each(function(){void 0!==this.pause&&this.pause()})},setupActiveSlide:function(i,t,s){var n=e(i).find(".cycle-sentinel"),o=e(t),d=o.find("video.sow-background-element");if(void 0==s?n.css("height",o.outerHeight()):n.animate({height:o.outerHeight()},s),d.length){o.outerWidth()/o.outerHeight()>d.outerWidth()/d.outerHeight()?d.css({width:"100%",height:"auto"}):d.css({width:"auto",height:"100%"}),d.css({"margin-left":-Math.ceil(d.width()/2),"margin-top":-Math.ceil(d.height()/2)})}}}},jQuery(function(e){sowb.setupSliders=sowb.setupSlider=function(){var i=new sowb.SiteOriginSlider(e);e(".sow-slider-images").each(function(){var t=e(this),s=t.siblings(".sow-slider-pagination"),n=t.closest(".sow-slider-base"),o=n.find(".sow-slide-nav"),d=t.find(".sow-slider-image"),c=t.data("settings");d.each(function(i,t){var s=e(t),n=s.data("url");void 0!==n&&n.hasOwnProperty("url")&&(s.click(function(e){e.preventDefault(),window.open(n.url,n.hasOwnProperty("new_window")&&n.new_window?"_blank":"_self").opener=null}),s.find("a").click(function(e){e.stopPropagation()}))});var l=function(){var a=t.closest(".so-widget-fittext-wrapper");if(a.length>0&&!a.data("fitTextDone"))return void a.on("fitTextDone",function(){l()});n.show();var r=function(){t.find(".sow-slider-image").each(function(){var i=e(this);i.css("height",i.find(".sow-slider-image-wrapper").outerHeight())})};if(e(window).on("resize panelsStretchRows",r).resize(),t.on({"cycle-after":function(t,s,n,o,d){var c=e(this);i.playSlideVideo(o),i.setupActiveSlide(c,o),e(o).trigger("sowSlideCycleAfter")},"cycle-before":function(t,n,o,d,c){var l=e(this);s.find("> li").removeClass("sow-active").eq(n.slideNum-1).addClass("sow-active"),i.pauseSlideVideo(o),i.setupActiveSlide(l,d,n.speed),e(d).trigger("sowSlideCycleBefore")},"cycle-initialized":function(n,d){i.playSlideVideo(e(this).find(".cycle-slide-active")),i.setupActiveSlide(t,d.slides[0]),s.find(">li").removeClass("sow-active").eq(0).addClass("sow-active"),e(this).find(".cycle-slide-active").trigger("sowSlideInitial"),d.slideCount<=1&&(s.hide(),o.hide()),e(window).resize(),setTimeout(function(){r(),i.setupActiveSlide(t,d.slides[0]),t.find(".cycle-sentinel").empty()},200)}}).cycle({slides:"> .sow-slider-image",speed:c.speed,timeout:c.timeout,swipe:c.swipe,"swipe-fx":"scrollHorz"}),t.find("video.sow-background-element").on("loadeddata",function(){i.setupActiveSlide(t,t.find(".cycle-slide-active"))}),s.add(o).hide(),!n.hasClass("sow-slider-is-mobile")&&d.length>1){var u=!1;n.mouseenter(function(){s.add(o).clearQueue().fadeIn(150),u=!1}).mouseleave(function(){u=!0,setTimeout(function(){u&&s.add(o).clearQueue().fadeOut(150),u=!1},750)})}e(window).resize(function(){i.setupActiveSlide(t,t.find(".cycle-slide-active"))}),s.find("> li > a").click(function(i){i.preventDefault(),t.cycle("goto",e(this).data("goto"))}),o.find("> a").click(function(i){i.preventDefault(),t.cycle(e(this).data("action"))}),n.keydown(function(e){37===e.which?t.cycle("prev"):39===e.which&&t.cycle("next")})},a=t.find("img"),r=0,u=!1;a.each(function(){e(this);this.complete?r++:e(this).one("load",function(){++r!==a.length||u||(l(),u=!0)}).attr("src",e(this).attr("src")),r!==a.length||u||(l(),u=!0)}),0===a.length&&l()})},sowb.setupSliders(),e(sowb).on("setup_widgets",sowb.setupSliders)}),window.sowb=sowb;
1
+ var sowb=window.sowb||{};sowb.SiteOriginSlider=function(e){return{playSlideVideo:function(i){e(i).find("video").each(function(){void 0!==this.play&&this.play()})},pauseSlideVideo:function(i){e(i).find("video").each(function(){void 0!==this.pause&&this.pause()})},setupActiveSlide:function(i,t,n){var s=e(i).find(".cycle-sentinel"),o=e(t),d=o.find("video.sow-background-element");if(void 0==n?s.css("height",o.outerHeight()):s.animate({height:o.outerHeight()},n),d.length){o.outerWidth()/o.outerHeight()>d.outerWidth()/d.outerHeight()?d.css({width:"100%",height:"auto"}):d.css({width:"auto",height:"100%"}),d.css({"margin-left":-Math.ceil(d.width()/2),"margin-top":-Math.ceil(d.height()/2)})}}}},jQuery(function(e){sowb.setupSliders=sowb.setupSlider=function(){var i=new sowb.SiteOriginSlider(e);e(".sow-slider-images").each(function(){var t=e(this);if(t.data("initialized"))return t;var n=t.siblings(".sow-slider-pagination"),s=t.closest(".sow-slider-base"),o=s.find(".sow-slide-nav"),d=t.find(".sow-slider-image"),l=t.data("settings");d.each(function(i,t){var n=e(t),s=n.data("url");void 0!==s&&s.hasOwnProperty("url")&&(n.click(function(e){e.preventDefault(),window.open(s.url,s.hasOwnProperty("new_window")&&s.new_window?"_blank":"_self").opener=null}),n.find("a").click(function(e){e.stopPropagation()}))});var a=function(){var c=t.closest(".so-widget-fittext-wrapper");if(c.length>0&&!c.data("fitTextDone"))return void c.on("fitTextDone",function(){a()});s.show();var r=function(){t.find(".sow-slider-image").each(function(){var i=e(this);i.css("height",i.find(".sow-slider-image-wrapper").outerHeight())})};if(e(window).on("resize panelsStretchRows",r).resize(),t.on({"cycle-after":function(t,n,s,o,d){var l=e(this);i.playSlideVideo(o),i.setupActiveSlide(l,o),e(o).trigger("sowSlideCycleAfter")},"cycle-before":function(t,s,o,d,l){var a=e(this);n.find("> li").removeClass("sow-active").eq(s.slideNum-1).addClass("sow-active"),i.pauseSlideVideo(o),i.setupActiveSlide(a,d,s.speed),e(d).trigger("sowSlideCycleBefore")},"cycle-initialized":function(s,d){i.playSlideVideo(e(this).find(".cycle-slide-active")),i.setupActiveSlide(t,d.slides[0]),n.find(">li").removeClass("sow-active").eq(0).addClass("sow-active"),e(this).find(".cycle-slide-active").trigger("sowSlideInitial"),d.slideCount<=1&&(n.hide(),o.hide()),e(window).resize(),setTimeout(function(){r(),i.setupActiveSlide(t,d.slides[0]),t.find(".cycle-sentinel").empty()},200)}}).cycle({slides:"> .sow-slider-image",speed:l.speed,timeout:l.timeout,swipe:l.swipe,"swipe-fx":"scrollHorz"}),t.find("video.sow-background-element").on("loadeddata",function(){i.setupActiveSlide(t,t.find(".cycle-slide-active"))}),n.add(o).hide(),!s.hasClass("sow-slider-is-mobile")&&d.length>1){var u=!1;s.mouseenter(function(){n.add(o).clearQueue().fadeIn(150),u=!1}).mouseleave(function(){u=!0,setTimeout(function(){u&&n.add(o).clearQueue().fadeOut(150),u=!1},750)})}e(window).resize(function(){i.setupActiveSlide(t,t.find(".cycle-slide-active"))}),n.find("> li > a").click(function(i){i.preventDefault(),t.cycle("goto",e(this).data("goto"))}),o.find("> a").click(function(i){i.preventDefault(),t.cycle(e(this).data("action"))}),s.keydown(function(e){37===e.which?t.cycle("prev"):39===e.which&&t.cycle("next")})},c=t.find("img"),r=0,u=!1;c.each(function(){e(this);this.complete?r++:e(this).one("load",function(){++r!==c.length||u||(a(),u=!0)}).attr("src",e(this).attr("src")),r!==c.length||u||(a(),u=!0)}),0===c.length&&a(),t.data("initialized",!0)})},sowb.setupSliders(),e(sowb).on("setup_widgets",sowb.setupSliders)}),window.sowb=sowb;
js/sow.google-map.js CHANGED
@@ -403,7 +403,11 @@ jQuery(function ($) {
403
  sowb.setupGoogleMaps = function() {
404
  var libraries = [];
405
  var apiKey;
406
- $('.sow-google-map-canvas').each(function(index, element) {
 
 
 
 
407
  var $this = $(element);
408
  if ( ! $this.is( ':visible' ) || $this.data( 'apiInitialized' ) ) {
409
  return $this;
@@ -419,10 +423,15 @@ jQuery(function ($) {
419
  }
420
  $this.data( 'apiInitialized', true );
421
  });
422
-
423
  var mapsApiLoaded = typeof window.google !== 'undefined' && typeof window.google.maps !== 'undefined';
424
- if ( mapsApiLoaded ) {
425
- soGoogleMapInitialize();
 
 
 
 
 
426
  } else {
427
  var apiUrl = 'https://maps.googleapis.com/maps/api/js?callback=soGoogleMapInitialize';
428
 
@@ -459,6 +468,7 @@ jQuery(function ($) {
459
  }
460
 
461
  $( 'body' ).append( '<script async type="text/javascript" src="' + apiUrl + '">' );
 
462
  }
463
  };
464
  sowb.setupGoogleMaps();
403
  sowb.setupGoogleMaps = function() {
404
  var libraries = [];
405
  var apiKey;
406
+ var $mapCanvas = $('.sow-google-map-canvas');
407
+ if ( ! $mapCanvas.length ) {
408
+ return;
409
+ }
410
+ $mapCanvas.each(function(index, element) {
411
  var $this = $(element);
412
  if ( ! $this.is( ':visible' ) || $this.data( 'apiInitialized' ) ) {
413
  return $this;
423
  }
424
  $this.data( 'apiInitialized', true );
425
  });
426
+
427
  var mapsApiLoaded = typeof window.google !== 'undefined' && typeof window.google.maps !== 'undefined';
428
+ if ( sowb.mapsApiInitialized ) {
429
+ var timeoutId = setTimeout( function () {
430
+ if ( mapsApiLoaded ) {
431
+ clearTimeout( timeoutId );
432
+ soGoogleMapInitialize();
433
+ }
434
+ }, 100 );
435
  } else {
436
  var apiUrl = 'https://maps.googleapis.com/maps/api/js?callback=soGoogleMapInitialize';
437
 
468
  }
469
 
470
  $( 'body' ).append( '<script async type="text/javascript" src="' + apiUrl + '">' );
471
+ sowb.mapsApiInitialized = true;
472
  }
473
  };
474
  sowb.setupGoogleMaps();
js/sow.google-map.min.js CHANGED
@@ -1 +1 @@
1
- function soGoogleMapInitialize(){new sowb.SiteOriginGoogleMap(jQuery).initMaps()}var sowb=window.sowb||{};sowb.SiteOriginGoogleMap=function(e){return{DEFAULT_LOCATIONS:["Addo Elephant National Park, R335, Addo","Cape Town, Western Cape, South Africa","San Francisco Bay Area, CA, United States","New York, NY, United States"],showMap:function(e,o,t){var i=Number(t.zoom);i||(i=14);var a={zoom:i,scrollwheel:t.scrollZoom,draggable:t.draggable,disableDefaultUI:t.disableUi,zoomControl:t.zoomControl,panControl:t.panControl,center:o,mapTypeControlOptions:{mapTypeIds:[google.maps.MapTypeId.ROADMAP,google.maps.MapTypeId.SATELLITE,"user_map_style"]}},n=new google.maps.Map(e,a),s={name:t.mapName},r=t.mapStyles;if(r){var l=new google.maps.StyledMapType(r,s);n.mapTypes.set("user_map_style",l),n.setMapTypeId("user_map_style")}if(t.markerAtCenter&&(this.centerMarker=new google.maps.Marker({position:o,map:n,draggable:t.markersDraggable,icon:t.markerIcon,title:""})),t.keepCentered){var d;google.maps.event.addDomListener(n,"idle",function(){d=n.getCenter()}),google.maps.event.addDomListener(window,"resize",function(){n.setCenter(d)})}this.linkAutocompleteField(t.autocomplete,t.autocompleteElement,n,t),this.showMarkers(t.markerPositions,n,t),this.showDirections(t.directions,n,t)},linkAutocompleteField:function(o,t,i,a){if(o&&t){var n=function(e){this.inputAddress!==e&&(this.inputAddress=e,this.getLocation(this.inputAddress).done(function(e){i.setZoom(15),i.setCenter(e),this.centerMarker&&(this.centerMarker.setPosition(e),this.centerMarker.setTitle(this.inputAddress))}.bind(this)))}.bind(this),s=e(t);o.addListener("place_changed",function(){var e=o.getPlace();i.setZoom(15),e.geometry&&(i.setCenter(e.geometry.location),this.centerMarker&&this.centerMarker.setPosition(e.geometry.location))}.bind(this)),google.maps.event.addDomListener(t,"keypress",function(e){"13"===(e.keyCode||e.which)&&e.preventDefault()}),s.focusin(function(){if(!this.resultsObserver){var o=document.querySelector(".pac-container");this.resultsObserver=new MutationObserver(function(){var o=e(e(".pac-item").get(0)),t=o.find(".pac-item-query").text(),i=o.find("span").not("[class]").text(),a=t+(i?", "+i:"");a&&n(a)});var t={attributes:!0,childList:!0,characterData:!0};this.resultsObserver.observe(o,t)}}.bind(this));var r=function(e){this.getGeocoder().geocode({location:e},function(o,t){if(t===google.maps.GeocoderStatus.OK&&o.length>0){var i=o[0].formatted_address;s.val(i),this.centerMarker&&(this.centerMarker.setPosition(e),this.centerMarker.setTitle(i))}}.bind(this))}.bind(this);i.addListener("click",function(e){r(e.latLng)}),this.centerMarker.addListener("dragend",function(e){r(e.latLng)})}},showMarkers:function(e,o,t){if(e&&e.length){this.infoWindows=[];for(var i=[],a=0;a<e.length;a++){var n=parseInt(a/10);i.length===n&&(i[n]=[]),i[n][a%10]=e[a]}var s=function(e,i){var a=0;e.forEach(function(n){this.getLocation(n.place).done(function(r){var l=t.markerIcon;n.custom_marker_icon&&(l=n.custom_marker_icon);var d=new google.maps.Marker({position:r,map:o,draggable:t.markersDraggable,icon:l,title:""});if(n.hasOwnProperty("info")&&n.info){var c={content:n.info};n.hasOwnProperty("info_max_width")&&n.info_max_width&&(c.maxWidth=n.info_max_width);var p=t.markerInfoDisplay;c.disableAutoPan="always"===p;var g=new google.maps.InfoWindow(c);this.infoWindows.push(g);var h=p;"always"===p&&(h="click",g.open(o,d)),d.addListener(h,function(){g.open(o,d),"always"===p||t.markerInfoMultiple||this.infoWindows.forEach(function(e){e!==g&&e.close()})}.bind(this)),"mouseover"===p&&d.addListener("mouseout",function(){setTimeout(function(){g.close()},100)})}++a===e.length&&i.length&&s(i.shift(),i)}.bind(this))}.bind(this))}.bind(this);s(i.shift(),i)}},showDirections:function(e,o){if(e){e.waypoints&&e.waypoints.length&&e.waypoints.map(function(e){e.stopover=Boolean(e.stopover)});var t=new google.maps.DirectionsRenderer;t.setMap(o);(new google.maps.DirectionsService).route({origin:e.origin,destination:e.destination,travelMode:e.travelMode.toUpperCase(),avoidHighways:e.avoidHighways,avoidTolls:e.avoidTolls,waypoints:e.waypoints,optimizeWaypoints:e.optimizeWaypoints},function(o,i){i===google.maps.DirectionsStatus.OK&&(t.setOptions({preserveViewport:e.preserveViewport}),t.setDirections(o))})}},initMaps:function(){var o=e(".sow-google-map-autocomplete"),t=new e.Deferred;0===o.length?t.resolve():o.each(function(o,i){if(void 0===google.maps.places)return void t.reject('Sorry, we couldn\'t load the "places" library due to another plugin, so the autocomplete feature is not available.');var a=new google.maps.places.Autocomplete(i,{types:["address"]}),n=e(i).siblings(".sow-google-map-canvas");if(n.length>0){var s=n.data("options");s.autocomplete=a,s.autocompleteElement=i,this.getLocation(s.address).done(function(e){this.showMap(n.get(0),e,s),n.data("initialized",!0),t.resolve()}.bind(this)).fail(function(){n.append("<div><p><strong>"+soWidgetsGoogleMap.geocode.noResults+"</strong></p></div>"),t.reject()})}}.bind(this)),t.always(function(){e(".sow-google-map-canvas").each(function(o,t){var i=e(t);if(i.data("initialized"))return!0;var a=i.data("options"),n=a.address;if(!n){var s=a.markerPositions;s&&s.length&&(n=s[0].place)}this.getLocation(n).done(function(e){this.showMap(i.get(0),e,a),i.data("initialized",!0)}.bind(this)).fail(function(){i.append("<div><p><strong>"+soWidgetsGoogleMap.geocode.noResults+"</strong></p></div>")})}.bind(this))}.bind(this)).fail(function(e){console.log(e)})},getGeocoder:function(){return this._geocoder||(this._geocoder=new google.maps.Geocoder),this._geocoder},getLocation:function(o){var t,i=new e.Deferred,a={address:o};if(o&&o.indexOf(",")>-1){var n=o.split(",");n&&2===n.length&&(t=new google.maps.LatLng(n[0],n[1]),isNaN(t.lat())||isNaN(t.lng())||(a={location:{lat:t.lat(),lng:t.lng()}}))}if(a.hasOwnProperty("location"))i.resolve(a.location);else if(a.hasOwnProperty("address")){if(!a.address){var s=parseInt(Math.random()*this.DEFAULT_LOCATIONS.length);a.address=this.DEFAULT_LOCATIONS[s]}var r=function(e,o){o===google.maps.GeocoderStatus.OK?i.resolve(e[0].geometry.location):o===google.maps.GeocoderStatus.OVER_QUERY_LIMIT?setTimeout(function(){this.getGeocoder().geocode.call(this,a,r)}.bind(this),100):o===google.maps.GeocoderStatus.ZERO_RESULTS&&i.reject(o)}.bind(this);this.getGeocoder().geocode(a,r)}return i}}},jQuery(function(e){sowb.setupGoogleMaps=function(){var o,t=[];if(e(".sow-google-map-canvas").each(function(i,a){var n=e(a);if(!n.is(":visible")||n.data("apiInitialized"))return n;var s=n.data("options");s&&(void 0!==s.libraries&&null!==s.libraries&&(t=t.concat(s.libraries)),!o&&s.apiKey&&(o=s.apiKey)),n.data("apiInitialized",!0)}),void 0!==window.google&&void 0!==window.google.maps)soGoogleMapInitialize();else{var i="https://maps.googleapis.com/maps/api/js?callback=soGoogleMapInitialize";if(t&&t.length&&(i+="&libraries="+t.join(",")),o&&(i+="&key="+o),window.console&&window.console.error){var a=window.console.error;sowb.onLoadMapsApiError=function(o){var t=o.match(/^Google Maps API (error|warning): ([^\s]*)\s([^\s]*)(?:\s(.*))?/);t&&t.length&&t[0]&&e(".sow-google-map-canvas").each(function(o,t){var i=e(t);if(i.data("fallbackImage")){var a=i.data("fallbackImage");a.hasOwnProperty("img")&&i.append(a.img)}}),a.apply(window.console,arguments)},window.console.error=sowb.onLoadMapsApiError}e("body").append('<script async type="text/javascript" src="'+i+'">')}},sowb.setupGoogleMaps(),e(sowb).on("setup_widgets",sowb.setupGoogleMaps)}),window.sowb=sowb;
1
+ function soGoogleMapInitialize(){new sowb.SiteOriginGoogleMap(jQuery).initMaps()}var sowb=window.sowb||{};sowb.SiteOriginGoogleMap=function(e){return{DEFAULT_LOCATIONS:["Addo Elephant National Park, R335, Addo","Cape Town, Western Cape, South Africa","San Francisco Bay Area, CA, United States","New York, NY, United States"],showMap:function(e,o,t){var i=Number(t.zoom);i||(i=14);var a={zoom:i,scrollwheel:t.scrollZoom,draggable:t.draggable,disableDefaultUI:t.disableUi,zoomControl:t.zoomControl,panControl:t.panControl,center:o,mapTypeControlOptions:{mapTypeIds:[google.maps.MapTypeId.ROADMAP,google.maps.MapTypeId.SATELLITE,"user_map_style"]}},n=new google.maps.Map(e,a),s={name:t.mapName},r=t.mapStyles;if(r){var l=new google.maps.StyledMapType(r,s);n.mapTypes.set("user_map_style",l),n.setMapTypeId("user_map_style")}if(t.markerAtCenter&&(this.centerMarker=new google.maps.Marker({position:o,map:n,draggable:t.markersDraggable,icon:t.markerIcon,title:""})),t.keepCentered){var d;google.maps.event.addDomListener(n,"idle",function(){d=n.getCenter()}),google.maps.event.addDomListener(window,"resize",function(){n.setCenter(d)})}this.linkAutocompleteField(t.autocomplete,t.autocompleteElement,n,t),this.showMarkers(t.markerPositions,n,t),this.showDirections(t.directions,n,t)},linkAutocompleteField:function(o,t,i,a){if(o&&t){var n=function(e){this.inputAddress!==e&&(this.inputAddress=e,this.getLocation(this.inputAddress).done(function(e){i.setZoom(15),i.setCenter(e),this.centerMarker&&(this.centerMarker.setPosition(e),this.centerMarker.setTitle(this.inputAddress))}.bind(this)))}.bind(this),s=e(t);o.addListener("place_changed",function(){var e=o.getPlace();i.setZoom(15),e.geometry&&(i.setCenter(e.geometry.location),this.centerMarker&&this.centerMarker.setPosition(e.geometry.location))}.bind(this)),google.maps.event.addDomListener(t,"keypress",function(e){"13"===(e.keyCode||e.which)&&e.preventDefault()}),s.focusin(function(){if(!this.resultsObserver){var o=document.querySelector(".pac-container");this.resultsObserver=new MutationObserver(function(){var o=e(e(".pac-item").get(0)),t=o.find(".pac-item-query").text(),i=o.find("span").not("[class]").text(),a=t+(i?", "+i:"");a&&n(a)});var t={attributes:!0,childList:!0,characterData:!0};this.resultsObserver.observe(o,t)}}.bind(this));var r=function(e){this.getGeocoder().geocode({location:e},function(o,t){if(t===google.maps.GeocoderStatus.OK&&o.length>0){var i=o[0].formatted_address;s.val(i),this.centerMarker&&(this.centerMarker.setPosition(e),this.centerMarker.setTitle(i))}}.bind(this))}.bind(this);i.addListener("click",function(e){r(e.latLng)}),this.centerMarker.addListener("dragend",function(e){r(e.latLng)})}},showMarkers:function(e,o,t){if(e&&e.length){this.infoWindows=[];for(var i=[],a=0;a<e.length;a++){var n=parseInt(a/10);i.length===n&&(i[n]=[]),i[n][a%10]=e[a]}var s=function(e,i){var a=0;e.forEach(function(n){this.getLocation(n.place).done(function(r){var l=t.markerIcon;n.custom_marker_icon&&(l=n.custom_marker_icon);var d=new google.maps.Marker({position:r,map:o,draggable:t.markersDraggable,icon:l,title:""});if(n.hasOwnProperty("info")&&n.info){var c={content:n.info};n.hasOwnProperty("info_max_width")&&n.info_max_width&&(c.maxWidth=n.info_max_width);var p=t.markerInfoDisplay;c.disableAutoPan="always"===p;var g=new google.maps.InfoWindow(c);this.infoWindows.push(g);var u=p;"always"===p&&(u="click",g.open(o,d)),d.addListener(u,function(){g.open(o,d),"always"===p||t.markerInfoMultiple||this.infoWindows.forEach(function(e){e!==g&&e.close()})}.bind(this)),"mouseover"===p&&d.addListener("mouseout",function(){setTimeout(function(){g.close()},100)})}++a===e.length&&i.length&&s(i.shift(),i)}.bind(this))}.bind(this))}.bind(this);s(i.shift(),i)}},showDirections:function(e,o){if(e){e.waypoints&&e.waypoints.length&&e.waypoints.map(function(e){e.stopover=Boolean(e.stopover)});var t=new google.maps.DirectionsRenderer;t.setMap(o);(new google.maps.DirectionsService).route({origin:e.origin,destination:e.destination,travelMode:e.travelMode.toUpperCase(),avoidHighways:e.avoidHighways,avoidTolls:e.avoidTolls,waypoints:e.waypoints,optimizeWaypoints:e.optimizeWaypoints},function(o,i){i===google.maps.DirectionsStatus.OK&&(t.setOptions({preserveViewport:e.preserveViewport}),t.setDirections(o))})}},initMaps:function(){var o=e(".sow-google-map-autocomplete"),t=new e.Deferred;0===o.length?t.resolve():o.each(function(o,i){if(void 0===google.maps.places)return void t.reject('Sorry, we couldn\'t load the "places" library due to another plugin, so the autocomplete feature is not available.');var a=new google.maps.places.Autocomplete(i,{types:["address"]}),n=e(i).siblings(".sow-google-map-canvas");if(n.length>0){var s=n.data("options");s.autocomplete=a,s.autocompleteElement=i,this.getLocation(s.address).done(function(e){this.showMap(n.get(0),e,s),n.data("initialized",!0),t.resolve()}.bind(this)).fail(function(){n.append("<div><p><strong>"+soWidgetsGoogleMap.geocode.noResults+"</strong></p></div>"),t.reject()})}}.bind(this)),t.always(function(){e(".sow-google-map-canvas").each(function(o,t){var i=e(t);if(i.data("initialized"))return!0;var a=i.data("options"),n=a.address;if(!n){var s=a.markerPositions;s&&s.length&&(n=s[0].place)}this.getLocation(n).done(function(e){this.showMap(i.get(0),e,a),i.data("initialized",!0)}.bind(this)).fail(function(){i.append("<div><p><strong>"+soWidgetsGoogleMap.geocode.noResults+"</strong></p></div>")})}.bind(this))}.bind(this)).fail(function(e){console.log(e)})},getGeocoder:function(){return this._geocoder||(this._geocoder=new google.maps.Geocoder),this._geocoder},getLocation:function(o){var t,i=new e.Deferred,a={address:o};if(o&&o.indexOf(",")>-1){var n=o.split(",");n&&2===n.length&&(t=new google.maps.LatLng(n[0],n[1]),isNaN(t.lat())||isNaN(t.lng())||(a={location:{lat:t.lat(),lng:t.lng()}}))}if(a.hasOwnProperty("location"))i.resolve(a.location);else if(a.hasOwnProperty("address")){if(!a.address){var s=parseInt(Math.random()*this.DEFAULT_LOCATIONS.length);a.address=this.DEFAULT_LOCATIONS[s]}var r=function(e,o){o===google.maps.GeocoderStatus.OK?i.resolve(e[0].geometry.location):o===google.maps.GeocoderStatus.OVER_QUERY_LIMIT?setTimeout(function(){this.getGeocoder().geocode.call(this,a,r)}.bind(this),100):o===google.maps.GeocoderStatus.ZERO_RESULTS&&i.reject(o)}.bind(this);this.getGeocoder().geocode(a,r)}return i}}},jQuery(function(e){sowb.setupGoogleMaps=function(){var o,t=[],i=e(".sow-google-map-canvas");if(i.length){i.each(function(i,a){var n=e(a);if(!n.is(":visible")||n.data("apiInitialized"))return n;var s=n.data("options");s&&(void 0!==s.libraries&&null!==s.libraries&&(t=t.concat(s.libraries)),!o&&s.apiKey&&(o=s.apiKey)),n.data("apiInitialized",!0)});var a=void 0!==window.google&&void 0!==window.google.maps;if(sowb.mapsApiInitialized)var n=setTimeout(function(){a&&(clearTimeout(n),soGoogleMapInitialize())},100);else{var s="https://maps.googleapis.com/maps/api/js?callback=soGoogleMapInitialize";if(t&&t.length&&(s+="&libraries="+t.join(",")),o&&(s+="&key="+o),window.console&&window.console.error){var r=window.console.error;sowb.onLoadMapsApiError=function(o){var t=o.match(/^Google Maps API (error|warning): ([^\s]*)\s([^\s]*)(?:\s(.*))?/);t&&t.length&&t[0]&&e(".sow-google-map-canvas").each(function(o,t){var i=e(t);if(i.data("fallbackImage")){var a=i.data("fallbackImage");a.hasOwnProperty("img")&&i.append(a.img)}}),r.apply(window.console,arguments)},window.console.error=sowb.onLoadMapsApiError}e("body").append('<script async type="text/javascript" src="'+s+'">'),sowb.mapsApiInitialized=!0}}},sowb.setupGoogleMaps(),e(sowb).on("setup_widgets",sowb.setupGoogleMaps)}),window.sowb=sowb;
lang/so-widgets-bundle.pot CHANGED
@@ -68,7 +68,7 @@ msgstr ""
68
  msgid "Save"
69
  msgstr ""
70
 
71
- #: base/inc/actions.php:10, base/inc/actions.php:75, base/inc/actions.php:119, base/inc/actions.php:155, base/inc/actions.php:168, base/inc/actions.php:172, base/inc/actions.php:263, base/inc/actions.php:266, so-widgets-bundle.php:370, so-widgets-bundle.php:394, so-widgets-bundle.php:407, so-widgets-bundle.php:437, so-widgets-bundle.php:448, so-widgets-bundle.php:514, so-widgets-bundle.php:525
72
  msgid "Invalid request."
73
  msgstr ""
74
 
@@ -76,19 +76,19 @@ msgstr ""
76
  msgid "Invalid post."
77
  msgstr ""
78
 
79
- #: base/inc/actions.php:50, base/siteorigin-widget.class.php:637
80
  msgid "Widget Preview"
81
  msgstr ""
82
 
83
- #: base/inc/actions.php:211
84
  msgid "Nonce error"
85
  msgstr ""
86
 
87
- #: base/inc/actions.php:221
88
  msgid "Signature error"
89
  msgstr ""
90
 
91
- #: base/inc/actions.php:247
92
  msgid "Attachment error"
93
  msgstr ""
94
 
@@ -405,6 +405,9 @@ msgstr ""
405
  msgid "Widgets Bundle Post Meta Data"
406
  msgstr ""
407
 
 
 
 
408
  #: base/inc/widgets/base-slider.class.php:54
409
  msgid "Animation speed"
410
  msgstr ""
@@ -513,39 +516,39 @@ msgstr ""
513
  msgid "previous slide"
514
  msgstr ""
515
 
516
- #: base/siteorigin-widget.class.php:481
517
  msgid "Preview"
518
  msgstr ""
519
 
520
- #: base/siteorigin-widget.class.php:486
521
  msgid "Help"
522
  msgstr ""
523
 
524
- #: base/siteorigin-widget.class.php:552
525
  msgid "This widget has scripts and styles that need to be loaded before you can use it. Please save and reload your current page."
526
  msgstr ""
527
 
528
- #: base/siteorigin-widget.class.php:553
529
  msgid "You will only need to do this once."
530
  msgstr ""
531
 
532
- #: base/siteorigin-widget.class.php:580
533
  msgid "Are you sure?"
534
  msgstr ""
535
 
536
- #: base/siteorigin-widget.class.php:582
537
  msgid "There is a newer version of this widget's content available."
538
  msgstr ""
539
 
540
- #: base/siteorigin-widget.class.php:583, base/siteorigin-widget.class.php:587
541
  msgid "Restore"
542
  msgstr ""
543
 
544
- #: base/siteorigin-widget.class.php:584
545
  msgid "Dismiss"
546
  msgstr ""
547
 
548
- #: base/siteorigin-widget.class.php:586
549
  msgid "Clicking %s will replace the current widget contents. You can revert by refreshing the page before updating."
550
  msgstr ""
551
 
@@ -573,6 +576,10 @@ msgstr ""
573
  msgid "Visual Composer"
574
  msgstr ""
575
 
 
 
 
 
576
  #: compat/visual-composer/visual-composer.php:38, compat/visual-composer/visual-composer.php:54
577
  msgid "SiteOrigin Widget"
578
  msgstr ""
@@ -633,11 +640,11 @@ msgstr ""
633
  msgid "Deactivated"
634
  msgstr ""
635
 
636
- #: so-widgets-bundle.php:746
637
  msgid "Manage Widgets"
638
  msgstr ""
639
 
640
- #: so-widgets-bundle.php:747
641
  msgid "Support"
642
  msgstr ""
643
 
@@ -2527,166 +2534,174 @@ msgid "RSS"
2527
  msgstr ""
2528
 
2529
  #: widgets/social-media-buttons/data/networks.php:35
2530
- msgid "Snapchat"
2531
  msgstr ""
2532
 
2533
  #: widgets/social-media-buttons/data/networks.php:41
2534
- msgid "LinkedIn"
2535
  msgstr ""
2536
 
2537
  #: widgets/social-media-buttons/data/networks.php:47
2538
- msgid "Pinterest"
2539
  msgstr ""
2540
 
2541
  #: widgets/social-media-buttons/data/networks.php:53
2542
- msgid "Tumblr"
2543
  msgstr ""
2544
 
2545
  #: widgets/social-media-buttons/data/networks.php:59
2546
- msgid "Instagram"
2547
  msgstr ""
2548
 
2549
  #: widgets/social-media-buttons/data/networks.php:65
2550
- msgid "VK"
2551
  msgstr ""
2552
 
2553
  #: widgets/social-media-buttons/data/networks.php:71
2554
- msgid "Flickr"
2555
  msgstr ""
2556
 
2557
  #: widgets/social-media-buttons/data/networks.php:77
 
 
 
 
2558
  msgid "Vine"
2559
  msgstr ""
2560
 
2561
- #: widgets/social-media-buttons/data/networks.php:86
2562
  msgid "500px"
2563
  msgstr ""
2564
 
2565
- #: widgets/social-media-buttons/data/networks.php:92
 
 
 
 
2566
  msgid "Behance"
2567
  msgstr ""
2568
 
2569
- #: widgets/social-media-buttons/data/networks.php:98
2570
  msgid "Bitbucket"
2571
  msgstr ""
2572
 
2573
- #: widgets/social-media-buttons/data/networks.php:104
2574
  msgid "Codepen"
2575
  msgstr ""
2576
 
2577
- #: widgets/social-media-buttons/data/networks.php:110
2578
  msgid "Delicious"
2579
  msgstr ""
2580
 
2581
- #: widgets/social-media-buttons/data/networks.php:116
2582
  msgid "deviantArt"
2583
  msgstr ""
2584
 
2585
- #: widgets/social-media-buttons/data/networks.php:122
2586
  msgid "Dribbble"
2587
  msgstr ""
2588
 
2589
- #: widgets/social-media-buttons/data/networks.php:128
2590
  msgid "Dropbox"
2591
  msgstr ""
2592
 
2593
- #: widgets/social-media-buttons/data/networks.php:134
2594
  msgid "Foursquare"
2595
  msgstr ""
2596
 
2597
- #: widgets/social-media-buttons/data/networks.php:140
2598
  msgid "Github"
2599
  msgstr ""
2600
 
2601
- #: widgets/social-media-buttons/data/networks.php:146
2602
  msgid "Gratipay"
2603
  msgstr ""
2604
 
2605
- #: widgets/social-media-buttons/data/networks.php:152
2606
  msgid "Hacker News"
2607
  msgstr ""
2608
 
2609
- #: widgets/social-media-buttons/data/networks.php:158
2610
  msgid "JSFiddle"
2611
  msgstr ""
2612
 
2613
- #: widgets/social-media-buttons/data/networks.php:164
2614
  msgid "Last.fm"
2615
  msgstr ""
2616
 
2617
- #: widgets/social-media-buttons/data/networks.php:170
2618
  msgid "Reddit"
2619
  msgstr ""
2620
 
2621
- #: widgets/social-media-buttons/data/networks.php:176
2622
  msgid "Slack"
2623
  msgstr ""
2624
 
2625
- #: widgets/social-media-buttons/data/networks.php:182
2626
  msgid "Slideshare"
2627
  msgstr ""
2628
 
2629
- #: widgets/social-media-buttons/data/networks.php:188
2630
  msgid "Soundcloud"
2631
  msgstr ""
2632
 
2633
- #: widgets/social-media-buttons/data/networks.php:194
2634
  msgid "Spotify"
2635
  msgstr ""
2636
 
2637
- #: widgets/social-media-buttons/data/networks.php:200
2638
  msgid "Stack Exchange"
2639
  msgstr ""
2640
 
2641
- #: widgets/social-media-buttons/data/networks.php:206
2642
  msgid "Stack Overflow"
2643
  msgstr ""
2644
 
2645
- #: widgets/social-media-buttons/data/networks.php:212
2646
  msgid "Steam"
2647
  msgstr ""
2648
 
2649
- #: widgets/social-media-buttons/data/networks.php:218
2650
  msgid "StumbleUpon"
2651
  msgstr ""
2652
 
2653
- #: widgets/social-media-buttons/data/networks.php:224
2654
  msgid "Trello"
2655
  msgstr ""
2656
 
2657
- #: widgets/social-media-buttons/data/networks.php:230
2658
  msgid "TripAdvisor"
2659
  msgstr ""
2660
 
2661
- #: widgets/social-media-buttons/data/networks.php:236
2662
  msgid "Twitch"
2663
  msgstr ""
2664
 
2665
- #: widgets/social-media-buttons/data/networks.php:242
2666
  msgid "Vimeo"
2667
  msgstr ""
2668
 
2669
- #: widgets/social-media-buttons/data/networks.php:248
2670
  msgid "WhatsApp"
2671
  msgstr ""
2672
 
2673
- #: widgets/social-media-buttons/data/networks.php:254
2674
  msgid "WordPress"
2675
  msgstr ""
2676
 
2677
- #: widgets/social-media-buttons/data/networks.php:260
2678
  msgid "Xing"
2679
  msgstr ""
2680
 
2681
- #: widgets/social-media-buttons/data/networks.php:266
2682
  msgid "Yahoo"
2683
  msgstr ""
2684
 
2685
- #: widgets/social-media-buttons/data/networks.php:272
2686
  msgid "Yelp"
2687
  msgstr ""
2688
 
2689
- #: widgets/social-media-buttons/data/networks.php:278
2690
  msgid "YouTube"
2691
  msgstr ""
2692
 
@@ -2722,7 +2737,11 @@ msgstr ""
2722
  msgid "Mobile Align"
2723
  msgstr ""
2724
 
2725
- #: widgets/social-media-buttons/tpl/default.php:9
 
 
 
 
2726
  msgid "%s on %s"
2727
  msgstr ""
2728
 
68
  msgid "Save"
69
  msgstr ""
70
 
71
+ #: base/inc/actions.php:10, base/inc/actions.php:74, base/inc/actions.php:118, base/inc/actions.php:154, base/inc/actions.php:167, base/inc/actions.php:171, base/inc/actions.php:262, base/inc/actions.php:265, so-widgets-bundle.php:370, so-widgets-bundle.php:394, so-widgets-bundle.php:407, so-widgets-bundle.php:437, so-widgets-bundle.php:448, so-widgets-bundle.php:514, so-widgets-bundle.php:525
72
  msgid "Invalid request."
73
  msgstr ""
74
 
76
  msgid "Invalid post."
77
  msgstr ""
78
 
79
+ #: base/inc/actions.php:50, base/siteorigin-widget.class.php:642
80
  msgid "Widget Preview"
81
  msgstr ""
82
 
83
+ #: base/inc/actions.php:210
84
  msgid "Nonce error"
85
  msgstr ""
86
 
87
+ #: base/inc/actions.php:220
88
  msgid "Signature error"
89
  msgstr ""
90
 
91
+ #: base/inc/actions.php:246
92
  msgid "Attachment error"
93
  msgstr ""
94
 
405
  msgid "Widgets Bundle Post Meta Data"
406
  msgstr ""
407
 
408
+ #: base/inc/routes/siteorigin-widgets-resource.class.php:89
409
+ msgstr ""
410
+
411
  #: base/inc/widgets/base-slider.class.php:54
412
  msgid "Animation speed"
413
  msgstr ""
516
  msgid "previous slide"
517
  msgstr ""
518
 
519
+ #: base/siteorigin-widget.class.php:486
520
  msgid "Preview"
521
  msgstr ""
522
 
523
+ #: base/siteorigin-widget.class.php:491
524
  msgid "Help"
525
  msgstr ""
526
 
527
+ #: base/siteorigin-widget.class.php:557
528
  msgid "This widget has scripts and styles that need to be loaded before you can use it. Please save and reload your current page."
529
  msgstr ""
530
 
531
+ #: base/siteorigin-widget.class.php:558
532
  msgid "You will only need to do this once."
533
  msgstr ""
534
 
535
+ #: base/siteorigin-widget.class.php:585
536
  msgid "Are you sure?"
537
  msgstr ""
538
 
539
+ #: base/siteorigin-widget.class.php:587
540
  msgid "There is a newer version of this widget's content available."
541
  msgstr ""
542
 
543
+ #: base/siteorigin-widget.class.php:588, base/siteorigin-widget.class.php:592
544
  msgid "Restore"
545
  msgstr ""
546
 
547
+ #: base/siteorigin-widget.class.php:589
548
  msgid "Dismiss"
549
  msgstr ""
550
 
551
+ #: base/siteorigin-widget.class.php:591
552
  msgid "Clicking %s will replace the current widget contents. You can revert by refreshing the page before updating."
553
  msgstr ""
554
 
576
  msgid "Visual Composer"
577
  msgstr ""
578
 
579
+ #: compat/gutenberg/gutenberg.php:63
580
+ msgid "You need to select a widget type before you'll see anything here. :)"
581
+ msgstr ""
582
+
583
  #: compat/visual-composer/visual-composer.php:38, compat/visual-composer/visual-composer.php:54
584
  msgid "SiteOrigin Widget"
585
  msgstr ""
640
  msgid "Deactivated"
641
  msgstr ""
642
 
643
+ #: so-widgets-bundle.php:748
644
  msgid "Manage Widgets"
645
  msgstr ""
646
 
647
+ #: so-widgets-bundle.php:749
648
  msgid "Support"
649
  msgstr ""
650
 
2534
  msgstr ""
2535
 
2536
  #: widgets/social-media-buttons/data/networks.php:35
2537
+ msgid "Phone"
2538
  msgstr ""
2539
 
2540
  #: widgets/social-media-buttons/data/networks.php:41
2541
+ msgid "Snapchat"
2542
  msgstr ""
2543
 
2544
  #: widgets/social-media-buttons/data/networks.php:47
2545
+ msgid "LinkedIn"
2546
  msgstr ""
2547
 
2548
  #: widgets/social-media-buttons/data/networks.php:53
2549
+ msgid "Pinterest"
2550
  msgstr ""
2551
 
2552
  #: widgets/social-media-buttons/data/networks.php:59
2553
+ msgid "Tumblr"
2554
  msgstr ""
2555
 
2556
  #: widgets/social-media-buttons/data/networks.php:65
2557
+ msgid "Instagram"
2558
  msgstr ""
2559
 
2560
  #: widgets/social-media-buttons/data/networks.php:71
2561
+ msgid "VK"
2562
  msgstr ""
2563
 
2564
  #: widgets/social-media-buttons/data/networks.php:77
2565
+ msgid "Flickr"
2566
+ msgstr ""
2567
+
2568
+ #: widgets/social-media-buttons/data/networks.php:83
2569
  msgid "Vine"
2570
  msgstr ""
2571
 
2572
+ #: widgets/social-media-buttons/data/networks.php:92
2573
  msgid "500px"
2574
  msgstr ""
2575
 
2576
+ #: widgets/social-media-buttons/data/networks.php:98
2577
+ msgid "AngelList"
2578
+ msgstr ""
2579
+
2580
+ #: widgets/social-media-buttons/data/networks.php:104
2581
  msgid "Behance"
2582
  msgstr ""
2583
 
2584
+ #: widgets/social-media-buttons/data/networks.php:110
2585
  msgid "Bitbucket"
2586
  msgstr ""
2587
 
2588
+ #: widgets/social-media-buttons/data/networks.php:116
2589
  msgid "Codepen"
2590
  msgstr ""
2591
 
2592
+ #: widgets/social-media-buttons/data/networks.php:122
2593
  msgid "Delicious"
2594
  msgstr ""
2595
 
2596
+ #: widgets/social-media-buttons/data/networks.php:128
2597
  msgid "deviantArt"
2598
  msgstr ""
2599
 
2600
+ #: widgets/social-media-buttons/data/networks.php:134
2601
  msgid "Dribbble"
2602
  msgstr ""
2603
 
2604
+ #: widgets/social-media-buttons/data/networks.php:140
2605
  msgid "Dropbox"
2606
  msgstr ""
2607
 
2608
+ #: widgets/social-media-buttons/data/networks.php:146
2609
  msgid "Foursquare"
2610
  msgstr ""
2611
 
2612
+ #: widgets/social-media-buttons/data/networks.php:152
2613
  msgid "Github"
2614
  msgstr ""
2615
 
2616
+ #: widgets/social-media-buttons/data/networks.php:158
2617
  msgid "Gratipay"
2618
  msgstr ""
2619
 
2620
+ #: widgets/social-media-buttons/data/networks.php:164
2621
  msgid "Hacker News"
2622
  msgstr ""
2623
 
2624
+ #: widgets/social-media-buttons/data/networks.php:170
2625
  msgid "JSFiddle"
2626
  msgstr ""
2627
 
2628
+ #: widgets/social-media-buttons/data/networks.php:176
2629
  msgid "Last.fm"
2630
  msgstr ""
2631
 
2632
+ #: widgets/social-media-buttons/data/networks.php:182
2633
  msgid "Reddit"
2634
  msgstr ""
2635
 
2636
+ #: widgets/social-media-buttons/data/networks.php:188
2637
  msgid "Slack"
2638
  msgstr ""
2639
 
2640
+ #: widgets/social-media-buttons/data/networks.php:194
2641
  msgid "Slideshare"
2642
  msgstr ""
2643
 
2644
+ #: widgets/social-media-buttons/data/networks.php:200
2645
  msgid "Soundcloud"
2646
  msgstr ""
2647
 
2648
+ #: widgets/social-media-buttons/data/networks.php:206
2649
  msgid "Spotify"
2650
  msgstr ""
2651
 
2652
+ #: widgets/social-media-buttons/data/networks.php:212
2653
  msgid "Stack Exchange"
2654
  msgstr ""
2655
 
2656
+ #: widgets/social-media-buttons/data/networks.php:218
2657
  msgid "Stack Overflow"
2658
  msgstr ""
2659
 
2660
+ #: widgets/social-media-buttons/data/networks.php:224
2661
  msgid "Steam"
2662
  msgstr ""
2663
 
2664
+ #: widgets/social-media-buttons/data/networks.php:230
2665
  msgid "StumbleUpon"
2666
  msgstr ""
2667
 
2668
+ #: widgets/social-media-buttons/data/networks.php:236
2669
  msgid "Trello"
2670
  msgstr ""
2671
 
2672
+ #: widgets/social-media-buttons/data/networks.php:242
2673
  msgid "TripAdvisor"
2674
  msgstr ""
2675
 
2676
+ #: widgets/social-media-buttons/data/networks.php:248
2677
  msgid "Twitch"
2678
  msgstr ""
2679
 
2680
+ #: widgets/social-media-buttons/data/networks.php:254
2681
  msgid "Vimeo"
2682
  msgstr ""
2683
 
2684
+ #: widgets/social-media-buttons/data/networks.php:260
2685
  msgid "WhatsApp"
2686
  msgstr ""
2687
 
2688
+ #: widgets/social-media-buttons/data/networks.php:266
2689
  msgid "WordPress"
2690
  msgstr ""
2691
 
2692
+ #: widgets/social-media-buttons/data/networks.php:272
2693
  msgid "Xing"
2694
  msgstr ""
2695
 
2696
+ #: widgets/social-media-buttons/data/networks.php:278
2697
  msgid "Yahoo"
2698
  msgstr ""
2699
 
2700
+ #: widgets/social-media-buttons/data/networks.php:284
2701
  msgid "Yelp"
2702
  msgstr ""
2703
 
2704
+ #: widgets/social-media-buttons/data/networks.php:290
2705
  msgid "YouTube"
2706
  msgstr ""
2707
 
2737
  msgid "Mobile Align"
2738
  msgstr ""
2739
 
2740
+ #: widgets/social-media-buttons/tpl/default.php:13
2741
+ msgid "%s %s"
2742
+ msgstr ""
2743
+
2744
+ #: widgets/social-media-buttons/tpl/default.php:19
2745
  msgid "%s on %s"
2746
  msgstr ""
2747
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Tags: bundle, widget, button, slider, image, carousel, price table, google maps, tinymce, social links
3
  Requires at least: 4.2
4
  Tested up to: 4.9.1
5
- Stable tag: 1.12.1
6
- Build time: 2018-07-17T11:59:12+02:00
7
  License: GPLv3 or later
8
  Contributors: gpriday, braam-genis
9
  Donate link: https://siteorigin.com/downloads/contribution/
@@ -65,6 +65,18 @@ The SiteOrigin Widgets Bundle is the perfect platform to build widgets for your
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  = 1.12.1 - 17 July 2018 =
69
  * Contact: Allow non-string values in required field validation.
70
  * Initialize CTA, Price Table and Video JS widgets correctly when in accordion/tabs widgets.
2
  Tags: bundle, widget, button, slider, image, carousel, price table, google maps, tinymce, social links
3
  Requires at least: 4.2
4
  Tested up to: 4.9.1
5
+ Stable tag: 1.13.0
6
+ Build time: 2018-09-17T08:23:30-07:00
7
  License: GPLv3 or later
8
  Contributors: gpriday, braam-genis
9
  Donate link: https://siteorigin.com/downloads/contribution/
65
 
66
  == Changelog ==
67
 
68
+ = 1.13.0 - 13 September 2018 =
69
+ * SiteOrigin Widgets Gutenberg block!
70
+ * Google Map: Prevent script from running further if no map canvas elements found.
71
+ * Removed style to set `p` margins to zero.
72
+ * Check that fallback image for static maps is not an empty string before attempting to use it.
73
+ * TinyMCE: Ensure target is one of the editor tabs when switching modes.
74
+ * Set values for repeaters which are direct children of section fields.
75
+ * Prevent unselected radio input state emitters from affecting form states, when form values are set programmatically.
76
+ * Plugin Action Links: Check if edit link is present before removal.
77
+ * Social Media Buttons: Added Phone and Angelist. Changed email title text.
78
+ * Metabox manager: Set empty post meta string value to array. Ensure metabox widget form values are saved when saving drafts too.
79
+
80
  = 1.12.1 - 17 July 2018 =
81
  * Contact: Allow non-string values in required field validation.
82
  * Initialize CTA, Price Table and Video JS widgets correctly when in accordion/tabs widgets.
so-widgets-bundle.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: SiteOrigin Widgets Bundle
4
  Description: A collection of all widgets, neatly bundled into a single plugin. It's also a framework to code your own widgets on top of.
5
- Version: 1.12.1
6
  Text Domain: so-widgets-bundle
7
  Domain Path: /lang
8
  Author: SiteOrigin
@@ -12,7 +12,7 @@ License: GPL3
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.txt
13
  */
14
 
15
- define('SOW_BUNDLE_VERSION', '1.12.1');
16
  define('SOW_BUNDLE_BASE_FILE', __FILE__);
17
 
18
  // Allow JS suffix to be pre-set
@@ -742,7 +742,9 @@ class SiteOrigin_Widgets_Bundle {
742
  * Add action links.
743
  */
744
  function plugin_action_links($links){
745
- unset( $links['edit'] );
 
 
746
  $links['manage'] = '<a href="' . admin_url('plugins.php?page=so-widgets-plugins') . '">'.__('Manage Widgets', 'so-widgets-bundle').'</a>';
747
  $links['support'] = '<a href="https://siteorigin.com/thread/" target="_blank" rel="noopener noreferrer">'.__('Support', 'so-widgets-bundle').'</a>';
748
  return $links;
2
  /*
3
  Plugin Name: SiteOrigin Widgets Bundle
4
  Description: A collection of all widgets, neatly bundled into a single plugin. It's also a framework to code your own widgets on top of.
5
+ Version: 1.13.0
6
  Text Domain: so-widgets-bundle
7
  Domain Path: /lang
8
  Author: SiteOrigin
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.txt
13
  */
14
 
15
+ define('SOW_BUNDLE_VERSION', '1.13.0');
16
  define('SOW_BUNDLE_BASE_FILE', __FILE__);
17
 
18
  // Allow JS suffix to be pre-set
742
  * Add action links.
743
  */
744
  function plugin_action_links($links){
745
+ if ( isset( $links['edit'] ) ) {
746
+ unset( $links['edit'] );
747
+ }
748
  $links['manage'] = '<a href="' . admin_url('plugins.php?page=so-widgets-plugins') . '">'.__('Manage Widgets', 'so-widgets-bundle').'</a>';
749
  $links['support'] = '<a href="https://siteorigin.com/thread/" target="_blank" rel="noopener noreferrer">'.__('Support', 'so-widgets-bundle').'</a>';
750
  return $links;
widgets/google-map/js/static-map.js CHANGED
@@ -10,7 +10,7 @@ jQuery( function ( $ ) {
10
  var showFallbackImage = function () {
11
  if ( $this.data( 'fallbackImage' ) ) {
12
  var imgData = $this.data( 'fallbackImage' );
13
- if ( imgData.hasOwnProperty( 'img' ) ) {
14
  $this.parent().append( imgData.img );
15
  $this.remove();
16
  }
10
  var showFallbackImage = function () {
11
  if ( $this.data( 'fallbackImage' ) ) {
12
  var imgData = $this.data( 'fallbackImage' );
13
+ if ( imgData.hasOwnProperty( 'img' ) && imgData.img.length > 0 ) {
14
  $this.parent().append( imgData.img );
15
  $this.remove();
16
  }
widgets/google-map/js/static-map.min.js CHANGED
@@ -1 +1 @@
1
- var sowb=window.sowb||{};jQuery(function(a){!function(){a(".sowb-google-map-static").each(function(){var o=a(this),r=function(){if(o.data("fallbackImage")){var a=o.data("fallbackImage");a.hasOwnProperty("img")&&(o.parent().append(a.img),o.remove())}};this.sowbLoadError?r():this.complete||o.error(r)})}()}),window.sowb=sowb;
1
+ var sowb=window.sowb||{};jQuery(function(a){!function(){a(".sowb-google-map-static").each(function(){var o=a(this),t=function(){if(o.data("fallbackImage")){var a=o.data("fallbackImage");a.hasOwnProperty("img")&&a.img.length>0&&(o.parent().append(a.img),o.remove())}};this.sowbLoadError?t():this.complete||o.error(t)})}()}),window.sowb=sowb;
widgets/post-carousel/js/carousel.js CHANGED
@@ -1,163 +1,176 @@
 
 
 
 
1
  jQuery( function ( $ ) {
2
- // The carousel widget
3
- $( '.sow-carousel-wrapper' ).each( function () {
4
-
5
- var $$ = $( this ),
6
- $postsContainer = $$.closest( '.sow-carousel-container' ),
7
- $container = $$.closest( '.sow-carousel-container' ).parent(),
8
- $itemsContainer = $$.find( '.sow-carousel-items' ),
9
- $items = $$.find( '.sow-carousel-item' ),
10
- $firstItem = $items.eq( 0 );
11
-
12
- var position = 0,
13
- page = 1,
14
- fetching = false,
15
- numItems = $items.length,
16
- totalPosts = $$.data( 'found-posts' ),
17
- complete = numItems === totalPosts,
18
- itemWidth = ( $firstItem.width() + parseInt( $firstItem.css( 'margin-right' ) ) ),
19
- isRTL = $postsContainer.hasClass( 'js-rtl' ),
20
- updateProp = isRTL ? 'margin-right' : 'margin-left';
21
-
22
- var updatePosition = function () {
23
- if ( position < 0 ) position = 0;
24
- if ( position >= $$.find( '.sow-carousel-item' ).length - 1 ) {
25
- position = $$.find( '.sow-carousel-item' ).length - 1;
26
- // Fetch the next batch
27
- if ( !fetching && !complete ) {
28
- fetching = true;
29
- page++;
30
- $itemsContainer.append( '<li class="sow-carousel-item sow-carousel-loading"></li>' );
31
- var instanceHash = $container.find( 'input[name="instance_hash"]' ).val();
32
-
33
- $.get(
34
- $$.data( 'ajax-url' ),
35
- {
36
- query: $$.data( 'query' ),
37
- action: 'sow_carousel_load',
38
- paged: page,
39
- instance_hash: instanceHash,
40
- },
41
- function ( data, status ) {
42
- var $items = $( data.html );
43
- $items.appendTo( $itemsContainer ).hide().fadeIn();
44
- $$.find( '.sow-carousel-loading' ).remove();
45
- numItems = $$.find( '.sow-carousel-item' ).length;
46
- complete = numItems === totalPosts;
47
- fetching = false;
48
- }
49
- )
50
- }
51
- }
52
- $itemsContainer.css( 'transition-duration', "0.45s" );
53
- $itemsContainer.css( updateProp, -( itemWidth * position ) + 'px' );
54
- };
55
-
56
- $container.on( 'click', 'a.sow-carousel-previous',
57
- function ( e ) {
58
- e.preventDefault();
59
- position -= isRTL ? -1 : 1;
60
- updatePosition();
61
- }
62
- );
63
-
64
- $container.on( 'click', 'a.sow-carousel-next',
65
- function ( e ) {
66
- e.preventDefault();
67
- position += isRTL ? -1 : 1;
68
- updatePosition();
69
- }
70
- );
71
-
72
- // Verify "swipe" method exists prior to invoking it.
73
- if ( 'function' === typeof $$.swipe ) {
74
- var validSwipe = false;
75
- var prevDistance = 0;
76
- var startPosition = 0;
77
- var velocity = 0;
78
- var prevTime = 0;
79
- var posInterval;
80
- var negativeDirection = isRTL ? 'right' : 'left';
81
-
82
- var setNewPosition = function ( newPosition ) {
83
- if ( newPosition < 50 && newPosition > -( itemWidth * numItems ) ) {
84
- $itemsContainer.css( 'transition-duration', "0s" );
85
- $itemsContainer.css( updateProp, newPosition + 'px' );
86
- return true;
87
  }
88
- return false;
89
- };
90
-
91
- var setFinalPosition = function () {
92
- var finalPosition = parseInt( $itemsContainer.css( updateProp ) );
93
- position = Math.abs( Math.round( finalPosition / itemWidth ) );
94
- updatePosition();
95
  };
96
-
97
- $$.on( 'click', '.sow-carousel-item a',
98
- function ( event ) {
99
- if ( validSwipe ) {
100
- event.preventDefault();
101
- validSwipe = false;
102
- }
103
  }
104
  );
105
-
106
- $$.swipe( {
107
- excludedElements: "",
108
- triggerOnTouchEnd: true,
109
- threshold: 75,
110
- swipeStatus: function ( event, phase, direction, distance, duration, fingerCount, fingerData ) {
111
- if ( direction === 'up' || direction === 'down' ) {
112
- return false;
113
- }
114
-
115
- if ( phase === "start" ) {
116
- startPosition = -( itemWidth * position );
117
- prevTime = new Date().getTime();
118
- clearInterval( posInterval );
119
- }
120
- else if ( phase === "move" ) {
121
- if ( direction === negativeDirection ) distance *= -1;
122
- setNewPosition( startPosition + distance );
123
- var newTime = new Date().getTime();
124
- var timeDelta = ( newTime - prevTime ) / 1000;
125
- velocity = ( distance - prevDistance ) / timeDelta;
126
- prevTime = newTime;
127
- prevDistance = distance;
 
128
  }
129
- else if ( phase === "end" ) {
130
- validSwipe = true;
131
- if ( direction === negativeDirection ) distance *= -1;
132
- if ( Math.abs( velocity ) > 400 ) {
133
- velocity *= 0.1;
134
- var startTime = new Date().getTime();
135
- var cumulativeDistance = 0;
136
- posInterval = setInterval( function () {
137
- var time = ( new Date().getTime() - startTime ) / 1000;
138
- cumulativeDistance += velocity * time;
139
- var newPos = startPosition + distance + cumulativeDistance;
140
- var decel = 30;
141
- var end = ( Math.abs( velocity ) - decel ) < 0;
142
- if ( direction === negativeDirection ) {
143
- velocity += decel;
144
- } else {
145
- velocity -= decel;
146
- }
147
- if ( end || !setNewPosition( newPos ) ) {
148
- clearInterval( posInterval );
149
- setFinalPosition();
150
- }
151
- }, 20 );
152
- } else {
153
- setFinalPosition();
154
  }
155
  }
156
- else if ( phase === "cancel" ) {
157
- updatePosition();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  }
159
- }
160
- } );
161
- }
162
- } );
 
 
 
 
163
  } );
 
 
1
+ /* globals jQuery, sowb */
2
+
3
+ var sowb = window.sowb || {};
4
+
5
  jQuery( function ( $ ) {
6
+
7
+ sowb.setupCarousel = function () {
8
+ // The carousel widget
9
+ $( '.sow-carousel-wrapper' ).each( function () {
10
+
11
+ var $$ = $( this ),
12
+ $postsContainer = $$.closest( '.sow-carousel-container' ),
13
+ $container = $$.closest( '.sow-carousel-container' ).parent(),
14
+ $itemsContainer = $$.find( '.sow-carousel-items' ),
15
+ $items = $$.find( '.sow-carousel-item' ),
16
+ $firstItem = $items.eq( 0 );
17
+
18
+ var position = 0,
19
+ page = 1,
20
+ fetching = false,
21
+ numItems = $items.length,
22
+ totalPosts = $$.data( 'found-posts' ),
23
+ complete = numItems === totalPosts,
24
+ itemWidth = ( $firstItem.width() + parseInt( $firstItem.css( 'margin-right' ) ) ),
25
+ isRTL = $postsContainer.hasClass( 'js-rtl' ),
26
+ updateProp = isRTL ? 'margin-right' : 'margin-left';
27
+
28
+ var updatePosition = function () {
29
+ if ( position < 0 ) position = 0;
30
+ if ( position >= $$.find( '.sow-carousel-item' ).length - 1 ) {
31
+ position = $$.find( '.sow-carousel-item' ).length - 1;
32
+ // Fetch the next batch
33
+ if ( !fetching && !complete ) {
34
+ fetching = true;
35
+ page++;
36
+ $itemsContainer.append( '<li class="sow-carousel-item sow-carousel-loading"></li>' );
37
+ var instanceHash = $container.find( 'input[name="instance_hash"]' ).val();
38
+
39
+ $.get(
40
+ $$.data( 'ajax-url' ),
41
+ {
42
+ query: $$.data( 'query' ),
43
+ action: 'sow_carousel_load',
44
+ paged: page,
45
+ instance_hash: instanceHash,
46
+ },
47
+ function ( data, status ) {
48
+ var $items = $( data.html );
49
+ $items.appendTo( $itemsContainer ).hide().fadeIn();
50
+ $$.find( '.sow-carousel-loading' ).remove();
51
+ numItems = $$.find( '.sow-carousel-item' ).length;
52
+ complete = numItems === totalPosts;
53
+ fetching = false;
54
+ }
55
+ )
56
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
+ $itemsContainer.css( 'transition-duration', "0.45s" );
59
+ $itemsContainer.css( updateProp, -( itemWidth * position) + 'px' );
 
 
 
 
 
60
  };
61
+
62
+ $container.on( 'click', 'a.sow-carousel-previous',
63
+ function ( e ) {
64
+ e.preventDefault();
65
+ position -= isRTL ? -1 : 1;
66
+ updatePosition();
 
67
  }
68
  );
69
+
70
+ $container.on( 'click', 'a.sow-carousel-next',
71
+ function ( e ) {
72
+ e.preventDefault();
73
+ position += isRTL ? -1 : 1;
74
+ updatePosition();
75
+ }
76
+ );
77
+
78
+ // Verify "swipe" method exists prior to invoking it.
79
+ if ( 'function' === typeof $$.swipe ) {
80
+ var validSwipe = false;
81
+ var prevDistance = 0;
82
+ var startPosition = 0;
83
+ var velocity = 0;
84
+ var prevTime = 0;
85
+ var posInterval;
86
+ var negativeDirection = isRTL ? 'right' : 'left';
87
+
88
+ var setNewPosition = function ( newPosition ) {
89
+ if ( newPosition < 50 && newPosition > -( itemWidth * numItems ) ) {
90
+ $itemsContainer.css( 'transition-duration', "0s" );
91
+ $itemsContainer.css( updateProp, newPosition + 'px' );
92
+ return true;
93
  }
94
+ return false;
95
+ };
96
+
97
+ var setFinalPosition = function () {
98
+ var finalPosition = parseInt( $itemsContainer.css( updateProp ) );
99
+ position = Math.abs( Math.round( finalPosition / itemWidth ) );
100
+ updatePosition();
101
+ };
102
+
103
+ $$.on( 'click', '.sow-carousel-item a',
104
+ function ( event ) {
105
+ if ( validSwipe ) {
106
+ event.preventDefault();
107
+ validSwipe = false;
 
 
 
 
 
 
 
 
 
 
 
108
  }
109
  }
110
+ );
111
+
112
+ $$.swipe( {
113
+ excludedElements: "",
114
+ triggerOnTouchEnd: true,
115
+ threshold: 75,
116
+ swipeStatus: function ( event, phase, direction, distance, duration, fingerCount, fingerData ) {
117
+ if ( direction === 'up' || direction === 'down' ) {
118
+ return false;
119
+ }
120
+
121
+ if ( phase === "start" ) {
122
+ startPosition = -( itemWidth * position);
123
+ prevTime = new Date().getTime();
124
+ clearInterval( posInterval );
125
+ }
126
+ else if ( phase === "move" ) {
127
+ if ( direction === negativeDirection ) distance *= -1;
128
+ setNewPosition( startPosition + distance );
129
+ var newTime = new Date().getTime();
130
+ var timeDelta = (newTime - prevTime) / 1000;
131
+ velocity = (distance - prevDistance) / timeDelta;
132
+ prevTime = newTime;
133
+ prevDistance = distance;
134
+ }
135
+ else if ( phase === "end" ) {
136
+ validSwipe = true;
137
+ if ( direction === negativeDirection ) distance *= -1;
138
+ if ( Math.abs( velocity ) > 400 ) {
139
+ velocity *= 0.1;
140
+ var startTime = new Date().getTime();
141
+ var cumulativeDistance = 0;
142
+ posInterval = setInterval( function () {
143
+ var time = (new Date().getTime() - startTime) / 1000;
144
+ cumulativeDistance += velocity * time;
145
+ var newPos = startPosition + distance + cumulativeDistance;
146
+ var decel = 30;
147
+ var end = (Math.abs( velocity ) - decel) < 0;
148
+ if ( direction === negativeDirection ) {
149
+ velocity += decel;
150
+ } else {
151
+ velocity -= decel;
152
+ }
153
+ if ( end || !setNewPosition( newPos ) ) {
154
+ clearInterval( posInterval );
155
+ setFinalPosition();
156
+ }
157
+ }, 20 );
158
+ } else {
159
+ setFinalPosition();
160
+ }
161
+ }
162
+ else if ( phase === "cancel" ) {
163
+ updatePosition();
164
+ }
165
  }
166
+ } );
167
+ }
168
+ } );
169
+ };
170
+
171
+ sowb.setupCarousel();
172
+
173
+ $( sowb ).on( 'setup_widgets', sowb.setupCarousel );
174
  } );
175
+
176
+ window.sowb = sowb;
widgets/post-carousel/js/carousel.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(e){e(".sow-carousel-wrapper").each(function(){var a=e(this),n=a.closest(".sow-carousel-container"),t=a.closest(".sow-carousel-container").parent(),s=a.find(".sow-carousel-items"),i=a.find(".sow-carousel-item"),o=i.eq(0),r=0,c=1,l=!1,u=i.length,f=a.data("found-posts"),d=u===f,w=o.width()+parseInt(o.css("margin-right")),h=n.hasClass("js-rtl"),p=h?"margin-right":"margin-left",g=function(){if(r<0&&(r=0),r>=a.find(".sow-carousel-item").length-1&&(r=a.find(".sow-carousel-item").length-1,!l&&!d)){l=!0,c++,s.append('<li class="sow-carousel-item sow-carousel-loading"></li>');var n=t.find('input[name="instance_hash"]').val();e.get(a.data("ajax-url"),{query:a.data("query"),action:"sow_carousel_load",paged:c,instance_hash:n},function(n,t){e(n.html).appendTo(s).hide().fadeIn(),a.find(".sow-carousel-loading").remove(),u=a.find(".sow-carousel-item").length,d=u===f,l=!1})}s.css("transition-duration","0.45s"),s.css(p,-w*r+"px")};if(t.on("click","a.sow-carousel-previous",function(e){e.preventDefault(),r-=h?-1:1,g()}),t.on("click","a.sow-carousel-next",function(e){e.preventDefault(),r+=h?-1:1,g()}),"function"==typeof a.swipe){var m,v=!1,D=0,I=0,T=0,x=0,y=h?"right":"left",M=function(e){return e<50&&e>-w*u&&(s.css("transition-duration","0s"),s.css(p,e+"px"),!0)},_=function(){var e=parseInt(s.css(p));r=Math.abs(Math.round(e/w)),g()};a.on("click",".sow-carousel-item a",function(e){v&&(e.preventDefault(),v=!1)}),a.swipe({excludedElements:"",triggerOnTouchEnd:!0,threshold:75,swipeStatus:function(e,a,n,t,s,i,o){if("up"===n||"down"===n)return!1;if("start"===a)I=-w*r,x=(new Date).getTime(),clearInterval(m);else if("move"===a){n===y&&(t*=-1),M(I+t);var c=(new Date).getTime(),l=(c-x)/1e3;T=(t-D)/l,x=c,D=t}else if("end"===a)if(v=!0,n===y&&(t*=-1),Math.abs(T)>400){T*=.1;var u=(new Date).getTime(),f=0;m=setInterval(function(){var e=((new Date).getTime()-u)/1e3;f+=T*e;var a=I+t+f,s=Math.abs(T)-30<0;n===y?T+=30:T-=30,!s&&M(a)||(clearInterval(m),_())},20)}else _();else"cancel"===a&&g()}})}})});
1
+ var sowb=window.sowb||{};jQuery(function(e){sowb.setupCarousel=function(){e(".sow-carousel-wrapper").each(function(){var s=e(this),t=s.closest(".sow-carousel-container"),n=s.closest(".sow-carousel-container").parent(),a=s.find(".sow-carousel-items"),o=s.find(".sow-carousel-item"),i=o.eq(0),r=0,l=1,c=!1,u=o.length,w=s.data("found-posts"),f=u===w,d=i.width()+parseInt(i.css("margin-right")),p=t.hasClass("js-rtl"),h=p?"margin-right":"margin-left",g=function(){if(r<0&&(r=0),r>=s.find(".sow-carousel-item").length-1&&(r=s.find(".sow-carousel-item").length-1,!c&&!f)){c=!0,l++,a.append('<li class="sow-carousel-item sow-carousel-loading"></li>');var t=n.find('input[name="instance_hash"]').val();e.get(s.data("ajax-url"),{query:s.data("query"),action:"sow_carousel_load",paged:l,instance_hash:t},function(t,n){e(t.html).appendTo(a).hide().fadeIn(),s.find(".sow-carousel-loading").remove(),u=s.find(".sow-carousel-item").length,f=u===w,c=!1})}a.css("transition-duration","0.45s"),a.css(h,-d*r+"px")};if(n.on("click","a.sow-carousel-previous",function(e){e.preventDefault(),r-=p?-1:1,g()}),n.on("click","a.sow-carousel-next",function(e){e.preventDefault(),r+=p?-1:1,g()}),"function"==typeof s.swipe){var m,v=!1,b=0,D=0,I=0,T=0,x=p?"right":"left",_=function(e){return e<50&&e>-d*u&&(a.css("transition-duration","0s"),a.css(h,e+"px"),!0)},y=function(){var e=parseInt(a.css(h));r=Math.abs(Math.round(e/d)),g()};s.on("click",".sow-carousel-item a",function(e){v&&(e.preventDefault(),v=!1)}),s.swipe({excludedElements:"",triggerOnTouchEnd:!0,threshold:75,swipeStatus:function(e,s,t,n,a,o,i){if("up"===t||"down"===t)return!1;if("start"===s)D=-d*r,T=(new Date).getTime(),clearInterval(m);else if("move"===s){t===x&&(n*=-1),_(D+n);var l=(new Date).getTime(),c=(l-T)/1e3;I=(n-b)/c,T=l,b=n}else if("end"===s)if(v=!0,t===x&&(n*=-1),Math.abs(I)>400){I*=.1;var u=(new Date).getTime(),w=0;m=setInterval(function(){var e=((new Date).getTime()-u)/1e3;w+=I*e;var s=D+n+w,a=Math.abs(I)-30<0;t===x?I+=30:I-=30,!a&&_(s)||(clearInterval(m),y())},20)}else y();else"cancel"===s&&g()}})}})},sowb.setupCarousel(),e(sowb).on("setup_widgets",sowb.setupCarousel)}),window.sowb=sowb;
widgets/social-media-buttons/data/networks.php CHANGED
@@ -25,12 +25,18 @@ return array(
25
  'icon_color' => '#FFFFFF',
26
  'button_color' => '#FAA21B'
27
  ),
28
- 'envelope' => array(
29
  'label' => __( 'Email', 'so-widgets-bundle' ),
30
  'base_url' => 'mailto:',
31
  'icon_color' => '#FFFFFF',
32
  'button_color' => '#99C4E6'
33
  ),
 
 
 
 
 
 
34
  'snapchat' => array(
35
  'label' => __( 'Snapchat', 'so-widgets-bundle' ),
36
  'base_url' => 'https://www.snapchat.com/',
@@ -88,6 +94,12 @@ return array(
88
  'icon_color' => '#FFFFFF',
89
  'button_color' => '#292929'
90
  ),
 
 
 
 
 
 
91
  'behance' => array(
92
  'label' => __( 'Behance', 'so-widgets-bundle' ),
93
  'base_url' => 'https://www.behance.net/',
25
  'icon_color' => '#FFFFFF',
26
  'button_color' => '#FAA21B'
27
  ),
28
+ 'email' => array(
29
  'label' => __( 'Email', 'so-widgets-bundle' ),
30
  'base_url' => 'mailto:',
31
  'icon_color' => '#FFFFFF',
32
  'button_color' => '#99C4E6'
33
  ),
34
+ 'phone' => array(
35
+ 'label' => __( 'Phone', 'so-widgets-bundle' ),
36
+ 'base_url' => 'tel:',
37
+ 'icon_color' => '#FFFFFF',
38
+ 'button_color' => '#99E5AA'
39
+ ),
40
  'snapchat' => array(
41
  'label' => __( 'Snapchat', 'so-widgets-bundle' ),
42
  'base_url' => 'https://www.snapchat.com/',
94
  'icon_color' => '#FFFFFF',
95
  'button_color' => '#292929'
96
  ),
97
+ 'angellist' => array(
98
+ 'label' => __( 'AngelList', 'so-widgets-bundle' ),
99
+ 'base_url' => 'https://angel.co/',
100
+ 'icon_color' => '#FFFFFF',
101
+ 'button_color' => '#2A2929'
102
+ ),
103
  'behance' => array(
104
  'label' => __( 'Behance', 'so-widgets-bundle' ),
105
  'base_url' => 'https://www.behance.net/',
widgets/social-media-buttons/social-media-buttons.php CHANGED
@@ -188,7 +188,11 @@ class SiteOrigin_Widget_SocialMediaButtons_Widget extends SiteOrigin_Widget {
188
  function modify_instance( $instance ) {
189
  if ( ! empty( $instance['networks'] ) ) {
190
  foreach ( $instance['networks'] as $name => $network ) {
191
- $instance['networks'][$name]['icon_name'] = 'fontawesome-' . $network['name'];
 
 
 
 
192
  }
193
  }
194
  return $instance;
188
  function modify_instance( $instance ) {
189
  if ( ! empty( $instance['networks'] ) ) {
190
  foreach ( $instance['networks'] as $name => $network ) {
191
+ if ( $network['name'] == 'envelope' ) {
192
+ $network['name'] = 'email';
193
+ }
194
+ $network['icon_name'] = 'fontawesome-' . ( $network['name'] == 'email' ? 'envelope' : $network['name'] );
195
+ $instance['networks'][$name] = $network;
196
  }
197
  }
198
  return $instance;
widgets/social-media-buttons/tpl/default.php CHANGED
@@ -1,30 +1,47 @@
1
- <?php if ( !empty( $instance['title'] ) ) echo $args['before_title'] . esc_html( $instance['title'] ) . $args['after_title']; ?>
2
-
3
- <div class="social-media-button-container">
4
- <?php foreach( $networks as $network ) :
5
- $classes = array();
6
- if( !empty($instance['design']['hover']) ) $classes[] = 'ow-button-hover';
7
- $classes[] = "sow-social-media-button-" . sanitize_html_class( $network['name'] );
8
- $classes[] = "sow-social-media-button";
9
- $title = empty( $network['icon_title'] ) ? sprintf( __( '%s on %s', 'so-widgets-bundle' ), get_bloginfo( 'name' ), ucwords( str_replace( '-', ' ', $network['name'] ) ) ) : $network['icon_title'];
10
- $button_attributes = array(
11
- 'class' => esc_attr( implode(' ', $classes) ),
12
- 'title' => $title,
13
- 'aria-label' => $title,
14
- );
15
- if( !empty( $instance['design']['new_window'] ) ) {
16
- $button_attributes['target'] = '_blank';
17
- $button_attributes['rel'] = 'noopener noreferrer';
18
- }
19
- if ( ! empty( $network['url'] ) ) $button_attributes['href'] = sow_esc_url( trim( $network['url'] ) );
20
- ?>
21
-
22
- <a <?php foreach($button_attributes as $name => $val) echo $name . '="' . esc_attr( $val ) . '" ' ?>>
23
- <span>
24
- <?php if( !empty( $network['is_custom'] ) ) echo '<!-- premium-' . $network['name'] . ' -->'; ?>
25
- <?php echo siteorigin_widget_get_icon( $network['icon_name'] ); ?>
26
- <?php if( !empty( $network['is_custom'] ) ) echo '<!-- endpremium -->'; ?>
27
- </span>
28
- </a>
29
- <?php endforeach; ?>
30
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ( !empty( $instance['title'] ) ) echo $args['before_title'] . esc_html( $instance['title'] ) . $args['after_title']; ?>
2
+
3
+ <div class="social-media-button-container">
4
+ <?php foreach( $networks as $network ) :
5
+ $classes = array();
6
+ if( !empty($instance['design']['hover']) ) $classes[] = 'ow-button-hover';
7
+ $classes[] = "sow-social-media-button-" . sanitize_html_class( $network['name'] );
8
+ $classes[] = "sow-social-media-button";
9
+
10
+ if ( empty( $network['icon_title'] ) ) {
11
+ if ( $network['name'] == 'email' || $network['name'] == 'phone' ) {
12
+ $title = sprintf(
13
+ __( '%s %s', 'so-widgets-bundle' ),
14
+ ucfirst( $network['name'] ),
15
+ get_bloginfo( 'name' )
16
+ );
17
+ } else {
18
+ $title = sprintf(
19
+ __( '%s on %s', 'so-widgets-bundle' ),
20
+ get_bloginfo( 'name' ),
21
+ ucwords( str_replace( '-', ' ', $network['name'] ) )
22
+ );
23
+ }
24
+ } else {
25
+ $title = $network['icon_title'];
26
+ }
27
+ $button_attributes = array(
28
+ 'class' => esc_attr( implode(' ', $classes) ),
29
+ 'title' => $title,
30
+ 'aria-label' => $title,
31
+ );
32
+ if( !empty( $instance['design']['new_window'] ) ) {
33
+ $button_attributes['target'] = '_blank';
34
+ $button_attributes['rel'] = 'noopener noreferrer';
35
+ }
36
+ if ( ! empty( $network['url'] ) ) $button_attributes['href'] = sow_esc_url( trim( $network['url'] ) );
37
+ ?>
38
+
39
+ <a <?php foreach($button_attributes as $name => $val) echo $name . '="' . esc_attr( $val ) . '" ' ?>>
40
+ <span>
41
+ <?php if( !empty( $network['is_custom'] ) ) echo '<!-- premium-' . $network['name'] . ' -->'; ?>
42
+ <?php echo siteorigin_widget_get_icon( $network['icon_name'] ); ?>
43
+ <?php if( !empty( $network['is_custom'] ) ) echo '<!-- endpremium -->'; ?>
44
+ </span>
45
+ </a>
46
+ <?php endforeach; ?>
47
+ </div>
widgets/tabs/styles/default.less CHANGED
@@ -110,10 +110,6 @@
110
  font-family: @panels_font_family;
111
  font-weight: @panels_font_weight;
112
  font-size: @panels_font_size;
113
-
114
- > p {
115
- margin: 0;
116
- }
117
  }
118
  }
119
  }
110
  font-family: @panels_font_family;
111
  font-weight: @panels_font_weight;
112
  font-size: @panels_font_size;
 
 
 
 
113
  }
114
  }
115
  }