Browse Source

Merge pull request #521 from twbs/js-2

JS tweaks
pull/743/head
XhmikosR 10 years ago
parent
commit
004d2d45b5
  1. 46
      dist/js/ratchet.js
  2. 4
      docs/assets/js/docs.js
  3. 2
      docs/assets/js/fingerblast.js
  4. 46
      docs/dist/js/ratchet.js
  5. 3
      js/popovers.js
  6. 28
      js/push.js
  7. 7
      js/segmented-controllers.js
  8. 4
      js/sliders.js
  9. 4
      js/toggles.js

46
dist/js/ratchet.js vendored

@ -103,8 +103,7 @@
try {
popover = document.querySelector(anchor.hash);
}
catch (error) {
} catch (error) {
popover = null;
}
@ -370,7 +369,11 @@
clearTimeout(options._timeout);
}
if (xhr.readyState === 4) {
xhr.status === 200 ? success(xhr, options) : failure(options.url);
if (xhr.status === 200) {
success(xhr, options);
} else {
failure(options.url);
}
}
};
@ -397,7 +400,7 @@
}
};
function cacheCurrentContent() {
function cacheCurrentContent () {
domCache[PUSH.id] = document.body.cloneNode(true);
}
@ -472,7 +475,7 @@
document.body.insertBefore(swap, document.querySelector('.content'));
}
} else {
enter = /in$/.test(transition);
enter = /in$/.test(transition);
if (transition === 'fade') {
container.classList.add('in');
@ -490,7 +493,9 @@
}
if (!transition) {
complete && complete();
if (complete) {
complete();
}
}
if (transition === 'fade') {
@ -506,7 +511,9 @@
container.parentNode.removeChild(container);
swap.classList.remove('fade');
swap.classList.remove('in');
complete && complete();
if (complete) {
complete();
}
};
container.addEventListener('webkitTransitionEnd', fadeContainerEnd);
@ -518,7 +525,9 @@
swap.classList.remove('sliding', 'sliding-in');
swap.classList.remove(swapDirection);
container.parentNode.removeChild(container);
complete && complete();
if (complete) {
complete();
}
};
container.offsetWidth; // force reflow
@ -623,7 +632,11 @@
window.addEventListener('touchstart', function () { isScrolling = false; });
window.addEventListener('touchmove', function () { isScrolling = true; });
window.addEventListener('touchend', touchend);
window.addEventListener('click', function (e) { if (getTarget(e)) {e.preventDefault();} });
window.addEventListener('click', function (e) {
if (getTarget(e)) {
e.preventDefault();
}
});
window.addEventListener('popstate', popstate);
window.PUSH = PUSH;
@ -692,7 +705,12 @@
targetBody.classList.add(className);
});
window.addEventListener('click', function (e) { if (getTarget(e.target)) {e.preventDefault();} });
window.addEventListener('click', function (e) {
if (getTarget(e.target)) {
e.preventDefault();
}
});
}());
/* ========================================================================
@ -820,9 +838,7 @@
// we're done moving
startedMoving = false;
setSlideNumber(
(+new Date()) - startTime < 1000 && Math.abs(deltaX) > 15 ? (deltaX < 0 ? -1 : 1) : 0
);
setSlideNumber((+new Date()) - startTime < 1000 && Math.abs(deltaX) > 15 ? (deltaX < 0 ? -1 : 1) : 0);
offsetX = slideNumber * sliderWidth;
@ -950,7 +966,9 @@
toggle.classList[slideOn ? 'add' : 'remove']('active');
e = new CustomEvent('toggle', {
detail: { isActive: slideOn },
detail: {
isActive: slideOn
},
bubbles: true,
cancelable: true
});

4
docs/assets/js/docs.js

@ -185,6 +185,8 @@ $(function () {
$(window).on('load resize', initialize);
$(window).on('load', function () {
window.FingerBlast && (new FingerBlast('.device-content'));
if (window.FingerBlast) {
new FingerBlast('.device-content');
}
});
});

2
docs/assets/js/fingerblast.js

@ -9,7 +9,7 @@
'use strict';
function FingerBlast(element) {
function FingerBlast (element) {
this.element = typeof element === 'string' ? document.querySelector(element) : element;
if (this.element) {

46
docs/dist/js/ratchet.js vendored

@ -103,8 +103,7 @@
try {
popover = document.querySelector(anchor.hash);
}
catch (error) {
} catch (error) {
popover = null;
}
@ -370,7 +369,11 @@
clearTimeout(options._timeout);
}
if (xhr.readyState === 4) {
xhr.status === 200 ? success(xhr, options) : failure(options.url);
if (xhr.status === 200) {
success(xhr, options);
} else {
failure(options.url);
}
}
};
@ -397,7 +400,7 @@
}
};
function cacheCurrentContent() {
function cacheCurrentContent () {
domCache[PUSH.id] = document.body.cloneNode(true);
}
@ -472,7 +475,7 @@
document.body.insertBefore(swap, document.querySelector('.content'));
}
} else {
enter = /in$/.test(transition);
enter = /in$/.test(transition);
if (transition === 'fade') {
container.classList.add('in');
@ -490,7 +493,9 @@
}
if (!transition) {
complete && complete();
if (complete) {
complete();
}
}
if (transition === 'fade') {
@ -506,7 +511,9 @@
container.parentNode.removeChild(container);
swap.classList.remove('fade');
swap.classList.remove('in');
complete && complete();
if (complete) {
complete();
}
};
container.addEventListener('webkitTransitionEnd', fadeContainerEnd);
@ -518,7 +525,9 @@
swap.classList.remove('sliding', 'sliding-in');
swap.classList.remove(swapDirection);
container.parentNode.removeChild(container);
complete && complete();
if (complete) {
complete();
}
};
container.offsetWidth; // force reflow
@ -623,7 +632,11 @@
window.addEventListener('touchstart', function () { isScrolling = false; });
window.addEventListener('touchmove', function () { isScrolling = true; });
window.addEventListener('touchend', touchend);
window.addEventListener('click', function (e) { if (getTarget(e)) {e.preventDefault();} });
window.addEventListener('click', function (e) {
if (getTarget(e)) {
e.preventDefault();
}
});
window.addEventListener('popstate', popstate);
window.PUSH = PUSH;
@ -692,7 +705,12 @@
targetBody.classList.add(className);
});
window.addEventListener('click', function (e) { if (getTarget(e.target)) {e.preventDefault();} });
window.addEventListener('click', function (e) {
if (getTarget(e.target)) {
e.preventDefault();
}
});
}());
/* ========================================================================
@ -820,9 +838,7 @@
// we're done moving
startedMoving = false;
setSlideNumber(
(+new Date()) - startTime < 1000 && Math.abs(deltaX) > 15 ? (deltaX < 0 ? -1 : 1) : 0
);
setSlideNumber((+new Date()) - startTime < 1000 && Math.abs(deltaX) > 15 ? (deltaX < 0 ? -1 : 1) : 0);
offsetX = slideNumber * sliderWidth;
@ -950,7 +966,9 @@
toggle.classList[slideOn ? 'add' : 'remove']('active');
e = new CustomEvent('toggle', {
detail: { isActive: slideOn },
detail: {
isActive: slideOn
},
bubbles: true,
cancelable: true
});

3
js/popovers.js

@ -52,8 +52,7 @@
try {
popover = document.querySelector(anchor.hash);
}
catch (error) {
} catch (error) {
popover = null;
}

28
js/push.js

@ -231,7 +231,11 @@
clearTimeout(options._timeout);
}
if (xhr.readyState === 4) {
xhr.status === 200 ? success(xhr, options) : failure(options.url);
if (xhr.status === 200) {
success(xhr, options);
} else {
failure(options.url);
}
}
};
@ -258,7 +262,7 @@
}
};
function cacheCurrentContent() {
function cacheCurrentContent () {
domCache[PUSH.id] = document.body.cloneNode(true);
}
@ -333,7 +337,7 @@
document.body.insertBefore(swap, document.querySelector('.content'));
}
} else {
enter = /in$/.test(transition);
enter = /in$/.test(transition);
if (transition === 'fade') {
container.classList.add('in');
@ -351,7 +355,9 @@
}
if (!transition) {
complete && complete();
if (complete) {
complete();
}
}
if (transition === 'fade') {
@ -367,7 +373,9 @@
container.parentNode.removeChild(container);
swap.classList.remove('fade');
swap.classList.remove('in');
complete && complete();
if (complete) {
complete();
}
};
container.addEventListener('webkitTransitionEnd', fadeContainerEnd);
@ -379,7 +387,9 @@
swap.classList.remove('sliding', 'sliding-in');
swap.classList.remove(swapDirection);
container.parentNode.removeChild(container);
complete && complete();
if (complete) {
complete();
}
};
container.offsetWidth; // force reflow
@ -484,7 +494,11 @@
window.addEventListener('touchstart', function () { isScrolling = false; });
window.addEventListener('touchmove', function () { isScrolling = true; });
window.addEventListener('touchend', touchend);
window.addEventListener('click', function (e) { if (getTarget(e)) {e.preventDefault();} });
window.addEventListener('click', function (e) {
if (getTarget(e)) {
e.preventDefault();
}
});
window.addEventListener('popstate', popstate);
window.PUSH = PUSH;

7
js/segmented-controllers.js

@ -61,5 +61,10 @@
targetBody.classList.add(className);
});
window.addEventListener('click', function (e) { if (getTarget(e.target)) {e.preventDefault();} });
window.addEventListener('click', function (e) {
if (getTarget(e.target)) {
e.preventDefault();
}
});
}());

4
js/sliders.js

@ -123,9 +123,7 @@
// we're done moving
startedMoving = false;
setSlideNumber(
(+new Date()) - startTime < 1000 && Math.abs(deltaX) > 15 ? (deltaX < 0 ? -1 : 1) : 0
);
setSlideNumber((+new Date()) - startTime < 1000 && Math.abs(deltaX) > 15 ? (deltaX < 0 ? -1 : 1) : 0);
offsetX = slideNumber * sliderWidth;

4
js/toggles.js

@ -104,7 +104,9 @@
toggle.classList[slideOn ? 'add' : 'remove']('active');
e = new CustomEvent('toggle', {
detail: { isActive: slideOn },
detail: {
isActive: slideOn
},
bubbles: true,
cancelable: true
});

Loading…
Cancel
Save