1jQuery(function(){ 2 initChangeItemView(); 3 initJcf(); 4 5}) 6function initJcf() { 7 $(function() { 8 jcf.replaceAll(); 9}); 10} 11 12function initChangeItemView() { 13 $(document).ready(function() { 14 $('.ctable').click(function(event) { 15 event.preventDefault() 16 $('.changeview').addClass('table') 17 $('.changeview').removeClass('cgrid') 18 $('.changeview').removeClass('clist') 19 $('.changeview').removeClass('list') 20 $('.changeview').removeClass('grid') 21 localStorage.setItem('.changeview', 'table'); 22 }); 23 $('.cgrid').click(function(event) { 24 event.preventDefault() 25 $('.changeview').addClass('grid') 26 $('.changeview').removeClass('ctable') 27 $('.changeview').removeClass('clist') 28 $('.changeview').removeClass('list') 29 $('.changeview').removeClass('table') 30 localStorage.setItem('.changeview', 'grid'); 31 }); 32 $('.clist').click(function(event) { 33 event.preventDefault() 34 $('.changeview').addClass('list') 35 $('.changeview').removeClass('ctable') 36 $('.changeview').removeClass('cgrid') 37 $('.changeview').removeClass('grid') 38 $('.changeview').removeClass('table') 39 localStorage.setItem('.changeview', 'list'); 40 }); 41 let itemClass = localStorage.getItem('.changeview'); 42 $('.changeview').addClass(itemClass) 43 }); 44 45 $(document).ready(function() { 46 $('.ctable').click(function(event) { 47 event.preventDefault() 48 $('.view').addClass('table') 49 $('.view').removeClass('cgrid') 50 $('.view').removeClass('clist') 51 $('.view').removeClass('list') 52 $('.view').removeClass('grid') 53 localStorage.setItem('.view', 'table'); 54 }); 55 $('.cgrid').click(function(event) { 56 event.preventDefault() 57 $('.view').addClass('grid') 58 $('.view').removeClass('ctable') 59 $('.view').removeClass('clist') 60 $('.view').removeClass('list') 61 $('.view').removeClass('table') 62 localStorage.setItem('.view', 'grid'); 63 }); 64 $('.clist').click(function(event) { 65 event.preventDefault() 66 $('.view').addClass('list') 67 $('.view').removeClass('ctable') 68 $('.view').removeClass('cgrid') 69 $('.view').removeClass('grid') 70 $('.view').removeClass('table') 71 localStorage.setItem('.view', 'list'); 72 }); 73 let itemClass = localStorage.getItem('.view') 74 $('.view').addClass(itemClass) 75 }); 76}; 77 78/*! 79 * JavaScript Custom Forms 80 * 81 * Copyright 2014-2015 PSD2HTML - http://psd2html.com/jcf 82 * Released under the MIT license (LICENSE.txt) 83 * 84 * Version: 1.1.3 85 */ 86 ;(function(root, factory) { 87 88 'use strict'; 89 if (typeof define === 'function' && define.amd) { 90 define(['jquery'], factory); 91 } else if (typeof exports === 'object') { 92 module.exports = factory(require('jquery')); 93 } else { 94 root.jcf = factory(jQuery); 95 } 96}(this, function($) { 97 98 'use strict'; 99 100 // define version 101 var version = '1.1.3'; 102 103 // private variables 104 var customInstances = []; 105 106 // default global options 107 var commonOptions = { 108 optionsKey: 'jcf', 109 dataKey: 'jcf-instance', 110 rtlClass: 'jcf-rtl', 111 focusClass: 'jcf-focus', 112 pressedClass: 'jcf-pressed', 113 disabledClass: 'jcf-disabled', 114 hiddenClass: 'jcf-hidden', 115 resetAppearanceClass: 'jcf-reset-appearance', 116 unselectableClass: 'jcf-unselectable' 117 }; 118 119 // detect device type 120 var isTouchDevice = ('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch, 121 isWinPhoneDevice = /Windows Phone/.test(navigator.userAgent); 122 commonOptions.isMobileDevice = !!(isTouchDevice || isWinPhoneDevice); 123 124 var isIOS = /(iPad|iPhone).*OS ([0-9_]*) .*/.exec(navigator.userAgent); 125 if(isIOS) isIOS = parseFloat(isIOS[2].replace(/_/g, '.')); 126 commonOptions.ios = isIOS; 127 128 // create global stylesheet if custom forms are used 129 var createStyleSheet = function() { 130 var styleTag = $('<style>').appendTo('head'), 131 styleSheet = styleTag.prop('sheet') || styleTag.prop('styleSheet'); 132 133 // crossbrowser style handling 134 var addCSSRule = function(selector, rules, index) { 135 if (styleSheet.insertRule) { 136 styleSheet.insertRule(selector + '{' + rules + '}', index); 137 } else { 138 styleSheet.addRule(selector, rules, index); 139 } 140 }; 141 142 // add special rules 143 addCSSRule('.' + commonOptions.hiddenClass, 'position:absolute !important;left:-9999px !important;height:1px !important;width:1px !important;margin:0 !important;border-width:0 !important;-webkit-appearance:none;-moz-appearance:none;appearance:none'); 144 addCSSRule('.' + commonOptions.rtlClass + ' .' + commonOptions.hiddenClass, 'right:-9999px !important; left: auto !important'); 145 addCSSRule('.' + commonOptions.unselectableClass, '-webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-tap-highlight-color: rgba(0,0,0,0);'); 146 addCSSRule('.' + commonOptions.resetAppearanceClass, 'background: none; border: none; -webkit-appearance: none; appearance: none; opacity: 0; filter: alpha(opacity=0);'); 147 148 // detect rtl pages 149 var html = $('html'), body = $('body'); 150 if (html.css('direction') === 'rtl' || body.css('direction') === 'rtl') { 151 html.addClass(commonOptions.rtlClass); 152 } 153 154 // handle form reset event 155 html.on('reset', function() { 156 setTimeout(function() { 157 api.refreshAll(); 158 }, 0); 159 }); 160 161 // mark stylesheet as created 162 commonOptions.styleSheetCreated = true; 163 }; 164 165 // simplified pointer events handler 166 (function() { 167 var pointerEventsSupported = navigator.pointerEnabled || navigator.msPointerEnabled, 168 touchEventsSupported = ('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch, 169 eventList, eventMap = {}, eventPrefix = 'jcf-'; 170 171 // detect events to attach 172 if (pointerEventsSupported) { 173 eventList = { 174 pointerover: navigator.pointerEnabled ? 'pointerover' : 'MSPointerOver', 175 pointerdown: navigator.pointerEnabled ? 'pointerdown' : 'MSPointerDown', 176 pointermove: navigator.pointerEnabled ? 'pointermove' : 'MSPointerMove', 177 pointerup: navigator.pointerEnabled ? 'pointerup' : 'MSPointerUp' 178 }; 179 } else { 180 eventList = { 181 pointerover: 'mouseover', 182 pointerdown: 'mousedown' + (touchEventsSupported ? ' touchstart' : ''), 183 pointermove: 'mousemove' + (touchEventsSupported ? ' touchmove' : ''), 184 pointerup: 'mouseup' + (touchEventsSupported ? ' touchend' : '') 185 }; 186 } 187 188 // create event map 189 $.each(eventList, function(targetEventName, fakeEventList) { 190 $.each(fakeEventList.split(' '), function(index, fakeEventName) { 191 eventMap[fakeEventName] = targetEventName; 192 }); 193 }); 194 195 // jQuery event hooks 196 $.each(eventList, function(eventName, eventHandlers) { 197 eventHandlers = eventHandlers.split(' '); 198 $.event.special[eventPrefix + eventName] = { 199 setup: function() { 200 var self = this; 201 $.each(eventHandlers, function(index, fallbackEvent) { 202 if (self.addEventListener) self.addEventListener(fallbackEvent, fixEvent, false); 203 else self['on' + fallbackEvent] = fixEvent; 204 }); 205 }, 206 teardown: function() { 207 var self = this; 208 $.each(eventHandlers, function(index, fallbackEvent) { 209 if (self.addEventListener) self.removeEventListener(fallbackEvent, fixEvent, false); 210 else self['on' + fallbackEvent] = null; 211 }); 212 } 213 }; 214 }); 215 216 // check that mouse event are not simulated by mobile browsers 217 var lastTouch = null; 218 var mouseEventSimulated = function(e) { 219 var dx = Math.abs(e.pageX - lastTouch.x), 220 dy = Math.abs(e.pageY - lastTouch.y), 221 rangeDistance = 25; 222 223 if (dx <= rangeDistance && dy <= rangeDistance) { 224 return true; 225 } 226 }; 227 228 // normalize event 229 var fixEvent = function(e) { 230 var origEvent = e || window.event, 231 touchEventData = null, 232 targetEventName = eventMap[origEvent.type]; 233 234 e = $.event.fix(origEvent); 235 e.type = eventPrefix + targetEventName; 236 237 if (origEvent.pointerType) { 238 switch (origEvent.pointerType) { 239 case 2: e.pointerType = 'touch'; break; 240 case 3: e.pointerType = 'pen'; break; 241 case 4: e.pointerType = 'mouse'; break; 242 default: e.pointerType = origEvent.pointerType; 243 } 244 } else { 245 e.pointerType = origEvent.type.substr(0, 5); // "mouse" or "touch" word length 246 } 247 248 if (!e.pageX && !e.pageY) { 249 touchEventData = origEvent.changedTouches ? origEvent.changedTouches[0] : origEvent; 250 e.pageX = touchEventData.pageX; 251 e.pageY = touchEventData.pageY; 252 } 253 254 if (origEvent.type === 'touchend') { 255 lastTouch = { x: e.pageX, y: e.pageY }; 256 } 257 if (e.pointerType === 'mouse' && lastTouch && mouseEventSimulated(e)) { 258 return; 259 } else { 260 return ($.event.dispatch || $.event.handle).call(this, e); 261 } 262 }; 263 }()); 264 265 // custom mousewheel/trackpad handler 266 (function() { 267 var wheelEvents = ('onwheel' in document || document.documentMode >= 9 ? 'wheel' : 'mousewheel DOMMouseScroll').split(' '), 268 shimEventName = 'jcf-mousewheel'; 269 270 $.event.special[shimEventName] = { 271 setup: function() { 272 var self = this; 273 $.each(wheelEvents, function(index, fallbackEvent) { 274 if (self.addEventListener) self.addEventListener(fallbackEvent, fixEvent, false); 275 else self['on' + fallbackEvent] = fixEvent; 276 }); 277 }, 278 teardown: function() { 279 var self = this; 280 $.each(wheelEvents, function(index, fallbackEvent) { 281 if (self.addEventListener) self.removeEventListener(fallbackEvent, fixEvent, false); 282 else self['on' + fallbackEvent] = null; 283 }); 284 } 285 }; 286 287 var fixEvent = function(e) { 288 var origEvent = e || window.event; 289 e = $.event.fix(origEvent); 290 e.type = shimEventName; 291 292 // old wheel events handler 293 if ('detail' in origEvent) { e.deltaY = -origEvent.detail; } 294 if ('wheelDelta' in origEvent) { e.deltaY = -origEvent.wheelDelta; } 295 if ('wheelDeltaY' in origEvent) { e.deltaY = -origEvent.wheelDeltaY; } 296 if ('wheelDeltaX' in origEvent) { e.deltaX = -origEvent.wheelDeltaX; } 297 298 // modern wheel event handler 299 if ('deltaY' in origEvent) { 300 e.deltaY = origEvent.deltaY; 301 } 302 if ('deltaX' in origEvent) { 303 e.deltaX = origEvent.deltaX; 304 } 305 306 // handle deltaMode for mouse wheel 307 e.delta = e.deltaY || e.deltaX; 308 if (origEvent.deltaMode === 1) { 309 var lineHeight = 16; 310 e.delta *= lineHeight; 311 e.deltaY *= lineHeight; 312 e.deltaX *= lineHeight; 313 } 314 315 return ($.event.dispatch || $.event.handle).call(this, e); 316 }; 317 }()); 318 319 // extra module methods 320 var moduleMixin = { 321 // provide function for firing native events 322 fireNativeEvent: function(elements, eventName) { 323 $(elements).each(function() { 324 var element = this, eventObject; 325 if (element.dispatchEvent) { 326 eventObject = document.createEvent('HTMLEvents'); 327 eventObject.initEvent(eventName, true, true); 328 element.dispatchEvent(eventObject); 329 } else if (document.createEventObject) { 330 eventObject = document.createEventObject(); 331 eventObject.target = element; 332 element.fireEvent('on' + eventName, eventObject); 333 } 334 }); 335 }, 336 // bind event handlers for module instance (functions beggining with "on") 337 bindHandlers: function() { 338 var self = this; 339 $.each(self, function(propName, propValue) { 340 if (propName.indexOf('on') === 0 && $.isFunction(propValue)) { 341 // dont use $.proxy here because it doesn't create unique handler 342 self[propName] = function() { 343 return propValue.apply(self, arguments); 344 }; 345 } 346 }); 347 } 348 }; 349 350 // public API 351 var api = { 352 version: version, 353 modules: {}, 354 getOptions: function() { 355 return $.extend({}, commonOptions); 356 }, 357 setOptions: function(moduleName, moduleOptions) { 358 if (arguments.length > 1) { 359 // set module options 360 if (this.modules[moduleName]) { 361 $.extend(this.modules[moduleName].prototype.options, moduleOptions); 362 } 363 } else { 364 // set common options 365 $.extend(commonOptions, moduleName); 366 } 367 }, 368 addModule: function(proto) { 369 // add module to list 370 var Module = function(options) { 371 // save instance to collection 372 if (!options.element.data(commonOptions.dataKey)) { 373 options.element.data(commonOptions.dataKey, this); 374 } 375 customInstances.push(this); 376 377 // save options 378 this.options = $.extend({}, commonOptions, this.options, getInlineOptions(options.element), options); 379 380 // bind event handlers to instance 381 this.bindHandlers(); 382 383 // call constructor 384 this.init.apply(this, arguments); 385 }; 386 387 // parse options from HTML attribute 388 var getInlineOptions = function(element) { 389 var dataOptions = element.data(commonOptions.optionsKey), 390 attrOptions = element.attr(commonOptions.optionsKey); 391 392 if (dataOptions) { 393 return dataOptions; 394 } else if (attrOptions) { 395 try { 396 return $.parseJSON(attrOptions); 397 } catch (e) { 398 // ignore invalid attributes 399 } 400 } 401 }; 402 403 // set proto as prototype for new module 404 Module.prototype = proto; 405 406 // add mixin methods to module proto 407 $.extend(proto, moduleMixin); 408 if (proto.plugins) { 409 $.each(proto.plugins, function(pluginName, plugin) { 410 $.extend(plugin.prototype, moduleMixin); 411 }); 412 } 413 414 // override destroy method 415 var originalDestroy = Module.prototype.destroy; 416 Module.prototype.destroy = function() { 417 this.options.element.removeData(this.options.dataKey); 418 419 for (var i = customInstances.length - 1; i >= 0; i--) { 420 if (customInstances[i] === this) { 421 customInstances.splice(i, 1); 422 break; 423 } 424 } 425 426 if (originalDestroy) { 427 originalDestroy.apply(this, arguments); 428 } 429 }; 430 431 // save module to list 432 this.modules[proto.name] = Module; 433 }, 434 getInstance: function(element) { 435 return $(element).data(commonOptions.dataKey); 436 }, 437 replace: function(elements, moduleName, customOptions) { 438 var self = this, 439 instance; 440 441 if (!commonOptions.styleSheetCreated) { 442 createStyleSheet(); 443 } 444 445 $(elements).each(function() { 446 var moduleOptions, 447 element = $(this); 448 449 instance = element.data(commonOptions.dataKey); 450 if (instance) { 451 instance.refresh(); 452 } else { 453 if (!moduleName) { 454 $.each(self.modules, function(currentModuleName, module) { 455 if (module.prototype.matchElement.call(module.prototype, element)) { 456 moduleName = currentModuleName; 457 return false;
458 } 459 }); 460 } 461 if (moduleName) { 462 moduleOptions = $.extend({ element: element }, customOptions); 463 instance = new self.modules[moduleName](moduleOptions); 464 } 465 } 466 }); 467 return instance; 468 }, 469 refresh: function(elements) { 470 $(elements).each(function() { 471 var instance = $(this).data(commonOptions.dataKey); 472 if (instance) { 473 instance.refresh(); 474 } 475 }); 476 }, 477 destroy: function(elements) { 478 $(elements).each(function() { 479 var instance = $(this).data(commonOptions.dataKey); 480 if (instance) { 481 instance.destroy(); 482 } 483 }); 484 }, 485 replaceAll: function(context) { 486 var self = this; 487 $.each(this.modules, function(moduleName, module) { 488 $(module.prototype.selector, context).each(function() { 489 if (this.className.indexOf('jcf-ignore') < 0) { 490 self.replace(this, moduleName); 491 } 492 }); 493 }); 494 }, 495 refreshAll: function(context) { 496 if (context) { 497 $.each(this.modules, function(moduleName, module) { 498 $(module.prototype.selector, context).each(function() { 499 var instance = $(this).data(commonOptions.dataKey); 500 if (instance) { 501 instance.refresh(); 502 } 503 }); 504 }); 505 } else { 506 for (var i = customInstances.length - 1; i >= 0; i--) { 507 customInstances[i].refresh(); 508 } 509 } 510 }, 511 destroyAll: function(context) { 512 if (context) { 513 $.each(this.modules, function(moduleName, module) { 514 $(module.prototype.selector, context).each(function(index, element) { 515 var instance = $(element).data(commonOptions.dataKey); 516 if (instance) { 517 instance.destroy(); 518 } 519 }); 520 }); 521 } else { 522 while (customInstances.length) { 523 customInstances[0].destroy(); 524 } 525 } 526 } 527 }; 528 529 // always export API to the global window object 530 window.jcf = api; 531 532 return api; 533})); 534 535 536 /*! 537 * JavaScript Custom Forms : Range Module 538 * 539 * Copyright 2014-2015 PSD2HTML - http://psd2html.com/jcf 540 * Released under the MIT license (LICENSE.txt) 541 * 542 * Version: 1.1.3 543 */ 544 ;(function($) { 545 546 'use strict'; 547 548 jcf.addModule({ 549 name: 'Range', 550 selector: 'input[type="range"]', 551 options: { 552 realElementClass: 'jcf-real-element', 553 fakeStructure: '<span class="jcf-range"><span class="jcf-range-wrapper"><span class="jcf-range-track"><span class="jcf-range-handle"></span></span></span></span>', 554 dataListMark: '<span class="jcf-range-mark"></span>', 555 rangeDisplayWrapper: '<span class="jcf-range-display-wrapper"></span>', 556 rangeDisplay: '<span class="jcf-range-display"></span>', 557 handleSelector: '.jcf-range-handle', 558 trackSelector: '.jcf-range-track', 559 activeHandleClass: 'jcf-active-handle', 560 verticalClass: 'jcf-vertical', 561 orientation: 'horizontal', 562 range: false, // or "min", "max", "all" 563 dragHandleCenter: true, 564 snapToMarks: true, 565 snapRadius: 5 566 }, 567 matchElement: function(element) { 568 return element.is(this.selector); 569 }, 570 init: function() { 571 this.initStructure(); 572 this.attachEvents(); 573 this.refresh(); 574 }, 575 initStructure: function() { 576 this.page = $('html'); 577 this.realElement = $(this.options.element).addClass(this.options.hiddenClass); 578 this.fakeElement = $(this.options.fakeStructure).insertBefore(this.realElement).prepend(this.realElement); 579 this.track = this.fakeElement.find(this.options.trackSelector); 580 this.trackHolder = this.track.parent(); 581 this.handle = this.fakeElement.find(this.options.handleSelector); 582 this.createdHandleCount = 0; 583 this.activeDragHandleIndex = 0; 584 this.isMultiple = this.realElement.prop('multiple') || typeof this.realElement.attr('multiple') === 'string'; 585 this.values = this.isMultiple ? this.realElement.attr('value').split(',') : [this.realElement.val()]; 586 this.handleCount = this.isMultiple ? this.values.length : 1; 587 588 // create range display 589 this.rangeDisplayWrapper = $(this.options.rangeDisplayWrapper).insertBefore(this.track); 590 if (this.options.range === 'min' || this.options.range === 'all') { 591 this.rangeMin = $(this.options.rangeDisplay).addClass('jcf-range-min').prependTo(this.rangeDisplayWrapper); 592 } 593 if (this.options.range === 'max' || this.options.range === 'all') { 594 this.rangeMax = $(this.options.rangeDisplay).addClass('jcf-range-max').prependTo(this.rangeDisplayWrapper); 595 } 596 597 // clone handles if needed 598 while (this.createdHandleCount < this.handleCount) { 599 this.createdHandleCount++; 600 this.handle.clone().addClass('jcf-index-' + this.createdHandleCount).insertBefore(this.handle); 601 602 // create mid ranges 603 if (this.createdHandleCount > 1) { 604 if (!this.rangeMid) { 605 this.rangeMid = $(); 606 } 607 this.rangeMid = this.rangeMid.add($(this.options.rangeDisplay).addClass('jcf-range-mid').prependTo(this.rangeDisplayWrapper)); 608 } 609 } 610 611 // grab all handles 612 this.handle.detach(); 613 this.handle = null; 614 this.handles = this.fakeElement.find(this.options.handleSelector); 615 this.handles.eq(0).addClass(this.options.activeHandleClass); 616 617 // handle orientation 618 this.isVertical = (this.options.orientation === 'vertical'); 619 this.directionProperty = this.isVertical ? 'top' : 'left'; 620 this.offsetProperty = this.isVertical ? 'bottom' : 'left'; 621 this.eventProperty = this.isVertical ? 'pageY' : 'pageX'; 622 this.sizeProperty = this.isVertical ? 'height' : 'width';
623 this.sizeMethod = this.isVertical ? 'innerHeight' : 'innerWidth'; 624 this.fakeElement.css('touchAction', this.isVertical ? 'pan-x' : 'pan-y'); 625 if (this.isVertical) { 626 this.fakeElement.addClass(this.options.verticalClass); 627 } 628 629 // set initial values 630 this.minValue = parseFloat(this.realElement.attr('min')); 631 this.maxValue = parseFloat(this.realElement.attr('max')); 632 this.stepValue = parseFloat(this.realElement.attr('step')) || 1; 633 634 // check attribute values 635 this.minValue = isNaN(this.minValue) ? 0 : this.minValue; 636 this.maxValue = isNaN(this.maxValue) ? 100 : this.maxValue; 637 638 // handle range 639 if (this.stepValue !== 1) { 640 this.maxValue -= (this.maxValue - this.minValue) % this.stepValue; 641 } 642 this.stepsCount = (this.maxValue - this.minValue) / this.stepValue; 643 this.createDataList(); 644 }, 645 attachEvents: function() { 646 this.realElement.on({ 647 focus: this.onFocus 648 }); 649 this.trackHolder.on('jcf-pointerdown', this.onTrackPress); 650 this.handles.on('jcf-pointerdown', this.onHandlePress); 651 }, 652 createDataList: function() { 653 var self = this, 654 dataValues = [], 655 dataListId = this.realElement.attr('list'); 656 657 if (dataListId) { 658 $('#' + dataListId).find('option').each(function() { 659 var itemValue = parseFloat(this.value || this.innerHTML), 660 mark, markOffset; 661 662 if (!isNaN(itemValue)) { 663 markOffset = self.valueToOffset(itemValue); 664 dataValues.push({ 665 value: itemValue, 666 offset: markOffset 667 }); 668 mark = $(self.options.dataListMark).text(itemValue).attr({ 669 'data-mark-value': itemValue 670 }).css(self.offsetProperty, markOffset + '%').appendTo(self.track); 671 } 672 }); 673 if (dataValues.length) { 674 self.dataValues = dataValues; 675 } 676 } 677 }, 678 getDragHandleRange: function(handleIndex) { 679 // calculate range for slider with multiple handles 680 var minStep = -Infinity, 681 maxStep = Infinity; 682 683 if (handleIndex > 0) { 684 minStep = this.valueToStepIndex(this.values[handleIndex - 1]); 685 } 686 if (handleIndex < this.handleCount - 1) { 687 maxStep = this.valueToStepIndex(this.values[handleIndex + 1]); 688 } 689 690 return { 691 minStepIndex: minStep, 692 maxStepIndex: maxStep 693 }; 694 }, 695 getNearestHandle: function(percent) { 696 // handle vertical sliders 697 if (this.isVertical) { 698 percent = 1 - percent; 699 } 700 701 // detect closest handle when track is pressed 702 var closestHandle = this.handles.eq(0), 703 closestDistance = Infinity, 704 self = this; 705 706 if (this.handleCount > 1) { 707 this.handles.each(function() { 708 var handleOffset = parseFloat(this.style[self.offsetProperty]) / 100, 709 handleDistance = Math.abs(handleOffset - percent); 710 711 if (handleDistance < closestDistance) { 712 closestDistance = handleDistance; 713 closestHandle = $(this); 714 } 715 }); 716 } 717 return closestHandle; 718 }, 719 onTrackPress: function(e) { 720 var trackSize, trackOffset, innerOffset; 721 722 e.preventDefault(); 723 if (!this.realElement.is(':disabled') && !this.activeDragHandle) { 724 trackSize = this.track[this.sizeMethod](); 725 trackOffset = this.track.offset()[this.directionProperty]; 726 this.activeDragHandle = this.getNearestHandle((e[this.eventProperty] - trackOffset) / this.trackHolder[this.sizeMethod]()); 727 this.activeDragHandleIndex = this.handles.index(this.activeDragHandle); 728 this.handles.removeClass(this.options.activeHandleClass).eq(this.activeDragHandleIndex).addClass(this.options.activeHandleClass); 729 innerOffset = this.activeDragHandle[this.sizeMethod]() / 2; 730 731 this.dragData = { 732 trackSize: trackSize, 733 innerOffset: innerOffset, 734 trackOffset: trackOffset, 735 min: trackOffset, 736 max: trackOffset + trackSize 737 }; 738 this.page.on({ 739 'jcf-pointermove': this.onHandleMove, 740 'jcf-pointerup': this.onHandleRelease 741 }); 742 743 if (e.pointerType === 'mouse') { 744 this.realElement.focus(); 745 } 746 747 this.onHandleMove(e); 748 } 749 }, 750 onHandlePress: function(e) { 751 var trackSize, trackOffset, innerOffset; 752 753 e.preventDefault(); 754 if (!this.realElement.is(':disabled') && !this.activeDragHandle) { 755 this.activeDragHandle = $(e.currentTarget); 756 this.activeDragHandleIndex = this.handles.index(this.activeDragHandle); 757 this.handles.removeClass(this.options.activeHandleClass).eq(this.activeDragHandleIndex).addClass(this.options.activeHandleClass); 758 trackSize = this.track[this.sizeMethod](); 759 trackOffset = this.track.offset()[this.directionProperty]; 760 innerOffset = this.options.dragHandleCenter ? this.activeDragHandle[this.sizeMethod]() / 2 : e[this.eventProperty] - this.handle.offset()[this.directionProperty]; 761 762 this.dragData = { 763 trackSize: trackSize, 764 innerOffset: innerOffset, 765 trackOffset: trackOffset, 766 min: trackOffset, 767 max: trackOffset + trackSize 768 }; 769 this.page.on({ 770 'jcf-pointermove': this.onHandleMove, 771 'jcf-pointerup': this.onHandleRelease 772 }); 773 774 if (e.pointerType === 'mouse') { 775 this.realElement.focus(); 776 } 777 } 778 }, 779 onHandleMove: function(e) { 780 var self = this, 781 newOffset, dragPercent, stepIndex, valuePercent, handleDragRange; 782 783 // calculate offset 784 if (this.isVertical) { 785 newOffset = this.dragData.max + (this.dragData.min - e[this.eventProperty]) - this.dragData.innerOffset; 786 } else { 787 newOffset = e[this.eventProperty] - this.dragData.innerOffset; 788 } 789 790 // fit in range 791 if (newOffset < this.dragData.min) { 792 newOffset = this.dragData.min; 793 } else if (newOffset > this.dragData.max) { 794 newOffset = this.dragData.max; 795 } 796 797 e.preventDefault(); 798 if (this.options.snapToMarks && this.dataValues) { 799 // snap handle to marks 800 var dragOffset = newOffset - this.dragData.trackOffset; 801 dragPercent = (newOffset - this.dragData.trackOffset) / this.dragData.trackSize * 100; 802 803 $.each(this.dataValues, function(index, item) { 804 var markOffset = item.offset / 100 * self.dragData.trackSize, 805 markMin = markOffset - self.options.snapRadius, 806 markMax = markOffset + self.options.snapRadius; 807 808 if (dragOffset >= markMin && dragOffset <= markMax) { 809 dragPercent = item.offset; 810 return false;
811 } 812 }); 813 } else { 814 // snap handle to steps 815 dragPercent = (newOffset - this.dragData.trackOffset) / this.dragData.trackSize * 100; 816 } 817 818 // move handle only in range 819 stepIndex = Math.round(dragPercent * this.stepsCount / 100); 820 if (this.handleCount > 1) { 821 handleDragRange = this.getDragHandleRange(this.activeDragHandleIndex); 822 if (stepIndex < handleDragRange.minStepIndex) { 823 stepIndex = Math.max(handleDragRange.minStepIndex, stepIndex); 824 } else if (stepIndex > handleDragRange.maxStepIndex) { 825 stepIndex = Math.min(handleDragRange.maxStepIndex, stepIndex); 826 } 827 } 828 valuePercent = stepIndex * (100 / this.stepsCount); 829 830 if (this.dragData.stepIndex !== stepIndex) { 831 this.dragData.stepIndex = stepIndex; 832 this.dragData.offset = valuePercent; 833 this.activeDragHandle.css(this.offsetProperty, this.dragData.offset + '%'); 834 835 // update value(s) and trigger "input" event 836 this.values[this.activeDragHandleIndex] = '' + this.stepIndexToValue(stepIndex); 837 this.updateValues(); 838 this.realElement.trigger('input'); 839 } 840 }, 841 onHandleRelease: function() { 842 var newValue; 843 if (typeof this.dragData.offset === 'number') { 844 newValue = this.stepIndexToValue(this.dragData.stepIndex); 845 this.realElement.val(newValue).trigger('change'); 846 } 847 848 this.page.off({ 849 'jcf-pointermove': this.onHandleMove, 850 'jcf-pointerup': this.onHandleRelease 851 }); 852 delete this.activeDragHandle; 853 delete this.dragData; 854 }, 855 onFocus: function() { 856 if (!this.fakeElement.hasClass(this.options.focusClass)) { 857 this.fakeElement.addClass(this.options.focusClass); 858 this.realElement.on({ 859 blur: this.onBlur, 860 keydown: this.onKeyPress 861 }); 862 } 863 }, 864 onBlur: function() { 865 this.fakeElement.removeClass(this.options.focusClass); 866 this.realElement.off({ 867 blur: this.onBlur, 868 keydown: this.onKeyPress 869 }); 870 }, 871 onKeyPress: function(e) { 872 var incValue = (e.which === 38 || e.which === 39), 873 decValue = (e.which === 37 || e.which === 40); 874 875 // handle TAB key in slider with multiple handles 876 if (e.which === 9 && this.handleCount > 1) { 877 if (e.shiftKey && this.activeDragHandleIndex > 0) { 878 this.activeDragHandleIndex--; 879 } else if (!e.shiftKey && this.activeDragHandleIndex < this.handleCount - 1) { 880 this.activeDragHandleIndex++; 881 } else { 882 return; 883 } 884 e.preventDefault(); 885 this.handles.removeClass(this.options.activeHandleClass).eq(this.activeDragHandleIndex).addClass(this.options.activeHandleClass); 886 } 887 888 // handle cursor keys 889 if (decValue || incValue) { 890 e.preventDefault(); 891 this.step(incValue ? this.stepValue : -this.stepValue); 892 } 893 }, 894 updateValues: function() { 895 var value = this.values.join(','); 896 if (this.values.length > 1) { 897 this.realElement.prop('valueLow', this.values[0]); 898 this.realElement.prop('valueHigh', this.values[this.values.length - 1]); 899 this.realElement.val(value); 900 901 // if browser does not accept multiple values set only one 902 if (this.realElement.val() !== value) { 903 this.realElement.val(this.values[this.values.length - 1]); 904 } 905 } else { 906 this.realElement.val(value); 907 } 908 909 this.updateRanges(); 910 }, 911 updateRanges: function() { 912 // update display ranges 913 var self = this, 914 handle; 915 916 if (this.rangeMin) { 917 handle = this.handles[0]; 918 this.rangeMin.css(this.offsetProperty, 0).css(this.sizeProperty, handle.style[this.offsetProperty]); 919 } 920 if (this.rangeMax) { 921 handle = this.handles[this.handles.length - 1]; 922 this.rangeMax.css(this.offsetProperty, handle.style[this.offsetProperty]).css(this.sizeProperty, 100 - parseFloat(handle.style[this.offsetProperty]) + '%'); 923 } 924 if (this.rangeMid) { 925 this.handles.each(function(index, curHandle) { 926 var prevHandle, midBox; 927 if (index > 0) { 928 prevHandle = self.handles[index - 1]; 929 midBox = self.rangeMid[index - 1]; 930 midBox.style[self.offsetProperty] = prevHandle.style[self.offsetProperty]; 931 midBox.style[self.sizeProperty] = parseFloat(curHandle.style[self.offsetProperty]) - parseFloat(prevHandle.style[self.offsetProperty]) + '%'; 932 } 933 }); 934 } 935 },
936 step: function(changeValue) { 937 var originalValue = parseFloat(this.values[this.activeDragHandleIndex || 0]), 938 newValue = originalValue, 939 minValue = this.minValue, 940 maxValue = this.maxValue; 941 942 if (isNaN(originalValue)) { 943 newValue = 0; 944 } 945 946 newValue += changeValue; 947 948 if (this.handleCount > 1) { 949 if (this.activeDragHandleIndex > 0) { 950 minValue = parseFloat(this.values[this.activeDragHandleIndex - 1]); 951 } 952 if (this.activeDragHandleIndex < this.handleCount - 1) { 953 maxValue = parseFloat(this.values[this.activeDragHandleIndex + 1]); 954 } 955 } 956 957 if (newValue > maxValue) { 958 newValue = maxValue; 959 } else if (newValue < minValue) { 960 newValue = minValue; 961 } 962 963 if (newValue !== originalValue) { 964 this.values[this.activeDragHandleIndex || 0] = '' + newValue; 965 this.updateValues(); 966 this.realElement.trigger('input').trigger('change'); 967 this.setSliderValue(this.values); 968 } 969 }, 970 valueToStepIndex: function(value) { 971 return (value - this.minValue) / this.stepValue; 972 }, 973 stepIndexToValue: function(stepIndex) { 974 return this.minValue + this.stepValue * stepIndex; 975 }, 976 valueToOffset: function(value) { 977 var range = this.maxValue - this.minValue, 978 percent = (value - this.minValue) / range; 979 980 return percent * 100; 981 }, 982 getSliderValue: function() { 983 return $.map(this.values, function(value) { 984 return parseFloat(value) || 0; 985 }); 986 }, 987 setSliderValue: function(values) { 988 // set handle position accordion according to value 989 var self = this; 990 this.handles.each(function(index, handle) { 991 handle.style[self.offsetProperty] = self.valueToOffset(values[index]) + '%'; 992 }); 993 }, 994 refresh: function() { 995 // handle disabled state 996 var isDisabled = this.realElement.is(':disabled'); 997 this.fakeElement.toggleClass(this.options.disabledClass, isDisabled); 998 999 // refresh handle position according to current value 1000 this.setSliderValue(this.getSliderValue()); 1001 this.updateRanges(); 1002 }, 1003 destroy: function() { 1004 this.realElement.removeClass(this.options.hiddenClass).insertBefore(this.fakeElement); 1005 this.fakeElement.remove(); 1006 1007 this.realElement.off({ 1008 keydown: this.onKeyPress, 1009 focus: this.onFocus, 1010 blur: this.onBlur 1011 }); 1012 } 1013 }); 1014 1015}(jQuery)); 1016 1017 1018 /*! 1019 * JavaScript Custom Forms : Number Module 1020 * 1021 * Copyright 2014-2015 PSD2HTML - http://psd2html.com/jcf 1022 * Released under the MIT license (LICENSE.txt) 1023 * 1024 * Version: 1.1.3 1025 */ 1026 ;(function($) { 1027 1028 'use strict'; 1029 1030 jcf.addModule({ 1031 name: 'Number', 1032 selector: 'input[type="number"]', 1033 options: { 1034 realElementClass: 'jcf-real-element', 1035 fakeStructure: '<span class="jcf-number"><span class="jcf-btn-inc"></span><span class="jcf-btn-dec"></span></span>', 1036 btnIncSelector: '.jcf-btn-inc', 1037 btnDecSelector: '.jcf-btn-dec', 1038 pressInterval: 150 1039 }, 1040 matchElement: function(element) { 1041 return element.is(this.selector); 1042 }, 1043 init: function() { 1044 this.initStructure(); 1045 this.attachEvents(); 1046 this.refresh(); 1047 }, 1048 initStructure: function() { 1049 this.page = $('html'); 1050 this.realElement = $(this.options.element).addClass(this.options.realElementClass); 1051 this.fakeElement = $(this.options.fakeStructure).insertBefore(this.realElement).prepend(this.realElement); 1052 this.btnDec = this.fakeElement.find(this.options.btnDecSelector); 1053 this.btnInc = this.fakeElement.find(this.options.btnIncSelector); 1054 1055 // set initial values 1056 this.initialValue = parseFloat(this.realElement.val()) || 0; 1057 this.minValue = parseFloat(this.realElement.attr('min')); 1058 this.maxValue = parseFloat(this.realElement.attr('max')); 1059 this.stepValue = parseFloat(this.realElement.attr('step')) || 1; 1060 1061 // check attribute values 1062 this.minValue = isNaN(this.minValue) ? -Infinity : this.minValue; 1063 this.maxValue = isNaN(this.maxValue) ? Infinity : this.maxValue; 1064 1065 // handle range 1066 if (isFinite(this.maxValue)) { 1067 this.maxValue -= (this.maxValue - this.minValue) % this.stepValue; 1068 } 1069 }, 1070 attachEvents: function() { 1071 this.realElement.on({ 1072 focus: this.onFocus 1073 }); 1074 this.btnDec.add(this.btnInc).on('jcf-pointerdown', this.onBtnPress); 1075 }, 1076 onBtnPress: function(e) { 1077 var self = this, 1078 increment; 1079 1080 if (!this.realElement.is(':disabled')) { 1081 increment = this.btnInc.is(e.currentTarget); 1082 1083 self.step(increment); 1084 clearInterval(this.stepTimer); 1085 this.stepTimer = setInterval(function() { 1086 self.step(increment); 1087 }, this.options.pressInterval); 1088 1089 this.page.on('jcf-pointerup', this.onBtnRelease); 1090 } 1091 }, 1092 onBtnRelease: function() { 1093 clearInterval(this.stepTimer); 1094 this.page.off('jcf-pointerup', this.onBtnRelease); 1095 }, 1096 onFocus: function() { 1097 this.fakeElement.addClass(this.options.focusClass); 1098 this.realElement.on({ 1099 blur: this.onBlur, 1100 keydown: this.onKeyPress 1101 }); 1102 }, 1103 onBlur: function() { 1104 this.fakeElement.removeClass(this.options.focusClass); 1105 this.realElement.off({ 1106 blur: this.onBlur, 1107 keydown: this.onKeyPress 1108 }); 1109 }, 1110 onKeyPress: function(e) { 1111 if (e.which === 38 || e.which === 40) { 1112 e.preventDefault(); 1113 this.step(e.which === 38); 1114 } 1115 }, 1116 step: function(increment) { 1117 var originalValue = parseFloat(this.realElement.val()), 1118 newValue = originalValue || 0, 1119 addValue = this.stepValue * (increment ? 1 : -1), 1120 edgeNumber = isFinite(this.minValue) ? this.minValue : this.initialValue - Math.abs(newValue * this.stepValue), 1121 diff = Math.abs(edgeNumber - newValue) % this.stepValue; 1122 1123 // handle step diff 1124 if (diff) { 1125 if (increment) { 1126 newValue += addValue - diff; 1127 } else { 1128 newValue -= diff; 1129 } 1130 } else { 1131 newValue += addValue; 1132 } 1133 1134 // handle min/max limits 1135 if (newValue < this.minValue) { 1136 newValue = this.minValue; 1137 } else if (newValue > this.maxValue) { 1138 newValue = this.maxValue; 1139 } 1140 1141 // update value in real input if its changed 1142 if (newValue !== originalValue) { 1143 this.realElement.val(newValue).trigger('change'); 1144 this.refresh(); 1145 } 1146 }, 1147 refresh: function() { 1148 var isDisabled = this.realElement.is(':disabled'), 1149 currentValue = parseFloat(this.realElement.val()); 1150 1151 // handle disabled state 1152 this.fakeElement.toggleClass(this.options.disabledClass, isDisabled); 1153 1154 // refresh button classes 1155 this.btnDec.toggleClass(this.options.disabledClass, currentValue === this.minValue); 1156 this.btnInc.toggleClass(this.options.disabledClass, currentValue === this.maxValue); 1157 }, 1158 destroy: function() { 1159 // restore original structure 1160 this.realElement.removeClass(this.options.realElementClass).insertBefore(this.fakeElement); 1161 this.fakeElement.remove(); 1162 clearInterval(this.stepTimer); 1163 1164 // remove event handlers 1165 this.page.off('jcf-pointerup', this.onBtnRelease); 1166 this.realElement.off({ 1167 keydown: this.onKeyPress, 1168 focus: this.onFocus, 1169 blur: this.onBlur 1170 }); 1171 } 1172 }); 1173 1174}(jQuery)); 1175 1176 1177 /*! 1178 * JavaScript Custom Forms : File Module 1179 * 1180 * Copyright 2014-2015 PSD2HTML - http://psd2html.com/jcf 1181 * Released under the MIT license (LICENSE.txt) 1182 * 1183 * Version: 1.1.3 1184 */ 1185 ;(function($) { 1186 1187 'use strict'; 1188 1189 jcf.addModule({ 1190 name: 'File', 1191 selector: 'input[type="file"]', 1192 options: { 1193 /*fakeStructure: '<span class="jcf-file"><span class="jcf-fake-input"></span><span class="jcf-upload-button"><span class="jcf-button-content"></span></span></span>', 1194 buttonText: 'ÐÑбÑаÑÑ Ñайл', 1195 placeholderText: 'No file chosen', */ 1196 realElementClass: 'jcf-real-element', 1197 extensionPrefixClass: 'jcf-extension-', 1198 selectedFileBlock: '.jcf-fake-input', 1199 buttonTextBlock: '.jcf-button-content' 1200 }, 1201 matchElement: function(element) { 1202 return element.is('input[type="file"]'); 1203 }, 1204 init: function() { 1205 this.initStructure(); 1206 this.attachEvents(); 1207 this.refresh(); 1208 }, 1209 initStructure: function() { 1210 this.doc = $(document); 1211 this.realElement = $(this.options.element).addClass(this.options.realElementClass); 1212 this.fakeElement = $(this.options.fakeStructure).insertBefore(this.realElement); 1213 this.fileNameBlock = this.fakeElement.find(this.options.selectedFileBlock); 1214 this.buttonTextBlock = this.fakeElement.find(this.options.buttonTextBlock).text(this.options.buttonText); 1215 1216 this.realElement.appendTo(this.fakeElement).css({ 1217 position: 'absolute', 1218 opacity: 0 1219 }); 1220 }, 1221 attachEvents: function() { 1222 this.realElement.on({ 1223 'jcf-pointerdown': this.onPress, 1224 change: this.onChange, 1225 focus: this.onFocus 1226 }); 1227 }, 1228 onChange: function() { 1229 this.refresh(); 1230 }, 1231 onFocus: function() { 1232 this.fakeElement.addClass(this.options.focusClass); 1233 this.realElement.on('blur', this.onBlur); 1234 }, 1235 onBlur: function() { 1236 this.fakeElement.removeClass(this.options.focusClass); 1237 this.realElement.off('blur', this.onBlur); 1238 }, 1239 onPress: function() { 1240 this.fakeElement.addClass(this.options.pressedClass); 1241 this.doc.on('jcf-pointerup', this.onRelease); 1242 }, 1243 onRelease: function() { 1244 this.fakeElement.removeClass(this.options.pressedClass); 1245 this.doc.off('jcf-pointerup', this.onRelease); 1246 }, 1247 getFileName: function() { 1248 var resultFileName = '', 1249 files = this.realElement.prop('files'); 1250 1251 if (files && files.length) { 1252 $.each(files, function(index, file) { 1253 resultFileName += (index > 0 ? ', ' : '') + file.name; 1254 }); 1255 } else { 1256 resultFileName = this.realElement.val().replace(/^[\s\S]*(?:\\|\/)([\s\S^\\\/]*)$/g, '$1'); 1257 } 1258 1259 return resultFileName; 1260 }, 1261 getFileExtension: function() { 1262 var fileName = this.realElement.val(); 1263 return fileName.lastIndexOf('.') < 0 ? '' : fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase(); 1264 }, 1265 updateExtensionClass: function() { 1266 var currentExtension = this.getFileExtension(), 1267 currentClassList = this.fakeElement.prop('className'), 1268 cleanedClassList = currentClassList.replace(new RegExp('(\\s|^)' + this.options.extensionPrefixClass + '[^ ]+','gi'), ''); 1269 1270 this.fakeElement.prop('className', cleanedClassList); 1271 if (currentExtension) { 1272 this.fakeElement.addClass(this.options.extensionPrefixClass + currentExtension); 1273 } 1274 }, 1275 refresh: function() { 1276 var selectedFileName = this.getFileName() || this.options.placeholderText; 1277 this.fakeElement.toggleClass(this.options.disabledClass, this.realElement.is(':disabled')); 1278 this.fileNameBlock.text(selectedFileName); 1279 this.updateExtensionClass(); 1280 }, 1281 destroy: function() { 1282 // reset styles and restore element position 1283 this.realElement.insertBefore(this.fakeElement).removeClass(this.options.realElementClass).css({ 1284 position: '', 1285 opacity: '' 1286 }); 1287 this.fakeElement.remove(); 1288 1289 // remove event handlers 1290 this.realElement.off({ 1291 'jcf-pointerdown': this.onPress, 1292 change: this.onChange, 1293 focus: this.onFocus, 1294 blur: this.onBlur 1295 }); 1296 this.doc.off('jcf-pointerup', this.onRelease); 1297 } 1298 }); 1299 1300}(jQuery)); 1301 1302/* global jQuery */ 1303(function ($) { 1304 // Custom easing function 1305 $.extend($.easing, { 1306 // This is ripped directly from the jQuery easing plugin (easeOutExpo), from: http://gsgd.co.uk/sandbox/jquery/easing/ 1307 spincrementEasing: function (x, t, b, c, d) { 1308 return (t === d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b 1309 } 1310 }) 1311 1312 // Spincrement function 1313 $.fn.spincrement = function (opts) { 1314 // Default values 1315 var defaults = { 1316 from: 0, 1317 to: null, 1318 decimalPlaces: null, 1319 decimalPoint: '.', 1320 thousandSeparator: ',', 1321 duration: 1000, // ms; TOTAL length animation 1322 leeway: 50, // percent of duraion 1323 easing: 'spincrementEasing', 1324 fade: true, 1325 complete: null 1326 } 1327 var options = $.extend(defaults, opts) 1328 1329 // Function for formatting number 1330 var re_thouSep = new RegExp(/^(-?[0-9]+)([0-9]{3})/) 1331 function format (num, dp) {
1332 num = num.toFixed(dp) // converts to string! 1333 1334 // Non "." decimal point 1335 if ((dp > 0) && (options.decimalPoint !== '.')) { 1336 num = num.replace('.', options.decimalPoint) 1337 } 1338 1339 // Thousands separator 1340 if (options.thousandSeparator) { 1341 while (re_thouSep.test(num)) { 1342 num = num.replace(re_thouSep, '$1' + options.thousandSeparator + '$2') 1343 } 1344 } 1345 return num 1346 } 1347 1348 // Apply to each matching item 1349 return this.each(function () { 1350 // Get handle on current obj 1351 var obj = $(this) 1352 1353 // Set params FOR THIS ELEM 1354 var from = options.from 1355 if (obj.attr('data-from')) { 1356 from = parseFloat(obj.attr('data-from')) 1357 } 1358 1359 var to 1360 if (obj.attr('data-to')) { 1361 to = parseFloat(obj.attr('data-to')) 1362 } else if (options.to !== null) { 1363 to = options.to 1364 } else { 1365 var ts = $.inArray(options.thousandSeparator, ['\\', '^', '$', '*', '+', '?', '.']) > -1 ? '\\' + options.thousandSeparator : options.thousandSeparator 1366 var re = new RegExp(ts, 'g') 1367 to = parseFloat(obj.text().replace(re, '')) 1368 } 1369 1370 var duration = options.duration 1371 if (options.leeway) { 1372 // If leeway is set, randomise duration a little 1373 duration += Math.round(options.duration * ((Math.random() * 2) - 1) * options.leeway / 100) 1374 } 1375 1376 var dp 1377 if (obj.attr('data-dp')) { 1378 dp = parseInt(obj.attr('data-dp'), 10) 1379 } else if (options.decimalPlaces !== null) { 1380 dp = options.decimalPlaces 1381 } else { 1382 var ix = obj.text().indexOf(options.decimalPoint) 1383 dp = (ix > -1) ? obj.text().length - (ix + 1) : 0 1384 } 1385 1386 // Start 1387 obj.css('counter', from) 1388 if (options.fade) obj.css('opacity', 0) 1389 obj.animate( 1390 { 1391 counter: to, 1392 opacity: 1 1393 }, 1394 { 1395 easing: options.easing, 1396 duration: duration, 1397 1398 // Invoke the callback for each step. 1399 step: function (progress) { 1400 obj.html(format(progress * to, dp)) 1401 }, 1402 complete: function () { 1403 // Cleanup 1404 obj.css('counter', null) 1405 obj.html(format(to, dp)) 1406 1407 // user's callback 1408 if (options.complete) { 1409 options.complete(obj) 1410 } 1411 } 1412 } 1413 ) 1414 }) 1415 } 1416})(jQuery) 1417 1418// PRODUCT QUANTITY BOX ///////////////////////////////////////////////////////////////////////////////////////////////////// 1419$(document).on("focusout",".quantity_input",function(){var a=$(this).val();isNaN(parseFloat(a))&&!isFinite(a)||0==parseInt(a)||""==a?$(this).val(1):parseInt(a)<0?$(this).val(parseInt(a)-2*parseInt(a)):$(this).val(parseInt(a))}),$(document).on("click",".quantity_up",function(){var a=$(this).parent().find(".quantity_input");isNaN(parseFloat(a.val()))||!isFinite(a.val())||a.attr("disabled")?a.val(1):a.val(parseInt(a.val())+1)}),$(document).on("click",".quantity_down",function(){var a=$(this).parent().find(".quantity_input");!isNaN(parseFloat(a.val()))&&isFinite(a.val())&&a.val()>1&&!a.attr("disabled")?a.val(parseInt(a.val())-1):a.val(1)}); 1420 1421 1422var printprice = function(str) { 1423 var parts = (str + '').split('.'), 1424 main = parts[0], 1425 len = main.length, 1426 output = '', 1427 i = len - 1; 1428 1429 while(i >= 0) { 1430 output = main.charAt(i) + output; 1431 if ((len - i) % 3 === 0 && i > 0) { 1432 output = ' ' + output; 1433 } 1434 --i; 1435 } 1436 1437 if (parts.length > 1) { 1438 output += '.' + parts[1]; 1439 } 1440 return output; 1441}; 1442function to_cart_tov(tovar_id){ 1443 tm = "#kolvo"+tovar_id; 1444 tm = tm.replace("\.","-"); 1445 kolvo1 = $(tm).prop("value"); 1446 color = $("#color").prop("value"); 1447 if(color!="") tovar_id = tovar_id+'.'+color; 1448 $.ajax({ 1449 type: "POST", 1450 url: "/to-cart-ajax.php", 1451 data: {tid:tovar_id,add:1,kolvo:kolvo1}, 1452 dataType: 'json', 1453 success:(function(result){ 1454 $("#cart-amount").html(result.amount); 1455 $("#cart-amount2").html(result.amount); 1456 $.fancybox.open($('#added-to-cart')); 1457 }) 1458 }) 1459 return false;
1460} 1461function change_color(color_id,price){ 1462 $(".colors a").removeClass('active'); 1463 $("#col"+color_id).addClass('active'); 1464 $("#color").val(color_id); 1465 if(price>0) $("#pricecolor").html(printprice(price)+' ÑÑб.'); 1466 else $("#pricecolor").html('Цена по запÑоÑÑ'); 1467 return false; 1468} 1469 1470function to_cart_all(){ 1471 formData = new FormData($("#allgoods").get(0)); 1472 $.ajax({ 1473 type: "POST", 1474 processData: false, 1475 contentType: false, 1476 url: "/to-cart-ajax.php", 1477 data: formData, 1478 dataType: 'json', 1479 success:(function(result){ 1480 $("#cart-amount").html(result.amount); 1481 $("#cart-amount2").html(result.amount); 1482 if(result.fanc) $.fancybox.open($('#added-to-cart')); 1483 }) 1484 }) 1485 return false; 1486} 1487function changekolvokor(i,tovar_id){ 1488 kl = "#kolvo"+i; 1489 kolvo1 = $(kl).prop("value"); 1490 sm = "#kor-summa"+i; 1491 $.ajax({ 1492 type: "POST", 1493 url: "/to-cart-ajax.php", 1494 data: {tid:tovar_id,kolvo:kolvo1,cartn:i,changekolvo:1}, 1495 dataType: 'json', 1496 success:(function(result){ 1497 $("#cart-total").html(result.total); 1498 $("#cart-amount").html(result.amount); 1499 $("#cart-amount2").html(result.amount); 1500 $(sm).html(result.summa); 1501 }) 1502 }) 1503} 1504function showaddress(){ 1505 dost1 = $("#dost").prop("value"); 1506 if(dost1=="ÑамовÑвоз") $("#address").css("display", "none"); 1507 else $("#address").css("display", "flex"); 1508 /*$.ajax({ 1509 type: "POST", 1510 url: "/to-cart-ajax.php", 1511 data: {changedost:1,dost:dost1}, 1512 dataType: 'json', 1513 success:(function(result){ 1514 $("#cart-final").html(result.final2); 1515 }) 1516 })*/ 1517} 1518function validate_order(){ 1519 valid = true; 1520 if(!$("#polit").prop('checked')){ 1521 alert("ÐожалÑйÑÑа, ознакомÑÑеÑÑ Ñ Ð¿Ð¾Ð»Ð¸Ñикой конÑиденÑиалÑноÑÑи и подÑвеÑдиÑе ÑоглаÑие на обÑабоÑÐºÑ Ð»Ð¸ÑнÑÑ Ð´Ð°Ð½Ð½ÑÑ ."); 1522 valid = false; 1523 } 1524 return valid; 1525}
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.