Placing Toolbar Button in Specific Position by Firefox Add-on SDK - firefox

I can add a Toolbar Button by this code
var { ActionButton } = require("sdk/ui/button/action");
var button = ActionButton({
id: "addon-button",
label: "Addon",
icon: {
"16": "./icon-16.png",
"32": "./icon-32.png"
},
onClick: function(state) {
//foo
}
})
But the button is placed at the end of toolbar.
How can I add the button next to Home button? Is it possible to set a specific position for Add-on SDK buttons?

Related

Xamarin.Forms: ScrollView not scrolling on Windows 10 Mobile

This code is working fine on iOS and Android, but not on a Windows 10 Mobile device (Microsoft Lumia 650, Version: 1511, Build: 10.0.10586.11):
public App()
{
var layout = new StackLayout
{
Orientation = StackOrientation.Vertical,
Padding = 0,
Children =
{
new Button { Text = "A" },
new Button { Text = "B" },
new Button { Text = "C" },
new Button { Text = "D" },
new Button { Text = "E" },
new Button { Text = "F" },
new Button { Text = "G" },
new Button { Text = "H" },
new Button { Text = "I" },
new Button { Text = "J" },
new Button { Text = "K" },
new Button { Text = "L" },
new Button { Text = "M" },
new Button { Text = "N" },
new Button { Text = "O" },
new Button { Text = "P" },
new Button { Text = "Q" },
new Button { Text = "R" },
new Button { Text = "S" },
new Button { Text = "T" },
new Button { Text = "U" },
new Button { Text = "V" },
new Button { Text = "W" },
new Button { Text = "X" },
new Button { Text = "Y" },
new Button { Text = "Z" },
},
};
var scrollView = new ScrollView { Content = layout };
// The root page of your application
MainPage = new ContentPage
{
Content = scrollView,
};
}
The scroll view is not scrolling at all. I can see the scrollbar, but it doesn't scroll. I tried to play with HorizontalOptions/VerticalOptions, but that didn't helped either. In the simulator it does work by scrolling with the mouse. The same problem also occurs with Label.
What is wrong here?
Has been fixed in Xamarin Forms 2.1.0.

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.

CKEditor: Button is not appearing

I want to add a button in toolbar of CKEditor but button is not appearing.This is code for creation of plugin saved in _source/plugins/footnote/
CKEDITOR.plugins.add('footnote',
{
init: function(editor)
{
var pluginName = 'footnote';
CKEDITOR.dialog.add(pluginName, this.path + 'dialogs/footnote.js');
editor.addCommand(pluginName, new CKEDITOR.dialogCommand(pluginName));
editor.ui.addButton('Footnote',
{
label: 'Footnote or Citation',
command: pluginName
});
}
});
And this is code of config.js
CKEDITOR.editorConfig = function( config )
{
config.toolbar = 'MyToolbar';
config.extraPlugins = 'footnote';
config.toolbar_MyToolbar =
[
['Bold','Footnote','Italic']
];
};
Just bold and italic are appearing in toolbar.But footnote button is not appearing.
Thanks for your help.
You are not providing an icon:
CKEDITOR.plugins.add('footnote',
{
icons: 'myfootnote',
init: function (editor) {
var pluginName = 'footnote';
CKEDITOR.dialog.add(pluginName, this.path + 'dialogs/footnote.js');
editor.addCommand(pluginName, new CKEDITOR.dialogCommand(pluginName));
editor.ui.addButton('Footnote',
{
label: 'Footnote or Citation',
icon: 'myfootnote',
command: pluginName
});
}
});
Be sure to create an icon at /plugins/footnote/icons/myfootnote.png.
Only PNGs are accepted.
The button must have the same name (case sensitive).
Thus replace editor.ui.addButton('Footnote', by editor.ui.addButton('footnote',

Replace the image plugin in CKeditor

I want to override the image plugin in CKeditor. When I right click on an image I want to open my own dialog. Can anyone point me in the right direction. I've done a basic plugin which I copied from the CKeditor site - How do I swap this to replace the image editor.
CKEDITOR.plugins.add('myplugin',
{
init: function (editor) {
editor.addCommand('mydialog', new CKEDITOR.dialogCommand('mydialog'));
if (editor.contextMenu) {
editor.addMenuGroup('mygroup', 10);
editor.addMenuItem('My Dialog',
{
label: 'Open dialog',
command: 'mydialog',
group: 'mygroup'
});
editor.contextMenu.addListener(function (element) {
return { 'My Dialog': CKEDITOR.TRISTATE_OFF };
});
}
CKEDITOR.dialog.add('mydialog', function (api) {
// CKEDITOR.dialog.definition
var dialogDefinition =
{
title: 'Sample dialog',
minWidth: 390,
minHeight: 130,
contents: [
{
id: 'tab1',
label: 'Label',
title: 'Title',
expand: true,
padding: 0,
elements:
[
{
type: 'html',
html: '<p>This is some sample HTML content.</p>'
},
{
type: 'textarea',
id: 'textareaId',
rows: 4,
cols: 40
}
]
}
],
buttons: [CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton],
onOk: function () {
// "this" is now a CKEDITOR.dialog object.
// Accessing dialog elements:
var textareaObj = this.getContentElement('tab1', 'textareaId');
alert("You have entered: " + textareaObj.getValue());
}
};
return dialogDefinition;
});
}
});
Hi the reason I wanted to do this was that we have our image editor control which for "usability" reasons we need to carry on using. It gets used in different bits of the site and two dialogs would confuse people. In summary what I did was
Remove the image plugin CKEDITOR.config.removePlugins = 'image, forms, div,flash,iframe,table';
Add extra plugins extraPlugins: 'tinsertimage,teditimage,teditlink,tinsertlink,teditimagelink' on creating the CKEditor
In the plugin run some JS which intercept the right click on the image
CKEDITOR.plugins.add('teditimage',
{
init: function (editor) {
editor.addCommand('tEditImage',
{
exec: function (editor) {
//This opens the custom editor
ZWSInlineEditor.openImageProperties(editor, false);
}
});
if (editor.addMenuItem) {
// A group menu is required
// order, as second parameter, is not required
editor.addMenuGroup('gImage');
// Create a manu item
editor.addMenuItem('gEditImageItem', {
label: 'Edit Image Properties',
command: 'tEditImage',
group: 'gImage'
});
}
if (editor.contextMenu) {
editor.contextMenu.addListener(function (element, selection) {
// Get elements parent, strong parent first
var parents = element.getParents("img");
// Check if it's strong
if (parents[0].getName() != "img")
return null; // No item
return { gEditImageItem: CKEDITOR.TRISTATE_ON };
});
}
}
});
I don't understand what's the point in what you're doing (or please explain us). Maybe you should rather customize dialogs than do things from scratch?

Sencha Touch, dock panel inside Nested List

I have a Sencha Touch app that has a nested list.
The nestedList automatically creates its own toolBar.
I would like to dock a panel below the toolbar, but above the list-items. And I only need this on the top-level of the list. I am hoping to have it disappear after the first leaf is selected.
Does this sound like something doable? As you can see in my code, I only have the ability to dock an item panel on top of the current toolbar.
Thanks so much in advance. I really appreciate any advice you guys might have.
Al.
Below is what I have so far...
// Menu Pages
var menu = new Ext.NestedList({
fullscreen: true,
title: 'Menu',
displayField: 'text',
store: menu_store,
// ** This is the dockedItem I would like to insert between the toolbar and list-items
dockedItems: [ {
xtype : 'panel',
dock : 'top',
html : '<span>This is the logo panel</span>',
cls : 'front-logo-panel',
flex : 1
}],
// Add Panel for Leaf nodes
getDetailCard: function(item, parent) {
var itemData = item.attributes.record.data,
parentData = parent.attributes.record.data,
detailCard = new Ext.Panel({
scroll: 'vertical',
cls: 'menu-item-panel',
styleHtmlContent : true,
tpl: menuTemplate,
// add button to Leaf Node
listeners: {
activate: function() {
Ext.getCmp('itemToolbar').setTitle('New Title Bar');
}
}
});
detailCard.update(itemData);
this.backButton.setText(parentData.text);
return detailCard;
},
// add template for all nodes
getItemTextTpl: function() {
var tplConstructor =
'<tpl if="newItem">' +
'<span class="list-new-item">New Item!</span>' +
'</tpl>'+
'{text}' +
'<tpl>'+
'<div class="metadata">' +
'{description:ellipsis(40)}' +
'</div>' +
'</tpl>';
return tplConstructor;
}
});
Old question, I know, but to solve this, you can remove the toolbar from the list (without destroying it) and add it to a panel above the list. All nestedList functionality stays the same on the toolbar. Here's the solution I have:
First, I created a view that extends from NestedList and contains a toolbar:
Ext.define('MyApp.view.DynamicList', {
extend: 'Ext.dataview.NestedList',
alias: 'widget.dynamiclist',
config: {
toolbar: {
xtype: 'toolbar',
docked: 'top',
itemId: 'header-bar',
layout: {
pack: 'end',
type: 'hbox'
},
items: [
{
xtype: 'spacer'
},
{
xtype: 'button',
itemId: 'show-nav-sheet-button',
ui: 'plain',
width: 45,
iconCls: 'more'
}
]
}
}
});
Next, I created a main panel with a vbox layout that contains a child panel and this toolbar:
Ext.define('MyApp.view.MainContainer', {
extend: 'Ext.Container',
requires: [
'MyApp.view.DynamicList'
],
config: {
id: 'main-container',
layout: {
type: 'vbox'
},
items: [
{
xtype: 'panel',
flex: 1,
itemId: 'info-container'
},
{
xtype: 'dynamiclist',
flex: 1
}
]
}
});
Then, in a controller, I listen for the initialize event of the nested list. When it's fired, I remove the toolbar from the nested list and add it to the panel.
onNestedListInitialize: function() {
// need to wait until everythin is initialized;
var me = this;
var renderFn = function renderPanels() {
var main = me.getMainContainer();
// wait until main is intialized;
if(!main) {
Ext.defer(renderFn, 50, this);
return;
}
var list = main.down('#my-list');
var infocont = main.down('#info-container');
// wait until the container's components are initialized
if(!list || !infocont) {
Ext.defer(renderFn, 50, this);
return;
}
// remove the toolbar from the list, and add it to the container.
var toolbar = list.down('#header-bar');
list.remove(toolbar, false);
infocont.add(toolbar);
}
// call the function for the first time.
renderFn();
}
Note, I had to add a few checks to make sure the components were correctly initialized before using them, but the heart of it comes to the list.remove(toolbar, false) followed by the infocont.add(toolbar) commands. The false flag in the .remove() method means that the item won't be destroyed, so it's available to be re-added to the panel.

Resources