Version Description
- 11 July 2018 =
- Contact: Add dedicated textarea height.
- Social Media Buttons: Adds WhatsApp social network.
- Features: Allow icon size to use a different unit of measurement.
- Repeater field: Update editor id in media buttons when duplicating item with TinyMCE editor.
- Posts field: taxonomy description.
- Price Table: Disable equalized row heights on mobile.
- Beaver Builder: Force icon fonts.
- Slider widgets: Added autoplay option for background videos.
- Maps: Renamed Google maps script to more sensible
sow.google-map.js
- Editor: Prevent errors when visual editing is disabled for a user.
- Optimized images.
- Accordion/tabs: Trigger 'setup_widgets' to ensure any widgets in panels are initialized correctly.
- Contact: Use 'From' email address if there is no email field in the form.
- Hero: Filter out the align field in the button sub-widget form.
- Testimonials: Switch mobile and tablet resolution width field descriptions.
- Posts field: Allow clearing dates.
- Font field: Use correct value for 'Helvetica Neue' and added 'Arial' option.
- TA: Additional setting to allow clearing the default background colors.
- Contact: Allow a value of '0' for required fields and subject values.
Download this release
Release Info
Developer | gpriday |
Plugin | ![]() |
Version | 1.12.0 |
Comparing to | |
See all releases |
Code changes from version 1.11.8 to 1.12.0
- admin/images/icon-back.png +0 -0
- admin/images/icon-front.png +0 -0
- admin/images/icon-gear.png +0 -0
- base/base.php +4 -1
- base/css/img/arrow-down.png +0 -0
- base/css/img/arrow-right.png +0 -0
- base/css/img/bundle-icon.png +0 -0
- base/css/img/close-white.png +0 -0
- base/css/img/close.png +0 -0
- base/css/img/loading.gif +0 -0
- base/css/img/order-asc.png +0 -0
- base/css/img/order-desc.png +0 -0
- base/css/img/ordering-icons.png +0 -0
- base/css/img/thumbnail-placeholder.png +0 -0
- base/css/img/wpspin_light-2x.gif +0 -0
- base/css/img/wpspin_light.gif +0 -0
- base/inc/fields/js/date-range-field.js +31 -21
- base/inc/fields/js/date-range-field.min.js +1 -1
- base/inc/fields/js/tinymce-field.js +4 -2
- base/inc/fields/js/tinymce-field.min.js +1 -1
- base/inc/fields/posts.class.php +189 -188
- base/inc/fields/tinymce.class.php +65 -57
- base/inc/fields/widget.class.php +71 -60
- base/inc/video.php +96 -0
- base/inc/widgets/base-slider.class.php +12 -4
- base/js/admin.js +9 -0
- base/js/admin.min.js +1 -1
- base/siteorigin-widget.class.php +14 -9
- compat/beaver-builder/styles.css +6 -6
- js/slider/jquery.slider.js +266 -267
- js/slider/jquery.slider.min.js +1 -1
- js/{sow.google.map.js → sow.google-map.js} +5 -12
- js/sow.google-map.min.js +1 -0
- js/sow.google.map.min.js +0 -1
- js/sow.jquery.fittext.js +71 -68
- js/sow.jquery.fittext.min.js +1 -1
- lang/so-widgets-bundle.pot +758 -755
- readme.txt +23 -2
- so-widgets-bundle.php +3 -3
- widgets/accordion/assets/banner.svg +1 -18
- widgets/accordion/js/accordion.js +6 -0
- widgets/accordion/js/accordion.min.js +1 -1
- widgets/button/assets/banner.svg +1 -30
- widgets/contact/assets/banner.svg +1 -43
- widgets/contact/contact.php +15 -5
- widgets/contact/styles/default.less +9 -1
- widgets/cta/assets/banner.svg +1 -33
- widgets/cta/css/style.css +1 -1
- widgets/cta/cta.php +22 -0
- widgets/cta/styles/default.less +8 -4
- widgets/editor/assets/banner.svg +1 -38
- widgets/features/assets/banner.svg +1 -56
- widgets/features/images/containers/explode.svg +1 -8
- widgets/features/images/containers/frame.svg +1 -7
- widgets/features/images/containers/hex.svg +1 -7
- widgets/features/images/containers/octagon.svg +1 -8
- widgets/features/images/containers/round.svg +1 -7
- widgets/features/images/containers/rounded-hex.svg +1 -10
- widgets/features/images/containers/rounded-square.svg +1 -7
- widgets/features/images/containers/rounded-sticker.svg +1 -12
- widgets/features/images/containers/square.svg +1 -7
- widgets/features/images/containers/sticker.svg +1 -9
- widgets/features/tpl/default.php +1 -1
- widgets/google-map/assets/banner.svg +1 -44
- widgets/headline/assets/banner.svg +1 -38
- widgets/hero/assets/banner.svg +1 -16
- widgets/hero/hero.php +9 -1
- widgets/icon/assets/banner.svg +1 -21
- widgets/image-grid/assets/banner.svg +1 -31
- widgets/image/assets/banner.svg +1 -36
- widgets/layout-slider/assets/banner.svg +1 -18
- widgets/layout-slider/layout-slider.php +314 -314
- widgets/layout-slider/styles/default.less +59 -59
- widgets/post-carousel/assets/banner.svg +1 -44
- widgets/post-carousel/css/images/carousel-loader.gif +0 -0
- widgets/price-table/assets/banner.svg +1 -36
- widgets/price-table/js/pricetable.js +46 -46
- widgets/price-table/styles/atom.less +238 -233
- widgets/simple-masonry/assets/banner.svg +1 -20
- widgets/simple-masonry/js/simple-masonry.js +86 -80
- widgets/simple-masonry/js/simple-masonry.min.js +1 -1
- widgets/slider/assets/banner.svg +1 -40
- widgets/social-media-buttons/assets/banner.svg +1 -39
- widgets/social-media-buttons/data/networks.php +283 -277
- widgets/tabs/assets/banner.svg +1 -17
- widgets/tabs/js/tabs.js +6 -0
- widgets/tabs/js/tabs.min.js +1 -1
- widgets/taxonomy/assets/banner.svg +1 -17
- widgets/testimonial/assets/banner.svg +1 -41
- widgets/testimonial/testimonial.php +2 -2
- widgets/video/assets/banner.svg +1 -36
- widgets/video/css/controls-skin.png +0 -0
- widgets/video/tpl/default.php +55 -53
- widgets/video/video.php +280 -346
admin/images/icon-back.png
CHANGED
Binary file
|
admin/images/icon-front.png
CHANGED
Binary file
|
admin/images/icon-gear.png
CHANGED
Binary file
|
base/base.php
CHANGED
@@ -11,6 +11,7 @@ include plugin_dir_path(__FILE__).'inc/array-utils.php';
|
|
11 |
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 |
|
15 |
/**
|
16 |
* @param $css
|
@@ -93,7 +94,8 @@ function siteorigin_widget_get_icon($icon_value, $icon_styles = false) {
|
|
93 |
function siteorigin_widget_get_font($font_value) {
|
94 |
|
95 |
$web_safe = array(
|
96 |
-
'
|
|
|
97 |
'Lucida Grande' => 'Lucida, Verdana, sans-serif',
|
98 |
'Georgia' => '"Times New Roman", Times, serif',
|
99 |
'Courier New' => 'Courier, mono',
|
@@ -201,6 +203,7 @@ function siteorigin_widgets_is_google_webfont( $font_value ) {
|
|
201 |
function siteorigin_widgets_font_families( ){
|
202 |
// Add the default fonts
|
203 |
$font_families = array(
|
|
|
204 |
'Helvetica Neue' => 'Helvetica Neue',
|
205 |
'Lucida Grande' => 'Lucida Grande',
|
206 |
'Georgia' => 'Georgia',
|
11 |
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
|
94 |
function siteorigin_widget_get_font($font_value) {
|
95 |
|
96 |
$web_safe = array(
|
97 |
+
'Arial' => 'Arial, "Helvetica Neue", Helvetica, sans-serif',
|
98 |
+
'Helvetica Neue' => '"Helvetica Neue", Helvetica, Arial, sans-serif',
|
99 |
'Lucida Grande' => 'Lucida, Verdana, sans-serif',
|
100 |
'Georgia' => '"Times New Roman", Times, serif',
|
101 |
'Courier New' => 'Courier, mono',
|
203 |
function siteorigin_widgets_font_families( ){
|
204 |
// Add the default fonts
|
205 |
$font_families = array(
|
206 |
+
'Arial' => 'Arial',
|
207 |
'Helvetica Neue' => 'Helvetica Neue',
|
208 |
'Lucida Grande' => 'Lucida Grande',
|
209 |
'Georgia' => 'Georgia',
|
base/css/img/arrow-down.png
CHANGED
Binary file
|
base/css/img/arrow-right.png
CHANGED
Binary file
|
base/css/img/bundle-icon.png
CHANGED
Binary file
|
base/css/img/close-white.png
CHANGED
Binary file
|
base/css/img/close.png
CHANGED
Binary file
|
base/css/img/loading.gif
CHANGED
Binary file
|
base/css/img/order-asc.png
CHANGED
Binary file
|
base/css/img/order-desc.png
CHANGED
Binary file
|
base/css/img/ordering-icons.png
CHANGED
Binary file
|
base/css/img/thumbnail-placeholder.png
CHANGED
Binary file
|
base/css/img/wpspin_light-2x.gif
CHANGED
Binary file
|
base/css/img/wpspin_light.gif
CHANGED
Binary file
|
base/inc/fields/js/date-range-field.js
CHANGED
@@ -12,36 +12,46 @@
|
|
12 |
if ( $dateRangeField.find( '[class*="sowb-specific-date"]' ).length > 0 ) {
|
13 |
var createPikadayInput = function ( inputName, initVal ) {
|
14 |
var $field = $dateRangeField.find( '.' + inputName + '-picker' );
|
15 |
-
var
|
16 |
-
|
17 |
-
|
18 |
-
toString: function( date, format ) {
|
19 |
var day = date.getDate();
|
20 |
day = day < 10 ? '0' + day.toString() : day.toString();
|
21 |
var month = date.getMonth() + 1;
|
22 |
month = month < 10 ? '0' + month.toString() : month.toString();
|
23 |
var year = date.getFullYear();
|
24 |
return year + '-' + month + '-' + day;
|
25 |
-
}
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
} );
|
42 |
|
43 |
-
// We trigger the change event on the hidden value field, so prevent 'change' from individual date inputs.
|
44 |
$field.change( function ( event ) {
|
|
|
|
|
|
|
|
|
45 |
event.preventDefault();
|
46 |
return false;
|
47 |
} );
|
12 |
if ( $dateRangeField.find( '[class*="sowb-specific-date"]' ).length > 0 ) {
|
13 |
var createPikadayInput = function ( inputName, initVal ) {
|
14 |
var $field = $dateRangeField.find( '.' + inputName + '-picker' );
|
15 |
+
var dateToString = function ( date, format ) {
|
16 |
+
var dateString = '';
|
17 |
+
if ( ! isNaN( date.valueOf() ) ) {
|
|
|
18 |
var day = date.getDate();
|
19 |
day = day < 10 ? '0' + day.toString() : day.toString();
|
20 |
var month = date.getMonth() + 1;
|
21 |
month = month < 10 ? '0' + month.toString() : month.toString();
|
22 |
var year = date.getFullYear();
|
23 |
return year + '-' + month + '-' + day;
|
24 |
+
}
|
25 |
+
|
26 |
+
return dateString;
|
27 |
+
};
|
28 |
+
var parse = function ( dateString, format ) {
|
29 |
+
var parts = dateString.split( '-' );
|
30 |
+
var day = parseInt( parts[ 2 ] );
|
31 |
+
var month = parseInt( parts[ 1 ] ) - 1;
|
32 |
+
var year = parseInt( parts[ 0 ] );
|
33 |
+
return new Date( year, month, day );
|
34 |
+
};
|
35 |
+
var updateValField = function ( date ) {
|
36 |
+
var curVal = valField.val() === '' ? {} : JSON.parse( valField.val() );
|
37 |
+
curVal[ inputName ] = dateToString( date );
|
38 |
+
$field.val( curVal[ inputName ] );
|
39 |
+
valField.val( JSON.stringify( curVal ) );
|
40 |
+
valField.trigger( 'change', { silent: true } );
|
41 |
+
};
|
42 |
+
var picker = new Pikaday( {
|
43 |
+
field: $field[ 0 ],
|
44 |
+
blurFieldOnSelect: false,
|
45 |
+
toString: dateToString,
|
46 |
+
parse: parse,
|
47 |
+
onSelect: updateValField,
|
48 |
} );
|
49 |
|
|
|
50 |
$field.change( function ( event ) {
|
51 |
+
var dateVal = parse( $field.val() );
|
52 |
+
updateValField( dateVal );
|
53 |
+
|
54 |
+
// We trigger the change event on the hidden value field, so prevent 'change' from individual date inputs.
|
55 |
event.preventDefault();
|
56 |
return false;
|
57 |
} );
|
base/inc/fields/js/date-range-field.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(
|
1 |
+
!function(e){e(document).on("sowsetupformfield",".siteorigin-widget-field-type-date-range",function(t){var i=e(this),a=i.find('input[type="hidden"][class="siteorigin-widget-input"]');if(!i.data("initialized")){if(i.find('[class*="sowb-specific-date"]').length>0){var n=function(e,t){var n=i.find("."+e+"-picker"),r=function(e,t){if(!isNaN(e.valueOf())){var i=e.getDate();i=i<10?"0"+i.toString():i.toString();var a=e.getMonth()+1;a=a<10?"0"+a.toString():a.toString();return e.getFullYear()+"-"+a+"-"+i}return""},l=function(e,t){var i=e.split("-"),a=parseInt(i[2]),n=parseInt(i[1])-1,r=parseInt(i[0]);return new Date(r,n,a)},s=function(t){var i=""===a.val()?{}:JSON.parse(a.val());i[e]=r(t),n.val(i[e]),a.val(JSON.stringify(i)),a.trigger("change",{silent:!0})},f=new Pikaday({field:n[0],blurFieldOnSelect:!1,toString:r,parse:l,onSelect:s});return n.change(function(e){var t=l(n.val());return s(t),e.preventDefault(),!1}),t&&n.val(t),f}.bind(this),r=""===a.val()?{after:"",before:""}:JSON.parse(a.val()),l=n("after",r.after),s=n("before",r.before);a.change(function(e,t){if(!t||!t.silent){var i=""===a.val()?{after:"",before:""}:JSON.parse(a.val());l.setDate(i.after),s.setDate(i.before)}})}else i.find(".sowb-relative-date").length>0&&i.find(".sowb-relative-date").each(function(){var t=e(this).data("name");e(this).change(function(){var i=""===a.val()?{}:JSON.parse(a.val());i.hasOwnProperty(t)||(i[t]={}),i[t].value=e(this).find("> input").val(),i[t].unit=e(this).find("> select").val(),a.val(JSON.stringify(i)),a.trigger("change",{silent:!0})}.bind(this)),a.change(function(i,n){if(!n||!n.silent){var r=""===a.val()?{from:{},to:{}}:JSON.parse(a.val());r.hasOwnProperty(t)&&(e(this).find("> input").val(r[t].value),e(this).find("> select").val(r[t].unit))}}.bind(this))});i.data("initialized",!0)}})}(jQuery);
|
base/inc/fields/js/tinymce-field.js
CHANGED
@@ -33,8 +33,10 @@
|
|
33 |
} );
|
34 |
}
|
35 |
};
|
36 |
-
|
37 |
-
|
|
|
|
|
38 |
$( document ).on( 'wp-before-tinymce-init', function ( event, init ) {
|
39 |
if ( init.selector === settings.tinymce.selector ) {
|
40 |
var mediaButtons = $container.data( 'mediaButtons' );
|
33 |
} );
|
34 |
}
|
35 |
};
|
36 |
+
|
37 |
+
if ( settings.tinymce ) {
|
38 |
+
settings.tinymce = $.extend( {}, settings.tinymce, { selector: '#' + id, setup: setupEditor } );
|
39 |
+
}
|
40 |
$( document ).on( 'wp-before-tinymce-init', function ( event, init ) {
|
41 |
if ( init.selector === settings.tinymce.selector ) {
|
42 |
var mediaButtons = $container.data( 'mediaButtons' );
|
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=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,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);
|
base/inc/fields/posts.class.php
CHANGED
@@ -1,188 +1,189 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class SiteOrigin_Widget_Field_Posts
|
5 |
-
*/
|
6 |
-
class SiteOrigin_Widget_Field_Posts extends SiteOrigin_Widget_Field_Container_Base {
|
7 |
-
|
8 |
-
public function __construct( $base_name, $element_id, $element_name, $field_options, SiteOrigin_Widget $for_widget, $parent_container = array() ) {
|
9 |
-
parent::__construct( $base_name, $element_id, $element_name, $field_options, $for_widget, $parent_container );
|
10 |
-
|
11 |
-
$types = get_post_types( array( 'public' => true ), 'objects' );
|
12 |
-
$type_options = array( '_all' => __( 'All', 'so-widgets-bundle' ) );
|
13 |
-
|
14 |
-
foreach ( $types as $id => $type ) {
|
15 |
-
$type_options[ $id ] = $type->labels->name;
|
16 |
-
}
|
17 |
-
|
18 |
-
$this->fields = array(
|
19 |
-
|
20 |
-
'post_type' => array(
|
21 |
-
'type' => 'select',
|
22 |
-
'label' => __( 'Post type', 'so-widgets-bundle' ),
|
23 |
-
'multiple' => true,
|
24 |
-
'options' => $type_options,
|
25 |
-
'default' => 'post'
|
26 |
-
),
|
27 |
-
|
28 |
-
'post__in' => array(
|
29 |
-
'type' => 'autocomplete',
|
30 |
-
'label' => __( 'Post in', 'so-widgets-bundle' ),
|
31 |
-
'source' => 'posts',
|
32 |
-
),
|
33 |
-
|
34 |
-
'tax_query' => array(
|
35 |
-
'type' => 'autocomplete',
|
36 |
-
'label' => __( 'Taxonomies', 'so-widgets-bundle' ),
|
37 |
-
'source' => 'terms',
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
'
|
43 |
-
'
|
44 |
-
|
45 |
-
'
|
46 |
-
|
47 |
-
|
48 |
-
'
|
49 |
-
'
|
50 |
-
|
51 |
-
'
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
'
|
58 |
-
'
|
59 |
-
'
|
60 |
-
|
61 |
-
'
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
'
|
68 |
-
'
|
69 |
-
'
|
70 |
-
|
71 |
-
'
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
'
|
78 |
-
'
|
79 |
-
|
80 |
-
'
|
81 |
-
'
|
82 |
-
'
|
83 |
-
'
|
84 |
-
'
|
85 |
-
'
|
86 |
-
'
|
87 |
-
'
|
88 |
-
'
|
89 |
-
'
|
90 |
-
'
|
91 |
-
'
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
'
|
99 |
-
'
|
100 |
-
|
101 |
-
'
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
'
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
'
|
114 |
-
'
|
115 |
-
|
116 |
-
'
|
117 |
-
'
|
118 |
-
'
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
'
|
125 |
-
'
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
$
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class SiteOrigin_Widget_Field_Posts
|
5 |
+
*/
|
6 |
+
class SiteOrigin_Widget_Field_Posts extends SiteOrigin_Widget_Field_Container_Base {
|
7 |
+
|
8 |
+
public function __construct( $base_name, $element_id, $element_name, $field_options, SiteOrigin_Widget $for_widget, $parent_container = array() ) {
|
9 |
+
parent::__construct( $base_name, $element_id, $element_name, $field_options, $for_widget, $parent_container );
|
10 |
+
|
11 |
+
$types = get_post_types( array( 'public' => true ), 'objects' );
|
12 |
+
$type_options = array( '_all' => __( 'All', 'so-widgets-bundle' ) );
|
13 |
+
|
14 |
+
foreach ( $types as $id => $type ) {
|
15 |
+
$type_options[ $id ] = $type->labels->name;
|
16 |
+
}
|
17 |
+
|
18 |
+
$this->fields = array(
|
19 |
+
|
20 |
+
'post_type' => array(
|
21 |
+
'type' => 'select',
|
22 |
+
'label' => __( 'Post type', 'so-widgets-bundle' ),
|
23 |
+
'multiple' => true,
|
24 |
+
'options' => $type_options,
|
25 |
+
'default' => 'post'
|
26 |
+
),
|
27 |
+
|
28 |
+
'post__in' => array(
|
29 |
+
'type' => 'autocomplete',
|
30 |
+
'label' => __( 'Post in', 'so-widgets-bundle' ),
|
31 |
+
'source' => 'posts',
|
32 |
+
),
|
33 |
+
|
34 |
+
'tax_query' => array(
|
35 |
+
'type' => 'autocomplete',
|
36 |
+
'label' => __( 'Taxonomies', 'so-widgets-bundle' ),
|
37 |
+
'source' => 'terms',
|
38 |
+
'description' => __( 'Taxonomies are groups such as categories, tags, posts and products.', 'so-widgets-bundle' ),
|
39 |
+
),
|
40 |
+
|
41 |
+
'date_type' => array(
|
42 |
+
'type' => 'radio',
|
43 |
+
'label' => __( 'Date selection type', 'so-widgets-bundle' ),
|
44 |
+
'options' => array(
|
45 |
+
'specific' => __( 'Specific', 'so-widgets-bundle' ),
|
46 |
+
'relative' => __( 'Relative', 'so-widgets-bundle' ),
|
47 |
+
),
|
48 |
+
'description' => __( 'Select a range between specific dates or relative to the current date.', 'so-widgets-bundle' ),
|
49 |
+
'default' => 'specific',
|
50 |
+
'state_emitter' => array(
|
51 |
+
'callback' => 'select',
|
52 |
+
'args' => array( 'date_type' )
|
53 |
+
),
|
54 |
+
),
|
55 |
+
|
56 |
+
'date_query' => array(
|
57 |
+
'type' => 'date-range',
|
58 |
+
'label' => __( 'Dates', 'so-widgets-bundle' ),
|
59 |
+
'date_type' => 'specific',
|
60 |
+
'state_handler' => array(
|
61 |
+
'date_type[specific]' => array('show'),
|
62 |
+
'_else[date_type]' => array('hide'),
|
63 |
+
),
|
64 |
+
),
|
65 |
+
|
66 |
+
'date_query_relative' => array(
|
67 |
+
'type' => 'date-range',
|
68 |
+
'label' => __( 'Dates', 'so-widgets-bundle' ),
|
69 |
+
'date_type' => 'relative',
|
70 |
+
'state_handler' => array(
|
71 |
+
'date_type[relative]' => array('show'),
|
72 |
+
'_else[date_type]' => array('hide'),
|
73 |
+
),
|
74 |
+
),
|
75 |
+
|
76 |
+
'orderby' => array(
|
77 |
+
'type' => 'select',
|
78 |
+
'label' => __( 'Order by', 'so-widgets-bundle' ),
|
79 |
+
'options' => array(
|
80 |
+
'none' => __( 'No order', 'so-widgets-bundle' ),
|
81 |
+
'ID' => __( 'Post ID', 'so-widgets-bundle' ),
|
82 |
+
'author' => __( 'Author', 'so-widgets-bundle' ),
|
83 |
+
'title' => __( 'Title', 'so-widgets-bundle' ),
|
84 |
+
'date' => __( 'Published date', 'so-widgets-bundle' ),
|
85 |
+
'modified' => __( 'Modified date', 'so-widgets-bundle' ),
|
86 |
+
'parent' => __( 'By parent', 'so-widgets-bundle' ),
|
87 |
+
'rand' => __( 'Random order', 'so-widgets-bundle' ),
|
88 |
+
'comment_count' => __( 'Comment count', 'so-widgets-bundle' ),
|
89 |
+
'menu_order' => __( 'Menu order', 'so-widgets-bundle' ),
|
90 |
+
'meta_value' => __( 'By meta value', 'so-widgets-bundle' ),
|
91 |
+
'meta_value_num' => __( 'By numeric meta value', 'so-widgets-bundle' ),
|
92 |
+
'post__in' => __( 'By include order', 'so-widgets-bundle' ),
|
93 |
+
),
|
94 |
+
'default' => 'date',
|
95 |
+
),
|
96 |
+
|
97 |
+
'order' => array(
|
98 |
+
'type' => 'radio',
|
99 |
+
'label' => __( 'Order direction', 'so-widgets-bundle' ),
|
100 |
+
'options' => array(
|
101 |
+
'ASC' => __( 'Ascending', 'so-widgets-bundle' ),
|
102 |
+
'DESC' => __( 'Descending', 'so-widgets-bundle' ),
|
103 |
+
),
|
104 |
+
'default' => 'DESC',
|
105 |
+
),
|
106 |
+
|
107 |
+
'posts_per_page' => array(
|
108 |
+
'type' => 'number',
|
109 |
+
'label' => __( 'Posts per page', 'so-widgets-bundle' ),
|
110 |
+
),
|
111 |
+
|
112 |
+
'sticky' => array(
|
113 |
+
'type' => 'select',
|
114 |
+
'label' => __( 'Sticky posts', 'so-widgets-bundle' ),
|
115 |
+
'options' => array(
|
116 |
+
'' => __( 'Default', 'so-widgets-bundle' ),
|
117 |
+
'ignore' => __( 'Ignore sticky', 'so-widgets-bundle' ),
|
118 |
+
'exclude' => __( 'Exclude sticky', 'so-widgets-bundle' ),
|
119 |
+
'only' => __( 'Only sticky', 'so-widgets-bundle' ),
|
120 |
+
),
|
121 |
+
),
|
122 |
+
|
123 |
+
'additional' => array(
|
124 |
+
'type' => 'text',
|
125 |
+
'label' => __( 'Additional', 'so-widgets-bundle' ),
|
126 |
+
'description' => __( 'Additional query arguments. See <a href="http://codex.wordpress.org/Function_Reference/query_posts" target="_blank" rel="noopener noreferrer">query_posts</a>.', 'so-widgets-bundle' ),
|
127 |
+
),
|
128 |
+
);
|
129 |
+
}
|
130 |
+
|
131 |
+
protected function render_field_label( $value, $instance ) {
|
132 |
+
?><div class="posts-container-label-wrapper<?php if ( $this->state == 'open' ) {
|
133 |
+
echo ' siteorigin-widget-section-visible';
|
134 |
+
} ?>"><?php
|
135 |
+
parent::render_field_label( $value, $instance );
|
136 |
+
?><span class="sow-current-count"><?php echo esc_html( siteorigin_widget_post_selector_count_posts( $value ) )?></span>
|
137 |
+
</div><?php
|
138 |
+
}
|
139 |
+
|
140 |
+
protected function render_field( $value, $instance ) {
|
141 |
+
$value = wp_parse_args( $value );
|
142 |
+
|
143 |
+
if( !empty( $value['post_type'] ) ) {
|
144 |
+
$value['post_type'] = strpos( $value['post_type'], ',' ) !== false ? explode( ',', $value['post_type'] ) : $value['post_type'];
|
145 |
+
}
|
146 |
+
|
147 |
+
if ( $this->collapsible ) {
|
148 |
+
?><div class="siteorigin-widget-section <?php if ( $this->state == 'closed' ) {
|
149 |
+
echo 'siteorigin-widget-section-hide';
|
150 |
+
} ?>"><?php
|
151 |
+
}
|
152 |
+
|
153 |
+
$this->create_and_render_sub_fields( $value, array( 'name' => $this->base_name, 'type' => 'composite' ) );
|
154 |
+
|
155 |
+
if ( $this->collapsible ) {
|
156 |
+
?></div><?php
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
public function enqueue_scripts() {
|
161 |
+
wp_enqueue_script(
|
162 |
+
'so-posts-selector-field',
|
163 |
+
plugin_dir_url( __FILE__ ) . 'js/posts-field' . SOW_BUNDLE_JS_SUFFIX . '.js',
|
164 |
+
array( 'jquery' ),
|
165 |
+
SOW_BUNDLE_VERSION,
|
166 |
+
true
|
167 |
+
);
|
168 |
+
}
|
169 |
+
|
170 |
+
protected function sanitize_field_input( $value, $instance ) {
|
171 |
+
// Special handling for the 'additional' args field.
|
172 |
+
if ( ! empty( $value['additional'] ) ) {
|
173 |
+
$value['additional'] = urlencode( $value['additional'] );
|
174 |
+
}
|
175 |
+
$value = parent::sanitize_field_input( $value, $instance );
|
176 |
+
$result = '';
|
177 |
+
foreach ( $value as $key => $item ) {
|
178 |
+
if ( ! empty( $item ) ) {
|
179 |
+
if ( is_array( $item ) ) {
|
180 |
+
$item = implode( ',', $item );
|
181 |
+
}
|
182 |
+
$result .= ( empty( $result ) ? '' : '&' ) . $key . '=' . $item;
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
186 |
+
return $result;
|
187 |
+
}
|
188 |
+
|
189 |
+
}
|
base/inc/fields/tinymce.class.php
CHANGED
@@ -329,42 +329,72 @@ class SiteOrigin_Widget_Field_TinyMCE extends SiteOrigin_Widget_Field_Text_Input
|
|
329 |
return;
|
330 |
}
|
331 |
|
332 |
-
$
|
333 |
|
334 |
-
$
|
335 |
-
'toolbar1' => apply_filters( 'mce_buttons', $this->mce_buttons, $this->element_id ),
|
336 |
-
'toolbar2' => apply_filters( 'mce_buttons_2', $this->mce_buttons_2, $this->element_id ),
|
337 |
-
'toolbar3' => apply_filters( 'mce_buttons_3',$this->mce_buttons_3, $this->element_id ),
|
338 |
-
'toolbar4' => apply_filters( 'mce_buttons_4',$this->mce_buttons_4, $this->element_id ),
|
339 |
-
'plugins' => array_unique( apply_filters( 'tiny_mce_plugins', $this->mce_plugins ) ),
|
340 |
-
);
|
341 |
-
|
342 |
-
foreach ( $tmce_settings as $name => $setting ) {
|
343 |
-
$tmce_settings[ $name ] = is_array( $setting ) ? implode( ',', $setting ) : '';
|
344 |
-
}
|
345 |
-
|
346 |
-
$tmce_settings['external_plugins'] = array_unique( apply_filters( 'mce_external_plugins', $this->mce_external_plugins ) );
|
347 |
-
|
348 |
-
$suffix = SCRIPT_DEBUG ? '' : '.min';
|
349 |
-
$version = 'ver=' . get_bloginfo( 'version' );
|
350 |
-
// Default stylesheets
|
351 |
-
$mce_css = includes_url( "css/dashicons$suffix.css?$version" ) . ',' .
|
352 |
-
includes_url( "js/tinymce/skins/wordpress/wp-content.css?$version" );
|
353 |
|
354 |
-
$
|
|
|
|
|
355 |
|
356 |
-
if (
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
}
|
362 |
}
|
363 |
|
364 |
-
$
|
365 |
}
|
366 |
-
$mce_css = trim( apply_filters( 'mce_css', $mce_css ), ' ,' );
|
367 |
-
$tmce_settings['content_css'] = $mce_css;
|
368 |
|
369 |
$qt_settings = apply_filters(
|
370 |
'quicktags_settings',
|
@@ -375,43 +405,21 @@ class SiteOrigin_Widget_Field_TinyMCE extends SiteOrigin_Widget_Field_Text_Input
|
|
375 |
$qt_settings['buttons'] = ! empty( $qt_settings['buttons'] ) ? $qt_settings['buttons'] : array();
|
376 |
$qt_settings['buttons'] = is_array( $qt_settings['buttons'] ) ? implode( ',', $qt_settings['buttons'] ) : '';
|
377 |
|
378 |
-
$settings = array(
|
379 |
-
'
|
380 |
-
'tinymce' => array(
|
381 |
-
'wp_skip_init' => strpos( $this->element_id, '__i__' ) != false ||
|
382 |
-
strpos( $this->element_id, '_id_' ) != false,
|
383 |
-
'wpautop' => ! empty( $this->wpautop ),
|
384 |
-
),
|
385 |
-
'quicktags' => array(
|
386 |
-
'buttons' => $qt_settings['buttons'],
|
387 |
-
),
|
388 |
);
|
389 |
|
390 |
-
$tmce_settings = apply_filters( 'tiny_mce_before_init', $tmce_settings, $this->element_id );
|
391 |
-
|
392 |
-
foreach ( $tmce_settings as $name => $setting ) {
|
393 |
-
unset( $jdec );
|
394 |
-
if ( ! empty( $tmce_settings[ $name ] ) ) {
|
395 |
-
// Attempt to decode setting as JSON. For back compat with filters used by WP editor.
|
396 |
-
if ( is_string( $setting ) ) {
|
397 |
-
$jdec = json_decode( $setting, true );
|
398 |
-
}
|
399 |
-
$settings['tinymce'][ $name ] = empty( $jdec ) ? $setting : $jdec;
|
400 |
-
}
|
401 |
-
}
|
402 |
-
|
403 |
$value = apply_filters( 'the_editor_content', $value, $this->selected_editor );
|
404 |
|
405 |
if ( false !== stripos( $value, 'textarea' ) ) {
|
406 |
$value = preg_replace( '%</textarea%i', '</textarea', $value );
|
407 |
}
|
408 |
|
409 |
-
|
410 |
-
$media_buttons = $this->render_media_buttons( $this->element_id );
|
411 |
-
|
412 |
?><div class="siteorigin-widget-tinymce-container"
|
413 |
-
|
414 |
-
|
|
|
|
|
415 |
<textarea id="<?php echo esc_attr( $this->element_id ) ?>"
|
416 |
name="<?php echo esc_attr( $this->element_name ) ?>"
|
417 |
<?php if ( isset( $this->editor_height ) ) : ?>
|
329 |
return;
|
330 |
}
|
331 |
|
332 |
+
$user_can_richedit = user_can_richedit();
|
333 |
|
334 |
+
$selected_editor = $user_can_richedit && in_array( $this->selected_editor, array( 'tinymce', 'tmce' ) ) ? 'tmce' : 'html';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
|
336 |
+
$settings = array(
|
337 |
+
'selectedEditor' => $selected_editor,
|
338 |
+
);
|
339 |
|
340 |
+
if ( $user_can_richedit ) {
|
341 |
+
|
342 |
+
$tmce_settings = array(
|
343 |
+
'toolbar1' => apply_filters( 'mce_buttons', $this->mce_buttons, $this->element_id ),
|
344 |
+
'toolbar2' => apply_filters( 'mce_buttons_2', $this->mce_buttons_2, $this->element_id ),
|
345 |
+
'toolbar3' => apply_filters( 'mce_buttons_3',$this->mce_buttons_3, $this->element_id ),
|
346 |
+
'toolbar4' => apply_filters( 'mce_buttons_4',$this->mce_buttons_4, $this->element_id ),
|
347 |
+
'plugins' => array_unique( apply_filters( 'tiny_mce_plugins', $this->mce_plugins ) ),
|
348 |
+
);
|
349 |
+
|
350 |
+
foreach ( $tmce_settings as $name => $setting ) {
|
351 |
+
$tmce_settings[ $name ] = is_array( $setting ) ? implode( ',', $setting ) : '';
|
352 |
+
}
|
353 |
+
|
354 |
+
$tmce_settings['external_plugins'] = array_unique( apply_filters( 'mce_external_plugins', $this->mce_external_plugins ) );
|
355 |
+
|
356 |
+
$suffix = SCRIPT_DEBUG ? '' : '.min';
|
357 |
+
$version = 'ver=' . get_bloginfo( 'version' );
|
358 |
+
// Default stylesheets
|
359 |
+
$mce_css = includes_url( "css/dashicons$suffix.css?$version" ) . ',' .
|
360 |
+
includes_url( "js/tinymce/skins/wordpress/wp-content.css?$version" );
|
361 |
+
|
362 |
+
$editor_styles = get_editor_stylesheets();
|
363 |
+
|
364 |
+
if ( ! empty( $editor_styles ) ) {
|
365 |
+
// Force urlencoding of commas.
|
366 |
+
foreach ( $editor_styles as $key => $url ) {
|
367 |
+
if ( strpos( $url, ',' ) !== false ) {
|
368 |
+
$editor_styles[ $key ] = str_replace( ',', '%2C', $url );
|
369 |
+
}
|
370 |
+
}
|
371 |
+
|
372 |
+
$mce_css .= ',' . implode( ',', $editor_styles );
|
373 |
+
}
|
374 |
+
$mce_css = trim( apply_filters( 'mce_css', $mce_css ), ' ,' );
|
375 |
+
$tmce_settings['content_css'] = $mce_css;
|
376 |
+
|
377 |
+
$settings['tinymce'] = array(
|
378 |
+
'wp_skip_init' => strpos( $this->element_id, '__i__' ) != false ||
|
379 |
+
strpos( $this->element_id, '_id_' ) != false,
|
380 |
+
'wpautop' => ! empty( $this->wpautop ),
|
381 |
+
);
|
382 |
+
|
383 |
+
$tmce_settings = apply_filters( 'tiny_mce_before_init', $tmce_settings, $this->element_id );
|
384 |
+
|
385 |
+
foreach ( $tmce_settings as $name => $setting ) {
|
386 |
+
unset( $jdec );
|
387 |
+
if ( ! empty( $tmce_settings[ $name ] ) ) {
|
388 |
+
// Attempt to decode setting as JSON. For back compat with filters used by WP editor.
|
389 |
+
if ( is_string( $setting ) ) {
|
390 |
+
$jdec = json_decode( $setting, true );
|
391 |
+
}
|
392 |
+
$settings['tinymce'][ $name ] = empty( $jdec ) ? $setting : $jdec;
|
393 |
}
|
394 |
}
|
395 |
|
396 |
+
$media_buttons = $this->render_media_buttons( $this->element_id );
|
397 |
}
|
|
|
|
|
398 |
|
399 |
$qt_settings = apply_filters(
|
400 |
'quicktags_settings',
|
405 |
$qt_settings['buttons'] = ! empty( $qt_settings['buttons'] ) ? $qt_settings['buttons'] : array();
|
406 |
$qt_settings['buttons'] = is_array( $qt_settings['buttons'] ) ? implode( ',', $qt_settings['buttons'] ) : '';
|
407 |
|
408 |
+
$settings['quicktags'] = array(
|
409 |
+
'buttons' => $qt_settings['buttons'],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
);
|
411 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
$value = apply_filters( 'the_editor_content', $value, $this->selected_editor );
|
413 |
|
414 |
if ( false !== stripos( $value, 'textarea' ) ) {
|
415 |
$value = preg_replace( '%</textarea%i', '</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 ) ) ) ?>"
|
421 |
+
<?php endif; ?>
|
422 |
+
data-editor-settings="<?php echo esc_attr( json_encode( $settings ) ) ?>">
|
423 |
<textarea id="<?php echo esc_attr( $this->element_id ) ?>"
|
424 |
name="<?php echo esc_attr( $this->element_name ) ?>"
|
425 |
<?php if ( isset( $this->editor_height ) ) : ?>
|
base/inc/fields/widget.class.php
CHANGED
@@ -1,60 +1,71 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class SiteOrigin_Widget_Field_Widget
|
5 |
-
*/
|
6 |
-
class SiteOrigin_Widget_Field_Widget extends SiteOrigin_Widget_Field_Container_Base {
|
7 |
-
/**
|
8 |
-
* The class name of the widget to be included.
|
9 |
-
*
|
10 |
-
* @access protected
|
11 |
-
* @var string
|
12 |
-
*/
|
13 |
-
protected $class;
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class SiteOrigin_Widget_Field_Widget
|
5 |
+
*/
|
6 |
+
class SiteOrigin_Widget_Field_Widget extends SiteOrigin_Widget_Field_Container_Base {
|
7 |
+
/**
|
8 |
+
* The class name of the widget to be included.
|
9 |
+
*
|
10 |
+
* @access protected
|
11 |
+
* @var string
|
12 |
+
*/
|
13 |
+
protected $class;
|
14 |
+
/**
|
15 |
+
* A filter for the widget's form fields. In some cases we may want to filter some fields out of a sub-widget form.
|
16 |
+
*
|
17 |
+
* @access protected
|
18 |
+
* @var callable
|
19 |
+
*/
|
20 |
+
protected $form_filter;
|
21 |
+
|
22 |
+
public function __construct( $base_name, $element_id, $element_name, $field_options, SiteOrigin_Widget $for_widget, $parent_container = array() ) {
|
23 |
+
parent::__construct( $base_name, $element_id, $element_name, $field_options, $for_widget, $parent_container );
|
24 |
+
|
25 |
+
if( isset( $this->class ) ) {
|
26 |
+
if( class_exists( $this->class ) ) {
|
27 |
+
/* @var $sub_widget SiteOrigin_Widget */
|
28 |
+
$sub_widget = new $this->class;
|
29 |
+
if( is_a( $sub_widget, 'SiteOrigin_Widget' ) ) {
|
30 |
+
if ( ! empty( $this->form_filter ) && is_callable( $this->form_filter ) ) {
|
31 |
+
$this->fields = call_user_func( $this->form_filter, $sub_widget->form_options( $this->for_widget ) );
|
32 |
+
} else {
|
33 |
+
$this->fields = $sub_widget->form_options( $this->for_widget );
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
protected function render_field( $value, $instance ) {
|
41 |
+
|
42 |
+
echo '<div class="siteorigin-widget-widget">';
|
43 |
+
if ( $this->collapsible ) {
|
44 |
+
?><div class="siteorigin-widget-section <?php if( $this->state == 'closed' ) echo 'siteorigin-widget-section-hide'; ?>"><?php
|
45 |
+
}
|
46 |
+
|
47 |
+
if( ! class_exists( $this->class ) ) {
|
48 |
+
printf( __( '%s does not exist', 'so-widgets-bundle' ), $this->class );
|
49 |
+
if ( $this->collapsible ) {
|
50 |
+
echo '</div>';
|
51 |
+
}
|
52 |
+
return;
|
53 |
+
}
|
54 |
+
|
55 |
+
/* @var $sub_widget SiteOrigin_Widget */
|
56 |
+
$sub_widget = new $this->class;
|
57 |
+
if( ! is_a( $sub_widget, 'SiteOrigin_Widget' ) ) {
|
58 |
+
printf( __( '%s is not a SiteOrigin Widget', 'so-widgets-bundle' ), $this->class );
|
59 |
+
if ( $this->collapsible ) {
|
60 |
+
echo '</div>';
|
61 |
+
}
|
62 |
+
return;
|
63 |
+
}
|
64 |
+
$this->create_and_render_sub_fields( $value, array( 'name' => $this->base_name, 'type' => 'widget' ) );
|
65 |
+
if ( $this->collapsible ) {
|
66 |
+
?></div><?php
|
67 |
+
}
|
68 |
+
echo '</div>';
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
base/inc/video.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This class handles video related functionality.
|
5 |
+
*
|
6 |
+
* Class SiteOrigin_Video
|
7 |
+
*/
|
8 |
+
|
9 |
+
class SiteOrigin_Video {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Check whether it's possible to oEmbed by testing if a provider URL can be obtained.
|
13 |
+
*
|
14 |
+
* @param string $url The URL of the video to be embedded.
|
15 |
+
*
|
16 |
+
* @return bool Whether it's possible to embed this video.
|
17 |
+
*/
|
18 |
+
function can_oembed( $url ) {
|
19 |
+
$wp_oembed = new WP_oEmbed();
|
20 |
+
$provider = $wp_oembed->get_provider( $url, array( 'discover' => false ) );
|
21 |
+
|
22 |
+
return ! empty( $provider );
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Gets a video source embed
|
27 |
+
*
|
28 |
+
* @param string $src The URL of the video.
|
29 |
+
* @param bool $autoplay Whether to start playing the video automatically once loaded. ( YouTube only )
|
30 |
+
* @param bool $related_videos Whether to show related videos after the video has finished playing. ( YouTube only )
|
31 |
+
*
|
32 |
+
* @return false|mixed|null|string|string[]
|
33 |
+
*/
|
34 |
+
function get_video_oembed( $src, $autoplay = false, $related_videos = true ) {
|
35 |
+
if ( empty( $src ) ) {
|
36 |
+
return '';
|
37 |
+
}
|
38 |
+
|
39 |
+
global $content_width;
|
40 |
+
|
41 |
+
$video_width = ! empty( $content_width ) ? $content_width : 640;
|
42 |
+
|
43 |
+
$hash = md5( serialize( array(
|
44 |
+
'src' => $src,
|
45 |
+
'width' => $video_width,
|
46 |
+
'autoplay' => $autoplay,
|
47 |
+
) ) );
|
48 |
+
|
49 |
+
$html = get_transient( 'sow-vid-embed[' . $hash . ']' );
|
50 |
+
if ( empty( $html ) ) {
|
51 |
+
$html = wp_oembed_get( $src, array( 'width' => $video_width ) );
|
52 |
+
|
53 |
+
if ( $autoplay ) {
|
54 |
+
$html = preg_replace_callback( '/src=["\'](http[^"\']*)["\']/', array(
|
55 |
+
$this,
|
56 |
+
'autoplay_callback'
|
57 |
+
), $html );
|
58 |
+
}
|
59 |
+
|
60 |
+
if ( empty( $related_videos ) ) {
|
61 |
+
$html = preg_replace_callback( '/src=["\'](http[^"\']*)["\']/', array(
|
62 |
+
$this,
|
63 |
+
'remove_related_videos'
|
64 |
+
), $html );
|
65 |
+
}
|
66 |
+
|
67 |
+
if ( ! empty( $html ) ) {
|
68 |
+
set_transient( 'sow-vid-embed[' . $hash . ']', $html, 30 * 86400 );
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
return $html;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* The preg_replace callback that adds autoplay.
|
77 |
+
*
|
78 |
+
* @param $match
|
79 |
+
*
|
80 |
+
* @return mixed
|
81 |
+
*/
|
82 |
+
function autoplay_callback( $match ) {
|
83 |
+
return str_replace( $match[1], add_query_arg( 'autoplay', 1, $match[1] ), $match[0] );
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* The preg_replace callback that adds the rel param for YouTube videos.
|
88 |
+
*
|
89 |
+
* @param $match
|
90 |
+
*
|
91 |
+
* @return mixed
|
92 |
+
*/
|
93 |
+
function remove_related_videos( $match ) {
|
94 |
+
return str_replace( $match[1], add_query_arg( 'rel', 0, $match[1] ), $match[0] );
|
95 |
+
}
|
96 |
+
}
|
base/inc/widgets/base-slider.class.php
CHANGED
@@ -115,6 +115,13 @@ abstract class SiteOrigin_Widget_Base_Slider extends SiteOrigin_Widget {
|
|
115 |
'optional' => 'true',
|
116 |
'description' => __('An external URL of the video. Overrides video file.', 'so-widgets-bundle')
|
117 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
'format' => array(
|
120 |
'type' => 'select',
|
@@ -307,6 +314,7 @@ abstract class SiteOrigin_Widget_Base_Slider extends SiteOrigin_Widget {
|
|
307 |
if( empty( $videos ) ) return;
|
308 |
$video_element = '<video class="' . esc_attr( implode( ',', $classes ) ) . '" autoplay loop muted playsinline>';
|
309 |
|
|
|
310 |
foreach( $videos as $video ) {
|
311 |
if( empty( $video['file'] ) && empty ( $video['url'] ) ) continue;
|
312 |
// If video is an external file, try and display it using oEmbed
|
@@ -315,13 +323,13 @@ abstract class SiteOrigin_Widget_Base_Slider extends SiteOrigin_Widget {
|
|
315 |
if ( ! empty( $video['height'] ) ) {
|
316 |
$args['height'] = $video['height'];
|
317 |
}
|
318 |
-
$
|
319 |
|
320 |
// Check if we can oEmbed the video or not
|
321 |
-
if(
|
322 |
$video_file = sow_esc_url( $video['url'] );
|
323 |
-
}else{
|
324 |
-
echo $
|
325 |
continue;
|
326 |
}
|
327 |
}
|
115 |
'optional' => 'true',
|
116 |
'description' => __('An external URL of the video. Overrides video file.', 'so-widgets-bundle')
|
117 |
),
|
118 |
+
|
119 |
+
'autoplay' => array(
|
120 |
+
'type' => 'checkbox',
|
121 |
+
'label' => __( 'Autoplay', 'so-widgets-bundle' ),
|
122 |
+
'default' => false,
|
123 |
+
'description' => __( 'Currently only for YouTube videos.', 'so-widgets-bundle' ),
|
124 |
+
),
|
125 |
|
126 |
'format' => array(
|
127 |
'type' => 'select',
|
314 |
if( empty( $videos ) ) return;
|
315 |
$video_element = '<video class="' . esc_attr( implode( ',', $classes ) ) . '" autoplay loop muted playsinline>';
|
316 |
|
317 |
+
$so_video = new SiteOrigin_Video();
|
318 |
foreach( $videos as $video ) {
|
319 |
if( empty( $video['file'] ) && empty ( $video['url'] ) ) continue;
|
320 |
// If video is an external file, try and display it using oEmbed
|
323 |
if ( ! empty( $video['height'] ) ) {
|
324 |
$args['height'] = $video['height'];
|
325 |
}
|
326 |
+
$can_oembed = $so_video->can_oembed( $video['url'] );
|
327 |
|
328 |
// Check if we can oEmbed the video or not
|
329 |
+
if( ! $can_oembed ) {
|
330 |
$video_file = sow_esc_url( $video['url'] );
|
331 |
+
} else {
|
332 |
+
echo $so_video->get_video_oembed( $video['url'], ! empty( $video['autoplay'] ) );
|
333 |
continue;
|
334 |
}
|
335 |
}
|
base/js/admin.js
CHANGED
@@ -826,6 +826,15 @@ var sowbForms = window.sowbForms || {};
|
|
826 |
}
|
827 |
|
828 |
$inputElement.attr('id', newId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
829 |
$copyItem.find('label[for=' + id + ']').attr('for', newId);
|
830 |
$copyItem.find('[id*=' + id + ']').each(function () {
|
831 |
var oldIdAttr = $(this).attr('id');
|
826 |
}
|
827 |
|
828 |
$inputElement.attr('id', newId);
|
829 |
+
if ( $inputElement.is( '.wp-editor-area' ) ) {
|
830 |
+
var tmceContainer = $inputElement.closest( '.siteorigin-widget-tinymce-container' );
|
831 |
+
var mediaButtons = tmceContainer.data( 'media-buttons' );
|
832 |
+
if ( mediaButtons && mediaButtons.html ) {
|
833 |
+
var idRegExp = new RegExp( id, 'g');
|
834 |
+
mediaButtons.html = mediaButtons.html.replace( idRegExp, newId );
|
835 |
+
tmceContainer.data( 'media-buttons', mediaButtons );
|
836 |
+
}
|
837 |
+
}
|
838 |
$copyItem.find('label[for=' + id + ']').attr('for', newId);
|
839 |
$copyItem.find('[id*=' + id + ']').each(function () {
|
840 |
var oldIdAttr = $(this).attr('id');
|
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=" "),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]++;i.attr("id",w),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 y=n.parents(".siteorigin-widget-field-repeater").length,F=e("body");(F.hasClass("wp-customizer")||F.hasClass("widgets-php"))&&0===r.closest(".panel-dialog").length&&(y+=1);var k=l.replace(new RegExp("((?:.*?\\[\\d+\\]){"+(y-1).toString()+"})?(.*?\\[)\\d+(\\])"),"$1$2"+o.toString()+"$3");i.attr("name",k),i.data("original-name",k)}),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");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=" "),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;
|
base/siteorigin-widget.class.php
CHANGED
@@ -441,7 +441,7 @@ abstract class SiteOrigin_Widget extends WP_Widget {
|
|
441 |
|
442 |
// Filter the instance specifically for the form
|
443 |
$instance = apply_filters('siteorigin_widgets_form_instance_' . $this->id_base, $instance, $this);
|
444 |
-
|
445 |
// `more_entropy` adds a period to the id.
|
446 |
$id = str_replace( '.', '', uniqid( rand(), true ) );
|
447 |
$form_id = 'siteorigin_widget_form_' . md5( $id );
|
@@ -1093,14 +1093,19 @@ abstract class SiteOrigin_Widget extends WP_Widget {
|
|
1093 |
* @return string
|
1094 |
*/
|
1095 |
function get_style_hash( $instance ) {
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1100 |
}
|
1101 |
-
$version = property_exists( $this, 'version' ) ? $this->version : '';
|
1102 |
|
1103 |
-
return
|
1104 |
}
|
1105 |
|
1106 |
/**
|
@@ -1227,7 +1232,7 @@ abstract class SiteOrigin_Widget extends WP_Widget {
|
|
1227 |
$instance,
|
1228 |
$this
|
1229 |
);
|
1230 |
-
|
1231 |
foreach ( $f_scripts as $f_script ) {
|
1232 |
if ( ! wp_script_is( $f_script[0] ) ) {
|
1233 |
wp_enqueue_script(
|
@@ -1264,7 +1269,7 @@ abstract class SiteOrigin_Widget extends WP_Widget {
|
|
1264 |
$instance,
|
1265 |
$this
|
1266 |
);
|
1267 |
-
|
1268 |
foreach ( $f_styles as $f_style ) {
|
1269 |
if ( ! wp_style_is( $f_style[0] ) ) {
|
1270 |
wp_enqueue_style(
|
441 |
|
442 |
// Filter the instance specifically for the form
|
443 |
$instance = apply_filters('siteorigin_widgets_form_instance_' . $this->id_base, $instance, $this);
|
444 |
+
|
445 |
// `more_entropy` adds a period to the id.
|
446 |
$id = str_replace( '.', '', uniqid( rand(), true ) );
|
447 |
$form_id = 'siteorigin_widget_form_' . md5( $id );
|
1093 |
* @return string
|
1094 |
*/
|
1095 |
function get_style_hash( $instance ) {
|
1096 |
+
$style_hash = apply_filters('siteorigin_widgets_widget_style_hash', '', $this);
|
1097 |
+
if( empty( $style_hash ) ) {
|
1098 |
+
if( method_exists( $this, 'get_style_hash_variables' ) ) {
|
1099 |
+
$vars = apply_filters( 'siteorigin_widgets_hash_variables_' . $this->id_base, $this->get_style_hash_variables( $instance ), $instance, $this );
|
1100 |
+
} else {
|
1101 |
+
$vars = apply_filters( 'siteorigin_widgets_less_variables_' . $this->id_base, $this->get_less_variables( $instance ), $instance, $this );
|
1102 |
+
}
|
1103 |
+
$version = property_exists( $this, 'version' ) ? $this->version : '';
|
1104 |
+
|
1105 |
+
$style_hash = substr( md5( json_encode( $vars ) . $version ), 0, 12 );
|
1106 |
}
|
|
|
1107 |
|
1108 |
+
return $style_hash;
|
1109 |
}
|
1110 |
|
1111 |
/**
|
1232 |
$instance,
|
1233 |
$this
|
1234 |
);
|
1235 |
+
|
1236 |
foreach ( $f_scripts as $f_script ) {
|
1237 |
if ( ! wp_script_is( $f_script[0] ) ) {
|
1238 |
wp_enqueue_script(
|
1269 |
$instance,
|
1270 |
$this
|
1271 |
);
|
1272 |
+
|
1273 |
foreach ( $f_styles as $f_style ) {
|
1274 |
if ( ! wp_style_is( $f_style[0] ) ) {
|
1275 |
wp_enqueue_style(
|
compat/beaver-builder/styles.css
CHANGED
@@ -90,27 +90,27 @@
|
|
90 |
}
|
91 |
.fl-lightbox .siteorigin-widget-form .sow-icon-elegantline,
|
92 |
.siteorigin-widgets-query-builder.media-modal .sow-icon-elegantline {
|
93 |
-
font-family: 'sow-elegantline';
|
94 |
}
|
95 |
.fl-lightbox .siteorigin-widget-form .sow-icon-fontawesome,
|
96 |
.siteorigin-widgets-query-builder.media-modal .sow-icon-fontawesome {
|
97 |
-
font-family: 'sow-fontawesome';
|
98 |
}
|
99 |
.fl-lightbox .siteorigin-widget-form .sow-icon-genericons,
|
100 |
.siteorigin-widgets-query-builder.media-modal .sow-icon-genericons {
|
101 |
-
font-family: 'sow-genericons';
|
102 |
}
|
103 |
.fl-lightbox .siteorigin-widget-form .sow-icon-icomoon,
|
104 |
.siteorigin-widgets-query-builder.media-modal .sow-icon-icomoon {
|
105 |
-
font-family: 'sow-icomoon';
|
106 |
}
|
107 |
.fl-lightbox .siteorigin-widget-form .sow-icon-ionicons,
|
108 |
.siteorigin-widgets-query-builder.media-modal .sow-icon-ionicons {
|
109 |
-
font-family: 'sow-ionicons';
|
110 |
}
|
111 |
.fl-lightbox .siteorigin-widget-form .sow-icon-typicons,
|
112 |
.siteorigin-widgets-query-builder.media-modal .sow-icon-typicons {
|
113 |
-
font-family: 'sow-typicons';
|
114 |
}
|
115 |
.fl-lightbox .siteorigin-widget-form .button,
|
116 |
.siteorigin-widgets-query-builder.media-modal .button,
|
90 |
}
|
91 |
.fl-lightbox .siteorigin-widget-form .sow-icon-elegantline,
|
92 |
.siteorigin-widgets-query-builder.media-modal .sow-icon-elegantline {
|
93 |
+
font-family: 'sow-elegantline' !important;
|
94 |
}
|
95 |
.fl-lightbox .siteorigin-widget-form .sow-icon-fontawesome,
|
96 |
.siteorigin-widgets-query-builder.media-modal .sow-icon-fontawesome {
|
97 |
+
font-family: 'sow-fontawesome' !important;
|
98 |
}
|
99 |
.fl-lightbox .siteorigin-widget-form .sow-icon-genericons,
|
100 |
.siteorigin-widgets-query-builder.media-modal .sow-icon-genericons {
|
101 |
+
font-family: 'sow-genericons' !important;
|
102 |
}
|
103 |
.fl-lightbox .siteorigin-widget-form .sow-icon-icomoon,
|
104 |
.siteorigin-widgets-query-builder.media-modal .sow-icon-icomoon {
|
105 |
+
font-family: 'sow-icomoon' !important;
|
106 |
}
|
107 |
.fl-lightbox .siteorigin-widget-form .sow-icon-ionicons,
|
108 |
.siteorigin-widgets-query-builder.media-modal .sow-icon-ionicons {
|
109 |
+
font-family: 'sow-ionicons' !important;
|
110 |
}
|
111 |
.fl-lightbox .siteorigin-widget-form .sow-icon-typicons,
|
112 |
.siteorigin-widgets-query-builder.media-modal .sow-icon-typicons {
|
113 |
+
font-family: 'sow-typicons' !important;
|
114 |
}
|
115 |
.fl-lightbox .siteorigin-widget-form .button,
|
116 |
.siteorigin-widgets-query-builder.media-modal .button,
|
js/slider/jquery.slider.js
CHANGED
@@ -1,267 +1,266 @@
|
|
1 |
-
/* globals jQuery, sowb */
|
2 |
-
|
3 |
-
var sowb = window.sowb || {};
|
4 |
-
|
5 |
-
sowb.SiteOriginSlider = function($) {
|
6 |
-
return {
|
7 |
-
playSlideVideo: function(el) {
|
8 |
-
$(el).find('video').each(function(){
|
9 |
-
if(typeof this.play !== 'undefined') {
|
10 |
-
this.play();
|
11 |
-
}
|
12 |
-
});
|
13 |
-
},
|
14 |
-
|
15 |
-
pauseSlideVideo: function(el) {
|
16 |
-
$(el).find('video').each(function(){
|
17 |
-
if(typeof this.pause !== 'undefined') {
|
18 |
-
this.pause();
|
19 |
-
}
|
20 |
-
});
|
21 |
-
},
|
22 |
-
|
23 |
-
setupActiveSlide: function(slider, newActive, speed){
|
24 |
-
// Start by setting up the active sentinel
|
25 |
-
var
|
26 |
-
sentinel = $(slider).find('.cycle-sentinel'),
|
27 |
-
active = $(newActive),
|
28 |
-
video = active.find('video.sow-background-element');
|
29 |
-
|
30 |
-
if( speed == undefined ) {
|
31 |
-
sentinel.css( 'height', active.outerHeight() );
|
32 |
-
}
|
33 |
-
else {
|
34 |
-
sentinel.animate( {height: active.outerHeight()}, speed );
|
35 |
-
}
|
36 |
-
|
37 |
-
if( video.length ) {
|
38 |
-
|
39 |
-
// Resize the video so it fits in the current slide
|
40 |
-
var
|
41 |
-
slideRatio = active.outerWidth() / active.outerHeight(),
|
42 |
-
videoRatio = video.outerWidth() / video.outerHeight();
|
43 |
-
|
44 |
-
if( slideRatio > videoRatio ) {
|
45 |
-
video.css( {
|
46 |
-
'width' : '100%',
|
47 |
-
'height' : 'auto'
|
48 |
-
} );
|
49 |
-
}
|
50 |
-
else {
|
51 |
-
video.css( {
|
52 |
-
'width' : 'auto',
|
53 |
-
'height' : '100%'
|
54 |
-
} );
|
55 |
-
}
|
56 |
-
|
57 |
-
video.css( {
|
58 |
-
'margin-left' : -Math.ceil(video.width()/2),
|
59 |
-
'margin-top' : -Math.ceil(video.height()/2)
|
60 |
-
} );
|
61 |
-
}
|
62 |
-
},
|
63 |
-
};
|
64 |
-
};
|
65 |
-
|
66 |
-
|
67 |
-
jQuery( function($){
|
68 |
-
sowb.setupSliders = sowb.setupSlider = function() {
|
69 |
-
var siteoriginSlider = new sowb.SiteOriginSlider($);
|
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');
|
76 |
-
var $slides = $$.find('.sow-slider-image');
|
77 |
-
var settings = $$.data('settings');
|
78 |
-
|
79 |
-
$slides.each(function( index, el) {
|
80 |
-
var $slide = $(el);
|
81 |
-
var urlData = $slide.data('url');
|
82 |
-
|
83 |
-
if( urlData !== undefined && urlData.hasOwnProperty( 'url' ) ) {
|
84 |
-
$slide.click(function(event) {
|
85 |
-
|
86 |
-
event.preventDefault();
|
87 |
-
var sliderWindow = window.open(
|
88 |
-
urlData.url,
|
89 |
-
urlData.hasOwnProperty( 'new_window' ) && urlData.new_window ? '_blank' : '_self'
|
90 |
-
);
|
91 |
-
sliderWindow.opener = null;
|
92 |
-
} );
|
93 |
-
$slide.find( 'a' ).click( function ( event ) {
|
94 |
-
event.stopPropagation();
|
95 |
-
} );
|
96 |
-
}
|
97 |
-
});
|
98 |
-
|
99 |
-
var setupSlider = function() {
|
100 |
-
|
101 |
-
// If we're inside a fittext wrapper, wait for it to complete, before setting up the slider.
|
102 |
-
var fitTextWrapper = $$.closest('.so-widget-fittext-wrapper');
|
103 |
-
if ( fitTextWrapper.length > 0 && ! fitTextWrapper.data('fitTextDone') ) {
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
}
|
109 |
-
|
110 |
-
// Show everything for this slider
|
111 |
-
$base.show();
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
'
|
166 |
-
'
|
167 |
-
'
|
168 |
-
'swipe' :
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
var
|
229 |
-
var
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
window.sowb = sowb;
|
1 |
+
/* globals jQuery, sowb */
|
2 |
+
|
3 |
+
var sowb = window.sowb || {};
|
4 |
+
|
5 |
+
sowb.SiteOriginSlider = function($) {
|
6 |
+
return {
|
7 |
+
playSlideVideo: function(el) {
|
8 |
+
$(el).find('video').each(function(){
|
9 |
+
if(typeof this.play !== 'undefined') {
|
10 |
+
this.play();
|
11 |
+
}
|
12 |
+
});
|
13 |
+
},
|
14 |
+
|
15 |
+
pauseSlideVideo: function(el) {
|
16 |
+
$(el).find('video').each(function(){
|
17 |
+
if(typeof this.pause !== 'undefined') {
|
18 |
+
this.pause();
|
19 |
+
}
|
20 |
+
});
|
21 |
+
},
|
22 |
+
|
23 |
+
setupActiveSlide: function(slider, newActive, speed){
|
24 |
+
// Start by setting up the active sentinel
|
25 |
+
var
|
26 |
+
sentinel = $(slider).find('.cycle-sentinel'),
|
27 |
+
active = $(newActive),
|
28 |
+
video = active.find('video.sow-background-element');
|
29 |
+
|
30 |
+
if( speed == undefined ) {
|
31 |
+
sentinel.css( 'height', active.outerHeight() );
|
32 |
+
}
|
33 |
+
else {
|
34 |
+
sentinel.animate( {height: active.outerHeight()}, speed );
|
35 |
+
}
|
36 |
+
|
37 |
+
if( video.length ) {
|
38 |
+
|
39 |
+
// Resize the video so it fits in the current slide
|
40 |
+
var
|
41 |
+
slideRatio = active.outerWidth() / active.outerHeight(),
|
42 |
+
videoRatio = video.outerWidth() / video.outerHeight();
|
43 |
+
|
44 |
+
if( slideRatio > videoRatio ) {
|
45 |
+
video.css( {
|
46 |
+
'width' : '100%',
|
47 |
+
'height' : 'auto'
|
48 |
+
} );
|
49 |
+
}
|
50 |
+
else {
|
51 |
+
video.css( {
|
52 |
+
'width' : 'auto',
|
53 |
+
'height' : '100%'
|
54 |
+
} );
|
55 |
+
}
|
56 |
+
|
57 |
+
video.css( {
|
58 |
+
'margin-left' : -Math.ceil(video.width()/2),
|
59 |
+
'margin-top' : -Math.ceil(video.height()/2)
|
60 |
+
} );
|
61 |
+
}
|
62 |
+
},
|
63 |
+
};
|
64 |
+
};
|
65 |
+
|
66 |
+
|
67 |
+
jQuery( function($){
|
68 |
+
sowb.setupSliders = sowb.setupSlider = function() {
|
69 |
+
var siteoriginSlider = new sowb.SiteOriginSlider($);
|
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');
|
76 |
+
var $slides = $$.find('.sow-slider-image');
|
77 |
+
var settings = $$.data('settings');
|
78 |
+
|
79 |
+
$slides.each(function( index, el) {
|
80 |
+
var $slide = $(el);
|
81 |
+
var urlData = $slide.data('url');
|
82 |
+
|
83 |
+
if( urlData !== undefined && urlData.hasOwnProperty( 'url' ) ) {
|
84 |
+
$slide.click(function(event) {
|
85 |
+
|
86 |
+
event.preventDefault();
|
87 |
+
var sliderWindow = window.open(
|
88 |
+
urlData.url,
|
89 |
+
urlData.hasOwnProperty( 'new_window' ) && urlData.new_window ? '_blank' : '_self'
|
90 |
+
);
|
91 |
+
sliderWindow.opener = null;
|
92 |
+
} );
|
93 |
+
$slide.find( 'a' ).click( function ( event ) {
|
94 |
+
event.stopPropagation();
|
95 |
+
} );
|
96 |
+
}
|
97 |
+
});
|
98 |
+
|
99 |
+
var setupSlider = function() {
|
100 |
+
|
101 |
+
// If we're inside a fittext wrapper, wait for it to complete, before setting up the slider.
|
102 |
+
var fitTextWrapper = $$.closest('.so-widget-fittext-wrapper');
|
103 |
+
if ( fitTextWrapper.length > 0 && ! fitTextWrapper.data('fitTextDone') ) {
|
104 |
+
fitTextWrapper.on('fitTextDone', function () {
|
105 |
+
setupSlider();
|
106 |
+
});
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
|
110 |
+
// Show everything for this slider
|
111 |
+
$base.show();
|
112 |
+
|
113 |
+
var resizeFrames = function () {
|
114 |
+
$$.find( '.sow-slider-image' ).each( function () {
|
115 |
+
var $i = $( this );
|
116 |
+
$i.css( 'height', $i.find( '.sow-slider-image-wrapper' ).outerHeight() );
|
117 |
+
} );
|
118 |
+
};
|
119 |
+
// Setup each of the slider frames
|
120 |
+
$(window).on('resize panelsStretchRows', resizeFrames ).resize();
|
121 |
+
|
122 |
+
// Set up the Cycle with videos
|
123 |
+
$$
|
124 |
+
.on({
|
125 |
+
'cycle-after' : function(event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag){
|
126 |
+
var $$ = $(this);
|
127 |
+
siteoriginSlider.playSlideVideo(incomingSlideEl);
|
128 |
+
siteoriginSlider.setupActiveSlide( $$, incomingSlideEl );
|
129 |
+
$( incomingSlideEl ).trigger('sowSlideCycleAfter');
|
130 |
+
},
|
131 |
+
|
132 |
+
'cycle-before' : function(event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) {
|
133 |
+
var $$ = $(this);
|
134 |
+
$p.find('> li').removeClass('sow-active').eq(optionHash.slideNum-1).addClass('sow-active');
|
135 |
+
siteoriginSlider.pauseSlideVideo(outgoingSlideEl);
|
136 |
+
siteoriginSlider.setupActiveSlide($$, incomingSlideEl, optionHash.speed);
|
137 |
+
$( incomingSlideEl ).trigger('sowSlideCycleBefore');
|
138 |
+
},
|
139 |
+
|
140 |
+
'cycle-initialized' : function(event, optionHash){
|
141 |
+
siteoriginSlider.playSlideVideo( $(this).find('.cycle-slide-active') );
|
142 |
+
siteoriginSlider.setupActiveSlide( $$, optionHash.slides[0] );
|
143 |
+
|
144 |
+
$p.find('>li').removeClass('sow-active').eq(0).addClass('sow-active');
|
145 |
+
$( this ).find('.cycle-slide-active').trigger( 'sowSlideInitial' );
|
146 |
+
|
147 |
+
if(optionHash.slideCount <= 1) {
|
148 |
+
// Special case when there is only one slide
|
149 |
+
$p.hide();
|
150 |
+
$n.hide();
|
151 |
+
}
|
152 |
+
|
153 |
+
$(window).resize();
|
154 |
+
|
155 |
+
setTimeout(function() {
|
156 |
+
resizeFrames();
|
157 |
+
siteoriginSlider.setupActiveSlide( $$, optionHash.slides[0] );
|
158 |
+
// Ensure we keep auto-height functionality, but we don't want the duplicated content.
|
159 |
+
$$.find('.cycle-sentinel').empty();
|
160 |
+
}, 200);
|
161 |
+
}
|
162 |
+
})
|
163 |
+
.cycle( {
|
164 |
+
'slides' : '> .sow-slider-image',
|
165 |
+
'speed' : settings.speed,
|
166 |
+
'timeout' : settings.timeout,
|
167 |
+
'swipe' : settings.swipe,
|
168 |
+
'swipe-fx' : 'scrollHorz'
|
169 |
+
} ) ;
|
170 |
+
|
171 |
+
$$ .find('video.sow-background-element').on('loadeddata', function(){
|
172 |
+
siteoriginSlider.setupActiveSlide( $$, $$.find( '.cycle-slide-active' ) );
|
173 |
+
} );
|
174 |
+
|
175 |
+
// Set up showing and hiding navs
|
176 |
+
$p.add($n).hide();
|
177 |
+
if( !$base.hasClass('sow-slider-is-mobile') && $slides.length > 1 ) {
|
178 |
+
|
179 |
+
var toHide = false;
|
180 |
+
$base
|
181 |
+
.mouseenter(function(){
|
182 |
+
$p.add($n).clearQueue().fadeIn(150);
|
183 |
+
toHide = false;
|
184 |
+
})
|
185 |
+
.mouseleave(function(){
|
186 |
+
toHide = true;
|
187 |
+
setTimeout(function(){
|
188 |
+
if( toHide ) {
|
189 |
+
$p.add($n).clearQueue().fadeOut(150);
|
190 |
+
}
|
191 |
+
toHide = false;
|
192 |
+
}, 750);
|
193 |
+
});
|
194 |
+
}
|
195 |
+
|
196 |
+
// Resize the sentinel when ever the window is resized
|
197 |
+
$( window ).resize( function(){
|
198 |
+
siteoriginSlider.setupActiveSlide( $$, $$.find( '.cycle-slide-active' ) );
|
199 |
+
} );
|
200 |
+
|
201 |
+
// Setup clicks on the pagination
|
202 |
+
$p.find( '> li > a' ).click( function(e){
|
203 |
+
e.preventDefault();
|
204 |
+
$$.cycle( 'goto', $(this).data('goto') );
|
205 |
+
} );
|
206 |
+
|
207 |
+
// Clicking on the next and previous navigation buttons
|
208 |
+
$n.find( '> a' ).click( function(e){
|
209 |
+
e.preventDefault();
|
210 |
+
$$.cycle( $(this).data('action') );
|
211 |
+
} );
|
212 |
+
|
213 |
+
$base.keydown(
|
214 |
+
function(event) {
|
215 |
+
if(event.which === 37) {
|
216 |
+
//left
|
217 |
+
$$.cycle('prev');
|
218 |
+
}
|
219 |
+
else if (event.which === 39) {
|
220 |
+
//right
|
221 |
+
$$.cycle('next');
|
222 |
+
}
|
223 |
+
}
|
224 |
+
);
|
225 |
+
};
|
226 |
+
|
227 |
+
var images = $$.find('img');
|
228 |
+
var imagesLoaded = 0;
|
229 |
+
var sliderLoaded = false;
|
230 |
+
|
231 |
+
// Preload all the images, when they're loaded, then display the slider
|
232 |
+
images.each( function(){
|
233 |
+
var $i = $(this);
|
234 |
+
if( this.complete ) {
|
235 |
+
imagesLoaded++;
|
236 |
+
}
|
237 |
+
else {
|
238 |
+
$(this).one('load', function(){
|
239 |
+
imagesLoaded++;
|
240 |
+
|
241 |
+
if(imagesLoaded === images.length && !sliderLoaded) {
|
242 |
+
setupSlider();
|
243 |
+
sliderLoaded = true;
|
244 |
+
}
|
245 |
+
})
|
246 |
+
// Reset src attribute to force 'load' event for cached images in IE9 and IE10.
|
247 |
+
.attr('src', $(this).attr('src'));
|
248 |
+
}
|
249 |
+
|
250 |
+
if(imagesLoaded === images.length && !sliderLoaded) {
|
251 |
+
setupSlider();
|
252 |
+
sliderLoaded = true;
|
253 |
+
}
|
254 |
+
} );
|
255 |
+
|
256 |
+
if(images.length === 0) {
|
257 |
+
setupSlider();
|
258 |
+
}
|
259 |
+
});
|
260 |
+
};
|
261 |
+
sowb.setupSliders();
|
262 |
+
|
263 |
+
$( sowb ).on( 'setup_widgets', sowb.setupSliders );
|
264 |
+
} );
|
265 |
+
|
266 |
+
window.sowb = sowb;
|
|
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()});
|
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;
|
js/{sow.google.map.js → sow.google-map.js}
RENAMED
@@ -75,17 +75,6 @@ sowb.SiteOriginGoogleMap = function($) {
|
|
75 |
this.showMarkers(options.markerPositions, map, options);
|
76 |
this.showDirections(options.directions, map, options);
|
77 |
|
78 |
-
// If the Google Maps element is hidden it won't display properly. This is an attempt to make it display by
|
79 |
-
// calling resize when a custom 'show' event is fired. The 'show' event is something we fire in a few widgets
|
80 |
-
// like Accordion and Tabs and in future any widgets which might show and hide content using `display:none;`.
|
81 |
-
if ( $( element ).is( ':hidden' ) ) {
|
82 |
-
var $visParent = $( element ).closest( ':visible' );
|
83 |
-
$visParent.find( '> :hidden' ).on( 'show', function () {
|
84 |
-
google.maps.event.trigger(map, 'resize');
|
85 |
-
map.setCenter(location);
|
86 |
-
} );
|
87 |
-
}
|
88 |
-
|
89 |
},
|
90 |
|
91 |
linkAutocompleteField: function (autocomplete, autocompleteElement, map, options) {
|
@@ -337,7 +326,7 @@ sowb.SiteOriginGoogleMap = function($) {
|
|
337 |
this.getLocation( address ).done(
|
338 |
function ( location ) {
|
339 |
this.showMap( $$.get( 0 ), location, options );
|
340 |
-
$$.data( 'initialized' );
|
341 |
}.bind( this )
|
342 |
).fail( function () {
|
343 |
$$.append( '<div><p><strong>' + soWidgetsGoogleMap.geocode.noResults + '</strong></p></div>' );
|
@@ -416,6 +405,9 @@ jQuery(function ($) {
|
|
416 |
var apiKey;
|
417 |
$('.sow-google-map-canvas').each(function(index, element) {
|
418 |
var $this = $(element);
|
|
|
|
|
|
|
419 |
var mapOptions = $this.data( 'options' );
|
420 |
if ( mapOptions) {
|
421 |
if( typeof mapOptions.libraries !== 'undefined' && mapOptions.libraries !== null ) {
|
@@ -425,6 +417,7 @@ jQuery(function ($) {
|
|
425 |
apiKey = mapOptions.apiKey;
|
426 |
}
|
427 |
}
|
|
|
428 |
});
|
429 |
|
430 |
var mapsApiLoaded = typeof window.google !== 'undefined' && typeof window.google.maps !== 'undefined';
|
75 |
this.showMarkers(options.markerPositions, map, options);
|
76 |
this.showDirections(options.directions, map, options);
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
},
|
79 |
|
80 |
linkAutocompleteField: function (autocomplete, autocompleteElement, map, options) {
|
326 |
this.getLocation( address ).done(
|
327 |
function ( location ) {
|
328 |
this.showMap( $$.get( 0 ), location, options );
|
329 |
+
$$.data( 'initialized', true );
|
330 |
}.bind( this )
|
331 |
).fail( function () {
|
332 |
$$.append( '<div><p><strong>' + soWidgetsGoogleMap.geocode.noResults + '</strong></p></div>' );
|
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;
|
410 |
+
}
|
411 |
var mapOptions = $this.data( 'options' );
|
412 |
if ( mapOptions) {
|
413 |
if( typeof mapOptions.libraries !== 'undefined' && mapOptions.libraries !== null ) {
|
417 |
apiKey = mapOptions.apiKey;
|
418 |
}
|
419 |
}
|
420 |
+
$this.data( 'apiInitialized', true );
|
421 |
});
|
422 |
|
423 |
var mapsApiLoaded = typeof window.google !== 'undefined' && typeof window.google.maps !== 'undefined';
|
js/sow.google-map.min.js
ADDED
@@ -0,0 +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;
|
js/sow.google.map.min.js
DELETED
@@ -1 +0,0 @@
|
|
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(o,t,i){var n=Number(i.zoom);n||(n=14);var a={zoom:n,scrollwheel:i.scrollZoom,draggable:i.draggable,disableDefaultUI:i.disableUi,zoomControl:i.zoomControl,panControl:i.panControl,center:t,mapTypeControlOptions:{mapTypeIds:[google.maps.MapTypeId.ROADMAP,google.maps.MapTypeId.SATELLITE,"user_map_style"]}},s=new google.maps.Map(o,a),r={name:i.mapName},l=i.mapStyles;if(l){var d=new google.maps.StyledMapType(l,r);s.mapTypes.set("user_map_style",d),s.setMapTypeId("user_map_style")}if(i.markerAtCenter&&(this.centerMarker=new google.maps.Marker({position:t,map:s,draggable:i.markersDraggable,icon:i.markerIcon,title:""})),i.keepCentered){var c;google.maps.event.addDomListener(s,"idle",function(){c=s.getCenter()}),google.maps.event.addDomListener(window,"resize",function(){s.setCenter(c)})}if(this.linkAutocompleteField(i.autocomplete,i.autocompleteElement,s,i),this.showMarkers(i.markerPositions,s,i),this.showDirections(i.directions,s,i),e(o).is(":hidden")){e(o).closest(":visible").find("> :hidden").on("show",function(){google.maps.event.trigger(s,"resize"),s.setCenter(t)})}},linkAutocompleteField:function(o,t,i,n){if(o&&t){var a=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(),n=t+(i?", "+i:"");n&&a(n)});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=[],n=0;n<e.length;n++){var a=parseInt(n/10);i.length===a&&(i[a]=[]),i[a][n%10]=e[n]}var s=function(e,i){var n=0;e.forEach(function(a){this.getLocation(a.place).done(function(r){var l=t.markerIcon;a.custom_marker_icon&&(l=a.custom_marker_icon);var d=new google.maps.Marker({position:r,map:o,draggable:t.markersDraggable,icon:l,title:""});if(a.hasOwnProperty("info")&&a.info){var c={content:a.info};a.hasOwnProperty("info_max_width")&&a.info_max_width&&(c.maxWidth=a.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)})}++n===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 n=new google.maps.places.Autocomplete(i,{types:["address"]}),a=e(i).siblings(".sow-google-map-canvas");if(a.length>0){var s=a.data("options");s.autocomplete=n,s.autocompleteElement=i,this.getLocation(s.address).done(function(e){this.showMap(a.get(0),e,s),a.data("initialized",!0),t.resolve()}.bind(this)).fail(function(){a.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 n=i.data("options"),a=n.address;if(!a){var s=n.markerPositions;s&&s.length&&(a=s[0].place)}this.getLocation(a).done(function(e){this.showMap(i.get(0),e,n),i.data("initialized")}.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,n={address:o};if(o&&o.indexOf(",")>-1){var a=o.split(",");a&&2===a.length&&(t=new google.maps.LatLng(a[0],a[1]),isNaN(t.lat())||isNaN(t.lng())||(n={location:{lat:t.lat(),lng:t.lng()}}))}if(n.hasOwnProperty("location"))i.resolve(n.location);else if(n.hasOwnProperty("address")){if(!n.address){var s=parseInt(Math.random()*this.DEFAULT_LOCATIONS.length);n.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,n,r)}.bind(this),100):o===google.maps.GeocoderStatus.ZERO_RESULTS&&i.reject(o)}.bind(this);this.getGeocoder().geocode(n,r)}return i}}},jQuery(function(e){sowb.setupGoogleMaps=function(){var o,t=[];if(e(".sow-google-map-canvas").each(function(i,n){var a=e(n),s=a.data("options");s&&(void 0!==s.libraries&&null!==s.libraries&&(t=t.concat(s.libraries)),!o&&s.apiKey&&(o=s.apiKey))}),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 n=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 n=i.data("fallbackImage");n.hasOwnProperty("img")&&i.append(n.img)}}),n.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;
|
|
js/sow.jquery.fittext.js
CHANGED
@@ -1,68 +1,71 @@
|
|
1 |
-
/*global jQuery, sowb */
|
2 |
-
/*!
|
3 |
-
* FitText.js 1.2
|
4 |
-
*
|
5 |
-
* Copyright 2011, Dave Rupert http://daverupert.com
|
6 |
-
* Released under the WTFPL license
|
7 |
-
* http://sam.zoy.org/wtfpl/
|
8 |
-
*
|
9 |
-
* Date: Thu May 05 14:23:00 2011 -0600
|
10 |
-
*/
|
11 |
-
var sowb = window.sowb || {};
|
12 |
-
|
13 |
-
(function ($) {
|
14 |
-
|
15 |
-
$.fn.fitText = function (kompressor, options) {
|
16 |
-
|
17 |
-
// Setup options
|
18 |
-
var compressor = kompressor || 1,
|
19 |
-
settings = $.extend({
|
20 |
-
'minFontSize': Number.NEGATIVE_INFINITY,
|
21 |
-
'maxFontSize': Number.POSITIVE_INFINITY
|
22 |
-
}, options);
|
23 |
-
|
24 |
-
return this.each(function () {
|
25 |
-
|
26 |
-
// Store the object
|
27 |
-
var $this = $(this);
|
28 |
-
|
29 |
-
// Resizer() resizes items based on the object width divided by the compressor * 10
|
30 |
-
var resizer = function () {
|
31 |
-
$this.css('font-size', Math.max(Math.min($this.width() / (compressor * 10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)));
|
32 |
-
};
|
33 |
-
|
34 |
-
// Call once to set.
|
35 |
-
resizer();
|
36 |
-
|
37 |
-
// Call on resize. Opera debounces their resize by default.
|
38 |
-
$(window).on('resize.fittext orientationchange.fittext', resizer);
|
39 |
-
|
40 |
-
});
|
41 |
-
};
|
42 |
-
})(jQuery);
|
43 |
-
|
44 |
-
jQuery( function( $ ){
|
45 |
-
|
46 |
-
// Apply FitText to all Widgets Bundle FitText wrappers
|
47 |
-
sowb.runFitText = function () {
|
48 |
-
$( '.so-widget-fittext-wrapper' ).each( function() {
|
49 |
-
var fitTextWrapper = $( this );
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
1 |
+
/*global jQuery, sowb */
|
2 |
+
/*!
|
3 |
+
* FitText.js 1.2
|
4 |
+
*
|
5 |
+
* Copyright 2011, Dave Rupert http://daverupert.com
|
6 |
+
* Released under the WTFPL license
|
7 |
+
* http://sam.zoy.org/wtfpl/
|
8 |
+
*
|
9 |
+
* Date: Thu May 05 14:23:00 2011 -0600
|
10 |
+
*/
|
11 |
+
var sowb = window.sowb || {};
|
12 |
+
|
13 |
+
(function ($) {
|
14 |
+
|
15 |
+
$.fn.fitText = function (kompressor, options) {
|
16 |
+
|
17 |
+
// Setup options
|
18 |
+
var compressor = kompressor || 1,
|
19 |
+
settings = $.extend({
|
20 |
+
'minFontSize': Number.NEGATIVE_INFINITY,
|
21 |
+
'maxFontSize': Number.POSITIVE_INFINITY
|
22 |
+
}, options);
|
23 |
+
|
24 |
+
return this.each(function () {
|
25 |
+
|
26 |
+
// Store the object
|
27 |
+
var $this = $(this);
|
28 |
+
|
29 |
+
// Resizer() resizes items based on the object width divided by the compressor * 10
|
30 |
+
var resizer = function () {
|
31 |
+
$this.css('font-size', Math.max(Math.min($this.width() / (compressor * 10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)));
|
32 |
+
};
|
33 |
+
|
34 |
+
// Call once to set.
|
35 |
+
resizer();
|
36 |
+
|
37 |
+
// Call on resize. Opera debounces their resize by default.
|
38 |
+
$(window).on('resize.fittext orientationchange.fittext', resizer);
|
39 |
+
|
40 |
+
});
|
41 |
+
};
|
42 |
+
})(jQuery);
|
43 |
+
|
44 |
+
jQuery( function( $ ){
|
45 |
+
|
46 |
+
// Apply FitText to all Widgets Bundle FitText wrappers
|
47 |
+
sowb.runFitText = function () {
|
48 |
+
$( '.so-widget-fittext-wrapper' ).each( function() {
|
49 |
+
var fitTextWrapper = $( this );
|
50 |
+
if ( ! fitTextWrapper.is( ':visible' ) || fitTextWrapper.data( 'fitTextDone' ) ) {
|
51 |
+
return fitTextWrapper;
|
52 |
+
}
|
53 |
+
$( window ).off( 'resize.fittext orientationchange.fittext' );
|
54 |
+
var compressor = fitTextWrapper.data( 'fitTextCompressor' ) || 0.85;
|
55 |
+
fitTextWrapper.find( 'h1,h2,h3,h4,h5,h6' ).each( function () {
|
56 |
+
var $$ = $( this );
|
57 |
+
$$.fitText( compressor, {
|
58 |
+
maxFontSize: $$.css( 'font-size' )
|
59 |
+
} );
|
60 |
+
} );
|
61 |
+
fitTextWrapper.data( 'fitTextDone', true );
|
62 |
+
fitTextWrapper.trigger( 'fitTextDone' );
|
63 |
+
});
|
64 |
+
};
|
65 |
+
|
66 |
+
$( sowb ).on( 'setup_widgets', sowb.runFitText );
|
67 |
+
|
68 |
+
sowb.runFitText();
|
69 |
+
} );
|
70 |
+
|
71 |
+
window.sowb = sowb;
|
js/sow.jquery.fittext.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var sowb=window.sowb||{};!function(t){t.fn.fitText=function(i,
|
1 |
+
var sowb=window.sowb||{};!function(t){t.fn.fitText=function(i,e){var n=i||1,o=t.extend({minFontSize:Number.NEGATIVE_INFINITY,maxFontSize:Number.POSITIVE_INFINITY},e);return this.each(function(){var i=t(this),e=function(){i.css("font-size",Math.max(Math.min(i.width()/(10*n),parseFloat(o.maxFontSize)),parseFloat(o.minFontSize)))};e(),t(window).on("resize.fittext orientationchange.fittext",e)})}}(jQuery),jQuery(function(t){sowb.runFitText=function(){t(".so-widget-fittext-wrapper").each(function(){var i=t(this);if(!i.is(":visible")||i.data("fitTextDone"))return i;t(window).off("resize.fittext orientationchange.fittext");var e=i.data("fitTextCompressor")||.85;i.find("h1,h2,h3,h4,h5,h6").each(function(){var i=t(this);i.fitText(e,{maxFontSize:i.css("font-size")})}),i.data("fitTextDone",!0),i.trigger("fitTextDone")})},t(sowb).on("setup_widgets",sowb.runFitText),sowb.runFitText()}),window.sowb=sowb;
|
lang/so-widgets-bundle.pot
CHANGED
@@ -3,2950 +3,2953 @@
|
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
"Project-Id-Version: so-widgets-bundle\n"
|
6 |
-
"Report-Msgid-Bugs-To: http://www.siteorigin.com\n"
|
7 |
"MIME-Version: 1.0\n"
|
8 |
"Content-Type: text/plain; charset=UTF-8\n"
|
9 |
"Content-Transfer-Encoding: 8bit\n"
|
10 |
-
"PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
|
11 |
-
"Last-Translator: SiteOrigin <support@siteorigin.com>\n"
|
12 |
"Language-Team: SiteOrigin <support@siteorigin.com>\n"
|
|
|
|
|
13 |
"X-Poedit-Basepath: ..\n"
|
14 |
-
"X-Poedit-
|
15 |
-
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
16 |
"X-Poedit-SearchPath-0: .\n"
|
17 |
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
|
|
18 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
19 |
|
20 |
-
#:
|
21 |
msgid "SiteOrigin Widgets Bundle"
|
22 |
msgstr ""
|
23 |
|
24 |
-
#:
|
25 |
msgid "Filter Widgets"
|
26 |
msgstr ""
|
27 |
|
28 |
-
#:
|
29 |
msgid "All"
|
30 |
msgstr ""
|
31 |
|
32 |
-
#:
|
33 |
msgid "Enabled"
|
34 |
msgstr ""
|
35 |
|
36 |
-
#:
|
37 |
msgid "Disabled"
|
38 |
msgstr ""
|
39 |
|
40 |
-
#:
|
41 |
msgid "Active"
|
42 |
msgstr ""
|
43 |
|
44 |
-
#:
|
45 |
msgid "Activate"
|
46 |
msgstr ""
|
47 |
|
48 |
-
#:
|
49 |
msgid "Deactivate"
|
50 |
msgstr ""
|
51 |
|
52 |
-
#:
|
53 |
msgid "Settings"
|
54 |
msgstr ""
|
55 |
|
56 |
-
#:
|
57 |
msgid "Developers - create your own widgets for the Widgets Bundle."
|
58 |
msgstr ""
|
59 |
|
60 |
-
#:
|
61 |
msgid "Read More"
|
62 |
msgstr ""
|
63 |
|
64 |
-
#:
|
65 |
msgid "Widget Settings"
|
66 |
msgstr ""
|
67 |
|
68 |
-
#:
|
69 |
msgid "Save"
|
70 |
msgstr ""
|
71 |
|
72 |
-
#:
|
73 |
msgid "Invalid request."
|
74 |
msgstr ""
|
75 |
|
76 |
-
#:
|
77 |
msgid "Invalid post."
|
78 |
msgstr ""
|
79 |
|
80 |
-
#:
|
81 |
msgid "Widget Preview"
|
82 |
msgstr ""
|
83 |
|
84 |
-
#:
|
85 |
msgid "Nonce error"
|
86 |
msgstr ""
|
87 |
|
88 |
-
#:
|
89 |
msgid "Signature error"
|
90 |
msgstr ""
|
91 |
|
92 |
-
#:
|
93 |
msgid "Attachment error"
|
94 |
msgstr ""
|
95 |
|
96 |
-
#:
|
97 |
msgid "Search"
|
98 |
msgstr ""
|
99 |
|
100 |
-
#:
|
101 |
msgid "Close"
|
102 |
msgstr ""
|
103 |
|
104 |
-
#:
|
105 |
msgid "Optional"
|
106 |
msgstr ""
|
107 |
|
108 |
-
#:
|
109 |
msgid "Required"
|
110 |
|