var self = require("sdk/self");
var toolbarbutton = require("toolbarbutton");
var toolbarbutton = toolbarbutton.ToolbarButton({
id: "annotator_toolbar_button",
label: "Web Annotator 2013",
image: self.data.url("stop.png"),
});
toolbarbutton.moveTo({
toolbarID: "nav-bar",
insertbefore: "home-button",
forceMove: false // only move once
});
toolbarbutton.image = self.data.url("start.png");// this command
I cannot change the image property of Erik Vold's toolbarbutton library for the Firefox addon sdk.
Any help would be appreciated.
You could use the library Toolbar Button Complete, which is my fork of toolbarbutton.js.
Using the library
You can use this library the same way as the original toolbarbutton.js, but it also has more options and features.
In your main.js file:
var self = require("sdk/self");
var toolbarbutton = require("toolbarbutton");
var button = toolbarbutton.ToolbarButton({
id: "annotator_toolbar_button",
label: "Web Annotator 2013",
image: self.data.url("stop.png"),
});
/* Only move button if installing for first time */
var forceMove = (self.loadReason === "install");
button.moveTo({
toolbarID: "nav-bar",
insertbefore: "home-button",
forceMove: forceMove
});
button.button().setAttribute( "image", self.data.url("start.png") );
You can find a working example of the library here. (Currently it is a little out of date, though.)
Installing the Library
If you are using the add-on SDK on your computer:
Download Toolbar Button Complete.
add it to your packages directory. (Either under your SDK directory or under your add-on's directory.)
If you are using the Add-on Builder to create your add-on:
Click the plus button next to your library folder:
Type in Toolbar Button Complete.
Click on the Add Library button:
Updating the Library
The library is hosted on github here.
If you are using the Add-on Builder for your add-on, you can simply click the little refresh button when there is an update available.
Related
I tried to search, but no luck for now. I integrated CKEditor 4.5.10 with uploadimage plugin (using Builder). I set the filebrowserUploadUrl and filebrowserBrowseUrl options when using CKEDITOR.replace.
No error (except the one stating I can't use local images that should be fixed when to image is uploaded and changed by the plugin).
I put a breakpoint as my first line in my upload PHP file, but I never get there. Yes, my debuging stuff is working perfectly as I can break using the Uploading tab in the image dialog.
I'm trying to copy/paste from Word an image with text using CTRL-C + CTRL-V.
What could I've missed ?
Code of initialization (I justed forked the imageuploader plugin to ameliorate it, so I have control over it) :
var superAdminPlugins = 'sourcearea,elementspath,forms';
var autoUploadPlugins = ''; //',uploadimage,uploadwidget'; // I already put them in VIA Builder
var toRemovePlugin = ',resize';
var toTestPlugin = ',base64image,ckeditortablecellsselection,autoembed,bgimage,backgrounds,pbckcode,tabletoolstoolbar';
alert(CKEDITOR.getUrl('') + 'plugins/imageuploader/imgupload.php');
ckEditor = CKEDITOR.replace(textareaId, {
language: wee.currentLanguage,
extraPlugins: 'allmedias,imageuploader' + autoUploadPlugins,
removePlugins: superAdminPlugins + toTestPlugin + toRemovePlugin,
toolbarCanCollapse: true,
scayt_sLang: scaytLanguageToUse,
youtube_width: 300,
youtube_height: 300,
filebrowserUploadUrl: CKEDITOR.getUrl('') + 'plugins/imageuploader/imgupload.php',
filebrowserBrowseUrl: CKEDITOR.getUrl('') + 'plugins/imageuploader/imgbrowser.php'
});
I discovered why it doesn't work. And indeed, it's normal, well kind of.
Copying an image from a picture editor creates an image using base64 encoding. So the image is included directly in the content thus accessible by the plugin.
Weirdly, copying only the image from MS Word does exactly the same thing, so it works! Yeah! But unfortunately, copying an image with text, the image is included as a link to a local file in a temporary folder. So, the content not being contained in the clipboard, the plugin can't use it.
I'll then try to create a Java software that will catch a clipboard change and adjust its content with base64 images instead. Hope I'll be able to do so! If yes, I'll post it somewhere.
EDIT :
Here is the Java software I made to support this :
https://github.com/djon2003/ClipboardImageToBase64
I'm making an android and ios app using kony and I want to be able to import an image from the phone's library (jpeg or png).
I have the function for my import button here:
this.control("btnImportPicture").onClick = function (button) {
// Insert solution here
};
The name of my image widget (which I want to set to the selected image) is imgUser
Problem is I have no idea what to do for my btnImportPicture button onClick function
Edit:
I have seen that you can use the following in the onClick function:
var config = {
selectMultipleFiles: false,
filter: ["image/png", "image/jpeg"]
};
kony.io.FileSystem.browse(config, selectedFileCallback);
But I have no idea what to do for the selectedFileCallback, currently it just crashes everytime I click the button.
I got an answer on the kony forums and thought I better share it here in-case anyone else runs into this issue.
kony.io.FileSystem.browse API is applicable for only Desktopweb Platform. it will not work in Mobile richclient applications.
we can use "kony.phone.openMediaGallery" API. The main usecase of this API is to open the gallery of the phone and to pick any image. Once we select any image then onselectioncallback function will trigger with image rawBytes as input parameter . we can use this rawBytes in our Application either to display image on the image Widget or for other usecases
Please refer below documentation link.
http://docs.kony.com/konylibrary/studio/kony_studio_api_reference_guide/Default.htm#phone.htm#phone.op
Put this in your onClick:
function openGallery()
{
var querycontext = {mimetype:"image/*"};
var returnStatus = kony.phone.openMediaGallery(onselectioncallback, querycontext);
}
function onselectioncallback(rawbytes)
{
if (rawbytes == null)
{
alert("Please select an Image");
return;
}
frmone.image26850851102837.rawBytes=rawbytes;
}
Note : we can select only one image at a time.
I'm upgrading TinyMCE on one of my websites and am trying to add a custom item to the contextmenu plugin. I can't seem to be able to find any documentation for it since all I can find is for v3.
I was easily able to add a custom link to the contextmenu in the last version but because TinyMCE has changed so much I'm having a hard time adding the new one. Can anyone point me to the correct documentation?
I used to use the following in the last version:
ed.addCommand('fileMan', function(e) {
fileman();
hide(ed, e);
});
m.add({title : 'Filemanager', icon : 'image', cmd : 'fileMan'});
I was able to figure this out. Here is what I did:
Created a new folder in the plugin directory called fileman
Created a file named plugin.js and added the code at the end of this post to it
Minifed the code and put the minified code in plugin.min.js
Edited plugin.min.js in the contextmenu plugin folder and added fileman to the list of loaded plugins
Added fileman to the list of loaded plugins when initializing the editor
Code:
tinymce.PluginManager.add('fileman', function(editor) {
editor.addMenuItem('fileman', {
icon: 'image',
text: 'Filemanager',
shortcut: 'Ctrl+J',
onclick: function() {
fileman.launch('editor');
},
context: 'insert',
prependToContext: true
});
});
This is somewhat tricky solution but the perfect one, worked for me after trying lot of things.
editor.on('contextmenu', function(editor) {
this.settings.contextmenu = 'fileman | link openlink image inserttable | cell row column deletetable';
var exampleMenuItem = this.menuItems['italic'];
this.menuItems['fileman'] = exampleMenuItem;
this.menuItems['fileman'].cmd = 'mceFileMan';
this.menuItems['fileman'].icon = '../../file-icon.png';
this.menuItems['fileman'].text = 'File Manager';
});
I found this image gallery http://coffeescripter.com/code/ad-gallery/ but I am having trouble.
the loader.gif image is not showing up at all in IE9 just a red x. I am a newbie to javascript, this is at the top of the javascript file
(function($) {
$.fn.adGallery = function(options) {
var defaults = { loader_image: 'loader.gif',
the image is in the same directory as this javascript file so the path is ok.. also there is no mention of this loader.gif in the css file at all.
this is the my site, www.kayleighwhite.org/black_white.html
Usually the file doesn't exist in the location the link is pointing to
loader_image: 'loader.gif' means it is looking for the file in the top level of the site. So www.kayleighwhite.org/loader.gif.
There is also an error looking for the file at http://www.kayleighwhite.org/img/loader.gif
Use Google Chrome. Right click > inspect element, have a look around
the path ok?
have you ever tried chrome developer tools?
here's the screenshoot
as you can see there are some 404 status
open jquery.ad-gallery.js and add the absolute path of the loader.gif file. Eg:
var defaults = { loader_image: 'http://your_domain.com/ad_gallery/lib/loader.gif',
Instead of hacking the jquery.ad-gallery.js, specify the image location under options:
(function($) {
$.fn.adGallery = function(options) {
var defaults = { loader_image: 'location/to/the/image/loader.gif',
I'm using plupload to client scaling of pictures before they are uploaded. I like the feature that it gracefully falls back to html4 if the user doesn't have flash, silverlight etc engines installed.
I want to be able to start the upload when the user clicks certain elements on the page and i want to handle the events (sometimes stopping a file dialog from opening). In fact i'd like to pop open the file dialog using javascript.
Ok, so HTML4 (or rather the browser, except chrome :P) won't let me do this, unless the user clicks a browse-button (or an overlay covering a browse-button), so when i get the fallback to HTML4 i'll accept that i can't do it, but most users will have flash or silverlight installed and they do not have this restriction. So my question is this:
How do i trigger the file open dialog in plupload (keeping in mind i only need the flash and silverlight engines to do this).
The former solutions not worked on iPhones with plupload 2.1.2.
The following code did the trick (jquery needed):
$("#id_of_the_second_button").click(function() {
$('div.moxie-shim input[type=file]').trigger('click');
});
Fallback runtimes will become irrelevant as times goes by. This means that sooner or later, we'll be all using HTML5 runtime. In case that you are using HTML5 runtime, but don't use pluploadQueue(), this will work as well:
// Set up and initialise uploader
var uploader = new plupload.Uploader({
'runtimes' : 'html5',
'browse_button' : 'id_of_the_first_button'
// Other options
});
uploader.init();
// Hook in the second button
plupload.addEvent(document.getElementById('id_of_the_second_button'), 'click', function(e) {
var input = document.getElementById(uploader.id + '_html5');
if (input && !input.disabled) {
input.click();
} // if
e.preventDefault();
});
If someone is searching for the HTML5 solution, here it is:
var up= $('#uploader').pluploadQueue();
if (up.features.triggerDialog) {
plupload.addEvent(document.getElementById('idOtherButton'), 'click', function(e) {
var input = document.getElementById(up.id + '_html5');
if (input && !input.disabled) { // for some reason FF (up to 8.0.1 so far) lets to click disabled input[type=file]
input.click();
}
e.preventDefault();
});
}
Ok. It doesn't seem possible to do this, so unless someone implements event handles for the silverlight and flash components i'm out of luck
I read your problem.
I found some articles that may help to figure this out. check them. It may help...!
01. https://stackoverflow.com/questions/210643/in-javascript-can-i-make-a-click-event-fire-programmatically-for-a-file-input-e
02. https://stackoverflow.com/questions/2048026/open-file-dialog-box-in-javascript
#Per Hornshøj-Schierbeck
After uploader has been init. It take few time to render input file to select. So you need to wait like below:
this.uploader.init();
var task = new Ext.util.DelayedTask(function () {
var inputArray = $('div.moxie-shim input[type=file]');
var input = inputArray.length > 1 ? inputArray[inputArray.length - 1] :
inputArray[0];
$(input).trigger('click');
});
task.delay(100);
The code in javascript is similar. Worked for me with plupload 2.3.6
Hop this help!