PageRenderTime 39ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/files/maxmertkit/1.0.5/js/maxmertkit.js

https://gitlab.com/Mirros/jsdelivr
JavaScript | 1674 lines | 1474 code | 199 blank | 1 comment | 362 complexity | a3b377bd91750eb9b5d36bb802417be8 MD5 | raw file
  1. (function() {
  2. "use strict";
  3. var MaxmertkitEvent, MaxmertkitHelpers, MaxmertkitReactor, isInDOM, _eventCallbackId, _eventCallbacks, _eventHandlers, _id, _reactor, _reactorEvents;
  4. _eventHandlers = [];
  5. _eventCallbacks = [];
  6. _reactorEvents = [];
  7. _eventCallbackId = 0;
  8. _id = 0;
  9. isInDOM = function(el) {
  10. var html;
  11. html = document.body.parentNode;
  12. while (el) {
  13. if (el === html) {
  14. return true;
  15. }
  16. el = el.parentNode;
  17. }
  18. return false;
  19. };
  20. MaxmertkitEvent = (function() {
  21. function MaxmertkitEvent(name) {
  22. this.name = name;
  23. this.callbacks = new Array();
  24. }
  25. MaxmertkitEvent.prototype.registerCallback = function(callback, el, id) {
  26. return this.callbacks.push({
  27. id: id,
  28. el: el,
  29. callback: callback
  30. });
  31. };
  32. MaxmertkitEvent.prototype.removeCallback = function(id) {
  33. var cb, index, _i, _len, _ref, _results;
  34. _ref = this.callbacks;
  35. _results = [];
  36. for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) {
  37. cb = _ref[index];
  38. if ((cb != null) && cb.id === id) {
  39. _results.push(this.callbacks.splice(index, 1));
  40. } else {
  41. _results.push(void 0);
  42. }
  43. }
  44. return _results;
  45. };
  46. return MaxmertkitEvent;
  47. })();
  48. MaxmertkitReactor = (function() {
  49. function MaxmertkitReactor() {}
  50. MaxmertkitReactor.prototype.events = _reactorEvents;
  51. MaxmertkitReactor.prototype.registerEvent = function(eventName) {
  52. var event;
  53. event = new MaxmertkitEvent(eventName);
  54. if (this.events[eventName] == null) {
  55. return this.events[eventName] = event;
  56. }
  57. };
  58. MaxmertkitReactor.prototype.dispatchEvent = function(eventName, eventArgs) {
  59. var callback, index, _i, _len, _ref, _results;
  60. _ref = this.events[eventName].callbacks;
  61. _results = [];
  62. for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) {
  63. callback = _ref[index];
  64. if (isInDOM(callback.el)) {
  65. _results.push(callback.callback(eventArgs));
  66. } else {
  67. _results.push(this.events[eventName].removeCallback(callback.id));
  68. }
  69. }
  70. return _results;
  71. };
  72. MaxmertkitReactor.prototype.removeEventListener = function(eventName, callbackId) {
  73. if (this.events[eventName] != null) {
  74. return this.events[eventName].removeCallback(callbackId);
  75. }
  76. };
  77. MaxmertkitReactor.prototype.addEventListener = function(eventName, callback, el, immediately) {
  78. var eventId, i, timer;
  79. eventId = _eventCallbackId++;
  80. if (this.events[eventName] != null) {
  81. this.events[eventName].registerCallback(callback, el, eventId);
  82. } else {
  83. i = 0;
  84. timer = setInterval((function(_this) {
  85. return function() {
  86. if (i < 10) {
  87. if (_this.events[eventName] != null) {
  88. if ((immediately != null) && immediately) {
  89. callback();
  90. }
  91. _this.events[eventName].registerCallback(callback, el, eventId);
  92. clearInterval(timer);
  93. return timer = null;
  94. } else {
  95. return i++;
  96. }
  97. } else {
  98. clearInterval(timer);
  99. return timer = null;
  100. }
  101. };
  102. })(this), 1000);
  103. }
  104. return eventId;
  105. };
  106. return MaxmertkitReactor;
  107. })();
  108. _reactor = new MaxmertkitReactor();
  109. MaxmertkitHelpers = (function() {
  110. MaxmertkitHelpers.prototype._id = null;
  111. MaxmertkitHelpers.prototype._instances = new Array();
  112. MaxmertkitHelpers.prototype.reactor = _reactor;
  113. function MaxmertkitHelpers(el, options) {
  114. this.el = el;
  115. this.options = options;
  116. this._pushInstance();
  117. }
  118. MaxmertkitHelpers.prototype.destroy = function() {
  119. this._popInstance();
  120. this._destroy(this);
  121. return true;
  122. };
  123. MaxmertkitHelpers.prototype._delete = function(object) {
  124. var key, value, _results;
  125. _results = [];
  126. for (key in object) {
  127. value = object[key];
  128. _results.push(delete object[key]);
  129. }
  130. return _results;
  131. };
  132. MaxmertkitHelpers.prototype._destroy = function(object) {
  133. this._delete(object);
  134. object = null;
  135. return true;
  136. };
  137. MaxmertkitHelpers.prototype._pushInstance = function() {
  138. this._id = _id++;
  139. return this._instances.push(this);
  140. };
  141. MaxmertkitHelpers.prototype._popInstance = function() {
  142. var index, instance, _i, _len, _ref, _results;
  143. _ref = this._instances;
  144. _results = [];
  145. for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) {
  146. instance = _ref[index];
  147. if ((instance != null ? instance._id : void 0) === this._id) {
  148. this._instances.splice(index, 1);
  149. }
  150. _results.push(delete this);
  151. }
  152. return _results;
  153. };
  154. MaxmertkitHelpers.prototype._setOptions = function(options) {
  155. return console.warning("Maxmertkit Helpers. There is no standart setOptions function.");
  156. };
  157. MaxmertkitHelpers.prototype._extend = function(object, properties) {
  158. var key, val;
  159. for (key in properties) {
  160. val = properties[key];
  161. object[key] = val;
  162. }
  163. return object;
  164. };
  165. MaxmertkitHelpers.prototype._merge = function(options, overrides) {
  166. return this._extend(this._extend({}, options), overrides);
  167. };
  168. MaxmertkitHelpers.prototype._selfish = function() {
  169. var index, instance, _i, _len, _ref, _results;
  170. _ref = this._instances;
  171. _results = [];
  172. for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) {
  173. instance = _ref[index];
  174. if (this._id !== instance._id) {
  175. _results.push((typeof instance.close === "function" ? instance.close() : void 0) || (typeof instance.deactivate === "function" ? instance.deactivate() : void 0));
  176. } else {
  177. _results.push(void 0);
  178. }
  179. }
  180. return _results;
  181. };
  182. MaxmertkitHelpers.prototype._isMobile = function() {
  183. return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent);
  184. };
  185. MaxmertkitHelpers.prototype._removeEventListener = function(el, eventName, handler) {
  186. if (el.removeEventListener) {
  187. el.removeEventListener(eventName, handler, false);
  188. } else {
  189. el.detachEvent("on" + eventName, handler);
  190. }
  191. };
  192. MaxmertkitHelpers.prototype._addEventListener = function(el, eventName, handler) {
  193. if (el.addEventListener) {
  194. el.addEventListener(eventName, handler, false);
  195. } else {
  196. el.attachEvent("on" + eventName, function() {
  197. handler.call(el);
  198. });
  199. }
  200. };
  201. MaxmertkitHelpers.prototype._isInDOM = isInDOM;
  202. MaxmertkitHelpers.prototype._hasClass = function(className, el) {
  203. el = el || this.el;
  204. if (el.classList) {
  205. return el.classList.contains(className);
  206. } else {
  207. return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
  208. }
  209. };
  210. MaxmertkitHelpers.prototype._addClass = function(className, el) {
  211. var classes, classin, _i, _len, _results;
  212. el = el || this.el;
  213. if (el.classList != null) {
  214. classes = className.split(" ");
  215. _results = [];
  216. for (_i = 0, _len = classes.length; _i < _len; _i++) {
  217. classin = classes[_i];
  218. _results.push(el.classList.add(classin));
  219. }
  220. return _results;
  221. } else {
  222. return el.className += ' ' + className;
  223. }
  224. };
  225. MaxmertkitHelpers.prototype._removeClass = function(className, el) {
  226. var classes, classin, _i, _len, _results;
  227. el = el || this.el;
  228. if (el.classList) {
  229. classes = className.split(" ");
  230. _results = [];
  231. for (_i = 0, _len = classes.length; _i < _len; _i++) {
  232. classin = classes[_i];
  233. _results.push(el.classList.remove(classin));
  234. }
  235. return _results;
  236. } else {
  237. return el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
  238. }
  239. };
  240. MaxmertkitHelpers.prototype._closest = function(selector, el) {
  241. var matchesSelector;
  242. el = el || this.el;
  243. matchesSelector = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
  244. while (el) {
  245. if (matchesSelector.bind(el)(selector)) {
  246. return el;
  247. } else {
  248. el = el.parentElement;
  249. }
  250. }
  251. return false;
  252. };
  253. MaxmertkitHelpers.prototype._outerWidth = function(el) {
  254. var style, width;
  255. el = el || this.el;
  256. width = el.offsetWidth;
  257. try {
  258. style = el.currentStyle || getComputedStyle(el);
  259. } catch (_error) {}
  260. if (style) {
  261. if ((style.paddingLeft != null) && style.paddingLeft !== '') {
  262. width += parseInt(style.paddingLeft);
  263. }
  264. if ((style.paddingRight != null) && style.paddingRight !== '') {
  265. width += parseInt(style.paddingRight);
  266. }
  267. }
  268. return width;
  269. };
  270. MaxmertkitHelpers.prototype._outerHeight = function(el) {
  271. var height, style;
  272. el = el || this.el;
  273. height = el.offsetHeight;
  274. try {
  275. style = el.currentStyle || getComputedStyle(el);
  276. } catch (_error) {}
  277. if (style != null) {
  278. if ((style.paddingTop != null) && style.paddingTop !== '') {
  279. height += parseInt(style.paddingTop);
  280. }
  281. if ((style.paddingBottom != null) && style.paddingBottom !== '') {
  282. height += parseInt(style.paddingBottom);
  283. }
  284. }
  285. return height;
  286. };
  287. MaxmertkitHelpers.prototype._getPosition = function(el) {
  288. var curleft, curtop, style;
  289. el = el || this.el;
  290. curleft = curtop = 0;
  291. if (el.offsetParent) {
  292. while (true) {
  293. /* FIXME: Not sure if it needed to calculate with style margin */
  294. try {
  295. style = el.currentStyle || getComputedStyle(el);
  296. } catch (_error) {}
  297. curleft += el.offsetLeft;
  298. curtop += el.offsetTop;
  299. if (!(el = el.offsetParent)) {
  300. break;
  301. }
  302. }
  303. }
  304. return {
  305. left: curleft,
  306. top: curtop
  307. };
  308. };
  309. MaxmertkitHelpers.prototype._getContainer = function(el) {
  310. var parent, style;
  311. parent = el || this.el;
  312. try {
  313. style = getComputedStyle(parent);
  314. } catch (_error) {}
  315. if (style == null) {
  316. return parent;
  317. }
  318. if (/(relative|fixed)/.test(style['position'])) {
  319. return parent;
  320. }
  321. while ((parent != null) && (parent = parent.parentNode)) {
  322. try {
  323. style = getComputedStyle(parent);
  324. } catch (_error) {}
  325. if (style == null) {
  326. return parent;
  327. }
  328. if (/(relative|fixed)/.test(style['position'])) {
  329. return parent;
  330. }
  331. }
  332. return document;
  333. };
  334. MaxmertkitHelpers.prototype._getScrollContainer = function(el) {
  335. var parent, style;
  336. parent = el || this.el;
  337. try {
  338. style = getComputedStyle(parent);
  339. } catch (_error) {}
  340. if (style == null) {
  341. return parent;
  342. }
  343. if (/(auto|scroll)/.test(style['overflow'] + style['overflow-y'] + style['overflow-x']) && parent.nodeName !== 'BODY') {
  344. return parent;
  345. }
  346. while (parent = parent.parentNode) {
  347. try {
  348. style = getComputedStyle(parent);
  349. } catch (_error) {}
  350. if (style == null) {
  351. return parent;
  352. }
  353. if (/(auto|scroll)/.test(style['overflow'] + style['overflow-y'] + style['overflow-x']) && parent.nodeName !== 'BODY') {
  354. return parent;
  355. }
  356. }
  357. return document;
  358. };
  359. MaxmertkitHelpers.prototype._setCSSTransform = function(el, transform) {
  360. el = el || this.el;
  361. el.style.webkitTransform = transform;
  362. el.style.mozTransform = transform;
  363. el.style.msTransform = transform;
  364. el.style.oTransform = transform;
  365. return el.style.transform = transform;
  366. };
  367. MaxmertkitHelpers.prototype._setCSSFilter = function(el, filter) {
  368. el = el || this.el;
  369. el.style.webkitFilter = filter;
  370. el.style.mozFilter = filter;
  371. el.style.msFilter = filter;
  372. el.style.oFilter = filter;
  373. return el.style.filter = filter;
  374. };
  375. MaxmertkitHelpers.prototype._setCSSOpacity = function(el, opacity) {
  376. el = el || this.el;
  377. el.style.webkitOpacity = opacity;
  378. el.style.mozOpacity = opacity;
  379. el.style.msOpacity = opacity;
  380. el.style.oOpacity = opacity;
  381. return el.style.opacity = opacity;
  382. };
  383. return MaxmertkitHelpers;
  384. })();
  385. (function() {
  386. var lastTime, vendors, x;
  387. lastTime = 0;
  388. vendors = ["ms", "moz", "webkit", "o"];
  389. x = 0;
  390. while (x < vendors.length && !window.requestAnimationFrame) {
  391. window.requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"];
  392. window.cancelAnimationFrame = window[vendors[x] + "CancelAnimationFrame"] || window[vendors[x] + "CancelRequestAnimationFrame"];
  393. ++x;
  394. }
  395. if (!window.requestAnimationFrame) {
  396. window.requestAnimationFrame = function(callback, element) {
  397. var currTime, id, timeToCall;
  398. currTime = new Date().getTime();
  399. timeToCall = Math.max(0, 16 - (currTime - lastTime));
  400. id = window.setTimeout(function() {
  401. callback(currTime + timeToCall);
  402. }, timeToCall);
  403. lastTime = currTime + timeToCall;
  404. return id;
  405. };
  406. }
  407. if (!window.cancelAnimationFrame) {
  408. window.cancelAnimationFrame = function(id) {
  409. clearTimeout(id);
  410. };
  411. }
  412. })();
  413. Function.prototype.bind = Function.prototype.bind || function(d) {
  414. var a, b, c;
  415. a = Array.prototype.splice.call(arguments, 1);
  416. c = this;
  417. b = function() {
  418. var e;
  419. e = a.concat(Array.prototype.splice.call(arguments, 0));
  420. if (!(this instanceof b)) {
  421. return c.apply(d, e);
  422. }
  423. c.apply(this, e);
  424. };
  425. b.prototype = c.prototype;
  426. return b;
  427. };
  428. window['MaxmertkitHelpers'] = MaxmertkitHelpers;
  429. window['MaxmertkitReactor'] = MaxmertkitReactor;
  430. window['MaxmertkitEvent'] = MaxmertkitEvent;
  431. }).call(this);
  432. (function() {
  433. "use strict";
  434. var MaxmertkitHelpers, Modal, _activate, _backdropClick, _beforeactivate, _beforedeactivate, _deactivate, _id, _instances, _name, _pushStart, _pushStop,
  435. __hasProp = {}.hasOwnProperty,
  436. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  437. _name = "modal";
  438. _instances = [];
  439. _id = 0;
  440. MaxmertkitHelpers = window['MaxmertkitHelpers'];
  441. Modal = (function(_super) {
  442. __extends(Modal, _super);
  443. Modal.prototype._name = _name;
  444. Modal.prototype._instances = _instances;
  445. Modal.prototype.enabled = true;
  446. Modal.prototype.opened = false;
  447. function Modal(el, options) {
  448. var _options;
  449. this.el = el;
  450. this.options = options;
  451. _options = {
  452. toggle: this.el.getAttribute('data-toggle') || _name,
  453. target: this.el.getAttribute('data-target') || null,
  454. dialog: this.el.getAttribute('data-dialog') || ".-dialog",
  455. event: this.el.getAttribute('data-event') || "click",
  456. eventClose: this.el.getAttribute('data-event-close') || "click",
  457. backdrop: this.el.getAttribute('data-backdrop') || false,
  458. push: this.el.getAttribute('data-push') || false,
  459. autoOpen: this.el.getAttribute('data-autoopen') || false,
  460. selfish: this.el.getAttribute('data-selfish') || true,
  461. beforeactive: function() {},
  462. onactive: function() {},
  463. failactive: function() {},
  464. beforedeactive: function() {},
  465. ondeactive: function() {},
  466. faildeactive: function() {}
  467. };
  468. this.options = this._merge(_options, this.options);
  469. this.target = document.querySelector(this.options.target);
  470. this.reactor.registerEvent("initialize." + _name);
  471. this.reactor.registerEvent("open." + _name);
  472. this.reactor.registerEvent("close." + _name);
  473. this.dialog = this.target.querySelector(this.options.dialog);
  474. this.closers = document.querySelectorAll("[data-dismiss='" + this.options.target + "']");
  475. this.closerF = this.close.bind(this);
  476. this.clickerF = this.clicker.bind(this);
  477. this.backdropClickF = _backdropClick.bind(this);
  478. this._setOptions(this.options);
  479. Modal.__super__.constructor.call(this, this.el, this.options);
  480. this.reactor.dispatchEvent("initialize." + _name);
  481. if (this.options.autoOpen) {
  482. this.open();
  483. }
  484. }
  485. Modal.prototype.destroy = function() {
  486. var closer, _i, _len, _ref;
  487. this._removeEventListener(this.el, this.options.event, this.clickerF);
  488. _ref = this.closers;
  489. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  490. closer = _ref[_i];
  491. this._removeEventListener(closer, this.options.eventClose, this.closerF(this));
  492. }
  493. this.el.data["kitModal"] = null;
  494. return Modal.__super__.destroy.apply(this, arguments);
  495. };
  496. Modal.prototype._setOptions = function(options) {
  497. var closer, key, value, _i, _len, _ref;
  498. for (key in options) {
  499. value = options[key];
  500. if (this.options[key] == null) {
  501. return console.error("Maxmertkit Modal. You're trying to set unpropriate option – " + key);
  502. }
  503. switch (key) {
  504. case 'event':
  505. this._removeEventListener(this.el, this.options.event, this.clickerF);
  506. this._addEventListener(this.el, value, this.clickerF);
  507. break;
  508. case 'eventClose':
  509. _ref = this.closers;
  510. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  511. closer = _ref[_i];
  512. this._removeEventListener(closer, this.options.eventClose, this.closerF);
  513. this._addEventListener(closer, value, this.closerF);
  514. }
  515. break;
  516. case 'backdrop':
  517. if (this.options.backdrop) {
  518. this._removeEventListener(this.el, "click", this.backdropClickF);
  519. }
  520. if (value) {
  521. this._addEventListener(this.el, "click", this.backdropClickF);
  522. }
  523. break;
  524. case 'push':
  525. if (value) {
  526. this.push = document.querySelectorAll(value);
  527. } else {
  528. this.push = false;
  529. }
  530. }
  531. this.options[key] = value;
  532. if (typeof value === 'function') {
  533. this[key] = value;
  534. }
  535. }
  536. };
  537. Modal.prototype.clicker = function() {
  538. if (!this.opened) {
  539. return this.open();
  540. } else {
  541. return this.close();
  542. }
  543. };
  544. Modal.prototype.open = function() {
  545. return this.activate();
  546. };
  547. Modal.prototype.close = function() {
  548. return this.deactivate();
  549. };
  550. Modal.prototype.activate = function() {
  551. if (this.enabled && !this.opened) {
  552. return _beforeactivate.call(this);
  553. }
  554. };
  555. Modal.prototype.deactivate = function() {
  556. if (this.enabled && this.opened) {
  557. return _beforedeactivate.call(this);
  558. }
  559. };
  560. Modal.prototype.disable = function() {
  561. return this.enabled = false;
  562. };
  563. Modal.prototype.enable = function() {
  564. return this.enabled = true;
  565. };
  566. return Modal;
  567. })(MaxmertkitHelpers);
  568. _pushStart = function() {
  569. if (this.push) {
  570. this._addClass('-start--', this.push);
  571. return this._removeClass('-stop--', this.push);
  572. }
  573. };
  574. _pushStop = function() {
  575. if (this.push) {
  576. this._addClass('-stop--', this.push);
  577. this._removeClass('-start--', this.push);
  578. if (this.push && (this.push.style != null) && (this.push.style['-webkit-overflow-scrolling'] != null)) {
  579. return this.push.style['-webkit-overflow-scrolling'] = 'auto';
  580. }
  581. }
  582. };
  583. _backdropClick = function(event) {
  584. if (this._hasClass('-modal', event.target) && this.opened) {
  585. return this.close();
  586. }
  587. };
  588. _beforeactivate = function() {
  589. var deferred;
  590. if (this.options.selfish) {
  591. this._selfish();
  592. }
  593. if (this.beforeactive != null) {
  594. try {
  595. deferred = this.beforeactive.call(this.el);
  596. return deferred.done((function(_this) {
  597. return function() {
  598. return _activate.call(_this);
  599. };
  600. })(this)).fail((function(_this) {
  601. return function() {
  602. var _ref;
  603. return (_ref = _this.faildeactive) != null ? _ref.call(_this.el) : void 0;
  604. };
  605. })(this));
  606. } catch (_error) {
  607. return _activate.call(this);
  608. }
  609. } else {
  610. return _activate.call(this);
  611. }
  612. };
  613. _activate = function() {
  614. var _ref;
  615. if (this.push) {
  616. this._addClass('_perspective_', document.body);
  617. }
  618. this._addClass('_no-scroll_', document.body);
  619. this.target.style.display = 'table';
  620. this._addClass('_visible_ -start--', this.target);
  621. this._addClass('_visible_ -start--', this.dialog);
  622. _pushStart.call(this);
  623. if ((_ref = this.onactive) != null) {
  624. _ref.call(this.el);
  625. }
  626. this.reactor.dispatchEvent("open." + _name);
  627. return this.opened = true;
  628. };
  629. _beforedeactivate = function() {
  630. var deferred;
  631. if (this.beforedeactive != null) {
  632. try {
  633. deferred = this.beforedeactive.call(this.el);
  634. return deferred.done((function(_this) {
  635. return function() {
  636. return _deactivate.call(_this);
  637. };
  638. })(this)).fail((function(_this) {
  639. return function() {
  640. var _ref;
  641. return (_ref = _this.faildeactive) != null ? _ref.call(_this.el) : void 0;
  642. };
  643. })(this));
  644. } catch (_error) {
  645. return _deactivate.call(this);
  646. }
  647. } else {
  648. return _deactivate.call(this);
  649. }
  650. };
  651. _deactivate = function() {
  652. var _ref;
  653. this._addClass('-stop--', this.target);
  654. this._addClass('-stop--', this.dialog);
  655. _pushStop.call(this);
  656. setTimeout((function(_this) {
  657. return function() {
  658. _this._removeClass('_visible_ -start-- -stop--', _this.target);
  659. _this._removeClass('_visible_ -start-- -stop--', _this.dialog);
  660. _this._removeClass('_no-scroll_', document.body);
  661. if (_this.push) {
  662. _this._removeClass('_perspective_', document.body);
  663. }
  664. return _this.target.style.display = 'none';
  665. };
  666. })(this), 1000);
  667. this.reactor.dispatchEvent("close." + _name);
  668. if ((_ref = this.ondeactive) != null) {
  669. _ref.call(this.el);
  670. }
  671. return this.opened = false;
  672. };
  673. window['Modal'] = Modal;
  674. window['mkitModal'] = function(options) {
  675. var result;
  676. result = null;
  677. if (this.data == null) {
  678. this.data = {};
  679. }
  680. if (!this.data['kitModal']) {
  681. result = new Modal(this, options);
  682. this.data['kitModal'] = result;
  683. } else {
  684. if (typeof options === 'object') {
  685. this.data['kitModal']._setOptions(options);
  686. } else {
  687. if (typeof options === "string" && options.charAt(0) !== "_") {
  688. this.data['kitModal'][options];
  689. }
  690. }
  691. result = this.data['kitModal'];
  692. }
  693. return result;
  694. };
  695. if (typeof Element !== "undefined" && Element !== null) {
  696. Element.prototype.modal = window['mkitModal'];
  697. }
  698. if (typeof jQuery !== "undefined" && jQuery !== null) {
  699. $.fn[_name] = function(options) {
  700. return this.each(function() {
  701. return window['mkitModal'].call(this, options);
  702. });
  703. };
  704. }
  705. }).call(this);
  706. (function() {
  707. "use strict";
  708. var MaxmertkitHelpers, Skyline, _activate, _beforeactivate, _beforedeactivate, _deactivate, _getWindowSize, _id, _instances, _lastScrollY, _name, _onResize, _onScroll, _requestResize, _requestTick, _resizing, _spy, _windowSize,
  709. __hasProp = {}.hasOwnProperty,
  710. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  711. _name = "skyline";
  712. _instances = [];
  713. _id = 0;
  714. _lastScrollY = 0;
  715. _windowSize = 0;
  716. MaxmertkitHelpers = window['MaxmertkitHelpers'];
  717. Skyline = (function(_super) {
  718. __extends(Skyline, _super);
  719. Skyline.prototype._name = _name;
  720. Skyline.prototype._instances = _instances;
  721. Skyline.prototype.started = false;
  722. Skyline.prototype.active = false;
  723. function Skyline(el, options) {
  724. var _options;
  725. this.el = el;
  726. this.options = options;
  727. _options = {
  728. spy: this.el.getAttribute('data-spy') || _name,
  729. offset: this.el.getAttribute('data-offset') || 5,
  730. delay: this.el.getAttribute('data-delay') || 300,
  731. onMobile: this.el.getAttribute('data-on-mobile') || false,
  732. beforeactive: function() {},
  733. onactive: function() {},
  734. failactive: function() {},
  735. beforedeactive: function() {},
  736. ondeactive: function() {},
  737. faildeactive: function() {}
  738. };
  739. this.options = this._merge(_options, this.options);
  740. this.ticking = false;
  741. this.resizingTick = false;
  742. this.scroller = this._getScrollContainer(this.el);
  743. this.spy = _spy.bind(this);
  744. this.onScroll = _onScroll.bind(this);
  745. this.onResize = _onResize.bind(this);
  746. this.resizing = _resizing.bind(this);
  747. this._setOptions(this.options);
  748. Skyline.__super__.constructor.call(this, this.el, this.options);
  749. this._addEventListener(window, 'resize', this.onResize);
  750. this.reactor.registerEvent("initialize." + _name);
  751. this.reactor.registerEvent("start." + _name);
  752. this.reactor.registerEvent("stop." + _name);
  753. this.reactor.dispatchEvent("initialize." + _name);
  754. if (!(!this.options.onMobile && _getWindowSize().width < 992)) {
  755. this.start(this.deactivate);
  756. }
  757. }
  758. Skyline.prototype.destroy = function() {
  759. _deactivate.call(this);
  760. this.el.data["kitSkyline"] = null;
  761. return Skyline.__super__.destroy.apply(this, arguments);
  762. };
  763. Skyline.prototype._setOptions = function(options) {
  764. var key, value;
  765. for (key in options) {
  766. value = options[key];
  767. if (this.options[key] == null) {
  768. return console.error("Maxmertkit Skyline. You're trying to set unpropriate option – " + key);
  769. }
  770. this.options[key] = value;
  771. if (typeof value === 'function') {
  772. this[key] = value;
  773. }
  774. }
  775. };
  776. Skyline.prototype.start = function(cb) {
  777. if (!this.started) {
  778. return _beforeactivate.call(this, cb);
  779. }
  780. };
  781. Skyline.prototype.stop = function(cb) {
  782. if (this.started) {
  783. return _beforedeactivate.call(this, cb);
  784. }
  785. };
  786. Skyline.prototype.activate = function() {
  787. var delay;
  788. if (typeof this.options.delay === 'function') {
  789. delay = this.options.delay();
  790. } else {
  791. delay = this.options.delay;
  792. }
  793. return this.timer = setTimeout((function(_this) {
  794. return function() {
  795. _this._addClass('-start--');
  796. _this._removeClass('-stop--');
  797. return _this.active = true;
  798. };
  799. })(this), delay);
  800. };
  801. Skyline.prototype.deactivate = function() {
  802. if (this.timer != null) {
  803. clearTimeout(this.timer);
  804. this.timer = null;
  805. }
  806. this._removeClass('-start-- _active_');
  807. this._addClass('-stop--');
  808. return this.active = false;
  809. };
  810. Skyline.prototype.refresh = function() {
  811. _windowSize = _getWindowSize();
  812. return this.spyParams = {
  813. offset: this._getPosition(this.el),
  814. height: this._outerHeight()
  815. };
  816. };
  817. return Skyline;
  818. })(MaxmertkitHelpers);
  819. _onResize = function() {
  820. return _requestResize.call(this);
  821. };
  822. _requestResize = function() {
  823. if (!this.resizingTick) {
  824. if (this.resizing != null) {
  825. requestAnimationFrame(this.resizing);
  826. return this.resizingTick = true;
  827. }
  828. }
  829. };
  830. _resizing = function() {
  831. this.refresh();
  832. if (!this.options.onMobile) {
  833. if (_getWindowSize().width < 992) {
  834. this.stop(this.activate);
  835. } else {
  836. this.start();
  837. }
  838. }
  839. return this.resizingTick = false;
  840. };
  841. _getWindowSize = function() {
  842. var clientHeight, clientWidth;
  843. clientWidth = 0;
  844. clientHeight = 0;
  845. if (typeof window.innerWidth === "number") {
  846. clientWidth = window.innerWidth;
  847. clientHeight = window.innerHeight;
  848. } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
  849. clientWidth = document.documentElement.clientWidth;
  850. clientHeight = document.documentElement.clientHeight;
  851. } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
  852. clientWidth = document.body.clientWidth;
  853. clientHeight = document.body.clientHeight;
  854. }
  855. return {
  856. width: clientWidth,
  857. height: clientHeight
  858. };
  859. };
  860. _onScroll = function(event) {
  861. _lastScrollY = event.target.nodeName === '#document' ? (document.documentElement && document.documentElement.scrollTop) || event.target.body.scrollTop : event.target.scrollTop;
  862. return _requestTick.call(this);
  863. };
  864. _requestTick = function() {
  865. if (!this.ticking) {
  866. requestAnimationFrame(this.spy);
  867. return this.ticking = true;
  868. }
  869. };
  870. _spy = function() {
  871. var _ref;
  872. if ((this.spyParams.offset.top - _windowSize.height <= (_ref = _lastScrollY + this.options.offset) && _ref <= this.spyParams.offset.top + this.spyParams.height)) {
  873. if (!this.active) {
  874. this.activate();
  875. }
  876. } else {
  877. if (this.active) {
  878. this.deactivate();
  879. }
  880. }
  881. return this.ticking = false;
  882. };
  883. _beforeactivate = function(cb) {
  884. var deferred;
  885. if (this.beforeactive != null) {
  886. try {
  887. deferred = this.beforeactive.call(this.el);
  888. return deferred.done((function(_this) {
  889. return function() {
  890. return _activate.call(_this, cb);
  891. };
  892. })(this)).fail((function(_this) {
  893. return function() {
  894. var _ref;
  895. return (_ref = _this.failactive) != null ? _ref.call(_this.el) : void 0;
  896. };
  897. })(this));
  898. } catch (_error) {
  899. return _activate.call(this, cb);
  900. }
  901. } else {
  902. return _activate.call(this, cb);
  903. }
  904. };
  905. _activate = function(cb) {
  906. var _ref;
  907. this.refresh();
  908. this._addEventListener(this.scroller, 'scroll', this.onScroll);
  909. if ((_ref = this.onactive) != null) {
  910. _ref.call(this.el);
  911. }
  912. this.reactor.dispatchEvent("start." + _name);
  913. this.started = true;
  914. if (cb != null) {
  915. cb.call(this);
  916. }
  917. return setTimeout((function(_this) {
  918. return function() {
  919. return _this.refresh();
  920. };
  921. })(this), 100);
  922. };
  923. _beforedeactivate = function(cb) {
  924. var deferred;
  925. if (this.beforedeactive != null) {
  926. try {
  927. deferred = this.beforedeactive.call(this.el);
  928. return deferred.done((function(_this) {
  929. return function() {
  930. return _deactivate.call(_this, cb);
  931. };
  932. })(this)).fail((function(_this) {
  933. return function() {
  934. var _ref;
  935. return (_ref = _this.faildeactive) != null ? _ref.call(_this.el) : void 0;
  936. };
  937. })(this));
  938. } catch (_error) {
  939. return _deactivate.call(this, cb);
  940. }
  941. } else {
  942. return _deactivate.call(this, cb);
  943. }
  944. };
  945. _deactivate = function(cb) {
  946. var _ref;
  947. this._removeEventListener(this.scroller, 'scroll', this.onScroll);
  948. this.reactor.dispatchEvent("stop." + _name);
  949. if ((_ref = this.ondeactive) != null) {
  950. _ref.call(this.el);
  951. }
  952. this.started = false;
  953. if (cb != null) {
  954. return cb.call(this);
  955. }
  956. };
  957. window['Skyline'] = Skyline;
  958. window['mkitSkyline'] = function(options) {
  959. var result;
  960. result = null;
  961. if (this.data == null) {
  962. this.data = {};
  963. }
  964. if (!this.data['kitSkyline']) {
  965. result = new Skyline(this, options);
  966. this.data['kitSkyline'] = result;
  967. } else {
  968. if (typeof options === 'object') {
  969. this.data['kitSkyline']._setOptions(options);
  970. } else {
  971. if (typeof options === "string" && options.charAt(0) !== "_") {
  972. this.data['kitSkyline'][options];
  973. }
  974. }
  975. result = this.data['kitSkyline'];
  976. }
  977. return result;
  978. };
  979. if (typeof Element !== "undefined" && Element !== null) {
  980. Element.prototype.skyline = window['mkitSkyline'];
  981. }
  982. if (typeof jQuery !== "undefined" && jQuery !== null) {
  983. $.fn[_name] = function(options) {
  984. return this.each(function() {
  985. return window['mkitSkyline'].call(this, options);
  986. });
  987. };
  988. }
  989. }).call(this);
  990. (function() {
  991. "use strict";
  992. var Affix, MaxmertkitHelpers, _activate, _beforeactivate, _beforedeactivate, _deactivate, _getWindowSize, _id, _instances, _lastScrollY, _name, _onResize, _onScroll, _requestResize, _requestTick, _resizing, _resizingTick, _setPosition, _setPositionAbsolute, _setPositionFixed, _setPositionRelative, _ticking,
  993. __hasProp = {}.hasOwnProperty,
  994. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  995. _name = "affix";
  996. _instances = [];
  997. _id = 0;
  998. _lastScrollY = 0;
  999. _ticking = false;
  1000. _resizingTick = false;
  1001. MaxmertkitHelpers = window['MaxmertkitHelpers'];
  1002. Affix = (function(_super) {
  1003. __extends(Affix, _super);
  1004. Affix.prototype._name = _name;
  1005. Affix.prototype._instances = _instances;
  1006. Affix.prototype.started = false;
  1007. function Affix(el, options) {
  1008. var _options;
  1009. this.el = el;
  1010. this.options = options;
  1011. _options = {
  1012. spy: this.el.getAttribute('data-spy') || _name,
  1013. offset: this.el.getAttribute('data-offset') || 5,
  1014. onMobile: this.el.getAttribute('data-on-mobile') || false,
  1015. beforeactive: function() {},
  1016. onactive: function() {},
  1017. failactive: function() {},
  1018. beforedeactive: function() {},
  1019. ondeactive: function() {},
  1020. faildeactive: function() {}
  1021. };
  1022. this.options = this._merge(_options, this.options);
  1023. this._setOptions(this.options);
  1024. Affix.__super__.constructor.call(this, this.el, this.options);
  1025. this.scroller = this._getScrollContainer();
  1026. this.container = this._getContainer();
  1027. this.onScroll = _onScroll.bind(this);
  1028. this.setPosition = _setPosition.bind(this);
  1029. this.onResize = _onResize.bind(this);
  1030. this.resizing = _resizing.bind(this);
  1031. this._addEventListener(window, 'resize', this.onResize);
  1032. this.reactor.registerEvent("initialize." + _name);
  1033. this.reactor.registerEvent("start." + _name);
  1034. this.reactor.registerEvent("stop." + _name);
  1035. this.reactor.dispatchEvent("initialize." + _name);
  1036. if (!(!this.options.onMobile && _getWindowSize().width < 992)) {
  1037. this.start();
  1038. }
  1039. }
  1040. Affix.prototype.destroy = function() {
  1041. _deactivate.call(this);
  1042. this.el.data["kitAffix"] = null;
  1043. return Affix.__super__.destroy.apply(this, arguments);
  1044. };
  1045. Affix.prototype.start = function() {
  1046. if (!this.started) {
  1047. return _beforeactivate.call(this);
  1048. }
  1049. };
  1050. Affix.prototype.stop = function() {
  1051. if (this.started) {
  1052. return _beforedeactivate.call(this);
  1053. }
  1054. };
  1055. Affix.prototype._setOptions = function(options) {
  1056. var key, value;
  1057. for (key in options) {
  1058. value = options[key];
  1059. if (this.options[key] == null) {
  1060. return console.error("Maxmertkit Affix. You're trying to set unpropriate option – " + key);
  1061. }
  1062. this.options[key] = value;
  1063. if (typeof value === 'function') {
  1064. this[key] = value;
  1065. }
  1066. }
  1067. };
  1068. Affix.prototype.refresh = function() {
  1069. this.HEIGHT = this._outerHeight();
  1070. return this.CONTAINER_HEIGHT = this._outerHeight(this.container);
  1071. };
  1072. return Affix;
  1073. })(MaxmertkitHelpers);
  1074. _onResize = function() {
  1075. return _requestResize.call(this);
  1076. };
  1077. _requestResize = function() {
  1078. if (!_resizingTick) {
  1079. if (this.resizing != null) {
  1080. requestAnimationFrame(this.resizing);
  1081. return _resizingTick = true;
  1082. }
  1083. }
  1084. };
  1085. _resizing = function() {
  1086. if (!this.options.onMobile) {
  1087. if (_getWindowSize().width < 992) {
  1088. this.stop();
  1089. _setPositionRelative.call(this);
  1090. } else {
  1091. this.refresh();
  1092. this.start();
  1093. }
  1094. }
  1095. return _resizingTick = false;
  1096. };
  1097. _getWindowSize = function() {
  1098. var clientHeight, clientWidth;
  1099. clientWidth = 0;
  1100. clientHeight = 0;
  1101. if (typeof window.innerWidth === "number") {
  1102. clientWidth = window.innerWidth;
  1103. clientHeight = window.innerHeight;
  1104. } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
  1105. clientWidth = document.documentElement.clientWidth;
  1106. clientHeight = document.documentElement.clientHeight;
  1107. } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
  1108. clientWidth = document.body.clientWidth;
  1109. clientHeight = document.body.clientHeight;
  1110. }
  1111. return {
  1112. width: clientWidth,
  1113. height: clientHeight
  1114. };
  1115. };
  1116. _onScroll = function(event) {
  1117. _lastScrollY = event.target.nodeName === '#document' ? (document.documentElement && document.documentElement.scrollTop) || event.target.body.scrollTop : event.target.scrollTop;
  1118. return _requestTick.call(this);
  1119. };
  1120. _requestTick = function() {
  1121. if (!_ticking) {
  1122. requestAnimationFrame(this.setPosition);
  1123. return _ticking = true;
  1124. }
  1125. };
  1126. _beforeactivate = function() {
  1127. var deferred;
  1128. if (this.beforeactive != null) {
  1129. try {
  1130. deferred = this.beforeactive.call(this.el);
  1131. return deferred.done((function(_this) {
  1132. return function() {
  1133. return _activate.call(_this);
  1134. };
  1135. })(this)).fail((function(_this) {
  1136. return function() {
  1137. var _ref;
  1138. return (_ref = _this.failactive) != null ? _ref.call(_this.el) : void 0;
  1139. };
  1140. })(this));
  1141. } catch (_error) {
  1142. return _activate.call(this);
  1143. }
  1144. } else {
  1145. return _activate.call(this);
  1146. }
  1147. };
  1148. _activate = function() {
  1149. var _ref;
  1150. this.refresh();
  1151. this._addEventListener(this.scroller, 'scroll', this.onScroll);
  1152. this._addClass('_active_');
  1153. if ((_ref = this.onactive) != null) {
  1154. _ref.call(this.el);
  1155. }
  1156. this.reactor.dispatchEvent("start." + _name);
  1157. this.started = true;
  1158. return setTimeout((function(_this) {
  1159. return function() {
  1160. return _this.refresh();
  1161. };
  1162. })(this), 100);
  1163. };
  1164. _beforedeactivate = function() {
  1165. var deferred;
  1166. if (this.beforedeactive != null) {
  1167. try {
  1168. deferred = this.beforedeactive.call(this.el);
  1169. return deferred.done((function(_this) {
  1170. return function() {
  1171. return _deactivate.call(_this);
  1172. };
  1173. })(this)).fail((function(_this) {
  1174. return function() {
  1175. var _ref;
  1176. return (_ref = _this.faildeactive) != null ? _ref.call(_this.el) : void 0;
  1177. };
  1178. })(this));
  1179. } catch (_error) {
  1180. return _deactivate.call(this);
  1181. }
  1182. } else {
  1183. return _deactivate.call(this);
  1184. }
  1185. };
  1186. _deactivate = function() {
  1187. var _ref;
  1188. this._removeEventListener(this.scroller, 'scroll', this.onScroll);
  1189. this._removeClass('_active_');
  1190. this.reactor.dispatchEvent("stop." + _name);
  1191. if ((_ref = this.ondeactive) != null) {
  1192. _ref.call(this.el);
  1193. }
  1194. return this.started = false;
  1195. };
  1196. _setPositionFixed = function() {
  1197. var style, top;
  1198. this.el.style.width = this.el.offsetWidth;
  1199. this.el.style.position = 'fixed';
  1200. top = this.options.offset;
  1201. try {
  1202. style = this.el.currentStyle || getComputedStyle(this.el);
  1203. } catch (_error) {}
  1204. if (style != null) {
  1205. if ((style.marginTop != null) && style.marginTop !== '') {
  1206. top += parseInt(style.marginTop);
  1207. }
  1208. }
  1209. this.el.style.top = "" + this.options.offset + "px";
  1210. return this.el.style.bottom = 'auto';
  1211. };
  1212. _setPositionRelative = function() {
  1213. this.el.style.position = 'relative';
  1214. return this.el.style.top = 'inherit';
  1215. };
  1216. _setPositionAbsolute = function() {
  1217. this.el.style.position = 'absolute';
  1218. this.el.style.top = 'auto';
  1219. this.el.style.bottom = "" + this.options.offset + "px";
  1220. return this.el.style.width = this.el.offsetWidth;
  1221. };
  1222. _setPosition = function() {
  1223. var containerTop;
  1224. containerTop = this.container.offsetTop;
  1225. if (containerTop - this.options.offset <= _lastScrollY) {
  1226. if (containerTop + this.CONTAINER_HEIGHT - this.options.offset - this.HEIGHT >= _lastScrollY) {
  1227. if (this.el.style.position !== 'fixed') {
  1228. _setPositionFixed.call(this);
  1229. }
  1230. } else {
  1231. if (this.el.style.position !== 'absolute') {
  1232. if (containerTop + this.CONTAINER_HEIGHT - this.options.offset - this.HEIGHT < _lastScrollY + this.HEIGHT) {
  1233. _setPositionAbsolute.call(this);
  1234. }
  1235. }
  1236. }
  1237. } else {
  1238. if (this.el.style.position !== 'relative') {
  1239. _setPositionRelative.call(this);
  1240. }
  1241. }
  1242. return _ticking = false;
  1243. };
  1244. window['Affix'] = Affix;
  1245. window['mkitAffix'] = function(options) {
  1246. var result;
  1247. result = null;
  1248. if (this.data == null) {
  1249. this.data = {};
  1250. }
  1251. if (!this.data['kitAffix']) {
  1252. result = new Affix(this, options);
  1253. this.data['kitAffix'] = result;
  1254. } else {
  1255. if (typeof options === 'object') {
  1256. this.data['kitAffix']._setOptions(options);
  1257. } else {
  1258. if (typeof options === "string" && options.charAt(0) !== "_") {
  1259. this.data['kitAffix'][options];
  1260. }
  1261. }
  1262. result = this.data['kitAffix'];
  1263. }
  1264. return result;
  1265. };
  1266. if (typeof Element !== "undefined" && Element !== null) {
  1267. Element.prototype.affix = window['mkitAffix'];
  1268. }
  1269. if (typeof jQuery !== "undefined" && jQuery !== null) {
  1270. $.fn[_name] = function(options) {
  1271. return this.each(function() {
  1272. return window['mkitAffix'].call(this, options);
  1273. });
  1274. };
  1275. }
  1276. }).call(this);
  1277. (function() {
  1278. "use strict";
  1279. var Button, MaxmertkitHelpers, _activate, _beforeactivate, _beforedeactivate, _clicker, _deactivate, _id, _instances, _name,
  1280. __hasProp = {}.hasOwnProperty,
  1281. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  1282. _name = "button";
  1283. _instances = [];
  1284. _id = 0;
  1285. MaxmertkitHelpers = window['MaxmertkitHelpers'];
  1286. Button = (function(_super) {
  1287. __extends(Button, _super);
  1288. Button.prototype._name = _name;
  1289. Button.prototype._instances = _instances;
  1290. Button.prototype.active = false;
  1291. Button.prototype.enabled = true;
  1292. function Button(el, options) {
  1293. var _options;
  1294. this.el = el;
  1295. this.options = options;
  1296. _options = {
  1297. toggle: this.el.getAttribute('data-toggle') || _name,
  1298. type: this.el.getAttribute('data-type') || _name,
  1299. group: this.el.getAttribute('data-group') || false,
  1300. event: this.el.getAttribute('data-event') || "click",
  1301. selfish: this.el.getAttribute('data-selfish') || false,
  1302. beforeactive: function() {},
  1303. onactive: function() {},
  1304. failactive: function() {},
  1305. beforedeactive: function() {},
  1306. ondeactive: function() {},
  1307. faildeactive: function() {}
  1308. };
  1309. this.options = this._merge(_options, this.options);
  1310. this.clicker = _clicker.bind(this);
  1311. this._setOptions(this.options);
  1312. Button.__super__.constructor.call(this, this.el, this.options);
  1313. this.reactor.registerEvent("initialize." + _name);
  1314. this.reactor.registerEvent("active." + _name);
  1315. this.reactor.registerEvent("deactive." + _name);
  1316. this.reactor.dispatchEvent("initialize." + _name);
  1317. }
  1318. Button.prototype.destroy = function() {
  1319. this._removeEventListener(this.el, this.options.event, this.clicker);
  1320. this.el.data["kitButton"] = null;
  1321. return Button.__super__.destroy.apply(this, arguments);
  1322. };
  1323. Button.prototype._setOptions = function(options) {
  1324. var key, value;
  1325. for (key in options) {
  1326. value = options[key];
  1327. if (this.options[key] == null) {
  1328. return console.error("Maxmertkit Button. You're trying to set unpropriate option – " + key);
  1329. }
  1330. switch (key) {
  1331. case 'event':
  1332. this._removeEventListener(this.el, this.options.event, this.clicker);
  1333. this._addEventListener(this.el, value, this.clicker);
  1334. }
  1335. this.options[key] = value;
  1336. if (typeof value === 'function') {
  1337. this[key] = value;
  1338. }
  1339. }
  1340. };
  1341. Button.prototype.activate = function() {
  1342. if (this.enabled && !this.active) {
  1343. return _beforeactivate.call(this);
  1344. }
  1345. };
  1346. Button.prototype.deactivate = function() {
  1347. if (this.enabled && this.active) {
  1348. return _beforedeactivate.call(this);
  1349. }
  1350. };
  1351. Button.prototype.disable = function() {
  1352. return this.enabled = false;
  1353. };
  1354. Button.prototype.enable = function() {
  1355. return this.enabled = true;
  1356. };
  1357. return Button;
  1358. })(MaxmertkitHelpers);
  1359. _clicker = function() {
  1360. if (!this.active) {
  1361. return this.activate();
  1362. } else {
  1363. return this.deactivate();
  1364. }
  1365. };
  1366. _beforeactivate = function() {
  1367. var deferred;
  1368. if (this.options.selfish) {
  1369. this._selfish();
  1370. }
  1371. if (this.beforeactive != null) {
  1372. try {
  1373. deferred = this.beforeactive.call(this.el);
  1374. return deferred.done((function(_this) {
  1375. return function() {
  1376. return _activate.call(_this);
  1377. };
  1378. })(this)).fail((function(_this) {
  1379. return function() {
  1380. var _ref;
  1381. return (_ref = _this.faildeactive) != null ? _ref.call(_this.el) : void 0;
  1382. };
  1383. })(this));
  1384. } catch (_error) {
  1385. return _activate.call(this);
  1386. }
  1387. } else {
  1388. return _activate.call(this);
  1389. }
  1390. };
  1391. _activate = function() {
  1392. var button, _i, _len, _ref, _ref1;
  1393. if (this.options.type === 'radio') {
  1394. _ref = this._instances;
  1395. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1396. button = _ref[_i];
  1397. if (this._id !== button._id && button.options.type === 'radio' && button.options.group === this.options.group) {
  1398. button.deactivate();
  1399. }
  1400. }
  1401. }
  1402. this._addClass('_active_');
  1403. if ((_ref1 = this.onactive) != null) {
  1404. _ref1.call(this.el);
  1405. }
  1406. this.reactor.dispatchEvent("active." + _name);
  1407. return this.active = true;
  1408. };
  1409. _beforedeactivate = function() {
  1410. var deferred;
  1411. if (this.beforedeactive != null) {
  1412. try {
  1413. deferred = this.beforedeactive.call(this.el);
  1414. return deferred.done((function(_this) {
  1415. return function() {
  1416. return _deactivate.call(_this);
  1417. };
  1418. })(this)).fail((function(_this) {
  1419. return function() {
  1420. var _ref;
  1421. return (_ref = _this.faildeactive) != null ? _ref.call(_this.el) : void 0;
  1422. };
  1423. })(this));
  1424. } catch (_error) {
  1425. return _deactivate.call(this);
  1426. }
  1427. } else {
  1428. return _deactivate.call(this);
  1429. }
  1430. };
  1431. _deactivate = function() {
  1432. var _ref;
  1433. this._removeClass('_active_');
  1434. this.reactor.dispatchEvent("deactive." + _name);
  1435. if ((_ref = this.ondeactive) != null) {
  1436. _ref.call(this.el);
  1437. }
  1438. return this.active = false;
  1439. };
  1440. window['Button'] = Button;
  1441. window['mkitButton'] = function(options) {
  1442. var result;
  1443. result = null;
  1444. if (this.data == null) {
  1445. this.data = {};
  1446. }
  1447. if (!this.data['kitButton']) {
  1448. result = new Button(this, options);
  1449. this.data['kitButton'] = result;
  1450. } else {
  1451. if (typeof options === 'object') {
  1452. this.data['kitButton']._setOptions(options);
  1453. } else {
  1454. if (typeof options === "string" && options.charAt(0) !== "_") {
  1455. this.data['kitButton'][options];
  1456. }
  1457. }
  1458. result = this.data['kitButton'];
  1459. }
  1460. return result;
  1461. };
  1462. if (typeof Element !== "undefined" && Element !== null) {
  1463. Element.prototype.button = window['mkitButton'];
  1464. }
  1465. if (typeof jQuery !== "undefined" && jQuery !== null) {
  1466. $.fn[_name] = function(options) {
  1467. return this.each(function() {
  1468. return window['mkitButton'].call(this, options);
  1469. });
  1470. };
  1471. }
  1472. }).call(this);
  1473. (function() {
  1474. "use strict";
  1475. var MaxmertkitHelpers, Scrollspy, _activate, _activateItem, _beforeactivate, _beforedeactivate, _deactivate, _deactivateAllItems, _deactivateItem, _getWindowSize, _id, _instances, _lastScrollY, _name, _onResize, _onScroll, _requestResize, _requestTick, _resizing, _resizingTick, _spy, _tickin