diff options
Diffstat (limited to 'vnfmarket/common/thirdparty/angular-material/modules/js/sticky')
5 files changed, 405 insertions, 0 deletions
diff --git a/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/bower.json b/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/bower.json new file mode 100644 index 00000000..6aa26a24 --- /dev/null +++ b/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/bower.json @@ -0,0 +1,8 @@ +{ + "name": "angular-material-sticky", + "version": "1.1.2-master-a9ba340", + "dependencies": { + "angular-material-core": "1.1.2-master-a9ba340", + "angular-material-content": "1.1.2-master-a9ba340" + } +}
\ No newline at end of file diff --git a/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/sticky.css b/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/sticky.css new file mode 100644 index 00000000..c9599a3f --- /dev/null +++ b/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/sticky.css @@ -0,0 +1,20 @@ +/*! + * Angular Material Design + * https://github.com/angular/material + * @license MIT + * v1.1.3 + */ +.md-sticky-clone { + z-index: 2; + top: 0; + left: 0; + right: 0; + position: absolute !important; + -webkit-transform: translate3d(-9999px, -9999px, 0); + transform: translate3d(-9999px, -9999px, 0); } + .md-sticky-clone[sticky-state="active"] { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); } + .md-sticky-clone[sticky-state="active"]:not(.md-sticky-no-effect) .md-subheader-inner { + -webkit-animation: subheaderStickyHoverIn 0.3s ease-out both; + animation: subheaderStickyHoverIn 0.3s ease-out both; } diff --git a/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/sticky.js b/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/sticky.js new file mode 100644 index 00000000..669df662 --- /dev/null +++ b/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/sticky.js @@ -0,0 +1,364 @@ +/*! + * Angular Material Design + * https://github.com/angular/material + * @license MIT + * v1.1.3 + */ +(function( window, angular, undefined ){ +"use strict"; + +/** + * @ngdoc module + * @name material.components.sticky + * @description + * Sticky effects for md + * + */ +MdSticky['$inject'] = ["$mdConstant", "$$rAF", "$mdUtil", "$compile"]; +angular + .module('material.components.sticky', [ + 'material.core', + 'material.components.content' + ]) + .factory('$mdSticky', MdSticky); + +/** + * @ngdoc service + * @name $mdSticky + * @module material.components.sticky + * + * @description + * The `$mdSticky`service provides a mixin to make elements sticky. + * + * Whenever the current browser supports stickiness natively, the `$mdSticky` service will just + * use the native browser stickiness. + * + * By default the `$mdSticky` service compiles the cloned element, when not specified through the `elementClone` + * parameter, in the same scope as the actual element lives. + * + * + * <h3>Notes</h3> + * When using an element which is containing a compiled directive, which changed its DOM structure during compilation, + * you should compile the clone yourself using the plain template.<br/><br/> + * See the right usage below: + * <hljs lang="js"> + * angular.module('myModule') + * .directive('stickySelect', function($mdSticky, $compile) { + * var SELECT_TEMPLATE = + * '<md-select ng-model="selected">' + + * '<md-option>Option 1</md-option>' + + * '</md-select>'; + * + * return { + * restrict: 'E', + * replace: true, + * template: SELECT_TEMPLATE, + * link: function(scope,element) { + * $mdSticky(scope, element, $compile(SELECT_TEMPLATE)(scope)); + * } + * }; + * }); + * </hljs> + * + * @usage + * <hljs lang="js"> + * angular.module('myModule') + * .directive('stickyText', function($mdSticky, $compile) { + * return { + * restrict: 'E', + * template: '<span>Sticky Text</span>', + * link: function(scope,element) { + * $mdSticky(scope, element); + * } + * }; + * }); + * </hljs> + * + * @returns A `$mdSticky` function that takes three arguments: + * - `scope` + * - `element`: The element that will be 'sticky' + * - `elementClone`: A clone of the element, that will be shown + * when the user starts scrolling past the original element. + * If not provided, it will use the result of `element.clone()` and compiles it in the given scope. + */ +function MdSticky($mdConstant, $$rAF, $mdUtil, $compile) { + + var browserStickySupport = $mdUtil.checkStickySupport(); + + /** + * Registers an element as sticky, used internally by directives to register themselves + */ + return function registerStickyElement(scope, element, stickyClone) { + var contentCtrl = element.controller('mdContent'); + if (!contentCtrl) return; + + if (browserStickySupport) { + element.css({ + position: browserStickySupport, + top: 0, + 'z-index': 2 + }); + } else { + var $$sticky = contentCtrl.$element.data('$$sticky'); + if (!$$sticky) { + $$sticky = setupSticky(contentCtrl); + contentCtrl.$element.data('$$sticky', $$sticky); + } + + // Compile our cloned element, when cloned in this service, into the given scope. + var cloneElement = stickyClone || $compile(element.clone())(scope); + + var deregister = $$sticky.add(element, cloneElement); + scope.$on('$destroy', deregister); + } + }; + + function setupSticky(contentCtrl) { + var contentEl = contentCtrl.$element; + + // Refresh elements is very expensive, so we use the debounced + // version when possible. + var debouncedRefreshElements = $$rAF.throttle(refreshElements); + + // setupAugmentedScrollEvents gives us `$scrollstart` and `$scroll`, + // more reliable than `scroll` on android. + setupAugmentedScrollEvents(contentEl); + contentEl.on('$scrollstart', debouncedRefreshElements); + contentEl.on('$scroll', onScroll); + + var self; + return self = { + prev: null, + current: null, //the currently stickied item + next: null, + items: [], + add: add, + refreshElements: refreshElements + }; + + /*************** + * Public + ***************/ + // Add an element and its sticky clone to this content's sticky collection + function add(element, stickyClone) { + stickyClone.addClass('md-sticky-clone'); + + var item = { + element: element, + clone: stickyClone + }; + self.items.push(item); + + $mdUtil.nextTick(function() { + contentEl.prepend(item.clone); + }); + + debouncedRefreshElements(); + + return function remove() { + self.items.forEach(function(item, index) { + if (item.element[0] === element[0]) { + self.items.splice(index, 1); + item.clone.remove(); + } + }); + debouncedRefreshElements(); + }; + } + + function refreshElements() { + // Sort our collection of elements by their current position in the DOM. + // We need to do this because our elements' order of being added may not + // be the same as their order of display. + self.items.forEach(refreshPosition); + self.items = self.items.sort(function(a, b) { + return a.top < b.top ? -1 : 1; + }); + + // Find which item in the list should be active, + // based upon the content's current scroll position + var item; + var currentScrollTop = contentEl.prop('scrollTop'); + for (var i = self.items.length - 1; i >= 0; i--) { + if (currentScrollTop > self.items[i].top) { + item = self.items[i]; + break; + } + } + setCurrentItem(item); + } + + /*************** + * Private + ***************/ + + // Find the `top` of an item relative to the content element, + // and also the height. + function refreshPosition(item) { + // Find the top of an item by adding to the offsetHeight until we reach the + // content element. + var current = item.element[0]; + item.top = 0; + item.left = 0; + item.right = 0; + while (current && current !== contentEl[0]) { + item.top += current.offsetTop; + item.left += current.offsetLeft; + if ( current.offsetParent ){ + item.right += current.offsetParent.offsetWidth - current.offsetWidth - current.offsetLeft; //Compute offsetRight + } + current = current.offsetParent; + } + item.height = item.element.prop('offsetHeight'); + + var defaultVal = $mdUtil.floatingScrollbars() ? '0' : undefined; + $mdUtil.bidi(item.clone, 'margin-left', item.left, defaultVal); + $mdUtil.bidi(item.clone, 'margin-right', defaultVal, item.right); + } + + // As we scroll, push in and select the correct sticky element. + function onScroll() { + var scrollTop = contentEl.prop('scrollTop'); + var isScrollingDown = scrollTop > (onScroll.prevScrollTop || 0); + + // Store the previous scroll so we know which direction we are scrolling + onScroll.prevScrollTop = scrollTop; + + // + // AT TOP (not scrolling) + // + if (scrollTop === 0) { + // If we're at the top, just clear the current item and return + setCurrentItem(null); + return; + } + + // + // SCROLLING DOWN (going towards the next item) + // + if (isScrollingDown) { + + // If we've scrolled down past the next item's position, sticky it and return + if (self.next && self.next.top <= scrollTop) { + setCurrentItem(self.next); + return; + } + + // If the next item is close to the current one, push the current one up out of the way + if (self.current && self.next && self.next.top - scrollTop <= self.next.height) { + translate(self.current, scrollTop + (self.next.top - self.next.height - scrollTop)); + return; + } + } + + // + // SCROLLING UP (not at the top & not scrolling down; must be scrolling up) + // + if (!isScrollingDown) { + + // If we've scrolled up past the previous item's position, sticky it and return + if (self.current && self.prev && scrollTop < self.current.top) { + setCurrentItem(self.prev); + return; + } + + // If the next item is close to the current one, pull the current one down into view + if (self.next && self.current && (scrollTop >= (self.next.top - self.current.height))) { + translate(self.current, scrollTop + (self.next.top - scrollTop - self.current.height)); + return; + } + } + + // + // Otherwise, just move the current item to the proper place (scrolling up or down) + // + if (self.current) { + translate(self.current, scrollTop); + } + } + + function setCurrentItem(item) { + if (self.current === item) return; + // Deactivate currently active item + if (self.current) { + translate(self.current, null); + setStickyState(self.current, null); + } + + // Activate new item if given + if (item) { + setStickyState(item, 'active'); + } + + self.current = item; + var index = self.items.indexOf(item); + // If index === -1, index + 1 = 0. It works out. + self.next = self.items[index + 1]; + self.prev = self.items[index - 1]; + setStickyState(self.next, 'next'); + setStickyState(self.prev, 'prev'); + } + + function setStickyState(item, state) { + if (!item || item.state === state) return; + if (item.state) { + item.clone.attr('sticky-prev-state', item.state); + item.element.attr('sticky-prev-state', item.state); + } + item.clone.attr('sticky-state', state); + item.element.attr('sticky-state', state); + item.state = state; + } + + function translate(item, amount) { + if (!item) return; + if (amount === null || amount === undefined) { + if (item.translateY) { + item.translateY = null; + item.clone.css($mdConstant.CSS.TRANSFORM, ''); + } + } else { + item.translateY = amount; + + $mdUtil.bidi( item.clone, $mdConstant.CSS.TRANSFORM, + 'translate3d(' + item.left + 'px,' + amount + 'px,0)', + 'translateY(' + amount + 'px)' + ); + } + } + } + + + // Android 4.4 don't accurately give scroll events. + // To fix this problem, we setup a fake scroll event. We say: + // > If a scroll or touchmove event has happened in the last DELAY milliseconds, + // then send a `$scroll` event every animationFrame. + // Additionally, we add $scrollstart and $scrollend events. + function setupAugmentedScrollEvents(element) { + var SCROLL_END_DELAY = 200; + var isScrolling; + var lastScrollTime; + element.on('scroll touchmove', function() { + if (!isScrolling) { + isScrolling = true; + $$rAF.throttle(loopScrollEvent); + element.triggerHandler('$scrollstart'); + } + element.triggerHandler('$scroll'); + lastScrollTime = +$mdUtil.now(); + }); + + function loopScrollEvent() { + if (+$mdUtil.now() - lastScrollTime > SCROLL_END_DELAY) { + isScrolling = false; + element.triggerHandler('$scrollend'); + } else { + element.triggerHandler('$scroll'); + $$rAF.throttle(loopScrollEvent); + } + } + } + +} + +})(window, window.angular);
\ No newline at end of file diff --git a/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/sticky.min.css b/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/sticky.min.css new file mode 100644 index 00000000..93d6d303 --- /dev/null +++ b/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/sticky.min.css @@ -0,0 +1,6 @@ +/*! + * Angular Material Design + * https://github.com/angular/material + * @license MIT + * v1.1.2-master-a9ba340 + */.md-sticky-clone{z-index:2;top:0;left:0;right:0;position:absolute!important;-webkit-transform:translate3d(-9999px,-9999px,0);transform:translate3d(-9999px,-9999px,0)}.md-sticky-clone[sticky-state=active]{-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.md-sticky-clone[sticky-state=active]:not(.md-sticky-no-effect) .md-subheader-inner{-webkit-animation:subheaderStickyHoverIn .3s ease-out both;animation:subheaderStickyHoverIn .3s ease-out both}
\ No newline at end of file diff --git a/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/sticky.min.js b/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/sticky.min.js new file mode 100644 index 00000000..21db499f --- /dev/null +++ b/vnfmarket/common/thirdparty/angular-material/modules/js/sticky/sticky.min.js @@ -0,0 +1,7 @@ +/*! + * Angular Material Design + * https://github.com/angular/material + * @license MIT + * v1.1.2-master-a9ba340 + */ +!function(t,e,n){"use strict";function r(t,e,r,o){function i(o){function i(t,e){e.addClass("md-sticky-clone");var n={element:t,clone:e};return v.items.push(n),r.nextTick(function(){m.prepend(n.clone)}),d(),function(){v.items.forEach(function(e,n){e.element[0]===t[0]&&(v.items.splice(n,1),e.clone.remove())}),d()}}function c(){v.items.forEach(s),v.items=v.items.sort(function(t,e){return t.top<e.top?-1:1});for(var t,e=m.prop("scrollTop"),n=v.items.length-1;n>=0;n--)if(e>v.items[n].top){t=v.items[n];break}f(t)}function s(t){var e=t.element[0];for(t.top=0,t.left=0,t.right=0;e&&e!==m[0];)t.top+=e.offsetTop,t.left+=e.offsetLeft,e.offsetParent&&(t.right+=e.offsetParent.offsetWidth-e.offsetWidth-e.offsetLeft),e=e.offsetParent;t.height=t.element.prop("offsetHeight");var o=r.floatingScrollbars()?"0":n;r.bidi(t.clone,"margin-left",t.left,o),r.bidi(t.clone,"margin-right",o,t.right)}function a(){var t=m.prop("scrollTop"),e=t>(a.prevScrollTop||0);if(a.prevScrollTop=t,0===t)return void f(null);if(e){if(v.next&&v.next.top<=t)return void f(v.next);if(v.current&&v.next&&v.next.top-t<=v.next.height)return void p(v.current,t+(v.next.top-v.next.height-t))}if(!e){if(v.current&&v.prev&&t<v.current.top)return void f(v.prev);if(v.next&&v.current&&t>=v.next.top-v.current.height)return void p(v.current,t+(v.next.top-t-v.current.height))}v.current&&p(v.current,t)}function f(t){if(v.current!==t){v.current&&(p(v.current,null),u(v.current,null)),t&&u(t,"active"),v.current=t;var e=v.items.indexOf(t);v.next=v.items[e+1],v.prev=v.items[e-1],u(v.next,"next"),u(v.prev,"prev")}}function u(t,e){t&&t.state!==e&&(t.state&&(t.clone.attr("sticky-prev-state",t.state),t.element.attr("sticky-prev-state",t.state)),t.clone.attr("sticky-state",e),t.element.attr("sticky-state",e),t.state=e)}function p(e,o){e&&(null===o||o===n?e.translateY&&(e.translateY=null,e.clone.css(t.CSS.TRANSFORM,"")):(e.translateY=o,r.bidi(e.clone,t.CSS.TRANSFORM,"translate3d("+e.left+"px,"+o+"px,0)","translateY("+o+"px)")))}var m=o.$element,d=e.throttle(c);l(m),m.on("$scrollstart",d),m.on("$scroll",a);var v;return v={prev:null,current:null,next:null,items:[],add:i,refreshElements:c}}function l(t){function n(){+r.now()-i>l?(o=!1,t.triggerHandler("$scrollend")):(t.triggerHandler("$scroll"),e.throttle(n))}var o,i,l=200;t.on("scroll touchmove",function(){o||(o=!0,e.throttle(n),t.triggerHandler("$scrollstart")),t.triggerHandler("$scroll"),i=+r.now()})}var c=r.checkStickySupport();return function(t,e,n){var r=e.controller("mdContent");if(r)if(c)e.css({position:c,top:0,"z-index":2});else{var l=r.$element.data("$$sticky");l||(l=i(r),r.$element.data("$$sticky",l));var s=n||o(e.clone())(t),a=l.add(e,s);t.$on("$destroy",a)}}}r.$inject=["$mdConstant","$$rAF","$mdUtil","$compile"],e.module("material.components.sticky",["material.core","material.components.content"]).factory("$mdSticky",r)}(window,window.angular);
\ No newline at end of file |