Skip to content

Commit

Permalink
v2.2.7 build
Browse files Browse the repository at this point in the history
  • Loading branch information
nikeo committed Jul 18, 2019
1 parent 81854b3 commit 7fafae2
Show file tree
Hide file tree
Showing 15 changed files with 548 additions and 46 deletions.
3 changes: 2 additions & 1 deletion addons/assets/front/js/jQuerySharrre.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ var SharrrePlatform = SharrrePlatform || (function () {
return {
settings: defaultSettings,
url: function (test) {
return "https://www.linkedin.com/countserv/count/share?format=jsonp&url={url}&callback=?";
return '';
//return "https://www.linkedin.com/countserv/count/share?format=jsonp&url={url}&callback=?";
},
trackingAction: {site: 'linkedin', action: 'share'},
load: function (self) {
Expand Down
2 changes: 1 addition & 1 deletion addons/assets/front/js/jQuerySharrre.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion addons/sharrre/ha-sharrre.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function ha_addons_scripts() {
if ( is_singular() ) {
wp_enqueue_script(
'sharrre',
sprintf( '%1$saddons/assets/front/js/jQuerySharrre%2$s', HU_AD() -> ha_get_base_url(), (defined('CZR_DEV') && true === CZR_DEV) ? '.js' : '.min.js' ),
sprintf( '%1$saddons/assets/front/js/jQuerySharrre%2$s', HU_AD() -> ha_get_base_url(), (defined('CZR_DEV') && true === CZR_DEV) ? '.js?' . time() : '.min.js' ),
array( 'jquery' ),
'',
true
Expand Down
2 changes: 1 addition & 1 deletion ha-fire.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Hueman Addons
* Plugin URI: https://presscustomizr.com
* Description: Hueman Theme Addons
* Version: 2.2.6
* Version: 2.2.7
* Text Domain: hueman-addons
* Author: Press Customizr
* Author URI: https://presscustomizr.com
Expand Down
5 changes: 3 additions & 2 deletions inc/czr-base-fmk/assets/css/czr-ccat-control-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ input:-ms-input-placeholder {

.customize-control select {
cursor: pointer;
width: 99%;
}


Expand Down Expand Up @@ -975,7 +976,7 @@ li.customize-control[data-module] .czr-notice {
display: block;
float: left;
margin: 2% 2% 0%;
width: 99%;
width: 98%;
padding: 2%;
background: #fff;
/* color: #fff;*/
Expand Down Expand Up @@ -1023,7 +1024,7 @@ li.customize-control[data-module] .czr-notice {
/* Display a thin outline around opened item, for multi-items modules */
#customize-theme-controls .czr-single-item.open {
/*border: 1px solid #dedede;*/
outline: 1px solid #ccc;
outline: 1px solid #22a0d2;
}
/* Keep the normal border for single module, mono items controls */
#customize-theme-controls .mono-item-mod .czr-single-item {
Expand Down
2 changes: 1 addition & 1 deletion inc/czr-base-fmk/assets/css/czr-ccat-control-base.min.css

Large diffs are not rendered by default.

93 changes: 64 additions & 29 deletions inc/czr-base-fmk/assets/js/_0_ccat_czr-base-fmk.js
Original file line number Diff line number Diff line change
Expand Up @@ -1632,11 +1632,16 @@ $.extend( CZRInputMths , {
}
];


// Try to find a match with the provided constructor type
// 1) Check the input instance to see if the default callback has been overriden in an extended Constructor
// ( @see column width module in Nimble Builder to see how the overrides works )
// 2) if not, try to find a match with the provided constructor type
// => fire the relevant callback with the provided input_options
// input.type_map is declared in extend_api_base
if ( api.czrInputMap && _.has( api.czrInputMap, input.type ) ) {
if ( input[input.type] && _.isFunction( input[input.type]) ) {
try { input[input.type]( options.input_options || null ); } catch( er ) {
api.errare( 'Error in overriden callback method in input init => for input id :' + input.id + ' in module type : ' + input.module.module_type, er );
}
} else if ( api.czrInputMap && _.has( api.czrInputMap, input.type ) ) {
var _meth = api.czrInputMap[ input.type ];
if ( _.isFunction( input[_meth]) ) {
try { input[_meth]( options.input_options || null ); } catch( er ) {
Expand Down Expand Up @@ -2171,19 +2176,27 @@ $.extend( CZRInputMths , {
canUpload : true
};

api.CZR_Helpers.getModuleTmpl( {
tmpl : 'img-uploader',
module_type: 'all_modules',
module_id : input.module.id
} ).done( function( _serverTmpl_ ) {
//console.log( 'renderModuleParts => success response =>', input.module.id, _serverTmpl_);
$_view_el.html( api.CZR_Helpers.parseTemplate( _serverTmpl_ )( _template_params ) );
if ( $('#tmpl-czr-img-uploader').length > 0 ) {
$_view_el.html( wp.template( 'czr-img-uploader' )( _template_params ) );
input.tmplRendered.resolve();
input.container.trigger( input.id + ':content_rendered' );
}).fail( function( _r_ ) {
//console.log( 'renderModuleParts => fail response =>', _r_);
input.tmplRendered.reject( 'renderImageUploaderTemplate => Problem when fetching the tmpl from server for module : '+ input.module.id );
});
} else {
api.CZR_Helpers.getModuleTmpl( {
tmpl : 'img-uploader',
module_type: 'all_modules',
module_id : input.module.id
} ).done( function( _serverTmpl_ ) {
//console.log( 'renderModuleParts => success response =>', input.module.id, _serverTmpl_);
$_view_el.html( api.CZR_Helpers.parseTemplate( _serverTmpl_ )( _template_params ) );
input.tmplRendered.resolve();
input.container.trigger( input.id + ':content_rendered' );
}).fail( function( _r_ ) {
//console.log( 'renderModuleParts => fail response =>', _r_);
input.tmplRendered.reject( 'renderImageUploaderTemplate => Problem when fetching the tmpl from server for module : '+ input.module.id );
});
}


return true;
},

Expand Down Expand Up @@ -2558,11 +2571,7 @@ $.extend( CZRItemMths , {
trigger : 'click keydown',
selector : [ '.' + item.module.control.css_attr.display_alert_btn, '.' + item.module.control.css_attr.cancel_alert_btn ].join(','),
name : 'toggle_remove_alert',
actions : function() {
var _isVisible = this.removeDialogVisible();
this.module.closeRemoveDialogs();
this.removeDialogVisible( ! _isVisible );
}
actions : ['toggleRemoveAlert']
},
//removes item and destroys its view
{
Expand Down Expand Up @@ -2740,11 +2749,20 @@ $.extend( CZRItemMths , {
});
},

// fired on click event
// @see initialize()
toggleRemoveAlert : function() {
var _isVisible = this.removeDialogVisible();
this.module.closeRemoveDialogs();
this.removeDialogVisible( ! _isVisible );
},

//fired on click dom event
//for dynamic multi input modules
//@return void()
//@param params : { dom_el : {}, dom_event : {}, event : {}, model {} }
removeItem : function( params ) {
params = params || {};
var item = this,
module = this.module,
_new_collection = _.clone( module.itemCollection() );
Expand Down Expand Up @@ -2877,7 +2895,7 @@ $.extend( CZRItemMths , {
if ( 1 > $( '#tmpl-' + _template_selector ).length ) {
dfd.reject( 'Missing template for item ' + item.id + '. The provided template script has no been found : #tmpl-' + _template_selector );
}
appendAndResolve( wp.template( _template_selector )( item_model_for_template_injection ) );
appendAndResolve( wp.template( _template_selector )( $.extend( item_model_for_template_injection, { is_sortable : module.sortable } ) ) );
} else {

// allow plugin to alter the ajax params before fetching
Expand All @@ -2902,7 +2920,7 @@ $.extend( CZRItemMths , {
} else {
api.CZR_Helpers.getModuleTmpl( requestParams ).done( function( _serverTmpl_ ) {
//console.log( 'renderItemWrapper => success response =>', module.id, _serverTmpl_);
appendAndResolve( api.CZR_Helpers.parseTemplate( _serverTmpl_ )( { is_sortable : module.sortable } ) );
appendAndResolve( api.CZR_Helpers.parseTemplate( _serverTmpl_ )( $.extend( item_model_for_template_injection, { is_sortable : module.sortable } ) ) );
}).fail( function( _r_ ) {
//console.log( 'renderItemWrapper => fail response =>', _r_);
dfd.reject( 'renderItemWrapper => Problem when fetching the rud-item-part tmpl from server for module : '+ module.id );
Expand Down Expand Up @@ -3147,7 +3165,7 @@ $.extend( CZRItemMths , {
if ( 1 > $( '#tmpl-' + tmplSelectorSuffix ).length ) {
dfd.reject( 'renderItemContent => No itemInputList content template defined for module ' + module.id + '. The template script id should be : #tmpl-' + tmplSelectorSuffix );
} else {
appendAndResolve( wp.template( tmplSelectorSuffix )( item_model_for_template_injection ) );
appendAndResolve( wp.template( tmplSelectorSuffix )( $.extend( item_model_for_template_injection, { control_id : module.control.id } ) ) );
}

} else {
Expand Down Expand Up @@ -3602,13 +3620,14 @@ $.extend( CZRModuleMths, {
$.extend( module, constructorOptions || {} );

//extend the module with new template Selectors
//can have been overriden at this stage from a module constructor
$.extend( module, {
crudModulePart : '', //'czr-crud-module-part',//create, read, update, delete
rudItemPart : '',// 'czr-rud-item-part',//read, update, delete
ruItemPart : '',// 'czr-ru-item-part',//read, update <= ONLY USED IN THE WIDGET MODULE
alertPart : '',// 'czr-rud-item-alert-part',//used both for items and modules removal
itemInputList : '',//is specific for each crud module
modOptInputList : ''//is specific for each module
crudModulePart : module.crudModulePart || '', //'czr-crud-module-part',//create, read, update, delete
rudItemPart : module.rudItemPart || '',// 'czr-rud-item-part',//read, update, delete
ruItemPart : module.ruItemPart || '',// 'czr-ru-item-part',//read, update <= ONLY USED IN THE WIDGET MODULE
alertPart : module.alertPart || '',// 'czr-rud-item-alert-part',//used both for items and modules removal
itemInputList : module.itemInputList || '',//is specific for each crud module
modOptInputList : module.modOptInputList || ''//is specific for each module
} );

//embed : define a container, store the embed state, fire the render method
Expand Down Expand Up @@ -3725,6 +3744,9 @@ $.extend( CZRModuleMths, {
if ( false !== module.sortable ) {
module._makeItemsSortable();
}

// this event is listened to by Nimble Builder to expand the module once all the items collection is populated
module.control.container.trigger('items-collection-populated');
});

//populate and instantiate the items now when a module is embedded in a regular control
Expand Down Expand Up @@ -4714,6 +4736,11 @@ $.extend( CZRModuleMths, {
if ( module.czr_Item.has(_item.id) && 'expanded' == module.czr_Item(_item.id)._getViewState(_item.id) )
module.czr_Item( _item.id ).viewState.set( 'closed' ); // => will fire the cb toggleItemExpansion
} );

// 'czr-all-items-closed' has been introduced when coding the Simple Nimble slider module. @see https://github.com/presscustomizr/nimble-builder/issues/82
// When using the text editor in the items of in a multi-item module
// We need to clear the editor instances each time all items are closed, before opening a new one
api.trigger('czr-all-items-closed', { module_id : module.id } );
return this;
},

Expand Down Expand Up @@ -5044,6 +5071,14 @@ $.extend( CZRDynModuleMths, {
module.trigger( 'pre-item-input-collection-ready' );
},

// Intended to be overriden in a module
// introduced in July 2019 to allow a multi-item module to set a default pre-item
// typically, in the slider image, this is a way to have a default image when adding an item
// @see https://github.com/presscustomizr/nimble-builder/issues/479
getPreItem : function() {
return this.preItem();
},


// overridable method introduced with the flat skope
// problem to solve in skope => an item, can't always be instantiated in a given context.
Expand All @@ -5061,7 +5096,7 @@ $.extend( CZRDynModuleMths, {
return dfd.reject().promise();
}
var module = this,
item_candidate = module.preItem(),
item_candidate = module.getPreItem(),
collapsePreItem = function() {
module.preItemExpanded.set( false );
//module.toggleSuccessMessage('off');
Expand Down
2 changes: 1 addition & 1 deletion inc/czr-base-fmk/assets/js/_0_ccat_czr-base-fmk.min.js

Large diffs are not rendered by default.

92 changes: 90 additions & 2 deletions inc/czr-base-fmk/czr-base-fmk.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ function czr_enqueue_fmk_resources() {

// adds specific js templates for the czr_module control
add_action( 'customize_controls_print_footer_scripts', array( $this, 'ac_print_module_control_templates' ) , 1 );

add_action( 'customize_controls_print_footer_scripts', array( $this, 'ac_print_img_uploader_template' ) , 1 );
}


Expand Down Expand Up @@ -353,6 +355,62 @@ function ac_print_module_control_templates() {
</script>
<?php
}


// this template is used in setupImageUploaderSaveAsId and setupImageUploaderSaveAsUrl
// @see js CZRInputMths
function ac_print_img_uploader_template() {
?>
<script type="text/html" id="tmpl-czr-img-uploader">
<?php // case when a regular attachement object is provided, fetched from an id with wp.media.attachment( id ) ?>
<# if ( ( data.attachment && data.attachment.id ) ) { #>
<div class="attachment-media-view attachment-media-view-{{ data.attachment.type }} {{ data.attachment.orientation }}">
<div class="thumbnail thumbnail-{{ data.attachment.type }}">
<# if ( 'image' === data.attachment.type && data.attachment.sizes && data.attachment.sizes.medium ) { #>
<img class="attachment-thumb" src="{{ data.attachment.sizes.medium.url }}" draggable="false" alt="" />
<# } else if ( 'image' === data.attachment.type && data.attachment.sizes && data.attachment.sizes.full ) { #>
<img class="attachment-thumb" src="{{ data.attachment.sizes.full.url }}" draggable="false" alt="" />
<# } #>
</div>
<div class="actions">
<# if ( data.canUpload ) { #>
<button type="button" class="button remove-button">{{ data.button_labels.remove }}</button>
<button type="button" class="button upload-button control-focus" id="{{ data.settings['default'] }}-button">{{ data.button_labels.change }}</button>
<div style="clear:both"></div>
<# } #>
</div>
</div>
<?php // case when an url is provided ?>
<# } else if ( ! _.isEmpty( data.fromUrl ) ) { #>
<div class="attachment-media-view">
<div class="thumbnail thumbnail-thumb">
<img class="attachment-thumb" src="{{ data.fromUrl }}" draggable="false" alt="" />
</div>
<div class="actions">
<# if ( data.canUpload ) { #>
<button type="button" class="button remove-button">{{ data.button_labels.remove }}</button>
<button type="button" class="button upload-button control-focus" id="{{ data.settings['default'] }}-button">{{ data.button_labels.change }}</button>
<div style="clear:both"></div>
<# } #>
</div>
</div>
<?php // case when neither attachement or url are provided => placeholder ?>
<# } else { #>
<div class="attachment-media-view">
<div class="placeholder">
{{ data.button_labels.placeholder }}
</div>
<div class="actions">
<# if ( data.canUpload ) { #>
<button type="button" class="button upload-button" id="{{ data.settings['default'] }}-button">{{ data.button_labels.select }}</button>
<# } #>
<div style="clear:both"></div>
</div>
</div>
<# } #>
</script>
<?php
}
}//class
endif;

Expand Down Expand Up @@ -404,7 +462,38 @@ function ac_set_ajax_czr_tmpl() {
}
$tmpl = $_POST['tmpl'];
$module_type = $_POST['module_type'];

///////////////////////////////////////////////////////////////////////
// @param $tmpl = 'item-inputs'
//
// @param $_POST = {
// [tmpl] => item-inputs
// [module_type] => czr_heading_child
// [module_id] => __nimble__51b2f35191b3__main_settings_czr_module
// [cache] => true
// [nonce] => b4b0aea848
// [control_id] => __nimble__51b2f35191b3__main_settings
// [item_model] => Array
// (
// [id] => czr_heading_child_0
// [title] =>
// [heading_text] => This is a heading.
// [heading_tag] => h1
// [h_alignment_css] => Array
// (
// [desktop] => center
// )

// [heading_title] =>
// [link-to] =>
// [link-custom-url] =>
// [link-target] =>
// )

// [action] => ac_get_template
// }
$html = apply_filters( "ac_set_ajax_czr_tmpl___{$module_type}", '', $tmpl, $_POST );
///////////////////////////////////////////////////////////////////////////

if ( empty( $html ) ) {
wp_send_json_error( 'ac_set_ajax_czr_tmpl => module ' . $module_type . ' => template empty for requested tmpl : ' . $tmpl );
Expand Down Expand Up @@ -591,8 +680,7 @@ function ac_generate_czr_tmpl_from_map( $tmpl_map ) {
'editor_params' => array(),

// introduced for https://github.com/presscustomizr/nimble-builder/issues/431
'section_collection' => array(),
'section_type' => 'content'
'section_collection' => array()
);
foreach( $tmpl_map as $input_id => $input_data ) {
if ( ! is_string( $input_id ) || empty( $input_id ) ) {
Expand Down
Loading

0 comments on commit 7fafae2

Please sign in to comment.