epuber 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/bin/epuber +10 -0
- data/epuber.gemspec +51 -0
- data/lib/epuber.rb +14 -0
- data/lib/epuber/book.rb +267 -0
- data/lib/epuber/book/contributor.rb +90 -0
- data/lib/epuber/book/file_request.rb +68 -0
- data/lib/epuber/book/target.rb +284 -0
- data/lib/epuber/book/toc_item.rb +130 -0
- data/lib/epuber/checker.rb +19 -0
- data/lib/epuber/checker/text_checker.rb +129 -0
- data/lib/epuber/checker_transformer_base.rb +71 -0
- data/lib/epuber/command.rb +65 -0
- data/lib/epuber/command/compile.rb +142 -0
- data/lib/epuber/command/init.rb +145 -0
- data/lib/epuber/command/server.rb +59 -0
- data/lib/epuber/compiler.rb +255 -0
- data/lib/epuber/compiler/compilation_context.rb +86 -0
- data/lib/epuber/compiler/file_finders/abstract.rb +270 -0
- data/lib/epuber/compiler/file_finders/imaginary.rb +167 -0
- data/lib/epuber/compiler/file_finders/normal.rb +22 -0
- data/lib/epuber/compiler/file_resolver.rb +316 -0
- data/lib/epuber/compiler/file_types/abstract_file.rb +119 -0
- data/lib/epuber/compiler/file_types/bade_file.rb +39 -0
- data/lib/epuber/compiler/file_types/container_xml_file.rb +26 -0
- data/lib/epuber/compiler/file_types/generated_file.rb +29 -0
- data/lib/epuber/compiler/file_types/ibooks_display_options_file.rb +31 -0
- data/lib/epuber/compiler/file_types/image_file.rb +42 -0
- data/lib/epuber/compiler/file_types/mime_type_file.rb +20 -0
- data/lib/epuber/compiler/file_types/nav_file.rb +42 -0
- data/lib/epuber/compiler/file_types/opf_file.rb +27 -0
- data/lib/epuber/compiler/file_types/source_file.rb +52 -0
- data/lib/epuber/compiler/file_types/static_file.rb +18 -0
- data/lib/epuber/compiler/file_types/stylus_file.rb +20 -0
- data/lib/epuber/compiler/file_types/xhtml_file.rb +102 -0
- data/lib/epuber/compiler/generator.rb +67 -0
- data/lib/epuber/compiler/meta_inf_generator.rb +41 -0
- data/lib/epuber/compiler/nav_generator.rb +201 -0
- data/lib/epuber/compiler/opf_generator.rb +284 -0
- data/lib/epuber/compiler/xhtml_processor.rb +254 -0
- data/lib/epuber/config.rb +133 -0
- data/lib/epuber/dsl/attribute.rb +248 -0
- data/lib/epuber/dsl/attribute_support.rb +130 -0
- data/lib/epuber/dsl/object.rb +145 -0
- data/lib/epuber/dsl/tree_object.rb +101 -0
- data/lib/epuber/helper.rb +19 -0
- data/lib/epuber/lockfile.rb +55 -0
- data/lib/epuber/plugin.rb +108 -0
- data/lib/epuber/ruby_extensions/match_data.rb +40 -0
- data/lib/epuber/ruby_extensions/thread.rb +13 -0
- data/lib/epuber/server.rb +614 -0
- data/lib/epuber/server/auto_refresh/auto_refresh.coffee +97 -0
- data/lib/epuber/server/auto_refresh/connector.coffee +125 -0
- data/lib/epuber/server/auto_refresh/protocol.coffee +41 -0
- data/lib/epuber/server/auto_refresh/reloader.coffee +261 -0
- data/lib/epuber/server/base.styl +3 -0
- data/lib/epuber/server/basic.styl +211 -0
- data/lib/epuber/server/book_content.styl +39 -0
- data/lib/epuber/server/default_cover.png +0 -0
- data/lib/epuber/server/fonts/AvenirNext/AvenirNext-Bold.ttf +0 -0
- data/lib/epuber/server/fonts/AvenirNext/AvenirNext-BoldItalic.ttf +0 -0
- data/lib/epuber/server/fonts/AvenirNext/AvenirNext-Italic.ttf +0 -0
- data/lib/epuber/server/fonts/AvenirNext/AvenirNext-Regular.ttf +0 -0
- data/lib/epuber/server/handlers.rb +67 -0
- data/lib/epuber/server/keyboard_control.coffee +6 -0
- data/lib/epuber/server/pages/book.bade +75 -0
- data/lib/epuber/server/pages/common.bade +59 -0
- data/lib/epuber/server/pages/files.bade +17 -0
- data/lib/epuber/server/pages/toc.bade +29 -0
- data/lib/epuber/server/support.coffee +10 -0
- data/lib/epuber/templates/template.bookspec +143 -0
- data/lib/epuber/third_party/bower.rb +22 -0
- data/lib/epuber/third_party/bower/bower.json +10 -0
- data/lib/epuber/third_party/bower/bower_components/cookies-js/bower.json +10 -0
- data/lib/epuber/third_party/bower/bower_components/cookies-js/dist/cookies.d.ts +33 -0
- data/lib/epuber/third_party/bower/bower_components/cookies-js/dist/cookies.js +173 -0
- data/lib/epuber/third_party/bower/bower_components/cookies-js/dist/cookies.min.js +6 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/MIT-LICENSE.txt +21 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/bower.json +28 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/dist/jquery.js +9210 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/dist/jquery.min.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/dist/jquery.min.map +1 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax.js +786 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/jsonp.js +89 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js +75 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/parseJSON.js +13 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/parseXML.js +28 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/script.js +64 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/var/nonce.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/var/rquery.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/ajax/xhr.js +136 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes.js +11 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/attr.js +141 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/classes.js +158 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/prop.js +94 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/support.js +35 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/attributes/val.js +161 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/callbacks.js +205 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core.js +502 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/access.js +60 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/init.js +123 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/parseHTML.js +39 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/ready.js +97 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/core/var/rsingleTag.js +4 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css.js +450 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/addGetHookIf.js +22 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/curCSS.js +57 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/defaultDisplay.js +70 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/hiddenVisibleSelectors.js +15 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/support.js +96 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/swap.js +28 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/cssExpand.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/getStyles.js +12 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/isHidden.js +13 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/rmargin.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/css/var/rnumnonpx.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data.js +178 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data/Data.js +181 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data/accepts.js +20 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data/var/data_priv.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/data/var/data_user.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/deferred.js +149 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/deprecated.js +13 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/dimensions.js +50 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/effects.js +648 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/effects/Tween.js +114 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/effects/animatedSelector.js +13 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event.js +868 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event/ajax.js +13 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event/alias.js +39 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/event/support.js +9 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/exports/amd.js +24 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/exports/global.js +32 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/intro.js +44 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/jquery.js +37 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation.js +580 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/_evalUrl.js +18 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/support.js +32 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/manipulation/var/rcheckableType.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/offset.js +207 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/outro.js +1 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/queue.js +142 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/queue/delay.js +22 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/selector-native.js +172 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/selector-sizzle.js +14 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/selector.js +1 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/serialize.js +111 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/sizzle/dist/sizzle.js +2067 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/sizzle/dist/sizzle.min.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/sizzle/dist/sizzle.min.map +1 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/traversing.js +199 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/traversing/findFilter.js +100 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/traversing/var/rneedsContext.js +6 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/arr.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/class2type.js +4 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/concat.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/hasOwn.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/indexOf.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/pnum.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/push.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/rnotwhite.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/slice.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/strundefined.js +3 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/support.js +4 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/var/toString.js +5 -0
- data/lib/epuber/third_party/bower/bower_components/jquery/src/wrap.js +79 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/MIT-LICENSE +20 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/Makefile +4 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/README.markdown +212 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/bower.json +27 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/keymaster.js +296 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/package.json +11 -0
- data/lib/epuber/third_party/bower/bower_components/keymaster/test.html +93 -0
- data/lib/epuber/third_party/bower/bower_components/spin.js/LICENSE.txt +21 -0
- data/lib/epuber/third_party/bower/bower_components/spin.js/README.md +21 -0
- data/lib/epuber/third_party/bower/bower_components/spin.js/bower.json +18 -0
- data/lib/epuber/third_party/bower/bower_components/spin.js/jquery.spin.js +80 -0
- data/lib/epuber/third_party/bower/bower_components/spin.js/spin.js +337 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/LICENSE.txt +21 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/README.md +534 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/bower.json +16 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/contributing.md +19 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/IPv6.js +188 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/SecondLevelDomains.js +241 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URI.fragmentQuery.js +104 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URI.fragmentURI.js +97 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URI.js +2115 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URI.min.js +86 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/URITemplate.js +499 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/jquery.URI.js +235 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/jquery.URI.min.js +7 -0
- data/lib/epuber/third_party/bower/bower_components/uri.js/src/punycode.js +508 -0
- data/lib/epuber/transformer.rb +19 -0
- data/lib/epuber/transformer/text_transformer.rb +60 -0
- data/lib/epuber/user_interface.rb +186 -0
- data/lib/epuber/vendor/globals_context.rb +26 -0
- data/lib/epuber/vendor/hash_binding.rb +26 -0
- data/lib/epuber/vendor/nokogiri_extensions.rb +30 -0
- data/lib/epuber/vendor/ruby_templater.rb +71 -0
- data/lib/epuber/vendor/size.rb +20 -0
- data/lib/epuber/vendor/version.rb +83 -0
- data/lib/epuber/version.rb +4 -0
- metadata +556 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"name": "keymaster",
|
3
|
+
"description": "library for defining and dispatching keyboard shortcuts",
|
4
|
+
"version": "1.6.3",
|
5
|
+
"author": "Thomas Fuchs <thomas@slash7.com> (http://mir.aculo.us)",
|
6
|
+
"repository": {
|
7
|
+
"type": "git",
|
8
|
+
"url": "https://github.com/madrobby/keymaster"
|
9
|
+
},
|
10
|
+
"main": "./keymaster.js"
|
11
|
+
}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
<!html>
|
2
|
+
<head>
|
3
|
+
<title>The Keymaster</title>
|
4
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<script src="keymaster.js"></script>
|
8
|
+
|
9
|
+
<h1>
|
10
|
+
The Keymaster
|
11
|
+
</h1>
|
12
|
+
|
13
|
+
<input type="text" placeholder="a text input"/>
|
14
|
+
<select><option></option><option>select</option></select>
|
15
|
+
<textarea placeholder="a textarea"></textarea>
|
16
|
+
|
17
|
+
<ol>
|
18
|
+
<li>Press 'c'. Nothing should be logged on console.</li>
|
19
|
+
<li>Press 'o' or Enter or Cursor ←. Console should log function call.</li>
|
20
|
+
<li>Press 'i'. Switches scope to 'issues'.</li>
|
21
|
+
<li>Press 'c'. Console should log function call.</li>
|
22
|
+
<li>Press 'o' or Enter or Cursor ←. Console should log function call.</li>
|
23
|
+
<li>Press and hold 'm'. Console should log a message every second.</li>
|
24
|
+
<li>Every second console should log a message listing all the currently pressed keycodes.</li>
|
25
|
+
</ol>
|
26
|
+
|
27
|
+
<p>
|
28
|
+
At any time, try pressing ⌘+right, shift+left or ctrl+shift+alt+d.
|
29
|
+
</p>
|
30
|
+
|
31
|
+
<p>
|
32
|
+
When a input, a select or a textarea element is focused, key inputs should be ignored.
|
33
|
+
</p>
|
34
|
+
|
35
|
+
<script>
|
36
|
+
key('c', 'issues', function(){
|
37
|
+
console.log('c/issues');
|
38
|
+
});
|
39
|
+
|
40
|
+
key('command+r, ctrl+r', 'issues', function(){
|
41
|
+
console.log('Hijacked Command+R or Ctrl+R, damn!');
|
42
|
+
return false;
|
43
|
+
});
|
44
|
+
|
45
|
+
key('i', function(){
|
46
|
+
key.setScope('issues');
|
47
|
+
console.log('Switched to "issues" scope. Command+R or Ctrl+R is now no longer reloading...');
|
48
|
+
});
|
49
|
+
|
50
|
+
key('i', function(){
|
51
|
+
console.log('(example of multiple assignment)');
|
52
|
+
});
|
53
|
+
|
54
|
+
key('o, enter, left', function(){
|
55
|
+
console.log('o, enter or left pressed!');
|
56
|
+
});
|
57
|
+
|
58
|
+
key('ctrl+c', function(){
|
59
|
+
console.log('this is not the command line');
|
60
|
+
});
|
61
|
+
|
62
|
+
key('⌘+right,shift+left,ctrl+shift+alt+d', function(event){
|
63
|
+
console.log('command+right, or shift+left, or ctrl+shift+alt+d');
|
64
|
+
console.log('here is the event: ', event);
|
65
|
+
console.log('key.control', key.control);
|
66
|
+
console.log('key.ctrl', key.ctrl);
|
67
|
+
console.log('key.shift', key.shift);
|
68
|
+
console.log('key.alt', key.alt);
|
69
|
+
console.log('key["⌘"]', key["⌘"]);
|
70
|
+
return false; // prevent default && stop propagation
|
71
|
+
});
|
72
|
+
|
73
|
+
key('⌘+x, ctrl+x', function(event, handler){
|
74
|
+
console.log(handler.shortcut, handler.scope);
|
75
|
+
return false;
|
76
|
+
});
|
77
|
+
|
78
|
+
key('/', function(){ console.log('/') });
|
79
|
+
key('shift+]', function(){ console.log('shift+]') });
|
80
|
+
|
81
|
+
setInterval(function () {
|
82
|
+
console.log('All keys currently down: ' + key.getPressedKeyCodes());
|
83
|
+
if (key.isPressed(77)) {
|
84
|
+
console.log('M key is currently down');
|
85
|
+
}
|
86
|
+
}, 1000);
|
87
|
+
|
88
|
+
// document.onkeydown = function(event){
|
89
|
+
// console.log(event.keyCode);
|
90
|
+
// }
|
91
|
+
</script>
|
92
|
+
</body>
|
93
|
+
</html>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011-2014 Felix Gnass [fgnass at neteye dot de]
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# spin.js
|
2
|
+
|
3
|
+
An animated CSS3 loading spinner with VML fallback for IE.
|
4
|
+
|
5
|
+
* No images, no external CSS
|
6
|
+
* No dependencies
|
7
|
+
* Highly configurable
|
8
|
+
* Resolution independent
|
9
|
+
* Uses VML as fallback in old IEs
|
10
|
+
* Uses @keyframe animations, falling back to setTimeout()
|
11
|
+
* Works in all major browsers, including IE6
|
12
|
+
* Small footprint (~1.9K gzipped)
|
13
|
+
* MIT License
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```javascript
|
18
|
+
new Spinner({color:'#fff', lines: 12}).spin(target);
|
19
|
+
```
|
20
|
+
|
21
|
+
For an interactive demo and a list of all supported options please refer to the [project's homepage](http://fgnass.github.io/spin.js/).
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"name": "spin.js",
|
3
|
+
"version": "2.0.1",
|
4
|
+
"main": "spin.js",
|
5
|
+
"dependencies": {},
|
6
|
+
"readme": "README.md",
|
7
|
+
"repository": {
|
8
|
+
"type": "git",
|
9
|
+
"url": "git://github.com/fgnass/spin.js.git"
|
10
|
+
},
|
11
|
+
"ignore": [
|
12
|
+
"Gruntfile.js",
|
13
|
+
"site",
|
14
|
+
"bower.json",
|
15
|
+
"component.json",
|
16
|
+
"package.json"
|
17
|
+
]
|
18
|
+
}
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2011-2014 Felix Gnass
|
3
|
+
* Licensed under the MIT license
|
4
|
+
*/
|
5
|
+
|
6
|
+
/*
|
7
|
+
|
8
|
+
Basic Usage:
|
9
|
+
============
|
10
|
+
|
11
|
+
$('#el').spin(); // Creates a default Spinner using the text color of #el.
|
12
|
+
$('#el').spin({ ... }); // Creates a Spinner using the provided options.
|
13
|
+
|
14
|
+
$('#el').spin(false); // Stops and removes the spinner.
|
15
|
+
|
16
|
+
Using Presets:
|
17
|
+
==============
|
18
|
+
|
19
|
+
$('#el').spin('small'); // Creates a 'small' Spinner using the text color of #el.
|
20
|
+
$('#el').spin('large', '#fff'); // Creates a 'large' white Spinner.
|
21
|
+
|
22
|
+
Adding a custom preset:
|
23
|
+
=======================
|
24
|
+
|
25
|
+
$.fn.spin.presets.flower = {
|
26
|
+
lines: 9,
|
27
|
+
length: 10,
|
28
|
+
width: 20,
|
29
|
+
radius: 0
|
30
|
+
}
|
31
|
+
|
32
|
+
$('#el').spin('flower', 'red');
|
33
|
+
|
34
|
+
*/
|
35
|
+
|
36
|
+
(function(factory) {
|
37
|
+
|
38
|
+
if (typeof exports == 'object') {
|
39
|
+
// CommonJS
|
40
|
+
factory(require('jquery'), require('spin.js'))
|
41
|
+
}
|
42
|
+
else if (typeof define == 'function' && define.amd) {
|
43
|
+
// AMD, register as anonymous module
|
44
|
+
define(['jquery', 'spin'], factory)
|
45
|
+
}
|
46
|
+
else {
|
47
|
+
// Browser globals
|
48
|
+
if (!window.Spinner) throw new Error('Spin.js not present')
|
49
|
+
factory(window.jQuery, window.Spinner)
|
50
|
+
}
|
51
|
+
|
52
|
+
}(function($, Spinner) {
|
53
|
+
|
54
|
+
$.fn.spin = function(opts, color) {
|
55
|
+
|
56
|
+
return this.each(function() {
|
57
|
+
var $this = $(this),
|
58
|
+
data = $this.data();
|
59
|
+
|
60
|
+
if (data.spinner) {
|
61
|
+
data.spinner.stop();
|
62
|
+
delete data.spinner;
|
63
|
+
}
|
64
|
+
if (opts !== false) {
|
65
|
+
opts = $.extend(
|
66
|
+
{ color: color || $this.css('color') },
|
67
|
+
$.fn.spin.presets[opts] || opts
|
68
|
+
)
|
69
|
+
data.spinner = new Spinner(opts).spin(this)
|
70
|
+
}
|
71
|
+
})
|
72
|
+
}
|
73
|
+
|
74
|
+
$.fn.spin.presets = {
|
75
|
+
tiny: { lines: 8, length: 2, width: 2, radius: 3 },
|
76
|
+
small: { lines: 8, length: 4, width: 3, radius: 5 },
|
77
|
+
large: { lines: 10, length: 8, width: 4, radius: 8 }
|
78
|
+
}
|
79
|
+
|
80
|
+
}));
|
@@ -0,0 +1,337 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2011-2014 Felix Gnass
|
3
|
+
* Licensed under the MIT license
|
4
|
+
*/
|
5
|
+
(function(root, factory) {
|
6
|
+
|
7
|
+
/* CommonJS */
|
8
|
+
if (typeof exports == 'object') module.exports = factory()
|
9
|
+
|
10
|
+
/* AMD module */
|
11
|
+
else if (typeof define == 'function' && define.amd) define(factory)
|
12
|
+
|
13
|
+
/* Browser global */
|
14
|
+
else root.Spinner = factory()
|
15
|
+
}
|
16
|
+
(this, function() {
|
17
|
+
"use strict";
|
18
|
+
|
19
|
+
var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */
|
20
|
+
, animations = {} /* Animation rules keyed by their name */
|
21
|
+
, useCssAnimations /* Whether to use CSS animations or setTimeout */
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Utility function to create elements. If no tag name is given,
|
25
|
+
* a DIV is created. Optionally properties can be passed.
|
26
|
+
*/
|
27
|
+
function createEl(tag, prop) {
|
28
|
+
var el = document.createElement(tag || 'div')
|
29
|
+
, n
|
30
|
+
|
31
|
+
for(n in prop) el[n] = prop[n]
|
32
|
+
return el
|
33
|
+
}
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Appends children and returns the parent.
|
37
|
+
*/
|
38
|
+
function ins(parent /* child1, child2, ...*/) {
|
39
|
+
for (var i=1, n=arguments.length; i<n; i++)
|
40
|
+
parent.appendChild(arguments[i])
|
41
|
+
|
42
|
+
return parent
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Insert a new stylesheet to hold the @keyframe or VML rules.
|
47
|
+
*/
|
48
|
+
var sheet = (function() {
|
49
|
+
var el = createEl('style', {type : 'text/css'})
|
50
|
+
ins(document.getElementsByTagName('head')[0], el)
|
51
|
+
return el.sheet || el.styleSheet
|
52
|
+
}())
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Creates an opacity keyframe animation rule and returns its name.
|
56
|
+
* Since most mobile Webkits have timing issues with animation-delay,
|
57
|
+
* we create separate rules for each line/segment.
|
58
|
+
*/
|
59
|
+
function addAnimation(alpha, trail, i, lines) {
|
60
|
+
var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-')
|
61
|
+
, start = 0.01 + i/lines * 100
|
62
|
+
, z = Math.max(1 - (1-alpha) / trail * (100-start), alpha)
|
63
|
+
, prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase()
|
64
|
+
, pre = prefix && '-' + prefix + '-' || ''
|
65
|
+
|
66
|
+
if (!animations[name]) {
|
67
|
+
sheet.insertRule(
|
68
|
+
'@' + pre + 'keyframes ' + name + '{' +
|
69
|
+
'0%{opacity:' + z + '}' +
|
70
|
+
start + '%{opacity:' + alpha + '}' +
|
71
|
+
(start+0.01) + '%{opacity:1}' +
|
72
|
+
(start+trail) % 100 + '%{opacity:' + alpha + '}' +
|
73
|
+
'100%{opacity:' + z + '}' +
|
74
|
+
'}', sheet.cssRules.length)
|
75
|
+
|
76
|
+
animations[name] = 1
|
77
|
+
}
|
78
|
+
|
79
|
+
return name
|
80
|
+
}
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Tries various vendor prefixes and returns the first supported property.
|
84
|
+
*/
|
85
|
+
function vendor(el, prop) {
|
86
|
+
var s = el.style
|
87
|
+
, pp
|
88
|
+
, i
|
89
|
+
|
90
|
+
prop = prop.charAt(0).toUpperCase() + prop.slice(1)
|
91
|
+
for(i=0; i<prefixes.length; i++) {
|
92
|
+
pp = prefixes[i]+prop
|
93
|
+
if(s[pp] !== undefined) return pp
|
94
|
+
}
|
95
|
+
if(s[prop] !== undefined) return prop
|
96
|
+
}
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Sets multiple style properties at once.
|
100
|
+
*/
|
101
|
+
function css(el, prop) {
|
102
|
+
for (var n in prop)
|
103
|
+
el.style[vendor(el, n)||n] = prop[n]
|
104
|
+
|
105
|
+
return el
|
106
|
+
}
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Fills in default values.
|
110
|
+
*/
|
111
|
+
function merge(obj) {
|
112
|
+
for (var i=1; i < arguments.length; i++) {
|
113
|
+
var def = arguments[i]
|
114
|
+
for (var n in def)
|
115
|
+
if (obj[n] === undefined) obj[n] = def[n]
|
116
|
+
}
|
117
|
+
return obj
|
118
|
+
}
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Returns the line color from the given string or array.
|
122
|
+
*/
|
123
|
+
function getColor(color, idx) {
|
124
|
+
return typeof color == 'string' ? color : color[idx % color.length]
|
125
|
+
}
|
126
|
+
|
127
|
+
// Built-in defaults
|
128
|
+
|
129
|
+
var defaults = {
|
130
|
+
lines: 12, // The number of lines to draw
|
131
|
+
length: 7, // The length of each line
|
132
|
+
width: 5, // The line thickness
|
133
|
+
radius: 10, // The radius of the inner circle
|
134
|
+
rotate: 0, // Rotation offset
|
135
|
+
corners: 1, // Roundness (0..1)
|
136
|
+
color: '#000', // #rgb or #rrggbb
|
137
|
+
direction: 1, // 1: clockwise, -1: counterclockwise
|
138
|
+
speed: 1, // Rounds per second
|
139
|
+
trail: 100, // Afterglow percentage
|
140
|
+
opacity: 1/4, // Opacity of the lines
|
141
|
+
fps: 20, // Frames per second when using setTimeout()
|
142
|
+
zIndex: 2e9, // Use a high z-index by default
|
143
|
+
className: 'spinner', // CSS class to assign to the element
|
144
|
+
top: '50%', // center vertically
|
145
|
+
left: '50%', // center horizontally
|
146
|
+
position: 'absolute' // element position
|
147
|
+
}
|
148
|
+
|
149
|
+
/** The constructor */
|
150
|
+
function Spinner(o) {
|
151
|
+
this.opts = merge(o || {}, Spinner.defaults, defaults)
|
152
|
+
}
|
153
|
+
|
154
|
+
// Global defaults that override the built-ins:
|
155
|
+
Spinner.defaults = {}
|
156
|
+
|
157
|
+
merge(Spinner.prototype, {
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Adds the spinner to the given target element. If this instance is already
|
161
|
+
* spinning, it is automatically removed from its previous target b calling
|
162
|
+
* stop() internally.
|
163
|
+
*/
|
164
|
+
spin: function(target) {
|
165
|
+
this.stop()
|
166
|
+
|
167
|
+
var self = this
|
168
|
+
, o = self.opts
|
169
|
+
, el = self.el = css(createEl(0, {className: o.className}), {position: o.position, width: 0, zIndex: o.zIndex})
|
170
|
+
|
171
|
+
css(el, {
|
172
|
+
left: o.left,
|
173
|
+
top: o.top
|
174
|
+
})
|
175
|
+
|
176
|
+
if (target) {
|
177
|
+
target.insertBefore(el, target.firstChild||null)
|
178
|
+
}
|
179
|
+
|
180
|
+
el.setAttribute('role', 'progressbar')
|
181
|
+
self.lines(el, self.opts)
|
182
|
+
|
183
|
+
if (!useCssAnimations) {
|
184
|
+
// No CSS animation support, use setTimeout() instead
|
185
|
+
var i = 0
|
186
|
+
, start = (o.lines - 1) * (1 - o.direction) / 2
|
187
|
+
, alpha
|
188
|
+
, fps = o.fps
|
189
|
+
, f = fps/o.speed
|
190
|
+
, ostep = (1-o.opacity) / (f*o.trail / 100)
|
191
|
+
, astep = f/o.lines
|
192
|
+
|
193
|
+
;(function anim() {
|
194
|
+
i++;
|
195
|
+
for (var j = 0; j < o.lines; j++) {
|
196
|
+
alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity)
|
197
|
+
|
198
|
+
self.opacity(el, j * o.direction + start, alpha, o)
|
199
|
+
}
|
200
|
+
self.timeout = self.el && setTimeout(anim, ~~(1000/fps))
|
201
|
+
})()
|
202
|
+
}
|
203
|
+
return self
|
204
|
+
},
|
205
|
+
|
206
|
+
/**
|
207
|
+
* Stops and removes the Spinner.
|
208
|
+
*/
|
209
|
+
stop: function() {
|
210
|
+
var el = this.el
|
211
|
+
if (el) {
|
212
|
+
clearTimeout(this.timeout)
|
213
|
+
if (el.parentNode) el.parentNode.removeChild(el)
|
214
|
+
this.el = undefined
|
215
|
+
}
|
216
|
+
return this
|
217
|
+
},
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Internal method that draws the individual lines. Will be overwritten
|
221
|
+
* in VML fallback mode below.
|
222
|
+
*/
|
223
|
+
lines: function(el, o) {
|
224
|
+
var i = 0
|
225
|
+
, start = (o.lines - 1) * (1 - o.direction) / 2
|
226
|
+
, seg
|
227
|
+
|
228
|
+
function fill(color, shadow) {
|
229
|
+
return css(createEl(), {
|
230
|
+
position: 'absolute',
|
231
|
+
width: (o.length+o.width) + 'px',
|
232
|
+
height: o.width + 'px',
|
233
|
+
background: color,
|
234
|
+
boxShadow: shadow,
|
235
|
+
transformOrigin: 'left',
|
236
|
+
transform: 'rotate(' + ~~(360/o.lines*i+o.rotate) + 'deg) translate(' + o.radius+'px' +',0)',
|
237
|
+
borderRadius: (o.corners * o.width>>1) + 'px'
|
238
|
+
})
|
239
|
+
}
|
240
|
+
|
241
|
+
for (; i < o.lines; i++) {
|
242
|
+
seg = css(createEl(), {
|
243
|
+
position: 'absolute',
|
244
|
+
top: 1+~(o.width/2) + 'px',
|
245
|
+
transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
|
246
|
+
opacity: o.opacity,
|
247
|
+
animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1/o.speed + 's linear infinite'
|
248
|
+
})
|
249
|
+
|
250
|
+
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}))
|
251
|
+
ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)')))
|
252
|
+
}
|
253
|
+
return el
|
254
|
+
},
|
255
|
+
|
256
|
+
/**
|
257
|
+
* Internal method that adjusts the opacity of a single line.
|
258
|
+
* Will be overwritten in VML fallback mode below.
|
259
|
+
*/
|
260
|
+
opacity: function(el, i, val) {
|
261
|
+
if (i < el.childNodes.length) el.childNodes[i].style.opacity = val
|
262
|
+
}
|
263
|
+
|
264
|
+
})
|
265
|
+
|
266
|
+
|
267
|
+
function initVML() {
|
268
|
+
|
269
|
+
/* Utility function to create a VML tag */
|
270
|
+
function vml(tag, attr) {
|
271
|
+
return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
|
272
|
+
}
|
273
|
+
|
274
|
+
// No CSS transforms but VML support, add a CSS rule for VML elements:
|
275
|
+
sheet.addRule('.spin-vml', 'behavior:url(#default#VML)')
|
276
|
+
|
277
|
+
Spinner.prototype.lines = function(el, o) {
|
278
|
+
var r = o.length+o.width
|
279
|
+
, s = 2*r
|
280
|
+
|
281
|
+
function grp() {
|
282
|
+
return css(
|
283
|
+
vml('group', {
|
284
|
+
coordsize: s + ' ' + s,
|
285
|
+
coordorigin: -r + ' ' + -r
|
286
|
+
}),
|
287
|
+
{ width: s, height: s }
|
288
|
+
)
|
289
|
+
}
|
290
|
+
|
291
|
+
var margin = -(o.width+o.length)*2 + 'px'
|
292
|
+
, g = css(grp(), {position: 'absolute', top: margin, left: margin})
|
293
|
+
, i
|
294
|
+
|
295
|
+
function seg(i, dx, filter) {
|
296
|
+
ins(g,
|
297
|
+
ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}),
|
298
|
+
ins(css(vml('roundrect', {arcsize: o.corners}), {
|
299
|
+
width: r,
|
300
|
+
height: o.width,
|
301
|
+
left: o.radius,
|
302
|
+
top: -o.width>>1,
|
303
|
+
filter: filter
|
304
|
+
}),
|
305
|
+
vml('fill', {color: getColor(o.color, i), opacity: o.opacity}),
|
306
|
+
vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
|
307
|
+
)
|
308
|
+
)
|
309
|
+
)
|
310
|
+
}
|
311
|
+
|
312
|
+
if (o.shadow)
|
313
|
+
for (i = 1; i <= o.lines; i++)
|
314
|
+
seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
|
315
|
+
|
316
|
+
for (i = 1; i <= o.lines; i++) seg(i)
|
317
|
+
return ins(el, g)
|
318
|
+
}
|
319
|
+
|
320
|
+
Spinner.prototype.opacity = function(el, i, val, o) {
|
321
|
+
var c = el.firstChild
|
322
|
+
o = o.shadow && o.lines || 0
|
323
|
+
if (c && i+o < c.childNodes.length) {
|
324
|
+
c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild
|
325
|
+
if (c) c.opacity = val
|
326
|
+
}
|
327
|
+
}
|
328
|
+
}
|
329
|
+
|
330
|
+
var probe = css(createEl('group'), {behavior: 'url(#default#VML)'})
|
331
|
+
|
332
|
+
if (!vendor(probe, 'transform') && probe.adj) initVML()
|
333
|
+
else useCssAnimations = vendor(probe, 'animation')
|
334
|
+
|
335
|
+
return Spinner
|
336
|
+
|
337
|
+
}));
|