ratchet_design 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/ratchet/favicon.ico +0 -0
  3. data/app/assets/javascripts/ratchet/base/form.js +117 -8
  4. data/app/assets/javascripts/ratchet/base/mobilemenu.js +50 -12
  5. data/app/assets/javascripts/ratchet/base/validation.js +263 -0
  6. data/app/assets/javascripts/ratchet/core.js +78 -57
  7. data/app/assets/javascripts/ratchet/enhancement/_collapse.js +6 -3
  8. data/app/assets/javascripts/ratchet/enhancement/_lightbox.js +93 -0
  9. data/app/assets/javascripts/ratchet/enhancement/_swap.js +7 -3
  10. data/app/assets/javascripts/ratchet/{utility → enhancement}/loader.js +8 -15
  11. data/app/assets/javascripts/ratchet/enhancement/notice.js +3 -8
  12. data/app/assets/javascripts/ratchet/enhancement/sticky.js +35 -18
  13. data/app/assets/javascripts/ratchet/enhancement/waypoints.js +162 -125
  14. data/app/assets/javascripts/ratchet/shim/classlist.js +234 -0
  15. data/app/assets/javascripts/ratchet/shim/object.assign.js +30 -0
  16. data/app/assets/javascripts/ratchet/utility/ajax.js +122 -0
  17. data/app/assets/javascripts/ratchet/utility/compile_data.js +40 -0
  18. data/app/assets/javascripts/ratchet/utility/from_top.js +14 -0
  19. data/app/assets/javascripts/ratchet/utility/full_stop.js +55 -0
  20. data/app/assets/javascripts/ratchet/utility/get_closest.js +20 -0
  21. data/app/assets/javascripts/ratchet/utility/get_next.js +17 -0
  22. data/app/assets/javascripts/ratchet/utility/matches.js +15 -0
  23. data/app/assets/javascripts/ratchet/utility/scroll_to.js +74 -0
  24. data/app/assets/javascripts/ratchet/utility/throttle.js +25 -0
  25. data/app/assets/javascripts/ratchet/utility/timeout.js +45 -0
  26. data/app/assets/javascripts/ratchet/utility/unhover.js +56 -0
  27. data/app/assets/javascripts/ratchet/utility/word_count.js +15 -0
  28. data/app/assets/stylesheets/ratchet/_core.scss +2 -4
  29. data/app/assets/stylesheets/ratchet/base/_button.scss +1 -1
  30. data/app/assets/stylesheets/ratchet/base/_form.scss +50 -61
  31. data/app/assets/stylesheets/ratchet/base/_text.scss +8 -8
  32. data/app/assets/stylesheets/ratchet/{utility → enhancement}/_loader.scss +1 -1
  33. data/app/assets/stylesheets/ratchet/enhancement/_tooltip.scss +1 -6
  34. data/app/assets/stylesheets/ratchet/utility/_global.scss +12 -2
  35. data/app/helpers/ratchet/application_helper.rb +2 -28
  36. data/app/views/layouts/ratchet/default.html.slim +4 -5
  37. data/app/views/shared/ratchet/_footer.html.slim +2 -3
  38. data/app/views/shared/ratchet/_header.html.slim +1 -1
  39. data/lib/ratchet_design/version.rb +1 -1
  40. data/lib/ratchet_design.rb +0 -1
  41. data/public/assets/ratchet/core-0.1.6.js +105 -0
  42. data/public/assets/ratchet/core-0.1.6.js.gz +0 -0
  43. data/public/assets/ratchet/core-0.1.6.map.json +1 -0
  44. data/public/assets/ratchet/{fonts-woff-0.1.5.css → fonts-woff-0.1.6.css} +0 -0
  45. data/public/assets/ratchet/{fonts-woff-0.1.5.css.gz → fonts-woff-0.1.6.css.gz} +0 -0
  46. data/public/assets/ratchet/{fonts-woff2-0.1.5.css → fonts-woff2-0.1.6.css} +0 -0
  47. data/public/assets/ratchet/{fonts-woff2-0.1.5.css.gz → fonts-woff2-0.1.6.css.gz} +0 -0
  48. metadata +28 -47
  49. data/app/assets/images/ratchet/safari-pinned-tab.svg +0 -1
  50. data/app/assets/javascripts/ratchet/base/sync-input-value.js +0 -30
  51. data/app/assets/javascripts/ratchet/enhancement/lightbox.js +0 -165
  52. data/app/assets/javascripts/ratchet/shim/scope.js +0 -94
  53. data/app/assets/stylesheets/ratchet/base/_multistep-form.scss +0 -64
  54. data/app/assets/stylesheets/ratchet/enhancement/_lightbox.scss +0 -98
  55. data/app/helpers/ratchet/form_helper.rb +0 -140
  56. data/public/assets/ratchet/core-0.1.5.js +0 -133
  57. data/public/assets/ratchet/core-0.1.5.js.gz +0 -0
  58. data/public/assets/ratchet/core-0.1.5.map.json +0 -1
@@ -1,76 +1,97 @@
1
+ // Shim modules
2
+ require( './shim/classlist' );
3
+ require( './shim/object.assign' );
4
+
1
5
  // Utility modules
2
- var loadFont = require( './utility/load_font' )
3
- var loadScript = require( './utility/load_script' )
6
+ var loadFont = require( './utility/load_font' );
7
+ var fullStop = require( './utility/full_stop' );
8
+ var unhover = require( './utility/unhover' );
9
+ var throttle = require( './utility/throttle' );
10
+ var loadScript = require( './utility/load_script' );
11
+ var fromTop = require( './utility/from_top' );
12
+ var scrollTo = require( './utility/scroll_to' );
13
+ var matches = require( './utility/matches' );
14
+ var getClosest = require( './utility/get_closest' );
15
+ var getNext = require( './utility/get_next' );
16
+ var wordCount = require( './utility/word_count' );
17
+ var compileData = require( './utility/compile_data' );
18
+ var timeout = require( './utility/timeout' );
19
+ var ajax = require( './utility/ajax' );
4
20
 
5
21
  // Base modules
6
- var mobileMenu = require( './base/mobilemenu' )
7
- var form = require( './base/form' )
8
- var formUp = require( 'compose-form-up' )
9
- form.validate = formUp.validate
10
- form.next = formUp.next
11
- require( './base/sync-input-value' )
22
+ var mobileMenu = require( './base/mobilemenu' );
23
+ var form = require( './base/form' );
24
+ var validation = require( './base/validation' );
12
25
 
13
26
  // Enhancement modules
14
- var waypoints = require( './enhancement/waypoints' )
15
- var notice = require( './enhancement/notice' )
16
- var sticky = require( './enhancement/sticky' )
17
- var lightbox = require( './enhancement/lightbox' )
18
- var esvg = require( './_svg' )
27
+ var loader = require( './enhancement/loader' );
28
+ var waypoints = require( './enhancement/waypoints' );
29
+ var notice = require( './enhancement/notice' );
30
+ var sticky = require( './enhancement/sticky' );
31
+ var esvg = require( './_svg' );
19
32
  // var swap = require( './enhancement/swap' );
20
33
 
21
34
  // Vendor modules
22
- var toolbox = require( 'compose-toolbox' )
23
- var event = toolbox.event
24
- var ajax = require( 'superagent' )
25
- var rangeTouch = require( 'rangetouch' )
26
- var highlighter = require( 'compose-code-highlighter' )
27
- var loader = require( 'compose-loader' )
28
-
29
- require( 'codemirror/mode/htmlmixed/htmlmixed' )
30
- require( 'codemirror/mode/slim/slim' )
31
- require( 'codemirror/mode/javascript/javascript' )
32
- require( 'codemirror/mode/css/css' )
33
- require( 'codemirror/mode/sql/sql' )
34
- require( 'codemirror/mode/php/php' )
35
- require( 'codemirror/mode/ruby/ruby' )
36
- require( 'codemirror/mode/shell/shell' )
37
- require( 'codemirror/mode/go/go' )
38
- require( 'codemirror/mode/python/python' )
39
- require( 'codemirror/mode/yaml/yaml' )
40
- require( 'codemirror/mode/clike/clike' )
41
- require( 'codemirror/addon/runmode/runmode' )
42
- require( 'codemirror/addon/edit/matchbrackets' )
43
-
44
- // Initialize component features
45
- rangeTouch.set("thumbWidth", 20); // Annoying hack to make input ranges work smoothly on touch devices
46
-
47
- event.scroll.disablePointer() // disable pointer events on scroll for performance (to avoid extra repaints)
48
- event.resize.disableAnimation() // disable animation on resize for performance (to avoid extra repaints)
49
-
50
- // Trigger these events each time the page loads
51
- event.change( function() {
52
-
53
- // Form module
54
- form()
55
-
56
- // Syntax highlighting
57
- highlighter.highlight()
58
- });
35
+ var event = require( 'compose-event' );
36
+ var highlighter = require( 'compose-code-highlighter' );
37
+ require( 'codemirror/mode/htmlmixed/htmlmixed' );
38
+ require( 'codemirror/mode/slim/slim' );
39
+ require( 'codemirror/mode/javascript/javascript' );
40
+ require( 'codemirror/mode/css/css' );
41
+ require( 'codemirror/mode/sql/sql' );
42
+ require( 'codemirror/mode/php/php' );
43
+ require( 'codemirror/mode/ruby/ruby' );
44
+ require( 'codemirror/mode/shell/shell' );
45
+ require( 'codemirror/mode/go/go' );
46
+ require( 'codemirror/mode/python/python' );
47
+ require( 'codemirror/mode/yaml/yaml' );
48
+ require( 'codemirror/mode/clike/clike' );
49
+ require( 'codemirror/addon/runmode/runmode' );
50
+ require( 'codemirror/addon/edit/matchbrackets' );
59
51
 
60
52
  // Public API object
61
- var ratchet = toolbox.merge( {
53
+ window.ratchet = module.exports = {
62
54
  loadFont : loadFont,
55
+ fullStop : fullStop,
56
+ unhover : unhover,
57
+ throttle : throttle,
63
58
  loadScript : loadScript,
59
+ fromTop : fromTop,
60
+ scrollTo : scrollTo,
61
+ matches : matches,
62
+ getClosest : getClosest,
63
+ getNext : getNext,
64
+ wordCount : wordCount,
65
+ compileData : compileData,
66
+ timeout : timeout,
64
67
  ajax : ajax,
65
- loader : loader,
66
68
  mobileMenu : mobileMenu,
67
69
  form : form,
68
- validation : formUp.validate,
70
+ validation : validation,
71
+ loader : loader,
69
72
  waypoints : waypoints,
70
73
  notice : notice,
71
74
  sticky : sticky,
72
- lightbox : lightbox,
73
- esvg : esvg
74
- }, toolbox )
75
+ esvg : esvg,
76
+ event : event
77
+ }
78
+
79
+ // Default events instantiation
80
+ event.change( function() {
81
+
82
+ // Unhover module
83
+ unhover();
84
+
85
+ // FullStop module
86
+ fullStop();
87
+
88
+ // Form module
89
+ form();
90
+
91
+ // Validation module
92
+ validation();
93
+
94
+ // Syntax highlighting
95
+ highlighter.highlight();
75
96
 
76
- window.ratchet = module.exports = ratchet
97
+ }, false );
@@ -5,6 +5,9 @@
5
5
  * @license MIT
6
6
  **/
7
7
 
8
+ // Dependencies
9
+ var getClosest = require('../utility/get_closest')
10
+
8
11
  ;( function( root, factory ) {
9
12
  if ( typeof define === 'function' && define.amd ) {
10
13
  define( factory );
@@ -26,7 +29,7 @@
26
29
  defaults = {
27
30
  expandText : 'Show more ∨',
28
31
  collapseText : 'Show less ∧',
29
- triggerText : '{{ more }}'
32
+ triggerText : ' '
30
33
  };
31
34
 
32
35
  // Only run if selector exists
@@ -74,7 +77,7 @@
74
77
  event.preventDefault();
75
78
 
76
79
  // Scoped variables
77
- var expandable = compose.getClosest( event.target, element ),
80
+ var expandable = getClosest( event.target, element ),
78
81
  stateObject = state[ expandable.dataset.idx ];
79
82
 
80
83
  // Toggle between excerpt and full text
@@ -90,4 +93,4 @@
90
93
  // Public API
91
94
  return exports;
92
95
 
93
- });
96
+ });
@@ -0,0 +1,93 @@
1
+ Event = require('compose-event')
2
+ /**
3
+ * Lightbox.js 0.0.2
4
+ * A lightbox plugin that makes sense
5
+ * @author Kyle Foster (@hkfoster)
6
+ * @license MIT
7
+ **/
8
+
9
+ // Transport
10
+ ( function( root, factory ) {
11
+ if ( typeof define === 'function' && define.amd ) {
12
+ define( factory );
13
+ } else if ( typeof exports === 'object' ) {
14
+ module.exports = factory;
15
+ } else {
16
+ root.lightbox = factory( root );
17
+ }
18
+ })( this, function( root ) {
19
+
20
+ 'use strict';
21
+
22
+ // Define global variable(s)
23
+ var lightboxTrigger = document.querySelectorAll( '[rel="lightbox"]' );
24
+
25
+ // Only run if lightbox trigger is present
26
+ if ( lightboxTrigger ) {
27
+ init();
28
+ }
29
+
30
+ // Where the magic happens
31
+ function init() {
32
+
33
+ // Preload lightbox images
34
+ for ( var imgIndex = 0; imgIndex < lightboxTrigger.length; imgIndex ++ ) {
35
+
36
+ // Create a temporary image element
37
+ var tempImg = new Image();
38
+
39
+ // And use it to load up image(s)
40
+ tempImg.src = lightboxTrigger[ imgIndex ].href;
41
+
42
+ }
43
+
44
+ // Attach our click listener
45
+ Event.on(document, 'click', '[rel="lightbox"]', openLightbox)
46
+
47
+ }
48
+
49
+ // Open lightbox function
50
+ function openLightbox( event ) {
51
+
52
+ // Prevent default behavior/bubbling
53
+ event.stopPropagation();
54
+ event.preventDefault();
55
+
56
+ // Define scoped variable(s)
57
+ var lightboxUrl = event.target.href,
58
+ lightboxCont = '<aside class="lightbox-overlay"><figure class="lightbox-content"><img src="' + lightboxUrl + '" alt=""><a class="close-btn" href="#?"></a></figure></aside>';
59
+
60
+ // Open the lightbox
61
+ document.body.insertAdjacentHTML('beforeend' lightboxCont );
62
+
63
+ // Prevent scrolling while lightbox is shown
64
+ document.body.style.overflow = 'hidden';
65
+
66
+ Event.one('.close-btn', 'click', closeLightbox)
67
+
68
+ }
69
+
70
+ // Close lightbox function
71
+ function closeLightbox( event ) {
72
+
73
+ // Prevent default behavior/bubbling
74
+ event.stopPropagation();
75
+ event.preventDefault();
76
+
77
+ // Define scoped variable(s)
78
+ var lightboxOverlay = document.querySelector( '.lightbox-overlay' ),
79
+ lightboxContent = lightboxOverlay.querySelector( '.lightbox-content' ),
80
+
81
+ // Kick off closing animation
82
+ lightboxContent.className += ' closing';
83
+
84
+ Event.one(lightboxContent, 'animationend', function() {
85
+ // Remove the lightbox from the DOM
86
+ document.body.removeChild( lightboxOverlay );
87
+
88
+ // And turn scrolling back on
89
+ document.body.style.overflow = '';
90
+ })
91
+ }
92
+
93
+ });
@@ -1,9 +1,13 @@
1
1
  /**
2
- * Swap.js 0.0.2
2
+ * Swap 0.0.2
3
+ * Compose swappable element module
3
4
  * @author Kyle Foster (@hkfoster)
4
5
  * @license MIT
5
6
  **/
6
7
 
8
+ // Dependencies
9
+ var ScrollTo = require('../utility/scroll_to')
10
+
7
11
  // Transport
8
12
  ;( function( root, factory ) {
9
13
  if ( typeof define === 'function' && define.amd ) {
@@ -67,7 +71,7 @@
67
71
  } else {
68
72
 
69
73
  // Stop default anchor tag jump
70
- window.scrollTo(0, 0);
74
+ ScrollTo(0, 0);
71
75
 
72
76
  // Assign appropriate element(s) variables
73
77
  var loadedTarget = document.querySelector( '#' + getHash() ),
@@ -113,4 +117,4 @@
113
117
 
114
118
  }
115
119
 
116
- });
120
+ });
@@ -5,8 +5,6 @@
5
5
  * @license MIT
6
6
  **/
7
7
 
8
- var toolbox = require( 'compose-toolbox' )
9
-
10
8
  // Public API function
11
9
  var loader = function( settings ) {
12
10
 
@@ -23,40 +21,35 @@ var loader = function( settings ) {
23
21
  };
24
22
 
25
23
  // Extend defaults
26
- var options = toolbox.merge( defaults, settings );
27
-
28
- // If it doesn’t already exist
29
- if ( !document.querySelector( 'div.' + options.loaderClass ) ) {
30
-
31
- // Create and prepend loader element
32
- options.selector.insertAdjacentHTML( 'afterbegin', '<div class="' + options.loaderClass + '"></div>' );
24
+ var options = Object.assign( {}, defaults, settings );
33
25
 
34
- }
26
+ // Create and prepend loader element
27
+ options.selector.insertAdjacentHTML( 'afterbegin', '<div class="' + options.loaderClass + '"></div>' );
35
28
 
36
29
  // Cache loader element
37
30
  var element = document.querySelector( 'div.' + options.loaderClass );
38
31
 
39
32
  // Show loader icon function
40
- var show = function( state, message ) {
33
+ var show = function( state ) {
41
34
 
42
35
  // Loader pending state
43
36
  if ( state === 'pending' ) {
44
37
 
45
- element.textContent = message || options.loadingMessage;
38
+ element.textContent = options.loadingMessage;
46
39
  element.classList.remove( options.successClass, options.failureClass );
47
40
  element.classList.add( options.loadingClass );
48
41
 
49
42
  // Loader failure state
50
43
  } else if ( state === 'failure' ) {
51
44
 
52
- element.textContent = message || options.failureMessage;
45
+ element.textContent = options.failureMessage;
53
46
  element.classList.remove( options.loadingClass );
54
47
  element.classList.add( options.failureClass );
55
48
 
56
49
  // Loader success state
57
50
  } else if ( state === 'success' ) {
58
51
 
59
- element.textContent = message || options.successMessage;
52
+ element.textContent = options.successMessage;
60
53
  element.classList.remove( options.loadingClass );
61
54
  element.classList.add( options.successClass );
62
55
 
@@ -81,4 +74,4 @@ var loader = function( settings ) {
81
74
  };
82
75
 
83
76
  // Public API
84
- module.exports = loader;
77
+ module.exports = loader;
@@ -5,8 +5,6 @@
5
5
  * @license MIT
6
6
  **/
7
7
 
8
- var toolbox = require( 'compose-toolbox' )
9
-
10
8
  // Public API function
11
9
  var notice = function( element, settings ) {
12
10
 
@@ -18,10 +16,9 @@ var notice = function( element, settings ) {
18
16
  };
19
17
 
20
18
  // Scoped variables
21
- var options = toolbox.merge( defaults, settings ),
19
+ var options = Object.assign( {}, defaults, settings ),
22
20
  selector = document.querySelector( element ),
23
- cookieName = 'dismiss-' + options.noticeName,
24
- button = selector.querySelector( '.' + options.noticeClass + ' .close-btn' );
21
+ cookieName = 'dismiss-' + options.noticeName;
25
22
 
26
23
  // Only run if selector exists & no dismiss cookie is found
27
24
  if ( !selector || getCookie( cookieName ) ) return false;
@@ -34,7 +31,7 @@ var notice = function( element, settings ) {
34
31
  document.querySelector( 'main' ).insertAdjacentHTML( 'afterbegin', html );
35
32
 
36
33
  // Listen for close button click
37
- toolbox.event.on( button , 'click', dismissNotice )
34
+ selector.querySelector( '.' + options.noticeClass + ' > .close-btn' ).addEventListener( 'click', dismissNotice, false );
38
35
 
39
36
  // Dismiss notice on close
40
37
  function dismissNotice( event ) {
@@ -50,8 +47,6 @@ var notice = function( element, settings ) {
50
47
 
51
48
  // Set cookie to prevent it from returning
52
49
  document.cookie = cookieName + '=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/';
53
-
54
- toolbox.event.off( button )
55
50
 
56
51
  }
57
52
 
@@ -6,8 +6,8 @@
6
6
  **/
7
7
 
8
8
  // Dependencies
9
- var toolbox = require( 'compose-toolbox' ),
10
- fromTop = toolbox.fromTop
9
+ var throttle = require( '../utility/throttle' ),
10
+ fromTop = require( '../utility/from_top' );
11
11
 
12
12
  // Public API function
13
13
  var sticky = function( element, settings ) {
@@ -21,7 +21,7 @@ var sticky = function( element, settings ) {
21
21
  };
22
22
 
23
23
  // Scoped variables
24
- var options = toolbox.merge( defaults, settings ),
24
+ var options = Object.assign( {}, defaults, settings ),
25
25
  selector = document.querySelector( element );
26
26
 
27
27
  // If selector is not present
@@ -40,11 +40,15 @@ var sticky = function( element, settings ) {
40
40
  elemHeight = selector.offsetHeight,
41
41
  anchorInit = options.anchorPoint,
42
42
  docBody = document.body,
43
- resizeHandler = toolbox.event.resize( resized ),
44
- scrollHandler = toolbox.event.scroll( scrolled ),
45
43
  docHeight,
46
44
  winHeight;
47
45
 
46
+ // Resize throttle function init
47
+ throttle( 'resize', 'optimizedResize' );
48
+
49
+ // Scroll throttle function init
50
+ throttle( 'scroll', 'optimizedScroll' );
51
+
48
52
  // Call listener function explicitly at run time
49
53
  queryHandler( widthQuery );
50
54
 
@@ -56,25 +60,38 @@ var sticky = function( element, settings ) {
56
60
  // Media query handler function
57
61
  function queryHandler( condition ) {
58
62
 
59
- // Call resize listener function explicitly at run time
60
- resized()
63
+ // If media query matches
64
+ if ( condition.matches ) {
65
+
66
+ // Call resize listener function explicitly at run time
67
+ resizeHandler();
61
68
 
62
- // Call scroll listener function explicitly at run time
63
- scrolled();
64
-
65
- // Reset styles
66
- if ( !condition.matches ) docBody.classList.remove( 'sticky' )
69
+ // Resize function listener
70
+ window.addEventListener( 'optimizedResize', resizeHandler, false );
67
71
 
68
- // Remove resize listener
69
- resizeHandler.toggle( condition.matches )
72
+ // Call scroll listener function explicitly at run time
73
+ scrollHandler();
74
+
75
+ // Scroll function listener
76
+ window.addEventListener( 'optimizedScroll', scrollHandler, false );
77
+
78
+ } else {
70
79
 
71
- // Remove scroll listener
72
- scrollHandler.toggle( condition.matches )
80
+ // Reset styles
81
+ docBody.classList.remove( 'sticky' );
82
+
83
+ // Remove resize listener
84
+ window.removeEventListener( 'optimizedResize', resizeHandler, false );
85
+
86
+ // Remove scroll listener
87
+ window.removeEventListener( 'optimizedScroll', scrollHandler, false );
88
+
89
+ }
73
90
 
74
91
  }
75
92
 
76
93
  // Resize handler function
77
- function resized() {
94
+ function resizeHandler() {
78
95
 
79
96
  // Update document height variable
80
97
  docHeight = document.body.scrollHeight;
@@ -85,7 +102,7 @@ var sticky = function( element, settings ) {
85
102
  }
86
103
 
87
104
  // Scroll handler function
88
- function scrolled() {
105
+ function scrollHandler() {
89
106
 
90
107
  // Scoped variables
91
108
  var newScrollY = window.pageYOffset,