mirror of
https://github.com/github/choosealicense.com
synced 2024-12-22 12:50:24 +01:00
javascript tweaks
This commit is contained in:
parent
59bd13024d
commit
58c7a4ee1d
@ -11,5 +11,16 @@
|
|||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
</div><!-- /container -->
|
</div><!-- /container -->
|
||||||
|
|
||||||
|
<script type="text/javascript" src="/javascripts/jquery-1.7.1.min.js"></script>
|
||||||
|
<script type="text/javascript" src="/javascripts/jquery.qtip.min.js"></script>
|
||||||
|
|
||||||
|
{% if page.layout == "license" %}
|
||||||
|
<script type="text/javascript" src="/javascripts/ZeroClipboard.js"></script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<script type="text/javascript" src="/javascripts/annotations.js"></script>
|
||||||
|
<script type="text/javascript" src="/javascripts/app.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -1,23 +1,18 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang='en'>
|
<html lang='en'>
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<title>{% if page.title %}{{ page.title }} - {% endif %}{{ site.title}}</title>
|
<title>{% if page.title %}{{ page.title }} - {% endif %}{{ site.title}}</title>
|
||||||
|
|
||||||
<meta charset='utf-8'>
|
<meta charset='utf-8'>
|
||||||
<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'>
|
<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'>
|
||||||
|
|
||||||
<link href='/favicon.ico' rel='shortcut icon' type='image/x-icon'>
|
<link href='/favicon.ico' rel='shortcut icon' type='image/x-icon'>
|
||||||
<link href='http://fonts.googleapis.com/css?family=Chivo:900' rel='stylesheet' type='text/css'>
|
<link href='http://fonts.googleapis.com/css?family=Chivo:900' rel='stylesheet' type='text/css'>
|
||||||
<link type="text/css" href="/css/application.css" media="screen" rel="stylesheet">
|
<link type="text/css" href="/css/application.css" media="screen" rel="stylesheet">
|
||||||
<link type="text/css" href="/css/jquery.qtip.css" media="screen" rel="stylesheet">
|
<link type="text/css" href="/css/jquery.qtip.css" media="screen" rel="stylesheet">
|
||||||
<script type="text/javascript" src="/javascripts/jquery-1.7.1.min.js"></script>
|
|
||||||
<script type="text/javascript" src="/javascripts/annotations.js"></script>
|
|
||||||
<script type="text/javascript" src="/javascripts/app.js"></script>
|
|
||||||
<script type="text/javascript" src="/javascripts/jquery.qtip.min.js"></script>
|
|
||||||
<script type="text/javascript" src="/javascripts/modernizr.js"></script>
|
|
||||||
|
|
||||||
{% if page.layout == "license" %}
|
<script type="text/javascript" src="/javascripts/modernizr.js"></script>
|
||||||
<script type="text/javascript" src="/javascripts/clipboard.js"></script>
|
|
||||||
<script type="text/javascript" src="/javascripts/ZeroClipboard.js"></script>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<!--[if (gte IE 6)&(lte IE 8)]>
|
<!--[if (gte IE 6)&(lte IE 8)]>
|
||||||
<script src='/javascripts/selectivizr-min.js' type='text/javascript'></script>
|
<script src='/javascripts/selectivizr-min.js' type='text/javascript'></script>
|
||||||
|
File diff suppressed because one or more lines are too long
62
javascripts/app.coffee
Normal file
62
javascripts/app.coffee
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
class Choosealicense
|
||||||
|
|
||||||
|
# Qtip position attributes for tooltips
|
||||||
|
qtip_position:
|
||||||
|
my: "top center"
|
||||||
|
at: "bottom center"
|
||||||
|
|
||||||
|
# Annotation categories as defined in `_config.yml`
|
||||||
|
categories:
|
||||||
|
required: "Required"
|
||||||
|
permitted: "Permitted"
|
||||||
|
forbidden: "Forbidden"
|
||||||
|
|
||||||
|
# fire on document.ready
|
||||||
|
constructor: ->
|
||||||
|
@initTooltips()
|
||||||
|
@initClipboard() if ZeroClipboard?
|
||||||
|
|
||||||
|
# Init tooltip action
|
||||||
|
initTooltips: ->
|
||||||
|
|
||||||
|
# Dynamically add annotations as title attribute to rule list items
|
||||||
|
for category, rules of annotations
|
||||||
|
for label, text of rules
|
||||||
|
$(".license-rules ul.license-#{category} li.#{label}").attr "title", text
|
||||||
|
|
||||||
|
# Init tooltips on all rule list items
|
||||||
|
for category, label of @categories
|
||||||
|
$(".license-#{category} li").qtip
|
||||||
|
content:
|
||||||
|
text: false
|
||||||
|
title:
|
||||||
|
text: label
|
||||||
|
position: @qtip_position
|
||||||
|
style:
|
||||||
|
classes: "qtip-shadow qtip-#{category}"
|
||||||
|
|
||||||
|
false
|
||||||
|
|
||||||
|
# if Zero Clipboard is present, bind to button and init
|
||||||
|
initClipboard: ->
|
||||||
|
|
||||||
|
# Backup the clipboard button's original text.
|
||||||
|
$(".js-clipboard-button").data "clipboard-prompt", $(".js-clipboard-button").text()
|
||||||
|
|
||||||
|
# Hook up copy to clipboard buttons
|
||||||
|
clip = new ZeroClipboard $(".js-clipboard-button"),
|
||||||
|
moviePath: "/javascripts/ZeroClipboard.swf"
|
||||||
|
clip.on "mouseout", @clipboardMouseout
|
||||||
|
clip.on "complete", @clipboardComplete
|
||||||
|
clip
|
||||||
|
|
||||||
|
# Callback to restore the clipboard button's original text
|
||||||
|
clipboardMouseout: (client, args) ->
|
||||||
|
@innerText = $(this).data("clipboard-prompt")
|
||||||
|
|
||||||
|
# Post-copy user feedback callback
|
||||||
|
clipboardComplete: (client, args) ->
|
||||||
|
@innerText = "Copied!"
|
||||||
|
|
||||||
|
$ ->
|
||||||
|
new Choosealicense()
|
@ -1,52 +1,81 @@
|
|||||||
var qtip_position = {
|
// Generated by CoffeeScript 1.6.2
|
||||||
my: 'top center',
|
(function() {
|
||||||
at: 'bottom center'
|
var Choosealicense;
|
||||||
};
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
Choosealicense = (function() {
|
||||||
for (var category in annotations) {
|
Choosealicense.prototype.qtip_position = {
|
||||||
var categoryAnnotations = annotations[category];
|
my: "top center",
|
||||||
for (var annotation in categoryAnnotations) {
|
at: "bottom center"
|
||||||
$('.license-rules ul.license-' + category + ' li.' + annotation).attr('title', categoryAnnotations[annotation]);
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$('.license-required li').qtip({
|
Choosealicense.prototype.categories = {
|
||||||
content: {
|
required: "Required",
|
||||||
text: false,
|
permitted: "Permitted",
|
||||||
title: {
|
forbidden: "Forbidden"
|
||||||
text: 'Required'
|
};
|
||||||
|
|
||||||
|
function Choosealicense() {
|
||||||
|
this.initTooltips();
|
||||||
|
if (typeof ZeroClipboard !== "undefined" && ZeroClipboard !== null) {
|
||||||
|
this.initClipboard();
|
||||||
}
|
}
|
||||||
},
|
|
||||||
position: qtip_position,
|
|
||||||
style: {
|
|
||||||
classes: 'qtip-shadow qtip-required'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Choosealicense.prototype.initTooltips = function() {
|
||||||
|
var category, label, rules, text, _ref;
|
||||||
|
|
||||||
|
for (category in annotations) {
|
||||||
|
rules = annotations[category];
|
||||||
|
for (label in rules) {
|
||||||
|
text = rules[label];
|
||||||
|
$(".license-rules ul.license-" + category + " li." + label).attr("title", text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ref = this.categories;
|
||||||
|
for (category in _ref) {
|
||||||
|
label = _ref[category];
|
||||||
|
$(".license-" + category + " li").qtip({
|
||||||
|
content: {
|
||||||
|
text: false,
|
||||||
|
title: {
|
||||||
|
text: label
|
||||||
|
}
|
||||||
|
},
|
||||||
|
position: this.qtip_position,
|
||||||
|
style: {
|
||||||
|
classes: "qtip-shadow qtip-" + category
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
Choosealicense.prototype.initClipboard = function() {
|
||||||
|
var clip;
|
||||||
|
|
||||||
|
$(".js-clipboard-button").data("clipboard-prompt", $(".js-clipboard-button").text());
|
||||||
|
clip = new ZeroClipboard($(".js-clipboard-button"), {
|
||||||
|
moviePath: "/javascripts/ZeroClipboard.swf"
|
||||||
|
});
|
||||||
|
clip.on("mouseout", this.clipboardMouseout);
|
||||||
|
clip.on("complete", this.clipboardComplete);
|
||||||
|
return clip;
|
||||||
|
};
|
||||||
|
|
||||||
|
Choosealicense.prototype.clipboardMouseout = function(client, args) {
|
||||||
|
return this.innerText = $(this).data("clipboard-prompt");
|
||||||
|
};
|
||||||
|
|
||||||
|
Choosealicense.prototype.clipboardComplete = function(client, args) {
|
||||||
|
return this.innerText = "Copied!";
|
||||||
|
};
|
||||||
|
|
||||||
|
return Choosealicense;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
return new Choosealicense();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.license-permitted li').qtip({
|
}).call(this);
|
||||||
content: {
|
|
||||||
text: false,
|
|
||||||
title: {
|
|
||||||
text: 'Permitted'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
position: qtip_position,
|
|
||||||
style: {
|
|
||||||
classes: 'qtip-shadow qtip-permitted'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.license-forbidden li').qtip({
|
|
||||||
content: {
|
|
||||||
text: false,
|
|
||||||
title: {
|
|
||||||
text: 'Forbidden'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
position: qtip_position,
|
|
||||||
style: {
|
|
||||||
classes: 'qtip-shadow qtip-forbidden'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
$(document).ready(function() {
|
|
||||||
|
|
||||||
// Backup the clipboard button's original text.
|
|
||||||
$(".js-clipboard-button").data('clipboard-prompt', $('.js-clipboard-button').text());
|
|
||||||
|
|
||||||
// Hook up copy to clipboard buttons
|
|
||||||
var clip = new ZeroClipboard($(".js-clipboard-button"), {
|
|
||||||
moviePath: "../../javascripts/ZeroClipboard.swf"
|
|
||||||
});
|
|
||||||
|
|
||||||
clip.on('mouseover', function(client, args) {
|
|
||||||
// Restore the clipboard button's original text.
|
|
||||||
this.innerText = $(this).data('clipboard-prompt');
|
|
||||||
});
|
|
||||||
|
|
||||||
clip.on('complete', function(client, args) {
|
|
||||||
this.innerText = 'Copied!';
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
Loading…
x
Reference in New Issue
Block a user