Version Description
- 13 October 2017 =
- Fix subwidget fields initializion when not contained in a section.
- TinyMCE field: fix initialization in repeaters.
Download this release
Release Info
Developer | gpriday |
Plugin | SiteOrigin Widgets Bundle |
Version | 1.10.1 |
Comparing to | |
See all releases |
Code changes from version 1.10.0 to 1.10.1
- base/inc/fields/js/tinymce-field.js +50 -13
- base/inc/fields/js/tinymce-field.min.js +1 -1
- base/js/admin.js +5 -2
- base/js/admin.min.js +1 -1
- readme.txt +6 -2
- so-widgets-bundle.php +2 -2
base/inc/fields/js/tinymce-field.js
CHANGED
@@ -1,14 +1,13 @@
|
|
1 |
/* global tinymce, switchEditors */
|
2 |
|
3 |
(function ( $ ) {
|
4 |
-
|
5 |
-
var $$ = $( this );
|
6 |
|
7 |
-
if (
|
8 |
return;
|
9 |
}
|
10 |
|
11 |
-
var $container =
|
12 |
var settings = $container.data( 'editorSettings' );
|
13 |
var $textarea = $container.find( 'textarea' );
|
14 |
var id = $textarea.attr( 'id' );
|
@@ -25,11 +24,11 @@
|
|
25 |
$( document ).one( 'wp-before-tinymce-init', function ( event, init ) {
|
26 |
if ( init.selector === settings.tinymce.selector ) {
|
27 |
var mediaButtons = $container.data( 'mediaButtons' );
|
28 |
-
|
29 |
}
|
30 |
} );
|
31 |
$( document ).one( 'tinymce-editor-setup', function () {
|
32 |
-
if ( !
|
33 |
setTimeout( function () {
|
34 |
window.switchEditors.go( id );
|
35 |
}, 10 );
|
@@ -50,8 +49,8 @@
|
|
50 |
}
|
51 |
}, 500);
|
52 |
}
|
53 |
-
|
54 |
-
|
55 |
var $target = $( event.target );
|
56 |
var mode = $target.hasClass( 'wp-switch-editor' ) ? 'tmce' : 'html';
|
57 |
if ( mode === 'tmce' ) {
|
@@ -65,12 +64,50 @@
|
|
65 |
}
|
66 |
editor.setContent(window.switchEditors.wpautop(content));
|
67 |
}
|
68 |
-
|
69 |
-
|
70 |
}
|
71 |
} );
|
72 |
-
|
73 |
-
|
74 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
})( jQuery );
|
1 |
/* global tinymce, switchEditors */
|
2 |
|
3 |
(function ( $ ) {
|
4 |
+
var setup = function( $field ) {
|
|
|
5 |
|
6 |
+
if ( $field.data( 'initialized' ) ) {
|
7 |
return;
|
8 |
}
|
9 |
|
10 |
+
var $container = $field.find( '.siteorigin-widget-tinymce-container' );
|
11 |
var settings = $container.data( 'editorSettings' );
|
12 |
var $textarea = $container.find( 'textarea' );
|
13 |
var id = $textarea.attr( 'id' );
|
24 |
$( document ).one( 'wp-before-tinymce-init', function ( event, init ) {
|
25 |
if ( init.selector === settings.tinymce.selector ) {
|
26 |
var mediaButtons = $container.data( 'mediaButtons' );
|
27 |
+
$field.find( '.wp-editor-tabs' ).before( mediaButtons.html );
|
28 |
}
|
29 |
} );
|
30 |
$( document ).one( 'tinymce-editor-setup', function () {
|
31 |
+
if ( ! $field.find( '.wp-editor-wrap' ).hasClass( settings.selectedEditor + '-active' ) ) {
|
32 |
setTimeout( function () {
|
33 |
window.switchEditors.go( id );
|
34 |
}, 10 );
|
49 |
}
|
50 |
}, 500);
|
51 |
}
|
52 |
+
|
53 |
+
$field.on( 'click', function ( event ) {
|
54 |
var $target = $( event.target );
|
55 |
var mode = $target.hasClass( 'wp-switch-editor' ) ? 'tmce' : 'html';
|
56 |
if ( mode === 'tmce' ) {
|
64 |
}
|
65 |
editor.setContent(window.switchEditors.wpautop(content));
|
66 |
}
|
67 |
+
|
68 |
+
$field.find( '.siteorigin-widget-tinymce-selected-editor' ).val( mode );
|
69 |
}
|
70 |
} );
|
71 |
+
|
72 |
+
$field.data( 'initialized', true );
|
73 |
+
};
|
74 |
+
|
75 |
+
$( document ).on( 'sowsetupformfield', '.siteorigin-widget-field-type-tinymce', function () {
|
76 |
+
var $field = $( this );
|
77 |
+
var $parentRepeaterItem = $field.closest( '.siteorigin-widget-field-repeater-item-form' );
|
78 |
+
|
79 |
+
if ( $parentRepeaterItem.length > 0 ) {
|
80 |
+
if ( $parentRepeaterItem.is( ':visible' ) ) {
|
81 |
+
setup( $field );
|
82 |
+
}
|
83 |
+
else {
|
84 |
+
$parentRepeaterItem.on('slideToggleOpenComplete', function onSlideToggleComplete() {
|
85 |
+
if ( $parentRepeaterItem.is( ':visible' ) ) {
|
86 |
+
setup( $field );
|
87 |
+
$parentRepeaterItem.off( 'slideToggleOpenComplete' );
|
88 |
+
}
|
89 |
+
});
|
90 |
+
}
|
91 |
+
}
|
92 |
+
else {
|
93 |
+
setup( $field );
|
94 |
+
}
|
95 |
+
});
|
96 |
+
|
97 |
+
$( document ).on( 'sortstop', function ( event, ui ) {
|
98 |
+
var $form;
|
99 |
+
if ( ui.item.is( '.siteorigin-widget-field-repeater-item' ) ) {
|
100 |
+
$form = ui.item.find( '> .siteorigin-widget-field-repeater-item-form' );
|
101 |
+
}
|
102 |
+
else {
|
103 |
+
$form = ui.item.find('.siteorigin-widget-form');
|
104 |
+
}
|
105 |
+
|
106 |
+
$form.find( '.siteorigin-widget-field-type-tinymce' ).each( function () {
|
107 |
+
$( this ).data( 'initialized', null );
|
108 |
+
setup( $( this ) );
|
109 |
+
} );
|
110 |
+
|
111 |
+
});
|
112 |
|
113 |
})( jQuery );
|
base/inc/fields/js/tinymce-field.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(i){
|
1 |
+
!function(i){var e=function(e){if(!e.data("initialized")){var t=e.find(".siteorigin-widget-tinymce-container"),n=t.data("editorSettings"),o=t.find("textarea"),r=o.attr("id"),s=function(i){i.on("change",function(){window.tinymce.get(r).save(),o.trigger("change")})};if(n.tinymce=i.extend({},n.tinymce,{selector:"#"+r,setup:s}),i(document).one("wp-before-tinymce-init",function(i,o){if(o.selector===n.tinymce.selector){var r=t.data("mediaButtons");e.find(".wp-editor-tabs").before(r.html)}}),i(document).one("tinymce-editor-setup",function(){e.find(".wp-editor-wrap").hasClass(n.selectedEditor+"-active")||setTimeout(function(){window.switchEditors.go(r)},10)}),wp.editor.remove(r),o.is(":visible"))wp.editor.initialize(r,n);else var d=setInterval(function(){o.is(":visible")&&(wp.editor.initialize(r,n),clearInterval(d))},500);e.on("click",function(t){var n=i(t.target),s=n.hasClass("wp-switch-editor")?"tmce":"html";if("tmce"===s){var d=window.tinymce.get(r);if(n.hasClass("switch-tmce")&&null!==d){var a=o.val();-1!==a.search("<")&&-1===a.search(">")&&(a=a.replace(/</g,""),o.val(a)),d.setContent(window.switchEditors.wpautop(a))}e.find(".siteorigin-widget-tinymce-selected-editor").val(s)}}),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/js/admin.js
CHANGED
@@ -213,10 +213,13 @@ var sowbForms = window.sowbForms || {};
|
|
213 |
var $fields = $el.find('> .siteorigin-widget-field');
|
214 |
|
215 |
// Process any sub sections
|
216 |
-
$fields.find('> .siteorigin-widget-section
|
|
|
|
|
|
|
217 |
|
218 |
// Process any sub widgets whose fields aren't contained in a section
|
219 |
-
$
|
220 |
|
221 |
// Store the field names
|
222 |
$fields.find('.siteorigin-widget-input').each(function (i, input) {
|
213 |
var $fields = $el.find('> .siteorigin-widget-field');
|
214 |
|
215 |
// Process any sub sections
|
216 |
+
$fields.find('> .siteorigin-widget-section').sowSetupForm();
|
217 |
+
|
218 |
+
var $subwidgetFields = $fields.find('> .siteorigin-widget-widget');
|
219 |
+
$subwidgetFields.find('> .siteorigin-widget-section').sowSetupForm();
|
220 |
|
221 |
// Process any sub widgets whose fields aren't contained in a section
|
222 |
+
$subwidgetFields.filter(':not(:has(> .siteorigin-widget-section))').sowSetupForm();
|
223 |
|
224 |
// Store the field names
|
225 |
$fields.find('.siteorigin-widget-input').each(function (i, input) {
|
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 k in n)if(g=!1,null!==(s=k.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 F=0;F<f.length&&!(g=o.group===t&&f[F]===r);F++);}if(g){d=n[k],o.multi||(d=[d]);for(var F=0;F<d.length;F++)l=void 0!==d[F][1]&&Boolean(d[F][1])?i.find(d[F][1]):i,l[d[F][0]].apply(l,void 0!==d[F][2]?d[F][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, > .siteorigin-widget-widget > .siteorigin-widget-section").sowSetupForm(),u.filter(".siteorigin-widget-widget: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 m=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(m),u.filter(".siteorigin-widget-field-type-posts").find(".posts-container-label-wrapper").click(m),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:parseInt(t.attr("max")),min:parseInt(t.attr("min")),value:parseInt(t.val()),slide:function(e,i){t.val(parseInt(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",parseInt(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").soPanelsSetupBuilderWidget()});var w=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(){e(this).find(".siteorigin-widget-input").on("keyup change",w),e(this).find(".siteorigin-widget-input").each(function(){var i=e(this);i.is(":radio")?i.is(":checked")&&w.call(i[0]):w.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).data("repeater-positions"),n=e(t);if(void 0!==r){var a=n.attr("data-original-name");if(a||(n.attr("data-original-name",n.attr("name")),a=n.attr("name")),!a)return;if(r)for(var s in r)a=a.replace("#"+s+"#",r[s]);n.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.trigger("updateFieldPositions")},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")}}}),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()})})},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.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 r=e(this).closest(".siteorigin-widget-field-repeater-items"),n=e(this).closest(".siteorigin-widget-field-repeater-item"),a=function(){n.remove(),r.sortable("refresh").trigger("updateFieldPositions"),e(window).resize()};t&&t.silent?a():confirm(soWidgets.sure)&&n.slideUp("fast",a)}),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=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,k=e("body");(k.hasClass("wp-customizer")||k.hasClass("widgets-php"))&&0===r.closest(".panel-dialog").length&&(y+=1);var F=l.replace(new RegExp("((?:.*?\\[\\d+\\]){"+(y-1).toString()+"})?(.*?\\[)\\d+(\\])"),"$1$2"+o.toString()+"$3");i.attr("name",F),i.data("original-name",F)}),s.append(a).sortable("refresh").trigger("updateFieldPositions"),a.sowSetupRepeaterItems(),a.hide().slideDown("fast",function(){e(window).resize()})}),r.find("> .siteorigin-widget-field-repeater-item-form").sowSetupForm(),r.data("sowrepeater-actions-setup",!0)}})},sowbForms.getContainerFieldId=function(e,i,t){var r=i+"FieldId";this.hasOwnProperty(r)||(this[r]=1);var n=e.closest(t);if(n.length){var a=n.data("field-id");return void 0===a&&(a=this[r]++),n.data("field-id",a),a}return!1},sowbForms.getWidgetFieldVariable=function(e,i,t){var r=window.sow_field_javascript_variables[e];i=i.replace(/\[#.*?#\]/g,"");for(var n=/[a-zA-Z0-9\-]+(?:\[c?[0-9]+\])?\[(.*)\]/.exec(i)[1],a=n.split("]["),s=a.length?r:null;a.length;)s=s[a.shift()];return s[t]},sowbForms.fetchWidgetVariable=function(i,t,r){window.sowVars=window.sowVars||{},void 0===window.sowVars[t]?e.post(soWidgets.ajaxurl,{action:"sow_get_javascript_variables",widget:t,key:i},function(e){window.sowVars[t]=e,r(window.sowVars[t][i])}):r(window.sowVars[t][i])},sowbForms.getWidgetFormValues=function(i){if(_.isUndefined(i))return null;var t={};return i.find("*[name]").each(function(){var i=e(this);try{var r=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(_.isEmpty(r))return!0;r=r[1];var n=r.split("][");n=n.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});var a=t,s=null,o=_.isString(i.attr("type"))?i.attr("type").toLowerCase():null;if("checkbox"===o)s=!!i.is(":checked")&&(""===i.val()||i.val());else if("radio"===o){if(!i.is(":checked"))return;s=i.val()}else if("TEXTAREA"===i.prop("tagName")&&i.hasClass("wp-editor-area")){var d=null;"undefined"!=typeof tinyMCE&&(d=tinyMCE.get(i.attr("id"))),s=null===d||"function"!=typeof d.getContent||d.isHidden()?i.val():d.getContent()}else if("SELECT"===i.prop("tagName")){var l=i.find("option:selected");1===l.length?s=i.find("option:selected").val():l.length>1&&(s=_.map(i.find("option:selected"),function(i,t){return e(i).val()}))}else s=i.val();for(var g=0;g<n.length;g++)g===n.length-1?""===n[g]?a.push(s):a[n[g]]=s:(_.isUndefined(a[n[g]])&&(_.isNumber(n[g+1])||""===n[g+1]?a[n[g]]=[]:a[n[g]]={}),a=a[n[g]])}catch(e){console.error("Field ["+i.attr("name")+"] could not be processed and was skipped - "+e.message)}}),t},sowbForms.setWidgetFormValues=function(i,t){var r=0,n=function(i,t){10!=++r&&i.find("> .siteorigin-widget-field-type-repeater").each(function(){var i=e(this).find("> .siteorigin-widget-field-repeater"),r=i.data("repeaterName"),a=t.hasOwnProperty(r)?t[r]:null;if(a&&Array.isArray(a)&&0!==a.length){var s=i.find("> .siteorigin-widget-field-repeater-items > .siteorigin-widget-field-repeater-item"),o=a.length,d=s.length;if(o>d)for(var l=0;l<o-d;l++)i.find("> .siteorigin-widget-field-repeater-add").click();else if(o<d)for(var g=o;g<d;g++){var f=e(s.eq(g));f.find("> .siteorigin-widget-field-repeater-item-top").find(".siteorigin-widget-field-remove").trigger("click",{silent:!0})}s=i.find("> .siteorigin-widget-field-repeater-items > .siteorigin-widget-field-repeater-item");for(var c=0;c<s.length;c++)s.eq(c).find("> .siteorigin-widget-field-repeater-item-form"),n(s.eq(c).find("> .siteorigin-widget-field-repeater-item-form"),a[c])}})};n(i,t),i.find("*[name]").each(function(){var i=e(this),r=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(void 0===r)return!0;r=r[1];var n=r.split("][");n=n.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});for(var a,s=t,o=0;o<n.length;o++)o===n.length-1?a=s[n[o]]:s=s[n[o]];if("checkbox"===i.attr("type"))i.prop("checked",a);else if("radio"===i.attr("type"))i.prop("checked",a===i.val());else if("TEXTAREA"===i.prop("tagName")&&i.hasClass("wp-editor-area")){var d=null;"undefined"!=typeof tinyMCE&&(d=tinyMCE.get(i.attr("id"))),null===d||"function"!=typeof d.getContent||d.isHidden()?i.val(a):d.setContent(a)}else i.val(a);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 k in n)if(g=!1,null!==(s=k.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 F=0;F<f.length&&!(g=o.group===t&&f[F]===r);F++);}if(g){d=n[k],o.multi||(d=[d]);for(var F=0;F<d.length;F++)l=void 0!==d[F][1]&&Boolean(d[F][1])?i.find(d[F][1]):i,l[d[F][0]].apply(l,void 0!==d[F][2]?d[F][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:parseInt(t.attr("max")),min:parseInt(t.attr("min")),value:parseInt(t.val()),slide:function(e,i){t.val(parseInt(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",parseInt(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").soPanelsSetupBuilderWidget()});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(){e(this).find(".siteorigin-widget-input").on("keyup change",v),e(this).find(".siteorigin-widget-input").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).data("repeater-positions"),n=e(t);if(void 0!==r){var a=n.attr("data-original-name");if(a||(n.attr("data-original-name",n.attr("name")),a=n.attr("name")),!a)return;if(r)for(var s in r)a=a.replace("#"+s+"#",r[s]);n.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.trigger("updateFieldPositions")},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")}}}),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()})})},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.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 r=e(this).closest(".siteorigin-widget-field-repeater-items"),n=e(this).closest(".siteorigin-widget-field-repeater-item"),a=function(){n.remove(),r.sortable("refresh").trigger("updateFieldPositions"),e(window).resize()};t&&t.silent?a():confirm(soWidgets.sure)&&n.slideUp("fast",a)}),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=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,k=e("body");(k.hasClass("wp-customizer")||k.hasClass("widgets-php"))&&0===r.closest(".panel-dialog").length&&(y+=1);var F=l.replace(new RegExp("((?:.*?\\[\\d+\\]){"+(y-1).toString()+"})?(.*?\\[)\\d+(\\])"),"$1$2"+o.toString()+"$3");i.attr("name",F),i.data("original-name",F)}),s.append(a).sortable("refresh").trigger("updateFieldPositions"),a.sowSetupRepeaterItems(),a.hide().slideDown("fast",function(){e(window).resize()})}),r.find("> .siteorigin-widget-field-repeater-item-form").sowSetupForm(),r.data("sowrepeater-actions-setup",!0)}})},sowbForms.getContainerFieldId=function(e,i,t){var r=i+"FieldId";this.hasOwnProperty(r)||(this[r]=1);var n=e.closest(t);if(n.length){var a=n.data("field-id");return void 0===a&&(a=this[r]++),n.data("field-id",a),a}return!1},sowbForms.getWidgetFieldVariable=function(e,i,t){var r=window.sow_field_javascript_variables[e];i=i.replace(/\[#.*?#\]/g,"");for(var n=/[a-zA-Z0-9\-]+(?:\[c?[0-9]+\])?\[(.*)\]/.exec(i)[1],a=n.split("]["),s=a.length?r:null;a.length;)s=s[a.shift()];return s[t]},sowbForms.fetchWidgetVariable=function(i,t,r){window.sowVars=window.sowVars||{},void 0===window.sowVars[t]?e.post(soWidgets.ajaxurl,{action:"sow_get_javascript_variables",widget:t,key:i},function(e){window.sowVars[t]=e,r(window.sowVars[t][i])}):r(window.sowVars[t][i])},sowbForms.getWidgetFormValues=function(i){if(_.isUndefined(i))return null;var t={};return i.find("*[name]").each(function(){var i=e(this);try{var r=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(_.isEmpty(r))return!0;r=r[1];var n=r.split("][");n=n.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});var a=t,s=null,o=_.isString(i.attr("type"))?i.attr("type").toLowerCase():null;if("checkbox"===o)s=!!i.is(":checked")&&(""===i.val()||i.val());else if("radio"===o){if(!i.is(":checked"))return;s=i.val()}else if("TEXTAREA"===i.prop("tagName")&&i.hasClass("wp-editor-area")){var d=null;"undefined"!=typeof tinyMCE&&(d=tinyMCE.get(i.attr("id"))),s=null===d||"function"!=typeof d.getContent||d.isHidden()?i.val():d.getContent()}else if("SELECT"===i.prop("tagName")){var l=i.find("option:selected");1===l.length?s=i.find("option:selected").val():l.length>1&&(s=_.map(i.find("option:selected"),function(i,t){return e(i).val()}))}else s=i.val();for(var g=0;g<n.length;g++)g===n.length-1?""===n[g]?a.push(s):a[n[g]]=s:(_.isUndefined(a[n[g]])&&(_.isNumber(n[g+1])||""===n[g+1]?a[n[g]]=[]:a[n[g]]={}),a=a[n[g]])}catch(e){console.error("Field ["+i.attr("name")+"] could not be processed and was skipped - "+e.message)}}),t},sowbForms.setWidgetFormValues=function(i,t){var r=0,n=function(i,t){10!=++r&&i.find("> .siteorigin-widget-field-type-repeater").each(function(){var i=e(this).find("> .siteorigin-widget-field-repeater"),r=i.data("repeaterName"),a=t.hasOwnProperty(r)?t[r]:null;if(a&&Array.isArray(a)&&0!==a.length){var s=i.find("> .siteorigin-widget-field-repeater-items > .siteorigin-widget-field-repeater-item"),o=a.length,d=s.length;if(o>d)for(var l=0;l<o-d;l++)i.find("> .siteorigin-widget-field-repeater-add").click();else if(o<d)for(var g=o;g<d;g++){var f=e(s.eq(g));f.find("> .siteorigin-widget-field-repeater-item-top").find(".siteorigin-widget-field-remove").trigger("click",{silent:!0})}s=i.find("> .siteorigin-widget-field-repeater-items > .siteorigin-widget-field-repeater-item");for(var c=0;c<s.length;c++)s.eq(c).find("> .siteorigin-widget-field-repeater-item-form"),n(s.eq(c).find("> .siteorigin-widget-field-repeater-item-form"),a[c])}})};n(i,t),i.find("*[name]").each(function(){var i=e(this),r=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(void 0===r)return!0;r=r[1];var n=r.split("][");n=n.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});for(var a,s=t,o=0;o<n.length;o++)o===n.length-1?a=s[n[o]]:s=s[n[o]];if("checkbox"===i.attr("type"))i.prop("checked",a);else if("radio"===i.attr("type"))i.prop("checked",a===i.val());else if("TEXTAREA"===i.prop("tagName")&&i.hasClass("wp-editor-area")){var d=null;"undefined"!=typeof tinyMCE&&(d=tinyMCE.get(i.attr("id"))),null===d||"function"!=typeof d.getContent||d.isHidden()?i.val(a):d.setContent(a)}else i.val(a);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;
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Tags: bundle, widget, button, slider, image, carousel, price table, google maps, tinymce, social links
|
3 |
Requires at least: 4.2
|
4 |
Tested up to: 4.8.1
|
5 |
-
Stable tag: 1.10.
|
6 |
-
Build time: 2017-10-
|
7 |
License: GPLv3 or later
|
8 |
Contributors: gpriday, braam-genis
|
9 |
Donate link: https://siteorigin.com/downloads/contribution/
|
@@ -54,6 +54,10 @@ The SiteOrigin Widgets Bundle is the perfect platform to build widgets for your
|
|
54 |
|
55 |
== Changelog ==
|
56 |
|
|
|
|
|
|
|
|
|
57 |
= 1.10.0 - 11 October 2017 =
|
58 |
* New Accordion widget!
|
59 |
* Prevent multiple initialization of media field.
|
2 |
Tags: bundle, widget, button, slider, image, carousel, price table, google maps, tinymce, social links
|
3 |
Requires at least: 4.2
|
4 |
Tested up to: 4.8.1
|
5 |
+
Stable tag: 1.10.1
|
6 |
+
Build time: 2017-10-13T17:43:55+02:00
|
7 |
License: GPLv3 or later
|
8 |
Contributors: gpriday, braam-genis
|
9 |
Donate link: https://siteorigin.com/downloads/contribution/
|
54 |
|
55 |
== Changelog ==
|
56 |
|
57 |
+
= 1.10.1 - 13 October 2017 =
|
58 |
+
* Fix subwidget fields initializion when not contained in a section.
|
59 |
+
* TinyMCE field: fix initialization in repeaters.
|
60 |
+
|
61 |
= 1.10.0 - 11 October 2017 =
|
62 |
* New Accordion widget!
|
63 |
* Prevent multiple initialization of media field.
|
so-widgets-bundle.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: SiteOrigin Widgets Bundle
|
4 |
Description: A collection of all widgets, neatly bundled into a single plugin. It's also a framework to code your own widgets on top of.
|
5 |
-
Version: 1.10.
|
6 |
Text Domain: so-widgets-bundle
|
7 |
Domain Path: /lang
|
8 |
Author: SiteOrigin
|
@@ -12,7 +12,7 @@ License: GPL3
|
|
12 |
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
13 |
*/
|
14 |
|
15 |
-
define('SOW_BUNDLE_VERSION', '1.10.
|
16 |
define('SOW_BUNDLE_BASE_FILE', __FILE__);
|
17 |
|
18 |
// Allow JS suffix to be pre-set
|
2 |
/*
|
3 |
Plugin Name: SiteOrigin Widgets Bundle
|
4 |
Description: A collection of all widgets, neatly bundled into a single plugin. It's also a framework to code your own widgets on top of.
|
5 |
+
Version: 1.10.1
|
6 |
Text Domain: so-widgets-bundle
|
7 |
Domain Path: /lang
|
8 |
Author: SiteOrigin
|
12 |
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
13 |
*/
|
14 |
|
15 |
+
define('SOW_BUNDLE_VERSION', '1.10.1');
|
16 |
define('SOW_BUNDLE_BASE_FILE', __FILE__);
|
17 |
|
18 |
// Allow JS suffix to be pre-set
|