The Office.context.officeTheme property is undefined - outlook-addin

The property Office.context.officeTheme is undefined when used in the Outlook application: Official documentation. In Word, Excel and PowerPoint, the property is defined and I can access its children properties (bodyBackgroundColor, controlForegroundColor, etc...). I tried with both latest (1.1.0.13) and previous (1.1.0.12) versions of Office.JS but it doesn't work. My outlook version is: 1711 (Build 8730.2127) and I also tried in the latest insiders build. Sample code:
Office.initialize = function (reason) {
$(document).ready(function () {
// The "Office" object and its "context" property are valid but the "officeTheme" property is undefined.
// This works in Word, Excel and PowerPoint but not in Outlook.
if (!Office.context.officeTheme) {
console.log("Office theme not loaded");
}
});
}

Per information received from the product team, Outlook does not currently support the office.context.officeTheme property. Thanks for pointing out this problem with the docs (and for logging the corresponding GitHub issue as well). We'll update the docs to reflect that Outlook does not currently support this property.

Related

Is it possible to assign editor styles to API tokens?

If I define my own API and I want to highlight values, classes and methods of my API in editor. How I can do it? Is it possible to assign some of keyword styles to api tokens?
Here is my instead.lua in api folder of ZBS:
return {
instead = {
type = "lib",
description = "Библиотека INSTEAD",
childs = {
tiny = {
type = "value",
description = "Флаг «минималистичного INSTEAD», без графики и множества других возможностей."
}
}
},
}
And this is some code snippet:
if not instead.tiny then
require "autotheme"
end
So I want instead and tiny to be highlighted in my code.
You can use keyword highlighting, but while it works for "instead" and "tiny", it will also have to be set for "instead.tiny", which is not ideal (this looks like a limitation in the version of the Scintilla editor component used by the IDE); see this ticket for a related discussion and explanation. You may also check a proposed highlight property plugin that does something similar (although for all properties).

The Office.context.mailbox.item.conversationId in Outlook add-in returns undefined

I tried to use conversationId in the Outlook add-in, but I am getting undefined. In the documentation it was given that I would not get the id for a new message but I tried to retrieve the id from an existing thread but was returning undefined. Any idea why the Id is undefined
Office.initialize = function (reason) {
$(document).ready(function () {
var conversationId = Office.context.mailbox.item.conversationId;
});
}
EDIT:
I am on a Windows computer and using Chrome version Version 70.0.3538.110. The output of mailbox item :
{"_data$p$0":{"_data$p$0":{"extensionId":"xxxxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxx","marketplaceContentMarket":null,"permissionLevel":3,"marketplaceAssetId":null,"entryPointUrl":"https://localhost:3000/index.html","consentMetadata":null,"endNodeUrl":null,"hostVersion":"2018112401.04","owaView":"mouse","timeZoneOffsets":[{"start":-8640000000000000,"localStart":-8640000000000000,"end":8640000000000000,"localEnd":8640000000000000,"offset":330}],"userDisplayName":"Anto Joy","userEmailAddress":"outlook_xxxxxxxxxxxxx#outlook.com","userTimeZone":"India Standard Time","userProfileType":"enterprise","ewsUrl":"https://outlook.office365.com/EWS/Exchange.asmx","restUrl":"https://outlook.office365.com/api","itemType":4,"isRead":false},"_permissionLevel$p$0":2}}

Dojox - mvc : How to get widgets declared in template?

In dojo 1.8 version, I have used this._startupWidgets to get widgets declared in template.But in dojo 1.9 version,I get this._startupwidgets as null.So I don't know that how to get it in dojo 1.9 version?
If you're actually looking for widgets contained within the reference widget, try:
var widget; // The widget you care about
require(["dijit/registry"], function(registry) {
registry.findWidgets(widget.domNode);
});
It should be noted that private variables/APIs begin with _. Thus, they're subject to disappear without notice. With that in mind, you could try looking at widget._attachPoints, which lists the names of all attach points in the template. This will also give you the names of plain DOM nodes, not just those of attach points that refer to widgets. A simple filter will extract those that are widgets for you:
var widget; // The widget you care about
require(["dojo/_base/array"], function(array) {
var templateWidgets = array.filter(widget._attachPoints, function(w) {
return !!widget[w].domNode;
});
});

How do I determine open/closed state of a dijit dropdownbutton?

I'm using a dijit DropDownButton with an application I'm developing. As you know, if you click on the button once, a menu appears. Click again and it disappears. I can't seem to find this in the API documentation but is there a property I can read to tell me whether or not my DropDownButton is currently open or closed?
I'm trying to use a dojo.connect listener on the DropDownButton's OnClick event in order to perform another task, but only if the DropDownButton is clicked "closed."
THANK YOU!
Steve
I had a similar problem. I couldn't find such a property either, so I ended up adding a custom property dropDownIsOpen and overriding openDropDown() and closeDropDown() to update its value, like this:
myButton.dropDownIsOpen = false;
myButton.openDropDown = function () {
this.dropDownIsOpen = true;
this.inherited("openDropDown", arguments);
};
myButton.closeDropDown = function () {
this.dropDownIsOpen = false;
this.inherited("closeDropDown", arguments);
};
You may track it through its CSS classes. When the DropDown is open, the underlying DOM node that gets the focus (property focusNode) receives an additional class, dijitHasDropDownOpen. So, for your situation:
// assuming "d" is a dijit.DropDownButton
dojo.connect(d, 'onClick', function() {
if (dojo.hasClass(d.focusNode, 'dijitHasDropDownOpen') === false) {
performAnotherTask(); // this fires only if the menu is closed.
}
});
This example is for dojo 1.6.2, since you didn't specify your version. It can, of course, be converted easily for other versions.

How do you recover the dijit registry after destroying it recursively?

I am working on an application and was doing something like this:
dojo.ready(
function(){ require['dojo/parser','dijit/registry','dojo/on'],function(.....){
//find a dijit and wrap it in event handling code.});
I was getting an error indicating that dojo was trying to register a widget with an id that was already in use. To solve the problem I entered this line of code:
//before finding the dijit destroy the existing registry.
However, logically this prevents the next line from working because now no widget exists to which I can connect an event. How can I recover the dijit ids?
The best solution is to find out why your code is trying to register a widget with an id that is already in use and change it to not to do so.
The #mschr's solution should work, but I would advise again using it, as it can break your code in many other places and you are likely to spend hours investigating strange behavior of your application.
Anyway, if you are willing to do it that way and automatically destroy widgets with the same ID, do not override registry.add() method. You could do it, but it does not mean, you should do it (especially in programming). Employ dojo/aspect instead to call a function that will destroy the widget with the same ID before registry.add() is called:
require([
"dojo/aspect",
"dijit/registry"
], function(
aspect,
registry
) {
aspect.before(registry, "add", function(widget) {
if(registry.byId(widget.id)) {
registry.byId(widget.id).destroy();
// this warning can save you hours of debugging:
console.warn("Widget with id==" + widget.id + " was destroyed to register a widget with the same id.");
}
return [widget];
});
});
I was myself curious how to accomplish #mschr solution without that override, so I created an jsFiddle to experiment: http://jsfiddle.net/phusick/feXVT/
What happens once you register a dijit is the following; it is referenced by the dijit.registry._hash:
function (widget) {
if (hash[widget.id]) {
throw new Error("Tried to register widget with id==" + widget.id + " but that id is already registered");
}
hash[widget.id] = widget;
this.length++;
}
Now, every now and then you would have a contentpane in which you would put a widget programatically (programatically, hence dojo.parser handles cpane.unload and derefences / destroys parser-instantiated widgets).
When this happens, you need to hook onto some form of 'unload', like, when your call cpane.set('content' foo) or cpane.set('href', bar). Hook is needed to destroy and unregister the instances you keep of widgets - otherwise you would have a memoryleak in your program.
Normally, once an object has no references anywhere - it will get cleaned out of memory however with complex objects such as a widget might be, 'class-variables' often have reference to something _outside _widget scope which flags the widget unsafe to delete to the garbage collector... Once you get this point, you will know to perform proper lifecycles, yet not before the concept is fully understood..
What you could do is to override the dijit.registry with your own handler and have any widgets that are doublets destroyed automatically like so:
// pull in registry in-sync and with global scoped
// accees (aka dijit.registry instead of dj_reg)
require({
async:false,
publishRequireResult:true
}, [
"dijit.registry"
], function(dj_reg) {
dijit.registry.add = function(widget) {
// lets change this bit
if (this._hash[widget.id]) {
this._hash[widget.id].destroy(); // optinally destroyRecursively
this.remove(widget.id)
}
this._hash[widget.id] = widget;
this.length++;
}
});