PageRenderTime 1554ms CodeModel.GetById 36ms RepoModel.GetById 4ms app.codeStats 3ms

/web/src/main/resources/public/scripts/js-all-min.js

http://github.com/lmco/eurekastreams
JavaScript | 1319 lines | 679 code | 195 blank | 445 comment | 78 complexity | cb7626a0aea9a591d77f223fc843663f MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations under the License.
  17. */
  18. /**
  19. * @fileoverview Functions for setting, getting and deleting cookies
  20. */
  21. /**
  22. * Namespace for cookie functions
  23. */
  24. // TODO: find the official solution for a cookies library
  25. var shindig = shindig || {};
  26. shindig.cookies = shindig.cookies || {};
  27. shindig.cookies.JsType_ = {
  28. UNDEFINED: 'undefined'
  29. };
  30. shindig.cookies.isDef = function(val) {
  31. return typeof val != shindig.cookies.JsType_.UNDEFINED;
  32. };
  33. /**
  34. * Sets a cookie.
  35. * The max_age can be -1 to set a session cookie. To remove and expire cookies,
  36. * use remove() instead.
  37. *
  38. * @param {string} name The cookie name.
  39. * @param {string} value The cookie value.
  40. * @param {number} opt_maxAge The max age in seconds (from now). Use -1 to set
  41. * a session cookie. If not provided, the default is
  42. * -1 (i.e. set a session cookie).
  43. * @param {string} opt_path The path of the cookie, or null to not specify a
  44. * path attribute (browser will use the full request
  45. * path). If not provided, the default is '/' (i.e.
  46. * path=/).
  47. * @param {string} opt_domain The domain of the cookie, or null to not specify
  48. * a domain attribute (browser will use the full
  49. * request host name). If not provided, the default
  50. * is null (i.e. let browser use full request host
  51. * name).
  52. */
  53. shindig.cookies.set = function(name, value, opt_maxAge, opt_path, opt_domain) {
  54. // we do not allow '=' or ';' in the name
  55. if (/;=/g.test(name)) {
  56. throw new Error('Invalid cookie name "' + name + '"');
  57. }
  58. // we do not allow ';' in value
  59. if (/;/g.test(value)) {
  60. throw new Error('Invalid cookie value "' + value + '"');
  61. }
  62. if (!shindig.cookies.isDef(opt_maxAge)) {
  63. opt_maxAge = -1;
  64. }
  65. var domainStr = opt_domain ? ';domain=' + opt_domain : '';
  66. var pathStr = opt_path ? ';path=' + opt_path : '';
  67. var expiresStr;
  68. // Case 1: Set a session cookie.
  69. if (opt_maxAge < 0) {
  70. expiresStr = '';
  71. // Case 2: Expire the cookie.
  72. // Note: We don't tell people about this option in the function doc because
  73. // we prefer people to use ExpireCookie() to expire cookies.
  74. } else if (opt_maxAge === 0) {
  75. // Note: Don't use Jan 1, 1970 for date because NS 4.76 will try to convert
  76. // it to local time, and if the local time is before Jan 1, 1970, then the
  77. // browser will ignore the Expires attribute altogether.
  78. var pastDate = new Date(1970, 1 /*Feb*/, 1); // Feb 1, 1970
  79. expiresStr = ';expires=' + pastDate.toUTCString();
  80. // Case 3: Set a persistent cookie.
  81. } else {
  82. var futureDate = new Date((new Date).getTime() + opt_maxAge * 1000);
  83. expiresStr = ';expires=' + futureDate.toUTCString();
  84. }
  85. document.cookie = name + '=' + value + domainStr + pathStr + expiresStr;
  86. };
  87. /**
  88. * Returns the value for the first cookie with the given name
  89. * @param {string} name The name of the cookie to get
  90. * @param {string} opt_default If not found this is returned instead.
  91. * @return {string|undefined} The value of the cookie. If no cookie is set this
  92. * returns opt_default or undefined if opt_default is
  93. * not provided.
  94. */
  95. shindig.cookies.get = function(name, opt_default) {
  96. var nameEq = name + "=";
  97. var cookie = String(document.cookie);
  98. for (var pos = -1; (pos = cookie.indexOf(nameEq, pos + 1)) >= 0;) {
  99. var i = pos;
  100. // walk back along string skipping whitespace and looking for a ; before
  101. // the name to make sure that we don't match cookies whose name contains
  102. // the given name as a suffix.
  103. while (--i >= 0) {
  104. var ch = cookie.charAt(i);
  105. if (ch == ';') {
  106. i = -1; // indicate success
  107. break;
  108. }
  109. }
  110. if (i == -1) { // first cookie in the string or we found a ;
  111. var end = cookie.indexOf(';', pos);
  112. if (end < 0) {
  113. end = cookie.length;
  114. }
  115. return cookie.substring(pos + nameEq.length, end);
  116. }
  117. }
  118. return opt_default;
  119. };
  120. /**
  121. * Removes and expires a cookie.
  122. *
  123. * @param {string} name The cookie name.
  124. * @param {string} opt_path The path of the cookie, or null to expire a cookie
  125. * set at the full request path. If not provided, the
  126. * default is '/' (i.e. path=/).
  127. * @param {string} opt_domain The domain of the cookie, or null to expire a
  128. * cookie set at the full request host name. If not
  129. * provided, the default is null (i.e. cookie at
  130. * full request host name).
  131. */
  132. shindig.cookies.remove = function(name, opt_path, opt_domain) {
  133. var rv = shindig.cookies.containsKey(name);
  134. shindig.cookies.set(name, '', 0, opt_path, opt_domain);
  135. return rv;
  136. };
  137. /**
  138. * Gets the names and values for all the cookies
  139. * @private
  140. * @return {Object} An object with keys and values
  141. */
  142. shindig.cookies.getKeyValues_ = function() {
  143. var cookie = String(document.cookie);
  144. var parts = cookie.split(/\s*;\s*/);
  145. var keys = [], values = [], index, part;
  146. for (var i = 0; part = parts[i]; i++) {
  147. index = part.indexOf('=');
  148. if (index == -1) { // empty name
  149. keys.push('');
  150. values.push(part);
  151. } else {
  152. keys.push(part.substring(0, index));
  153. values.push(part.substring(index + 1));
  154. }
  155. }
  156. return {keys: keys, values: values};
  157. };
  158. /**
  159. * Gets the names for all the cookies
  160. * @return {Array} An array with the names of the cookies
  161. */
  162. shindig.cookies.getKeys = function() {
  163. return shindig.cookies.getKeyValues_().keys;
  164. };
  165. /**
  166. * Gets the values for all the cookies
  167. * @return {Array} An array with the values of the cookies
  168. */
  169. shindig.cookies.getValues = function() {
  170. return shindig.cookies.getKeyValues_().values;
  171. };
  172. /**
  173. * Whether there are any cookies for this document
  174. * @return {boolean}
  175. */
  176. shindig.cookies.isEmpty = function() {
  177. return document.cookie === '';
  178. };
  179. /**
  180. * Returns the number of cookies for this document
  181. * @return {number}
  182. */
  183. shindig.cookies.getCount = function() {
  184. var cookie = String(document.cookie);
  185. if (cookie === '') {
  186. return 0;
  187. }
  188. var parts = cookie.split(/\s*;\s*/);
  189. return parts.length;
  190. };
  191. /**
  192. * Returns whether there is a cookie with the given name
  193. * @param {string} key The name of the cookie to test for
  194. * @return {boolean}
  195. */
  196. shindig.cookies.containsKey = function(key) {
  197. var sentinel = {};
  198. // if get does not find the key it returns the default value. We therefore
  199. // compare the result with an object to ensure we do not get any false
  200. // positives.
  201. return shindig.cookies.get(key, sentinel) !== sentinel;
  202. };
  203. /**
  204. * Returns whether there is a cookie with the given value. (This is an O(n)
  205. * operation.)
  206. * @param {string} value The value to check for
  207. * @return {boolean}
  208. */
  209. shindig.cookies.containsValue = function(value) {
  210. // this O(n) in any case so lets do the trivial thing.
  211. var values = shindig.cookies.getKeyValues_().values;
  212. for (var i = 0; i < values.length; i++) {
  213. if (values[i] == value) {
  214. return true;
  215. }
  216. }
  217. return false;
  218. };
  219. /**
  220. * Removes all cookies for this document
  221. */
  222. shindig.cookies.clear = function() {
  223. var keys = shindig.cookies.getKeyValues_().keys;
  224. for (var i = keys.length - 1; i >= 0; i--) {
  225. shindig.cookies.remove(keys[i]);
  226. }
  227. };
  228. /**
  229. * Static constant for the size of cookies. Per the spec, there's a 4K limit
  230. * to the size of a cookie. To make sure users can't break this limit, we
  231. * should truncate long cookies at 3950 bytes, to be extra careful with dumb
  232. * browsers/proxies that interpret 4K as 4000 rather than 4096
  233. * @type number
  234. */
  235. shindig.cookies.MAX_COOKIE_LENGTH = 3950;
  236. /**
  237. * Licensed to the Apache Software Foundation (ASF) under one
  238. * or more contributor license agreements. See the NOTICE file
  239. * distributed with this work for additional information
  240. * regarding copyright ownership. The ASF licenses this file
  241. * to you under the Apache License, Version 2.0 (the
  242. * "License"); you may not use this file except in compliance
  243. * with the License. You may obtain a copy of the License at
  244. *
  245. * http://www.apache.org/licenses/LICENSE-2.0
  246. *
  247. * Unless required by applicable law or agreed to in writing,
  248. * software distributed under the License is distributed on an
  249. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  250. * KIND, either express or implied. See the License for the
  251. * specific language governing permissions and limitations under the License.
  252. */
  253. /**
  254. * @fileoverview Utility functions for the Open Gadget Container
  255. */
  256. Function.prototype.inherits = function(parentCtor) {
  257. function tempCtor() {};
  258. tempCtor.prototype = parentCtor.prototype;
  259. this.superClass_ = parentCtor.prototype;
  260. this.prototype = new tempCtor();
  261. this.prototype.constructor = this;
  262. };/**
  263. * Licensed to the Apache Software Foundation (ASF) under one
  264. * or more contributor license agreements. See the NOTICE file
  265. * distributed with this work for additional information
  266. * regarding copyright ownership. The ASF licenses this file
  267. * to you under the Apache License, Version 2.0 (the
  268. * "License"); you may not use this file except in compliance
  269. * with the License. You may obtain a copy of the License at
  270. *
  271. * http://www.apache.org/licenses/LICENSE-2.0
  272. *
  273. * Unless required by applicable law or agreed to in writing,
  274. * software distributed under the License is distributed on an
  275. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  276. * KIND, either express or implied. See the License for the
  277. * specific language governing permissions and limitations under the License.
  278. */
  279. /**
  280. * @fileoverview Open Gadget Container
  281. */
  282. var gadgets = gadgets || {};
  283. gadgets.error = {};
  284. gadgets.error.SUBCLASS_RESPONSIBILITY = 'subclass responsibility';
  285. gadgets.error.TO_BE_DONE = 'to be done';
  286. gadgets.log = function(message) {
  287. if (window.console && console.log) {
  288. console.log(message);
  289. } else {
  290. var logEntry = document.createElement('div');
  291. logEntry.className = 'gadgets-log-entry';
  292. logEntry.innerHTML = message;
  293. document.body.appendChild(logEntry);
  294. }
  295. };
  296. /**
  297. * Calls an array of asynchronous functions and calls the continuation
  298. * function when all are done.
  299. * @param {Array} functions Array of asynchronous functions, each taking
  300. * one argument that is the continuation function that handles the result
  301. * That is, each function is something like the following:
  302. * function(continuation) {
  303. * // compute result asynchronously
  304. * continuation(result);
  305. * }
  306. * @param {Function} continuation Function to call when all results are in. It
  307. * is pass an array of all results of all functions
  308. * @param {Object} opt_this Optional object used as "this" when calling each
  309. * function
  310. */
  311. gadgets.callAsyncAndJoin = function(functions, continuation, opt_this) {
  312. var pending = functions.length;
  313. var results = [];
  314. for (var i = 0; i < functions.length; i++) {
  315. // we need a wrapper here because i changes and we need one index
  316. // variable per closure
  317. var wrapper = function(index) {
  318. functions[index].call(opt_this, function(result) {
  319. results[index] = result;
  320. if (--pending === 0) {
  321. continuation(results);
  322. }
  323. });
  324. };
  325. wrapper(i);
  326. }
  327. };
  328. // ----------
  329. // Extensible
  330. gadgets.Extensible = function() {
  331. };
  332. /**
  333. * Sets the dependencies.
  334. * @param {Object} dependencies Object whose properties are set on this
  335. * container as dependencies
  336. */
  337. gadgets.Extensible.prototype.setDependencies = function(dependencies) {
  338. for (var p in dependencies) {
  339. this[p] = dependencies[p];
  340. }
  341. };
  342. /**
  343. * Returns a dependency given its name.
  344. * @param {String} name Name of dependency
  345. * @return {Object} Dependency with that name or undefined if not found
  346. */
  347. gadgets.Extensible.prototype.getDependencies = function(name) {
  348. return this[name];
  349. };
  350. // -------------
  351. // UserPrefStore
  352. /**
  353. * User preference store interface.
  354. * @constructor
  355. */
  356. gadgets.UserPrefStore = function() {
  357. };
  358. /**
  359. * Gets all user preferences of a gadget.
  360. * @param {Object} gadget Gadget object
  361. * @return {Object} All user preference of given gadget
  362. */
  363. gadgets.UserPrefStore.prototype.getPrefs = function(gadget) {
  364. throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY);
  365. };
  366. /**
  367. * Saves user preferences of a gadget in the store.
  368. * @param {Object} gadget Gadget object
  369. * @param {Object} prefs User preferences
  370. */
  371. gadgets.UserPrefStore.prototype.savePrefs = function(gadget) {
  372. throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY);
  373. };
  374. // -------------
  375. // DefaultUserPrefStore
  376. /**
  377. * User preference store implementation.
  378. * TODO: Turn this into a real implementation that is production safe
  379. * @constructor
  380. */
  381. gadgets.DefaultUserPrefStore = function() {
  382. gadgets.UserPrefStore.call(this);
  383. };
  384. gadgets.DefaultUserPrefStore.inherits(gadgets.UserPrefStore);
  385. gadgets.DefaultUserPrefStore.prototype.getPrefs = function(gadget) { };
  386. gadgets.DefaultUserPrefStore.prototype.savePrefs = function(gadget) { };
  387. // -------------
  388. // GadgetService
  389. /**
  390. * Interface of service provided to gadgets for resizing gadgets,
  391. * setting title, etc.
  392. * @constructor
  393. */
  394. gadgets.GadgetService = function() {
  395. };
  396. gadgets.GadgetService.prototype.setHeight = function(elementId, height) {
  397. throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY);
  398. };
  399. gadgets.GadgetService.prototype.setTitle = function(gadget, title) {
  400. throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY);
  401. };
  402. gadgets.GadgetService.prototype.setUserPref = function(id) {
  403. throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY);
  404. };
  405. // ----------------
  406. // IfrGadgetService
  407. /**
  408. * Base implementation of GadgetService.
  409. * @constructor
  410. */
  411. gadgets.IfrGadgetService = function() {
  412. gadgets.GadgetService.call(this);
  413. gadgets.rpc.register('resize_iframe', this.setHeight);
  414. gadgets.rpc.register('set_pref', this.setUserPref);
  415. gadgets.rpc.register('set_title', this.setTitle);
  416. gadgets.rpc.register('requestNavigateTo', this.requestNavigateTo);
  417. };
  418. gadgets.IfrGadgetService.inherits(gadgets.GadgetService);
  419. gadgets.IfrGadgetService.prototype.setHeight = function(height) {
  420. if (height > gadgets.container.maxheight_) {
  421. height = gadgets.container.maxheight_;
  422. }
  423. var element = document.getElementById(this.f);
  424. if (element) {
  425. element.style.height = height + 'px';
  426. }
  427. };
  428. gadgets.IfrGadgetService.prototype.setTitle = function(title) {
  429. var element = document.getElementById(this.f + '_title');
  430. if (element) {
  431. element.innerHTML = title.replace(/&/g, '&amp;').replace(/</g, '&lt;');
  432. }
  433. };
  434. /**
  435. * Sets one or more user preferences
  436. * @param {String} editToken
  437. * @param {String} name Name of user preference
  438. * @param {String} value Value of user preference
  439. * More names and values may follow
  440. */
  441. gadgets.IfrGadgetService.prototype.setUserPref = function(editToken, name,
  442. value) {
  443. var id = gadgets.container.gadgetService.getGadgetIdFromModuleId(this.f);
  444. var gadget = gadgets.container.getGadget(id);
  445. var prefs = gadget.getUserPrefs() || {};
  446. for (var i = 1, j = arguments.length; i < j; i += 2) {
  447. prefs[arguments[i]] = arguments[i + 1];
  448. }
  449. gadget.setUserPrefs(prefs);
  450. };
  451. /**
  452. * Navigates the page to a new url based on a gadgets requested view and
  453. * parameters.
  454. */
  455. gadgets.IfrGadgetService.prototype.requestNavigateTo = function(view,
  456. opt_params) {
  457. var id = gadgets.container.gadgetService.getGadgetIdFromModuleId(this.f);
  458. var url = gadgets.container.gadgetService.getUrlForView(view);
  459. if (opt_params) {
  460. var paramStr = gadgets.json.stringify(opt_params);
  461. if (paramStr.length > 0) {
  462. url += '&appParams=' + encodeURIComponent(paramStr);
  463. }
  464. }
  465. if (url && document.location.href.indexOf(url) == -1) {
  466. document.location.href = url;
  467. }
  468. };
  469. /**
  470. * This is a silly implementation that will need to be overriden by almost all
  471. * real containers.
  472. * TODO: Find a better default for this function
  473. *
  474. * @param view The view name to get the url for
  475. */
  476. gadgets.IfrGadgetService.prototype.getUrlForView = function(
  477. view) {
  478. if (view === 'canvas') {
  479. return '/canvas';
  480. } else if (view === 'profile') {
  481. return '/profile';
  482. } else {
  483. return null;
  484. }
  485. };
  486. gadgets.IfrGadgetService.prototype.getGadgetIdFromModuleId = function(
  487. moduleId) {
  488. // Quick hack to extract the gadget id from module id
  489. return parseInt(moduleId.match(/_([0-9]+)$/)[1], 10);
  490. };
  491. // -------------
  492. // LayoutManager
  493. /**
  494. * Layout manager interface.
  495. * @constructor
  496. */
  497. gadgets.LayoutManager = function() {
  498. };
  499. /**
  500. * Gets the HTML element that is the chrome of a gadget into which the content
  501. * of the gadget can be rendered.
  502. * @param {Object} gadget Gadget instance
  503. * @return {Object} HTML element that is the chrome for the given gadget
  504. */
  505. gadgets.LayoutManager.prototype.getGadgetChrome = function(gadget) {
  506. throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY);
  507. };
  508. // -------------------
  509. // StaticLayoutManager
  510. /**
  511. * Static layout manager where gadget ids have a 1:1 mapping to chrome ids.
  512. * @constructor
  513. */
  514. gadgets.StaticLayoutManager = function() {
  515. gadgets.LayoutManager.call(this);
  516. };
  517. gadgets.StaticLayoutManager.inherits(gadgets.LayoutManager);
  518. /**
  519. * Sets chrome ids, whose indexes are gadget instance ids (starting from 0).
  520. * @param {Array} gadgetChromeIds Gadget id to chrome id map
  521. */
  522. gadgets.StaticLayoutManager.prototype.setGadgetChromeIds =
  523. function(gadgetChromeIds) {
  524. this.gadgetChromeIds_ = gadgetChromeIds;
  525. };
  526. gadgets.StaticLayoutManager.prototype.getGadgetChrome = function(gadget) {
  527. var chromeId = this.gadgetChromeIds_[gadget.id];
  528. return chromeId ? document.getElementById(chromeId) : null;
  529. };
  530. // ----------------------
  531. // FloatLeftLayoutManager
  532. /**
  533. * FloatLeft layout manager where gadget ids have a 1:1 mapping to chrome ids.
  534. * @constructor
  535. * @param {String} layoutRootId Id of the element that is the parent of all
  536. * gadgets.
  537. */
  538. gadgets.FloatLeftLayoutManager = function(layoutRootId) {
  539. gadgets.LayoutManager.call(this);
  540. this.layoutRootId_ = layoutRootId;
  541. };
  542. gadgets.FloatLeftLayoutManager.inherits(gadgets.LayoutManager);
  543. gadgets.FloatLeftLayoutManager.prototype.getGadgetChrome =
  544. function(gadget) {
  545. var layoutRoot = document.getElementById(this.layoutRootId_);
  546. if (layoutRoot) {
  547. var chrome = document.createElement('div');
  548. chrome.className = 'gadgets-gadget-chrome';
  549. chrome.style.cssFloat = 'left';
  550. layoutRoot.appendChild(chrome);
  551. return chrome;
  552. } else {
  553. return null;
  554. }
  555. };
  556. // ------
  557. // Gadget
  558. /**
  559. * Creates a new instance of gadget. Optional parameters are set as instance
  560. * variables.
  561. * @constructor
  562. * @param {Object} params Parameters to set on gadget. Common parameters:
  563. * "specUrl": URL to gadget specification
  564. * "private": Whether gadget spec is accessible only privately, which means
  565. * browser can load it but not gadget server
  566. * "spec": Gadget Specification in XML
  567. * "viewParams": a javascript object containing attribute value pairs
  568. * for this gadgets
  569. * "secureToken": an encoded token that is passed on the URL hash
  570. * "hashData": Query-string like data that will be added to the
  571. * hash portion of the URL.
  572. * "specVersion": a hash value used to add a v= param to allow for better caching
  573. * "title": the default title to use for the title bar.
  574. * "height": height of the gadget
  575. * "width": width of the gadget
  576. * "debug": send debug=1 to the gadget server, gets us uncompressed
  577. * javascript
  578. */
  579. gadgets.Gadget = function(params) {
  580. this.userPrefs_ = {};
  581. if (params) {
  582. for (var name in params) if (params.hasOwnProperty(name)) {
  583. this[name] = params[name];
  584. }
  585. }
  586. if (!this.secureToken) {
  587. // Assume that the default security token implementation is
  588. // in use on the server.
  589. this.secureToken = 'john.doe:john.doe:appid:cont:url:0:default';
  590. }
  591. };
  592. gadgets.Gadget.prototype.getUserPrefs = function() {
  593. return this.userPrefs_;
  594. };
  595. gadgets.Gadget.prototype.setUserPrefs = function(userPrefs) {
  596. this.userPrefs_ = userPrefs;
  597. gadgets.container.userPrefStore.savePrefs(this);
  598. };
  599. gadgets.Gadget.prototype.getUserPref = function(name) {
  600. return this.userPrefs_[name];
  601. };
  602. gadgets.Gadget.prototype.setUserPref = function(name, value) {
  603. this.userPrefs_[name] = value;
  604. gadgets.container.userPrefStore.savePrefs(this);
  605. };
  606. gadgets.Gadget.prototype.render = function(chrome) {
  607. if (chrome) {
  608. var gadget = this;
  609. this.getContent(function(content) {
  610. chrome.innerHTML = content;
  611. window.frames[gadget.getIframeId()].location = gadget.getIframeUrl();
  612. });
  613. }
  614. };
  615. gadgets.Gadget.prototype.getContent = function(continuation) {
  616. gadgets.callAsyncAndJoin([
  617. this.getTitleBarContent, this.getUserPrefsDialogContent,
  618. this.getMainContent], function(results) {
  619. continuation(results.join(''));
  620. }, this);
  621. };
  622. /**
  623. * Gets title bar content asynchronously or synchronously.
  624. * @param {Function} continuation Function that handles title bar content as
  625. * the one and only argument
  626. */
  627. gadgets.Gadget.prototype.getTitleBarContent = function(continuation) {
  628. throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY);
  629. };
  630. /**
  631. * Gets user preferences dialog content asynchronously or synchronously.
  632. * @param {Function} continuation Function that handles user preferences
  633. * content as the one and only argument
  634. */
  635. gadgets.Gadget.prototype.getUserPrefsDialogContent = function(continuation) {
  636. throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY);
  637. };
  638. /**
  639. * Gets gadget content asynchronously or synchronously.
  640. * @param {Function} continuation Function that handles gadget content as
  641. * the one and only argument
  642. */
  643. gadgets.Gadget.prototype.getMainContent = function(continuation) {
  644. throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY);
  645. };
  646. /*
  647. * Gets additional parameters to append to the iframe url
  648. * Override this method if you need any custom params.
  649. */
  650. gadgets.Gadget.prototype.getAdditionalParams = function() {
  651. return '';
  652. };
  653. // ---------
  654. // IfrGadget
  655. gadgets.IfrGadget = function(opt_params) {
  656. gadgets.Gadget.call(this, opt_params);
  657. this.serverBase_ = '../../'; // default gadget server
  658. };
  659. gadgets.IfrGadget.inherits(gadgets.Gadget);
  660. gadgets.IfrGadget.prototype.GADGET_IFRAME_PREFIX_ = 'remote_iframe_';
  661. gadgets.IfrGadget.prototype.CONTAINER = 'default';
  662. gadgets.IfrGadget.prototype.cssClassGadget = 'gadgets-gadget';
  663. gadgets.IfrGadget.prototype.cssClassTitleBar = 'gadgets-gadget-title-bar';
  664. gadgets.IfrGadget.prototype.cssClassTitle = 'gadgets-gadget-title';
  665. gadgets.IfrGadget.prototype.cssClassTitleButtonBar =
  666. 'gadgets-gadget-title-button-bar';
  667. gadgets.IfrGadget.prototype.cssClassGadgetUserPrefsDialog =
  668. 'gadgets-gadget-user-prefs-dialog';
  669. gadgets.IfrGadget.prototype.cssClassGadgetUserPrefsDialogActionBar =
  670. 'gadgets-gadget-user-prefs-dialog-action-bar';
  671. gadgets.IfrGadget.prototype.cssClassTitleButton = 'gadgets-gadget-title-button';
  672. gadgets.IfrGadget.prototype.cssClassGadgetContent = 'gadgets-gadget-content';
  673. gadgets.IfrGadget.prototype.rpcToken = (0x7FFFFFFF * Math.random()) | 0;
  674. gadgets.IfrGadget.prototype.rpcRelay = 'files/container/rpc_relay.html';
  675. gadgets.IfrGadget.prototype.getTitleBarContent = function(continuation) {
  676. continuation('<div id="' + this.cssClassTitleBar + '-' + this.id +
  677. '" class="' + this.cssClassTitleBar + '"><span id="' +
  678. this.getIframeId() + '_title" class="' +
  679. this.cssClassTitle + '">' + (this.title ? this.title : 'Title') + '</span> | <span class="' +
  680. this.cssClassTitleButtonBar +
  681. '"><a href="#" onclick="gadgets.container.getGadget(' + this.id +
  682. ').handleOpenUserPrefsDialog();return false;" class="' + this.cssClassTitleButton +
  683. '">settings</a> <a href="#" onclick="gadgets.container.getGadget(' +
  684. this.id + ').handleToggle();return false;" class="' + this.cssClassTitleButton +
  685. '">toggle</a></span></div>');
  686. };
  687. gadgets.IfrGadget.prototype.getUserPrefsDialogContent = function(continuation) {
  688. continuation('<div id="' + this.getUserPrefsDialogId() + '" class="' +
  689. this.cssClassGadgetUserPrefsDialog + '"></div>');
  690. };
  691. gadgets.IfrGadget.prototype.setServerBase = function(url) {
  692. this.serverBase_ = url;
  693. };
  694. gadgets.IfrGadget.prototype.getServerBase = function() {
  695. return this.serverBase_;
  696. };
  697. gadgets.IfrGadget.prototype.getMainContent = function(continuation) {
  698. var iframeId = this.getIframeId();
  699. gadgets.rpc.setRelayUrl(iframeId, this.serverBase_ + this.rpcRelay);
  700. gadgets.rpc.setAuthToken(iframeId, this.rpcToken);
  701. continuation('<div class="' + this.cssClassGadgetContent + '"><iframe id="' +
  702. iframeId + '" name="' + iframeId + '" class="' + this.cssClassGadget +
  703. '" src="about:blank' +
  704. '" frameborder="no" scrolling="no"' +
  705. (this.height ? ' height="' + this.height + '"' : '') +
  706. (this.width ? ' width="' + this.width + '"' : '') +
  707. '></iframe></div>');
  708. };
  709. gadgets.IfrGadget.prototype.getIframeId = function() {
  710. return this.GADGET_IFRAME_PREFIX_ + this.id;
  711. };
  712. gadgets.IfrGadget.prototype.getUserPrefsDialogId = function() {
  713. return this.getIframeId() + '_userPrefsDialog';
  714. };
  715. gadgets.IfrGadget.prototype.getIframeUrl = function() {
  716. return this.serverBase_ + 'ifr?' +
  717. 'container=' + this.CONTAINER +
  718. '&mid=' + this.id +
  719. '&nocache=' + gadgets.container.nocache_ +
  720. '&country=' + gadgets.container.country_ +
  721. '&lang=' + gadgets.container.language_ +
  722. '&view=' + gadgets.container.view_ +
  723. (this.specVersion ? '&v=' + this.specVersion : '') +
  724. (gadgets.container.parentUrl_ ? '&parent=' + encodeURIComponent(gadgets.container.parentUrl_) : '') +
  725. (this.debug ? '&debug=1' : '') +
  726. this.getAdditionalParams() +
  727. this.getUserPrefsParams() +
  728. (this.secureToken ? '&st=' + this.secureToken : '') +
  729. '&url=' + encodeURIComponent(this.specUrl) +
  730. '#rpctoken=' + this.rpcToken +
  731. (this.viewParams ?
  732. '&view-params=' + encodeURIComponent(gadgets.json.stringify(this.viewParams)) : '') +
  733. (this.hashData ? '&' + this.hashData : '');
  734. };
  735. gadgets.IfrGadget.prototype.getUserPrefsParams = function() {
  736. var params = '';
  737. if (this.getUserPrefs()) {
  738. for(var name in this.getUserPrefs()) {
  739. var value = this.getUserPref(name);
  740. params += '&up_' + encodeURIComponent(name) + '=' +
  741. encodeURIComponent(value);
  742. }
  743. }
  744. return params;
  745. };
  746. gadgets.IfrGadget.prototype.handleToggle = function() {
  747. var gadgetIframe = document.getElementById(this.getIframeId());
  748. if (gadgetIframe) {
  749. var gadgetContent = gadgetIframe.parentNode;
  750. var display = gadgetContent.style.display;
  751. gadgetContent.style.display = display ? '' : 'none';
  752. }
  753. };
  754. gadgets.IfrGadget.prototype.handleOpenUserPrefsDialog = function() {
  755. if (this.userPrefsDialogContentLoaded) {
  756. this.showUserPrefsDialog();
  757. } else {
  758. var gadget = this;
  759. var igCallbackName = 'ig_callback_' + this.id;
  760. window[igCallbackName] = function(userPrefsDialogContent) {
  761. gadget.userPrefsDialogContentLoaded = true;
  762. gadget.buildUserPrefsDialog(userPrefsDialogContent);
  763. gadget.showUserPrefsDialog();
  764. };
  765. var script = document.createElement('script');
  766. script.src = 'http://gmodules.com/ig/gadgetsettings?mid=' + this.id +
  767. '&output=js' + this.getUserPrefsParams() + '&url=' + this.specUrl;
  768. document.body.appendChild(script);
  769. }
  770. };
  771. gadgets.IfrGadget.prototype.buildUserPrefsDialog = function(content) {
  772. var userPrefsDialog = document.getElementById(this.getUserPrefsDialogId());
  773. userPrefsDialog.innerHTML = content +
  774. '<div class="' + this.cssClassGadgetUserPrefsDialogActionBar +
  775. '"><input type="button" value="Save" onclick="gadgets.container.getGadget(' +
  776. this.id +').handleSaveUserPrefs()"> <input type="button" value="Cancel" onclick="gadgets.container.getGadget(' +
  777. this.id +').handleCancelUserPrefs()"></div>';
  778. userPrefsDialog.childNodes[0].style.display = '';
  779. };
  780. gadgets.IfrGadget.prototype.showUserPrefsDialog = function(opt_show) {
  781. var userPrefsDialog = document.getElementById(this.getUserPrefsDialogId());
  782. userPrefsDialog.style.display = (opt_show || opt_show === undefined)
  783. ? '' : 'none';
  784. };
  785. gadgets.IfrGadget.prototype.hideUserPrefsDialog = function() {
  786. this.showUserPrefsDialog(false);
  787. };
  788. gadgets.IfrGadget.prototype.handleSaveUserPrefs = function() {
  789. this.hideUserPrefsDialog();
  790. var prefs = {};
  791. var numFields = document.getElementById('m_' + this.id +
  792. '_numfields').value;
  793. for (var i = 0; i < numFields; i++) {
  794. var input = document.getElementById('m_' + this.id + '_' + i);
  795. if (input.type != 'hidden') {
  796. var userPrefNamePrefix = 'm_' + this.id + '_up_';
  797. var userPrefName = input.name.substring(userPrefNamePrefix.length);
  798. var userPrefValue = input.value;
  799. prefs[userPrefName] = userPrefValue;
  800. }
  801. }
  802. this.setUserPrefs(prefs);
  803. this.refresh();
  804. };
  805. gadgets.IfrGadget.prototype.handleCancelUserPrefs = function() {
  806. this.hideUserPrefsDialog();
  807. };
  808. gadgets.IfrGadget.prototype.refresh = function() {
  809. var iframeId = this.getIframeId();
  810. document.getElementById(iframeId).src = this.getIframeUrl();
  811. };
  812. // ---------
  813. // Container
  814. /**
  815. * Container interface.
  816. * @constructor
  817. */
  818. gadgets.Container = function() {
  819. this.gadgets_ = {};
  820. this.parentUrl_ = 'http://' + document.location.host;
  821. this.country_ = 'ALL';
  822. this.language_ = 'ALL';
  823. this.view_ = 'default';
  824. this.nocache_ = 1;
  825. // signed max int
  826. this.maxheight_ = 0x7FFFFFFF;
  827. };
  828. gadgets.Container.inherits(gadgets.Extensible);
  829. /**
  830. * Known dependencies:
  831. * gadgetClass: constructor to create a new gadget instance
  832. * userPrefStore: instance of a subclass of gadgets.UserPrefStore
  833. * gadgetService: instance of a subclass of gadgets.GadgetService
  834. * layoutManager: instance of a subclass of gadgets.LayoutManager
  835. */
  836. gadgets.Container.prototype.gadgetClass = gadgets.Gadget;
  837. gadgets.Container.prototype.userPrefStore = new gadgets.DefaultUserPrefStore();
  838. gadgets.Container.prototype.gadgetService = new gadgets.GadgetService();
  839. gadgets.Container.prototype.layoutManager =
  840. new gadgets.StaticLayoutManager();
  841. gadgets.Container.prototype.setParentUrl = function(url) {
  842. this.parentUrl_ = url;
  843. };
  844. gadgets.Container.prototype.setCountry = function(country) {
  845. this.country_ = country;
  846. };
  847. gadgets.Container.prototype.setNoCache = function(nocache) {
  848. this.nocache_ = nocache;
  849. };
  850. gadgets.Container.prototype.setLanguage = function(language) {
  851. this.language_ = language;
  852. };
  853. gadgets.Container.prototype.setView = function(view) {
  854. this.view_ = view;
  855. };
  856. gadgets.Container.prototype.setMaxHeight = function(maxheight) {
  857. this.maxheight_ = maxheight;
  858. };
  859. gadgets.Container.prototype.getGadgetKey_ = function(instanceId) {
  860. return 'gadget_' + instanceId;
  861. };
  862. gadgets.Container.prototype.getGadget = function(instanceId) {
  863. return this.gadgets_[this.getGadgetKey_(instanceId)];
  864. };
  865. gadgets.Container.prototype.createGadget = function(opt_params) {
  866. return new this.gadgetClass(opt_params);
  867. };
  868. gadgets.Container.prototype.addGadget = function(gadget) {
  869. gadget.id = this.getNextGadgetInstanceId();
  870. gadget.setUserPrefs(this.userPrefStore.getPrefs(gadget));
  871. this.gadgets_[this.getGadgetKey_(gadget.id)] = gadget;
  872. };
  873. gadgets.Container.prototype.addGadgets = function(gadgets) {
  874. for (var i = 0; i < gadgets.length; i++) {
  875. this.addGadget(gadgets[i]);
  876. }
  877. };
  878. /**
  879. * Renders all gadgets in the container.
  880. */
  881. gadgets.Container.prototype.renderGadgets = function() {
  882. for (var key in this.gadgets_) {
  883. this.renderGadget(this.gadgets_[key]);
  884. }
  885. };
  886. /**
  887. * Renders a gadget. Gadgets are rendered inside their chrome element.
  888. * @param {Object} gadget Gadget object
  889. */
  890. gadgets.Container.prototype.renderGadget = function(gadget) {
  891. throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY);
  892. };
  893. gadgets.Container.prototype.nextGadgetInstanceId_ = 0;
  894. gadgets.Container.prototype.getNextGadgetInstanceId = function() {
  895. return this.nextGadgetInstanceId_++;
  896. };
  897. /**
  898. * Refresh all the gadgets in the container.
  899. */
  900. gadgets.Container.prototype.refreshGadgets = function() {
  901. for (var key in this.gadgets_) {
  902. this.gadgets_[key].refresh();
  903. }
  904. };
  905. // ------------
  906. // IfrContainer
  907. /**
  908. * Container that renders gadget using ifr.
  909. * @constructor
  910. */
  911. gadgets.IfrContainer = function() {
  912. gadgets.Container.call(this);
  913. };
  914. gadgets.IfrContainer.inherits(gadgets.Container);
  915. gadgets.IfrContainer.prototype.gadgetClass = gadgets.IfrGadget;
  916. gadgets.IfrContainer.prototype.gadgetService = new gadgets.IfrGadgetService();
  917. gadgets.IfrContainer.prototype.setParentUrl = function(url) {
  918. if (!url.match(/^http[s]?:\/\//)) {
  919. url = document.location.href.match(/^[^?#]+\//)[0] + url;
  920. }
  921. this.parentUrl_ = url;
  922. };
  923. /**
  924. * Renders a gadget using ifr.
  925. * @param {Object} gadget Gadget object
  926. */
  927. gadgets.IfrContainer.prototype.renderGadget = function(gadget) {
  928. var chrome = this.layoutManager.getGadgetChrome(gadget);
  929. gadget.render(chrome);
  930. };
  931. /**
  932. * Default container.
  933. */
  934. gadgets.container = new gadgets.IfrContainer();
  935. /**
  936. * Licensed to the Apache Software Foundation (ASF) under one
  937. * or more contributor license agreements. See the NOTICE file
  938. * distributed with this work for additional information
  939. * regarding copyright ownership. The ASF licenses this file
  940. * to you under the Apache License, Version 2.0 (the
  941. * "License"); you may not use this file except in compliance
  942. * with the License. You may obtain a copy of the License at
  943. *
  944. * http://www.apache.org/licenses/LICENSE-2.0
  945. *
  946. * Unless required by applicable law or agreed to in writing,
  947. * software distributed under the License is distributed on an
  948. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  949. * KIND, either express or implied. See the License for the
  950. * specific language governing permissions and limitations under the License.
  951. */
  952. /**
  953. * @fileoverview Implements the gadgets.UserPrefStore interface using a cookies
  954. * based implementation. Depends on cookies.js. This code should not be used in
  955. * a production environment.
  956. */
  957. /**
  958. * Cookie-based user preference store.
  959. * @constructor
  960. */
  961. gadgets.CookieBasedUserPrefStore = function() {
  962. gadgets.UserPrefStore.call(this);
  963. };
  964. gadgets.CookieBasedUserPrefStore.inherits(gadgets.UserPrefStore);
  965. gadgets.CookieBasedUserPrefStore.prototype.USER_PREFS_PREFIX =
  966. 'gadgetUserPrefs-';
  967. gadgets.CookieBasedUserPrefStore.prototype.getPrefs = function(gadget) {
  968. var userPrefs = {};
  969. var cookieName = this.USER_PREFS_PREFIX + gadget.id;
  970. var cookie = shindig.cookies.get(cookieName);
  971. if (cookie) {
  972. var pairs = cookie.split('&');
  973. for (var i = 0; i < pairs.length; i++) {
  974. var nameValue = pairs[i].split('=');
  975. var name = decodeURIComponent(nameValue[0]);
  976. var value = decodeURIComponent(nameValue[1]);
  977. userPrefs[name] = value;
  978. }
  979. }
  980. return userPrefs;
  981. };
  982. gadgets.CookieBasedUserPrefStore.prototype.savePrefs = function(gadget) {
  983. var pairs = [];
  984. for (var name in gadget.getUserPrefs()) {
  985. var value = gadget.getUserPref(name);
  986. var pair = encodeURIComponent(name) + '=' + encodeURIComponent(value);
  987. pairs.push(pair);
  988. }
  989. var cookieName = this.USER_PREFS_PREFIX + gadget.id;
  990. var cookieValue = pairs.join('&');
  991. shindig.cookies.set(cookieName, cookieValue);
  992. };
  993. gadgets.Container.prototype.userPrefStore =
  994. new gadgets.CookieBasedUserPrefStore();
  995. /*
  996. Copyright (c) 2009, Yahoo! Inc. All rights reserved.
  997. Code licensed under the BSD License:
  998. http://developer.yahoo.net/yui/license.txt
  999. version: 2.7.0
  1000. */
  1001. if(typeof YAHOO=="undefined"||!YAHOO){var YAHOO={};}YAHOO.namespace=function(){var A=arguments,E=null,C,B,D;for(C=0;C<A.length;C=C+1){D=(""+A[C]).split(".");E=YAHOO;for(B=(D[0]=="YAHOO")?1:0;B<D.length;B=B+1){E[D[B]]=E[D[B]]||{};E=E[D[B]];}}return E;};YAHOO.log=function(D,A,C){var B=YAHOO.widget.Logger;if(B&&B.log){return B.log(D,A,C);}else{return false;}};YAHOO.register=function(A,E,D){var I=YAHOO.env.modules,B,H,G,F,C;if(!I[A]){I[A]={versions:[],builds:[]};}B=I[A];H=D.version;G=D.build;F=YAHOO.env.listeners;B.name=A;B.version=H;B.build=G;B.versions.push(H);B.builds.push(G);B.mainClass=E;for(C=0;C<F.length;C=C+1){F[C](B);}if(E){E.VERSION=H;E.BUILD=G;}else{YAHOO.log("mainClass is undefined for module "+A,"warn");}};YAHOO.env=YAHOO.env||{modules:[],listeners:[]};YAHOO.env.getVersion=function(A){return YAHOO.env.modules[A]||null;};YAHOO.env.ua=function(){var C={ie:0,opera:0,gecko:0,webkit:0,mobile:null,air:0,caja:0},B=navigator.userAgent,A;if((/KHTML/).test(B)){C.webkit=1;}A=B.match(/AppleWebKit\/([^\s]*)/);if(A&&A[1]){C.webkit=parseFloat(A[1]);if(/ Mobile\//.test(B)){C.mobile="Apple";}else{A=B.match(/NokiaN[^\/]*/);if(A){C.mobile=A[0];}}A=B.match(/AdobeAIR\/([^\s]*)/);if(A){C.air=A[0];}}if(!C.webkit){A=B.match(/Opera[\s\/]([^\s]*)/);if(A&&A[1]){C.opera=parseFloat(A[1]);A=B.match(/Opera Mini[^;]*/);if(A){C.mobile=A[0];}}else{A=B.match(/MSIE\s([^;]*)/);if(A&&A[1]){C.ie=parseFloat(A[1]);}else{A=B.match(/Gecko\/([^\s]*)/);if(A){C.gecko=1;A=B.match(/rv:([^\s\)]*)/);if(A&&A[1]){C.gecko=parseFloat(A[1]);}}}}}A=B.match(/Caja\/([^\s]*)/);if(A&&A[1]){C.caja=parseFloat(A[1]);}return C;}();(function(){YAHOO.namespace("util","widget","example");if("undefined"!==typeof YAHOO_config){var B=YAHOO_config.listener,A=YAHOO.env.listeners,D=true,C;if(B){for(C=0;C<A.length;C=C+1){if(A[C]==B){D=false;break;}}if(D){A.push(B);}}}})();YAHOO.lang=YAHOO.lang||{};(function(){var B=YAHOO.lang,F="[object Array]",C="[object Function]",A=Object.prototype,E=["toString","valueOf"],D={isArray:function(G){return A.toString.apply(G)===F;},isBoolean:function(G){return typeof G==="boolean";},isFunction:function(G){return A.toString.apply(G)===C;},isNull:function(G){return G===null;},isNumber:function(G){return typeof G==="number"&&isFinite(G);},isObject:function(G){return(G&&(typeof G==="object"||B.isFunction(G)))||false;},isString:function(G){return typeof G==="string";},isUndefined:function(G){return typeof G==="undefined";},_IEEnumFix:(YAHOO.env.ua.ie)?function(I,H){var G,K,J;for(G=0;G<E.length;G=G+1){K=E[G];J=H[K];if(B.isFunction(J)&&J!=A[K]){I[K]=J;}}}:function(){},extend:function(J,K,I){if(!K||!J){throw new Error("extend failed, please check that "+"all dependencies are included.");}var H=function(){},G;H.prototype=K.prototype;J.prototype=new H();J.prototype.constructor=J;J.superclass=K.prototype;if(K.prototype.constructor==A.constructor){K.prototype.constructor=K;}if(I){for(G in I){if(B.hasOwnProperty(I,G)){J.prototype[G]=I[G];}}B._IEEnumFix(J.prototype,I);}},augmentObject:function(K,J){if(!J||!K){throw new Error("Absorb failed, verify dependencies.");}var G=arguments,I,L,H=G[2];if(H&&H!==true){for(I=2;I<G.length;I=I+1){K[G[I]]=J[G[I]];}}else{for(L in J){if(H||!(L in K)){K[L]=J[L];}}B._IEEnumFix(K,J);}},augmentProto:function(J,I){if(!I||!J){throw new Error("Augment failed, verify dependencies.");}var G=[J.prototype,I.prototype],H;for(H=2;H<arguments.length;H=H+1){G.push(arguments[H]);}B.augmentObject.apply(this,G);},dump:function(G,L){var I,K,N=[],O="{...}",H="f(){...}",M=", ",J=" => ";if(!B.isObject(G)){return G+"";}else{if(G instanceof Date||("nodeType" in G&&"tagName" in G)){return G;}else{if(B.isFunction(G)){return H;}}}L=(B.isNumber(L))?L:3;if(B.isArray(G)){N.push("[");for(I=0,K=G.length;I<K;I=I+1){if(B.isObject(G[I])){N.push((L>0)?B.dump(G[I],L-1):O);}else{N.push(G[I]);}N.push(M);}if(N.length>1){N.pop();}N.push("]");}else{N.push("{");for(I in G){if(B.hasOwnProperty(G,I)){N.push(I+J);if(B.isObject(G[I])){N.push((L>0)?B.dump(G[I],L-1):O);}else{N.push(G[I]);}N.push(M);}}if(N.length>1){N.pop();}N.push("}");}return N.join("");},substitute:function(V,H,O){var L,K,J,R,S,U,Q=[],I,M="dump",P=" ",G="{",T="}",N;for(;;){L=V.lastIndexOf(G);if(L<0){break;}K=V.indexOf(T,L);if(L+1>=K){break;}I=V.substring(L+1,K);R=I;U=null;J=R.indexOf(P);if(J>-1){U=R.substring(J+1);R=R.substring(0,J);}S=H[R];if(O){S=O(R,S,U);}if(B.isObject(S)){if(B.isArray(S)){S=B.dump(S,parseInt(U,10));}else{U=U||"";N=U.indexOf(M);if(N>-1){U=U.substring(4);}if(S.toString===A.toString||N>-1){S=B.dump(S,parseInt(U,10));}else{S=S.toString();}}}else{if(!B.isString(S)&&!B.isNumber(S)){S="~-"+Q.length+"-~";Q[Q.length]=I;}}V=V.substring(0,L)+S+V.substring(K+1);}for(L=Q.length-1;L>=0;L=L-1){V=V.replace(new RegExp("~-"+L+"-~"),"{"+Q[L]+"}","g");}return V;},trim:function(G){try{return G.replace(/^\s+|\s+$/g,"");}catch(H){return G;}},merge:function(){var J={},H=arguments,G=H.length,I;for(I=0;I<G;I=I+1){B.augmentObject(J,H[I],true);}return J;},later:function(N,H,O,J,K){N=N||0;H=H||{};var I=O,M=J,L,G;if(B.isString(O)){I=H[O];}if(!I){throw new TypeError("method undefined");}if(!B.isArray(M)){M=[J];}L=function(){I.apply(H,M);};G=(K)?setInterval(L,N):setTimeout(L,N);return{interval:K,cancel:function(){if(this.interval){clearInterval(G);}else{clearTimeout(G);}}};},isValue:function(G){return(B.isObject(G)||B.isString(G)||B.isNumber(G)||B.isBoolean(G));}};B.hasOwnProperty=(A.hasOwnProperty)?function(G,H){return G&&G.hasOwnProperty(H);}:function(G,H){return !B.isUndefined(G[H])&&G.constructor.prototype[H]!==G[H];};D.augmentObject(B,D,true);YAHOO.util.Lang=B;B.augment=B.augmentProto;YAHOO.augment=B.augmentProto;YAHOO.extend=B.extend;})();YAHOO.register("yahoo",YAHOO,{version:"2.7.0",build:"1796"});(function(){YAHOO.env._id_counter=YAHOO.env._id_counter||0;var E=YAHOO.util,L=YAHOO.lang,m=YAHOO.env.ua,A=YAHOO.lang.trim,d={},h={},N=/^t(?:able|d|h)$/i,X=/color$/i,K=window.document,W=K.documentElement,e="ownerDocument",n="defaultView",v="documentElement",t="compatMode",b="offsetLeft",P="offsetTop",u="offsetParent",Z="parentNode",l="nodeType",C="tagName",O="scrollLeft",i="scrollTop",Q="getBoundingClientRect",w="getComputedStyle",a="currentStyle",M="CSS1Compat",c="BackCompat",g="class",F="className",J="",B=" ",s="(?:^|\\s)",k="(?= |$)",U="g",p="position",f="fixed",V="relative",j="left",o="top",r="medium",q="borderLeftWidth",R="borderTopWidth",D=m.opera,I=m.webkit,H=m.gecko,T=m.ie;E.Dom={CUSTOM_ATTRIBUTES:(!W.hasAttribute)?{"for":"htmlFor","class":F}:{"htmlFor":"for","className":g},get:function(y){var AA,Y,z,x,G;if(y){if(y[l]||y.item){return y;}if(typeof y==="string"){AA=y;y=K.getElementById(y);if(y&&y.id===AA){return y;}else{if(y&&K.all){y=null;Y=K.all[AA];for(x=0,G=Y.length;x<G;++x){if(Y[x].id===AA){return Y[x];}}}}return y;}if(y.DOM_EVENTS){y=y.get("element");}if("length" in y){z=[];for(x=0,G=y.length;x<G;++x){z[z.length]=E.Dom.get(y[x]);}return z;}return y;}return null;},getComputedStyle:function(G,Y){if(window[w]){return G[e][n][w](G,null)[Y];}else{if(G[a]){return E.Dom.IE_ComputedStyle.get(G,Y);}}},getStyle:function(G,Y){return E.Dom.batch(G,E.Dom._getStyle,Y);},_getStyle:function(){if(window[w]){return function(G,y){y=(y==="float")?y="cssFloat":E.Dom._toCamel(y);var x=G.style[y],Y;if(!x){Y=G[e][n][w](G,null);if(Y){x=Y[y];}}return x;};}else{if(W[a]){return function(G,y){var x;switch(y){case"opacity":x=100;try{x=G.filters["DXImageTransform.Microsoft.Alpha"].opacity;}catch(z){try{x=G.filters("alpha").opacity;}catch(Y){}}return x/100;case"float":y="styleFloat";default:y=E.Dom._toCamel(y);x=G[a]?G[a][y]:null;return(G.style[y]||x);}};}}}(),setStyle:function(G,Y,x){E.Dom.batch(G,E.Dom._setStyle,{prop:Y,val:x});},_setStyle:function(){if(T){return function(Y,G){var x=E.Dom._toCamel(G.prop),y=G.val;if(Y){switch(x){case"opacity":if(L.isString(Y.style.filter)){Y.style.filter="alpha(opacity="+y*100+")";if(!Y[a]||!Y[a].hasLayout){Y.style.zoom=1;}}break;case"float":x="styleFloat";default:Y.style[x]=y;}}else{}};}else{return function(Y,G){var x=E.Dom._toCamel(G.prop),y=G.val;if(Y){if(x=="float"){x="cssFloat";}Y.style[x]=y;}else{}};}}(),getXY:function(G){return E.Dom.batch(G,E.Dom._getXY);},_canPosition:function(G){return(E.Dom._getStyle(G,"display")!=="none"&&E.Dom._inDoc(G));},_getXY:function(){if(K[v][Q]){return function(y){var z,Y,AA,AF,AE,AD,AC,G,x,AB=Math.floor,AG=false;if(E.Dom._canPosition(y)){AA=y[Q]();AF=y[e];z=E.Dom.getDocumentScrollLeft(AF);Y=E.Dom.getDocumentScrollTop(AF);AG=[AB(AA[j]),AB(AA[o])];if(T&&m.ie<8){AE=2;AD=2;AC=AF[t];G=S(AF[v],q);x=S(AF[v],R);if(m.ie===6){if(AC!==c){AE=0;AD=0;}}if((AC==c)){if(G!==r){AE=parseInt(G,10);}if(x!==r){AD=parseInt(x,10);}}AG[0]-=AE;AG[1]-=AD;}if((Y||z)){AG[0]+=z;AG[1]+=Y;}AG[0]=AB(AG[0]);AG[1]=AB(AG[1]);}else{}return AG;};}else{return function(y){var x,Y,AA,AB,AC,z=false,G=y;if(E.Dom._canPosition(y)){z=[y[b],y[P]];x=E.Dom.getDocumentScrollLeft(y[e]);Y=E.Dom.getDocumentScrollTop(y[e]);AC=((H||m.webkit>519)?true:false);while((G=G[u])){z[0]+=G[b];z[1]+=G[P];if(AC){z=E.Dom._calcBorders(G,z);}}if(E.Dom._getStyle(y,p)!==f){G=y;while((G=G[Z])&&G[C]){AA=G[i];AB=G[O];if(H&&(E.Dom._getStyle(G,"overflow")!=="visible")){z=E.Dom._calcBorders(G,z);}if(AA||AB){z[0]-=AB;z[1]-=AA;}}z[0]+=x;z[1]+=Y;}else{if(D){z[0]-=x;z[1]-=Y;}else{if(I||H){z[0]+=x;z[1]+=Y;}}}z[0]=Math.floor(z[0]);z[1]=Math.floor(z[1]);}else{}return z;};}}(),getX:function(G){var Y=function(x){return E.Dom.getXY(x)[0];};return E.Dom.batch(G,Y,E.Dom,true);},getY:function(G){var Y=function(x){return E.Dom.getXY(x)[1];};return E.Dom.batch(G,Y,E.Dom,true);},setXY:function(G,x,Y){E.Dom.batch(G,E.Dom._setXY,{pos:x,noRetry:Y});},_setXY:function(G,z){var AA=E.Dom._getStyle(G,p),y=E.Dom.setStyle,AD=z.pos,Y=z.noRetry,AB=[parseInt(E.Dom.getComputedStyle(G,j),10),parseInt(E.Dom.getComputedStyle(G,o),10)],AC,x;if(AA=="static"){AA=V;y(G,p,AA);}AC=E.Dom._getXY(G);if(!AD||AC===false){return false;}if(isNaN(AB[0])){AB[0]=(AA==V)?0:G[b];}if(isNaN(AB[1])){AB[1]=(AA==V)?0:G[P];}if(AD[0]!==null){y(G,j,AD[0]-AC[0]+AB[0]+"px");}if(AD[1]!==null){y(G,o,AD[1]-AC[1]+AB[1]+"px");}if(!Y){x=E.Dom._getXY(G);if((AD[0]!==null&&x[0]!=AD[0])||(AD[1]!==null&&x[1]!=AD[1])){E.Dom._setXY(G,{pos:AD,noRetry:true});}}},setX:function(Y,G){E.Dom.setXY(Y,[G,null]);},setY:function(G,Y){E.Dom.setXY(G,[null,Y]);},getRegion:function(G){var Y=function(x){var y=false;if(E.Dom._canPosition(x)){y=E.Region.getRegion(x);}else{}return y;};return E.Dom.batch(G,Y,E.Dom,true);},getClientWidth:function(){return E.Dom.getViewportWidth();},getClientHeight:function(){return E.Dom.getViewportHeight();},getElementsByClassName:function(AB,AF,AC,AE,x,AD){AB=L.trim(AB);AF=AF||"*";AC=(AC)?E.Dom.get(AC):null||K;if(!AC){return[];}var Y=[],G=AC.getElementsByTagName(AF),z=E.Dom.hasClass;for(var y=0,AA=G.length;y<AA;++y){if(z(G[y],AB)){Y[Y.length]=G[y];}}if(AE){E.Dom.batch(Y,AE,x,AD);}return Y;},hasClass:function(Y,G){return E.Dom.batch(Y,E.Dom._hasClass,G);},_hasClass:function(x,Y){var G=false,y;if(x&&Y){y=E.Dom.getAttribute(x,F)||J;if(Y.exec){G=Y.test(y);}else{G=Y&&(B+y+B).indexOf(B+Y+B)>-1;}}else{}return G;},addClass:function(Y,G){return E.Dom.batch(Y,E.Dom._addClass,G);},_addClass:function(x,Y){var G=false,y;if(x&&Y){y=E.Dom.getAttribute(x,F)||J;if(!E.Dom._hasClass(x,Y)){E.Dom.setAttribute(x,F,A(y+B+Y));G=true;}}else{}return G;},removeClass:function(Y,G){return E.Dom.batch(Y,E.Dom._removeClass,G);},_removeClass:function(y,x){var Y=false,AA,z,G;if(y&&x){AA=E.Dom.getAttribute(y,F)||J;E.Dom.setAttribute(y,F,AA.replace(E.Dom._getClassRegex(x),J));z=E.Dom.getAttribute(y,F);if(AA!==z){E.Dom.setAttribute(y,F,A(z));Y=true;if(E.Dom.getAttribute(y,F)===""){G=(y.hasAttribute&&y.hasAttribute(g))?g:F;y.removeAttribute(G);}}}else{}return Y;},replaceClass:function(x,Y,G){return E.Dom.batch(x,E.Dom._replaceClass,{from:Y,to:G});
  1002. },_replaceClass:function(y,x){var Y,AB,AA,G=false,z;if(y&&x){AB=x.from;AA=x.to;if(!AA){G=false;}else{if(!AB){G=E.Dom._addClass(y,x.to);}else{if(AB!==AA){z=E.Dom.getAttribute(y,F)||J;Y=(B+z.replace(E.Dom._getClassRegex(AB),B+AA)).split(E.Dom._getClassRegex(AA));Y.splice(1,0,B+AA);E.Dom.setAttribute(y,F,A(Y.join(J)));G=true;}}}}else{}return G;},generateId:function(G,x){x=x||"yui-gen";var Y=function(y){if(y&&y.id){return y.id;}var z=x+YAHOO.env._id_counter++;if(y){if(y[e].getElementById(z)){return E.Dom.generateId(y,z+x);}y.id=z;}return z;};return E.Dom.batch(G,Y,E.Dom,true)||Y.apply(E.Dom,arguments);},isAncestor:function(Y,x){Y=E.Dom.get(Y);x=E.Dom.get(x);var G=false;if((Y&&x)&&(Y[l]&&x[l])){if(Y.contains&&Y!==x){G=Y.contains(x);}else{if(Y.compareDocumentPosition){G=!!(Y.compareDocumentPosition(x)&16);}}}else{}return G;},inDocument:function(G,Y){return E.Dom._inDoc(E.Dom.get(G),Y);},_inDoc:function(Y,x){var G=false;if(Y&&Y[C]){x=x||Y[e];G=E.Dom.isAncestor(x[v],Y);}else{}return G;},getElementsBy:function(Y,AF,AB,AD,y,AC,AE){AF=AF||"*";AB=(AB)?E.Dom.get(AB):null||K;if(!AB){return[];}var x=[],G=AB.getElementsByTagName(AF);for(var z=0,AA=G.length;z<AA;++z){if(Y(G[z])){if(AE){x=G[z];break;}else{x[x.length]=G[z];}}}if(AD){E.Dom.batch(x,AD,y,AC);}return x;},getElementBy:function(x,G,Y){return E.Dom.getElementsBy(x,G,Y,null,null,null,true);},batch:function(x,AB,AA,z){var y=[],Y=(z)?AA:window;x=(x&&(x[C]||x.item))?x:E.Dom.get(x);if(x&&AB){if(x[C]||x.length===undefined){return AB.call(Y,x,AA);}for(var G=0;G<x.length;++G){y[y.length]=AB.call(Y,x[G],AA);}}else{return false;}return y;},getDocumentHeight:function(){var Y=(K[t]!=M||I)?K.body.scrollHeight:W.scrollHeight,G=Math.max(Y,E.Dom.getViewportHeight());return G;},getDocumentWidth:function

Large files files are truncated, but you can click here to view the full file