Skip to content

Commit

Permalink
Add form sticky elements
Browse files Browse the repository at this point in the history
  • Loading branch information
qsomazzi committed Aug 26, 2015
1 parent 3d8a451 commit 51ee4b0
Show file tree
Hide file tree
Showing 27 changed files with 2,829 additions and 2 deletions.
3 changes: 3 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function getConfigTreeBuilder()
->booleanNode('use_select2')->defaultTrue()->end()
->booleanNode('use_icheck')->defaultTrue()->end()
->booleanNode('use_bootlint')->defaultFalse()->end()
->booleanNode('use_stickyforms')->defaultTrue()->end()
->integerNode('pager_links')->defaultNull()->end()
->scalarNode('form_type')->defaultValue('standard')->end()
->integerNode('dropdown_number_groups_per_colums')->defaultValue(2)->end()
Expand Down Expand Up @@ -324,6 +325,8 @@ public function getConfigTreeBuilder()
'bundles/sonataadmin/vendor/admin-lte/dist/js/app.min.js',
'bundles/sonataadmin/vendor/iCheck/icheck.min.js',
'bundles/sonataadmin/vendor/slimScroll/jquery.slimscroll.min.js',
'bundles/sonataadmin/vendor/waypoints/lib/jquery.waypoints.min.js',
'bundles/sonataadmin/vendor/waypoints/lib/shortcuts/sticky.min.js',

'bundles/sonataadmin/Admin.js',
'bundles/sonataadmin/treeview.js',
Expand Down
41 changes: 41 additions & 0 deletions Resources/public/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var Admin = {
Admin.setup_inline_form_errors(subject);
Admin.setup_tree_view(subject);
Admin.setup_collection_counter(subject);
Admin.setup_sticky_elements(subject);

// Admin.setup_list_modal(subject);
},
Expand Down Expand Up @@ -528,5 +529,45 @@ var Admin = {
}
subject.remove();
});
},

setup_sticky_elements: function(subject) {
if (window.SONATA_CONFIG && window.SONATA_CONFIG.USE_STICKYFORMS) {
Admin.log('[core|setup_sticky_elements] setup sticky elements on', subject);

var stickyHeader = new Waypoint.Sticky({
element: jQuery(subject).find('.content-wrapper nav.navbar')[0],
offset: 50
});

var footer = jQuery.find('.content-wrapper .form-actions');
var stickyFooter = new Waypoint({
element: jQuery.find('.content-wrapper')[0],
offset: 'bottom-in-view',
handler: function(direction) {
var position = jQuery('.sonata-ba-form form > .row').outerHeight() + jQuery(footer).outerHeight() - 2;

if (position < jQuery(footer).offset().top) {
jQuery(footer).removeClass('stuck');
}

if (direction == 'up') {
jQuery(footer).addClass('stuck');
}
}
});

Admin.handleScroll(footer);
}
},
handleScroll: function(footer) {
if (jQuery(window).scrollTop() + jQuery(window).height() != jQuery(document).height()) {
jQuery(footer).addClass('stuck');
}
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
jQuery(footer).removeClass('stuck');
}
});
}
};
19 changes: 19 additions & 0 deletions Resources/public/css/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,22 @@ legend.sonata-ba-fieldset-collapsed-description + .sonata-ba-collapsed-fields {
text-align: center;
width: 100%;
}

body.fixed .content-header .navbar.stuck {
position:fixed;
top:50px;
width: 100%;
margin-left: -15px;
z-index: 1;
border-radius: 0;
}

.form-actions.stuck {
position:fixed;
bottom:0;
width: 100%;
margin-left: -15px;
margin-bottom: 0;
z-index: 1;
border-radius: 0;
}
29 changes: 29 additions & 0 deletions Resources/public/vendor/waypoints/.bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "waypoints",
"main": "lib/noframework.waypoints.js",
"description": "Easily execute a function when you scroll to an element.",
"ignore": [
"gulpfile.js",
"package.json",
"src",
"test",
"testem.json"
],
"devDependencies": {
"jquery": "~1.11.1",
"lodash": "~2.4.1",
"jasmine-jquery": "~1.7.0",
"zepto": "~1.1.3"
},
"homepage": "https://github.com/imakewebthings/waypoints",
"version": "4.0.0",
"_release": "4.0.0",
"_resolution": {
"type": "version",
"tag": "4.0.0",
"commit": "0944e1569dd46a05494c3c056e4328884a739a4f"
},
"_source": "git://github.com/imakewebthings/waypoints.git",
"_target": "~4.0.0",
"_originalSource": "waypoints"
}
25 changes: 25 additions & 0 deletions Resources/public/vendor/waypoints/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"env": {
"browser": true,
"node": true
},

"rules": {
"brace-style": [1, "stroustrup"],
"consistent-this": [1, "self"],
"eqeqeq": [1, "smart"],
"func-style": [1, "declaration"],
"no-else-return": 1,
"no-extra-parens": 1,
"no-floating-decimal": 1,
"no-nested-ternary": 1,
"no-lonely-if": 1,
"quotes": [1, "single", "avoid-escape"],
"radix": 1,
"semi": [1, "never"],
"space-after-keywords": [1, "always"],
"space-in-brackets": [1, "never"],
"space-unary-word-ops": 1,
"wrap-iife": 1
}
}
7 changes: 7 additions & 0 deletions Resources/public/vendor/waypoints/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
_site
.sass-cache
.DS_Store
/style.scss
*.gz
node_modules
bower_components
7 changes: 7 additions & 0 deletions Resources/public/vendor/waypoints/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: node_js
sudo: false
node_js:
- "0.10"
before_script:
- npm install -g bower
- bower install
141 changes: 141 additions & 0 deletions Resources/public/vendor/waypoints/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Changelog

## v4.0.0

- Allow Sticky option `wrapper` to accept false, which will not create a wrapper and instead use the preexisting parent element. (Pull #416)
- Waypoints that are immediately triggered on creation because they've already passed their trigger point now run their handlers on the next animation frame. This contains Zalgo. (Issue #384)
- Pass the jQuery object of items added during an Infinite page load to the `onAfterPageLoad` callback. (Pull #398)
- Add `enabled` option, `enable` and `disable` methods to the Inview shortcut (Pull #406)
- Make the Inview instance `this` within the callbacks, rather than the invdividual underlying waypoints. (Issue #412)
- Account for changes to jQuery 3 around calling `offset` on the window. (Pull #430)
- Add `context` option to Inview. (Issue #433)

## v3.1.1

- Fix bad `isWindow` checks causing errors in IE8-. (Issue #372)

## v3.1.0

- Add `Waypoint.disableAll` and `Waypoint.enableAll` methods.
- Fix Illegal Invocation errors stemming from non-window context use of `requestAnimationFrame`. (Pull #366)
- Keep disabled waypoints from triggering debug script errors. (Pull #365)
- Allow Infinite Scroll items to be root elements in the AJAX response. (Pull #361)
- In debug script, detect display none and fixed positioning defined in CSS.

## v3.0.1

- Add semicolons to the end of built files to aid in clean concatenation. (Issue #353)

## v3.0.0

- Remove hard jQuery dependency. Create builds for jQuery, Zepto, and no DOM framework. (Issue #282)
- Expose `Waypoint` and `Context` classes. (Issue #281)
- Add `Group` class and `group` option for grouping waypoints. Make `continuous` option work within these groups. (Issue #264)
- Add Inview shortcut. (Issue #131)
- Extend `continuous` option to cover refreshes. (Issue #166)
- Throttle resize and scroll handlers using `requestAnimationFrame` instead of a set millisecond timeout. Fallback to the old 60 FPS `setTimeout` throttle for unsupported browsers. (Issue #242)
- Add debugging script for diagnosing common problems.
- Remove `triggerOnce` option.
- Add `viewportWidth` utility method.
- Remove all traces of CoffeeScript.

## v2.0.5

- Allow sticky users to define which direction the stuck class shold be applied. (Issue #192)
- Fix bug where short content on a large screen could cause the infinite shortcut to stall after the first page load. (Issue #207)
- Make `unsticky` safe to use on any element. Previously it would unwrap the parent even if the element had never had `sticky` called on it or already had `unsticky` called previously. (Issue #225)
- Fix bug that would cause handlers to be overwritten when trying to reuse an options object. (Issue #253)
- Remove "More" link when infinite shortcut reaches last page. (Issue #260)
- Fix use of `this` instead of `window`, causing Browserify to fail. (Issue #262)
- Stop using deprecated jQuery `load` method. (Issue #283)

## v2.0.4

- Fix enable, disable, and destroys calls not chaining the jQuery object. (Issue #244) (Thanks [@robharper](https://github.com/robharper))
- Fix destroy not unregistering internal waypoint references if underlying node has been removed from the document, causing memory leaks. (Issue #243)

## v2.0.3

- Add "unsticky" function for sticky shortcut. (Issue #130)
- Exit early from Infinite shortcut if no "more" link exists. (Issue #140)
- Delay height evaluation of sticky shortcut wrapper. (Issue #151)
- Fix errors with Infinite shortcut's parsing of HTML with jQuery 1.9+. (Issue #163)


## v2.0.2

- Add AMD support. (Issue #116)
- Work around iOS issue with cancelled `setTimeout` timers by not using scroll throttling on touch devices. (Issue #120)
- If defined, execute `handler` option passed to sticky shortcut at the end of the stuck/unstuck change. (Issue #123)

## v2.0.1

- Lower default throttle values for `scrollThrottle` and `resizeThrottle`.
- Fix Issue #104: Pixel offsets written as strings are interpreted as %s.
- Fix Issue #100: Work around IE not firing scroll event on document shortening by forcing a scroll check on `refresh` calls.

## v2.0.0

- Rewrite Waypoints in CoffeeScript.
- Add Sticky and Infinite shortcut scripts.
- Allow multiple Waypoints on each element. (Issue #40)
- Allow horizontal scrolling Waypoints. (Issue #14)
- API additions: (#69, 83, 88)
- prev, next, above, below, left, right, extendFn, enable, disable
- API subtractions:
- remove
- Remove custom 'waypoint.reached' jQuery Event from powering the trigger.
- $.waypoints now returns object with vertical+horizontal properties and HTMLElement arrays instead of jQuery object (to preserve trigger order instead of jQuery's forced source order).
- Add enabled option.

## v1.1.7

- Actually fix the post-load bug in Issue #28 from v1.1.3.

## v1.1.6

- Fix potential memory leak by unbinding events on empty context elements.

## v1.1.5

- Make plugin compatible with Browserify/RequireJS. (Thanks [@cjroebuck](https://github.com/cjroebuck))

## v1.1.4

- Add handler option to give alternate binding method.

## v1.1.3

- Fix cases where waypoints are added post-load and should be triggered immediately.

## v1.1.2

- Fixed error thrown by waypoints with triggerOnce option that were triggered via resize refresh.

## v1.1.1

- Fixed bug in initialization where all offsets were being calculated as if set to 0 initially, causing unwarranted triggers during the subsequent refresh.
- Added `onlyOnScroll`, an option for individual waypoints that disables triggers due to an offset refresh that crosses the current scroll point. (All credit to [@knuton](https://github.com/knuton) on this one.)

## v1.1

- Moved the continuous option out of global settings and into the options
object for individual waypoints.
- Added the context option, which allows for using waypoints within any
scrollable element, not just the window.

## v1.0.2

- Moved scroll and resize handler bindings out of load. Should play nicer with async loaders like Head JS and LABjs.
- Fixed a 1px off error when using certain % offsets.
- Added unit tests.

## v1.0.1

- Added $.waypoints('viewportHeight').
- Fixed iOS bug (using the new viewportHeight method).
- Added offset function alias: 'bottom-in-view'.

## v1.0

- Initial release.
31 changes: 31 additions & 0 deletions Resources/public/vendor/waypoints/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Opening an Issue

The GitHub issue tracker is exclusively for opening demonstrable bugs with the library or for discussing/implementing enhancements. If you need general help with Waypoints try searching through existing closed tickets, searching through the [#jquery-waypoints](http://stackoverflow.com/questions/tagged/jquery-waypoints) tag on StackOverflow, or asking your question there using that tag. If you do ask a question on StackOverflow, please follow the guidelines for [asking a good question](http://stackoverflow.com/help/how-to-ask).

If you're opening a ticket for a bug:

- Give a clear explanation of the bug.
- Try to provide a link to a [JSFiddle](http://jsfiddle.net/) or [CodePen](http://codepen.io/) or similar reduced test case.
- If you cannot provide a reduced test case, please provide a link to a live site demonstrating your bug and include in the ticket the relevant Waypoints code.

If you're interested in discussing a possible new feature:

- Search closed tickets for discussions that may have already occurred.
- Open a ticket and let's talk!

# Pull Requests

- Please send the pull request against the master branch.
- Note any tickets that the pull request addresses.
- Add any necessary tests (see below).
- Follow the coding style of the current codebase.

# Tests

Tests are written in [Jasmine](http://jasmine.github.io/) and run through the [testem](https://github.com/airportyh/testem) test runner. To run them locally you'll need to:

- Install, if you haven't already: [PhantomJS](http://phantomjs.org/), node, and [Bower](bower.io).
- `npm install`
- `bower install`

You can then run the tests one time by running `npm test`, or enter TDD mode by running `npm run tdd`.
33 changes: 33 additions & 0 deletions Resources/public/vendor/waypoints/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Waypoints

Waypoints is a library that makes it easy to execute a function whenever you scroll to an element. ![Build Status](https://travis-ci.org/imakewebthings/waypoints.svg)

```js
var waypoint = new Waypoint({
element: document.getElementById('thing'),
handler: function(direction) {
alert('You have scrolled to a thing')
}
})
```

If you're new to Waypoints, check out the [Getting Started](http://imakewebthings.com/waypoints/guides/getting-started) guide.

[Read the full documentation](http://imakewebthings.com/waypoints/api/waypoint) for more details on usage and customization.

## Shortcuts

In addition to the normal Waypoints script, extensions exist to make common UI patterns just a little easier to implement:

- [Infinite Scrolling](http://imakewebthings.com/waypoints/shortcuts/infinite-scroll)
- [Sticky Elements](http://imakewebthings.com/waypoints/shortcuts/sticky-elements)
- [Inview Detection](http://imakewebthings.com/waypoints/shortcuts/inview)


## Contributing

If you want to report a Waypoints bug or contribute code to the library, please read the [Contributing Guidelines](https://github.com/imakewebthings/waypoints/blob/master/CONTRIBUTING.md). If you need help *using* Waypoints, please do not open an issue. Instead, ask the question on [Stack Overflow](http://stackoverflow.com) and tag it with <code>#jquery-waypoints</code>. Be sure to follow the guidelines for [asking a good question](http://stackoverflow.com/help/how-to-ask).

## License

Copyright (c) 2011-2014 Caleb Troughton. Licensed under the [MIT license](https://github.com/imakewebthings/waypoints/blob/master/licenses.txt).
18 changes: 18 additions & 0 deletions Resources/public/vendor/waypoints/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "waypoints",
"main": "lib/noframework.waypoints.js",
"description": "Easily execute a function when you scroll to an element.",
"ignore": [
"gulpfile.js",
"package.json",
"src",
"test",
"testem.json"
],
"devDependencies": {
"jquery": "~1.11.1",
"lodash": "~2.4.1",
"jasmine-jquery": "~1.7.0",
"zepto": "~1.1.3"
}
}
Loading

0 comments on commit 51ee4b0

Please sign in to comment.