Scroll Back To Top - Version 1.0

Version Description

  • Initial Release

=

Download this release

Release Info

Developer joesexton00
Plugin Icon wp plugin Scroll Back To Top
Version 1.0
Comparing to
See all releases

Version 1.0

Files changed (40) hide show
  1. assets/js/admin.js +24 -0
  2. assets/js/scroll-back-to-top.js +91 -0
  3. assets/lib/jquery-textfill/CHANGES.mkd +74 -0
  4. assets/lib/jquery-textfill/COPYING +20 -0
  5. assets/lib/jquery-textfill/Makefile +9 -0
  6. assets/lib/jquery-textfill/README.mkd +106 -0
  7. assets/lib/jquery-textfill/css/index.css +57 -0
  8. assets/lib/jquery-textfill/img/ChimpThinking.png +0 -0
  9. assets/lib/jquery-textfill/img/Computer2.png +0 -0
  10. assets/lib/jquery-textfill/img/ComputerGlare.png +0 -0
  11. assets/lib/jquery-textfill/index.html +38 -0
  12. assets/lib/jquery-textfill/jquery.textfill.js +149 -0
  13. assets/lib/jquery-textfill/jquery.textfill.min.js +17 -0
  14. assets/lib/jquery-textfill/js/index.js +13 -0
  15. assets/lib/jquery-textfill/js/tests.js +364 -0
  16. assets/lib/jquery-textfill/tests.html +17 -0
  17. assets/lib/jquery-textfill/textfill.jquery.json +35 -0
  18. assets/screenshot-1.png +0 -0
  19. assets/screenshot-2.png +0 -0
  20. assets/screenshot-3.png +0 -0
  21. assets/screenshot-4.png +0 -0
  22. assets/screenshot-5.png +0 -0
  23. controller/SBTT_AdminMenuController.php +48 -0
  24. controller/SBTT_FrontendController.php +283 -0
  25. framework/JmsAdminSettingsPage.php +959 -0
  26. framework/JmsBootstrap.php +178 -0
  27. framework/JmsController.php +420 -0
  28. framework/JmsUserOptionsCollection.php +234 -0
  29. framework/readme.md +3 -0
  30. model/SBTT_Options.php +261 -0
  31. readme.txt +77 -0
  32. scroll-back-to-top.php +12 -0
  33. view/dynamic-styles.php +94 -0
  34. view/framework/admin/partials/checkbox_input.php +22 -0
  35. view/framework/admin/partials/radio_input.php +23 -0
  36. view/framework/admin/partials/required_indicator.php +1 -0
  37. view/framework/admin/partials/text_input.php +22 -0
  38. view/framework/admin/partials/textarea_input.php +13 -0
  39. view/framework/admin/settings.php +45 -0
  40. view/scroll-button.php +9 -0
assets/js/admin.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($){
2
+ $(function(){
3
+ sbttLoaded();
4
+ $('[name="scroll-back-to-top[label_type]"]').on('change', sbttLoaded);
5
+ });
6
+
7
+ function sbttLoaded(){
8
+ if($('[name="scroll-back-to-top[label_type]"]:checked').val() == 'text'){
9
+ $('[name="scroll-back-to-top[icon_size]"]').prop('disabled', true);
10
+ $('[name="scroll-back-to-top[label_text]"]').prop('disabled', false);
11
+ $('[name="scroll-back-to-top[font_size]"]').prop('disabled', false);
12
+ if(!$('[name="scroll-back-to-top[font_size]"]').val()){
13
+ $('[name="scroll-back-to-top[font_size]"]').val(12);
14
+ }
15
+ } else {
16
+ $('[name="scroll-back-to-top[icon_size]"]').prop('disabled', false);
17
+ $('[name="scroll-back-to-top[label_text]"]').prop('disabled', true);
18
+ $('[name="scroll-back-to-top[font_size]"]').prop('disabled', true);
19
+ if(!$('[name="scroll-back-to-top[icon_size]"]:checked').val()){
20
+ $('[name="scroll-back-to-top[icon_size]"][value="fa-2x"]').prop('checked', true);
21
+ }
22
+ }
23
+ }
24
+ })(jQuery);
assets/js/scroll-back-to-top.js ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($){
2
+
3
+ $(function(){
4
+ if(typeof scrollBackToTop.autoFontSize !== 'undefined' && scrollBackToTop.autoFontSize){
5
+ $('.scroll-back-to-top-wrapper').textfill({ maxFontPixels: 36 });
6
+ }
7
+
8
+ $('.scroll-back-to-top-wrapper').on('click', function(){
9
+ if(typeof scrollBackToTop.scrollDuration !== 'undefined'){
10
+ scrollToElement("body", scrollBackToTop.scrollDuration, 0);
11
+ }
12
+ });
13
+
14
+ $(document).on( 'scroll', function(){
15
+
16
+ if ($(window).scrollTop() > 100) {
17
+ $('.scroll-back-to-top-wrapper').addClass('show');
18
+ } else {
19
+ $('.scroll-back-to-top-wrapper').removeClass('show');
20
+ }
21
+ });
22
+ });
23
+
24
+ function scrollToElement(selector, time, verticalOffset) {
25
+
26
+ time = typeof(time) != 'undefined' ? time : 1000;
27
+ verticalOffset = typeof(verticalOffset) != 'undefined' ? verticalOffset : 0;
28
+ element = $(selector);
29
+ offset = element.offset();
30
+ offsetTop = offset.top + verticalOffset;
31
+ $('html, body').animate({scrollTop: offsetTop}, parseInt(time), 'linear');
32
+ }
33
+
34
+ function isFullyVisible(el) {
35
+
36
+ if ( ! el.length ) {
37
+ return false;
38
+ }
39
+
40
+ if ( el instanceof jQuery ) {
41
+ el = el[0];
42
+ }
43
+
44
+ var top = el.offsetTop;
45
+ var left = el.offsetLeft;
46
+ var width = el.offsetWidth;
47
+ var height = el.offsetHeight;
48
+
49
+ while(el.offsetParent) {
50
+ el = el.offsetParent;
51
+ top += el.offsetTop;
52
+ left += el.offsetLeft;
53
+ }
54
+
55
+ return (
56
+ top >= window.pageYOffset &&
57
+ left >= window.pageXOffset &&
58
+ (top + height) <= (window.pageYOffset + window.innerHeight) &&
59
+ (left + width) <= (window.pageXOffset + window.innerWidth)
60
+ );
61
+ }
62
+
63
+ function isPartiallyVisible(el) {
64
+
65
+ if ( ! el.length ) {
66
+ return false;
67
+ }
68
+
69
+ if ( el instanceof jQuery ) {
70
+ el = el[0];
71
+ }
72
+
73
+ var top = el.offsetTop;
74
+ var left = el.offsetLeft;
75
+ var width = el.offsetWidth;
76
+ var height = el.offsetHeight;
77
+
78
+ while(el.offsetParent) {
79
+ el = el.offsetParent;
80
+ top += el.offsetTop;
81
+ left += el.offsetLeft;
82
+ }
83
+
84
+ return (
85
+ top < (window.pageYOffset + window.innerHeight) &&
86
+ left < (window.pageXOffset + window.innerWidth) &&
87
+ (top + height) > window.pageYOffset &&
88
+ (left + width) > window.pageXOffset
89
+ );
90
+ }
91
+ })(jQuery);
assets/lib/jquery-textfill/CHANGES.mkd ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ CHANGES
2
+ =======
3
+
4
+ ## Future
5
+
6
+ * drop `callback` callback
7
+
8
+ ## Development
9
+
10
+ ## Version 0.4.0 (2013-08-16T17:17:02Z)
11
+
12
+ * add tests for callbacks
13
+ * add `fail` callback (#15)
14
+ * deprecate `callback` callback with `success` callback
15
+ * fix `widthOnly` option (#4)
16
+
17
+ Height will not cause failure when `widthOnly` is set as long as width can fit into the container.
18
+
19
+ ## Version 0.3.5 (2013-05-08T00:40:22Z)
20
+
21
+ * merge patch for compatibility to ZeptoJS (by sagens42 #13)
22
+
23
+ ## Version 0.3.4 (2013-04-10T03:55:51Z)
24
+
25
+ * fix error when no console.debug.
26
+ * add test for debug flag.
27
+
28
+ ## Version 0.3.3 (2013-03-25T23:35:21Z)
29
+
30
+ * retag for including the manefest in the tag.
31
+
32
+ ## Version 0.3.2 (2013-02-09T02:43:32Z)
33
+
34
+ * fix introduced global variable fontSize by `_sizing()`
35
+ * fix container too small for bigger font size setting (#11)
36
+
37
+ ## Version 0.3.1 (2013-01-27T05:10:51Z)
38
+
39
+ * Add `debug` option.
40
+ * Fix a couple of bugs, they didn't size up as big as possible
41
+
42
+ ## Version 0.3 (2013-01-04T16:27:52Z)
43
+
44
+ * Allow to use *MaxFontPixels <= 0* to make sizing as big as possible.
45
+
46
+ ## Version 0.2.1 (2012-11-11T07:04:20Z)
47
+
48
+ * Add explicitWidth and explicitHeight options (#6)
49
+
50
+ ## Version 0.2 (2012-07-02T17:13:27Z)
51
+
52
+ * Fix resizing algorithm (#3)
53
+ * Add option widthOnly for header tags (#4)
54
+
55
+ ## Version 0.1.3 (2012-03-27T04:03:30Z)
56
+
57
+ * Add callbacks for each filled and all filled. (by alex-pex #2)
58
+
59
+ ## Version 0.1.2 (2012-01-29T12:46:12Z)
60
+
61
+ * Use binary search instead of plain do-while to accelerate the function.
62
+ (by acsaga #1)
63
+
64
+ ## Version 0.1.1
65
+
66
+ Add minFontPixels parameter
67
+
68
+ ## 2012-01-16T16:56:32Z
69
+
70
+ This project was moved to GitHub and licensed under the MIT License.
71
+
72
+ ## Version 0.1
73
+
74
+ Released in May 2009.
assets/lib/jquery-textfill/COPYING ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2012-2013 Yu-Jie Lin
2
+ Copyright (c) 2009 Russ Painter
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ this software and associated documentation files (the "Software"), to deal in
6
+ the Software without restriction, including without limitation the rights to
7
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8
+ of the Software, and to permit persons to whom the Software is furnished to do
9
+ so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
assets/lib/jquery-textfill/Makefile ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ all: jquery.textfill.min.js
2
+
3
+ jquery.textfill.min.js: jquery.textfill.js
4
+ curl --data output_info=compiled_code --data-urlencode js_code@jquery.textfill.js http://closure-compiler.appspot.com/compile > jquery.textfill.min.js
5
+
6
+ clean:
7
+ rm -f jquery.textfill.min.js
8
+
9
+ .PHONY: clean
assets/lib/jquery-textfill/README.mkd ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery TextFill
2
+ ===============
3
+
4
+ **[jQuery TextFill][index]** resizes text to fit into a container and makes font size as big as possible.
5
+
6
+ This jQuery plugin was created by Russ Painter around May 2009, beginning with a StackOverflow [question][soq]. In very early 2012, Yu-Jie Lin helped to move the project to GitHub with version 0.1 and obtained the clearly stated open source licensing from Russ.
7
+
8
+ [soq]: http://stackoverflow.com/questions/687998/auto-size-dynamic-text-to-fill-fixed-size-container
9
+ [index]: http://jquery-textfill.github.io/jquery-textfill/index.html
10
+
11
+ Usage
12
+ -----
13
+
14
+ ```html
15
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
16
+ <script src="http://jquery-textfill.github.io/jquery-textfill/jquery.textfill.min.js"></script>
17
+ ```
18
+
19
+ The code above uses minified version. By default options, you need to put text inside of `<span/>`:
20
+
21
+ ```html
22
+ <div class='textfill' style='width:100px;height:50px;'>
23
+ <span>The quick brown fox jumps over the lazy dog</span>
24
+ </div>
25
+ ```
26
+
27
+ ### Initialization
28
+
29
+ ```js
30
+ $(selector).textfill(options);
31
+ ```
32
+
33
+ For example,
34
+
35
+ ```html
36
+ <script>
37
+ $(function(){
38
+ $('.textfill').textfill({ maxFontPixels: 36 });
39
+ });
40
+ </script>
41
+ ```
42
+
43
+ ### Options
44
+
45
+ Name | Description | Default
46
+ --- | --- | ---
47
+ `debug` | output debug message to console | `false`
48
+ `minFontPixels` | minimal font size | 4
49
+ `maxFontPixels` | sizing up the text as big as possible to this setting. For *size <= 0*, the text is sized to as big as the container can accommodate | 40
50
+ `innerTag` | the element tag to resize, select by `$(innerTag + ':visible:first', container)` | `span`
51
+ `success` | callback when a resizing is successful
52
+ `fail` | callback when a resizing is failed
53
+ `complete` | callback when all elements are done
54
+ `widthOnly` | only resizing for width restraint, this is intentionally used with CSS `white-space: nowrap` for header tags
55
+ `explicitWidth` | explicit width
56
+ `explicitHeight` | explicit height
57
+
58
+ Help and Support
59
+ ----------------
60
+
61
+ ### Reporting bug
62
+
63
+ When report a bug, please reproduce the bug using [Gist][] or [jsFiddle][] as a template. Environment can be different and some may be fine, some may be not. **Please make sure you can clearly demonstrate the bug** unless the bug is super easy to spot like `a < b` should be `a <= b`.
64
+
65
+ When reproduce a bug, it's important that CSS matches the page where you encounter the bug, it could be crucial that container's and innertag's styles have to be exactly the same.
66
+
67
+ Please also provide enough information about your system and browser, if necessary, here is a template:
68
+
69
+ TextFill version:
70
+ jQuery version:
71
+ Font family:
72
+ OS/Version:
73
+ Browser/Version:
74
+
75
+ Since TextFill 0.3.1, there is debugging option, can be enabled by `debug: true`, you can also include those messages.
76
+
77
+ [Gist]: https://gist.github.com/4650697
78
+ [jsFiddle]: http://jsfiddle.net/livibetter/3gMFG/
79
+
80
+ *If you can not provide a bug reprouction, then please do not report*, I could not fix something I can't see.
81
+
82
+ ### Contributing
83
+
84
+ You are very welcome to contribute whatever you can, but **please do not**:
85
+
86
+ * Update version number.
87
+ * Generate minified file.
88
+
89
+ These tasks are for releasing, contributors should not take on them.
90
+
91
+ Before you submit, make sure:
92
+
93
+ * Coding style generally matches.
94
+ * Pass all [tests][] previously have passed.
95
+ * *Optional* Update [`README`](README.mkd) if necessary.
96
+ * *Optional* Update [`CHANGES`](CHANGES.mkd) if worth mentioning.
97
+
98
+ [tests]: http://jquery-textfill.github.io/jquery-textfill/tests.html
99
+
100
+ License
101
+ -------
102
+
103
+ It is licensed under the MIT License, see [`COPYING`](COPYING) file.
104
+
105
+ Copyright (c) 2012-2013 Yu-Jie Lin
106
+ Copyright (c) 2009 Russ Painter
assets/lib/jquery-textfill/css/index.css ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ background-color: #ddf;
3
+ }
4
+
5
+ #dyntext {
6
+ width: 400px;
7
+ }
8
+
9
+ .monkeythink {
10
+ position: relative;
11
+ float: left;
12
+ width: 200px;
13
+ height: 286px;
14
+ background-image: url("../img/ChimpThinking.png");
15
+ }
16
+
17
+ .monkeythink .jtextfill {
18
+ position: absolute;
19
+ top: 30px;
20
+ left: 20px;
21
+ width: 150px;
22
+ height: 70px;
23
+ background-color: #fff;
24
+ text-align: center;
25
+ }
26
+
27
+ .monkeythink .jtextfill span {
28
+ font-family: "Happy Monkey";
29
+ }
30
+
31
+ .computer {
32
+ position: relative;
33
+ float: right;
34
+ width: 450px;
35
+ height: 424px;
36
+ background-image: url("../img/Computer2.png");
37
+ }
38
+
39
+ .computer .jtextfill {
40
+ position: absolute;
41
+ top: 70px;
42
+ left: 85px;
43
+ width: 285px;
44
+ height: 210px;
45
+ color: #8f8;
46
+ }
47
+
48
+ .computer .jtextfill span {
49
+ font-family: "VT323";
50
+ }
51
+
52
+ .computerglare {
53
+ position: absolute;
54
+ width: 450px;
55
+ height: 424px;
56
+ background-image: url("../img/ComputerGlare.png");
57
+ }
assets/lib/jquery-textfill/img/ChimpThinking.png ADDED
Binary file
assets/lib/jquery-textfill/img/Computer2.png ADDED
Binary file
assets/lib/jquery-textfill/img/ComputerGlare.png ADDED
Binary file
assets/lib/jquery-textfill/index.html ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>jQuery Plugin: Text Fill</title>
6
+ <link href='http://fonts.googleapis.com/css?family=VT323|Happy+Monkey' rel='stylesheet' type='text/css'/>
7
+ <link href="css/index.css" rel="stylesheet" type="text/css"/>
8
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
9
+ <script src="jquery.textfill.js" ></script>
10
+ <script src="js/index.js" ></script>
11
+ </head>
12
+
13
+ <body>
14
+ <div>
15
+ <h1>Example of TextFill jQuery Plugin</h1>
16
+ <div>
17
+ <label for="dyntext">What is monkey thinking?</label>
18
+ <input type="text" id="dyntext" value="e=mc²"></input>
19
+ </div>
20
+ <div>
21
+ <label for="maxsize">Maximal font size in pixels?</label>
22
+ <input type="text" id="maxsize" value="0"></input>
23
+ </div>
24
+ <hr />
25
+ <div class="monkeythink">
26
+ <div class="jtextfill">
27
+ <span class="dyntextval">e=mc²</span>
28
+ </div>
29
+ </div>
30
+ <div class="computer">
31
+ <div class="jtextfill">
32
+ <span class="dyntextval">e=mc²</span>
33
+ </div>
34
+ <div class="computerglare"></div>
35
+ </div>
36
+ </div>
37
+ </body>
38
+ </html>
assets/lib/jquery-textfill/jquery.textfill.js ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @preserve textfill
3
+ * @name jquery.textfill.js
4
+ * @author Russ Painter
5
+ * @author Yu-Jie Lin
6
+ * @version 0.4.0
7
+ * @date 2013-08-16
8
+ * @copyright (c) 2012-2013 Yu-Jie Lin
9
+ * @copyright (c) 2009 Russ Painter
10
+ * @license MIT License
11
+ * @homepage https://github.com/jquery-textfill/jquery-textfill
12
+ * @example http://jquery-textfill.github.io/jquery-textfill/index.html
13
+ */
14
+ ; (function($) {
15
+ /**
16
+ * Resizes an inner element's font so that the inner element completely fills the outer element.
17
+ * @param {Object} Options which are maxFontPixels (default=40), innerTag (default='span')
18
+ * @return All outer elements processed
19
+ */
20
+ $.fn.textfill = function(options) {
21
+ var defaults = {
22
+ debug: false,
23
+ maxFontPixels: 40,
24
+ minFontPixels: 4,
25
+ innerTag: 'span',
26
+ widthOnly: false,
27
+ success: null, // callback when a resizing is done
28
+ callback: null, // callback when a resizing is done (deprecated, use success)
29
+ fail: null, // callback when a resizing is failed
30
+ complete: null, // callback when all is done
31
+ explicitWidth: null,
32
+ explicitHeight: null
33
+ };
34
+ var Opts = $.extend(defaults, options);
35
+
36
+ function _debug() {
37
+ if (!Opts.debug
38
+ || typeof console == 'undefined'
39
+ || typeof console.debug == 'undefined') {
40
+ return;
41
+ }
42
+
43
+ console.debug.apply(console, arguments);
44
+ }
45
+
46
+ function _warn() {
47
+ if (typeof console == 'undefined'
48
+ || typeof console.warn == 'undefined') {
49
+ return;
50
+ }
51
+
52
+ console.warn.apply(console, arguments);
53
+ }
54
+
55
+ function _debug_sizing(prefix, ourText, maxHeight, maxWidth, minFontPixels, maxFontPixels) {
56
+ function _m(v1, v2) {
57
+ var marker = ' / ';
58
+ if (v1 > v2) {
59
+ marker = ' > ';
60
+ } else if (v1 == v2) {
61
+ marker = ' = ';
62
+ }
63
+ return marker;
64
+ }
65
+
66
+ _debug(
67
+ prefix +
68
+ 'font: ' + ourText.css('font-size') +
69
+ ', H: ' + ourText.height() + _m(ourText.height(), maxHeight) + maxHeight +
70
+ ', W: ' + ourText.width() + _m(ourText.width() , maxWidth) + maxWidth +
71
+ ', minFontPixels: ' + minFontPixels +
72
+ ', maxFontPixels: ' + maxFontPixels
73
+ );
74
+ }
75
+
76
+ function _sizing(prefix, ourText, func, max, maxHeight, maxWidth, minFontPixels, maxFontPixels) {
77
+ _debug_sizing(prefix + ': ', ourText, maxHeight, maxWidth, minFontPixels, maxFontPixels);
78
+ while (minFontPixels < maxFontPixels - 1) {
79
+ var fontSize = Math.floor((minFontPixels + maxFontPixels) / 2)
80
+ ourText.css('font-size', fontSize);
81
+ if (func.call(ourText) <= max) {
82
+ minFontPixels = fontSize;
83
+ if (func.call(ourText) == max) {
84
+ break;
85
+ }
86
+ } else {
87
+ maxFontPixels = fontSize;
88
+ }
89
+ _debug_sizing(prefix + ': ', ourText, maxHeight, maxWidth, minFontPixels, maxFontPixels);
90
+ }
91
+ ourText.css('font-size', maxFontPixels);
92
+ if (func.call(ourText) <= max) {
93
+ minFontPixels = maxFontPixels;
94
+ _debug_sizing(prefix + '* ', ourText, maxHeight, maxWidth, minFontPixels, maxFontPixels);
95
+ }
96
+ return minFontPixels;
97
+ }
98
+
99
+ this.each(function() {
100
+ var ourText = $(Opts.innerTag + ':visible:first', this);
101
+ // Use explicit dimensions when specified
102
+ var maxHeight = Opts.explicitHeight || $(this).height();
103
+ var maxWidth = Opts.explicitWidth || $(this).width();
104
+ var oldFontSize = ourText.css('font-size');
105
+ var fontSize;
106
+
107
+ _debug('Opts: ', Opts);
108
+ _debug('Vars:' +
109
+ ' maxHeight: ' + maxHeight +
110
+ ', maxWidth: ' + maxWidth
111
+ );
112
+
113
+ var minFontPixels = Opts.minFontPixels;
114
+ var maxFontPixels = Opts.maxFontPixels <= 0 ? maxHeight : Opts.maxFontPixels;
115
+ var HfontSize = undefined;
116
+ if (!Opts.widthOnly) {
117
+ HfontSize = _sizing('H', ourText, $.fn.height, maxHeight, maxHeight, maxWidth, minFontPixels, maxFontPixels);
118
+ }
119
+ var WfontSize = _sizing('W', ourText, $.fn.width, maxWidth, maxHeight, maxWidth, minFontPixels, maxFontPixels);
120
+
121
+ if (Opts.widthOnly) {
122
+ ourText.css('font-size', WfontSize);
123
+ } else {
124
+ ourText.css('font-size', Math.min(HfontSize, WfontSize));
125
+ }
126
+ _debug('Final: ' + ourText.css('font-size'));
127
+
128
+ if (ourText.width() > maxWidth
129
+ || (ourText.height() > maxHeight && !Opts.widthOnly)
130
+ ) {
131
+ ourText.css('font-size', oldFontSize);
132
+ if (Opts.fail) {
133
+ Opts.fail(this);
134
+ }
135
+ } else if (Opts.success) {
136
+ Opts.success(this);
137
+ } else if (Opts.callback) {
138
+ _warn('callback is deprecated, use success, instead');
139
+ // call callback on each result
140
+ Opts.callback(this);
141
+ }
142
+ });
143
+
144
+ // call complete when all is complete
145
+ if (Opts.complete) Opts.complete(this);
146
+
147
+ return this;
148
+ };
149
+ })(window.jQuery);
assets/lib/jquery-textfill/jquery.textfill.min.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ textfill
3
+ @name jquery.textfill.js
4
+ @author Russ Painter
5
+ @author Yu-Jie Lin
6
+ @version 0.4.0
7
+ @date 2013-08-16
8
+ @copyright (c) 2012-2013 Yu-Jie Lin
9
+ @copyright (c) 2009 Russ Painter
10
+ @license MIT License
11
+ @homepage https://github.com/jquery-textfill/jquery-textfill
12
+ @example http://jquery-textfill.github.io/jquery-textfill/index.html
13
+ */
14
+ (function(e){e.fn.textfill=function(q){function m(){a.debug&&("undefined"!=typeof console&&"undefined"!=typeof console.debug)&&console.debug.apply(console,arguments)}function r(){"undefined"!=typeof console&&"undefined"!=typeof console.warn&&console.warn.apply(console,arguments)}function n(a,b,d,h,f,k){function c(a,b){var c=" / ";a>b?c=" > ":a==b&&(c=" = ");return c}m(a+"font: "+b.css("font-size")+", H: "+b.height()+c(b.height(),d)+d+", W: "+b.width()+c(b.width(),h)+h+", minFontPixels: "+f+", maxFontPixels: "+
15
+ k)}function p(a,b,d,h,f,k,c,l){for(n(a+": ",b,f,k,c,l);c<l-1;){var e=Math.floor((c+l)/2);b.css("font-size",e);if(d.call(b)<=h){if(c=e,d.call(b)==h)break}else l=e;n(a+": ",b,f,k,c,l)}b.css("font-size",l);d.call(b)<=h&&(c=l,n(a+"* ",b,f,k,c,l));return c}var a=e.extend({debug:!1,maxFontPixels:40,minFontPixels:4,innerTag:"span",widthOnly:!1,success:null,callback:null,fail:null,complete:null,explicitWidth:null,explicitHeight:null},q);this.each(function(){var g=e(a.innerTag+":visible:first",this),b=a.explicitHeight||
16
+ e(this).height(),d=a.explicitWidth||e(this).width(),h=g.css("font-size");m("Opts: ",a);m("Vars: maxHeight: "+b+", maxWidth: "+d);var f=a.minFontPixels,k=0>=a.maxFontPixels?b:a.maxFontPixels,c=void 0;a.widthOnly||(c=p("H",g,e.fn.height,b,b,d,f,k));f=p("W",g,e.fn.width,d,b,d,f,k);a.widthOnly?g.css("font-size",f):g.css("font-size",Math.min(c,f));m("Final: "+g.css("font-size"));g.width()>d||g.height()>b&&!a.widthOnly?(g.css("font-size",h),a.fail&&a.fail(this)):a.success?a.success(this):a.callback&&(r("callback is deprecated, use success, instead"),
17
+ a.callback(this))});a.complete&&a.complete(this);return this}})(window.jQuery);
assets/lib/jquery-textfill/js/index.js ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function update() {
2
+ var size = parseInt($('#maxsize').val(), 10);
3
+ if (!isNaN(size)) {
4
+ $('.dyntextval').html($('#dyntext').val());
5
+ $('.jtextfill').textfill({debug: true, maxFontPixels: size});
6
+ }
7
+ }
8
+
9
+ $(function () {
10
+ $('#maxsize').keyup(update);
11
+ $('#dyntext').keyup(update);
12
+ update()
13
+ });
assets/lib/jquery-textfill/js/tests.js ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var JTF = 'jtf';
2
+
3
+
4
+ function setup(opts) {
5
+ var $t = $('#qunit-fixture');
6
+ var $d = $('<div/>', opts.div).appendTo($t);
7
+ var $s = $('<span/>', opts.span).appendTo($d);
8
+ }
9
+
10
+
11
+ test('capped at 10px', function () {
12
+ setup({
13
+ div: {
14
+ id: JTF,
15
+ width: 285,
16
+ height: 210
17
+ },
18
+ span: {
19
+ css: {
20
+ 'font-family': 'VT323',
21
+ },
22
+ text: 'test'
23
+ }
24
+ });
25
+
26
+ var $jtf = $('#' + JTF);
27
+ var $span = $jtf.find('span');
28
+ $jtf.textfill({debug: true, maxFontPixels: 10});
29
+ equal($span.css('font-size'), '10px');
30
+ });
31
+
32
+
33
+ test('size up to max', function () {
34
+ setup({
35
+ div: {
36
+ id: JTF,
37
+ width: 285,
38
+ height: 210
39
+ },
40
+ span: {
41
+ css: {
42
+ 'font-family': 'VT323',
43
+ },
44
+ text: 'test'
45
+ }
46
+ });
47
+
48
+ var $jtf = $('#' + JTF);
49
+ var $span = $jtf.find('span');
50
+ $jtf.textfill({debug: true, maxFontPixels: 0});
51
+ equal($span.css('font-size'), '172px');
52
+ });
53
+
54
+
55
+ test('width be maxWidth', function () {
56
+ setup({
57
+ div: {
58
+ id: JTF,
59
+ width: 196,
60
+ height: 210
61
+ },
62
+ span: {
63
+ css: {
64
+ 'font-family': 'VT323',
65
+ },
66
+ text: 'test'
67
+ }
68
+ });
69
+
70
+ var $jtf = $('#' + JTF);
71
+ var $span = $jtf.find('span');
72
+ $jtf.textfill({debug: true, maxFontPixels: 0});
73
+ equal($span.css('font-size'), '119px');
74
+ });
75
+
76
+
77
+ test('height be maxHeight', function () {
78
+ setup({
79
+ div: {
80
+ id: JTF,
81
+ width: 285,
82
+ height: 158
83
+ },
84
+ span: {
85
+ css: {
86
+ 'font-family': 'VT323',
87
+ },
88
+ text: 'test'
89
+ }
90
+ });
91
+
92
+ var $jtf = $('#' + JTF);
93
+ var $span = $jtf.find('span');
94
+ $jtf.textfill({debug: true, maxFontPixels: 0});
95
+ equal($span.css('font-size'), '158px');
96
+ });
97
+
98
+
99
+ test('minFontPixels too big to fit in', function () {
100
+ setup({
101
+ div: {
102
+ id: JTF,
103
+ width: 40,
104
+ height: 40
105
+ },
106
+ span: {
107
+ css: {
108
+ 'font-family': 'VT323',
109
+ 'font-size': '20px',
110
+ },
111
+ text: 'test'
112
+ }
113
+ });
114
+
115
+ var $jtf = $('#' + JTF);
116
+ var $span = $jtf.find('span');
117
+ $jtf.textfill({debug: true, minFontPixels: 100, maxFontPixels: 0});
118
+ equal($span.css('font-size'), '20px');
119
+ });
120
+
121
+
122
+ test('minFontPixels too big to fit in, but widthOnly = True and width fits', function () {
123
+ // @ fontSize = 60 => H > 10, W = 100
124
+ setup({
125
+ div: {
126
+ id: JTF,
127
+ // just enough to fit in with minFontPixels
128
+ width: 100,
129
+ // H is busted, but widthOnly = True, so ignored
130
+ height: 10
131
+ },
132
+ span: {
133
+ css: {
134
+ 'font-family': 'VT323',
135
+ 'font-size': '20px',
136
+ },
137
+ text: 'test'
138
+ }
139
+ });
140
+
141
+ var $jtf = $('#' + JTF);
142
+ var $span = $jtf.find('span');
143
+ $jtf.textfill({
144
+ debug: true,
145
+ minFontPixels: 20,
146
+ maxFontPixels: 100,
147
+ widthOnly: true
148
+ });
149
+ equal($span.css('font-size'), '60px');
150
+ });
151
+
152
+
153
+ test('minFontPixels too big to fit in, W/H both fail, even widthOnly = True', function () {
154
+ setup({
155
+ div: {
156
+ id: JTF,
157
+ width: 10,
158
+ height: 10
159
+ },
160
+ span: {
161
+ css: {
162
+ 'font-family': 'VT323',
163
+ 'font-size': '20px',
164
+ },
165
+ text: 'test'
166
+ }
167
+ });
168
+
169
+ var $jtf = $('#' + JTF);
170
+ var $span = $jtf.find('span');
171
+ $jtf.textfill({
172
+ debug: true,
173
+ minFontPixels: 20,
174
+ maxFontPixels: 100,
175
+ widthOnly: true
176
+ });
177
+ equal($span.css('font-size'), '20px');
178
+ });
179
+
180
+
181
+ /*************/
182
+ /* callbacks */
183
+ /*************/
184
+
185
+ test('success callback', 1, function() {
186
+ setup({
187
+ div: {
188
+ id: JTF,
189
+ width: 285,
190
+ height: 210
191
+ },
192
+ span: {
193
+ css: {
194
+ 'font-family': 'VT323',
195
+ },
196
+ text: 'test'
197
+ }
198
+ });
199
+
200
+ var $jtf = $('#' + JTF);
201
+ var $span = $jtf.find('span');
202
+ $jtf.textfill({
203
+ debug: true,
204
+ maxFontPixels: 0,
205
+ success: function(e) {
206
+ equal(e, $jtf[0]);
207
+ }
208
+ });
209
+ });
210
+
211
+
212
+ test('callback callback (deprecated)', 1, function() {
213
+ setup({
214
+ div: {
215
+ id: JTF,
216
+ width: 285,
217
+ height: 210
218
+ },
219
+ span: {
220
+ css: {
221
+ 'font-family': 'VT323',
222
+ },
223
+ text: 'test'
224
+ }
225
+ });
226
+
227
+ var $jtf = $('#' + JTF);
228
+ var $span = $jtf.find('span');
229
+ $jtf.textfill({
230
+ debug: true,
231
+ maxFontPixels: 0,
232
+ callback: function(e) {
233
+ equal(e, $jtf[0]);
234
+ }
235
+ });
236
+ });
237
+
238
+
239
+ test('fail callback', 1, function () {
240
+ setup({
241
+ div: {
242
+ id: JTF,
243
+ width: 40,
244
+ height: 40
245
+ },
246
+ span: {
247
+ css: {
248
+ 'font-family': 'VT323',
249
+ 'font-size': '20px',
250
+ },
251
+ text: 'test'
252
+ }
253
+ });
254
+
255
+ var $jtf = $('#' + JTF);
256
+ var $span = $jtf.find('span');
257
+ $jtf.textfill({
258
+ debug: true,
259
+ minFontPixels: 100,
260
+ maxFontPixels: 0,
261
+ fail: function(e) {
262
+ equal(e, $jtf[0]);
263
+ }
264
+ });
265
+ });
266
+
267
+
268
+ test('complete callback', 2, function() {
269
+ setup({
270
+ div: {
271
+ id: JTF,
272
+ width: 285,
273
+ height: 210
274
+ },
275
+ span: {
276
+ css: {
277
+ 'font-family': 'VT323',
278
+ },
279
+ text: 'test'
280
+ }
281
+ });
282
+
283
+ var $jtf = $('#' + JTF);
284
+ $jtf.textfill({
285
+ debug: true,
286
+ maxFontPixels: 0,
287
+ callback: function(e) {
288
+ equal(e, $jtf[0]);
289
+ },
290
+ complete: function(e) {
291
+ equal(e, $jtf);
292
+ }
293
+ });
294
+ });
295
+
296
+
297
+ /****************/
298
+ /* debug option */
299
+ /****************/
300
+
301
+ module('debug option', {
302
+ setup: function () {
303
+ if (console.debug_original) {
304
+ throw 'console.debug_original already has value.';
305
+ }
306
+ console.debug_original = console.debug;
307
+ console.debug_called = false;
308
+ console.debug = function () {
309
+ console.debug_called = true;
310
+ }
311
+ },
312
+ teardown: function () {
313
+ if (!console.debug_original) {
314
+ throw 'console.debug_original is empty.';
315
+ }
316
+ console.debug = console.debug_original;
317
+ console.debug_original = undefined;
318
+ console.debug_called = undefined;
319
+ }
320
+ });
321
+
322
+
323
+ test('debug used', function () {
324
+ setup({
325
+ div: {
326
+ id: JTF,
327
+ width: 285,
328
+ height: 210
329
+ },
330
+ span: {
331
+ css: {
332
+ 'font-family': 'VT323',
333
+ },
334
+ text: 'test'
335
+ }
336
+ });
337
+
338
+ var $jtf = $('#' + JTF);
339
+ $jtf.textfill({debug: true, maxFontPixels: 10});
340
+ equal(console.debug_called, true);
341
+ });
342
+
343
+
344
+ test('debug not used', function () {
345
+ setup({
346
+ div: {
347
+ id: JTF,
348
+ width: 285,
349
+ height: 210
350
+ },
351
+ span: {
352
+ css: {
353
+ 'font-family': 'VT323',
354
+ },
355
+ text: 'test'
356
+ }
357
+ });
358
+
359
+ var $jtf = $('#' + JTF);
360
+ $jtf.textfill({debug: false, maxFontPixels: 10});
361
+ equal(console.debug_called, false);
362
+ });
363
+
364
+
assets/lib/jquery-textfill/tests.html ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>Tests of jQuery Plugin: Text Fill</title>
6
+ <link href='http://fonts.googleapis.com/css?family=VT323' rel='stylesheet' type='text/css'/>
7
+ <link href='http://code.jquery.com/qunit/qunit-1.11.0.css' rel='stylesheet' type='text/css'/>
8
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
9
+ <script src='http://code.jquery.com/qunit/qunit-1.11.0.js'></script>
10
+ <script src='jquery.textfill.js'></script>
11
+ <script src='js/tests.js'></script>
12
+ </head>
13
+ <body>
14
+ <div id="qunit"></div>
15
+ <div id="qunit-fixture"></div>
16
+ </body>
17
+ </html>
assets/lib/jquery-textfill/textfill.jquery.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "textfill",
3
+ "version": "0.4.0",
4
+ "title": "jQuery TextFill",
5
+ "author": {
6
+ "name": "jQuery TextFill contributors",
7
+ "url": "https://github.com/jquery-textfill/jquery-textfill"
8
+ },
9
+ "licenses": [
10
+ {
11
+ "type": "MIT",
12
+ "url": "https://github.com/jquery-textfill/jquery-textfill/blob/master/COPYING"
13
+ }
14
+ ],
15
+ "dependencies": {
16
+ "jquery": "*"
17
+ },
18
+
19
+ "description": "Resizing text to fit into container.",
20
+ "keywords": [
21
+ "resize",
22
+ "text"
23
+ ],
24
+ "homepage": "https://github.com/jquery-textfill/jquery-textfill",
25
+ "docs": "https://github.com/jquery-textfill/jquery-textfill",
26
+ "demo": "http://jquery-textfill.github.io/jquery-textfill/index.html",
27
+ "bugs": "https://github.com/jquery-textfill/jquery-textfill/issues",
28
+ "maintainers": [
29
+ {
30
+ "name": "Yu-Jie Lin",
31
+ "email": "livibetter@gmail.com",
32
+ "url": "http://yjl.im"
33
+ }
34
+ ]
35
+ }
assets/screenshot-1.png ADDED
Binary file
assets/screenshot-2.png ADDED
Binary file
assets/screenshot-3.png ADDED
Binary file
assets/screenshot-4.png ADDED
Binary file
assets/screenshot-5.png ADDED
Binary file
controller/SBTT_AdminMenuController.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SBTT Admin Menu Controller class
4
+ *
5
+ * @author Joe Sexton <joe@josephmsexton.com>
6
+ * @package WordPress
7
+ * @subpackage scroll-back-to-top
8
+ */
9
+ if ( !class_exists( 'SBTT_AdminMenuController' ) ){
10
+ class SBTT_AdminMenuController extends JmsAdminSettingsPage {
11
+
12
+ /**
13
+ * register Wordpress actions and filters
14
+ */
15
+ protected function _init() {
16
+
17
+ $options = new SBTT_Options();
18
+ $this->addOptionsPage(
19
+ __( 'Scroll Back to Top Settings', $this->textDomain() ),
20
+ __( 'Scroll Back to Top', $this->textDomain() ),
21
+ $options
22
+ );
23
+ }
24
+
25
+ /**
26
+ * enqueue admin scripts
27
+ */
28
+ public function enqueueAdminScripts() {
29
+
30
+ $this->enqueueScript( 'sbtt-admin', 'admin' );
31
+ }
32
+
33
+ /**
34
+ * enqueue admin styles
35
+ */
36
+ public function enqueueAdminStyles() {
37
+ $this->enqueueCdnStyle( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' );
38
+ }
39
+
40
+ /**
41
+ * on plugin activation init default options
42
+ */
43
+ public function onActivation() {
44
+
45
+ $this->options->initDefaultOptions();
46
+ }
47
+ }
48
+ }
controller/SBTT_FrontendController.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SBTT Frontend Controller class
4
+ *
5
+ * @author Joe Sexton <joe@josephmsexton.com>
6
+ * @package WordPress
7
+ * @subpackage scroll-back-to-top
8
+ */
9
+ if ( !class_exists( 'SBTT_FrontEndController' ) ){
10
+ class SBTT_FrontEndController extends JmsController {
11
+
12
+ /**
13
+ * @var array
14
+ */
15
+ protected $args;
16
+
17
+ /**
18
+ * @var SBTT_Options
19
+ */
20
+ protected $options;
21
+
22
+ /**
23
+ * Register Wordpress actions and filters
24
+ */
25
+ protected function _init() {
26
+
27
+ $this->options = new SBTT_Options();
28
+ $this->args = $this->_getScrollButtonArgs();
29
+
30
+ $this->_preprocessArgs();
31
+
32
+ add_action('wp_head', array( $this, 'headSection' ) );
33
+ add_action('wp_footer', array( $this, 'footerSection' ) );
34
+ }
35
+
36
+ /**
37
+ * Enqueue scripts
38
+ *
39
+ * @return false if not enabled
40
+ */
41
+ public function enqueueScripts(){
42
+
43
+ if ( !$this->isAuthorized() ) {
44
+ return false;
45
+ }
46
+
47
+ $dependencies = array( 'jquery' );
48
+ $vars = array( 'scrollBackToTop' => array() );
49
+
50
+ if ( isset($this->args['scroll_duration']) ) {
51
+ $vars['scrollBackToTop']['scrollDuration'] = $this->args['scroll_duration'];
52
+ }
53
+
54
+ if ( isset($this->args['fade_duration']) ) {
55
+ $vars['scrollBackToTop']['fadeDuration'] = $this->args['fade_duration'];
56
+ }
57
+
58
+ // load textfill js only if using auto font sizing
59
+ if ( isset($this->args['label_type']) && isset($this->args['font_size']) && $this->args['font_size'] == '0px' ) {
60
+ $this->enqueueCdnScript('text-fill', 'http://jquery-textfill.github.io/jquery-textfill/jquery.textfill.min.js' );
61
+ $dependencies = array( 'jquery', 'text-fill' );
62
+ $vars['scrollBackToTop']['autoFontSize'] = true;
63
+ }
64
+
65
+ $this->enqueueScript( 'scroll-back-to-top', 'scroll-back-to-top', $dependencies, null, true, $vars );
66
+ }
67
+
68
+ /**
69
+ * Enqueue styles
70
+ *
71
+ * @return false if not enabled
72
+ */
73
+ public function enqueueStyles(){
74
+
75
+ if ( !$this->isAuthorized() ) {
76
+ return false;
77
+ }
78
+
79
+ // Only need the font pack if using icons, not text
80
+ if ( isset( $this->args['label_type'] ) && $this->args['label_type'] != 'text' ) {
81
+ $this->enqueueCdnStyle( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' );
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Render head markup
87
+ *
88
+ * @return false if not enabled
89
+ */
90
+ public function headSection(){
91
+
92
+ if ( !$this->isAuthorized() ) {
93
+ return false;
94
+ }
95
+
96
+ echo apply_filters( 'sbtt_styles', $this->render( 'dynamic-styles', $this->args, false ) );
97
+ }
98
+
99
+ /**
100
+ * Render footer markup
101
+ *
102
+ * @return false if not enabled
103
+ */
104
+ public function footerSection(){
105
+
106
+ if ( !$this->isAuthorized() ) {
107
+ return false;
108
+ }
109
+
110
+ echo apply_filters( 'sbtt_button_markup', $this->render( 'scroll-button', $this->args, false ) );
111
+ }
112
+
113
+ /**
114
+ * Get options
115
+ *
116
+ * @return array
117
+ */
118
+ protected function _getScrollButtonArgs() {
119
+
120
+ return get_option( $this->options->optionsKey() );
121
+ }
122
+
123
+ /**
124
+ * Preprocess variables
125
+ */
126
+ protected function _preprocessArgs() {
127
+
128
+ $this->_processFade();
129
+ $this->_processHorizontalAlignment();
130
+ $this->_processVerticalAlignment();
131
+ $this->_processVerticalAlignment();
132
+ $this->_processBorderRadii();
133
+ $this->_processSize();
134
+ $this->_processOpacity();
135
+ $this->_processIconSize();
136
+ }
137
+
138
+ /**
139
+ * Process fade
140
+ */
141
+ protected function _processFade(){
142
+
143
+ if ( isset( $this->args['fade_duration'] ) ) {
144
+ $this->args['fade_duration'] = number_format( ( $this->args['fade_duration'] ) / 1000, 1 );
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Process horizontal alignment
150
+ */
151
+ protected function _processHorizontalAlignment(){
152
+
153
+ if ( isset( $this->args['align_x'] ) && isset( $this->args['margin_x'] )) {
154
+
155
+ if ( $this->args['align_x'] == 'right' ) {
156
+
157
+ $this->args['css_right'] = $this->args['margin_x'] . 'px';
158
+
159
+ } elseif ( $this->args['align_x'] == 'left' ) {
160
+
161
+ $this->args['css_left'] = $this->args['margin_x'] . 'px';
162
+
163
+ } elseif ( $this->args['align_x'] == 'center' ) {
164
+
165
+ $this->args['css_left'] = '50%';
166
+ $this->args['margin_left'] = isset( $this->args['size_w'] ) ? (string)( $this->args['size_w'] / -2 ) . 'px' : '0px';
167
+ }
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Process vertical alignment
173
+ */
174
+ protected function _processVerticalAlignment(){
175
+
176
+ if ( isset( $this->args['align_y'] ) && isset( $this->args['margin_y'] )) {
177
+
178
+ if ( $this->args['align_y'] == 'bottom' ) {
179
+
180
+ $this->args['css_bottom'] = $this->args['margin_y'] . 'px';
181
+
182
+ } elseif ( $this->args['align_y'] == 'top' ) {
183
+
184
+ $this->args['css_top'] = $this->args['margin_y'] . 'px';
185
+
186
+ }
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Process border radii
192
+ */
193
+ protected function _processBorderRadii(){
194
+
195
+ // Border Radius
196
+ // Because the button could be touching the edge of the screen,
197
+ // check that margin is greater than border radius for corners that touch.
198
+ if (
199
+ !isset( $this->args['border_radius'] ) ||
200
+ !isset( $this->args['align_x'] ) ||
201
+ !isset( $this->args['align_y'] ) ||
202
+ !isset( $this->args['margin_x'] ) ||
203
+ !isset( $this->args['margin_y'] )
204
+ ) {
205
+ return false;
206
+ }
207
+
208
+ $x_sides = array( 'left', 'right' );
209
+ $y_sides = array( 'top', 'bottom' );
210
+
211
+ foreach ( $x_sides as $x_side ) {
212
+ foreach ( $y_sides as $y_side ) {
213
+
214
+ if (
215
+ !( $this->args['align_x'] == $x_side && $this->args['margin_x'] == 0 ) && // touching left or right
216
+ !( $this->args['align_y'] == $y_side && $this->args['margin_y'] == 0 ) // touching top or bottom
217
+ ) {
218
+ $this->args["border_radius_{$y_side}_{$x_side}"] = (string)$this->args['border_radius'] . 'px';
219
+ }
220
+ }
221
+ }
222
+
223
+ return true;
224
+ }
225
+
226
+ /**
227
+ * Process size
228
+ */
229
+ protected function _processSize(){
230
+
231
+ if ( isset( $this->args['size_w'] ) ) {
232
+ $this->args['size_w'] = (string)$this->args['size_w'] . 'px';
233
+ }
234
+ if ( isset( $this->args['size_h'] ) ) {
235
+ $this->args['size_h'] = (string)($this->args['size_h'] - 2) . 'px';
236
+ $this->args['padding_top'] = '2px';
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Process opacity
242
+ */
243
+ protected function _processOpacity(){
244
+
245
+ if ( isset( $this->ar