PageRenderTime 57ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

/default/js/dist/mura.js

http://github.com/blueriver/MuraCMS
JavaScript | 9409 lines | 7137 code | 1017 blank | 1255 comment | 1738 complexity | a44c762b60a9a3c40dca090502bf5d3f MD5 | raw file
Possible License(s): GPL-3.0, ISC, GPL-2.0, MPL-2.0-no-copyleft-exception, MIT, BSD-3-Clause, CPL-1.0, Apache-2.0, 0BSD, LGPL-2.1
  1. if (!Object.create) {
  2. Object.create = function(proto, props) {
  3. if (typeof props !== "undefined") {
  4. throw "The multiple-argument version of Object.create is not provided by this browser and cannot be shimmed.";
  5. }
  6. function ctor() { }
  7. ctor.prototype = proto;
  8. return new ctor();
  9. };
  10. }
  11. if (!Array.isArray) {
  12. Array.isArray = function(arg) {
  13. return Object.prototype.toString.call(arg) === '[object Array]';
  14. };
  15. }
  16. // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
  17. if (!Object.keys) {
  18. Object.keys = (function() {
  19. 'use strict';
  20. var hasOwnProperty = Object.prototype.hasOwnProperty,
  21. hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),
  22. dontEnums = [
  23. 'toString',
  24. 'toLocaleString',
  25. 'valueOf',
  26. 'hasOwnProperty',
  27. 'isPrototypeOf',
  28. 'propertyIsEnumerable',
  29. 'constructor'
  30. ],
  31. dontEnumsLength = dontEnums.length;
  32. return function(obj) {
  33. if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
  34. throw new TypeError('Object.keys called on non-object');
  35. }
  36. var result = [], prop, i;
  37. for (prop in obj) {
  38. if (hasOwnProperty.call(obj, prop)) {
  39. result.push(prop);
  40. }
  41. }
  42. if (hasDontEnumBug) {
  43. for (i = 0; i < dontEnumsLength; i++) {
  44. if (hasOwnProperty.call(obj, dontEnums[i])) {
  45. result.push(dontEnums[i]);
  46. }
  47. }
  48. }
  49. return result;
  50. };
  51. }());
  52. }
  53. !window.addEventListener && (function (WindowPrototype, DocumentPrototype, ElementPrototype, addEventListener, removeEventListener, dispatchEvent, registry) {
  54. WindowPrototype[addEventListener] = DocumentPrototype[addEventListener] = ElementPrototype[addEventListener] = function (type, listener) {
  55. var target = this;
  56. registry.unshift([target, type, listener, function (event) {
  57. event.currentTarget = target;
  58. event.preventDefault = function () { event.returnValue = false };
  59. event.stopPropagation = function () { event.cancelBubble = true };
  60. event.target = event.srcElement || target;
  61. listener.call(target, event);
  62. }]);
  63. this.attachEvent("on" + type, registry[0][3]);
  64. };
  65. WindowPrototype[removeEventListener] = DocumentPrototype[removeEventListener] = ElementPrototype[removeEventListener] = function (type, listener) {
  66. for (var index = 0, register; register = registry[index]; ++index) {
  67. if (register[0] == this && register[1] == type && register[2] == listener) {
  68. return this.detachEvent("on" + type, registry.splice(index, 1)[0][3]);
  69. }
  70. }
  71. };
  72. WindowPrototype[dispatchEvent] = DocumentPrototype[dispatchEvent] = ElementPrototype[dispatchEvent] = function (eventObject) {
  73. return this.fireEvent("on" + eventObject.type, eventObject);
  74. };
  75. })(Window.prototype, HTMLDocument.prototype, Element.prototype, "addEventListener", "removeEventListener", "dispatchEvent", []);
  76. if (!Array.prototype.forEach) {
  77. Array.prototype.forEach = function(callback, thisArg) {
  78. var T, k;
  79. if (this == null) {
  80. throw new TypeError(' this is null or not defined');
  81. }
  82. // 1. Let O be the result of calling toObject() passing the
  83. // |this| value as the argument.
  84. var O = Object(this);
  85. // 2. Let lenValue be the result of calling the Get() internal
  86. // method of O with the argument "length".
  87. // 3. Let len be toUint32(lenValue).
  88. var len = O.length >>> 0;
  89. // 4. If isCallable(callback) is false, throw a TypeErrorexception.
  90. // See: http://es5.github.com/#x9.11
  91. if (typeof callback !== "function") {
  92. throw new TypeError(callback + ' is not a function');
  93. }
  94. // 5. If thisArg was supplied, let T be thisArg; else let
  95. // T be undefined.
  96. if (arguments.length > 1) {
  97. T = thisArg;
  98. }
  99. // 6. Let k be 0
  100. k = 0;
  101. // 7. Repeat, while k < len
  102. while (k < len) {
  103. var kValue;
  104. // a. Let Pk be ToString(k).
  105. // This is implicit for LHS operands of the in operator
  106. // b. Let kPresent be the result of calling the HasProperty
  107. // internal method of O with argument Pk.
  108. // This step can be combined with c
  109. // c. If kPresent is true, then
  110. if (k in O) {
  111. // i. Let kValue be the result of calling the Get internal
  112. // method of O with argument Pk.
  113. kValue = O[k];
  114. // ii. Call the Call internal method of callback with T as
  115. // the this value and argument list containing kValue, k, and O.
  116. callback.call(T, kValue, k, O);
  117. }
  118. // d. Increase k by 1.
  119. k++;
  120. }
  121. // 8. return undefined
  122. };
  123. }
  124. if (!Array.prototype.filter) {
  125. Array.prototype.filter = function(fun/*, thisArg*/) {
  126. 'use strict';
  127. if (this === void 0 || this === null) {
  128. throw new TypeError();
  129. }
  130. var t = Object(this);
  131. var len = t.length >>> 0;
  132. if (typeof fun !== 'function') {
  133. throw new TypeError();
  134. }
  135. var res = [];
  136. var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
  137. for (var i = 0; i < len; i++) {
  138. if (i in t) {
  139. var val = t[i];
  140. // NOTE: Technically this should Object.defineProperty at
  141. // the next index, as push can be affected by
  142. // properties on Object.prototype and Array.prototype.
  143. // But that method's new, and collisions should be
  144. // rare, so use the more-compatible alternative.
  145. if (fun.call(thisArg, val, i, t)) {
  146. res.push(val);
  147. }
  148. }
  149. }
  150. return res;
  151. };
  152. }
  153. // Production steps of ECMA-262, Edition 5, 15.4.4.19
  154. // Reference: http://es5.github.io/#x15.4.4.19
  155. if (!Array.prototype.map) {
  156. Array.prototype.map = function(callback, thisArg) {
  157. var T, A, k;
  158. if (this == null) {
  159. throw new TypeError(' this is null or not defined');
  160. }
  161. // 1. Let O be the result of calling ToObject passing the |this|
  162. // value as the argument.
  163. var O = Object(this);
  164. // 2. Let lenValue be the result of calling the Get internal
  165. // method of O with the argument "length".
  166. // 3. Let len be ToUint32(lenValue).
  167. var len = O.length >>> 0;
  168. // 4. If IsCallable(callback) is false, throw a TypeError exception.
  169. // See: http://es5.github.com/#x9.11
  170. if (typeof callback !== 'function') {
  171. throw new TypeError(callback + ' is not a function');
  172. }
  173. // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
  174. if (arguments.length > 1) {
  175. T = thisArg;
  176. }
  177. // 6. Let A be a new array created as if by the expression new Array(len)
  178. // where Array is the standard built-in constructor with that name and
  179. // len is the value of len.
  180. A = new Array(len);
  181. // 7. Let k be 0
  182. k = 0;
  183. // 8. Repeat, while k < len
  184. while (k < len) {
  185. var kValue, mappedValue;
  186. // a. Let Pk be ToString(k).
  187. // This is implicit for LHS operands of the in operator
  188. // b. Let kPresent be the result of calling the HasProperty internal
  189. // method of O with argument Pk.
  190. // This step can be combined with c
  191. // c. If kPresent is true, then
  192. if (k in O) {
  193. // i. Let kValue be the result of calling the Get internal
  194. // method of O with argument Pk.
  195. kValue = O[k];
  196. // ii. Let mappedValue be the result of calling the Call internal
  197. // method of callback with T as the this value and argument
  198. // list containing kValue, k, and O.
  199. mappedValue = callback.call(T, kValue, k, O);
  200. // iii. Call the DefineOwnProperty internal method of A with arguments
  201. // Pk, Property Descriptor
  202. // { Value: mappedValue,
  203. // Writable: true,
  204. // Enumerable: true,
  205. // Configurable: true },
  206. // and false.
  207. // In browsers that support Object.defineProperty, use the following:
  208. // Object.defineProperty(A, k, {
  209. // value: mappedValue,
  210. // writable: true,
  211. // enumerable: true,
  212. // configurable: true
  213. // });
  214. // For best browser support, use the following:
  215. A[k] = mappedValue;
  216. }
  217. // d. Increase k by 1.
  218. k++;
  219. }
  220. // 9. return A
  221. return A;
  222. };
  223. }
  224. /*!
  225. * @overview es6-promise - a tiny implementation of Promises/A+.
  226. * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
  227. * @license Licensed under MIT license
  228. * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
  229. * @version 2.3.0
  230. */
  231. (function() {
  232. "use strict";
  233. function lib$es6$promise$utils$$objectOrFunction(x) {
  234. return typeof x === 'function' || (typeof x === 'object' && x !== null);
  235. }
  236. function lib$es6$promise$utils$$isFunction(x) {
  237. return typeof x === 'function';
  238. }
  239. function lib$es6$promise$utils$$isMaybeThenable(x) {
  240. return typeof x === 'object' && x !== null;
  241. }
  242. var lib$es6$promise$utils$$_isArray;
  243. if (!Array.isArray) {
  244. lib$es6$promise$utils$$_isArray = function (x) {
  245. return Object.prototype.toString.call(x) === '[object Array]';
  246. };
  247. } else {
  248. lib$es6$promise$utils$$_isArray = Array.isArray;
  249. }
  250. var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray;
  251. var lib$es6$promise$asap$$len = 0;
  252. var lib$es6$promise$asap$$toString = {}.toString;
  253. var lib$es6$promise$asap$$vertxNext;
  254. var lib$es6$promise$asap$$customSchedulerFn;
  255. var lib$es6$promise$asap$$asap = function asap(callback, arg) {
  256. lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback;
  257. lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg;
  258. lib$es6$promise$asap$$len += 2;
  259. if (lib$es6$promise$asap$$len === 2) {
  260. // If len is 2, that means that we need to schedule an async flush.
  261. // If additional callbacks are queued before the queue is flushed, they
  262. // will be processed by this flush that we are scheduling.
  263. if (lib$es6$promise$asap$$customSchedulerFn) {
  264. lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush);
  265. } else {
  266. lib$es6$promise$asap$$scheduleFlush();
  267. }
  268. }
  269. }
  270. function lib$es6$promise$asap$$setScheduler(scheduleFn) {
  271. lib$es6$promise$asap$$customSchedulerFn = scheduleFn;
  272. }
  273. function lib$es6$promise$asap$$setAsap(asapFn) {
  274. lib$es6$promise$asap$$asap = asapFn;
  275. }
  276. var lib$es6$promise$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined;
  277. var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {};
  278. var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver;
  279. var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
  280. // test for web worker but not in IE10
  281. var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' &&
  282. typeof importScripts !== 'undefined' &&
  283. typeof MessageChannel !== 'undefined';
  284. // node
  285. function lib$es6$promise$asap$$useNextTick() {
  286. var nextTick = process.nextTick;
  287. // node version 0.10.x displays a deprecation warning when nextTick is used recursively
  288. // setImmediate should be used instead instead
  289. var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);
  290. if (Array.isArray(version) && version[1] === '0' && version[2] === '10') {
  291. nextTick = setImmediate;
  292. }
  293. return function() {
  294. nextTick(lib$es6$promise$asap$$flush);
  295. };
  296. }
  297. // vertx
  298. function lib$es6$promise$asap$$useVertxTimer() {
  299. return function() {
  300. lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush);
  301. };
  302. }
  303. function lib$es6$promise$asap$$useMutationObserver() {
  304. var iterations = 0;
  305. var observer = new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush);
  306. var node = document.createTextNode('');
  307. observer.observe(node, { characterData: true });
  308. return function() {
  309. node.data = (iterations = ++iterations % 2);
  310. };
  311. }
  312. // web worker
  313. function lib$es6$promise$asap$$useMessageChannel() {
  314. var channel = new MessageChannel();
  315. channel.port1.onmessage = lib$es6$promise$asap$$flush;
  316. return function () {
  317. channel.port2.postMessage(0);
  318. };
  319. }
  320. function lib$es6$promise$asap$$useSetTimeout() {
  321. return function() {
  322. setTimeout(lib$es6$promise$asap$$flush, 1);
  323. };
  324. }
  325. var lib$es6$promise$asap$$queue = new Array(1000);
  326. function lib$es6$promise$asap$$flush() {
  327. for (var i = 0; i < lib$es6$promise$asap$$len; i+=2) {
  328. var callback = lib$es6$promise$asap$$queue[i];
  329. var arg = lib$es6$promise$asap$$queue[i+1];
  330. callback(arg);
  331. lib$es6$promise$asap$$queue[i] = undefined;
  332. lib$es6$promise$asap$$queue[i+1] = undefined;
  333. }
  334. lib$es6$promise$asap$$len = 0;
  335. }
  336. function lib$es6$promise$asap$$attemptVertex() {
  337. try {
  338. var r = require;
  339. var vertx = r('vertx');
  340. lib$es6$promise$asap$$vertxNext = vertx.runOnLoop || vertx.runOnContext;
  341. return lib$es6$promise$asap$$useVertxTimer();
  342. } catch(e) {
  343. return lib$es6$promise$asap$$useSetTimeout();
  344. }
  345. }
  346. var lib$es6$promise$asap$$scheduleFlush;
  347. // Decide what async method to use to triggering processing of queued callbacks:
  348. if (lib$es6$promise$asap$$isNode) {
  349. lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick();
  350. } else if (lib$es6$promise$asap$$BrowserMutationObserver) {
  351. lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMutationObserver();
  352. } else if (lib$es6$promise$asap$$isWorker) {
  353. lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel();
  354. } else if (lib$es6$promise$asap$$browserWindow === undefined && typeof require === 'function') {
  355. lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$attemptVertex();
  356. } else {
  357. lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout();
  358. }
  359. function lib$es6$promise$$internal$$noop() {}
  360. var lib$es6$promise$$internal$$PENDING = void 0;
  361. var lib$es6$promise$$internal$$FULFILLED = 1;
  362. var lib$es6$promise$$internal$$REJECTED = 2;
  363. var lib$es6$promise$$internal$$GET_THEN_ERROR = new lib$es6$promise$$internal$$ErrorObject();
  364. function lib$es6$promise$$internal$$selfFullfillment() {
  365. return new TypeError("You cannot resolve a promise with itself");
  366. }
  367. function lib$es6$promise$$internal$$cannotReturnOwn() {
  368. return new TypeError('A promises callback cannot return that same promise.');
  369. }
  370. function lib$es6$promise$$internal$$getThen(promise) {
  371. try {
  372. return promise.then;
  373. } catch(error) {
  374. lib$es6$promise$$internal$$GET_THEN_ERROR.error = error;
  375. return lib$es6$promise$$internal$$GET_THEN_ERROR;
  376. }
  377. }
  378. function lib$es6$promise$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) {
  379. try {
  380. then.call(value, fulfillmentHandler, rejectionHandler);
  381. } catch(e) {
  382. return e;
  383. }
  384. }
  385. function lib$es6$promise$$internal$$handleForeignThenable(promise, thenable, then) {
  386. lib$es6$promise$asap$$asap(function(promise) {
  387. var sealed = false;
  388. var error = lib$es6$promise$$internal$$tryThen(then, thenable, function(value) {
  389. if (sealed) { return; }
  390. sealed = true;
  391. if (thenable !== value) {
  392. lib$es6$promise$$internal$$resolve(promise, value);
  393. } else {
  394. lib$es6$promise$$internal$$fulfill(promise, value);
  395. }
  396. }, function(reason) {
  397. if (sealed) { return; }
  398. sealed = true;
  399. lib$es6$promise$$internal$$reject(promise, reason);
  400. }, 'Settle: ' + (promise._label || ' unknown promise'));
  401. if (!sealed && error) {
  402. sealed = true;
  403. lib$es6$promise$$internal$$reject(promise, error);
  404. }
  405. }, promise);
  406. }
  407. function lib$es6$promise$$internal$$handleOwnThenable(promise, thenable) {
  408. if (thenable._state === lib$es6$promise$$internal$$FULFILLED) {
  409. lib$es6$promise$$internal$$fulfill(promise, thenable._result);
  410. } else if (thenable._state === lib$es6$promise$$internal$$REJECTED) {
  411. lib$es6$promise$$internal$$reject(promise, thenable._result);
  412. } else {
  413. lib$es6$promise$$internal$$subscribe(thenable, undefined, function(value) {
  414. lib$es6$promise$$internal$$resolve(promise, value);
  415. }, function(reason) {
  416. lib$es6$promise$$internal$$reject(promise, reason);
  417. });
  418. }
  419. }
  420. function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable) {
  421. if (maybeThenable.constructor === promise.constructor) {
  422. lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable);
  423. } else {
  424. var then = lib$es6$promise$$internal$$getThen(maybeThenable);
  425. if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) {
  426. lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error);
  427. } else if (then === undefined) {
  428. lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
  429. } else if (lib$es6$promise$utils$$isFunction(then)) {
  430. lib$es6$promise$$internal$$handleForeignThenable(promise, maybeThenable, then);
  431. } else {
  432. lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
  433. }
  434. }
  435. }
  436. function lib$es6$promise$$internal$$resolve(promise, value) {
  437. if (promise === value) {
  438. lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFullfillment());
  439. } else if (lib$es6$promise$utils$$objectOrFunction(value)) {
  440. lib$es6$promise$$internal$$handleMaybeThenable(promise, value);
  441. } else {
  442. lib$es6$promise$$internal$$fulfill(promise, value);
  443. }
  444. }
  445. function lib$es6$promise$$internal$$publishRejection(promise) {
  446. if (promise._onerror) {
  447. promise._onerror(promise._result);
  448. }
  449. lib$es6$promise$$internal$$publish(promise);
  450. }
  451. function lib$es6$promise$$internal$$fulfill(promise, value) {
  452. if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; }
  453. promise._result = value;
  454. promise._state = lib$es6$promise$$internal$$FULFILLED;
  455. if (promise._subscribers.length !== 0) {
  456. lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, promise);
  457. }
  458. }
  459. function lib$es6$promise$$internal$$reject(promise, reason) {
  460. if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; }
  461. promise._state = lib$es6$promise$$internal$$REJECTED;
  462. promise._result = reason;
  463. lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection, promise);
  464. }
  465. function lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection) {
  466. var subscribers = parent._subscribers;
  467. var length = subscribers.length;
  468. parent._onerror = null;
  469. subscribers[length] = child;
  470. subscribers[length + lib$es6$promise$$internal$$FULFILLED] = onFulfillment;
  471. subscribers[length + lib$es6$promise$$internal$$REJECTED] = onRejection;
  472. if (length === 0 && parent._state) {
  473. lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, parent);
  474. }
  475. }
  476. function lib$es6$promise$$internal$$publish(promise) {
  477. var subscribers = promise._subscribers;
  478. var settled = promise._state;
  479. if (subscribers.length === 0) { return; }
  480. var child, callback, detail = promise._result;
  481. for (var i = 0; i < subscribers.length; i += 3) {
  482. child = subscribers[i];
  483. callback = subscribers[i + settled];
  484. if (child) {
  485. lib$es6$promise$$internal$$invokeCallback(settled, child, callback, detail);
  486. } else {
  487. callback(detail);
  488. }
  489. }
  490. promise._subscribers.length = 0;
  491. }
  492. function lib$es6$promise$$internal$$ErrorObject() {
  493. this.error = null;
  494. }
  495. var lib$es6$promise$$internal$$TRY_CATCH_ERROR = new lib$es6$promise$$internal$$ErrorObject();
  496. function lib$es6$promise$$internal$$tryCatch(callback, detail) {
  497. try {
  498. return callback(detail);
  499. } catch(e) {
  500. console.error(e);
  501. lib$es6$promise$$internal$$TRY_CATCH_ERROR.error = e;
  502. return lib$es6$promise$$internal$$TRY_CATCH_ERROR;
  503. }
  504. }
  505. function lib$es6$promise$$internal$$invokeCallback(settled, promise, callback, detail) {
  506. var hasCallback = lib$es6$promise$utils$$isFunction(callback),
  507. value, error, succeeded, failed;
  508. if (hasCallback) {
  509. value = lib$es6$promise$$internal$$tryCatch(callback, detail);
  510. if (value === lib$es6$promise$$internal$$TRY_CATCH_ERROR) {
  511. failed = true;
  512. error = value.error;
  513. value = null;
  514. } else {
  515. succeeded = true;
  516. }
  517. if (promise === value) {
  518. lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$cannotReturnOwn());
  519. return;
  520. }
  521. } else {
  522. value = detail;
  523. succeeded = true;
  524. }
  525. if (promise._state !== lib$es6$promise$$internal$$PENDING) {
  526. // noop
  527. } else if (hasCallback && succeeded) {
  528. lib$es6$promise$$internal$$resolve(promise, value);
  529. } else if (failed) {
  530. lib$es6$promise$$internal$$reject(promise, error);
  531. } else if (settled === lib$es6$promise$$internal$$FULFILLED) {
  532. lib$es6$promise$$internal$$fulfill(promise, value);
  533. } else if (settled === lib$es6$promise$$internal$$REJECTED) {
  534. lib$es6$promise$$internal$$reject(promise, value);
  535. }
  536. }
  537. function lib$es6$promise$$internal$$initializePromise(promise, resolver) {
  538. try {
  539. resolver(function resolvePromise(value){
  540. lib$es6$promise$$internal$$resolve(promise, value);
  541. }, function rejectPromise(reason) {
  542. lib$es6$promise$$internal$$reject(promise, reason);
  543. });
  544. } catch(e) {
  545. lib$es6$promise$$internal$$reject(promise, e);
  546. }
  547. }
  548. function lib$es6$promise$enumerator$$Enumerator(Constructor, input) {
  549. var enumerator = this;
  550. enumerator._instanceConstructor = Constructor;
  551. enumerator.promise = new Constructor(lib$es6$promise$$internal$$noop);
  552. if (enumerator._validateInput(input)) {
  553. enumerator._input = input;
  554. enumerator.length = input.length;
  555. enumerator._remaining = input.length;
  556. enumerator._init();
  557. if (enumerator.length === 0) {
  558. lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
  559. } else {
  560. enumerator.length = enumerator.length || 0;
  561. enumerator._enumerate();
  562. if (enumerator._remaining === 0) {
  563. lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
  564. }
  565. }
  566. } else {
  567. lib$es6$promise$$internal$$reject(enumerator.promise, enumerator._validationError());
  568. }
  569. }
  570. lib$es6$promise$enumerator$$Enumerator.prototype._validateInput = function(input) {
  571. return lib$es6$promise$utils$$isArray(input);
  572. };
  573. lib$es6$promise$enumerator$$Enumerator.prototype._validationError = function() {
  574. return new Error('Array Methods must be provided an Array');
  575. };
  576. lib$es6$promise$enumerator$$Enumerator.prototype._init = function() {
  577. this._result = new Array(this.length);
  578. };
  579. var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator;
  580. lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() {
  581. var enumerator = this;
  582. var length = enumerator.length;
  583. var promise = enumerator.promise;
  584. var input = enumerator._input;
  585. for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
  586. enumerator._eachEntry(input[i], i);
  587. }
  588. };
  589. lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) {
  590. var enumerator = this;
  591. var c = enumerator._instanceConstructor;
  592. if (lib$es6$promise$utils$$isMaybeThenable(entry)) {
  593. if (entry.constructor === c && entry._state !== lib$es6$promise$$internal$$PENDING) {
  594. entry._onerror = null;
  595. enumerator._settledAt(entry._state, i, entry._result);
  596. } else {
  597. enumerator._willSettleAt(c.resolve(entry), i);
  598. }
  599. } else {
  600. enumerator._remaining--;
  601. enumerator._result[i] = entry;
  602. }
  603. };
  604. lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) {
  605. var enumerator = this;
  606. var promise = enumerator.promise;
  607. if (promise._state === lib$es6$promise$$internal$$PENDING) {
  608. enumerator._remaining--;
  609. if (state === lib$es6$promise$$internal$$REJECTED) {
  610. lib$es6$promise$$internal$$reject(promise, value);
  611. } else {
  612. enumerator._result[i] = value;
  613. }
  614. }
  615. if (enumerator._remaining === 0) {
  616. lib$es6$promise$$internal$$fulfill(promise, enumerator._result);
  617. }
  618. };
  619. lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) {
  620. var enumerator = this;
  621. lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) {
  622. enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value);
  623. }, function(reason) {
  624. enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason);
  625. });
  626. };
  627. function lib$es6$promise$promise$all$$all(entries) {
  628. return new lib$es6$promise$enumerator$$default(this, entries).promise;
  629. }
  630. var lib$es6$promise$promise$all$$default = lib$es6$promise$promise$all$$all;
  631. function lib$es6$promise$promise$race$$race(entries) {
  632. /*jshint validthis:true */
  633. var Constructor = this;
  634. var promise = new Constructor(lib$es6$promise$$internal$$noop);
  635. if (!lib$es6$promise$utils$$isArray(entries)) {
  636. lib$es6$promise$$internal$$reject(promise, new TypeError('You must pass an array to race.'));
  637. return promise;
  638. }
  639. var length = entries.length;
  640. function onFulfillment(value) {
  641. lib$es6$promise$$internal$$resolve(promise, value);
  642. }
  643. function onRejection(reason) {
  644. lib$es6$promise$$internal$$reject(promise, reason);
  645. }
  646. for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
  647. lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
  648. }
  649. return promise;
  650. }
  651. var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race;
  652. function lib$es6$promise$promise$resolve$$resolve(object) {
  653. /*jshint validthis:true */
  654. var Constructor = this;
  655. if (object && typeof object === 'object' && object.constructor === Constructor) {
  656. return object;
  657. }
  658. var promise = new Constructor(lib$es6$promise$$internal$$noop);
  659. lib$es6$promise$$internal$$resolve(promise, object);
  660. return promise;
  661. }
  662. var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve;
  663. function lib$es6$promise$promise$reject$$reject(reason) {
  664. /*jshint validthis:true */
  665. var Constructor = this;
  666. var promise = new Constructor(lib$es6$promise$$internal$$noop);
  667. lib$es6$promise$$internal$$reject(promise, reason);
  668. return promise;
  669. }
  670. var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject;
  671. var lib$es6$promise$promise$$counter = 0;
  672. function lib$es6$promise$promise$$needsResolver() {
  673. throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
  674. }
  675. function lib$es6$promise$promise$$needsNew() {
  676. throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
  677. }
  678. var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise;
  679. /**
  680. Promise objects represent the eventual result of an asynchronous operation. The
  681. primary way of interacting with a promise is through its `then` method, which
  682. registers callbacks to receive either a promise's eventual value or the reason
  683. why the promise cannot be fulfilled.
  684. Terminology
  685. -----------
  686. - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
  687. - `thenable` is an object or function that defines a `then` method.
  688. - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
  689. - `exception` is a value that is thrown using the throw statement.
  690. - `reason` is a value that indicates why a promise was rejected.
  691. - `settled` the final resting state of a promise, fulfilled or rejected.
  692. A promise can be in one of three states: pending, fulfilled, or rejected.
  693. Promises that are fulfilled have a fulfillment value and are in the fulfilled
  694. state. Promises that are rejected have a rejection reason and are in the
  695. rejected state. A fulfillment value is never a thenable.
  696. Promises can also be said to *resolve* a value. If this value is also a
  697. promise, then the original promise's settled state will match the value's
  698. settled state. So a promise that *resolves* a promise that rejects will
  699. itself reject, and a promise that *resolves* a promise that fulfills will
  700. itself fulfill.
  701. Basic Usage:
  702. ------------
  703. ```js
  704. var promise = new Promise(function(resolve, reject) {
  705. // on success
  706. resolve(value);
  707. // on failure
  708. reject(reason);
  709. });
  710. promise.then(function(value) {
  711. // on fulfillment
  712. }, function(reason) {
  713. // on rejection
  714. });
  715. ```
  716. Advanced Usage:
  717. ---------------
  718. Promises shine when abstracting away asynchronous interactions such as
  719. `XMLHttpRequest`s.
  720. ```js
  721. function getJSON(url) {
  722. return new Promise(function(resolve, reject){
  723. var xhr = new XMLHttpRequest();
  724. xhr.open('GET', url);
  725. xhr.onreadystatechange = handler;
  726. xhr.responseType = 'json';
  727. xhr.setRequestHeader('Accept', 'application/json');
  728. xhr.send();
  729. function handler() {
  730. if (this.readyState === this.DONE) {
  731. if (this.status === 200) {
  732. resolve(this.response);
  733. } else {
  734. reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
  735. }
  736. }
  737. };
  738. });
  739. }
  740. getJSON('/posts.json').then(function(json) {
  741. // on fulfillment
  742. }, function(reason) {
  743. // on rejection
  744. });
  745. ```
  746. Unlike callbacks, promises are great composable primitives.
  747. ```js
  748. Promise.all([
  749. getJSON('/posts'),
  750. getJSON('/comments')
  751. ]).then(function(values){
  752. values[0] // => postsJSON
  753. values[1] // => commentsJSON
  754. return values;
  755. });
  756. ```
  757. @class Promise
  758. @param {function} resolver
  759. Useful for tooling.
  760. @constructor
  761. */
  762. function lib$es6$promise$promise$$Promise(resolver) {
  763. this._id = lib$es6$promise$promise$$counter++;
  764. this._state = undefined;
  765. this._result = undefined;
  766. this._subscribers = [];
  767. if (lib$es6$promise$$internal$$noop !== resolver) {
  768. if (!lib$es6$promise$utils$$isFunction(resolver)) {
  769. lib$es6$promise$promise$$needsResolver();
  770. }
  771. if (!(this instanceof lib$es6$promise$promise$$Promise)) {
  772. lib$es6$promise$promise$$needsNew();
  773. }
  774. lib$es6$promise$$internal$$initializePromise(this, resolver);
  775. }
  776. }
  777. lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default;
  778. lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default;
  779. lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default;
  780. lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default;
  781. lib$es6$promise$promise$$Promise._setScheduler = lib$es6$promise$asap$$setScheduler;
  782. lib$es6$promise$promise$$Promise._setAsap = lib$es6$promise$asap$$setAsap;
  783. lib$es6$promise$promise$$Promise._asap = lib$es6$promise$asap$$asap;
  784. lib$es6$promise$promise$$Promise.prototype = {
  785. constructor: lib$es6$promise$promise$$Promise,
  786. /**
  787. The primary way of interacting with a promise is through its `then` method,
  788. which registers callbacks to receive either a promise's eventual value or the
  789. reason why the promise cannot be fulfilled.
  790. ```js
  791. findUser().then(function(user){
  792. // user is available
  793. }, function(reason){
  794. // user is unavailable, and you are given the reason why
  795. });
  796. ```
  797. Chaining
  798. --------
  799. The return value of `then` is itself a promise. This second, 'downstream'
  800. promise is resolved with the return value of the first promise's fulfillment
  801. or rejection handler, or rejected if the handler throws an exception.
  802. ```js
  803. findUser().then(function (user) {
  804. return user.name;
  805. }, function (reason) {
  806. return 'default name';
  807. }).then(function (userName) {
  808. // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
  809. // will be `'default name'`
  810. });
  811. findUser().then(function (user) {
  812. throw new Error('Found user, but still unhappy');
  813. }, function (reason) {
  814. throw new Error('`findUser` rejected and we're unhappy');
  815. }).then(function (value) {
  816. // never reached
  817. }, function (reason) {
  818. // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
  819. // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
  820. });
  821. ```
  822. If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
  823. ```js
  824. findUser().then(function (user) {
  825. throw new PedagogicalException('Upstream error');
  826. }).then(function (value) {
  827. // never reached
  828. }).then(function (value) {
  829. // never reached
  830. }, function (reason) {
  831. // The `PedgagocialException` is propagated all the way down to here
  832. });
  833. ```
  834. Assimilation
  835. ------------
  836. Sometimes the value you want to propagate to a downstream promise can only be
  837. retrieved asynchronously. This can be achieved by returning a promise in the
  838. fulfillment or rejection handler. The downstream promise will then be pending
  839. until the returned promise is settled. This is called *assimilation*.
  840. ```js
  841. findUser().then(function (user) {
  842. return findCommentsByAuthor(user);
  843. }).then(function (comments) {
  844. // The user's comments are now available
  845. });
  846. ```
  847. If the assimliated promise rejects, then the downstream promise will also reject.
  848. ```js
  849. findUser().then(function (user) {
  850. return findCommentsByAuthor(user);
  851. }).then(function (comments) {
  852. // If `findCommentsByAuthor` fulfills, we'll have the value here
  853. }, function (reason) {
  854. // If `findCommentsByAuthor` rejects, we'll have the reason here
  855. });
  856. ```
  857. Simple Example
  858. --------------
  859. Synchronous Example
  860. ```javascript
  861. var result;
  862. try {
  863. result = findResult();
  864. // success
  865. } catch(reason) {
  866. // failure
  867. }
  868. ```
  869. Errback Example
  870. ```js
  871. findResult(function(result, err){
  872. if (err) {
  873. // failure
  874. } else {
  875. // success
  876. }
  877. });
  878. ```
  879. Promise Example;
  880. ```javascript
  881. findResult().then(function(result){
  882. // success
  883. }, function(reason){
  884. // failure
  885. });
  886. ```
  887. Advanced Example
  888. --------------
  889. Synchronous Example
  890. ```javascript
  891. var author, books;
  892. try {
  893. author = findAuthor();
  894. books = findBooksByAuthor(author);
  895. // success
  896. } catch(reason) {
  897. // failure
  898. }
  899. ```
  900. Errback Example
  901. ```js
  902. function foundBooks(books) {
  903. }
  904. function failure(reason) {
  905. }
  906. findAuthor(function(author, err){
  907. if (err) {
  908. failure(err);
  909. // failure
  910. } else {
  911. try {
  912. findBoooksByAuthor(author, function(books, err) {
  913. if (err) {
  914. failure(err);
  915. } else {
  916. try {
  917. foundBooks(books);
  918. } catch(reason) {
  919. failure(reason);
  920. }
  921. }
  922. });
  923. } catch(error) {
  924. failure(err);
  925. }
  926. // success
  927. }
  928. });
  929. ```
  930. Promise Example;
  931. ```javascript
  932. findAuthor().
  933. then(findBooksByAuthor).
  934. then(function(books){
  935. // found books
  936. }).catch(function(reason){
  937. // something went wrong
  938. });
  939. ```
  940. @method then
  941. @param {Function} onFulfilled
  942. @param {Function} onRejected
  943. Useful for tooling.
  944. @return {Promise}
  945. */
  946. then: function(onFulfillment, onRejection) {
  947. var parent = this;
  948. var state = parent._state;
  949. if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) {
  950. return this;
  951. }
  952. var child = new this.constructor(lib$es6$promise$$internal$$noop);
  953. var result = parent._result;
  954. if (state) {
  955. var callback = arguments[state - 1];
  956. lib$es6$promise$asap$$asap(function(){
  957. lib$es6$promise$$internal$$invokeCallback(state, child, callback, result);
  958. });
  959. } else {
  960. lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection);
  961. }
  962. return child;
  963. },
  964. /**
  965. `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
  966. as the catch block of a try/catch statement.
  967. ```js
  968. function findAuthor(){
  969. throw new Error('couldn't find that author');
  970. }
  971. // synchronous
  972. try {
  973. findAuthor();
  974. } catch(reason) {
  975. // something went wrong
  976. }
  977. // async with promises
  978. findAuthor().catch(function(reason){
  979. // something went wrong
  980. });
  981. ```
  982. @method catch
  983. @param {Function} onRejection
  984. Useful for tooling.
  985. @return {Promise}
  986. */
  987. 'catch': function(onRejection) {
  988. return this.then(null, onRejection);
  989. }
  990. };
  991. function lib$es6$promise$polyfill$$polyfill() {
  992. var local;
  993. if (typeof global !== 'undefined') {
  994. local = global;
  995. } else if (typeof self !== 'undefined') {
  996. local = self;
  997. } else {
  998. try {
  999. local = Function('return this')();
  1000. } catch (e) {
  1001. throw new Error('polyfill failed because global object is unavailable in this environment');
  1002. }
  1003. }
  1004. var P = local.Promise;
  1005. if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) {
  1006. return;
  1007. }
  1008. local.Promise = lib$es6$promise$promise$$default;
  1009. }
  1010. var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill;
  1011. var lib$es6$promise$umd$$ES6Promise = {
  1012. 'Promise': lib$es6$promise$promise$$default,
  1013. 'polyfill': lib$es6$promise$polyfill$$default
  1014. };
  1015. /* global define:true module:true window: true */
  1016. if (typeof define === 'function' && define['amd']) {
  1017. define(function() { return lib$es6$promise$umd$$ES6Promise; });
  1018. } else if (typeof module !== 'undefined' && module['exports']) {
  1019. module['exports'] = lib$es6$promise$umd$$ES6Promise;
  1020. } else if (typeof this !== 'undefined') {
  1021. this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise;
  1022. }
  1023. lib$es6$promise$polyfill$$default();
  1024. }).call(this);
  1025. // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
  1026. // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
  1027. // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
  1028. // refactored by Yannick Albert
  1029. // MIT license
  1030. (function(window) {
  1031. var equestAnimationFrame = 'equestAnimationFrame',
  1032. requestAnimationFrame = 'r' + equestAnimationFrame,
  1033. ancelAnimationFrame = 'ancelAnimationFrame',
  1034. cancelAnimationFrame = 'c' + ancelAnimationFrame,
  1035. expectedTime = 0,
  1036. vendors = ['moz', 'ms', 'o', 'webkit'],
  1037. vendor;
  1038. while(!window[requestAnimationFrame] && (vendor = vendors.pop())) {
  1039. window[requestAnimationFrame] = window[vendor + 'R' + equestAnimationFrame];
  1040. window[cancelAnimationFrame] = window[vendor + 'C' + ancelAnimationFrame] || window[vendor + 'CancelR' + equestAnimationFrame];
  1041. }
  1042. if(!window[requestAnimationFrame]) {
  1043. window[requestAnimationFrame] = function(callback) {
  1044. var currentTime = new Date().getTime(),
  1045. adjustedDelay = 16 - (currentTime - expectedTime),
  1046. delay = adjustedDelay > 0 ? adjustedDelay : 0;
  1047. expectedTime = currentTime + delay;
  1048. return setTimeout(function() {
  1049. callback(expectedTime);
  1050. }, delay);
  1051. };
  1052. window[cancelAnimationFrame] = clearTimeout;
  1053. }
  1054. }(this));
  1055. //https://gist.github.com/jonathantneal/3062955
  1056. this.Element && function(ElementPrototype) {
  1057. ElementPrototype.matchesSelector = ElementPrototype.matchesSelector ||
  1058. ElementPrototype.mozMatchesSelector ||
  1059. ElementPrototype.msMatchesSelector ||
  1060. ElementPrototype.oMatchesSelector ||
  1061. ElementPrototype.webkitMatchesSelector ||
  1062. function (selector) {
  1063. var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1;
  1064. while (nodes[++i] && nodes[i] != node);
  1065. return !!nodes[i];
  1066. }
  1067. }(Element.prototype);
  1068. // EventListener | MIT/GPL2 | github.com/jonathantneal/EventListener
  1069. this.Element && Element.prototype.attachEvent && !Element.prototype.addEventListener && (function () {
  1070. function addToPrototype(name, method) {
  1071. Window.prototype[name] = HTMLDocument.prototype[name] = Element.prototype[name] = method;
  1072. }
  1073. // add
  1074. addToPrototype("addEventListener", function (type, listener) {
  1075. var
  1076. target = this,
  1077. listeners = target.addEventListener.listeners = target.addEventListener.listeners || {},
  1078. typeListeners = listeners[type] = listeners[type] || [];
  1079. // if no events exist, attach the listener
  1080. if (!typeListeners.length) {
  1081. target.attachEvent("on" + type, typeListeners.event = function (event) {
  1082. var documentElement = target.document && target.document.documentElement || target.documentElement || { scrollLeft: 0, scrollTop: 0 };
  1083. // polyfill w3c properties and methods
  1084. event.currentTarget = target;
  1085. event.pageX = event.clientX + documentElement.scrollLeft;
  1086. event.pageY = event.clientY + documentElement.scrollTop;
  1087. event.preventDefault = function () { event.returnValue = false };
  1088. event.relatedTarget = event.fromElement || null;
  1089. event.stopImmediatePropagation = function () { immediatePropagation = false; event.cancelBubble = true };
  1090. event.stopPropagation = function () { event.cancelBubble = true };
  1091. event.relatedTarget = event.fromElement || null;
  1092. event.target = event.srcElement || target;
  1093. event.timeStamp = +new Date;
  1094. // create an cached list of the master events list (to protect this loop from breaking when an event is removed)
  1095. for (var i = 0, typeListenersCache = [].concat(typeListeners), typeListenerCache, immediatePropagation = true; immediatePropagation && (typeListenerCache = typeListenersCache[i]); ++i) {
  1096. // check to see if the cached event still exists in the master events list
  1097. for (var ii = 0, typeListener; typeListener = typeListeners[ii]; ++ii) {
  1098. if (typeListener == typeListenerCache) {
  1099. typeListener.call(target, event);
  1100. break;
  1101. }
  1102. }
  1103. }
  1104. });
  1105. }
  1106. // add the event to the master event list
  1107. typeListeners.push(listener);
  1108. });
  1109. // remove
  1110. addToPrototype("removeEventListener", function (type, listener) {
  1111. var
  1112. target = this,
  1113. listeners = target.addEventListener.listeners = target.addEventListener.listeners || {},
  1114. typeListeners = listeners[type] = listeners[type] || [];
  1115. // remove the newest matching event from the master event list
  1116. for (var i = typeListeners.length - 1, typeListener; typeListener = typeListeners[i]; --i) {
  1117. if (typeListener == listener) {
  1118. typeListeners.splice(i, 1);
  1119. break;
  1120. }
  1121. }
  1122. // if no events exist, detach the listener
  1123. if (!typeListeners.length && typeListeners.event) {
  1124. target.detachEvent("on" + type, typeListeners.event);
  1125. }
  1126. });
  1127. // dispatch
  1128. addToPrototype("dispatchEvent", function (eventObject) {
  1129. var
  1130. target = this,
  1131. type = eventObject.type,
  1132. listeners = target.addEventListener.listeners = target.addEventListener.listeners || {},
  1133. typeListeners = listeners[type] = listeners[type] || [];
  1134. try {
  1135. return target.fireEvent("on" + type, eventObject);
  1136. } catch (error) {
  1137. if (typeListeners.event) {
  1138. typeListeners.event(eventObject);
  1139. }
  1140. return;
  1141. }
  1142. });
  1143. // CustomEvent
  1144. Object.defineProperty(Window.prototype, "CustomEvent", {
  1145. get: function () {
  1146. var self = this;
  1147. return function CustomEvent(type, detail) {
  1148. detail = detail || {};
  1149. var event = self.document.createEventObject(), key;
  1150. event.type = type;
  1151. event.returnValue = !detail.cancelable;
  1152. event.cancelBubble = !detail.bubbles;
  1153. for (key in detail) {
  1154. event[key] = detail[key];
  1155. }
  1156. return event;
  1157. };
  1158. }
  1159. });
  1160. // ready
  1161. function ready(event) {
  1162. if (ready.interval && document.body) {
  1163. ready.interval = clearInterval(ready.interval);
  1164. document.dispatchEvent(new CustomEvent("DOMContentLoaded"));
  1165. }
  1166. }
  1167. ready.interval = setInterval(ready, 1);
  1168. window.addEventListener("load", ready);
  1169. })();
  1170. ;/*!
  1171. handlebars v4.0.5
  1172. Copyright (C) 2011-2015 by Yehuda Katz
  1173. Permission is hereby granted, free of charge, to any person obtaining a copy
  1174. of this software and associated documentation files (the "Software"), to deal
  1175. in the Software without restriction, including without limitation the rights
  1176. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1177. copies of the Software, and to permit persons to whom the Software is
  1178. furnished to do so, subject to the following conditions:
  1179. The above copyright notice and this permission notice shall be included in
  1180. all copies or substantial portions of the Software.
  1181. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1182. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1183. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1184. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1185. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1186. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1187. THE SOFTWARE.
  1188. @license
  1189. */
  1190. (function webpackUniversalModuleDefinition(root, factory) {
  1191. if(typeof exports === 'object' && typeof module === 'object')
  1192. module.exports = factory();
  1193. else if(typeof define === 'function' && define.amd)
  1194. define([], factory);
  1195. else if(typeof exports === 'object')
  1196. exports["Handlebars"] = factory();
  1197. else
  1198. root["Handlebars"] = factory();
  1199. })(this, function() {
  1200. return /******/ (function(modules) { // webpackBootstrap
  1201. /******/ // The module cache
  1202. /******/ var installedModules = {};
  1203. /******/ // The require function
  1204. /******/ function __webpack_require__(moduleId) {
  1205. /******/ // Check if module is in cache
  1206. /******/ if(installedModules[moduleId])
  1207. /******/ return installedModules[moduleId].exports;
  1208. /******/ // Create a new module (and put it into the cache)
  1209. /******/ var module = installedModules[moduleId] = {
  1210. /******/ exports: {},
  1211. /******/ id: moduleId,
  1212. /******/ loaded: false
  1213. /******/ };
  1214. /******/ // Execute the module function
  1215. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  1216. /******/ // Flag the module as loaded
  1217. /******/ module.loaded = true;
  1218. /******/ // Return the exports of the module
  1219. /******/ return module.exports;
  1220. /******/ }
  1221. /******/ // expose the modules object (__webpack_modules__)
  1222. /******/ __webpack_require__.m = modules;
  1223. /******/ // expose the module cache
  1224. /******/ __webpack_require__.c = installedModules;
  1225. /******/ // __webpack_public_path__
  1226. /******/ __webpack_require__.p = "";
  1227. /******/ // Load entry module and return exports
  1228. /******/ return __webpack_require__(0);
  1229. /******/ })
  1230. /************************************************************************/
  1231. /******/ ([
  1232. /* 0 */
  1233. /***/ function(module, exports, __webpack_require__) {
  1234. 'use strict';
  1235. var _interopRequireWildcard = __webpack_require__(1)['default'];
  1236. var _interopRequireDefault = __webpack_require__(2)['default'];
  1237. exports.__esModule = true;
  1238. var _handlebarsBase = __webpack_require__(3);
  1239. var base = _interopRequireWildcard(_handlebarsBase);
  1240. // Each of these augment the Handlebars object. No need to setup here.
  1241. // (This is done to easily share code between commonjs and browse envs)
  1242. var _handlebarsSafeString = __webpack_require__(17);
  1243. var _handlebarsSafeString2 = _interopRequireDefault(_handlebarsSafeString);
  1244. var _handlebarsException = __webpack_require__(5);
  1245. var _handlebarsException2 = _interopRequireDefault(_handlebarsException);
  1246. var _handlebarsUtils = __webpack_require__(4);
  1247. var Utils = _interopRequireWildcard(_handlebarsUtils);
  1248. var _handlebarsRuntime = __webpack_require__(18);
  1249. var runtime = _interopRequireWildcard(_handlebarsRuntime);
  1250. var _handlebarsNoConflict = __webpack_require__(19);
  1251. var _handlebarsNoConflict2 = _interopRequireDefault(_handlebarsNoConflict);
  1252. // For compatibility and usage outside of module systems, make the Handlebars object a namespace
  1253. function create() {
  1254. var hb = new base.HandlebarsEnvironment();
  1255. Utils.extend(hb, base);
  1256. hb.SafeString = _handlebarsSafeString2['default'];
  1257. hb.Exception = _handlebarsException2['default'];
  1258. hb.Utils = Utils;
  1259. hb.escapeExpression = Utils.escapeExpression;
  1260. hb.VM = runtime;
  1261. hb.template = function (spec) {
  1262. return runtime.template(spec, hb);
  1263. };
  1264. return hb;
  1265. }
  1266. var inst = create();
  1267. inst.create = create;
  1268. _handlebarsNoConflict2['default'](inst);
  1269. inst['default'] = inst;
  1270. exports['default'] = inst;
  1271. module.exports = exports['default'];
  1272. /***/ },
  1273. /* 1 */
  1274. /***/ function(module, exports) {
  1275. "use strict";
  1276. exports["default"] = function (obj) {
  1277. if (obj && obj.__esModule) {
  1278. return obj;
  1279. } else {
  1280. var newObj = {};
  1281. if (obj != null) {
  1282. for (var key in obj) {
  1283. if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
  1284. }
  1285. }
  1286. newObj["default"] = obj;
  1287. return newObj;
  1288. }
  1289. };
  1290. exports.__esModule = true;
  1291. /***/ },
  1292. /* 2 */
  1293. /***/ function(module, exports) {
  1294. "use strict";
  1295. exports["default"] = function (obj) {
  1296. return obj && obj.__esModule ? obj : {
  1297. "default": obj
  1298. };
  1299. };
  1300. exports.__esModule = true;
  1301. /***/ },
  1302. /* 3 */
  1303. /***/ function(module, exports, __webpack_require__) {
  1304. 'use strict';
  1305. var _interopRequireDefault = __webpack_require__(2)['default'];
  1306. exports.__esModule = true;
  1307. exports.HandlebarsEnvironment = HandlebarsEnvironment;
  1308. var _utils = __webpack_require__(4);
  1309. var _exception = __webpack_require__(5);
  1310. var _exception2 = _interopRequireDefault(_exception);
  1311. var _helpers = __webpack_require__(6);
  1312. var _decorators = __webpack_require__(14);
  1313. var _logger = __webpack_require__(16);
  1314. var _logger2 = _interopRequireDefault(_logger);
  1315. var VERSION = '4.0.5';
  1316. exports.VERSION = VERSION;
  1317. var COMPILER_REVISION = 7;
  1318. exports.COMPILER_REVISION = COMPILER_REVISION;
  1319. var REVISION_CHANGES = {
  1320. 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
  1321. 2: '== 1.0.0-rc.3',
  1322. 3: '== 1.0.0-rc.4',
  1323. 4: '== 1.x.x',
  1324. 5: '== 2.0.0-alpha.x',
  1325. 6: '>= 2.0.0-beta.1',
  1326. 7: '>= 4.0.0'
  1327. };
  1328. exports.REVISION_CHANGES = REVISION_CHANGES;
  1329. var objectType = '[object Object]';
  1330. function HandlebarsEnvironment(helpers, partials, decorators) {
  1331. this.helpers = helpers || {};
  1332. this.partials = partials || {};
  1333. this.decorators = decorators || {};
  1334. _helpers.registerDefaultHelpers(this);
  1335. _decorators.registerDefaultDecorators(this);
  1336. }
  1337. HandlebarsEnvironment.prototype = {
  1338. constructor: HandlebarsEnvironment,
  1339. logger: _logger2['default'],
  1340. log: _logger2['default'].log,
  1341. registerHelper: function registerHelper(name, fn) {
  1342. if (_utils.toString.call(name) === objectType) {
  1343. if (fn) {
  1344. throw new _exception2['default']('Arg not supported with multiple helpers');
  1345. }
  1346. _utils.extend(this.helpers, name);
  1347. } else {
  1348. this.helpers[name] = fn;
  1349. }
  1350. },
  1351. unregisterHelper: function unregisterHelper(name) {
  1352. delete this.helpers[name];
  1353. },
  1354. registerPartial: function registerPartial(name, partial) {
  1355. if (_utils.toString.call(name) === objectType) {
  1356. _utils.extend(this.partials, name);
  1357. } else {
  1358. if (typeof partial === 'undefined') {
  1359. throw new _exception2['default']('Attempting to register a partial called "' + name + '" as undefined');
  1360. }
  1361. this.partials[name] = partial;
  1362. }
  1363. },
  1364. unregisterPartial: function unregisterPartial(name) {
  1365. delete this.partials[name];
  1366. },
  1367. registerDecorator: function registerDecorator(name, fn) {
  1368. if (_utils.toString.call(name) === objectType) {
  1369. if (fn) {
  1370. throw new _exception2['default']('Arg not supported with multiple decorators');
  1371. }
  1372. _utils.extend(this.decorators, name);
  1373. } else {
  1374. this.decorators[name] = fn;
  1375. }
  1376. },
  1377. unregisterDecorator: function unregisterDecorator(name) {
  1378. delete this.decorators[name];
  1379. }
  1380. };
  1381. var log = _logger2['default'].log;
  1382. exports.log = log;
  1383. exports.createFrame = _utils.createFrame;
  1384. exports.logger = _logger2['default'];
  1385. /***/ },
  1386. /* 4 */
  1387. /***/ function(module, exports) {
  1388. 'use strict';
  1389. exports.__esModule = true;
  1390. exports.extend = extend;
  1391. exports.indexOf = indexOf;
  1392. exports.escapeExpression = escapeExpression;
  1393. exports.isEmpty = isEmpty;
  1394. exports.createFrame = createFrame;
  1395. exports.blockParams = blockParams;
  1396. exports.appendContextPath = appendContextPath;
  1397. var escape = {
  1398. '&': '&amp;',
  1399. '<': '&lt;',
  1400. '>': '&gt;',
  1401. '"': '&quot;',
  1402. "'": '&#x27;',
  1403. '`': '&#x60;',
  1404. '=': '&#x3D;'
  1405. };
  1406. var badChars = /[&<>"'`=]/g,
  1407. possible = /[&<>"'`=]/;
  1408. function escapeChar(chr) {
  1409. return escape[chr];
  1410. }
  1411. function extend(obj /* , ...source */) {
  1412. for (var i = 1; i < arguments.length; i++) {
  1413. for (var key in arguments[i]) {
  1414. if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
  1415. obj[key] = arguments[i][key];
  1416. }
  1417. }
  1418. }
  1419. return obj;
  1420. }
  1421. var toString = Object.prototype.toString;
  1422. exports.toString = toString;
  1423. // Sourced from lodash
  1424. // https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
  1425. /* eslint-disable func-style */
  1426. var isFunction = function isFunction(value) {
  1427. return typeof value === 'function';
  1428. };
  1429. // fallback for older versions of Chrome and Safari
  1430. /* istanbul ignore next */
  1431. if (isFunction(/x/)) {
  1432. exports.isFunction = isFunction = function (value) {
  1433. return typeof value === 'function' && toString.call(value) === '[object Function]';
  1434. };
  1435. }
  1436. exports.isFunction = isFunction;
  1437. /* eslint-enable func-style */
  1438. /* istanbul ignore next */
  1439. var isArray = Array.isArray || function (value) {
  1440. return value && typeof value === 'object' ? toString.call(value) === '[object Array]' : false;
  1441. };
  1442. exports.isArray = isArray;
  1443. // Older IE versions do not directly support indexOf so we must implement our own, sadly.
  1444. function indexOf(array, value) {
  1445. for (var i = 0, len = array.length; i < len; i++) {
  1446. if (array[i] === value) {
  1447. return i;
  1448. }
  1449. }
  1450. return -1;
  1451. }
  1452. function escapeExpression(string) {
  1453. if (typeof string !== 'string') {
  1454. // don't escape SafeStrings, since they're already safe
  1455. if (string && string.toHTML) {
  1456. return string.toHTML();
  1457. } else if (string == null) {
  1458. return '';
  1459. } else if (!string) {
  1460. return string + '';
  1461. }
  1462. // Force a string conversion as this will be done by the append regardless and
  1463. // the regex test will do this transparently behind the scenes, causing issues if
  1464. // an object's to string has escaped characters in it.
  1465. string = '' + string;
  1466. }
  1467. if (!possible.test(string)) {
  1468. return string;
  1469. }
  1470. return string.replace(badChars, escapeChar);
  1471. }
  1472. function isEmpty(value) {
  1473. if (!value && value !== 0) {
  1474. return true;
  1475. } else if (isArray(value) && value.length === 0) {
  1476. return true;
  1477. } else {
  1478. return false;
  1479. }
  1480. }
  1481. function createFrame(object) {
  1482. var frame = extend({}, object);
  1483. frame._parent = object;
  1484. return frame;
  1485. }
  1486. function blockParams(params, ids) {
  1487. params.path = ids;
  1488. return params;
  1489. }
  1490. function appendContextPath(contextPath, id) {
  1491. return (contextPath ? contextPath + '.' : '') + id;
  1492. }
  1493. /***/ },
  1494. /* 5 */
  1495. /***/ function(module, exports) {
  1496. 'use strict';
  1497. exports.__esModule = true;
  1498. var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
  1499. function Exception(message, node) {
  1500. var loc = node && node.loc,
  1501. line = undefined,
  1502. column = undefined;
  1503. if (loc) {
  1504. line = loc.start.line;
  1505. column = loc.start.column;
  1506. message += ' - ' + line + ':' + column;
  1507. }
  1508. var tmp = Error.prototype.constructor.call(this, message);
  1509. // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
  1510. for (var idx = 0; idx < errorProps.length; idx++) {
  1511. this[errorProps[idx]] = tmp[errorProps[idx]];
  1512. }
  1513. /* istanbul ignore else */
  1514. if (Error.captureStackTrace) {
  1515. Error.captureStackTrace(this, Exception);
  1516. }
  1517. if (loc) {
  1518. this.lineNumber = line;
  1519. this.column = column;
  1520. }
  1521. }
  1522. Exception.prototype = new Error();
  1523. exports['default'] = Exception;
  1524. module.exports = exports['default'];
  1525. /***/ },
  1526. /* 6 */
  1527. /***/ function(module, exports, __webpack_require__) {
  1528. 'use strict';
  1529. var _interopRequireDefault = __webpack_require__(2)['default'];
  1530. exports.__esModule = true;
  1531. exports.registerDefaultHelpers = registerDefaultHelpers;
  1532. var _helpersBlockHelperMissing = __webpack_require__(7);
  1533. var _helpersBlockHelperMissing2 = _interopRequireDefault(_helpersBlockHelperMissing);
  1534. var _helpersEach = __webpack_require__(8);
  1535. var _helpersEach2 = _interopRequireDefault(_helpersEach);
  1536. var _helpersHelperMissing = __webpack_require__(9);
  1537. var _helpersHelperMissing2 = _interopRequireDefault(_helpersHelperMissing);
  1538. var _helpersIf = __webpack_require__(10);
  1539. var _helpersIf2 = _interopRequireDefault(_helpersIf);
  1540. var _helpersLog = __webpack_require__(11);
  1541. var _helpersLog2 = _interopRequireDefault(_helpersLog);
  1542. var _helpersLookup = __webpack_require__(12);
  1543. var _helpersLookup2 = _interopRequireDefault(_helpersLookup);
  1544. var _helpersWith = __webpack_require__(13);
  1545. var _helpersWith2 = _interopRequireDefault(_helpersWith);
  1546. function registerDefaultHelpers(instance) {
  1547. _helpersBlockHelperMissing2['default'](instance);
  1548. _helpersEach2['default'](instance);
  1549. _helpersHelperMissing2['default'](instance);
  1550. _helpersIf2['default'](instance);
  1551. _helpersLog2['default'](instance);
  1552. _helpersLookup2['default'](instance);
  1553. _helpersWith2['default'](instance);
  1554. }
  1555. /***/ },
  1556. /* 7 */
  1557. /***/ function(module, exports, __webpack_require__) {
  1558. 'use strict';
  1559. exports.__esModule = true;
  1560. var _utils = __webpack_require__(4);
  1561. exports['default'] = function (instance) {
  1562. instance.registerHelper('blockHelperMissing', function (context, options) {
  1563. var inverse = options.inverse,
  1564. fn = options.fn;
  1565. if (context === true) {
  1566. return fn(this);
  1567. } else if (context === false || context == null) {
  1568. return inverse(this);
  1569. } else if (_utils.isArray(context)) {
  1570. if (context.length > 0) {
  1571. if (options.ids) {
  1572. options.ids = [options.name];
  1573. }
  1574. return instance.helpers.each(context, options);
  1575. } else {
  1576. return inverse(this);
  1577. }
  1578. } else {
  1579. if (options.data && options.ids) {
  1580. var data = _utils.createFrame(options.data);
  1581. data.contextPath = _utils.appendContextPath(options.data.contextPath, options.name);
  1582. options = { data: data };
  1583. }
  1584. return fn(context, options);
  1585. }
  1586. });
  1587. };
  1588. module.exports = exports['default'];
  1589. /***/ },
  1590. /* 8 */
  1591. /***/ function(module, exports, __webpack_require__) {
  1592. 'use strict';
  1593. var _interopRequireDefault = __webpack_require__(2)['default'];
  1594. exports.__esModule = true;
  1595. var _utils = __webpack_require__(4);
  1596. var _exception = __webpack_require__(5);
  1597. var _exception2 = _interopRequireDefault(_exception);
  1598. exports['default'] = function (instance) {
  1599. instance.registerHelper('each', function (context, options) {
  1600. if (!options) {
  1601. throw new _exception2['default']('Must pass iterator to #each');
  1602. }
  1603. var fn = options.fn,
  1604. inverse = options.inverse,
  1605. i = 0,
  1606. ret = '',
  1607. data = undefined,
  1608. contextPath = undefined;
  1609. if (options.data && options.ids) {
  1610. contextPath = _utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.';
  1611. }
  1612. if (_utils.isFunction(context)) {
  1613. context = context.call(this);
  1614. }
  1615. if (options.data) {
  1616. data = _utils.createFrame(options.data);
  1617. }
  1618. function execIteration(field, index, last) {
  1619. if (data) {
  1620. data.key = field;
  1621. data.index = index;
  1622. data.first = index === 0;
  1623. data.last = !!last;
  1624. if (contextPath) {
  1625. data.contextPath = contextPath + field;
  1626. }
  1627. }
  1628. ret = ret + fn(context[field], {
  1629. data: data,
  1630. blockParams: _utils.blockParams([context[field], field], [contextPath + field, null])
  1631. });
  1632. }
  1633. if (context && typeof context === 'object') {
  1634. if (_utils.isArray(context)) {
  1635. for (var j = context.length; i < j; i++) {
  1636. if (i in context) {
  1637. execIteration(i, i, i === context.length - 1);
  1638. }
  1639. }
  1640. } else {
  1641. var priorKey = undefined;
  1642. for (var key in context) {
  1643. if (context.hasOwnProperty(key)) {
  1644. // We're running the iterations one step out of sync so we can detect
  1645. // the last iteration without have to scan the object twice and create
  1646. // an itermediate keys array.
  1647. if (priorKey !== undefined) {
  1648. execIteration(priorKey, i - 1);
  1649. }
  1650. priorKey = key;
  1651. i++;
  1652. }
  1653. }
  1654. if (priorKey !== undefined) {
  1655. execIteration(priorKey, i - 1, true);
  1656. }
  1657. }
  1658. }
  1659. if (i === 0) {
  1660. ret = inverse(this);
  1661. }
  1662. return ret;
  1663. });
  1664. };
  1665. module.exports = exports['default'];
  1666. /***/ },
  1667. /* 9 */
  1668. /***/ function(module, exports, __webpack_require__) {
  1669. 'use strict';
  1670. var _interopRequireDefault = __webpack_require__(2)['default'];
  1671. exports.__esModule = true;
  1672. var _exception = __webpack_require__(5);
  1673. var _exception2 = _interopRequireDefault(_exception);
  1674. exports['default'] = function (instance) {
  1675. instance.registerHelper('helperMissing', function () /* [args, ]options */{
  1676. if (arguments.length === 1) {
  1677. // A missing field in a {{foo}} construct.
  1678. return undefined;
  1679. } else {
  1680. // Someone is actually trying to call something, blow up.
  1681. throw new _exception2['default']('Missing helper: "' + arguments[arguments.length - 1].name + '"');
  1682. }
  1683. });
  1684. };
  1685. module.exports = exports['default'];
  1686. /***/ },
  1687. /* 10 */
  1688. /***/ function(module, exports, __webpack_require__) {
  1689. 'use strict';
  1690. exports.__esModule = true;
  1691. var _utils = __webpack_require__(4);
  1692. exports['default'] = function (instance) {
  1693. instance.registerHelper('if', function (conditional, options) {
  1694. if (_utils.isFunction(conditional)) {
  1695. conditional = conditional.call(this);
  1696. }
  1697. // Default behavior is to render the positive path if the value is truthy and not empty.
  1698. // The `includeZero` option may be set to treat the condtional as purely not empty based on the
  1699. // behavior of isEmpty. Effectively this determines if 0 is handled by the positive path or negative.
  1700. if (!options.hash.includeZero && !conditional || _utils.isEmpty(conditional)) {
  1701. return options.inverse(this);
  1702. } else {
  1703. return options.fn(this);
  1704. }
  1705. });
  1706. instance.registerHelper('unless', function (conditional, options) {
  1707. return instance.helpers['if'].call(this, conditional, { fn: options.inverse, inverse: options.fn, hash: options.hash });
  1708. });
  1709. };
  1710. module.exports = exports['default'];
  1711. /***/ },
  1712. /* 11 */
  1713. /***/ function(module, exports) {
  1714. 'use strict';
  1715. exports.__esModule = true;
  1716. exports['default'] = function (instance) {
  1717. instance.registerHelper('log', function () /* message, options */{
  1718. var args = [undefined],
  1719. options = arguments[arguments.length - 1];
  1720. for (var i = 0; i < arguments.length - 1; i++) {
  1721. args.push(arguments[i]);
  1722. }
  1723. var level = 1;
  1724. if (options.hash.level != null) {
  1725. level = options.hash.level;
  1726. } else if (options.data && options.data.level != null) {
  1727. level = options.data.level;
  1728. }
  1729. args[0] = level;
  1730. instance.log.apply(instance, args);
  1731. });
  1732. };
  1733. module.exports = exports['default'];
  1734. /***/ },
  1735. /* 12 */
  1736. /***/ function(module, exports) {
  1737. 'use strict';
  1738. exports.__esModule = true;
  1739. exports['default'] = function (instance) {
  1740. instance.registerHelper('lookup', function (obj, field) {
  1741. return obj && obj[field];
  1742. });
  1743. };
  1744. module.exports = exports['default'];
  1745. /***/ },
  1746. /* 13 */
  1747. /***/ function(module, exports, __webpack_require__) {
  1748. 'use strict';
  1749. exports.__esModule = true;
  1750. var _utils = __webpack_require__(4);
  1751. exports['default'] = function (instance) {
  1752. instance.registerHelper('with', function (context, options) {
  1753. if (_utils.isFunction(context)) {
  1754. context = context.call(this);
  1755. }
  1756. var fn = options.fn;
  1757. if (!_utils.isEmpty(context)) {
  1758. var data = options.data;
  1759. if (options.data && options.ids) {
  1760. data = _utils.createFrame(options.data);
  1761. data.contextPath = _utils.appendContextPath(options.data.contextPath, options.ids[0]);
  1762. }
  1763. return fn(context, {
  1764. data: data,
  1765. blockParams: _utils.blockParams([context], [data && data.contextPath])
  1766. });
  1767. } else {
  1768. return options.inverse(this);
  1769. }
  1770. });
  1771. };
  1772. module.exports = exports['default'];
  1773. /***/ },
  1774. /* 14 */
  1775. /***/ function(module, exports, __webpack_require__) {
  1776. 'use strict';
  1777. var _interopRequireDefault = __webpack_require__(2)['default'];
  1778. exports.__esModule = true;
  1779. exports.registerDefaultDecorators = registerDefaultDecorators;
  1780. var _decoratorsInline = __webpack_require__(15);
  1781. var _decoratorsInline2 = _interopRequireDefault(_decoratorsInline);
  1782. function registerDefaultDecorators(instance) {
  1783. _decoratorsInline2['default'](instance);
  1784. }
  1785. /***/ },
  1786. /* 15 */
  1787. /***/ function(module, exports, __webpack_require__) {
  1788. 'use strict';
  1789. exports.__esModule = true;
  1790. var _utils = __webpack_require__(4);
  1791. exports['default'] = function (instance) {
  1792. instance.registerDecorator('inline', function (fn, props, container, options) {
  1793. var ret = fn;
  1794. if (!props.partials) {
  1795. props.partials = {};
  1796. ret = function (context, options) {
  1797. // Create a new partials stack frame prior to exec.
  1798. var original = container.partials;
  1799. container.partials = _utils.extend({}, original, props.partials);
  1800. var ret = fn(context, options);
  1801. container.partials = original;
  1802. return ret;
  1803. };
  1804. }
  1805. props.partials[options.args[0]] = options.fn;
  1806. return ret;
  1807. });
  1808. };
  1809. module.exports = exports['default'];
  1810. /***/ },
  1811. /* 16 */
  1812. /***/ function(module, exports, __webpack_require__) {
  1813. 'use strict';
  1814. exports.__esModule = true;
  1815. var _utils = __webpack_require__(4);
  1816. var logger = {
  1817. methodMap: ['debug', 'info', 'warn', 'error'],
  1818. level: 'info',
  1819. // Maps a given level value to the `methodMap` indexes above.
  1820. lookupLevel: function lookupLevel(level) {
  1821. if (typeof level === 'string') {
  1822. var levelMap = _utils.indexOf(logger.methodMap, level.toLowerCase());
  1823. if (levelMap >= 0) {
  1824. level = levelMap;
  1825. } else {
  1826. level = parseInt(level, 10);
  1827. }
  1828. }
  1829. return level;
  1830. },
  1831. // Can be overridden in the host environment
  1832. log: function log(level) {
  1833. level = logger.lookupLevel(level);
  1834. if (typeof console !== 'undefined' && logger.lookupLevel(logger.level) <= level) {
  1835. var method = logger.methodMap[level];
  1836. if (!console[method]) {
  1837. // eslint-disable-line no-console
  1838. method = 'log';
  1839. }
  1840. for (var _len = arguments.length, message = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1841. message[_key - 1] = arguments[_key];
  1842. }
  1843. console[method].apply(console, message); // eslint-disable-line no-console
  1844. }
  1845. }
  1846. };
  1847. exports['default'] = logger;
  1848. module.exports = exports['default'];
  1849. /***/ },
  1850. /* 17 */
  1851. /***/ function(module, exports) {
  1852. // Build out our basic SafeString type
  1853. 'use strict';
  1854. exports.__esModule = true;
  1855. function SafeString(string) {
  1856. this.string = string;
  1857. }
  1858. SafeString.prototype.toString = SafeString.prototype.toHTML = function () {
  1859. return '' + this.string;
  1860. };
  1861. exports['default'] = SafeString;
  1862. module.exports = exports['default'];
  1863. /***/ },
  1864. /* 18 */
  1865. /***/ function(module, exports, __webpack_require__) {
  1866. 'use strict';
  1867. var _interopRequireWildcard = __webpack_require__(1)['default'];
  1868. var _interopRequireDefault = __webpack_require__(2)['default'];
  1869. exports.__esModule = true;
  1870. exports.checkRevision = checkRevision;
  1871. exports.template = template;
  1872. exports.wrapProgram = wrapProgram;
  1873. exports.resolvePartial = resolvePartial;
  1874. exports.invokePartial = invokePartial;
  1875. exports.noop = noop;
  1876. var _utils = __webpack_require__(4);
  1877. var Utils = _interopRequireWildcard(_utils);
  1878. var _exception = __webpack_require__(5);
  1879. var _exception2 = _interopRequireDefault(_exception);
  1880. var _base = __webpack_require__(3);
  1881. function checkRevision(compilerInfo) {
  1882. var compilerRevision = compilerInfo && compilerInfo[0] || 1,
  1883. currentRevision = _base.COMPILER_REVISION;
  1884. if (compilerRevision !== currentRevision) {
  1885. if (compilerRevision < currentRevision) {
  1886. var runtimeVersions = _base.REVISION_CHANGES[currentRevision],
  1887. compilerVersions = _base.REVISION_CHANGES[compilerRevision];
  1888. throw new _exception2['default']('Template was precompiled with an older version of Handlebars than the current runtime. ' + 'Please update your precompiler to a newer version (' + runtimeVersions + ') or downgrade your runtime to an older version (' + compilerVersions + ').');
  1889. } else {
  1890. // Use the embedded version info since the runtime doesn't know about this revision yet
  1891. throw new _exception2['default']('Template was precompiled with a newer version of Handlebars than the current runtime. ' + 'Please update your runtime to a newer version (' + compilerInfo[1] + ').');
  1892. }
  1893. }
  1894. }
  1895. function template(templateSpec, env) {
  1896. /* istanbul ignore next */
  1897. if (!env) {
  1898. throw new _exception2['default']('No environment passed to template');
  1899. }
  1900. if (!templateSpec || !templateSpec.main) {
  1901. throw new _exception2['default']('Unknown template object: ' + typeof templateSpec);
  1902. }
  1903. templateSpec.main.decorator = templateSpec.main_d;
  1904. // Note: Using env.VM references rather than local var references throughout this section to allow
  1905. // for external users to override these as psuedo-supported APIs.
  1906. env.VM.checkRevision(templateSpec.compiler);
  1907. function invokePartialWrapper(partial, context, options) {
  1908. if (options.hash) {
  1909. context = Utils.extend({}, context, options.hash);
  1910. if (options.ids) {
  1911. options.ids[0] = true;
  1912. }
  1913. }
  1914. partial = env.VM.resolvePartial.call(this, partial, context, options);
  1915. var result = env.VM.invokePartial.call(this, partial, context, options);
  1916. if (result == null && env.compile) {
  1917. options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env);
  1918. result = options.partials[options.name](context, options);
  1919. }
  1920. if (result != null) {
  1921. if (options.indent) {
  1922. var lines = result.split('\n');
  1923. for (var i = 0, l = lines.length; i < l; i++) {
  1924. if (!lines[i] && i + 1 === l) {
  1925. break;
  1926. }
  1927. lines[i] = options.indent + lines[i];
  1928. }
  1929. result = lines.join('\n');
  1930. }
  1931. return result;
  1932. } else {
  1933. throw new _exception2['default']('The partial ' + options.name + ' could not be compiled when running in runtime-only mode');
  1934. }
  1935. }
  1936. // Just add water
  1937. var container = {
  1938. strict: function strict(obj, name) {
  1939. if (!(name in obj)) {
  1940. throw new _exception2['default']('"' + name + '" not defined in ' + obj);
  1941. }
  1942. return obj[name];
  1943. },
  1944. lookup: function lookup(depths, name) {
  1945. var len = depths.length;
  1946. for (var i = 0; i < len; i++) {
  1947. if (depths[i] && depths[i][name] != null) {
  1948. return depths[i][name];
  1949. }
  1950. }
  1951. },
  1952. lambda: function lambda(current, context) {
  1953. return typeof current === 'function' ? current.call(context) : current;
  1954. },
  1955. escapeExpression: Utils.escapeExpression,
  1956. invokePartial: invokePartialWrapper,
  1957. fn: function fn(i) {
  1958. var ret = templateSpec[i];
  1959. ret.decorator = templateSpec[i + '_d'];
  1960. return ret;
  1961. },
  1962. programs: [],
  1963. program: function program(i, data, declaredBlockParams, blockParams, depths) {
  1964. var programWrapper = this.programs[i],
  1965. fn = this.fn(i);
  1966. if (data || depths || blockParams || declaredBlockParams) {
  1967. programWrapper = wrapProgram(this, i, fn, data, declaredBlockParams, blockParams, depths);
  1968. } else if (!programWrapper) {
  1969. programWrapper = this.programs[i] = wrapProgram(this, i, fn);
  1970. }
  1971. return programWrapper;
  1972. },
  1973. data: function data(value, depth) {
  1974. while (value && depth--) {
  1975. value = value._parent;
  1976. }
  1977. return value;
  1978. },
  1979. merge: function merge(param, common) {
  1980. var obj = param || common;
  1981. if (param && common && param !== common) {
  1982. obj = Utils.extend({}, common, param);
  1983. }
  1984. return obj;
  1985. },
  1986. noop: env.VM.noop,
  1987. compilerInfo: templateSpec.compiler
  1988. };
  1989. function ret(context) {
  1990. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  1991. var data = options.data;
  1992. ret._setup(options);
  1993. if (!options.partial && templateSpec.useData) {
  1994. data = initData(context, data);
  1995. }
  1996. var depths = undefined,
  1997. blockParams = templateSpec.useBlockParams ? [] : undefined;
  1998. if (templateSpec.useDepths) {
  1999. if (options.depths) {
  2000. depths = context !== options.depths[0] ? [context].concat(options.depths) : options.depths;
  2001. } else {
  2002. depths = [context];
  2003. }
  2004. }
  2005. function main(context /*, options*/) {
  2006. return '' + templateSpec.main(container, context, container.helpers, container.partials, data, blockParams, depths);
  2007. }
  2008. main = executeDecorators(templateSpec.main, main, container, options.depths || [], data, blockParams);
  2009. return main(context, options);
  2010. }
  2011. ret.isTop = true;
  2012. ret._setup = function (options) {
  2013. if (!options.partial) {
  2014. container.helpers = container.merge(options.helpers, env.helpers);
  2015. if (templateSpec.usePartial) {
  2016. container.partials = container.merge(options.partials, env.partials);
  2017. }
  2018. if (templateSpec.usePartial || templateSpec.useDecorators) {
  2019. container.decorators = container.merge(options.decorators, env.decorators);
  2020. }
  2021. } else {
  2022. container.helpers = options.helpers;
  2023. container.partials = options.partials;
  2024. container.decorators = options.decorators;
  2025. }
  2026. };
  2027. ret._child = function (i, data, blockParams, depths) {
  2028. if (templateSpec.useBlockParams && !blockParams) {
  2029. throw new _exception2['default']('must pass block params');
  2030. }
  2031. if (templateSpec.useDepths && !depths) {
  2032. throw new _exception2['default']('must pass parent depths');
  2033. }
  2034. return wrapProgram(container, i, templateSpec[i], data, 0, blockParams, depths);
  2035. };
  2036. return ret;
  2037. }
  2038. function wrapProgram(container, i, fn, data, declaredBlockParams, blockParams, depths) {
  2039. function prog(context) {
  2040. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  2041. var currentDepths = depths;
  2042. if (depths && context !== depths[0]) {
  2043. currentDepths = [context].concat(depths);
  2044. }
  2045. return fn(container, context, container.helpers, container.partials, options.data || data, blockParams && [options.blockParams].concat(blockParams), currentDepths);
  2046. }
  2047. prog = executeDecorators(fn, prog, container, depths, data, blockParams);
  2048. prog.program = i;
  2049. prog.depth = depths ? depths.length : 0;
  2050. prog.blockParams = declaredBlockParams || 0;
  2051. return prog;
  2052. }
  2053. function resolvePartial(partial, context, options) {
  2054. if (!partial) {
  2055. if (options.name === '@partial-block') {
  2056. partial = options.data['partial-block'];
  2057. } else {
  2058. partial = options.partials[options.name];
  2059. }
  2060. } else if (!partial.call && !options.name) {
  2061. // This is a dynamic partial that returned a string
  2062. options.name = partial;
  2063. partial = options.partials[partial];
  2064. }
  2065. return partial;
  2066. }
  2067. function invokePartial(partial, context, options) {
  2068. options.partial = true;
  2069. if (options.ids) {
  2070. options.data.contextPath = options.ids[0] || options.data.contextPath;
  2071. }
  2072. var partialBlock = undefined;
  2073. if (options.fn && options.fn !== noop) {
  2074. options.data = _base.createFrame(options.data);
  2075. partialBlock = options.data['partial-block'] = options.fn;
  2076. if (partialBlock.partials) {
  2077. options.partials = Utils.extend({}, options.partials, partialBlock.partials);
  2078. }
  2079. }
  2080. if (partial === undefined && partialBlock) {
  2081. partial = partialBlock;
  2082. }
  2083. if (partial === undefined) {
  2084. throw new _exception2['default']('The partial ' + options.name + ' could not be found');
  2085. } else if (partial instanceof Function) {
  2086. return partial(context, options);
  2087. }
  2088. }
  2089. function noop() {
  2090. return '';
  2091. }
  2092. function initData(context, data) {
  2093. if (!data || !('root' in data)) {
  2094. data = data ? _base.createFrame(data) : {};
  2095. data.root = context;
  2096. }
  2097. return data;
  2098. }
  2099. function executeDecorators(fn, prog, container, depths, data, blockParams) {
  2100. if (fn.decorator) {
  2101. var props = {};
  2102. prog = fn.decorator(prog, props, container, depths && depths[0], data, blockParams, depths);
  2103. Utils.extend(prog, props);
  2104. }
  2105. return prog;
  2106. }
  2107. /***/ },
  2108. /* 19 */
  2109. /***/ function(module, exports) {
  2110. /* WEBPACK VAR INJECTION */(function(global) {/* global window */
  2111. 'use strict';
  2112. exports.__esModule = true;
  2113. exports['default'] = function (Handlebars) {
  2114. /* istanbul ignore next */
  2115. var root = typeof global !== 'undefined' ? global : window,
  2116. $Handlebars = root.Handlebars;
  2117. /* istanbul ignore next */
  2118. Handlebars.noConflict = function () {
  2119. if (root.Handlebars === Handlebars) {
  2120. root.Handlebars = $Handlebars;
  2121. }
  2122. return Handlebars;
  2123. };
  2124. };
  2125. module.exports = exports['default'];
  2126. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  2127. /***/ }
  2128. /******/ ])
  2129. });
  2130. ;;/* This file is part of Mura CMS.
  2131. Mura CMS is free software: you can redistribute it and/or modify
  2132. it under the terms of the GNU General Public License as published by
  2133. the Free Software Foundation, Version 2 of the License.
  2134. Mura CMS is distributed in the hope that it will be useful,
  2135. but WITHOUT ANY WARRANTY; without even the implied warranty of
  2136. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2137. GNU General Public License for more details.
  2138. You should have received a copy of the GNU General Public License
  2139. along with Mura CMS. If not, see <http://www.gnu.org/licenses/>.
  2140. Linking Mura CMS statically or dynamically with other modules constitutes the preparation of a derivative work based on
  2141. Mura CMS. Thus, the terms and conditions of the GNU General Public License version 2 ("GPL") cover the entire combined work.
  2142. However, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with programs
  2143. or libraries that are released under the GNU Lesser General Public License version 2.1.
  2144. In addition, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with
  2145. independent software modules (plugins, themes and bundles), and to distribute these plugins, themes and bundles without
  2146. Mura CMS under the license of your choice, provided that you follow these specific guidelines:
  2147. Your custom code
  2148. • Must not alter any default objects in the Mura CMS database and
  2149. • May not alter the default display of the Mura CMS logo within Mura CMS and
  2150. • Must not alter any files in the following directories.
  2151. /admin/
  2152. /tasks/
  2153. /config/
  2154. /requirements/mura/
  2155. /Application.cfc
  2156. /index.cfm
  2157. /MuraProxy.cfc
  2158. You may copy and distribute Mura CMS with a plug-in, theme or bundle that meets the above guidelines as a combined work
  2159. under the terms of GPL for Mura CMS, provided that you include the source code of that other code when and as the GNU GPL
  2160. requires distribution of source code.
  2161. For clarity, if you create a modified version of Mura CMS, you are not obligated to grant this special exception for your
  2162. modified version; it is your choice whether to do so, or to make such modified version available under the GNU General Public License
  2163. version 2 without this exception. You may, if you choose, apply this exception to your own modified versions of Mura CMS. */
  2164. ;(function (root, factory) {
  2165. if (typeof define === 'function' && define.amd) {
  2166. // AMD. Register as an anonymous module.
  2167. define(['Mura'], factory);
  2168. } else if (typeof module === 'object' && module.exports) {
  2169. // Node. Does not work with strict CommonJS, but
  2170. // only CommonJS-like environments that support module.exports,
  2171. // like Node.
  2172. root.Mura=factory(root);
  2173. } else {
  2174. // Browser globals (root is window)
  2175. root.Mura=factory(root);
  2176. }
  2177. }(this, function (root) {
  2178. function login(username,password,siteid){
  2179. siteid=siteid || root.Mura.siteid;
  2180. return new Promise(function(resolve,reject) {
  2181. root.Mura.ajax({
  2182. async:true,
  2183. type:'post',
  2184. url:root.Mura.apiEndpoint,
  2185. data:{
  2186. siteid:siteid,
  2187. username:username,
  2188. password:password,
  2189. method:'login'
  2190. },
  2191. success:function(resp){
  2192. resolve(resp.data);
  2193. }
  2194. });
  2195. });
  2196. }
  2197. function logout(siteid){
  2198. siteid=siteid || root.Mura.siteid;
  2199. return new Promise(function(resolve,reject) {
  2200. root.Mura.ajax({
  2201. async:true,
  2202. type:'post',
  2203. url:root.Mura.apiEndpoint,
  2204. data:{
  2205. siteid:siteid,
  2206. method:'logout'
  2207. },
  2208. success:function(resp){
  2209. resolve(resp.data);
  2210. }
  2211. });
  2212. });
  2213. }
  2214. function escapeHTML(str) {
  2215. var div = document.createElement('div');
  2216. div.appendChild(document.createTextNode(str));
  2217. return div.innerHTML;
  2218. };
  2219. // UNSAFE with unsafe strings; only use on previously-escaped ones!
  2220. function unescapeHTML(escapedStr) {
  2221. var div = document.createElement('div');
  2222. div.innerHTML = escapedStr;
  2223. var child = div.childNodes[0];
  2224. return child ? child.nodeValue : '';
  2225. };
  2226. function renderFilename(filename,params){
  2227. var query = [];
  2228. params = params || {};
  2229. params.filename= params.filename || '';
  2230. params.siteid= params.siteid || root.Mura.siteid;
  2231. for (var key in params) {
  2232. if(key != 'entityname' && key != 'filename' && key != 'siteid' && key != 'method'){
  2233. query.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
  2234. }
  2235. }
  2236. return new Promise(function(resolve,reject) {
  2237. root.Mura.ajax({
  2238. async:true,
  2239. type:'get',
  2240. url:root.Mura.apiEndpoint + params.siteid + '/content/_path/' + filename + '?' + query.join('&'),
  2241. success:function(resp){
  2242. if(typeof resolve == 'function'){
  2243. var item=new root.Mura.Entity();
  2244. item.set(resp.data);
  2245. resolve(item);
  2246. }
  2247. }
  2248. });
  2249. });
  2250. }
  2251. function getEntity(entityname,siteid){
  2252. if(typeof entityname == 'string'){
  2253. var properties={entityname:entityname};
  2254. properties.siteid = siteid || root.Mura.siteid;
  2255. } else {
  2256. properties=entityname;
  2257. properties.entityname=properties.entityname || 'content';
  2258. properties.siteid=properties.siteid || root.Mura.siteid;
  2259. }
  2260. if(root.Mura.entities[properties.entityname]){
  2261. return new root.Mura.entities[properties.entityname](properties);
  2262. } else {
  2263. return new root.Mura.Entity(properties);
  2264. }
  2265. }
  2266. function getFeed(entityname){
  2267. return new root.Mura.Feed(Mura.siteid,entityname);
  2268. }
  2269. function findQuery(params){
  2270. params=params || {};
  2271. params.entityname=params.entityname || 'content';
  2272. params.siteid=params.siteid || Mura.siteid;
  2273. params.method=params.method || 'findQuery';
  2274. return new Promise(function(resolve,reject) {
  2275. root.Mura.ajax({
  2276. type:'get',
  2277. url:root.Mura.apiEndpoint,
  2278. data:params,
  2279. success:function(resp){
  2280. var collection=new root.Mura.EntityCollection(resp.data)
  2281. if(typeof resolve == 'function'){
  2282. resolve(collection);
  2283. }
  2284. }
  2285. });
  2286. });
  2287. }
  2288. function evalScripts(el) {
  2289. if(typeof el=='string'){
  2290. el=parseHTML(el);
  2291. }
  2292. var scripts = [];
  2293. var ret = el.childNodes;
  2294. for ( var i = 0; ret[i]; i++ ) {
  2295. if ( scripts && nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
  2296. scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
  2297. } else if(ret[i].nodeType==1 || ret[i].nodeType==9 || ret[i].nodeType==11){
  2298. evalScripts(ret[i]);
  2299. }
  2300. }
  2301. for(script in scripts){
  2302. evalScript(scripts[script]);
  2303. }
  2304. }
  2305. function nodeName( el, name ) {
  2306. return el.nodeName && el.nodeName.toUpperCase() === name.toUpperCase();
  2307. }
  2308. function evalScript(el) {
  2309. var data = ( el.text || el.textContent || el.innerHTML || "" );
  2310. var head = document.getElementsByTagName("head")[0] || document.documentElement,
  2311. script = document.createElement("script");
  2312. script.type = "text/javascript";
  2313. //script.appendChild( document.createTextNode( data ) );
  2314. script.text=data;
  2315. head.insertBefore( script, head.firstChild );
  2316. head.removeChild( script );
  2317. if ( el.parentNode ) {
  2318. el.parentNode.removeChild( el );
  2319. }
  2320. }
  2321. function changeElementType(el, to) {
  2322. var newEl = document.createElement(to);
  2323. // Try to copy attributes across
  2324. for (var i = 0, a = el.attributes, n = a.length; i < n; ++i)
  2325. el.setAttribute(a[i].name, a[i].value);
  2326. // Try to move children across
  2327. while (el.hasChildNodes())
  2328. newEl.appendChild(el.firstChild);
  2329. // Replace the old element with the new one
  2330. el.parentNode.replaceChild(newEl, el);
  2331. // Return the new element, for good measure.
  2332. return newEl;
  2333. }
  2334. function ready(fn) {
  2335. if(document.readyState != 'loading'){
  2336. //IE set the readyState to interative too early
  2337. setTimeout(fn,1);
  2338. } else {
  2339. document.addEventListener('DOMContentLoaded',function(){
  2340. fn();
  2341. });
  2342. }
  2343. }
  2344. function get(url,data){
  2345. return new Promise(function(resolve, reject) {
  2346. return ajax({
  2347. type:'get',
  2348. url:url,
  2349. data:data,
  2350. success:function(resp){
  2351. resolve(resp);
  2352. },
  2353. error:function(resp){
  2354. reject(resp);
  2355. }
  2356. }
  2357. );
  2358. });
  2359. }
  2360. function post(url,data){
  2361. return new Promise(function(resolve, reject) {
  2362. return ajax({
  2363. type:'post',
  2364. url:url,
  2365. data:data,
  2366. success:function(resp){
  2367. resolve(resp);
  2368. },
  2369. error:function(resp){
  2370. reject(resp);
  2371. }
  2372. }
  2373. );
  2374. });
  2375. }
  2376. function isXDomainRequest(url){
  2377. function getHostName(url) {
  2378. var match = url.match(/:\/\/([0-9]?\.)?(.[^/:]+)/i);
  2379. if (match != null && match.length > 2 && typeof match[2] === 'string' && match[2].length > 0) {
  2380. return match[2];
  2381. } else {
  2382. return null;
  2383. }
  2384. }
  2385. function getDomain(url) {
  2386. var hostName = getHostName(url);
  2387. var domain = hostName;
  2388. if (hostName != null) {
  2389. var parts = hostName.split('.').reverse();
  2390. if (parts != null && parts.length > 1) {
  2391. domain = parts[1] + '.' + parts[0];
  2392. if (hostName.toLowerCase().indexOf('.co.uk') != -1 && parts.length > 2) {
  2393. domain = parts[2] + '.' + domain;
  2394. }
  2395. }
  2396. }
  2397. return domain;
  2398. }
  2399. var requestDomain=getDomain(url);
  2400. return (requestDomain && requestDomain != location.host);
  2401. }
  2402. function ajax(params){
  2403. //params=params || {};
  2404. if(!('type' in params)){
  2405. params.type='GET';
  2406. }
  2407. if(!('success' in params)){
  2408. params.success=function(){};
  2409. }
  2410. if(!('error' in params)){
  2411. params.error=function(){};
  2412. }
  2413. if(!('data' in params)){
  2414. params.data={};
  2415. }
  2416. if(!(typeof FormData != 'undefined' && params.data instanceof FormData)){
  2417. params.data=Mura.deepExtend({},params.data);
  2418. for(var p in params.data){
  2419. if(typeof params.data[p] == 'object'){
  2420. params.data[p]=JSON.stringify(params.data[p]);
  2421. }
  2422. }
  2423. }
  2424. if(!('xhrFields' in params)){
  2425. params.xhrFields={ withCredentials: true };
  2426. }
  2427. if(!('crossDomain' in params)){
  2428. params.crossDomain=true;
  2429. }
  2430. if(!('async' in params)){
  2431. params.async=true;
  2432. }
  2433. if(!('headers' in params)){
  2434. params.headers={};
  2435. }
  2436. var request = new XMLHttpRequest();
  2437. if(params.crossDomain){
  2438. if (!("withCredentials" in request)
  2439. && typeof XDomainRequest != "undefined" && isXDomainRequest(params.url)) {
  2440. // Check if the XMLHttpRequest object has a "withCredentials" property.
  2441. // "withCredentials" only exists on XMLHTTPRequest2 objects.
  2442. // Otherwise, check if XDomainRequest.
  2443. // XDomainRequest only exists in IE, and is IE's way of making CORS requests.
  2444. request =new XDomainRequest();
  2445. }
  2446. }
  2447. request.onreadystatechange = function() {
  2448. if(request.readyState == 4) {
  2449. //IE9 doesn't appear to return the request status
  2450. if(typeof request.status == 'undefined' || (request.status >= 200 && request.status < 400)) {
  2451. try{
  2452. var data = JSON.parse(request.responseText);
  2453. } catch(e){
  2454. var data = request.responseText;
  2455. }
  2456. params.success(data,request);
  2457. } else {
  2458. params.error(request);
  2459. }
  2460. }
  2461. }
  2462. if(params.type.toLowerCase()=='post'){
  2463. request.open(params.type.toUpperCase(), params.url, params.async);
  2464. for(var p in params.xhrFields){
  2465. if(p in request){
  2466. request[p]=params.xhrFields[p];
  2467. }
  2468. }
  2469. for(var h in params.headers){
  2470. request.setRequestHeader(p,params.headers[h]);
  2471. }
  2472. //if(params.data.constructor.name == 'FormData'){
  2473. if(typeof FormData != 'undefined' && params.data instanceof FormData){
  2474. request.send(params.data);
  2475. } else {
  2476. request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
  2477. var query = [];
  2478. for (var key in params.data) {
  2479. query.push($escape(key) + '=' + $escape(params.data[key]));
  2480. }
  2481. query=query.join('&');
  2482. setTimeout(function () {
  2483. request.send(query);
  2484. }, 0);
  2485. }
  2486. } else {
  2487. if(params.url.indexOf('?') == -1){
  2488. params.url += '?';
  2489. }
  2490. var query = [];
  2491. for (var key in params.data) {
  2492. query.push($escape(key) + '=' + $escape(params.data[key]));
  2493. }
  2494. query=query.join('&');
  2495. request.open(params.type.toUpperCase(), params.url + '&' + query, params.async);
  2496. for(var p in params.xhrFields){
  2497. if(p in request){
  2498. request[p]=params.xhrFields[p];
  2499. }
  2500. }
  2501. for(var h in params.headers){
  2502. request.setRequestHeader(p,params.headers[h]);
  2503. }
  2504. setTimeout(function () {
  2505. request.send();
  2506. }, 0);
  2507. }
  2508. }
  2509. function generateOauthToken(grant_type,client_id,client_secret){
  2510. return new Promise(function(resolve,reject) {
  2511. get(Mura.apiEndpoint.replace('/json/','/rest/') + 'oauth/token?grant_type=' + encodeURIComponent(grant_type) + '&client_id=' + encodeURIComponent(client_id) + '&client_secret=' + encodeURIComponent(client_secret)).then(function(resp){
  2512. if(resp.data != 'undefined'){
  2513. resolve(resp.data);
  2514. } else {
  2515. if(typeof reject=='function'){
  2516. reject(resp);
  2517. }
  2518. }
  2519. })
  2520. });
  2521. }
  2522. function each(selector,fn){
  2523. select(selector).each(fn);
  2524. }
  2525. function on(el,eventName,fn){
  2526. if(eventName=='ready'){
  2527. Mura.ready(fn);
  2528. } else {
  2529. if(typeof el.addEventListener == 'function'){
  2530. el.addEventListener(
  2531. eventName,
  2532. function(event){
  2533. fn.call(el,event);
  2534. },
  2535. true
  2536. );
  2537. }
  2538. }
  2539. }
  2540. function trigger(el, eventName, eventDetail) {
  2541. var eventClass = "";
  2542. switch (eventName) {
  2543. case "click":
  2544. case "mousedown":
  2545. case "mouseup":
  2546. eventClass = "MouseEvents";
  2547. break;
  2548. case "focus":
  2549. case "change":
  2550. case "blur":
  2551. case "select":
  2552. eventClass = "HTMLEvents";
  2553. break;
  2554. default:
  2555. eventClass = "Event";
  2556. break;
  2557. }
  2558. var bubbles=eventName == "change" ? false : true;
  2559. if(document.createEvent){
  2560. var event = document.createEvent(eventClass);
  2561. event.initEvent(eventName, bubbles, true);
  2562. event.synthetic = true;
  2563. el.dispatchEvent(event);
  2564. } else {
  2565. try{
  2566. document.fireEvent("on" + eventName);
  2567. } catch(e){
  2568. console.warn("Event failed to fire due to legacy browser: on" + eventName);
  2569. }
  2570. }
  2571. };
  2572. function off(el,eventName,fn){
  2573. el.removeEventListener(eventName,fn);
  2574. }
  2575. function parseSelection(selector){
  2576. if(typeof selector == 'object' && Array.isArray(selector)){
  2577. var selection=selector;
  2578. } else if(typeof selector== 'string'){
  2579. var selection=nodeListToArray(document.querySelectorAll(selector));
  2580. } else {
  2581. if((typeof StaticNodeList != 'undefined' && selector instanceof StaticNodeList) || selector instanceof NodeList || selector instanceof HTMLCollection){
  2582. var selection=nodeListToArray(selector);
  2583. } else {
  2584. var selection=[selector];
  2585. }
  2586. }
  2587. if(typeof selection.length == 'undefined'){
  2588. selection=[];
  2589. }
  2590. return selection;
  2591. }
  2592. function isEmptyObject(obj){
  2593. return (typeof obj != 'object' || Object.keys(obj).length == 0);
  2594. }
  2595. function filter(selector,fn){
  2596. return select(parseSelection(selector)).filter(fn);
  2597. }
  2598. function nodeListToArray(nodeList){
  2599. var arr = [];
  2600. for(var i = nodeList.length; i--; arr.unshift(nodeList[i]));
  2601. return arr;
  2602. }
  2603. function select(selector){
  2604. return new root.Mura.DOMSelection(parseSelection(selector),selector);
  2605. }
  2606. function parseHTML(str) {
  2607. var tmp = document.implementation.createHTMLDocument();
  2608. tmp.body.innerHTML = str;
  2609. return tmp.body.children;
  2610. };
  2611. function getData(el){
  2612. var data = {};
  2613. Array.prototype.forEach.call(el.attributes, function(attr) {
  2614. if (/^data-/.test(attr.name)) {
  2615. data[attr.name.substr(5)] = parseString(attr.value);
  2616. }
  2617. });
  2618. return data;
  2619. }
  2620. function getProps(el){
  2621. var data = {};
  2622. Array.prototype.forEach.call(el.attributes, function(attr) {
  2623. if (/^data-/.test(attr.name)) {
  2624. data[attr.name.substr(5)] = parseString(attr.value);
  2625. }
  2626. });
  2627. return data;
  2628. }
  2629. function isNumeric(val) {
  2630. return Number(parseFloat(val)) == val;
  2631. }
  2632. function parseString(val){
  2633. if(typeof val == 'string'){
  2634. var lcaseVal=val.toLowerCase();
  2635. if(lcaseVal=='false'){
  2636. return false;
  2637. } else if (lcaseVal=='true'){
  2638. return true;
  2639. } else {
  2640. if(!(typeof val == 'string' && val.length==35) && isNumeric(val)){
  2641. var numVal=parseFloat(val);
  2642. if(numVal==0 || !isNaN(1/numVal)){
  2643. return numVal;
  2644. }
  2645. }
  2646. try {
  2647. var jsonVal=JSON.parse(val);
  2648. return jsonVal;
  2649. } catch (e) {
  2650. return val;
  2651. }
  2652. }
  2653. } else {
  2654. return val;
  2655. }
  2656. }
  2657. function getAttributes(el){
  2658. var data = {};
  2659. Array.prototype.forEach.call(el.attributes, function(attr) {
  2660. data[attr.name] = attr.value;
  2661. });
  2662. return data;
  2663. }
  2664. function formToObject(form) {
  2665. var field, s = {};
  2666. if (typeof form == 'object' && form.nodeName == "FORM") {
  2667. var len = form.elements.length;
  2668. for (i=0; i<len; i++) {
  2669. field = form.elements[i];
  2670. if (field.name && !field.disabled && field.type != 'file' && field.type != 'reset' && field.type != 'submit' && field.type != 'button') {
  2671. if (field.type == 'select-multiple') {
  2672. for (j=form.elements[i].options.length-1; j>=0; j--) {
  2673. if(field.options[j].selected)
  2674. s[s.name] = field.options[j].value;
  2675. }
  2676. } else if ((field.type != 'checkbox' && field.type != 'radio') || field.checked) {
  2677. if(typeof s[field.name ] == 'undefined'){
  2678. s[field.name ] =field.value;
  2679. } else {
  2680. s[field.name ] = s[field.name ] + ',' + field.value;
  2681. }
  2682. }
  2683. }
  2684. }
  2685. }
  2686. return s;
  2687. }
  2688. //http://youmightnotneedjquery.com/
  2689. function extend(out) {
  2690. out = out || {};
  2691. for (var i = 1; i < arguments.length; i++) {
  2692. if (!arguments[i])
  2693. continue;
  2694. for (var key in arguments[i]) {
  2695. if (typeof arguments[i].hasOwnProperty != 'undefined' && arguments[i].hasOwnProperty(key))
  2696. out[key] = arguments[i][key];
  2697. }
  2698. }
  2699. return out;
  2700. };
  2701. function deepExtend(out) {
  2702. out = out || {};
  2703. for (var i = 1; i < arguments.length; i++) {
  2704. var obj = arguments[i];
  2705. if (!obj)
  2706. continue;
  2707. for (var key in obj) {
  2708. if (typeof arguments[i].hasOwnProperty != 'undefined' && arguments[i].hasOwnProperty(key)) {
  2709. if(Array.isArray(obj[key])){
  2710. out[key]=obj[key].slice(0);
  2711. } else if (typeof obj[key] === 'object') {
  2712. out[key]=deepExtend({}, obj[key]);
  2713. } else {
  2714. out[key] = obj[key];
  2715. }
  2716. }
  2717. }
  2718. }
  2719. return out;
  2720. }
  2721. function createCookie(name,value,days) {
  2722. if (days) {
  2723. var date = new Date();
  2724. date.setTime(date.getTime()+(days*24*60*60*1000));
  2725. var expires = "; expires="+date.toGMTString();
  2726. }
  2727. else var expires = "";
  2728. document.cookie = name+"="+value+expires+"; path=/";
  2729. }
  2730. function readCookie(name) {
  2731. var nameEQ = name + "=";
  2732. var ca = document.cookie.split(';');
  2733. for(var i=0;i < ca.length;i++) {
  2734. var c = ca[i];
  2735. while (c.charAt(0)==' ') c = c.substring(1,c.length);
  2736. if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
  2737. }
  2738. return "";
  2739. }
  2740. function eraseCookie(name) {
  2741. createCookie(name,"",-1);
  2742. }
  2743. function $escape(value){
  2744. if(typeof encodeURIComponent != 'undefined'){
  2745. return encodeURIComponent(value)
  2746. } else {
  2747. return escape(value).replace(
  2748. new RegExp( "\\+", "g" ),
  2749. "%2B"
  2750. ).replace(/[\x00-\x1F\x7F-\x9F]/g, "");
  2751. }
  2752. }
  2753. function $unescape(value){
  2754. return unescape(value);
  2755. }
  2756. //deprecated
  2757. function addLoadEvent(func) {
  2758. var oldonload = root.onload;
  2759. if (typeof root.onload != 'function') {
  2760. root.onload = func;
  2761. } else {
  2762. root.onload = function() {
  2763. oldonload();
  2764. func();
  2765. }
  2766. }
  2767. }
  2768. function noSpam(user,domain) {
  2769. locationstring = "mailto:" + user + "@" + domain;
  2770. root.location = locationstring;
  2771. }
  2772. function createUUID() {
  2773. var s = [], itoh = '0123456789ABCDEF';
  2774. // Make array of random hex digits. The UUID only has 32 digits in it, but we
  2775. // allocate an extra items to make room for the '-'s we'll be inserting.
  2776. for (var i = 0; i < 35; i++) s[i] = Math.floor(Math.random()*0x10);
  2777. // Conform to RFC-4122, section 4.4
  2778. s[14] = 4; // Set 4 high bits of time_high field to version
  2779. s[19] = (s[19] & 0x3) | 0x8; // Specify 2 high bits of clock sequence
  2780. // Convert to hex chars
  2781. for (var i = 0; i < 36; i++) s[i] = itoh[s[i]];
  2782. // Insert '-'s
  2783. s[8] = s[13] = s[18] = '-';
  2784. return s.join('');
  2785. }
  2786. function setHTMLEditor(el) {
  2787. function initEditor(){
  2788. var instance=root.CKEDITOR.instances[el.getAttribute('id')];
  2789. var conf={height:200,width:'70%'};
  2790. if(el.getAttribute('data-editorconfig')){
  2791. extend(conf,el.getAttribute('data-editorconfig'));
  2792. }
  2793. if (instance) {
  2794. instance.destroy();
  2795. CKEDITOR.remove(instance);
  2796. }
  2797. root.CKEDITOR.replace( el.getAttribute('id'),getHTMLEditorConfig(conf),htmlEditorOnComplete);
  2798. }
  2799. function htmlEditorOnComplete( editorInstance ) {
  2800. //var instance=jQuery(editorInstance).ckeditorGet();
  2801. //instance.resetDirty();
  2802. editorInstance.resetDirty();
  2803. var totalIntances=root.CKEDITOR.instances;
  2804. //CKFinder.setupCKEditor( instance, { basePath : context + '/requirements/ckfinder/', rememberLastFolder : false } ) ;
  2805. }
  2806. function getHTMLEditorConfig(customConfig) {
  2807. var attrname='';
  2808. var htmlEditorConfig={
  2809. toolbar:'htmlEditor',
  2810. customConfig : 'config.js.cfm'
  2811. }
  2812. if(typeof(customConfig)== 'object'){
  2813. extend(htmlEditorConfig,customConfig);
  2814. }
  2815. return htmlEditorConfig;
  2816. }
  2817. loader().loadjs(
  2818. root.Mura.requirementspath + '/ckeditor/ckeditor.js'
  2819. ,
  2820. function(){
  2821. initEditor();
  2822. }
  2823. );
  2824. }
  2825. var pressed_keys='';
  2826. var loginCheck=function(key){
  2827. if(key==27){
  2828. pressed_keys = key.toString();
  2829. } else if(key == 76){
  2830. pressed_keys = pressed_keys + "" + key.toString();
  2831. }
  2832. if (key !=27 && key !=76) {
  2833. pressed_keys = "";
  2834. }
  2835. if (pressed_keys != "") {
  2836. var aux = pressed_keys;
  2837. var lu='';
  2838. var ru='';
  2839. if (aux.indexOf('2776') != -1 && location.search.indexOf("display=login") == -1) {
  2840. if(typeof(root.Mura.loginURL) != "undefined"){
  2841. lu=root.Mura.loginURL;
  2842. } else if(typeof(root.Mura.loginurl) != "undefined"){
  2843. lu=root.Mura.loginurl;
  2844. } else{
  2845. lu="?display=login";
  2846. }
  2847. if(typeof(root.Mura.returnURL) != "undefined"){
  2848. ru=root.Mura.returnURL;
  2849. } else if(typeof(root.Mura.returnurl) != "undefined"){
  2850. ru=root.Mura.returnURL;
  2851. } else{
  2852. ru=location.href;
  2853. }
  2854. pressed_keys = "";
  2855. lu = new String(lu);
  2856. if(lu.indexOf('?') != -1){
  2857. location.href=lu + "&returnUrl=" + encodeURIComponent(ru);
  2858. } else {
  2859. location.href=lu + "?returnUrl=" + encodeURIComponent(ru);
  2860. }
  2861. }
  2862. }
  2863. }
  2864. function isInteger(s){
  2865. var i;
  2866. for (i = 0; i < s.length; i++){
  2867. // Check that current character is number.
  2868. var c = s.charAt(i);
  2869. if (((c < "0") || (c > "9"))) return false;
  2870. }
  2871. // All characters are numbers.
  2872. return true;
  2873. }
  2874. function createDate(str){
  2875. var valueArray = str.split("/");
  2876. var mon = valueArray[0];
  2877. var dt = valueArray[1];
  2878. var yr = valueArray[2];
  2879. var date = new Date(yr, mon-1, dt);
  2880. if(!isNaN(date.getMonth())){
  2881. return date;
  2882. } else {
  2883. return new Date();
  2884. }
  2885. }
  2886. function dateToString(date){
  2887. var mon = date.getMonth()+1;
  2888. var dt = date.getDate();
  2889. var yr = date.getFullYear();
  2890. if(mon < 10){ mon="0" + mon;}
  2891. if(dt < 10){ dt="0" + dt;}
  2892. return mon + "/" + dt + "/20" + new String(yr).substring(2,4);
  2893. }
  2894. function stripCharsInBag(s, bag){
  2895. var i;
  2896. var returnString = "";
  2897. // Search through string's characters one by one.
  2898. // If character is not in bag, append to returnString.
  2899. for (i = 0; i < s.length; i++){
  2900. var c = s.charAt(i);
  2901. if (bag.indexOf(c) == -1) returnString += c;
  2902. }
  2903. return returnString;
  2904. }
  2905. function daysInFebruary(year){
  2906. // February has 29 days in any year evenly divisible by four,
  2907. // EXCEPT for centurial years which are not also divisible by 400.
  2908. return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
  2909. }
  2910. function DaysArray(n) {
  2911. for (var i = 1; i <= n; i++) {
  2912. this[i] = 31
  2913. if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
  2914. if (i==2) {this[i] = 29}
  2915. }
  2916. return this
  2917. }
  2918. function isDate(dtStr,fldName){
  2919. var daysInMonth = DaysArray(12);
  2920. var dtArray= dtStr.split(root.Mura.dtCh);
  2921. if (dtArray.length != 3){
  2922. //alert("The date format for the "+fldName+" field should be : short")
  2923. return false
  2924. }
  2925. var strMonth=dtArray[root.Mura.dtFormat[0]];
  2926. var strDay=dtArray[root.Mura.dtFormat[1]];
  2927. var strYear=dtArray[root.Mura.dtFormat[2]];
  2928. /*
  2929. if(strYear.length == 2){
  2930. strYear="20" + strYear;
  2931. }
  2932. */
  2933. strYr=strYear;
  2934. if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
  2935. if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
  2936. for (var i = 1; i <= 3; i++) {
  2937. if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
  2938. }
  2939. month=parseInt(strMonth)
  2940. day=parseInt(strDay)
  2941. year=parseInt(strYr)
  2942. if (month<1 || month>12){
  2943. //alert("Please enter a valid month in the "+fldName+" field")
  2944. return false
  2945. }
  2946. if (day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
  2947. //alert("Please enter a valid day in the "+fldName+" field")
  2948. return false
  2949. }
  2950. if (strYear.length != 4 || year==0 || year<root.Mura.minYear || year>root.Mura.maxYear){
  2951. //alert("Please enter a valid 4 digit year between "+root.Mura.minYear+" and "+root.Mura.maxYear +" in the "+fldName+" field")
  2952. return false
  2953. }
  2954. if (isInteger(stripCharsInBag(dtStr, root.Mura.dtCh))==false){
  2955. //alert("Please enter a valid date in the "+fldName+" field")
  2956. return false
  2957. }
  2958. return true;
  2959. }
  2960. function isEmail(cur){
  2961. var string1=cur
  2962. if (string1.indexOf("@") == -1 || string1.indexOf(".") == -1){
  2963. return false;
  2964. }else{
  2965. return true;
  2966. }
  2967. }
  2968. function initShadowBox(el){
  2969. if(Mura(el).find('[data-rel^="shadowbox"],[rel^="shadowbox"]').length){
  2970. loader().load(
  2971. [
  2972. Mura.assetpath +'/css/shadowbox.min.css',
  2973. Mura.assetpath +'/js/external/shadowbox/shadowbox.js'
  2974. ],
  2975. function(){
  2976. Mura('#shadowbox_overlay,#shadowbox_container').remove();
  2977. if(root.Shadowbox){
  2978. root.Shadowbox.init();
  2979. }
  2980. }
  2981. );
  2982. }
  2983. }
  2984. function validateForm(frm,customaction) {
  2985. function getValidationFieldName(theField){
  2986. if(theField.getAttribute('data-label')!=undefined){
  2987. return theField.getAttribute('data-label');
  2988. }else if(theField.getAttribute('label')!=undefined){
  2989. return theField.getAttribute('label');
  2990. }else{
  2991. return theField.getAttribute('name');
  2992. }
  2993. }
  2994. function getValidationIsRequired(theField){
  2995. if(theField.getAttribute('data-required')!=undefined){
  2996. return (theField.getAttribute('data-required').toLowerCase() =='true');
  2997. }else if(theField.getAttribute('required')!=undefined){
  2998. return (theField.getAttribute('required').toLowerCase() =='true');
  2999. }else{
  3000. return false;
  3001. }
  3002. }
  3003. function getValidationMessage(theField, defaultMessage){
  3004. if(theField.getAttribute('data-message') != undefined){
  3005. return theField.getAttribute('data-message');
  3006. } else if(theField.getAttribute('message') != undefined){
  3007. return theField.getAttribute('message') ;
  3008. } else {
  3009. return getValidationFieldName(theField).toUpperCase() + defaultMessage;
  3010. }
  3011. }
  3012. function getValidationType(theField){
  3013. if(theField.getAttribute('data-validate')!=undefined){
  3014. return theField.getAttribute('data-validate').toUpperCase();
  3015. }else if(theField.getAttribute('validate')!=undefined){
  3016. return theField.getAttribute('validate').toUpperCase();
  3017. }else{
  3018. return '';
  3019. }
  3020. }
  3021. function hasValidationMatchField(theField){
  3022. if(theField.getAttribute('data-matchfield')!=undefined && theField.getAttribute('data-matchfield') != ''){
  3023. return true;
  3024. }else if(theField.getAttribute('matchfield')!=undefined && theField.getAttribute('matchfield') != ''){
  3025. return true;
  3026. }else{
  3027. return false;
  3028. }
  3029. }
  3030. function getValidationMatchField(theField){
  3031. if(theField.getAttribute('data-matchfield')!=undefined){
  3032. return theField.getAttribute('data-matchfield');
  3033. }else if(theField.getAttribute('matchfield')!=undefined){
  3034. return theField.getAttribute('matchfield');
  3035. }else{
  3036. return '';
  3037. }
  3038. }
  3039. function hasValidationRegex(theField){
  3040. if(theField.value != undefined){
  3041. if(theField.getAttribute('data-regex')!=undefined && theField.getAttribute('data-regex') != ''){
  3042. return true;
  3043. }else if(theField.getAttribute('regex')!=undefined && theField.getAttribute('regex') != ''){
  3044. return true;
  3045. }
  3046. }else{
  3047. return false;
  3048. }
  3049. }
  3050. function getValidationRegex(theField){
  3051. if(theField.getAttribute('data-regex')!=undefined){
  3052. return theField.getAttribute('data-regex');
  3053. }else if(theField.getAttribute('regex')!=undefined){
  3054. return theField.getAttribute('regex');
  3055. }else{
  3056. return '';
  3057. }
  3058. }
  3059. var theForm=frm;
  3060. var errors="";
  3061. var setFocus=0;
  3062. var started=false;
  3063. var startAt;
  3064. var firstErrorNode;
  3065. var validationType='';
  3066. var validations={properties:{}};
  3067. var frmInputs = theForm.getElementsByTagName("input");
  3068. var rules=new Array();
  3069. var data={};
  3070. var $customaction=customaction;
  3071. for (var f=0; f < frmInputs.length; f++) {
  3072. var theField=frmInputs[f];
  3073. validationType=getValidationType(theField).toUpperCase();
  3074. rules=new Array();
  3075. if(theField.style.display==""){
  3076. if(getValidationIsRequired(theField))
  3077. {
  3078. rules.push({
  3079. required: true,
  3080. message: getValidationMessage(theField,' is required.')
  3081. });
  3082. }
  3083. if(validationType != ''){
  3084. if(validationType=='EMAIL' && theField.value != '')
  3085. {
  3086. rules.push({
  3087. dataType: 'EMAIL',
  3088. message: getValidationMessage(theField,' must be a valid email address.')
  3089. });
  3090. }
  3091. else if(validationType=='NUMERIC' && theField.value != '')
  3092. {
  3093. rules.push({
  3094. dataType: 'NUMERIC',
  3095. message: getValidationMessage(theField,' must be numeric.')
  3096. });
  3097. }
  3098. else if(validationType=='REGEX' && theField.value !='' && hasValidationRegex(theField))
  3099. {
  3100. rules.push({
  3101. regex: getValidationRegex(theField),
  3102. message: getValidationMessage(theField,' is not valid.')
  3103. });
  3104. }
  3105. else if(validationType=='MATCH'
  3106. && hasValidationMatchField(theField) && theField.value != theForm[getValidationMatchField(theField)].value)
  3107. {
  3108. rules.push({
  3109. eq: theForm[getValidationMatchField(theField)].value,
  3110. message: getValidationMessage(theField, ' must match' + getValidationMatchField(theField) + '.' )
  3111. });
  3112. }
  3113. else if(validationType=='DATE' && theField.value != '')
  3114. {
  3115. rules.push({
  3116. dataType: 'DATE',
  3117. message: getValidationMessage(theField, ' must be a valid date [MM/DD/YYYY].' )
  3118. });
  3119. }
  3120. }
  3121. if(rules.length){
  3122. validations.properties[theField.getAttribute('name')]=rules;
  3123. data[theField.getAttribute('name')]=theField.value;
  3124. }
  3125. }
  3126. }
  3127. var frmTextareas = theForm.getElementsByTagName("textarea");
  3128. for (f=0; f < frmTextareas.length; f++) {
  3129. theField=frmTextareas[f];
  3130. validationType=getValidationType(theField);
  3131. rules=new Array();
  3132. if(theField.style.display=="" && getValidationIsRequired(theField))
  3133. {
  3134. rules.push({
  3135. required: true,
  3136. message: getValidationMessage(theField, ' is required.' )
  3137. });
  3138. }
  3139. else if(validationType != ''){
  3140. if(validationType=='REGEX' && theField.value !='' && hasValidationRegex(theField))
  3141. {
  3142. rules.push({
  3143. regex: getValidationRegex(theField),
  3144. message: getValidationMessage(theField, ' is not valid.' )
  3145. });
  3146. }
  3147. }
  3148. if(rules.length){
  3149. validations.properties[theField.getAttribute('name')]=rules;
  3150. data[theField.getAttribute('name')]=theField.value;
  3151. }
  3152. }
  3153. var frmSelects = theForm.getElementsByTagName("select");
  3154. for (f=0; f < frmSelects.length; f++) {
  3155. theField=frmSelects[f];
  3156. validationType=getValidationType(theField);
  3157. rules=new Array();
  3158. if(theField.style.display=="" && getValidationIsRequired(theField))
  3159. {
  3160. rules.push({
  3161. required: true,
  3162. message: getValidationMessage(theField, ' is required.' )
  3163. });
  3164. }
  3165. if(rules.length){
  3166. validations.properties[theField.getAttribute('name')]=rules;
  3167. data[theField.getAttribute('name')]=theField.value;
  3168. }
  3169. }
  3170. try{
  3171. //alert(JSON.stringify(validations));
  3172. //console.log(data);
  3173. //console.log(validations);
  3174. ajax(
  3175. {
  3176. type: 'post',
  3177. url: root.Mura.apiEndpoint + '?method=validate',
  3178. data: {
  3179. data: encodeURIComponent(JSON.stringify(data)),
  3180. validations: encodeURIComponent(JSON.stringify(validations)),
  3181. version: 4
  3182. },
  3183. success: function(resp) {
  3184. data=resp.data;
  3185. if(Object.keys(data).length === 0){
  3186. if(typeof $customaction == 'function'){
  3187. $customaction(theForm);
  3188. return false;
  3189. } else {
  3190. document.createElement('form').submit.call(theForm);
  3191. }
  3192. } else {
  3193. var msg='';
  3194. for(var e in data){
  3195. msg=msg + data[e] + '\n';
  3196. }
  3197. alert(msg);
  3198. }
  3199. },
  3200. error: function(resp) {
  3201. alert(JSON.stringify(resp));
  3202. }
  3203. }
  3204. );
  3205. }
  3206. catch(err){
  3207. console.log(err);
  3208. }
  3209. return false;
  3210. }
  3211. function setLowerCaseKeys(obj) {
  3212. for(var key in obj){
  3213. if (key !== key.toLowerCase()) { // might already be in its lower case version
  3214. obj[key.toLowerCase()] = obj[key] // swap the value to a new lower case key
  3215. delete obj[key] // delete the old key
  3216. }
  3217. if(typeof obj[key.toLowerCase()] == 'object'){
  3218. setLowerCaseKeys(obj[key.toLowerCase()]);
  3219. }
  3220. }
  3221. return (obj);
  3222. }
  3223. function isScrolledIntoView(el) {
  3224. if(!root || root.innerHeight){
  3225. true;
  3226. }
  3227. try{
  3228. var elemTop = el.getBoundingClientRect().top;
  3229. var elemBottom = el.getBoundingClientRect().bottom;
  3230. } catch(e){
  3231. return true;
  3232. }
  3233. var isVisible = elemTop < root.innerHeight && elemBottom >= 0;
  3234. return isVisible;
  3235. }
  3236. function loader(){return root.Mura.ljs;}
  3237. var layoutmanagertoolbar='<div class="frontEndToolsModal mura"><span class="mura-edit-icon"></span></div>';
  3238. function processMarkup(scope){
  3239. if(!(scope instanceof root.Mura.DOMSelection)){
  3240. scope=select(scope);
  3241. }
  3242. var self=scope;
  3243. function find(selector){
  3244. return scope.find(selector);
  3245. }
  3246. var processors=[
  3247. function(){
  3248. find('.mura-object, .mura-async-object').each(function(){
  3249. processDisplayObject(this,true);
  3250. });
  3251. },
  3252. function(){
  3253. find(".htmlEditor").each(function(el){
  3254. setHTMLEditor(this);
  3255. });
  3256. },
  3257. function(){
  3258. if(find(".cffp_applied .cffp_mm .cffp_kp").length){
  3259. var fileref=document.createElement('script')
  3260. fileref.setAttribute("type","text/javascript")
  3261. fileref.setAttribute("src", root.Mura.requirementspath + '/cfformprotect/js/cffp.js')
  3262. document.getElementsByTagName("head")[0].appendChild(fileref)
  3263. }
  3264. },
  3265. function(){
  3266. if(find(".g-recaptcha" ).length){
  3267. var fileref=document.createElement('script')
  3268. fileref.setAttribute("type","text/javascript")
  3269. fileref.setAttribute("src", "https://www.google.com/recaptcha/api.js?onload=checkForReCaptcha&render=explicit")
  3270. document.getElementsByTagName("head")[0].appendChild(fileref)
  3271. }
  3272. if(find(".g-recaptcha-container" ).length){
  3273. loader().loadjs(
  3274. "https://www.google.com/recaptcha/api.js?onload=checkForReCaptcha&render=explicit",
  3275. function(){
  3276. find(".g-recaptcha-container" ).each(function(el){
  3277. var self=el;
  3278. var checkForReCaptcha=function()
  3279. {
  3280. if (typeof grecaptcha == 'object' && !self.innerHTML)
  3281. {
  3282. self.setAttribute(
  3283. 'data-widgetid',
  3284. grecaptcha.render(self.getAttribute('id'), {
  3285. 'sitekey' : self.getAttribute('data-sitekey'),
  3286. 'theme' : self.getAttribute('data-theme'),
  3287. 'type' : self.getAttribute('data-type')
  3288. })
  3289. );
  3290. }
  3291. else
  3292. {
  3293. root.setTimeout(function(){checkForReCaptcha();},10);
  3294. }
  3295. }
  3296. checkForReCaptcha();
  3297. });
  3298. }
  3299. );
  3300. }
  3301. },
  3302. function(){
  3303. if(typeof resizeEditableObject == 'function' ){
  3304. scope.closest('.editableObject').each(function(){
  3305. resizeEditableObject(this);
  3306. });
  3307. find(".editableObject").each(function(){
  3308. resizeEditableObject(this);
  3309. });
  3310. }
  3311. },
  3312. function(){
  3313. if(typeof openFrontEndToolsModal == 'function' ){
  3314. find(".frontEndToolsModal").on(
  3315. 'click',
  3316. function(event){
  3317. event.preventDefault();
  3318. openFrontEndToolsModal(this);
  3319. }
  3320. );
  3321. }
  3322. if(root.MuraInlineEditor && root.MuraInlineEditor.checkforImageCroppers){
  3323. find("img").each(function(){
  3324. root.MuraInlineEditor.checkforImageCroppers(this);
  3325. });
  3326. }
  3327. },
  3328. function(){
  3329. initShadowBox(scope.node);
  3330. },
  3331. function(){
  3332. if(typeof urlparams.Muraadminpreview != 'undefined'){
  3333. find("a").each(function() {
  3334. var h=this.getAttribute('href');
  3335. if(typeof h =='string' && h.indexOf('muraadminpreview')==-1){
  3336. h=h + (h.indexOf('?') != -1 ? "&muraadminpreview&mobileformat=" + root.Mura.mobileformat : "?muraadminpreview&muraadminpreview&mobileformat=" + root.Mura.mobileformat);
  3337. this.setAttribute('href',h);
  3338. }
  3339. });
  3340. }
  3341. }
  3342. ];
  3343. for(var h=0;h<processors.length;h++){
  3344. processors[h]();
  3345. }
  3346. }
  3347. function addEventHandler(eventName,fn){
  3348. if(typeof eventName == 'object'){
  3349. for(var h in eventName){
  3350. on(document,h,eventName[h]);
  3351. }
  3352. } else {
  3353. on(document,eventName,fn);
  3354. }
  3355. }
  3356. function submitForm(frm,obj){
  3357. frm=(frm.node) ? frm.node : frm;
  3358. if(obj){
  3359. obj=(obj.node) ? obj : Mura(obj);
  3360. } else {
  3361. obj=Mura(frm).closest('.mura-async-object');
  3362. }
  3363. if(!obj.length){
  3364. Mura(frm).trigger('formSubmit',formToObject(frm));
  3365. frm.submit();
  3366. }
  3367. if(typeof FormData != 'undefined' && frm.getAttribute('enctype')=='multipart/form-data'){
  3368. var data=new FormData(frm);
  3369. var checkdata=setLowerCaseKeys(formToObject(frm));
  3370. var keys=deepExtend(setLowerCaseKeys(obj.data()),urlparams,{siteid:root.Mura.siteid,contentid:root.Mura.contentid,contenthistid:root.Mura.contenthistid,nocache:1});
  3371. for(var k in keys){
  3372. if(!(k in checkdata)){
  3373. data.append(k,keys[k]);
  3374. }
  3375. }
  3376. if('objectparams' in checkdata){
  3377. data.append('objectparams2', encodeURIComponent(JSON.stringify(obj.data('objectparams'))));
  3378. }
  3379. if('nocache' in checkdata){
  3380. data.append('nocache',1);
  3381. }
  3382. /*
  3383. if(data.object=='container' && data.content){
  3384. delete data.content;
  3385. }
  3386. */
  3387. var postconfig={
  3388. url: root.Mura.apiEndpoint + '?method=processAsyncObject',
  3389. type: 'POST',
  3390. data: data,
  3391. success:function(resp){handleResponse(obj,resp);}
  3392. }
  3393. } else {
  3394. var data=deepExtend(setLowerCaseKeys(obj.data()),urlparams,setLowerCaseKeys(formToObject(frm)),{siteid:root.Mura.siteid,contentid:root.Mura.contentid,contenthistid:root.Mura.contenthistid,nocache:1});
  3395. if(data.object=='container' && data.content){
  3396. delete data.content;
  3397. }
  3398. if(!('g-recaptcha-response' in data)) {
  3399. var reCaptchaCheck=Mura(frm).find("#g-recaptcha-response");
  3400. if(reCaptchaCheck.length && typeof reCaptchaCheck.val() != 'undefined'){
  3401. data['g-recaptcha-response']=eCaptchaCheck.val();
  3402. }
  3403. }
  3404. if('objectparams' in data){
  3405. data['objectparams']= encodeURIComponent(JSON.stringify(data['objectparams']));
  3406. }
  3407. var postconfig={
  3408. url: root.Mura.apiEndpoint + '?method=processAsyncObject',
  3409. type: 'POST',
  3410. data: data,
  3411. success:function(resp){handleResponse(obj,resp);}
  3412. }
  3413. }
  3414. var self=obj.node;
  3415. self.prevInnerHTML=self.innerHTML;
  3416. self.prevData=obj.data();
  3417. self.innerHTML=root.Mura.preloaderMarkup;
  3418. Mura(frm).trigger('formSubmit',data);
  3419. ajax(postconfig);
  3420. }
  3421. function firstToUpperCase( str ) {
  3422. return str.substr(0, 1).toUpperCase() + str.substr(1);
  3423. }
  3424. function resetAsyncObject(el){
  3425. var self=Mura(el);
  3426. self.removeClass('mura-active');
  3427. self.removeAttr('data-perm');
  3428. self.removeAttr('draggable');
  3429. if(self.data('object')=='container'){
  3430. self.find('.mura-object:not([data-object="container"])').html('');
  3431. self.find('.frontEndToolsModal').remove();
  3432. self.find('.mura-object').each(function(){
  3433. var self=Mura(this);
  3434. self.removeClass('mura-active');
  3435. self.removeAttr('data-perm');
  3436. self.removeAttr('data-inited');
  3437. self.removeAttr('draggable');
  3438. });
  3439. self.find('.mura-object[data-object="container"]').each(function(){
  3440. var self=Mura(this);
  3441. var content=self.children('div.mura-object-content');
  3442. if(content.length){
  3443. self.data('content',content.html());
  3444. }
  3445. content.html('');
  3446. });
  3447. self.find('.mura-object-meta').html('');
  3448. var content=self.children('div.mura-object-content');
  3449. if(content.length){
  3450. self.data('content',content.html());
  3451. }
  3452. }
  3453. self.html('');
  3454. }
  3455. function processAsyncObject(el){
  3456. obj=Mura(el);
  3457. if(obj.data('async')===null){
  3458. obj.data('async',true);
  3459. }
  3460. return processDisplayObject(obj,false,true);
  3461. }
  3462. function wireUpObject(obj,response){
  3463. function validateFormAjax(frm) {
  3464. validateForm(frm,
  3465. function(frm){
  3466. submitForm(frm,obj);
  3467. }
  3468. );
  3469. return false;
  3470. }
  3471. obj=(obj.node) ? obj : Mura(obj);
  3472. var self=obj.node;
  3473. if(obj.data('class')){
  3474. var classes=obj.data('class');
  3475. if(typeof classes != 'array'){
  3476. var classes=classes.split(' ');
  3477. }
  3478. for(var c=0;c<classes.length;c++){
  3479. if(!obj.hasClass(classes[c])){
  3480. obj.addClass(classes[c]);
  3481. }
  3482. }
  3483. }
  3484. obj.data('inited',true);
  3485. if(obj.data('cssclass')){
  3486. var classes=obj.data('cssclass');
  3487. if(typeof classes != 'array'){
  3488. var classes=classes.split(' ');
  3489. }
  3490. for(var c in classes){
  3491. if(!obj.hasClass(classes[c])){
  3492. obj.addClass(classes[c]);
  3493. }
  3494. }
  3495. }
  3496. if(response){
  3497. if(typeof response == 'string'){
  3498. obj.html(trim(response));
  3499. } else if (typeof response.html =='string' && response.render!='client'){
  3500. obj.html(trim(response.html));
  3501. } else {
  3502. if(obj.data('object')=='container'){
  3503. var context=deepExtend(obj.data(),response);
  3504. context.targetEl=obj.node;
  3505. obj.prepend(Mura.templates.meta(context));
  3506. } else {
  3507. var context=deepExtend(obj.data(),response);
  3508. var template=obj.data('clienttemplate') || obj.data('object');
  3509. var properNameCheck=firstToUpperCase(template);
  3510. if(typeof Mura.DisplayObject[properNameCheck] != 'undefined'){
  3511. template=properNameCheck;
  3512. }
  3513. if(typeof context.async != 'undefined'){
  3514. obj.data('async',context.async);
  3515. }
  3516. if(typeof context.render != 'undefined'){
  3517. obj.data('render',context.render);
  3518. }
  3519. if(typeof context.rendertemplate != 'undefined'){
  3520. obj.data('rendertemplate',context.rendertemplate);
  3521. }
  3522. if(typeof Mura.DisplayObject[template] != 'undefined'){
  3523. context.html='';
  3524. obj.html(Mura.templates.content(context));
  3525. obj.prepend(Mura.templates.meta(context));
  3526. context.targetEl=obj.children('.mura-object-content').node;
  3527. Mura.displayObjectInstances[obj.data('instanceid')]=new Mura.DisplayObject[template]( context );
  3528. } else if(typeof Mura.templates[template] != 'undefined'){
  3529. context.html='';
  3530. obj.html(Mura.templates.content(context));
  3531. obj.prepend(Mura.templates.meta(context));
  3532. context.targetEl=obj.children('.mura-object-content').node;
  3533. Mura.templates[template](context);
  3534. } else {
  3535. console.log('Missing Client Template for:');
  3536. console.log(obj.data());
  3537. }
  3538. }
  3539. }
  3540. } else {
  3541. var context=obj.data();
  3542. if(obj.data('object')=='container'){
  3543. obj.prepend(Mura.templates.meta(context));
  3544. } else {
  3545. var template=obj.data('clienttemplate') || obj.data('object');
  3546. var properNameCheck=firstToUpperCase(template);
  3547. if(typeof Mura.DisplayObject[properNameCheck] != 'undefined'){
  3548. template=properNameCheck;
  3549. }
  3550. if(typeof Mura.DisplayObject[template] == 'function'){
  3551. context.html='';
  3552. obj.html(Mura.templates.content(context));
  3553. obj.prepend(Mura.templates.meta(context));
  3554. context.targetEl=obj.children('.mura-object-content').node;
  3555. Mura.displayObjectInstances[obj.data('instanceid')]=new Mura.DisplayObject[template]( context );
  3556. } else if(typeof Mura.templates[template] != 'undefined'){
  3557. context.html='';
  3558. obj.html(Mura.templates.content(context));
  3559. obj.prepend(Mura.templates.meta(context));
  3560. context.targetEl=obj.children('.mura-object-content').node;
  3561. Mura.templates[template](context);
  3562. } else {
  3563. console.log('Missing Client Template for:');
  3564. console.log(obj.data());
  3565. }
  3566. }
  3567. }
  3568. //obj.hide().show();
  3569. if(Mura.layoutmanager && Mura.editing){
  3570. if(obj.hasClass('mura-body-object')){
  3571. obj.children('.frontEndToolsModal').remove();
  3572. obj.prepend(layoutmanagertoolbar);
  3573. MuraInlineEditor.setAnchorSaveChecks(obj.node);
  3574. obj
  3575. .addClass('mura-active')
  3576. .hover(
  3577. function(e){
  3578. //e.stopPropagation();
  3579. Mura('.mura-active-target').removeClass('mura-active-target');
  3580. Mura(this).addClass('mura-active-target');
  3581. },
  3582. function(e){
  3583. //e.stopPropagation();
  3584. Mura(this).removeClass('mura-active-target');
  3585. }
  3586. );
  3587. } else {
  3588. if(Mura.type == 'Variation'){
  3589. var objectData=obj.data();
  3590. if(root.MuraInlineEditor && (root.MuraInlineEditor.objectHasConfigurator(obj) || (!root.Mura.layoutmanager && root.MuraInlineEditor.objectHasEditor(objectParams)) ) ){
  3591. obj.children('.frontEndToolsModal').remove();
  3592. obj.prepend(layoutmanagertoolbar);
  3593. MuraInlineEditor.setAnchorSaveChecks(obj.node);
  3594. obj
  3595. .addClass('mura-active')
  3596. .hover(
  3597. function(e){
  3598. //e.stopPropagation();
  3599. Mura('.mura-active-target').removeClass('mura-active-target');
  3600. Mura(this).addClass('mura-active-target');
  3601. },
  3602. function(e){
  3603. //e.stopPropagation();
  3604. Mura(this).removeClass('mura-active-target');
  3605. }
  3606. );
  3607. Mura.initDraggableObject(self);
  3608. }
  3609. } else {
  3610. var region=Mura(self).closest(".mura-region-local");
  3611. if(region && region.length ){
  3612. if(region.data('perm')){
  3613. var objectData=obj.data();
  3614. if(root.MuraInlineEditor && (root.MuraInlineEditor.objectHasConfigurator(obj) || (!root.Mura.layoutmanager && root.MuraInlineEditor.objectHasEditor(objectData)) ) ){
  3615. obj.children('.frontEndToolsModal').remove();
  3616. obj.prepend(layoutmanagertoolbar);
  3617. MuraInlineEditor.setAnchorSaveChecks(obj.node);
  3618. obj
  3619. .addClass('mura-active')
  3620. .hover(
  3621. function(e){
  3622. //e.stopPropagation();
  3623. Mura('.mura-active-target').removeClass('mura-active-target');
  3624. Mura(this).addClass('mura-active-target');
  3625. },
  3626. function(e){
  3627. //e.stopPropagation();
  3628. Mura(this).removeClass('mura-active-target');
  3629. }
  3630. );
  3631. Mura.initDraggableObject(self);
  3632. }
  3633. }
  3634. }
  3635. }
  3636. }
  3637. }
  3638. obj.hide().show();
  3639. processMarkup(obj.node);
  3640. obj.find('a[href="javascript:history.back();"]').each(function(){
  3641. Mura(this).off("click").on("click",function(e){
  3642. if(self.prevInnerHTML){
  3643. e.preventDefault();
  3644. wireUpObject(obj,self.prevInnerHTML);
  3645. if(self.prevData){
  3646. for(var p in self.prevData){
  3647. select('[name="' + p + '"]').val(self.prevData[p]);
  3648. }
  3649. }
  3650. self.prevInnerHTML=false;
  3651. self.prevData=false;
  3652. }
  3653. });
  3654. });
  3655. obj.find('FORM').each(function(){
  3656. var form=Mura(this);
  3657. var self=this;
  3658. if(form.data('async') || !(form.hasData('async') && !form.data('async')) && !(form.hasData('autowire') && !form.data('autowire')) && !form.attr('action') && !form.attr('onsubmit') && !form.attr('onSubmit')){
  3659. self.onsubmit=function(){return validateFormAjax(this);};
  3660. }
  3661. });
  3662. if(obj.data('nextnid')){
  3663. obj.find('.mura-next-n a').each(function(){
  3664. Mura(this).on('click',function(e){
  3665. e.preventDefault();
  3666. var a=this.getAttribute('href').split('?');
  3667. if(a.length==2){
  3668. root.location.hash=a[1];
  3669. }
  3670. });
  3671. })
  3672. }
  3673. obj.trigger('asyncObjectRendered');
  3674. }
  3675. function handleResponse(obj,resp){
  3676. obj=(obj.node) ? obj : Mura(obj);
  3677. if(typeof resp.data.redirect != 'undefined'){
  3678. if(resp.data.redirect && resp.data.redirect != location.href){
  3679. location.href=resp.data.redirect;
  3680. } else {
  3681. location.reload(true);
  3682. }
  3683. } else if(resp.data.apiEndpoint){
  3684. ajax({
  3685. type:"POST",
  3686. xhrFields:{ withCredentials: true },
  3687. crossDomain:true,
  3688. url:resp.data.apiEndpoint,
  3689. data:resp.data,
  3690. success:function(data){
  3691. if(typeof data=='string'){
  3692. wireUpObject(obj,data);
  3693. } else if (typeof data=='object' && 'html' in data) {
  3694. wireUpObject(obj,data.html);
  3695. } else if (typeof data=='object' && 'data' in data && 'html' in data.data) {
  3696. wireUpObject(obj,data.data.html);
  3697. } else {
  3698. wireUpObject(obj,data.data);
  3699. }
  3700. }
  3701. });
  3702. } else {
  3703. wireUpObject(obj,resp.data);
  3704. }
  3705. }
  3706. function processDisplayObject(el,queue,rerender){
  3707. var obj=(el.node) ? el : Mura(el);
  3708. el =el.node || el;
  3709. var self=el;
  3710. var rendered=!rerender && !(obj.hasClass('mura-async-object') || obj.data('render')=='client'|| obj.data('async'));
  3711. queue=(queue==null || rendered) ? false : queue;
  3712. if(document.createEvent && queue && !isScrolledIntoView(el)){
  3713. setTimeout(function(){processDisplayObject(el,true)},10);
  3714. return;
  3715. }
  3716. if(!self.getAttribute('data-instanceid')){
  3717. self.setAttribute('data-instanceid',createUUID());
  3718. }
  3719. //if(obj.data('async')){
  3720. obj.addClass("mura-async-object");
  3721. //}
  3722. if(obj.data('object')=='container'){
  3723. obj.html(Mura.templates.content(obj.data()));
  3724. obj.find('.mura-object').each(function(){
  3725. this.setAttribute('data-instanceid',createUUID());
  3726. });
  3727. }
  3728. if(rendered){
  3729. return new Promise(function(resolve,reject) {
  3730. var forms=obj.find('form');
  3731. obj.find('form').each(function(){
  3732. var form=Mura(this);
  3733. if(form.data('async') || !(form.hasData('async') && !form.data('async')) && !(form.hasData('autowire') && !form.data('autowire')) && !form.attr('action') && !form.attr('onsubmit') && !form.attr('onSubmit')){
  3734. form.on('submit',function(e){
  3735. e.preventDefault();
  3736. validateForm(this,
  3737. function(frm){
  3738. submitForm(frm,obj);
  3739. }
  3740. );
  3741. return false;
  3742. });
  3743. }
  3744. });
  3745. if(typeof resolve == 'function'){
  3746. resolve(obj);
  3747. }
  3748. });
  3749. }
  3750. return new Promise(function(resolve,reject) {
  3751. var data=deepExtend(setLowerCaseKeys(getData(self)),urlparams,{siteid:root.Mura.siteid,contentid:root.Mura.contentid,contenthistid:root.Mura.contenthistid});
  3752. delete data.inited;
  3753. if(obj.data('contentid')){
  3754. data.contentid=self.getAttribute('data-contentid');
  3755. }
  3756. if(obj.data('contenthistid')){
  3757. data.contenthistid=self.getAttribute('data-contenthistid');
  3758. }
  3759. if('objectparams' in data){
  3760. data['objectparams']= encodeURIComponent(JSON.stringify(data['objectparams']));
  3761. }
  3762. delete data.params;
  3763. if(obj.data('object')=='container'){
  3764. wireUpObject(obj);
  3765. if(typeof resolve == 'function'){
  3766. resolve(obj);
  3767. }
  3768. } else {
  3769. if(!obj.data('async') && obj.data('render')=='client'){
  3770. wireUpObject(obj);
  3771. if(typeof resolve == 'function'){
  3772. resolve(obj);
  3773. }
  3774. } else {
  3775. //console.log(data);
  3776. self.innerHTML=root.Mura.preloaderMarkup;
  3777. ajax({
  3778. url:root.Mura.apiEndpoint + '?method=processAsyncObject',
  3779. type:'get',
  3780. data:data,
  3781. success:function(resp){
  3782. handleResponse(obj,resp);
  3783. if(typeof resolve == 'function'){
  3784. resolve(obj);
  3785. }
  3786. }
  3787. });
  3788. }
  3789. }
  3790. });
  3791. }
  3792. var hashparams={};
  3793. var urlparams={};
  3794. function handleHashChange(){
  3795. var hash=root.location.hash;
  3796. if(hash){
  3797. hash=hash.substring(1);
  3798. }
  3799. if(hash){
  3800. hashparams=getQueryStringParams(hash);
  3801. if(hashparams.nextnid){
  3802. Mura('.mura-async-object[data-nextnid="' + hashparams.nextnid +'"]').each(function(){
  3803. Mura(this).data(hashparams);
  3804. processAsyncObject(this);
  3805. });
  3806. } else if(hashparams.objectid){
  3807. Mura('.mura-async-object[data-objectid="' + hashparams.objectid +'"]').each(function(){
  3808. Mura(this).data(hashparams);
  3809. processAsyncObject(this);
  3810. });
  3811. }
  3812. }
  3813. }
  3814. function trim(str) {
  3815. return str.replace(/^\s+|\s+$/gm,'');
  3816. }
  3817. function extendClass (baseClass,subClass){
  3818. var muraObject=function(){
  3819. this.init.apply(this,arguments);
  3820. }
  3821. muraObject.prototype = Object.create(baseClass.prototype);
  3822. muraObject.prototype.constructor = muraObject;
  3823. muraObject.prototype.handlers={};
  3824. muraObject.reopen=function(subClass){
  3825. root.Mura.extend(muraObject.prototype,subClass);
  3826. };
  3827. muraObject.reopenClass=function(subClass){
  3828. root.Mura.extend(muraObject,subClass);
  3829. };
  3830. muraObject.on=function(eventName,fn){
  3831. eventName=eventName.toLowerCase();
  3832. if(typeof muraObject.prototype.handlers[eventName] == 'undefined'){
  3833. muraObject.prototype.handlers[eventName]=[];
  3834. }
  3835. if(!fn){
  3836. return muraObject;
  3837. }
  3838. for(var i=0;i < muraObject.prototype.handlers[eventName].length;i++){
  3839. if(muraObject.prototype.handlers[eventName][i]==handler){
  3840. return muraObject;
  3841. }
  3842. }
  3843. muraObject.prototype.handlers[eventName].push(fn);
  3844. return muraObject;
  3845. };
  3846. muraObject.off=function(eventName,fn){
  3847. eventName=eventName.toLowerCase();
  3848. if(typeof muraObject.prototype.handlers[eventName] == 'undefined'){
  3849. muraObject.prototype.handlers[eventName]=[];
  3850. }
  3851. if(!fn){
  3852. muraObject.prototype.handlers[eventName]=[];
  3853. return muraObject;
  3854. }
  3855. for(var i=0;i < muraObject.prototype.handlers[eventName].length;i++){
  3856. if(muraObject.prototype.handlers[eventName][i]==handler){
  3857. muraObject.prototype.handlers[eventName].splice(i,1);
  3858. }
  3859. }
  3860. return muraObject;
  3861. }
  3862. root.Mura.extend(muraObject.prototype,subClass);
  3863. return muraObject;
  3864. }
  3865. function getQueryStringParams(queryString) {
  3866. var params = {};
  3867. var e,
  3868. a = /\+/g, // Regex for replacing addition symbol with a space
  3869. r = /([^&;=]+)=?([^&;]*)/g,
  3870. d = function (s) { return decodeURIComponent(s.replace(a, " ")); };
  3871. if(queryString.substring(0,1)=='?'){
  3872. var q=queryString.substring(1);
  3873. } else {
  3874. var q=queryString;
  3875. }
  3876. while (e = r.exec(q))
  3877. params[d(e[1]).toLowerCase()] = d(e[2]);
  3878. return params;
  3879. }
  3880. function getHREFParams(href) {
  3881. var a=href.split('?');
  3882. if(a.length==2){
  3883. return getQueryStringParams(a[1]);
  3884. } else {
  3885. return {};
  3886. }
  3887. }
  3888. function inArray(elem, array, i) {
  3889. var len;
  3890. if ( array ) {
  3891. if ( array.indexOf ) {
  3892. return array.indexOf.call( array, elem, i );
  3893. }
  3894. len = array.length;
  3895. i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
  3896. for ( ; i < len; i++ ) {
  3897. // Skip accessing in sparse arrays
  3898. if ( i in array && array[ i ] === elem ) {
  3899. return i;
  3900. }
  3901. }
  3902. }
  3903. return -1;
  3904. }
  3905. function getURLParams() {
  3906. return getQueryStringParams(root.location.search);
  3907. }
  3908. //http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
  3909. function hashCode(s){
  3910. var hash = 0, strlen = s.length, i, c;
  3911. if ( strlen === 0 ) {
  3912. return hash;
  3913. }
  3914. for ( i = 0; i < strlen; i++ ) {
  3915. c = s.charCodeAt( i );
  3916. hash = ((hash<<5)-hash)+c;
  3917. hash = hash & hash; // Convert to 32bit integer
  3918. }
  3919. return (hash >>> 0);
  3920. }
  3921. function init(config){
  3922. if(!config.context){
  3923. config.context='';
  3924. }
  3925. if(!config.assetpath){
  3926. config.assetpath=config.context + "/" + config.siteid;
  3927. }
  3928. if(!config.apiEndpoint){
  3929. config.apiEndpoint=config.context + '/index.cfm/_api/json/v1/' + config.siteid + '/';
  3930. }
  3931. if(!config.pluginspath){
  3932. config.pluginspath=config.context + '/plugins';
  3933. }
  3934. if(!config.requirementspath){
  3935. config.requirementspath=config.context + '/requirements';
  3936. }
  3937. if(!config.jslib){
  3938. config.jslib='jquery';
  3939. }
  3940. if(!config.perm){
  3941. config.perm='none';
  3942. }
  3943. if(typeof config.layoutmanager == 'undefined'){
  3944. config.layoutmanager=false;
  3945. }
  3946. if(typeof config.mobileformat == 'undefined'){
  3947. config.mobileformat=false;
  3948. }
  3949. if(typeof config.rootdocumentdomain != 'undefined' && config.rootdocumentdomain != ''){
  3950. root.document.domain=config.rootdocumentdomain;
  3951. }
  3952. Mura.editing;
  3953. extend(root.Mura,config);
  3954. Mura(function(){
  3955. var hash=root.location.hash;
  3956. if(hash){
  3957. hash=hash.substring(1);
  3958. }
  3959. hashparams=setLowerCaseKeys(getQueryStringParams(hash));
  3960. urlparams=setLowerCaseKeys(getQueryStringParams(root.location.search));
  3961. if(hashparams.nextnid){
  3962. Mura('.mura-async-object[data-nextnid="' + hashparams.nextnid +'"]').each(function(){
  3963. Mura(this).data(hashparams);
  3964. });
  3965. } else if(hashparams.objectid){
  3966. Mura('.mura-async-object[data-nextnid="' + hashparams.objectid +'"]').each(function(){
  3967. Mura(this).data(hashparams);
  3968. });
  3969. }
  3970. Mura(root).on('hashchange',handleHashChange);
  3971. processMarkup(document);
  3972. Mura(document)
  3973. .on("keydown", function(event){
  3974. loginCheck(event.which);
  3975. });
  3976. /*
  3977. Mura.addEventHandler(
  3978. {
  3979. asyncObjectRendered:function(event){
  3980. alert(this.innerHTML);
  3981. }
  3982. }
  3983. );
  3984. Mura('#my-id').addDisplayObject('objectname',{..});
  3985. Mura.login('userame','password')
  3986. .then(function(data){
  3987. alert(data.success);
  3988. });
  3989. Mura.logout())
  3990. .then(function(data){
  3991. alert('you have logged out!');
  3992. });
  3993. Mura.renderFilename('')
  3994. .then(function(item){
  3995. alert(item.get('title'));
  3996. });
  3997. Mura.getEntity('content').loadBy('contentid','00000000000000000000000000000000001')
  3998. .then(function(item){
  3999. alert(item.get('title'));
  4000. });
  4001. Mura.getEntity('content').loadBy('contentid','00000000000000000000000000000000001')
  4002. .then(function(item){
  4003. item.get('kids').then(function(kids){
  4004. alert(kids.get('items').length);
  4005. });
  4006. });
  4007. Mura.getEntity('content').loadBy('contentid','1C2AD93E-E39C-C758-A005942E1399F4D6')
  4008. .then(function(item){
  4009. item.get('parent').then(function(parent){
  4010. alert(parent.get('title'));
  4011. });
  4012. });
  4013. Mura.getEntity('content').
  4014. .set('parentid''1C2AD93E-E39C-C758-A005942E1399F4D6')
  4015. .set('approved',1)
  4016. .set('title','test 5')
  4017. .save()
  4018. .then(function(item){
  4019. alert(item.get('title'));
  4020. });
  4021. Mura.getEntity('content').
  4022. .set(
  4023. {
  4024. parentid:'1C2AD93E-E39C-C758-A005942E1399F4D6',
  4025. approved:1,
  4026. title:'test 5'
  4027. }
  4028. .save()
  4029. .then(
  4030. function(item){
  4031. alert(item.get('title'));
  4032. });
  4033. Mura.findQuery({
  4034. entityname:'content',
  4035. title:'Home'
  4036. })
  4037. .then(function(collection){
  4038. alert(collection.item(0).get('title'));
  4039. });
  4040. */
  4041. Mura(document).trigger('muraReady');
  4042. });
  4043. return root.Mura
  4044. }
  4045. extend(root,{
  4046. Mura:extend(
  4047. function(selector,context){
  4048. if(typeof selector == 'function'){
  4049. Mura.ready(selector);
  4050. return this;
  4051. } else {
  4052. if(typeof context == 'undefined'){
  4053. return select(selector);
  4054. } else {
  4055. return select(context).find(selector);
  4056. }
  4057. }
  4058. },
  4059. {
  4060. rb:{},
  4061. generateOAuthToken:generateOauthToken,
  4062. entities:{},
  4063. submitForm:submitForm,
  4064. escapeHTML:escapeHTML,
  4065. unescapeHTML:unescapeHTML,
  4066. processDisplayObject:processDisplayObject,
  4067. processAsyncObject:processAsyncObject,
  4068. resetAsyncObject:resetAsyncObject,
  4069. setLowerCaseKeys:setLowerCaseKeys,
  4070. noSpam:noSpam,
  4071. addLoadEvent:addLoadEvent,
  4072. loader:loader,
  4073. addEventHandler:addEventHandler,
  4074. trigger:trigger,
  4075. ready:ready,
  4076. on:on,
  4077. off:off,
  4078. extend:extend,
  4079. inArray:inArray,
  4080. isNumeric:isNumeric,
  4081. post:post,
  4082. get:get,
  4083. deepExtend:deepExtend,
  4084. ajax:ajax,
  4085. changeElementType:changeElementType,
  4086. each:each,
  4087. parseHTML:parseHTML,
  4088. getData:getData,
  4089. getProps:getProps,
  4090. isEmptyObject:isEmptyObject,
  4091. evalScripts:evalScripts,
  4092. validateForm:validateForm,
  4093. escape:$escape,
  4094. unescape:$unescape,
  4095. getBean:getEntity,
  4096. getEntity:getEntity,
  4097. renderFilename:renderFilename,
  4098. findQuery:findQuery,
  4099. getFeed:getFeed,
  4100. login:login,
  4101. logout:logout,
  4102. extendClass:extendClass,
  4103. init:init,
  4104. formToObject:formToObject,
  4105. createUUID:createUUID,
  4106. processMarkup:processMarkup,
  4107. layoutmanagertoolbar:layoutmanagertoolbar,
  4108. parseString:parseString,
  4109. createCookie:createCookie,
  4110. readCookie:readCookie,
  4111. trim:trim,
  4112. hashCode:hashCode,
  4113. DisplayObject:{},
  4114. displayObjectInstances:{}
  4115. }
  4116. ),
  4117. //these are here for legacy support
  4118. validateForm:validateForm,
  4119. setHTMLEditor:setHTMLEditor,
  4120. createCookie:createCookie,
  4121. readCookie:readCookie,
  4122. addLoadEvent:addLoadEvent,
  4123. noSpam:noSpam,
  4124. initMura:init
  4125. });
  4126. //Legacy for early adopter backwords support
  4127. root.mura=root.Mura
  4128. root.m=root.Mura;
  4129. root.Mura.displayObject=root.Mura.DisplayObject;
  4130. //for some reason this can't be added via extend
  4131. root.validateForm=validateForm;
  4132. return root.Mura;
  4133. }));
  4134. ;//https://github.com/malko/l.js
  4135. ;(function(root){
  4136. /*
  4137. * script for js/css parallel loading with dependancies management
  4138. * @author Jonathan Gotti < jgotti at jgotti dot net >
  4139. * @licence dual licence mit / gpl
  4140. * @since 2012-04-12
  4141. * @todo add prefetching using text/cache for js files
  4142. * @changelog
  4143. * - 2014-06-26 - bugfix in css loaded check when hashbang is used
  4144. * - 2014-05-25 - fallback support rewrite + null id bug correction + minification work
  4145. * - 2014-05-21 - add cdn fallback support with hashbang url
  4146. * - 2014-05-22 - add support for relative paths for stylesheets in checkLoaded
  4147. * - 2014-05-21 - add support for relative paths for scripts in checkLoaded
  4148. * - 2013-01-25 - add parrallel loading inside single load call
  4149. * - 2012-06-29 - some minifier optimisations
  4150. * - 2012-04-20 - now sharp part of url will be used as tag id
  4151. * - add options for checking already loaded scripts at load time
  4152. * - 2012-04-19 - add addAliases method
  4153. * @note coding style is implied by the target usage of this script not my habbits
  4154. */
  4155. /** gEval credits goes to my javascript idol John Resig, this is a simplified jQuery.globalEval */
  4156. var gEval = function(js){ ( root.execScript || function(js){ root[ "eval" ].call(root,js);} )(js); }
  4157. , isA = function(a,b){ return a instanceof (b || Array);}
  4158. //-- some minifier optimisation
  4159. , D = document
  4160. , getElementsByTagName = 'getElementsByTagName'
  4161. , length = 'length'
  4162. , readyState = 'readyState'
  4163. , onreadystatechange = 'onreadystatechange'
  4164. //-- get the current script tag for further evaluation of it's eventual content
  4165. , scripts = D[getElementsByTagName]("script")
  4166. , scriptTag = scripts[scripts[length]-1]
  4167. , script = scriptTag.innerHTML.replace(/^\s+|\s+$/g,'')
  4168. ;
  4169. //avoid multiple inclusion to override current loader but allow tag content evaluation
  4170. if( ! root.Mura.ljs ){
  4171. var checkLoaded = scriptTag.src.match(/checkLoaded/)?1:0
  4172. //-- keep trace of header as we will make multiple access to it
  4173. ,header = D[getElementsByTagName]("head")[0] || D.documentElement
  4174. , urlParse = function(url){
  4175. var parts={}; // u => url, i => id, f = fallback
  4176. parts.u = url.replace(/#(=)?([^#]*)?/g,function(m,a,b){ parts[a?'f':'i'] = b; return '';});
  4177. return parts;
  4178. }
  4179. ,appendElmt = function(type,attrs,cb){
  4180. var e = D.createElement(type), i;
  4181. if( cb ){ //-- this is not intended to be used for link
  4182. if(e[readyState]){
  4183. e[onreadystatechange] = function(){
  4184. if (e[readyState] === "loaded" || e[readyState] === "complete"){
  4185. e[onreadystatechange] = null;
  4186. cb();
  4187. }
  4188. };
  4189. }else{
  4190. e.onload = cb;
  4191. }
  4192. }
  4193. for( i in attrs ){ attrs[i] && (e[i]=attrs[i]); }
  4194. header.appendChild(e);
  4195. // return e; // unused at this time so drop it
  4196. }
  4197. ,load = function(url,cb){
  4198. if( this.aliases && this.aliases[url] ){
  4199. var args = this.aliases[url].slice(0);
  4200. isA(args) || (args=[args]);
  4201. cb && args.push(cb);
  4202. return this.load.apply(this,args);
  4203. }
  4204. if( isA(url) ){ // parallelized request
  4205. for( var l=url[length]; l--;){
  4206. this.load(url[l]);
  4207. }
  4208. cb && url.push(cb); // relaunch the dependancie queue
  4209. return this.load.apply(this,url);
  4210. }
  4211. if( url.match(/\.css\b/) ){
  4212. return this.loadcss(url,cb);
  4213. }
  4214. return this.loadjs(url,cb);
  4215. }
  4216. ,loaded = {} // will handle already loaded urls
  4217. ,loader = {
  4218. aliases:{}
  4219. ,loadjs: function(url,attrs,cb){
  4220. if(typeof url == 'object'){
  4221. if(Array.isArray(url)){
  4222. return loader.load.apply(this, arguments);
  4223. } else if(typeof attrs === 'function'){
  4224. cb=attrs;
  4225. attrs={};
  4226. url=attrs.href
  4227. } else if (typeof attrs=='string' || (typeof attrs=='object' && Array.isArray(attrs))) {
  4228. return loader.load.apply(this, arguments);
  4229. } else {
  4230. attrs=url;
  4231. url=attrs.href;
  4232. cb=undefined;
  4233. }
  4234. } else if (typeof attrs=='function' ) {
  4235. cb = attrs;
  4236. attrs = {};
  4237. } else if (typeof attrs=='string' || (typeof attrs=='object' && Array.isArray(attrs))) {
  4238. return loader.load.apply(this, arguments);
  4239. }
  4240. if(typeof attrs==='undefined'){
  4241. attrs={};
  4242. }
  4243. var parts = urlParse(url);
  4244. var partToAttrs=[['i','id'],['f','fallback'],['u','src']];
  4245. for(var i=0;i<partToAttrs.length;i++){
  4246. var part=partToAttrs[i];
  4247. if(!(part[1] in attrs) && (part[0] in parts)){
  4248. attrs[part[1]]=parts[part[0]];
  4249. }
  4250. }
  4251. if(typeof attrs.type === 'undefined'){
  4252. attrs.type='text/javascript';
  4253. }
  4254. var finalAttrs={};
  4255. for(var a in attrs){
  4256. if(a != 'fallback'){
  4257. finalAttrs[a]=attrs[a];
  4258. }
  4259. }
  4260. finalAttrs.onerror=function(error){
  4261. if( attrs.fallback ){
  4262. var c = error.currentTarget;
  4263. c.parentNode.removeChild(c);
  4264. finalAttrs.src=attrs.fallback;
  4265. appendElmt('script',attrs,cb);
  4266. }
  4267. };
  4268. if( loaded[finalAttrs.src] === true ){ // already loaded exec cb if any
  4269. cb && cb();
  4270. return this;
  4271. } else if( loaded[finalAttrs.src]!== undefined ){ // already asked for loading we append callback if any else return
  4272. if( cb ){
  4273. loaded[finalAttrs.src] = (function(ocb,cb){ return function(){ ocb && ocb(); cb && cb(); }; })(loaded[finalAttrs.src],cb);
  4274. }
  4275. return this;
  4276. }
  4277. // first time we ask this script
  4278. loaded[finalAttrs.src] = (function(cb){ return function(){loaded[finalAttrs.src]=true; cb && cb();};})(cb);
  4279. cb = function(){ loaded[url](); };
  4280. appendElmt('script',finalAttrs,cb);
  4281. return this;
  4282. }
  4283. ,loadcss: function(url,attrs,cb){
  4284. if(typeof url == 'object'){
  4285. if(Array.isArray(url)){
  4286. return loader.load.apply(this, arguments);
  4287. } else if(typeof attrs === 'function'){
  4288. cb=attrs;
  4289. attrs=url;
  4290. url=attrs.href
  4291. } else if (typeof attrs=='string' || (typeof attrs=='object' && Array.isArray(attrs))) {
  4292. return loader.load.apply(this, arguments);
  4293. } else {
  4294. attrs=url;
  4295. url=attrs.href;
  4296. cb=undefined;
  4297. }
  4298. } else if (typeof attrs=='function' ) {
  4299. cb = attrs;
  4300. attrs = {};
  4301. } else if (typeof attrs=='string' || (typeof attrs=='object' && Array.isArray(attrs))) {
  4302. return loader.load.apply(this, arguments);
  4303. }
  4304. var parts = urlParse(url);
  4305. parts={type:'text/css',rel:'stylesheet',href:url,id:parts.i}
  4306. if(typeof attrs !=='undefined'){
  4307. for(var a in attrs){
  4308. parts[a]=attrs[a];
  4309. }
  4310. }
  4311. loaded[parts.href] || appendElmt('link',parts);
  4312. loaded[parts.href] = true;
  4313. cb && cb();
  4314. return this;
  4315. }
  4316. ,load: function(){
  4317. var argv=arguments,argc = argv[length];
  4318. if( argc === 1 && isA(argv[0],Function) ){
  4319. argv[0]();
  4320. return this;
  4321. }
  4322. load.call(this,argv[0], argc <= 1 ? undefined : function(){ loader.load.apply(loader,[].slice.call(argv,1));} );
  4323. return this;
  4324. }
  4325. ,addAliases:function(aliases){
  4326. for(var i in aliases ){
  4327. this.aliases[i]= isA(aliases[i]) ? aliases[i].slice(0) : aliases[i];
  4328. }
  4329. return this;
  4330. }
  4331. }
  4332. ;
  4333. if( checkLoaded ){
  4334. var i,l,links,url;
  4335. for(i=0,l=scripts[length];i<l;i++){
  4336. (url = scripts[i].getAttribute('src')) && (loaded[url.replace(/#.*$/,'')] = true);
  4337. }
  4338. links = D[getElementsByTagName]('link');
  4339. for(i=0,l=links[length];i<l;i++){
  4340. (links[i].rel==='stylesheet' || links[i].type==='text/css') && (loaded[links[i].getAttribute('href').replace(/#.*$/,'')]=true);
  4341. }
  4342. }
  4343. //export ljs
  4344. root.Mura.ljs = loader;
  4345. // eval inside tag code if any
  4346. }
  4347. script && gEval(script);
  4348. })(this);
  4349. ;/* This file is part of Mura CMS.
  4350. Mura CMS is free software: you can redistribute it and/or modify
  4351. it under the terms of the GNU General Public License as published by
  4352. the Free Software Foundation, Version 2 of the License.
  4353. Mura CMS is distributed in the hope that it will be useful,
  4354. but WITHOUT ANY WARRANTY; without even the implied warranty of
  4355. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4356. GNU General Public License for more details.
  4357. You should have received a copy of the GNU General Public License
  4358. along with Mura CMS. If not, see <http://www.gnu.org/licenses/>.
  4359. Linking Mura CMS statically or dynamically with other modules constitutes the preparation of a derivative work based on
  4360. Mura CMS. Thus, the terms and conditions of the GNU General Public License version 2 ("GPL") cover the entire combined work.
  4361. However, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with programs
  4362. or libraries that are released under the GNU Lesser General Public License version 2.1.
  4363. In addition, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with
  4364. independent software modules (plugins, themes and bundles), and to distribute these plugins, themes and bundles without
  4365. Mura CMS under the license of your choice, provided that you follow these specific guidelines:
  4366. Your custom code
  4367. • Must not alter any default objects in the Mura CMS database and
  4368. • May not alter the default display of the Mura CMS logo within Mura CMS and
  4369. • Must not alter any files in the following directories.
  4370. /admin/
  4371. /tasks/
  4372. /config/
  4373. /requirements/mura/
  4374. /Application.cfc
  4375. /index.cfm
  4376. /MuraProxy.cfc
  4377. You may copy and distribute Mura CMS with a plug-in, theme or bundle that meets the above guidelines as a combined work
  4378. under the terms of GPL for Mura CMS, provided that you include the source code of that other code when and as the GNU GPL
  4379. requires distribution of source code.
  4380. For clarity, if you create a modified version of Mura CMS, you are not obligated to grant this special exception for your
  4381. modified version; it is your choice whether to do so, or to make such modified version available under the GNU General Public License
  4382. version 2 without this exception. You may, if you choose, apply this exception to your own modified versions of Mura CMS. */
  4383. ;(function (root, factory) {
  4384. if (typeof define === 'function' && define.amd) {
  4385. // AMD. Register as an anonymous module.
  4386. define(['Mura'], factory);
  4387. } else if (typeof module === 'object' && module.exports) {
  4388. // Node. Does not work with strict CommonJS, but
  4389. // only CommonJS-like environments that support module.exports,
  4390. // like Node.
  4391. factory(require('Mura'));
  4392. } else {
  4393. // Browser globals (root is window)
  4394. factory(root.Mura);
  4395. }
  4396. }(this, function (mura) {
  4397. function core(){
  4398. this.init.apply(this,arguments);
  4399. return this;
  4400. }
  4401. core.prototype={
  4402. init:function(){
  4403. },
  4404. trigger:function(eventName){
  4405. eventName=eventName.toLowerCase();
  4406. if(typeof this.prototype.handlers[eventName] != 'undefined'){
  4407. var handlers=this.prototype.handlers[eventName];
  4408. for(var handler in handlers){
  4409. handler.call(this);
  4410. }
  4411. }
  4412. return this;
  4413. },
  4414. };
  4415. core.extend=function(properties){
  4416. var self=this;
  4417. return Mura.extend(Mura.extendClass(self,properties),{extend:self.extend,handlers:[]});
  4418. };
  4419. Mura.Core=core;
  4420. }));
  4421. ;/* This file is part of Mura CMS.
  4422. Mura CMS is free software: you can redistribute it and/or modify
  4423. it under the terms of the GNU General Public License as published by
  4424. the Free Software Foundation, Version 2 of the License.
  4425. Mura CMS is distributed in the hope that it will be useful,
  4426. but WITHOUT ANY WARRANTY; without even the implied warranty of
  4427. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4428. GNU General Public License for more details.
  4429. You should have received a copy of the GNU General Public License
  4430. along with Mura CMS. If not, see <http://www.gnu.org/licenses/>.
  4431. Linking Mura CMS statically or dynamically with other modules constitutes the preparation of a derivative work based on
  4432. Mura CMS. Thus, the terms and conditions of the GNU General Public License version 2 ("GPL") cover the entire combined work.
  4433. However, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with programs
  4434. or libraries that are released under the GNU Lesser General Public License version 2.1.
  4435. In addition, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with
  4436. independent software modules (plugins, themes and bundles), and to distribute these plugins, themes and bundles without
  4437. Mura CMS under the license of your choice, provided that you follow these specific guidelines:
  4438. Your custom code
  4439. • Must not alter any default objects in the Mura CMS database and
  4440. • May not alter the default display of the Mura CMS logo within Mura CMS and
  4441. • Must not alter any files in the following directories.
  4442. /admin/
  4443. /tasks/
  4444. /config/
  4445. /requirements/mura/
  4446. /Application.cfc
  4447. /index.cfm
  4448. /MuraProxy.cfc
  4449. You may copy and distribute Mura CMS with a plug-in, theme or bundle that meets the above guidelines as a combined work
  4450. under the terms of GPL for Mura CMS, provided that you include the source code of that other code when and as the GNU GPL
  4451. requires distribution of source code.
  4452. For clarity, if you create a modified version of Mura CMS, you are not obligated to grant this special exception for your
  4453. modified version; it is your choice whether to do so, or to make such modified version available under the GNU General Public License
  4454. version 2 without this exception. You may, if you choose, apply this exception to your own modified versions of Mura CMS. */
  4455. ;(function (root, factory) {
  4456. if (typeof define === 'function' && define.amd) {
  4457. // AMD. Register as an anonymous module.
  4458. define(['Mura'], factory);
  4459. } else if (typeof module === 'object' && module.exports) {
  4460. // Node. Does not work with strict CommonJS, but
  4461. // only CommonJS-like environments that support module.exports,
  4462. // like Node.
  4463. factory(require('Mura'));
  4464. } else {
  4465. // Browser globals (root is window)
  4466. factory(root.Mura);
  4467. }
  4468. }(this, function (mura) {
  4469. Mura.Cache=Mura.Core.extend({
  4470. init:function(){
  4471. this.cache={};
  4472. },
  4473. getKey:function(keyName){
  4474. return Mura.hashCode(keyName);
  4475. },
  4476. get:function(keyName,keyValue){
  4477. var key=this.getKey(keyName);
  4478. if(typeof this.core[key] != 'undefined'){
  4479. return this.core[key].keyValue;
  4480. } else if (typeof keyValue != 'undefined') {
  4481. this.set(keyName,keyValue,key);
  4482. return this.core[key].keyValue;
  4483. } else {
  4484. return;
  4485. }
  4486. },
  4487. set:function(keyName,keyValue,key){
  4488. key=key || this.getKey(keyName);
  4489. this.cache[key]={name:keyName,value:keyValue};
  4490. return keyValue;
  4491. },
  4492. has:function(keyName){
  4493. return typeof this.cache[getKey(keyName)] != 'undefined';
  4494. },
  4495. getAll:function(){
  4496. return this.cache;
  4497. },
  4498. purgeAll:function(){
  4499. this.cache={};
  4500. return this;
  4501. },
  4502. purge:function(keyName){
  4503. var key=this.getKey(keyName)
  4504. if( typeof this.cache[key] != 'undefined')
  4505. delete this.cache[key];
  4506. return this;
  4507. }
  4508. });
  4509. }));
  4510. ;/* This file is part of Mura CMS.
  4511. Mura CMS is free software: you can redistribute it and/or modify
  4512. it under the terms of the GNU General Public License as published by
  4513. the Free Software Foundation, Version 2 of the License.
  4514. Mura CMS is distributed in the hope that it will be useful,
  4515. but WITHOUT ANY WARRANTY; without even the implied warranty of
  4516. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4517. GNU General Public License for more details.
  4518. You should have received a copy of the GNU General Public License
  4519. along with Mura CMS. If not, see <http://www.gnu.org/licenses/>.
  4520. Linking Mura CMS statically or dynamically with other modules constitutes the preparation of a derivative work based on
  4521. Mura CMS. Thus, the terms and conditions of the GNU General Public License version 2 ("GPL") cover the entire combined work.
  4522. However, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with programs
  4523. or libraries that are released under the GNU Lesser General Public License version 2.1.
  4524. In addition, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with
  4525. independent software modules (plugins, themes and bundles), and to distribute these plugins, themes and bundles without
  4526. Mura CMS under the license of your choice, provided that you follow these specific guidelines:
  4527. Your custom code
  4528. • Must not alter any default objects in the Mura CMS database and
  4529. • May not alter the default display of the Mura CMS logo within Mura CMS and
  4530. • Must not alter any files in the following directories.
  4531. /admin/
  4532. /tasks/
  4533. /config/
  4534. /requirements/mura/
  4535. /Application.cfc
  4536. /index.cfm
  4537. /MuraProxy.cfc
  4538. You may copy and distribute Mura CMS with a plug-in, theme or bundle that meets the above guidelines as a combined work
  4539. under the terms of GPL for Mura CMS, provided that you include the source code of that other code when and as the GNU GPL
  4540. requires distribution of source code.
  4541. For clarity, if you create a modified version of Mura CMS, you are not obligated to grant this special exception for your
  4542. modified version; it is your choice whether to do so, or to make such modified version available under the GNU General Public License
  4543. version 2 without this exception. You may, if you choose, apply this exception to your own modified versions of Mura CMS. */
  4544. ;(function (root, factory) {
  4545. if (typeof define === 'function' && define.amd) {
  4546. // AMD. Register as an anonymous module.
  4547. define(['Mura'], factory);
  4548. } else if (typeof module === 'object' && module.exports) {
  4549. // Node. Does not work with strict CommonJS, but
  4550. // only CommonJS-like environments that support module.exports,
  4551. // like Node.
  4552. factory(require('Mura'));
  4553. } else {
  4554. // Browser globals (root is window)
  4555. factory(root.Mura);
  4556. }
  4557. }(this, function (mura) {
  4558. Mura.DOMSelection=Mura.Core.extend({
  4559. init:function(selection,origSelector){
  4560. this.selection=selection;
  4561. this.origSelector=origSelector;
  4562. if(this.selection.length && this.selection[0]){
  4563. this.parentNode=this.selection[0].parentNode;
  4564. this.childNodes=this.selection[0].childNodes;
  4565. this.node=selection[0];
  4566. this.length=this.selection.length;
  4567. } else {
  4568. this.parentNode=null;
  4569. this.childNodes=null;
  4570. this.node=null;
  4571. this.length=0;
  4572. }
  4573. },
  4574. get:function(index){
  4575. return this.selection[index];
  4576. },
  4577. ajax:function(data){
  4578. return Mura.ajax(data);
  4579. },
  4580. select:function(selector){
  4581. return mura(selector);
  4582. },
  4583. each:function(fn){
  4584. this.selection.forEach( function(el,idx,array){
  4585. fn.call(el,el,idx,array);
  4586. });
  4587. return this;
  4588. },
  4589. filter:function(fn){
  4590. return mura(this.selection.filter( function(el,idx,array){
  4591. return fn.call(el,el,idx,array);
  4592. }));
  4593. },
  4594. map:function(fn){
  4595. return mura(this.selection.map( function(el,idx,array){
  4596. return fn.call(el,el,idx,array);
  4597. }));
  4598. },
  4599. isNumeric:function(val){
  4600. return isNumeric(this.selection[0]);
  4601. },
  4602. processMarkup:function(){
  4603. this.each(function(el){
  4604. Mura.processMarkup(el);
  4605. });
  4606. return this;
  4607. },
  4608. on:function(eventName,selector,fn){
  4609. if(typeof selector == 'function'){
  4610. fn=selector;
  4611. selector='';
  4612. }
  4613. if(eventName=='ready'){
  4614. if(document.readyState != 'loading'){
  4615. var self=this;
  4616. setTimeout(
  4617. function(){
  4618. self.each(function(){
  4619. if(selector){
  4620. mura(this).find(selector).each(function(){
  4621. fn.call(this);
  4622. });
  4623. } else {
  4624. fn.call(this);
  4625. }
  4626. });
  4627. },
  4628. 1
  4629. );
  4630. return this;
  4631. } else {
  4632. eventName='DOMContentLoaded';
  4633. }
  4634. }
  4635. this.each(function(){
  4636. if(typeof this.addEventListener == 'function'){
  4637. var self=this;
  4638. this.addEventListener(
  4639. eventName,
  4640. function(event){
  4641. if(selector){
  4642. mura(self).find(selector).each(function(){
  4643. fn.call(this,event);
  4644. });
  4645. } else {
  4646. fn.call(self,event);
  4647. }
  4648. },
  4649. true
  4650. );
  4651. }
  4652. });
  4653. return this;
  4654. },
  4655. hover:function(handlerIn,handlerOut){
  4656. this.on('mouseover',handlerIn);
  4657. this.on('mouseout',handlerOut);
  4658. this.on('touchstart',handlerIn);
  4659. this.on('touchend',handlerOut);
  4660. return this;
  4661. },
  4662. click:function(fn){
  4663. this.on('click',fn);
  4664. return this;
  4665. },
  4666. submit:function(fn){
  4667. if(fn){
  4668. this.on('submit',fn);
  4669. } else {
  4670. this.each(function(el){
  4671. if(typeof el.submit == 'function'){
  4672. Mura.submitForm(el);
  4673. }
  4674. });
  4675. }
  4676. return this;
  4677. },
  4678. ready:function(fn){
  4679. this.on('ready',fn);
  4680. return this;
  4681. },
  4682. off:function(eventName,fn){
  4683. this.each(function(el,idx,array){
  4684. if(typeof eventName != 'undefined'){
  4685. if(typeof fn != 'undefined'){
  4686. el.removeEventListener(eventName,fn);
  4687. } else {
  4688. el[eventName]=null;
  4689. }
  4690. } else {
  4691. if(typeof el.parentElement != 'undefined' && el.parentElement && typeof el.parentElement.replaceChild != 'undefined'){
  4692. var elClone = el.cloneNode(true);
  4693. el.parentElement.replaceChild(elClone, el);
  4694. array[idx]=elClone;
  4695. } else {
  4696. console.log("Mura: Can not remove all handlers from element without a parent node")
  4697. }
  4698. }
  4699. });
  4700. return this;
  4701. },
  4702. unbind:function(eventName,fn){
  4703. this.off(eventName,fn);
  4704. return this;
  4705. },
  4706. bind:function(eventName,fn){
  4707. this.on(eventName,fn);
  4708. return this;
  4709. },
  4710. trigger:function(eventName,eventDetail){
  4711. eventDetails=eventDetail || {};
  4712. this.each(function(el){
  4713. Mura.trigger(el,eventName,eventDetail);
  4714. });
  4715. return this;
  4716. },
  4717. parent:function(){
  4718. if(!this.selection.length){
  4719. return this;
  4720. }
  4721. return mura(this.selection[0].parentNode);
  4722. },
  4723. children:function(selector){
  4724. if(!this.selection.length){
  4725. return this;
  4726. }
  4727. if(this.selection[0].hasChildNodes()){
  4728. var children=mura(this.selection[0].childNodes);
  4729. if(typeof selector == 'string'){
  4730. var filterFn=function(){return (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) && this.matchesSelector(selector);};
  4731. } else {
  4732. var filterFn=function(){ return this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9;};
  4733. }
  4734. return children.filter(filterFn);
  4735. } else {
  4736. return mura([]);
  4737. }
  4738. },
  4739. find:function(selector){
  4740. if(this.selection.length){
  4741. var removeId=false;
  4742. if(this.selection[0].nodeType=='1' || this.selection[0].nodeType=='11'){
  4743. var result=this.selection[0].querySelectorAll(selector);
  4744. } else if(this.selection[0].nodeType=='9'){
  4745. var result=document.querySelectorAll(selector);
  4746. } else {
  4747. var result=[];
  4748. }
  4749. return mura(result);
  4750. } else {
  4751. return mura([]);
  4752. }
  4753. },
  4754. selector:function() {
  4755. var pathes = [];
  4756. var path, node = mura(this.selection[0]);
  4757. while (node.length) {
  4758. var realNode = node.get(0), name = realNode.localName;
  4759. if (!name) { break; }
  4760. if(!node.data('hastempid') && node.attr('id') && node.attr('id') != 'mura-variation-el'){
  4761. name='#' + node.attr('id');
  4762. path = name + (path ? ' > ' + path : '');
  4763. break;
  4764. } else {
  4765. name = name.toLowerCase();
  4766. var parent = node.parent();
  4767. var sameTagSiblings = parent.children(name);
  4768. if (sameTagSiblings.length > 1)
  4769. {
  4770. var allSiblings = parent.children();
  4771. var index = allSiblings.index(realNode) +1;
  4772. if (index > 0) {
  4773. name += ':nth-child(' + index + ')';
  4774. }
  4775. }
  4776. path = name + (path ? ' > ' + path : '');
  4777. node = parent;
  4778. }
  4779. }
  4780. pathes.push(path);
  4781. return pathes.join(',');
  4782. },
  4783. siblings:function(selector){
  4784. if(!this.selection.length){
  4785. return this;
  4786. }
  4787. var el=this.selection[0];
  4788. if(el.hasChildNodes()){
  4789. var silbings=mura(this.selection[0].childNodes);
  4790. if(typeof selector == 'string'){
  4791. var filterFn=function(){return (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) && this.matchesSelector(selector);};
  4792. } else {
  4793. var filterFn=function(){return this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9;};
  4794. }
  4795. return silbings.filter(filterFn);
  4796. } else {
  4797. return mura([]);
  4798. }
  4799. },
  4800. item:function(idx){
  4801. return this.selection[idx];
  4802. },
  4803. index:function(el){
  4804. return this.selection.indexOf(el);
  4805. },
  4806. closest:function(selector) {
  4807. if(!this.selection.length){
  4808. return null;
  4809. }
  4810. var el = this.selection[0];
  4811. for( var parent = el ; parent !== null && parent.matchesSelector && !parent.matchesSelector(selector) ; parent = el.parentElement ){ el = parent; };
  4812. if(parent){
  4813. return mura(parent)
  4814. } else {
  4815. return mura([]);
  4816. }
  4817. },
  4818. append:function(el) {
  4819. this.each(function(){
  4820. if(typeof el == 'string'){
  4821. this.insertAdjacentHTML('beforeend', el);
  4822. } else {
  4823. this.appendChild(el);
  4824. }
  4825. });
  4826. return this;
  4827. },
  4828. appendDisplayObject:function(data) {
  4829. var self=this;
  4830. return new Promise(function(resolve,reject){
  4831. self.each(function(){
  4832. var el=document.createElement('div');
  4833. el.setAttribute('class','mura-object');
  4834. for(var a in data){
  4835. el.setAttribute('data-' + a,data[a]);
  4836. }
  4837. if(typeof data.async == 'undefined'){
  4838. el.setAttribute('data-async',true);
  4839. }
  4840. if(typeof data.render == 'undefined'){
  4841. el.setAttribute('data-render','server');
  4842. }
  4843. el.setAttribute('data-instanceid',Mura.createUUID());
  4844. mura(this).append(el);
  4845. Mura.processDisplayObject(el).then(resolve,reject);
  4846. });
  4847. });
  4848. },
  4849. prependDisplayObject:function(data) {
  4850. var self=this;
  4851. return new Promise(function(resolve,reject){
  4852. self.each(function(){
  4853. var el=document.createElement('div');
  4854. el.setAttribute('class','mura-object');
  4855. for(var a in data){
  4856. el.setAttribute('data-' + a,data[a]);
  4857. }
  4858. if(typeof data.async == 'undefined'){
  4859. el.setAttribute('data-async',true);
  4860. }
  4861. if(typeof data.render == 'undefined'){
  4862. el.setAttribute('data-render','server');
  4863. }
  4864. el.setAttribute('data-instanceid',Mura.createUUID());
  4865. mura(this).prepend(el);
  4866. Mura.processDisplayObject(el).then(resolve,reject);
  4867. });
  4868. });
  4869. },
  4870. processDisplayObject:function(data) {
  4871. var self=this;
  4872. return new Promise(function(resolve,reject){
  4873. self.each(function(){
  4874. Mura.processDisplayObject(this).then(resolve,reject);
  4875. });
  4876. });
  4877. },
  4878. prepend:function(el) {
  4879. this.each(function(){
  4880. if(typeof el == 'string'){
  4881. this.insertAdjacentHTML('afterbegin', el);
  4882. } else {
  4883. this.insertBefore(el,this.firstChild);
  4884. }
  4885. });
  4886. return this;
  4887. },
  4888. before:function(el) {
  4889. this.each(function(){
  4890. if(typeof el == 'string'){
  4891. this.insertAdjacentHTML('beforebegin', el);
  4892. } else {
  4893. this.parent.insertBefore(el,this);
  4894. }
  4895. });
  4896. return this;
  4897. },
  4898. after:function(el) {
  4899. this.each(function(){
  4900. if(typeof el == 'string'){
  4901. this.insertAdjacentHTML('afterend', el);
  4902. } else {
  4903. this.parent.insertBefore(el,this.parent.firstChild);
  4904. }
  4905. });
  4906. return this;
  4907. },
  4908. prependMuraObject:function(data) {
  4909. var el=createElement('div');
  4910. el.setAttribute('class','mura-async-object');
  4911. for(var a in data){
  4912. el.setAttribute('data-' + a,data[a]);
  4913. }
  4914. this.prepend(el);
  4915. Mura.processAsyncObject(el);
  4916. return el;
  4917. },
  4918. hide:function(){
  4919. this.each(function(el){
  4920. el.style.display = 'none';
  4921. });
  4922. return this;
  4923. },
  4924. show:function(){
  4925. this.each(function(el){
  4926. el.style.display = '';
  4927. });
  4928. return this;
  4929. },
  4930. remove:function(){
  4931. this.each(function(el){
  4932. el.parentNode.removeChild(el);
  4933. });
  4934. return this;
  4935. },
  4936. addClass:function(className){
  4937. this.each(function(el){
  4938. if (el.classList){
  4939. el.classList.add(className);
  4940. } else {
  4941. el.className += ' ' + className;
  4942. }
  4943. });
  4944. return this;
  4945. },
  4946. hasClass:function(className){
  4947. return this.is("." + className);
  4948. },
  4949. removeClass:function(className){
  4950. this.each(function(el){
  4951. if (el.classList){
  4952. el.classList.remove(className);
  4953. } else if (el.className) {
  4954. el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
  4955. }
  4956. });
  4957. return this;
  4958. },
  4959. toggleClass:function(className){
  4960. this.each(function(el){
  4961. if (el.classList) {
  4962. el.classList.toggle(className);
  4963. } else {
  4964. var classes = el.className.split(' ');
  4965. var existingIndex = classes.indexOf(className);
  4966. if (existingIndex >= 0)
  4967. classes.splice(existingIndex, 1);
  4968. else
  4969. classes.push(className);
  4970. el.className = classes.join(' ');
  4971. }
  4972. });
  4973. return this;
  4974. },
  4975. after:function(el){
  4976. this.each(function(){
  4977. if(type)
  4978. this.insertAdjacentHTML('afterend', el);
  4979. });
  4980. return this;
  4981. },
  4982. before:function(el){
  4983. this.each(function(){
  4984. this.insertAdjacentHTML('beforebegin', el);
  4985. });
  4986. return this;
  4987. },
  4988. empty:function(){
  4989. this.each(function(el){
  4990. el.innerHTML = '';
  4991. });
  4992. return this;
  4993. },
  4994. evalScripts:function(){
  4995. if(!this.selection.length){
  4996. return this;
  4997. }
  4998. this.each(function(el){
  4999. Mura.evalScripts(el);
  5000. });
  5001. return this;
  5002. },
  5003. html:function(htmlString){
  5004. if(typeof htmlString != 'undefined'){
  5005. this.each(function(el){
  5006. el.innerHTML=htmlString;
  5007. Mura.evalScripts(el);
  5008. });
  5009. return this;
  5010. } else {
  5011. if(!this.selection.length){
  5012. return '';
  5013. }
  5014. return this.selection[0].innerHTML;
  5015. }
  5016. },
  5017. css:function(ruleName,value){
  5018. if(!this.selection.length){
  5019. return this;
  5020. }
  5021. if(typeof ruleName == 'undefined' && typeof value == 'undefined'){
  5022. try{
  5023. return getComputedStyle(this.selection[0]);
  5024. } catch(e){
  5025. return {};
  5026. }
  5027. } else if (typeof ruleName == 'object'){
  5028. this.each(function(el){
  5029. try{
  5030. for(var p in ruleName){
  5031. el.style[p]=ruleName[p];
  5032. }
  5033. } catch(e){}
  5034. });
  5035. } else if(typeof value != 'undefined'){
  5036. this.each(function(el){
  5037. try{
  5038. el.style[ruleName]=value;
  5039. } catch(e){}
  5040. });
  5041. return this;
  5042. } else{
  5043. try{
  5044. return getComputedStyle(this.selection[0])[ruleName];
  5045. } catch(e){}
  5046. }
  5047. },
  5048. text:function(textString){
  5049. if(typeof textString == 'undefined'){
  5050. this.each(function(el){
  5051. el.textContent=textString;
  5052. });
  5053. return this;
  5054. } else {
  5055. return this.selection[0].textContent;
  5056. }
  5057. },
  5058. is:function(selector){
  5059. if(!this.selection.length){
  5060. return false;
  5061. }
  5062. return this.selection[0].matchesSelector && this.selection[0].matchesSelector(selector);
  5063. },
  5064. hasAttr:function(attributeName){
  5065. if(!this.selection.length){
  5066. return false;
  5067. }
  5068. return typeof this.selection[0].hasAttribute == 'function' && this.selection[0].hasAttribute(attributeName);
  5069. },
  5070. hasData:function(attributeName){
  5071. if(!this.selection.length){
  5072. return false;
  5073. }
  5074. return this.hasAttr('data-' + attributeName);
  5075. },
  5076. offsetParent:function(){
  5077. if(!this.selection.length){
  5078. return this;
  5079. }
  5080. var el=this.selection[0];
  5081. return el.offsetParent || el;
  5082. },
  5083. outerHeight:function(withMargin){
  5084. if(!this.selection.length){
  5085. return this;
  5086. }
  5087. if(typeof withMargin == 'undefined'){
  5088. function outerHeight(el) {
  5089. var height = el.offsetHeight;
  5090. var style = getComputedStyle(el);
  5091. height += parseInt(style.marginTop) + parseInt(style.marginBottom);
  5092. return height;
  5093. }
  5094. return outerHeight(this.selection[0]);
  5095. } else {
  5096. return this.selection[0].offsetHeight;
  5097. }
  5098. },
  5099. height:function(height) {
  5100. if(!this.selection.length){
  5101. return this;
  5102. }
  5103. if(typeof width != 'undefined'){
  5104. if(!isNaN(height)){
  5105. height += 'px';
  5106. }
  5107. this.css('height',height);
  5108. return this;
  5109. }
  5110. var el=this.selection[0];
  5111. //var type=el.constructor.name.toLowerCase();
  5112. if(el === root){
  5113. return innerHeight
  5114. } else if(el === document){
  5115. var body = document.body;
  5116. var html = document.documentElement;
  5117. return Math.max( body.scrollHeight, body.offsetHeight,
  5118. html.clientHeight, html.scrollHeight, html.offsetHeight )
  5119. }
  5120. var styles = getComputedStyle(el);
  5121. var margin = parseFloat(styles['marginTop']) + parseFloat(styles['marginBottom']);
  5122. return Math.ceil(el.offsetHeight + margin);
  5123. },
  5124. width:function(width) {
  5125. if(!this.selection.length){
  5126. return this;
  5127. }
  5128. if(typeof width != 'undefined'){
  5129. if(!isNaN(width)){
  5130. width += 'px';
  5131. }
  5132. this.css('width',width);
  5133. return this;
  5134. }
  5135. var el=this.selection[0];
  5136. //var type=el.constructor.name.toLowerCase();
  5137. if(el === root){
  5138. return innerWidth
  5139. } else if(el === document){
  5140. var body = document.body;
  5141. var html = document.documentElement;
  5142. return Math.max( body.scrollWidth, body.offsetWidth,
  5143. html.clientWidth, html.scrolWidth, html.offsetWidth )
  5144. }
  5145. return getComputedStyle(el).width;
  5146. },
  5147. offset:function(){
  5148. if(!this.selection.length){
  5149. return this;
  5150. }
  5151. var el=this.selection[0];
  5152. var rect = el.getBoundingClientRect()
  5153. return {
  5154. top: rect.top + document.body.scrollTop,
  5155. left: rect.left + document.body.scrollLeft
  5156. };
  5157. },
  5158. scrollTop:function() {
  5159. return document.body.scrollTop;
  5160. },
  5161. offset:function(attributeName,value){
  5162. if(!this.selection.length){
  5163. return this;
  5164. }
  5165. var box = this.selection[0].getBoundingClientRect();
  5166. return {
  5167. top: box.top + ( pageYOffset || document.scrollTop ) - ( document.clientTop || 0 ),
  5168. left: box.left + ( pageXOffset || document.scrollLeft ) - ( document.clientLeft || 0 )
  5169. };
  5170. },
  5171. removeAttr:function(attributeName){
  5172. if(!this.selection.length){
  5173. return this;
  5174. }
  5175. this.each(function(el){
  5176. if(el && typeof el.removeAttribute == 'function'){
  5177. el.removeAttribute(attributeName);
  5178. }
  5179. });
  5180. return this;
  5181. },
  5182. changeElementType:function(type){
  5183. if(!this.selection.length){
  5184. return this;
  5185. }
  5186. this.each(function(el){
  5187. Mura.changeElementType(el,type)
  5188. });
  5189. return this;
  5190. },
  5191. val:function(value){
  5192. if(!this.selection.length){
  5193. return this;
  5194. }
  5195. if(typeof value != 'undefined'){
  5196. this.each(function(el){
  5197. if(el.tagName=='radio'){
  5198. if(el.value==value){
  5199. el.checked=true;
  5200. } else {
  5201. el.checked=false;
  5202. }
  5203. } else {
  5204. el.value=value;
  5205. }
  5206. });
  5207. return this;
  5208. } else {
  5209. if(Object.prototype.hasOwnProperty.call(this.selection[0],'value') || typeof this.selection[0].value != 'undefined'){
  5210. return this.selection[0].value;
  5211. } else {
  5212. return '';
  5213. }
  5214. }
  5215. },
  5216. attr:function(attributeName,value){
  5217. if(!this.selection.length){
  5218. return this;
  5219. }
  5220. if(typeof value == 'undefined' && typeof attributeName == 'undefined'){
  5221. return Mura.getAttributes(this.selection[0]);
  5222. } else if (typeof attributeName == 'object'){
  5223. this.each(function(el){
  5224. if(el.setAttribute){
  5225. for(var p in attributeName){
  5226. el.setAttribute(p,attributeName[p]);
  5227. }
  5228. }
  5229. });
  5230. return this;
  5231. } else if(typeof value != 'undefined'){
  5232. this.each(function(el){
  5233. if(el.setAttribute){
  5234. el.setAttribute(attributeName,value);
  5235. }
  5236. });
  5237. return this;
  5238. } else {
  5239. if(this.selection[0] && this.selection[0].getAttribute){
  5240. return this.selection[0].getAttribute(attributeName);
  5241. } else {
  5242. return undefined;
  5243. }
  5244. }
  5245. },
  5246. data:function(attributeName,value){
  5247. if(!this.selection.length){
  5248. return this;
  5249. }
  5250. if(typeof value == 'undefined' && typeof attributeName == 'undefined'){
  5251. return Mura.getData(this.selection[0]);
  5252. } else if (typeof attributeName == 'object'){
  5253. this.each(function(el){
  5254. for(var p in attributeName){
  5255. el.setAttribute("data-" + p,attributeName[p]);
  5256. }
  5257. });
  5258. return this;
  5259. } else if(typeof value != 'undefined'){
  5260. this.each(function(el){
  5261. el.setAttribute("data-" + attributeName,value);
  5262. });
  5263. return this;
  5264. } else if (this.selection[0] && this.selection[0].getAttribute) {
  5265. return Mura.parseString(this.selection[0].getAttribute("data-" + attributeName));
  5266. } else {
  5267. return undefined;
  5268. }
  5269. },
  5270. prop:function(attributeName,value){
  5271. if(!this.selection.length){
  5272. return this;
  5273. }
  5274. if(typeof value == 'undefined' && typeof attributeName == 'undefined'){
  5275. return Mura.getProps(this.selection[0]);
  5276. } else if (typeof attributeName == 'object'){
  5277. this.each(function(el){
  5278. for(var p in attributeName){
  5279. el.setAttribute(p,attributeName[p]);
  5280. }
  5281. });
  5282. return this;
  5283. } else if(typeof value != 'undefined'){
  5284. this.each(function(el){
  5285. el.setAttribute(attributeName,value);
  5286. });
  5287. return this;
  5288. } else {
  5289. return Mura.parseString(this.selection[0].getAttribute(attributeName));
  5290. }
  5291. },
  5292. fadeOut:function(){
  5293. this.each(function(el){
  5294. el.style.opacity = 1;
  5295. (function fade() {
  5296. if ((el.style.opacity -= .1) < 0) {
  5297. el.style.display = "none";
  5298. } else {
  5299. requestAnimationFrame(fade);
  5300. }
  5301. })();
  5302. });
  5303. return this;
  5304. },
  5305. fadeIn:function(display){
  5306. this.each(function(el){
  5307. el.style.opacity = 0;
  5308. el.style.display = display || "block";
  5309. (function fade() {
  5310. var val = parseFloat(el.style.opacity);
  5311. if (!((val += .1) > 1)) {
  5312. el.style.opacity = val;
  5313. requestAnimationFrame(fade);
  5314. }
  5315. })();
  5316. });
  5317. return this;
  5318. },
  5319. toggle:function(){
  5320. this.each(function(el){
  5321. if(typeof el.style.display == 'undefined' || el.style.display==''){
  5322. el.style.display='none';
  5323. } else {
  5324. el.style.display='';
  5325. }
  5326. });
  5327. return this;
  5328. }
  5329. });
  5330. }));
  5331. ;/* This file is part of Mura CMS.
  5332. Mura CMS is free software: you can redistribute it and/or modify
  5333. it under the terms of the GNU General Public License as published by
  5334. the Free Software Foundation, Version 2 of the License.
  5335. Mura CMS is distributed in the hope that it will be useful,
  5336. but WITHOUT ANY WARRANTY; without even the implied warranty of
  5337. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5338. GNU General Public License for more details.
  5339. You should have received a copy of the GNU General Public License
  5340. along with Mura CMS. If not, see <http://www.gnu.org/licenses/>.
  5341. Linking Mura CMS statically or dynamically with other modules constitutes the preparation of a derivative work based on
  5342. Mura CMS. Thus, the terms and conditions of the GNU General Public License version 2 ("GPL") cover the entire combined work.
  5343. However, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with programs
  5344. or libraries that are released under the GNU Lesser General Public License version 2.1.
  5345. In addition, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with
  5346. independent software modules (plugins, themes and bundles), and to distribute these plugins, themes and bundles without
  5347. Mura CMS under the license of your choice, provided that you follow these specific guidelines:
  5348. Your custom code
  5349. • Must not alter any default objects in the Mura CMS database and
  5350. • May not alter the default display of the Mura CMS logo within Mura CMS and
  5351. • Must not alter any files in the following directories.
  5352. /admin/
  5353. /tasks/
  5354. /config/
  5355. /requirements/mura/
  5356. /Application.cfc
  5357. /index.cfm
  5358. /MuraProxy.cfc
  5359. You may copy and distribute Mura CMS with a plug-in, theme or bundle that meets the above guidelines as a combined work
  5360. under the terms of GPL for Mura CMS, provided that you include the source code of that other code when and as the GNU GPL
  5361. requires distribution of source code.
  5362. For clarity, if you create a modified version of Mura CMS, you are not obligated to grant this special exception for your
  5363. modified version; it is your choice whether to do so, or to make such modified version available under the GNU General Public License
  5364. version 2 without this exception. You may, if you choose, apply this exception to your own modified versions of Mura CMS. */
  5365. ;(function (root, factory) {
  5366. if (typeof define === 'function' && define.amd) {
  5367. // AMD. Register as an anonymous module.
  5368. define(['Mura'], factory);
  5369. } else if (typeof module === 'object' && module.exports) {
  5370. // Node. Does not work with strict CommonJS, but
  5371. // only CommonJS-like environments that support module.exports,
  5372. // like Node.
  5373. factory(require('Mura'));
  5374. } else {
  5375. // Browser globals (root is window)
  5376. factory(root.Mura);
  5377. }
  5378. }(this, function (mura) {
  5379. Mura.Entity=Mura.Core.extend({
  5380. init:function(properties){
  5381. properties=properties || {};
  5382. properties.entityname = properties.entityname || 'content';
  5383. properties.siteid = properties.siteid || Mura.siteid;
  5384. this.set(properties);
  5385. if(typeof this.properties.isnew == 'undefined'){
  5386. this.properties.isnew=1;
  5387. }
  5388. if(this.properties.isnew){
  5389. this.set('isdirty',true);
  5390. } else {
  5391. this.set('isdirty',false);
  5392. }
  5393. if(typeof this.properties.isdeleted == 'undefined'){
  5394. this.properties.isdeleted=false;
  5395. }
  5396. this.cachePut();
  5397. },
  5398. get:function(propertyName,defaultValue){
  5399. if(typeof this.properties.links != 'undefined'
  5400. && typeof this.properties.links[propertyName] != 'undefined'){
  5401. var self=this;
  5402. if(typeof this.properties[propertyName] != 'undefined'){
  5403. return new Promise(function(resolve,reject) {
  5404. if('items' in self.properties[propertyName]){
  5405. var returnObj = new Mura.EntityCollection(self.properties[propertyName]);
  5406. } else {
  5407. if(Mura.entities[self.properties[propertyName].entityname]){
  5408. var returnObj = new Mura.entities[self.properties[propertyName].entityname](obj.properties[propertyName]);
  5409. } else {
  5410. var returnObj = new Mura.Entity(self.properties[propertyName]);
  5411. }
  5412. }
  5413. if(typeof resolve == 'function'){
  5414. resolve(returnObj);
  5415. }
  5416. });
  5417. } else {
  5418. if(typeof defaultValue == 'object'){
  5419. var params=defaultValue;
  5420. } else {
  5421. var params={};
  5422. }
  5423. return new Promise(function(resolve,reject) {
  5424. Mura.ajax({
  5425. type:'get',
  5426. url:self.properties.links[propertyName],
  5427. params:params,
  5428. success:function(resp){
  5429. if('items' in resp.data){
  5430. var returnObj = new Mura.EntityCollection(resp.data);
  5431. } else {
  5432. if(Mura.entities[obj.entityname]){
  5433. var returnObj = new Mura.entities[obj.entityname](obj);
  5434. } else {
  5435. var returnObj = new Mura.Entity(resp.data);
  5436. }
  5437. }
  5438. //Dont cache it there are custom params
  5439. if(Mura.isEmptyObject(params)){
  5440. self.set(propertyName,resp.data);
  5441. }
  5442. if(typeof resolve == 'function'){
  5443. resolve(returnObj);
  5444. }
  5445. },
  5446. error:reject
  5447. });
  5448. });
  5449. }
  5450. } else if(typeof this.properties[propertyName] != 'undefined'){
  5451. return this.properties[propertyName];
  5452. } else if (typeof defaultValue != 'undefined') {
  5453. this.properties[propertyName]=defaultValue;
  5454. return this.properties[propertyName];
  5455. } else {
  5456. return '';
  5457. }
  5458. },
  5459. set:function(propertyName,propertyValue){
  5460. if(typeof propertyName == 'object'){
  5461. this.properties=Mura.deepExtend(this.properties,propertyName);
  5462. this.set('isdirty',true);
  5463. } else if(typeof this.properties[propertyName] == 'undefined' || this.properties[propertyName] != propertyValue){
  5464. this.properties[propertyName]=propertyValue;
  5465. this.set('isdirty',true);
  5466. }
  5467. return this;
  5468. },
  5469. has:function(propertyName){
  5470. return typeof this.properties[propertyName] != 'undefined' || (typeof this.properties.links != 'undefined' && typeof this.properties.links[propertyName] != 'undefined');
  5471. },
  5472. getAll:function(){
  5473. return this.properties;
  5474. },
  5475. load:function(){
  5476. return this.loadBy('id',this.get('id'));
  5477. },
  5478. 'new':function(params){
  5479. return new Promise(function(resolve,reject){
  5480. params=Mura.extend(
  5481. {
  5482. entityname:self.get('entityname'),
  5483. method:'findQuery',
  5484. siteid:self.get('siteid')
  5485. },
  5486. params
  5487. );
  5488. Mura.findNew(params).then(function(collection){
  5489. if(collection.get('items').length){
  5490. self.set(collection.get('items')[0].getAll());
  5491. }
  5492. if(typeof resolve == 'function'){
  5493. resolve(self);
  5494. }
  5495. });
  5496. });
  5497. },
  5498. loadBy:function(propertyName,propertyValue,params){
  5499. propertyName=propertyName || 'id';
  5500. propertyValue=propertyValue || this.get(propertyName);
  5501. var self=this;
  5502. if(propertyName =='id'){
  5503. var cachedValue = Mura.datacache.get(propertyValue);
  5504. if(cachedValue){
  5505. this.set(cachedValue);
  5506. return new Promise(function(resolve,reject){
  5507. resolve(self);
  5508. });
  5509. }
  5510. }
  5511. return new Promise(function(resolve,reject){
  5512. params=Mura.extend(
  5513. {
  5514. entityname:self.get('entityname'),
  5515. method:'findQuery',
  5516. siteid:self.get('siteid')
  5517. },
  5518. params
  5519. );
  5520. params[propertyName]=propertyValue;
  5521. Mura.findQuery(params).then(function(collection){
  5522. if(collection.get('items').length){
  5523. self.set(collection.get('items')[0].getAll());
  5524. }
  5525. if(typeof resolve == 'function'){
  5526. resolve(self);
  5527. }
  5528. });
  5529. });
  5530. },
  5531. validate:function(fields){
  5532. fields=fields || '';
  5533. var self=this;
  5534. var data=Mura.deepExtend({},self.getAll());
  5535. data.fields=fields;
  5536. return new Promise(function(resolve,reject) {
  5537. Mura.ajax({
  5538. type: 'post',
  5539. url: Mura.apiEndpoint + '?method=validate',
  5540. data: {
  5541. data: Mura.escape(data),
  5542. validations: '{}',
  5543. version: 4
  5544. },
  5545. success:function(resp){
  5546. if(resp.data != 'undefined'){
  5547. self.set('errors',resp.data)
  5548. } else {
  5549. self.set('errors',resp.error);
  5550. }
  5551. if(typeof resolve == 'function'){
  5552. resolve(self);
  5553. }
  5554. }
  5555. });
  5556. });
  5557. },
  5558. hasErrors:function(){
  5559. var errors=this.get('errors',{});
  5560. return (typeof errors=='string' && errors !='') || (typeof errors=='object' && !Mura.isEmptyObject(errors));
  5561. },
  5562. getErrors:function(){
  5563. return this.get('errors',{});
  5564. },
  5565. save:function(){
  5566. var self=this;
  5567. if(!this.get('isdirty')){
  5568. return new Promise(function(resolve,reject) {
  5569. if(typeof resolve == 'function'){
  5570. resolve(self);
  5571. }
  5572. });
  5573. }
  5574. if(!this.get('id')){
  5575. return new Promise(function(resolve,reject) {
  5576. var temp=Mura.deepExtend({},self.getAll());
  5577. Mura.ajax({
  5578. type:'get',
  5579. url:Mura.apiEndpoint + self.get('entityname') + '/new' ,
  5580. success:function(resp){
  5581. self.set(resp.data);
  5582. self.set(temp);
  5583. self.set('id',resp.data.id);
  5584. self.set('isdirty',true);
  5585. self.cachePut();
  5586. self.save().then(resolve,reject);
  5587. }
  5588. });
  5589. });
  5590. } else {
  5591. return new Promise(function(resolve,reject) {
  5592. var context=self.get('id');
  5593. Mura.ajax({
  5594. type:'post',
  5595. url:Mura.apiEndpoint + '?method=generateCSRFTokens',
  5596. data:{
  5597. siteid:self.get('siteid'),
  5598. context:context
  5599. },
  5600. success:function(resp){
  5601. Mura.ajax({
  5602. type:'post',
  5603. url:Mura.apiEndpoint + '?method=save',
  5604. data:Mura.extend(self.getAll(),{'csrf_token':resp.data.csrf_token,'csrf_token_expires':resp.data.csrf_token_expires}),
  5605. success:function(resp){
  5606. if(resp.data != 'undefined'){
  5607. self.set(resp.data)
  5608. self.set('isdirty',false);
  5609. if(self.get('saveErrors') || Mura.isEmptyObject(self.getErrors())){
  5610. if(typeof resolve == 'function'){
  5611. resolve(self);
  5612. }
  5613. } else {
  5614. if(typeof reject == 'function'){
  5615. reject(self);
  5616. }
  5617. }
  5618. } else {
  5619. self.set('errors',resp.error);
  5620. if(typeof reject == 'function'){
  5621. reject(self);
  5622. }
  5623. }
  5624. }
  5625. });
  5626. }
  5627. });
  5628. });
  5629. }
  5630. },
  5631. 'delete':function(){
  5632. var self=this;
  5633. return new Promise(function(resolve,reject) {
  5634. Mura.ajax({
  5635. type:'get',
  5636. url:Mura.apiEndpoint + '?method=generateCSRFTokens',
  5637. data:{
  5638. siteid:self.get('siteid'),
  5639. context:self.get('id')
  5640. },
  5641. success:function(resp){
  5642. Mura.ajax({
  5643. type:'post',
  5644. url:Mura.apiEndpoint + '?method=delete',
  5645. data:{
  5646. siteid:self.get('siteid'),
  5647. id:self.get('id'),
  5648. entityname:self.get('entityname'),
  5649. 'csrf_token':resp.data.csrf_token,
  5650. 'csrf_token_expires':resp.data.csrf_token_expires
  5651. },
  5652. success:function(){
  5653. self.set('isdeleted',true);
  5654. self.cachePurge();
  5655. if(typeof resolve == 'function'){
  5656. resolve(self);
  5657. }
  5658. }
  5659. });
  5660. }
  5661. });
  5662. });
  5663. },
  5664. getFeed:function(){
  5665. var siteid=get('siteid') || Mura.siteid;
  5666. return new Mura.Feed(this.get('entityName'));
  5667. },
  5668. cachePurge:function(){
  5669. Mura.datacache.purge(this.get('id'));
  5670. return this;
  5671. },
  5672. cachePut:function(){
  5673. if(!this.get('isnew')){
  5674. Mura.datacache.set(this.get('id'),this);
  5675. }
  5676. return this;
  5677. }
  5678. });
  5679. }));
  5680. ;/* This file is part of Mura CMS.
  5681. Mura CMS is free software: you can redistribute it and/or modify
  5682. it under the terms of the GNU General Public License as published by
  5683. the Free Software Foundation, Version 2 of the License.
  5684. Mura CMS is distributed in the hope that it will be useful,
  5685. but WITHOUT ANY WARRANTY; without even the implied warranty of
  5686. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5687. GNU General Public License for more details.
  5688. You should have received a copy of the GNU General Public License
  5689. along with Mura CMS. If not, see <http://www.gnu.org/licenses/>.
  5690. Linking Mura CMS statically or dynamically with other modules constitutes the preparation of a derivative work based on
  5691. Mura CMS. Thus, the terms and conditions of the GNU General Public License version 2 ("GPL") cover the entire combined work.
  5692. However, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with programs
  5693. or libraries that are released under the GNU Lesser General Public License version 2.1.
  5694. In addition, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with
  5695. independent software modules (plugins, themes and bundles), and to distribute these plugins, themes and bundles without
  5696. Mura CMS under the license of your choice, provided that you follow these specific guidelines:
  5697. Your custom code
  5698. • Must not alter any default objects in the Mura CMS database and
  5699. • May not alter the default display of the Mura CMS logo within Mura CMS and
  5700. • Must not alter any files in the following directories.
  5701. /admin/
  5702. /tasks/
  5703. /config/
  5704. /requirements/mura/
  5705. /Application.cfc
  5706. /index.cfm
  5707. /MuraProxy.cfc
  5708. You may copy and distribute Mura CMS with a plug-in, theme or bundle that meets the above guidelines as a combined work
  5709. under the terms of GPL for Mura CMS, provided that you include the source code of that other code when and as the GNU GPL
  5710. requires distribution of source code.
  5711. For clarity, if you create a modified version of Mura CMS, you are not obligated to grant this special exception for your
  5712. modified version; it is your choice whether to do so, or to make such modified version available under the GNU General Public License
  5713. version 2 without this exception. You may, if you choose, apply this exception to your own modified versions of Mura CMS. */
  5714. ;(function (root, factory) {
  5715. if (typeof define === 'function' && define.amd) {
  5716. // AMD. Register as an anonymous module.
  5717. define(['Mura'], factory);
  5718. } else if (typeof module === 'object' && module.exports) {
  5719. // Node. Does not work with strict CommonJS, but
  5720. // only CommonJS-like environments that support module.exports,
  5721. // like Node.
  5722. factory(require('Mura'));
  5723. } else {
  5724. // Browser globals (root is window)
  5725. factory(root.Mura);
  5726. }
  5727. }(this, function (mura) {
  5728. Mura.EntityCollection=Mura.Entity.extend({
  5729. init:function(properties){
  5730. properties=properties || {};
  5731. this.set(properties);
  5732. var self=this;
  5733. if(Array.isArray(self.get('items'))){
  5734. self.set('items',self.get('items').map(function(obj){
  5735. if(Mura.entities[obj.entityname]){
  5736. return new Mura.entities[obj.entityname](obj);
  5737. } else {
  5738. return new Mura.Entity(obj);
  5739. }
  5740. }));
  5741. }
  5742. return this;
  5743. },
  5744. item:function(idx){
  5745. return this.properties.items[idx];
  5746. },
  5747. index:function(item){
  5748. return this.properties.items.indexOf(item);
  5749. },
  5750. getAll:function(){
  5751. var self=this;
  5752. return Mura.extend(
  5753. {},
  5754. self.properties,
  5755. {
  5756. items:self.map(function(obj){
  5757. return obj.getAll();
  5758. })
  5759. }
  5760. );
  5761. },
  5762. each:function(fn){
  5763. this.properties.items.forEach( function(item,idx){
  5764. fn.call(item,item,idx);
  5765. });
  5766. return this;
  5767. },
  5768. sort:function(fn){
  5769. this.properties.items.sort(fn);
  5770. },
  5771. filter:function(fn){
  5772. var collection=new Mura.EntityCollection(this.properties);
  5773. return collection.set('items',collection.get('items').filter( function(item,idx){
  5774. return fn.call(item,item,idx);
  5775. }));
  5776. },
  5777. map:function(fn){
  5778. var collection=new Mura.EntityCollection(this.properties);
  5779. return collection.set('items',collection.get('items').map( function(item,idx){
  5780. return fn.call(item,item,idx);
  5781. }));
  5782. }
  5783. });
  5784. }));
  5785. ;/* This file is part of Mura CMS.
  5786. Mura CMS is free software: you can redistribute it and/or modify
  5787. it under the terms of the GNU General Public License as published by
  5788. the Free Software Foundation, Version 2 of the License.
  5789. Mura CMS is distributed in the hope that it will be useful,
  5790. but WITHOUT ANY WARRANTY; without even the implied warranty of
  5791. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5792. GNU General Public License for more details.
  5793. You should have received a copy of the GNU General Public License
  5794. along with Mura CMS. If not, see <http://www.gnu.org/licenses/>.
  5795. Linking Mura CMS statically or dynamically with other modules constitutes the preparation of a derivative work based on
  5796. Mura CMS. Thus, the terms and conditions of the GNU General Public License version 2 ("GPL") cover the entire combined work.
  5797. However, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with programs
  5798. or libraries that are released under the GNU Lesser General Public License version 2.1.
  5799. In addition, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with
  5800. independent software modules (plugins, themes and bundles), and to distribute these plugins, themes and bundles without
  5801. Mura CMS under the license of your choice, provided that you follow these specific guidelines:
  5802. Your custom code
  5803. • Must not alter any default objects in the Mura CMS database and
  5804. • May not alter the default display of the Mura CMS logo within Mura CMS and
  5805. • Must not alter any files in the following directories.
  5806. /admin/
  5807. /tasks/
  5808. /config/
  5809. /requirements/mura/
  5810. /Application.cfc
  5811. /index.cfm
  5812. /MuraProxy.cfc
  5813. You may copy and distribute Mura CMS with a plug-in, theme or bundle that meets the above guidelines as a combined work
  5814. under the terms of GPL for Mura CMS, provided that you include the source code of that other code when and as the GNU GPL
  5815. requires distribution of source code.
  5816. For clarity, if you create a modified version of Mura CMS, you are not obligated to grant this special exception for your
  5817. modified version; it is your choice whether to do so, or to make such modified version available under the GNU General Public License
  5818. version 2 without this exception. You may, if you choose, apply this exception to your own modified versions of Mura CMS. */
  5819. ;(function (root, factory) {
  5820. if (typeof define === 'function' && define.amd) {
  5821. // AMD. Register as an anonymous module.
  5822. define(['Mura'], factory);
  5823. } else if (typeof module === 'object' && module.exports) {
  5824. // Node. Does not work with strict CommonJS, but
  5825. // only CommonJS-like environments that support module.exports,
  5826. // like Node.
  5827. factory(require('Mura'));
  5828. } else {
  5829. // Browser globals (root is window)
  5830. factory(root.Mura);
  5831. }
  5832. }(this, function (mura) {
  5833. Mura.Feed=Mura.Core.extend({
  5834. init:function(siteid,entityname){
  5835. this.queryString= entityname + '/?';
  5836. this.propIndex=0;
  5837. this.entityname=entityname;
  5838. return this;
  5839. },
  5840. fields:function(fields){
  5841. this.queryString+='&fields=' + encodeURIComponent(fields);
  5842. return this;
  5843. },
  5844. where:function(property){
  5845. if(property){
  5846. return this.andProp(property);
  5847. }
  5848. return this;
  5849. },
  5850. prop:function(property){
  5851. return this.andProp(property);
  5852. },
  5853. andProp:function(property){
  5854. this.queryString+='&' + encodeURIComponent(property) + '[' + this.propIndex + ']=';
  5855. this.propIndex++;
  5856. return this;
  5857. },
  5858. orProp:function(property){
  5859. this.queryString+='&or[' + this.propIndex + ']&';
  5860. this.propIndex++;
  5861. this.queryString+= encodeURIComponent(property) + '[' + this.propIndex + ']=';
  5862. this.propIndex++;
  5863. return this;
  5864. },
  5865. isEQ:function(criteria){
  5866. this.queryString+=encodeURIComponent(criteria);
  5867. return this;
  5868. },
  5869. isNEQ:function(criteria){
  5870. this.queryString+='neq^' + encodeURIComponent(criteria);
  5871. return this;
  5872. },
  5873. isLT:function(criteria){
  5874. this.queryString+='lt^' + encodeURIComponent(criteria);
  5875. return this;
  5876. },
  5877. isLTE:function(criteria){
  5878. this.queryString+='lte^' + encodeURIComponent(criteria);
  5879. return this;
  5880. },
  5881. isGT:function(criteria){
  5882. this.queryString+='gt^' + encodeURIComponent(criteria);
  5883. return this;
  5884. },
  5885. isGTE:function(criteria){
  5886. this.queryString+='gte^' + encodeURIComponent(criteria);
  5887. return this;
  5888. },
  5889. isIn:function(criteria){
  5890. this.queryString+='in^' + encodeURIComponent(criteria);
  5891. return this;
  5892. },
  5893. isNotIn:function(criteria){
  5894. this.queryString+='notin^' + encodeURIComponent(criteria);
  5895. return this;
  5896. },
  5897. containsValue:function(criteria){
  5898. this.queryString+='containsValue^' + encodeURIComponent(criteria);
  5899. return this;
  5900. },
  5901. contains:function(criteria){
  5902. this.queryString+='containsValue^' + encodeURIComponent(criteria);
  5903. return this;
  5904. },
  5905. beginsWith:function(criteria){
  5906. this.queryString+='begins^' + encodeURIComponent(criteria);
  5907. return this;
  5908. },
  5909. endsWith:function(criteria){
  5910. this.queryString+='ends^' + encodeURIComponent(criteria);
  5911. return this;
  5912. },
  5913. openGrouping:function(criteria){
  5914. this.queryString+='&openGrouping';
  5915. return this;
  5916. },
  5917. andOpenGrouping:function(criteria){
  5918. this.queryString+='&andOpenGrouping';
  5919. return this;
  5920. },
  5921. closeGrouping:function(criteria){
  5922. this.queryString+='&closeGrouping:';
  5923. return this;
  5924. },
  5925. sort:function(property,direction){
  5926. direction=direction || 'asc';
  5927. if(direction == 'desc'){
  5928. this.queryString+='&sort[' + this.propIndex + ']=-' + encodeURIComponent(property);
  5929. } else {
  5930. this.queryString+='&sort[' + this.propIndex + ']=+' + encodeURIComponent(property);
  5931. }
  5932. this.propIndex++;
  5933. return this;
  5934. },
  5935. itemsPerPage:function(itemsPerPage){
  5936. this.queryString+='&itemsPerPage=' + encodeURIComponent(itemsPerPage);
  5937. return this;
  5938. },
  5939. maxItems:function(maxItems){
  5940. this.queryString+='&maxItems=' + encodeURIComponent(maxItems);
  5941. return this;
  5942. },
  5943. innerJoin:function(relatedEntity){
  5944. this.queryString+='&innerJoin[' + this.propIndex + ']=' + encodeURIComponent(relatedEntity);
  5945. this.propIndex++;
  5946. return this;
  5947. },
  5948. leftJoin:function(relatedEntity){
  5949. this.queryString+='&leftJoin[' + this.propIndex + ']=' + encodeURIComponent(relatedEntity);
  5950. this.propIndex++;
  5951. return this;
  5952. },
  5953. getQuery:function(){
  5954. var self=this;
  5955. return new Promise(function(resolve,reject) {
  5956. Mura.ajax({
  5957. type:'get',
  5958. url:Mura.apiEndpoint + self.queryString,
  5959. success:function(resp){
  5960. var returnObj = new Mura.EntityCollection(resp.data);
  5961. if(typeof resolve == 'function'){
  5962. resolve(returnObj);
  5963. }
  5964. },
  5965. error:reject
  5966. });
  5967. });
  5968. }
  5969. });
  5970. }));
  5971. ;/* This file is part of Mura CMS.
  5972. Mura CMS is free software: you can redistribute it and/or modify
  5973. it under the terms of the GNU General Public License as published by
  5974. the Free Software Foundation, Version 2 of the License.
  5975. Mura CMS is distributed in the hope that it will be useful,
  5976. but WITHOUT ANY WARRANTY; without even the implied warranty of
  5977. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5978. GNU General Public License for more details.
  5979. You should have received a copy of the GNU General Public License
  5980. along with Mura CMS. If not, see <http://www.gnu.org/licenses/>.
  5981. Linking Mura CMS statically or dynamically with other modules constitutes the preparation of a derivative work based on
  5982. Mura CMS. Thus, the terms and conditions of the GNU General Public License version 2 ("GPL") cover the entire combined work.
  5983. However, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with programs
  5984. or libraries that are released under the GNU Lesser General Public License version 2.1.
  5985. In addition, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with
  5986. independent software modules (plugins, themes and bundles), and to distribute these plugins, themes and bundles without
  5987. Mura CMS under the license of your choice, provided that you follow these specific guidelines:
  5988. Your custom code
  5989. • Must not alter any default objects in the Mura CMS database and
  5990. • May not alter the default display of the Mura CMS logo within Mura CMS and
  5991. • Must not alter any files in the following directories.
  5992. /admin/
  5993. /tasks/
  5994. /config/
  5995. /requirements/mura/
  5996. /Application.cfc
  5997. /index.cfm
  5998. /MuraProxy.cfc
  5999. You may copy and distribute Mura CMS with a plug-in, theme or bundle that meets the above guidelines as a combined work
  6000. under the terms of GPL for Mura CMS, provided that you include the source code of that other code when and as the GNU GPL
  6001. requires distribution of source code.
  6002. For clarity, if you create a modified version of Mura CMS, you are not obligated to grant this special exception for your
  6003. modified version; it is your choice whether to do so, or to make such modified version available under the GNU General Public License
  6004. version 2 without this exception. You may, if you choose, apply this exception to your own modified versions of Mura CMS. */
  6005. ;(function (root, factory) {
  6006. if (typeof define === 'function' && define.amd) {
  6007. // AMD. Register as an anonymous module.
  6008. define(['Mura'], factory);
  6009. } else if (typeof module === 'object' && module.exports) {
  6010. // Node. Does not work with strict CommonJS, but
  6011. // only CommonJS-like environments that support module.exports,
  6012. // like Node.
  6013. factory(require('Mura'));
  6014. } else {
  6015. // Browser globals (root is window)
  6016. factory(mura);
  6017. }
  6018. }(this, function (mura) {
  6019. Mura.templates=Mura.templates || {};
  6020. Mura.templates['meta']=function(context){
  6021. if(context.label){
  6022. return '<div class="mura-object-meta"><h3>' + Mura.escapeHTML(context.label) + '</h3></div>';
  6023. } else {
  6024. return '';
  6025. }
  6026. }
  6027. Mura.templates['content']=function(context){
  6028. context.html=context.html || context.content || context.source || '';
  6029. return '<div class="mura-object-content">' + context.html + '</div>';
  6030. }
  6031. Mura.templates['text']=function(context){
  6032. context=context || {};
  6033. context.source=context.source || '<p>This object has not been configured.</p>';
  6034. return context.source;
  6035. }
  6036. Mura.templates['embed']=function(context){
  6037. context=context || {};
  6038. context.source=context.source || '<p>This object has not been configured.</p>';
  6039. return context.source;
  6040. }
  6041. }));
  6042. ;/* This file is part of Mura CMS.
  6043. Mura CMS is free software: you can redistribute it and/or modify
  6044. it under the terms of the GNU General Public License as published by
  6045. the Free Software Foundation, Version 2 of the License.
  6046. Mura CMS is distributed in the hope that it will be useful,
  6047. but WITHOUT ANY WARRANTY; without even the implied warranty of
  6048. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6049. GNU General Public License for more details.
  6050. You should have received a copy of the GNU General Public License
  6051. along with Mura CMS. If not, see <http://www.gnu.org/licenses/>.
  6052. Linking Mura CMS statically or dynamically with other modules constitutes the preparation of a derivative work based on
  6053. Mura CMS. Thus, the terms and conditions of the GNU General Public License version 2 ("GPL") cover the entire combined work.
  6054. However, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with programs
  6055. or libraries that are released under the GNU Lesser General Public License version 2.1.
  6056. In addition, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with
  6057. independent software modules (plugins, themes and bundles), and to distribute these plugins, themes and bundles without
  6058. Mura CMS under the license of your choice, provided that you follow these specific guidelines:
  6059. Your custom code
  6060. • Must not alter any default objects in the Mura CMS database and
  6061. • May not alter the default display of the Mura CMS logo within Mura CMS and
  6062. • Must not alter any files in the following directories.
  6063. /admin/
  6064. /tasks/
  6065. /config/
  6066. /requirements/mura/
  6067. /Application.cfc
  6068. /index.cfm
  6069. /MuraProxy.cfc
  6070. You may copy and distribute Mura CMS with a plug-in, theme or bundle that meets the above guidelines as a combined work
  6071. under the terms of GPL for Mura CMS, provided that you include the source code of that other code when and as the GNU GPL
  6072. requires distribution of source code.
  6073. For clarity, if you create a modified version of Mura CMS, you are not obligated to grant this special exception for your
  6074. modified version; it is your choice whether to do so, or to make such modified version available under the GNU General Public License
  6075. version 2 without this exception. You may, if you choose, apply this exception to your own modified versions of Mura CMS. */
  6076. ;(function (root, factory) {
  6077. if (typeof define === 'function' && define.amd) {
  6078. // AMD. Register as an anonymous module.
  6079. define(['Mura'], factory);
  6080. } else if (typeof module === 'object' && module.exports) {
  6081. // Node. Does not work with strict CommonJS, but
  6082. // only CommonJS-like environments that support module.exports,
  6083. // like Node.
  6084. factory(require('Mura'));
  6085. } else {
  6086. // Browser globals (root is window)
  6087. factory(root.Mura);
  6088. }
  6089. }(this, function (mura) {
  6090. Mura.UI=Mura.Core.extend({
  6091. rb:{},
  6092. context:{},
  6093. onAfterRender:function(){},
  6094. onBeforeRender:function(){},
  6095. trigger:function(eventName){
  6096. $eventName=eventName.toLowerCase();
  6097. if(typeof this.context.targetEl != 'undefined'){
  6098. var obj=mura(this.context.targetEl).closest('.mura-object');
  6099. if(obj.length && typeof obj.node != 'undefined'){
  6100. if(typeof this.handlers[$eventName] != 'undefined'){
  6101. var $handlers=this.handlers[$eventName];
  6102. for(var i=0;i < $handlers.length;i++){
  6103. $handlers[i].call(obj.node);
  6104. }
  6105. }
  6106. if(typeof this[eventName] == 'function'){
  6107. this[eventName].call(obj.node);
  6108. }
  6109. var fnName='on' + eventName.substring(0,1).toUpperCase() + eventName.substring(1,eventName.length);
  6110. if(typeof this[fnName] == 'function'){
  6111. this[fnName].call(obj.node);
  6112. }
  6113. }
  6114. }
  6115. return this;
  6116. },
  6117. render:function(){
  6118. mura(this.context.targetEl).html(Mura.templates[context.object](this.context));
  6119. this.trigger('afterRender');
  6120. return this;
  6121. },
  6122. init:function(args){
  6123. this.context=args;
  6124. this.registerHelpers();
  6125. this.trigger('beforeRender');
  6126. this.render();
  6127. return this;
  6128. },
  6129. registerHelpers:function(){
  6130. }
  6131. });
  6132. }));
  6133. ;/* This file is part of Mura CMS.
  6134. Mura CMS is free software: you can redistribute it and/or modify
  6135. it under the terms of the GNU General Public License as published by
  6136. the Free Software Foundation, Version 2 of the License.
  6137. Mura CMS is distributed in the hope that it will be useful,
  6138. but WITHOUT ANY WARRANTY; without even the implied warranty of
  6139. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6140. GNU General Public License for more details.
  6141. You should have received a copy of the GNU General Public License
  6142. along with Mura CMS. If not, see <http://www.gnu.org/licenses/>.
  6143. Linking Mura CMS statically or dynamically with other modules constitutes the preparation of a derivative work based on
  6144. Mura CMS. Thus, the terms and conditions of the GNU General Public License version 2 ("GPL") cover the entire combined work.
  6145. However, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with programs
  6146. or libraries that are released under the GNU Lesser General Public License version 2.1.
  6147. In addition, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with
  6148. independent software modules (plugins, themes and bundles), and to distribute these plugins, themes and bundles without
  6149. Mura CMS under the license of your choice, provided that you follow these specific guidelines:
  6150. Your custom code
  6151. • Must not alter any default objects in the Mura CMS database and
  6152. • May not alter the default display of the Mura CMS logo within Mura CMS and
  6153. • Must not alter any files in the following directories.
  6154. /admin/
  6155. /tasks/
  6156. /config/
  6157. /requirements/mura/
  6158. /Application.cfc
  6159. /index.cfm
  6160. /MuraProxy.cfc
  6161. You may copy and distribute Mura CMS with a plug-in, theme or bundle that meets the above guidelines as a combined work
  6162. under the terms of GPL for Mura CMS, provided that you include the source code of that other code when and as the GNU GPL
  6163. requires distribution of source code.
  6164. For clarity, if you create a modified version of Mura CMS, you are not obligated to grant this special exception for your
  6165. modified version; it is your choice whether to do so, or to make such modified version available under the GNU General Public License
  6166. version 2 without this exception. You may, if you choose, apply this exception to your own modified versions of Mura CMS. */
  6167. ;(function (root, factory) {
  6168. if (typeof define === 'function' && define.amd) {
  6169. // AMD. Register as an anonymous module.
  6170. define(['Mura'], factory);
  6171. } else if (typeof module === 'object' && module.exports) {
  6172. // Node. Does not work with strict CommonJS, but
  6173. // only CommonJS-like environments that support module.exports,
  6174. // like Node.
  6175. factory(require('Mura'));
  6176. } else {
  6177. // Browser globals (root is window)
  6178. factory(root.Mura);
  6179. }
  6180. }(this, function (mura) {
  6181. Mura.DisplayObject.Form=Mura.UI.extend({
  6182. context:{},
  6183. ormform: false,
  6184. formJSON:{},
  6185. data:{},
  6186. columns:[],
  6187. currentpage: 0,
  6188. entity: {},
  6189. fields:{},
  6190. filters: {},
  6191. datasets: [],
  6192. sortfield: '',
  6193. sortdir: '',
  6194. inlineerrors: true,
  6195. properties: {},
  6196. rendered: {},
  6197. renderqueue: 0,
  6198. //templateList: ['file','error','textblock','checkbox','checkbox_static','dropdown','dropdown_static','radio','radio_static','nested','textarea','textfield','form','paging','list','table','view','hidden','section'],
  6199. formInit: false,
  6200. responsemessage: "",
  6201. rb: {
  6202. btnsubmitclass:"form-submit"
  6203. },
  6204. render:function(){
  6205. if(this.context.mode == undefined){
  6206. this.context.mode = 'form';
  6207. }
  6208. var ident = "mura-form-" + this.context.objectid;
  6209. this.context.formEl = "#" + ident;
  6210. this.context.html = "<div id='"+ident+"'></div>";
  6211. mura(this.context.targetEl).html( this.context.html );
  6212. if (this.context.view == 'form') {
  6213. this.getForm();
  6214. }
  6215. else {
  6216. this.getList();
  6217. }
  6218. return this;
  6219. },
  6220. getTemplates:function() {
  6221. var self = this;
  6222. if (self.context.view == 'form') {
  6223. self.loadForm();
  6224. } else {
  6225. self.loadList();
  6226. }
  6227. /*
  6228. if(Mura.templatesLoaded.length){
  6229. var temp = Mura.templateList.pop();
  6230. Mura.ajax(
  6231. {
  6232. url:Mura.assetpath + '/includes/display_objects/form/templates/' + temp + '.hb',
  6233. type:'get',
  6234. xhrFields:{ withCredentials: false },
  6235. success:function(data) {
  6236. Mura.templates[temp] = Mura.Handlebars.compile(data);
  6237. if(!Mura.templateList.length) {
  6238. if (self.context.view == 'form') {
  6239. self.loadForm();
  6240. } else {
  6241. self.loadList();
  6242. }
  6243. } else {
  6244. self.getTemplates();
  6245. }
  6246. }
  6247. }
  6248. );
  6249. }
  6250. */
  6251. },
  6252. getPageFieldList:function(){
  6253. var page=this.currentpage;
  6254. var fields = self.formJSON.form.pages[page];
  6255. var result=[];
  6256. for(var f=0;f < fields.length;f++){
  6257. //console.log("add: " + self.formJSON.form.fields[fields[f]].name);
  6258. result.push(self.formJSON.form.fields[fields[f]].name);
  6259. }
  6260. //console.log(result);
  6261. return result.join(',');
  6262. },
  6263. renderField:function(fieldtype,field) {
  6264. var self = this;
  6265. var templates = Mura.templates;
  6266. var template = fieldtype;
  6267. if( field.datasetid != "" && self.isormform)
  6268. field.options = self.formJSON.datasets[field.datasetid].options;
  6269. else if(field.datasetid != "") {
  6270. field.dataset = self.formJSON.datasets[field.datasetid];
  6271. }
  6272. self.setDefault( fieldtype,field );
  6273. if (fieldtype == "nested") {
  6274. var context = {};
  6275. context.objectid = field.formid;
  6276. context.paging = 'single';
  6277. context.mode = 'nested';
  6278. context.master = this;
  6279. var nestedForm = new Mura.FormUI( context );
  6280. var holder = mura('<div id="nested-'+field.formid+'"></div>');
  6281. mura(".field-container-" + self.context.objectid,self.context.formEl).append(holder);
  6282. context.formEl = holder;
  6283. nestedForm.getForm();
  6284. var html = Mura.templates[template](field);
  6285. mura(".field-container-" + self.context.objectid,self.context.formEl).append(html);
  6286. }
  6287. else {
  6288. if(fieldtype == "checkbox") {
  6289. if(self.ormform) {
  6290. field.selected = [];
  6291. var ds = self.formJSON.datasets[field.datasetid];
  6292. for (var i in ds.datarecords) {
  6293. if(ds.datarecords[i].selected && ds.datarecords[i].selected == 1)
  6294. field.selected.push(i);
  6295. }
  6296. field.selected = field.selected.join(",");
  6297. }
  6298. else {
  6299. template = template + "_static";
  6300. }
  6301. }
  6302. else if(fieldtype == "dropdown") {
  6303. if(!self.ormform) {
  6304. template = template + "_static";
  6305. }
  6306. }
  6307. else if(fieldtype == "radio") {
  6308. if(!self.ormform) {
  6309. template = template + "_static";
  6310. }
  6311. }
  6312. var html = Mura.templates[template](field);
  6313. mura(".field-container-" + self.context.objectid,self.context.formEl).append(html);
  6314. }
  6315. },
  6316. setDefault:function(fieldtype,field) {
  6317. var self = this;
  6318. switch( fieldtype ) {
  6319. case "textfield":
  6320. case "textarea":
  6321. field.value = self.data[field.name];
  6322. break;
  6323. case "checkbox":
  6324. var ds = self.formJSON.datasets[field.datasetid];
  6325. for(var i=0;i<ds.datarecords.length;i++) {
  6326. if (self.ormform) {
  6327. var sourceid = ds.source + "id";
  6328. ds.datarecords[i].selected = 0;
  6329. ds.datarecords[i].isselected = 0;
  6330. if(self.data[field.name].items && self.data[field.name].items.length) {
  6331. for(var x = 0;x < self.data[field.name].items.length;x++) {
  6332. if (ds.datarecords[i].id == self.data[field.name].items[x][sourceid]) {
  6333. ds.datarecords[i].isselected = 1;
  6334. ds.datarecords[i].selected = 1;
  6335. }
  6336. }
  6337. }
  6338. }
  6339. else {
  6340. if (self.data[field.name] && ds.datarecords[i].value && self.data[field.name].indexOf(ds.datarecords[i].value) > -1) {
  6341. ds.datarecords[i].isselected = 1;
  6342. ds.datarecords[i].selected = 1;
  6343. }
  6344. else {
  6345. ds.datarecords[i].selected = 0;
  6346. ds.datarecords[i].isselected = 0;
  6347. }
  6348. }
  6349. }
  6350. break;
  6351. case "radio":
  6352. case "dropdown":
  6353. var ds = self.formJSON.datasets[field.datasetid];
  6354. for(var i=0;i<ds.datarecords.length;i++) {
  6355. if(self.ormform) {
  6356. if(ds.datarecords[i].id == self.data[field.name+'id']) {
  6357. ds.datarecords[i].isselected = 1;
  6358. field.selected = self.data[field.name+'id'];
  6359. }
  6360. else {
  6361. ds.datarecords[i].selected = 0;
  6362. ds.datarecords[i].isselected = 0;
  6363. }
  6364. }
  6365. else {
  6366. if(ds.datarecords[i].value == self.data[field.name]) {
  6367. ds.datarecords[i].isselected = 1;
  6368. field.selected = self.data[field.name];
  6369. }
  6370. else {
  6371. ds.datarecords[i].isselected = 0;
  6372. }
  6373. }
  6374. }
  6375. break;
  6376. }
  6377. },
  6378. renderData:function() {
  6379. var self = this;
  6380. if(self.datasets.length == 0){
  6381. if (self.renderqueue == 0) {
  6382. self.renderForm();
  6383. }
  6384. return;
  6385. }
  6386. var dataset = self.formJSON.datasets[self.datasets.pop()];
  6387. if(dataset.sourcetype && dataset.sourcetype != 'muraorm'){
  6388. self.renderData();
  6389. return;
  6390. }
  6391. if(dataset.sourcetype=='muraorm'){
  6392. dataset.options = [];
  6393. self.renderqueue++;
  6394. Mura.getFeed( dataset.source )
  6395. .getQuery()
  6396. .then( function(collection) {
  6397. collection.each(function(item) {
  6398. var itemid = item.get('id');
  6399. dataset.datarecordorder.push( itemid );
  6400. dataset.datarecords[itemid] = item.getAll();
  6401. dataset.datarecords[itemid]['value'] = itemid;
  6402. dataset.datarecords[itemid]['datarecordid'] = itemid;
  6403. dataset.datarecords[itemid]['datasetid'] = dataset.datasetid;
  6404. dataset.datarecords[itemid]['isselected'] = 0;
  6405. dataset.options.push( dataset.datarecords[itemid] );
  6406. });
  6407. })
  6408. .then(function() {
  6409. self.renderqueue--;
  6410. self.renderData();
  6411. if (self.renderqueue == 0) {
  6412. self.renderForm();
  6413. }
  6414. });
  6415. } else {
  6416. if (self.renderqueue == 0) {
  6417. self.renderForm();
  6418. }
  6419. }
  6420. },
  6421. renderForm: function( ) {
  6422. var self = this;
  6423. //console.log("render form: " + self.currentpage);
  6424. mura(".field-container-" + self.context.objectid,self.context.formEl).empty();
  6425. if(!self.formInit) {
  6426. self.initForm();
  6427. }
  6428. var fields = self.formJSON.form.pages[self.currentpage];
  6429. for(var i = 0;i < fields.length;i++) {
  6430. var field = self.formJSON.form.fields[fields[i]];
  6431. try {
  6432. if( field.fieldtype.fieldtype != undefined && field.fieldtype.fieldtype != "") {
  6433. self.renderField(field.fieldtype.fieldtype,field);
  6434. }
  6435. } catch(e){
  6436. console.log('Error rendering form field:');
  6437. console.log(field);
  6438. }
  6439. }
  6440. if(self.ishuman && self.currentpage==(self.formJSON.form.pages.length-1)){
  6441. mura(".field-container-" + self.context.objectid,self.context.formEl).append(self.ishuman);
  6442. }
  6443. if (self.context.mode == 'form') {
  6444. self.renderPaging();
  6445. }
  6446. Mura.processMarkup(".field-container-" + self.context.objectid,self.context.formEl);
  6447. self.trigger('afterRender');
  6448. },
  6449. renderPaging:function() {
  6450. var self = this;
  6451. var submitlabel=(typeof self.formJSON.form.formattributes != 'undefined' && typeof self.formJSON.form.formattributes.submitlabel != 'undefined' && self.formJSON.form.formattributes.submitlabel) ? self.formJSON.form.formattributes.submitlabel : 'Submit';
  6452. mura(".error-container-" + self.context.objectid,self.context.formEl).empty();
  6453. mura(".paging-container-" + self.context.objectid,self.context.formEl).empty();
  6454. if(self.formJSON.form.pages.length == 1) {
  6455. mura(".paging-container-" + self.context.objectid,self.context.formEl).append(Mura.templates['paging']({page:self.currentpage+1,label:submitlabel,"class":self.rb.btnsubmitclass}));
  6456. }
  6457. else {
  6458. if(self.currentpage == 0) {
  6459. mura(".paging-container-" + self.context.objectid,self.context.formEl).append(Mura.templates['paging']({page:1,label:"Next","class":"form-nav"}));
  6460. } else {
  6461. mura(".paging-container-" + self.context.objectid,self.context.formEl).append(Mura.templates['paging']({page:self.currentpage-1,label:"Back","class":'form-nav'}));
  6462. if(self.currentpage+1 < self.formJSON.form.pages.length) {
  6463. mura(".paging-container-" + self.context.objectid,self.context.formEl).append(Mura.templates['paging']({page:self.currentpage+1,label:"Next","class":'form-nav'}));
  6464. }
  6465. else {
  6466. mura(".paging-container-" + self.context.objectid,self.context.formEl).append(Mura.templates['paging']({page:self.currentpage+1,label:submitlabel,"class":'form-submit btn-primary'}));
  6467. }
  6468. }
  6469. if(self.backlink != undefined && self.backlink.length)
  6470. mura(".paging-container-" + self.context.objectid,self.context.formEl).append(Mura.templates['paging']({page:self.currentpage+1,label:"Cancel","class":'form-cancel btn-primary pull-right'}));
  6471. }
  6472. mura(".form-submit",self.context.formEl).click( function() {
  6473. self.submitForm();
  6474. });
  6475. mura(".form-cancel",self.context.formEl).click( function() {
  6476. self.getTableData( self.backlink );
  6477. });
  6478. var formNavHandler=function() {
  6479. self.setDataValues();
  6480. var keepGoing=self.onPageSubmit.call(self.context.targetEl);
  6481. if(typeof keepGoing != 'undefined' && !keepGoing){
  6482. return;
  6483. }
  6484. var button = this;
  6485. if(self.ormform) {
  6486. Mura.getEntity(self.entity)
  6487. .set(
  6488. self.data
  6489. )
  6490. .validate(self.getPageFieldList())
  6491. .then(
  6492. function( entity ) {
  6493. if(entity.hasErrors()){
  6494. self.showErrors( entity.properties.errors );
  6495. } else {
  6496. self.currentpage = mura(button).data('page');
  6497. self.renderForm();
  6498. }
  6499. }
  6500. );
  6501. } else {
  6502. var data=Mura.deepExtend({}, self.data, self.context);
  6503. data.validateform=true;
  6504. data.formid=data.objectid;
  6505. data.siteid=data.siteid || Mura.siteid;
  6506. data.fields=self.getPageFieldList();
  6507. Mura.post(
  6508. Mura.apiEndpoint + '?method=processAsyncObject',
  6509. data)
  6510. .then(function(resp){
  6511. if(typeof resp.data.errors == 'object' && !Mura.isEmptyObject(resp.data.errors)){
  6512. self.showErrors( resp.data.errors );
  6513. } else if(typeof resp.data.redirect != 'undefined') {
  6514. if(resp.data.redirect && resp.data.redirect != location.href){
  6515. location.href=resp.data.redirect;
  6516. } else {
  6517. location.reload(true);
  6518. }
  6519. } else {
  6520. self.currentpage = mura(button).data('page');
  6521. self.renderForm();
  6522. }
  6523. }
  6524. );
  6525. }
  6526. /*
  6527. }
  6528. else {
  6529. console.log('oops!');
  6530. }
  6531. */
  6532. };
  6533. mura(".form-nav",self.context.formEl).off('click',formNavHandler).on('click',formNavHandler);
  6534. },
  6535. setDataValues: function() {
  6536. var self = this;
  6537. var multi = {};
  6538. var item = {};
  6539. var valid = [];
  6540. mura(".field-container-" + self.context.objectid + " input, .field-container-" + self.context.objectid + " select, .field-container-" + self.context.objectid + " textarea").each( function() {
  6541. if( mura(this).is('[type="checkbox"]')) {
  6542. if ( multi[mura(this).attr('name')] == undefined )
  6543. multi[mura(this).attr('name')] = [];
  6544. if( this.checked ) {
  6545. if (self.ormform) {
  6546. item = {};
  6547. item['id'] = Mura.createUUID();
  6548. item[self.entity + 'id'] = self.data.id;
  6549. item[mura(this).attr('source') + 'id'] = mura(this).val();
  6550. item['key'] = mura(this).val();
  6551. multi[mura(this).attr('name')].push(item);
  6552. }
  6553. else {
  6554. multi[mura(this).attr('name')].push(mura(this).val());
  6555. }
  6556. }
  6557. }
  6558. else if( mura(this).is('[type="radio"]')) {
  6559. if( this.checked ) {
  6560. self.data[ mura(this).attr('name') ] = mura(this).val();
  6561. valid[ mura(this).attr('name') ] = self.data[name];
  6562. }
  6563. }
  6564. else {
  6565. self.data[ mura(this).attr('name') ] = mura(this).val();
  6566. valid[ mura(this).attr('name') ] = self.data[mura(this).attr('name')];
  6567. }
  6568. });
  6569. for(var i in multi) {
  6570. if(self.ormform) {
  6571. self.data[ i ].cascade = "replace";
  6572. self.data[ i ].items = multi[ i ];
  6573. valid[ i ] = self.data[i];
  6574. }
  6575. else {
  6576. self.data[ i ] = multi[i].join(",");
  6577. valid[ i ] = multi[i].join(",");
  6578. }
  6579. }
  6580. return valid;
  6581. },
  6582. validate: function( entity,fields ) {
  6583. return true;
  6584. },
  6585. getForm: function( entityid,backlink ) {
  6586. var self = this;
  6587. var formJSON = {};
  6588. var entityName = '';
  6589. if(entityid != undefined){
  6590. self.entityid = entityid;
  6591. } else {
  6592. delete self.entityid;
  6593. }
  6594. if(backlink != undefined){
  6595. self.backlink = backlink;
  6596. } else {
  6597. delete self.backlink;
  6598. }
  6599. /*
  6600. if(Mura.templateList.length) {
  6601. self.getTemplates( entityid );
  6602. }
  6603. else {
  6604. */
  6605. self.loadForm();
  6606. //}
  6607. },
  6608. loadForm: function( data ) {
  6609. var self = this;
  6610. //console.log('a');
  6611. //console.log(self.formJSOrenderN);
  6612. formJSON = JSON.parse(self.context.def);
  6613. // old forms
  6614. if(!formJSON.form.pages) {
  6615. formJSON.form.pages = [];
  6616. formJSON.form.pages[0] = formJSON.form.fieldorder;
  6617. formJSON.form.fieldorder = [];
  6618. }
  6619. if(typeof formJSON.datasets != 'undefined'){
  6620. for(var d in formJSON.datasets){
  6621. if(typeof formJSON.datasets[d].DATARECORDS != 'undefined'){
  6622. formJSON.datasets[d].datarecords=formJSON.datasets[d].DATARECORDS;
  6623. delete formJSON.datasets[d].DATARECORDS;
  6624. }
  6625. if(typeof formJSON.datasets[d].DATARECORDORDER != 'undefined'){
  6626. formJSON.datasets[d].datarecordorder=formJSON.datasets[d].DATARECORDORDER;
  6627. delete formJSON.datasets[d].DATARECORDORDER;
  6628. }
  6629. }
  6630. }
  6631. entityName = self.context.filename.replace(/\W+/g, "");
  6632. self.entity = entityName;
  6633. self.formJSON = formJSON;
  6634. self.fields = formJSON.form.fields;
  6635. self.responsemessage = self.context.responsemessage;
  6636. self.ishuman=self.context.ishuman;
  6637. if (formJSON.form.formattributes && formJSON.form.formattributes.Muraormentities == 1) {
  6638. self.ormform = true;
  6639. }
  6640. for(var i=0;i < self.formJSON.datasets;i++){
  6641. self.datasets.push(i);
  6642. }
  6643. if(self.ormform) {
  6644. self.entity = entityName;
  6645. if(self.entityid == undefined) {
  6646. Mura.get(
  6647. Mura.apiEndpoint +'/'+ entityName + '/new?expand=all&ishuman=true'
  6648. ).then(function(resp) {
  6649. self.data = resp.data;
  6650. self.renderData();
  6651. });
  6652. }
  6653. else {
  6654. Mura.get(
  6655. Mura.apiEndpoint + '/'+ entityName + '/' + self.entityid + '?expand=all&ishuman=true'
  6656. ).then(function(resp) {
  6657. self.data = resp.data;
  6658. self.renderData();
  6659. });
  6660. }
  6661. }
  6662. else {
  6663. self.renderData();
  6664. }
  6665. /*
  6666. Mura.get(
  6667. Mura.apiEndpoint + '/content/' + self.context.objectid
  6668. + '?fields=body,title,filename,responsemessage&ishuman=true'
  6669. ).then(function(data) {
  6670. formJSON = JSON.parse( data.data.body );
  6671. // old forms
  6672. if(!formJSON.form.pages) {
  6673. formJSON.form.pages = [];
  6674. formJSON.form.pages[0] = formJSON.form.fieldorder;
  6675. formJSON.form.fieldorder = [];
  6676. }
  6677. entityName = data.data.filename.replace(/\W+/g, "");
  6678. self.entity = entityName;
  6679. self.formJSON = formJSON;
  6680. self.fields = formJSON.form.fields;
  6681. self.responsemessage = data.data.responsemessage;
  6682. self.ishuman=data.data.ishuman;
  6683. if (formJSON.form.formattributes && formJSON.form.formattributes.Muraormentities == 1) {
  6684. self.ormform = true;
  6685. }
  6686. for(var i=0;i < self.formJSON.datasets;i++){
  6687. self.datasets.push(i);
  6688. }
  6689. if(self.ormform) {
  6690. self.entity = entityName;
  6691. if(self.entityid == undefined) {
  6692. Mura.get(
  6693. Mura.apiEndpoint +'/'+ entityName + '/new?expand=all&ishuman=true'
  6694. ).then(function(resp) {
  6695. self.data = resp.data;
  6696. self.renderData();
  6697. });
  6698. }
  6699. else {
  6700. Mura.get(
  6701. Mura.apiEndpoint + '/'+ entityName + '/' + self.entityid + '?expand=all&ishuman=true'
  6702. ).then(function(resp) {
  6703. self.data = resp.data;
  6704. self.renderData();
  6705. });
  6706. }
  6707. }
  6708. else {
  6709. self.renderData();
  6710. }
  6711. }
  6712. );
  6713. */
  6714. },
  6715. initForm: function() {
  6716. var self = this;
  6717. mura(self.context.formEl).empty();
  6718. if(self.context.mode != undefined && self.context.mode == 'nested') {
  6719. var html = Mura.templates['nested'](self.context);
  6720. }
  6721. else {
  6722. var html = Mura.templates['form'](self.context);
  6723. }
  6724. mura(self.context.formEl).append(html);
  6725. self.currentpage = 0;
  6726. self.formInit=true;
  6727. },
  6728. onSubmit: function(){
  6729. return true;
  6730. },
  6731. onPageSubmit: function(){
  6732. return true;
  6733. },
  6734. submitForm: function() {
  6735. var self = this;
  6736. var valid = self.setDataValues();
  6737. mura(".error-container-" + self.context.objectid,self.context.formEl).empty();
  6738. var keepGoing=this.onSubmit.call(this.context.targetEl);
  6739. if(typeof keepGoing != 'undefined' && !keepGoing){
  6740. return;
  6741. }
  6742. delete self.data.isNew;
  6743. mura(self.context.formEl)
  6744. .find('form')
  6745. .trigger('formSubmit');
  6746. if(self.ormform) {
  6747. //console.log('a!');
  6748. Mura.getEntity(self.entity)
  6749. .set(
  6750. self.data
  6751. )
  6752. .save()
  6753. .then(
  6754. function( entity ) {
  6755. if(self.backlink != undefined) {
  6756. self.getTableData( self.location );
  6757. return;
  6758. }
  6759. if(typeof resp.data.redirect != 'undefined'){
  6760. if(resp.data.redirect && resp.data.redirect != location.href){
  6761. location.href=resp.data.redirect;
  6762. } else {
  6763. location.reload(true);
  6764. }
  6765. } else {
  6766. mura(self.context.formEl).html( Mura.templates['success'](data) );
  6767. }
  6768. },
  6769. function( entity ) {
  6770. self.showErrors( entity.properties.errors );
  6771. }
  6772. );
  6773. }
  6774. else {
  6775. //console.log('b!');
  6776. var data=Mura.deepExtend({},self.context,self.data);
  6777. data.saveform=true;
  6778. data.formid=data.objectid;
  6779. data.siteid=data.siteid || Mura.siteid;
  6780. Mura.post(
  6781. Mura.apiEndpoint + '?method=processAsyncObject',
  6782. data)
  6783. .then(function(resp){
  6784. if(typeof resp.data.errors == 'object' && !Mura.isEmptyObject(resp.data.errors )){
  6785. self.showErrors( resp.data.errors );
  6786. } else if(typeof resp.data.redirect != 'undefined'){
  6787. if(resp.data.redirect && resp.data.redirect != location.href){
  6788. location.href=resp.data.redirect;
  6789. } else {
  6790. location.reload(true);
  6791. }
  6792. } else {
  6793. mura(self.context.formEl).html( Mura.templates['success'](resp.data) );
  6794. }
  6795. });
  6796. }
  6797. },
  6798. showErrors: function( errors ) {
  6799. var self = this;
  6800. var frm=mura(this.context.formEl);
  6801. var frmErrors=frm.find(".error-container-" + self.context.objectid);
  6802. frm.find('.mura-response-error').remove();
  6803. console.log(errors);
  6804. //var errorData = {};
  6805. /*
  6806. for(var i in self.fields) {
  6807. var field = self.fields[i];
  6808. if( errors[ field.name ] ) {
  6809. var error = {};
  6810. error.message = field.validatemessage && field.validatemessage.length ? field.validatemessage : errors[field.name];
  6811. error.field = field.name;
  6812. error.label = field.label;
  6813. errorData[field.name] = error;
  6814. }
  6815. }
  6816. */
  6817. for(var e in errors) {
  6818. if( typeof self.fields[e] != 'undefined' ) {
  6819. var field = self.fields[e]
  6820. var error = {};
  6821. error.message = field.validatemessage && field.validatemessage.length ? field.validatemessage : errors[field.name];
  6822. error.field = field.name;
  6823. error.label = field.label;
  6824. //errorData[e] = error;
  6825. } else {
  6826. var error = {};
  6827. error.message = errors[e];
  6828. error.field = '';
  6829. error.label = '';
  6830. //errorData[e] = error;
  6831. }
  6832. if(this.inlineerrors){
  6833. var label=mura(this.context.formEl).find('label[for="' + e + '"]');
  6834. if(label.length){
  6835. label.node.insertAdjacentHTML('afterend',Mura.templates['error'](error));
  6836. } else {
  6837. frmErrors.append(Mura.templates['error'](error));
  6838. }
  6839. } else {
  6840. frmErrors.append(Mura.templates['error'](error));
  6841. }
  6842. }
  6843. //var html = Mura.templates['error'](errorData);
  6844. //console.log(errorData);
  6845. mura(self.context.formEl).find('.g-recaptcha-container').each(function(el){
  6846. grecaptcha.reset(el.getAttribute('data-widgetid'));
  6847. });
  6848. //mura(".error-container-" + self.context.objectid,self.context.formEl).html(html);
  6849. },
  6850. // lists
  6851. getList: function() {
  6852. var self = this;
  6853. var entityName = '';
  6854. /*
  6855. if(Mura.templateList.length) {
  6856. self.getTemplates();
  6857. }
  6858. else {
  6859. */
  6860. self.loadList();
  6861. //}
  6862. },
  6863. filterResults: function() {
  6864. var self = this;
  6865. var before = "";
  6866. var after = "";
  6867. self.filters.filterby = mura("#results-filterby",self.context.formEl).val();
  6868. self.filters.filterkey = mura("#results-keywords",self.context.formEl).val();
  6869. if( mura("#date1",self.context.formEl).length ) {
  6870. if(mura("#date1",self.context.formEl).val().length) {
  6871. self.filters.from = mura("#date1",self.context.formEl).val() + " " + mura("#hour1",self.context.formEl).val() + ":00:00";
  6872. self.filters.fromhour = mura("#hour1",self.context.formEl).val();
  6873. self.filters.fromdate = mura("#date1",self.context.formEl).val();
  6874. }
  6875. else {
  6876. self.filters.from = "";
  6877. self.filters.fromhour = 0;
  6878. self.filters.fromdate = "";
  6879. }
  6880. if(mura("#date2",self.context.formEl).val().length) {
  6881. self.filters.to = mura("#date2",self.context.formEl).val() + " " + mura("#hour2",self.context.formEl).val() + ":00:00";
  6882. self.filters.tohour = mura("#hour2",self.context.formEl).val();
  6883. self.filters.todate = mura("#date2",self.context.formEl).val();
  6884. }
  6885. else {
  6886. self.filters.to = "";
  6887. self.filters.tohour = 0;
  6888. self.filters.todate = "";
  6889. }
  6890. }
  6891. self.getTableData();
  6892. },
  6893. downloadResults: function() {
  6894. var self = this;
  6895. self.filterResults();
  6896. },
  6897. loadList: function() {
  6898. var self = this;
  6899. formJSON = self.context.formdata;
  6900. entityName = dself.context.filename.replace(/\W+/g, "");
  6901. self.entity = entityName;
  6902. self.formJSON = formJSON;
  6903. if (formJSON.form.formattributes && formJSON.form.formattributes.Muraormentities == 1) {
  6904. self.ormform = true;
  6905. }
  6906. else {
  6907. mura(self.context.formEl).append("Unsupported for pre-Mura 7.0 MuraORM Forms.");
  6908. return;
  6909. }
  6910. self.getTableData();
  6911. /*
  6912. Mura.get(
  6913. Mura.apiEndpoint + 'content/' + self.context.objectid
  6914. + '?fields=body,title,filename,responsemessage'
  6915. ).then(function(data) {
  6916. formJSON = JSON.parse( data.data.body );
  6917. entityName = data.data.filename.replace(/\W+/g, "");
  6918. self.entity = entityName;
  6919. self.formJSON = formJSON;
  6920. if (formJSON.form.formattributes && formJSON.form.formattributes.Muraormentities == 1) {
  6921. self.ormform = true;
  6922. }
  6923. else {
  6924. mura(self.context.formEl).append("Unsupported for pre-Mura 7.0 MuraORM Forms.");
  6925. return;
  6926. }
  6927. self.getTableData();
  6928. });
  6929. */
  6930. },
  6931. getTableData: function( navlink ) {
  6932. var self = this;
  6933. Mura.get(
  6934. Mura.apiEndpoint + self.entity + '/listviewdescriptor'
  6935. ).then(function(resp) {
  6936. self.columns = resp.data;
  6937. Mura.get(
  6938. Mura.apiEndpoint + self.entity + '/propertydescriptor/'
  6939. ).then(function(resp) {
  6940. self.properties = self.cleanProps(resp.data);
  6941. if( navlink == undefined) {
  6942. navlink = Mura.apiEndpoint + self.entity + '?sort=' + self.sortdir + self.sortfield;
  6943. var fields = [];
  6944. for(var i = 0;i < self.columns.length;i++) {
  6945. fields.push(self.columns[i].column);
  6946. }
  6947. navlink = navlink + "&fields=" + fields.join(",");
  6948. if (self.filters.filterkey && self.filters.filterkey != '') {
  6949. navlink = navlink + "&" + self.filters.filterby + "=contains^" + self.filters.filterkey;
  6950. }
  6951. if (self.filters.from && self.filters.from != '') {
  6952. navlink = navlink + "&created[1]=gte^" + self.filters.from;
  6953. }
  6954. if (self.filters.to && self.filters.to != '') {
  6955. navlink = navlink + "&created[2]=lte^" + self.filters.to;
  6956. }
  6957. }
  6958. Mura.get(
  6959. navlink
  6960. ).then(function(resp) {
  6961. self.data = resp.data;
  6962. self.location = self.data.links.self;
  6963. var tableData = {rows:self.data,columns:self.columns,properties:self.properties,filters:self.filters};
  6964. self.renderTable( tableData );
  6965. });
  6966. });
  6967. });
  6968. },
  6969. renderTable: function( tableData ) {
  6970. var self = this;
  6971. var html = Mura.templates['table'](tableData);
  6972. mura(self.context.formEl).html( html );
  6973. if (self.context.view == 'list') {
  6974. mura("#date-filters",self.context.formEl).empty();
  6975. mura("#btn-results-download",self.context.formEl).remove();
  6976. }
  6977. else {
  6978. if (self.context.render == undefined) {
  6979. mura(".datepicker", self.context.formEl).datepicker();
  6980. }
  6981. mura("#btn-results-download",self.context.formEl).click( function() {
  6982. self.downloadResults();
  6983. });
  6984. }
  6985. mura("#btn-results-search",self.context.formEl).click( function() {
  6986. self.filterResults();
  6987. });
  6988. mura(".data-edit",self.context.formEl).click( function() {
  6989. self.renderCRUD( mura(this).attr('data-value'),mura(this).attr('data-pos'));
  6990. });
  6991. mura(".data-view",self.context.formEl).click( function() {
  6992. self.loadOverview(mura(this).attr('data-value'),mura(this).attr('data-pos'));
  6993. });
  6994. mura(".data-nav",self.context.formEl).click( function() {
  6995. self.getTableData( mura(this).attr('data-value') );
  6996. });
  6997. mura(".data-sort").click( function() {
  6998. var sortfield = mura(this).attr('data-value');
  6999. if(sortfield == self.sortfield && self.sortdir == '')
  7000. self.sortdir = '-';
  7001. else
  7002. self.sortdir = '';
  7003. self.sortfield = mura(this).attr('data-value');
  7004. self.getTableData();
  7005. });
  7006. },
  7007. loadOverview: function(itemid,pos) {
  7008. var self = this;
  7009. Mura.get(
  7010. Mura.apiEndpoint + entityName + '/' + itemid + '?expand=all'
  7011. ).then(function(resp) {
  7012. self.item = resp.data;
  7013. self.renderOverview();
  7014. });
  7015. },
  7016. renderOverview: function() {
  7017. var self = this;
  7018. //console.log('ia');
  7019. //console.log(self.item);
  7020. mura(self.context.formEl).empty();
  7021. var html = Mura.templates['view'](self.item);
  7022. mura(self.context.formEl).append(html);
  7023. mura(".nav-back",self.context.formEl).click( function() {
  7024. self.getTableData( self.location );
  7025. });
  7026. },
  7027. renderCRUD: function( itemid,pos ) {
  7028. var self = this;
  7029. self.formInit = 0;
  7030. self.initForm();
  7031. self.getForm(itemid,self.data.links.self);
  7032. },
  7033. cleanProps: function( props ) {
  7034. var propsOrdered = {};
  7035. var propsRet = {};
  7036. var ct = 100000;
  7037. delete props.isnew;
  7038. delete props.created;
  7039. delete props.lastUpdate;
  7040. delete props.errors;
  7041. delete props.saveErrors;
  7042. delete props.instance;
  7043. delete props.instanceid;
  7044. delete props.frommuracache;
  7045. delete props[self.entity + "id"];
  7046. for(var i in props) {
  7047. if( props[i].orderno != undefined) {
  7048. propsOrdered[props[i].orderno] = props[i];
  7049. }
  7050. else {
  7051. propsOrdered[ct++] = props[i];
  7052. }
  7053. }
  7054. Object.keys(propsOrdered)
  7055. .sort()
  7056. .forEach(function(v, i) {
  7057. propsRet[v] = propsOrdered[v];
  7058. });
  7059. return propsRet;
  7060. },
  7061. registerHelpers: function() {
  7062. var self = this;
  7063. Mura.Handlebars.registerHelper('eachColRow',function(row, columns, options) {
  7064. var ret = "";
  7065. for(var i = 0;i < columns.length;i++) {
  7066. ret = ret + options.fn(row[columns[i].column]);
  7067. }
  7068. return ret;
  7069. });
  7070. Mura.Handlebars.registerHelper('eachProp',function(data, options) {
  7071. var ret = "";
  7072. var obj = {};
  7073. for(var i in self.properties) {
  7074. obj.displayName = self.properties[i].displayName;
  7075. if( self.properties[i].fieldtype == "one-to-one" ) {
  7076. obj.displayValue = data[ self.properties[i].cfc ].val;
  7077. }
  7078. else
  7079. obj.displayValue = data[ self.properties[i].column ];
  7080. ret = ret + options.fn(obj);
  7081. }
  7082. return ret;
  7083. });
  7084. Mura.Handlebars.registerHelper('eachKey',function(properties, by, options) {
  7085. var ret = "";
  7086. var item = "";
  7087. for(var i in properties) {
  7088. item = properties[i];
  7089. if(item.column == by)
  7090. item.selected = "Selected";
  7091. if(item.rendertype == 'textfield')
  7092. ret = ret + options.fn(item);
  7093. }
  7094. return ret;
  7095. });
  7096. Mura.Handlebars.registerHelper('eachHour',function(hour, options) {
  7097. var ret = "";
  7098. var h = 0;
  7099. var val = "";
  7100. for(var i = 0;i < 24;i++) {
  7101. if(i == 0 ) {
  7102. val = {label:"12 AM",num:i};
  7103. }
  7104. else if(i <12 ) {
  7105. h = i;
  7106. val = {label:h + " AM",num:i};
  7107. }
  7108. else if(i == 12 ) {
  7109. h = i;
  7110. val = {label:h + " PM",num:i};
  7111. }
  7112. else {
  7113. h = i-12;
  7114. val = {label:h + " PM",num:i};
  7115. }
  7116. if(hour == i)
  7117. val.selected = "selected";
  7118. ret = ret + options.fn(val);
  7119. }
  7120. return ret;
  7121. });
  7122. Mura.Handlebars.registerHelper('eachColButton',function(row, options) {
  7123. var ret = "";
  7124. row.label='View';
  7125. row.type='data-view';
  7126. // only do view if there are more properties than columns
  7127. if( Object.keys(self.properties).length > self.columns.length) {
  7128. ret = ret + options.fn(row);
  7129. }
  7130. if( self.context.view == 'edit') {
  7131. row.label='Edit';
  7132. row.type='data-edit';
  7133. ret = ret + options.fn(row);
  7134. }
  7135. return ret;
  7136. });
  7137. Mura.Handlebars.registerHelper('eachCheck',function(checks, selected, options) {
  7138. var ret = "";
  7139. for(var i = 0;i < checks.length;i++) {
  7140. if( selected.indexOf( checks[i].id ) > -1 )
  7141. checks[i].isselected = 1;
  7142. else
  7143. checks[i].isselected = 0;
  7144. ret = ret + options.fn(checks[i]);
  7145. }
  7146. return ret;
  7147. });
  7148. Mura.Handlebars.registerHelper('eachStatic',function(dataset, options) {
  7149. var ret = "";
  7150. for(var i = 0;i < dataset.datarecordorder.length;i++) {
  7151. ret = ret + options.fn(dataset.datarecords[dataset.datarecordorder[i]]);
  7152. }
  7153. return ret;
  7154. });
  7155. Mura.Handlebars.registerHelper('inputWrapperClass',function() {
  7156. var escapeExpression=Mura.Handlebars.escapeExpression;
  7157. var returnString='mura-control-group';
  7158. if(this.wrappercssclass){
  7159. returnString += ' ' + escapeExpression(this.wrappercssclass);
  7160. }
  7161. if(this.isrequired){
  7162. returnString += ' req';
  7163. }
  7164. return returnString;
  7165. });
  7166. Mura.Handlebars.registerHelper('formClass',function() {
  7167. var escapeExpression=Mura.Handlebars.escapeExpression;
  7168. var returnString='mura-form';
  7169. if(this['class']){
  7170. returnString += ' ' + escapeExpression(this['class']);
  7171. }
  7172. return returnString;
  7173. });
  7174. Mura.Handlebars.registerHelper('commonInputAttributes',function() {
  7175. //id, class, title, size
  7176. var escapeExpression=Mura.Handlebars.escapeExpression;
  7177. var returnString='name="' + escapeExpression(this.name) + '"';
  7178. if(this.cssid){
  7179. returnString += ' id="' + escapeExpression(this.cssid) + '"';
  7180. } else {
  7181. returnString += ' id="field-' + escapeExpression(this.name) + '"';
  7182. }
  7183. if(this.cssclass){
  7184. returnString += ' class="' + escapeExpression(this.cssclass) + '"';
  7185. }
  7186. if(this.tooltip){
  7187. returnString += ' title="' + escapeExpression(this.tooltip) + '"';
  7188. }
  7189. if(this.size){
  7190. returnString += ' size="' + escapeExpression(this.size) + '"';
  7191. }
  7192. return returnString;
  7193. });
  7194. }
  7195. });
  7196. //Legacy for early adopter backwords support
  7197. Mura.DisplayObject.form=Mura.DisplayObject.Form;
  7198. }));
  7199. ;/* This file is part of Mura CMS.
  7200. Mura CMS is free software: you can redistribute it and/or modify
  7201. it under the terms of the GNU General Public License as published by
  7202. the Free Software Foundation, Version 2 of the License.
  7203. Mura CMS is distributed in the hope that it will be useful,
  7204. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7205. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  7206. GNU General Public License for more details.
  7207. You should have received a copy of the GNU General Public License
  7208. along with Mura CMS. If not, see <http://www.gnu.org/licenses/>.
  7209. Linking Mura CMS statically or dynamically with other modules constitutes the preparation of a derivative work based on
  7210. Mura CMS. Thus, the terms and conditions of the GNU General Public License version 2 ("GPL") cover the entire combined work.
  7211. However, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with programs
  7212. or libraries that are released under the GNU Lesser General Public License version 2.1.
  7213. In addition, as a special exception, the copyright holders of Mura CMS grant you permission to combine Mura CMS with
  7214. independent software modules (plugins, themes and bundles), and to distribute these plugins, themes and bundles without
  7215. Mura CMS under the license of your choice, provided that you follow these specific guidelines:
  7216. Your custom code
  7217. • Must not alter any default objects in the Mura CMS database and
  7218. • May not alter the default display of the Mura CMS logo within Mura CMS and
  7219. • Must not alter any files in the following directories.
  7220. /admin/
  7221. /tasks/
  7222. /config/
  7223. /requirements/mura/
  7224. /Application.cfc
  7225. /index.cfm
  7226. /MuraProxy.cfc
  7227. You may copy and distribute Mura CMS with a plug-in, theme or bundle that meets the above guidelines as a combined work
  7228. under the terms of GPL for Mura CMS, provided that you include the source code of that other code when and as the GNU GPL
  7229. requires distribution of source code.
  7230. For clarity, if you create a modified version of Mura CMS, you are not obligated to grant this special exception for your
  7231. modified version; it is your choice whether to do so, or to make such modified version available under the GNU General Public License
  7232. version 2 without this exception. You may, if you choose, apply this exception to your own modified versions of Mura CMS. */
  7233. ;(function (root, factory) {
  7234. if (typeof define === 'function' && define.amd) {
  7235. // AMD. Register as an anonymous module.
  7236. define(['Mura'], factory);
  7237. } else if (typeof module === 'object' && module.exports) {
  7238. // Node. Does not work with strict CommonJS, but
  7239. // only CommonJS-like environments that support module.exports,
  7240. // like Node.
  7241. mura=factory(require('Mura'),require('Handlebars'));
  7242. } else {
  7243. // Browser globals (root is window)
  7244. factory(root.Mura,root.Handlebars);
  7245. }
  7246. }(this, function (mura,Handlebars) {
  7247. Mura.datacache=new Mura.Cache();
  7248. Mura.Handlebars=Handlebars.create();
  7249. Mura.templatesLoaded=false;
  7250. Handlebars.noConflict();
  7251. }));
  7252. ;this["mura"] = this["mura"] || {};
  7253. this["mura"]["templates"] = this["mura"]["templates"] || {};
  7254. this["mura"]["templates"]["checkbox"] = this.mura.Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
  7255. return " <ins>Required</ins>";
  7256. },"3":function(container,depth0,helpers,partials,data,blockParams,depths) {
  7257. var stack1, helper, alias1=container.lambda, alias2=container.escapeExpression, alias3=depth0 != null ? depth0 : {}, alias4=helpers.helperMissing, alias5="function";
  7258. return " <label class=\"checkbox\">\r\n <input source=\""
  7259. + alias2(alias1(((stack1 = (depths[1] != null ? depths[1].dataset : depths[1])) != null ? stack1.source : stack1), depth0))
  7260. + "\" type=\"checkbox\" name=\""
  7261. + alias2(alias1((depths[1] != null ? depths[1].name : depths[1]), depth0))
  7262. + "\" id=\"field-"
  7263. + alias2(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias4),(typeof helper === alias5 ? helper.call(alias3,{"name":"id","hash":{},"data":data}) : helper)))
  7264. + "\" value=\""
  7265. + alias2(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias4),(typeof helper === alias5 ? helper.call(alias3,{"name":"id","hash":{},"data":data}) : helper)))
  7266. + "\" id=\""
  7267. + alias2(alias1((depths[1] != null ? depths[1].name : depths[1]), depth0))
  7268. + "-"
  7269. + alias2(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias4),(typeof helper === alias5 ? helper.call(alias3,{"name":"id","hash":{},"data":data}) : helper)))
  7270. + "\" "
  7271. + ((stack1 = helpers["if"].call(alias3,(depth0 != null ? depth0.isselected : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7272. + "/>\r\n "
  7273. + alias2(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias4),(typeof helper === alias5 ? helper.call(alias3,{"name":"label","hash":{},"data":data}) : helper)))
  7274. + "</label>\r\n";
  7275. },"4":function(container,depth0,helpers,partials,data) {
  7276. return "checked='checked'";
  7277. },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) {
  7278. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7279. return " <div class=\""
  7280. + ((stack1 = ((helper = (helper = helpers.inputWrapperClass || (depth0 != null ? depth0.inputWrapperClass : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"inputWrapperClass","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7281. + "\" id=\"field-"
  7282. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7283. + "-container\">\r\n <div class=\"mura-checkbox-group\">\r\n <div class=\"mura-group-label\">"
  7284. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7285. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isrequired : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7286. + "</div>\r\n"
  7287. + ((stack1 = (helpers.eachCheck || (depth0 && depth0.eachCheck) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.dataset : depth0)) != null ? stack1.options : stack1),(depth0 != null ? depth0.selected : depth0),{"name":"eachCheck","hash":{},"fn":container.program(3, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7288. + " </div>\r\n </div>\r\n";
  7289. },"useData":true,"useDepths":true});
  7290. this["mura"]["templates"]["checkbox_static"] = this.mura.Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
  7291. return " <ins>Required</ins>";
  7292. },"3":function(container,depth0,helpers,partials,data,blockParams,depths) {
  7293. var stack1, helper, alias1=container.lambda, alias2=container.escapeExpression, alias3=depth0 != null ? depth0 : {}, alias4=helpers.helperMissing, alias5="function";
  7294. return " <label class=\"checkbox\">\r\n <input type=\"checkbox\" name=\""
  7295. + alias2(alias1((depths[1] != null ? depths[1].name : depths[1]), depth0))
  7296. + "\" id=\"field-"
  7297. + alias2(((helper = (helper = helpers.datarecordid || (depth0 != null ? depth0.datarecordid : depth0)) != null ? helper : alias4),(typeof helper === alias5 ? helper.call(alias3,{"name":"datarecordid","hash":{},"data":data}) : helper)))
  7298. + "\" value=\""
  7299. + alias2(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias4),(typeof helper === alias5 ? helper.call(alias3,{"name":"value","hash":{},"data":data}) : helper)))
  7300. + "\" id=\""
  7301. + alias2(alias1((depths[1] != null ? depths[1].name : depths[1]), depth0))
  7302. + "\" "
  7303. + ((stack1 = helpers["if"].call(alias3,(depth0 != null ? depth0.isselected : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7304. + ((stack1 = helpers["if"].call(alias3,(depth0 != null ? depth0.selected : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7305. + "/>\r\n "
  7306. + alias2(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias4),(typeof helper === alias5 ? helper.call(alias3,{"name":"label","hash":{},"data":data}) : helper)))
  7307. + "</label>\r\n";
  7308. },"4":function(container,depth0,helpers,partials,data) {
  7309. return " checked='checked'";
  7310. },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) {
  7311. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7312. return " <div class=\""
  7313. + ((stack1 = ((helper = (helper = helpers.inputWrapperClass || (depth0 != null ? depth0.inputWrapperClass : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"inputWrapperClass","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7314. + "\" id=\"field-"
  7315. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7316. + "-container\">\r\n <div class=\"mura-checkbox-group\">\r\n <div class=\"mura-group-label\">"
  7317. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7318. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isrequired : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7319. + "</div>\r\n"
  7320. + ((stack1 = (helpers.eachStatic || (depth0 && depth0.eachStatic) || alias2).call(alias1,(depth0 != null ? depth0.dataset : depth0),{"name":"eachStatic","hash":{},"fn":container.program(3, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7321. + " </div>\r\n </div>\r\n";
  7322. },"useData":true,"useDepths":true});
  7323. this["mura"]["templates"]["dropdown"] = this.mura.Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
  7324. return " <ins>Required</ins>";
  7325. },"3":function(container,depth0,helpers,partials,data) {
  7326. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7327. return " <option data-isother=\""
  7328. + alias4(((helper = (helper = helpers.isother || (depth0 != null ? depth0.isother : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"isother","hash":{},"data":data}) : helper)))
  7329. + "\" id=\"field-"
  7330. + alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
  7331. + "\" value=\""
  7332. + alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
  7333. + "\" "
  7334. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isselected : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7335. + ">"
  7336. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7337. + "</option>\n";
  7338. },"4":function(container,depth0,helpers,partials,data) {
  7339. return "selected='selected'";
  7340. },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7341. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7342. return " <div class=\""
  7343. + ((stack1 = ((helper = (helper = helpers.inputWrapperClass || (depth0 != null ? depth0.inputWrapperClass : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"inputWrapperClass","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7344. + "\" id=\"field-"
  7345. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7346. + "-container\">\n <label for=\""
  7347. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7348. + "\">"
  7349. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7350. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isrequired : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7351. + "</label>\n <select "
  7352. + ((stack1 = ((helper = (helper = helpers.commonInputAttributes || (depth0 != null ? depth0.commonInputAttributes : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"commonInputAttributes","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7353. + ">\n"
  7354. + ((stack1 = helpers.each.call(alias1,((stack1 = (depth0 != null ? depth0.dataset : depth0)) != null ? stack1.options : stack1),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7355. + " </select>\n </div>\n";
  7356. },"useData":true});
  7357. this["mura"]["templates"]["dropdown_static"] = this.mura.Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
  7358. return " <ins>Required</ins>";
  7359. },"3":function(container,depth0,helpers,partials,data) {
  7360. var helper;
  7361. return " <div class=\"mura-group-label\">"
  7362. + container.escapeExpression(((helper = (helper = helpers.summary || (depth0 != null ? depth0.summary : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"summary","hash":{},"data":data}) : helper)))
  7363. + "</div>\n";
  7364. },"5":function(container,depth0,helpers,partials,data) {
  7365. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7366. return " <option data-isother=\""
  7367. + alias4(((helper = (helper = helpers.isother || (depth0 != null ? depth0.isother : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"isother","hash":{},"data":data}) : helper)))
  7368. + "\" id=\"field-"
  7369. + alias4(((helper = (helper = helpers.datarecordid || (depth0 != null ? depth0.datarecordid : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"datarecordid","hash":{},"data":data}) : helper)))
  7370. + "\" value=\""
  7371. + alias4(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper)))
  7372. + "\" "
  7373. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isselected : depth0),{"name":"if","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7374. + ">"
  7375. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7376. + "</option>\n";
  7377. },"6":function(container,depth0,helpers,partials,data) {
  7378. return "selected='selected'";
  7379. },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7380. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7381. return " <div class=\""
  7382. + ((stack1 = ((helper = (helper = helpers.inputWrapperClass || (depth0 != null ? depth0.inputWrapperClass : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"inputWrapperClass","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7383. + "\" id=\"field-"
  7384. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7385. + "-container\">\n <label for=\""
  7386. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7387. + "\">"
  7388. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7389. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isrequired : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7390. + "</label>\n"
  7391. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.summary : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7392. + " <select "
  7393. + ((stack1 = ((helper = (helper = helpers.commonInputAttributes || (depth0 != null ? depth0.commonInputAttributes : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"commonInputAttributes","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7394. + ">\n"
  7395. + ((stack1 = (helpers.eachStatic || (depth0 && depth0.eachStatic) || alias2).call(alias1,(depth0 != null ? depth0.dataset : depth0),{"name":"eachStatic","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7396. + " </select>\n </div>\n";
  7397. },"useData":true});
  7398. this["mura"]["templates"]["error"] = this.mura.Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
  7399. var helper;
  7400. return container.escapeExpression(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"label","hash":{},"data":data}) : helper)))
  7401. + ": ";
  7402. },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7403. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7404. return "<div class=\"mura-response-error\" data-field=\""
  7405. + alias4(((helper = (helper = helpers.field || (depth0 != null ? depth0.field : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"field","hash":{},"data":data}) : helper)))
  7406. + "\">"
  7407. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.label : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7408. + alias4(((helper = (helper = helpers.message || (depth0 != null ? depth0.message : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"message","hash":{},"data":data}) : helper)))
  7409. + "</div>\r\n";
  7410. },"useData":true});
  7411. this["mura"]["templates"]["file"] = this.mura.Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
  7412. return " <ins>Required</ins>";
  7413. },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7414. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7415. return "<div class=\""
  7416. + ((stack1 = ((helper = (helper = helpers.inputWrapperClass || (depth0 != null ? depth0.inputWrapperClass : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"inputWrapperClass","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7417. + "\" id=\"field-"
  7418. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7419. + "-container\">\r\n <label for=\""
  7420. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7421. + "\">"
  7422. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7423. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isrequired : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7424. + "</label>\r\n <input type=\"file\" "
  7425. + ((stack1 = ((helper = (helper = helpers.commonInputAttributes || (depth0 != null ? depth0.commonInputAttributes : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"commonInputAttributes","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7426. + "/>\r\n</div>\r\n";
  7427. },"useData":true});
  7428. this["mura"]["templates"]["form"] = this.mura.Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7429. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7430. return "<form id=\"frm"
  7431. + alias4(((helper = (helper = helpers.objectid || (depth0 != null ? depth0.objectid : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"objectid","hash":{},"data":data}) : helper)))
  7432. + "\" class=\""
  7433. + ((stack1 = ((helper = (helper = helpers.formClass || (depth0 != null ? depth0.formClass : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"formClass","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7434. + "\" novalidate=\"novalidate\" enctype='multipart/form-data'>\n<div class=\"error-container-"
  7435. + alias4(((helper = (helper = helpers.objectid || (depth0 != null ? depth0.objectid : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"objectid","hash":{},"data":data}) : helper)))
  7436. + "\">\n</div>\n<div class=\"field-container-"
  7437. + alias4(((helper = (helper = helpers.objectid || (depth0 != null ? depth0.objectid : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"objectid","hash":{},"data":data}) : helper)))
  7438. + "\">\n</div>\n<div class=\"paging-container-"
  7439. + alias4(((helper = (helper = helpers.objectid || (depth0 != null ? depth0.objectid : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"objectid","hash":{},"data":data}) : helper)))
  7440. + "\">\n</div>\n <input type=\"hidden\" name=\"formid\" class=\""
  7441. + alias4(((helper = (helper = helpers.objectid || (depth0 != null ? depth0.objectid : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"objectid","hash":{},"data":data}) : helper)))
  7442. + "\" value=\"1025\">\n</form>\n";
  7443. },"useData":true});
  7444. this["mura"]["templates"]["hidden"] = this.mura.Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7445. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7446. return "<input type=\"hidden\" name=\""
  7447. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7448. + "\" "
  7449. + ((stack1 = ((helper = (helper = helpers.commonInputAttributes || (depth0 != null ? depth0.commonInputAttributes : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"commonInputAttributes","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7450. + " value=\""
  7451. + alias4(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper)))
  7452. + "\" /> \n";
  7453. },"useData":true});
  7454. this["mura"]["templates"]["list"] = this.mura.Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
  7455. var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7456. return " <option value=\""
  7457. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7458. + "\">"
  7459. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7460. + "</option>\n";
  7461. },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7462. var stack1;
  7463. return "<form>\n <div class=\"mura-control-group\">\n <label for=\"beanList\">Choose Entity:</label> \n <div class=\"form-group-select\">\n <select type=\"text\" name=\"bean\" id=\"select-bean-value\">\n"
  7464. + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},depth0,{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7465. + " </select>\n </div>\n </div>\n <div class=\"mura-control-group\">\n <button type=\"button\" id=\"select-bean\">Go</button>\n </div>\n</form>";
  7466. },"useData":true});
  7467. this["mura"]["templates"]["nested"] = this.mura.Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7468. var helper;
  7469. return "<div class=\"field-container-"
  7470. + container.escapeExpression(((helper = (helper = helpers.objectid || (depth0 != null ? depth0.objectid : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"objectid","hash":{},"data":data}) : helper)))
  7471. + "\">\r\n\r\n</div>\r\n";
  7472. },"useData":true});
  7473. this["mura"]["templates"]["paging"] = this.mura.Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7474. var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7475. return "<button class=\""
  7476. + alias4(((helper = (helper = helpers["class"] || (depth0 != null ? depth0["class"] : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"class","hash":{},"data":data}) : helper)))
  7477. + "\" type=\"button\" data-page=\""
  7478. + alias4(((helper = (helper = helpers.page || (depth0 != null ? depth0.page : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"page","hash":{},"data":data}) : helper)))
  7479. + "\">"
  7480. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7481. + "</button> ";
  7482. },"useData":true});
  7483. this["mura"]["templates"]["radio"] = this.mura.Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
  7484. return " <ins>Required</ins>";
  7485. },"3":function(container,depth0,helpers,partials,data,blockParams,depths) {
  7486. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7487. return " <label for=\""
  7488. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7489. + "\" class=\"radio\">\n <input type=\"radio\" name=\""
  7490. + alias4(container.lambda((depths[1] != null ? depths[1].name : depths[1]), depth0))
  7491. + "id\" id=\"field-"
  7492. + alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
  7493. + "\" value=\""
  7494. + alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
  7495. + "\" "
  7496. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isselected : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7497. + "/>\n "
  7498. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7499. + "</label>\n";
  7500. },"4":function(container,depth0,helpers,partials,data) {
  7501. return "checked='checked'";
  7502. },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) {
  7503. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7504. return " <div class=\""
  7505. + ((stack1 = ((helper = (helper = helpers.inputWrapperClass || (depth0 != null ? depth0.inputWrapperClass : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"inputWrapperClass","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7506. + "\" id=\"field-"
  7507. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7508. + "-container\">\n <div class=\"mura-radio-group\">\n <div class=\"mura-group-label\">"
  7509. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7510. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isrequired : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7511. + "</div>\n"
  7512. + ((stack1 = helpers.each.call(alias1,((stack1 = (depth0 != null ? depth0.dataset : depth0)) != null ? stack1.options : stack1),{"name":"each","hash":{},"fn":container.program(3, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7513. + " </div>\n </div>\n";
  7514. },"useData":true,"useDepths":true});
  7515. this["mura"]["templates"]["radio_static"] = this.mura.Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
  7516. return " <ins>Required</ins>";
  7517. },"3":function(container,depth0,helpers,partials,data,blockParams,depths) {
  7518. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7519. return " <label for=\""
  7520. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7521. + "\" class=\"radio\">\n <input type=\"radio\" name=\""
  7522. + alias4(container.lambda((depths[1] != null ? depths[1].name : depths[1]), depth0))
  7523. + "\" id=\"field-"
  7524. + alias4(((helper = (helper = helpers.datarecordid || (depth0 != null ? depth0.datarecordid : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"datarecordid","hash":{},"data":data}) : helper)))
  7525. + "\" value=\""
  7526. + alias4(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper)))
  7527. + "\" "
  7528. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isselected : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7529. + "/>\n "
  7530. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7531. + "</label>\n";
  7532. },"4":function(container,depth0,helpers,partials,data) {
  7533. return "checked='checked'";
  7534. },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) {
  7535. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7536. return " <div class=\""
  7537. + ((stack1 = ((helper = (helper = helpers.inputWrapperClass || (depth0 != null ? depth0.inputWrapperClass : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"inputWrapperClass","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7538. + "\" id=\"field-"
  7539. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7540. + "-container\">\n <div class=\"mura-radio-group\">\n <div class=\"mura-group-label\">"
  7541. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7542. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isrequired : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7543. + "</div>\n"
  7544. + ((stack1 = (helpers.eachStatic || (depth0 && depth0.eachStatic) || alias2).call(alias1,(depth0 != null ? depth0.dataset : depth0),{"name":"eachStatic","hash":{},"fn":container.program(3, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7545. + " </div>\n </div>\n";
  7546. },"useData":true,"useDepths":true});
  7547. this["mura"]["templates"]["section"] = this.mura.Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7548. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7549. return "<div class=\""
  7550. + ((stack1 = ((helper = (helper = helpers.inputWrapperClass || (depth0 != null ? depth0.inputWrapperClass : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"inputWrapperClass","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7551. + "\" id=\"field-"
  7552. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7553. + "-container\">\r\n<div class=\"mura-section\">"
  7554. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7555. + "</div>\r\n<div class=\"mura-divide\"></div>\r\n</div>";
  7556. },"useData":true});
  7557. this["mura"]["templates"]["success"] = this.mura.Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7558. var stack1, helper;
  7559. return "<div class=\"mura-response-success\">"
  7560. + ((stack1 = ((helper = (helper = helpers.responsemessage || (depth0 != null ? depth0.responsemessage : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"responsemessage","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7561. + "</div>\n";
  7562. },"useData":true});
  7563. this["mura"]["templates"]["table"] = this.mura.Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
  7564. var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7565. return "<option value=\""
  7566. + alias4(((helper = (helper = helpers.num || (depth0 != null ? depth0.num : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"num","hash":{},"data":data}) : helper)))
  7567. + "\" "
  7568. + alias4(((helper = (helper = helpers.selected || (depth0 != null ? depth0.selected : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"selected","hash":{},"data":data}) : helper)))
  7569. + ">"
  7570. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7571. + "</option>";
  7572. },"3":function(container,depth0,helpers,partials,data) {
  7573. var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7574. return " <option value=\""
  7575. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7576. + "\" "
  7577. + alias4(((helper = (helper = helpers.selected || (depth0 != null ? depth0.selected : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"selected","hash":{},"data":data}) : helper)))
  7578. + ">"
  7579. + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
  7580. + "</option>\n";
  7581. },"5":function(container,depth0,helpers,partials,data) {
  7582. var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7583. return " <th class='data-sort' data-value='"
  7584. + alias4(((helper = (helper = helpers.column || (depth0 != null ? depth0.column : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"column","hash":{},"data":data}) : helper)))
  7585. + "'>"
  7586. + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
  7587. + "</th>\n";
  7588. },"7":function(container,depth0,helpers,partials,data,blockParams,depths) {
  7589. var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing;
  7590. return " <tr class=\"even\">\n"
  7591. + ((stack1 = (helpers.eachColRow || (depth0 && depth0.eachColRow) || alias2).call(alias1,depth0,(depths[1] != null ? depths[1].columns : depths[1]),{"name":"eachColRow","hash":{},"fn":container.program(8, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7592. + " <td>\n"
  7593. + ((stack1 = (helpers.eachColButton || (depth0 && depth0.eachColButton) || alias2).call(alias1,depth0,{"name":"eachColButton","hash":{},"fn":container.program(10, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7594. + " </td>\n </tr>\n";
  7595. },"8":function(container,depth0,helpers,partials,data) {
  7596. return " <td>"
  7597. + container.escapeExpression(container.lambda(depth0, depth0))
  7598. + "</td>\n";
  7599. },"10":function(container,depth0,helpers,partials,data) {
  7600. var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7601. return " <button type=\"button\" class=\""
  7602. + alias4(((helper = (helper = helpers.type || (depth0 != null ? depth0.type : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"type","hash":{},"data":data}) : helper)))
  7603. + "\" data-value=\""
  7604. + alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper)))
  7605. + "\" data-pos=\""
  7606. + alias4(((helper = (helper = helpers.index || (data && data.index)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"index","hash":{},"data":data}) : helper)))
  7607. + "\">"
  7608. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7609. + "</button>\n";
  7610. },"12":function(container,depth0,helpers,partials,data) {
  7611. var stack1;
  7612. return " <button class='data-nav' data-value=\""
  7613. + container.escapeExpression(container.lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.rows : depth0)) != null ? stack1.links : stack1)) != null ? stack1.first : stack1), depth0))
  7614. + "\">First</button>\n";
  7615. },"14":function(container,depth0,helpers,partials,data) {
  7616. var stack1;
  7617. return " <button class='data-nav' data-value=\""
  7618. + container.escapeExpression(container.lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.rows : depth0)) != null ? stack1.links : stack1)) != null ? stack1.previous : stack1), depth0))
  7619. + "\">Prev</button>\n";
  7620. },"16":function(container,depth0,helpers,partials,data) {
  7621. var stack1;
  7622. return " <button class='data-nav' data-value=\""
  7623. + container.escapeExpression(container.lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.rows : depth0)) != null ? stack1.links : stack1)) != null ? stack1.next : stack1), depth0))
  7624. + "\">Next</button>\n";
  7625. },"18":function(container,depth0,helpers,partials,data) {
  7626. var stack1;
  7627. return " <button class='data-nav' data-value=\""
  7628. + container.escapeExpression(container.lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.rows : depth0)) != null ? stack1.links : stack1)) != null ? stack1.last : stack1), depth0))
  7629. + "\">Last</button>\n";
  7630. },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) {
  7631. var stack1, alias1=container.lambda, alias2=container.escapeExpression, alias3=depth0 != null ? depth0 : {}, alias4=helpers.helperMissing;
  7632. return " <div class=\"mura-control-group\">\n <div id=\"filter-results-container\">\n <div id=\"date-filters\">\n <div class=\"control-group\">\n <label>From</label>\n <div class=\"controls\">\n <input type=\"text\" class=\"datepicker mura-date\" id=\"date1\" name=\"date1\" validate=\"date\" value=\""
  7633. + alias2(alias1(((stack1 = (depth0 != null ? depth0.filters : depth0)) != null ? stack1.fromdate : stack1), depth0))
  7634. + "\">\n <select id=\"hour1\" name=\"hour1\" class=\"mura-date\">"
  7635. + ((stack1 = (helpers.eachHour || (depth0 && depth0.eachHour) || alias4).call(alias3,((stack1 = (depth0 != null ? depth0.filters : depth0)) != null ? stack1.fromhour : stack1),{"name":"eachHour","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7636. + "</select></select>\n </div>\n </div>\n \n <div class=\"control-group\">\n <label>To</label>\n <div class=\"controls\">\n <input type=\"text\" class=\"datepicker mura-date\" id=\"date2\" name=\"date2\" validate=\"date\" value=\""
  7637. + alias2(alias1(((stack1 = (depth0 != null ? depth0.filters : depth0)) != null ? stack1.todate : stack1), depth0))
  7638. + "\">\n <select id=\"hour2\" name=\"hour2\" class=\"mura-date\">"
  7639. + ((stack1 = (helpers.eachHour || (depth0 && depth0.eachHour) || alias4).call(alias3,((stack1 = (depth0 != null ? depth0.filters : depth0)) != null ? stack1.tohour : stack1),{"name":"eachHour","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7640. + "</select></select>\n </select>\n </div>\n </div>\n </div>\n \n <div class=\"control-group\">\n <label>Keywords</label>\n <div class=\"controls\">\n <select name=\"filterBy\" class=\"mura-date\" id=\"results-filterby\">\n"
  7641. + ((stack1 = (helpers.eachKey || (depth0 && depth0.eachKey) || alias4).call(alias3,(depth0 != null ? depth0.properties : depth0),((stack1 = (depth0 != null ? depth0.filters : depth0)) != null ? stack1.filterby : stack1),{"name":"eachKey","hash":{},"fn":container.program(3, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7642. + " </select>\n <input type=\"text\" class=\"mura-half\" name=\"keywords\" id=\"results-keywords\" value=\""
  7643. + alias2(alias1(((stack1 = (depth0 != null ? depth0.filters : depth0)) != null ? stack1.filterkey : stack1), depth0))
  7644. + "\">\n </div>\n </div>\n <div class=\"form-actions\">\n <button type=\"button\" class=\"btn\" id=\"btn-results-search\" ><i class=\"mi-bar-chart\"></i> View Data</button>\n <button type=\"button\" class=\"btn\" id=\"btn-results-download\" ><i class=\"mi-download\"></i> Download</button>\n </div>\n </div>\n <div>\n\n <ul class=\"metadata\">\n <li>Page:\n <strong>"
  7645. + alias2(alias1(((stack1 = (depth0 != null ? depth0.rows : depth0)) != null ? stack1.pageindex : stack1), depth0))
  7646. + " of "
  7647. + alias2(alias1(((stack1 = (depth0 != null ? depth0.rows : depth0)) != null ? stack1.totalpages : stack1), depth0))
  7648. + "</strong>\n </li>\n <li>Total Records:\n <strong>"
  7649. + alias2(alias1(((stack1 = (depth0 != null ? depth0.rows : depth0)) != null ? stack1.totalitems : stack1), depth0))
  7650. + "</strong>\n </li>\n </ul>\n\n <table style=\"width: 100%\" class=\"table\">\n <thead>\n <tr>\n"
  7651. + ((stack1 = helpers.each.call(alias3,(depth0 != null ? depth0.columns : depth0),{"name":"each","hash":{},"fn":container.program(5, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7652. + " <th></th>\n </tr>\n </thead>\n <tbody>\n"
  7653. + ((stack1 = helpers.each.call(alias3,((stack1 = (depth0 != null ? depth0.rows : depth0)) != null ? stack1.items : stack1),{"name":"each","hash":{},"fn":container.program(7, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7654. + " </tbody>\n <tfoot>\n <tr>\n <td>\n"
  7655. + ((stack1 = helpers["if"].call(alias3,((stack1 = ((stack1 = (depth0 != null ? depth0.rows : depth0)) != null ? stack1.links : stack1)) != null ? stack1.first : stack1),{"name":"if","hash":{},"fn":container.program(12, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7656. + ((stack1 = helpers["if"].call(alias3,((stack1 = ((stack1 = (depth0 != null ? depth0.rows : depth0)) != null ? stack1.links : stack1)) != null ? stack1.previous : stack1),{"name":"if","hash":{},"fn":container.program(14, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7657. + ((stack1 = helpers["if"].call(alias3,((stack1 = ((stack1 = (depth0 != null ? depth0.rows : depth0)) != null ? stack1.links : stack1)) != null ? stack1.next : stack1),{"name":"if","hash":{},"fn":container.program(16, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7658. + ((stack1 = helpers["if"].call(alias3,((stack1 = ((stack1 = (depth0 != null ? depth0.rows : depth0)) != null ? stack1.links : stack1)) != null ? stack1.last : stack1),{"name":"if","hash":{},"fn":container.program(18, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7659. + " </td>\n </tfoot>\n </table>\n</div>";
  7660. },"useData":true,"useDepths":true});
  7661. this["mura"]["templates"]["textarea"] = this.mura.Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
  7662. return " <ins>Required</ins>";
  7663. },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7664. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7665. return "<div class=\""
  7666. + ((stack1 = ((helper = (helper = helpers.inputWrapperClass || (depth0 != null ? depth0.inputWrapperClass : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"inputWrapperClass","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7667. + "\" id=\"field-"
  7668. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7669. + "-container\">\r\n <label for=\""
  7670. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7671. + "\">"
  7672. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7673. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isrequired : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7674. + "</label>\r\n <textarea "
  7675. + ((stack1 = ((helper = (helper = helpers.commonInputAttributes || (depth0 != null ? depth0.commonInputAttributes : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"commonInputAttributes","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7676. + ">"
  7677. + alias4(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper)))
  7678. + "</textarea>\r\n</div>\r\n";
  7679. },"useData":true});
  7680. this["mura"]["templates"]["textblock"] = this.mura.Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7681. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function";
  7682. return "<div class=\""
  7683. + ((stack1 = ((helper = (helper = helpers.inputWrapperClass || (depth0 != null ? depth0.inputWrapperClass : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"inputWrapperClass","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7684. + "\" id=\"field-"
  7685. + container.escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7686. + "-container\">\r\n<div class=\"mura-form-text\">"
  7687. + ((stack1 = ((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7688. + "</div>\r\n</div>";
  7689. },"useData":true});
  7690. this["mura"]["templates"]["textfield"] = this.mura.Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
  7691. return " <ins>Required</ins>";
  7692. },"3":function(container,depth0,helpers,partials,data) {
  7693. var helper;
  7694. return " placeholder=\""
  7695. + container.escapeExpression(((helper = (helper = helpers.placeholder || (depth0 != null ? depth0.placeholder : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"placeholder","hash":{},"data":data}) : helper)))
  7696. + "\"";
  7697. },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7698. var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7699. return "<div class=\""
  7700. + ((stack1 = ((helper = (helper = helpers.inputWrapperClass || (depth0 != null ? depth0.inputWrapperClass : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"inputWrapperClass","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7701. + "\" id=\"field-"
  7702. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7703. + "-container\">\r\n <label for=\""
  7704. + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
  7705. + "\">"
  7706. + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper)))
  7707. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isrequired : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7708. + "</label>\r\n <input type=\"text\" "
  7709. + ((stack1 = ((helper = (helper = helpers.commonInputAttributes || (depth0 != null ? depth0.commonInputAttributes : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"commonInputAttributes","hash":{},"data":data}) : helper))) != null ? stack1 : "")
  7710. + " value=\""
  7711. + alias4(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper)))
  7712. + "\""
  7713. + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.placeholder : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7714. + "/>\r\n</div>\r\n";
  7715. },"useData":true});
  7716. this["mura"]["templates"]["view"] = this.mura.Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
  7717. var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
  7718. return " <li>\n <strong>"
  7719. + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
  7720. + ": </strong> "
  7721. + alias4(((helper = (helper = helpers.displayValue || (depth0 != null ? depth0.displayValue : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayValue","hash":{},"data":data}) : helper)))
  7722. + " \n </li>\n";
  7723. },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
  7724. var stack1;
  7725. return "<div class=\"mura-control-group\">\n<ul>\n"
  7726. + ((stack1 = (helpers.eachProp || (depth0 && depth0.eachProp) || helpers.helperMissing).call(depth0 != null ? depth0 : {},depth0,{"name":"eachProp","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
  7727. + "</ul>\n<button type=\"button\" class=\"nav-back\">Back</button>\n</div>";
  7728. },"useData":true});