Hide TabGroup / TabBar - android-tabs

I've tried multiple methods to hide this tab:
Following are the methods I've used:
tabGroup.hide()
tabBar.hide()
tabGroupHidden: true
tabBarHidden: true
tabGroup.setNavBarHidden()
tabGroup.NAVIGATION_METHOD_STANDARD
visible: false
mainWindow.tabGroup = hidden
And this is the current code as it sits now:
var mainWindow = Titanium.UI.createWindow({
title:'Title',
layout:'vertical',
backgroundColor:'#fff',
tabGroupHidden:true
});
mainWindow.add(Helpers.buildNavTableView(mainNavItems));
// Tab Group
var tabGroup = Titanium.UI.createTabGroup({
tabGroupHidden:true
});
var tab1 = Titanium.UI.createTab({
title:'Tab 1',
tabGroupHidden:true,
window:mainWindow
});
tabGroup.addTab(tab1);
// open tab group
tabGroup.hide();
tabGroup.open();

Just create a simple window and open it
var win=Ti.UI.createWindow()
win.open();
Thanks

We can Hide TabGroup / TabBar then write below code
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(actionBar.NAVIGATION_MODE_STANDARD);

Related

TabView does not update UI when property "items" gets changed

In my project I make a TabView programmatically and expect it to update its TabViewItem (changing title for example) whenever I set myTabView.items = newArray. Unfortunately, it doesn't work like that. Any help will be greatly appreciated.
Here are my code when I generate the TabView:
function initTabview(tabList: Array<string>) {
let items = [];
let myTabView = page.getViewById("myTabView");
for (let i in tabList) {
let stackLayout = new StackLayout();
let tabEntry = {
title: tabList[i],
view: stackLayout
};
items.push(tabEntry);
}
myTabView.items = items;
myTabView.on(TabView.selectedIndexChangedEvent, (data: SelectedIndexChangedEventData) => {
// Some code here
});
}
Thank you very much.

Ckeditor plugin : how to unwrap text?

I have created a ckeditor plugin that wraps the selected text into a span.
I wonder how can I unwrap the selected when I apply this plugin on a text that has been previously wrapped into the span.
CKEDITOR.plugins.add('important', {
// Register the icons. They must match command names.
//trick to get a 16*16 icon : http://www.favicomatic.com
icons: 'important',
init: function (editor) {
editor.addCommand('important', {
// Define the function that will be fired when the command is executed.
exec: function (editor) {
var selected_text = editor.getSelection().getSelectedText();
console.log(editor.getSelection()) ;
var newElement = new CKEDITOR.dom.element("span");
newElement.setAttributes({class: 'important'});
newElement.setText(selected_text);
editor.insertElement(newElement);
//how to unwrap the selected text ?
});
// Create the toolbar button that executes the above command.
editor.ui.addButton('important', {
label: 'Set this as important',
command: 'important',
toolbar: 'insert'
});
}
});
Finally, using editor.getSelection().getStartElement(), I can check if the starting element has already been wrapped with the class and remove it if necessary.
CKEDITOR.plugins.add('important', {
//trick to get a 16*16 icon : http://www.favicomatic.com
icons: 'important',
init: function (editor) {
var className = 'important';
editor.addCommand('important', {
// Define the function that will be fired when the command is executed.
exec: function (editor) {
var editorSelection = editor.getSelection();
var selected_text = editorSelection.getSelectedText();
var startElement = editorSelection.getStartElement();
//if the element has already been wrapped, let's UNwrap it
if (className === startElement.$.className) {
var html = startElement.$.innerHTML;
editor.getSelection().getStartElement().remove();
editor.insertHtml(html);
} else {
//if the element has NOT already been wrapped, let's wrap it
var newElement = new CKEDITOR.dom.element("span");
newElement.setAttributes({class: 'important'});
newElement.setText(selected_text);
editor.insertElement(newElement);
}
}
});
// Create the toolbar button that executes the above command.
editor.ui.addButton('important', {
label: 'Set this as important',
command: 'important',
toolbar: 'insert'
});
}
});

how make an addon/extension add an icon/button to the Firefox address bar if the tab is open in a certain domain?

I need to make a Firefox addon add a button to the address bar if the tab is in a certain domain.
I've managed to find the element navbar-icons for the current window and add a child, but that add the icon to all tabs for that window, instead of just the relevant tab. How can I do this?
EDIT:
Sorry i was on mobile and didn't include the code.
What i have so far:
var windowsUtils = require('sdk/window/utils');
var loadButton = function(doc, urlBtnClick) {
var urlBarIcons = doc.getElementById('urlbar-icons');
var btn = doc.createElement('toolbarbutton');
btn.setAttribute('id', 'button-icon');
btn.setAttribute('image', self.data.url('./images/icon16.png'));
btn.click(onButtonClick);
urlBarIcons.appendChild(btn);
return btn;
}
var onButtonClick = function(event) {
console.log('i was clicked');
}
whenever i call the above i add a icon/button to every tab instead of the current active one.
This is a hacky implementation just using the SDK's tabs and button apis:
let { ActionButton } = require("sdk/ui/button/action");
let tabs = require('sdk/tabs');
let soButton;
tabs.on('activate', (tab) => {
if (/^http[s]*\:\/\/stackoverflow.com/.test(tab.url)) {
soButton = ActionButton({
id: "so-button",
label: "This is StackOverflow!!",
icon: {
"16": "chrome://mozapps/skin/extensions/extensionGeneric.png",
"32": "chrome://mozapps/skin/extensions/extensionGeneric.png"
},
onClick: function(state) {
console.log("clicked");
}
});
} else {
if (soButton && typeof (soButton.destroy === 'Function')) {
soButton.destroy();
}
}
});
It feels klugey to create / destroy the button every time we switch tabs, but the user experience is exactly what you want. A similar and perhaps 'better supported' approach might be instead to just disable the button.

Why am I Getting error on panel's content script of Firefox Addon SDK?

Getting the following error, even after making the script empty I go this error.
console.error: my-addon:
Message: SyntaxError: expected expression, got end of script
Panel code of my addon:
var { ToggleButton } = require('sdk/ui/button/toggle');
var panels = require("sdk/panel");
var self = require("sdk/self");
var ss = require("sdk/simple-storage");
var button = ToggleButton({
id: "my-addon",
label: "My Addon",
icon: {
"16": "./img/16-16.png",
"32": "./img/32-32.png",
"64": "./img/64-64.png"
},
onChange: handleChange
});
var panel = panels.Panel({
contentURL: self.data.url("popup.html"),
contentScript: self.data.url("js/pop_listener.js"),
onHide: handleHide,
width: 300,
height: 550
});
Use contentScriptFile instead of contentScript

Photoshop UI Radio buttons in javascript

Having problems implementing radio buttons. I know radio buttons in CS2 can be problematic but I'm not sure where I am going wrong. I suspect I have a bracket or comma in the wrong place; but can't see it. Thank you.
var dlg =
"dialog {text:'Script Interface',bounds:[100,100,300,260]," +
"info: Group { orientation: 'column', alignChildren: 'center'," +
"radiobutton0:RadioButton {bounds:[50,30,150,40] , text:'layerName0', alignment: 'left' }," +
"radiobutton1:RadioButton {bounds:[50,50,150,90] , text:'layerName1', alignment: 'left' }}" +
"cancelBTN:Button{bounds:[110,130,190,150] , text:'Cancel' },"+
"processBTN:Button{bounds:[10,130,90,150] , text:'Ok' }}";
var win = new Window(dlg,"radio buttons");
win.radiobutton0.value = true;
win.center();
win.show();
Another thing: Is there a better way of writing UI elements as this format is rather ugly.
Here's the bare bones code that works.
var dialogBox =
"dialog { orientation: 'column', alignChildren: 'center', \
info: Group { orientation: 'column', alignChildren: 'center', \
rbtn1: RadioButton { text: 'Radio Button 1', align: 'left'}, \
rbtn2: RadioButton { text: 'Radio Button 2', align: 'left'}, }, }, \
} }";
win = new Window (dialogBox);
win.center();
win.show();
I think the radio button toggle is controlled by line 3 as commenting it out stops the radio buttons working correctly.
When I ran the code it threw an error on this line win.radiobutton0.value = true; Object is undefined. This is because the way you have the dialog structured the button is part of the info group within the window. The line should read
win.info.radiobutton0.value = true;
This should toggle radiobutton0 on initially.
You don't have to use a resource string to craft the dialogs if you don't want. Individual elements can be added by creating a reference to the window object (or to a pallate or panel) and using .add()
For example:
var w = new Window ("dialog");
w.alignChildren = "left";
var radio1 = w.add ("radiobutton", undefined, "Radio Button 1");
var radio2 = w.add ("radiobutton", undefined, "Radio Button 2");
radio1.value = true;
w.show ();
This is the most thorough reference on ScriptUI that I've found.
Here's a nicer additive version of a dialogue box with radio buttons working as I want them to.
var w = new Window ("dialog");
w.alignChildren = "left";
var myButtonGroup = w.add ("group");
myButtonGroup.orientation = "column";
myButtonGroup.alignment = "left";
var radio1 = myButtonGroup.add ("radiobutton", undefined, "Radio Button 1");
var radio2 = myButtonGroup.add ("radiobutton", undefined, "Radio Button 2");
myButtonGroup.add ("button", undefined, "OK");
myButtonGroup.add ("button", undefined, "Cancel");
radio1.value = true;
w.center();
// w.show ();
if (w.show() == 1)
{
alert("You picked " + youSelected(myButtonGroup))
}
function youSelected(rButtons)
{
if (radio1.value == true)
// radio1 selected
return radio1.text
else
// radio2 selected
return radio2.text
}

Resources