How to create a tabpanel (xul) in Javascript - firefox

i dev a Firefox extension and i try to add a tabpanel in a tabbox (xul).
The tabbox:
<tabbox id="tbDashboard" selectedIndex="0" >
<tabs><!-- list of tabs -->
<tab label="Overview"/> <!-- default tab -->
<tab label="test"/>
</tabs>
<tabpanels><!-- list of contents -->
<tabpanel ><!-- default tab's content -->
<box orient="horizontal" flex="1">
<description style="font-size: 24pt;">overview</description>
</box>
</tabpanel>
<tabpanel ><!-- test tab's content -->
<box orient="horizontal" flex="1">
<description style="font-size: 24pt;">test</description>
</box>
</tabpanel>
</tabpanel>
</tabpanels>
</tabbox>
I can add a new tab in JS with:
document.getElementById("tbDashboard")["tabs"].appendItem("popo");
The tab is appears but the tab page is empty, i tried to:
use appendItem with a second parameter => don't work
document.getElementById("tbDashboard")["tabpanels"].appendItem(...) => fail
Someone have an idea to create the tab page (a tabpanel) ??
thx

tabs.appendItem() is merely a convenient helper to create a tab element. It is essentially the same as:
var tabbox = document.getElementById("tbDashboard");
var tab = document.createElement("tab");
tab.textContent = "popo";
tabbox.tabs.appendChild(tab);
You can create and add a tabpanel element in the same way (here with a text box as only contents):
var panel = document.createElement("tabpanel");
panel.appendChild(document.createElement("textbox"));
tabbox.tabpanels.appendChild(panel);
For a tutorial on DOM manipulation see https://developer.mozilla.org/en/XUL_Tutorial/Modifying_a_XUL_Interface.

You'll need to create the panel using the DOM API and then append it to your XUL document, e.g.:
let newPanel = document.createElement("tabpanel");
let panelContent = document.createElement("hbox");
// Add more content here
newPanel.appendChild(panelContent);
document.getElementById("tbDashboard").tabPanels.appendChild(newPanel);

Related

Svelte Native ListView - Horizontal

I try out and build my first App on Svelte Native. I develop this for an Tablet.
The standard ListView only supports vertical stacking.
I need this for horizontal.
This part only works for vertical:
<listView items="{listOfItems}" on:itemTap="{onItemTap}">
<Template let:item>
<!-- Shows the list item label in the default color and style. -->
<label text="{item}" />
</Template>
</listView>
<script>
import { Template } from 'svelte-native/components'
let listOfItems = ['one', 'two', 'three']
</script>
I also try this:
Here i have the Problem that nothing is showing.
{#each one as ones}
<button on:tap={addToList(ones)} text="{ones.name}" class="prod-btn" />
{/each}
So i need help to show a list of objects in an horizontal view.

how to set a backgroundColor from a js in appcelerator Titanium Alloy MVC

I have a small Question about setting Tab Names Dynamically.
I am Thinking to create an options.js and I want my tab names to gather data from options.js
<Alloy>
<TabGroup>
<Tab title="Tab 1" icon="KS_nav_ui.png">
<Window class="tab1" title="Tab 1">
<Label>I am Window 1</Label>
<Button class="exampleBut">Button </Button>
</Window>
</Tab>
</TabGroup>
</Alloy>
I would like to set Tab 1 Title from another JS file.
How to solve it ?
Regards
You have to identify the tab by a unique id
<Tab title="Tab 1" id='tab1' icon="KS_nav_ui.png">
in the same js file for exemple index.js (the tab is defined in index.xml) you can use :
$.tab1.title="my title"
if you would set title from another js file you can use application events:
in index file you define an application event listener :
Ti.App.addEventListener("app:changeTabTitlle",function(e){
$.tab1.title=e.title;
});
and from the other js file you have to send the tab title using fireEvent:
Ti.App.fireEvent("app:changeTabTitlle",{title:"My tab title"});

Insert text into text area of Joomla editor

i can't insert text into text area of JFactory::getEditor().
$("textarea").val('some text');
can't update text area in my dom.
If i use a default <textarea> it work fine.
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_categories/models/fields" >
<field
type="editor"
name="myEditorField"
id="myEditorField"
label="MY EDITOR FIELD LABEL"
description="MY EDITOR FIELD DESCRIPTION"
width= "99%"
rows="5"
editor="desired|alternative"
cols="200"
buttons="true"/>
<field name="articletext" type="editor" class="inputbox"
label="COM_CONTENT_FIELD_ARTICLETEXT_LABEL" description="COM_CONTENT_FIELD_ARTICLETEXT_DESC"
filter="JComponentHelper::filterText" buttons="true" />
</fieldset>
</form>
save above code in editor.xml and use following php code to display editor
<?php
$mypath= JPATH_COMPONENT.'/views/' .'createTask'. '/tmpl/editor.xml';
$form = JForm::getInstance('myform',$mypath );
echo $form->getInput('myEditorField');
?>
follwoing code will echo javascript to set editor content
$editor =JFactory::getEditor();
$setContent=$editor->setContent($name,'hello');
$js1 = 'function setEditorText (){return '.$setContent.'}';
$doc= JFactory::getDocument();
$doc->addScriptDeclaration($js1);
for details click here
.
.
.
.
Other way to get and set content in JOOMLA editor is use following js.
Wrap your editor in div having class .myPreviewEditor
to set content
$('.myPreviewEditor iframe').contents().find('body').html("i am in editor");
to get content
$editoContent=$('.myPreviewEditor iframe').contents().find('body').html();
but make sure that these statement execute after JOOMLA editor loads itself

Creating panel in firefox

in my xul file:
<!DOCTYPE overlay >
<overlay id="custombutton-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="browserOverlay.js"/>
<!-- Firefox -->
<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton id="custom-button-1"/>
</toolbarpalette>
<!-- button details -->
<toolbarbutton id="custom-button-1"
label="Custom"
tooltiptext="My custom toolbar button"
oncommand="xyz.showPanel()"
class="toolbarbutton-1 chromeclass-toolbar-additional custombutton"
/>
<panel id="thepanel">
<hbox align="start">
<image src="warning.png"/>
<vbox>
<description value="You have 6 new messages."/>
<hbox>
<button label="Read Mail"/>
<button label="New Message"/>
</hbox>
</vbox>
</hbox>
</panel>
</overlay>
when calling the function "xyz.showPanel()" which has the following code:
var xyz = {
showPanel: function (e)
{
var button = document.getElementById('custom-button-1');
var panel = document.getElementById('thepanel');
panel.openPopup(button, 'after_start', 0, 0, false, false);
}
}
it gives me error in the error console that says:
Error: TypeError: panel is null
I want to show a panel like "Downloads" toolbar button in Firefox
I am new to Firefox addons,
so how to show a panel when clicking on toolbar button ??
In overlays, the first level of nested elements must refer to something already in the DOM (the element stuff will be added to), or else these elements will be ignored. (Some exceptions to that rule, like <script>.)
Your panel definition basically says (contrary to what you want it to say)
Find an existing panel with id "thepanel"
If found, add a hbox and its children to the panel
If not, ignore the subtree.
You need to change your XUL to provide a container for your panel, e.g. #mainPopupSet, like you did with #BrowserToolbarPalette for your toolbarbutton.
<overlay ...>
...
<popupset id="mainPopupSet">
<panel id="thepanel">
...
</panel>
</popupset>
</overlay>

How make .swf file is as link?

I use .swf file in may site:
<div>
<object width="100%" height="100%">
<embed src="#Url.Content( "~/Content/TopRight.swf" )" type="application/x-shockwave-flash" width="310" height="95"></embed>
</object>
</div>
And I want when click this banner, opens any link (any page). I placed <object> into <a> tag, but nothings changed. How can I do this?
put this at the end of your code:
import flash.display.MovieClip;
var hit = new MovieClip();
hit.graphics.beginFill(0xFFFFFF);
hit.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
var clicky = new SimpleButton(null,null,null,hit);
this.addChild(clicky);
clicky.addEventListener(MouseEvent.CLICK, function(){
navigateToURL(new URLRequest("http://google.com"));
});
should work :)

Resources