New addon

Permalink
Hi, I am trying to make new addon in concrete5 which contatain the following field:
1. Name
2. Email
3. Image
All is going well but when i am trying to add the image from fileset, i am done upto fileset to choose the image but when i am try to choose a image then there is nothing happen, i dont know whts the main problem
i use the following js code

var SlideshowBlock = {

init:function(){},

chooseImg:function(){
//alert ("hellos 1");
ccm_launchFileManager('&fType=' + ccmi18n_filemanager.FTYPE_IMAGE);
},

showImages:function(){
$("#ccm-slideshowBlock-imgRows").show();
$("#ccm-slideshowBlock-chooseImg").show();
$("#ccm-slideshowBlock-fsRow").hide();
},

showFileSet:function(){
$("#ccm-slideshowBlock-imgRows").hide();
$("#ccm-slideshowBlock-chooseImg").hide();
$("#ccm-slideshowBlock-fsRow").show();
},

selectObj:function(obj){
if (obj.fsID != undefined) {
$("#ccm-slideshowBlock-fsRow input[name=fsID]").attr("value", obj.fsID);
$("#ccm-slideshowBlock-fsRow input[name=fsName]").attr("value", obj.fsName);
$("#ccm-slideshowBlock-fsRow .ccm-slideshowBlock-fsName").text(obj.fsName);
} else {
this.addNewImage(obj.fID, obj.thumbnailLevel1, obj.height, obj.title);
}
},

addImages:0,
addNewImage: function(fID, thumbPath, imgHeight, title) {
this.addImages--; //negative counter - so it doesn't compete with real slideshowImgIds
var slideshowImgId=this.addImages;
var templateHTML=$('#imgRowTemplateWrap .ccm-slideshowBlock-imgRow').html().replace(/tempFID/g,fID);
templateHTML=templateHTML.replace(/tempThumbPath/g,thumbPath);
templateHTML=templateHTML.replace(/tempFilename/g,title);
templateHTML=templateHTML.replace(/tempSlideshowImgId/g,slideshowImgId).replace(/tempHeight/g,imgHeight);
var imgRow = document.createElement("div");
imgRow.innerHTML=templateHTML;
imgRow.id='ccm-slideshowBlock-imgRow'+parseInt(slideshowImgId);
imgRow.className='ccm-slideshowBlock-imgRow';
document.getElementById('ccm-slideshowBlock-imgRows').appendChild(imgRow);
var bgRow=$('#ccm-slideshowBlock-imgRow'+parseInt(fID)+' .backgroundRow');
bgRow.css('background','url('+escape(thumbPath)+') no-repeat left top');

$("a.ccm-sitemap-select-page").unbind();
$("a.ccm-sitemap-select-page").dialog();
$("a.ccm-sitemap-select-page").click(function() {
ccmActivePageField = this;
});
},

removeImage: function(fID){
$('#ccm-slideshowBlock-imgRow'+fID).remove();
},

moveUp:function(fID){
var thisImg=$('#ccm-slideshowBlock-imgRow'+fID);
var qIDs=this.serialize();
var previousQID=0;
for(var i=0;i<qIDs.length;i++){
if(qIDs[i]==fID){
if(previousQID==0) break;
thisImg.after($('#ccm-slideshowBlock-imgRow'+previousQID));
break;
}
previousQID=qIDs[i];
}
},
moveDown:function(fID){
var thisImg=$('#ccm-slideshowBlock-imgRow'+fID);
var qIDs=this.serialize();
var thisQIDfound=0;
for(var i=0;i<qIDs.length;i++){
if(qIDs[i]==fID){
thisQIDfound=1;
continue;
}
if(thisQIDfound){
$('#ccm-slideshowBlock-imgRow'+qIDs[i]).after(thisImg);
break;
}
}
},
serialize:function(){
var t = document.getElementById("ccm-slideshowBlock-imgRows");
var qIDs=[];
for(var i=0;i<t.childNodes.length;i++){
if( t.childNodes[i].className && t.childNodes[i].className.indexOf('ccm-slideshowBlock-imgRow')>=0 ){
var qID=t.childNodes[i].id.replace('ccm-slideshowBlock-imgRow','');
qIDs.push(qID);
}
}
return qIDs;
},

validate:function(){
var failed=0;

if ($("#newImg select[name=type]").val() == 'FILESET')
{
if ($("#ccm-slideshowBlock-fsRow input[name=fsID]").val() <= 0) {
alert(ccm_t('choose-fileset'));
$('#ccm-slideshowBlock-AddImg').focus();
failed=1;
}
} else {
qIDs=this.serialize();
if( qIDs.length<2 ){
alert(ccm_t('choose-min-2'));
$('#ccm-slideshowBlock-AddImg').focus();
failed=1;
}
}

if(failed){
ccm_isBlockError=1;
return false;
}
return true;
}
}

ccmValidateBlockForm = function() { return SlideshowBlock.validate(); }
ccm_chooseAsset = function(obj) { SlideshowBlock.selectObj(obj); }

$(function() {
if ($("#newImg select[name=type]").val() == 'FILESET') {
$("#newImg select[name=type]").val('FILESET');
SlideshowBlock.showFileSet();
} else {
$("#newImg select[name=type]").val('CUSTOM');
SlideshowBlock.showImages();
}

$("#newImg select[name=type]").change(function(){
if (this.value == 'FILESET') {
SlideshowBlock.showFileSet();
} else {
SlideshowBlock.showImages();
}
});
});


thanks in advance for the reply

phpsoftsol
 
TheRealSean replied on at Permalink Reply
TheRealSean
I may be overlooking something here but is it not possible to use the asset library helper for what you need?

$al = Loader::helper('concrete/asset_library');
and then where you would like to display the image selector,
$al->image($formElementID, $formName, $chooseText, $fileObject = null);
//eg $al->image('image_fID', 'image', Select Image, $fileObject )


If its a block you are attempting to create I would recommend the designer content block, with this you just choose the elements you would like in your addon and select "Make Block"
http://www.concrete5.org/marketplace/addons/designer-content/...