Added buttons to edit cutomcode directly from where it is added in other areas around the component. This will improve the customcode workflow in JCB.

This commit is contained in:
2019-01-31 23:44:21 +02:00
parent 8cdf056ad4
commit 1a538e71d7
52 changed files with 1407 additions and 236 deletions

View File

@ -8,4 +8,50 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
jQuery(document).ready(function($)
{
// check and load all the custom code edit buttons
getEditCustomCodeButtons();
});
function getEditCustomCodeButtons_server(id){
var getUrl = "index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod;
if(token.length > 0 && id > 0){
var request = 'token='+token+'&id='+id+'&return_here='+return_here;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'json',
data: request,
jsonp: false
});
}
function getEditCustomCodeButtons(){
// get the id
id = jQuery("#jform_id").val();
getEditCustomCodeButtons_server(id).done(function(result) {
if(isObject(result)){
jQuery.each(result, function( field, buttons ) {
jQuery('<div class="control-group"><div class="control-label"><label>Edit Customcode</label></div><div class="controls control-customcode-buttons-'+field+'"></div></div>').insertBefore(".control-wrapper-"+ field);
jQuery.each(buttons, function( name, button ) {
jQuery(".control-customcode-buttons-"+field).append(button);
});
});
}
})
}
// check object is not empty
function isObject(obj) {
for(var prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
return true;
}
}
return false;
}