How do I add listbox to tab1 and something else in tab2? - extendscript

Here is my code and I can't seem to get Listbox or anything to show up.
I found the main code posted on other forums.
I only added the Listbox code however I cannot seem to see any of my objects visible, not sure what’s happening.
var dlg = new Window ("dialog", "Abas", [0,0,0,0]);
dlg.size = [240, 120]
dlg.location = [415, 230]
var tpanel = dlg.add ("tabbedpanel" ,[10,10,0,0],);
tpanel.size = [220,100];
dlg.location = [10, 10];
var general = tpanel.add ("tab", [0,0,0,0], "Color");
var general1 = dlg.add('tabbedpanel')
var boo_tab = general1.add('tab', u, "Create Solids");
var t = boo_tab.add("statictext", undefined, "Hello", {multiline:false});
t.text = "Create Solids";
var listBox = tpanel.add("listbox", undefined, []);
listBox.selection = 0;
listBox.size = [300, 100];
listBox.add("item", "Create 2 solids");
listBox.add("item", "Create Solid");
listBox.add("item", "Create Solid dlgith fractual noise");
var images = tpanel.add ("tab", undefined, "Levels");
var img_options = images.add ("panel", undefined, "Image Options");
var buttons = dlg.add ("group");
buttons.add ("button", undefined, "Export", {name: "ok"});
buttons.add ("button", undefined, "Cancel");
var images1 = tpanel.add ("tab", undefined, "Curves");
var img_options = images1.add ("panel", undefined, "Image Options");
var buttons = dlg.add ("group");
buttons.add ("button", undefined, "Export", {name: "ok"});
buttons.add ("button", undefined, "Cancel");
tpanel.selection = 0;
dlg.center();
dlg.show ();

There appears to be quite a few things wrong with this code and it is difficult to figure out exactly what you are hoping to achieve.
The first thing that I'm noticing is that you are adding some objects to the tabbed panel instead of the tabs themselves.
For instance, you can't add listbox to tpanel because tpanel will only be expecting tab objects. Instead add listbox to either a group or a tab object. For instance, you could add it to your boo_tab object like so:
var listBox = boo_tab.add("listbox", undefined, []);
The same is true with images1. It cannot be added to tpanel. So you will need to choose where you want it.
I can't tell for certain if it was your intention to create a second tabbed panel general1 under the first one or if you just wanted it to be a new tab. If you wanted a new tabbed panel you are going to want to put both tabbed panels in their own groups.
It also looks like you want to add some buttons to the bottom. I believe, in order for this to work the way you want, you will also need to put tpanel in its own group.
I would like to suggest that while you are learning, you only add one item at a time. This way, if something goes wrong, you only have to troubleshoot one thing at a time and it is easier to discover where mistakes have been made.

Related

How do I right align text in a form field using pdf-lib?

I've seen TextAlignment googling but not sure how to implement it or if it applies to form fields? How would I right align text for totalField in the code below?
var pdfDoc = await PDFDocument.load(formPdfBytes)
var form = pdfDoc.getForm()
var totalField = form.getTextField('total')
totalField.setText('$' + total)

error on a dojo grid when adding new item to the store

I'm stuck with a problem on a dojo grid when adding new item to the store.
I've got :
a dojox/grid/EnhancedGrid containing articles
a tabcontainer where the tabs represent article's family.
Each time I choose a tab , it filters the grid to display that family, so far everything work fine.
But I've a button that allows to add a new article to the grid through a new window.
If the grid is not filtered no problem , but if i've got a tab selected I get the error:
grid assertion failed in itemwritestore
Same error on FF and IE, I search internet for that error but i didn't find anything revelant.
My code if its helps ...
var grid=parent.registry.byId('lagrid');
var items=lagrid.store._arrayOfAllItems;
var item=items[e.rowIndex];
var lestab=parent.registry.byId( 'TabContainerRayon');
var tabsel=lestab.selectedChildWidget.id
var ongletR=tabsel.substring(1,tabsel.length);
if (grid)
{
var storeParent=grid.store;
var itemsParent=storeParent._arrayOfAllItems;
for (i=0 ; i< itemsParent.length ; i++)
{
if (itemsParent[i].col17==idLigne)
{
alert("Article déjà présent");
return false;
}
}
var myNewItem = {
id: grid.rowCount+1,
col2:trim(lagrid.store.getValue(lagrid.getItem(e.rowIndex),"Col5")),
col3:undefined,
col4:undefined,
col5:trim(lagrid.store.getValue(lagrid.getItem(e.rowIndex),"Col6")),
col6:trim(lagrid.store.getValue(lagrid.getItem(e.rowIndex),"Col8")),
col7:undefined,
col8: undefined,
col9: undefined,
col10: 1,
col11: undefined,
col12:trim(lagrid.store.getValue(lagrid.getItem(tabInd[0]),"Col1")),
col13:trim(lagrid.store.getValue(lagrid.getItem(e.rowIndex),"Col2")),
col14:'' ,
col15: ongletR,
col16:"<img src='/" + CheminBase + "/pictures.png?OpenImageResource' border=0>",
col17:idLigne ,
col18:trim(lagrid.store.getValue(lagrid.getItem(e.rowIndex),"Col9"))
};
parent.PctPrixTolere.push(parseInt(lagrid.store.getValue(lagrid.getItem(e.rowIndex),"Col7")));
parent.PresenceReleve.push("0");
}
// ajoute l'item dans le store
grid.store.newItem(myNewItem);
grid.store.save();
parent.registry.byId('external').hide();
Thanks for your help
ok I finally find my mistake thanks to ie debugger :)
in fact I was using grid.rowCount+1 to identify my new item, but if I click onto a tab, I have always less row than the store has => same id than an existing row => assertion failed. I changed that to grid.store._arrayOfAllItems.length and it works fine :)

XPages - Is it possible to make view column header fixed?

Just checking to see if there is a very simple way to make the view header fixed so that as you page down in the view in XPages, the header stays where it is. position=Fixed is not a property of xp:viewColumnHeader.
If you want to add the attribute of position to xp:viewColumnHeader you can use the attrs property to do that (works on 8.5.3). You code would look something like this:
<xp:viewColumnHeader ......>
<xp:this.attrs>
<xp:attr name="position" value="fixed"></xp:attr>
</xp:this.attrs>
</xp:viewColumnHeader>
But I don't think that alone would do the trick. Some time back I created a CSS snippet to make floating Banner, Title Bar and Place Bar in Application Layout control of Extension Library. You can get some ideas from that.
yes, it is possible, but requires some JavaScript coding.
I solved it for a customer recently using with the following code. The basic idea is to geht the width of the columns out of the first line of TDs, then apply this with to the THs ad set the THs to fixed afterwards.
You need to run this function after a partial update, too. Good luck.
var fixTableHeaders = function() {
var thead = dojo.query("thead")[0];
if (!thead) return;
thead.style.position = "static";
var THs = dojo.query('.xspDataTable th');
var firstTDs = dojo.query('.xspDataTable tr:first-child td');
var secondTDs = null;
if (firstTDs.length < 2) {
// categorized view, first line is a category with only one cell
// -> we need the second line
secondTDs = dojo.query('.xspDataTable tr:nth-child(2) td');
}
var w = 0;
for (var i = 0; i < THs.length; i++) {
w = dojo.coords(THs[i], true).w;
// console.log(i+" w="+w);
THs[i].style.width = (w)+"px";
if (firstTDs[i]) {
//if (secondTDs && secondTDs[i]) secondTDs[i].style.width = w+"px";
//else firstTDs[i].style.width = w+"px";
firstTDs[i].style.paddingTop = "3em";
}
}
thead.style.position = "fixed";
}
dojo.addOnLoad(fixTableHeaders);
I saw some jQuery code the other day that could make a Table Header fixed. Don't remember where it was but something that can help you should be out there.

Hide buttons on pagedown

I'm using pagedown on my website right now, and it's awesome so far, the only detail is
it's not a programming-oriented website, so I'd like to remove the 'code' button.
Is there a way I can do it? I tried using CSS to hide the buttons but the html has inline styles "left: xxx" which I can't change using CSS.
Thanks in advance!
If you open up Markdown.Editor.js, and scroll to approximately line 1360 (it varies depending upon which version you're using), you'll see an area with:
group1 = makeGroup(1);
buttons.bold = makeButton("wmd-bold-button", "Bold - Ctrl+B", "icon-bold", bindCommand("doBold"), group1);
buttons.italic = makeButton("wmd-italic-button", "Italic - Ctrl+I", "icon-italic", bindCommand("doItalic"), group1);
group2 = makeGroup(2);
buttons.link = makeButton("wmd-link-button", "Link - Ctrl+L", "icon-link", bindCommand(function (chunk, postProcessing) {
return this.doLinkOrImage(chunk, postProcessing, false);
}), group2);
buttons.quote = makeButton("wmd-quote-button", "Blockquote - Ctrl+Q", "icon-blockquote", bindCommand("doBlockquote"), group2);
buttons.code = makeButton("wmd-code-button", "Code Sample - Ctrl+K", "icon-code", bindCommand("doCode"), group2);
buttons.image = makeButton("wmd-image-button", "Image - Ctrl+G", "icon-picture", bindCommand(function (chunk, postProcessing) {
return this.doLinkOrImage(chunk, postProcessing, true);
}), group2);
So on and so forth. Simply quote out the buttons you don't want.
Alternatively, you can simply leave out the entire wmd-buttons div and only use the editor and preview components.
Search for doClick(buttons.code)in the code and comment it out
If you look at the makeButton function:
var makeButton = function (id, title, XShift, textOp) {
var button = document.createElement("li");
button.className = "wmd-button";
button.style.left = xPosition + "px";
xPosition += 25;
var buttonImage = document.createElement("span");
button.id = id + postfix;
button.appendChild(buttonImage);
button.title = title;
button.XShift = XShift;
if (textOp)
button.textOp = textOp;
setupButton(button, true); // <--- LOOK HERE
buttonRow.appendChild(button);
return button;
};
The true that is being passed in the call of the setupButton function is the isEnabled flag. What I did was just created another makeButton function and put it right under the first one. The only thing that I changed was that isEnabled flag to false. Then I changed to button.code = makeButton(...) to button.code = makeButton2(...).
buttons.code = makeButton2("wmd-code-button", getString("code"), "-80px", bindCommand("doCode"));

Titanium: Error trying to play a sound when tapping a row in a table?

I'm making a rather simple app that displays a table where each row contains an English word and the corresponding Polish word. When a row is pressed it should play a sound clip of the word expressed. However, I cannot make it work, even though I've tried to troubleshoot it with all that Google has to offer. Would appreciate if someone could point out the flaw...
var win = Titanium.UI.currentWindow;
var data =[];
var CustomData = [
{ file:'001', english:'Do you?', polish:'Czy masz?', fav:false },
{ file:'002', english:'How long?', polish:'Jak d?ugo?', fav:false },
{ file:'003', english:'Is it?', polish:'Czy?', fav:false },
];
var section = Ti.UI.createTableViewSection();
data.push(section);
for (var i=0; i<CustomData.length; i++) {
var row = Ti.UI.createTableViewRow({layout : 'vertical', height:'auto'});
var item = Ti.UI.createLabel({
color:'#000',
text:CustomData[i].english,
font:{fontSize:12, fontWeight:'bold'},
top:3,
left:10,
right:30,
height:'auto'
});
row.add(item);
var cost = Ti.UI.createLabel({
color:'#444',
text:CustomData[i].polish,
font:{fontSize:12},
top:0,
left:15,
right:30,
bottom:5,
height:'auto'
});
row.add(cost);
row.filter = CustomData[i].english;
section.add(row);
};
var tableview = Titanium.UI.createTableView({
data:data, search:search, searchHidden:false, filterAttribute: 'filter' });
win.add(tableview);
tableview.addEventListener('click', function(e)
{
var sound = Titanium.Media.createSound();
sound.url = '../sound/' + e.rowData.file + '.mp3';
sound.play();
if (e.rowData.test)
{
var win = Titanium.UI.createWindow({
url:e.rowData.test,
title:e.rowData.title
});
Titanium.UI.currentTab.open(win,{animated:true});
}
});
Just a shot in the dark, but are you sure you can set the URL after the sound object is created? Have you tried:
Titanium.Media.createSound({url:'../sound/' + e.rowData.file + '.mp3'});
Aside from that, are you sure the relative URL is evaluated from where you think? Maybe try it with an absolute URL just to be sure.

Resources