Modernizing, initial pass.

This commit is contained in:
Elf M. Sternberg 2016-06-15 16:20:04 -07:00
parent 9ceabc0a75
commit a5ceb5e25e
10 changed files with 97 additions and 4555 deletions

1
.babelrc Normal file
View File

@ -0,0 +1 @@
{ "presets": ["es2015"] }

3
.gitignore vendored
View File

@ -3,3 +3,6 @@
*# *#
.#* .#*
*~ *~
\#*
node_modules/*
es5/*

21
Makefile Normal file
View File

@ -0,0 +1,21 @@
# -*-makefile-gmake-*-
.PHONY: test list style ntest
all: es5 es5/sitedarts.js
es5:
mkdir -p es5
es5/sitedarts.js: es5 node_modules/babel-cli
./node_modules/babel-cli/bin/babel.js -o es5/sitedarts.js es6/sitedarts.js
node_modules/http-server node_modules/babel-cli:
npm install
serve: node_modules/http-server es5/sitedarts.js
./node_modules/http-server/bin/http-server .
clean:
rm -fr es5
rm -fr node_modules

View File

@ -13,15 +13,13 @@ develop code for e-book readers.
## Installation ## Installation
Sitedarts uses jquery (1.3.2 or better required) and jquery.easing. Sitedarts uses jquery (1.3.2 or better required) and jquery.easing.
Both are provided in this download. It's just Javascript, otherwise.
Use as directed.
## Copyright ## Copyright
Sitedarts is copyright (c) 2011 Elf M. Sternberg. Included libraries Sitedarts is copyright (c) 2011, 2016 Elf M. Sternberg. Included
are covered by their respective copyright holders, and are used with libraries are covered by their respective copyright holders, and are
permission of the licenses included. See the MIT-LICENSE file for used with permission of the licenses included. See the MIT-LICENSE file
the license on sitedarts.js itself. for the license on sitedarts.js itself.
## To Do ## To Do
@ -34,17 +32,17 @@ Provide themes for dart types (metal, glass, plain, colorful, drab).
Fix the arbitrariness of the layout: ensure that the bottom of the Fix the arbitrariness of the layout: ensure that the bottom of the
bottom dart, and the top of the top dart, are within the viewport. bottom dart, and the top of the top dart, are within the viewport.
Allow the darts to be on the left, or even across the top and bottom Allow the darts to be on the left, or even across the top and bottom of
of the viewport. the viewport.
Guarantee easing to the target even when the target mark is well Guarantee easing to the target even when the target mark is well
within the viewport at the bottom of the document. within the viewport at the bottom of the document.
Set a highlight class on the dart corresponding to the anchor the user Set a highlight class on the dart corresponding to the anchor the user
is "within." This is a nebulous concept. If two or more anchors are is "within." This is a nebulous concept. If two or more anchors are
visible on the screen, keep the lower one highlighted if it was the visible on the screen, keep the lower one highlighted if it was the last
last one chosen. (cf. Eugene Jarvis' "The way a program looks smart one chosen. (cf. Eugene Jarvis' "The way a program looks smart is it
is it doesn't do anything stupid.") doesn't do anything stupid.")
Allow sitedarts to work within an arbitrary container pair, rather Allow sitedarts to work within an arbitrary container pair, rather
than $(window) and $(document). than $(window) and $(document).

View File

@ -1,8 +1,9 @@
/*global jQuery */
/*! /*!
* jQuery siteDarts * jQuery siteDarts
* Examples and documentation at: http://elfsternberg.com/projects/sitedarts/ * Examples and documentation at: http://elfsternberg.com/projects/sitedarts/
* Copyright (c) 2011 E. M. Sternberg * Copyright (c) 2011 E. M. Sternberg
* Version: 0.8 * Version: 0.9
* Dual licensed under the MIT and GPL licenses: * Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php * http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html * http://www.gnu.org/licenses/gpl.html
@ -11,50 +12,51 @@
;(function($) { ;(function($) {
$.fn.siteDarts = (options) => {
$.fn.siteDarts = function(options) { return this.each(() => {
return this.each(function() { options = $.extend(true, {}, $.fn.siteDarts.defaults, options);
var names = $('a[name]');
options = $.extend(true, {}, $.fn.siteDarts.defaults, options)
names = $('a[name]');
function reposition() { var reposition = () => {
var prop = $(window).height(); var prop = $(window).height();
var doch = $(document).height(); var doch = $(document).height();
names.each(function(dex) { names.each((dex) => {
var n = $(this).attr('name') var n = $(this).attr('name');
var d = $(this).offset().top; var d = $(this).offset().top;
var a = $("li." + options.markitem + ' a[href="#' + n + '"]'); $("li." + options.markitem + ' a[href="#' + n + '"]')
var p = a.parent(); .parent()
p.animate({top: prop * (d / doch) - dex * 7}); .animate({top: prop * (d / doch) - dex * 7});
}); });
} };
function buildDarts() { var buildDarts = () => {
var self = this;
if ($('#' + options.marklist)) { if ($('#' + options.marklist)) {
$('#' + options.marklist).remove() $('#' + options.marklist).remove();
} }
var l = $('<ul id="' + options.marklist + '"></ul>').appendTo('body'); var l = $('<ul id="' + options.marklist + '"></ul>').appendTo('body');
names.each(function() { names.each(() => {
var o = $('<li class="' + options.markitem + '"><a href="#' + var o = $('<li class="' + options.markitem + '"><a href="#' +
$(this).attr('name') + '">' + $(this).text() + '</a></li>').appendTo(l); $(this).attr('name') + '">' + $(this).text() + '</a></li>').appendTo(l);
$('a', o).click(function(event) { $('a', o).click(function(event) {
event.preventDefault(); event.preventDefault();
var target = $(event.target).attr('href').replace('#', '') var target = $(event.target).attr('href').replace('#', '');
var targetOffset = $('a[name="' + target + '"]').offset().top; var targetOffset = $('a[name="' + target + '"]').offset().top;
$('html body').animate({scrollTop: targetOffset}, $('html body').animate(
{duration: 800, {
easing: options.easing, scrollTop: targetOffset
complete: function() { },
location.hash = target; {
} duration: 800,
}); easing: options.easing,
complete: function() {
window.location.hash = target;
}
});
}); });
}); });
} };
buildDarts(); buildDarts();
reposition(); reposition();
}); });

4376
js/jquery-1.3.2.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,140 +0,0 @@
/*
* jQuery EasIng v1.1.2 - http://gsgd.co.uk/sandbox/jquery.easIng.php
*
* Uses the built In easIng capabilities added In jQuery 1.1
* to offer multiple easIng options
*
* Copyright (c) 2007 George Smith
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*/
// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.extend( jQuery.easing,
{
easeInQuad: function (x, t, b, c, d) {
return c*(t/=d)*t + b;
},
easeOutQuad: function (x, t, b, c, d) {
return -c *(t/=d)*(t-2) + b;
},
easeInOutQuad: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t + b;
return -c/2 * ((--t)*(t-2) - 1) + b;
},
easeInCubic: function (x, t, b, c, d) {
return c*(t/=d)*t*t + b;
},
easeOutCubic: function (x, t, b, c, d) {
return c*((t=t/d-1)*t*t + 1) + b;
},
easeInOutCubic: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t*t + b;
return c/2*((t-=2)*t*t + 2) + b;
},
easeInQuart: function (x, t, b, c, d) {
return c*(t/=d)*t*t*t + b;
},
easeOutQuart: function (x, t, b, c, d) {
return -c * ((t=t/d-1)*t*t*t - 1) + b;
},
easeInOutQuart: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
return -c/2 * ((t-=2)*t*t*t - 2) + b;
},
easeInQuint: function (x, t, b, c, d) {
return c*(t/=d)*t*t*t*t + b;
},
easeOutQuint: function (x, t, b, c, d) {
return c*((t=t/d-1)*t*t*t*t + 1) + b;
},
easeInOutQuint: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
return c/2*((t-=2)*t*t*t*t + 2) + b;
},
easeInSine: function (x, t, b, c, d) {
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
},
easeOutSine: function (x, t, b, c, d) {
return c * Math.sin(t/d * (Math.PI/2)) + b;
},
easeInOutSine: function (x, t, b, c, d) {
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
},
easeInExpo: function (x, t, b, c, d) {
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
},
easeOutExpo: function (x, t, b, c, d) {
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
},
easeInOutExpo: function (x, t, b, c, d) {
if (t==0) return b;
if (t==d) return b+c;
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
},
easeInCirc: function (x, t, b, c, d) {
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
},
easeOutCirc: function (x, t, b, c, d) {
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
},
easeInOutCirc: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
},
easeInElastic: function (x, t, b, c, d) {
var s=1.70158;var p=0;var a=c;
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
},
easeOutElastic: function (x, t, b, c, d) {
var s=1.70158;var p=0;var a=c;
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
},
easeInOutElastic: function (x, t, b, c, d) {
var s=1.70158;var p=0;var a=c;
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
},
easeInBack: function (x, t, b, c, d, s) {
if (s == undefined) s = 1.70158;
return c*(t/=d)*t*((s+1)*t - s) + b;
},
easeOutBack: function (x, t, b, c, d, s) {
if (s == undefined) s = 1.70158;
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
},
easeInOutBack: function (x, t, b, c, d, s) {
if (s == undefined) s = 1.70158;
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
},
easeInBounce: function (x, t, b, c, d) {
return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
},
easeOutBounce: function (x, t, b, c, d) {
if ((t/=d) < (1/2.75)) {
return c*(7.5625*t*t) + b;
} else if (t < (2/2.75)) {
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
} else if (t < (2.5/2.75)) {
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
} else {
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
}
},
easeInOutBounce: function (x, t, b, c, d) {
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
}
});

33
package.json Normal file
View File

@ -0,0 +1,33 @@
{
"name": "Sitedarts",
"version": "0.9.0",
"description": "A jQUery module to assist with navigating large documents",
"main": "sitedarts.js",
"directories": {
"example": "examples"
},
"devDependencies": {
"babel-cli": "~6.10.1",
"babel-preset-es2015": "~6.9.0",
"bower": "~1.7.9",
"http-server": "~0.9.0"
},
"dependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git://github.com/elfsternberg/sitedarts.git"
},
"keywords": [
"jquery",
"plugin",
"navigation"
],
"author": "Elf M. Sternberg <elf.sternberg@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/elfsternberg/sitedarts/issues"
}
}