UNPKG

16 kBJavaScriptView Raw
1/*
2 Copyright (c) Microsoft Corporation. All rights reserved.
3*/
4
5/*
6 Your use of this file is governed by the Microsoft Services Agreement http://go.microsoft.com/fwlink/?LinkId=266419.
7*/
8
9/*
10* @overview es6-promise - a tiny implementation of Promises/A+.
11* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
12* @license Licensed under MIT license
13* See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
14* @version 2.3.0
15*/
16
17
18// Sources:
19// osfweb: 16.0\15202.10000
20// runtime: 16.0\15202.10000
21// core: 16.0\15202.10000
22// host: 16.0\15202.10000
23
24
25
26var __extends = (this && this.__extends) || (function () {
27 var extendStatics = function (d, b) {
28 extendStatics = Object.setPrototypeOf ||
29 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30 function (d, b) { for (var p in b)
31 if (b.hasOwnProperty(p))
32 d[p] = b[p]; };
33 return extendStatics(d, b);
34 };
35 return function (d, b) {
36 extendStatics(d, b);
37 function __() { this.constructor = d; }
38 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
39 };
40})();
41var OfficeExt;
42(function (OfficeExt) {
43 var MicrosoftAjaxFactory = (function () {
44 function MicrosoftAjaxFactory() {
45 }
46 MicrosoftAjaxFactory.prototype.isMsAjaxLoaded = function () {
47 if (typeof (Sys) !== 'undefined' && typeof (Type) !== 'undefined' &&
48 Sys.StringBuilder && typeof (Sys.StringBuilder) === "function" &&
49 Type.registerNamespace && typeof (Type.registerNamespace) === "function" &&
50 Type.registerClass && typeof (Type.registerClass) === "function" &&
51 typeof (Function._validateParams) === "function" &&
52 Sys.Serialization && Sys.Serialization.JavaScriptSerializer && typeof (Sys.Serialization.JavaScriptSerializer.serialize) === "function") {
53 return true;
54 }
55 else {
56 return false;
57 }
58 };
59 MicrosoftAjaxFactory.prototype.loadMsAjaxFull = function (callback) {
60 var msAjaxCDNPath = (window.location.protocol.toLowerCase() === 'https:' ? 'https:' : 'http:') + '//ajax.aspnetcdn.com/ajax/3.5/MicrosoftAjax.js';
61 OSF.OUtil.loadScript(msAjaxCDNPath, callback);
62 };
63 Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxError", {
64 get: function () {
65 if (this._msAjaxError == null && this.isMsAjaxLoaded()) {
66 this._msAjaxError = Error;
67 }
68 return this._msAjaxError;
69 },
70 set: function (errorClass) {
71 this._msAjaxError = errorClass;
72 },
73 enumerable: true,
74 configurable: true
75 });
76 Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxString", {
77 get: function () {
78 if (this._msAjaxString == null && this.isMsAjaxLoaded()) {
79 this._msAjaxString = String;
80 }
81 return this._msAjaxString;
82 },
83 set: function (stringClass) {
84 this._msAjaxString = stringClass;
85 },
86 enumerable: true,
87 configurable: true
88 });
89 Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxDebug", {
90 get: function () {
91 if (this._msAjaxDebug == null && this.isMsAjaxLoaded()) {
92 this._msAjaxDebug = Sys.Debug;
93 }
94 return this._msAjaxDebug;
95 },
96 set: function (debugClass) {
97 this._msAjaxDebug = debugClass;
98 },
99 enumerable: true,
100 configurable: true
101 });
102 return MicrosoftAjaxFactory;
103 }());
104 OfficeExt.MicrosoftAjaxFactory = MicrosoftAjaxFactory;
105})(OfficeExt || (OfficeExt = {}));
106var OsfMsAjaxFactory = new OfficeExt.MicrosoftAjaxFactory();
107var OSF = OSF || {};
108(function (OfficeExt) {
109 var SafeStorage = (function () {
110 function SafeStorage(_internalStorage) {
111 this._internalStorage = _internalStorage;
112 }
113 SafeStorage.prototype.getItem = function (key) {
114 try {
115 return this._internalStorage && this._internalStorage.getItem(key);
116 }
117 catch (e) {
118 return null;
119 }
120 };
121 SafeStorage.prototype.setItem = function (key, data) {
122 try {
123 this._internalStorage && this._internalStorage.setItem(key, data);
124 }
125 catch (e) {
126 }
127 };
128 SafeStorage.prototype.clear = function () {
129 try {
130 this._internalStorage && this._internalStorage.clear();
131 }
132 catch (e) {
133 }
134 };
135 SafeStorage.prototype.removeItem = function (key) {
136 try {
137 this._internalStorage && this._internalStorage.removeItem(key);
138 }
139 catch (e) {
140 }
141 };
142 SafeStorage.prototype.getKeysWithPrefix = function (keyPrefix) {
143 var keyList = [];
144 try {
145 var len = this._internalStorage && this._internalStorage.length || 0;
146 for (var i = 0; i < len; i++) {
147 var key = this._internalStorage.key(i);
148 if (key.indexOf(keyPrefix) === 0) {
149 keyList.push(key);
150 }
151 }
152 }
153 catch (e) {
154 }
155 return keyList;
156 };
157 SafeStorage.prototype.isLocalStorageAvailable = function () {
158 return (this._internalStorage != null);
159 };
160 return SafeStorage;
161 }());
162 OfficeExt.SafeStorage = SafeStorage;
163})(OfficeExt || (OfficeExt = {}));
164OSF.XdmFieldName = {
165 ConversationUrl: "ConversationUrl",
166 AppId: "AppId"
167};
168OSF.TestFlightStart = 1000;
169OSF.TestFlightEnd = 1009;
170OSF.FlightNames = {
171 UseOriginNotUrl: 0,
172 AddinEnforceHttps: 2,
173 FirstPartyAnonymousProxyReadyCheckTimeout: 6,
174 AddinRibbonIdAllowUnknown: 9,
175 ManifestParserDevConsoleLog: 15,
176 AddinActionDefinitionHybridMode: 18,
177 UseActionIdForUILessCommand: 20,
178 RequirementSetRibbonApiOnePointTwo: 21,
179 SetFocusToTaskpaneIsEnabled: 22,
180 ShortcutInfoArrayInUserPreferenceData: 23,
181 OSFTestFlight1000: OSF.TestFlightStart,
182 OSFTestFlight1001: OSF.TestFlightStart + 1,
183 OSFTestFlight1002: OSF.TestFlightStart + 2,
184 OSFTestFlight1003: OSF.TestFlightStart + 3,
185 OSFTestFlight1004: OSF.TestFlightStart + 4,
186 OSFTestFlight1005: OSF.TestFlightStart + 5,
187 OSFTestFlight1006: OSF.TestFlightStart + 6,
188 OSFTestFlight1007: OSF.TestFlightStart + 7,
189 OSFTestFlight1008: OSF.TestFlightStart + 8,
190 OSFTestFlight1009: OSF.TestFlightEnd
191};
192OSF.TrustUXFlightValues = {
193 TrustUXControlA: 0,
194 TrustUXExperimentB: 1,
195 TrustUXExperimentC: 2
196};
197OSF.FlightTreatmentNames = {
198 AllowStorageAccessByUserActivationOnIFrameCheck: "Microsoft.Office.SharedOnline.AllowStorageAccessByUserActivationOnIFrameCheck",
199 WopiPreinstalledAddInsEnabled: "Microsoft.Office.SharedOnline.WopiPreinstalledAddInsEnabled",
200 WopiUseNewActivate: "Microsoft.Office.SharedOnline.WopiUseNewActivate",
201 CheckProxyIsReadyRetry: "Microsoft.Office.SharedOnline.OEP.CheckProxyIsReadyRetry",
202 InsertionDialogFixesEnabled: "Microsoft.Office.SharedOnline.InsertionDialogFixesEnabled",
203 BlockAutoOpenAddInIfStoreDisabled: "Microsoft.Office.SharedOnline.BlockAutoOpenAddInIfStoreDisabled",
204 AddinTrustUXImprovement: "Microsoft.Office.SharedOnline.AddinTrustUXImprovement",
205 TeachingUIForPrivateCatelogEnabled: "Microsoft.Office.SharedOnline.TeachingUIForPrivateCatelogEnabled"
206};
207OSF.Flights = [];
208OSF.IntFlights = {};
209OSF.Settings = {};
210OSF.WindowNameItemKeys = {
211 BaseFrameName: "baseFrameName",
212 HostInfo: "hostInfo",
213 XdmInfo: "xdmInfo",
214 SerializerVersion: "serializerVersion",
215 AppContext: "appContext",
216 Flights: "flights"
217};
218OSF.OUtil = (function () {
219 var _uniqueId = -1;
220 var _xdmInfoKey = '&_xdm_Info=';
221 var _serializerVersionKey = '&_serializer_version=';
222 var _flightsKey = '&_flights=';
223 var _xdmSessionKeyPrefix = '_xdm_';
224 var _serializerVersionKeyPrefix = '_serializer_version=';
225 var _flightsKeyPrefix = '_flights=';
226 var _fragmentSeparator = '#';
227 var _fragmentInfoDelimiter = '&';
228 var _classN = "class";
229 var _loadedScripts = {};
230 var _defaultScriptLoadingTimeout = 30000;
231 var _safeSessionStorage = null;
232 var _safeLocalStorage = null;
233 var _rndentropy = new Date().getTime();
234 function _random() {
235 var nextrand = 0x7fffffff * (Math.random());
236 nextrand ^= _rndentropy ^ ((new Date().getMilliseconds()) << Math.floor(Math.random() * (31 - 10)));
237 return nextrand.toString(16);
238 }
239 ;
240 function _getSessionStorage() {
241 if (!_safeSessionStorage) {
242 try {
243 var sessionStorage = window.sessionStorage;
244 }
245 catch (ex) {
246 sessionStorage = null;
247 }
248 _safeSessionStorage = new OfficeExt.SafeStorage(sessionStorage);
249 }
250 return _safeSessionStorage;
251 }
252 ;
253 function _reOrderTabbableElements(elements) {
254 var bucket0 = [];
255 var bucketPositive = [];
256 var i;
257 var len = elements.length;
258 var ele;
259 for (i = 0; i < len; i++) {
260 ele = elements[i];
261 if (ele.tabIndex) {
262 if (ele.tabIndex > 0) {
263 bucketPositive.push(ele);
264 }
265 else if (ele.tabIndex === 0) {
266 bucket0.push(ele);
267 }
268 }
269 else {
270 bucket0.push(ele);
271 }
272 }
273 bucketPositive = bucketPositive.sort(function (left, right) {
274 var diff = left.tabIndex - right.tabIndex;
275 if (diff === 0) {
276 diff = bucketPositive.indexOf(left) - bucketPositive.indexOf(right);
277 }
278 return diff;
279 });
280 return [].concat(bucketPositive, bucket0);
281 }
282 ;
283 return {
284 set_entropy: function OSF_OUtil$set_entropy(entropy) {
285 if (typeof entropy == "string") {
286 for (var i = 0; i < entropy.length; i += 4) {
287 var temp = 0;
288 for (var j = 0; j < 4 && i + j < entropy.length; j++) {
289 temp = (temp << 8) + entropy.charCodeAt(i + j);
290 }
291 _rndentropy ^= temp;
292 }
293 }
294 else if (typeof entropy == "number") {
295 _rndentropy ^= entropy;
296 }
297 else {
298 _rndentropy ^= 0x7fffffff * Math.random();
299 }
300 _rndentropy &= 0x7fffffff;
301 },
302 extend: function OSF_OUtil$extend(child, parent) {
303 var F = function () { };
304 F.prototype = parent.prototype;
305 child.prototype = new F();
306 child.prototype.constructor = child;
307 child.uber = parent.prototype;
308 if (parent.prototype.constructor === Object.prototype.constructor) {
309 parent.prototype.constructor = parent;
310 }
311 },
312 setNamespace: function OSF_OUtil$setNamespace(name, parent) {
313 if (parent && name && !parent[name]) {
314 parent[name] = {};
315 }
316 },
317 unsetNamespace: function OSF_OUtil$unsetNamespace(name, parent) {
318 if (parent && name && parent[name]) {
319 delete parent[name];
320 }
321 },
322 serializeSettings: function OSF_OUtil$serializeSettings(settingsCollection) {
323 var ret = {};
324 for (var key in settingsCollection) {
325 var value = settingsCollection[key];
326 try {
327 if (JSON) {
328 value = JSON.stringify(value, function dateReplacer(k, v) {
329 return OSF.OUtil.isDate(this[k]) ? OSF.DDA.SettingsManager.DateJSONPrefix + this[k].getTime() + OSF.DDA.SettingsManager.DataJSONSuffix : v;
330 });
331 }
332 else {
333 value = Sys.Serialization.JavaScriptSerializer.serialize(value);
334 }
335 ret[key] = value;
336 }
337 catch (ex) {
338 }
339 }
340 return ret;
341 },
342 deserializeSettings: function OSF_OUtil$deserializeSettings(serializedSettings) {
343 var ret = {};
344 serializedSettings = serializedSettings || {};
345 for (var key in serializedSettings) {
346 var value = serializedSettings[key];
347 try {
348 if (JSON) {
349 value = JSON.parse(value, function dateReviver(k, v) {
350 var d;
351 if (typeof v === 'string' && v && v.length > 6 && v.slice(0, 5) === OSF.DDA.SettingsManager.DateJSONPrefix && v.slice(-1) === OSF.DDA.SettingsManager.DataJSONSuffix) {
352 d = new Date(parseInt(v.slice(5, -1)));
353 if (d) {
354 return d;
355 }
356 }
357 return v;
358 });
359 }
360 else {
361 value = Sys.Serialization.JavaScriptSerializer.deserialize(value, true);
362 }
363 ret[key] = value;
364 }
365 catch (ex) {
366 }
367 }
368 return ret;
369 },
370 loadScript: function OSF_OUtil$loadScript(url, callback, timeoutInMs) {
371 if (url && callback) {
372 var doc = window.document;
373 var _loadedScriptEntry = _loadedScripts[url];
374 if (!_loadedScriptEntry) {
375 var script = doc.createElement("script");
376 script.type = "text/javascript";
377 _loadedScriptEntry = { loaded: false, pendingCallbacks: [callback], timer: null };
378 _loadedScripts[url] = _loadedScriptEntry;
379 var onLoadCallback = function OSF_OUtil_loadScript$onLoadCallback() {
380 if (_loadedScriptEntry.timer != null) {
381 clearTimeout(_loadedScriptEntry.timer);
382 delete _loadedScriptEntry.timer;
383 }
384 _loadedScriptEntry.loaded = true;
385 var pendingCallbackCount = _loadedScriptEntry.pendingCallbacks.length;
386 for (var i = 0; i < pendingCallbackCount; i++) {
387 var currentCallback = _loadedScriptEntry.pendingCallbacks.shift();
388 currentCallback();
389 }
390 };
391 var onLoadTimeOut = function OSF_OUtil_loadScript$onLoadTimeOut() {
392 if (window.navigator.userAgent.indexOf("Trident") > 0) {
393 onLoadError(null);
394 }
395 else {
396 onLoadError(new Event("Script load timed out"));
397
\No newline at end of file