Update shortcodes library

This commit is contained in:
Robin Cornett
2017-11-02 12:46:16 -04:00
parent ac6e60bc8d
commit bad07bd655
3 changed files with 7 additions and 6 deletions
@@ -104,6 +104,7 @@ If an image ID is required, Six/Ten Press image fields in a group will work, as
#### 0.3.5
* reverted: target shortcode buttons back to class (in case of multiples)
* fixed: textarea inputs being skipped in self closing widgets
#### 0.3.4
* added: hooks before/after media buttons
@@ -51,7 +51,7 @@
function _insert( e ) {
e.preventDefault();
if ( $( sixtenpress_trigger_target ).hasClass( IndividualObject.button ) ) {
var string = _getAttributes( inputs, IndividualObject.group ),
var string = _getAttributes( inputs, IndividualObject ),
multi = IndividualObject.group ? _getMulti( IndividualObject.group, IndividualObject.slug ) : '',
output = '';
if ( string ) {
@@ -160,11 +160,11 @@
* Get the shortcode attributes as a string.
*
* @param inputs
* @param group
* @param object
* @returns {string}
* @private
*/
function _getAttributes( inputs, group ) {
function _getAttributes( inputs, object ) {
var output = '';
$( inputs ).each( function ( index ) {
var original_id = $( this ).attr( 'id' ),
@@ -176,7 +176,7 @@
value = '';
}
if ( 'checkbox' === type ) {
if ( group.length && id.includes( group ) ) {
if ( object.group.length && id.includes( object.group ) ) {
value = '';
} else if ( $( this ).is( ':checked' ) ) {
var truthy = [ 1, '1', 'on' ],
@@ -191,7 +191,7 @@
if ( 'button' === type ) {
value = '';
}
if ( 'textarea' === type ) {
if ( 'textarea' === type && ! object.self ) {
value = '';
}
if ( value || $( this ).is( ':required' ) ) {
@@ -1 +1 @@
!function(t,e,i){"use strict";function n(t){var n=[];return e(t).each(function(t){var r=e(this).attr("id");i!==r&&(n[r]=e(this).val()),e(this).is(":checked")&&(n[r]="checked")}),n}function r(t,i){var n="";return e(t).each(function(t){var r=e(this).attr("id"),a=e(this).val(),c=this.type;if(r){var o=r.substr(r.lastIndexOf("-")+1);if(o.includes("nonce")&&(a=""),"checkbox"===c)if(i.length&&o.includes(i))a="";else if(e(this).is(":checked")){var s=[1,"1","on"],d=s.indexOf(a);a=-1!==d?"true":a}else a=e(this).is(":required")?"false":"";"button"===c&&(a=""),"textarea"===c&&(a=""),(a||e(this).is(":required"))&&(n+=" "+o+'="'+a+'"')}}),n}function a(t,i){var n=e("#"+i),r=n.find("textarea").val();if(!r){var a=n.find("textarea[id*='"+t+"']").attr("id");"undefined"!==a&&a.length&&(r=tinymce.get(a).getContent({format:"text"}))}return r}function c(t,i){var n="";return e(t).each(function(t,r){var a=e("#"+i).find("[id*='"+r+"']"),c=[];e(a).each(function(t){e(this).is(":checked")&&c.push(e(this).val())}),n+=c.length?" "+r+'="'+c.toString()+'"':""}),n}var o={};o.init=function(){Object.keys(o.params).forEach(function(i){function s(i){i.preventDefault(),v=i.target,m=!0,e(k).show(),e(".media-modal-close, .media-modal-backdrop, .sixtenpress-cancel-insertion").click(u),e(t).on("keydown",function(t){27===t.keyCode&&m&&u(t)})}function d(t){if(t.preventDefault(),e(v).hasClass(p.button)){var i=r(x,p.group),n=p.group?c(p.group,p.slug):"",o="";i&&(o="["+p.shortcode+n+i+"]",p.self||(o+=a(p.slug,p.modal)+"[/"+p.shortcode+"]"),tinymce.get(e(v).attr("data-editor")).execCommand("mceInsertContent",!1,o))}u(t)}function u(t){t.preventDefault(),e(k).hide(),f(),v=m=!1}function f(){e(x).each(function(t){var i=e(this).attr("id");if("checkbox"===this.type){var n="checked"===g[i];e(this).attr("checked",n)}else e(this).val(g[i])}),e(k+" .upload-file-preview").remove(),h(),l()}function h(){var t=e(k).find(".wp-picker-container");t.length&&t.each(function(){var t=e(this).parent();t.html(t.find('input[type="text"].color-field').attr("style","")),t.find('input[type="text"].wp-color-picker').each(function(){var t=e(this),i=t.data("colorpicker")||{};t.wpColorPicker(e.extend({},!1,i))})})}function l(){var t=e(k).find("textarea[id*='"+p.slug+"']");if(t.length){var i=t.attr("id");tinymce.get(i).setContent("")}}if(o.params.hasOwnProperty(i)){var p=o.params[i],v=!1,m=!1,k="."+p.modal,x=e("#"+p.modal).find(":input"),g=n(x),y=p.button.replace(" ",".");e("."+y).click(s),e(k+".sixtenpress-default-ui .sixtenpress-insert").click(d)}})},e(t).ready(function(){o.params="undefined"==typeof SixTenShortcodes?"":SixTenShortcodes,void 0!==o.params&&o.init()})}(document,jQuery);
!function(t,e,i){"use strict";function n(t){var n=[];return e(t).each(function(t){var r=e(this).attr("id");i!==r&&(n[r]=e(this).val()),e(this).is(":checked")&&(n[r]="checked")}),n}function r(t,i){var n="";return e(t).each(function(t){var r=e(this).attr("id"),a=e(this).val(),c=this.type;if(r){var o=r.substr(r.lastIndexOf("-")+1);if(o.includes("nonce")&&(a=""),"checkbox"===c)if(i.group.length&&o.includes(i.group))a="";else if(e(this).is(":checked")){var s=[1,"1","on"],d=s.indexOf(a);a=-1!==d?"true":a}else a=e(this).is(":required")?"false":"";"button"===c&&(a=""),"textarea"!==c||i.self||(a=""),(a||e(this).is(":required"))&&(n+=" "+o+'="'+a+'"')}}),n}function a(t,i){var n=e("#"+i),r=n.find("textarea").val();if(!r){var a=n.find("textarea[id*='"+t+"']").attr("id");"undefined"!==a&&a.length&&(r=tinymce.get(a).getContent({format:"text"}))}return r}function c(t,i){var n="";return e(t).each(function(t,r){var a=e("#"+i).find("[id*='"+r+"']"),c=[];e(a).each(function(t){e(this).is(":checked")&&c.push(e(this).val())}),n+=c.length?" "+r+'="'+c.toString()+'"':""}),n}var o={};o.init=function(){Object.keys(o.params).forEach(function(i){function s(i){i.preventDefault(),v=i.target,m=!0,e(k).show(),e(".media-modal-close, .media-modal-backdrop, .sixtenpress-cancel-insertion").click(u),e(t).on("keydown",function(t){27===t.keyCode&&m&&u(t)})}function d(t){if(t.preventDefault(),e(v).hasClass(p.button)){var i=r(g,p),n=p.group?c(p.group,p.slug):"",o="";i&&(o="["+p.shortcode+n+i+"]",p.self||(o+=a(p.slug,p.modal)+"[/"+p.shortcode+"]"),tinymce.get(e(v).attr("data-editor")).execCommand("mceInsertContent",!1,o))}u(t)}function u(t){t.preventDefault(),e(k).hide(),f(),v=m=!1}function f(){e(g).each(function(t){var i=e(this).attr("id");if("checkbox"===this.type){var n="checked"===x[i];e(this).attr("checked",n)}else e(this).val(x[i])}),e(k+" .upload-file-preview").remove(),h(),l()}function h(){var t=e(k).find(".wp-picker-container");t.length&&t.each(function(){var t=e(this).parent();t.html(t.find('input[type="text"].color-field').attr("style","")),t.find('input[type="text"].wp-color-picker').each(function(){var t=e(this),i=t.data("colorpicker")||{};t.wpColorPicker(e.extend({},!1,i))})})}function l(){var t=e(k).find("textarea[id*='"+p.slug+"']");if(t.length){var i=t.attr("id");tinymce.get(i).setContent("")}}if(o.params.hasOwnProperty(i)){var p=o.params[i],v=!1,m=!1,k="."+p.modal,g=e("#"+p.modal).find(":input"),x=n(g),y=p.button.replace(" ",".");e("."+y).click(s),e(k+".sixtenpress-default-ui .sixtenpress-insert").click(d)}})},e(t).ready(function(){o.params="undefined"==typeof SixTenShortcodes?"":SixTenShortcodes,void 0!==o.params&&o.init()})}(document,jQuery);