Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ project/boot/
target/
src/test/
src_managed/
.idea/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These generally should be i your global git ignore.

.idea_modules/
42 changes: 4 additions & 38 deletions project/XRay.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@ object XRay extends Build
name := "sxr",
organization in ThisBuild := "org.scala-sbt.sxr",
version in ThisBuild := "0.3.1-SNAPSHOT",
scalaVersion in ThisBuild := "2.10.2",
scalaVersion in ThisBuild := "2.10.3",
scalacOptions += "-deprecation",
ivyConfigurations += js,
exportJars := true,
libraryDependencies ++= dependencies,
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
jqueryAll := target.value / "jquery-all.js",
combineJs := combineJquery(update.value, jqueryAll.value, streams.value.log),
resourceGenerators in Compile <+= combineJs
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided"
)

lazy val test = project.dependsOn(main % CompilerPlugin).settings(testProjectSettings: _*)
Expand All @@ -42,35 +37,6 @@ object XRay extends Build
}
)

val js = config("js").hide

val combineJs = TaskKey[Seq[File]]("combine-js")
val jqueryAll = SettingKey[File]("jquery-all")

val jquery_version = "1.3.2"
val jquery_scrollto_version = "1.4.2"
val jquery_qtip_version = "1.0.0-rc3"

def dependencies = Seq(
"jquery" % "jquery" % jquery_version % "js->default" from ("http://jqueryjs.googlecode.com/files/jquery-" + jquery_version + ".min.js"),
"jquery" % "jquery-scrollto" % jquery_scrollto_version % "js->default" from ("http://flesler-plugins.googlecode.com/files/jquery.scrollTo-" + jquery_scrollto_version + "-min.js"),
"jquery" % "jquery-qtip" % jquery_qtip_version % "js->default" from ("http://craigsworks.com/projects/qtip/packages/1.0.0-rc3/jquery.qtip-" + jquery_qtip_version + ".min.js")
)

def combineJquery(report: UpdateReport, jsOut: File, log: Logger): Seq[File] =
{
IO.delete(jsOut)
inputs(report) foreach { in => appendJs(in, jsOut) }
log.info("Wrote combined js to " + jsOut.getAbsolutePath)
Seq(jsOut)
}
def inputs(report: UpdateReport) = report.select( configurationFilter(js.name)) sortBy { _.name }
def appendJs(js: File, to: File): Unit =
Using.fileInputStream(js) { in =>
Using.fileOutputStream(append = true)(to) { out => IO.transfer(in, out) }
}


def checkOutput(sxrDir: File, expectedDir: File, log: Logger) {
val actual = filesToCompare(sxrDir)
val expected = filesToCompare(expectedDir)
Expand All @@ -81,7 +47,7 @@ object XRay extends Build
val expectedOnly = expectedRelative -- actualRelative
def print(n: Iterable[String]): String = n.mkString("\n\t", "\n\t", "\n")
log.error(s"Actual filenames not expected: ${print(actualOnly)}Expected filenames not present: ${print(expectedOnly)}")
error("Actual filenames differed from expected filenames.")
sys.error("Actual filenames differed from expected filenames.")
}
val different = actualRelative filterNot { relativePath =>
val actualFile = actual.reverse(relativePath).head
Expand All @@ -91,7 +57,7 @@ object XRay extends Build
same
}
if(different.nonEmpty)
error("Actual content differed from expected content")
sys.error("Actual content differed from expected content")
}
def filesToCompare(dir: File): Relation[File,String] = {
val mappings = dir ** ("*.html" | "*.index") x relativeTo(dir)
Expand Down
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2")
6 changes: 6 additions & 0 deletions src/main/resources/jquery-1.10.2.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/main/resources/jquery-qtip2-2.2.0.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/main/resources/jquery-qtip2-css-2.2.0.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

186 changes: 186 additions & 0 deletions src/main/resources/jquery-scrollto-1.4.9.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
/*!
* jQuery.ScrollTo
* Copyright (c) 2007-2014 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
* Licensed under MIT
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
* @projectDescription Easy element scrolling using jQuery.
* @author Ariel Flesler
* @version 1.4.9
*/

;(function (factory) {
// AMD Support
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else {
factory(jQuery);
}
}(function ($) {

var $scrollTo = $.scrollTo = function( target, duration, settings ) {
return $(window).scrollTo( target, duration, settings );
};

$scrollTo.defaults = {
axis:'xy',
duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1,
limit:true
};

// Returns the element that needs to be animated to scroll the window.
// Kept for backwards compatibility (specially for localScroll & serialScroll)
$scrollTo.window = function( scope ) {
return $(window)._scrollable();
};

// Hack, hack, hack :)
// Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
$.fn._scrollable = function() {
return this.map(function() {
var elem = this,
isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1;

if (!isWin)
return elem;

var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;

return /webkit/i.test(navigator.userAgent) || doc.compatMode == 'BackCompat' ?
doc.body :
doc.documentElement;
});
};

$.fn.scrollTo = function( target, duration, settings ) {
if (typeof duration == 'object') {
settings = duration;
duration = 0;
}
if (typeof settings == 'function')
settings = { onAfter:settings };

if (target == 'max')
target = 9e9;

settings = $.extend( {}, $scrollTo.defaults, settings );
// Speed is still recognized for backwards compatibility
duration = duration || settings.duration;
// Make sure the settings are given right
settings.queue = settings.queue && settings.axis.length > 1;

if (settings.queue)
// Let's keep the overall duration
duration /= 2;
settings.offset = both( settings.offset );
settings.over = both( settings.over );

return this._scrollable().each(function() {
// Null target yields nothing, just like jQuery does
if (target == null) return;

var elem = this,
$elem = $(elem),
targ = target, toff, attr = {},
win = $elem.is('html,body');

switch (typeof targ) {
// A number will pass the regex
case 'number':
case 'string':
if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
targ = both( targ );
// We are done
break;
}
// Relative selector, no break!
targ = $(targ,this);
if (!targ.length) return;
case 'object':
// DOMElement / jQuery
if (targ.is || targ.style)
// Get the real position of the target
toff = (targ = $(targ)).offset();
}

var offset = $.isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset;

$.each( settings.axis.split(''), function( i, axis ) {
var Pos = axis == 'x' ? 'Left' : 'Top',
pos = Pos.toLowerCase(),
key = 'scroll' + Pos,
old = elem[key],
max = $scrollTo.max(elem, axis);

if (toff) {// jQuery / DOMElement
attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );

// If it's a dom element, reduce the margin
if (settings.margin) {
attr[key] -= parseInt(targ.css('margin'+Pos)) || 0;
attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0;
}

attr[key] += offset[pos] || 0;

if(settings.over[pos])
// Scroll to a fraction of its width/height
attr[key] += targ[axis=='x'?'width':'height']() * settings.over[pos];
} else {
var val = targ[pos];
// Handle percentage values
attr[key] = val.slice && val.slice(-1) == '%' ?
parseFloat(val) / 100 * max
: val;
}

// Number or 'number'
if (settings.limit && /^\d+$/.test(attr[key]))
// Check the limits
attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max );

// Queueing axes
if (!i && settings.queue) {
// Don't waste time animating, if there's no need.
if (old != attr[key])
// Intermediate animation
animate( settings.onAfterFirst );
// Don't animate this axis again in the next iteration.
delete attr[key];
}
});

animate( settings.onAfter );

function animate( callback ) {
$elem.animate( attr, duration, settings.easing, callback && function() {
callback.call(this, targ, settings);
});
};

}).end();
};

// Max scrolling position, works on quirks mode
// It only fails (not too badly) on IE, quirks mode.
$scrollTo.max = function( elem, axis ) {
var Dim = axis == 'x' ? 'Width' : 'Height',
scroll = 'scroll'+Dim;

if (!$(elem).is('html,body'))
return elem[scroll] - $(elem)[Dim.toLowerCase()]();

var size = 'client' + Dim,
html = elem.ownerDocument.documentElement,
body = elem.ownerDocument.body;

return Math.max( html[scroll], body[scroll] )
- Math.min( html[size] , body[size] );
};

function both( val ) {
return $.isFunction(val) || typeof val == 'object' ? val : { top:val, left:val };
};

// AMD requirement
return $scrollTo;
}));
47 changes: 25 additions & 22 deletions src/main/resources/linked.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,38 @@ function scrollTo(def) {
return false;
}
$(function() {
$("pre [id]").live("mouseover",
$("pre [id]").on("mouseover",
function() { $(this).references().highlight() }
).live("mouseout",
).on("mouseout",
function() { $(this).references().unhighlight() }
).live("click", function() { $(this).attr("href") ? false : scrollTo($(this)) });
).on("click", function() { $(this).attr("href") ? false : scrollTo($(this)) });

$("pre a[href^='#']").live("mouseover",
$("pre a[href^='#']").on("mouseover",
function() { $(this).definition().highlight() }
).live("mouseout",
).on("mouseout",
function() { $(this).definition().unhighlight() }
).live("click",
).on("click",
function() { return scrollTo($(this).definition()); }
);

$('[title]').live("mouseover", function() {
if ($(this).data('qtip') !== 'object') {
$(this).qtip({
style: {
name: 'dark',
tip: true,
border: { width: 7, radius: 5 },
width: { max: 500 }
},
content: { prerender: true },
show: { delay: { length: 0 } },
position: { corner: { tooltip: "bottomLeft", target: "topMiddle" } }
}).qtip("show");
}
});
});


$(document).ready(function () {
$('[title!=""]').qtip({
style: {
classes: 'qtip-dark qtip-rounded',
tip: true,
width: { max: 500 }
},
hide: {
event: false,
inactive: 2000
},
show: {
solo: true,
delay: { length: 0 }
}
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this looks like a good improvement.

});

$(window).load(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,28 @@ div#pop-out { left: 0; width: 100%; }
div#pop-out input {
margin-right: .75em;
vertical-align: middle;
}


#index {
float:left;
width:250px;
}

#content {
border-left-width: 1px;
border-left-color: black;
right: 0px;
left: 0px;
bottom: 0px;
top: 0px;
position: fixed;
margin-left: 300px;
display: block;
}

#content > iframe {
display: block;
height: 100%;
width: 100%;
}
Loading