1/* cached */ 2/* 3ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 4â ease/js/ease.main.js â 5ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 6*/ 7/** 8 * Copyright 2013 Faroe Media 9 * Any unauthorized use of this code is prohibited and will be prosecuted 10 */ 11$(function () { 12 $(document).ajaxError(function (event, jqxhr, settings, exception) { 13 console.log(exception.message); 14 console.log(settings.url); 15 }); 16 17 $(document).bind('drop dragover', function (e) { 18 e.preventDefault(); 19 }); 20 21 $(document).keyup(function (e) { 22 if (e.keyCode === 27) { 23 Modal.close(); 24 } 25 }); 26 27 /** 28 * Settings 29 */ 30 Ease.language = EaseLanguage; 31 Ease.isLoggedIn = EaseLoggedIn; 32 Ease.datetator = { 33 labels: { 34 fo: { 35 week: 'Vk', 36 dayNames: [ 37 'Má', 38 'Tý', 39 'Mi', 40 'Hó', 41 'Fr', 42 'Le', 43 'Su' 44 ], 45 monthNames: [ 46 'januar', 47 'februar', 48 'mars', 49 'aprÃl', 50 'mai', 51 'juni', 52 'juli', 53 'august', 54 'septembur', 55 'oktobur', 56 'novembur', 57 'desembur' 58 ], 59 previous: '« {month}', 60 today: 'à dag', 61 next: '{month} »', 62 empty: 'Strika', 63 previousTooltip: 'VÃs undanfarna mánað', 64 todayTooltip: 'VÃs og vel dagin à dag', 65 nextTooltip: 'VÃs næsta mánað', 66 emptyTooltip: 'Strika dagfesting' 67 }, 68 da: { 69 week: 'Ug', 70 dayNames: [ 71 'Ma', 72 'Ti', 73 'On', 74 'To', 75 'Fr', 76 'Lø', 77 'Sø' 78 ], 79 monthNames: [ 80 'januar', 81 'februar', 82 'marts', 83 'april', 84 'maj', 85 'juni', 86 'juli', 87 'august', 88 'september', 89 'oktober', 90 'november', 91 'desember' 92 ], 93 previous: '« {month}', 94 today: 'i dag', 95 next: '{month} »', 96 empty: 'Fjern', 97 previousTooltip: 'Vis foregÃ¥ende mÃ¥ned', 98 todayTooltip: 'Vis og vælg dagens i dag', 99 nextTooltip: 'Vis næste mÃ¥ned', 100 emptyTooltip: 'Fjern dato' 101 }, 102 en: { 103 week: 'Wk', 104 dayNames: [ 105 'Mo', 106 'Tu', 107 'We', 108 'Th', 109 'Fr', 110 'Sa', 111 'Su' 112 ], 113 monthNames: [ 114 'January', 115 'February', 116 'March', 117 'April', 118 'May', 119 'June', 120 'July', 121 'August', 122 'September', 123 'October', 124 'November', 125 'December' 126 ], 127 previous: '« {month}', 128 today: 'today', 129 next: '{month} »', 130 empty: 'Remove', 131 previousTooltip: 'Show previous month', 132 todayTooltip: 'Show and choose today\'s date', 133 nextTooltip: 'Show next month', 134 emptyTooltip: 'Remove date' 135 } 136 } 137 }; 138 139 /** 140 * Initialize 141 */ 142 if (Ease.isLoggedIn) { 143 Ease.overlay.initialize(); 144 } 145 $('#ease_login').click(function () { 146 Ease.login.show(); 147 }); 148 $('#ease_headerButton_logout').click(function () { 149 Ease.login.logout(); 150 }); 151}); 152 153/** 154 * @constructor 155 */ 156function Ease() {} 157 158 159 160/* 161ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 162â ease/js/ease.login.js â 163ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 164*/ 165/** 166 * Copyright 2013 Faroe Media 167 * Any unauthorized use of this code is prohibited and will be prosecuted 168 */ 169 170/** 171 * Innritan 172 * @type {{path: string, show: show, submit: submit, logout: logout}} 173 */ 174Ease.login = { 175 path: '/ease/', 176 show: function () { 177 Modal.open({ 178 url: Ease.login.path + 'ease_login.php', 179 width: 450, 180 modalId: 'ease_login', 181 callbackOnLoad: function () { 182 $('#easeModal_formLogin').find('#easeModal_checkboxRememberMe').checkator(); 183 }, 184 callbackOnComplete: function () { 185 $('#easeModal_textboxUsername').focus(); 186 $('#easeModal_buttonLogin').click(function (e) { 187 e.preventDefault(); 188 if (!$(this).hasClass('disabled') && !$(this).hasClass('busy')) { 189 Ease.login.submit(); 190 } 191 }); 192 } 193 }); 194 }, 195 submit: function () { 196 var $easeModal_formLogin = $('#easeModal_formLogin'); 197 $easeModal_formLogin.find('#easeModal_error').slideUp(); 198 $easeModal_formLogin.find('#easeModal_buttonLogin').addClass('busy'); 199 $.post(Ease.login.path + 'ease_login_do.php', $easeModal_formLogin.serialize(),function (result) { 200 if (result.status == 'success') { 201 Modal.close({ 202 callbackOnComplete: function () { 203 window.location.reload(); 204 } 205 }); 206 } else { 207 var $easeModal_formLogin = $('#easeModal_formLogin'); 208 $easeModal_formLogin.find('#easeModal_error').html(result.message).slideDown(); 209 $easeModal_formLogin.find('#easeModal_buttonLogin').removeClass('busy'); 210 switch (result.status) { 211 case 'missing username': 212 $easeModal_formLogin.find('#easeModal_textboxUsername').select(); 213 break; 214 case 'missing password': 215 $easeModal_formLogin.find('#easeModal_textboxPassword').select(); 216 break; 217 default: 218 $easeModal_formLogin.find('#easeModal_textboxUsername').select(); 219 break; 220 } 221 } 222 }, 'json').fail(function () { 223 var $easeModal_formLogin = $('#easeModal_formLogin'); 224 $easeModal_formLogin.find('#easeModal_error').html('Error').slideDown(); 225 $easeModal_formLogin.find('#easeModal_buttonLogin').removeClass('busy'); 226 }); 227 }, 228 logout: function () { 229 window.location = '/ease/ease_logout_do.php?l=' + SiteLanguage + '&ReturnUrl=' + Base64Url; 230 } 231}; 232 233 234 235/* 236ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 237â ease/js/ease.modal.js â 238ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 239*/ 240/** 241 * Modal (ease) v1.0.5 - copyright 2013 Faroe Media 242 * All rights reserved 243 * No use of this code is allowed 244 * Any unauthorized use of this code is prohibited and will be prosecuted 245 */ 246 247var Modal; 248$(function () { 249 $('a').each(function () { 250 if (!$(this).attr('tabindex')) { 251 $(this).attr('tabindex', '-1'); 252 } 253 }); 254 255 Modal = { 256 container: null, 257 dimmerStack: [], 258 stack: [], 259 /** 260 * options { 261 * * url (default null) 262 * * top (default 40) 263 * * width (default null) 264 * * height (default null) 265 * * send (default {}) 266 * * method (default 'get') 267 * * dimmerClass (default 'easeModal_dimmer') 268 * * modalClass (default 'easeModal') 269 * * modalId (default '') 270 * * zIndex (default Modal.stack + 1) 271 * * closeWhenClickOutside (default true) 272 * * callbackOnLoad (default function (modal) {}) 273 * * callbackOnComplete (default function (modal) {}) 274 * } 275 */ 276 open: function(options) { 277 options = options || {}; 278 options.zIndex = options.zIndex || (Modal.stack.length+1); 279 options.url = options.url || null; 280 options.top = options.top || (40 + ((options.zIndex - 1) * 20)); 281 options.width = options.width || null; 282 options.height = options.height || null; 283 options.send = options.send || {}; 284 options.method = options.method || 'get'; 285 options.dimmerClass = options.dimmerClass || 'easeModal_dimmer'; 286 options.modalClass = options.modalClass || 'easeModal'; 287 options.modalId = options.modalId || ''; 288 options.closeWhenClickOutside = options.closeWhenClickOutside || true; 289 options.callbackOnLoad = options.callbackOnLoad || function (modal) {}; 290 options.callbackOnComplete = options.callbackOnComplete || function (modal) {}; 291 292 if (Modal.container == null) { 293 $(document.body).addClass('noscroll'); 294 Modal.container = document.createElement('div'); 295 Modal.container.id = 'easeModal_container'; 296 $(document.body).prepend(Modal.container); 297 } 298 299 var dimmer = document.createElement('div'); 300 $(dimmer).addClass(options.dimmerClass); 301 $(dimmer).hide(); 302 $(dimmer).css({ 303 zIndex: 1000 + options.zIndex 304 }); 305 Modal.dimmerStack.push(dimmer); 306 $(Modal.container).append(dimmer); 307 $(dimmer).fadeIn(250); 308 309 options.send.zIndex = options.zIndex; 310 if (options.method == 'get') { 311 $.get(options.url, options.send, function (html) { 312 openDone(html, options); 313 }); 314 } else if (options.method == 'post') { 315 $.post(options.url, options.send, function (html) { 316 openDone(html, options); 317 }); 318 } 319 function openDone(html, options) { 320 var modal = document.createElement('div'); 321 $(modal).addClass(options.modalClass); 322 $(modal).attr('id', options.modalId); 323 if (options.top != null) { 324 $(modal).css('top', options.top + 'px'); 325 } 326 $(modal).width(options.width); 327 $(modal).height(options.height); 328 $(modal).hide(); 329 $(modal).html(html); 330 $(modal).find('.easeModal_close').click(function () { 331 Modal.close(); 332 }); 333 Modal.stack.push(modal); 334 $('input, button, select, textarea').each(function () { 335 if (!$(this).attr('tabindex')) { 336 $(this).attr('tabindex', '-1'); 337 } 338 }); 339 $(dimmer).append(modal); 340 Scrollator !== undefined && $('div,ul').each(function () { 341 if ($(this).css('overflow-y') == 'auto' || $(this).css('overflow-y') == 'scroll') { 342 $(this).scrollator({ 343 zIndex: 1000 + options.zIndex 344 }); 345 } 346 }); 347 options.callbackOnLoad(modal); 348 349 $(modal).fadeIn(250, function () { 350 Scrollator !== undefined && Scrollator.refreshAll(); 351 options.callbackOnComplete(this); 352 }); 353 } 354 }, 355 /** 356 * options { 357 * * zIndex (default Modal.stack + 1) 358 * * callbackOnComplete (default function () {}) 359 * } 360 */ 361 close: function(options) { 362 options = options || {}; 363 options.zIndex = options.zIndex || Modal.stack.length; 364 options.callbackOnComplete = options.callbackOnComplete || function () {}; 365 366 $(Modal.dimmerStack[options.zIndex-1]).find('.scrollator').addBack('.scrollator').each(function () { 367 $(this).data('scrollator').hide(); 368 }); 369 $(Modal.stack[options.zIndex-1]).fadeOut(250, function () { 370 $(Modal.stack[options.zIndex-1]).find('.easeModal_textarea').each(function () { 371 if ($(this).tinymce() != undefined) { 372 $(this).tinymce().remove(); 373 } 374 }); 375 $(Modal.stack[options.zIndex-1]).remove(); 376 Modal.stack.splice(options.zIndex-1, 1); 377 $(Modal.dimmerStack[options.zIndex-1]).fadeOut(250, function () { 378 $(Modal.dimmerStack[options.zIndex-1]).remove(); 379 Modal.dimmerStack.splice(options.zIndex-1, 1); 380 if (Modal.stack.length == 0) { 381 $(Modal.container).remove(); 382 $(document.body).removeClass('noscroll'); 383 Modal.container = null; 384 $('input, button, select, textarea').each(function () { 385 if ($(this).attr('tabindex') && $(this).attr('tabindex') == '-1') { 386 $(this).removeAttr('tabindex'); 387 } 388 }); 389 } 390 options.callbackOnComplete(); 391 if (Overlay != undefined && Overlay.repositionAll != undefined) { 392 Overlay && Overlay.repositionAll(); 393 } 394 Scrollator !== undefined && Scrollator.refreshAll(); 395 }); 396 }); 397 } 398 } 399}); 400 401 402/* 403ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 404â ease/js/fm.checkator.jquery.js â 405ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 406*/ 407/* 408 Checkator jQuery Plugin 409 A plugin for radio and checkbox elements 410 version 1.0, Dec 20th, 2013 411 by Ingi P. Jacobsen 412 413 The MIT License (MIT) 414 415 Copyright (c) 2013 Ingi P. Jacobsen 416 417 Permission is hereby granted, free of charge, to any person obtaining a copy of
418 this software and associated documentation files (the "Software"), to deal in 419 the Software without restriction, including without limitation the rights to 420 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 421 the Software, and to permit persons to whom the Software is furnished to do so, 422 subject to the following conditions: 423 424 The above copyright notice and this permission notice shall be included in all 425 copies or substantial portions of the Software. 426 427 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 428 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 429 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 430 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 431 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 432 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 433*/ 434 435(function($) { 436 $.checkator = function (element, options) { 437 var defaults = { 438 prefix: 'checkator_' 439 }; 440 441 var plugin = this; 442 var type = $(element).attr('type'); 443 var checked = $(element)[0].checked; 444 var wrapper = null; 445 var new_element = null; 446 plugin.settings = {}; 447 448 449 450 // INITIALIZE PLUGIN 451 plugin.init = function () { 452 plugin.settings = $.extend({}, defaults, options); 453 454 wrapper = document.createElement('div'); 455 $(wrapper).addClass(plugin.settings.prefix + 'holder ' + type); 456 $(element).before(wrapper); 457 $(wrapper).append(element); 458 new_element = document.createElement('div'); 459 if (element.id !== undefined) { 460 $(new_element).attr('id', plugin.settings.prefix + element.id); 461 } 462 $(new_element).addClass('checkator ' + type + ' ' + (checked ? 'checked ' : '')); 463 464 $(wrapper).css({ 465 width: $(element).outerWidth() + 'px', 466 height: $(element).outerHeight() + 'px', 467 'margin-top': $(element).css('margin-top'), 468 'margin-right': $(element).css('margin-right'), 469 'margin-bottom': $(element).css('margin-bottom'), 470 'margin-left': $(element).css('margin-left'), 471 'float': $(element).css('float'), 472 'display': $(element).css('display') === 'inline' ? 'inline-clock' : $(element).css('display') 473 }); 474 $(element).css({ 475 opacity: 0, 476 margin: 0 477 }); 478 479 $(element).addClass('checkator_source'); 480 $(element).after(new_element); 481 482 }; 483 484 485 // REMOVE PLUGIN AND REVERT SELECT ELEMENT TO ORIGINAL STATE 486 plugin.destroy = function () { 487 $(new_element).remove(); 488 $.removeData(element, 'checkator'); 489 $(element).css({ 490 opacity: '', 491 margin: '' 492 }); 493 $(element).removeClass('checkator_source'); 494 $(element).unwrap(); 495 }; 496 497 498 // Initialize plugin 499 plugin.init(); 500 }; 501 502 $.fn.checkator = function(options) { 503 options = options !== undefined ? options : {}; 504 return this.each(function () { 505 if (typeof(options) === 'object') { 506 if (undefined === $(this).data('checkator')) { 507 var plugin = new $.checkator(this, options); 508 $(this).data('checkator', plugin); 509 } 510 } else if ($(this).data('checkator')[options]) { 511 $(this).data('checkator')[options].apply(this, Array.prototype.slice.call(arguments, 1)); 512 } else { 513 $.error('Method ' + options + ' does not exist in $.checkator'); 514 } 515 }); 516 }; 517 518}(jQuery)); 519 520 521 522/* 523ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 524â ease/js/fm.datetator.jquery.js â 525ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 526*/ 527/* 528 Datetator jQuery Plugin 529 Datetator is a jQuery-based replacement for input boxes, making them date pickers. 530 version 1.0, Jan 13th, 2014 531 by Ingi P. Jacobsen 532 533 The MIT License (MIT) 534 535 Copyright (c) 2014 Faroe Media 536 537 Permission is hereby granted, free of charge, to any person obtaining a copy of
538 this software and associated documentation files (the "Software"), to deal in 539 the Software without restriction, including without limitation the rights to 540 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 541 the Software, and to permit persons to whom the Software is furnished to do so, 542 subject to the following conditions: 543 544 The above copyright notice and this permission notice shall be included in all 545 copies or substantial portions of the Software. 546 547 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 548 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 549 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 550 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 551 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 552 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 553 */ 554 555(function($) { 556 /** 557 * Datetator 558 * @param element 559 * @param options 560 */ 561 $.datetator = function (element, options) { 562 var defaults = { 563 prefix: 'datetator_', 564 height: 'auto', 565 useDimmer: false, 566 labels: { 567 week: 'Vk', 568 dayNames: [ 569 'Má', 570 'Tý', 571 'Mi', 572 'Hó', 573 'Fr', 574 'Le', 575 'Su' 576 ], 577 monthNames: [ 578 'januar', 579 'februar', 580 'mars', 581 'aprÃl', 582 'mai', 583 'juni', 584 'juli', 585 'august', 586 'septembur', 587 'oktobur', 588 'novembur', 589 'desembur' 590 ], 591 previous: '« {month}', 592 today: 'à dag', 593 next: '{month} »', 594 empty: 'Strika', 595 previousTooltip: 'VÃs undanfarna mánað', 596 todayTooltip: 'VÃs og vel dagin à dag', 597 nextTooltip: 'VÃs næsta mánað', 598 emptyTooltip: 'Strika dagfesting' 599 } 600 }; 601 602 var plugin = this; 603 var $element = $(element); 604 var $holder_element = null; 605 var $input_element = null; 606 var $picker_element = null; 607 var reloadDate = function () { 608 if (!isNaN(new Date($element.val()).getDate())) { 609 return new Date(new Date($element.val()).getFullYear(), new Date($element.val()).getMonth(), 1, 0, 0, 0); 610 } else { 611 return new Date(new Date().getFullYear(), new Date().getMonth(), 1, 0, 0, 0); 612 } 613 }; 614 var currentDate = reloadDate(); 615 var key = { 616 backspace: 8, 617 enter: 13, 618 escape: 27, 619 left: 37, 620 up: 38, 621 right: 39, 622 down: 40 623 }; 624 plugin.settings = {}; 625 626 627 628 // INITIALIZE PLUGIN 629 plugin.init = function () { 630 plugin.settings = $.extend({}, defaults, options); 631 632 //// ================== CREATE ELEMENTS ================== //// 633 // dimmer 634 if (plugin.settings.useDimmer) { 635 if ($('#' + plugin.settings.prefix + 'dimmer').length === 0) { 636 var dimmer_element = document.createElement('div'); 637 $(dimmer_element).attr('id', plugin.settings.prefix + 'dimmer'); 638 $(dimmer_element).hide(); 639 $(document.body).prepend(dimmer_element); 640 } 641 } 642 // holder element 643 $holder_element = $(document.createElement('div')); 644 $holder_element.addClass('datetator_holder picker-hidden'); 645 $holder_element.css({ 646 display: $element.css('display') 647 }); 648 $element.after($holder_element); 649 650 // input element 651 $input_element = $(document.createElement('input')); 652 if (element.id !== undefined) { 653 $input_element.attr('id', plugin.settings.prefix + element.id); 654 } 655 $input_element.addClass('datetator picker-hidden'); 656 $input_element.css({ 657 width: $element.css('width'), 658 padding: $element.css('padding'), 659 position: 'relative' 660 }); 661 $input_element.attr('readonly', true); 662 if (plugin.settings.height === 'element') { 663 $input_element.css({ 664 height: $element.outerHeight() + 'px' 665 }); 666 } 667 $holder_element.append($input_element); 668 $element.hide(); 669 670 // picker element 671 $picker_element = $(document.createElement('div')); 672 $picker_element.addClass(plugin.settings.prefix + 'picker'); 673 $holder_element.append($picker_element); 674 675 //// ================== BIND ELEMENTS EVENTS ================== //// 676 // source element 677 $element.change(function () { 678 currentDate = reloadDate(); 679 refreshPicker(); 680 }); 681 $input_element.mouseup(function (e) { 682 e.preventDefault(); 683 e.stopPropagation(); 684 $input_element.trigger('focus'); 685 }); 686 $input_element.focus(function (e) { 687 currentDate = reloadDate(); 688 refreshPicker(); 689 //$input_element.select(); 690 }); 691 $input_element.blur(function (e) { 692 hidePicker(); 693 }); 694 refreshPicker(); 695 }; 696 697 plugin.refresh = function () { 698 refreshPicker(); 699 }; 700 var refreshPicker = function () { 701 $input_element.val(formatDate(new Date($element.val()), 2));
702 703 $picker_element.empty(); 704 $picker_element.css('top', $input_element.outerHeight() + 3); 705 $picker_element.mousedown(function (e) { 706 e.preventDefault(); 707 e.stopPropagation(); 708 }); 709 710 // navigation holder 711 var $nav_element = $(document.createElement('div')); 712 $nav_element.addClass(plugin.settings.prefix + 'navigation'); 713 $picker_element.append($nav_element); 714 // previous button 715 var $nav_prev_element = $(document.createElement('div')); 716 $nav_prev_element.addClass(plugin.settings.prefix + 'button'); 717 $nav_prev_element.addClass(plugin.settings.prefix + 'previous'); 718 $nav_prev_element.html(plugin.settings.labels.previous.replace('{month}', plugin.settings.labels.monthNames[new Date(new Date(currentDate).setMonth(currentDate.getMonth()-1)).getMonth()].substring(0, 3))); 719 $nav_prev_element.attr('title', plugin.settings.labels.previousTooltip); 720 $nav_prev_element.click(function (e) { 721 e.preventDefault(); 722 e.stopPropagation(); 723 previousMonth(); 724 }); 725 $nav_element.append($nav_prev_element); 726 // today button 727 var $nav_today_element = $(document.createElement('div')); 728 $nav_today_element.addClass(plugin.settings.prefix + 'button'); 729 $nav_today_element.addClass(plugin.settings.prefix + 'today'); 730 $nav_today_element.html(plugin.settings.labels.today); 731 $nav_today_element.attr('title', plugin.settings.labels.todayTooltip); 732 $nav_today_element.click(function (e) { 733 e.preventDefault(); 734 e.stopPropagation(); 735 today(); 736 }); 737 $nav_element.append($nav_today_element); 738 // next button 739 var $nav_next_element = $(document.createElement('div')); 740 $nav_next_element.addClass(plugin.settings.prefix + 'button'); 741 $nav_next_element.addClass(plugin.settings.prefix + 'next'); 742 $nav_next_element.html(plugin.settings.labels.next.replace('{month}', plugin.settings.labels.monthNames[new Date(new Date(currentDate).setMonth(currentDate.getMonth()+1)).getMonth()].substring(0, 3))); 743 $nav_next_element.attr('title', plugin.settings.labels.nextTooltip); 744 $nav_next_element.click(function (e) { 745 e.preventDefault(); 746 e.stopPropagation(); 747 nextMonth(); 748 }); 749 $nav_element.append($nav_next_element); 750 751 // month holder 752 var $month_element = $(document.createElement('div')); 753 $month_element.addClass(plugin.settings.prefix + 'month'); 754 $month_element.html(plugin.settings.labels.monthNames[currentDate.getMonth()] + ' ' + currentDate.getFullYear()); 755 $picker_element.append($month_element); 756 757 // calendar holder 758 var $calendar_element = $(document.createElement('table')); 759 $calendar_element.addClass(plugin.settings.prefix + 'calendar'); 760 $picker_element.append($calendar_element); 761 // tr element (header) 762 var $tr_element = $(document.createElement('tr')); 763 $calendar_element.append($tr_element); 764 // td element (week header) 765 var $td_element = $(document.createElement('th')); 766 $td_element.addClass(plugin.settings.prefix + 'week_header'); 767 $td_element.html(plugin.settings.labels.week); 768 $tr_element.append($td_element); 769 for (var i = 0; i < 7; i++) { 770 // td element (day header) 771 $td_element = $(document.createElement('th')); 772 $td_element.addClass(plugin.settings.prefix + 'day_header'); 773 $td_element.html(plugin.settings.labels.dayNames[i]); 774 $tr_element.append($td_element); 775 } 776 777 // DATES 778 var firstDayOfMonth = currentDate; 779 var lastDayOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, currentDate.getDate() - 1); 780 var firstWeekAndYear = getWeekAndYear(firstDayOfMonth); 781 var lastWeekAndYear = getWeekAndYear(lastDayOfMonth); 782 var mondayFirstWeek = getDateOfISOWeek(firstWeekAndYear.week, firstWeekAndYear.year); 783 var sundayLastWeek = getDateOfISOWeek(lastWeekAndYear.week, lastWeekAndYear.year, 6); 784 785 var rows = Math.ceil((getDateDifferenceInDays(mondayFirstWeek, sundayLastWeek)) / 7); 786 for (var row = 0; row < rows; row++) { 787 // tr element 788 var $tr_element = $(document.createElement('tr')); 789 $calendar_element.append($tr_element); 790 // td element (week) 791 var $td_element = $(document.createElement('td')); 792 $td_element.addClass(plugin.settings.prefix + 'week'); 793 $td_element.html(getWeekAndYear(new Date(firstDayOfMonth).setDate(firstDayOfMonth.getDate() + (row * 7))).week); 794 $tr_element.append($td_element); 795 for (var x = 0; x < 7; x++) { 796 // td element (day) 797 $td_element = $(document.createElement('td')); 798 var date = new Date(mondayFirstWeek.getFullYear(), mondayFirstWeek.getMonth(), mondayFirstWeek.getDate() + (x+(row*7))); 799 $td_element.html(date.getDate()); 800 $td_element.data('date', date); 801 $td_element.click(function (e) { 802 selectDate($(this).data('date')); 803 });
804 $td_element.addClass(plugin.settings.prefix + 'day'); 805 if (formatDate(date, 0) == $element.val()) { 806 $td_element.addClass(plugin.settings.prefix + 'day_active'); 807 } 808 if (date < firstDayOfMonth || date > lastDayOfMonth) { 809 $td_element.addClass(plugin.settings.prefix + 'day_other'); 810 } 811 if (date.getDay() == 0 || date.getDay() == 6) { 812 $td_element.addClass(plugin.settings.prefix + 'day_weekend'); 813 } 814 $tr_element.append($td_element); 815 } 816 } 817 818 // operations holder 819 var $operations_element = $(document.createElement('div')); 820 $operations_element.addClass(plugin.settings.prefix + 'operations'); 821 $picker_element.append($operations_element); 822 // next button 823 var $opr_delete_element = $(document.createElement('div')); 824 $opr_delete_element.addClass(plugin.settings.prefix + 'button'); 825 $opr_delete_element.addClass(plugin.settings.prefix + 'empty'); 826 $opr_delete_element.html(plugin.settings.labels.empty); 827 $opr_delete_element.attr('title', plugin.settings.labels.emptyTooltip); 828 $opr_delete_element.click(function (e) { 829 e.preventDefault(); 830 e.stopPropagation(); 831 empty(); 832 }); 833 $operations_element.append($opr_delete_element); 834 835 if (document.activeElement === $input_element[0]) { 836 showPicker(); 837 } 838 }; 839 840 var previousMonth = function () { 841 currentDate.setMonth(currentDate.getMonth() - 1); 842 refreshPicker(); 843 }; 844 845 var today = function () { 846 currentDate.setYear(new Date().getFullYear()); 847 currentDate.setMonth(new Date().getMonth()); 848 $element.val(formatDate(new Date(), 0)); 849 $element.trigger('change'); 850 hidePicker(); 851 }; 852 853 var nextMonth = function () { 854 currentDate.setMonth(currentDate.getMonth() + 1); 855 refreshPicker(); 856 }; 857 858 var selectDate = function (date) { 859 $element.val(formatDate(date, 0)); 860 $element.trigger('change'); 861 hidePicker(); 862 }; 863 864 var empty = function () { 865 $element.val(''); 866 $element.trigger('change'); 867 hidePicker(); 868 }; 869 870 var showPicker = function () { 871 $holder_element.removeClass('picker-hidden').addClass('picker-visible'); 872 if (plugin.settings.useDimmer) { 873 $('#' + plugin.settings.prefix + 'dimmer').show(); 874 } 875 }; 876 877 var hidePicker = function () { 878 $holder_element.removeClass('picker-visible').addClass('picker-hidden'); 879 if (plugin.settings.useDimmer) { 880 $('#' + plugin.settings.prefix + 'dimmer').hide(); 881 } 882 }; 883 884 var formatDate = function (date, type) { 885 type = type !== undefined ? type : 1; 886 date = typeof date == 'object' ? date : new Date(date); 887 if (isNaN(date.getDate())) { 888 return ''; 889 } 890 var day = date.getDate(); 891 var month = date.getMonth() + 1; 892 var year = date.getFullYear(); 893 switch (type) { 894 case 0: 895 return year + '-' + (month > 9 ? month : '0' + month) + '-' + (day > 9 ? day : '0' + day); 896 break; 897 case 1: 898 return (day > 9 ? day : '0' + day) + '-' + (month > 9 ? month : '0' + month) + '-' + year; 899 break; 900 case 2: 901 return day + '. ' + plugin.settings.labels.monthNames[month - 1] + ' ' + year; 902 break; 903 case 3: 904 return day + '. ' + plugin.settings.labels.monthNames[month - 1].substring(0, 3) + '. ' + year; 905 break; 906 } 907 return 'Invalid Type'; 908 }; 909 910 var getWeekAndYear = function(date) { 911 date = new Date(date); 912 date.setHours(0,0,0); 913 date.setDate(date.getDate() + 4 - (date.getDay() || 7)); 914 var yearStart = new Date(date.getFullYear(), 0, 1); 915 var weekNo = Math.ceil((((date - yearStart) / 86400000) + 1) / 7); 916 return { week: weekNo, year: date.getFullYear() }; 917 }; 918 919 var getDateOfISOWeek = function(week, year, weekDay) { 920 weekDay = weekDay ? weekDay : 0; 921 var simple = new Date(year, 0, 1 + (week - 1) * 7); 922 var date = new Date(simple.setDate((simple.getDay() <= 4) ? (simple.getDate() - simple.getDay() + 1) : (simple.getDate() + 8 - simple.getDay()))); 923 return new Date(date.setDate(date.getDate() + weekDay)); 924 }; 925 926 var getDateDifferenceInDays = function (date1, date2) { 927 var dayMs = 24 * 60 * 60 * 1000; 928 var utc1 = Date.UTC(date1.getFullYear(), date1.getMonth(), date1.getDate()); 929 var utc2 = Date.UTC(date2.getFullYear(), date2.getMonth(), date2.getDate()); 930 return Math.floor((utc2 - utc1) / dayMs); 931 }; 932 933 // REMOVE PLUGIN AND REVERT INPUT ELEMENT TO ORIGINAL STATE 934 plugin.destroy = function () { 935 $input_element.remove(); 936 $.removeData(element, 'datetator'); 937 $element.unbind('change', refreshPicker); 938 $element.show(); 939 if ($('.datetator').length === 0) { 940 $('#' + plugin.settings.prefix + 'dimmer').remove(); 941 } 942 }; 943 944 // Initialize plugin 945 plugin.init(); 946 }; 947 948 $.fn.datetator = function(options) { 949 options = options !== undefined ? options : {}; 950 return this.each(function () { 951 if (typeof(options) === 'object') { 952 if (undefined === $(this).data('datetator')) { 953 var plugin = new $.datetator(this, options); 954 $(this).data('datetator', plugin); 955 } 956 } else if ($(this).data('datetator')[options]) { 957 $(this).data('datetator')[options].apply(this, Array.prototype.slice.call(arguments, 1)); 958 } else { 959 $.error('Method ' + options + ' does not exist in $.datetator'); 960 } 961 }); 962 }; 963 964}(jQuery)); 965 966 967 968/* 969ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 970â ease/js/fm.numbertor.jquery.js â 971ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 972*/ 973/* 974 Numbertor jQuery Plugin 975 Numbertor is a jQuery-based addon for input boxes, giving them a t
975ime sanitizer. 976 version 1.0, Jan 13th, 2014 977 by Ingi P. Jacobsen 978 979 The MIT License (MIT) 980 981 Copyright (c) 2014 Faroe Media 982 983 Permission is hereby granted, free of charge, to any person obtaining a copy of 984 this software and associated documentation files (the "Software"), to deal in 985 the Software without restriction, including without limitation the rights to 986 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 987 the Software, and to permit persons to whom the Software is furnished to do so, 988 subject to the following conditions: 989 990 The above copyright notice and this permission notice shall be included in all 991 copies or substantial portions of the Software. 992 993 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 994 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 995 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 996 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 997 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 998 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 999 */ 1000 1001(function($) { 1002 $.numbertor = function (element, options) { 1003 var defaults = { 1004 decimals: 'auto', 1005 decimal_seperator: ',', 1006 thousand_seperator: '.', 1007 allow_empty: false 1008 }; 1009 1010 var plugin = this; 1011 var $element = $(element); 1012 plugin.settings = {}; 1013 1014 1015 // INITIALIZE PLUGIN 1016 plugin.init = function () { 1017 plugin.settings = $.extend({}, defaults, options); 1018 $element.addClass('numbertor'); 1019 $element.bind('blur', sanitize); 1020 $element.bind('mouseup', unsanitize); 1021 $element.bind('mouseup', select); 1022 sanitize(); 1023 }; 1024 1025 plugin.refresh = function () { 1026 sanitize(); 1027 }; 1028 1029 var sanitize = function () { 1030 $element.val(sanitizeNumber($element.val(), plugin.settings.decimals, plugin.settings.decimal_seperator, plugin.settings.thousand_seperator)); 1031 }; 1032 1033 var unsanitize = function () { 1034 $element.val(unsanitizeNumber($element.val(), plugin.settings.decimals, plugin.settings.decimal_seperator, plugin.settings.thousand_seperator)); 1035 }; 1036 1037 var select = function () { 1038 $element.select(); 1039 }; 1040 1041 var sanitizeNumber = function (number, decimals, decimal_seperator, thousand_seperator) { 1042 decimals = decimals === undefined ? 'auto' : decimals; 1043 decimal_seperator = decimal_seperator === undefined ? ',' : decimal_seperator; 1044 thousand_seperator = thousand_seperator === undefined ? '.' : thousand_seperator; 1045 if (number !== '') { 1046 number = number.toString(); 1047 number = number.replace(/[^0-9,\.]/g,'').replace(thousand_seperator, '').replace(decimal_seperator, '.'); 1048 number = number_format(number, decimals, decimal_seperator, thousand_seperator); 1049 } else if (!plugin.settings.allow_empty) { 1050 number = 0; 1051 number = number_format(number, decimals, decimal_seperator, thousand_seperator); 1052 } 1053 return number; 1054 }; 1055 1056 var unsanitizeNumber = function (number, decimals, decimal_seperator, thousand_seperator) { 1057 decimals = decimals === undefined ? 'auto' : decimals; 1058 decimal_seperator = decimal_seperator === undefined ? ',' : decimal_seperator; 1059 thousand_seperator = thousand_seperator === undefined ? '.' : thousand_seperator; 1060 if (number !== '') { 1061 number = parseFloat(number.toString().replace(thousand_seperator, '').replace(decimal_seperator, '.')).toString().replace('.', decimal_seperator); 1062 } 1063 return number; 1064 }; 1065 1066 var number_format = function (number, decimals, dec_point, thousands_sep) { 1067 number = (number + '').replace(/[^0-9+\-Ee.]/g, ''); 1068 var n = !isFinite(+number) ? 0 : +number, 1069 prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), 1070 sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, 1071 dec = (typeof dec_point === 'undefined') ? '.' : dec_point, 1072 s = '', 1073 toFixedFix = function (n, prec) { 1074 var k = Math.pow(10, prec); 1075 return '' + Math.round(n * k) / k; 1076 }; 1077 // Fix for IE parseFloat(0.55).toFixed(0) = 0; 1078 s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); 1079 if (s[0].length > 3) { 1080 s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); 1081 } 1082 if ((s[1] || '').length < prec) { 1083 s[1] = s[1] || ''; 1084 s[1] += new Array(prec - s[1].length + 1).join('0'); 1085 } 1086 return s.join(dec); 1087 }; 1088 1089 1090 1091 // REMOVE PLUGIN AND REVERT INPUT ELEMENT TO ORIGINAL STATE 1092 plugin.destroy = function () { 1093 $element.removeClass('numbertor'); 1094 $.removeData(element, 'numbertor'); 1095 $element.unbind('blur', sanitize); 1096 $element.unbind('mouseup', select); 1097 $element.unbind('mouseup', unsanitize); 1098 $element.show(); 1099 }; 1100 1101 // Initialize plugin 1102 plugin.init(); 1103 }; 1104 1105 $.fn.numbertor = function(options) { 1106 options = options !== undefined ? options : {}; 1107 return this.each(function () { 1108 if (typeof(options) === 'object') { 1109 if (undefined === $(this).data('numbertor')) { 1110 var plugin = new $.numbertor(this, options); 1111 $(this).data('numbertor', plugin); 1112 } 1113 } else if ($(this).data('numbertor')[options]) { 1114 $(this).data('numbertor')[options].apply(this, Array.prototype.slice.call(arguments, 1)); 1115 } else { 1116 $.error('Method ' + options + ' does not exist in $.numbertor'); 1117 } 1118 }); 1119 }; 1120 1121}(jQuery)); 1122 1123 1124 1125/* 1126ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 1127â ease/js/fm.scrollator.jquery.js â 1128ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 1129*/ 1130/* 1131 Scrollator jQuery Plugin 1132 Scrollator is a jQuery-based replacement for the browsers scroll bar, which doesn't use any space. 1133 version 1.1, July 3rd, 2014 1134 by Ingi P. Jacobsen 1135 1136 The MIT License (MIT) 1137 1138 Copyright (c) 2014 Faroe Media 1139 1140 Permission is hereby granted, free of charge, to any person obtaining a copy of
1141 this software and associated documentation files (the "Software"), to deal in 1142 the Software without restriction, including without limitation the rights to 1143 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 1144 the Software, and to permit persons to whom the Software is furnished to do so, 1145 subject to the following conditions: 1146 1147 The above copyright notice and this permission notice shall be included in all 1148 copies or substantial portions of the Software. 1149 1150 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1151 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 1152 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 1153 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 1154 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1155 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 1156 */ 1157 1158Scrollator = { 1159 scrollatorElementsStack: [], 1160 refreshAll: function () { 1161 var i = Scrollator.scrollatorElementsStack.length; 1162 while (i--) { 1163 if (!Scrollator.scrollatorElementsStack[i].$sourceElement.closest('body').length > 0) { 1164 Scrollator.scrollatorElementsStack[i].destroy(); 1165 } else { 1166 Scrollator.scrollatorElementsStack[i].refresh(); 1167 } 1168 } 1169 } 1170}; 1171$(window).load(function () { 1172 Scrollator.refreshAll(); 1173}); 1174(function($) { 1175 $.scrollator = function (sourceElement, options) { 1176 var defaults = { 1177 custom_class: '', 1178 zIndex: '' 1179 }; 1180 var plugin = this; 1181 plugin.settings = {}; 1182 var $html = $('html'); 1183 var $sourceElement = $(sourceElement); 1184 plugin.$sourceElement = $sourceElement; 1185 var $mainScrollatorHolder = null; 1186 var $thisScrollatorLaneHolder = null; 1187 var $thisScrollatorLane = null; 1188 var $thisScrollatorHandleHolder = null; 1189 var $thisScrollatorHandle = null; 1190 var timerVisibility = null; 1191 var isDraggingHandle = false; 1192 var dragStartY = 0; 1193 var dragStartScrollTop = 0; 1194 var dragHandleOffsetY = 0; 1195 1196 1197 // INITIALIZE PLUGIN 1198 plugin.init = function () { 1199 plugin.settings = $.extend({}, defaults, options); 1200 $mainScrollatorHolder = $('#scrollator_holder'); 1201 $sourceElement.addClass('scrollator'); 1202 // initialize scrollator lane holder 1203 $thisScrollatorLaneHolder = $(document.createElement('div')).addClass('scrollator_lane_holder'); 1204 $thisScrollatorLaneHolder.addClass(plugin.settings.custom_class); 1205 $thisScrollatorLaneHolder.css('z-index', $sourceElement.css('z-index')); 1206 plugin.settings.zIndex !== '' && $thisScrollatorLaneHolder.css('z-index', plugin.settings.zIndex); 1207 $sourceElement.is('body') && $thisScrollatorLaneHolder.addClass('scrollator_on_body'); 1208 // initialize scrollator lane 1209 $thisScrollatorLane = $(document.createElement('div')).addClass('scrollator_lane'); 1210 // initialize scrollator handle holder 1211 $thisScrollatorHandleHolder = $(document.createElement('div')).addClass('scrollator_handle_holder'); 1212 // initialize scrollator handle 1213 $thisScrollatorHandle = $(document.createElement('div')).addClass('scrollator_handle'); 1214 initializeMainScrollatorsHolder(); 1215 if ($sourceElement.prop('tagName') == 'BODY') { 1216 $html.bind('mousewheel DOMMouseScroll', mouseWheelEvent); 1217 $html.bind('mousemove', mouseMoveEvent); 1218 } else { 1219 $sourceElement.bind('mousewheel DOMMouseScroll', mouseWheelEvent); 1220 $sourceElement.bind('mousemove', mouseMoveEvent); 1221 } 1222 $thisScrollatorLaneHolder.bind('mousewheel DOMMouseScroll', mouseWheelEvent); 1223 $thisScrollatorLane.bind('mousewheel DOMMouseScroll', mouseWheelEvent); 1224 $thisScrollatorHandleHolder.bind('mousewheel DOMMouseScroll', mouseWheelEvent); 1225 $thisScrollatorHandle.bind('mousewheel DOMMouseScroll', mouseWheelEvent); 1226 $thisScrollatorLaneHolder.bind('mousemove', mouseMoveEvent); 1227 $thisScrollatorLane.bind('mousemove', mouseMoveEvent); 1228 $thisScrollatorHandleHolder.bind('mousemove', mouseMoveEvent); 1229 $thisScrollatorHandle.bind('mousemove', mouseMoveEvent); 1230 $thisScrollatorHandleHolder.bind('mousedown', mouseDownEvent); 1231 $thisScrollatorHandle.bind('mousedown', mouseDownEvent); 1232 $(window).bind('mouseup', windowMouseUpEvent); 1233 $(window).bind('mousemove', windowMouseMoveEvent); 1234 $(window).bind('keydown', windowKeyDownEvent); 1235 $thisScrollatorHandleHolder.append($thisScrollatorHandle); 1236 $thisScrollatorLane.append($thisScrollatorHandleHolder); 1237 $thisScrollatorLaneHolder.append($thisScrollatorLane); 1238 $mainScrollatorHolder.append($thisScrollatorLaneHolder); 1239 refreshScrollatorPosition();
1240 // refresh/resize/position all scrollators on window resize 1241 if (!document.body.hasScrollatorPageResizeEventHandler) { 1242 document.body.hasScrollatorPageResizeEventHandler = true; 1243 $(window).bind('resize', function () { 1244 Scrollator.refreshAll(); 1245 }); 1246 } 1247 mouseMoveEvent(); 1248 }; 1249 1250 1251 var mouseWheelEvent = function (e) { 1252 if (!e.ctrlKey) { 1253 if ($(e.target).css('overflow-y') != 'auto') { 1254 e.preventDefault(); 1255 e.stopPropagation(); 1256 var scrollTop = ($sourceElement.is('body') ? $(window) : $sourceElement).scrollTop(); 1257 var scrollAdjust = 0; 1258 if (e.originalEvent.wheelDeltaY !== undefined && e.originalEvent.wheelDeltaY !== 0) { // Chrome 1259 scrollAdjust = e.originalEvent.wheelDeltaY / 1.2; 1260 } else if (e.originalEvent.wheelDelta !== undefined && e.originalEvent.wheelDelta !== 0) { // IE, Opera 1261 scrollAdjust = e.originalEvent.wheelDelta / 1.2; 1262 } else if (e.originalEvent.detail !== undefined && e.originalEvent.detail !== 0) { // Firefox 1263 scrollAdjust = e.originalEvent.detail * -33.33; 1264 } 1265 scrollTop += scrollAdjust*-1; 1266 ($sourceElement.is('body') ? $(window) : $sourceElement).scrollTop(scrollTop); 1267 Scrollator.refreshAll(); 1268 } 1269 } 1270 }; 1271 var mouseMoveEvent = function () { 1272 clearTimeout(timerVisibility); 1273 if ($sourceElement[0].scrollHeight > ($sourceElement.is('body') ? $(window).height() : $sourceElement.innerHeight())) { 1274 $thisScrollatorLaneHolder.css('opacity', 1); 1275 timerVisibility = setTimeout(function () { 1276 $thisScrollatorLaneHolder.css('opacity', 0); 1277 }, 1500); 1278 } else { 1279 $thisScrollatorLaneHolder.css('opacity', 0); 1280 } 1281 }; 1282 var mouseDownEvent = function (e) { 1283 e.preventDefault(); 1284 isDraggingHandle = true; 1285 dragStartY = e.clientY; 1286 dragStartScrollTop = ($sourceElement.is('body') ? $(window) : $sourceElement).scrollTop(); 1287 dragHandleOffsetY = e.offsetY; 1288 $thisScrollatorLaneHolder.addClass('hover'); 1289 }; 1290 var windowMouseMoveEvent = function (e) { 1291 if (isDraggingHandle) { 1292 var draggedY = e.clientY - dragStartY; 1293 var multiplier = $sourceElement[0].scrollHeight / ($sourceElement.is('body') ? $(window).height() : $sourceElement.innerHeight()); 1294 ($sourceElement.is('body') ? $(window) : $sourceElement).scrollTop(dragStartScrollTop + (draggedY * multiplier)); 1295 Scrollator.refreshAll(); 1296 mouseMoveEvent(); 1297 } 1298 }; 1299 var windowMouseUpEvent = function () { 1300 isDraggingHandle = false; 1301 $thisScrollatorLaneHolder.removeClass('hover'); 1302 }; 1303 var windowKeyDownEvent = function (e) { 1304 var key = { 1305 pageUp: 33, 1306 pageDown: 34 1307 }; 1308 if ((e.keyCode == key.pageUp || e.keyCode == key.pageDown) && $(document.activeElement).prop('tagName') != 'TEXTAREA') { 1309 var scrollTop = ($sourceElement.is('body') ? $(window) : $sourceElement).scrollTop(); 1310 if (e.keyCode == key.pageUp) { 1311 scrollTop -= $(window).height() - 100; 1312 } else if (e.keyCode == key.pageDown) { 1313 scrollTop += $(window).height() - 100; 1314 } 1315 ($sourceElement.is('body') ? $(window) : $sourceElement).scrollTop(scrollTop); 1316 Scrollator.refreshAll(); 1317 mouseMoveEvent(); 1318 } 1319 }; 1320 1321 1322 plugin.refresh = function () { 1323 refreshScrollatorPosition(); 1324 }; 1325 var refreshScrollatorPosition = function () { 1326 var boundingClientRect = $sourceElement[0].getBoundingClientRect(); 1327 var sourceBounds = { 1328 left: boundingClientRect.left + $(window).scrollLeft(), 1329 top: boundingClientRect.top + $(window).scrollTop(), 1330 right: boundingClientRect.right + $(window).scrollLeft(), 1331 bottom: boundingClientRect.bottom + $(window).scrollTop(), 1332 width: boundingClientRect.width, 1333 height: boundingClientRect.height 1334 }; 1335 var paddingTop = parseInt($sourceElement.css('border-top-width'), 10); 1336 var paddingRight = parseInt($sourceElement.css('border-right-width'), 10); 1337 var paddingBottom = parseInt($sourceElement.css('border-bottom-width'), 10); 1338 var paddingLeft = parseInt($sourceElement.css('border-left-width'), 10); 1339 var contentHeight = $sourceElement[0].scrollHeight; 1340 var laneHeight = ($sourceElement.is('body')) ? $(window).height() : $sourceElement.innerHe
1340ight(); 1341 var handleHeight = (laneHeight / contentHeight) * 100; 1342 var handlePosition = (($sourceElement.is('body') ? $(window) : $sourceElement).scrollTop() / contentHeight) * 100; 1343 if (!$sourceElement.is('body')) { 1344 $thisScrollatorLaneHolder.css({ 1345 top: sourceBounds.top + paddingTop, 1346 right: -sourceBounds.right + paddingRight, 1347 bottom: -sourceBounds.bottom + paddingBottom 1348 }); 1349 } 1350 $thisScrollatorHandleHolder.css({ 1351 height: handleHeight + '%', 1352 top: handlePosition + '%' 1353 }); 1354 }; 1355 1356 1357 // INITIALIZE SCROLLATORS HOLDER IF NEEDED 1358 var initializeMainScrollatorsHolder = function () { 1359 if ($mainScrollatorHolder.length === 0) { 1360 $mainScrollatorHolder = $(document.createElement('div')).attr('id', 'scrollator_holder'); 1361 $('body').append($mainScrollatorHolder); 1362 } 1363 }; 1364 1365 1366 // HIDE SCROLLATOR 1367 plugin.hide = function () { 1368 $thisScrollatorLaneHolder.hide(); 1369 }; 1370 1371 // SHOW SCROLLATOR 1372 plugin.show = function () { 1373 $thisScrollatorLaneHolder.show(); 1374 }; 1375 1376 1377 // REMOVE PLUGIN AND REVERT INPUT ELEMENT TO ORIGINAL STATE 1378 plugin.destroy = function () { 1379 $sourceElement.removeClass('scrollator'); 1380 $.removeData(sourceElement, 'scrollator'); 1381 if ($sourceElement.prop('tagName') == 'BODY') { 1382 $html.unbind('mousewheel DOMMouseScroll', mouseWheelEvent); 1383 $html.unbind('mousemove', mouseMoveEvent); 1384 } else { 1385 $sourceElement.unbind('mousewheel DOMMouseScroll', mouseWheelEvent); 1386 $sourceElement.unbind('mousemove', mouseMoveEvent); 1387 } 1388 $(window).unbind('mouseup', windowMouseUpEvent); 1389 $(window).unbind('mousemove', windowMouseMoveEvent); 1390 $(window).unbind('keydown', windowKeyDownEvent); 1391 $thisScrollatorLaneHolder.remove(); 1392 var i = Scrollator.scrollatorElementsStack.length; 1393 while (i--) { 1394 if (Scrollator.scrollatorElementsStack[i] === plugin) { 1395 Scrollator.scrollatorElementsStack.splice(i, 1); 1396 } 1397 } 1398 if ($mainScrollatorHolder.children().length === 0) { 1399 $mainScrollatorHolder.remove(); 1400 $mainScrollatorHolder = null; 1401 } 1402 }; 1403 1404 // Initialize plugin 1405 plugin.init(); 1406 }; 1407 1408 $.fn.scrollator = function(options) { 1409 options = options !== undefined ? options : {}; 1410 return this.each(function () { 1411 if ( !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|ARM|Touch|Opera Mini/i.test(navigator.userAgent) ) { 1412 if (typeof(options) === 'object') { 1413 if (undefined === $(this).data('scrollator')) { 1414 var plugin = new $.scrollator(this, options); 1415 Scrollator.scrollatorElementsStack.push(plugin); 1416 $(this).data('scrollator', plugin); 1417 } 1418 } else if ($(this).data('scrollator')[options]) { 1419 $(this).data('scrollator')[options].apply(this, Array.prototype.slice.call(arguments, 1)); 1420 } else { 1421 $.error('Method ' + options + ' does not exist in $.scrollator'); 1422 } 1423 } 1424 }); 1425 }; 1426 1427}(jQuery)); 1428 1429 1430 1431/* 1432ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 1433â ease/js/fm.selectator.jquery.js â 1434ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 1435*/ 1436/* 1437 Selectator jQuery Plugin 1438 A plugin for select elements 1439 version 1.1, Dec 10th, 2013 1440 by Ingi P. Jacobsen 1441 1442 The MIT License (MIT) 1443 1444 Copyright (c) 2013 Faroe Media 1445 1446 Permission is hereby granted, free of charge, to any person obtaining a copy of 1447 this software and associated documentation files (the "Software"), to deal in 1448 the Software without restriction, including without limitation the rights to 1449 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 1450 the Software, and to permit persons to whom the Software is furnished to do so, 1451 subject to the following conditions: 1452 1453 The above copyright notice and this permission notice shall be included in all 1454 copies or substantial portions of the Software. 1455 1456 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1457 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 1458 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 1459 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 1460 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1461 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 1462*/ 1463 1464(function($) { 1465 $.selectator = function (element, options) { 1466 var defaults = { 1467 prefix: 'selectator_', 1468 height: 'auto', 1469 useDimmer: false,
1470 useSearch: true, 1471 showAllOptionsOnFocus: false, 1472 selectFirstOptionOnSearch: true, 1473 searchCallback: function(){}, 1474 labels: { 1475 search: 'Search...' 1476 } 1477 }; 1478 1479 var plugin = this; 1480 plugin.settings = {}; 1481 var $source_element = $(element); 1482 var $box_element = null; 1483 var $chosenitems_element = null; 1484 var $input_element = null; 1485 var $textlength_element = null; 1486 var $options_element = null; 1487 var multiple = $source_element.attr('multiple') !== undefined; 1488 var selected_index = multiple ? -1 : 0; 1489 var key = { 1490 backspace: 8, 1491 enter: 13, 1492 escape: 27, 1493 left: 37, 1494 up: 38, 1495 right: 39, 1496 down: 40 1497 }; 1498 1499 1500 1501 // INITIALIZE PLUGIN 1502 plugin.init = function () { 1503 plugin.settings = $.extend({}, defaults, options); 1504 1505 //// ================== CREATE ELEMENTS ================== //// 1506 // dimmer 1507 if (plugin.settings.useDimmer) { 1508 if ($('#' + plugin.settings.prefix + 'dimmer').length === 0) { 1509 var $dimmer_element = $(document.createElement('div')); 1510 $dimmer_element.attr('id', plugin.settings.prefix + 'dimmer'); 1511 $dimmer_element.hide(); 1512 $(document.body).prepend($dimmer_element); 1513 } 1514 } 1515 // box element 1516 $box_element = $(document.createElement('div')); 1517 if ($source_element.attr('id') !== undefined) { 1518 $box_element.attr('id', plugin.settings.prefix + $source_element.attr('id')); 1519 } 1520 $box_element.addClass('selectator ' + (multiple ? 'multiple ' : 'single ') + 'options-hidden'); 1521 if (!plugin.settings.useSearch) { 1522 $box_element.addClass('disable_search'); 1523 } 1524 $box_element.css({ 1525 width: $source_element.css('width'), 1526 minHeight: $source_element.css('height'), 1527 padding: $source_element.css('padding'), 1528 position: 'relative' 1529 }); 1530 if (plugin.settings.height === 'element') { 1531 $box_element.css({ 1532 height: $source_element.outerHeight() + 'px' 1533 }); 1534 } 1535 $source_element.after($box_element); 1536 $source_element.hide(); 1537 // textlength element 1538 $textlength_element = $(document.createElement('span')); 1539 $textlength_element.addClass(plugin.settings.prefix + 'textlength'); 1540 $textlength_element.css({ 1541 position: 'absolute', 1542 visibility: 'hidden' 1543 }); 1544 $box_element.append($textlength_element); 1545 // chosen items element 1546 $chosenitems_element = $(document.createElement('div')); 1547 $chosenitems_element.addClass(plugin.settings.prefix + 'chosen_items'); 1548 $box_element.append($chosenitems_element); 1549 // input element 1550 $input_element = $(document.createElement('input')); 1551 $input_element.addClass(plugin.settings.prefix + 'input'); 1552 if (!plugin.settings.useSearch) { 1553 $input_element.attr('readonly', true); 1554 $input_element.css({ 1555 'width': '0px', 1556 'height': '0px', 1557 'overflow': 'hidden', 1558 'border': 0, 1559 'padding': 0, 1560 'position': 'absolute' 1561 }); 1562 } else { 1563 if (!multiple) { 1564 $input_element.attr('placeholder', plugin.settings.labels.search); 1565 } else { 1566 $input_element.width(20); 1567 } 1568 } 1569 $input_element.attr('autocomplete', 'false'); 1570 $box_element.append($input_element); 1571 // options element 1572 $options_element = $(document.createElement('ul')); 1573 $options_element.addClass(plugin.settings.prefix + 'options'); 1574 1575 $box_element.append($options_element); 1576 1577 Scrollator !== undefined && $options_element.scrollator({ 1578 zIndex: 1001 1579 }); 1580 1581 1582 //// ================== BIND ELEMENTS EVENTS ================== //// 1583 // source element 1584 $source_element.change(function () { 1585 refreshSelectedOptions(); 1586 }); 1587 // box element 1588 $box_element.bind('focus', function (e) { 1589 e.preventDefault(); 1590 e.stopPropagation(); 1591 showOptions(); 1592 $input_element.focus(); 1593 }); 1594 $box_element.bind('mousedown', function (e) { 1595 e.preventDefault(); 1596 e.stopPropagation(); 1597 $input_element.focus(); 1598 if ($input_element[0].setSelectionRange) { 1599 $input_element.focus(); 1600 $input_element[0].setSelectionRange($input_element.val().length, $input_element.val().length); 1601 } else if ($input_element[0].createTextRange) { 1602 var range = $input_element[0].createTextRange(); 1603 range.collapse(true); 1604 range.moveEnd('character', $input_element.val().length); 1605 range.moveStart('character', $input_element.val().length); 1606 range.select(); 1607 } 1608 }); 1609 $box_element.bind('mouseup', function (e) { 1610 e.preventDefault(); 1611 e.stopPropagation(); 1612 }); 1613 $box_element.bind('click', function (e) { 1614 e.preventDefault(); 1615 e.stopPropagation(); 1616 if (!multiple || plugin.settings.showAllOptionsOnFocus || !plugin.settings.useSearch) { 1617 //showOptions(); 1618 search(); 1619 } 1620 $input_element.focus(); 1621 }); 1622 $box_element.bind('dblclick', function (e) { 1623 e.preventDefault(); 1624 e.stopPropagation(); 1625 $input_element.focus(); 1626 $input_element.select(); 1627 }); 1628 // input element 1629 $input_element.bind('click', function (e) { 1630 e.preventDefault(); 1631 e.stopPropagation(); 1632 }); 1633 $input_element.bind('dblclick', function (e) { 1634 e.preventDefault(); 1635 e.stopPropagation(); 1636 }); 1637 $input_element.bind('keydown', function (e) { 1638 e.stopPropagation(); 1639 var keyCode = e.keyCode || e.which; 1640 switch (keyCode) { 1641 case key.up: 1642 e.preventDefault(); 1643 if (selected_index > (multiple ? -1 : 0)) { 1644 selected_index = selected_index - 1; 1645 } else { 1646 selected_index = $options_element.find('.' + plugin.settings.prefix + 'option').length - 1; 1647 } 1648 refreshActiveOption(); 1649 scrollToActiveOption(); 1650 break; 1651 case key.down: 1652 e.preventDefault(); 1653 if (selected_index < $options_element.find('.' + plugin.settings.prefix + 'option').length - 1) { 1654 selected_index = selected_index + 1; 1655 } else { 1656 selected_index = (multiple ? -1 : 0); 1657 } 1658 refreshActiveOption(); 1659 scrollToActiveOption(); 1660 break; 1661 case key.escape: 1662 e.preventDefault(); 1663 break; 1664 case key.enter: 1665 e.preventDefault(); 1666 if (selected_index !== -1) { 1667 selectOption(); 1668 } else { 1669 if ($input_element.val() !== '') { 1670 plugin.settings.searchCallback(); 1671 } 1672 } 1673 resizeInput(); 1674 break; 1675 case key.backspace: 1676 if ($input_element.val() === '') { 1677 $source_element.find('option:selected').last()[0].selected = false; 1678 $source_element.trigger('change'); 1679 refreshSelectedOptions(); 1680 search(); 1681 } 1682 resizeInput(); 1683 break; 1684 default: 1685 resizeInput(); 1686 break; 1687 } 1688 }); 1689 $input_element.bind('keyup', function (e) { 1690 e.preventDefault(); 1691 e.stopPropagation(); 1692 var keyCode = e.keyCode || e.which; 1693 if (keyCode === key.escape || keyCode === key.enter) { 1694 hideOptions(); 1695 } else if (keyCode < 37 || keyCode > 40) { 1696 search(); 1697 } 1698 if ($box_element.hasClass('options-hidden') && (keyCode === key.left || keyCode === key.right ||
1698keyCode === key.up || keyCode === key.down)) { 1699 search(); 1700 } 1701 resizeInput(); 1702 }); 1703 $input_element.bind('focus', function (e) { 1704 e.preventDefault(); 1705 e.stopPropagation(); 1706 if (!$options_element.is(':empty') || !multiple || plugin.settings.showAllOptionsOnFocus || !plugin.settings.useSearch) { 1707 search(); 1708 showOptions(); 1709 } 1710 }); 1711 $input_element.bind('blur', function (e) { 1712 e.preventDefault(); 1713 e.stopPropagation(); 1714 hideOptions(); 1715 }); 1716 refreshSelectedOptions(); 1717 }; 1718 1719 1720 1721 // RESIZE INPUT 1722 var resizeInput = function () { 1723 $textlength_element.text($input_element.val()); 1724 if (multiple) { 1725 $input_element.css({ width: ($textlength_element.width() + 20) + 'px' }); 1726 } 1727 }; 1728 1729 1730 1731 // REFRESH SELECTED OPTIONS 1732 plugin.refresh = function () { 1733 refreshSelectedOptions(); 1734 }; 1735 var refreshSelectedOptions = function () { 1736 $chosenitems_element.empty(); 1737 $source_element.find('option').each(function () { 1738 var $option = $(this); 1739 if (this.selected) { 1740 var $item_element = $(document.createElement('div')); 1741 $item_element.addClass(plugin.settings.prefix + 'chosen_item'); 1742 //$item_element.html($option.html()); 1743 1744 // left 1745 if ($option.data('left') !== undefined) { 1746 var $left_element = $(document.createElement('div')); 1747 $left_element.addClass(plugin.settings.prefix + 'chosen_item_left').html($option.attr('data-left')); 1748 $item_element.append($left_element); 1749 } 1750 // right 1751 if ($option.data('right') !== undefined) { 1752 var $right_element = $(document.createElement('div')); 1753 $right_element.addClass(plugin.settings.prefix + 'chosen_item_right').html($option.attr('data-right')); 1754 $item_element.append($right_element); 1755 } 1756 // title 1757 var $title_element = $(document.createElement('div')); 1758 $title_element.addClass(plugin.settings.prefix + 'chosen_item_title').html($option.html()); 1759 $item_element.append($title_element); 1760 // subtitle 1761 if ($option.data('subtitle') !== undefined) { 1762 var $subtitle_element = $(document.createElement('div')); 1763 $subtitle_element.addClass(plugin.settings.prefix + 'chosen_item_subtitle').html($option.attr('data-subtitle')); 1764 $item_element.append($subtitle_element); 1765 } 1766 // remove button 1767 var $button_remove_element = $(document.createElement('div')); 1768 $button_remove_element.data('element', this); 1769 $button_remove_element.addClass(plugin.settings.prefix + 'chosen_item_remove'); 1770 $button_remove_element.bind('mousedown', function (e) { 1771 e.preventDefault(); 1772 e.stopPropagation(); 1773 }); 1774 $button_remove_element.bind('mouseup', function (e) { 1775 e.preventDefault(); 1776 e.stopPropagation(); 1777 $(this).data('element').selected = false; 1778 $source_element.trigger('change'); 1779 refreshSelectedOptions(); 1780 }); 1781 $button_remove_element.html('X'); 1782 $item_element.append($button_remove_element); 1783 // clear 1784 var $clear_element = $(document.createElement('div')); 1785 $clear_element.css('clear', 'both'); 1786 $item_element.append($clear_element); 1787 1788 $chosenitems_element.append($item_element); 1789 } 1790 }); 1791 search(); 1792 }; 1793 1794 1795 1796 // OPTIONS SEARCH METHOD 1797 var search = function () { 1798 selected_index = plugin.settings.selectFirstOptionOnSearch ? ($input_element.val().replace(/\s/g, '') !== '' ? 0 : -1) : -1; 1799 $options_element.empty(); 1800 if ($input_element.val().replace(/\s/g, '') !== '' || !multiple || plugin.settings.showAllOptionsOnFocus || !plugin.settings.useSearch) { 1801 var optionsArray = []; 1802 $source_element.children().each(function () { 1803 if ($(this).prop('tagName').toLowerCase() === 'optgroup') { 1804 var $group = $(this); 1805 if ($group.children('option').length !== 0) { 1806 var hasMatches = false; 1807 $group.children('option').each(function () { 1808 if ((!this.selected || !multiple) && $(this).html().toLowerCase().indexOf($input_element.val().toLowerCase()) !== -1) { 1809 hasMatches = true; 1810 } 1811 });
1812 if (hasMatches) { 1813 var groupOptionsArray = []; 1814 $group.children('option').each(function () { 1815 if ((!this.selected || !multiple) && $(this).html().toLowerCase().indexOf($input_element.val().toLowerCase()) !== -1) { 1816 groupOptionsArray.push({ 1817 type: 'option', 1818 text: $(this).html(), 1819 element: this 1820 }); 1821 } 1822 }); 1823 optionsArray.push({ 1824 type: 'group', 1825 text: $group.attr('label'), 1826 options: groupOptionsArray, 1827 element: $group 1828 }); 1829 } 1830 } 1831 } else { 1832 if ($(this).html().toLowerCase().indexOf($input_element.val().toLowerCase()) !== -1) { 1833 if (!this.selected || !multiple) { 1834 optionsArray.push({ 1835 type: 'option', 1836 text: $(this).html(), 1837 element: this 1838 }); 1839 } 1840 } 1841 } 1842 }); 1843 generateOptions(optionsArray); 1844 } 1845 if ($input_element.is(':focus')) { 1846 if (!$options_element.is(':empty') || !multiple) { 1847 showOptions(); 1848 } else { 1849 hideOptions(); 1850 } 1851 } else { 1852 hideOptions(); 1853 } 1854 }; 1855 1856 // GENERATE OPTIONS 1857 var generateOptions = function (optionsArray) { 1858 var index = -1; 1859 $(optionsArray).each(function () { 1860 if (this.type === 'group') { 1861 var $group_header_element = $(document.createElement('li')); 1862 $group_header_element.addClass(plugin.settings.prefix + 'group_header'); 1863 $group_header_element.html($(this.element).attr('label')); 1864 $options_element.append($group_header_element); 1865 1866 var $group = $(document.createElement('ul')); 1867 $group.addClass(plugin.settings.prefix + 'group'); 1868 $options_element.append($group); 1869 1870 $(this.options).each(function () { 1871 index++; 1872 var option = createOption.call(this.element, index); 1873 $group.append(option); 1874 }); 1875 1876 $options_element.append($group); 1877 } else { 1878 index++; 1879 var option = createOption.call(this.element, index); 1880 $options_element.append(option); 1881 } 1882 }); 1883 refreshActiveOption(); 1884 }; 1885 1886 // CREATE RESULT OPTION 1887 var createOption = function (index) { 1888 // holder li 1889 var $option = $(document.createElement('li')); 1890 $option.data('index', index); 1891 $option.data('element', this); 1892 $option.addClass(plugin.settings.prefix + 'option'); 1893 if (this.selected) { 1894 $option.addClass('active'); 1895 } 1896 // left 1897 if ($(this).data('left') !== undefined) { 1898 var $left_element = $(document.createElement('div')); 1899 $left_element.addClass(plugin.settings.prefix + 'option_left').html($(this).attr('data-left')); 1900 $option.append($left_element); 1901 } 1902 // right 1903 if ($(this).data('right') !== undefined) { 1904 var $right_element = $(document.createElement('div')); 1905 $right_element.addClass(plugin.settings.prefix + 'option_right').html($(this).attr('data-right')); 1906 $option.append($right_element); 1907 } 1908 // title 1909 var $title_element = $(document.createElement('div')); 1910 $title_element.addClass(plugin.settings.prefix + 'option_title').html($(this).html()); 1911 $option.append($title_element); 1912 // subtitle 1913 if ($(this).data('subtitle') !== undefined) { 1914 var $subtitle_element = $(document.createElement('div')); 1915 $subtitle_element.addClass(plugin.settings.prefix + 'option_subtitle').html($(this).attr('data-subtitle')); 1916 $option.append($subtitle_element); 1917 } 1918 // clear 1919 var $clear_element = $(document.createElement('div')); 1920 $clear_element.css('clear', 'both'); 1921 $option.append($clear_element); 1922 1923 // BIND EVENTS 1924 $option.bind('mouseover', function (e) { 1925 e.stopPropagation(); 1926 e.preventDefault(); 1927 selected_index = index; 1928 refreshActiveOption(); 1929 }); 1930 $option.bind('mousedown', function (e) { 1931 e.stopPropagation(); 1932 e.preventDefault(); 1933 }); 1934 $option.bind('click', function (e) { 1935 e.preventDefault(); 1936 e.stopPropagation(); 1937 selectOption(); 1938 }); 1939 return $option; 1940 }; 1941 1942 // SHOW OPTIONS AND DIMMER 1943 var showOptions = function () { 1944 $box_element.removeClass('options-hidden').addClass('options-visible'); 1945 if (plugin.settings.useDimmer) { 1946 $('#' + plugin.settings.prefix + 'dimmer').show(); 1947 } 1948 setTimeout(function () { 1949 $options_element.css('top', ($box_element.outerHeight() + (multiple ? 0 : $input_element.outerHeight()) -2) + 'px'); 1950 }, 1); 1951 if ($box_element.hasClass('single')) { 1952 selected_index = $options_element.find('.' + plugin.settings.prefix + 'option').index($options_element.find('.' + plugin.settings.prefix + 'option.active')); 1953 } 1954 scrollToActiveOption(); 1955 }; 1956 1957 // HIDE OPTIONS AND DIMMER 1958 var hideOptions = function () { 1959 $box_element.removeClass('options-visible').addClass('options-hidden'); 1960 if (plugin.settings.useDimmer) { 1961 $('#' + plugin.settings.prefix + 'dimmer').hide(); 1962 } 1963 }; 1964 1965 // REFRESH ACTIVE IN OPTIONS METHOD 1966 var refreshActiveOption = function () { 1967 $options_element.find('.active').removeClass('active'); 1968 if (selected_index !== -1) { 1969 $options_element.find('.' + plugin.settings.prefix + 'option').eq(selected_index).addClass('active'); 1970 } 1971 }; 1972 1973 // SCROLL TO ACTIVE OPTION IN OPTIONS LIST 1974 var scrollToActiveOption = function () { 1975 var $active_element = $options_element.find('.' + plugin.settings.prefix + 'option.active'); 1976 if ($active_element.length > 0) { 1977 $options_element.scrollTop($options_element.scrollTop() + $active_element.position().top - $options_element.height()/2 + $active_element.height()/2); 1978 } 1979 1980 }; 1981 1982 // SELECT ACTIVE OPTION 1983 var selectOption = function () { 1984 $options_element.find('.' + plugin.settings.prefix + 'option').eq(selected_index).data('element').selected = true; 1985 $source_element.trigger('change'); 1986 refreshSelectedOptions(); 1987 $input_element.val(''); 1988 $box_element.focus(); 1989 hideOptions(); 1990 }; 1991 1992 1993 1994 // REMOVE PLUGIN AND REVERT SELECT ELEMENT TO ORIGINAL STATE 1995 plugin.destroy = function () { 1996 $box_element.remove(); 1997 $.removeData(element, 'selectator'); 1998 $source_element.show(); 1999 if ($('.selectator').length === 0) { 2000 $('#' + plugin.settings.prefix + 'dimmer').remove(); 2001 } 2002 }; 2003 2004 // Initialize plugin 2005 plugin.init(); 2006 }; 2007 2008 $.fn.selectator = function(options) { 2009 options = options !== undefined ? options : {}; 2010 return this.each(function () { 2011 if (typeof(options) === 'object') { 2012 if (undefined === $(this).data('selectator')) { 2013 var plugin = new $.selectator(this, options); 2014 $(this).data('selectator', plugin); 2015 } 2016 } else if ($(this).data('selectator')[options]) { 2017 $(this).data('selectator')[options].apply(this, Array.prototype.slice.call(arguments, 1)); 2018 } else { 2019 $.error('Method ' + options + ' does not exist in $.selectator'); 2020 } 2021 }); 2022 }; 2023 2024}(jQuery)); 2025 2026 2027 2028/* 2029ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 2030â ease/js/fm.tagator.jquery.js â 2031ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 2032*/ 2033/* 2034 Tagator jQuery Plugin 2035 A plugin to make input elements, tag holders 2036 version 1.0, Jan 13th, 2014 2037 by Ingi P. Jacobsen 2038 2039 The MIT License (MIT) 2040 2041 Copyright (c) 2014 Faroe Media 2042 2043 Permission is hereby granted, free of charge, to any person obtaining a copy of
2044 this software and associated documentation files (the "Software"), to deal in 2045 the Software without restriction, including without limitation the rights to 2046 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 2047 the Software, and to permit persons to whom the Software is furnished to do so, 2048 subject to the following conditions: 2049 2050 The above copyright notice and this permission notice shall be included in all 2051 copies or substantial portions of the Software. 2052 2053 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2054 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 2055 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 2056 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 2057 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2058 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2059*/ 2060 2061(function($) { 2062 $.tagator = function (element, options) { 2063 var defaults = { 2064 prefix: 'tagator_', 2065 height: 'auto', 2066 useDimmer: false, 2067 showAllOptionsOnFocus: false, 2068 autocomplete: [] 2069 }; 2070 2071 var plugin = this; 2072 var selected_index = -1; 2073 var box_element = null; 2074 var tags_element = null; 2075 var input_element = null; 2076 var textlength_element = null; 2077 var options_element = null; 2078 var key = { 2079 backspace: 8, 2080 enter: 13, 2081 escape: 27, 2082 left: 37, 2083 up: 38, 2084 right: 39, 2085 down: 40, 2086 comma: 188 2087 }; 2088 plugin.settings = {}; 2089 2090 2091 2092 // INITIALIZE PLUGIN 2093 plugin.init = function () { 2094 plugin.settings = $.extend({}, defaults, options); 2095 2096 //// ================== CREATE ELEMENTS ================== //// 2097 // dimmer 2098 if (plugin.settings.useDimmer) { 2099 if ($('#' + plugin.settings.prefix + 'dimmer').length === 0) { 2100 var dimmer_element = document.createElement('div'); 2101 $(dimmer_element).attr('id', plugin.settings.prefix + 'dimmer'); 2102 $(dimmer_element).hide(); 2103 $(document.body).prepend(dimmer_element); 2104 } 2105 } 2106 // box element 2107 box_element = document.createElement('div'); 2108 if (element.id !== undefined) { 2109 $(box_element).attr('id', plugin.settings.prefix + element.id); 2110 } 2111 $(box_element).addClass('tagator options-hidden'); 2112 $(box_element).css({ 2113 width: $(element).css('width'), 2114 padding: $(element).css('padding'), 2115 position: 'relative' 2116 }); 2117 if (plugin.settings.height === 'element') { 2118 $(box_element).css({ 2119 height: $(element).outerHeight() + 'px' 2120 }); 2121 } 2122 $(element).after(box_element); 2123 $(element).hide(); 2124 // textlength element 2125 textlength_element = document.createElement('span'); 2126 $(textlength_element).addClass(plugin.settings.prefix + 'textlength'); 2127 $(textlength_element).css({ 2128 position: 'absolute', 2129 visibility: 'hidden' 2130 }); 2131 $(box_element).append(textlength_element); 2132 // tags element 2133 tags_element = document.createElement('div'); 2134 $(tags_element).addClass(plugin.settings.prefix + 'tags'); 2135 $(box_element).append(tags_element); 2136 // input element 2137 input_element = document.createElement('input'); 2138 $(input_element).addClass(plugin.settings.prefix + 'input'); 2139 $(input_element).width(20); 2140 $(input_element).attr('autocomplete', 'false'); 2141 $(box_element).append(input_element); 2142 // options element 2143 options_element = document.createElement('ul'); 2144 $(options_element).addClass(plugin.settings.prefix + 'options'); 2145 2146 $(box_element).append(options_element); 2147 2148 //// ================== BIND ELEMENTS EVENTS ================== //// 2149 // source element 2150 $(element).change(function () { 2151 refreshTags(); 2152 }); 2153 // box element 2154 $(box_element).bind('focus', function (e) { 2155 e.preventDefault(); 2156 e.stopPropagation(); 2157 showOptions(); 2158 $(input_element).focus(); 2159 }); 2160 $(box_element).bind('mousedown', function (e) { 2161 e.preventDefault(); 2162 e.stopPropagation(); 2163 input_element.focus(); 2164 if (input_element.setSelectionRange) { 2165 input_element.focus(); 2166 input_element.setSelectionRange(input_element.value.length, input_element.value.length); 2167 } else if (input_element.createTextRange) { 2168 var range = input_element.createTextRange(); 2169 range.collapse(true); 2170 range.moveEnd('character', input_element.value.length); 2171 range.moveStart('character', input_element.value.length); 2172 range.select(); 2173 } 2174 }); 2175 $(box_element).bind('mouseup', function (e) { 2176 e.preventDefault(); 2177 e.stopPropagation(); 2178 }); 2179 $(box_element).bind('click', function (e) { 2180 e.preventDefault(); 2181 e.stopPropagation(); 2182 if (plugin.settings.showAllOptionsOnFocus) { 2183 //showOptions(); 2184 searchOptions(); 2185 } 2186 input_element.focus(); 2187 }); 2188 $(box_element).bind('dblclick', function (e) { 2189 e.preventDefault(); 2190 e.stopPropagation(); 2191 input_element.focus(); 2192 input_element.select(); 2193 }); 2194 // input element 2195 $(input_element).bind('click', function (e) { 2196 e.preventDefault(); 2197 e.stopPropagation(); 2198 }); 2199 $(input_element).bind('dblclick', function (e) { 2200 e.preventDefault(); 2201 e.stopPropagation(); 2202 }); 2203 $(input_element).bind('keydown', function (e) { 2204 e.stopPropagation(); 2205 var keyCode = e.keyCode || e.which; 2206 switch (keyCode) { 2207 case key.up: 2208 e.preventDefault(); 2209 if (selected_index > -1) { 2210 selected_index = selected_index - 1; 2211 } else { 2212 selected_index = $(options_element).find('.' + plugin.settings.prefix + 'option').length - 1; 2213 } 2214 refreshActiveOption(); 2215 scrollToActiveOption(); 2216 break; 2217 case key.down: 2218 e.preventDefault(); 2219 if (selected_index < $(options_element).find('.' + plugin.settings.prefix + 'option').length - 1) { 2220 selected_index = selected_index + 1; 2221 } else { 2222 selected_index = -1; 2223 } 2224 refreshActiveOption(); 2225 scrollToActiveOption(); 2226 break; 2227 case key.escape: 2228 e.preventDefault(); 2229 break; 2230 case key.comma: 2231 e.preventDefault(); 2232 if (selected_index === -1) { 2233 if ($(input_element).val() !== '') { 2234 addTag($(input_element).val()); 2235 } 2236 } 2237 resizeInput(); 2238 break; 2239 case key.enter: 2240 e.preventDefault(); 2241 if (selected_index !== -1) { 2242 selectOption(); 2243 } else { 2244 if ($(input_element).val() !== '') { 2245 addTag($(input_element).val()); 2246 } 2247 } 2248 resizeInput(); 2249 break; 2250 case key.backspace: 2251 if (input_element.value === '') { 2252 $(element).val($(element).val().substring(0, $(element).val().lastIndexOf(','))); 2253 $(element).trigger('change'); 2254 searchOptions(); 2255 } 2256 resizeInput(); 2257 break; 2258 default: 2259 resizeInput(); 2260 break; 2261 } 2262 }); 2263 $(input_element).bind('keyup', function (e) { 2264 e.preventDefault(); 2265 e.stopPropagation(); 2266 var keyCode = e.keyCode || e.which; 2267 if (keyCode === key.escape || keyCode === key.enter) { 2268 hideOptions(); 2269 } else if (keyCode < 37 || keyCode > 40) { 2270 searchOptions(); 2271 } 2272 if ($(box_element).hasClass('options-hidden') && (keyCode === key.left || keyCode === key.right ||
2272keyCode === key.up || keyCode === key.down)) { 2273 searchOptions(); 2274 } 2275 resizeInput(); 2276 }); 2277 $(input_element).bind('focus', function (e) { 2278 e.preventDefault(); 2279 e.stopPropagation(); 2280 if (!$(options_element).is(':empty') || plugin.settings.showAllOptionsOnFocus) { 2281 searchOptions(); 2282 showOptions(); 2283 } 2284 }); 2285 $(input_element).bind('blur', function (e) { 2286 e.preventDefault(); 2287 e.stopPropagation(); 2288 hideOptions(); 2289 }); 2290 refreshTags(); 2291 }; 2292 2293 2294 2295 // RESIZE INPUT 2296 var resizeInput = function () { 2297 textlength_element.innerHTML = input_element.value; 2298 $(input_element).css({ width: ($(textlength_element).width() + 20) + 'px' }); 2299 }; 2300 2301 2302 2303 // SET AUTOCOMPLETE LIST 2304 plugin.autocomplete = function (autocomplete) { 2305 plugin.settings.autocomplete = autocomplete !== undefined ? autocomplete : []; 2306 }; 2307 2308 2309 2310 // REFRESH TAGS 2311 plugin.refresh = function () { 2312 refreshTags(); 2313 }; 2314 var refreshTags = function () { 2315 $(tags_element).empty(); 2316 var tags = $(element).val().split(','); 2317 $.each(tags, function (key, value) { 2318 if (value !== '') { 2319 var tag_element = document.createElement('div'); 2320 $(tag_element).addClass(plugin.settings.prefix + 'tag'); 2321 $(tag_element).html(value); 2322 // remove button 2323 var button_remove_element = document.createElement('div'); 2324 $(button_remove_element).data('text', value); 2325 $(button_remove_element).addClass(plugin.settings.prefix + 'tag_remove'); 2326 $(button_remove_element).bind('mousedown', function (e) { 2327 e.preventDefault(); 2328 e.stopPropagation(); 2329 }); 2330 $(button_remove_element).bind('mouseup', function (e) { 2331 e.preventDefault(); 2332 e.stopPropagation(); 2333 removeTag($(this).data('text')); 2334 $(element).trigger('change'); 2335 }); 2336 $(button_remove_element).html('X'); 2337 $(tag_element).append(button_remove_element); 2338 // clear 2339 var clear_element = document.createElement('div'); 2340 clear_element.style.clear = 'both'; 2341 $(tag_element).append(clear_element); 2342 2343 $(tags_element).append(tag_element); 2344 } 2345 }); 2346 searchOptions(); 2347 }; 2348 2349 // REMOVE TAG FROM ORIGINAL ELEMENT 2350 var removeTag = function (text) { 2351 var tagsBefore = $(element).val().split(','); 2352 var tagsAfter = []; 2353 $.each(tagsBefore, function (key, value) { 2354 if (value !== text && value !== '') { 2355 tagsAfter.push(value); 2356 } 2357 }); 2358 $(element).val(tagsAfter.join(',')); 2359 }; 2360 2361 // CHECK IF TAG IS PRESENT 2362 var hasTag = function (text) { 2363 var tags = $(element).val().split(','); 2364 var hasTag = false; 2365 $.each(tags, function (key, value) { 2366 if ($.trim(value) === $.trim(text)) { 2367 hasTag = true; 2368 } 2369 }); 2370 return hasTag; 2371 }; 2372 2373 // ADD TAG TO ORIGINAL ELEMENT 2374 var addTag = function (text) { 2375 if (!hasTag(text)) { 2376 $(element).val($(element).val() + ($(element).val() !== '' ? ',' : '') + text); 2377 $(element).trigger('change'); 2378 } 2379 $(input_element).val(''); 2380 box_element.focus(); 2381 hideOptions(); 2382 }; 2383 2384 2385 2386 // OPTIONS SEARCH METHOD 2387 var searchOptions = function () { 2388 $(options_element).empty(); 2389 if (input_element.value.replace(/\s/g, '') !== '' || plugin.settings.showAllOptionsOnFocus) { 2390 var optionsArray = []; 2391 $.each(plugin.settings.autocomplete, function (key, value) { 2392 if (value.toLowerCase().indexOf(input_element.value.toLowerCase()) !== -1) { 2393 if (!hasTag(value)) { 2394 optionsArray.push(value); 2395 } 2396 } 2397 }); 2398 generateOptions(optionsArray); 2399 } 2400 if ($(input_element).is(':focus')) { 2401 if (!$(options_element).is(':empty')) { 2402 showOptions(); 2403 } else { 2404 hideOptions(); 2405 } 2406 } else { 2407 hideOptions(); 2408 } 2409 selected_index = -1; 2410 }; 2411 2412 // GENERATE OPTIONS 2413 var generateOptions = function (optionsArray) { 2414 var index = -1; 2415 $(optionsArray).each(function (key, value) { 2416 index++; 2417 var option = createOption(value, index); 2418 $(options_element).append(option); 2419 }); 2420 refreshActiveOption(); 2421 }; 2422 2423 // CREATE RESULT OPTION 2424 var createOption = function (text, index) { 2425 // holder li 2426 var option = document.createElement('li'); 2427 $(option).data('index', index); 2428 $(option).data('text', text); 2429 $(option).html(text); 2430 $(option).addClass(plugin.settings.prefix + 'option'); 2431 if (this.selected) { 2432 $(option).addClass('active'); 2433 } 2434 2435 // BIND EVENTS 2436 $(option).bind('mouseover', function (e) { 2437 e.stopPropagation(); 2438 e.preventDefault(); 2439 selected_index = index; 2440 refreshActiveOption(); 2441 }); 2442 $(option).bind('mousedown', function (e) { 2443 e.stopPropagation(); 2444 e.preventDefault(); 2445 }); 2446 $(option).bind('click', function (e) { 2447 e.preventDefault(); 2448 e.stopPropagation(); 2449 selectOption(); 2450 }); 2451 2452 2453 return option; 2454 }; 2455 2456 // SHOW OPTIONS AND DIMMER 2457 var showOptions = function () { 2458 $(box_element).removeClass('options-hidden').addClass('options-visible'); 2459 if (plugin.settings.useDimmer) { 2460 $('#' + plugin.settings.prefix + 'dimmer').show(); 2461 } 2462 $(options_element).css('top', ($(box_element).outerHeight()-2) + 'px'); 2463 if ($(box_element).hasClass('single')) { 2464 selected_index = $(options_element).find('.' + plugin.settings.prefix + 'option').index($(options_element).find('.' + plugin.settings.prefix + 'option.active')); 2465 } 2466 scrollToActiveOption(); 2467 }; 2468 2469 // HIDE OPTIONS AND DIMMER 2470 var hideOptions = function () { 2471 $(box_element).removeClass('options-visible').addClass('options-hidden'); 2472 if (plugin.settings.useDimmer) { 2473 $('#' + plugin.settings.prefix + 'dimmer').hide(); 2474 } 2475 }; 2476 2477 // REFRESH ACTIVE IN OPTIONS METHOD 2478 var refreshActiveOption = function () { 2479 $(options_element).find('.active').removeClass('active'); 2480 if (selected_index !== -1) { 2481 $(options_element).find('.' + plugin.settings.prefix + 'option').eq(selected_index).addClass('active'); 2482 } 2483 }; 2484 2485 // SCROLL TO ACTIVE OPTION IN OPTIONS LIST 2486 var scrollToActiveOption = function () { 2487 var $active_element = $(options_element).find('.' + plugin.settings.prefix + 'option.active'); 2488 if ($active_element.length > 0) { 2489 $(options_element).scrollTop($(options_element).scrollTop() + $active_element.position().top - $(options_element).height()/2 + $active_element.height()/2); 2490 } 2491 2492 }; 2493 2494 // SELECT ACTIVE OPTION 2495 var selectOption = function () { 2496 addTag($(options_element).find('.' + plugin.settings.prefix + 'option').eq(selected_index).data('text'));
2497 }; 2498 2499 2500 2501 // REMOVE PLUGIN AND REVERT INPUT ELEMENT TO ORIGINAL STATE 2502 plugin.destroy = function () { 2503 $(box_element).remove(); 2504 $.removeData(element, 'tagator'); 2505 $(element).show(); 2506 if ($('.tagator').length === 0) { 2507 $('#' + plugin.settings.prefix + 'dimmer').remove(); 2508 } 2509 }; 2510 2511 // Initialize plugin 2512 plugin.init(); 2513 }; 2514 2515 $.fn.tagator = function() { 2516 var parameters = arguments[0] !== undefined ? arguments : [{}]; 2517 return this.each(function () { 2518 if (typeof(parameters[0]) === 'object') { 2519 if (undefined === $(this).data('tagator')) { 2520 var plugin = new $.tagator(this, parameters[0]); 2521 $(this).data('tagator', plugin); 2522 } 2523 } else if ($(this).data('tagator')[parameters[0]]) { 2524 $(this).data('tagator')[parameters[0]].apply(this, Array.prototype.slice.call(parameters, 1)); 2525 } else { 2526 $.error('Method ' + parameters[0] + ' does not exist in $.tagator'); 2527 } 2528 }); 2529 }; 2530 2531}(jQuery)); 2532 2533 2534 2535/* 2536ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 2537â ease/js/fm.timetator.jquery.js â 2538ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 2539*/ 2540/* 2541 Timetator jQuery Plugin 2542 Timetator is a jQuery-based addon for input boxes, giving them a time sanitizer.
2543 version 1.0, Jan 13th, 2014 2544 by Ingi P. Jacobsen 2545 2546 The MIT License (MIT) 2547 2548 Copyright (c) 2014 Faroe Media 2549 2550 Permission is hereby granted, free of charge, to any person obtaining a copy of 2551 this software and associated documentation files (the "Software"), to deal in 2552 the Software without restriction, including without limitation the rights to 2553 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 2554 the Software, and to permit persons to whom the Software is furnished to do so, 2555 subject to the following conditions: 2556 2557 The above copyright notice and this permission notice shall be included in all 2558 copies or substantial portions of the Software. 2559 2560 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2561 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 2562 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 2563 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 2564 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2565 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2566 */ 2567 2568(function($) { 2569 $.timetator = function (element, options) { 2570 var defaults = { 2571 seperator: ':', 2572 useSeconds: false, 2573 useCap: true 2574 }; 2575 2576 var plugin = this; 2577 var $element = $(element); 2578 plugin.settings = {}; 2579 2580 2581 // INITIALIZE PLUGIN 2582 plugin.init = function () { 2583 plugin.settings = $.extend({}, defaults, options); 2584 $element.addClass('timetator'); 2585 $element.bind('blur', sanitize); 2586 $element.bind('mouseup', select); 2587 sanitize(); 2588 }; 2589 2590 var sanitize = function () { 2591 $element.val(sanitizeTime($element.val(), plugin.settings.seperator, plugin.settings.useSeconds, plugin.settings.useCap)); 2592 }; 2593 2594 var select = function () { 2595 $element.select(); 2596 }; 2597 2598 var sanitizeTime = function (time, seperator, useSeconds, useCap) {
2599 useSeconds = useSeconds === undefined ? false : useSeconds; 2600 useCap = useCap === undefined ? true : useCap; 2601 seperator = seperator === undefined ? ':' : seperator; 2602 if (time !== '') { 2603 time = time.toString(); 2604 time = time.replace(/\D/g,''); 2605 if (useCap) { 2606 time = time.substring(0, useSeconds ? 6 : 4); 2607 } 2608 2609 switch(time.length) { 2610 case 0: 2611 time = '0000' + (useSeconds ? '00' : ''); 2612 break; 2613 case 1: 2614 time = '0' + time + '00' + (useSeconds ? '00' : ''); 2615 break; 2616 case 2: 2617 time = time + '00' + (useSeconds ? '00' : ''); 2618 break; 2619 case 3: 2620 time = '0' + time + (useSeconds ? '00' : ''); 2621 break; 2622 case 4: 2623 time = time + (useSeconds ? '00' : ''); 2624 break; 2625 case 5: 2626 time = useCap ? '0' + time : time; 2627 break; 2628 case 6: 2629 break; 2630 } 2631 if (!useSeconds) { 2632 time = ((parseInt(time.substring(0, time.length - 2), 10) > 23 && useCap) ? '23' : time.substring(0, time.length - 2)) + (parseInt(time.substring(time.length - 2, time.length), 10) > 59 ? '59' : time.substring(time.length - 2, time.length)); 2633 } else { 2634 time = ((parseInt(time.substring(0, time.length - 4), 10) > 23 && useCap) ? '23' : time.substring(0, time.length - 4)) + (parseInt(time.substring(time.length - 4, time.length - 2), 10) > 59 ? '59' : time.substring(time.length - 4, time.length - 2)) + (parseInt(time.substring(time.length - 2, time.length), 10) > 59 ? '59' : time.substring(time.length - 2, time.length)); 2635 } 2636 if (!useSeconds) { 2637 time = time.substring(0, time.length -2) + seperator + time.substring(time.length - 2, time.length); 2638 } else { 2639 time = time.substring(0, time.length - 4) + seperator + time.substring(time.length - 4, time.length - 2) + seperator + time.substring(time.length - 2, time.length); 2640 } 2641 } 2642 return time; 2643 }; 2644 2645 2646 // REMOVE PLUGIN AND REVERT INPUT ELEMENT TO ORIGINAL STATE 2647 plugin.destroy = function () { 2648 $element.removeClass('timetator'); 2649 $.removeData(element, 'timetator'); 2650 $element.unbind('blur', sanitize); 2651 $element.unbind('mouseup', select); 2652 $element.show(); 2653 }; 2654 2655 // Initialize plugin 2656 plugin.init(); 2657 }; 2658 2659 $.fn.timetator = function(options) { 2660 options = options !== undefined ? options : {}; 2661 return this.each(function () { 2662 if (typeof(options) === 'object') { 2663 if (undefined === $(this).data('timetator')) { 2664 var plugin = new $.timetator(this, options); 2665 $(this).data('timetator', plugin); 2666 } 2667 } else if ($(this).data('timetator')[options]) { 2668 $(this).data('timetator')[options].apply(this, Array.prototype.slice.call(arguments, 1)); 2669 } else { 2670 $.error('Method ' + options + ' does not exist in $.timetator'); 2671 } 2672 }); 2673 }; 2674 2675}(jQuery)); 2676 2677 2678 2679/* 2680ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 2681â ease/js/fm.validator.js â 2682ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 2683*/ 2684/* 2685 Validator jQuery Plugin 2686 Validator is a JQuery validation plugin for forms. 2687 version 1.5, Jan 31th, 2014 2688 by Ingi P. Jacobsen 2689 2690 The MIT License (MIT) 2691 2692 Copyright (c) 2014 Faroe Media 2693 2694 Permission is hereby granted, free of charge, to any person obtaining a copy of 2695 this software and associated documentation files (the "Software"), to deal in 2696 the Software without restriction, including without limitation the rights to 2697 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 2698 the Software, and to permit persons to whom the Software is furnished to do so, 2699 subject to the following conditions: 2700 2701 The above copyright notice and this permission notice shall be included in all 2702 copies or substantial portions of the Software. 2703 2704 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2705 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 2706 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 2707 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 2708 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2709 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2710 */ 2711 2712Validator = { 2713 elementErrorClass: 'error', 2714 language: 'fo', 2715 languages: { 2716 'fo': { 2717 textbox: { 2718 required: 'Hetta økið er kravt', 2719 min: 'Hetta økið skal à minsta lagi vera {characters} stavir', 2720 max: 'Hetta økið skal à mesta lagi vera {characters} stavir', 2721 email: 'Teldupost adressan er ikki gildig', 2722 url: 'Vev adressan er ikki gildig', 2723 number: 'Bert tøl eru loyvd', 2724 digits: 'Bert tøl eru loyvd' 2725 }, 2726 password: { 2727 required: 'Hetta økið er kravt', 2728 min: 'Hetta økið skal à minsta lagi vera {characters} stavir', 2729 max: 'Hetta økið skal à mesta lagi vera {characters} stavir', 2730 match: 'Loyniorðini eru ikki lÃka' 2731 }, 2732 radio: { 2733 }, 2734 checkbox: { 2735 required: 'Hesin avkrossingarteigur er kravdur' 2736 }, 2737 select: { 2738 required: 'Vel eitt virði à hesum vallista' 2739 }, 2740 textarea: { 2741 required: 'Hetta økið er kravt', 2742 min: 'Hetta økið skal à minsta lagi vera {characters} stavir', 2743 max: 'Hetta økið skal à mesta lagi vera {characters} stavir', 2744 url: 'Vev adressan er ikki gildig' 2745 } 2746 }, 2747 'da': { 2748 textbox: { 2749 required: 'Dette felt skal udfyldes', 2750 min: 'Dette felt skal være mindst {characters} tegn', 2751 max: 'Dette felt skal være højst {characters} tegn', 2752 email: 'Denne email er ugyldig', 2753 url: 'Denne webside er ugyldigt', 2754 number: 'Kun tal', 2755 digits: 'Kun tal' 2756 }, 2757 password: { 2758 required: 'Dette felt skal udfyldes', 2759 min: 'Dette felt skal være mindst {characters} tegn', 2760 max: 'Dette felt skal være højst {characters} tegn', 2761 match: 'Kodeordene er ikke ens' 2762 }, 2763 radio: { 2764 }, 2765 checkbox: { 2766 required: 'Denne checkbox skal checkes' 2767 }, 2768 select: { 2769 required: 'Vælg et felt i listen' 2770 }, 2771 textarea: { 2772 required: 'Dette felt skal udfyldes', 2773 min: 'Dette felt skal være mindst {characters} tegn', 2774 max: 'Dette felt skal være højst {characters} tegn', 2775 url: 'Denne webside er ugyldigt' 2776 } 2777 }, 2778 'en': { 2779 textbox: { 2780 required: 'This field is required', 2781 min: 'This field must contain at least {characters} characters', 2782 max: 'This field must not contain more than {characters} characters',
2783 email: 'Email is not valid', 2784 url: 'Website is not valid', 2785 number: 'Only numbers', 2786 digits: 'Only numbers' 2787 }, 2788 password: { 2789 required: 'This field is required', 2790 min: 'This field must contain at least {characters} characters', 2791 max: 'This field must not contain more than {characters} characters', 2792 match: 'The passwords do not match' 2793 }, 2794 radio: { 2795 }, 2796 checkbox: { 2797 required: 'This checkbox is required' 2798 }, 2799 select: { 2800 required: 'Choose a field from the list' 2801 }, 2802 textarea: { 2803 required: 'This field is required', 2804 min: 'This field must contain at least {characters} characters', 2805 max: 'This field must not contain more than {characters} characters', 2806 url: 'Website is not valid' 2807 } 2808 } 2809 }, 2810 showError: function (element, text) { 2811 if (!$(element).hasClass(Validator.elementErrorClass)) { 2812 var error = document.createElement('div'); 2813 $(error).addClass('validator-error').html(text); 2814 2815 if ($(element).attr('data-error-position') == undefined) { 2816 var errorPosition = 'before'; 2817 if ($(this).is('input') && $(this).attr('type') == 'checkbox') { 2818 errorPosition = 'before label'; 2819 } 2820 } else { 2821 errorPosition = $(element).attr('data-error-position'); 2822 } 2823 var attrValue = errorPosition.split(' '); 2824 var targetElementForError; 2825 if (attrValue[1] == undefined) { 2826 targetElementForError = element; 2827 } else { 2828 targetElementForError = $(element).closest(attrValue[1])[0]; 2829 }
2830 if (attrValue[0] == 'before') { 2831 $(targetElementForError).before(error); 2832 } else if (attrValue[0] == 'after') { 2833 $(targetElementForError).after(error); 2834 } 2835 $(targetElementForError).addClass(Validator.elementErrorClass); 2836 2837 if ($(element).attr('data-match') != undefined) { 2838 $('#' + $(element).attr('data-match')).addClass(Validator.elementErrorClass); 2839 } 2840 } 2841 }, 2842 validate: function (form) { 2843 var hasErrors = false; 2844 var firstErrorElement = null; 2845 2846 Validator.removeErrors(form); 2847 2848 $(form).find('input, select, textarea').each(function () { 2849 var regex = null; 2850 // Input[type=text] 2851 if ($(this).is('input') && ($(this).attr('type') == 'text' || $(this).attr('type') == undefined)) { 2852 // required 2853 if ($(this).attr('data-required') != undefined && $(this).val() == '' && $(this).attr('data-required-if') == undefined) { 2854 Validator.showError(this, Validator.languages[Validator.language].textbox.required); 2855 hasErrors = true; 2856 } 2857 // required-if & required-if-value 2858 if ($(this).attr('data-required-if') != undefined && $(this).val() == '' && (($(this).attr('data-required-if-value') == undefined && $('#' + $(this).attr('data-required-if')).is(':checked')) || ($(this).attr('data-required-if-value') != undefined && $('#' + $(this).attr('data-required-if')).val() == $(this).attr('data-required-if-value')))) { 2859 Validator.showError(this, Validator.languages[Validator.language].textbox.required); 2860 hasErrors = true; 2861 } 2862 // min 2863 if ($(this).attr('data-min') != undefined && $(this).val().length < parseFloat($(this).attr('data-min')) && $(this).val().length != 0) { 2864 Validator.showError(this, Validator.languages[Validator.language].textbox.min.replace('{characters}', $(this).attr('data-min'))); 2865 hasErrors = true; 2866 } 2867 // max 2868 if ($(this).attr('data-max') != undefined && $(this).val().length > parseFloat($(this).attr('data-max'))) { 2869 Validator.showError(this, Validator.languages[Validator.language].textbox.max.replace('{characters}', $(this).attr('data-min'))); 2870 hasErrors = true; 2871 } 2872 2873 // patterns 2874 if ($(this).attr('data-type') != undefined) { 2875 switch ($(this).attr('data-type')) { 2876 case 'email': 2877 regex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 2878 if (!regex.test($(this).val()) && $(this).val() != '') { 2879 Validator.showError(this, Validator.languages[Validator.language].textbox.email); 2880 hasErrors = true; 2881 } 2882 break; 2883 case 'url': 2884 regex = /^(https?:\/\/)?((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3}))(\:\d+)?(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_{},.~+=-]*)?(\#[-a-z\d_]*)?$/i; 2885 if ($(this).val().substr(0, 1) !== '/' && !regex.test($(this).val().replace('_', '')) && $(this).val() != '') { 2886 Validator.showError(this, Validator.languages[Validator.language].textbox.url); 2887 hasErrors = true; 2888 } 2889 break; 2890 case 'number': 2891 regex = /^\s*(\+|-)?((\d+([\.,]\d+)?)|([\.,]\d+))\s*$/; 2892 if (!regex.test($(this).val()) && $(this).val() != '') { 2893 Validator.showError(this, Validator.languages[Validator.language].textbox.number); 2894 hasErrors = true; 2895 } 2896 break; 2897 case 'digits': 2898 regex = /^\s*\d+\s*$/; 2899 if (!regex.test($(this).val()) && $(this).val() != '') { 2900 Validator.showError(this, Validator.languages[Validator.language].textbox.digits); 2901 hasErrors = true; 2902 } 2903 break; 2904 } 2905 } 2906 } 2907 2908 // Input[type=password] 2909 if ($(this).is('input') && $(this).attr('type') == 'password') { 2910 // required 2911 if ($(this).attr('data-required') != undefined && $(this).val() == '' && $(this).attr('data-required-if') == undefined) { 2912 Validator.showError(this, Validator.languages[Validator.language].password.required); 2913 hasErrors = true; 2914 } 2915 // required-if & required-if-value 2916 if ($(this).attr('data-required-if') != undefined && $(this).val() == '' && (($(this).attr('data-required-if-value') == undefined && $('#' + $(this).attr('data-required-if')).is(':checked')) || ($(this).attr('data-required-if-value') != undefined && $('#' + $(this).attr('data-required-if')).val() == $(this).attr('data-required-if-value')))) { 2917 Validator.showError(this, Validator.languages[Validator.language].password.required); 2918 hasErrors = true; 2919 } 2920 // min 2921 if ($(this).attr('data-min') != undefined && $(this).val().length < parseFloat($(this).attr('data-min')) && $(this).val().length != 0) { 2922 Validator.showError(this, Validator.languages[Validator.language].password.min.replace('{characters}', $(this).attr('data-min'))); 2923 hasErrors = true; 2924 } 2925 // max 2926 if ($(this).attr('data-max') != undefined && $(this).val().length > parseFloat($(this).attr('data-max'))) { 2927 Validator.showError(this, Validator.languages[Validator.language].password.max.replace('{characters}', $(this).attr('data-min'))); 2928 hasErrors = true; 2929 } 2930 // match 2931 if ($(this).attr('data-match') != undefined && $(this).val() != $('#' + $(this).attr('data-match')).val()) { 2932 Validator.showError(this, Validator.languages[Validator.language].password.match); 2933 hasErrors = true; 2934 } 2935 } 2936 2937 // Input[type=radio] 2938 if ($(this).is('input') && $(this).attr('type') == 'radio') { 2939 } 2940 2941 // Input[type=checkbox] 2942 if ($(this).is('input') && $(this).attr('type') == 'checkbox') { 2943 // required 2944 if ($(this).attr('data-required') != undefined && !$(this).is(':checked') && $(this).attr('data-required-if') == undefined) { 2945 Validator.showError(this, Validator.languages[Validator.language].checkbox.required); 2946 hasErrors = true; 2947 } 2948 // required-if & required-if-value 2949 if ($(this).attr('data-required-if') != undefined && $(this).val() == '' && (($(this).attr('data-required-if-value') == undefined && $('#' + $(this).attr('data-required-if')).is(':checked')) || ($(this).attr('data-required-if-value') != undefined && $('#' + $(this).attr('data-required-if')).val() == $(this).attr('data-required-if-value')))) { 2950 Validator.showError(this, Validator.languages[Validator.language].checkbox.required); 2951 hasErrors = true; 2952 } 2953 } 2954 2955 // Select 2956 if ($(this).is('select')) { 2957 // required 2958 if ($(this).attr('data-required') != undefined && $(this).val() == '' && $(this).attr('data-required-if') == undefined) { 2959 Validator.showError(this, Validator.languages[Validator.language].select.required); 2960 hasErrors = true; 2961 } 2962 // required-if & required-if-value 2963 if ($(this).attr('data-required-if') != undefined && $(this).val() == '' && (($(this).attr('data-required-if-value') == undefined && $('#' + $(this).attr('data-required-if')).is(':checked')) || ($(this).attr('data-required-if-value') != undefined && $('#' + $(this).attr('data-required-if')).val() == $(this).attr('data-required-if-value')))) { 2964 Validator.showError(this, Validator.languages[Validator.language].select.required); 2965 hasErrors = true; 2966 } 2967 2968 } 2969 2970 // Textarea 2971 if ($(this).is('textarea')) { 2972 // required 2973 if ($(this).attr('data-required') != undefined && $(this).val() == '' && $(this).attr('data-required-if') == undefined) { 2974 Validator.showError(this, Validator.languages[Validator.language].textarea.required); 2975 hasErrors = true; 2976 } 2977 // required-if & required-if-value 2978 if ($(this).attr('data-required-if') != undefined && $(this).val() == '' && (($(this).attr('data-required-if-value') == undefined && $('#' + $(this).attr('data-required-if')).is(':checked')) || ($(this).attr('data-required-if-value') != undefined && $('#' + $(this).attr('data-required-if')).val() == $(this).attr('data-required-if-value')))) { 2979 Validator.showError(this, Validator.languages[Validator.language].textarea.required); 2980 hasErrors = true; 2981 } 2982 // min 2983 if ($(this).attr('data-min') != undefined && $(this).val().length < parseFloat($(this).attr('data-min')) && $(this).val().length != 0) { 2984 Validator.showError(this, Validator.languages[Validator.language].textarea.min.replace('{characters}', $(this).attr('data-min'))); 2985 hasErrors = true; 2986 } 2987 // max 2988 if ($(this).attr('data-max') != undefined && $(this).val().length > parseFloat($(this).attr('data-max'))) { 2989 Validator.showError(this, Validator.languages[Validator.language].textarea.max.replace('{characters}', $(this).attr('data-min'))); 2990 hasErrors = true; 2991 } 2992 // patterns 2993 if ($(this).attr('data-type') != undefined) { 2994 switch ($(this).attr('data-type')) { 2995 case 'url': 2996 regex = /^(https?:\/\/)?((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3}))(\:\d+)?(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_{},.~+=-]*)?(\#[-a-z\d_]*)?$/i; 2997 if (!regex.test($(this).val()) && $(this).val() != '') { 2998 Validator.showError(this, Validator.languages[Validator.language].textarea.url); 2999 hasErrors = true; 3000 } 3001 break; 3002 } 3003 } 3004 } 3005 3006 // Focus first element with error 3007 if (hasErrors && firstErrorElement == null) { 3008 firstErrorElement = this; 3009 $(this).focus(); 3010 } 3011 }); 3012 return !hasErrors; 3013 }, 3014 removeErrors: function (form) { 3015 // Remove all error text divs 3016 $(form).find('.validator-error').each(function () { 3017 $(this).remove(); 3018 }); 3019 $(form).find('.error').each(function () { 3020 $(this).removeClass('error'); 3021 }); 3022 3023 // Reset error classes 3024 $(form).find('input[type=text], input[type=password], input[type=radio], input[type=checkbox], select, textarea').each(function () { 3025 if ($(this).attr('type') == 'radio' || $(this).attr('type') == 'checkbox') { 3026 $(this).closest('label').removeClass(Validator.elementErrorClass); 3027 } else { 3028 $(this).removeClass(Validator.elementErrorClass); 3029 } 3030 }); 3031 3032 } 3033}; 3034 3035$(function () { 3036 $('form.validator').each(function () { 3037 $(this).submit(function () { 3038 return Validator.validate(this); 3039 }); 3040 }); 3041}); 3042 3043 3044/* 3045âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 3046â ease/modules/schedules/ease.schedules.site.js â 3047âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 3048*/ 3049/** 3050 * Copyright 2013 Faroe Media 3051 * Any unauthorized use of this code is prohibited and will be prosecuted 3052 */ 3053 3054// When updating schedule or schedule item, only that specifik content element will be reloaded on the page, 3055// which differs from other modules, as they reload the entire content (every element) area of the page. 3056 3057/** 3058 * Vikuætlan (site) 3059 */
3060if (Ease.schedules == undefined) { 3061 Ease.schedules = { 3062 contentitems: {} 3063 } 3064} 3065 3066Ease.schedules.path = '/ease/modules/schedules/'; 3067 3068Ease.schedules.contentitems.onchange = function (options) { 3069 var $contentitem = $('#ease_contentitem_' + options.ContentitemId); 3070 options.Offset = options.Offset !== undefined ? options.Offset : parseInt($contentitem.attr('data-ease-offset')); 3071 $.get(Ease.schedules.path + 'ease_schedules_contentitems_element.php', { ContentitemId: options.ContentitemId, o: options.Offset }, function (html) { 3072 $contentitem.replaceWith(html); 3073 if (Ease.isLoggedIn) { 3074 Ease.overlay.initialize('#ease_contentitem_' + options.ContentitemId); 3075 } 3076 }); 3077}; 3078 3079Ease.schedules.contentitems.previousWeek = function (ContentitemId) { 3080 var $contentitem = $('#ease_contentitem_' + ContentitemId); 3081 var iOffset = parseInt($contentitem.attr('data-ease-offset')); 3082 Ease.schedules.contentitems.onchange({ ContentitemId: ContentitemId, Offset: iOffset -1 }); 3083}; 3084 3085Ease.schedules.contentitems.nextWeek = function (ContentitemId) { 3086 var $contentitem = $('#ease_contentitem_' + ContentitemId); 3087 var iOffset = parseInt($contentitem.attr('data-ease-offset')); 3088 Ease.schedules.contentitems.onchange({ ContentitemId: ContentitemId, Offset: iOffset +1 }); 3089}; 3090 3091 3092/* 3093ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 3094â Settings â 3095ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 3096*/ 3097try { 3098 tinyMCE.baseURL = 'ease/3rdparty/tinymce'; 3099 tinyMCE.suffix = '.min'; 3100} catch (e) { 3101}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.