Курсовая работа: Разработка сайта по составлению комплектации компьютера

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам

},

checkAp : function () {

var base = this;

if (base.apStatus !== "stop") {

base.play();

}

},

play : function () {

var base = this;

base.apStatus = "play";

if (base.options.autoPlay === false) {

return false;

}

window.clearInterval(base.autoPlayInterval);

base.autoPlayInterval = window.setInterval(function () {

base.next(true);

}, base.options.autoPlay);

},

swapSpeed : function (action) {

var base = this;

if (action === "slideSpeed") {

base.$owlWrapper.css(base.addCssSpeed(base.options.slideSpeed));

} else if (action === "paginationSpeed") {

base.$owlWrapper.css(base.addCssSpeed(base.options.paginationSpeed));

} else if (typeof action !== "string") {

base.$owlWrapper.css(base.addCssSpeed(action));

}

},

addCssSpeed : function (speed) {

return {

"-webkit-transition": "all " + speed + "ms ease",

"-moz-transition": "all " + speed + "ms ease",

"-o-transition": "all " + speed + "ms ease",

"transition": "all " + speed + "ms ease"

};

},

removeTransition : function () {

return {

"-webkit-transition": "",

"-moz-transition": "",

"-o-transition": "",

"transition": ""

};

},

doTranslate : function (pixels) {

return {

"-webkit-transform": "translate3d(" + pixels + "px, 0px, 0px)",

"-moz-transform": "translate3d(" + pixels + "px, 0px, 0px)",

"-o-transform": "translate3d(" + pixels + "px, 0px, 0px)",

"-ms-transform": "translate3d(" + pixels + "px, 0px, 0px)",

"transform": "translate3d(" + pixels + "px, 0px,0px)"

};

},

transition3d : function (value) {

var base = this;

base.$owlWrapper.css(base.doTranslate(value));

},

css2move : function (value) {

var base = this;

base.$owlWrapper.css({"left" : value});

},

css2slide : function (value, speed) {

var base = this;

base.isCssFinish = false;

base.$owlWrapper.stop(true, true).animate({

"left" : value

}, {

duration : speed || base.options.slideSpeed,

complete : function () {

base.isCssFinish = true;

}

});

},

checkBrowser : function () {

var base = this,

translate3D = "translate3d(0px, 0px, 0px)",

tempElem = document.createElement("div"),

regex,

asSupport,

support3d,

isTouch;

tempElem.style.cssText = " -moz-transform:" + translate3D +

"; -ms-transform:" + translate3D +

"; -o-transform:" + translate3D +

"; -webkit-transform:" + translate3D +

"; transform:" + translate3D;

regex = /translate3d\(0px, 0px, 0px\)/g;

asSupport = tempElem.style.cssText.match(regex);

support3d = (asSupport !== null && asSupport.length === 1);

isTouch = "ontouchstart" in window || window.navigator.msMaxTouchPoints;

base.browser = {

"support3d" : support3d,

"isTouch" : isTouch

};

},

moveEvents : function () {

var base = this;

if (base.options.mouseDrag !== false || base.options.touchDrag !== false) {

base.gestures();

base.disabledEvents();

}

},

eventTypes : function () {

var base = this,

types = ["s", "e", "x"];

base.ev_types = {};

if (base.options.mouseDrag === true && base.options.touchDrag === true) {

types = [

"touchstart.owl mousedown.owl",

"touchmove.owl mousemove.owl",

"touchend.owl touchcancel.owl mouseup.owl"

];

} else if (base.options.mouseDrag === false && base.options.touchDrag === true) {

types = [

"touchstart.owl",

"touchmove.owl",

"touchend.owl touchcancel.owl"

];

} else if (base.options.mouseDrag === true && base.options.touchDrag === false) {

types = [

"mousedown.owl",

"mousemove.owl",

"mouseup.owl"

];

}

base.ev_types.start = types[0];

base.ev_types.move = types[1];

base.ev_types.end = types[2];

},

disabledEvents : function () {

var base = this;

base.$elem.on("dragstart.owl", function (event) { event.preventDefault(); });

base.$elem.on("mousedown.disableTextSelect", function (e) {

return $(e.target).is('input, textarea, select, option');

});

},

gestures : function () {

/*jslint unparam: true*/

var base = this,

locals = {

offsetX : 0,

offsetY : 0,

baseElWidth : 0,

relativePos : 0,

position: null,

minSwipe : null,

maxSwipe: null,

sliding : null,

dargging: null,

targetElement : null

};

base.isCssFinish = true;

function getTouches(event) {

if (event.touches !== undefined) {

return {

x : event.touches[0].pageX,

y : event.touches[0].pageY

};

}

if (event.touches === undefined) {

if (event.pageX !== undefined) {

return {

x : event.pageX,

y : event.pageY

};

}

if (event.pageX === undefined) {

return {

x : event.clientX,

y : event.clientY

};

}

}

}

function swapEvents(type) {

if (type === "on") {

$(document).on(base.ev_types.move, dragMove);

$(document).on(base.ev_types.end, dragEnd);

} else if (type === "off") {

$(document).off(base.ev_types.move);

$(document).off(base.ev_types.end);

}

}

function dragStart(event) {

var ev = event.originalEvent || event || window.event,

position;

if (ev.which === 3) {

return false;

}

if (base.itemsAmount <= base.options.items) {

return;

}

if (base.isCssFinish === false && !base.options.dragBeforeAnimFinish) {

return false;

}

if (base.isCss3Finish === false && !base.options.dragBeforeAnimFinish) {

return false;

}

if (base.options.autoPlay !== false) {

window.clearInterval(base.autoPlayInterval);

}

if (base.browser.isTouch !== true && !base.$owlWrapper.hasClass("grabbing")) {

base.$owlWrapper.addClass("grabbing");

}

base.newPosX = 0;

base.newRelativeX = 0;

$(this).css(base.removeTransition());

position = $(this).position();

locals.relativePos = position.left;

locals.offsetX = getTouches(ev).x - position.left;

locals.offsetY = getTouches(ev).y - position.top;

swapEvents("on");

locals.sliding = false;

locals.targetElement = ev.target || ev.srcElement;

}

function dragMove(event) {

var ev = event.originalEvent || event || window.event,

minSwipe,

maxSwipe;

base.newPosX = getTouches(ev).x - locals.offsetX;

base.newPosY = getTouches(ev).y - locals.offsetY;

base.newRelativeX = base.newPosX - locals.relativePos;

if (typeof base.options.startDragging === "function" && locals.dragging !== true && base.newRelativeX !== 0) {

locals.dragging = true;

base.options.startDragging.apply(base, [base.$elem]);

}

if ((base.newRelativeX > 8 || base.newRelativeX < -8) && (base.browser.isTouch === true)) {

if (ev.preventDefault !== undefined) {

ev.preventDefault();

} else {

ev.returnValue = false;

}

locals.sliding = true;

}

if ((base.newPosY > 10 || base.newPosY < -10) && locals.sliding === false) {

$(document).off("touchmove.owl");

}

minSwipe = function () {

return base.newRelativeX / 5;

};

maxSwipe = function () {

return base.maximumPixels + base.newRelativeX / 5;

};

base.newPosX = Math.max(Math.min(base.newPosX, minSwipe()), maxSwipe());

if (base.browser.support3d === true) {

base.transition3d(base.newPosX);

} else {

base.css2move(base.newPosX);

}

}

function dragEnd(event) {

var ev = event.originalEvent || event || window.event,

newPosition,

handlers,

owlStopEvent;

ev.target = ev.target || ev.srcElement;

locals.dragging = false;

if (base.browser.isTouch !== true) {

base.$owlWrapper.removeClass("grabbing");

}

if (base.newRelativeX < 0) {

base.dragDirection = base.owl.dragDirection = "left";

} else {

base.dragDirection = base.owl.dragDirection = "right";

}

if (base.newRelativeX !== 0) {

newPosition = base.getNewPosition();

base.goTo(newPosition, false, "drag");

if (locals.targetElement === ev.target && base.browser.isTouch !== true) {

$(ev.target).on("click.disable", function (ev) {

ev.stopImmediatePropagation();

ev.stopPropagation();

ev.preventDefault();

$(ev.target).off("click.disable");

});

handlers = $._data(ev.target, "events").click;

owlStopEvent = handlers.pop();

handlers.splice(0, 0, owlStopEvent);

}

}

swapEvents("off");

}

base.$elem.on(base.ev_types.start, ".owl-wrapper", dragStart);

},

getNewPosition : function () {

var base = this,

newPosition = base.closestItem();

if (newPosition > base.maximumItem) {

base.currentItem = base.maximumItem;

newPosition = base.maximumItem;

} else if (base.newPosX >= 0) {

newPosition = 0;

base.currentItem = 0;

}

return newPosition;

},

closestItem : function () {

var base = this,

array = base.options.scrollPerPage === true ? base.pagesInArray : base.positionsInArray,

goal = base.newPosX,

closest = null;

$.each(array, function (i, v) {

if (goal - (base.itemWidth / 20) > array[i + 1] && goal - (base.itemWidth / 20) < v && base.moveDirection() === "left") {

closest = v;

if (base.options.scrollPerPage === true) {

base.currentItem = $.inArray(closest, base.positionsInArray);

} else {

base.currentItem = i;

}

} else if (goal + (base.itemWidth / 20) < v && goal + (base.itemWidth / 20) > (array[i + 1] || array[i] - base.itemWidth) && base.moveDirection() === "right") {

if (base.options.scrollPerPage === true) {

closest = array[i + 1] || array[array.length - 1];

base.currentItem = $.inArray(closest, base.positionsInArray);

} else {

closest = array[i + 1];

base.currentItem = i + 1;

}

}

});

return base.currentItem;

},

moveDirection : function () {

var base = this,

direction;

if (base.newRelativeX < 0) {

direction = "right";

base.playDirection = "next";

} else {

direction = "left";

base.playDirection = "prev";

}

return direction;

},

customEvents : function () {

/*jslint unparam: true*/

var base = this;

base.$elem.on("owl.next", function () {

base.next();

});

base.$elem.on("owl.prev", function () {

base.prev();

});

base.$elem.on("owl.play", function (event, speed) {

base.options.autoPlay = speed;

base.play();

base.hoverStatus = "play";

});

base.$elem.on("owl.stop", function () {

base.stop();

base.hoverStatus = "stop";

});

base.$elem.on("owl.goTo", function (event, item) {

base.goTo(item);

});

base.$elem.on("owl.jumpTo", function (event, item) {

base.jumpTo(item);

});

},

stopOnHover : function () {

var base = this;

if (base.options.stopOnHover === true && base.browser.isTouch !== true && base.options.autoPlay !== false) {

base.$elem.on("mouseover", function () {

base.stop();

});

base.$elem.on("mouseout", function () {

if (base.hoverStatus !== "stop") {

base.play();

}

});

}

},

lazyLoad : function () {

var base = this,

i,

$item,

itemNumber,

$lazyImg,

follow;

if (base.options.lazyLoad === false) {

return false;

}

for (i = 0; i < base.itemsAmount; i += 1) {

$item = $(base.$owlItems[i]);

if ($item.data("owl-loaded") === "loaded") {

continue;

}

itemNumber = $item.data("owl-item");

$lazyImg = $item.find(".lazyOwl");

if (typeof $lazyImg.data("src") !== "string") {

$item.data("owl-loaded", "loaded");

continue;

}

if ($item.data("owl-loaded") === undefined) {

$lazyImg.hide();

$item.addClass("loading").data("owl-loaded", "checked");

}

if (base.options.lazyFollow === true) {

follow = itemNumber >= base.currentItem;

} else {

follow = true;

}

if (follow && itemNumber < base.currentItem + base.options.items && $lazyImg.length) {

base.lazyPreload($item, $lazyImg);

}

}

},

lazyPreload : function ($item, $lazyImg) {

var base = this,

iterations = 0,

isBackgroundImg;

if ($lazyImg.prop("tagName") === "DIV") {

$lazyImg.css("background-image", "url(" + $lazyImg.data("src") + ")");

isBackgroundImg = true;

} else {

$lazyImg[0].src = $lazyImg.data("src");

}

function showImage() {

$item.data("owl-loaded", "loaded").removeClass("loading");

$lazyImg.removeAttr("data-src");

if (base.options.lazyEffect === "fade") {

$lazyImg.fadeIn(400);

} else {

$lazyImg.show();

}

if (typeof base.options.afterLazyLoad === "function") {

base.options.afterLazyLoad.apply(this, [base.$elem]);

}

}

function checkLazyImage() {

iterations += 1;

if (base.completeImg($lazyImg.get(0)) || isBackgroundImg === true) {

showImage();

} else if (iterations <= 100) {//if image loads in less than 10 seconds

window.setTimeout(checkLazyImage, 100);

} else {

showImage();

}

}

checkLazyImage();

},

autoHeight : function () {

var base = this,

$currentimg = $(base.$owlItems[base.currentItem]).find("img"),

iterations;

function addHeight() {

var $currentItem = $(base.$owlItems[base.currentItem]).height();

base.wrapperOuter.css("height", $currentItem + "px");

if (!base.wrapperOuter.hasClass("autoHeight")) {

window.setTimeout(function () {

base.wrapperOuter.addClass("autoHeight");

}, 0);

}

}

function checkImage() {

iterations += 1;

if (base.completeImg($currentimg.get(0))) {

addHeight();

} else if (iterations <= 100) { //if image loads in less than 10 seconds

window.setTimeout(checkImage, 100);