Skip to content

Instantly share code, notes, and snippets.

@jeznag
Created September 17, 2020 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeznag/977e4207f0f14b0160652ceb34ed8567 to your computer and use it in GitHub Desktop.
Save jeznag/977e4207f0f14b0160652ceb34ed8567 to your computer and use it in GitHub Desktop.
updated code
!function(o) {
var d = null
, l = null;
function n(e) {
e = e || 10;
for (var t = "", a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", i = 0; i < e; )
t += a.charAt(Math.floor(Math.random() * a.length)),
i++;
return t
}
function e(e) {
if (!o.localStorage)
throw new Error("localStorage not available");
var t = "BroadcastChannelPoly_" + e
, a = null === d;
return this.channelId = t,
l = l || n(),
(d = d || {})[t] = d[t] || [],
d[t].push(this),
this.name = t + "::::" + n() + (new Date).getTime(),
a && o.addEventListener("storage", i.bind(this), !1),
this
}
function i(e) {
var t = e.key
, a = e.newValue
, i = !a
, n = null;
if (-1 < t.indexOf("eomBCmessage_") && !i) {
try {
n = JSON.parse(a)
} catch (e) {
throw new Error("Unable to parse JsonString")
}
if (n.tabId !== l && n.channelId && d && d[n.channelId]) {
var r = d[n.channelId];
for (var s in r)
!r[s].closed && r[s].onmessage && r[s].onmessage(n.message);
o.localStorage.removeItem(t)
}
}
}
e.prototype.postMessage = function(e) {
if (e = {
data: e
},
this.closed)
throw new Error("This BroadcastChannel is closed.");
var t = {
channelId: this.channelId,
bcId: this.name,
tabId: l,
message: e
};
try {
var a = JSON.stringify(t)
, i = "eomBCmessage_" + n() + "_" + this.channelId;
o.localStorage.setItem(i, a)
} catch (e) {
throw new Error("Unable to parse msgObj")
}
setTimeout(function() {
o.localStorage.removeItem(i)
}, 1e3)
}
,
e.prototype.close = function() {
this.closed = !0;
var e = d[this.channelId].indexOf(this);
-1 < e && d[this.channelId].splice(e, 1),
d[this.channelId].length || delete d[this.channelId],
function(e) {
for (var t in e)
if (e.hasOwnProperty(t))
return;
return 1
}(d) && o.removeEventListener("storage", i.bind(this))
}
,
o.BroadcastChannel = o.BroadcastChannel || e
}(window.self),
function() {
function e(e, a, i, t) {
t.forEach(function(t) {
t in i.prototype && (e.prototype[t] = function() {
return i = this[a],
n = t,
r = arguments,
(e = new Promise(function(e, t) {
var a;
s = i[n].apply(i, r),
a = s,
new Promise(function(e, t) {
a.onsuccess = function() {
e(a.result)
}
,
a.onerror = function() {
t(a.error)
}
}
).then(e, t)
}
)).request = s,
e;
var i, n, r, s, e
}
)
})
}
function t(e, a, t) {
t.forEach(function(t) {
Object.defineProperty(e.prototype, t, {
get: function() {
return this[a][t]
},
set: function(e) {
this[a][t] = e
}
})
})
}
function a(t, a, i, e) {
e.forEach(function(e) {
e in i.prototype && (t.prototype[e] = function() {
return this[a][e].apply(this[a], arguments)
}
)
})
}
function s(e) {
this._name = e.name,
this._version = e.version,
this._objectStoreNames = e.objectStoreNames,
this._db = e
}
function i(a) {
this._tx = a,
this.complete = new Promise(function(e, t) {
a.oncomplete = function() {
e()
}
,
a.onerror = function() {
t(a.error)
}
,
a.onabort = function() {
t(a.error)
}
}
)
}
function n(e) {
this._store = e
}
function r(e) {
this._index = e
}
s.prototype.createObjectStore = function() {
return new n(this._db.createObjectStore.apply(this._db, arguments))
}
,
s.prototype.transaction = function() {
return new i(this._db.transaction.apply(this._db, arguments))
}
,
t(s, "_db", ["name", "version", "objectStoreNames"]),
a(s, "_db", IDBDatabase, ["close"]),
i.prototype.objectStore = function() {
return new n(this._tx.objectStore.apply(this._tx, arguments))
}
,
t(i, "_tx", ["objectStoreNames", "mode"]),
a(i, "_tx", IDBTransaction, ["abort"]),
n.prototype.createIndex = function() {
return new r(this._store.createIndex.apply(this._store, arguments))
}
,
n.prototype.index = function() {
return new r(this._store.index.apply(this._store, arguments))
}
,
t(n, "_store", ["name", "keyPath", "indexNames", "autoIncrement"]),
e(n, "_store", IDBObjectStore, ["put", "add", "delete", "clear", "get", "getAll", "getKey", "getAllKeys", "count"]),
t(r, "_index", ["name", "keyPath", "multiEntry", "unique"]),
e(r, "_index", IDBIndex, ["get", "getKey", "getAll", "getAllKeys", "count"]),
self.idbHandler = {
open: function(i, n, r) {
return new Promise(function(a, t) {
var e = indexedDB.open(i, n);
e.onupgradeneeded = function(e) {
if (r) {
var t = new s(e.target.result);
r(t)
}
}
,
e.onerror = function(e) {
t(e.target.result)
}
,
e.onsuccess = function(e) {
var t = new s(e.target.result);
a(t)
}
}
)
}
}
}(),
function(r) {
var s = {
Threads: 4,
Timeout: 0,
Worker: function(e, t) {
console.log("finished : " + e.data),
t()
}
};
r.ZReqPool = function(e) {
var t = r.extend({}, s, e)
, a = {
ready: t.Threads,
assign: function() {
a.ready--
},
free: function() {
a.ready++,
n.process()
},
available: function() {
return 0 < a.ready
}
}
, i = []
, n = {
add: function(e) {
e && (i.push(e),
n.process())
},
next: function() {
return i.shift()
},
flush: function(t) {
t && (i = i.filter(function(e) {
return !t(e)
}))
},
flushAll: function() {
var e = i;
return i = [],
e
},
process: function() {
if (a.available()) {
var e = n.next();
if (e) {
a.assign();
setTimeout(function() {
t.Worker(e, function() {
a.free()
})
}, t.Timeout)
}
}
}
};
return n
}
}(jQuery);
var ZAppUtil = function(e) {
var t;
function a() {}
return a.prototype.Info = function() {
(e.isDevMode() || e.isLogEnabled()) && console.info.apply(window.console, arguments)
}
,
a.prototype.Error = function() {
(e.isDevMode() || e.isLogEnabled()) && console.error.apply(window.console, arguments)
}
,
e.getPatchedString = function(e, a) {
if (!e || "string" != typeof e)
throw new Error("Invalid String");
if (!a || "object" != typeof a)
throw new Error("Invalid Params object");
return e.replace(/\$\{\w{1,}\}/g, function(e) {
var t = e.replace(/[${}]/g, "");
return a[t]
})
}
,
e.getURLOrigin = function(e) {
var t = e || document.location.href
, a = document.createElement("a");
return a.setAttribute("href", t),
a.protocol + "//" + a.host
}
,
e.getQueryParams = function(e) {
var i = {};
e = e || window.location.href;
var t = document.createElement("a");
t.setAttribute("href", e);
var a = "string" == typeof t.search ? t.search.substr(1) : e.substr(e.indexOf("?") + 1);
return (1 < a.length ? a.split("&") : []).forEach(function(e, t) {
var a = e.split("=");
i[a[0]] = a[1]
}),
i
}
,
e.isURL = function(e) {
return -1 !== e.indexOf("http")
}
,
e.isDevMode = function() {
return localStorage && !!localStorage.getItem("isDevMode")
}
,
e.isLogEnabled = function() {
return localStorage && !!localStorage.getItem("isLogEnabled")
}
,
e.getLogger = function() {
return t && t instanceof a || (t = new a),
t
}
,
e.constructQueryParamsString = function(e) {
var t = [];
for (var a in e)
a && e[a] && t.push(a + "=" + e[a]);
return t.join("&")
}
,
e
}(window.ZAppUtil || {})
, MessageManager = function(a) {
var u, m = ZAppUtil.getLogger();
function n(e, t) {
for (var a, i = e.source, n = e.origin, r = u.GetModelStore(), s = document.getElementsByTagName("iframe"), o = 0; o < s.length; o++)
s[o].contentWindow === i && (a = s[o].id);
var d = u.GetAppInstance(a);
if (d) {
if (h(d.resolvedURL) !== h(decodeURIComponent(t.appOrigin)))
throw new Error("Message from Un-Authorized App");
var l = d.extensionID;
d.state = "REGISTERED",
d.origin = n,
m.Info("App Registered: " + d.location);
var c = u.GetExtensionInstance(l)
, g = {
model: r,
locale: c && c.Locale ? c.Locale : "en",
localeResource: c && c.localeResource,
uniqueID: d.uniqueID
}
, p = u.GetPanelReference(d.uniqueID);
p.initialized = d.initialized = !0,
p.SendEvent("SET_CONTEXT", g),
"function" == typeof d.onload && setTimeout(d.onload.bind(null, [d.config]), window.AppOnLoadDelay || 0)
} else
m.Error("Message from UnAuthorized window arrived.")
}
function r(e, t) {
var a = t.uniqueID
, i = u.GetPanelReference(a)
, n = u.GetAppInstance(a);
n ? (n.initialized = i.initialized = !1,
m.Info("App[" + a + "] DeRegistered successfully"),
"function" == typeof n.onunload && setTimeout(n.onunload.bind(null, [n.config]), window.AppOnUnLoadDelay || 0)) : m.Info("Coult not find App Instance to De-Register.")
}
function s(t, e) {
var a = e.data
, i = e.promiseid
, n = e.uniqueID;
u.ProcessGetRequest(i, n, a).then(function(e) {
o(t.source, t.origin, i, e, !0)
}).catch(function(e) {
o(t.source, t.origin, i, e, !1)
})
}
function o(e, t, a, i, n) {
var r = {
type: "FRAMEWORK.EVENT",
eventName: "EVENT_RESPONSE",
data: i,
time: (new Date).getTime(),
promiseid: a,
isSuccess: n
};
e.postMessage(r, t)
}
function h(e) {
var t = document.createElement("a");
return t.setAttribute("href", e),
t.protocol + "//" + t.host + t.pathname
}
return a.Init = function(e, t) {
if (!e || "object" != typeof e)
throw Error("Invalid Context object passed");
if (t && "object" != typeof t)
throw Error("Invalid Configuration Passed to MessageHandler");
return u = e,
function(t) {
try {
var a = "string" == typeof t.data ? JSON.parse(t.data) : t.data
} catch (e) {
a = t.data
}
var e = a.type;
if ("SDK.EVENT" != e)
return;
var i = "SDK.EVENT" === e ? a.eventName : void 0;
try {
if (-1 !== ["REGISTER", "DEREGISTER"].indexOf(i) || function(e, t) {
var a = u.GetAppInstance(t.uniqueID)
, i = document.getElementById(a.uniqueID)
, n = i && i.contentWindow
, r = h(a.resolvedURL)
, s = a.uniqueID
, o = e.source
, d = t.uniqueID
, l = h(decodeURIComponent(t.appOrigin));
if (n === o && r === l && s === d)
return 1;
throw new Error("Message from UnAuthorized Source")
}(t, a))
switch (e) {
case "SDK.EVENT":
!function(e, t) {
var a = {
REGISTER: n,
DEREGISTER: r,
HTTP_REQUEST: s
}[t.eventName];
a && "function" == typeof a ? a(e, t) : function(e) {
var t, a, i = e.eventName, n = e.promiseid, r = e.data, s = e.uniqueID, o = u.GetAppInstance(s), d = u.GetPanelReference(s), l = d && d.getConfig();
o.extension_id;
if (n) {
var c = document.getElementById(o.location).contentWindow;
t = function(e, t, a, i, n) {
var r = {
type: "FRAMEWORK.EVENT",
eventName: "EVENT_RESPONSE",
promiseid: a,
time: (new Date).getTime(),
data: n
};
e.postMessage(r, t)
}
.bind(null, c, o.origin, n, i),
a = function(e, t, a, i, n) {
var r = {
type: "FRAMEWORK.EVENT",
eventName: "EVENT_RESPONSE_FAILURE",
promiseid: a,
time: (new Date).getTime(),
data: n
};
e.postMessage(r, t)
}
.bind(null, c, o.origin, n, i)
}
m.Info("Event from SDK => Eventname : ", i, ", Time : ", e.time, ", Eventpayload : ", r);
var g = {
data: r,
config: l,
callback: t,
callbackFailure: a,
iframe: document.getElementById(o.location)
};
u.TriggerEventListeners(i, g)
}(t)
}(t, a);
break;
default:
u.InterceptMessage(t, a)
}
} catch (e) {
m.Error("[MessageHandler] => ", e.stack)
}
}
.bind(a)
}
,
a.GetMessenger = function(n) {
return {
SendEvent: function(e, t) {
!function(e) {
if (void 0 !== e) {
var t = u.GetAppInstance(n)
, a = t && t.resolvedURL
, i = document.getElementById(n) && document.getElementById(n).contentWindow;
i && i.postMessage(e, a)
} else
m.Error("Invalid Message.")
}({
type: "FRAMEWORK.EVENT",
eventName: e,
data: t,
time: (new Date).getTime(),
uniqueID: n
})
}
}
}
,
a.BroadcastEvent = function(e, t) {
var a = u.GetAllAppInstance();
for (var i in a) {
var n = u.GetPanelReference(i);
n && n.initialized ? n.SendEvent(e, t) : m.Error("App reference could not be found.")
}
}
,
a
}(window.MessageManager || {})
, DefaultPluginManager = function(e) {
return e.RenderPanel = function(e) {
var t, a = e.location, i = e.resolvedURL;
return a && "string" == typeof a && (a = t = document.getElementById(a)),
a instanceof HTMLIFrameElement && ((t = a).setAttribute("src", i),
t.setAttribute("id", e.uniqueID)),
t
}
,
e
}(window.DefaultPluginManager || {})
, ZApp = function(s) {
var v = ZAppUtil.getLogger();
try {
var o, d, l, w, a, c = !1, t = {}, g = {
devHost: "http://127.0.0.1:5000",
zappsHost: "http://zapps.zohousercontent/appfiles/"
}, i = {}, p = {}, u = {}, m = {};
function I(e) {
return p[e]
}
function h() {
return p
}
function f(e) {
return u[e]
}
function b(e) {
return i[e]
}
function E(e) {
var t, a;
try {
var i = {}
, n = e ? e.uniqueID : void 0;
n && p[n] ? i = p[n] : (n = e.uniqueID || (a = (new Date).getTime(),
"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
var t = (a + 16 * Math.random()) % 16 | 0;
return a = Math.floor(a / 16),
("x" == e ? t : 3 & t | 8).toString(16)
})),
i.uniqueID = n,
i.url = e.url,
i.config = e.config || {},
i.location = e.location,
i.extension_id = e.extension_id,
i.extension_version = e.extension_version,
i.resolvedURL = function(e) {
var t, a = e.url, i = ZAppUtil.isDevMode() ? g.devHost : g.zappsHost, n = ZAppUtil.getURLOrigin(), r = {
serviceOrigin: encodeURIComponent(n),
frameorigin: encodeURIComponent(n),
isDevMode: ZAppUtil.isDevMode(),
isLogEnabled: ZAppUtil.isLogEnabled()
}, s = ZAppUtil.constructQueryParamsString(r), o = e.extension_id, d = e.extension_version;
!ZAppUtil.isDevMode() && o && d && (i += "/" + o + "/" + d);
t = ZAppUtil.isURL(a) ? a : i + a;
return t += -1 === t.indexOf("?") ? "?" : "&",
t += s
}(i)),
i.ondemand = e.ondemand,
i.onload = e.onload,
i.onunload = e.onunload,
y(o, i);
var r = l.RenderPanel(i);
r ? r instanceof HTMLIFrameElement && (p[n] = i,
(t = MessageManager.GetMessenger(n)).getConfig = function() {
return e.config
}
,
u[n] = t,
y(d, i)) : i.initialized = !1
} catch (e) {
v.Error(e)
}
return t
}
function y(e, t) {
return e && "function" == typeof e && e(t)
}
function C(e) {
try {
if ("string" == typeof e && (e = JSON.parse(e)),
"object" != typeof e)
return void v.Error("Invalid extension config passed");
var t = e.modules
, a = {
version: e.version,
locale: e.locale,
modules: t,
widgets: t ? t.widgets : void 0,
connectors: t ? t.connectors : void 0,
id: e.id,
params: e.params,
modules: void 0
};
delete a.modules,
function(e) {
if (e) {
for (var t = e.widgets || [], a = [], i = 0; i < t.length; i++) {
var n = t[i];
n.extension_id = e.id,
n.extension_version = e.version;
var r = E(n);
r && a.push(r)
}
return e.panelRefs = a
}
v.Error("Invalid Extension data passed.")
}(a),
i[e.id] = a
} catch (e) {
v.Error("Error in Loading App Data ", e)
}
}
function A(e, t) {
"function" == typeof a && a(e, t)
}
var _ = {};
function W() {
return t
}
function P(m, h, f) {
return new Promise(function(e, t) {
try {
v.Info("ProcessGetRequest : PromiseID: ", m, ", Options: ", f);
var a = f.url
, i = f.type
, n = f.data
, r = f.postBody
, s = f.headers
, o = f.contentType || "application/text"
, d = f.dataType || "text"
, l = I(h)
, c = b(l && l.extension_id);
if ("object" == typeof c) {
var g = function(e) {
if (!Array.isArray(e))
throw new Error("Invalid params array");
for (var t = {}, a = 0; a < e.length; a++) {
var i = e[a].name
, n = e[a].value;
t[i] = n
}
return t
}(c.params);
a = ZAppUtil.getPatchedString(a, g),
n = n ? function(e, t) {
if (!e || "object" != typeof e)
return;
if (t && "object" == typeof t)
return JSON.parse(ZAppUtil.getPatchedString(JSON.stringify(e), t));
throw new Error("Invalid Params object")
}(n, g) : void 0
}
var p = "";
n && "object" == typeof n && (p = Object.keys(n).map(function(e) {
return e + "=" + n[e]
}).join("&"));
var u = {
requestURL: a,
requestType: i,
queryParams: p,
headers: s,
postBody: r || "",
contentType: o,
dataType: d
};
if ("function" != typeof w)
throw new Error("Provide Request handler implementation in the Bootstrap.");
w(u, e, t)
} catch (e) {
v.Error("ProcessGetRequest : Error => ", e),
t(e)
}
}
)
}
function R(e) {
return ZAppUtil.isDevMode(),
{}
}
return s.Bootstrap = function(e) {
var t, a, i;
v.Info("Running in Dev Mode : ", ZAppUtil.isDevMode());
try {
if (!e || "object" != typeof e)
throw new Error("Invalid configurations passed to Bootstrap.");
l = e.PluginManager || DefaultPluginManager,
w = e.RequestHandler,
o = e.preRenderApp,
d = e.postRenderApp,
$.extend(g, e.serverConfig),
m.ProcessGetRequest = P,
m.Logger = v,
m.GetLocaleResource = R,
m.GetAppInstance = I,
m.GetAllAppInstance = h,
m.GetPanelReference = f,
m.GetExtensionInstance = b,
m.GetModelStore = W,
m.InterceptMessage = A,
m.TriggerEventListeners = function(e, t) {
var a = _[e];
if (Array.isArray(a))
for (var i = 0; i < a.length; i++)
a[i](t)
}
;
var n = e.EventListeners || {};
for (var r in n)
i = n[a = r],
_.hasOwnProperty(a) || (_[a] = []),
_[a].push(i);
return t = MessageManager.Init(m),
window.addEventListener("message", t),
c = !0,
ZAppUtil.isDevMode() && new Promise(function(t, a) {
var e = g.devHost + "/plugin-manifest.json";
$.support.cors = !0,
$.ajax({
type: "GET",
url: e,
dataType: "json",
success: function(e) {
t(e)
},
error: function(e) {
var t;
t = e,
v.Error("Error occured while trying to Get plugin-manifest.json : ", t),
a(e)
}
})
}
).then(function(e) {
var t = e.modules;
C({
locale: e.locale,
modules: t,
widgets: t ? t.widgets : void 0,
connectors: t ? t.connectors : void 0,
id: e.id || "00000000",
params: e.params
})
}).catch(function(e) {
v.Error("Error occured while loading Meta data. Error: ", e.message)
}),
s
} catch (e) {
v.Error("Error occured while Initiating Framework : ", e.message)
}
}
,
s.isInitialized = function() {
return c
}
,
s.LoadExtension = function(e) {
if (!ZAppUtil.isDevMode())
return C(e);
v.Info("Running in Dev mode so can't Load the Extension.")
}
,
s.LoadApp = function(e) {
if (v.Info("Load App : [ " + e.url + "," + e.location + "]"),
!ZAppUtil.isDevMode())
return E(e);
v.Info("Running in Dev mode so can't Load the app.")
}
,
s.RenderApps = function(e, t) {
for (var a in v.Info("Render Apps with LocationID => ", e),
"string" == typeof e && (e = [e]),
p)
try {
var i = p[a]
, n = i.location
, r = i.ref;
if (e && -1 === e.indexOf(n))
continue;
if (r && r.initialized)
continue;
E(i)
} catch (e) {
v.Error("Exception while Rendering Panel ==> ", a, ".", e)
}
}
,
s.GetAppInstance = I,
s.GetAllAppInstance = h,
s.isDevMode = ZAppUtil.isDevMode,
s.SetModel = function(e) {
return t = e,
!0
}
,
s.UpdateModel = function(e) {
return t
}
,
s.GetModel = function(e) {
return t[e]
}
,
s.BroadcastEvent = function(e, t) {
MessageManager.BroadcastEvent(e, t)
}
,
s.getLogger = ZAppUtil.getLogger,
s.version = "0.7.0",
s
} catch (e) {
v.Error("Error Occured ", e.message)
}
}(window.ZApp || {})
, CrmWidgets = function() {
var p, h = {}, a = {}, f = {
NAME: "WIDGET_DB",
OBJECT_STORE_NAME: "WIDGET_REQUEST_TRACKER"
}, v = {
CLEANUP_DELAY: 1e4,
HASHING_METHOD: "SHA-256"
}, w = {
CHANNEL: "WIDGET_TELEPHONY_RESULT_CHANNEL",
REPETITION: 4,
INTRAVEL: 400
}, I = idbHandler.open(f.NAME, 1, function(e) {
e.createObjectStore(f.OBJECT_STORE_NAME)
});
function b(a) {
var e = a.requestHash
, t = h[e];
t && t instanceof Array && (t.each(function(e) {
var t = e.cachedPromise;
"DONE" === a.status ? t.done(a.response) : t.fail(a.response),
clearTimeout(e.setTimeoutID)
}),
delete h[e])
}
var i = new BroadcastChannel(w.CHANNEL);
function s(e, t) {
var a, i = function(e) {
if (window.TextEncoder)
return new TextEncoder("utf-8").encode(e);
for (var t = unescape(encodeURIComponent(e)), a = new Uint8Array(t.length), i = t.length, n = 0; n < i; n++)
a[n] = t.charCodeAt(n);
return a
}(t);
if (window.crypto)
a = window.crypto.subtle.digest(e, i);
else if (window.msCrypto) {
var n;
a = new Promise(function(e) {
n = e
}
),
window.msCrypto.subtle.digest(e, i).oncomplete = function(e) {
n(e.target.result)
}
}
return a.then(function(e) {
return Array.from(new Uint8Array(e)).map(function(e) {
return ("00" + e.toString(16)).slice(-2)
}).join("")
})
}
function u(e, t) {
if (e instanceof Object) {
var a = {
"x-ratelimit-remaining": t.getResponseHeader("x-ratelimit-remaining"),
"x-ratelimit-limit": t.getResponseHeader("x-ratelimit-limit"),
"x-ratelimit-reset": t.getResponseHeader("x-ratelimit-reset")
};
e.$responseHeaders = a
}
}
function t(a) {
return CrmWidgets.Utils.isMobileWidget() || "21" != a.context.TYPE ? Promise.resolve(a) : I.then(function(e) {
return i = e.transaction(f.OBJECT_STORE_NAME, "readwrite"),
(n = i.objectStore(f.OBJECT_STORE_NAME)).get(a.requestHash)
}).then(function(e) {
var t = (new Date).getTime();
return !e || Math.abs(t - e) > v.CLEANUP_DELAY + 1e3 ? (n.put(t, a.requestHash),
a.broadcastResult = !0) : a.handlerType = "DEFER",
i.complete
}).then(function() {
return a
});
var i, n
}
i.onmessage = function(e) {
var t = e.data;
if (t && t.action)
switch (t.action) {
case "mimicResponse":
b(t.data)
}
}
;
function n(c) {
function g(e, t) {
var a = new CrmWidgets.Exceptions.InternalServerException;
if (400 === t.status || 403 === t.status) {
a = t.responseJSON || t.responseText;
var i = alert;
CrmWidgets.Utils.isMobileWidget() && a && a.constructor === {}.constructor && a.code && "REQUIRED_HEADER_MISSING" === a.code && i("Kindly update your app for the feature to work")
} else
401 === t.status ? a = new CrmWidgets.Exceptions.AuthorizationException : 429 === t.status && (a = new CrmWidgets.Exceptions.LimitException);
u(a, t),
e(a, !0)
}
return {
setKeySpec: function(e) {
if (!(e && e instanceof Object && e.iv && e.secret))
throw new CrmWidgets.Exceptions.InvalidKeySpec;
p = {
iv: CryptoJS.enc.Hex.parse(e.iv),
key: CryptoJS.enc.Hex.parse(e.secret),
handShake: e.handShake,
orgId: e["X-CRM-ORG"]
}
},
getHandShakeToken: function() {
if (p && p instanceof Object && p.handShake)
return p.handShake
},
makeRequest: function(e, t, a, r, i) {
var n = a instanceof FormData
, s = {
widget_id: c.ID,
widget_name: encodeURIComponent(c.NAME)
}
, o = {
"X-ZOHO-SERVICE": "widget",
"X-ZOHO-SERVICE-DETAILS": JSON.stringify(s)
};
"undefined" != typeof Crm && void 0 !== Crm.userDetails.CLIENT_PORTAL_NAME && (o["X-CRMPORTAL"] = Crm.userDetails.CLIENT_PORTAL_NAME),
"undefined" != typeof csrfToken ? o["X-ZCSRF-TOKEN"] = csrfParamName + "=" + csrfToken : CrmWidgets.Utils.isMobileWidget() && (o.Authorization = CrmWidgets.Utils.getDeviceToken(p),
p && p.orgId && (o["X-CRM-ORG"] = p.orgId));
var d = {};
a && "stream" === a.RESPONSE_TYPE && (d.responseType = "blob",
delete a.RESPONSE_TYPE);
var l = {
type: e,
url: t,
data: a,
headers: o,
contentType: !n && void 0,
processData: !n && void 0,
xhrFields: d,
cachedPromise: {
done: r,
fail: i
},
success: function(t, e, a) {
var i, n;
if ("string" == typeof t)
try {
i = jQuery.parseJSON(t)
} catch (e) {
i = t
}
else
i = t;
if (200 === a.status || 201 === a.status || 202 === a.status)
n = i;
else if (204 === a.status) {
n = {
status: a.status,
statusText: a.statusText
}
}
n && (u(n, a),
r(n))
},
error: g.bind(null, i)
};
CrmWidgets.APIHelper.RequestPool.add({
category: c.ID,
context: c,
obj: l
})
},
makeAjax: function(e, t, a, i, n) {
var r = {
widget_id: c.ID,
widget_name: encodeURIComponent(c.NAME)
}
, s = {
"X-ZOHO-SERVICE": "widget",
"X-ZOHO-SERVICE-DETAILS": JSON.stringify(r)
};
"undefined" != typeof Crm && void 0 !== Crm.userDetails.CLIENT_PORTAL_NAME && (s["X-CRMPORTAL"] = Crm.userDetails.CLIENT_PORTAL_NAME),
"undefined" != typeof csrfToken ? s["X-ZCSRF-TOKEN"] = csrfParamName + "=" + csrfToken : CrmWidgets.Utils.isMobileWidget() && (s.Authorization = CrmWidgets.Utils.getDeviceToken(p),
p && p.orgId && (s["X-CRM-ORG"] = p.orgId));
var o = {};
a && "stream" === a.RESPONSE_TYPE && (o.responseType = "blob",
delete a.RESPONSE_TYPE);
var d = {
type: e,
url: t,
data: JSON.stringify(a),
processData: !1,
contentType: "application/json",
headers: s,
xhrFields: o,
success: function(e) {
i(e)
},
error: g.bind(null, n)
};
CrmWidgets.APIHelper.RequestPool.add({
category: c.ID,
context: c,
obj: d
})
},
get: function(a, i) {
var n = this;
return new Promise(function(e, t) {
n.makeRequest("GET", a, i, e, t)
}
)
},
put: function(a, i) {
var n = this;
return new Promise(function(e, t) {
n.makeRequest("PUT", a, i, e, t)
}
)
},
post: function(a, i) {
var n = this;
return new Promise(function(e, t) {
n.makeRequest("POST", a, i, e, t)
}
)
},
del: function(a, i) {
var n = this;
return new Promise(function(e, t) {
n.makeRequest("DELETE", a, i, e, t)
}
)
},
ajax: function(a, i, n) {
var r = this;
return new Promise(function(e, t) {
r.makeAjax(a, i, n, e, t)
}
)
}
}
}
return {
Exceptions: {
PermissionException: function(e) {
this.message = "Permission Denied for widget",
this.code = "403",
this.detail = e
},
AuthorizationException: function(e) {
this.message = "Authorization Exception",
this.code = "403",
this.detail = e
},
LimitException: function(e) {
this.message = "API Limit Exception",
this.code = "429",
this.detail = e
},
InternalServerException: function(e) {
this.message = "Internal Server Error",
this.code = "500",
this.detail = e
},
InvalidKeySpec: function(e) {
this.message = "Invalid Key Sepc provided",
this.code = "400",
this.detail = e
},
invalidTokenReceived: function(e) {
this.message = "Invalid Token received",
this.code = "400",
this.detail = e
},
widgetInterfaceException: function(e) {
this.code = e,
this.Message = {
200: "Success",
401: "Authentication Failure",
404: "Invalid Module API Name",
403: "Permission Denied"
}[e]
}
},
Utils: {
getCrmBasePath: function() {
return Crm && Crm.getCrmBasePath instanceof Function ? Crm.getCrmBasePath() : "/crm"
},
isMobileWidget: function() {
return !!CrmWidgets.Utils.getJSInterface()
},
getJSInterface: function() {
if ("undefined" != typeof WidgetJSInterface)
return WidgetJSInterface;
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.WidgetJSInterface) {
var t = prompt;
return {
getOauthToken: function() {
var e = {
action: "getOauthToken",
handShake: arguments[0]
};
return t(JSON.stringify(e))
},
openDetailsView: function() {
var e = {
action: "openDetailsView",
handShake: arguments[0],
Entity: arguments[1],
RecordID: arguments[2]
};
return t(JSON.stringify(e))
},
editRecord: function() {
var e = {
action: "editRecord",
handShake: arguments[0],
Entity: arguments[1],
RecordID: arguments[2]
};
return t(JSON.stringify(e))
},
addRecord: function() {
var e = {
action: "addRecord",
handShake: arguments[0],
Entity: arguments[1]
};
return t(JSON.stringify(e))
},
openWebTabWidget: function() {
var e = {
action: "openWebTabWidget",
handShake: arguments[0],
webTabSysRefName: arguments[1],
customPageLoadData: arguments[2]
};
return t(JSON.stringify(e))
}
}
}
},
PermissionHandler: function(t) {
return {
authorize: function(e) {
if (-1 === t.indexOf(e))
throw new CrmWidgets.Exceptions.PermissionException({
OperationPerformed: e,
OperationsAllowed: t
})
}
}
},
VersionHandler: function(e) {
return {
isBeta: function() {
return !e
}
}
},
DeepFreeze: function(a) {
return Object.getOwnPropertyNames(a).forEach(function(e) {
var t = a[e];
null !== t && "object" == typeof t && CrmWidgets.Utils.DeepFreeze(t)
}),
Object.freeze(a)
},
GetTabNameFromSysRef: function(e) {
if (!this.SysRefVSTabName) {
this.SysRefVSTabName = {};
var t = Crm.userDetails.MODULE_LIST;
for (module in t)
this.SysRefVSTabName[t[module].api_name] = module
}
var a = this.SysRefVSTabName[e];
if (a)
return a
},
GetSysRefFromTabName: function(e) {
var t = Crm.userDetails.MODULE_LIST[e];
if (t)
return t.api_name
},
GetTabIDFromTabName: function(e) {
var t = Crm.userDetails.MODULE_LIST[e];
if (t)
return t.id
},
requestFlusher: function(t) {
CrmWidgets.APIHelper.RequestPool.flush(function(e) {
if (e.category === t)
return !0
})
},
hideLoading: function() {
$(this).removeClass("widget_Frame_loading")
},
forceLoadStartupWidget: function() {
WidgetHandler.PopUp.render(WidgetHandler.WidgetConfig.Startup, {
ButtonPosition: "startup"
}, "startup", !0)
},
resolveConnectorAuthorize: function(e) {
var t = a[e];
t && t.resolve()
},
rejectConnectorAuthorize: function(e) {
var t = a[e];
t && (t.reject("authorize failed"),
delete a[e])
},
addConnectorAuthorizePromise: function(e, t) {
a[e] = t
},
getDeviceToken: function(e) {
var t;
try {
var a = CrmWidgets.Utils.getJSInterface().getOauthToken(e.handShake);
if (!e)
throw new CrmWidgets.Exceptions.InvalidKeySpec("Key Spec missing");
if (!a)
throw new CrmWidgets.Exceptions.invalidTokenReceived("Device Token not received");
var i = CryptoJS.AES.decrypt(a, e.key, {
iv: e.iv,
padding: CryptoJS.pad.Pkcs7,
mode: CryptoJS.mode.CBC
});
if (i) {
var n = i.toString(CryptoJS.enc.Utf8);
if (n && "" != n)
return "Zoho-oauthtoken " + n
}
t = "Device Token Decryption Failure"
} catch (e) {
t = "Device Token Decryption Failure"
}
throw new CrmWidgets.Exceptions.invalidTokenReceived(t)
},
GetCustomSettingsIDbyAPI: function(e) {
if (!this.CustomSettingsApiVsId) {
this.CustomSettingsApiVsId = {};
var t = WidgetHandler.WidgetConfig.Setup;
for (widget in t)
this.CustomSettingsApiVsId[t[widget].API_NAME] = widget
}
var a = this.CustomSettingsApiVsId[e];
if (a)
return a
},
openWebTab: function(e, t, a, i) {
return CrmWidgets.Utils.lyteTransitTo(t, a, "crm.tab.module.index-module", i),
!0
},
lyteTransitTo: function(e, t, a, i) {
var n = {
route: a,
dynamicParams: [e],
queryParams: {
widgetparams: JSON.stringify(t)
}
};
if ("_blank" === i) {
var r = Lyte.Router.getURL(n);
Utils.openUrl(r, "_blank")
} else
Lyte.Router.transitionTo(n)
},
deleteEntityFromCache: function(e) {
if (!CrmWidgets.Utils.isMobileWidget()) {
var t = this.GetTabNameFromSysRef(e);
crmTab.deleteFromCache(t)
}
},
refreshNotesInUI: function(e, t) {
CrmWidgets.Utils.isMobileWidget() || Notes.loadNotes(t, void 0, e, "")
},
getAudioNotifier: function() {
return this.AudioNotifier || (this.AudioNotifier = new Audio("/Platform/audio/Bell.wav")),
this.AudioNotifier
},
getDimensionCss: function(e, t) {
var a = {}
, i = /^[0-9\s]*[\s]?%/
, n = t.ALLOWED_PROP;
return isNaN(e.height) && isNaN(e.width) ? (i.test(e.height) || i.test(e.width)) && (-1 !== n.indexOf("HEIGHT") && i.test(e.height) && (a.height = parseInt(e.height.replace("%")) / 100,
a.height *= window.innerHeight),
-1 !== n.indexOf("WIDTH") && i.test(e.width) && (a.width = parseInt(e.width.replace("%")) / 100,
a.width *= window.innerWidth)) : (-1 !== n.indexOf("HEIGHT") && (void 0 !== t.MAX_HEIGHT ? a.height = e.height <= t.MAX_HEIGHT ? e.height : t.MAX_HEIGHT : a.height = e.height),
-1 !== n.indexOf("WIDTH") && (void 0 !== t.MAX_WIDTH ? a.width = e.width <= t.MAX_WIDTH ? e.width : t.MAX_WIDTH : a.width = e.width)),
a
}
},
APIHelper: {
APISpec: {
AddNotes: "/crm/v2/{0}/{1}/Notes",
AttachFileToNotes: "/crm/v2/Notes/{2}/Attachments",
AddAttachment: "/crm/v2/{0}/{1}/Attachments",
InsertRecord: "/crm/v2/{0}",
UpsertRecord: "/crm/v2/{0}/upsert",
GetRecordById: "/crm/v2/{0}/{1}",
GetAllRecord: "/crm/v2/{0}",
GetMultipleRecord: "/crm/v2/{0}",
UpdateRecord: "/crm/v2/{0}",
DeleteRecord: "/crm/v2/{0}/{1}",
DeleteRecords: "/crm/v2/{0}",
queryRecord: "/crm/v2/coql",
roles: "/crm/v2/settings/roles",
specificRole: "/crm/v2/settings/roles/{0}",
SearchRecord: "/crm/v2/{0}/search",
InvokeConnector: "/crm/connectorAPI/execute.do?nameSpace={0}",
InvokeCrmConnection: "/crm/v2/connections/{0}/actions/invoke",
ExecuteFunction: "/crm/v2/functions/{0}/actions/execute",
GetOrgVariable: "/crm/getOrgVariable.do?orgVariable={0}",
GetUsers: "/crm/v2/users",
GetUser: "/crm/v2/users/{0}",
GetOrgInfo: "/crm/v2/org",
GetRelatedRecords: "/crm/v2/{0}/{1}/{2}",
GetRelatedRecords_email: "/crm/v2/{0}/{1}/{2}/{3}",
UpdateRelatedList: "/crm/v2/{0}/{1}/{2}/{3}",
UpdateRelatedList_photo: "/crm/v2/{0}/{1}/{2}",
GetFields: "/crm/v2/settings/fields?module={0}",
GetModuleList: "/crm/v2/settings/modules",
GetAssignmentRules: "/crm/v2/settings/assignment_rules/{0}",
GetLayouts: "/crm/v2/settings/layouts?module={0}",
GetLayout: "/crm/v2/settings/layouts/{0}?module={1}",
GetRelatedList: "/crm/v2/settings/related_lists?module={0}",
GetCustomViews: "/crm/v2/settings/custom_views?module={0}",
GetCustomView: "/crm/v2/settings/custom_views/{0}?module={1}",
GetEmailFromAliases: "/crm/v2/settings/emails/from_aliases",
GetAllProfiles: "/crm/v2/settings/profiles",
GetAllTemplates: "/crm/v2/settings/templates?type={0}&module={1}"",
GetProfile: "/crm/v2/settings/profiles/{0}",
UpdateProfile: "/crm/v2/settings/profiles/{0}",
EnableAccountAccess: "/crm/enableAccountAccess.do",
Blueprint: "/crm/v2/{0}/{1}/actions/blueprint",
ZfsFile: "/crm/v2/files",
ViewAllActions: "/crm/v2/{0}/{1}/actions",
GetApprovalRecords: "/crm/v2/Approvals",
GetApprovalActions: "/crm/v2/{0}/{1}/actions/approvals?action={2}",
GetAuthorizeUrl: "/market/getConnectorAuthorizeMap.do?connectorNS={0}",
GetRevokeUrl: "/market/revokeAuthToken.do?connectorNS={0}",
GetSendmailUrl: "/crm/v2/{0}/{1}/actions/send_mail",
UpdateVoiceURL: "/crm/v2/phonebridge/voiceurl?callactivityid={0}&voiceurl={1}"
},
generatorURL: function() {
for (var e = arguments[0], t = arguments.length, a = 0; a < t - 1; a += 1) {
var i = new RegExp("\\{" + a + "\\}","gm");
e = e.replace(i, arguments[a + 1])
}
return e
},
RequestPool: new $.ZReqPool({
Worker: function(a, m) {
var e = a.obj;
(a && a.context && a.context.CONFIG && "21" == a.context.CONFIG.TYPE ? function(e) {
var t, a = JSON.stringify({
data: e.data,
type: e.type,
url: e.url
});
switch (v.HASHING_METHOD) {
case "SHA-256":
t = s("SHA-256", a);
break;
default:
var i = 0
, n = a.length
, r = 0;
if (0 < n)
for (; r < n; )
i = (i << 5) - i + a.charCodeAt(r++) | 0;
t = Promise.resolve(i)
}
return t
}(e) : Promise.resolve(void 0)).then(function(e) {
var t = a.obj;
return {
handlerType: "REG",
broadcastResult: !(t.beforeSend = function() {
"undefined" != typeof Crm && Crm.REQUEST_QUEUE && delete Crm.REQUEST_QUEUE[this.url + "---" + this.data]
}
),
request: t,
context: a.context.CONFIG,
requestHash: e,
WBC: i
}
}).then(t).then(function(e) {
var t = e.handlerType
, a = e.broadcastResult
, i = e.request
, o = e.requestHash
, n = e.WBC;
if ("REG" === t) {
var r = i.success
, s = i.error;
i.success = void 0,
i.error = void 0;
var d = $.ajax(i);
if (d.done(r).fail(s).always(function() {
m()
}),
a) {
var l, c = function(e) {
this.postMessage({
action: "mimicResponse",
data: e
}),
b(e)
}
.bind(n);
d.done(function() {
var e = arguments[0]
, t = arguments[2];
204 === t.status && (e = {
status: t.status,
statusText: t.statusText
}),
l = {
status: "DONE",
requestHash: o,
response: e
}
}).fail(function() {
l = {
status: "FAIL",
requestHash: o,
response: arguments[0].responseJSON
}
}).always(function() {
var n, r, s;
n = function() {
c(l)
}
,
r = w.REPETITION,
s = w.INTRAVEL,
new Promise(function(e, t) {
var a, i = 1;
a = setInterval(function() {
try {
r < i && (clearInterval(a),
e()),
i++,
n()
} catch (e) {
t(e)
}
}, s)
}
).then(function() {
var e = l;
I.then(function(e) {
var t = e.transaction(f.OBJECT_STORE_NAME, "readwrite");
return t.objectStore(f.OBJECT_STORE_NAME).delete(o),
t.complete
}).then(function() {
c(e)
})
})
})
}
} else if ("DEFER" === t) {
var g = (new Date).getTime()
, p = {
cachedPromise: i.cachedPromise,
timeStamp: g
};
h[o] = h[o] || [],
h[o].push(p);
var u = setTimeout(function() {
h[o] = h[o].filter(function(e) {
return e.timeStamp !== g || (e.cachedPromise.fail({
Error: "Request Timed Out"
}),
!1)
})
}, v.CLEANUP_DELAY);
p.setTimeoutID = u,
m()
}
})
}
}),
getRequester: function(e) {
return new n(e)
},
Requester: function(e) {
return n(e)
}
}
}
}();
function loadRecordTransition(e, t) {
var a = window.location.pathname
, i = Lyte.Router.getRoute(a)
, n = i.dynamicParams;
0 < n.length && null != n[1] && n[1] == e.RecordID && i.route === t.route ? Lyte.Router.getRouteInstance().refresh() : Lyte.Router.transitionTo(t)
}
function makeAPIDataJson(e, t) {
var a = "users" === e ? "users" : "data"
, i = {}
, n = t.trigger;
return n && (delete t.trigger,
i.trigger = n),
t instanceof Array || (t = [t]),
i[a] = t,
i
}
CrmWidgets.Utils.DeepFreeze(CrmWidgets.APIHelper),
Object.defineProperties(window, {
CrmWidget: {
enumerable: !0,
value: {
Telephony: void 0,
Detail: void 0,
RelatedList: void 0
}
}
}),
Object.defineProperties(window, {
WidgetHandler: {
enumerable: !0,
value: {
WidgetConfig: void 0,
SetConfig: function(e) {
Object.defineProperty(WidgetHandler, "WidgetConfig", {
value: e,
writable: !1,
enumerable: !0,
configurable: !1
}),
CrmWidgets.Utils.DeepFreeze(WidgetHandler.WidgetConfig)
},
getWidget: function(e, t) {
if (WidgetHandler && WidgetHandler.WidgetConfig && WidgetHandler.WidgetConfig[e]) {
var a = WidgetHandler.WidgetConfig[e];
return t ? a[t] : a
}
},
getWidgetById: function(e, t) {
if (WidgetHandler && WidgetHandler.WidgetConfig && WidgetHandler.WidgetConfig[e]) {
var a = WidgetHandler.WidgetConfig[e];
for (key in a)
if (a[key].ID === t)
return a[key]
}
},
loadWidgets: function(e) {
var t = e.moduleID
, a = e.paramsID
, i = e.urlModule
, n = "undefined" != typeof WidgetHandler ? WidgetHandler.getWidget("RecordViewBC", t) : void 0;
if (n) {
var r = {
Entity: CrmWidgets.Utils.GetSysRefFromTabName(i),
EntityId: a
};
WidgetHandler.Record.render(n, r)
}
}
}
}
}),
WidgetHandler.Telephony = {
render: function() {
var e = WidgetHandler.getWidget("Telephony")
, t = "widgetTelephony";
if (e && (CrmWidget.Telephony = ZApp.LoadApp({
uniqueID: t,
location: t,
url: e.START_URL,
config: e,
onload: function() {
WidgetHandler.EventNotifier.pageLoad(CrmWidget.Telephony, {})
},
onunload: function() {
CrmWidgets.Utils.requestFlusher(e.ID)
}
}),
0 < $("#chatBarIcons").length)) {
$("#chatBarIcons tr:first").prepend("<td id='widgetIcon'><div style='border-left: 1px solid #ddd;padding: 2px 3px;' class='cP widgetIcon' onmouseenter='crmui.toolTip_show(this,\"center\",\"Telephony\")' onmouseleave='crmui.hideTooltip(this)' onclick='WidgetHandler.Telephony.toggle()' data-title='Telephony'><div class='telephony_Dialer_icon'></div></td>")
}
},
hide: function() {
$("#widget_Panel").hide()
},
show: function() {
CrmWidget.Telephony && $("#widget_Panel").show()
},
toggle: function(e) {
$("#widget_Panel").is(":visible") ? this.hide() : (CrmWidget.Telephony.SendEvent("DialerActive", e || {}),
this.show())
}
},
WidgetHandler.StandAlone = {
render: function() {
var e = WidgetHandler.getWidget("StandAlone")
, t = "widgetStandAlone";
e && (CrmWidget.StandAlone = ZApp.LoadApp({
uniqueID: t,
location: t,
url: e.START_URL,
config: e,
onunload: function() {
CrmWidgets.Utils.requestFlusher(e.ID)
}
}))
}
},
WidgetHandler.CustomAction = {
render: function(e, t) {
var a = "Widget_Frame_CustomAction" + e.ID
, i = document.createElement("iframe");
(i = $(i)).addClass("widget_Frame_CustomAction"),
i.attr("id", a),
i.attr("allow", "geolocation; microphone; camera; midi; encrypted-media"),
$("#actionOption").html(i[0]).show(),
crmui.showPopup("commonActionPage"),
CrmWidget.CustomActions = ZApp.LoadApp({
uniqueID: a,
location: a,
url: e.START_URL,
config: e,
onload: function() {
WidgetHandler.EventNotifier.pageLoad(CrmWidget.CustomActions, t)
},
onunload: function() {
CrmWidgets.Utils.requestFlusher(e.ID)
}
})
}
},
WidgetHandler.PopUp = WidgetHandler.CustomButtons = {
render: function(e, t, a, i) {
if (e.ISACTIVE || "0" === e.TYPE) {
if (!e.ISACTIVE && !i)
return;
var n, r = "widgetPopFrame" + e.ID, s = document.createElement("iframe");
if ((s = $(s)).addClass("widget_Frame_Popup"),
s.addClass("widget_Frame_loading"),
s.attr("id", r),
s.attr("allow", "geolocation; microphone; camera; midi; encrypted-media"),
CrmWidgets.Utils.isMobileWidget() && s.attr("sandbox", "allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-top-navigation-by-user-activation"),
$("#CBWidgetPopUpRespContent").html(s[0]),
$("#CBWidgetPopUp .popup-model-header.f21").text(e.NAME),
$("#CBWidgetExecutedPage").val(a),
s.load(CrmWidgets.Utils.hideLoading),
e.dimensionSpec) {
var o = CrmWidgets.Utils.getDimensionCss(e, e.DIMENSION);
s.css(o)
}
switch (a) {
case "eachRecord":
n = "ListViewEachRecord";
break;
case "listView":
n = "ListView";
break;
case "view":
case "viewEntity":
n = "DetailView";
break;
case "edit":
case "cbedit":
n = "EditView";
break;
case "create_clone":
case "createclone":
n = "CreateOrCloneView";
break;
case "startup":
n = "StartUp",
$("#CBWidgetPopUp .widgetPopup").addClass("startupWidget"),
$(".startupWidget .newPopupCloseIcon").hide()
}
t.ButtonPosition = n,
CrmWidget.CustomButton = ZApp.LoadApp({
uniqueID: r,
location: r,
url: e.START_URL,
config: e,
onload: function() {
WidgetHandler.EventNotifier.pageLoad(CrmWidget.CustomButton, t)
},
onunload: function() {
CrmWidgets.Utils.requestFlusher(e.ID)
}
})
} else {
$("#CBWidgetPopUp .popup-model-header.f21").text(e.NAME);
var d = $("#CBWidgetPopUpRespContent");
d.html('<table class="borderCollapse h100p w100p"><tr><td class="vam txt-ctr color7">' + I18n.getMsg("crm.label.widgets.error.feature.unsupported") + "</td></tr></table>"),
d.addClass("widget_Frame_Popup").css({
position: "absolute",
"min-height": "160px",
background: "#fff"
})
}
setTimeout(function() {
if (!CrmWidgets.Utils.isMobileWidget()) {
var e = $("#CBWidgetPopUp")
, t = Utils.windowHeight;
e.addClass("zcrm-show"),
e.css("max-height", t - 80 + "px"),
freezeBackground(),
"startup" !== a && ($("#CBWidgetPopUp .widgetPopup").removeClass("startupWidget"),
$("#CBWidgetPopUp .newPopupCloseIcon").show()),
e.show()
}
}, 150)
},
close: function(e) {
if ($("#multipleFieldsEditPop").is(":visible"))
return ProcessFlow.validateAndClosePopUp(),
void removeFreezeLayer();
var t = $("#CBWidgetPopUp");
if (t.removeClass("zcrm-show"),
t.hide(),
$("#CBWidgetPopUpRespContent").empty(),
removeFreezeLayer(),
e) {
var a = null
, i = $("#CBWidgetExecutedPage");
i && (a = i.val()),
"viewEntity" === a || "relatedlist" === a ? ("undefined" != typeof CustomButtonJSObjectInit && (CustomButtonJSObjectInit.checkBox = {}),
reloadCurrentEntityView()) : "eachRecord" !== a && "listView" !== a || crmListView.reloadCurrentListView()
}
}
},
WidgetHandler.SalesSignals = {
show: function(e, t) {
var a = e.signal
, i = e.id
, n = a.id
, r = crmNTCGlobal.getPageLoadDataForWidget(e, t)
, s = WidgetHandler.WidgetConfig.SalesSignals[n];
if (s.ISACTIVE) {
var o = "signalPlatformIframeContent_" + i
, d = $(o);
d.attr("id", o),
d.load(CrmWidgets.Utils.hideLoading),
CrmWidget.SalesSignals || (CrmWidget.SalesSignals = {}),
CrmWidget.SalesSignals[n] = ZApp.LoadApp({
uniqueID: o,
location: o,
url: s.START_URL,
config: s,
onload: function() {
WidgetHandler.EventNotifier.pageLoad(CrmWidget.SalesSignals[n], r)
},
onunload: function() {
CrmWidgets.Utils.requestFlusher(s.ID)
}
})
} else
$("#ntcPlatformIframeWrap_" + i).html('<table class="borderCollapse h100p w100p"><tr><td class="vam txt-ctr color7">' + I18n.getMsg("crm.label.widgets.error.feature.unsupported") + "</td></tr></table>").addClass("h150").css("border", "1px solid #e9e9e9")
},
render: function(e, t, a) {
if (e.ISACTIVE) {
$("#SignalWidgetPopup").css({
"z-index": 249
}),
freezeBackground(),
$("#FreezeLayer").css({
display: "block",
opacity: ".1",
"z-index": 31
});
var i = "signalWidgetPopFrame_" + e.ID
, n = document.createElement("iframe");
(n = $(n)).addClass("signal_Widget_Frame_Popup"),
n.addClass("widget_Frame_loading"),
n.attr("id", i),
n.attr("allow", "geolocation; microphone; camera; midi; encrypted-media"),
$("#signalWidgetPopupTitle").text(e.NAME),
$("#SignalWidgetPopUpRespContent").html(n[0]),
n.load(CrmWidgets.Utils.hideLoading),
CrmWidget.SalesSignals || (CrmWidget.SalesSignals = {}),
CrmWidget.SalesSignals[a] = ZApp.LoadApp({
uniqueID: i,
location: i,
url: e.START_URL,
config: e,
onload: function() {
WidgetHandler.EventNotifier.pageLoad(CrmWidget.SalesSignals[a], t)
},
onunload: function() {
CrmWidgets.Utils.requestFlusher(e.ID)
}
})
} else {
var r = $("#SignalWidgetPopUpRespContent");
$("#SignalWidgetPopup .popup-model-header.f21").text(e.NAME),
r.html('<table class="borderCollapse h100p w100p"><tr><td class="vam txt-ctr color7">' + I18n.getMsg("crm.label.widgets.error.feature.unsupported") + "</td></tr></table>"),
r.addClass("widget_Frame_Popup").css({
position: "absolute",
"min-height": "160px",
background: "#fff"
})
}
setTimeout(function() {
var e = $("#SignalWidgetPopup");
e.addClass("zcrm-show"),
freezeBackground(),
e.show()
}, 150)
},
close: function() {
var e = $("#SignalWidgetPopup");
e.removeClass("zcrm-show"),
e.hide(),
$("#SignalWidgetPopUpRespContent").empty(),
removeFreezeLayer()
}
},
WidgetHandler.Settings = {
render: function(e, t) {
var a = WidgetHandler.getWidget("Settings", t);
if (a) {
var i = $("#settingWidgetContainer")
, n = "settingsWidget_" + a.ID
, r = document.createElement("iframe");
if (r.id = n,
1 === a.SOURCE) {
var s = Utils.windowHeight - i.offset().top - 28;
r.setAttribute("style", "background: #fff; width: 100%; border: none; height: " + s + "px"),
r.setAttribute("class", "widget_Frame_settings widget_Frame_loading"),
$(r).load(CrmWidgets.Utils.hideLoading)
} else
r.setAttribute("class", "widget_Frame_settings"),
r.setAttribute("scrolling", "no");
$("#ExtensionName").html(e + " - Settings"),
r.setAttribute("allow", "geolocation; microphone; camera; midi; encrypted-media"),
i.html(r),
setTimeout(function() {
crmLayout.Resize.Setup()
}, 0),
CrmWidget.Settings = ZApp.LoadApp({
uniqueID: n,
location: n,
url: a.START_URL,
config: a,
onload: function() {
WidgetHandler.EventNotifier.pageLoad(CrmWidget.Settings, {})
},
onunload: function() {
CrmWidgets.Utils.requestFlusher(a.ID)
}
}),
$(".pluginMainDiv #pluginPageContent").hide(),
$("#setUp_widget_Panel").show()
} else
crmui.showMsgBand("error", I18n.getMsg("crm.label.creator.noaccess"), 4e3, ""),
Utils.windowLocationHref(CrmWidgets.Utils.getCrmBasePath() + "/settings/index")
},
close: function() {
$("#setUp_widget_Panel").hide(),
$(".pluginMainDiv #pluginPageContent").show(),
$("#setupWidget").attr("src", "")
}
},
WidgetHandler.Record = {
render: function(e, t) {
var a, i;
"29" === e.TYPE ? (a = "#fullInfoDiv",
i = "widget_Frame_RecordView") : "28" === e.TYPE || "27" === e.TYPE ? (a = "#show",
i = "widget_Frame_RecordEdit") : "27" === e.TYPE ? (a = "#bcWraperDiv",
i = "widget_Frame_RecordBC") : "30" === e.TYPE && (a = "#widget_businessCard",
i = "widget_businessCard");
var n = document.createElement("iframe")
, r = i + "_" + e.ID;
if (n.id = r,
"28" === e.TYPE || "27" === e.TYPE) {
var s = Utils.windowHeight
, o = $("#mainMenuTabDiv").height()
, d = $("#wms-chatwindowcontainer").height()
, l = s - (o + (d || 0));
n.setAttribute("style", "height:" + l + "px;")
}
return n.setAttribute("class", i),
n.setAttribute("allow", "geolocation; microphone; camera; midi; encrypted-media"),
$(a).html(n),
Utils.showHideLoadingDiv(),
CrmWidget.Record || (CrmWidget.Record = {}),
CrmWidget.Record[r] = ZApp.LoadApp({
uniqueID: r,
location: r,
url: e.START_URL,
config: e,
onload: function() {
WidgetHandler.EventNotifier.pageLoad(CrmWidget.Record[r], t)
},
onunload: function() {
CrmWidgets.Utils.requestFlusher(e.ID)
}
}),
$("#widget_Record").show(),
n
},
close: function() {
$("#widget_Record").hide(),
$("#widgetRecord").attr("src", "")
}
},
WidgetHandler.RelatedList = {
render: function(e, t, a, i) {
if (e.ISACTIVE) {
var n = "RelatedList_" + t
, r = document.createElement("iframe");
(r = $(r)).attr("id", n),
i ? r.addClass("widget_Frame_relatedList_canvas") : r.addClass("widget_Frame_relatedList"),
r.addClass("widget_Frame_loading"),
r.attr("allow", "geolocation; microphone; camera; midi; encrypted-media"),
CrmWidgets.Utils.isMobileWidget() && r.attr("sandbox", "allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-top-navigation-by-user-activation");
var s = $("#customRelatedListDiv_" + t);
if (i ? s.html(r[0]) : s.html(r[0]).css({
"max-height": "700px"
}),
r.load(CrmWidgets.Utils.hideLoading),
e.dimensionSpec && !i) {
var o = CrmWidgets.Utils.getDimensionCss(e, e.DIMENSION);
r.css(o)
}
CrmWidget.RelatedList || (CrmWidget.RelatedList = {}),
CrmWidget.RelatedList[t] = ZApp.LoadApp({
uniqueID: n,
location: n,
url: e.START_URL,
config: e,
onload: function() {
WidgetHandler.EventNotifier.pageLoad(CrmWidget.RelatedList[t], a)
},
onunload: function() {
CrmWidgets.Utils.requestFlusher(e.ID)
}
})
} else
$("#customRelatedListDiv_" + t).html('<table class="borderCollapse h100p w100p"><tr><td class="vam txt-ctr color7">' + I18n.getMsg("crm.label.widgets.error.feature.unsupported") + "</td></tr></table>").addClass("h150").css("border", "1px solid #e9e9e9")
}
},
WidgetHandler.Blueprint = {
render: function(e, t, a) {
var i = $("#" + t)
, n = "undefined" != typeof WidgetHandler ? WidgetHandler.getWidget("Blueprint", e) : void 0
, r = n.ID;
if (n)
if (n.ISACTIVE) {
var s = "WidgetFrame_" + r
, o = document.createElement("iframe");
(o = $(o)).attr({
id: s,
frameborder: "0",
height: "100%",
allow: "geolocation; microphone; camera; midi; encrypted-media",
width: "100%"
}),
o.addClass("widget_Frame_Blueprint widget_Frame_loading"),
i.html(o[0]),
o.load(CrmWidgets.Utils.hideLoading),
CrmWidget.Blueprint || (CrmWidget.Blueprint = {}),
CrmWidget.Blueprint[r] = ZApp.LoadApp({
uniqueID: s,
location: s,
url: n.START_URL,
config: n,
onload: function() {
WidgetHandler.EventNotifier.pageLoad(CrmWidget.Blueprint[r], a || {})
},
onunload: function() {
CrmWidgets.Utils.requestFlusher(r)
}
})
} else
i.html('<table class="borderCollapse h100p w100p"><tr><td class="vam txt-ctr color7">' + I18n.getMsg("crm.label.widgets.error.feature.unsupported") + "</td></tr></table>")
}
},
WidgetHandler.HomePage = {
render: function(e) {
var t = $("#widget_" + e);
t.attr("style", "width:98%;height:88%;");
var a = "undefined" != typeof WidgetHandler ? WidgetHandler.getWidgetById("HomePage", e) : void 0;
if (a)
if (a.ISACTIVE) {
var i = "WidgetFrame_" + e
, n = document.createElement("iframe");
(n = $(n)).attr("id", i),
n.attr("frameborder", "0"),
n.attr("height", "100%"),
n.attr("width", "100%"),
n.addClass("widget_Frame_homePage"),
n.addClass("widget_Frame_loading"),
n.attr("allow", "geolocation; microphone; camera; midi; encrypted-media"),
t.html(n[0]),
n.load(CrmWidgets.Utils.hideLoading),
CrmWidget.HomePage || (CrmWidget.HomePage = {}),
CrmWidget.HomePage[e] = ZApp.LoadApp({
uniqueID: i,
location: i,
url: a.START_URL,
config: a,
onload: function() {
WidgetHandler.EventNotifier.pageLoad(CrmWidget.HomePage[e])
},
onunload: function() {
CrmWidgets.Utils.requestFlusher(a.ID)
}
})
} else
t.html('<table class="borderCollapse h100p w100p"><tr><td class="vam txt-ctr color7">' + I18n.getMsg("crm.label.widgets.error.feature.unsupported") + "</td></tr></table>")
}
},
WidgetHandler.WebTab = {
render: function(e, t, a) {
var i = "externalIframe_" + e.ID;
1 !== e.SOURCE && isNaN(t) || (t = ""),
$("#" + i).load(CrmWidgets.Utils.hideLoading);
var n = e.START_URL + t;
CrmWidget.WebTab = ZApp.LoadApp({
uniqueID: i,
location: i,
url: n,
config: e,
onload: function() {
CrmWidget.currentWidget = "WebTab",
a = a || WidgetHandler.Utils.fetchHistoryStateParam(),
WidgetHandler.EventNotifier.pageLoad(CrmWidget.WebTab, a || {})
},
onunload: function() {
CrmWidgets.Utils.requestFlusher(e.ID),
delete CrmWidget.currentWidget
}
})
}
},
WidgetHandler.SetupWidget = {
render: function(e, t) {
var a = WidgetHandler.getWidget("Settings", t);
if (a) {
var i = $("#settingWidgetContainer")
, n = "settingsWidget_" + a.ID
, r = document.createElement("iframe");
r.id = n,
r.setAttribute("style", "border: none;width: 100%;height:100%;float:left;"),
r.setAttribute("allow", "geolocation; microphone; camera; midi; encrypted-media"),
i.html(r),
setTimeout(function() {
crmLayout.Resize.Setup()
}, 0),
CrmWidget.Setup = ZApp.LoadApp({
uniqueID: n,
location: n,
url: a.START_URL,
config: a,
onload: function() {
CrmWidget.currentWidget = "Setup";
var e = WidgetHandler.Utils.fetchHistoryStateParam();
WidgetHandler.EventNotifier.pageLoad(CrmWidget.Setup, e || {})
},
onunload: function() {
CrmWidgets.Utils.requestFlusher(a.ID),
delete CrmWidget.currentWidget
}
}),
$("#setUp_widget_Panel").show()
} else
crmui.showMsgBand("error", I18n.getMsg("crm.label.creator.noaccess"), 4e3, ""),
Utils.windowLocationHref(CrmWidgets.Utils.getCrmBasePath() + "/settings/index")
}
},
WidgetHandler.Utils = {
getRequestParams: function(e) {
var t = []
, a = {}
, i = location.search;
if (i && "" !== i)
for (var n = i.substr(1).split("&"), r = n.length, s = 0; s < r; s++) {
var o = (t = n[s].split("="))[0]
, d = decodeURIComponent(t[1]);
if (e) {
if (o === e)
return d
} else
a[o] = d
}
return a
},
readForm: function() {
var e = $("form[name='createEntityNewForm']")[0]
, t = $(e).find("[data-sysRefName]").not(".subformTabl [data-sysRefName]")
, r = WidgetHandler.Utils.fieldData(t)
, a = $(e).find(".subformTabl");
0 < a.length && $.each(a, function(e, t) {
var a = t.getAttribute("sub-data")
, i = $(t).find("tbody tr")
, n = [];
$.each(i, function() {
var e = $(this).find("[data-sysRefName]")
, t = WidgetHandler.Utils.fieldData(e);
n.push(t)
}),
r[a] = n
});
var o = {
hdnProductId: "ID",
txtProduct: "Name",
itemDescription: "Description",
txtListPrice: "ListPrice",
hdnUnitPrice: "UnitPrice",
txtQty: "NewQuantity",
hdnOldQty: "OldQuantity",
hdnQtyStock: "InStock",
discount: "Discount",
discPc: "DiscountPerItem",
tax: "Tax",
prdTaxDet: "TaxDetection",
netTotal: "Total"
}
, i = $("#linesTbody tr")
, n = [];
$.each(i, function(e, t) {
var r = (t = $(t)).attr("id").replace("hrow", "")
, a = t.find("input")
, s = {};
$.each(a, function(e, t) {
var a = (t = $(t)).attr("id").replace(r, "")
, i = o[a]
, n = t.val();
i && (s[i] = n)
}),
n.push(s)
});
var s = {
Data: r
};
return n && 0 < n.length && (s.LineItems = n),
s
},
fieldData: function(e) {
var d = {};
return $.each(e, function(e, t) {
var a, i = (t = $(t)).attr("data-sysRefName");
if (t) {
var n = t.prop("type")
, r = t.attr("data-content-type");
switch (n) {
case "text":
if ("Lookup" === r) {
var s = t.val()
, o = t.data("id");
s && "" !== s && o && "" !== o && ((a = {}).name = s,
a.id = o)
} else
a = t.val();
break;
case "checkbox":
a = t.is(":checked");
break;
default:
a = t.val()
}
}
a = "" === a ? void 0 : a,
d[i] = a
}),
d
},
populateForm: function(e) {
var t, a, l = ["First_Name"];
if (e.$data ? (t = e.$data,
a = e.$lineItems) : t = e,
t) {
var c = $("#subFrmaddRowBtn");
jQuery.each(t, function(i, n) {
var e = $("table[sub-data='" + i + "']");
if (0 < e.length) {
for (var t = e.attr("id").split("_")[1], a = crmCommonModule.createEditJson.module, r = n.length, s = 1; s < r; s++)
crmTemplate.addSubFromRow(c, t, a, "2");
var o = e.find("tbody tr");
$.each(o, function(e, t) {
for (objKey in n[e]) {
var a = $(t).find("[data-sysRefName='" + objKey + "']")[0];
WidgetHandler.Utils.addFieldValues(i, n[e][objKey], a)
}
})
} else {
var d;
(d = l.includes(i) ? $("[data-sysRefName='" + i + "'][data-content-type='Text']")[0] : $("[data-sysRefName='" + i + "']")[0]) && WidgetHandler.Utils.addFieldValues(i, n, d)
}
})
}
if (a) {
var i = a[0]
, n = {
ISTAXABLE: !0,
PRODUCTCODE: void 0,
PRODUCTID: void 0,
PRODUCTNAME: void 0,
QUANTITY: 0,
QUANTITY_IN_DEMAND: 0,
QUANTITY_IN_STOCK: 0,
UNITPRICE: 0,
USAGE_UNIT: "Box",
VENDORID: "null"
}
, r = $.extend({}, n, i);
productDetails.addSave(r)
}
},
addFieldValues: function(e, t, a) {
var i = (a = $(a)).prop("type")
, n = a.attr("data-content-type");
switch (i) {
case "text":
if ("Lookup" === n) {
if (t.constructor === Object) {
var r = t.id
, s = t.name;
a.data("id", r),
a.val(s)
}
} else
a.val(t);
break;
case "textarea":
a.val(t);
break;
case "checkbox":
"boolean" == typeof t && a.prop("checked", t);
break;
case "select-multiple":
Array.isArray(t) && (populatePicklist(a, t),
a.val(t),
Utils.triggerEvent("change", a));
break;
case "select-one":
"string" == typeof t && (populatePicklist(a, [t]),
a.val(t),
Utils.triggerEvent("change", a))
}
},
resize: function(n, e, t) {
n = n instanceof HTMLElement ? $(n) : $("#" + n.id);
var a = e.height
, i = e.width
, r = e.hideParent;
n.css({
transition: "all .8s ease",
"-webkit-transition": "all .8s ease"
});
var s = function(e, t, a) {
var i = {};
void 0 !== e && (i.width = e + "px"),
void 0 !== t && (i.height = t + "px"),
a && (0 < e ? (freezeBackground(),
i.display = "block") : ($("#FreezeLayer").remove(),
i.display = "none")),
n.css(i)
}
.bind(void 0, i, a, t);
if (void 0 !== r) {
var o = n.parent();
r ? o.slideUp("slow", "swing", s) : (s(),
o.slideDown("slow", "swing"))
} else
s()
},
playSound: function() {
CrmWidgets.Utils.getAudioNotifier().play()
},
loadDetailPage: function(e) {
if (e.Entity && e.RecordID) {
var t = {
route: "crm.tab.module.entity.detail",
dynamicParams: [e.Entity, e.RecordID]
};
if ("Calls" !== e.Entity && "Tasks" !== e.Entity && "Events" !== e.Entity || (t.dynamicParams = ["Activities", e.RecordID],
t.queryParams = {
sub_module: e.Entity
}),
e.target && "_blank" === e.target) {
var a = Lyte.Router.getURL(t);
Utils.openUrl(a, "_blank")
} else
loadRecordTransition(e, t);
WidgetHandler.PopUp.close()
}
},
loadEditPage: function(e) {
if (e.Entity && e.RecordID) {
var t = {
route: "crm.tab.module.entity.edit",
dynamicParams: [e.Entity, e.RecordID]
};
if (e.target && "_blank" === e.target) {
var a = Lyte.Router.getURL(t);
Utils.openUrl(a, "_blank")
} else
loadRecordTransition(e, t);
WidgetHandler.PopUp.close()
}
},
loadCreatePage: function(e) {
if (e.Entity) {
var t = {
route: "crm.tab.module.create",
dynamicParams: [e.Entity]
};
if (e.target && "_blank" === e.target) {
var a = Lyte.Router.getURL(t);
Utils.openUrl(a, "_blank")
} else {
var i = window.location.pathname
, n = Lyte.Router.getRoute(i)
, r = n.dynamicParams;
0 < r.length && null != r[0] && r[0] == e.Entity && n.route === t.route ? Lyte.Router.getRouteInstance().refresh().data = {
refreshPage: !0
} : Lyte.Router.transitionTo(t)
}
WidgetHandler.PopUp.close()
}
},
fetchHistoryStateParam: function() {
if (history.state && history.state.meta && history.state.meta.matched && history.state.meta.matched.queryParams) {
var e = history.state.meta.matched.queryParams;
if (e instanceof Object)
try {
return e.widgetparams ? JSON.parse(e.widgetparams) : {}
} catch (e) {
return
}
}
}
},
WidgetHandler.EventNotifier = {
pageLoad: function(e, t) {
e && e.SendEvent("PageLoad", t || {})
},
historyPopState: function(e) {
var t = WidgetHandler.Utils.fetchHistoryStateParam();
e && t && e.SendEvent("HistoryPopState", t)
},
dial: function(e, t, a, i) {
var n = CrmWidgets.Utils.GetSysRefFromTabName(t);
if (CrmWidget.Telephony) {
var r = {
Number: e,
EntityType: n,
EntityID: a,
CallActivityID: i
};
return CrmWidget.Telephony.SendEvent("Dial", r),
!1
}
return !0
}
},
CrmWidgets.Utils.messageHandler = function(e) {
var t = (P = e.data).sdkVersion
, a = e.config
, i = e.callback
, n = e.callbackFailure
, r = e.iframe;
if (i && "function" == typeof i) {
var s = new CrmWidgets.APIHelper.getRequester({
ID: a.ID,
EMBEDDED_APP_ID: a.EMBEDDED_APP_ID,
NAME: a.NAME,
CONFIG: a
})
, o = new CrmWidgets.Utils.PermissionHandler(a.PERMISSIONS)
, d = new CrmWidgets.Utils.VersionHandler(t);
if ("CREATE" === P.category) {
if (o.authorize("CREATE"),
"NOTES" === P.type) {
var l = P.APIData;
l = JSON.stringify(l);
var c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.AddNotes, P.Entity, P.RelatedID);
s.post(c, l).then(function(e) {
var t = e;
return e.data && (CrmWidgets.Utils.refreshNotesInUI(P.Entity, P.RelatedID),
d.isBeta() && (t = e.data[0])),
t
}).then(i).catch(n)
} else if ("ATTACHMENT" === P.type) {
var g = (l = P.APIData).FileData
, p = l.FileName;
(D = new FormData).append("file", g, p);
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.AddAttachment, P.Entity, P.RelatedID);
s.post(c, D).then(function(e) {
var t = e;
return e.data && (CrmWidgets.Utils.refreshNotesInUI(P.Entity, P.RelatedID),
d.isBeta() && (t = e.data[0])),
t
}).then(i).catch(n)
} else if ("RECORD" === P.type) {
l = P.APIData,
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.InsertRecord, P.Entity);
"UPSERT" === l.action && (c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.UpsertRecord, P.Entity),
delete l.action),
!Array.isArray(l) && "object" != typeof l || (l = makeAPIDataJson(P.Entity, l)),
l = JSON.stringify(l),
s.post(c, l).then(function(e) {
return CrmWidgets.Utils.deleteEntityFromCache(P.Entity),
d.isBeta() && e.data || e
}).then(i).catch(n)
}
} else if ("READ" === P.category) {
if (o.authorize("READ"),
(l = P.APIData).RelatedList) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetRelatedRecords, l.Entity, l.RecordID, l.RelatedList);
"photo" === l.RelatedList ? l.RESPONSE_TYPE = "stream" : "Emails" === l.RelatedList && l.RelatedRecordID && (c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetRelatedRecords_email, l.Entity, l.RecordID, l.RelatedList, l.RelatedRecordID),
delete l.RelatedRecordID),
delete l.Entity,
delete l.RecordID,
delete l.RelatedList,
s.get(c, l).then(function(e) {
return d.isBeta() && e.data || e
}).then(i).catch(n)
} else {
var u = (l = P.APIData).RecordID;
if (u) {
c = u instanceof Array ? (x = {
ids: u.join(",")
},
CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetMultipleRecord, l.Entity)) : CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetRecordById, l.Entity, l.RecordID),
s.get(c, x).then(function(e) {
return d.isBeta() && e.data ? e.data[0] : e
}).then(i).catch(n)
} else {
c = "";
if (l.criteria) {
var m = encodeURIComponent(l.criteria);
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetAllRecord, l.Entity) + "?filters=" + m
} else
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetAllRecord, l.Entity);
delete l.Entity,
s.get(c, l).then(function(e) {
return d.isBeta() && e.data || e
}).then(i).catch(n)
}
}
} else if ("UPDATE" === P.category) {
if (o.authorize("UPDATE"),
"RECORD" === P.type) {
l = P.APIData;
(Array.isArray(l) || "object" == typeof l) && (l = makeAPIDataJson(P.Entity, l)),
l = JSON.stringify(l);
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.UpdateRecord, P.Entity);
s.put(c, l).then(function(e) {
return CrmWidgets.Utils.deleteEntityFromCache(P.Entity),
d.isBeta() && e.data && e.data || e
}).then(i).catch(n)
} else if ("NOTES" === P.type) {
g = (l = P.APIData).FileData,
p = l.FileName;
(D = new FormData).append("file", g, p);
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.AttachFileToNotes, P.Entity, P.RecordID, P.RelatedRecordID);
s.post(c, D).then(function(e) {
var t = e;
return e.data && (CrmWidgets.Utils.refreshNotesInUI(P.Entity, P.RelatedID),
d.isBeta() && (t = e.data[0])),
t
}).then(i).catch(n)
} else if ("RELATED_RECORD" === P.type) {
var h;
if (P.APIData instanceof File) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.UpdateRelatedList_photo, P.Entity, P.RecordID, P.RelatedList);
(D = new FormData).append("file", P.APIData, P.APIData.name),
h = s.post(c, D)
} else {
l = {
data: [P.APIData]
};
l = JSON.stringify(l);
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.UpdateRelatedList, P.Entity, P.RecordID, P.RelatedList, P.RelatedRecordID);
h = s.put(c, l)
}
h.then(function(e) {
return CrmWidgets.Utils.deleteEntityFromCache(P.RelatedList),
d.isBeta() && e.data || e
}).then(i).catch(n)
} else if ("PROFILE" === P.type) {
l = P.APIData;
l = JSON.stringify(l);
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.UpdateProfile, P.ID);
s.put(c, l).then(function(e) {
return e.data || e
}).then(i).catch(n)
} else if ("VOICE_URL" === P.type) {
(l = P.APIData).VoiceURL = encodeURIComponent(l.VoiceURL);
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.UpdateVoiceURL, l.RecordID, l.VoiceURL);
s.put(c, l).then(function(e) {
return e.data || e
}).then(i).catch(n)
}
} else if ("DELETE" === P.category) {
if (o.authorize("DELETE"),
"RECORD" === P.type) {
var f = {};
c = P.RecordID instanceof Array ? (f = {
ids: P.RecordID.join()
},
(c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.DeleteRecords, P.Entity)).concat("?").concat(jQuery.param(f))) : CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.DeleteRecord, P.Entity, P.RecordID),
s.del(c).then(function(e) {
return CrmWidgets.Utils.deleteEntityFromCache(P.Entity),
d.isBeta() && e.data || e
}).then(i).catch(n)
} else if ("RELATED_RECORD" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.UpdateRelatedList, P.Entity, P.RecordID, P.RelatedList, P.RelatedRecordID);
s.del(c, l).then(function(e) {
return CrmWidgets.Utils.deleteEntityFromCache(P.RelatedList),
d.isBeta() && e.data ? e.data[0] : e
}).then(i).catch(n)
}
} else if ("SEARCH" === P.category) {
if (o.authorize("READ"),
P.APIData) {
var v = (l = P.APIData).Entity
, w = l.Type
, I = l.Query;
delete l.Entity,
delete l.Type,
delete l.Query,
l[w] = I
} else {
v = P.Entity,
w = P.Type,
I = P.Query;
(l = {})[w] = I,
P.page && (l.page = P.page),
P.per_page && (l.per_page = P.per_page),
P.delay && (l.delay = P.delay)
}
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.SearchRecord, v);
s.get(c, l).then(i).catch(n)
} else if ("PAGEINFO" === P.category) {
o.authorize("READ");
var b = detailView.currentModule
, E = detailView.entityId;
if (b && Crm.userDetails.MODULE_LIST) {
var y = Crm.userDetails.MODULE_LIST[b];
if (y)
if (v = y.api_name) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetRecordById, v, E);
s.get(c, l).then(function(e) {
var t = void 0 !== e.data ? e.data[0] : e;
return {
entity: v,
data: t
}
}).then(i).catch(n)
}
}
} else if ("FUNCTIONS_EXECUTE" === P.category) {
o.authorize("READ");
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.ExecuteFunction, P.customFunctionName);
(C = P.data) && s.post(c, C.data, "", C.headers).then(i).catch(n)
} else if ("CRM_CONNECTION" === P.category) {
o.authorize("CONNECTOR");
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.InvokeCrmConnection, P.connectionName);
(C = P.data) && s.post(c, C.data, "").then(i).catch(n)
} else if ("CRM_WIZARD" === P.category)
wizardWidgetHandler.receiver(JSON.parse(P.data));
else if ("CRM_BLUEPRINT" === P.category)
ProcessFlow.proceedWidget();
else if ("CONNECTOR" === P.category)
if (o.authorize("CONNECTOR"),
P.type && "CONNECTOR_API" !== P.type) {
if ("CONNECTOR_AUTHORIZE" === P.type) {
A = P.nameSpace,
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetAuthorizeUrl, A);
s.get(c, D).then(function(e) {
if (void 0 !== e.RESULT && "SUCCESS" === e.RESULT) {
var t = e.AUTHORIZEURL;
Utils.openUrl(t, "widgetConnectorAuthorize", "width=600, height=600, top=200, left=400")
}
var a, i, n = new Promise(function(e, t) {
a = e,
i = t
}
), r = e.NAMESPACE, s = {
resolve: a,
reject: i
};
return CrmWidgets.Utils.addConnectorAuthorizePromise(r, s),
setTimeout(function() {
if (connectorAuthorizePromiseMap) {
var e = connectorAuthorizePromiseMap[r];
e && (e.reject("Timeout"),
delete connectorAuthorizePromiseMap[r])
}
}, 3e5),
n
}).then(i).catch(n)
} else if ("CONNECTOR_REVOKE" === P.type) {
A = P.nameSpace,
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetRevokeUrl, A);
s.post(c, D).then(i).catch(n)
}
} else {
var C = P.data
, A = P.nameSpace;
C.invokeType && "ISAUTHORIZE" === C.invokeType && (A = "isAuthorized_" + A);
var c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.InvokeConnector, A);
if (C) {
var _ = C.CONTENT_TYPE
, W = C.RESPONSE_TYPE;
if (_ && "multipart" === _) {
var P = new FormData;
if (C.FORWARD_TYPE && "data-binary" === C.FORWARD_TYPE ? P.append("forwardType", "data-binary") : P.append("forwardType", "multi"),
C.FILE) {
var R = C.FILE.fileParam
, T = C.FILE.file
, S = new File([T],T.name,{
type: T.type
});
P.append(R, S)
}
var L = C.VARIABLES;
!L && C.url && (L = {
url: C.url,
Header: C.Header
});
var O = {
parts: C.PARTS,
partBoundary: C.PARTS_BOUNDARY
}
, U = JSON.stringify(O);
P.append("partContents", U),
P.append("VARIABLES", JSON.stringify(L)),
void 0 !== W && P.append("resultType", W),
s.post(c, P).then(i).catch(n)
} else {
var x = {
VARIABLES: C
};
W && (c = c.concat("&resultType=").concat(W),
x.RESPONSE_TYPE = W),
s.ajax("POST", c, x).then(i).catch(n)
}
}
}
else if ("FILES" === P.category) {
if ("UPLOAD_FILE" === P.type)
if (o.authorize("CREATE"),
(l = P).FileData instanceof File) {
var D;
(D = new FormData).append("file", l.FileData, l.FileData.name);
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.ZfsFile);
s.post(c, D).then(function(e) {
return e
}).then(i).catch(n)
} else
n("Input is not of type 'File'");
else if ("DOWNLOAD_FILE" === P.type) {
l = {
id: P.id,
RESPONSE_TYPE: "stream"
};
o.authorize("READ");
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.ZfsFile);
s.get(c, l).then(function(e) {
return d.isBeta() && e.data || e
}).then(i).catch(n)
}
} else if ("BLUEPRINT" === P.category) {
if ("GET_BLUEPRINT_STATUS" === (l = P).action) {
o.authorize("READ");
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.Blueprint, l.Entity, l.RecordID);
s.get(c).then(function(e) {
return d.isBeta() && e.data || e
}).then(i).catch(n)
} else if ("UPDATE_BLUEPRINT_STATUS" === l.action) {
o.authorize("UPDATE");
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.Blueprint, l.Entity, l.RecordID);
l = JSON.stringify(l.BlueprintData),
s.put(c, l).then(function(e) {
return d.isBeta() && e.data && e.data || e
}).then(i).catch(n)
}
} else if ("APPROVALS" === P.category) {
if ("GET_ALL_ACTIONS" === (l = P).action) {
o.authorize("READ");
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.ViewAllActions, l.Entity, l.RecordID);
s.get(c).then(function(e) {
return d.isBeta() && e.data || e
}).then(i).catch(n)
} else if ("GET_APPROVAL_RECORDS" === l.action) {
o.authorize("READ");
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetApprovalRecords);
l.type && (c = c + "?type=" + l.type),
s.get(c).then(function(e) {
return d.isBeta() && e.data || e
}).then(i).catch(n)
} else if ("GET_APPROVALBYID" === l.action) {
o.authorize("READ");
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetApprovalRecords);
l.id && (c = c + "/" + l.id),
s.get(c).then(function(e) {
return d.isBeta() && e.data || e
}).then(i).catch(n)
} else if ("GET_APPROVALS_HISTORY" === l.action) {
o.authorize("READ");
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetApprovalRecords) + "/history";
s.get(c).then(function(e) {
return d.isBeta() && e.data || e
}).then(i).catch(n)
} else if ("UPDATE_APPROVAL" === l.action) {
o.authorize("UPDATE");
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetApprovalActions, l.Entity, l.RecordID, l.actionType);
l.comments && (c = c + "&comments=" + l.comments),
l.user && (c = c + "&user=" + l.user),
s.post(c).then(function(e) {
return d.isBeta() && e.data || e
}).then(i).catch(n)
}
} else if ("MAIL" === P.category) {
o.authorize("CREATE");
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetSendmailUrl, P.APIData.Entity, P.APIData.RecordID);
var N = P.APIData.APIData;
s.post(c, JSON.stringify(N)).then(function(e) {
return e
}).then(i).catch(n)
} else if ("QUERY" === P.category)
P.APIData && s.post(CrmWidgets.APIHelper.APISpec.queryRecord, JSON.stringify(P.APIData)).then(i).catch(n);
else if ("ROLES" === P.category) {
c = void 0 === P.roleId ? CrmWidgets.APIHelper.APISpec.roles : CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.specificRole, P.roleId);
s.get(c).then(i).catch(n)
} else if ("UI" === P.category) {
if (P.action.telephony) {
if ("MAXIMIZE" === P.action.telephony)
WidgetHandler.Telephony.show();
else if ("MINIMIZE" === P.action.telephony)
WidgetHandler.Telephony.hide();
else {
if ("NOTIFY" !== P.action.telephony)
return;
WidgetHandler.Utils.playSound()
}
i(!0)
} else if (P.action.record) {
var H = P.data;
H.Entity = CrmWidgets.Utils.GetTabNameFromSysRef(H.Entity);
var M = "200";
"OPEN" === P.action.record ? CrmWidgets.Utils.isMobileWidget() ? M = CrmWidgets.Utils.getJSInterface().openDetailsView(s.getHandShakeToken(), H.Entity, H.RecordID) : WidgetHandler.Utils.loadDetailPage(H) : "EDIT" === P.action.record ? CrmWidgets.Utils.isMobileWidget() ? M = CrmWidgets.Utils.getJSInterface().editRecord(s.getHandShakeToken(), H.Entity, H.RecordID) : WidgetHandler.Utils.loadEditPage(H) : "CREATE" === P.action.record ? CrmWidgets.Utils.isMobileWidget() ? M = CrmWidgets.Utils.getJSInterface().addRecord(s.getHandShakeToken(), H.Entity) : WidgetHandler.Utils.loadCreatePage(H) : "POPULATE" === P.action.record && WidgetHandler.Utils.populateForm(P.data),
"200" == M ? i(!0) : n(new CrmWidgets.Exceptions.widgetInterfaceException(M))
} else if (P.action.setting) {
if ("OPEN" === P.action.setting) {
var F = P.data
, j = F.target
, k = F.APIName;
if (k.includes("__")) {
(Q = CrmWidgets.Utils.GetCustomSettingsIDbyAPI(k)) && CrmWidgets.Utils.lyteTransitTo(Q, F.Message, "crm.settings.section.widget", j)
} else {
var B = Lyte.Router.getRoute(CrmWidgets.Utils.getCrmBasePath() + "/settings/" + k);
Lyte.Router.transitionTo(B)
}
}
} else if (P.action.popup)
"CLOSE" === P.action.popup && WidgetHandler.PopUp.close(),
"CLOSE_RELOAD" === P.action.popup && WidgetHandler.PopUp.close(!0),
i(!0);
else if ("RESIZE" === P.action) {
if (CrmWidgets.Utils.isMobileWidget())
return void i(!0);
var z = a.DIMENSION
, q = (z.ALLOWED_PROP,
P.data)
, G = CrmWidgets.Utils.getDimensionCss(q, z)
, V = !1;
"30" === a.TYPE ? 0 === G.height ? G.hideParent = !0 : G.hideParent = !1 : "55" === a.TYPE && (r = $("#widget_StandAlone_Panel")[0],
V = !0),
WidgetHandler.Utils.resize(r, G, V),
i(!0)
} else if (P.action.webTab) {
if ("OPEN" === P.action.webTab) {
var J = (ee = P.data).Entity
, Z = ee.Message
, Y = ee.target;
M = "200";
if (CrmWidgets.Utils.isMobileWidget()) {
var K = JSON.stringify({
data: JSON.stringify(Z),
dataType: typeof Z
});
return void ("200" == (M = CrmWidgets.Utils.getJSInterface().openWebTabWidget(s.getHandShakeToken(), J, K)) ? i(!0) : n(new CrmWidgets.Exceptions.widgetInterfaceException(M)))
}
if (b = CrmWidgets.Utils.GetTabNameFromSysRef(J)) {
var X = Crm.userDetails.MODULE_LIST[b];
if (X) {
var Q = X.id;
if (WidgetHandler.WidgetConfig && WidgetHandler.WidgetConfig.WebTab && WidgetHandler.WidgetConfig.WebTab[Q])
return CrmWidgets.Utils.openWebTab(Q, b, Z, null, Y),
void i(!0)
}
}
i(!1)
} else if ("HISTORY" === P.action.webTab) {
l = P.data;
new Promise(function(e) {
var t = Lyte.Router.getRouteInstance().transition.info.route
, a = Lyte.Router.getRouteInstance().transition.info.dynamicParams;
Lyte.Router.transitionTo({
route: t,
dynamicParams: a,
queryParams: {
widgetparams: JSON.stringify(l)
}
}),
e(!0)
}
).then(i).catch(n)
}
} else if (P.action.StandAlone) {
if ("OPEN" === P.action.StandAlone) {
var ee, te = (ee = P.data).Message;
CrmWidgets.Utils.isMobileWidget() || WidgetHandler.WidgetConfig && WidgetHandler.WidgetConfig.StandAlone && (CrmWidget.StandAlone ? WidgetHandler.EventNotifier.pageLoad(CrmWidget.StandAlone, te || {}) : WidgetHandler.StandAlone.render(te),
i(!0)),
i(!1)
}
"CLOSE" === P.action.StandAlone && (WidgetHandler.StandAlone.hide(),
i(!0))
}
} else if ("CONFIG" === P.category) {
if (o.authorize("READ"),
"CURRENT_USER" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetUsers),
l = {
type: "CurrentUser"
};
s.get(c, l).then(function(e) {
return d.isBeta() && e.users ? e.users : e
}).then(i).catch(n)
} else if ("ORG_LEVEL_INFO" === P.type) {
var ae = Crm.userDetails
, ie = {
deployment: ae.DEPLOYMENT,
zgid: ae.ZGID,
zuid: ae.ZUID
};
(Crm.isVertical || Crm.isSolution) && (ie.appDetails = {
url: window.location.protocol + "//" + window.location.hostname,
name: Crm.Vertical.appName
}),
new Promise(function(e) {
return e(ie)
}
).then(i).catch(n)
} else if ("CREATEUSER" === P.type) {
o.authorize("CREATE");
l = P.APIData,
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetUsers);
var ne = JSON.stringify(l);
s.post(c, ne).then(function(e) {
return d.isBeta() && e.users ? e.users : e
}).then(i).catch(n)
} else if ("EDITUSER" === P.type) {
o.authorize("UPDATE");
l = P.APIData,
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetUser, l.id),
ne = JSON.stringify(l.userobject);
s.put(c, ne).then(function(e) {
return d.isBeta() && e.users ? e.users : e
}).then(i).catch(n)
} else if ("DELETEUSER" === P.type) {
o.authorize("DELETE");
l = P.APIData,
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetUser, l.id);
s.del(c).then(function(e) {
return d.isBeta() && e.users ? e.users : e
}).then(i).catch(n)
} else if ("VARIABLE" === P.type) {
var re = P.nameSpace;
"object" == typeof re && (re = re.apiKeys.toString());
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetOrgVariable, re);
s.get(c, l).then(i).catch(n)
} else if ("ORG" === P.type) {
c = CrmWidgets.APIHelper.APISpec.GetOrgInfo;
s.get(c, void 0).then(function(e) {
return d.isBeta() && e.org ? e.org[0] : e
}).then(i).catch(n)
}
} else if ("ACTION" === P.category) {
if ("CUSTOM_ACTION_SAVE_CONFIG" === P.type && wfCustomActions.selectedAction && wfCustomActions.selectedAction.widgetId === a.ID && (wfCustomActions.SavedConfig = P.object,
wfCustomActions.validateCustomAction() ? (wfCustomActions.saveCustomAction(),
i(!0)) : n(!1)),
"ENABLE_ACCOUNT_ACCESS" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.EnableAccountAccess);
s.post(c).then(function() {
WidgetHandler.PopUp.close()
}).then(i).catch(n)
}
} else if ("USER" === P.category) {
if (o.authorize("READ"),
P.ID) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetUser, P.ID);
s.get(c, void 0).then(function(e) {
return d.isBeta() && e.users ? e.users[0] : e
}).then(i).catch(n)
} else if (P.Type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetUsers),
l = {
type: P.Type
};
P.page && (l.page = P.page),
P.per_page && (l.per_page = P.per_page),
s.get(c, l).then(function(e) {
return d.isBeta() && e.users || e
}).then(i).catch(n)
}
} else if ("META" === P.category) {
if ("FIELD_LIST" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetFields, P.Entity);
s.get(c, void 0).then(i).catch(n)
} else if ("MODULE_LIST" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetModuleList);
s.get(c, void 0).then(i).catch(n)
} else if ("ASSIGNMENT_RULES" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetAssignmentRules, P.Entity);
s.get(c, void 0).then(i).catch(n)
} else if ("LAYOUTS" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetLayouts, P.Entity);
s.get(c, void 0).then(i).catch(n)
} else if ("LAYOUT" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetLayout, P.Id, P.Entity);
s.get(c, void 0).then(i).catch(n)
} else if ("RELATED_LIST" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetRelatedList, P.Entity);
s.get(c, void 0).then(i).catch(n)
} else if ("CUSTOM_VIEWS" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetCustomViews, P.Entity);
s.get(c, void 0).then(i).catch(n)
} else if ("CUSTOM_VIEW" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetCustomView, P.Id, P.Entity);
s.get(c, void 0).then(i).catch(n)
} else if ("EMAIL" === P.type && "GET_ALIAS" === P.subType) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetEmailFromAliases);
s.get(c, void 0).then(i).catch(n)
}
} else if ("PROFILES" === P.category) {
if ("GET_ALL_PROFILES" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetAllProfiles);
s.get(c, void 0).then(function(e) {
return e
}).then(i).catch(n)
} else if ("GET_PROFILE" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetProfile, P.ID);
s.get(c, void 0).then(function(e) {
return e.users ? e.users[0] : e
}).then(i).catch(n)
}
} else if ("TEMPLATES" === P.category) {
if ("GET_ALL_TEMPLATES" === P.type) {
c = CrmWidgets.APIHelper.generatorURL(CrmWidgets.APIHelper.APISpec.GetAllTemplates, P.Type, P.Entity);
s.get(c, void 0).then(function(e) {
return e
}).then(i).catch(n)
}
}
}
}
,
$(document).ready(function() {
ZApp.Bootstrap({
EventListeners: {
CRM_EVENT: CrmWidgets.Utils.messageHandler
}
})
}),
window.addEventListener("message", function(e) {
"string" == typeof e.data && -1 < e.data.indexOf("CONNECTOR_SUCCESS") && CrmWidgets.Utils.resolveConnectorAuthorize(e.data.replace("CONNECTOR_SUCCESS_", "")),
"string" == typeof e.data && -1 < e.data.indexOf("CONNECTOR_ERROR") && CrmWidgets.Utils.rejectConnectorAuthorize(e.data.replace("CONNECTOR_ERROR_", ""))
}),
window.addEventListener("popstate", function() {
CrmWidget && CrmWidget.currentWidget && WidgetHandler.EventNotifier.historyPopState(CrmWidget[CrmWidget.currentWidget])
});
var crmWidgetsObj = {
STATUS: !1,
ERROR_POPUP_DELAY: 15e8,
ERROR: "error",
SUCCESS: "success",
SUCCESS_POPUP_DELAY: 3e3,
timer: 0,
AJAX_TYPE: {
GET: "GET",
POST: "POST",
PUT: "PUT",
DELETE: "DELETE"
},
URL: "/crm/v2/settings/widgets"
};
crmWidgetsObj.URL_POSITION = crmWidgetsObj.URL + "/position",
crmWidgetsObj.TYPE = {
INSTALLED: "installed",
UNINSTALLED: "uninstalled",
ORG: "org"
},
crmWidgetsObj.file = "",
crmWidgetsObj.regex = /[^~`^*(){}[\]|\;"<>\\]/g,
crmWidgetsObj.dependancy = "",
crmWidgetsObj.installedWidgets = [],
crmWidgetsObj.prevHtml = "",
crmWidgetsObj.currentCategory = "",
crmWidgetsObj.depObj,
crmWidgetsObj.errorCode = {
DEFAULT_URL: {
url: Crm.getCrmBasePath() + "/ShowTab.do?module=Setup",
data: {
module: "Setup",
toolTip: "Setup",
isFromBack: "true",
fetchNotifications: "true",
isload: "true",
clearCache: "false"
}
},
INTERNAL_ERROR: {
code: "INTERNAL_ERROR",
message: I18n.getMsg("crm.label.widgets.error.internal")
},
CANNOT_DELETE: {
code: "CANNOT_DELETE",
message: I18n.getMsg("crm.label.widgets.error.cannotdelete")
},
UNCONFIRMED_EMAIL: {
code: "UNCONFIRMED_EMAIL",
error_popup: !0,
width: "500px",
previousState: !0,
message: I18n.getMsg("crm.label.widgets.error.email.unconfirmed")
},
LIMIT_EXCEEDED: {
code: "LIMIT_EXCEEDED",
error_popup: !0,
width: "500px",
previousState: !0,
message: I18n.getMsg("crm.massmail.limit.title")
},
INVALID_INPUT: {
code: "INVALID_DATA",
message: I18n.getMsg("crm.label.widgets.error.internal")
},
PATTERN_NOT_MATCHED: {
code: "PATTERN_NOT_MATCHED",
message: I18n.getMsg("crm.label.widgets.properinput")
},
INVALID_URL: {
code: "INVALID_URL",
message: I18n.getMsg("crm.label.widgets.error.url")
},
CONNECTION_TIMEOUT: {
code: "CONNECTION_TIMEOUT",
message: I18n.getMsg("crm.label.widgets.error.connection.timeout")
},
AUTHORIZATION_FAILED: {
code: "AUTHORIZATION_FAILED",
message: I18n.getMsg("crm.label.widgets.error.authorization")
},
NO_PERMISSION: {
code: "NO_PERMISSION",
message: I18n.getMsg("crm.label.cf.error.authorization")
},
NO_DATA: {
code: "NO_DATA",
message: I18n.getMsg("crm.label.widgets.error.nodata")
},
IMPROPER_FILE: {
code: "IMPROPER FILE",
message: I18n.getMsg("crm.label.widgets.propfile")
},
FEATURE_NOT_AVAILABLE: {
code: "FEATURE_NOT_AVAILABLE",
message: I18n.getMsg("crm.label.widgets.error.feature.unsupported")
}
},
crmWidgetsObj.url = "/crm/v2/settings/widgets",
crmWidgetsObj.loadListView = function(a, e, t, i, n, r) {
var s = crmWidgetsObj.URL
, o = {
source: "crm"
};
i && (o.position = i),
crmWidgetsObj.dependancy && (o.dependancy = crmWidgetsObj.dependancy),
r && (crmWidgetsObj.depObj = r),
crmWidgetsObj.makeAjaxCall(s, crmWidgetsObj.AJAX_TYPE.GET, o, function(e) {
if ($("#" + a).html(Handlebars.templates.CrmWidgetsListViewHeaders()).css({
"z-index": 31
}),
$("#crmWidgetsListViewContentHeader").html(Handlebars.templates.CrmWidgetsListViewContentHeader()),
crmWidgetsObj.currentCategory = i,
e && e.crm_widgets) {
var t = e.crm_widgets;
i && "SETUP_PAGE" == i && (t.dep_obj = crmWidgetsObj.depObj,
t.forEach(function(e) {
e.installed = crmWidgetsObj.installedWidgets.contains(e.widgets_id)
})),
i && Utils.getValueFromObj(window, ["ProcessBuilder", "WidgetKey"]) === i && (t.dep_obj = crmWidgetsObj.depObj),
$("tbody#crmWidgetsListViewContent").html(Handlebars.templates.CrmWidgetsListViewContent(t))
} else
$("tbody#crmWidgetsListViewContent").html(Handlebars.templates.CrmWidgetsListViewContent(""));
crmui.showPopup(a),
n && $("#wid_row_" + n).addClass("lastActive"),
setTimeout(function() {
crmWidgetsObj.descSeemoreShow()
}, 500)
}, void 0)
}
,
crmWidgetsObj.makeAjaxCall = function(e, t, a, i, n) {
var r = {
"X-ZCSRF-TOKEN": csrfParamName + "=" + csrfToken
};
-1 < window.location.href.indexOf("/settings/widgets") && (r.isFrom = "widget"),
t = t || crmWidgetsObj.TYPE.POST,
!a || t != crmWidgetsObj.AJAX_TYPE.POST && t != crmWidgetsObj.AJAX_TYPE.PUT || (a = JSON.stringify(a)),
Utils.showHideLoadingDiv(!0),
(new crmRequestPool).initiate({
action: e,
type: t,
headers: r,
data: a,
success: function(e) {
Utils.showHideLoadingDiv(!1),
e && e.status && "error" == e.status ? (e.responseJSON = e,
n ? n(e) : crmWidgetsObj.showErrorMessage(e.responseJSON, !0, !0, void 0, !0)) : i(e)
},
error: function(e) {
Utils.showHideLoadingDiv(!1),
n ? n(e) : crmWidgetsObj.showErrorMessage(e.responseJSON, !0, !0, void 0, !0)
}
})
}
,
crmWidgetsObj.showErrorMessage = function(e, t, a, i, n, r, s) {
var o, d = crmWidgetsObj.errorCode;
if (Utils.showHideLoadingDiv(!1),
"AUTHENTICATION_FAILURE" !== (o = e ? e.code ? e.code : e : "") && "NO_CRM_ACCOUNT" !== o && (!s || 1 != s)) {
var l, c, g;
switch (o) {
case d.UNCONFIRMED_EMAIL.code:
l = d.UNCONFIRMED_EMAIL.error_popup,
c = d.UNCONFIRMED_EMAIL.message,
g = d.UNCONFIRMED_EMAIL.width,
i = d.UNCONFIRMED_EMAIL.previousState;
var p = {}
, u = crmConstants.helpUrl["help.domain.url"] + crmConstants.helpUrl["help.customization.widgets.support"];
p.widgetSupportHelpLink = I18n.getMsg("crm.label.widgets.getstarted.label1", u),
Lyte.Router.getRouteInstance().htmlContent = Handlebars.templates.CrmWidgetsWelcome(p);
break;
case d.INVALID_INPUT.code:
c = d.INVALID_INPUT.message;
break;
case d.INVALID_URL.code:
c = d.INVALID_URL.message;
break;
case d.PATTERN_NOT_MATCHED.code:
c = d.PATTERN_NOT_MATCHED.message;
break;
case d.CONNECTION_TIMEOUT.code:
c = d.CONNECTION_TIMEOUT.message;
break;
case d.AUTHORIZATION_FAILED.code:
c = d.AUTHORIZATION_FAILED.message;
break;
case d.NO_PERMISSION.code:
c = d.NO_PERMISSION.message;
break;
case d.CANNOT_DELETE.code:
c = d.CANNOT_DELETE.message;
break;
case d.NO_DATA.code:
c = d.NO_DATA.message;
break;
case d.IMPROPER_FILE.code:
return c = d.IMPROPER_FILE.message,
void $("#widgetsNoFile").html(c).show();
case d.FEATURE_NOT_AVAILABLE.code:
c = d.FEATURE_NOT_AVAILABLE.message;
break;
case d.LIMIT_EXCEEDED.code:
c = d.LIMIT_EXCEEDED.message;
break;
default:
c = d.INTERNAL_ERROR.message
}
l ? crmWidgetsObj.showErrorPopup(c, g, i) : (r ? crmui.showMsgBand(crmWidgetsObj.ERROR, c, r) : crmui.showMsgBand(crmWidgetsObj.ERROR, c, crmWidgetsObj.ERROR_POPUP_DELAY),
a && $("#crm-msg-close").on("click", function() {
crmWidgetsObj.restoreState(i)
}))
}
}
,
crmWidgetsObj.restoreState = function(e) {
hideFreezeLayer(),
removeFreezeLayer(),
e && Lyte.Router.transitionTo("crm.settings.index")
}
,
crmWidgetsObj.associatedWidget = function(e, t, a) {
switch (t) {
case "related_list":
case "RELATED_LIST":
CustomRelatedListObj.saveWidgetInfo(e);
break;
case "webtab":
case "WEBTAB":
webTabJSObject.saveWidgetInfo(e);
break;
case "custom_button":
case "CUSTOM_BUTTON":
CustomButtonJSObject.saveWidgetInfo(e);
break;
case "home_page_dashboard":
case "HOME_PAGE_DASHBOARD":
CrmDashboard.associateWidgets(e);
break;
case "SETUP_PAGE":
case "setup_page":
case "SETTINGS_WIDGET":
case "settings_widget":
crmSetup.associateWidgets(e, a);
break;
case "BLUEPRINT":
ProcessBuilder.WidgetHandler.associateWidgets(e, a)
}
}
,
crmWidgetsObj.showCreateWidgetPopUp = function(s) {
crmWidgetsObj.makeAjaxCall(crmWidgetsObj.URL_POSITION, crmWidgetsObj.AJAX_TYPE.GET, void 0, function(e) {
if (e && e.crm_widgets) {
for (var t = e.crm_widgets[0].category, a = Object.keys(t), i = [], n = a.length, r = 0; r < n; r++)
i[r] = t[a[r]];
void 0 !== s && s.includes("salessignals") ? ($("#CrmWidgetsForm").html(Handlebars.templates.CrmWidgetsForm({
categoryArray: i,
callFrom: s
})),
$("#widgetType").val("SALES_SIGNALS").change()) : $("#CrmWidgetsForm").html(Handlebars.templates.CrmWidgetsForm(i)),
crmui.showPopup(CrmWidgetsForm),
wfForm.initFormClick(),
wfForm.inputfieldFocus()
}
}, void 0)
}
,
crmWidgetsObj.createWidgets = function(i, n) {
if (crmui.hideMsgBand(1),
crmWidgetsObj.validateInput()) {
var r = $("#widgetsSave");
r.attr("disabled", !0);
var e = crmWidgetsObj.URL
, t = $("#widgetHosting").val()
, a = new FormData;
if (a.append(csrfParamName, encodeURIComponent(csrfToken)),
a.append("name", "" + $("#widgetFormName").val().trim()),
a.append("description", "" + $("#widgetDescription").val()),
a.append("type", "" + $("#widgetType").val()),
a.append("hosting", t),
"internal" === t) {
if (!crmWidgetsObj.file)
return r.attr("disabled", !1),
void $("#widgetsNoFile").text(I18n.getMsg("crm.label.widgets.error.fileupload")).show();
a.append("file", crmWidgetsObj.file),
a.append("start_url", $("#widgetIndexPage").val())
} else
a.append("base_url", $("#widgetExternalUrl").val());
var s = {
read: !0,
update: !0,
create: !0,
delete: !0,
connector: !0
};
a.append("permissions", JSON.stringify(s)),
i || Utils.showHideLoadingDiv(!0);
var o = new XMLHttpRequest;
o.open(crmWidgetsObj.AJAX_TYPE.POST, e, !0),
o.setRequestHeader("X-ZCSRF-TOKEN", csrfParamName + "=" + csrfToken),
o.setRequestHeader("X-CRM-ORG", crmZgid),
o.setRequestHeader("isFrom", "widget"),
o.send(a),
o.onload = function() {
i || Utils.showHideLoadingDiv(!1);
var e = JSON.parse(this.response);
if (200 == this.status)
if (crmWidgetsObj.file = "",
i)
$("#newRelatedListPopUpDiv").hide(),
crmui.showMsgBand("success", I18n.getMsg("crm.label.widgets.create.success"), 5e3),
crmWidgetsObj.loadListView("newRelatedListPopUpDiv", void 0, void 0, crmWidgetsObj.currentCategory, e.details.widgets_id);
else if (void 0 !== n && n.includes("salessignals"))
crmNTCGlobal.createWidSuccessCallBack(n, e);
else {
if (crmui.hidePopup("CrmWidgetsForm"),
0 === $(".contentRows").length)
Lyte.Router.getRouteInstance().refresh().data = {
isAjax: !1,
newWidgetId: e.details.widgets_id
};
else
Lyte.Router.getRouteInstance().refresh().data = {
isAjax: !0,
newWidgetId: e.details.widgets_id
};
crmui.showMsgBand("success", I18n.getMsg("crm.label.widgets.create.success"), 5e3)
}
else if (r.attr("disabled", !1),
"invalid_url" === e.message) {
var t = crmWidgetsObj.errorCode.INVALID_URL.message
, a = $("#widgetsUrlError");
a.text(t),
a.show()
} else
crmWidgetsObj.showErrorMessage(e.code, !0, !1, void 0, void 0, 1e8, void 0)
}
}
}
,
crmWidgetsObj.showInputFields = function(e) {
var t = $(".info_icon");
$("#widgetsSave").attr("disabled", !1),
$("#widgetsNoFile, #widgetsHostingError").hide();
var a = $("#widgetsExternal")
, i = $("#widgetsInternalUpload")
, n = $("#widgetsInternal")
, r = $("#widgetsInternalBase");
switch (t.hide(),
e) {
case "internal":
a.hide(),
i.show(),
n.show(),
"" != $("#widgetIndexPage2").val() && r.show(),
t.show(),
t.attr("onmouseover", "crmui.toolTip_show(this, 'left', '" + I18n.getMsg("crm.label.widgets.hosting.internal.info") + "');"),
t.attr("onmouseout", "crmui.toolTip_hide();");
break;
case "external":
i.hide(),
n.hide(),
r.hide(),
a.show(),
t.show(),
t.attr("onmouseover", "crmui.toolTip_show(this, 'left', '" + I18n.getMsg("crm.label.widgets.hosting.external.info") + "');"),
t.attr("onmouseout", "crmui.toolTip_hide();");
break;
default:
a.hide(),
i.hide(),
r.hide(),
n.hide()
}
}
,
crmWidgetsObj.deleteWidget = function(e) {
showDeletePopup(I18n.getMsg("crm.label.widgets.delete.confirmation.message"), "crm.label.widgets.delete.yes", "", "", this),
$("#deletepopup #deleteButton").unbind("click").click(function() {
crmWidgetsObj.deleteWidgetById(e)
})
}
,
crmWidgetsObj.deleteWidgetById = function(e) {
var t = crmWidgetsObj.URL + "/" + e;
hideAnimatePopup("deletepopup"),
crmWidgetsObj.makeAjaxCall(t, crmWidgetsObj.AJAX_TYPE.DELETE, void 0, function() {
Lyte.Router.getRouteInstance().refresh().data = {
isAjax: !0
},
crmui.showMsgBand("success", I18n.getMsg("crm.label.widgets.delete.success"), 5e3)
}, void 0)
}
,
crmWidgetsObj.closeWidgetPopup = function() {
hideFreezeLayer(),
crmui.hidePopup("newRelatedListPopUpDiv, CrmWidgetsForm");
var e = $("#tab_widgetName");
void 0 === e || void 0 === e.val() || 0 !== e.val().length && "null" != e.val() || ($("#widget_checkbox").prop("checked", !1),
$("#widgetNameDiv").addClass("hide"),
$("#save_webTab").addClass("inActiveSec")),
void 0 !== (e = $("#buttonAction")) && e.val("-1").trigger("change.select2"),
(e = $("#editor-menuprop")[0]) && e.ltProp("show", !0)
}
,
crmWidgetsObj.showAllAssociatedPlace = function() {
for (var e = $("#widgetsAssociatedPlaces").val().split(","), t = e.length, a = "", i = 0; i < t; i++)
a = a + I18n.getMsg("crm.label.widgets." + e[i]) + ",";
a = a.substring(0, a.length - 1),
$("#widgetsAPDiv").html(a)
}
,
crmWidgetsObj.onFileSelected = function(e) {
var t = $("#widgetsNoFile");
t.hide();
var a = (e = e || window.event).target.files[0];
if (a) {
var i = a.name
, n = a.size;
if ("zip" != i.substring(i.lastIndexOf(".") + 1).toLowerCase())
$(".uploadedfileName").html(""),
t.text(I18n.getMsg("crm.label.widgets.onlyzip")).show();
else if (26214400 < n)
$(".uploadedfileName").html(""),
t.text(I18n.getMsg("crm.mailmerge.filesize", 25)).show();
else {
var r = 1048576 < n ? Math.ceil(n / 1024 / 1024) + I18n.getMsg("MB") : Math.ceil(n / 1024) + I18n.getMsg("KB");
crmWidgetsObj.file = a,
$(".uploadbtnholder").addClass("fR").find('input[type="button"]').removeClass("primarybtn").addClass("newgreybtn").val(I18n.getMsg("crm.label.change")),
$(".uploadedfileName").text(i + " (" + r + ")").removeClass("dN")
}
}
}
,
crmWidgetsObj.renderSandboxDiffContent = function(e) {
var t = "<div>" + Handlebars.templates.CrmWidgetsDetailPopUp(e) + "</div>"
, a = $(t);
return a.find(".pp-header,.pp-footer,.info_icon,.uploadbtnholder,button").remove(),
a.find("table").attr("id", "widtable"),
a.find(".uploadedfileName").attr("id", "uploadedfileName"),
a.find("#widgetFormName,#widgetDescription,#widgetType,#widgetExternalUrl,#widgetIndexPage,#uploadedfileName,#widgetHosting,#widgetIndexPage2").addClass("sandboxDiffChanges"),
a.html()
}
,
crmWidgetsObj.showWidgetsPopUp = function(e, s) {
var o = JSON.parse(e);
crmWidgetsObj.makeAjaxCall(crmWidgetsObj.URL_POSITION, crmWidgetsObj.AJAX_TYPE.GET, void 0, function(e) {
if (e && e.crm_widgets) {
for (var t = e.crm_widgets[0].category, a = Object.keys(t), i = [], n = a.length, r = 0; r < n; r++)
i[r] = t[a[r]];
o.categoryArray = i,
void 0 !== s && s.includes("salessignals") ? $("#CrmWidgetsForm").html(Handlebars.templates.CrmWidgetsDetailPopUp({
json: o,
source: s
})) : $("#CrmWidgetsForm").html(Handlebars.templates.CrmWidgetsDetailPopUp({
json: o
})),
crmui.showPopup(CrmWidgetsForm),
wfForm.initFormClick(),
wfForm.inputfieldFocus()
}
}, void 0)
}
,
crmWidgetsObj.updateWidgets = function(e, n) {
crmui.hideMsgBand(1);
var r = $("#widgetsSave");
if (crmWidgetsObj.validateInput()) {
r.attr("disabled", !0);
var t = crmWidgetsObj.URL + "/" + e
, a = $("#widgetHosting").val()
, i = new FormData;
if (i.append(csrfParamName, encodeURIComponent(csrfToken)),
i.append("name", "" + $("#widgetFormName").val().trim()),
i.append("description", "" + $("#widgetDescription").val()),
i.append("type", "" + $("#widgetType").val()),
i.append("hosting", a),
"internal" === a) {
if (!crmWidgetsObj.file && "" == $("#widgetsInternalUpload .uploadedfileName").text())
return r.attr("disabled", !1),
void $("#widgetsNoFile").text(I18n.getMsg("crm.label.widgets.error.fileupload")).show();
crmWidgetsObj.file && i.append("file", crmWidgetsObj.file),
i.append("start_url", $("#widgetIndexPage").val())
} else
i.append("base_url", $("#widgetExternalUrl").val());
var s = {
read: !0,
update: !0,
create: !0,
delete: !0,
connector: !0
};
i.append("permissions", JSON.stringify(s));
var o = new XMLHttpRequest;
o.open(crmWidgetsObj.AJAX_TYPE.PUT, t, !0),
o.setRequestHeader("X-CRM-ORG", crmZgid),
o.send(i),
o.onload = function() {
var e = JSON.parse(this.response);
if (200 == this.status)
void 0 !== n && n.includes("salessignals") ? crmNTCGlobal.updateWidSuccessCallBack(n, e) : (crmWidgetsObj.file = "",
crmui.hidePopup("CrmWidgetsForm"),
Lyte.Router.getRouteInstance().refresh().data = {
isAjax: !0,
newWidgetId: e.details.widgets_id
},
crmui.showMsgBand("success", I18n.getMsg("crm.label.widgets.update.success"), 5e3));
else if (void 0 !== n && n.includes("salessignals")) {
var t = widget_name + "Sorry, Internal Error Occured! Please try again.";
crmNTCManage.showErrorMessage(t)
} else if (r.attr("disabled", !1),
"invalid_url" === e.message) {
var a = crmWidgetsObj.errorCode.INVALID_URL.message
, i = $("#widgetsUrlError");
i.text(a),
i.show()
} else
crmWidgetsObj.showErrorMessage(e.code, !0, !1, void 0, void 0, 1e8, void 0)
}
}
}
,
crmWidgetsObj.showOptionList = function(e) {
$(e).next("#settingActions").show()
}
,
crmWidgetsObj.mouseEnterActions = function(e) {
var t = $(e);
t.find(".settingsIcons").show(),
t.last("td").find(".assocFn").removeClass("vH")
}
,
crmWidgetsObj.mouseLeaveActions = function(e) {
var t = $(e);
t.find(".settingsIcons, #settingActions").hide(),
t.last("td").find(".assocFn").addClass("vH")
}
,
crmWidgetsObj.showCreatePopupInListView = function() {
crmWidgetsObj.prevHtml = $("#newRelatedListPopUpDiv").html(),
crmWidgetsObj.makeAjaxCall(crmWidgetsObj.URL_POSITION, crmWidgetsObj.AJAX_TYPE.GET, void 0, function(e) {
if (e && e.crm_widgets) {
for (var t = $("#newRelatedListPopUpDiv"), a = e.crm_widgets[0].category, i = Object.keys(a), n = [], r = i.length, s = 0; s < r; s++)
n[s] = a[i[s]];
var o = {};
o.categoryArray = n,
o.listView = !0,
o.type = crmWidgetsObj.currentCategory,
t.html(Handlebars.templates.CrmWidgetsForm(o)),
crmui.showPopup("newRelatedListPopUpDiv"),
t.removeClass("w800"),
t.css("width", "initial"),
select2ChangesInFields(t),
wfForm.initFormClick(),
wfForm.inputfieldFocus()
}
}, void 0)
}
,
crmWidgetsObj.showPreviousPopup = function() {
var e = $("#newRelatedListPopUpDiv");
e.html(crmWidgetsObj.prevHtml),
e.css("width", "1000px"),
crmui.showPopup("newRelatedListPopUpDiv")
}
,
crmWidgetsObj.validateInput = function() {
var e = !0;
if ($("#widgetFormName").val().trim())
if ("" != (n = getClrTxtPtnResChars($("#widgetFormName").val().trim(), crmWidgetsObj.regex))) {
var t = I18n.getMsg("crm.label.widgets.name");
$("#widgetsNameError").text(1 === n.length ? I18n.getMsg("crm.clearTextPattern.validationFail.alert", [t, n]) : I18n.getMsg("crm.clearTextPattern.validationFail.alert.moreThanOneChar", [t, n])).show(),
e = !1
} else
$("#widgetsNameError").hide();
else
$("#widgetsNameError").text(I18n.getMsg("crm.label.widgets.error.name")).show(),
e = !1;
var a = $("#widgetType").val();
a && "none" !== a ? $("#widgetsTypeError").hide() : ($("#widgetsTypeError").text(I18n.getMsg("crm.label.widgets.error.type")).show(),
e = !1);
var i = $("#widgetHosting").val();
if (i && "none" !== i)
if ($("#widgetsHostingError").hide(),
"internal" == i) {
if ($("#widgetIndexPage").val())
if ($("#widgetIndexPage").val().startsWith("/")) {
if ("" != (n = getClrTxtPtnResChars($("#widgetIndexPage").val(), crmWidgetsObj.regex))) {
t = I18n.getMsg("crm.label.widgets.indexpage");
$("#widgetsStartUrlError").text(1 === n.length ? I18n.getMsg("crm.clearTextPattern.validationFail.alert", [t, n]) : I18n.getMsg("crm.clearTextPattern.validationFail.alert.moreThanOneChar", [t, n])).show(),
e = !1
} else
$("#widgetsStartUrlError").hide()
} else
$("#widgetsStartUrlError").text(I18n.getMsg("crm.label.widgets.indexpage") + " " + I18n.getMsg("crm.condition.doesnot.startswith") + " /").show(),
e = !1;
else
$("#widgetsStartUrlError").text(I18n.getMsg("crm.label.widgets.error.start_url")).show(),
e = !1;
crmWidgetsObj.file || "" != $("#widgetsInternalUpload .uploadedfileName").text() ? $("#widgetsNoFile").hide() : ($("#widgetsNoFile").text(I18n.getMsg("crm.label.widgets.error.fileupload")).show(),
e = !1)
} else {
var n;
if ($("#widgetExternalUrl").val())
if ("" != (n = getClrTxtPtnResChars($("#widgetExternalUrl").val(), crmWidgetsObj.regex))) {
t = I18n.getMsg("crm.label.widgets.baseurl");
$("#widgetsUrlError").text(1 === n.length ? I18n.getMsg("crm.clearTextPattern.validationFail.alert", [t, n]) : I18n.getMsg("crm.clearTextPattern.validationFail.alert.moreThanOneChar", [t, n])).show(),
e = !1
} else
$("#widgetsUrlError").hide();
else
$("#widgetsUrlError").text(I18n.getMsg("crm.label.widgets.error.base_url")).show(),
e = !1
}
else
$("#widgetsHostingError").text(I18n.getMsg("crm.label.widgets.error.hosting")).show(),
e = !1;
return e
}
,
crmWidgetsObj.processFilter = function() {
var e = $("#CrmWidgetsCustomizationListView");
e.addClass("mT25");
var t = $("#widgetListTable .topEdition");
t.show(),
$(".lastActive").removeClass("lastActive");
var a = $("#widgetListTableFixed");
a.show();
var i = $("#widgetListTable")
, n = i.find("tr");
n.show();
var r = $("#nowidgetdiv")
, s = $("#crmWidgetCategoryList option:selected")
, o = $("#crmWidgetConfigList option:selected");
"all" !== o.val() && t.hide(),
r.hide();
var d = i.find("tbody");
d.show(),
n.each(function() {
var e = $(this);
"-1" !== s.val() && (e.hasClass(s.val()) || e.hide()),
"all" !== o.val() && (e.hasClass(o.val()) || e.hide())
}),
0 === $(".contentRows:visible").length && (a.hide(),
r.fadeIn(150),
d.hide(),
e.removeClass("mT25"))
}
,
crmWidgetsObj.descSeemoreShow = function() {
$(".descText").each(function() {
var e = $(this)
, t = e.parent().width() - 30
, a = e.innerWidth()
, i = e[0].scrollWidth
, n = e.parent("td").width();
a < i ? e.css({
"white-space": "nowrap",
"text-overflow": "ellipsis",
float: "left",
width: n
}).attr("onclick", '$(this).removeAttr("style").removeClass("descText");sE(event);') : e.css({
width: t
})
})
}
,
crmWidgetsObj.fixedTblheader = function() {
var e = $("#widgetListTable").offset().top
, t = Utils.windowHeight - e - 28;
$("#CrmWidgetsCustomizationListViewTable").height(t)
}
,
crmWidgetsObj.showErrorPopup = function(e) {
crmui.showMsgBand("error", e, 5e3),
hideFreezeLayer(),
removeFreezeLayer()
}
,
crmWidgetsObj.init = function() {
Handlebars.registerPartial("CrmWidgetsForm", Handlebars.templates.CrmWidgetsForm),
Handlebars.registerPartial("CrmWidgetsDetailPopUp", Handlebars.templates.CrmWidgetsDetailPopUp),
Handlebars.registerPartial("CrmWidgetsListView", Handlebars.templates.CrmWidgetsListView),
Handlebars.registerPartial("CrmWidgetsBody", Handlebars.templates.CrmWidgetsBody),
Handlebars.registerPartial("CrmWidgetsListViewHeaders", Handlebars.templates.CrmWidgetsListViewHeaders),
Handlebars.registerPartial("CrmWidgetsListViewContentHeader", Handlebars.templates.CrmWidgetsListViewContentHeader),
Handlebars.registerPartial("CrmWidgetsListViewContent", Handlebars.templates.CrmWidgetsListViewContent)
}
,
crmWidgetsObj.processClientForSandbox = function() {
var t = $("#parentObj_sandboxChanges")
, a = $("#sandboxObj_sandboxChanges");
t.on("scroll", function() {
var e = $(this)
, t = $("#sandboxObj_sandboxChanges");
t.scrollTop(e.scrollTop()),
t.scrollLeft(e.scrollLeft())
}),
a.on("scroll", function() {
var e = $(this)
, t = $("#parentObj_sandboxChanges");
t.scrollTop(e.scrollTop()),
t.scrollLeft(e.scrollLeft())
}),
Utils.bindPerfectScroll("#parentObj_sandboxChanges", {
wheelSpeed: 1,
wheelPropagation: !0,
suppressScrollX: !1
}),
Utils.bindPerfectScroll("#sandboxObj_sandboxChanges", {
wheelSpeed: 1,
wheelPropagation: !0,
suppressScrollX: !1
});
var i = "#FAE3B1";
$("#sandboxObj_sandboxChanges .sandboxDiffChanges").each(function() {
var e = t.find("[id='parent_" + this.id + "']");
null !== this && null !== this.id && "" !== this.id && (("text" !== this.type && "textarea" !== this.type || $(this).val() === e.val()) && ("select-multiple" !== this.type && "select-one" !== this.type || $(this).val() === e.val()) ? "radio" === this.type ? $(this).is(":checked") !== $(e).is(":checked") && ($(this).closest("tr").css("background-color", i),
e.closest("tr").css("background-color", i)) : "checkbox" === this.type && $(this).is(":checked") !== e.is(":checked") ? ($(this).closest("tr").css("background-color", i),
e.closest("tr").css("background-color", i)) : $(this).is("span") || $(this).is("div") ? $(this).children("span").length < 1 ? sandbox.setColorForElem($(this).closest("tr"), e.closest("tr"), $(this).text(), e.text()) : sandbox.setColorForElem($(this).closest("tr"), e.closest("tr"), "temp", void 0) : sandbox.setColorForElem($(this).closest("tr"), e.closest("tr"), $(this).val(), e.val()) : sandbox.setColorForElem($(this).closest("tr"), e.closest("tr"), $(this).val(), e.val()))
}),
$("#parentObj_sandboxChanges .sandboxDiffChanges").each(function() {
var e = a.find("#" + this.id.replace("parent_", ""));
if (null !== this && null !== this.id && "" !== this.id)
if ("text" !== this.type && "textarea" !== this.type || $(this).val() === $(e).val())
if ("select-multiple" === this.type || "select-one" === this.type) {
null !== sandbox.setColor(e.find(":selected").text(), $("#" + this.id).find(":selected").text()) && ($(this).addClass("sandbox_change"),
e.addClass("sandbox_change"))
} else
$(this).is("div") ? sandbox.setColorForElem(e.find("textarea").closest("tr"), $(this).find("textarea").closest("tr"), e.text(), $(this).text()) : $(this).is("table") ? sandbox.compareTable($(this).find("tr"), e.find("tr"), "Schedules") : sandbox.setColorForElem(e.closest("tr"), $(this).closest("tr"), e.val(), $(this).val());
else
sandbox.setColorForElem(e.closest("tr"), $(this).closest("tr"), e.val(), $(this).val());
else
null !== this.id && null === e && $(this).closest("tr").css("background-color", "#FFD2D2")
})
}
,
function() {
var e = Handlebars.template
, t = Handlebars.templates = Handlebars.templates || {};
t.CrmWidgetsBody = e({
1: function(e, t, a, i, n) {
var r = e.lambda
, s = e.escapeExpression;
return ' <option data-zcqa="wid_opt_' + s(r(t, t)) + '" value="' + s(r(t, t)) + '">' + s(a.getI18nByAppendKey.call(null != t ? t : {}, "crm.label.widgets.", t, {
name: "getI18nByAppendKey",
hash: {},
data: n
})) + "</option> "
},
3: function(e, t, a, i, n) {
return ' <td class="fR webInteg_zscKey" style="text-align: right; white-space: nowrap"><input data-zcqa="wid_newbtn" id="createWidgetButton" type="button" onclick="crmWidgetsObj.showCreateWidgetPopUp()" value="' + e.escapeExpression(a.getI18n.call(null != t ? t : {}, "crm.label.widgets.button.create", {
name: "getI18n",
hash: {},
data: n
})) + '" class="primaryflatbtn mL30"></td> '
},
compiler: [7, ">= 4.0.0"],
main: function(e, t, a, i, n) {
var r, s = null != t ? t : {}, o = e.escapeExpression;
return '<div class="setup-space"> <div id="widgetsTabHeader" style="display: block;"> <div class="posrel"> <h2>' + o(a.getI18n.call(s, "crm.label.widgets", {
name: "getI18n",
hash: {},
data: n
})) + '</h2> <div class="posabs"> <a data-zcqa="wid_help" id="context-helplink" class="toplink dIB f13 lh18" onclick="openHelp(\'' + o(a.getHelpUrl.call(s, "help.customization.widgets.usewidget", "zoho", {
name: "getHelpUrl",
hash: {},
data: n
})) + '\')" href="javascript:;">' + o(a.getI18n.call(s, "crm.label.context.help", {
name: "getI18n",
hash: {},
data: n
})) + '</a> </div> </div> <div class="mt15 content col444 w90per">' + o(a.getI18n.call(s, "crm.label.widgets.productinfo", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </div> <div> <div id="widgetHeaderLabel" class="mB25"></div> <div id="crmWidgetsListViewPopUp" class="mT25"></div> <table class="w100p" cellpadding="0" cellspacing="0" border="0"> <tbody> <tr> <td class="webInteg_zscKey nuEnhancFocusBox"> <div class="newSelect fL"> <select data-zcqa="wid_prfilter" class="newSelect" id="crmWidgetCategoryList" onchange="crmWidgetsObj.processFilter();"> <option data-zcqa="wid_opt_alltype" value="-1">' + o(a.getI18n.call(s, "crm.label.widgets.allType", {
name: "getI18n",
hash: {},
data: n
})) + "</option> " + (null != (r = a.each.call(s, null != t ? t.category : t, {
name: "each",
hash: {},
fn: e.program(1, n, 0),
inverse: e.noop,
data: n
})) ? r : "") + ' </select> </div> <div class="newSelect fL mL20"> <select data-zcqa="wid_prfilter2" class="newSelect" id="crmWidgetConfigList" onchange="crmWidgetsObj.processFilter();"> <option data-zcqa="wid_opt_all" value="all">' + o(a.getI18n.call(s, "crm.globalsearch.option.all", {
name: "getI18n",
hash: {},
data: n
})) + '</option> <option data-zcqa="wid_opt_installed" value="installed">' + o(a.getI18n.call(s, "crm.newrelatedlist.gallery.installed", {
name: "getI18n",
hash: {},
data: n
})) + '</option> <option data-zcqa="wid_opt_notinstalled" value="notinstalled">' + o(a.getI18n.call(s, "crm.newrelatedlist.gallery.notinstalled", {
name: "getI18n",
hash: {},
data: n
})) + '</option> <option data-zcqa="wid_opt_extn" value="extn">' + o(a.getI18n.call(s, "crm.setup.label.extensions", {
name: "getI18n",
hash: {},
data: n
})) + "</option> </select> </div> </td> " + (null != (r = a.ifEquals.call(s, a.isAdvancePermission.call(s, {
name: "isAdvancePermission",
hash: {},
data: n
}), "true", {
name: "ifEquals",
hash: {},
fn: e.program(3, n, 0),
inverse: e.noop,
data: n
})) ? r : "") + ' </tr> </tbody> </table> <div id="crmWidgetsListViewHeader" class="mT25" data-loaded="true" data-load="true"></div> <div id="crmWidgetsListViewContentHeader" class="mT10" data-loaded="true" data-load="true"> <table id="crmWidgetsListViewContent" class="newListView bdrCollapse w100p"> <tbody> </tbody> </table> </div> <div id="CrmWidgetsCustomizationListView" class="mT25" data-loaded="true" data-load="true"></div> <div id="CrmWidgetsForm" class="newpopup is-scroll ppTop dN showPpTop newInputStyleEle newPopupStyleEle" style=" display: none;"></div> </div> </div> '
},
useData: !0
}),
t.CrmWidgetsDetailPopUp = e({
1: function(e, t, a, i, n) {
return ' <span class="svgIcons ico-close op05 dIB cP r0" data-zcqa="wid_close" onclick="crmNTCGlobal.closePopupAndOpenSigPanel( \'CrmWidgetsForm\' , \'' + e.escapeExpression(e.lambda(null != t ? t.source : t, t)) + "' )\"></span> "
},
3: function(e, t, a, i, n) {
return ' <span class="svgIcons ico-close op05 dIB cP r0" data-zcqa="wid_close" onclick="crmui.hidePopup(\'CrmWidgetsForm\');"></span> '
},
5: function(e, t, a, i, n) {
var r = null != t ? t : {}
, s = e.escapeExpression;
return ' <option data-zcqa="wid_opt_int" value="internal" selected="selected">' + s(a.getI18n.call(r, "crm.label.widgets.internal", {
name: "getI18n",
hash: {},
data: n
})) + '</option> <option data-zcqa="wid_opt_ext" value="external">' + s(a.getI18n.call(r, "crm.label.widgets.external", {
name: "getI18n",
hash: {},
data: n
})) + "</option> "
},
7: function(e, t, a, i, n) {
var r = null != t ? t : {}
, s = e.escapeExpression;
return ' <option data-zcqa="wid_opt_int" value="internal">' + s(a.getI18n.call(r, "crm.label.widgets.internal", {
name: "getI18n",
hash: {},
data: n
})) + '</option> <option data-zcqa="wid_opt_ext" value="external" selected="selected">' + s(a.getI18n.call(r, "crm.label.widgets.external", {
name: "getI18n",
hash: {},
data: n
})) + "</option> "
},
9: function(e, t, a, i, n) {
return ' <span data-zcqa="wid_tooltip" class="svgIcons info_icon mL10 cP dIB vtxtBot pA" style="top: 12px;right: -23px;" onmouseover="crmui.toolTip_show(this,\'left\',\'' + e.escapeExpression(a.getI18n.call(null != t ? t : {}, "crm.label.widgets.hosting.internal.info", {
name: "getI18n",
hash: {},
data: n
})) + '\');" onmouseout="crmui.toolTip_hide();"></span> '
},
11: function(e, t, a, i, n) {
return ' <span data-zcqa="wid_tooltip" class="svgIcons info_icon mL10 cP dIB vtxtBot pA" style="top: 12px;right: -23px;" onmouseover="crmui.toolTip_show(this,\'left\',\'' + e.escapeExpression(a.getI18n.call(null != t ? t : {}, "crm.label.widgets.hosting.external.info", {
name: "getI18n",
hash: {},
data: n
})) + '\');" onmouseout="crmui.toolTip_hide();"></span> '
},
13: function(e, t, a, i, n) {
var r, s = null != t ? t : {}, o = e.escapeExpression, d = e.lambda;
return ' <tr id="widgetsExternal" style="display: none"> <td class="wf_requiredMark"> <div>' + o(a.getI18n.call(s, "crm.label.widgets.baseurl", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><input data-zcqa="wid_ip_base" id="widgetExternalUrl" type="text" value="" class="newinputText w100per" placeholder="https://zapps.zoho.com/zapps#apps/sample/index.html" /> <div class="form_err_msg" id="widgetsUrlError" style="display: none;"></div></td> </tr> <tr id="widgetsInternalUpload"> <td> <div class="wf_requiredMark">' + o(a.getI18n.call(s, "crm.label.widgets.fileupload", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><span class="uploadedfileName color_1">' + o(d(null != (r = null != t ? t.json : t) ? r.file_name : r, t)) + '</span> <label class="uploadbtnholder fR"> <input data-zcqa="wid_btn_up" type="button" value="' + o(a.getI18n.call(s, "crm.button.change", {
name: "getI18n",
hash: {},
data: n
})) + '" class="newgreybtn"> <input data-zcqa="wid_ip_upd" id="widgetUploadFile" type="file" title="' + o(a.getI18n.call(s, "webform.fileupload", {
name: "getI18n",
hash: {},
data: n
})) + '" onchange="crmWidgetsObj.onFileSelected(event);" accept=".zip" value="change"> </label><div class="form_err_msg zI10" id="widgetsNoFile" style="display: none;"></div></td> </tr> <tr id="widgetsInternalBase"> <td> <div class="wf_requiredMark">' + o(a.getI18n.call(s, "crm.label.widgets.baseurl", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><input data-zcqa="wid_ip_sys_base" id="widgetIndexPage2" type="text" value="' + o(d(null != (r = null != t ? t.json : t) ? r.base_url : r, t)) + '" class="newinputText w100per" disabled ></input></td> </tr> <tr id="widgetsInternal"> <td> <div class="wf_requiredMark">' + o(a.getI18n.call(s, "crm.label.widgets.indexpage", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><input data-zcqa="wid_ip_index" id="widgetIndexPage" type="text" value="' + o(d(null != (r = null != t ? t.json : t) ? r.start_url : r, t)) + '" class="newinputText w100per" placeholder="/sample/index.html" /> <div class="form_err_msg" id="widgetsStartUrlError" style="display: none;"></div></td> </tr> '
},
15: function(e, t, a, i, n) {
var r, s = null != t ? t : {}, o = e.escapeExpression;
return ' <tr id="widgetsExternal"> <td class="wf_requiredMark"> <div>' + o(a.getI18n.call(s, "crm.label.widgets.baseurl", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><input data-zcqa="wid_ip_base" id="widgetExternalUrl" type="text" value="' + o(e.lambda(null != (r = null != t ? t.json : t) ? r.base_url : r, t)) + '" class="newinputText w100per" placeholder="https://zapps.zoho.com/zapps#apps/sample/index.html" /> <div class="form_err_msg" id="widgetsUrlError" style="display: none;"></div></td> </tr> <tr id="widgetsInternalUpload" style="display: none"> <td> <div class="wf_requiredMark">' + o(a.getI18n.call(s, "crm.label.widgets.fileupload", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><span class="uploadedfileName dN color_1"></span> <label class="uploadbtnholder fL"> <input data-zcqa="wid_btn_up" type="button" value="' + o(a.getI18n.call(s, "crm.button.upload", {
name: "getI18n",
hash: {},
data: n
})) + '" class="primarybtn"> <input data-zcqa="wid_ip_upd" id="widgetUploadFile" type="file" title="' + o(a.getI18n.call(s, "webform.fileupload", {
name: "getI18n",
hash: {},
data: n
})) + '" onchange="crmWidgetsObj.onFileSelected(event);" accept=".zip" value="upload"> </label><div class="form_err_msg zI10" id="widgetsNoFile" style="display: none;"></div></td> </tr> <tr id="widgetsInternalBase" style="display: none"> <td> <div class="wf_requiredMark">' + o(a.getI18n.call(s, "crm.label.widgets.baseurl", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><input data-zcqa="wid_ip_sys_base" id="widgetIndexPage2" type="text" value="" class="newinputText w100per" disabled ></input></td> </tr> <tr id="widgetsInternal" style="display: none"> <td> <div class="wf_requiredMark">' + o(a.getI18n.call(s, "crm.label.widgets.indexpage", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><input data-zcqa="wid_ip_index" id="widgetIndexPage" type="text" value="" class="newinputText w100per" placeholder="/sample/index.html"> <div class="form_err_msg" id="widgetsStartUrlError" style="display: none;"></div></td> </tr> '
},
17: function(e, t, a, i, n) {
var r, s = e.lambda, o = e.escapeExpression, d = null != t ? t : {};
return ' <input type="button" data-zcqa="wid_hidpop" onclick="crmNTCGlobal.closePopupAndOpenSigPanel( \'CrmWidgetsForm\' , \'' + o(s(null != t ? t.source : t, t)) + '\' )" class="newgraybtn" value="' + o(a.getI18n.call(d, "crm.button.cancel", {
name: "getI18n",
hash: {},
data: n
})) + '"> <input data-zcqa="wid_save" type="button" id="widgetsSave" onclick="crmWidgetsObj.updateWidgets(\'' + o(s(null != (r = null != t ? t.json : t) ? r.widgets_id : r, t)) + "','" + o(s(null != t ? t.source : t, t)) + '\');" class="primarybtn clickSave" value="' + o(a.getI18n.call(d, "crm.button.save", {
name: "getI18n",
hash: {},
data: n
})) + '"> '
},
19: function(e, t, a, i, n) {
var r, s = null != t ? t : {}, o = e.escapeExpression;
return ' <input type="button" data-zcqa="wid_hidpop" onclick="crmui.hidePopup(\'CrmWidgetsForm\'); " class="newgraybtn" value="' + o(a.getI18n.call(s, "crm.button.cancel", {
name: "getI18n",
hash: {},
data: n
})) + '"> <input data-zcqa="wid_save" type="button" id="widgetsSave" onclick="crmWidgetsObj.updateWidgets(\'' + o(e.lambda(null != (r = null != t ? t.json : t) ? r.widgets_id : r, t)) + '\');" class="primarybtn clickSave" value="' + o(a.getI18n.call(s, "crm.button.save", {
name: "getI18n",
hash: {},
data: n
})) + '"> '
},
compiler: [7, ">= 4.0.0"],
main: function(e, t, a, i, n) {
var r, s = null != t ? t : {}, o = e.escapeExpression, d = e.lambda;
return ' <div class="pp-header"> <table width="100%" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="f22 crm-font-bold">' + o(a.getI18n.call(s, "crm.label.edit.widget", {
name: "getI18n",
hash: {},
data: n
})) + '<br></td> <td class="alignright f14 pR" valign="top" width="200"><a id="context-helplink" class="toplink dIB f13 lh18 mR20" data-zcqa="wid_help" onclick="openHelp(\'' + o(a.getHelpUrl.call(s, "help.customization.widgets.addwidget", "zoho", {
name: "getHelpUrl",
hash: {},
data: n
})) + '\')" href="javascript:;">' + o(a.getI18n.call(s, "crm.label.context.help", {
name: "getI18n",
hash: {},
data: n
})) + "</a> " + (null != (r = a.isCallFromSalesSignals.call(s, null != t ? t.source : t, {
name: "isCallFromSalesSignals",
hash: {},
fn: e.program(1, n, 0),
inverse: e.program(3, n, 0),
data: n
})) ? r : "") + ' </td> </tr> </tbody> </table> </div> <div class="pp-content" style="max-height: 624px;"> <table class="wf_form_UI w100per wf_form_focus" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="wf_requiredMark"> <div>' + o(a.getI18n.call(s, "crm.label.widgets.name", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><input data-zcqa="wid_name" id="widgetFormName" type="text" value="' + o(d(null != (r = null != t ? t.json : t) ? r.name : r, t)) + '" class="newinputText w100per" maxlength="30" autocomplete="off" ></input> <div class="form_err_msg" id="widgetsNameError" style="display: none;"></div></td> </tr> <tr id="functionDescriptionDiv"> <td>' + o(a.getI18n.call(s, "Description", {
name: "getI18n",
hash: {},
data: n
})) + '</td> <td><textarea data-zcqa="txtarea_cfunc_desc" rows="3" class="textField w600" maxlength="250" id="widgetDescription" name="description" style="height: 0px;">' + o(d(null != (r = null != t ? t.json : t) ? r.description : r, t)) + '</textarea></td> </tr> <tr> <td class="wf_requiredMark"> <div>' + o(a.getI18n.call(s, "crm.label.widgets.type", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td style="padding-top: 10px"> <div>' + o(a.getI18nByAppendKey.call(s, "crm.label.widgets.", null != (r = null != t ? t.json : t) ? r.type : r, {
name: "getI18nByAppendKey",
hash: {},
data: n
})) + '</div><input data-zcqa="wid_sel_type" type="hidden" value="' + o(d(null != (r = null != t ? t.json : t) ? r.type : r, t)) + '" id="widgetType" ></input> <div class="form_err_msg" id="widgetsTypeError" style="display: none;"></div> </td> </tr> <tr class="selectBoxSelect2"> <td class="wf_requiredMark"> <div class="">' + o(a.getI18n.call(s, "crm.label.widgets.hosting", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td style="padding-top: 10px"> <div class="newSelect"> <select data-zcqa="wid_sel_host" id="widgetHosting" style="border: 0" onchange="crmWidgetsObj.showInputFields(value);"> ' + (null != (r = a.ifEquals.call(s, null != (r = null != t ? t.json : t) ? r.hosting : r, "Internal", {
name: "ifEquals",
hash: {},
fn: e.program(5, n, 0),
inverse: e.program(7, n, 0),
data: n
})) ? r : "") + " </select> </div> " + (null != (r = a.ifEquals.call(s, null != (r = null != t ? t.json : t) ? r.hosting : r, "Internal", {
name: "ifEquals",
hash: {},
fn: e.program(9, n, 0),
inverse: e.program(11, n, 0),
data: n
})) ? r : "") + ' <div class="form_err_msg" id="widgetsHostingError" style="display: none;"></div> </td> </tr> ' + (null != (r = a.ifEquals.call(s, null != (r = null != t ? t.json : t) ? r.hosting : r, "Internal", {
name: "ifEquals",
hash: {},
fn: e.program(13, n, 0),
inverse: e.program(15, n, 0),
data: n
})) ? r : "") + ' </tbody> </table> </div> <div class="pp-footer"> ' + (null != (r = a.isCallFromSalesSignals.call(s, null != t ? t.source : t, {
name: "isCallFromSalesSignals",
hash: {},
fn: e.program(17, n, 0),
inverse: e.program(19, n, 0),
data: n
})) ? r : "") + " </div> "
},
useData: !0
}),
t.CrmWidgetsForm = e({
1: function(e, t, a, i, n) {
var r = null != t ? t : {}
, s = e.escapeExpression;
return ' <div> <div class="pp-header"> ' + s(a.getI18n.call(r, "crm.label.widgets.button.create", {
name: "getI18n",
hash: {},
data: n
})) + ' <div class="alignright f14 fR pR" valign="top" width="200"> <a data-zcqa="wid_help" id="context-helplink" class="toplink dIB lh18 f13 mT8 mR20 pR10 rightSeparation" onclick="openHelp(\'' + s(a.getHelpUrl.call(r, "help.customization.widgets.addwidget", "zoho", {
name: "getHelpUrl",
hash: {},
data: n
})) + '\')" href="javascript:;">' + s(a.getI18n.call(r, "crm.label.context.help", {
name: "getI18n",
hash: {},
data: n
})) + '</a><span class="dbBtnClose svgIcons ico-close op05 dIB cP mT8 r0" onclick="crmWidgetsObj.showPreviousPopup();"></span> </div> <div class="cB"></div> </div> <div class="pp-content" style="max-height: 624px;"> <table class="wf_form_UI w100per wf_form_focus" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="wf_requiredMark"> <div>' + s(a.getI18n.call(r, "crm.label.widgets.name", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><input data-zcqa="wid_name" id="widgetFormName" type="text" value="" class="newinputText w100per" maxlength="30" autocomplete="off" onblur="wfForm.removeFocus(this,\'form\')" ></input> <div class="form_err_msg" id="widgetsNameError" style="display: none;"></div></td> </tr> <tr id="functionDescriptionDiv"> <td>' + s(a.getI18n.call(r, "Description", {
name: "getI18n",
hash: {},
data: n
})) + '</td> <td><textarea data-zcqa="txtarea_cfunc_desc" rows="3" class="textField w600" id="widgetDescription" maxlength="250" name="description" style="height: 0px;"></textarea></td> </tr> <tr> <td class="wf_requiredMark"> <div>' + s(a.getI18n.call(r, "crm.label.widgets.type", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td style="padding-top: 10px"> <div>' + s(a.getI18nByAppendKey.call(r, "crm.label.widgets.", null != t ? t.type : t, {
name: "getI18nByAppendKey",
hash: {},
data: n
})) + '</div> <input data-zcqa="wid_opt_type" type="hidden" value="' + s(e.lambda(null != t ? t.type : t, t)) + '" id="widgetType" ></input> </td> </tr> <tr> <td class="wf_requiredMark"> <div>' + s(a.getI18n.call(r, "crm.label.widgets.hosting", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td style="padding-top: 10px"> <div class="newSelect"> <select data-zcqa="wid_opt_host" id="widgetHosting" style="border: 0" onchange="crmWidgetsObj.showInputFields(value);"> <option data-zcqa="wid_opt_none" value="none">' + s(a.getI18n.call(r, "None", {
name: "getI18n",
hash: {},
data: n
})) + '</option> <option data-zcqa="wid_opt_int" value="internal">' + s(a.getI18n.call(r, "crm.label.widgets.internal", {
name: "getI18n",
hash: {},
data: n
})) + '</option> <option data-zcqa="wid_opt_ext" value="external">' + s(a.getI18n.call(r, "crm.label.widgets.external", {
name: "getI18n",
hash: {},
data: n
})) + '</option> </select> </div> <span class="svgIcons info_icon mL10 cP dIB vtxtBot" style="display: none"></span> <div class="form_err_msg" id="widgetsHostingError" style="display: none;"></div> </td> </tr> <tr id="widgetsExternal" style="display: none"> <td class="wf_requiredMark"> <div>' + s(a.getI18n.call(r, "crm.label.widgets.baseurl", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><input data-zcqa="wid_ip_base" id="widgetExternalUrl" type="text" value="" class="newinputText w100per" placeholder="https://zapps.zoho.com/zapps#apps/sample/index.html"> <div class="form_err_msg" id="widgetsUrlError" style="display: none;"></div></td> </tr> <tr id="widgetsInternalUpload" style="display: none"> <td class="wf_requiredMark"> <div>' + s(a.getI18n.call(r, "crm.label.widgets.fileupload", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><span class="uploadedfileName dN color_1"></span> <label class="uploadbtnholder dIB mT5"> <input data-zcqa="wid_ip_up" type="button" value="' + s(a.getI18n.call(r, "crm.button.upload", {
name: "getI18n",
hash: {},
data: n
})) + '" class="primarybtn"> <input data-zcqa="wid_ip_upd" id="widgetUploadFile" type="file" title="' + s(a.getI18n.call(r, "webform.fileupload", {
name: "getI18n",
hash: {},
data: n
})) + '" onchange="crmWidgetsObj.onFileSelected(event);" accept=".zip" value="upload"> </label><div class="form_err_msg zI10" id="widgetsNoFile" style="display: none;"></div></td> </tr> <tr id="widgetsInternal" style="display: none"> <td class="wf_requiredMark"> <div>' + s(a.getI18n.call(r, "crm.label.widgets.indexpage", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><input data-zcqa="wid_ip_index" id="widgetIndexPage" type="text" value="" class="newinputText w100per" placeholder="/sample/index.html"> <div class="form_err_msg" id="widgetsStartUrlError" style="display: none;"></div></td> </tr> </tbody> </table> </div> <div class="pp-footer"> <input type="button" data-zcqa="wid_hidpop" onclick="crmWidgetsObj.showPreviousPopup();" class="newgraybtn" value="' + s(a.getI18n.call(r, "crm.button.cancel", {
name: "getI18n",
hash: {},
data: n
})) + '"> <input data-zcqa="wid_save" type="button" id="widgetsSave" onclick="crmWidgetsObj.createWidgets(true);" class="primarybtn clickSave" value="' + s(a.getI18n.call(r, "crm.button.save", {
name: "getI18n",
hash: {},
data: n
})) + '"> </div> </div> '
},
3: function(e, t, a, i, n) {
var r, s = null != t ? t : {}, o = e.escapeExpression;
return ' <div class="pp-header"> ' + o(a.getI18n.call(s, "crm.label.widgets.button.create", {
name: "getI18n",
hash: {},
data: n
})) + ' <div class="alignright f14 fR" valign="top" width="200"> ' + (null != (r = a.isCallFromSalesSignals.call(s, null != t ? t.callFrom : t, {
name: "isCallFromSalesSignals",
hash: {},
fn: e.program(4, n, 0),
inverse: e.program(6, n, 0),
data: n
})) ? r : "") + ' </div> <div class="cB"></div> </div> <div class="pp-content" style="max-height: 624px;"> <table class="wf_form_UI w100per wf_form_focus" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="wf_requiredMark"> <div>' + o(a.getI18n.call(s, "crm.label.widgets.name", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><input data-zcqa="wid_name" id="widgetFormName" type="text" value="" class="newinputText w100per" autocomplete="off" maxlength="30" onblur="wfForm.removeFocus(this,\'form\')" ></input> <div class="form_err_msg" id="widgetsNameError" style="display: none;"></div></td> </tr> <tr id="functionDescriptionDiv"> <td>' + o(a.getI18n.call(s, "Description", {
name: "getI18n",
hash: {},
data: n
})) + '</td> <td><textarea data-zcqa="txtarea_cfunc_desc" rows="3" class="textField w600" id="widgetDescription" maxlength="250" name="description" style="height: 0px;"></textarea></td> </tr> ' + (null != (r = a.isCallFromSalesSignals.call(s, null != t ? t.callFrom : t, {
name: "isCallFromSalesSignals",
hash: {},
fn: e.program(8, n, 0),
inverse: e.program(10, n, 0),
data: n
})) ? r : "") + ' <tr class="selectBoxSelect2"> <td class="wf_requiredMark"> <div class="wf_requiredMark">' + o(a.getI18n.call(s, "crm.label.widgets.hosting", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td style="padding-top: 10px"> <div class="newSelect"> <select data-zcqa="wid_sel_host" id="widgetHosting" style="border: 0" onchange="crmWidgetsObj.showInputFields(value);"> <option data-zcqa="wid_opt_none" value="none">' + o(a.getI18n.call(s, "None", {
name: "getI18n",
hash: {},
data: n
})) + '</option> <option data-zcqa="wid_opt_int" value="internal">' + o(a.getI18n.call(s, "crm.label.widgets.internal", {
name: "getI18n",
hash: {},
data: n
})) + '</option> <option data-zcqa="wid_opt_ext" value="external">' + o(a.getI18n.call(s, "crm.label.widgets.external", {
name: "getI18n",
hash: {},
data: n
})) + '</option> </select> </div> <span class="svgIcons info_icon mL10 cP dIB vtxtBot pA" style="display: none;top:12px; right: -23px;"></span> <div class="form_err_msg" id="widgetsHostingError" style="display: none;"></div> </td> </tr> <tr id="widgetsExternal" style="display: none"> <td class="wf_requiredMark"> <div>' + o(a.getI18n.call(s, "crm.label.widgets.baseurl", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><input data-zcqa="wid_ip_base" id="widgetExternalUrl" type="text" value="" class="newinputText w100per" placeholder="https://zapps.zoho.com/zapps#apps/sample/index.html"> <div class="form_err_msg" id="widgetsUrlError" style="display: none;"></div> </td> </tr> <tr id="widgetsInternalUpload" style="display: none"> <td class="wf_requiredMark"> <div>' + o(a.getI18n.call(s, "crm.label.widgets.fileupload", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><span class="uploadedfileName dN color_1"></span> <label class="uploadbtnholder fL"> <input data-zcqa="wid_btn_up" type="button" value="' + o(a.getI18n.call(s, "crm.button.upload", {
name: "getI18n",
hash: {},
data: n
})) + '" class="primarybtn"> <input data-zcqa="wid_ip_upd" id="widgetUploadFile" type="file" title="' + o(a.getI18n.call(s, "webform.fileupload", {
name: "getI18n",
hash: {},
data: n
})) + '" onchange="crmWidgetsObj.onFileSelected(event);" accept=".zip" value="upload"> </label><div class="form_err_msg zI10" id="widgetsNoFile" style="display: none;"></div></td> </tr> <tr id="widgetsInternal" style="display: none"> <td class="wf_requiredMark"> <div>' + o(a.getI18n.call(s, "crm.label.widgets.indexpage", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td><input data-zcqa="wid_ip_index" id="widgetIndexPage" type="text" value="" class="newinputText w100per" placeholder="/sample/index.html"> <div class="form_err_msg" id="widgetsStartUrlError" style="display: none;"></div> </td> </tr> </tbody> </table> </div> <div class="pp-footer"> ' + (null != (r = a.isCallFromSalesSignals.call(s, null != t ? t.callFrom : t, {
name: "isCallFromSalesSignals",
hash: {},
fn: e.program(13, n, 0),
inverse: e.program(15, n, 0),
data: n
})) ? r : "") + " </div> "
},
4: function(e, t, a, i, n) {
var r = null != t ? t : {}
, s = e.escapeExpression;
return ' <a data-zcqa="wid_help" id="context-helplink" class="toplink dIB f13 lh18" onclick="openHelp(\'' + s(a.getHelpUrl.call(r, "help.customization.widgets.addwidget", "zoho", {
name: "getHelpUrl",
hash: {},
data: n
})) + '\')" href="javascript:;">' + s(a.getI18n.call(r, "crm.label.context.help", {
name: "getI18n",
hash: {},
data: n
})) + "</a><span class=\"dbBtnClose svgIcons ico-close op05 dIB cP mL20 mT7\" onclick=\"crmNTCGlobal.closePopupAndOpenSigPanel('CrmWidgetsForm', '" + s(e.lambda(null != t ? t.callFrom : t, t)) + "');\"></span> "
},
6: function(e, t, a, i, n) {
var r = null != t ? t : {}
, s = e.escapeExpression;
return ' <a data-zcqa="wid_help" id="context-helplink" class="toplink dIB f13 lh18" onclick="openHelp(\'' + s(a.getHelpUrl.call(r, "help.customization.widgets.addwidget", "zoho", {
name: "getHelpUrl",
hash: {},
data: n
})) + '\')" href="javascript:;">' + s(a.getI18n.call(r, "crm.label.context.help", {
name: "getI18n",
hash: {},
data: n
})) + '</a><span class="dbBtnClose svgIcons ico-close op05 dIB cP mL20 mT7" onclick="crmui.hidePopup(\'CrmWidgetsForm\');"></span> '
},
8: function(e, t, a, i, n) {
return ' <tr> <td> <div class="wf_requiredMark">' + e.escapeExpression(a.getI18n.call(null != t ? t : {}, "crm.label.widgets.type", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td style=""> <div>Sales Signals</div><input data-zcqa="wid_sel_type" type="hidden" value="SALES_SIGNALS" id="widgetType"> <div class="form_err_msg" id="widgetsTypeError" style="display: none;"></div> </td> </tr> '
},
10: function(e, t, a, i, n) {
var r, s = null != t ? t : {}, o = e.escapeExpression;
return ' <tr class="selectBoxSelect2" > <td class="wf_requiredMark"> <div>' + o(a.getI18n.call(s, "crm.label.widgets.type", {
name: "getI18n",
hash: {},
data: n
})) + '</div> </td> <td style="padding-top: 10px"> <div class="newSelect"> <select data-zcqa="wid_sel_type" id="widgetType" style="border: 0"> <option data-zcqa="wid_opt_none" value="none">' + o(a.getI18n.call(s, "None", {
name: "getI18n",
hash: {},
data: n
})) + "</option> " + (null != (r = a.each.call(s, t, {
name: "each",
hash: {},
fn: e.program(11, n, 0),
inverse: e.noop,
data: n
})) ? r : "") + ' </select> </div> <div class="form_err_msg" id="widgetsTypeError" style="display: none;"></div> </td> </tr> '
},
11: function(e, t, a, i, n) {
var r = e.lambda
, s = e.escapeExpression;
return ' <option data-zcqa="wid_opt_' + s(r(t, t)) + '" value="' + s(r(t, t)) + '">' + s(a.getI18nByAppendKey.call(null != t ? t : {}, "crm.label.widgets.", t, {
name: "getI18nByAppendKey",
hash: {},
data: n
})) + "</option> "
},
13: function(e, t, a, i, n) {
var r = e.lambda
, s = e.escapeExpression
, o = null != t ? t : {};
return ' <input type="button" data-zcqa="wid_hidpop" onclick="crmNTCGlobal.closePopupAndOpenSigPanel(\'CrmWidgetsForm\', \'' + s(r(null != t ? t.callFrom : t, t)) + '\');" class="newgraybtn" value="' + s(a.getI18n.call(o, "crm.button.cancel", {
name: "getI18n",
hash: {},
data: n
})) + '"> <input data-zcqa="wid_save" type="button" id="widgetsSave" onclick="crmWidgetsObj.createWidgets(false,\'' + s(r(null != t ? t.callFrom : t, t)) + '\');" class="primarybtn clickSave" value="' + s(a.getI18n.call(o, "crm.button.save", {
name: "getI18n",
hash: {},
data: n
})) + '"> '
},
15: function(e, t, a, i, n) {
var r = null != t ? t : {}
, s = e.escapeExpression;
return ' <input type="button" data-zcqa="wid_hidpop" onclick="crmui.hidePopup(\'CrmWidgetsForm\');" class="newgraybtn" value="' + s(a.getI18n.call(r, "crm.button.cancel", {
name: "getI18n",
hash: {},
data: n
})) + '"> <input data-zcqa="wid_save" type="button" id="widgetsSave" onclick="crmWidgetsObj.createWidgets();" class="primarybtn clickSave" value="' + s(a.getI18n.call(r, "crm.button.save", {
name: "getI18n",
hash: {},
data: n
})) + '"> '
},
compiler: [7, ">= 4.0.0"],
main: function(e, t, a, i, n) {
var r;
return (null != (r = a.if.call(null != t ? t : {}, null != t ? t.listView : t, {
name: "if",
hash: {},
fn: e.program(1, n, 0),
inverse: e.program(3, n, 0),
data: n
})) ? r : "") + " "
},
useData: !0
}),
t.CrmWidgetsListView = e({
1: function(e, t, a, i, n) {
return ' <tr> <td> <p align="center" class="aligncenter fontsmooth f15 pT20 pB20 color_9">' + e.escapeExpression(e.lambda(null != t ? t.errorMessage : t, t)) + "</p> </td> </tr> "
},
3: function(e, t, a, i, n) {
var r, s = null != t ? t : {};
return " " + (null != (r = a.if.call(s, a.hasKeys.call(s, t, {
name: "hasKeys",
hash: {},
data: n
}), {
name: "if",
hash: {},
fn: e.program(4, n, 0),
inverse: e.noop,
data: n
})) ? r : "") + ' <div id="nowidgetdiv" style="display: none;" name="templateheader"> <br> <br> <div class="norec fontsmooth f15 aligncenter dN" name="nomatch" style="display: block;">' + e.escapeExpression(a.getI18n.call(s, "crm.label.widgets.nodata", {
name: "getI18n",
hash: {},
data: n
})) + "</div> <br> </div> "
},
4: function(e, t, a, i, n) {
var r;
return " " + (null != (r = a.each.call(null != t ? t : {}, t, {
name: "each",
hash: {},
fn: e.program(5, n, 0),
inverse: e.noop,
data: n
})) ? r : "") + " "
},
5: function(e, t, a, i, n) {
var r;
return " " + (null != (r = a.ifEquals.call(null != t ? t : {}, null != t ? t.source : t, "extension", {
name: "ifEquals",
hash: {},
fn: e.program(6, n, 0),
inverse: e.program(11, n, 0),
data: n
})) ? r : "") + " "
},
6: function(e, t, a, i, n) {
var r, s = e.lambda, o = e.escapeExpression, d = null != t ? t : {};
return ' <tr data-zcqa="wid_row_' + o(s(null != t ? t.widgets_id : t, t)) + '" class="tableTitleHeaderRow extn installed ' + o(s(null != t ? t.type : t, t)) + ' contentRows" onmouseenter="crmWidgetsObj.mouseEnterActions(this)" onmouseleave="crmWidgetsObj.mouseLeaveActions(this)" id="wid_row_' + o(s(null != t ? t.widgets_id : t, t)) + '"> ' + (null != (r = a.ifEquals.call(d, a.isAdvancePermission.call(d, {
name: "isAdvancePermission",
hash: {},
data: n
}), "true", {
name: "ifEquals",
hash: {},
fn: e.program(7, n, 0),
inverse: e.noop,
data: n
})) ? r : "") + ' <td width="73%"> <div class="f15"> <span class="fnHd">' + o(s(null != t ? t.name : t, t)) + "</span> " + (null != (r = a.ifEquals.call(d, null != t ? t.source : t, "extension", {
name: "ifEquals",
hash: {},
fn: e.program(9, n, 0),
inverse: e.noop,
data: n
})) ? r : "") + ' <div class="descTextWrap"> <div class="f14 mT5 color_7 descText" style="width: 75%">' + o(s(null != t ? t.description : t, t)) + '</div> </div> </div> </td> <td width="27%">' + o(a.getI18nByAppendKey.call(d, "crm.label.widgets.", null != t ? t.type : t, {
name: "getI18nByAppendKey",
hash: {},
data: n
})) + "</td> </tr> "
},
7: function(e, t, a, i, n) {
var r = e.escapeExpression;
return ' <td class="wwbw" id="cf_delete" onclick="sE(event);" width="4%"> <div align="center" class=" pR"> <span data-zcqa="wid_sethv_' + r(e.lambda(null != t ? t.widgets_id : t, t)) + '" class="settingsIcons dIB cP disable mT3" style="display: none;" onmouseover="crmui.toolTip_show(this,\'left\',\'' + r(a.getI18n.call(null != t ? t : {}, "crm.label.widgets.extn.delete.warn", {
name: "getI18n",
hash: {},
data: n
})) + '\');" onmouseout="crmui.toolTip_hide();"></span> <div id="settingActions" style="display: none;" class="p0 pA"> <i class="setDDPopupAbG" style="top: -8px;"><i class="setDDPopupA"></i></i> </div> </div> </td> '
},
9: function(e, t, a, i, n) {
return ' <span class="topEdition mL5">' + e.escapeExpression(a.getI18n.call(null != t ? t : {}, "crm.label.widgets.extension", {
name: "getI18n",
hash: {},
data: n
})) + "</span> "
},
11: function(e, t, a, i, n) {
var r, s = e.lambda, o = e.escapeExpression, d = null != t ? t : {};
return ' <tr data-zcqa="wid_row_' + o(s(null != t ? t.widgets_id : t, t)) + '" class="tableTitleHeaderRow ' + (null != (r = a.isNotEmpty.call(d, null != t ? t.associated_places : t, {
name: "isNotEmpty",
hash: {},
fn: e.program(12, n, 0),
inverse: e.program(14, n, 0),
data: n
})) ? r : "") + " " + o(s(null != t ? t.type : t, t)) + ' contentRows" onmouseenter="crmWidgetsObj.mouseEnterActions(this)" onmouseleave="crmWidgetsObj.mouseLeaveActions(this)" onclick="crmWidgetsObj.showWidgetsPopUp(\'' + o(a.encodeJS.call(d, a.ObjToString.call(d, t, {
name: "ObjToString",
hash: {},
data: n
}), {
name: "encodeJS",
hash: {},
data: n
})) + '\');" id="wid_row_' + o(s(null != t ? t.widgets_id : t, t)) + '"> ' + (null != (r = a.ifEquals.call(d, a.isAdvancePermission.call(d, {
name: "isAdvancePermission",
hash: {},
data: n
}), "true", {
name: "ifEquals",
hash: {},
fn: e.program(16, n, 0),
inverse: e.noop,
data: n
})) ? r : "") + ' <td width="73%"> <div class="f15"> <span class="fnHd">' + o(s(null != t ? t.name : t, t)) + "</span> " + (null != (r = a.ifEquals.call(d, null != t ? t.source : t, "extension", {
name: "ifEquals",
hash: {},
fn: e.program(9, n, 0),
inverse: e.program(21, n, 0),
data: n
})) ? r : "") + ' <div class="descTextWrap"> <div class="f14 mT5 color_7 descText" style="width: 75%">' + o(s(null != t ? t.description : t, t)) + '</div> </div> </div> </td> <td width="27%">' + o(a.getI18nByAppendKey.call(d, "crm.label.widgets.", null != t ? t.type : t, {
name: "getI18nByAppendKey",
hash: {},
data: n
})) + "</td> </tr> "
},
12: function(e, t, a, i, n) {
return "installed"
},
14: function(e, t, a, i, n) {
return "notinstalled"
},
16: function(e, t, a, i, n) {
var r, s = e.lambda, o = e.escapeExpression, d = null != t ? t : {};
return ' <td class="wwbw" id="cf_delete" onclick="sE(event);" width="4%"> <div align="center" class="pR"> <span data-zcqa="wid_sethv_' + o(s(null != t ? t.widgets_id : t, t)) + '" class="settingsIcons dIB cP mT3" style="display: none;" onclick="crmWidgetsObj.showOptionList(this);sE(event);"></span> <div id="settingActions" style="display: none;" class="p0 pA"> <i class="setDDPopupAbG" style="top: -8px; "><i class="setDDPopupA"></i></i> <ul class="m0 modListMenuDD" style="min-width: 80px;"> <li data-zcqa="wid_sete_' + o(s(null != t ? t.widgets_id : t, t)) + '" class="modListLi crm-font-regular f14 color_7 cP alignleft editWid" onclick="crmWidgetsObj.showWidgetsPopUp(\'' + o(a.encodeJS.call(d, a.ObjToString.call(d, t, {
name: "ObjToString",
hash: {},
data: n
}), {
name: "encodeJS",
hash: {},
data: n
})) + "');sE(event);\">" + o(a.getI18n.call(d, "crm.label.customRL.modifyScript", {
name: "getI18n",
hash: {},
data: n
})) + "</li> " + (null != (r = a.isNotEmpty.call(d, null != t ? t.associated_places : t, {
name: "isNotEmpty",
hash: {},
fn: e.program(17, n, 0),
inverse: e.program(19, n, 0),
data: n
})) ? r : "") + " </ul> </div> </div> </td> "
},
17: function(e, t, a, i, n) {
var r = e.escapeExpression
, s = null != t ? t : {};
return ' <li data-zcqa="wid_setd_' + r(e.lambda(null != t ? t.widgets_id : t, t)) + '" class="modListLi crm-font-regular f14 color_7 cP alignleft deleteCF disabled" onmouseover="crmui.toolTip_show(this,\'left\',\'' + r(a.getI18n.call(s, "crm.label.widgets.error.cannotdelete", {
name: "getI18n",
hash: {},
data: n
})) + '\');" onmouseout="crmui.toolTip_hide();">' + r(a.getI18n.call(s, "crm.label.customRL.uninstall", {
name: "getI18n",
hash: {},
data: n
})) + "</li> "
},
19: function(e, t, a, i, n) {
var r = e.lambda
, s = e.escapeExpression;
return ' <li data-zcqa="wid_setd_' + s(r(null != t ? t.widgets_id : t, t)) + '" class="modListLi crm-font-regular f14 color_7 cP alignleft deleteCF" onclick="crmWidgetsObj.deleteWidget(\'' + s(r(null != t ? t.widgets_id : t, t)) + "');sE(event);\">" + s(a.getI18n.call(null != t ? t : {}, "crm.label.customRL.uninstall", {
name: "getI18n",
hash: {},
data: n
})) + "</li> "
},
21: function(e, t, a, i, n) {
var r;
return " " + (null != (r = a.isNotEmpty.call(null != t ? t : {}, null != t ? t.associated_places : t, {
name: "isNotEmpty",
hash: {},
fn: e.program(22, n, 0),
inverse: e.noop,
data: n
})) ? r : "") + " "
},
22: function(e, t, a, i, n) {
return ' <span class="topEdition mL5">' + e.escapeExpression(a.getI18n.call(null != t ? t : {}, "crm.label.widgets.installed", {
name: "getI18n",
hash: {},
data: n
})) + "</span> "
},
compiler: [7, ">= 4.0.0"],
main: function(e, t, a, i, n) {
var r, s = null != t ? t : {}, o = e.escapeExpression;
return ' <table id="widgetListTableFixed" border="0" class="newListView bdrCollapse newTb fontSmooth w100per"> <tr class="tableTitleHeaderRow"> <th width="4%"></th> <th width="73%">' + o(a.getI18n.call(s, "crm.label.widgets.name", {
name: "getI18n",
hash: {},
data: n
})) + '</th> <th width="27%">' + o(a.getI18n.call(s, "crm.label.widgets.type", {
name: "getI18n",
hash: {},
data: n
})) + '</th> </tr> </table> <div id=\'CrmWidgetsCustomizationListViewTable\' class=\'oA\'> <table id="widgetListTable" border="0" class="w100p newListView bdrCollapse newTb pT0 fontSmooth"> <tbody> ' + (null != (r = a.if.call(s, null != t ? t.errorMessage : t, {
name: "if",
hash: {},
fn: e.program(1, n, 0),
inverse: e.program(3, n, 0),
data: n
})) ? r : "") + " </tbody> </table> </div>"
},
useData: !0
}),
t.CrmWidgetsListViewContent = e({
1: function(e, t, a, i, n) {
return ' <tr> <td colspan="2"> <p align="center" class="aligncenter fontsmooth f14 pT20 pB20 color_9">' + e.escapeExpression(e.lambda(null != t ? t.errorMessage : t, t)) + "</p> </td> </tr> "
},
3: function(e, t, a, i, n, r, s) {
var o, d = null != t ? t : {};
return " " + (null != (o = a.if.call(d, a.hasKeys.call(d, t, {
name: "hasKeys",
hash: {},
data: n
}), {
name: "if",
hash: {},
fn: e.program(4, n, 0, r, s),
inverse: e.program(12, n, 0, r, s),
data: n
})) ? o : "") + " "
},
4: function(e, t, a, i, n, r, s) {
var o;
return " " + (null != (o = a.each.call(null != t ? t : {}, t, {
name: "each",
hash: {},
fn: e.program(5, n, 0, r, s),
inverse: e.noop,
data: n
})) ? o : "") + " "
},
5: function(e, t, a, i, n, r, s) {
var o, d = e.lambda, l = e.escapeExpression, c = null != t ? t : {};
return ' <tr class="tableTitleHeaderRow" id="wid_row_' + l(d(null != t ? t.widgets_id : t, t)) + '"> <td class="w250"> <div class="f14" id="div_' + l(d(null != t ? t.widgets_id : t, t)) + '" wid_name="' + l(d(null != t ? t.name : t, t)) + '"> ' + l(d(null != t ? t.name : t, t)) + " \x3c!-- " + (null != (o = a.if.call(c, null != t ? t.associated_places : t, {
name: "if",
hash: {},
fn: e.program(6, n, 0, r, s),
inverse: e.noop,
data: n
})) ? o : "") + ' --\x3e <div> <div class="f12 mT5 color_7 descText" style="width: 75%" id="desc_' + l(d(null != t ? t.widgets_id : t, t)) + '">' + l(d(null != t ? t.description : t, t)) + "</div> </div> </div> </td> " + (null != (o = a.if.call(c, null != t ? t.installed : t, {
name: "if",
hash: {},
fn: e.program(8, n, 0, r, s),
inverse: e.program(10, n, 0, r, s),
data: n
})) ? o : "") + " </tr> "
},
6: function(e, t, a, i, n) {
return ' <span class="topEdition mL5">' + e.escapeExpression(a.getI18n.call(null != t ? t : {}, "crm.label.widgets.installed", {
name: "getI18n",
hash: {},
data: n
})) + "</span> "
},
8: function(e, t, a, i, n) {
var r = e.escapeExpression
, s = null != t ? t : {};
return ' <td class="w100"><input data-zcqa="txt_btn_' + r(e.lambda(null != t ? t.widgets_id : t, t)) + '" type="button" class="w90 newbutton disabled fR" value="' + r(a.getI18n.call(s, "crm.label.widgets.installed", {
name: "getI18n",
hash: {},
data: n
})) + "\" onmouseover=\"crmui.toolTip_show(this,'left','" + r(a.getI18n.call(s, "crm.label.widgets.webtab.installed.already", {
name: "getI18n",
hash: {},
data: n
})) + '\');" onmouseout="crmui.toolTip_hide();"></input></td> '
},
10: function(e, t, a, i, n, r, s) {
var o = e.lambda
, d = e.escapeExpression
, l = null != t ? t : {};
return ' <td class="w100"><input data-zcqa="txt_btn_' + d(o(null != t ? t.widgets_id : t, t)) + '" type="button" class="w90 newbutton outlinegreenlight fR" value="' + d(a.getI18n.call(l, "crm.label.install", {
name: "getI18n",
hash: {},
data: n
})) + '" onclick="crmWidgetsObj.associatedWidget(\'' + d(o(null != t ? t.widgets_id : t, t)) + "','" + d(a.encodeJS.call(l, null != t ? t.type : t, {
name: "encodeJS",
hash: {},
data: n
})) + "','" + d(o(null != s[1] ? s[1].dep_obj : s[1], t)) + "');event.stopPropagation();\" /></td> "
},
12: function(e, t, a, i, n) {
return ' <tr> <td colspan="2"> <p align="center" class="aligncenter fontsmooth f14 pT20 pB20 color_9">' + e.escapeExpression(a.getI18n.call(null != t ? t : {}, "crm.label.widgets.nodata", {
name: "getI18n",
hash: {},
data: n
})) + "</p> </td> </tr> "
},
compiler: [7, ">= 4.0.0"],
main: function(e, t, a, i, n, r, s) {
var o;
return " " + (null != (o = a.if.call(null != t ? t : {}, null != t ? t.errorMessage : t, {
name: "if",
hash: {},
fn: e.program(1, n, 0, r, s),
inverse: e.program(3, n, 0, r, s),
data: n
})) ? o : "") + " "
},
useData: !0,
useDepths: !0
}),
t.CrmWidgetsListViewContentHeader = e({
compiler: [7, ">= 4.0.0"],
main: function(e, t, a, i, n) {
return '<table border="0" class="w100p newListView bdrCollapse mycustomFunction"> <thead> <tr class="tableTitleHeaderRow"> <th class="w250">' + e.escapeExpression(a.getI18n.call(null != t ? t : {}, "crm.label.widgets.name", {
name: "getI18n",
hash: {},
data: n
})) + '</th> <th class="w100">&nbsp;</th> </tr> </thead> <tbody id=\'crmWidgetsListViewContent\'></tbody> </table> <input type="hidden" id="widgetCategory" value="" ></input>'
},
useData: !0
}),
t.CrmWidgetsListViewHeaders = e({
1: function(e, t, a, i, n) {
return ' <div class="fR"> <input data-zcqa="txt_btn_b1" id="newmodbtn" type="button" onclick="crmWidgetsObj.showCreatePopupInListView();" value="' + e.escapeExpression(a.getI18n.call(null != t ? t : {}, "crm.label.widgets.button.create", {
name: "getI18n",
hash: {},
data: n
})) + '" class="newbutton outlineprimaryflat mR0"> </div> '
},
compiler: [7, ">= 4.0.0"],
main: function(e, t, a, i, n) {
var r, s = null != t ? t : {};
return '<div class="pp-header"> <table class="w100p" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="f22 crm-font-bold" nowrap="nowrap">' + e.escapeExpression(a.getI18n.call(s, "crm.label.widgets", {
name: "getI18n",
hash: {},
data: n
})) + '</td> <td class="alignright pR"><span data-zcqa="txt_wid_close" class="svgIcons widgetCloseIcon ico-close op05 dIB cP" onclick="crmWidgetsObj.closeWidgetPopup(this);"></span></td> </tr> </tbody> </table> </div> <div class="p30 pp-content mB20" style="max-height: 613px;"> ' + (null != (r = a.ifEquals.call(s, a.isAdvancePermission.call(s, {
name: "isAdvancePermission",
hash: {},
data: n
}), "true", {
name: "ifEquals",
hash: {},
fn: e.program(1, n, 0),
inverse: e.noop,
data: n
})) ? r : "") + ' <div class="cB"></div> <div id="crmWidgetsListViewContentHeader" class="mT25"></div> </div> '
},
useData: !0
}),
t.CrmWidgetsWelcome = e({
compiler: [7, ">= 4.0.0"],
main: function(e, t, a, i, n) {
var r, s = null != t ? t : {}, o = e.escapeExpression;
return ' <div class="setup-space"> <div class="w1100"> <div class="borderBottom pB30"> <div class="dIB vam w50per"> <h3 class="f26 color_5 mB30">' + o(a.getI18n.call(s, "crm.label.widgets", {
name: "getI18n",
hash: {},
data: n
})) + '</h3> <button class="greenbtn btn_medium" data-zcqa="txt_btn_w1" onClick="crmWidgetsObj.showCreateWidgetPopUp();">' + o(a.getI18n.call(s, "crm.label.widgets.getstarted.label4", {
name: "getI18n",
hash: {},
data: n
})) + '</button> </div> <div class="alignright dIB vam w49per"> <img src="' + o(a.img_link.call(s, {
name: "img_link",
hash: {},
data: n
})) + '/WidgetWelcome_0b64158_.svg" alt="' + o(a.getI18n.call(s, "crm.label.widgets.getstarted.label4", {
name: "getI18n",
hash: {},
data: n
})) + '"> </div> </div> <div class="pT30"> <p class="color444 lh20">' + o(a.getI18n.call(s, "crm.label.widgets.productinfo", {
name: "getI18n",
hash: {},
data: n
})) + ' <a data-zcqa="wid_help" id="context-helplink1" class="f13 undline" onclick="openHelp(\'' + o(a.getHelpUrl.call(s, "help.customization.widgets.helplink", "zoho", {
name: "getHelpUrl",
hash: {},
data: n
})) + '\')" href="javascript:;">' + o(a.getI18n.call(s, "crm.login.learn.more", {
name: "getI18n",
hash: {},
data: n
})) + '</a></p> <p class="mT30"><span data-zcqa="txt_btn_w2" class="widPrsLst dIB aligncenter mR5">' + o(a.getI18n.call(s, "crm.label.1", {
name: "getI18n",
hash: {},
data: n
})) + "</span> " + (null != (r = a.getI18n.call(s, "crm.label.widgets.getstarted.label3", a.getHelpUrl.call(s, "help.customization.widgets.installcli", {
name: "getHelpUrl",
hash: {},
data: n
}), {
name: "getI18n",
hash: {},
data: n
})) ? r : "") + ' <span data-zcqa="txt_btn_w3" class="widPrsLst dIB aligncenter mL20 mR5">' + o(a.getI18n.call(s, "crm.label.2", {
name: "getI18n",
hash: {},
data: n
})) + "</span> " + (null != (r = a.getI18n.call(s, "crm.label.widgets.getstarted.label2", {
name: "getI18n",
hash: {},
data: n
})) ? r : "") + ' <span data-zcqa="txt_btn_w4" class="widPrsLst dIB aligncenter mL20 mR5">' + o(a.getI18n.call(s, "crm.label.3", {
name: "getI18n",
hash: {},
data: n
})) + "</span>" + (null != (r = a.getI18n.call(s, "crm.label.widgets.getstarted.label5", a.getHelpUrl.call(s, "help.customization.widgets.firstwidget", {
name: "getHelpUrl",
hash: {},
data: n
}), {
name: "getI18n",
hash: {},
data: n
})) ? r : "") + '</p> </div> </div> </div> <div id="CrmWidgetsForm" class="newpopup is-scroll ppTop dN showPpTop newInputStyleEle newPopupStyleEle" style="display: none;"></div>'
},
useData: !0
})
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment