1 (function(global) { 2 if(global.Sfdc && global.Sfdc.canvas) { 3 return 4 } 5 var oproto = Object.prototype, aproto = Array.prototype, doc = global.document, $ = {hasOwn:function(obj, prop) { 6 return oproto.hasOwnProperty.call(obj, prop) 7 }, isUndefined:function(value) { 8 var undef; 9 return value === undef 10 }, isNil:function(value) { 11 return $.isUndefined(value) || value === null || value === "" 12 }, isNumber:function(value) { 13 return!!(value === 0 || value && value.toExponential && value.toFixed) 14 }, isFunction:function(value) { 15 return!!(value && value.constructor && value.call && value.apply) 16 }, isArray:Array.isArray || function(value) { 17 return oproto.toString.call(value) === "[object Array]" 18 }, isArguments:function(value) { 19 return!!(value && $.hasOwn(value, "callee")) 20 }, isObject:function(value) { 21 return value !== null && typeof value === "object" 22 }, isString:function(value) { 23 return value !== null && typeof value == "string" 24 }, appearsJson:function(value) { 25 return/^\{.*\}$/.test(value) 26 }, nop:function() { 27 }, invoker:function(fn) { 28 if($.isFunction(fn)) { 29 fn() 30 } 31 }, identity:function(obj) { 32 return obj 33 }, each:function(obj, it, ctx) { 34 if($.isNil(obj)) { 35 return 36 } 37 var nativ = aproto.forEach, i = 0, l, key; 38 l = obj.length; 39 ctx = ctx || obj; 40 if(nativ && nativ === obj.forEach) { 41 obj.forEach(it, ctx) 42 }else { 43 if($.isNumber(l)) { 44 while(i < l) { 45 if(it.call(ctx, obj[i], i, obj) === false) { 46 return 47 } 48 i += 1 49 } 50 }else { 51 for(key in obj) { 52 if($.hasOwn(obj, key) && it.call(ctx, obj[key], key, obj) === false) { 53 return 54 } 55 } 56 } 57 } 58 }, map:function(obj, it, ctx) { 59 var results = [], nativ = aproto.map; 60 if($.isNil(obj)) { 61 return results 62 } 63 if(nativ && obj.map === nativ) { 64 return obj.map(it, ctx) 65 } 66 ctx = ctx || obj; 67 $.each(obj, function(value, i, list) { 68 results.push(it.call(ctx, value, i, list)) 69 }); 70 return results 71 }, values:function(obj) { 72 return $.map(obj, $.identity) 73 }, slice:function(array, begin, end) { 74 return aproto.slice.call(array, $.isUndefined(begin) ? 0 : begin, $.isUndefined(end) ? array.length : end) 75 }, toArray:function(iterable) { 76 if(!iterable) { 77 return[] 78 } 79 if(iterable.toArray) { 80 return iterable.toArray 81 } 82 if($.isArray(iterable)) { 83 return iterable 84 } 85 if($.isArguments(iterable)) { 86 return $.slice(iterable) 87 } 88 return $.values(iterable) 89 }, size:function(obj) { 90 return $.toArray(obj).length 91 }, indexOf:function(array, item) { 92 var nativ = aproto.indexOf, i, l; 93 if(!array) { 94 return-1 95 } 96 if(nativ && array.indexOf === nativ) { 97 return array.indexOf(item) 98 } 99 for(i = 0, l = array.length;i < l;i += 1) { 100 if(array[i] === item) { 101 return i 102 } 103 } 104 return-1 105 }, remove:function(array, item) { 106 var i = $.indexOf(array, item); 107 if(i >= 0) { 108 array.splice(i, 1) 109 } 110 }, param:function(a, encode) { 111 var s = []; 112 encode = encode || false; 113 function add(key, value) { 114 if($.isNil(value)) { 115 return 116 } 117 value = $.isFunction(value) ? value() : value; 118 if($.isArray(value)) { 119 $.each(value, function(v, n) { 120 add(key, v) 121 }) 122 }else { 123 if(encode) { 124 s[s.length] = encodeURIComponent(key) + "\x3d" + encodeURIComponent(value) 125 }else { 126 s[s.length] = key + "\x3d" + value 127 } 128 } 129 } 130 if($.isArray(a)) { 131 $.each(a, function(v, n) { 132 add(n, v) 133 }) 134 }else { 135 for(var p in a) { 136 if($.hasOwn(a, p)) { 137 add(p, a[p]) 138 } 139 } 140 } 141 return s.join("\x26").replace(/%20/g, "+") 142 }, objectify:function(q) { 143 var o = {}; 144 q.replace(new RegExp("([^?\x3d\x26]+)(\x3d([^\x26]*))?", "g"), function($0, $1, $2, $3) { 145 o[$1] = $3 146 }); 147 return o 148 }, stripUrl:function(url) { 149 return $.isNil(url) ? null : url.replace(/([^:]+:\/\/[^\/\?#]+).*/, "$1") 150 }, query:function(url, q) { 151 if($.isNil(q)) { 152 return url 153 } 154 url = url.replace(/#.*$/, ""); 155 url += /^\#/.test(q) ? q : (/\?/.test(url) ? "\x26" : "?") + q; 156 return url 157 }, extend:function(dest) { 158 $.each($.slice(arguments, 1), function(mixin, i) { 159 $.each(mixin, function(value, key) { 160 dest[key] = value 161 }) 162 }); 163 return dest 164 }, endsWith:function(str, suffix) { 165 return str.indexOf(suffix, str.length - suffix.length) !== -1 166 }, capitalize:function(str) { 167 return str.charAt(0).toUpperCase() + str.slice(1) 168 }, uncapitalize:function(str) { 169 return str.charAt(0).toLowerCase() + str.slice(1) 170 }, validEventName:function(name, res) { 171 var ns, parts = name.split(/\./), regex = /^[$A-Z_][0-9A-Z_$]*$/i, reserved = {"sfdc":true, "canvas":true, "force":true, "salesforce":true, "chatter":true}; 172 $.each($.isArray(res) ? res : [res], function(v) { 173 reserved[v] = false 174 }); 175 if(parts.length > 2) { 176 return 1 177 } 178 if(parts.length === 2) { 179 ns = parts[0].toLowerCase(); 180 if(reserved[ns]) { 181 return 2 182 } 183 } 184 if(!regex.test(parts[0]) || !regex.test(parts[1])) { 185 return 3 186 } 187 return 0 188 }, prototypeOf:function(obj) { 189 var nativ = Object.getPrototypeOf, proto = "__proto__"; 190 if($.isFunction(nativ)) { 191 return nativ.call(Object, obj) 192 }else { 193 if(typeof{}[proto] === "object") { 194 return obj[proto] 195 }else { 196 return obj.constructor.prototype 197 } 198 } 199 }, module:function(ns, decl) { 200 var parts = ns.split("."), parent = global.Sfdc.canvas, i, length; 201 if(parts[1] === "canvas") { 202 parts = parts.slice(2) 203 } 204 length = parts.length; 205 for(i = 0;i < length;i += 1) { 206 if($.isUndefined(parent[parts[i]])) { 207 parent[parts[i]] = {} 208 } 209 parent = parent[parts[i]] 210 } 211 if($.isFunction(decl)) { 212 decl = decl() 213 } 214 return $.extend(parent, decl) 215 }, document:function() { 216 return doc 217 }, byId:function(id) { 218 return doc.getElementById(id) 219 }, byClass:function(clazz) { 220 return doc.getElementsByClassName(clazz) 221 }, attr:function(el, name) { 222 var a = el.attributes, i; 223 for(i = 0;i < a.length;i += 1) { 224 if(name === a[i].name) { 225 return a[i].value 226 } 227 } 228 }, onReady:function(cb) { 229 if($.isFunction(cb)) { 230 readyHandlers.push(cb) 231 } 232 }}, readyHandlers = [], ready = function() { 233 ready = $.nop; 234 $.each(readyHandlers, $.invoker); 235 readyHandlers = null 236 }, canvas = function(cb) { 237 if($.isFunction(cb)) { 238 readyHandlers.push(cb) 239 } 240 }; 241 (function() { 242 var ael = "addEventListener", tryReady = function() { 243 if(doc && /loaded|complete/.test(doc.readyState)) { 244 ready() 245 }else { 246 if(readyHandlers) { 247 if(!$.isNil(global.setTimeout)) { 248 global.setTimeout(tryReady, 30) 249 } 250 } 251 } 252 }; 253 if(doc && doc[ael]) { 254 doc[ael]("DOMContentLoaded", ready, false) 255 } 256 tryReady(); 257 if(global[ael]) { 258 global[ael]("load", ready, false) 259 }else { 260 if(global.attachEvent) { 261 global.attachEvent("onload", ready) 262 } 263 } 264 })(); 265 $.each($, function(fn, name) { 266 canvas[name] = fn 267 }); 268 if(!global.Sfdc) { 269 global.Sfdc = {} 270 } 271 global.Sfdc.canvas = canvas 272 })(this); 273 (function($$) { 274 var module = function() { 275 function isSecure() { 276 return window.location.protocol === "https:" 277 } 278 function set(name, value, days) { 279 var expires = "", date; 280 if(days) { 281 date = new Date; 282 date.setTime(date.getTime() + days * 24 * 60 * 60 * 1E3); 283 expires = "; expires\x3d" + date.toGMTString() 284 }else { 285 expires = "" 286 } 287 document.cookie = name + "\x3d" + value + expires + "; path\x3d/" + (isSecure() === true ? "; secure" : "") 288 } 289 function get(name) { 290 var nameEQ, ca, c, i; 291 if($$.isUndefined(name)) { 292 return document.cookie.split(";") 293 } 294 nameEQ = name + "\x3d"; 295 ca = document.cookie.split(";"); 296 for(i = 0;i < ca.length;i += 1) { 297 c = ca[i]; 298 while(c.charAt(0) === " ") { 299 c = c.substring(1, c.length) 300 } 301 if(c.indexOf(nameEQ) === 0) { 302 return c.substring(nameEQ.length, c.length) 303 } 304 } 305 return null 306 } 307 function remove(name) { 308 set(name, "", -1) 309 } 310 return{set:set, get:get, remove:remove} 311 }(); 312 $$.module("Sfdc.canvas.cookies", module) 313 })(Sfdc.canvas); 314 (function($$) { 315 var module = function() { 316 var accessToken, instUrl, instId, tOrigin, childWindow; 317 function init() { 318 accessToken = $$.cookies.get("access_token"); 319 $$.cookies.remove("access_token") 320 } 321 function query(params) { 322 var r = [], n; 323 if(!$$.isUndefined(params)) { 324 for(n in params) { 325 if(params.hasOwnProperty(n)) { 326 r.push(n + "\x3d" + params[n]) 327 } 328 } 329 return"?" + r.join("\x26") 330 } 331 return"" 332 } 333 function refresh() { 334 $$.cookies.set("access_token", accessToken); 335 self.location.reload() 336 } 337 function login(ctx) { 338 var uri; 339 ctx = ctx || {}; 340 uri = ctx.uri || "/rest/oauth2"; 341 ctx.params = ctx.params || {state:""}; 342 ctx.params.state = ctx.params.state || ctx.callback || window.location.pathname; 343 ctx.params.display = ctx.params.display || "popup"; 344 uri = uri + query(ctx.params); 345 childWindow = window.open(uri, "OAuth", "status\x3d0,toolbar\x3d0,menubar\x3d0,resizable\x3d0,scrollbars\x3d1,top\x3d50,left\x3d50,height\x3d500,width\x3d680") 346 } 347 function token(t) { 348 if(arguments.length === 0) { 349 if(!$$.isNil(accessToken)) { 350 return accessToken 351 } 352 }else { 353 accessToken = t 354 } 355 return accessToken 356 } 357 function instanceUrl(i) { 358 if(arguments.length === 0) { 359 if(!$$.isNil(instUrl)) { 360 return instUrl 361 } 362 instUrl = $$.cookies.get("instance_url") 363 }else { 364 if(i === null) { 365 $$.cookies.remove("instance_url"); 366 instUrl = null 367 }else { 368 $$.cookies.set("instance_url", i); 369 instUrl = i 370 } 371 } 372 return instUrl 373 } 374 function parseHash(hash) { 375 var i, nv, nvp, n, v; 376 if(!$$.isNil(hash)) { 377 if(hash.indexOf("#") === 0) { 378 hash = hash.substr(1) 379 } 380 nvp = hash.split("\x26"); 381 for(i = 0;i < nvp.length;i += 1) { 382 nv = nvp[i].split("\x3d"); 383 n = nv[0]; 384 v = decodeURIComponent(nv[1]); 385 if("access_token" === n) { 386 token(v) 387 }else { 388 if("instance_url" === n) { 389 instanceUrl(v) 390 }else { 391 if("target_origin" === n) { 392 tOrigin = decodeURIComponent(v) 393 }else { 394 if("instance_id" === n) { 395 instId = v 396 } 397 } 398 } 399 } 400 } 401 } 402 } 403 function checkChildWindowStatus() { 404 if(!childWindow || childWindow.closed) { 405 refresh() 406 } 407 } 408 function childWindowUnloadNotification(hash) { 409 parseHash(hash); 410 setTimeout(window.Sfdc.canvas.oauth.checkChildWindowStatus, 50) 411 } 412 function logout() { 413 token(null) 414 } 415 function loggedin() { 416 return!$$.isNil(token()) 417 } 418 function loginUrl() { 419 var i, nvs, nv, q = self.location.search; 420 if(q) { 421 q = q.substring(1); 422 nvs = q.split("\x26"); 423 for(i = 0;i < nvs.length;i += 1) { 424 nv = nvs[i].split("\x3d"); 425 if("loginUrl" === nv[0]) { 426 return decodeURIComponent(nv[1]) + "/services/oauth2/authorize" 427 } 428 } 429 } 430 return"https://login.salesforce.com/services/oauth2/authorize" 431 } 432 function targetOrigin(to) { 433 if(!$$.isNil(to)) { 434 tOrigin = to; 435 return to 436 } 437 if(!$$.isNil(tOrigin)) { 438 return tOrigin 439 } 440 parseHash(document.location.hash); 441 return tOrigin 442 } 443 function instanceId(id) { 444 if(!$$.isNil(id)) { 445 instId = id; 446 return id 447 } 448 if(!$$.isNil(instId)) { 449 return instId 450 } 451 parseHash(document.location.hash); 452 return instId 453 } 454 function client() { 455 return{oauthToken:token(), instanceId:instanceId(), targetOrigin:targetOrigin()} 456 } 457 return{init:init, login:login, logout:logout, loggedin:loggedin, loginUrl:loginUrl, token:token, instance:instanceUrl, client:client, checkChildWindowStatus:checkChildWindowStatus, childWindowUnloadNotification:childWindowUnloadNotification} 458 }(); 459 $$.module("Sfdc.canvas.oauth", module); 460 $$.oauth.init() 461 })(Sfdc.canvas); 462 (function($$, window) { 463 var module = function() { 464 var internalCallback; 465 function postMessage(message, target_url, target) { 466 var sfdcJson = Sfdc.JSON || JSON; 467 if($$.isNil(target_url)) { 468 throw"ERROR: target_url was not supplied on postMessage"; 469 } 470 var otherWindow = $$.stripUrl(target_url); 471 target = target || parent; 472 if(window.postMessage) { 473 if($$.isObject(message)) { 474 message.targetModule = "Canvas" 475 } 476 message = sfdcJson.stringify(message); 477 target.postMessage(message, otherWindow) 478 } 479 } 480 function receiveMessage(callback, source_origin) { 481 if(window.postMessage) { 482 if(callback) { 483 internalCallback = function(e) { 484 var data, r; 485 var sfdcJson = Sfdc.JSON || JSON; 486 if(!$$.isNil(e)) { 487 if(typeof source_origin === "string" && e.origin !== source_origin) { 488 return false 489 } 490 if($$.isFunction(source_origin)) { 491 r = source_origin(e.origin, e.data); 492 if(r === false) { 493 return false 494 } 495 } 496 if($$.appearsJson(e.data)) { 497 try { 498 data = sfdcJson.parse(e.data) 499 }catch(ignore) { 500 } 501 if(!$$.isNil(data) && ($$.isNil(data.targetModule) || data.targetModule === "Canvas")) { 502 callback(data, r) 503 } 504 } 505 } 506 } 507 } 508 if(window.addEventListener) { 509 window.addEventListener("message", internalCallback, false) 510 }else { 511 window.attachEvent("onmessage", internalCallback) 512 } 513 } 514 } 515 function removeListener() { 516 if(window.postMessage) { 517 if(window.removeEventListener) { 518 window.removeEventListener("message", internalCallback, false) 519 }else { 520 window.detachEvent("onmessage", internalCallback) 521 } 522 } 523 } 524 return{post:postMessage, receive:receiveMessage, remove:removeListener} 525 }(); 526 $$.module("Sfdc.canvas.xd", module) 527 })(Sfdc.canvas, this); 528 (function($$) { 529 var pversion, cversion = "29.0"; 530 var module = function() { 531 var purl; 532 function startsWithHttp(u, d) { 533 return $$.isNil(u) ? u : u.substring(0, 4) === "http" ? u : d 534 } 535 function getTargetOrigin(to) { 536 var h; 537 if(to === "*") { 538 return to 539 } 540 if(!$$.isNil(to)) { 541 h = $$.stripUrl(to); 542 purl = startsWithHttp(h, purl); 543 if(purl) { 544 return purl 545 } 546 } 547 h = $$.document().location.hash; 548 if(h) { 549 h = decodeURIComponent(h.replace(/^#/, "")); 550 purl = startsWithHttp(h, purl) 551 } 552 return purl 553 } 554 function xdCallback(data) { 555 if(data) { 556 if(submodules[data.type]) { 557 submodules[data.type].callback(data) 558 } 559 } 560 } 561 var submodules = function() { 562 var cbs = [], seq = 0, autog = true; 563 function postit(clientscb, message) { 564 var wrapped, to, c; 565 seq = seq > 100 ? 0 : seq + 1; 566 cbs[seq] = clientscb; 567 wrapped = {seq:seq, src:"client", clientVersion:cversion, parentVersion:pversion, body:message}; 568 c = message && message.config && message.config.client; 569 to = getTargetOrigin($$.isNil(c) ? null : c.targetOrigin); 570 if($$.isNil(to)) { 571 throw"ERROR: targetOrigin was not supplied and was not found on the hash tag, this can result from a redirect or link to another page."; 572 } 573 $$.xd.post(wrapped, to, parent) 574 } 575 function validateClient(client, cb) { 576 var msg; 577 client = client || $$.oauth && $$.oauth.client(); 578 if($$.isNil(client) || $$.isNil(client.oauthToken)) { 579 msg = {status:401, statusText:"Unauthorized", parentVersion:pversion, payload:"client or client.oauthToken not supplied"} 580 } 581 if($$.isNil(client.instanceId) || $$.isNil(client.targetOrigin)) { 582 msg = {status:400, statusText:"Bad Request", parentVersion:pversion, payload:"client.instanceId or client.targetOrigin not supplied"} 583 } 584 if(!$$.isNil(msg)) { 585 if($$.isFunction(cb)) { 586 cb(msg); 587 return false 588 }else { 589 throw msg; 590 } 591 } 592 return true 593 } 594 var event = function() { 595 var subscriptions = {}, STR_EVT = "sfdc.streamingapi"; 596 function validName(name, res) { 597 var msg, r = $$.validEventName(name, res); 598 if(r !== 0) { 599 msg = {1:"Event names can only contain one namespace", 2:"Namespace has already been reserved", 3:"Event name contains invalid characters"}; 600 throw msg[r]; 601 } 602 } 603 function findSubscription(event) { 604 var s, name = event.name; 605 if(name === STR_EVT) { 606 s = subscriptions[name][event.params.topic] 607 }else { 608 s = subscriptions[name] 609 } 610 if(!$$.isNil(s) && $$.isFunction(s.onData)) { 611 return s 612 } 613 return null 614 } 615 return{callback:function(data) { 616 var event = data.payload, subscription = findSubscription(event), func; 617 if(!$$.isNil(subscription)) { 618 if(event.method === "onData") { 619 func = subscription.onData 620 }else { 621 if(event.method === "onComplete") { 622 func = subscription.onComplete 623 } 624 } 625 if(!$$.isNil(func) && $$.isFunction(func)) { 626 func(event.payload) 627 } 628 } 629 }, subscribe:function(client, s) { 630 var subs = {}; 631 if($$.isNil(s) || !validateClient(client)) { 632 throw"precondition fail"; 633 } 634 $$.each($$.isArray(s) ? s : [s], function(v) { 635 if(!$$.isNil(v.name)) { 636 validName(v.name, ["canvas", "sfdc"]); 637 if(v.name === STR_EVT) { 638 if(!$$.isNil(v.params) && !$$.isNil(v.params.topic)) { 639 if($$.isNil(subscriptions[v.name])) { 640 subscriptions[v.name] = {} 641 } 642 subscriptions[v.name][v.params.topic] = v 643 }else { 644 throw"[" + STR_EVT + "] topic is missing"; 645 } 646 }else { 647 subscriptions[v.name] = v 648 } 649 subs[v.name] = {params:v.params} 650 }else { 651 throw"subscription does not have a 'name'"; 652 } 653 }); 654 if(!client.isVF) { 655 postit(null, {type:"subscribe", config:{client:client}, subscriptions:subs}) 656 } 657 }, unsubscribe:function(client, s) { 658 var subs = {}; 659 if($$.isNil(s) || !validateClient(client)) { 660 throw"PRECONDITION FAIL: need fo supply client and event name"; 661 } 662 if($$.isString(s)) { 663 subs[s] = {}; 664 delete subscriptions[s] 665 }else { 666 $$.each($$.isArray(s) ? s : [s], function(v) { 667 var name = v.name ? v.name : v; 668 validName(name, ["canvas", "sfdc"]); 669 subs[name] = {params:v.params}; 670 if(name === STR_EVT) { 671 if(!$$.isNil(subscriptions[name])) { 672 if(!$$.isNil(subscriptions[name][v.params.topic])) { 673 delete subscriptions[name][v.params.topic] 674 } 675 if($$.size(subscriptions[name]) <= 0) { 676 delete subscriptions[name] 677 } 678 } 679 }else { 680 delete subscriptions[name] 681 } 682 }) 683 } 684 if(!client.isVF) { 685 postit(null, {type:"unsubscribe", config:{client:client}, subscriptions:subs}) 686 } 687 }, publish:function(client, e) { 688 if(!$$.isNil(e) && !$$.isNil(e.name)) { 689 validName(e.name); 690 if(validateClient(client)) { 691 postit(null, {type:"publish", config:{client:client}, event:e}) 692 } 693 } 694 }} 695 }(); 696 var callback = function() { 697 return{callback:function(data) { 698 if(data.status === 401 && $$.isArray(data.payload) && data.payload[0].errorCode && data.payload[0].errorCode === "INVALID_SESSION_ID") { 699 if($$.oauth) { 700 $$.oauth.logout() 701 } 702 } 703 if($$.isFunction(cbs[data.seq])) { 704 if(!$$.isFunction(cbs[data.seq])) { 705 alert("not function") 706 } 707 cbs[data.seq](data) 708 }else { 709 } 710 }} 711 }(); 712 var services = function() { 713 var sr; 714 return{ajax:function(url, settings) { 715 var ccb, config, defaults; 716 if(!url) { 717 throw"PRECONDITION ERROR: url required with AJAX call"; 718 } 719 if(!settings || !$$.isFunction(settings.success)) { 720 throw"PRECONDITION ERROR: function: 'settings.success' missing."; 721 } 722 if(!validateClient(settings.client, settings.success)) { 723 return 724 } 725 ccb = settings.success; 726 defaults = {method:"GET", async:true, contentType:"application/json", headers:{"Authorization":"OAuth " + settings.client.oauthToken, "Accept":"application/json"}, data:null}; 727 config = $$.extend(defaults, settings || {}); 728 config.success = undefined; 729 config.failure = undefined; 730 if(config.client.targetOrigin === "*") { 731 config.client.targetOrigin = null 732 }else { 733 purl = startsWithHttp(config.targetOrigin, purl) 734 } 735 postit(ccb, {type:"ajax", url:url, config:config}) 736 }, ctx:function(clientscb, client) { 737 if(validateClient(client, clientscb)) { 738 postit(clientscb, {type:"ctx", accessToken:client.oauthToken, config:{client:client}}) 739 } 740 }, token:function(t) { 741 return $$.oauth && $$.oauth.token(t) 742 }, version:function() { 743 return{clientVersion:cversion, parentVersion:pversion} 744 }, signedrequest:function(s) { 745 if(arguments.length > 0) { 746 sr = s 747 } 748 return sr 749 }} 750 }(); 751 var frame = function() { 752 return{size:function() { 753 var docElement = $$.document().documentElement; 754 var contentHeight = docElement.scrollHeight, pageHeight = docElement.clientHeight, scrollTop = docElement && docElement.scrollTop || $$.document().body.scrollTop, contentWidth = docElement.scrollWidth, pageWidth = docElement.clientWidth, scrollLeft = docElement && docElement.scrollLeft || $$.document().body.scrollLeft; 755 return{heights:{contentHeight:contentHeight, pageHeight:pageHeight, scrollTop:scrollTop}, widths:{contentWidth:contentWidth, pageWidth:pageWidth, scrollLeft:scrollLeft}} 756 }, resize:function(client, size) { 757 var sh, ch, sw, cw, s = {height:"", width:""}, docElement = $$.document().documentElement; 758 if($$.isNil(size)) { 759 sh = docElement.scrollHeight; 760 ch = docElement.clientHeight; 761 if(ch !== sh) { 762 s.height = sh + "px" 763 } 764 sw = docElement.scrollWidth; 765 cw = docElement.clientWidth; 766 if(sw !== cw) { 767 s.width = sw + "px" 768 } 769 }else { 770 if(!$$.isNil(size.height)) { 771 s.height = size.height 772 } 773 if(!$$.isNil(size.width)) { 774 s.width = size.width 775 } 776 } 777 if(!$$.isNil(s.height) || !$$.isNil(s.width)) { 778 postit(null, {type:"resize", config:{client:client}, size:s}) 779 } 780 }, autogrow:function(client, b, interval) { 781 var ival = $$.isNil(interval) ? 300 : interval; 782 autog = $$.isNil(b) ? true : b; 783 if(autog === false) { 784 return 785 } 786 setTimeout(function() { 787 submodules.frame.resize(client); 788 submodules.frame.autogrow(client, autog) 789 }, ival) 790 }} 791 }(); 792 return{services:services, frame:frame, event:event, callback:callback} 793 }(); 794 $$.xd.receive(xdCallback, getTargetOrigin); 795 return{ctx:submodules.services.ctx, ajax:submodules.services.ajax, token:submodules.services.token, version:submodules.services.version, resize:submodules.frame.resize, size:submodules.frame.size, autogrow:submodules.frame.autogrow, subscribe:submodules.event.subscribe, unsubscribe:submodules.event.unsubscribe, publish:submodules.event.publish, signedrequest:submodules.services.signedrequest} 796 }(); 797 $$.module("Sfdc.canvas.client", module) 798 })(Sfdc.canvas); 799