beautify_js

This commit is contained in:
Ilya Kantor 2015-03-09 18:48:58 +03:00
parent 0febe4f5fd
commit 5c2f32e184
208 changed files with 3891 additions and 1474 deletions

View file

@ -28,9 +28,12 @@ function Voter(options) {
function setVote(vote) {
voteElem.innerHTML = +vote;
var widgetEvent = new CustomEvent("change", { bubbles: true, detail: +vote });
var widgetEvent = new CustomEvent("change", {
bubbles: true,
detail: +vote
});
elem.dispatchEvent(widgetEvent);
};
this.setVote = setVote;
}
}

View file

@ -1,4 +1,3 @@
function ListSelect(options) {
var elem = options.elem;
@ -12,7 +11,7 @@ function ListSelect(options) {
var li = e.target.closest('li');
if (!li) return;
if(e.metaKey || e.ctrlKey) { // для Mac проверяем Cmd, т.к. Ctrl + click там контекстное меню
if (e.metaKey || e.ctrlKey) { // для Mac проверяем Cmd, т.к. Ctrl + click там контекстное меню
toggleSelect(li);
} else if (e.shiftKey) {
selectFromLast(li);
@ -47,17 +46,17 @@ function ListSelect(options) {
if (startElem == target) {
// клик на том же элементе, что и раньше
// это особый случай
return;
return;
}
var isLastClickedBefore = startElem.compareDocumentPosition(target) & 4;
if (isLastClickedBefore) {
for(var elem = startElem; elem != target; elem = elem.nextElementSibling) {
for (var elem = startElem; elem != target; elem = elem.nextElementSibling) {
elem.classList.add('selected');
}
} else {
for(var elem = startElem; elem != target; elem = elem.previousElementSibling) {
for (var elem = startElem; elem != target; elem = elem.previousElementSibling) {
elem.classList.add('selected');
}
}
@ -65,7 +64,7 @@ function ListSelect(options) {
function dispatchEvent() {
var widgetEvent = new CustomEvent("select", {
bubbles: true,
bubbles: true,
detail: getSelected()
});
elem.dispatchEvent(widgetEvent);
@ -78,4 +77,4 @@ function ListSelect(options) {
};
this.getSelected = getSelected;
}
}

View file

@ -25,11 +25,11 @@ function CustomSelect(options) {
elem.querySelector('.title').innerHTML = title;
var widgetEvent = new CustomEvent('select', {
bubbles: true,
bubbles: true,
detail: {
title: title,
value: value
}
}
});
elem.dispatchEvent(widgetEvent);
@ -53,4 +53,4 @@ function CustomSelect(options) {
isOpen = false;
}
}
}

View file

@ -38,11 +38,11 @@ function Slider(options) {
var newLeft = clientX - shiftX - sliderCoords.left;
// курсор ушёл вне слайдера
if(newLeft < 0) {
if (newLeft < 0) {
newLeft = 0;
}
var rightEdge = elem.offsetWidth - thumbElem.offsetWidth;
if(newLeft > rightEdge) {
if (newLeft > rightEdge) {
newLeft = rightEdge;
}
@ -59,7 +59,7 @@ function Slider(options) {
}
function positionToValue(left) {
return Math.round( left / pixelsPerValue);
return Math.round(left / pixelsPerValue);
}
function onDocumentMouseMove(e) {
@ -85,4 +85,4 @@ function Slider(options) {
}
this.setValue = setValue;
}
}

View file

@ -7,7 +7,9 @@ function Menu(options) {
}
function render() {
var html = options.template({title: options.title});
var html = options.template({
title: options.title
});
elem = document.createElement('div');
elem.innerHTML = html;
@ -32,8 +34,10 @@ function Menu(options) {
function renderItems() {
if (elem.querySelector('ul')) return;
var listHtml = options.listTemplate({items: options.items});
var listHtml = options.listTemplate({
items: options.items
});
elem.insertAdjacentHTML("beforeEnd", listHtml);
}
@ -59,4 +63,4 @@ function Menu(options) {
this.toggle = toggle;
this.close = close;
this.open = open;
}
}

View file

@ -7,7 +7,9 @@ function Menu(options) {
}
function render() {
var html = options.template({title: options.title});
var html = options.template({
title: options.title
});
elem = document.createElement('div');
elem.innerHTML = html;
@ -32,13 +34,15 @@ function Menu(options) {
function renderItems() {
if (elem.querySelector('ul')) return;
var listHtml = options.listTemplate({items: options.items});
var listHtml = options.listTemplate({
items: options.items
});
elem.insertAdjacentHTML("beforeEnd", listHtml);
}
function select(link) {
var widgetEvent = new CustomEvent("select", {
var widgetEvent = new CustomEvent("select", {
bubbles: true,
detail: link.getAttribute('href').slice(1)
});
@ -63,4 +67,4 @@ function Menu(options) {
this.toggle = toggle;
this.close = close;
this.open = open;
}
}