DotaNoobs main site.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2277 lines
66 KiB

  1. /*! UIkit 2.5.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
  2. (function(core) {
  3. if (typeof define == "function" && define.amd) { // AMD
  4. define("uikit", function(){
  5. var uikit = core(window, window.jQuery, window.document);
  6. uikit.load = function(res, req, onload, config) {
  7. var resources = res.split(','), load = [], i, base = (config.config && config.config.uikit && config.config.uikit.base ? config.config.uikit.base : "").replace(/\/+$/g, "");
  8. if (!base) {
  9. throw new Error( "Please define base path to uikit in the requirejs config." );
  10. }
  11. for (i = 0; i < resources.length; i += 1) {
  12. var resource = resources[i].replace(/\./g, '/');
  13. load.push(base+'/js/addons/'+resource);
  14. }
  15. req(load, function() {
  16. onload(uikit);
  17. });
  18. };
  19. return uikit;
  20. });
  21. }
  22. if (!window.jQuery) {
  23. throw new Error( "UIkit requires jQuery" );
  24. }
  25. if (window && window.jQuery) {
  26. core(window, window.jQuery, window.document);
  27. }
  28. })(function(global, $, doc) {
  29. "use strict";
  30. var UI = $.UIkit || {}, $html = $("html"), $win = $(window);
  31. if (UI.fn) {
  32. return UI;
  33. }
  34. UI.version = '2.5.0';
  35. UI.fn = function(command, options) {
  36. var args = arguments, cmd = command.match(/^([a-z\-]+)(?:\.([a-z]+))?/i), component = cmd[1], method = cmd[2];
  37. if (!UI[component]) {
  38. $.error("UIkit component [" + component + "] does not exist.");
  39. return this;
  40. }
  41. return this.each(function() {
  42. var $this = $(this), data = $this.data(component);
  43. if (!data) $this.data(component, (data = new UI[component](this, method ? undefined : options)));
  44. if (method) data[method].apply(data, Array.prototype.slice.call(args, 1));
  45. });
  46. };
  47. UI.support = {};
  48. UI.support.transition = (function() {
  49. var transitionEnd = (function() {
  50. var element = doc.body || doc.documentElement,
  51. transEndEventNames = {
  52. WebkitTransition: 'webkitTransitionEnd',
  53. MozTransition: 'transitionend',
  54. OTransition: 'oTransitionEnd otransitionend',
  55. transition: 'transitionend'
  56. }, name;
  57. for (name in transEndEventNames) {
  58. if (element.style[name] !== undefined) return transEndEventNames[name];
  59. }
  60. }());
  61. return transitionEnd && { end: transitionEnd };
  62. })();
  63. UI.support.animation = (function() {
  64. var animationEnd = (function() {
  65. var element = doc.body || doc.documentElement,
  66. animEndEventNames = {
  67. WebkitAnimation: 'webkitAnimationEnd',
  68. MozAnimation: 'animationend',
  69. OAnimation: 'oAnimationEnd oanimationend',
  70. animation: 'animationend'
  71. }, name;
  72. for (name in animEndEventNames) {
  73. if (element.style[name] !== undefined) return animEndEventNames[name];
  74. }
  75. }());
  76. return animationEnd && { end: animationEnd };
  77. })();
  78. UI.support.requestAnimationFrame = global.requestAnimationFrame || global.webkitRequestAnimationFrame || global.mozRequestAnimationFrame || global.msRequestAnimationFrame || global.oRequestAnimationFrame || function(callback){ global.setTimeout(callback, 1000/60); };
  79. UI.support.touch = (
  80. ('ontouchstart' in window && navigator.userAgent.toLowerCase().match(/mobile|tablet/)) ||
  81. (global.DocumentTouch && document instanceof global.DocumentTouch) ||
  82. (global.navigator['msPointerEnabled'] && global.navigator['msMaxTouchPoints'] > 0) || //IE 10
  83. (global.navigator['pointerEnabled'] && global.navigator['maxTouchPoints'] > 0) || //IE >=11
  84. false
  85. );
  86. UI.support.mutationobserver = (global.MutationObserver || global.WebKitMutationObserver || global.MozMutationObserver || null);
  87. UI.Utils = {};
  88. UI.Utils.debounce = function(func, wait, immediate) {
  89. var timeout;
  90. return function() {
  91. var context = this, args = arguments;
  92. var later = function() {
  93. timeout = null;
  94. if (!immediate) func.apply(context, args);
  95. };
  96. var callNow = immediate && !timeout;
  97. clearTimeout(timeout);
  98. timeout = setTimeout(later, wait);
  99. if (callNow) func.apply(context, args);
  100. };
  101. };
  102. UI.Utils.removeCssRules = function(selectorRegEx) {
  103. var idx, idxs, stylesheet, _i, _j, _k, _len, _len1, _len2, _ref;
  104. if(!selectorRegEx) return;
  105. setTimeout(function(){
  106. try {
  107. _ref = document.styleSheets;
  108. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  109. stylesheet = _ref[_i];
  110. idxs = [];
  111. stylesheet.cssRules = stylesheet.cssRules;
  112. for (idx = _j = 0, _len1 = stylesheet.cssRules.length; _j < _len1; idx = ++_j) {
  113. if (stylesheet.cssRules[idx].type === CSSRule.STYLE_RULE && selectorRegEx.test(stylesheet.cssRules[idx].selectorText)) {
  114. idxs.unshift(idx);
  115. }
  116. }
  117. for (_k = 0, _len2 = idxs.length; _k < _len2; _k++) {
  118. stylesheet.deleteRule(idxs[_k]);
  119. }
  120. }
  121. } catch (_error) {}
  122. }, 0);
  123. };
  124. UI.Utils.isInView = function(element, options) {
  125. var $element = $(element);
  126. if (!$element.is(':visible')) {
  127. return false;
  128. }
  129. var window_left = $win.scrollLeft(), window_top = $win.scrollTop(), offset = $element.offset(), left = offset.left, top = offset.top;
  130. options = $.extend({topoffset:0, leftoffset:0}, options);
  131. if (top + $element.height() >= window_top && top - options.topoffset <= window_top + $win.height() &&
  132. left + $element.width() >= window_left && left - options.leftoffset <= window_left + $win.width()) {
  133. return true;
  134. } else {
  135. return false;
  136. }
  137. };
  138. UI.Utils.options = function(string) {
  139. if ($.isPlainObject(string)) return string;
  140. var start = (string ? string.indexOf("{") : -1), options = {};
  141. if (start != -1) {
  142. try {
  143. options = (new Function("", "var json = " + string.substr(start) + "; return JSON.parse(JSON.stringify(json));"))();
  144. } catch (e) {}
  145. }
  146. return options;
  147. };
  148. UI.Utils.template = function(str, data) {
  149. var tokens = str.replace(/\n/g, '\\n').replace(/\{\{\{\s*(.+?)\s*\}\}\}/g, "{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g),
  150. i=0, toc, cmd, prop, val, fn, output = [], openblocks = 0;
  151. while(i < tokens.length) {
  152. toc = tokens[i];
  153. if(toc.match(/\{\{\s*(.+?)\s*\}\}/)) {
  154. i = i + 1;
  155. toc = tokens[i];
  156. cmd = toc[0];
  157. prop = toc.substring(toc.match(/^(\^|\#|\!|\~|\:)/) ? 1:0);
  158. switch(cmd) {
  159. case '~':
  160. output.push("for(var $i=0;$i<"+prop+".length;$i++) { var $item = "+prop+"[$i];");
  161. openblocks++;
  162. break;
  163. case ':':
  164. output.push("for(var $key in "+prop+") { var $val = "+prop+"[$key];");
  165. openblocks++;
  166. break;
  167. case '#':
  168. output.push("if("+prop+") {");
  169. openblocks++;
  170. break;
  171. case '^':
  172. output.push("if(!"+prop+") {");
  173. openblocks++;
  174. break;
  175. case '/':
  176. output.push("}");
  177. openblocks--;
  178. break;
  179. case '!':
  180. output.push("__ret.push("+prop+");");
  181. break;
  182. default:
  183. output.push("__ret.push(escape("+prop+"));");
  184. break;
  185. }
  186. } else {
  187. output.push("__ret.push('"+toc.replace(/\'/g, "\\'")+"');");
  188. }
  189. i = i + 1;
  190. }
  191. fn = [
  192. 'var __ret = [];',
  193. 'try {',
  194. 'with($data){', (!openblocks ? output.join('') : '__ret = ["Not all blocks are closed correctly."]'), '};',
  195. '}catch(e){__ret = [e.message];}',
  196. 'return __ret.join("").replace(/\\n\\n/g, "\\n");',
  197. "function escape(html) { return String(html).replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');}"
  198. ].join("\n");
  199. var func = new Function('$data', fn);
  200. return data ? func(data) : func;
  201. };
  202. UI.Utils.events = {};
  203. UI.Utils.events.click = UI.support.touch ? 'tap' : 'click';
  204. $.UIkit = UI;
  205. $.fn.uk = UI.fn;
  206. $.UIkit.langdirection = $html.attr("dir") == "rtl" ? "right" : "left";
  207. $(function(){
  208. $(doc).trigger("uk-domready");
  209. // Check for dom modifications
  210. if(!UI.support.mutationobserver) return;
  211. var observer = new UI.support.mutationobserver(UI.Utils.debounce(function(mutations) {
  212. $(doc).trigger("uk-domready");
  213. }, 300));
  214. // pass in the target node, as well as the observer options
  215. observer.observe(document.body, { childList: true, subtree: true });
  216. // remove css hover rules for touch devices
  217. if (UI.support.touch) {
  218. UI.Utils.removeCssRules(/\.uk-(?!navbar).*:hover/);
  219. }
  220. });
  221. // add touch identifier class
  222. $html.addClass(UI.support.touch ? "uk-touch" : "uk-notouch");
  223. return UI;
  224. });
  225. (function($, UI) {
  226. "use strict";
  227. var win = $(window), event = 'resize orientationchange';
  228. var StackMargin = function(element, options) {
  229. var $this = this, $element = $(element);
  230. if($element.data("stackMargin")) return;
  231. this.element = $element;
  232. this.columns = this.element.children();
  233. this.options = $.extend({}, StackMargin.defaults, options);
  234. if (!this.columns.length) return;
  235. win.on(event, (function() {
  236. var fn = function() {
  237. $this.process();
  238. };
  239. $(function() {
  240. fn();
  241. win.on("load", fn);
  242. });
  243. return UI.Utils.debounce(fn, 150);
  244. })());
  245. $(document).on("uk-domready", function(e) {
  246. $this.columns = $this.element.children();
  247. $this.process();
  248. });
  249. this.element.data("stackMargin", this);
  250. };
  251. $.extend(StackMargin.prototype, {
  252. process: function() {
  253. var $this = this;
  254. this.revert();
  255. var skip = false,
  256. firstvisible = this.columns.filter(":visible:first"),
  257. offset = firstvisible.length ? firstvisible.offset().top : false;
  258. if (offset === false) return;
  259. this.columns.each(function() {
  260. var column = $(this);
  261. if (column.is(":visible")) {
  262. if (skip) {
  263. column.addClass($this.options.cls);
  264. } else {
  265. if (column.offset().top != offset) {
  266. column.addClass($this.options.cls);
  267. skip = true;
  268. }
  269. }
  270. }
  271. });
  272. return this;
  273. },
  274. revert: function() {
  275. this.columns.removeClass(this.options.cls);
  276. return this;
  277. }
  278. });
  279. StackMargin.defaults = {
  280. 'cls': 'uk-margin-small-top'
  281. };
  282. UI["stackMargin"] = StackMargin;
  283. // init code
  284. $(document).on("uk-domready", function(e) {
  285. $("[data-uk-margin]").each(function() {
  286. var ele = $(this), obj;
  287. if (!ele.data("stackMargin")) {
  288. obj = new StackMargin(ele, UI.Utils.options(ele.attr("data-uk-margin")));
  289. }
  290. });
  291. });
  292. })(jQuery, jQuery.UIkit);
  293. // Based on Zeptos touch.js
  294. // https://raw.github.com/madrobby/zepto/master/src/touch.js
  295. // Zepto.js may be freely distributed under the MIT license.
  296. ;(function($){
  297. var touch = {},
  298. touchTimeout, tapTimeout, swipeTimeout, longTapTimeout,
  299. longTapDelay = 750,
  300. gesture;
  301. function swipeDirection(x1, x2, y1, y2) {
  302. return Math.abs(x1 - x2) >= Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down');
  303. }
  304. function longTap() {
  305. longTapTimeout = null;
  306. if (touch.last) {
  307. touch.el.trigger('longTap');
  308. touch = {};
  309. }
  310. }
  311. function cancelLongTap() {
  312. if (longTapTimeout) clearTimeout(longTapTimeout);
  313. longTapTimeout = null;
  314. }
  315. function cancelAll() {
  316. if (touchTimeout) clearTimeout(touchTimeout);
  317. if (tapTimeout) clearTimeout(tapTimeout);
  318. if (swipeTimeout) clearTimeout(swipeTimeout);
  319. if (longTapTimeout) clearTimeout(longTapTimeout);
  320. touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null;
  321. touch = {};
  322. }
  323. function isPrimaryTouch(event){
  324. return event.pointerType == event.MSPOINTER_TYPE_TOUCH && event.isPrimary;
  325. }
  326. $(function(){
  327. var now, delta, deltaX = 0, deltaY = 0, firstTouch;
  328. if ('MSGesture' in window) {
  329. gesture = new MSGesture();
  330. gesture.target = document.body;
  331. }
  332. $(document)
  333. .bind('MSGestureEnd', function(e){
  334. var swipeDirectionFromVelocity = e.originalEvent.velocityX > 1 ? 'Right' : e.originalEvent.velocityX < -1 ? 'Left' : e.originalEvent.velocityY > 1 ? 'Down' : e.originalEvent.velocityY < -1 ? 'Up' : null;
  335. if (swipeDirectionFromVelocity) {
  336. touch.el.trigger('swipe');
  337. touch.el.trigger('swipe'+ swipeDirectionFromVelocity);
  338. }
  339. })
  340. .on('touchstart MSPointerDown', function(e){
  341. if(e.type == 'MSPointerDown' && !isPrimaryTouch(e.originalEvent)) return;
  342. firstTouch = e.type == 'MSPointerDown' ? e : e.originalEvent.touches[0];
  343. now = Date.now();
  344. delta = now - (touch.last || now);
  345. touch.el = $('tagName' in firstTouch.target ? firstTouch.target : firstTouch.target.parentNode);
  346. if(touchTimeout) clearTimeout(touchTimeout);
  347. touch.x1 = firstTouch.pageX;
  348. touch.y1 = firstTouch.pageY;
  349. if (delta > 0 && delta <= 250) touch.isDoubleTap = true;
  350. touch.last = now;
  351. longTapTimeout = setTimeout(longTap, longTapDelay);
  352. // adds the current touch contact for IE gesture recognition
  353. if (gesture && e.type == 'MSPointerDown') gesture.addPointer(e.originalEvent.pointerId);
  354. })
  355. .on('touchmove MSPointerMove', function(e){
  356. if(e.type == 'MSPointerMove' && !isPrimaryTouch(e.originalEvent)) return;
  357. firstTouch = e.type == 'MSPointerMove' ? e : e.originalEvent.touches[0];
  358. cancelLongTap();
  359. touch.x2 = firstTouch.pageX;
  360. touch.y2 = firstTouch.pageY;
  361. deltaX += Math.abs(touch.x1 - touch.x2);
  362. deltaY += Math.abs(touch.y1 - touch.y2);
  363. })
  364. .on('touchend MSPointerUp', function(e){
  365. if(e.type == 'MSPointerUp' && !isPrimaryTouch(e.originalEvent)) return;
  366. cancelLongTap();
  367. // swipe
  368. if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) || (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30)){
  369. swipeTimeout = setTimeout(function() {
  370. touch.el.trigger('swipe');
  371. touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)));
  372. touch = {};
  373. }, 0);
  374. // normal tap
  375. } else if ('last' in touch) {
  376. // don't fire tap when delta position changed by more than 30 pixels,
  377. // for instance when moving to a point and back to origin
  378. if (isNaN(deltaX) || (deltaX < 30 && deltaY < 30)) {
  379. // delay by one tick so we can cancel the 'tap' event if 'scroll' fires
  380. // ('tap' fires before 'scroll')
  381. tapTimeout = setTimeout(function() {
  382. // trigger universal 'tap' with the option to cancelTouch()
  383. // (cancelTouch cancels processing of single vs double taps for faster 'tap' response)
  384. var event = $.Event('tap');
  385. event.cancelTouch = cancelAll;
  386. touch.el.trigger(event);
  387. // trigger double tap immediately
  388. if (touch.isDoubleTap) {
  389. touch.el.trigger('doubleTap');
  390. touch = {};
  391. }
  392. // trigger single tap after 250ms of inactivity
  393. else {
  394. touchTimeout = setTimeout(function(){
  395. touchTimeout = null;
  396. touch.el.trigger('singleTap');
  397. touch = {};
  398. }, 250);
  399. }
  400. }, 0);
  401. } else {
  402. touch = {};
  403. }
  404. deltaX = deltaY = 0;
  405. }
  406. })
  407. // when the browser window loses focus,
  408. // for example when a modal dialog is shown,
  409. // cancel all ongoing events
  410. .on('touchcancel MSPointerCancel', cancelAll);
  411. // scrolling the window indicates intention of the user
  412. // to scroll, not tap or swipe, so cancel all ongoing events
  413. $(window).on('scroll', cancelAll);
  414. });
  415. ['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(eventName){
  416. $.fn[eventName] = function(callback){ return $(this).on(eventName, callback); };
  417. });
  418. })(jQuery);
  419. (function($, UI) {
  420. "use strict";
  421. var Alert = function(element, options) {
  422. var $this = this;
  423. this.options = $.extend({}, Alert.defaults, options);
  424. this.element = $(element);
  425. if(this.element.data("alert")) return;
  426. this.element.on("click", this.options.trigger, function(e) {
  427. e.preventDefault();
  428. $this.close();
  429. });
  430. this.element.data("alert", this);
  431. };
  432. $.extend(Alert.prototype, {
  433. close: function() {
  434. var element = this.element.trigger("close");
  435. if (this.options.fade) {
  436. element.css("overflow", "hidden").css("max-height", element.height()).animate({
  437. "height": 0,
  438. "opacity": 0,
  439. "padding-top": 0,
  440. "padding-bottom": 0,
  441. "margin-top": 0,
  442. "margin-bottom": 0
  443. }, this.options.duration, removeElement);
  444. } else {
  445. removeElement();
  446. }
  447. function removeElement() {
  448. element.trigger("closed").remove();
  449. }
  450. }
  451. });
  452. Alert.defaults = {
  453. "fade": true,
  454. "duration": 200,
  455. "trigger": ".uk-alert-close"
  456. };
  457. UI["alert"] = Alert;
  458. // init code
  459. $(document).on("click.alert.uikit", "[data-uk-alert]", function(e) {
  460. var ele = $(this);
  461. if (!ele.data("alert")) {
  462. var alert = new Alert(ele, UI.Utils.options(ele.data("uk-alert")));
  463. if ($(e.target).is(ele.data("alert").options.trigger)) {
  464. e.preventDefault();
  465. alert.close();
  466. }
  467. }
  468. });
  469. })(jQuery, jQuery.UIkit);
  470. (function($, UI) {
  471. "use strict";
  472. var ButtonRadio = function(element, options) {
  473. var $this = this, $element = $(element);
  474. if($element.data("buttonRadio")) return;
  475. this.options = $.extend({}, ButtonRadio.defaults, options);
  476. this.element = $element.on("click", this.options.target, function(e) {
  477. e.preventDefault();
  478. $element.find($this.options.target).not(this).removeClass("uk-active").blur();
  479. $element.trigger("change", [$(this).addClass("uk-active")]);
  480. });
  481. this.element.data("buttonRadio", this);
  482. };
  483. $.extend(ButtonRadio.prototype, {
  484. getSelected: function() {
  485. this.element.find(".uk-active");
  486. }
  487. });
  488. ButtonRadio.defaults = {
  489. "target": ".uk-button"
  490. };
  491. var ButtonCheckbox = function(element, options) {
  492. var $element = $(element);
  493. if($element.data("buttonCheckbox")) return;
  494. this.options = $.extend({}, ButtonCheckbox.defaults, options);
  495. this.element = $element.on("click", this.options.target, function(e) {
  496. e.preventDefault();
  497. $element.trigger("change", [$(this).toggleClass("uk-active").blur()]);
  498. });
  499. this.element.data("buttonCheckbox", this);
  500. };
  501. $.extend(ButtonCheckbox.prototype, {
  502. getSelected: function() {
  503. this.element.find(".uk-active");
  504. }
  505. });
  506. ButtonCheckbox.defaults = {
  507. "target": ".uk-button"
  508. };
  509. var Button = function(element, options) {
  510. var $this = this, $element = $(element);
  511. if($element.data("button")) return;
  512. this.options = $.extend({}, Button.defaults, options);
  513. this.element = $element.on("click", function(e) {
  514. e.preventDefault();
  515. $this.toggle();
  516. $element.trigger("change", [$element.blur().hasClass("uk-active")]);
  517. });
  518. this.element.data("button", this);
  519. };
  520. $.extend(Button.prototype, {
  521. options: {},
  522. toggle: function() {
  523. this.element.toggleClass("uk-active");
  524. }
  525. });
  526. Button.defaults = {};
  527. UI["button"] = Button;
  528. UI["buttonCheckbox"] = ButtonCheckbox;
  529. UI["buttonRadio"] = ButtonRadio;
  530. // init code
  531. $(document).on("click.buttonradio.uikit", "[data-uk-button-radio]", function(e) {
  532. var ele = $(this);
  533. if (!ele.data("buttonRadio")) {
  534. var obj = new ButtonRadio(ele, UI.Utils.options(ele.attr("data-uk-button-radio")));
  535. if ($(e.target).is(obj.options.target)) {
  536. $(e.target).trigger("click");
  537. }
  538. }
  539. });
  540. $(document).on("click.buttoncheckbox.uikit", "[data-uk-button-checkbox]", function(e) {
  541. var ele = $(this);
  542. if (!ele.data("buttonCheckbox")) {
  543. var obj = new ButtonCheckbox(ele, UI.Utils.options(ele.attr("data-uk-button-checkbox")));
  544. if ($(e.target).is(obj.options.target)) {
  545. $(e.target).trigger("click");
  546. }
  547. }
  548. });
  549. $(document).on("click.button.uikit", "[data-uk-button]", function(e) {
  550. var ele = $(this);
  551. if (!ele.data("button")) {
  552. var obj = new Button(ele, ele.attr("data-uk-button"));
  553. ele.trigger("click");
  554. }
  555. });
  556. })(jQuery, jQuery.UIkit);
  557. (function($, UI) {
  558. "use strict";
  559. var active = false,
  560. Dropdown = function(element, options) {
  561. var $this = this, $element = $(element);
  562. if($element.data("dropdown")) return;
  563. this.options = $.extend({}, Dropdown.defaults, options);
  564. this.element = $element;
  565. this.dropdown = this.element.find(".uk-dropdown");
  566. this.centered = this.dropdown.hasClass("uk-dropdown-center");
  567. this.justified = this.options.justify ? $(this.options.justify) : false;
  568. this.boundary = $(this.options.boundary);
  569. if(!this.boundary.length) {
  570. this.boundary = $(window);
  571. }
  572. if (this.options.mode == "click" || UI.support.touch) {
  573. this.element.on("click", function(e) {
  574. var $target = $(e.target);
  575. if (!$target.parents(".uk-dropdown").length) {
  576. if ($target.is("a[href='#']") || $target.parent().is("a[href='#']")){
  577. e.preventDefault();
  578. }
  579. $target.blur();
  580. }
  581. if (!$this.element.hasClass("uk-open")) {
  582. $this.show();
  583. } else {
  584. if ($target.is("a") || !$this.element.find(".uk-dropdown").find(e.target).length) {
  585. $this.element.removeClass("uk-open");
  586. active = false;
  587. }
  588. }
  589. });
  590. } else {
  591. this.element.on("mouseenter", function(e) {
  592. if ($this.remainIdle) {
  593. clearTimeout($this.remainIdle);
  594. }
  595. $this.show();
  596. }).on("mouseleave", function() {
  597. $this.remainIdle = setTimeout(function() {
  598. $this.element.removeClass("uk-open");
  599. $this.remainIdle = false;
  600. if (active && active[0] == $this.element[0]) active = false;
  601. }, $this.options.remaintime);
  602. });
  603. }
  604. this.element.data("dropdown", this);
  605. };
  606. $.extend(Dropdown.prototype, {
  607. remainIdle: false,
  608. show: function(){
  609. if (active && active[0] != this.element[0]) {
  610. active.removeClass("uk-open");
  611. }
  612. this.checkDimensions();
  613. this.element.addClass("uk-open");
  614. active = this.element;
  615. this.registerOuterClick();
  616. },
  617. registerOuterClick: function(){
  618. var $this = this;
  619. $(document).off("click.outer.dropdown");
  620. setTimeout(function() {
  621. $(document).on("click.outer.dropdown", function(e) {
  622. if (active && active[0] == $this.element[0] && ($(e.target).is("a") || !$this.element.find(".uk-dropdown").find(e.target).length)) {
  623. active.removeClass("uk-open");
  624. $(document).off("click.outer.dropdown");
  625. }
  626. });
  627. }, 10);
  628. },
  629. checkDimensions: function() {
  630. if(!this.dropdown.length) return;
  631. var dropdown = this.dropdown.css("margin-" + $.UIkit.langdirection, "").css("min-width", ""),
  632. offset = dropdown.show().offset(),
  633. width = dropdown.outerWidth(),
  634. boundarywidth = this.boundary.width(),
  635. boundaryoffset = this.boundary.offset() ? this.boundary.offset().left:0;
  636. // centered dropdown
  637. if (this.centered) {
  638. dropdown.css("margin-" + $.UIkit.langdirection, (parseFloat(width) / 2 - dropdown.parent().width() / 2) * -1);
  639. offset = dropdown.offset();
  640. // reset dropdown
  641. if ((width + offset.left) > boundarywidth || offset.left < 0) {
  642. dropdown.css("margin-" + $.UIkit.langdirection, "");
  643. offset = dropdown.offset();
  644. }
  645. }
  646. // justify dropdown
  647. if (this.justified && this.justified.length) {
  648. var jwidth = this.justified.outerWidth();
  649. dropdown.css("min-width", jwidth);
  650. if ($.UIkit.langdirection == 'right') {
  651. var right1 = boundarywidth - (this.justified.offset().left + jwidth),
  652. right2 = boundarywidth - (dropdown.offset().left + dropdown.outerWidth());
  653. dropdown.css("margin-right", right1 - right2);
  654. } else {
  655. dropdown.css("margin-left", this.justified.offset().left - offset.left);
  656. }
  657. offset = dropdown.offset();
  658. }
  659. if ((width + (offset.left-boundaryoffset)) > boundarywidth) {
  660. dropdown.addClass("uk-dropdown-flip");
  661. offset = dropdown.offset();
  662. }
  663. if (offset.left < 0) {
  664. dropdown.addClass("uk-dropdown-stack");
  665. }
  666. dropdown.css("display", "");
  667. }
  668. });
  669. Dropdown.defaults = {
  670. "mode": "hover",
  671. "remaintime": 800,
  672. "justify": false,
  673. "boundary": $(window)
  674. };
  675. UI["dropdown"] = Dropdown;
  676. var triggerevent = UI.support.touch ? "click":"mouseenter";
  677. // init code
  678. $(document).on(triggerevent+".dropdown.uikit", "[data-uk-dropdown]", function(e) {
  679. var ele = $(this);
  680. if (!ele.data("dropdown")) {
  681. var dropdown = new Dropdown(ele, UI.Utils.options(ele.data("uk-dropdown")));
  682. if (triggerevent=="click" || (triggerevent=="mouseenter" && dropdown.options.mode=="hover")) {
  683. dropdown.show();
  684. }
  685. if(dropdown.element.find('.uk-dropdown').length) {
  686. e.preventDefault();
  687. }
  688. }
  689. });
  690. })(jQuery, jQuery.UIkit);
  691. (function($, UI) {
  692. "use strict";
  693. var win = $(window), event = 'resize orientationchange';
  694. var GridMatchHeight = function(element, options) {
  695. var $this = this, $element = $(element);
  696. if($element.data("gridMatchHeight")) return;
  697. this.options = $.extend({}, GridMatchHeight.defaults, options);
  698. this.element = $element;
  699. this.columns = this.element.children();
  700. this.elements = this.options.target ? this.element.find(this.options.target) : this.columns;
  701. if (!this.columns.length) return;
  702. win.on(event, (function() {
  703. var fn = function() {
  704. $this.match();
  705. };
  706. $(function() {
  707. fn();
  708. win.on("load", fn);
  709. });
  710. return UI.Utils.debounce(fn, 150);
  711. })());
  712. $(document).on("uk-domready", function(e) {
  713. $this.columns = $this.element.children();
  714. $this.elements = $this.options.target ? $this.element.find($this.options.target) : $this.columns;
  715. $this.match();
  716. });
  717. this.element.data("gridMatchHeight", this);
  718. };
  719. $.extend(GridMatchHeight.prototype, {
  720. match: function() {
  721. this.revert();
  722. var firstvisible = this.columns.filter(":visible:first");
  723. if (!firstvisible.length) return;
  724. var stacked = Math.ceil(100 * parseFloat(firstvisible.css('width')) / parseFloat(firstvisible.parent().css('width'))) >= 100 ? true : false,
  725. max = 0,
  726. $this = this;
  727. if (stacked) return;
  728. if(this.options.row) {
  729. this.element.width(); // force redraw
  730. setTimeout(function(){
  731. var lastoffset = false, group = [];
  732. $this.elements.each(function(i) {
  733. var ele = $(this), offset = ele.offset().top;
  734. if(offset != lastoffset && group.length) {
  735. $this.matchHeights($(group));
  736. group = [];
  737. offset = ele.offset().top;
  738. }
  739. group.push(ele);
  740. lastoffset = offset;
  741. });
  742. if(group.length) {
  743. $this.matchHeights($(group));
  744. }
  745. }, 0);
  746. } else {
  747. this.matchHeights(this.elements);
  748. }
  749. return this;
  750. },
  751. revert: function() {
  752. this.elements.css('min-height', '');
  753. return this;
  754. },
  755. matchHeights: function(elements){
  756. if(elements.length < 2) return;
  757. var max = 0;
  758. elements.each(function() {
  759. max = Math.max(max, $(this).outerHeight());
  760. }).each(function(i) {
  761. var element = $(this),
  762. height = max - (element.outerHeight() - element.height());
  763. element.css('min-height', height + 'px');
  764. });
  765. }
  766. });
  767. GridMatchHeight.defaults = {
  768. "target" : false,
  769. "row" : false
  770. };
  771. var GridMargin = function(element, options) {
  772. var $element = $(element);
  773. if($element.data("gridMargin")) return;
  774. this.options = $.extend({}, GridMargin.defaults, options);
  775. var stackMargin = new UI.stackMargin($element, this.options);
  776. $element.data("gridMargin", stackMargin);
  777. };
  778. GridMargin.defaults = {
  779. cls: 'uk-grid-margin'
  780. };
  781. UI["gridMatchHeight"] = GridMatchHeight;
  782. UI["gridMargin"] = GridMargin;
  783. // init code
  784. $(document).on("uk-domready", function(e) {
  785. $("[data-uk-grid-match],[data-uk-grid-margin]").each(function() {
  786. var grid = $(this), obj;
  787. if (grid.is("[data-uk-grid-match]") && !grid.data("gridMatchHeight")) {
  788. obj = new GridMatchHeight(grid, UI.Utils.options(grid.attr("data-uk-grid-match")));
  789. }
  790. if (grid.is("[data-uk-grid-margin]") && !grid.data("gridMargin")) {
  791. obj = new GridMargin(grid, UI.Utils.options(grid.attr("data-uk-grid-margin")));
  792. }
  793. });
  794. });
  795. })(jQuery, jQuery.UIkit);
  796. (function($, UI, $win) {
  797. "use strict";
  798. var active = false,
  799. html = $("html"),
  800. Modal = function(element, options) {
  801. var $this = this;
  802. this.element = $(element);
  803. this.options = $.extend({}, Modal.defaults, options);
  804. this.transition = UI.support.transition;
  805. this.dialog = this.element.find(".uk-modal-dialog");
  806. this.scrollable = (function(){
  807. var scrollable = $this.dialog.find('.uk-overflow-container:first');
  808. return scrollable.length ? scrollable : false;
  809. })();
  810. this.element.on("click", ".uk-modal-close", function(e) {
  811. e.preventDefault();
  812. $this.hide();
  813. }).on("click", function(e) {
  814. var target = $(e.target);
  815. if (target[0] == $this.element[0] && $this.options.bgclose) {
  816. $this.hide();
  817. }
  818. });
  819. };
  820. $.extend(Modal.prototype, {
  821. scrollable: false,
  822. transition: false,
  823. toggle: function() {
  824. return this[this.isActive() ? "hide" : "show"]();
  825. },
  826. show: function() {
  827. var $this = this;
  828. if (this.isActive()) return;
  829. if (active) active.hide(true);
  830. this.element.removeClass("uk-open").show();
  831. this.resize();
  832. active = this;
  833. html.addClass("uk-modal-page").height(); // force browser engine redraw
  834. this.element.addClass("uk-open").trigger("uk.modal.show");
  835. return this;
  836. },
  837. hide: function(force) {
  838. if (!this.isActive()) return;
  839. if (!force && UI.support.transition) {
  840. var $this = this;
  841. this.element.one(UI.support.transition.end, function() {
  842. $this._hide();
  843. }).removeClass("uk-open");
  844. } else {
  845. this._hide();
  846. }
  847. return this;
  848. },
  849. resize: function() {
  850. var paddingdir = "padding-" + (UI.langdirection == 'left' ? "right":"left");
  851. this.scrollbarwidth = window.innerWidth - html.width();
  852. html.css(paddingdir, this.scrollbarwidth);
  853. this.element.css(paddingdir, "");
  854. if (this.dialog.offset().left > this.scrollbarwidth) {
  855. this.element.css(paddingdir, this.scrollbarwidth);
  856. }
  857. if (this.scrollable) {
  858. this.scrollable.css("height", 0);
  859. var offset = Math.abs(parseInt(this.dialog.css("margin-top"), 10)),
  860. dh = this.dialog.outerHeight(),
  861. wh = window.innerHeight,
  862. h = wh - 2*(offset < 20 ? 20:offset) - dh;
  863. this.scrollable.css("height", h < this.options.minScrollHeight ? "":h);
  864. }
  865. },
  866. _hide: function() {
  867. this.element.hide().removeClass("uk-open");
  868. html.removeClass("uk-modal-page").css("padding-" + (UI.langdirection == 'left' ? "right":"left"), "");
  869. if(active===this) active = false;
  870. this.element.trigger("uk.modal.hide");
  871. },
  872. isActive: function() {
  873. return (active == this);
  874. }
  875. });
  876. Modal.dialog = {
  877. tpl : '<div class="uk-modal"><div class="uk-modal-dialog"></div></div>'
  878. };
  879. Modal.defaults = {
  880. keyboard: true,
  881. show: false,
  882. bgclose: true,
  883. minScrollHeight: 150
  884. };
  885. var ModalTrigger = function(element, options) {
  886. var $this = this,
  887. $element = $(element);
  888. if($element.data("modal")) return;
  889. this.options = $.extend({
  890. "target": $element.is("a") ? $element.attr("href") : false
  891. }, options);
  892. this.element = $element;
  893. this.modal = new Modal(this.options.target, options);
  894. $element.on("click", function(e) {
  895. e.preventDefault();
  896. $this.show();
  897. });
  898. //methods
  899. $.each(["show", "hide", "isActive"], function(index, method) {
  900. $this[method] = function() { return $this.modal[method](); };
  901. });
  902. this.element.data("modal", this);
  903. };
  904. ModalTrigger.dialog = function(content, options) {
  905. var modal = new Modal($(Modal.dialog.tpl).appendTo("body"), options);
  906. modal.element.on("uk.modal.hide", function(){
  907. if (modal.persist) {
  908. modal.persist.appendTo(modal.persist.data("modalPersistParent"));
  909. modal.persist = false;
  910. }
  911. modal.element.remove();
  912. });
  913. setContent(content, modal);
  914. return modal;
  915. };
  916. ModalTrigger.alert = function(content, options) {
  917. ModalTrigger.dialog(([
  918. '<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
  919. '<div class="uk-modal-buttons"><button class="uk-button uk-button-primary uk-modal-close">Ok</button></div>'
  920. ]).join(""), $.extend({bgclose:false, keyboard:false}, options)).show();
  921. };
  922. ModalTrigger.confirm = function(content, onconfirm, options) {
  923. onconfirm = $.isFunction(onconfirm) ? onconfirm : function(){};
  924. var modal = ModalTrigger.dialog(([
  925. '<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
  926. '<div class="uk-modal-buttons"><button class="uk-button uk-button-primary js-modal-confirm">Ok</button> <button class="uk-button uk-modal-close">Cancel</button></div>'
  927. ]).join(""), $.extend({bgclose:false, keyboard:false}, options));
  928. modal.element.find(".js-modal-confirm").on("click", function(){
  929. onconfirm();
  930. modal.hide();
  931. });
  932. modal.show();
  933. };
  934. ModalTrigger.Modal = Modal;
  935. UI["modal"] = ModalTrigger;
  936. // init code
  937. $(document).on("click.modal.uikit", "[data-uk-modal]", function(e) {
  938. var ele = $(this);
  939. if(ele.is("a")) {
  940. e.preventDefault();
  941. }
  942. if (!ele.data("modal")) {
  943. var modal = new ModalTrigger(ele, UI.Utils.options(ele.attr("data-uk-modal")));
  944. modal.show();
  945. }
  946. });
  947. // close modal on esc button
  948. $(document).on('keydown.modal.uikit', function (e) {
  949. if (active && e.keyCode === 27 && active.options.keyboard) { // ESC
  950. e.preventDefault();
  951. active.hide();
  952. }
  953. });
  954. $win.on("resize orientationchange", UI.Utils.debounce(function(){
  955. if(active) active.resize();
  956. }, 150));
  957. // helper functions
  958. function setContent(content, modal){
  959. if(!modal) return;
  960. if (typeof content === 'object') {
  961. // convert DOM object to a jQuery object
  962. content = content instanceof jQuery ? content : $(content);
  963. if(content.parent().length) {
  964. modal.persist = content;
  965. modal.persist.data("modalPersistParent", content.parent());
  966. }
  967. }else if (typeof content === 'string' || typeof content === 'number') {
  968. // just insert the data as innerHTML
  969. content = $('<div></div>').html(content);
  970. }else {
  971. // unsupported data type!
  972. content = $('<div></div>').html('$.UIkitt.modal Error: Unsupported data type: ' + typeof content);
  973. }
  974. content.appendTo(modal.element.find('.uk-modal-dialog'));
  975. return modal;
  976. }
  977. })(jQuery, jQuery.UIkit, jQuery(window));
  978. (function($, UI) {
  979. "use strict";
  980. var $win = $(window),
  981. $doc = $(document),
  982. Offcanvas = {
  983. show: function(element) {
  984. element = $(element);
  985. if (!element.length) return;
  986. var doc = $("html"),
  987. bar = element.find(".uk-offcanvas-bar:first"),
  988. rtl = ($.UIkit.langdirection == "right"),
  989. dir = (bar.hasClass("uk-offcanvas-bar-flip") ? -1 : 1) * (rtl ? -1 : 1),
  990. scrollbar = dir == -1 && $win.width() < window.innerWidth ? (window.innerWidth - $win.width()) : 0;
  991. scrollpos = {x: window.scrollX, y: window.scrollY};
  992. element.addClass("uk-active");
  993. doc.css({"width": window.innerWidth, "height": window.innerHeight}).addClass("uk-offcanvas-page");
  994. doc.css((rtl ? "margin-right" : "margin-left"), (rtl ? -1 : 1) * ((bar.outerWidth() - scrollbar) * dir)).width(); // .width() - force redraw
  995. bar.addClass("uk-offcanvas-bar-show").width();
  996. element.off(".ukoffcanvas").on("click.ukoffcanvas swipeRight.ukoffcanvas swipeLeft.ukoffcanvas", function(e) {
  997. var target = $(e.target);
  998. if (!e.type.match(/swipe/)) {
  999. if (!target.hasClass("uk-offcanvas-close")) {
  1000. if (target.hasClass("uk-offcanvas-bar")) return;
  1001. if (target.parents(".uk-offcanvas-bar:first").length) return;
  1002. }
  1003. }
  1004. e.stopImmediatePropagation();
  1005. Offcanvas.hide();
  1006. });
  1007. $doc.on('keydown.ukoffcanvas', function(e) {
  1008. if (e.keyCode === 27) { // ESC
  1009. Offcanvas.hide();
  1010. }
  1011. });
  1012. },
  1013. hide: function(force) {
  1014. var doc = $("html"),
  1015. panel = $(".uk-offcanvas.uk-active"),
  1016. rtl = ($.UIkit.langdirection == "right"),
  1017. bar = panel.find(".uk-offcanvas-bar:first");
  1018. if (!panel.length) return;
  1019. if ($.UIkit.support.transition && !force) {
  1020. doc.one($.UIkit.support.transition.end, function() {
  1021. doc.removeClass("uk-offcanvas-page").attr("style", "");
  1022. panel.removeClass("uk-active");
  1023. window.scrollTo(scrollpos.x, scrollpos.y);
  1024. }).css((rtl ? "margin-right" : "margin-left"), "");
  1025. setTimeout(function(){
  1026. bar.removeClass("uk-offcanvas-bar-show");
  1027. }, 50);
  1028. } else {
  1029. doc.removeClass("uk-offcanvas-page").attr("style", "");
  1030. panel.removeClass("uk-active");
  1031. bar.removeClass("uk-offcanvas-bar-show");
  1032. window.scrollTo(scrollpos.x, scrollpos.y);
  1033. }
  1034. panel.off(".ukoffcanvas");
  1035. $doc.off(".ukoffcanvas");
  1036. }
  1037. }, scrollpos;
  1038. var OffcanvasTrigger = function(element, options) {
  1039. var $this = this,
  1040. $element = $(element);
  1041. if($element.data("offcanvas")) return;
  1042. this.options = $.extend({
  1043. "target": $element.is("a") ? $element.attr("href") : false
  1044. }, options);
  1045. this.element = $element;
  1046. $element.on("click", function(e) {
  1047. e.preventDefault();
  1048. Offcanvas.show($this.options.target);
  1049. });
  1050. this.element.data("offcanvas", this);
  1051. };
  1052. OffcanvasTrigger.offcanvas = Offcanvas;
  1053. UI["offcanvas"] = OffcanvasTrigger;
  1054. // init code
  1055. $doc.on("click.offcanvas.uikit", "[data-uk-offcanvas]", function(e) {
  1056. e.preventDefault();
  1057. var ele = $(this);
  1058. if (!ele.data("offcanvas")) {
  1059. var obj = new OffcanvasTrigger(ele, UI.Utils.options(ele.attr("data-uk-offcanvas")));
  1060. ele.trigger("click");
  1061. }
  1062. });
  1063. })(jQuery, jQuery.UIkit);
  1064. (function($, UI) {
  1065. "use strict";
  1066. var Nav = function(element, options) {
  1067. var $this = this, $element = $(element);
  1068. if($element.data("nav")) return;
  1069. this.options = $.extend({}, Nav.defaults, options);
  1070. this.element = $element.on("click", this.options.toggle, function(e) {
  1071. e.preventDefault();
  1072. var ele = $(this);
  1073. $this.open(ele.parent()[0] == $this.element[0] ? ele : ele.parent("li"));
  1074. });
  1075. this.element.find(this.options.lists).each(function() {
  1076. var $ele = $(this),
  1077. parent = $ele.parent(),
  1078. active = parent.hasClass("uk-active");
  1079. $ele.wrap('<div style="overflow:hidden;height:0;position:relative;"></div>');
  1080. parent.data("list-container", $ele.parent());
  1081. if (active) $this.open(parent, true);
  1082. });
  1083. this.element.data("nav", this);
  1084. };
  1085. $.extend(Nav.prototype, {
  1086. open: function(li, noanimation) {
  1087. var element = this.element, $li = $(li);
  1088. if (!this.options.multiple) {
  1089. element.children(".uk-open").not(li).each(function() {
  1090. if ($(this).data("list-container")) {
  1091. $(this).data("list-container").stop().animate({height: 0}, function() {
  1092. $(this).parent().removeClass("uk-open");
  1093. });
  1094. }
  1095. });
  1096. }
  1097. $li.toggleClass("uk-open");
  1098. if ($li.data("list-container")) {
  1099. if (noanimation) {
  1100. $li.data('list-container').stop().height($li.hasClass("uk-open") ? "auto" : 0);
  1101. } else {
  1102. $li.data('list-container').stop().animate({
  1103. height: ($li.hasClass("uk-open") ? getHeight($li.data('list-container').find('ul:first')) : 0)
  1104. });
  1105. }
  1106. }
  1107. }
  1108. });
  1109. Nav.defaults = {
  1110. "toggle": ">li.uk-parent > a[href='#']",
  1111. "lists": ">li.uk-parent > ul",
  1112. "multiple": false
  1113. };
  1114. UI["nav"] = Nav;
  1115. // helper
  1116. function getHeight(ele) {
  1117. var $ele = $(ele), height = "auto";
  1118. if ($ele.is(":visible")) {
  1119. height = $ele.outerHeight();
  1120. } else {
  1121. var tmp = {
  1122. position: $ele.css("position"),
  1123. visibility: $ele.css("visibility"),
  1124. display: $ele.css("display")
  1125. };
  1126. height = $ele.css({position: 'absolute', visibility: 'hidden', display: 'block'}).outerHeight();
  1127. $ele.css(tmp); // reset element
  1128. }
  1129. return height;
  1130. }
  1131. // init code
  1132. $(document).on("uk-domready", function(e) {
  1133. $("[data-uk-nav]").each(function() {
  1134. var nav = $(this);
  1135. if (!nav.data("nav")) {
  1136. var obj = new Nav(nav, UI.Utils.options(nav.attr("data-uk-nav")));
  1137. }
  1138. });
  1139. });
  1140. })(jQuery, jQuery.UIkit);
  1141. (function($, UI, $win) {
  1142. "use strict";
  1143. var $tooltip, // tooltip container
  1144. tooltipdelay;
  1145. var Tooltip = function(element, options) {
  1146. var $this = this, $element = $(element);
  1147. if($element.data("tooltip")) return;
  1148. this.options = $.extend({}, Tooltip.defaults, options);
  1149. this.element = $element.on({
  1150. "focus" : function(e) { $this.show(); },
  1151. "blur" : function(e) { $this.hide(); },
  1152. "mouseenter": function(e) { $this.show(); },
  1153. "mouseleave": function(e) { $this.hide(); }
  1154. });
  1155. this.tip = typeof(this.options.src) === "function" ? this.options.src.call(this.element) : this.options.src;
  1156. // disable title attribute
  1157. this.element.attr("data-cached-title", this.element.attr("title")).attr("title", "");
  1158. this.element.data("tooltip", this);
  1159. };
  1160. $.extend(Tooltip.prototype, {
  1161. tip: "",
  1162. show: function() {
  1163. if (tooltipdelay) clearTimeout(tooltipdelay);
  1164. if (!this.tip.length) return;
  1165. $tooltip.stop().css({"top": -2000, "visibility": "hidden"}).show();
  1166. $tooltip.html('<div class="uk-tooltip-inner">' + this.tip + '</div>');
  1167. var $this = this,
  1168. pos = $.extend({}, this.element.offset(), {width: this.element[0].offsetWidth, height: this.element[0].offsetHeight}),
  1169. width = $tooltip[0].offsetWidth,
  1170. height = $tooltip[0].offsetHeight,
  1171. offset = typeof(this.options.offset) === "function" ? this.options.offset.call(this.element) : this.options.offset,
  1172. position = typeof(this.options.pos) === "function" ? this.options.pos.call(this.element) : this.options.pos,
  1173. tcss = {
  1174. "display": "none",
  1175. "visibility": "visible",
  1176. "top": (pos.top + pos.height + height),
  1177. "left": pos.left
  1178. },
  1179. tmppos = position.split("-");
  1180. if ((tmppos[0] == "left" || tmppos[0] == "right") && $.UIkit.langdirection == 'right') {
  1181. tmppos[0] = tmppos[0] == "left" ? "right" : "left";
  1182. }
  1183. var variants = {
  1184. "bottom" : {top: pos.top + pos.height + offset, left: pos.left + pos.width / 2 - width / 2},
  1185. "top" : {top: pos.top - height - offset, left: pos.left + pos.width / 2 - width / 2},
  1186. "left" : {top: pos.top + pos.height / 2 - height / 2, left: pos.left - width - offset},
  1187. "right" : {top: pos.top + pos.height / 2 - height / 2, left: pos.left + pos.width + offset}
  1188. };
  1189. $.extend(tcss, variants[tmppos[0]]);
  1190. if (tmppos.length == 2) tcss.left = (tmppos[1] == 'left') ? (pos.left) : ((pos.left + pos.width) - width);
  1191. var boundary = this.checkBoundary(tcss.left, tcss.top, width, height);
  1192. if(boundary) {
  1193. switch(boundary) {
  1194. case "x":
  1195. if (tmppos.length == 2) {
  1196. position = tmppos[0]+"-"+(tcss.left < 0 ? "left": "right");
  1197. } else {
  1198. position = tcss.left < 0 ? "right": "left";
  1199. }
  1200. break;
  1201. case "y":
  1202. if (tmppos.length == 2) {
  1203. position = (tcss.top < 0 ? "bottom": "top")+"-"+tmppos[1];
  1204. } else {
  1205. position = (tcss.top < 0 ? "bottom": "top");
  1206. }
  1207. break;
  1208. case "xy":
  1209. if (tmppos.length == 2) {
  1210. position = (tcss.top < 0 ? "bottom": "top")+"-"+(tcss.left < 0 ? "left": "right");
  1211. } else {
  1212. position = tcss.left < 0 ? "right": "left";
  1213. }
  1214. break;
  1215. }
  1216. tmppos = position.split("-");
  1217. $.extend(tcss, variants[tmppos[0]]);
  1218. if (tmppos.length == 2) tcss.left = (tmppos[1] == 'left') ? (pos.left) : ((pos.left + pos.width) - width);
  1219. }
  1220. tcss.left -= $("body").position().left;
  1221. tooltipdelay = setTimeout(function(){
  1222. $tooltip.css(tcss).attr("class", "uk-tooltip uk-tooltip-" + position);
  1223. if ($this.options.animation) {
  1224. $tooltip.css({opacity: 0, display: 'block'}).animate({opacity: 1}, parseInt($this.options.animation, 10) || 400);
  1225. } else {
  1226. $tooltip.show();
  1227. }
  1228. tooltipdelay = false;
  1229. }, parseInt(this.options.delay, 10) || 0);
  1230. },
  1231. hide: function() {
  1232. if(this.element.is("input") && this.element[0]===document.activeElement) return;
  1233. if(tooltipdelay) clearTimeout(tooltipdelay);
  1234. $tooltip.stop();
  1235. if (this.options.animation) {
  1236. $tooltip.fadeOut(parseInt(this.options.animation, 10) || 400);
  1237. } else {
  1238. $tooltip.hide();
  1239. }
  1240. },
  1241. content: function() {
  1242. return this.tip;
  1243. },
  1244. checkBoundary: function(left, top, width, height) {
  1245. var axis = "";
  1246. if(left < 0 || ((left-$win.scrollLeft())+width) > window.innerWidth) {
  1247. axis += "x";
  1248. }
  1249. if(top < 0 || ((top-$win.scrollTop())+height) > window.innerHeight) {
  1250. axis += "y";
  1251. }
  1252. return axis;
  1253. }
  1254. });
  1255. Tooltip.defaults = {
  1256. "offset": 5,
  1257. "pos": "top",
  1258. "animation": false,
  1259. "delay": 0, // in miliseconds
  1260. "src": function() { return this.attr("title"); }
  1261. };
  1262. UI["tooltip"] = Tooltip;
  1263. $(function() {
  1264. $tooltip = $('<div class="uk-tooltip"></div>').appendTo("body");
  1265. });
  1266. // init code
  1267. $(document).on("mouseenter.tooltip.uikit focus.tooltip.uikit", "[data-uk-tooltip]", function(e) {
  1268. var ele = $(this);
  1269. if (!ele.data("tooltip")) {
  1270. var obj = new Tooltip(ele, UI.Utils.options(ele.attr("data-uk-tooltip")));
  1271. ele.trigger("mouseenter");
  1272. }
  1273. });
  1274. })(jQuery, jQuery.UIkit, jQuery(window));
  1275. (function($, UI) {
  1276. "use strict";
  1277. var Switcher = function(element, options) {
  1278. var $this = this, $element = $(element);
  1279. if($element.data("switcher")) return;
  1280. this.options = $.extend({}, Switcher.defaults, options);
  1281. this.element = $element.on("click", this.options.toggle, function(e) {
  1282. e.preventDefault();
  1283. $this.show(this);
  1284. });
  1285. if (this.options.connect) {
  1286. this.connect = $(this.options.connect).find(".uk-active").removeClass(".uk-active").end();
  1287. var toggles = this.element.find(this.options.toggle),
  1288. active = toggles.filter(".uk-active");
  1289. if (active.length) {
  1290. this.show(active);
  1291. } else {
  1292. active = toggles.eq(this.options.active);
  1293. this.show(active.length ? active : toggles.eq(0));
  1294. }
  1295. }
  1296. this.element.data("switcher", this);
  1297. };
  1298. $.extend(Switcher.prototype, {
  1299. show: function(tab) {
  1300. tab = isNaN(tab) ? $(tab) : this.element.find(this.options.toggle).eq(tab);
  1301. var active = tab;
  1302. if (active.hasClass("uk-disabled")) return;
  1303. this.element.find(this.options.toggle).filter(".uk-active").removeClass("uk-active");
  1304. active.addClass("uk-active");
  1305. if (this.options.connect && this.connect.length) {
  1306. var index = this.element.find(this.options.toggle).index(active);
  1307. this.connect.children().removeClass("uk-active").eq(index).addClass("uk-active");
  1308. }
  1309. this.element.trigger("uk.switcher.show", [active]);
  1310. }
  1311. });
  1312. Switcher.defaults = {
  1313. connect : false,
  1314. toggle : ">*",
  1315. active : 0
  1316. };
  1317. UI["switcher"] = Switcher;
  1318. // init code
  1319. $(document).on("uk-domready", function(e) {
  1320. $("[data-uk-switcher]").each(function() {
  1321. var switcher = $(this);
  1322. if (!switcher.data("switcher")) {
  1323. var obj = new Switcher(switcher, UI.Utils.options(switcher.attr("data-uk-switcher")));
  1324. }
  1325. });
  1326. });
  1327. })(jQuery, jQuery.UIkit);
  1328. (function($, UI) {
  1329. "use strict";
  1330. var Tab = function(element, options) {
  1331. var $this = this, $element = $(element);
  1332. if($element.data("tab")) return;
  1333. this.element = $element;
  1334. this.options = $.extend({}, Tab.defaults, options);
  1335. if (this.options.connect) {
  1336. this.connect = $(this.options.connect);
  1337. }
  1338. if (window.location.hash) {
  1339. var active = this.element.children().filter(window.location.hash);
  1340. if (active.length) {
  1341. this.element.children().removeClass('uk-active').filter(active).addClass("uk-active");
  1342. }
  1343. }
  1344. var mobiletab = $('<li class="uk-tab-responsive uk-active"><a href="javascript:void(0);"></a></li>'),
  1345. caption = mobiletab.find("a:first"),
  1346. dropdown = $('<div class="uk-dropdown uk-dropdown-small"><ul class="uk-nav uk-nav-dropdown"></ul><div>'),
  1347. ul = dropdown.find("ul");
  1348. caption.html(this.element.find("li.uk-active:first").find("a").text());
  1349. if (this.element.hasClass("uk-tab-bottom")) dropdown.addClass("uk-dropdown-up");
  1350. if (this.element.hasClass("uk-tab-flip")) dropdown.addClass("uk-dropdown-flip");
  1351. this.element.find("a").each(function(i) {
  1352. var tab = $(this).parent(),
  1353. item = $('<li><a href="javascript:void(0);">' + tab.text() + '</a></li>').on("click", function(e) {
  1354. $this.element.data("switcher").show(i);
  1355. });
  1356. if (!$(this).parents(".uk-disabled:first").length) ul.append(item);
  1357. });
  1358. this.element.uk("switcher", {"toggle": ">li:not(.uk-tab-responsive)", "connect": this.options.connect, "active": this.options.active});
  1359. mobiletab.append(dropdown).uk("dropdown", {"mode": "click"});
  1360. this.element.append(mobiletab).data({
  1361. "dropdown": mobiletab.data("dropdown"),
  1362. "mobilecaption": caption
  1363. }).on("uk.switcher.show", function(e, tab) {
  1364. mobiletab.addClass("uk-active");
  1365. caption.html(tab.find("a").text());
  1366. });
  1367. this.element.data("tab", this);
  1368. };
  1369. Tab.defaults = {
  1370. connect: false,
  1371. active: 0
  1372. };
  1373. UI["tab"] = Tab;
  1374. $(document).on("uk-domready", function(e) {
  1375. $("[data-uk-tab]").each(function() {
  1376. var tab = $(this);
  1377. if (!tab.data("tab")) {
  1378. var obj = new Tab(tab, UI.Utils.options(tab.attr("data-uk-tab")));
  1379. }
  1380. });
  1381. });
  1382. })(jQuery, jQuery.UIkit);
  1383. (function($, UI) {
  1384. "use strict";
  1385. var $win = $(window),
  1386. scrollspies = [],
  1387. checkScrollSpy = function() {
  1388. for(var i=0; i < scrollspies.length; i++) {
  1389. UI.support.requestAnimationFrame.apply(window, [scrollspies[i].check]);
  1390. }
  1391. },
  1392. ScrollSpy = function(element, options) {
  1393. var $element = $(element);
  1394. if($element.data("scrollspy")) return;
  1395. this.options = $.extend({}, ScrollSpy.defaults, options);
  1396. this.element = $(element);
  1397. var $this = this, idle, inviewstate, initinview,
  1398. fn = function(){
  1399. var inview = UI.Utils.isInView($this.element, $this.options);
  1400. if(inview && !inviewstate) {
  1401. if(idle) clearTimeout(idle);
  1402. if(!initinview) {
  1403. $this.element.addClass($this.options.initcls);
  1404. $this.offset = $this.element.offset();
  1405. initinview = true;
  1406. $this.element.trigger("uk-scrollspy-init");
  1407. }
  1408. idle = setTimeout(function(){
  1409. if(inview) {
  1410. $this.element.addClass("uk-scrollspy-inview").addClass($this.options.cls).width();
  1411. }
  1412. }, $this.options.delay);
  1413. inviewstate = true;
  1414. $this.element.trigger("uk.scrollspy.inview");
  1415. }
  1416. if (!inview && inviewstate && $this.options.repeat) {
  1417. $this.element.removeClass("uk-scrollspy-inview").removeClass($this.options.cls);
  1418. inviewstate = false;
  1419. $this.element.trigger("uk.scrollspy.outview");
  1420. }
  1421. };
  1422. fn();
  1423. this.element.data("scrollspy", this);
  1424. this.check = fn;
  1425. scrollspies.push(this);
  1426. };
  1427. ScrollSpy.defaults = {
  1428. "cls" : "uk-scrollspy-inview",
  1429. "initcls" : "uk-scrollspy-init-inview",
  1430. "topoffset" : 0,
  1431. "leftoffset" : 0,
  1432. "repeat" : false,
  1433. "delay" : 0
  1434. };
  1435. UI["scrollspy"] = ScrollSpy;
  1436. var scrollspynavs = [],
  1437. checkScrollSpyNavs = function() {
  1438. for(var i=0; i < scrollspynavs.length; i++) {
  1439. UI.support.requestAnimationFrame.apply(window, [scrollspynavs[i].check]);
  1440. }
  1441. },
  1442. ScrollSpyNav = function(element, options) {
  1443. var $element = $(element);
  1444. if($element.data("scrollspynav")) return;
  1445. this.element = $element;
  1446. this.options = $.extend({}, ScrollSpyNav.defaults, options);
  1447. var ids = [],
  1448. links = this.element.find("a[href^='#']").each(function(){ ids.push($(this).attr("href")); }),
  1449. targets = $(ids.join(","));
  1450. var $this = this, inviews, fn = function(){
  1451. inviews = [];
  1452. for(var i=0 ; i < targets.length ; i++) {
  1453. if(UI.Utils.isInView(targets.eq(i), $this.options)) {
  1454. inviews.push(targets.eq(i));
  1455. }
  1456. }
  1457. if(inviews.length) {
  1458. var scrollTop = $win.scrollTop(),
  1459. target = (function(){
  1460. for(var i=0; i< inviews.length;i++){
  1461. if(inviews[i].offset().top >= scrollTop){
  1462. return inviews[i];
  1463. }
  1464. }
  1465. })();
  1466. if(!target) return;
  1467. if($this.options.closest) {
  1468. links.closest($this.options.closest).removeClass($this.options.cls).end().filter("a[href='#"+target.attr("id")+"']").closest($this.options.closest).addClass($this.options.cls);
  1469. } else {
  1470. links.removeClass($this.options.cls).filter("a[href='#"+target.attr("id")+"']").addClass($this.options.cls);
  1471. }
  1472. }
  1473. };
  1474. if(this.options.smoothscroll && UI["smoothScroll"]) {
  1475. links.each(function(){
  1476. new UI["smoothScroll"](this, $this.options.smoothscroll);
  1477. });
  1478. }
  1479. fn();
  1480. this.element.data("scrollspynav", this);
  1481. this.check = fn;
  1482. scrollspynavs.push(this);
  1483. };
  1484. ScrollSpyNav.defaults = {
  1485. "cls" : 'uk-active',
  1486. "closest" : false,
  1487. "topoffset" : 0,
  1488. "leftoffset" : 0,
  1489. "smoothscroll" : false
  1490. };
  1491. UI["scrollspynav"] = ScrollSpyNav;
  1492. var fnCheck = function(){
  1493. checkScrollSpy();
  1494. checkScrollSpyNavs();
  1495. };
  1496. // listen to scroll and resize
  1497. $win.on("scroll", fnCheck).on("resize orientationchange", UI.Utils.debounce(fnCheck, 50));
  1498. // init code
  1499. $(document).on("uk-domready", function(e) {
  1500. $("[data-uk-scrollspy]").each(function() {
  1501. var element = $(this);
  1502. if (!element.data("scrollspy")) {
  1503. var obj = new ScrollSpy(element, UI.Utils.options(element.attr("data-uk-scrollspy")));
  1504. }
  1505. });
  1506. $("[data-uk-scrollspy-nav]").each(function() {
  1507. var element = $(this);
  1508. if (!element.data("scrollspynav")) {
  1509. var obj = new ScrollSpyNav(element, UI.Utils.options(element.attr("data-uk-scrollspy-nav")));
  1510. }
  1511. });
  1512. });
  1513. })(jQuery, jQuery.UIkit);
  1514. (function($, UI) {
  1515. "use strict";
  1516. var SmoothScroll = function(element, options) {
  1517. var $this = this, $element = $(element);
  1518. if($element.data("smoothScroll")) return;
  1519. this.options = $.extend({}, SmoothScroll.defaults, options);
  1520. this.element = $element.on("click", function(e) {
  1521. // get / set parameters
  1522. var ele = ($(this.hash).length ? $(this.hash) : $("body")),
  1523. target = ele.offset().top - $this.options.offset,
  1524. docheight = $(document).height(),
  1525. winheight = $(window).height(),
  1526. eleheight = ele.outerHeight();
  1527. if ((target + winheight) > docheight) {
  1528. target = docheight - winheight;
  1529. }
  1530. // animate to target and set the hash to the window.location after the animation
  1531. $("html,body").stop().animate({scrollTop: target}, $this.options.duration, $this.options.transition);
  1532. // cancel default click action
  1533. return false;
  1534. });
  1535. this.element.data("smoothScroll", this);
  1536. };
  1537. SmoothScroll.defaults = {
  1538. duration: 1000,
  1539. transition: 'easeOutExpo',
  1540. offset: 0
  1541. };
  1542. UI["smoothScroll"] = SmoothScroll;
  1543. if (!$.easing['easeOutExpo']) {
  1544. $.easing['easeOutExpo'] = function(x, t, b, c, d) { return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b; };
  1545. }
  1546. // init code
  1547. $(document).on("click.smooth-scroll.uikit", "[data-uk-smooth-scroll]", function(e) {
  1548. var ele = $(this);
  1549. if (!ele.data("smoothScroll")) {
  1550. var obj = new SmoothScroll(ele, UI.Utils.options(ele.attr("data-uk-smooth-scroll")));
  1551. ele.trigger("click");
  1552. }
  1553. });
  1554. })(jQuery, jQuery.UIkit);
  1555. (function(global, $, UI){
  1556. var Toggle = function(element, options) {
  1557. var $this = this, $element = $(element);
  1558. if($element.data("toggle")) return;
  1559. this.options = $.extend({}, Toggle.defaults, options);
  1560. this.totoggle = this.options.target ? $(this.options.target):[];
  1561. this.element = $element.on("click", function(e) {
  1562. e.preventDefault();
  1563. $this.toggle();
  1564. });
  1565. this.element.data("toggle", this);
  1566. };
  1567. $.extend(Toggle.prototype, {
  1568. toggle: function() {
  1569. if(!this.totoggle.length) return;
  1570. this.totoggle.toggleClass(this.options.cls);
  1571. }
  1572. });
  1573. Toggle.defaults = {
  1574. target: false,
  1575. cls: 'uk-hidden'
  1576. };
  1577. UI["toggle"] = Toggle;
  1578. $(document).on("uk-domready", function(e) {
  1579. $("[data-uk-toggle]").each(function() {
  1580. var ele = $(this);
  1581. if (!ele.data("toggle")) {
  1582. var obj = new Toggle(ele, UI.Utils.options(ele.attr("data-uk-toggle")));
  1583. }
  1584. });
  1585. });
  1586. })(this, jQuery, jQuery.UIkit);