id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
5,000
angular/material
src/core/services/theming/theming.js
function (scope, el) { if (el === undefined) { el = scope; scope = undefined; } if (scope === undefined) { scope = $rootScope; } applyTheme.inherit(el, el); }
javascript
function (scope, el) { if (el === undefined) { el = scope; scope = undefined; } if (scope === undefined) { scope = $rootScope; } applyTheme.inherit(el, el); }
[ "function", "(", "scope", ",", "el", ")", "{", "if", "(", "el", "===", "undefined", ")", "{", "el", "=", "scope", ";", "scope", "=", "undefined", ";", "}", "if", "(", "scope", "===", "undefined", ")", "{", "scope", "=", "$rootScope", ";", "}", "applyTheme", ".", "inherit", "(", "el", ",", "el", ")", ";", "}" ]
Allow us to be invoked via a linking function signature.
[ "Allow", "us", "to", "be", "invoked", "via", "a", "linking", "function", "signature", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/theming/theming.js#L711-L715
5,001
angular/material
src/core/services/theming/theming.js
registered
function registered(themeName) { if (themeName === undefined || themeName === '') return true; return applyTheme.THEMES[themeName] !== undefined; }
javascript
function registered(themeName) { if (themeName === undefined || themeName === '') return true; return applyTheme.THEMES[themeName] !== undefined; }
[ "function", "registered", "(", "themeName", ")", "{", "if", "(", "themeName", "===", "undefined", "||", "themeName", "===", "''", ")", "return", "true", ";", "return", "applyTheme", ".", "THEMES", "[", "themeName", "]", "!==", "undefined", ";", "}" ]
Determine is specified theme name is a valid, registered theme
[ "Determine", "is", "specified", "theme", "name", "is", "a", "valid", "registered", "theme" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/theming/theming.js#L768-L771
5,002
angular/material
src/core/services/theming/theming.js
inheritTheme
function inheritTheme (el, parent) { var ctrl = parent.controller('mdTheme') || el.data('$mdThemeController'); var scope = el.scope(); updateThemeClass(lookupThemeName()); if (ctrl) { var watchTheme = alwaysWatchTheme || ctrl.$shouldWatch || $mdUtil.parseAttributeBoolean(el.attr('md-theme-watch')); if (watchTheme || ctrl.isAsyncTheme) { var clearNameWatcher = function () { if (unwatch) { unwatch(); unwatch = undefined; } }; var unwatch = ctrl.registerChanges(function(name) { updateThemeClass(name); if (!watchTheme) { clearNameWatcher(); } }); if (scope) { scope.$on('$destroy', clearNameWatcher); } else { el.on('$destroy', clearNameWatcher); } } } /** * Find the theme name from the parent controller or element data */ function lookupThemeName() { // As a few components (dialog) add their controllers later, we should also watch for a controller init. return ctrl && ctrl.$mdTheme || (defaultTheme === 'default' ? '' : defaultTheme); } /** * Remove old theme class and apply a new one * NOTE: if not a valid theme name, then the current name is not changed */ function updateThemeClass(theme) { if (!theme) return; if (!registered(theme)) { $log.warn('Attempted to use unregistered theme \'' + theme + '\'. ' + 'Register it with $mdThemingProvider.theme().'); } var oldTheme = el.data('$mdThemeName'); if (oldTheme) el.removeClass('md-' + oldTheme +'-theme'); el.addClass('md-' + theme + '-theme'); el.data('$mdThemeName', theme); if (ctrl) { el.data('$mdThemeController', ctrl); } } }
javascript
function inheritTheme (el, parent) { var ctrl = parent.controller('mdTheme') || el.data('$mdThemeController'); var scope = el.scope(); updateThemeClass(lookupThemeName()); if (ctrl) { var watchTheme = alwaysWatchTheme || ctrl.$shouldWatch || $mdUtil.parseAttributeBoolean(el.attr('md-theme-watch')); if (watchTheme || ctrl.isAsyncTheme) { var clearNameWatcher = function () { if (unwatch) { unwatch(); unwatch = undefined; } }; var unwatch = ctrl.registerChanges(function(name) { updateThemeClass(name); if (!watchTheme) { clearNameWatcher(); } }); if (scope) { scope.$on('$destroy', clearNameWatcher); } else { el.on('$destroy', clearNameWatcher); } } } /** * Find the theme name from the parent controller or element data */ function lookupThemeName() { // As a few components (dialog) add their controllers later, we should also watch for a controller init. return ctrl && ctrl.$mdTheme || (defaultTheme === 'default' ? '' : defaultTheme); } /** * Remove old theme class and apply a new one * NOTE: if not a valid theme name, then the current name is not changed */ function updateThemeClass(theme) { if (!theme) return; if (!registered(theme)) { $log.warn('Attempted to use unregistered theme \'' + theme + '\'. ' + 'Register it with $mdThemingProvider.theme().'); } var oldTheme = el.data('$mdThemeName'); if (oldTheme) el.removeClass('md-' + oldTheme +'-theme'); el.addClass('md-' + theme + '-theme'); el.data('$mdThemeName', theme); if (ctrl) { el.data('$mdThemeController', ctrl); } } }
[ "function", "inheritTheme", "(", "el", ",", "parent", ")", "{", "var", "ctrl", "=", "parent", ".", "controller", "(", "'mdTheme'", ")", "||", "el", ".", "data", "(", "'$mdThemeController'", ")", ";", "var", "scope", "=", "el", ".", "scope", "(", ")", ";", "updateThemeClass", "(", "lookupThemeName", "(", ")", ")", ";", "if", "(", "ctrl", ")", "{", "var", "watchTheme", "=", "alwaysWatchTheme", "||", "ctrl", ".", "$shouldWatch", "||", "$mdUtil", ".", "parseAttributeBoolean", "(", "el", ".", "attr", "(", "'md-theme-watch'", ")", ")", ";", "if", "(", "watchTheme", "||", "ctrl", ".", "isAsyncTheme", ")", "{", "var", "clearNameWatcher", "=", "function", "(", ")", "{", "if", "(", "unwatch", ")", "{", "unwatch", "(", ")", ";", "unwatch", "=", "undefined", ";", "}", "}", ";", "var", "unwatch", "=", "ctrl", ".", "registerChanges", "(", "function", "(", "name", ")", "{", "updateThemeClass", "(", "name", ")", ";", "if", "(", "!", "watchTheme", ")", "{", "clearNameWatcher", "(", ")", ";", "}", "}", ")", ";", "if", "(", "scope", ")", "{", "scope", ".", "$on", "(", "'$destroy'", ",", "clearNameWatcher", ")", ";", "}", "else", "{", "el", ".", "on", "(", "'$destroy'", ",", "clearNameWatcher", ")", ";", "}", "}", "}", "/**\n * Find the theme name from the parent controller or element data\n */", "function", "lookupThemeName", "(", ")", "{", "// As a few components (dialog) add their controllers later, we should also watch for a controller init.", "return", "ctrl", "&&", "ctrl", ".", "$mdTheme", "||", "(", "defaultTheme", "===", "'default'", "?", "''", ":", "defaultTheme", ")", ";", "}", "/**\n * Remove old theme class and apply a new one\n * NOTE: if not a valid theme name, then the current name is not changed\n */", "function", "updateThemeClass", "(", "theme", ")", "{", "if", "(", "!", "theme", ")", "return", ";", "if", "(", "!", "registered", "(", "theme", ")", ")", "{", "$log", ".", "warn", "(", "'Attempted to use unregistered theme \\''", "+", "theme", "+", "'\\'. '", "+", "'Register it with $mdThemingProvider.theme().'", ")", ";", "}", "var", "oldTheme", "=", "el", ".", "data", "(", "'$mdThemeName'", ")", ";", "if", "(", "oldTheme", ")", "el", ".", "removeClass", "(", "'md-'", "+", "oldTheme", "+", "'-theme'", ")", ";", "el", ".", "addClass", "(", "'md-'", "+", "theme", "+", "'-theme'", ")", ";", "el", ".", "data", "(", "'$mdThemeName'", ",", "theme", ")", ";", "if", "(", "ctrl", ")", "{", "el", ".", "data", "(", "'$mdThemeController'", ",", "ctrl", ")", ";", "}", "}", "}" ]
Get theme name for the element, then update with Theme CSS class
[ "Get", "theme", "name", "for", "the", "element", "then", "update", "with", "Theme", "CSS", "class" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/theming/theming.js#L776-L838
5,003
angular/material
src/components/autocomplete/js/autocompleteController.js
init
function init () { $mdUtil.initOptionalProperties($scope, $attrs, { searchText: '', selectedItem: null, clearButton: false, disableVirtualRepeat: false, }); $mdTheming($element); configureWatchers(); $mdUtil.nextTick(function () { gatherElements(); moveDropdown(); // Forward all focus events to the input element when autofocus is enabled if ($scope.autofocus) { $element.on('focus', focusInputElement); } if ($scope.inputAriaDescribedBy) { elements.input.setAttribute('aria-describedby', $scope.inputAriaDescribedBy); } if (!$scope.floatingLabel) { if ($scope.inputAriaLabel) { elements.input.setAttribute('aria-label', $scope.inputAriaLabel); } else if ($scope.inputAriaLabelledBy) { elements.input.setAttribute('aria-labelledby', $scope.inputAriaLabelledBy); } else if ($scope.placeholder) { // If no aria-label or aria-labelledby references are defined, then just label using the // placeholder. elements.input.setAttribute('aria-label', $scope.placeholder); } } }); }
javascript
function init () { $mdUtil.initOptionalProperties($scope, $attrs, { searchText: '', selectedItem: null, clearButton: false, disableVirtualRepeat: false, }); $mdTheming($element); configureWatchers(); $mdUtil.nextTick(function () { gatherElements(); moveDropdown(); // Forward all focus events to the input element when autofocus is enabled if ($scope.autofocus) { $element.on('focus', focusInputElement); } if ($scope.inputAriaDescribedBy) { elements.input.setAttribute('aria-describedby', $scope.inputAriaDescribedBy); } if (!$scope.floatingLabel) { if ($scope.inputAriaLabel) { elements.input.setAttribute('aria-label', $scope.inputAriaLabel); } else if ($scope.inputAriaLabelledBy) { elements.input.setAttribute('aria-labelledby', $scope.inputAriaLabelledBy); } else if ($scope.placeholder) { // If no aria-label or aria-labelledby references are defined, then just label using the // placeholder. elements.input.setAttribute('aria-label', $scope.placeholder); } } }); }
[ "function", "init", "(", ")", "{", "$mdUtil", ".", "initOptionalProperties", "(", "$scope", ",", "$attrs", ",", "{", "searchText", ":", "''", ",", "selectedItem", ":", "null", ",", "clearButton", ":", "false", ",", "disableVirtualRepeat", ":", "false", ",", "}", ")", ";", "$mdTheming", "(", "$element", ")", ";", "configureWatchers", "(", ")", ";", "$mdUtil", ".", "nextTick", "(", "function", "(", ")", "{", "gatherElements", "(", ")", ";", "moveDropdown", "(", ")", ";", "// Forward all focus events to the input element when autofocus is enabled", "if", "(", "$scope", ".", "autofocus", ")", "{", "$element", ".", "on", "(", "'focus'", ",", "focusInputElement", ")", ";", "}", "if", "(", "$scope", ".", "inputAriaDescribedBy", ")", "{", "elements", ".", "input", ".", "setAttribute", "(", "'aria-describedby'", ",", "$scope", ".", "inputAriaDescribedBy", ")", ";", "}", "if", "(", "!", "$scope", ".", "floatingLabel", ")", "{", "if", "(", "$scope", ".", "inputAriaLabel", ")", "{", "elements", ".", "input", ".", "setAttribute", "(", "'aria-label'", ",", "$scope", ".", "inputAriaLabel", ")", ";", "}", "else", "if", "(", "$scope", ".", "inputAriaLabelledBy", ")", "{", "elements", ".", "input", ".", "setAttribute", "(", "'aria-labelledby'", ",", "$scope", ".", "inputAriaLabelledBy", ")", ";", "}", "else", "if", "(", "$scope", ".", "placeholder", ")", "{", "// If no aria-label or aria-labelledby references are defined, then just label using the", "// placeholder.", "elements", ".", "input", ".", "setAttribute", "(", "'aria-label'", ",", "$scope", ".", "placeholder", ")", ";", "}", "}", "}", ")", ";", "}" ]
initialization methods Initialize the controller, setup watchers, gather elements
[ "initialization", "methods", "Initialize", "the", "controller", "setup", "watchers", "gather", "elements" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L80-L115
5,004
angular/material
src/components/autocomplete/js/autocompleteController.js
getVerticalOffset
function getVerticalOffset () { var offset = 0; var inputContainer = $element.find('md-input-container'); if (inputContainer.length) { var input = inputContainer.find('input'); offset = inputContainer.prop('offsetHeight'); offset -= input.prop('offsetTop'); offset -= input.prop('offsetHeight'); // add in the height left up top for the floating label text offset += inputContainer.prop('offsetTop'); } return offset; }
javascript
function getVerticalOffset () { var offset = 0; var inputContainer = $element.find('md-input-container'); if (inputContainer.length) { var input = inputContainer.find('input'); offset = inputContainer.prop('offsetHeight'); offset -= input.prop('offsetTop'); offset -= input.prop('offsetHeight'); // add in the height left up top for the floating label text offset += inputContainer.prop('offsetTop'); } return offset; }
[ "function", "getVerticalOffset", "(", ")", "{", "var", "offset", "=", "0", ";", "var", "inputContainer", "=", "$element", ".", "find", "(", "'md-input-container'", ")", ";", "if", "(", "inputContainer", ".", "length", ")", "{", "var", "input", "=", "inputContainer", ".", "find", "(", "'input'", ")", ";", "offset", "=", "inputContainer", ".", "prop", "(", "'offsetHeight'", ")", ";", "offset", "-=", "input", ".", "prop", "(", "'offsetTop'", ")", ";", "offset", "-=", "input", ".", "prop", "(", "'offsetHeight'", ")", ";", "// add in the height left up top for the floating label text", "offset", "+=", "inputContainer", ".", "prop", "(", "'offsetTop'", ")", ";", "}", "return", "offset", ";", "}" ]
Calculates the vertical offset for floating label examples to account for ngMessages @returns {number}
[ "Calculates", "the", "vertical", "offset", "for", "floating", "label", "examples", "to", "account", "for", "ngMessages" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L188-L200
5,005
angular/material
src/components/autocomplete/js/autocompleteController.js
moveDropdown
function moveDropdown () { if (!elements.$.root.length) return; $mdTheming(elements.$.scrollContainer); elements.$.scrollContainer.detach(); elements.$.root.append(elements.$.scrollContainer); if ($animate.pin) $animate.pin(elements.$.scrollContainer, $rootElement); }
javascript
function moveDropdown () { if (!elements.$.root.length) return; $mdTheming(elements.$.scrollContainer); elements.$.scrollContainer.detach(); elements.$.root.append(elements.$.scrollContainer); if ($animate.pin) $animate.pin(elements.$.scrollContainer, $rootElement); }
[ "function", "moveDropdown", "(", ")", "{", "if", "(", "!", "elements", ".", "$", ".", "root", ".", "length", ")", "return", ";", "$mdTheming", "(", "elements", ".", "$", ".", "scrollContainer", ")", ";", "elements", ".", "$", ".", "scrollContainer", ".", "detach", "(", ")", ";", "elements", ".", "$", ".", "root", ".", "append", "(", "elements", ".", "$", ".", "scrollContainer", ")", ";", "if", "(", "$animate", ".", "pin", ")", "$animate", ".", "pin", "(", "elements", ".", "$", ".", "scrollContainer", ",", "$rootElement", ")", ";", "}" ]
Moves the dropdown menu to the body tag in order to avoid z-index and overflow issues.
[ "Moves", "the", "dropdown", "menu", "to", "the", "body", "tag", "in", "order", "to", "avoid", "z", "-", "index", "and", "overflow", "issues", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L218-L224
5,006
angular/material
src/components/autocomplete/js/autocompleteController.js
cleanup
function cleanup () { if (!ctrl.hidden) { $mdUtil.enableScrolling(); } angular.element($window).off('resize', debouncedOnResize); if (elements){ var items = ['ul', 'scroller', 'scrollContainer', 'input']; angular.forEach(items, function(key){ elements.$[key].remove(); }); } }
javascript
function cleanup () { if (!ctrl.hidden) { $mdUtil.enableScrolling(); } angular.element($window).off('resize', debouncedOnResize); if (elements){ var items = ['ul', 'scroller', 'scrollContainer', 'input']; angular.forEach(items, function(key){ elements.$[key].remove(); }); } }
[ "function", "cleanup", "(", ")", "{", "if", "(", "!", "ctrl", ".", "hidden", ")", "{", "$mdUtil", ".", "enableScrolling", "(", ")", ";", "}", "angular", ".", "element", "(", "$window", ")", ".", "off", "(", "'resize'", ",", "debouncedOnResize", ")", ";", "if", "(", "elements", ")", "{", "var", "items", "=", "[", "'ul'", ",", "'scroller'", ",", "'scrollContainer'", ",", "'input'", "]", ";", "angular", ".", "forEach", "(", "items", ",", "function", "(", "key", ")", "{", "elements", ".", "$", "[", "key", "]", ".", "remove", "(", ")", ";", "}", ")", ";", "}", "}" ]
Removes any events or leftover elements created by this controller
[ "Removes", "any", "events", "or", "leftover", "elements", "created", "by", "this", "controller" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L254-L267
5,007
angular/material
src/components/autocomplete/js/autocompleteController.js
gatherSnapWrap
function gatherSnapWrap() { var element; var value; for (element = $element; element.length; element = element.parent()) { value = element.attr('md-autocomplete-snap'); if (angular.isDefined(value)) break; } if (element.length) { return { snap: element[0], wrap: (value.toLowerCase() === 'width') ? element[0] : $element.find('md-autocomplete-wrap')[0] }; } var wrap = $element.find('md-autocomplete-wrap')[0]; return { snap: wrap, wrap: wrap }; }
javascript
function gatherSnapWrap() { var element; var value; for (element = $element; element.length; element = element.parent()) { value = element.attr('md-autocomplete-snap'); if (angular.isDefined(value)) break; } if (element.length) { return { snap: element[0], wrap: (value.toLowerCase() === 'width') ? element[0] : $element.find('md-autocomplete-wrap')[0] }; } var wrap = $element.find('md-autocomplete-wrap')[0]; return { snap: wrap, wrap: wrap }; }
[ "function", "gatherSnapWrap", "(", ")", "{", "var", "element", ";", "var", "value", ";", "for", "(", "element", "=", "$element", ";", "element", ".", "length", ";", "element", "=", "element", ".", "parent", "(", ")", ")", "{", "value", "=", "element", ".", "attr", "(", "'md-autocomplete-snap'", ")", ";", "if", "(", "angular", ".", "isDefined", "(", "value", ")", ")", "break", ";", "}", "if", "(", "element", ".", "length", ")", "{", "return", "{", "snap", ":", "element", "[", "0", "]", ",", "wrap", ":", "(", "value", ".", "toLowerCase", "(", ")", "===", "'width'", ")", "?", "element", "[", "0", "]", ":", "$element", ".", "find", "(", "'md-autocomplete-wrap'", ")", "[", "0", "]", "}", ";", "}", "var", "wrap", "=", "$element", ".", "find", "(", "'md-autocomplete-wrap'", ")", "[", "0", "]", ";", "return", "{", "snap", ":", "wrap", ",", "wrap", ":", "wrap", "}", ";", "}" ]
Gathers the snap and wrap elements
[ "Gathers", "the", "snap", "and", "wrap", "elements" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L306-L326
5,008
angular/material
src/components/autocomplete/js/autocompleteController.js
getAngularElements
function getAngularElements (elements) { var obj = {}; for (var key in elements) { if (elements.hasOwnProperty(key)) obj[ key ] = angular.element(elements[ key ]); } return obj; }
javascript
function getAngularElements (elements) { var obj = {}; for (var key in elements) { if (elements.hasOwnProperty(key)) obj[ key ] = angular.element(elements[ key ]); } return obj; }
[ "function", "getAngularElements", "(", "elements", ")", "{", "var", "obj", "=", "{", "}", ";", "for", "(", "var", "key", "in", "elements", ")", "{", "if", "(", "elements", ".", "hasOwnProperty", "(", "key", ")", ")", "obj", "[", "key", "]", "=", "angular", ".", "element", "(", "elements", "[", "key", "]", ")", ";", "}", "return", "obj", ";", "}" ]
Gathers angular-wrapped versions of each element @param elements @returns {{}}
[ "Gathers", "angular", "-", "wrapped", "versions", "of", "each", "element" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L333-L339
5,009
angular/material
src/components/autocomplete/js/autocompleteController.js
disableElementScrollEvents
function disableElementScrollEvents(element) { function preventDefault(e) { e.preventDefault(); } element.on('wheel', preventDefault); element.on('touchmove', preventDefault); return function() { element.off('wheel', preventDefault); element.off('touchmove', preventDefault); }; }
javascript
function disableElementScrollEvents(element) { function preventDefault(e) { e.preventDefault(); } element.on('wheel', preventDefault); element.on('touchmove', preventDefault); return function() { element.off('wheel', preventDefault); element.off('touchmove', preventDefault); }; }
[ "function", "disableElementScrollEvents", "(", "element", ")", "{", "function", "preventDefault", "(", "e", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "}", "element", ".", "on", "(", "'wheel'", ",", "preventDefault", ")", ";", "element", ".", "on", "(", "'touchmove'", ",", "preventDefault", ")", ";", "return", "function", "(", ")", "{", "element", ".", "off", "(", "'wheel'", ",", "preventDefault", ")", ";", "element", ".", "off", "(", "'touchmove'", ",", "preventDefault", ")", ";", "}", ";", "}" ]
Disables scrolling for a specific element
[ "Disables", "scrolling", "for", "a", "specific", "element" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L373-L386
5,010
angular/material
src/components/autocomplete/js/autocompleteController.js
onListLeave
function onListLeave () { if (!hasFocus && !ctrl.hidden) elements.input.focus(); noBlur = false; ctrl.hidden = shouldHide(); }
javascript
function onListLeave () { if (!hasFocus && !ctrl.hidden) elements.input.focus(); noBlur = false; ctrl.hidden = shouldHide(); }
[ "function", "onListLeave", "(", ")", "{", "if", "(", "!", "hasFocus", "&&", "!", "ctrl", ".", "hidden", ")", "elements", ".", "input", ".", "focus", "(", ")", ";", "noBlur", "=", "false", ";", "ctrl", ".", "hidden", "=", "shouldHide", "(", ")", ";", "}" ]
When the user's mouse leaves the menu, blur events may hide the menu again.
[ "When", "the", "user", "s", "mouse", "leaves", "the", "menu", "blur", "events", "may", "hide", "the", "menu", "again", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L398-L402
5,011
angular/material
src/components/autocomplete/js/autocompleteController.js
unregisterSelectedItemWatcher
function unregisterSelectedItemWatcher (cb) { var i = selectedItemWatchers.indexOf(cb); if (i !== -1) { selectedItemWatchers.splice(i, 1); } }
javascript
function unregisterSelectedItemWatcher (cb) { var i = selectedItemWatchers.indexOf(cb); if (i !== -1) { selectedItemWatchers.splice(i, 1); } }
[ "function", "unregisterSelectedItemWatcher", "(", "cb", ")", "{", "var", "i", "=", "selectedItemWatchers", ".", "indexOf", "(", "cb", ")", ";", "if", "(", "i", "!==", "-", "1", ")", "{", "selectedItemWatchers", ".", "splice", "(", "i", ",", "1", ")", ";", "}", "}" ]
Unregister a function previously registered for selected item changes. @param cb
[ "Unregister", "a", "function", "previously", "registered", "for", "selected", "item", "changes", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L483-L488
5,012
angular/material
src/components/autocomplete/js/autocompleteController.js
doBlur
function doBlur(forceBlur) { if (forceBlur) { noBlur = false; hasFocus = false; } elements.input.blur(); }
javascript
function doBlur(forceBlur) { if (forceBlur) { noBlur = false; hasFocus = false; } elements.input.blur(); }
[ "function", "doBlur", "(", "forceBlur", ")", "{", "if", "(", "forceBlur", ")", "{", "noBlur", "=", "false", ";", "hasFocus", "=", "false", ";", "}", "elements", ".", "input", ".", "blur", "(", ")", ";", "}" ]
Force blur on input element @param forceBlur
[ "Force", "blur", "on", "input", "element" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L544-L550
5,013
angular/material
src/components/autocomplete/js/autocompleteController.js
focus
function focus($event) { hasFocus = true; if (isSearchable() && isMinLengthMet()) { handleQuery(); } ctrl.hidden = shouldHide(); evalAttr('ngFocus', { $event: $event }); }
javascript
function focus($event) { hasFocus = true; if (isSearchable() && isMinLengthMet()) { handleQuery(); } ctrl.hidden = shouldHide(); evalAttr('ngFocus', { $event: $event }); }
[ "function", "focus", "(", "$event", ")", "{", "hasFocus", "=", "true", ";", "if", "(", "isSearchable", "(", ")", "&&", "isMinLengthMet", "(", ")", ")", "{", "handleQuery", "(", ")", ";", "}", "ctrl", ".", "hidden", "=", "shouldHide", "(", ")", ";", "evalAttr", "(", "'ngFocus'", ",", "{", "$event", ":", "$event", "}", ")", ";", "}" ]
Handles input focus event, determines if the dropdown should show.
[ "Handles", "input", "focus", "event", "determines", "if", "the", "dropdown", "should", "show", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L555-L565
5,014
angular/material
src/components/autocomplete/js/autocompleteController.js
getItemAsNameVal
function getItemAsNameVal (item) { if (!item) { return undefined; } var locals = {}; if (ctrl.itemName) { locals[ ctrl.itemName ] = item; } return locals; }
javascript
function getItemAsNameVal (item) { if (!item) { return undefined; } var locals = {}; if (ctrl.itemName) { locals[ ctrl.itemName ] = item; } return locals; }
[ "function", "getItemAsNameVal", "(", "item", ")", "{", "if", "(", "!", "item", ")", "{", "return", "undefined", ";", "}", "var", "locals", "=", "{", "}", ";", "if", "(", "ctrl", ".", "itemName", ")", "{", "locals", "[", "ctrl", ".", "itemName", "]", "=", "item", ";", "}", "return", "locals", ";", "}" ]
Returns the locals object for compiling item templates. @param item @returns {Object|undefined}
[ "Returns", "the", "locals", "object", "for", "compiling", "item", "templates", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L667-L678
5,015
angular/material
src/components/autocomplete/js/autocompleteController.js
isSearchable
function isSearchable() { if (ctrl.loading && !hasMatches()) { // No query when query is in progress. return false; } else if (hasSelection()) { // No query if there is already a selection return false; } else if (!hasFocus) { // No query if the input does not have focus return false; } return true; }
javascript
function isSearchable() { if (ctrl.loading && !hasMatches()) { // No query when query is in progress. return false; } else if (hasSelection()) { // No query if there is already a selection return false; } else if (!hasFocus) { // No query if the input does not have focus return false; } return true; }
[ "function", "isSearchable", "(", ")", "{", "if", "(", "ctrl", ".", "loading", "&&", "!", "hasMatches", "(", ")", ")", "{", "// No query when query is in progress.", "return", "false", ";", "}", "else", "if", "(", "hasSelection", "(", ")", ")", "{", "// No query if there is already a selection", "return", "false", ";", "}", "else", "if", "(", "!", "hasFocus", ")", "{", "// No query if the input does not have focus", "return", "false", ";", "}", "return", "true", ";", "}" ]
Determines whether the autocomplete is able to query within the current state. @returns {boolean} true if the query can be run
[ "Determines", "whether", "the", "autocomplete", "is", "able", "to", "query", "within", "the", "current", "state", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L713-L726
5,016
angular/material
src/components/autocomplete/js/autocompleteController.js
select
function select (index) { // force form to update state for validation $mdUtil.nextTick(function () { getDisplayValue(ctrl.matches[ index ]).then(function (val) { var ngModel = elements.$.input.controller('ngModel'); $mdLiveAnnouncer.announce(val + ' ' + ctrl.selectedMessage, 'assertive'); ngModel.$setViewValue(val); ngModel.$render(); }).finally(function () { $scope.selectedItem = ctrl.matches[ index ]; setLoading(false); }); }, false); }
javascript
function select (index) { // force form to update state for validation $mdUtil.nextTick(function () { getDisplayValue(ctrl.matches[ index ]).then(function (val) { var ngModel = elements.$.input.controller('ngModel'); $mdLiveAnnouncer.announce(val + ' ' + ctrl.selectedMessage, 'assertive'); ngModel.$setViewValue(val); ngModel.$render(); }).finally(function () { $scope.selectedItem = ctrl.matches[ index ]; setLoading(false); }); }, false); }
[ "function", "select", "(", "index", ")", "{", "// force form to update state for validation", "$mdUtil", ".", "nextTick", "(", "function", "(", ")", "{", "getDisplayValue", "(", "ctrl", ".", "matches", "[", "index", "]", ")", ".", "then", "(", "function", "(", "val", ")", "{", "var", "ngModel", "=", "elements", ".", "$", ".", "input", ".", "controller", "(", "'ngModel'", ")", ";", "$mdLiveAnnouncer", ".", "announce", "(", "val", "+", "' '", "+", "ctrl", ".", "selectedMessage", ",", "'assertive'", ")", ";", "ngModel", ".", "$setViewValue", "(", "val", ")", ";", "ngModel", ".", "$render", "(", ")", ";", "}", ")", ".", "finally", "(", "function", "(", ")", "{", "$scope", ".", "selectedItem", "=", "ctrl", ".", "matches", "[", "index", "]", ";", "setLoading", "(", "false", ")", ";", "}", ")", ";", "}", ",", "false", ")", ";", "}" ]
Selects the item at the given index. @param {number} index to select
[ "Selects", "the", "item", "at", "the", "given", "index", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L819-L832
5,017
angular/material
src/components/autocomplete/js/autocompleteController.js
reportMessages
function reportMessages(isPolite, types) { var politeness = isPolite ? 'polite' : 'assertive'; var messages = []; if (types & ReportType.Selected && ctrl.index !== -1) { messages.push(getCurrentDisplayValue()); } if (types & ReportType.Count) { messages.push($q.resolve(getCountMessage())); } $q.all(messages).then(function(data) { $mdLiveAnnouncer.announce(data.join(' '), politeness); }); }
javascript
function reportMessages(isPolite, types) { var politeness = isPolite ? 'polite' : 'assertive'; var messages = []; if (types & ReportType.Selected && ctrl.index !== -1) { messages.push(getCurrentDisplayValue()); } if (types & ReportType.Count) { messages.push($q.resolve(getCountMessage())); } $q.all(messages).then(function(data) { $mdLiveAnnouncer.announce(data.join(' '), politeness); }); }
[ "function", "reportMessages", "(", "isPolite", ",", "types", ")", "{", "var", "politeness", "=", "isPolite", "?", "'polite'", ":", "'assertive'", ";", "var", "messages", "=", "[", "]", ";", "if", "(", "types", "&", "ReportType", ".", "Selected", "&&", "ctrl", ".", "index", "!==", "-", "1", ")", "{", "messages", ".", "push", "(", "getCurrentDisplayValue", "(", ")", ")", ";", "}", "if", "(", "types", "&", "ReportType", ".", "Count", ")", "{", "messages", ".", "push", "(", "$q", ".", "resolve", "(", "getCountMessage", "(", ")", ")", ")", ";", "}", "$q", ".", "all", "(", "messages", ")", ".", "then", "(", "function", "(", "data", ")", "{", "$mdLiveAnnouncer", ".", "announce", "(", "data", ".", "join", "(", "' '", ")", ",", "politeness", ")", ";", "}", ")", ";", "}" ]
Reports given message types to supported screen readers. @param {boolean} isPolite Whether the announcement should be polite. @param {!number} types Message flags to be reported to the screen reader.
[ "Reports", "given", "message", "types", "to", "supported", "screen", "readers", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L928-L943
5,018
angular/material
src/components/autocomplete/js/autocompleteController.js
handleQuery
function handleQuery () { var searchText = $scope.searchText || ''; var term = searchText.toLowerCase(); // If caching is enabled and the current searchText is stored in the cache if (!$scope.noCache && cache[term]) { // The results should be handled as same as a normal un-cached request does. handleResults(cache[term]); } else { fetchResults(searchText); } ctrl.hidden = shouldHide(); }
javascript
function handleQuery () { var searchText = $scope.searchText || ''; var term = searchText.toLowerCase(); // If caching is enabled and the current searchText is stored in the cache if (!$scope.noCache && cache[term]) { // The results should be handled as same as a normal un-cached request does. handleResults(cache[term]); } else { fetchResults(searchText); } ctrl.hidden = shouldHide(); }
[ "function", "handleQuery", "(", ")", "{", "var", "searchText", "=", "$scope", ".", "searchText", "||", "''", ";", "var", "term", "=", "searchText", ".", "toLowerCase", "(", ")", ";", "// If caching is enabled and the current searchText is stored in the cache", "if", "(", "!", "$scope", ".", "noCache", "&&", "cache", "[", "term", "]", ")", "{", "// The results should be handled as same as a normal un-cached request does.", "handleResults", "(", "cache", "[", "term", "]", ")", ";", "}", "else", "{", "fetchResults", "(", "searchText", ")", ";", "}", "ctrl", ".", "hidden", "=", "shouldHide", "(", ")", ";", "}" ]
Starts the query to gather the results for the current searchText. Attempts to return cached results first, then forwards the process to `fetchResults` if necessary.
[ "Starts", "the", "query", "to", "gather", "the", "results", "for", "the", "current", "searchText", ".", "Attempts", "to", "return", "cached", "results", "first", "then", "forwards", "the", "process", "to", "fetchResults", "if", "necessary", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L1023-L1036
5,019
angular/material
src/components/datepicker/js/datepickerDirective.spec.js
createDatepickerInstance
function createDatepickerInstance(template) { var outputElement = $compile(template)(pageScope); pageScope.$apply(); ngElement = outputElement[0].tagName == 'MD-DATEPICKER' ? outputElement : outputElement.find('md-datepicker'); element = ngElement[0]; scope = ngElement.isolateScope(); controller = ngElement.controller('mdDatepicker'); return outputElement; }
javascript
function createDatepickerInstance(template) { var outputElement = $compile(template)(pageScope); pageScope.$apply(); ngElement = outputElement[0].tagName == 'MD-DATEPICKER' ? outputElement : outputElement.find('md-datepicker'); element = ngElement[0]; scope = ngElement.isolateScope(); controller = ngElement.controller('mdDatepicker'); return outputElement; }
[ "function", "createDatepickerInstance", "(", "template", ")", "{", "var", "outputElement", "=", "$compile", "(", "template", ")", "(", "pageScope", ")", ";", "pageScope", ".", "$apply", "(", ")", ";", "ngElement", "=", "outputElement", "[", "0", "]", ".", "tagName", "==", "'MD-DATEPICKER'", "?", "outputElement", ":", "outputElement", ".", "find", "(", "'md-datepicker'", ")", ";", "element", "=", "ngElement", "[", "0", "]", ";", "scope", "=", "ngElement", ".", "isolateScope", "(", ")", ";", "controller", "=", "ngElement", ".", "controller", "(", "'mdDatepicker'", ")", ";", "return", "outputElement", ";", "}" ]
Compile and link the given template and store values for element, scope, and controller. @param {string} template @returns {angular.JQLite} The root compiled element.
[ "Compile", "and", "link", "the", "given", "template", "and", "store", "values", "for", "element", "scope", "and", "controller", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/datepickerDirective.spec.js#L58-L69
5,020
angular/material
gulp/util.js
buildJs
function buildJs() { const jsFiles = config.jsCoreFiles; config.componentPaths.forEach(component => { jsFiles.push(path.join(component, '*.js')); jsFiles.push(path.join(component, '**/*.js')); }); gutil.log("building js files..."); const jsBuildStream = gulp.src(jsFiles) .pipe(filterNonCodeFiles()) .pipe(utils.buildNgMaterialDefinition()) .pipe(plumber()) .pipe(ngAnnotate()) .pipe(utils.addJsWrapper(true)); const jsProcess = series(jsBuildStream, themeBuildStream()) .pipe(concat('angular-material.js')) .pipe(BUILD_MODE.transform()) .pipe(insert.prepend(config.banner)) .pipe(insert.append(';window.ngMaterial={version:{full: "' + VERSION + '"}};')) .pipe(gulp.dest(config.outputDir)) .pipe(gulpif(!IS_DEV, uglify({output: {comments: 'some'}}))) .pipe(rename({extname: '.min.js'})) .pipe(gulp.dest(config.outputDir)); return series(jsProcess, deployMaterialMocks()); // Deploy the `angular-material-mocks.js` file to the `dist` directory function deployMaterialMocks() { return gulp.src(config.mockFiles) .pipe(gulp.dest(config.outputDir)); } }
javascript
function buildJs() { const jsFiles = config.jsCoreFiles; config.componentPaths.forEach(component => { jsFiles.push(path.join(component, '*.js')); jsFiles.push(path.join(component, '**/*.js')); }); gutil.log("building js files..."); const jsBuildStream = gulp.src(jsFiles) .pipe(filterNonCodeFiles()) .pipe(utils.buildNgMaterialDefinition()) .pipe(plumber()) .pipe(ngAnnotate()) .pipe(utils.addJsWrapper(true)); const jsProcess = series(jsBuildStream, themeBuildStream()) .pipe(concat('angular-material.js')) .pipe(BUILD_MODE.transform()) .pipe(insert.prepend(config.banner)) .pipe(insert.append(';window.ngMaterial={version:{full: "' + VERSION + '"}};')) .pipe(gulp.dest(config.outputDir)) .pipe(gulpif(!IS_DEV, uglify({output: {comments: 'some'}}))) .pipe(rename({extname: '.min.js'})) .pipe(gulp.dest(config.outputDir)); return series(jsProcess, deployMaterialMocks()); // Deploy the `angular-material-mocks.js` file to the `dist` directory function deployMaterialMocks() { return gulp.src(config.mockFiles) .pipe(gulp.dest(config.outputDir)); } }
[ "function", "buildJs", "(", ")", "{", "const", "jsFiles", "=", "config", ".", "jsCoreFiles", ";", "config", ".", "componentPaths", ".", "forEach", "(", "component", "=>", "{", "jsFiles", ".", "push", "(", "path", ".", "join", "(", "component", ",", "'*.js'", ")", ")", ";", "jsFiles", ".", "push", "(", "path", ".", "join", "(", "component", ",", "'**/*.js'", ")", ")", ";", "}", ")", ";", "gutil", ".", "log", "(", "\"building js files...\"", ")", ";", "const", "jsBuildStream", "=", "gulp", ".", "src", "(", "jsFiles", ")", ".", "pipe", "(", "filterNonCodeFiles", "(", ")", ")", ".", "pipe", "(", "utils", ".", "buildNgMaterialDefinition", "(", ")", ")", ".", "pipe", "(", "plumber", "(", ")", ")", ".", "pipe", "(", "ngAnnotate", "(", ")", ")", ".", "pipe", "(", "utils", ".", "addJsWrapper", "(", "true", ")", ")", ";", "const", "jsProcess", "=", "series", "(", "jsBuildStream", ",", "themeBuildStream", "(", ")", ")", ".", "pipe", "(", "concat", "(", "'angular-material.js'", ")", ")", ".", "pipe", "(", "BUILD_MODE", ".", "transform", "(", ")", ")", ".", "pipe", "(", "insert", ".", "prepend", "(", "config", ".", "banner", ")", ")", ".", "pipe", "(", "insert", ".", "append", "(", "';window.ngMaterial={version:{full: \"'", "+", "VERSION", "+", "'\"}};'", ")", ")", ".", "pipe", "(", "gulp", ".", "dest", "(", "config", ".", "outputDir", ")", ")", ".", "pipe", "(", "gulpif", "(", "!", "IS_DEV", ",", "uglify", "(", "{", "output", ":", "{", "comments", ":", "'some'", "}", "}", ")", ")", ")", ".", "pipe", "(", "rename", "(", "{", "extname", ":", "'.min.js'", "}", ")", ")", ".", "pipe", "(", "gulp", ".", "dest", "(", "config", ".", "outputDir", ")", ")", ";", "return", "series", "(", "jsProcess", ",", "deployMaterialMocks", "(", ")", ")", ";", "// Deploy the `angular-material-mocks.js` file to the `dist` directory", "function", "deployMaterialMocks", "(", ")", "{", "return", "gulp", ".", "src", "(", "config", ".", "mockFiles", ")", ".", "pipe", "(", "gulp", ".", "dest", "(", "config", ".", "outputDir", ")", ")", ";", "}", "}" ]
Builds the entire component library javascript.
[ "Builds", "the", "entire", "component", "library", "javascript", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/gulp/util.js#L43-L76
5,021
angular/material
gulp/util.js
deployMaterialMocks
function deployMaterialMocks() { return gulp.src(config.mockFiles) .pipe(gulp.dest(config.outputDir)); }
javascript
function deployMaterialMocks() { return gulp.src(config.mockFiles) .pipe(gulp.dest(config.outputDir)); }
[ "function", "deployMaterialMocks", "(", ")", "{", "return", "gulp", ".", "src", "(", "config", ".", "mockFiles", ")", ".", "pipe", "(", "gulp", ".", "dest", "(", "config", ".", "outputDir", ")", ")", ";", "}" ]
Deploy the `angular-material-mocks.js` file to the `dist` directory
[ "Deploy", "the", "angular", "-", "material", "-", "mocks", ".", "js", "file", "to", "the", "dist", "directory" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/gulp/util.js#L72-L75
5,022
angular/material
gulp/util.js
themeBuildStream
function themeBuildStream() { // Make a copy so that we don't modify the actual config that is used by other functions var paths = config.themeBaseFiles.slice(0); config.componentPaths.forEach(component => paths.push(path.join(component, '*-theme.scss'))); paths.push(config.themeCore); return gulp.src(paths) .pipe(concat('default-theme.scss')) .pipe(utils.hoistScssVariables()) .pipe(sass()) .pipe(dedupeCss()) // The PostCSS orderedValues plugin modifies the theme color expressions. .pipe(minifyCss({orderedValues: false})) .pipe(utils.cssToNgConstant('material.core', '$MD_THEME_CSS')); }
javascript
function themeBuildStream() { // Make a copy so that we don't modify the actual config that is used by other functions var paths = config.themeBaseFiles.slice(0); config.componentPaths.forEach(component => paths.push(path.join(component, '*-theme.scss'))); paths.push(config.themeCore); return gulp.src(paths) .pipe(concat('default-theme.scss')) .pipe(utils.hoistScssVariables()) .pipe(sass()) .pipe(dedupeCss()) // The PostCSS orderedValues plugin modifies the theme color expressions. .pipe(minifyCss({orderedValues: false})) .pipe(utils.cssToNgConstant('material.core', '$MD_THEME_CSS')); }
[ "function", "themeBuildStream", "(", ")", "{", "// Make a copy so that we don't modify the actual config that is used by other functions", "var", "paths", "=", "config", ".", "themeBaseFiles", ".", "slice", "(", "0", ")", ";", "config", ".", "componentPaths", ".", "forEach", "(", "component", "=>", "paths", ".", "push", "(", "path", ".", "join", "(", "component", ",", "'*-theme.scss'", ")", ")", ")", ";", "paths", ".", "push", "(", "config", ".", "themeCore", ")", ";", "return", "gulp", ".", "src", "(", "paths", ")", ".", "pipe", "(", "concat", "(", "'default-theme.scss'", ")", ")", ".", "pipe", "(", "utils", ".", "hoistScssVariables", "(", ")", ")", ".", "pipe", "(", "sass", "(", ")", ")", ".", "pipe", "(", "dedupeCss", "(", ")", ")", "// The PostCSS orderedValues plugin modifies the theme color expressions.", ".", "pipe", "(", "minifyCss", "(", "{", "orderedValues", ":", "false", "}", ")", ")", ".", "pipe", "(", "utils", ".", "cssToNgConstant", "(", "'material.core'", ",", "'$MD_THEME_CSS'", ")", ")", ";", "}" ]
builds the theming related css and provides it as a JS const for angular
[ "builds", "the", "theming", "related", "css", "and", "provides", "it", "as", "a", "JS", "const", "for", "angular" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/gulp/util.js#L235-L249
5,023
angular/material
gulp/util.js
dedupeCss
function dedupeCss() { const prefixRegex = /-(webkit|moz|ms|o)-.+/; return insert.transform(function(contents) { // Parse the CSS into an AST. const parsed = postcss.parse(contents); // Walk through all the rules, skipping comments, media queries etc. parsed.walk(function(rule) { // Skip over any comments, media queries and rules that have less than 2 properties. if (rule.type !== 'rule' || !rule.nodes || rule.nodes.length < 2) return; // Walk all of the properties within a rule. rule.walk(function(prop) { // Check if there's a similar property that comes after the current one. const hasDuplicate = validateProp(prop) && _.find(rule.nodes, function(otherProp) { return prop !== otherProp && prop.prop === otherProp.prop && validateProp(otherProp); }); // Remove the declaration if it's duplicated. if (hasDuplicate) { prop.remove(); gutil.log(gutil.colors.yellow( 'Removed duplicate property: "' + prop.prop + ': ' + prop.value + '" from "' + rule.selector + '"...' )); } }); }); // Turn the AST back into CSS. return parsed.toResult().css; }); // Checks if a property is a style declaration and that it // doesn't contain any vendor prefixes. function validateProp(prop) { return prop && prop.type === 'decl' && ![prop.prop, prop.value].some(function(value) { return value.indexOf('-') > -1 && prefixRegex.test(value); }); } }
javascript
function dedupeCss() { const prefixRegex = /-(webkit|moz|ms|o)-.+/; return insert.transform(function(contents) { // Parse the CSS into an AST. const parsed = postcss.parse(contents); // Walk through all the rules, skipping comments, media queries etc. parsed.walk(function(rule) { // Skip over any comments, media queries and rules that have less than 2 properties. if (rule.type !== 'rule' || !rule.nodes || rule.nodes.length < 2) return; // Walk all of the properties within a rule. rule.walk(function(prop) { // Check if there's a similar property that comes after the current one. const hasDuplicate = validateProp(prop) && _.find(rule.nodes, function(otherProp) { return prop !== otherProp && prop.prop === otherProp.prop && validateProp(otherProp); }); // Remove the declaration if it's duplicated. if (hasDuplicate) { prop.remove(); gutil.log(gutil.colors.yellow( 'Removed duplicate property: "' + prop.prop + ': ' + prop.value + '" from "' + rule.selector + '"...' )); } }); }); // Turn the AST back into CSS. return parsed.toResult().css; }); // Checks if a property is a style declaration and that it // doesn't contain any vendor prefixes. function validateProp(prop) { return prop && prop.type === 'decl' && ![prop.prop, prop.value].some(function(value) { return value.indexOf('-') > -1 && prefixRegex.test(value); }); } }
[ "function", "dedupeCss", "(", ")", "{", "const", "prefixRegex", "=", "/", "-(webkit|moz|ms|o)-.+", "/", ";", "return", "insert", ".", "transform", "(", "function", "(", "contents", ")", "{", "// Parse the CSS into an AST.", "const", "parsed", "=", "postcss", ".", "parse", "(", "contents", ")", ";", "// Walk through all the rules, skipping comments, media queries etc.", "parsed", ".", "walk", "(", "function", "(", "rule", ")", "{", "// Skip over any comments, media queries and rules that have less than 2 properties.", "if", "(", "rule", ".", "type", "!==", "'rule'", "||", "!", "rule", ".", "nodes", "||", "rule", ".", "nodes", ".", "length", "<", "2", ")", "return", ";", "// Walk all of the properties within a rule.", "rule", ".", "walk", "(", "function", "(", "prop", ")", "{", "// Check if there's a similar property that comes after the current one.", "const", "hasDuplicate", "=", "validateProp", "(", "prop", ")", "&&", "_", ".", "find", "(", "rule", ".", "nodes", ",", "function", "(", "otherProp", ")", "{", "return", "prop", "!==", "otherProp", "&&", "prop", ".", "prop", "===", "otherProp", ".", "prop", "&&", "validateProp", "(", "otherProp", ")", ";", "}", ")", ";", "// Remove the declaration if it's duplicated.", "if", "(", "hasDuplicate", ")", "{", "prop", ".", "remove", "(", ")", ";", "gutil", ".", "log", "(", "gutil", ".", "colors", ".", "yellow", "(", "'Removed duplicate property: \"'", "+", "prop", ".", "prop", "+", "': '", "+", "prop", ".", "value", "+", "'\" from \"'", "+", "rule", ".", "selector", "+", "'\"...'", ")", ")", ";", "}", "}", ")", ";", "}", ")", ";", "// Turn the AST back into CSS.", "return", "parsed", ".", "toResult", "(", ")", ".", "css", ";", "}", ")", ";", "// Checks if a property is a style declaration and that it", "// doesn't contain any vendor prefixes.", "function", "validateProp", "(", "prop", ")", "{", "return", "prop", "&&", "prop", ".", "type", "===", "'decl'", "&&", "!", "[", "prop", ".", "prop", ",", "prop", ".", "value", "]", ".", "some", "(", "function", "(", "value", ")", "{", "return", "value", ".", "indexOf", "(", "'-'", ")", ">", "-", "1", "&&", "prefixRegex", ".", "test", "(", "value", ")", ";", "}", ")", ";", "}", "}" ]
Removes duplicated CSS properties.
[ "Removes", "duplicated", "CSS", "properties", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/gulp/util.js#L252-L294
5,024
angular/material
gulp/util.js
validateProp
function validateProp(prop) { return prop && prop.type === 'decl' && ![prop.prop, prop.value].some(function(value) { return value.indexOf('-') > -1 && prefixRegex.test(value); }); }
javascript
function validateProp(prop) { return prop && prop.type === 'decl' && ![prop.prop, prop.value].some(function(value) { return value.indexOf('-') > -1 && prefixRegex.test(value); }); }
[ "function", "validateProp", "(", "prop", ")", "{", "return", "prop", "&&", "prop", ".", "type", "===", "'decl'", "&&", "!", "[", "prop", ".", "prop", ",", "prop", ".", "value", "]", ".", "some", "(", "function", "(", "value", ")", "{", "return", "value", ".", "indexOf", "(", "'-'", ")", ">", "-", "1", "&&", "prefixRegex", ".", "test", "(", "value", ")", ";", "}", ")", ";", "}" ]
Checks if a property is a style declaration and that it doesn't contain any vendor prefixes.
[ "Checks", "if", "a", "property", "is", "a", "style", "declaration", "and", "that", "it", "doesn", "t", "contain", "any", "vendor", "prefixes", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/gulp/util.js#L289-L293
5,025
angular/material
src/core/util/iterator.js
add
function add(item, index) { if (!item) return -1; if (!angular.isNumber(index)) { index = _items.length; } _items.splice(index, 0, item); return indexOf(item); }
javascript
function add(item, index) { if (!item) return -1; if (!angular.isNumber(index)) { index = _items.length; } _items.splice(index, 0, item); return indexOf(item); }
[ "function", "add", "(", "item", ",", "index", ")", "{", "if", "(", "!", "item", ")", "return", "-", "1", ";", "if", "(", "!", "angular", ".", "isNumber", "(", "index", ")", ")", "{", "index", "=", "_items", ".", "length", ";", "}", "_items", ".", "splice", "(", "index", ",", "0", ",", "item", ")", ";", "return", "indexOf", "(", "item", ")", ";", "}" ]
Add item to list @param item @param index @returns {*}
[ "Add", "item", "to", "list" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/iterator.js#L134-L144
5,026
angular/material
src/core/util/iterator.js
findSubsequentItem
function findSubsequentItem(backwards, item, validate, limit) { validate = validate || trueFn; var curIndex = indexOf(item); while (true) { if (!inRange(curIndex)) return null; var nextIndex = curIndex + (backwards ? -1 : 1); var foundItem = null; if (inRange(nextIndex)) { foundItem = _items[nextIndex]; } else if (reloop) { foundItem = backwards ? last() : first(); nextIndex = indexOf(foundItem); } if ((foundItem === null) || (nextIndex === limit)) return null; if (validate(foundItem)) return foundItem; if (angular.isUndefined(limit)) limit = nextIndex; curIndex = nextIndex; } }
javascript
function findSubsequentItem(backwards, item, validate, limit) { validate = validate || trueFn; var curIndex = indexOf(item); while (true) { if (!inRange(curIndex)) return null; var nextIndex = curIndex + (backwards ? -1 : 1); var foundItem = null; if (inRange(nextIndex)) { foundItem = _items[nextIndex]; } else if (reloop) { foundItem = backwards ? last() : first(); nextIndex = indexOf(foundItem); } if ((foundItem === null) || (nextIndex === limit)) return null; if (validate(foundItem)) return foundItem; if (angular.isUndefined(limit)) limit = nextIndex; curIndex = nextIndex; } }
[ "function", "findSubsequentItem", "(", "backwards", ",", "item", ",", "validate", ",", "limit", ")", "{", "validate", "=", "validate", "||", "trueFn", ";", "var", "curIndex", "=", "indexOf", "(", "item", ")", ";", "while", "(", "true", ")", "{", "if", "(", "!", "inRange", "(", "curIndex", ")", ")", "return", "null", ";", "var", "nextIndex", "=", "curIndex", "+", "(", "backwards", "?", "-", "1", ":", "1", ")", ";", "var", "foundItem", "=", "null", ";", "if", "(", "inRange", "(", "nextIndex", ")", ")", "{", "foundItem", "=", "_items", "[", "nextIndex", "]", ";", "}", "else", "if", "(", "reloop", ")", "{", "foundItem", "=", "backwards", "?", "last", "(", ")", ":", "first", "(", ")", ";", "nextIndex", "=", "indexOf", "(", "foundItem", ")", ";", "}", "if", "(", "(", "foundItem", "===", "null", ")", "||", "(", "nextIndex", "===", "limit", ")", ")", "return", "null", ";", "if", "(", "validate", "(", "foundItem", ")", ")", "return", "foundItem", ";", "if", "(", "angular", ".", "isUndefined", "(", "limit", ")", ")", "limit", "=", "nextIndex", ";", "curIndex", "=", "nextIndex", ";", "}", "}" ]
Find the next item. If reloop is true and at the end of the list, it will go back to the first item. If given, the `validate` callback will be used to determine whether the next item is valid. If not valid, it will try to find the next item again. @param {boolean} backwards Specifies the direction of searching (forwards/backwards) @param {*} item The item whose subsequent item we are looking for @param {Function=} validate The `validate` function @param {integer=} limit The recursion limit @returns {*} The subsequent item or null
[ "Find", "the", "next", "item", ".", "If", "reloop", "is", "true", "and", "at", "the", "end", "of", "the", "list", "it", "will", "go", "back", "to", "the", "first", "item", ".", "If", "given", "the", "validate", "callback", "will", "be", "used", "to", "determine", "whether", "the", "next", "item", "is", "valid", ".", "If", "not", "valid", "it", "will", "try", "to", "find", "the", "next", "item", "again", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/iterator.js#L202-L225
5,027
angular/material
src/components/select/select.js
preLink
function preLink(scope, element, attr, ctrls) { var selectCtrl = ctrls[0]; element.addClass('_md'); // private md component indicator for styling $mdTheming(element); element.on('click', clickListener); element.on('keypress', keyListener); function keyListener(e) { if (e.keyCode == 13 || e.keyCode == 32) { clickListener(e); } } function clickListener(ev) { var option = $mdUtil.getClosest(ev.target, 'md-option'); var optionCtrl = option && angular.element(option).data('$mdOptionController'); if (!option || !optionCtrl) return; if (option.hasAttribute('disabled')) { ev.stopImmediatePropagation(); return false; } var optionHashKey = selectCtrl.hashGetter(optionCtrl.value); var isSelected = angular.isDefined(selectCtrl.selected[optionHashKey]); scope.$apply(function() { if (selectCtrl.isMultiple) { if (isSelected) { selectCtrl.deselect(optionHashKey); } else { selectCtrl.select(optionHashKey, optionCtrl.value); } } else { if (!isSelected) { selectCtrl.deselect(Object.keys(selectCtrl.selected)[0]); selectCtrl.select(optionHashKey, optionCtrl.value); } } selectCtrl.refreshViewValue(); }); } }
javascript
function preLink(scope, element, attr, ctrls) { var selectCtrl = ctrls[0]; element.addClass('_md'); // private md component indicator for styling $mdTheming(element); element.on('click', clickListener); element.on('keypress', keyListener); function keyListener(e) { if (e.keyCode == 13 || e.keyCode == 32) { clickListener(e); } } function clickListener(ev) { var option = $mdUtil.getClosest(ev.target, 'md-option'); var optionCtrl = option && angular.element(option).data('$mdOptionController'); if (!option || !optionCtrl) return; if (option.hasAttribute('disabled')) { ev.stopImmediatePropagation(); return false; } var optionHashKey = selectCtrl.hashGetter(optionCtrl.value); var isSelected = angular.isDefined(selectCtrl.selected[optionHashKey]); scope.$apply(function() { if (selectCtrl.isMultiple) { if (isSelected) { selectCtrl.deselect(optionHashKey); } else { selectCtrl.select(optionHashKey, optionCtrl.value); } } else { if (!isSelected) { selectCtrl.deselect(Object.keys(selectCtrl.selected)[0]); selectCtrl.select(optionHashKey, optionCtrl.value); } } selectCtrl.refreshViewValue(); }); } }
[ "function", "preLink", "(", "scope", ",", "element", ",", "attr", ",", "ctrls", ")", "{", "var", "selectCtrl", "=", "ctrls", "[", "0", "]", ";", "element", ".", "addClass", "(", "'_md'", ")", ";", "// private md component indicator for styling", "$mdTheming", "(", "element", ")", ";", "element", ".", "on", "(", "'click'", ",", "clickListener", ")", ";", "element", ".", "on", "(", "'keypress'", ",", "keyListener", ")", ";", "function", "keyListener", "(", "e", ")", "{", "if", "(", "e", ".", "keyCode", "==", "13", "||", "e", ".", "keyCode", "==", "32", ")", "{", "clickListener", "(", "e", ")", ";", "}", "}", "function", "clickListener", "(", "ev", ")", "{", "var", "option", "=", "$mdUtil", ".", "getClosest", "(", "ev", ".", "target", ",", "'md-option'", ")", ";", "var", "optionCtrl", "=", "option", "&&", "angular", ".", "element", "(", "option", ")", ".", "data", "(", "'$mdOptionController'", ")", ";", "if", "(", "!", "option", "||", "!", "optionCtrl", ")", "return", ";", "if", "(", "option", ".", "hasAttribute", "(", "'disabled'", ")", ")", "{", "ev", ".", "stopImmediatePropagation", "(", ")", ";", "return", "false", ";", "}", "var", "optionHashKey", "=", "selectCtrl", ".", "hashGetter", "(", "optionCtrl", ".", "value", ")", ";", "var", "isSelected", "=", "angular", ".", "isDefined", "(", "selectCtrl", ".", "selected", "[", "optionHashKey", "]", ")", ";", "scope", ".", "$apply", "(", "function", "(", ")", "{", "if", "(", "selectCtrl", ".", "isMultiple", ")", "{", "if", "(", "isSelected", ")", "{", "selectCtrl", ".", "deselect", "(", "optionHashKey", ")", ";", "}", "else", "{", "selectCtrl", ".", "select", "(", "optionHashKey", ",", "optionCtrl", ".", "value", ")", ";", "}", "}", "else", "{", "if", "(", "!", "isSelected", ")", "{", "selectCtrl", ".", "deselect", "(", "Object", ".", "keys", "(", "selectCtrl", ".", "selected", ")", "[", "0", "]", ")", ";", "selectCtrl", ".", "select", "(", "optionHashKey", ",", "optionCtrl", ".", "value", ")", ";", "}", "}", "selectCtrl", ".", "refreshViewValue", "(", ")", ";", "}", ")", ";", "}", "}" ]
We use preLink instead of postLink to ensure that the select is initialized before its child options run postLink.
[ "We", "use", "preLink", "instead", "of", "postLink", "to", "ensure", "that", "the", "select", "is", "initialized", "before", "its", "child", "options", "run", "postLink", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/select/select.js#L600-L643
5,028
angular/material
src/components/select/select.js
cleanElement
function cleanElement() { destroyListener(); element .removeClass('md-active') .attr('aria-hidden', 'true') .css({ 'display': 'none', 'top': '', 'right': '', 'bottom': '', 'left': '', 'font-size': '', 'min-width': '' }); element.parent().find('md-select-value').removeAttr('aria-hidden'); announceClosed(opts); if (!opts.$destroy && opts.restoreFocus) { opts.target.focus(); } }
javascript
function cleanElement() { destroyListener(); element .removeClass('md-active') .attr('aria-hidden', 'true') .css({ 'display': 'none', 'top': '', 'right': '', 'bottom': '', 'left': '', 'font-size': '', 'min-width': '' }); element.parent().find('md-select-value').removeAttr('aria-hidden'); announceClosed(opts); if (!opts.$destroy && opts.restoreFocus) { opts.target.focus(); } }
[ "function", "cleanElement", "(", ")", "{", "destroyListener", "(", ")", ";", "element", ".", "removeClass", "(", "'md-active'", ")", ".", "attr", "(", "'aria-hidden'", ",", "'true'", ")", ".", "css", "(", "{", "'display'", ":", "'none'", ",", "'top'", ":", "''", ",", "'right'", ":", "''", ",", "'bottom'", ":", "''", ",", "'left'", ":", "''", ",", "'font-size'", ":", "''", ",", "'min-width'", ":", "''", "}", ")", ";", "element", ".", "parent", "(", ")", ".", "find", "(", "'md-select-value'", ")", ".", "removeAttr", "(", "'aria-hidden'", ")", ";", "announceClosed", "(", "opts", ")", ";", "if", "(", "!", "opts", ".", "$destroy", "&&", "opts", ".", "restoreFocus", ")", "{", "opts", ".", "target", ".", "focus", "(", ")", ";", "}", "}" ]
Restore the element to a closed state
[ "Restore", "the", "element", "to", "a", "closed", "state" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/select/select.js#L1254-L1276
5,029
angular/material
src/components/select/select.js
mouseOnScrollbar
function mouseOnScrollbar() { var clickOnScrollbar = false; if (ev && (ev.currentTarget.children.length > 0)) { var child = ev.currentTarget.children[0]; var hasScrollbar = child.scrollHeight > child.clientHeight; if (hasScrollbar && child.children.length > 0) { var relPosX = ev.pageX - ev.currentTarget.getBoundingClientRect().left; if (relPosX > child.querySelector('md-option').offsetWidth) clickOnScrollbar = true; } } return clickOnScrollbar; }
javascript
function mouseOnScrollbar() { var clickOnScrollbar = false; if (ev && (ev.currentTarget.children.length > 0)) { var child = ev.currentTarget.children[0]; var hasScrollbar = child.scrollHeight > child.clientHeight; if (hasScrollbar && child.children.length > 0) { var relPosX = ev.pageX - ev.currentTarget.getBoundingClientRect().left; if (relPosX > child.querySelector('md-option').offsetWidth) clickOnScrollbar = true; } } return clickOnScrollbar; }
[ "function", "mouseOnScrollbar", "(", ")", "{", "var", "clickOnScrollbar", "=", "false", ";", "if", "(", "ev", "&&", "(", "ev", ".", "currentTarget", ".", "children", ".", "length", ">", "0", ")", ")", "{", "var", "child", "=", "ev", ".", "currentTarget", ".", "children", "[", "0", "]", ";", "var", "hasScrollbar", "=", "child", ".", "scrollHeight", ">", "child", ".", "clientHeight", ";", "if", "(", "hasScrollbar", "&&", "child", ".", "children", ".", "length", ">", "0", ")", "{", "var", "relPosX", "=", "ev", ".", "pageX", "-", "ev", ".", "currentTarget", ".", "getBoundingClientRect", "(", ")", ".", "left", ";", "if", "(", "relPosX", ">", "child", ".", "querySelector", "(", "'md-option'", ")", ".", "offsetWidth", ")", "clickOnScrollbar", "=", "true", ";", "}", "}", "return", "clickOnScrollbar", ";", "}" ]
check if the mouseup event was on a scrollbar
[ "check", "if", "the", "mouseup", "event", "was", "on", "a", "scrollbar" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/select/select.js#L1593-L1605
5,030
angular/material
src/core/services/gesture/gesture.js
register
function register(element, handlerName, options) { var handler = HANDLERS[handlerName.replace(/^\$md./, '')]; if (!handler) { throw new Error('Failed to register element with handler ' + handlerName + '. ' + 'Available handlers: ' + Object.keys(HANDLERS).join(', ')); } return handler.registerElement(element, options); }
javascript
function register(element, handlerName, options) { var handler = HANDLERS[handlerName.replace(/^\$md./, '')]; if (!handler) { throw new Error('Failed to register element with handler ' + handlerName + '. ' + 'Available handlers: ' + Object.keys(HANDLERS).join(', ')); } return handler.registerElement(element, options); }
[ "function", "register", "(", "element", ",", "handlerName", ",", "options", ")", "{", "var", "handler", "=", "HANDLERS", "[", "handlerName", ".", "replace", "(", "/", "^\\$md.", "/", ",", "''", ")", "]", ";", "if", "(", "!", "handler", ")", "{", "throw", "new", "Error", "(", "'Failed to register element with handler '", "+", "handlerName", "+", "'. '", "+", "'Available handlers: '", "+", "Object", ".", "keys", "(", "HANDLERS", ")", ".", "join", "(", "', '", ")", ")", ";", "}", "return", "handler", ".", "registerElement", "(", "element", ",", "options", ")", ";", "}" ]
Register an element to listen for a handler. This allows an element to override the default options for a handler. Additionally, some handlers like drag and hold only dispatch events if the domEvent happens inside an element that's registered to listen for these events. @see GestureHandler for how overriding of default options works. @example $mdGesture.register(myElement, 'drag', { minDistance: 20, horizontal: false })
[ "Register", "an", "element", "to", "listen", "for", "a", "handler", ".", "This", "allows", "an", "element", "to", "override", "the", "default", "options", "for", "a", "handler", ".", "Additionally", "some", "handlers", "like", "drag", "and", "hold", "only", "dispatch", "events", "if", "the", "domEvent", "happens", "inside", "an", "element", "that", "s", "registered", "to", "listen", "for", "these", "events", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/gesture/gesture.js#L179-L186
5,031
angular/material
src/core/services/gesture/gesture.js
function (ev, pointer) { if (this.state.isRunning) return; var parentTarget = this.getNearestParent(ev.target); // Get the options from the nearest registered parent var parentTargetOptions = parentTarget && parentTarget.$mdGesture[this.name] || {}; this.state = { isRunning: true, // Override the default options with the nearest registered parent's options options: angular.extend({}, this.options, parentTargetOptions), // Pass in the registered parent node to the state so the onStart listener can use registeredParent: parentTarget }; this.onStart(ev, pointer); }
javascript
function (ev, pointer) { if (this.state.isRunning) return; var parentTarget = this.getNearestParent(ev.target); // Get the options from the nearest registered parent var parentTargetOptions = parentTarget && parentTarget.$mdGesture[this.name] || {}; this.state = { isRunning: true, // Override the default options with the nearest registered parent's options options: angular.extend({}, this.options, parentTargetOptions), // Pass in the registered parent node to the state so the onStart listener can use registeredParent: parentTarget }; this.onStart(ev, pointer); }
[ "function", "(", "ev", ",", "pointer", ")", "{", "if", "(", "this", ".", "state", ".", "isRunning", ")", "return", ";", "var", "parentTarget", "=", "this", ".", "getNearestParent", "(", "ev", ".", "target", ")", ";", "// Get the options from the nearest registered parent", "var", "parentTargetOptions", "=", "parentTarget", "&&", "parentTarget", ".", "$mdGesture", "[", "this", ".", "name", "]", "||", "{", "}", ";", "this", ".", "state", "=", "{", "isRunning", ":", "true", ",", "// Override the default options with the nearest registered parent's options", "options", ":", "angular", ".", "extend", "(", "{", "}", ",", "this", ".", "options", ",", "parentTargetOptions", ")", ",", "// Pass in the registered parent node to the state so the onStart listener can use", "registeredParent", ":", "parentTarget", "}", ";", "this", ".", "onStart", "(", "ev", ",", "pointer", ")", ";", "}" ]
onStart sets up a new state for the handler, which includes options from the nearest registered parent element of ev.target.
[ "onStart", "sets", "up", "a", "new", "state", "for", "the", "handler", "which", "includes", "options", "from", "the", "nearest", "registered", "parent", "element", "of", "ev", ".", "target", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/gesture/gesture.js#L414-L428
5,032
angular/material
src/core/services/gesture/gesture.js
isInputEventFromLabelClick
function isInputEventFromLabelClick(event) { return lastLabelClickPos && lastLabelClickPos.x == event.x && lastLabelClickPos.y == event.y; }
javascript
function isInputEventFromLabelClick(event) { return lastLabelClickPos && lastLabelClickPos.x == event.x && lastLabelClickPos.y == event.y; }
[ "function", "isInputEventFromLabelClick", "(", "event", ")", "{", "return", "lastLabelClickPos", "&&", "lastLabelClickPos", ".", "x", "==", "event", ".", "x", "&&", "lastLabelClickPos", ".", "y", "==", "event", ".", "y", ";", "}" ]
Gets whether the given event is an input event that was caused by clicking on an associated label element. This is necessary because the browser will, upon clicking on a label element, fire an *extra* click event on its associated input (if any). mdGesture is able to flag the label click as with `$material` correctly, but not the second input click. In order to determine whether an input event is from a label click, we compare the (x, y) for the event to the (x, y) for the most recent label click (which is cleared whenever a non-label click occurs). Unfortunately, there are no event properties that tie the input and the label together (such as relatedTarget). @param {MouseEvent} event @returns {boolean}
[ "Gets", "whether", "the", "given", "event", "is", "an", "input", "event", "that", "was", "caused", "by", "clicking", "on", "an", "associated", "label", "element", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/gesture/gesture.js#L741-L745
5,033
angular/material
src/core/services/gesture/gesture.js
getEventPoint
function getEventPoint(ev) { ev = ev.originalEvent || ev; // support jQuery events return (ev.touches && ev.touches[0]) || (ev.changedTouches && ev.changedTouches[0]) || ev; }
javascript
function getEventPoint(ev) { ev = ev.originalEvent || ev; // support jQuery events return (ev.touches && ev.touches[0]) || (ev.changedTouches && ev.changedTouches[0]) || ev; }
[ "function", "getEventPoint", "(", "ev", ")", "{", "ev", "=", "ev", ".", "originalEvent", "||", "ev", ";", "// support jQuery events", "return", "(", "ev", ".", "touches", "&&", "ev", ".", "touches", "[", "0", "]", ")", "||", "(", "ev", ".", "changedTouches", "&&", "ev", ".", "changedTouches", "[", "0", "]", ")", "||", "ev", ";", "}" ]
Normalize the point where the DOM event happened whether it's touch or mouse. @returns point event obj with pageX and pageY on it.
[ "Normalize", "the", "point", "where", "the", "DOM", "event", "happened", "whether", "it", "s", "touch", "or", "mouse", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/gesture/gesture.js#L774-L779
5,034
angular/material
src/core/services/gesture/gesture.js
canFocus
function canFocus(element) { return ( !!element && element.getAttribute('tabindex') !== '-1' && !element.hasAttribute('disabled') && ( element.hasAttribute('tabindex') || element.hasAttribute('href') || element.isContentEditable || ['INPUT', 'SELECT', 'BUTTON', 'TEXTAREA', 'VIDEO', 'AUDIO'].indexOf(element.nodeName) !== -1 ) ); }
javascript
function canFocus(element) { return ( !!element && element.getAttribute('tabindex') !== '-1' && !element.hasAttribute('disabled') && ( element.hasAttribute('tabindex') || element.hasAttribute('href') || element.isContentEditable || ['INPUT', 'SELECT', 'BUTTON', 'TEXTAREA', 'VIDEO', 'AUDIO'].indexOf(element.nodeName) !== -1 ) ); }
[ "function", "canFocus", "(", "element", ")", "{", "return", "(", "!", "!", "element", "&&", "element", ".", "getAttribute", "(", "'tabindex'", ")", "!==", "'-1'", "&&", "!", "element", ".", "hasAttribute", "(", "'disabled'", ")", "&&", "(", "element", ".", "hasAttribute", "(", "'tabindex'", ")", "||", "element", ".", "hasAttribute", "(", "'href'", ")", "||", "element", ".", "isContentEditable", "||", "[", "'INPUT'", ",", "'SELECT'", ",", "'BUTTON'", ",", "'TEXTAREA'", ",", "'VIDEO'", ",", "'AUDIO'", "]", ".", "indexOf", "(", "element", ".", "nodeName", ")", "!==", "-", "1", ")", ")", ";", "}" ]
Checks whether an element can be focused.
[ "Checks", "whether", "an", "element", "can", "be", "focused", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/gesture/gesture.js#L782-L794
5,035
angular/material
docs/app/js/demoInclude.js
handleDemoIndexFile
function handleDemoIndexFile() { files.index.contentsPromise.then(function(contents) { demoContainer = angular.element( '<div class="demo-content ' + ngModule + '">' ); var isStandalone = !!ngModule; var demoScope; var demoCompileService; if (isStandalone) { angular.bootstrap(demoContainer[0], [ngModule]); demoScope = demoContainer.scope(); demoCompileService = demoContainer.injector().get('$compile'); scope.$on('$destroy', function() { demoScope.$destroy(); }); } else { demoScope = scope.$new(); demoCompileService = $compile; } // Once everything is loaded, put the demo into the DOM $q.all([ handleDemoStyles(), handleDemoTemplates() ]).finally(function() { demoScope.$evalAsync(function() { element.append(demoContainer); demoContainer.html(contents); demoCompileService(demoContainer.contents())(demoScope); }); }); }); }
javascript
function handleDemoIndexFile() { files.index.contentsPromise.then(function(contents) { demoContainer = angular.element( '<div class="demo-content ' + ngModule + '">' ); var isStandalone = !!ngModule; var demoScope; var demoCompileService; if (isStandalone) { angular.bootstrap(demoContainer[0], [ngModule]); demoScope = demoContainer.scope(); demoCompileService = demoContainer.injector().get('$compile'); scope.$on('$destroy', function() { demoScope.$destroy(); }); } else { demoScope = scope.$new(); demoCompileService = $compile; } // Once everything is loaded, put the demo into the DOM $q.all([ handleDemoStyles(), handleDemoTemplates() ]).finally(function() { demoScope.$evalAsync(function() { element.append(demoContainer); demoContainer.html(contents); demoCompileService(demoContainer.contents())(demoScope); }); }); }); }
[ "function", "handleDemoIndexFile", "(", ")", "{", "files", ".", "index", ".", "contentsPromise", ".", "then", "(", "function", "(", "contents", ")", "{", "demoContainer", "=", "angular", ".", "element", "(", "'<div class=\"demo-content '", "+", "ngModule", "+", "'\">'", ")", ";", "var", "isStandalone", "=", "!", "!", "ngModule", ";", "var", "demoScope", ";", "var", "demoCompileService", ";", "if", "(", "isStandalone", ")", "{", "angular", ".", "bootstrap", "(", "demoContainer", "[", "0", "]", ",", "[", "ngModule", "]", ")", ";", "demoScope", "=", "demoContainer", ".", "scope", "(", ")", ";", "demoCompileService", "=", "demoContainer", ".", "injector", "(", ")", ".", "get", "(", "'$compile'", ")", ";", "scope", ".", "$on", "(", "'$destroy'", ",", "function", "(", ")", "{", "demoScope", ".", "$destroy", "(", ")", ";", "}", ")", ";", "}", "else", "{", "demoScope", "=", "scope", ".", "$new", "(", ")", ";", "demoCompileService", "=", "$compile", ";", "}", "// Once everything is loaded, put the demo into the DOM", "$q", ".", "all", "(", "[", "handleDemoStyles", "(", ")", ",", "handleDemoTemplates", "(", ")", "]", ")", ".", "finally", "(", "function", "(", ")", "{", "demoScope", ".", "$evalAsync", "(", "function", "(", ")", "{", "element", ".", "append", "(", "demoContainer", ")", ";", "demoContainer", ".", "html", "(", "contents", ")", ";", "demoCompileService", "(", "demoContainer", ".", "contents", "(", ")", ")", "(", "demoScope", ")", ";", "}", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Fetch the index file, and if it contains its own ngModule then bootstrap a new angular app with that ngModule. Otherwise, compile the demo into the current ng-app.
[ "Fetch", "the", "index", "file", "and", "if", "it", "contains", "its", "own", "ngModule", "then", "bootstrap", "a", "new", "angular", "app", "with", "that", "ngModule", ".", "Otherwise", "compile", "the", "demo", "into", "the", "current", "ng", "-", "app", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/app/js/demoInclude.js#L25-L60
5,036
angular/material
docs/app/js/demoInclude.js
handleDemoStyles
function handleDemoStyles() { return $q.all(files.css.map(function(file) { return file.contentsPromise; })) .then(function(styles) { styles = styles.join('\n'); // join styles as one string var styleElement = angular.element('<style>' + styles + '</style>'); document.body.appendChild(styleElement[0]); scope.$on('$destroy', function() { styleElement.remove(); }); }); }
javascript
function handleDemoStyles() { return $q.all(files.css.map(function(file) { return file.contentsPromise; })) .then(function(styles) { styles = styles.join('\n'); // join styles as one string var styleElement = angular.element('<style>' + styles + '</style>'); document.body.appendChild(styleElement[0]); scope.$on('$destroy', function() { styleElement.remove(); }); }); }
[ "function", "handleDemoStyles", "(", ")", "{", "return", "$q", ".", "all", "(", "files", ".", "css", ".", "map", "(", "function", "(", "file", ")", "{", "return", "file", ".", "contentsPromise", ";", "}", ")", ")", ".", "then", "(", "function", "(", "styles", ")", "{", "styles", "=", "styles", ".", "join", "(", "'\\n'", ")", ";", "// join styles as one string", "var", "styleElement", "=", "angular", ".", "element", "(", "'<style>'", "+", "styles", "+", "'</style>'", ")", ";", "document", ".", "body", ".", "appendChild", "(", "styleElement", "[", "0", "]", ")", ";", "scope", ".", "$on", "(", "'$destroy'", ",", "function", "(", ")", "{", "styleElement", ".", "remove", "(", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Fetch the demo styles, and append them to the DOM.
[ "Fetch", "the", "demo", "styles", "and", "append", "them", "to", "the", "DOM", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/app/js/demoInclude.js#L66-L81
5,037
angular/material
docs/app/js/demoInclude.js
handleDemoTemplates
function handleDemoTemplates() { return $q.all(files.html.map(function(file) { return file.contentsPromise.then(function(contents) { // Get the $templateCache instance that goes with the demo's specific ng-app. var demoTemplateCache = demoContainer.injector().get('$templateCache'); demoTemplateCache.put(file.name, contents); scope.$on('$destroy', function() { demoTemplateCache.remove(file.name); }); }); })); }
javascript
function handleDemoTemplates() { return $q.all(files.html.map(function(file) { return file.contentsPromise.then(function(contents) { // Get the $templateCache instance that goes with the demo's specific ng-app. var demoTemplateCache = demoContainer.injector().get('$templateCache'); demoTemplateCache.put(file.name, contents); scope.$on('$destroy', function() { demoTemplateCache.remove(file.name); }); }); })); }
[ "function", "handleDemoTemplates", "(", ")", "{", "return", "$q", ".", "all", "(", "files", ".", "html", ".", "map", "(", "function", "(", "file", ")", "{", "return", "file", ".", "contentsPromise", ".", "then", "(", "function", "(", "contents", ")", "{", "// Get the $templateCache instance that goes with the demo's specific ng-app.", "var", "demoTemplateCache", "=", "demoContainer", ".", "injector", "(", ")", ".", "get", "(", "'$templateCache'", ")", ";", "demoTemplateCache", ".", "put", "(", "file", ".", "name", ",", "contents", ")", ";", "scope", ".", "$on", "(", "'$destroy'", ",", "function", "(", ")", "{", "demoTemplateCache", ".", "remove", "(", "file", ".", "name", ")", ";", "}", ")", ";", "}", ")", ";", "}", ")", ")", ";", "}" ]
Fetch the templates for this demo, and put the templates into the demo app's templateCache, with a url that allows the demo apps to reference their templates local to the demo index file. For example, make it so the dialog demo can reference templateUrl 'my-dialog.tmpl.html' instead of having to reference the url 'generated/material.components.dialog/demo/demo1/my-dialog.tmpl.html'.
[ "Fetch", "the", "templates", "for", "this", "demo", "and", "put", "the", "templates", "into", "the", "demo", "app", "s", "templateCache", "with", "a", "url", "that", "allows", "the", "demo", "apps", "to", "reference", "their", "templates", "local", "to", "the", "demo", "index", "file", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/app/js/demoInclude.js#L92-L108
5,038
angular/material
src/components/sidenav/sidenav.js
findInstance
function findInstance(handle, shouldWait) { var instance = $mdComponentRegistry.get(handle); if (!instance && !shouldWait) { // Report missing instance $log.error($mdUtil.supplant(errorMsg, [handle || ""])); // The component has not registered itself... most like NOT yet created // return null to indicate that the Sidenav is not in the DOM return undefined; } return instance; }
javascript
function findInstance(handle, shouldWait) { var instance = $mdComponentRegistry.get(handle); if (!instance && !shouldWait) { // Report missing instance $log.error($mdUtil.supplant(errorMsg, [handle || ""])); // The component has not registered itself... most like NOT yet created // return null to indicate that the Sidenav is not in the DOM return undefined; } return instance; }
[ "function", "findInstance", "(", "handle", ",", "shouldWait", ")", "{", "var", "instance", "=", "$mdComponentRegistry", ".", "get", "(", "handle", ")", ";", "if", "(", "!", "instance", "&&", "!", "shouldWait", ")", "{", "// Report missing instance", "$log", ".", "error", "(", "$mdUtil", ".", "supplant", "(", "errorMsg", ",", "[", "handle", "||", "\"\"", "]", ")", ")", ";", "// The component has not registered itself... most like NOT yet created", "// return null to indicate that the Sidenav is not in the DOM", "return", "undefined", ";", "}", "return", "instance", ";", "}" ]
Synchronously lookup the controller instance for the specified sidNav instance which has been registered with the markup `md-component-id`
[ "Synchronously", "lookup", "the", "controller", "instance", "for", "the", "specified", "sidNav", "instance", "which", "has", "been", "registered", "with", "the", "markup", "md", "-", "component", "-", "id" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/sidenav/sidenav.js#L131-L143
5,039
angular/material
src/components/sidenav/sidenav.js
toggleOpen
function toggleOpen(isOpen) { if (scope.isOpen === isOpen) { return $q.when(true); } else { if (scope.isOpen && sidenavCtrl.onCloseCb) sidenavCtrl.onCloseCb(); return $q(function(resolve) { // Toggle value to force an async `updateIsOpen()` to run scope.isOpen = isOpen; $mdUtil.nextTick(function() { // When the current `updateIsOpen()` animation finishes promise.then(function(result) { if (!scope.isOpen && triggeringElement && triggeringInteractionType === 'keyboard') { // reset focus to originating element (if available) upon close triggeringElement.focus(); triggeringElement = null; } resolve(result); }); }); }); } }
javascript
function toggleOpen(isOpen) { if (scope.isOpen === isOpen) { return $q.when(true); } else { if (scope.isOpen && sidenavCtrl.onCloseCb) sidenavCtrl.onCloseCb(); return $q(function(resolve) { // Toggle value to force an async `updateIsOpen()` to run scope.isOpen = isOpen; $mdUtil.nextTick(function() { // When the current `updateIsOpen()` animation finishes promise.then(function(result) { if (!scope.isOpen && triggeringElement && triggeringInteractionType === 'keyboard') { // reset focus to originating element (if available) upon close triggeringElement.focus(); triggeringElement = null; } resolve(result); }); }); }); } }
[ "function", "toggleOpen", "(", "isOpen", ")", "{", "if", "(", "scope", ".", "isOpen", "===", "isOpen", ")", "{", "return", "$q", ".", "when", "(", "true", ")", ";", "}", "else", "{", "if", "(", "scope", ".", "isOpen", "&&", "sidenavCtrl", ".", "onCloseCb", ")", "sidenavCtrl", ".", "onCloseCb", "(", ")", ";", "return", "$q", "(", "function", "(", "resolve", ")", "{", "// Toggle value to force an async `updateIsOpen()` to run", "scope", ".", "isOpen", "=", "isOpen", ";", "$mdUtil", ".", "nextTick", "(", "function", "(", ")", "{", "// When the current `updateIsOpen()` animation finishes", "promise", ".", "then", "(", "function", "(", "result", ")", "{", "if", "(", "!", "scope", ".", "isOpen", "&&", "triggeringElement", "&&", "triggeringInteractionType", "===", "'keyboard'", ")", "{", "// reset focus to originating element (if available) upon close", "triggeringElement", ".", "focus", "(", ")", ";", "triggeringElement", "=", "null", ";", "}", "resolve", "(", "result", ")", ";", "}", ")", ";", "}", ")", ";", "}", ")", ";", "}", "}" ]
Toggle the sideNav view and publish a promise to be resolved when the view animation finishes. @param {boolean} isOpen true to open the sidenav, false to close it @returns {*} promise to be resolved when the view animation finishes
[ "Toggle", "the", "sideNav", "view", "and", "publish", "a", "promise", "to", "be", "resolved", "when", "the", "view", "animation", "finishes", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/sidenav/sidenav.js#L474-L499
5,040
angular/material
src/components/sidenav/sidenav.js
onKeyDown
function onKeyDown(ev) { var isEscape = (ev.keyCode === $mdConstant.KEY_CODE.ESCAPE); return isEscape ? close(ev) : $q.when(true); }
javascript
function onKeyDown(ev) { var isEscape = (ev.keyCode === $mdConstant.KEY_CODE.ESCAPE); return isEscape ? close(ev) : $q.when(true); }
[ "function", "onKeyDown", "(", "ev", ")", "{", "var", "isEscape", "=", "(", "ev", ".", "keyCode", "===", "$mdConstant", ".", "KEY_CODE", ".", "ESCAPE", ")", ";", "return", "isEscape", "?", "close", "(", "ev", ")", ":", "$q", ".", "when", "(", "true", ")", ";", "}" ]
Auto-close sideNav when the `escape` key is pressed. @param {KeyboardEvent} ev keydown event
[ "Auto", "-", "close", "sideNav", "when", "the", "escape", "key", "is", "pressed", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/sidenav/sidenav.js#L505-L508
5,041
angular/material
src/components/datepicker/js/calendarMonthBody.js
mdCalendarMonthBodyDirective
function mdCalendarMonthBodyDirective($compile, $$mdSvgRegistry) { var ARROW_ICON = $compile('<md-icon md-svg-src="' + $$mdSvgRegistry.mdTabsArrow + '"></md-icon>')({})[0]; return { require: ['^^mdCalendar', '^^mdCalendarMonth', 'mdCalendarMonthBody'], scope: { offset: '=mdMonthOffset' }, controller: CalendarMonthBodyCtrl, controllerAs: 'mdMonthBodyCtrl', bindToController: true, link: function(scope, element, attrs, controllers) { var calendarCtrl = controllers[0]; var monthCtrl = controllers[1]; var monthBodyCtrl = controllers[2]; monthBodyCtrl.calendarCtrl = calendarCtrl; monthBodyCtrl.monthCtrl = monthCtrl; monthBodyCtrl.arrowIcon = ARROW_ICON.cloneNode(true); // The virtual-repeat re-uses the same DOM elements, so there are only a limited number // of repeated items that are linked, and then those elements have their bindings updated. // Since the months are not generated by bindings, we simply regenerate the entire thing // when the binding (offset) changes. scope.$watch(function() { return monthBodyCtrl.offset; }, function(offset) { if (angular.isNumber(offset)) { monthBodyCtrl.generateContent(); } }); } }; }
javascript
function mdCalendarMonthBodyDirective($compile, $$mdSvgRegistry) { var ARROW_ICON = $compile('<md-icon md-svg-src="' + $$mdSvgRegistry.mdTabsArrow + '"></md-icon>')({})[0]; return { require: ['^^mdCalendar', '^^mdCalendarMonth', 'mdCalendarMonthBody'], scope: { offset: '=mdMonthOffset' }, controller: CalendarMonthBodyCtrl, controllerAs: 'mdMonthBodyCtrl', bindToController: true, link: function(scope, element, attrs, controllers) { var calendarCtrl = controllers[0]; var monthCtrl = controllers[1]; var monthBodyCtrl = controllers[2]; monthBodyCtrl.calendarCtrl = calendarCtrl; monthBodyCtrl.monthCtrl = monthCtrl; monthBodyCtrl.arrowIcon = ARROW_ICON.cloneNode(true); // The virtual-repeat re-uses the same DOM elements, so there are only a limited number // of repeated items that are linked, and then those elements have their bindings updated. // Since the months are not generated by bindings, we simply regenerate the entire thing // when the binding (offset) changes. scope.$watch(function() { return monthBodyCtrl.offset; }, function(offset) { if (angular.isNumber(offset)) { monthBodyCtrl.generateContent(); } }); } }; }
[ "function", "mdCalendarMonthBodyDirective", "(", "$compile", ",", "$$mdSvgRegistry", ")", "{", "var", "ARROW_ICON", "=", "$compile", "(", "'<md-icon md-svg-src=\"'", "+", "$$mdSvgRegistry", ".", "mdTabsArrow", "+", "'\"></md-icon>'", ")", "(", "{", "}", ")", "[", "0", "]", ";", "return", "{", "require", ":", "[", "'^^mdCalendar'", ",", "'^^mdCalendarMonth'", ",", "'mdCalendarMonthBody'", "]", ",", "scope", ":", "{", "offset", ":", "'=mdMonthOffset'", "}", ",", "controller", ":", "CalendarMonthBodyCtrl", ",", "controllerAs", ":", "'mdMonthBodyCtrl'", ",", "bindToController", ":", "true", ",", "link", ":", "function", "(", "scope", ",", "element", ",", "attrs", ",", "controllers", ")", "{", "var", "calendarCtrl", "=", "controllers", "[", "0", "]", ";", "var", "monthCtrl", "=", "controllers", "[", "1", "]", ";", "var", "monthBodyCtrl", "=", "controllers", "[", "2", "]", ";", "monthBodyCtrl", ".", "calendarCtrl", "=", "calendarCtrl", ";", "monthBodyCtrl", ".", "monthCtrl", "=", "monthCtrl", ";", "monthBodyCtrl", ".", "arrowIcon", "=", "ARROW_ICON", ".", "cloneNode", "(", "true", ")", ";", "// The virtual-repeat re-uses the same DOM elements, so there are only a limited number", "// of repeated items that are linked, and then those elements have their bindings updated.", "// Since the months are not generated by bindings, we simply regenerate the entire thing", "// when the binding (offset) changes.", "scope", ".", "$watch", "(", "function", "(", ")", "{", "return", "monthBodyCtrl", ".", "offset", ";", "}", ",", "function", "(", "offset", ")", "{", "if", "(", "angular", ".", "isNumber", "(", "offset", ")", ")", "{", "monthBodyCtrl", ".", "generateContent", "(", ")", ";", "}", "}", ")", ";", "}", "}", ";", "}" ]
Private directive consumed by md-calendar-month. Having this directive lets the calender use md-virtual-repeat and also cleanly separates the month DOM construction functions from the rest of the calendar controller logic. @ngInject
[ "Private", "directive", "consumed", "by", "md", "-", "calendar", "-", "month", ".", "Having", "this", "directive", "lets", "the", "calender", "use", "md", "-", "virtual", "-", "repeat", "and", "also", "cleanly", "separates", "the", "month", "DOM", "construction", "functions", "from", "the", "rest", "of", "the", "calendar", "controller", "logic", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/calendarMonthBody.js#L13-L43
5,042
angular/material
src/components/datepicker/js/calendarMonthBody.js
CalendarMonthBodyCtrl
function CalendarMonthBodyCtrl($element, $$mdDateUtil, $mdDateLocale) { /** @final {!angular.JQLite} */ this.$element = $element; /** @final */ this.dateUtil = $$mdDateUtil; /** @final */ this.dateLocale = $mdDateLocale; /** @type {Object} Reference to the month view. */ this.monthCtrl = null; /** @type {Object} Reference to the calendar. */ this.calendarCtrl = null; /** * Number of months from the start of the month "items" that the currently rendered month * occurs. Set via angular data binding. * @type {number} */ this.offset = null; /** * Date cell to focus after appending the month to the document. * @type {HTMLElement} */ this.focusAfterAppend = null; }
javascript
function CalendarMonthBodyCtrl($element, $$mdDateUtil, $mdDateLocale) { /** @final {!angular.JQLite} */ this.$element = $element; /** @final */ this.dateUtil = $$mdDateUtil; /** @final */ this.dateLocale = $mdDateLocale; /** @type {Object} Reference to the month view. */ this.monthCtrl = null; /** @type {Object} Reference to the calendar. */ this.calendarCtrl = null; /** * Number of months from the start of the month "items" that the currently rendered month * occurs. Set via angular data binding. * @type {number} */ this.offset = null; /** * Date cell to focus after appending the month to the document. * @type {HTMLElement} */ this.focusAfterAppend = null; }
[ "function", "CalendarMonthBodyCtrl", "(", "$element", ",", "$$mdDateUtil", ",", "$mdDateLocale", ")", "{", "/** @final {!angular.JQLite} */", "this", ".", "$element", "=", "$element", ";", "/** @final */", "this", ".", "dateUtil", "=", "$$mdDateUtil", ";", "/** @final */", "this", ".", "dateLocale", "=", "$mdDateLocale", ";", "/** @type {Object} Reference to the month view. */", "this", ".", "monthCtrl", "=", "null", ";", "/** @type {Object} Reference to the calendar. */", "this", ".", "calendarCtrl", "=", "null", ";", "/**\n * Number of months from the start of the month \"items\" that the currently rendered month\n * occurs. Set via angular data binding.\n * @type {number}\n */", "this", ".", "offset", "=", "null", ";", "/**\n * Date cell to focus after appending the month to the document.\n * @type {HTMLElement}\n */", "this", ".", "focusAfterAppend", "=", "null", ";", "}" ]
Controller for a single calendar month. @ngInject @constructor
[ "Controller", "for", "a", "single", "calendar", "month", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/calendarMonthBody.js#L49-L77
5,043
angular/material
src/components/datepicker/js/calendarYearBody.js
mdCalendarYearDirective
function mdCalendarYearDirective() { return { require: ['^^mdCalendar', '^^mdCalendarYear', 'mdCalendarYearBody'], scope: { offset: '=mdYearOffset' }, controller: CalendarYearBodyCtrl, controllerAs: 'mdYearBodyCtrl', bindToController: true, link: function(scope, element, attrs, controllers) { var calendarCtrl = controllers[0]; var yearCtrl = controllers[1]; var yearBodyCtrl = controllers[2]; yearBodyCtrl.calendarCtrl = calendarCtrl; yearBodyCtrl.yearCtrl = yearCtrl; scope.$watch(function() { return yearBodyCtrl.offset; }, function(offset) { if (angular.isNumber(offset)) { yearBodyCtrl.generateContent(); } }); } }; }
javascript
function mdCalendarYearDirective() { return { require: ['^^mdCalendar', '^^mdCalendarYear', 'mdCalendarYearBody'], scope: { offset: '=mdYearOffset' }, controller: CalendarYearBodyCtrl, controllerAs: 'mdYearBodyCtrl', bindToController: true, link: function(scope, element, attrs, controllers) { var calendarCtrl = controllers[0]; var yearCtrl = controllers[1]; var yearBodyCtrl = controllers[2]; yearBodyCtrl.calendarCtrl = calendarCtrl; yearBodyCtrl.yearCtrl = yearCtrl; scope.$watch(function() { return yearBodyCtrl.offset; }, function(offset) { if (angular.isNumber(offset)) { yearBodyCtrl.generateContent(); } }); } }; }
[ "function", "mdCalendarYearDirective", "(", ")", "{", "return", "{", "require", ":", "[", "'^^mdCalendar'", ",", "'^^mdCalendarYear'", ",", "'mdCalendarYearBody'", "]", ",", "scope", ":", "{", "offset", ":", "'=mdYearOffset'", "}", ",", "controller", ":", "CalendarYearBodyCtrl", ",", "controllerAs", ":", "'mdYearBodyCtrl'", ",", "bindToController", ":", "true", ",", "link", ":", "function", "(", "scope", ",", "element", ",", "attrs", ",", "controllers", ")", "{", "var", "calendarCtrl", "=", "controllers", "[", "0", "]", ";", "var", "yearCtrl", "=", "controllers", "[", "1", "]", ";", "var", "yearBodyCtrl", "=", "controllers", "[", "2", "]", ";", "yearBodyCtrl", ".", "calendarCtrl", "=", "calendarCtrl", ";", "yearBodyCtrl", ".", "yearCtrl", "=", "yearCtrl", ";", "scope", ".", "$watch", "(", "function", "(", ")", "{", "return", "yearBodyCtrl", ".", "offset", ";", "}", ",", "function", "(", "offset", ")", "{", "if", "(", "angular", ".", "isNumber", "(", "offset", ")", ")", "{", "yearBodyCtrl", ".", "generateContent", "(", ")", ";", "}", "}", ")", ";", "}", "}", ";", "}" ]
Private component, consumed by the md-calendar-year, which separates the DOM construction logic and allows for the year view to use md-virtual-repeat.
[ "Private", "component", "consumed", "by", "the", "md", "-", "calendar", "-", "year", "which", "separates", "the", "DOM", "construction", "logic", "and", "allows", "for", "the", "year", "view", "to", "use", "md", "-", "virtual", "-", "repeat", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/calendarYearBody.js#L11-L33
5,044
angular/material
src/components/datepicker/js/calendarYearBody.js
CalendarYearBodyCtrl
function CalendarYearBodyCtrl($element, $$mdDateUtil, $mdDateLocale) { /** @final {!angular.JQLite} */ this.$element = $element; /** @final */ this.dateUtil = $$mdDateUtil; /** @final */ this.dateLocale = $mdDateLocale; /** @type {Object} Reference to the calendar. */ this.calendarCtrl = null; /** @type {Object} Reference to the year view. */ this.yearCtrl = null; /** * Number of months from the start of the month "items" that the currently rendered month * occurs. Set via angular data binding. * @type {number} */ this.offset = null; /** * Date cell to focus after appending the month to the document. * @type {HTMLElement} */ this.focusAfterAppend = null; }
javascript
function CalendarYearBodyCtrl($element, $$mdDateUtil, $mdDateLocale) { /** @final {!angular.JQLite} */ this.$element = $element; /** @final */ this.dateUtil = $$mdDateUtil; /** @final */ this.dateLocale = $mdDateLocale; /** @type {Object} Reference to the calendar. */ this.calendarCtrl = null; /** @type {Object} Reference to the year view. */ this.yearCtrl = null; /** * Number of months from the start of the month "items" that the currently rendered month * occurs. Set via angular data binding. * @type {number} */ this.offset = null; /** * Date cell to focus after appending the month to the document. * @type {HTMLElement} */ this.focusAfterAppend = null; }
[ "function", "CalendarYearBodyCtrl", "(", "$element", ",", "$$mdDateUtil", ",", "$mdDateLocale", ")", "{", "/** @final {!angular.JQLite} */", "this", ".", "$element", "=", "$element", ";", "/** @final */", "this", ".", "dateUtil", "=", "$$mdDateUtil", ";", "/** @final */", "this", ".", "dateLocale", "=", "$mdDateLocale", ";", "/** @type {Object} Reference to the calendar. */", "this", ".", "calendarCtrl", "=", "null", ";", "/** @type {Object} Reference to the year view. */", "this", ".", "yearCtrl", "=", "null", ";", "/**\n * Number of months from the start of the month \"items\" that the currently rendered month\n * occurs. Set via angular data binding.\n * @type {number}\n */", "this", ".", "offset", "=", "null", ";", "/**\n * Date cell to focus after appending the month to the document.\n * @type {HTMLElement}\n */", "this", ".", "focusAfterAppend", "=", "null", ";", "}" ]
Controller for a single year. @ngInject @constructor
[ "Controller", "for", "a", "single", "year", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/calendarYearBody.js#L39-L67
5,045
angular/material
src/core/services/interimElement/interimElement.js
setDefaults
function setDefaults(definition) { providerConfig.optionsFactory = definition.options; providerConfig.methods = (definition.methods || []).concat(EXPOSED_METHODS); return provider; }
javascript
function setDefaults(definition) { providerConfig.optionsFactory = definition.options; providerConfig.methods = (definition.methods || []).concat(EXPOSED_METHODS); return provider; }
[ "function", "setDefaults", "(", "definition", ")", "{", "providerConfig", ".", "optionsFactory", "=", "definition", ".", "options", ";", "providerConfig", ".", "methods", "=", "(", "definition", ".", "methods", "||", "[", "]", ")", ".", "concat", "(", "EXPOSED_METHODS", ")", ";", "return", "provider", ";", "}" ]
Save the configured defaults to be used when the factory is instantiated
[ "Save", "the", "configured", "defaults", "to", "be", "used", "when", "the", "factory", "is", "instantiated" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/interimElement/interimElement.js#L65-L69
5,046
angular/material
src/core/services/interimElement/interimElement.js
addPreset
function addPreset(name, definition) { definition = definition || {}; definition.methods = definition.methods || []; definition.options = definition.options || function() { return {}; }; if (/^cancel|hide|show$/.test(name)) { throw new Error("Preset '" + name + "' in " + interimFactoryName + " is reserved!"); } if (definition.methods.indexOf('_options') > -1) { throw new Error("Method '_options' in " + interimFactoryName + " is reserved!"); } providerConfig.presets[name] = { methods: definition.methods.concat(EXPOSED_METHODS), optionsFactory: definition.options, argOption: definition.argOption }; return provider; }
javascript
function addPreset(name, definition) { definition = definition || {}; definition.methods = definition.methods || []; definition.options = definition.options || function() { return {}; }; if (/^cancel|hide|show$/.test(name)) { throw new Error("Preset '" + name + "' in " + interimFactoryName + " is reserved!"); } if (definition.methods.indexOf('_options') > -1) { throw new Error("Method '_options' in " + interimFactoryName + " is reserved!"); } providerConfig.presets[name] = { methods: definition.methods.concat(EXPOSED_METHODS), optionsFactory: definition.options, argOption: definition.argOption }; return provider; }
[ "function", "addPreset", "(", "name", ",", "definition", ")", "{", "definition", "=", "definition", "||", "{", "}", ";", "definition", ".", "methods", "=", "definition", ".", "methods", "||", "[", "]", ";", "definition", ".", "options", "=", "definition", ".", "options", "||", "function", "(", ")", "{", "return", "{", "}", ";", "}", ";", "if", "(", "/", "^cancel|hide|show$", "/", ".", "test", "(", "name", ")", ")", "{", "throw", "new", "Error", "(", "\"Preset '\"", "+", "name", "+", "\"' in \"", "+", "interimFactoryName", "+", "\" is reserved!\"", ")", ";", "}", "if", "(", "definition", ".", "methods", ".", "indexOf", "(", "'_options'", ")", ">", "-", "1", ")", "{", "throw", "new", "Error", "(", "\"Method '_options' in \"", "+", "interimFactoryName", "+", "\" is reserved!\"", ")", ";", "}", "providerConfig", ".", "presets", "[", "name", "]", "=", "{", "methods", ":", "definition", ".", "methods", ".", "concat", "(", "EXPOSED_METHODS", ")", ",", "optionsFactory", ":", "definition", ".", "options", ",", "argOption", ":", "definition", ".", "argOption", "}", ";", "return", "provider", ";", "}" ]
Save the configured preset to be used when the factory is instantiated
[ "Save", "the", "configured", "preset", "to", "be", "used", "when", "the", "factory", "is", "instantiated" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/interimElement/interimElement.js#L83-L100
5,047
angular/material
src/core/services/interimElement/interimElement.js
waitForInterim
function waitForInterim(callbackFn) { return function() { var fnArguments = arguments; if (!showingInterims.length) { // When there are still interim's opening, then wait for the first interim element to // finish its open animation. if (showPromises.length) { return showPromises[0].finally(function () { return callbackFn.apply(service, fnArguments); }); } return $q.when("No interim elements currently showing up."); } return callbackFn.apply(service, fnArguments); }; }
javascript
function waitForInterim(callbackFn) { return function() { var fnArguments = arguments; if (!showingInterims.length) { // When there are still interim's opening, then wait for the first interim element to // finish its open animation. if (showPromises.length) { return showPromises[0].finally(function () { return callbackFn.apply(service, fnArguments); }); } return $q.when("No interim elements currently showing up."); } return callbackFn.apply(service, fnArguments); }; }
[ "function", "waitForInterim", "(", "callbackFn", ")", "{", "return", "function", "(", ")", "{", "var", "fnArguments", "=", "arguments", ";", "if", "(", "!", "showingInterims", ".", "length", ")", "{", "// When there are still interim's opening, then wait for the first interim element to", "// finish its open animation.", "if", "(", "showPromises", ".", "length", ")", "{", "return", "showPromises", "[", "0", "]", ".", "finally", "(", "function", "(", ")", "{", "return", "callbackFn", ".", "apply", "(", "service", ",", "fnArguments", ")", ";", "}", ")", ";", "}", "return", "$q", ".", "when", "(", "\"No interim elements currently showing up.\"", ")", ";", "}", "return", "callbackFn", ".", "apply", "(", "service", ",", "fnArguments", ")", ";", "}", ";", "}" ]
Creates a function to wait for at least one interim element to be available. @param callbackFn Function to be used as callback @returns {Function}
[ "Creates", "a", "function", "to", "wait", "for", "at", "least", "one", "interim", "element", "to", "be", "available", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/interimElement/interimElement.js#L425-L443
5,048
angular/material
src/core/services/interimElement/interimElement.js
createAndTransitionIn
function createAndTransitionIn() { return $q(function(resolve, reject) { // Trigger onCompiling callback before the compilation starts. // This is useful, when modifying options, which can be influenced by developers. options.onCompiling && options.onCompiling(options); compileElement(options) .then(function(compiledData) { element = linkElement(compiledData, options); // Expose the cleanup function from the compiler. options.cleanupElement = compiledData.cleanup; showAction = showElement(element, options, compiledData.controller) .then(resolve, rejectAll); }).catch(rejectAll); function rejectAll(fault) { // Force the '$md<xxx>.show()' promise to reject self.deferred.reject(fault); // Continue rejection propagation reject(fault); } }); }
javascript
function createAndTransitionIn() { return $q(function(resolve, reject) { // Trigger onCompiling callback before the compilation starts. // This is useful, when modifying options, which can be influenced by developers. options.onCompiling && options.onCompiling(options); compileElement(options) .then(function(compiledData) { element = linkElement(compiledData, options); // Expose the cleanup function from the compiler. options.cleanupElement = compiledData.cleanup; showAction = showElement(element, options, compiledData.controller) .then(resolve, rejectAll); }).catch(rejectAll); function rejectAll(fault) { // Force the '$md<xxx>.show()' promise to reject self.deferred.reject(fault); // Continue rejection propagation reject(fault); } }); }
[ "function", "createAndTransitionIn", "(", ")", "{", "return", "$q", "(", "function", "(", "resolve", ",", "reject", ")", "{", "// Trigger onCompiling callback before the compilation starts.", "// This is useful, when modifying options, which can be influenced by developers.", "options", ".", "onCompiling", "&&", "options", ".", "onCompiling", "(", "options", ")", ";", "compileElement", "(", "options", ")", ".", "then", "(", "function", "(", "compiledData", ")", "{", "element", "=", "linkElement", "(", "compiledData", ",", "options", ")", ";", "// Expose the cleanup function from the compiler.", "options", ".", "cleanupElement", "=", "compiledData", ".", "cleanup", ";", "showAction", "=", "showElement", "(", "element", ",", "options", ",", "compiledData", ".", "controller", ")", ".", "then", "(", "resolve", ",", "rejectAll", ")", ";", "}", ")", ".", "catch", "(", "rejectAll", ")", ";", "function", "rejectAll", "(", "fault", ")", "{", "// Force the '$md<xxx>.show()' promise to reject", "self", ".", "deferred", ".", "reject", "(", "fault", ")", ";", "// Continue rejection propagation", "reject", "(", "fault", ")", ";", "}", "}", ")", ";", "}" ]
Compile, link, and show this interim element Use optional autoHided and transition-in effects
[ "Compile", "link", "and", "show", "this", "interim", "element", "Use", "optional", "autoHided", "and", "transition", "-", "in", "effects" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/interimElement/interimElement.js#L492-L518
5,049
angular/material
src/core/services/interimElement/interimElement.js
compileElement
function compileElement(options) { var compiled = !options.skipCompile ? $mdCompiler.compile(options) : null; return compiled || $q(function (resolve) { resolve({ locals: {}, link: function () { return options.element; } }); }); }
javascript
function compileElement(options) { var compiled = !options.skipCompile ? $mdCompiler.compile(options) : null; return compiled || $q(function (resolve) { resolve({ locals: {}, link: function () { return options.element; } }); }); }
[ "function", "compileElement", "(", "options", ")", "{", "var", "compiled", "=", "!", "options", ".", "skipCompile", "?", "$mdCompiler", ".", "compile", "(", "options", ")", ":", "null", ";", "return", "compiled", "||", "$q", "(", "function", "(", "resolve", ")", "{", "resolve", "(", "{", "locals", ":", "{", "}", ",", "link", ":", "function", "(", ")", "{", "return", "options", ".", "element", ";", "}", "}", ")", ";", "}", ")", ";", "}" ]
Compile an element with a templateUrl, controller, and locals
[ "Compile", "an", "element", "with", "a", "templateUrl", "controller", "and", "locals" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/interimElement/interimElement.js#L605-L617
5,050
angular/material
src/core/services/interimElement/interimElement.js
linkElement
function linkElement(compileData, options){ angular.extend(compileData.locals, options); var element = compileData.link(options.scope); // Search for parent at insertion time, if not specified options.element = element; options.parent = findParent(element, options); if (options.themable) $mdTheming(element); return element; }
javascript
function linkElement(compileData, options){ angular.extend(compileData.locals, options); var element = compileData.link(options.scope); // Search for parent at insertion time, if not specified options.element = element; options.parent = findParent(element, options); if (options.themable) $mdTheming(element); return element; }
[ "function", "linkElement", "(", "compileData", ",", "options", ")", "{", "angular", ".", "extend", "(", "compileData", ".", "locals", ",", "options", ")", ";", "var", "element", "=", "compileData", ".", "link", "(", "options", ".", "scope", ")", ";", "// Search for parent at insertion time, if not specified", "options", ".", "element", "=", "element", ";", "options", ".", "parent", "=", "findParent", "(", "element", ",", "options", ")", ";", "if", "(", "options", ".", "themable", ")", "$mdTheming", "(", "element", ")", ";", "return", "element", ";", "}" ]
Link an element with compiled configuration
[ "Link", "an", "element", "with", "compiled", "configuration" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/interimElement/interimElement.js#L622-L633
5,051
angular/material
src/core/services/interimElement/interimElement.js
findParent
function findParent(element, options) { var parent = options.parent; // Search for parent at insertion time, if not specified if (angular.isFunction(parent)) { parent = parent(options.scope, element, options); } else if (angular.isString(parent)) { parent = angular.element($document[0].querySelector(parent)); } else { parent = angular.element(parent); } // If parent querySelector/getter function fails, or it's just null, // find a default. if (!(parent || {}).length) { var el; if ($rootElement[0] && $rootElement[0].querySelector) { el = $rootElement[0].querySelector(':not(svg) > body'); } if (!el) el = $rootElement[0]; if (el.nodeName == '#comment') { el = $document[0].body; } return angular.element(el); } return parent; }
javascript
function findParent(element, options) { var parent = options.parent; // Search for parent at insertion time, if not specified if (angular.isFunction(parent)) { parent = parent(options.scope, element, options); } else if (angular.isString(parent)) { parent = angular.element($document[0].querySelector(parent)); } else { parent = angular.element(parent); } // If parent querySelector/getter function fails, or it's just null, // find a default. if (!(parent || {}).length) { var el; if ($rootElement[0] && $rootElement[0].querySelector) { el = $rootElement[0].querySelector(':not(svg) > body'); } if (!el) el = $rootElement[0]; if (el.nodeName == '#comment') { el = $document[0].body; } return angular.element(el); } return parent; }
[ "function", "findParent", "(", "element", ",", "options", ")", "{", "var", "parent", "=", "options", ".", "parent", ";", "// Search for parent at insertion time, if not specified", "if", "(", "angular", ".", "isFunction", "(", "parent", ")", ")", "{", "parent", "=", "parent", "(", "options", ".", "scope", ",", "element", ",", "options", ")", ";", "}", "else", "if", "(", "angular", ".", "isString", "(", "parent", ")", ")", "{", "parent", "=", "angular", ".", "element", "(", "$document", "[", "0", "]", ".", "querySelector", "(", "parent", ")", ")", ";", "}", "else", "{", "parent", "=", "angular", ".", "element", "(", "parent", ")", ";", "}", "// If parent querySelector/getter function fails, or it's just null,", "// find a default.", "if", "(", "!", "(", "parent", "||", "{", "}", ")", ".", "length", ")", "{", "var", "el", ";", "if", "(", "$rootElement", "[", "0", "]", "&&", "$rootElement", "[", "0", "]", ".", "querySelector", ")", "{", "el", "=", "$rootElement", "[", "0", "]", ".", "querySelector", "(", "':not(svg) > body'", ")", ";", "}", "if", "(", "!", "el", ")", "el", "=", "$rootElement", "[", "0", "]", ";", "if", "(", "el", ".", "nodeName", "==", "'#comment'", ")", "{", "el", "=", "$document", "[", "0", "]", ".", "body", ";", "}", "return", "angular", ".", "element", "(", "el", ")", ";", "}", "return", "parent", ";", "}" ]
Search for parent at insertion time, if not specified
[ "Search", "for", "parent", "at", "insertion", "time", "if", "not", "specified" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/interimElement/interimElement.js#L638-L665
5,052
angular/material
src/core/services/interimElement/interimElement.js
startAutoHide
function startAutoHide() { var autoHideTimer, cancelAutoHide = angular.noop; if (options.hideDelay) { autoHideTimer = $timeout(service.hide, options.hideDelay) ; cancelAutoHide = function() { $timeout.cancel(autoHideTimer); }; } // Cache for subsequent use options.cancelAutoHide = function() { cancelAutoHide(); options.cancelAutoHide = undefined; }; }
javascript
function startAutoHide() { var autoHideTimer, cancelAutoHide = angular.noop; if (options.hideDelay) { autoHideTimer = $timeout(service.hide, options.hideDelay) ; cancelAutoHide = function() { $timeout.cancel(autoHideTimer); }; } // Cache for subsequent use options.cancelAutoHide = function() { cancelAutoHide(); options.cancelAutoHide = undefined; }; }
[ "function", "startAutoHide", "(", ")", "{", "var", "autoHideTimer", ",", "cancelAutoHide", "=", "angular", ".", "noop", ";", "if", "(", "options", ".", "hideDelay", ")", "{", "autoHideTimer", "=", "$timeout", "(", "service", ".", "hide", ",", "options", ".", "hideDelay", ")", ";", "cancelAutoHide", "=", "function", "(", ")", "{", "$timeout", ".", "cancel", "(", "autoHideTimer", ")", ";", "}", ";", "}", "// Cache for subsequent use", "options", ".", "cancelAutoHide", "=", "function", "(", ")", "{", "cancelAutoHide", "(", ")", ";", "options", ".", "cancelAutoHide", "=", "undefined", ";", "}", ";", "}" ]
If auto-hide is enabled, start timer and prepare cancel function
[ "If", "auto", "-", "hide", "is", "enabled", "start", "timer", "and", "prepare", "cancel", "function" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/interimElement/interimElement.js#L670-L685
5,053
angular/material
src/components/radioButton/radio-button.js
changeSelectedButton
function changeSelectedButton(parent, increment) { // Coerce all child radio buttons into an array, then wrap then in an iterator var buttons = $mdUtil.iterator(parent[0].querySelectorAll('md-radio-button'), true); if (buttons.count()) { var validate = function (button) { // If disabled, then NOT valid return !angular.element(button).attr("disabled"); }; var selected = parent[0].querySelector('md-radio-button.md-checked'); var target = buttons[increment < 0 ? 'previous' : 'next'](selected, validate) || buttons.first(); // Activate radioButton's click listener (triggerHandler won't create a real click event) angular.element(target).triggerHandler('click'); } }
javascript
function changeSelectedButton(parent, increment) { // Coerce all child radio buttons into an array, then wrap then in an iterator var buttons = $mdUtil.iterator(parent[0].querySelectorAll('md-radio-button'), true); if (buttons.count()) { var validate = function (button) { // If disabled, then NOT valid return !angular.element(button).attr("disabled"); }; var selected = parent[0].querySelector('md-radio-button.md-checked'); var target = buttons[increment < 0 ? 'previous' : 'next'](selected, validate) || buttons.first(); // Activate radioButton's click listener (triggerHandler won't create a real click event) angular.element(target).triggerHandler('click'); } }
[ "function", "changeSelectedButton", "(", "parent", ",", "increment", ")", "{", "// Coerce all child radio buttons into an array, then wrap then in an iterator", "var", "buttons", "=", "$mdUtil", ".", "iterator", "(", "parent", "[", "0", "]", ".", "querySelectorAll", "(", "'md-radio-button'", ")", ",", "true", ")", ";", "if", "(", "buttons", ".", "count", "(", ")", ")", "{", "var", "validate", "=", "function", "(", "button", ")", "{", "// If disabled, then NOT valid", "return", "!", "angular", ".", "element", "(", "button", ")", ".", "attr", "(", "\"disabled\"", ")", ";", "}", ";", "var", "selected", "=", "parent", "[", "0", "]", ".", "querySelector", "(", "'md-radio-button.md-checked'", ")", ";", "var", "target", "=", "buttons", "[", "increment", "<", "0", "?", "'previous'", ":", "'next'", "]", "(", "selected", ",", "validate", ")", "||", "buttons", ".", "first", "(", ")", ";", "// Activate radioButton's click listener (triggerHandler won't create a real click event)", "angular", ".", "element", "(", "target", ")", ".", "triggerHandler", "(", "'click'", ")", ";", "}", "}" ]
Change the radio group's selected button by a given increment. If no button is selected, select the first button.
[ "Change", "the", "radio", "group", "s", "selected", "button", "by", "a", "given", "increment", ".", "If", "no", "button", "is", "selected", "select", "the", "first", "button", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/radioButton/radio-button.js#L188-L204
5,054
angular/material
src/components/radioButton/radio-button.js
initialize
function initialize() { if (!rgCtrl) { throw 'RadioButton: No RadioGroupController could be found.'; } rgCtrl.add(render); attr.$observe('value', render); element .on('click', listener) .on('$destroy', function() { rgCtrl.remove(render); }); }
javascript
function initialize() { if (!rgCtrl) { throw 'RadioButton: No RadioGroupController could be found.'; } rgCtrl.add(render); attr.$observe('value', render); element .on('click', listener) .on('$destroy', function() { rgCtrl.remove(render); }); }
[ "function", "initialize", "(", ")", "{", "if", "(", "!", "rgCtrl", ")", "{", "throw", "'RadioButton: No RadioGroupController could be found.'", ";", "}", "rgCtrl", ".", "add", "(", "render", ")", ";", "attr", ".", "$observe", "(", "'value'", ",", "render", ")", ";", "element", ".", "on", "(", "'click'", ",", "listener", ")", ".", "on", "(", "'$destroy'", ",", "function", "(", ")", "{", "rgCtrl", ".", "remove", "(", "render", ")", ";", "}", ")", ";", "}" ]
Initializes the component.
[ "Initializes", "the", "component", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/radioButton/radio-button.js#L281-L294
5,055
angular/material
src/components/radioButton/radio-button.js
listener
function listener(ev) { if (element[0].hasAttribute('disabled') || rgCtrl.isDisabled()) return; scope.$apply(function() { rgCtrl.setViewValue(attr.value, ev && ev.type); }); }
javascript
function listener(ev) { if (element[0].hasAttribute('disabled') || rgCtrl.isDisabled()) return; scope.$apply(function() { rgCtrl.setViewValue(attr.value, ev && ev.type); }); }
[ "function", "listener", "(", "ev", ")", "{", "if", "(", "element", "[", "0", "]", ".", "hasAttribute", "(", "'disabled'", ")", "||", "rgCtrl", ".", "isDisabled", "(", ")", ")", "return", ";", "scope", ".", "$apply", "(", "function", "(", ")", "{", "rgCtrl", ".", "setViewValue", "(", "attr", ".", "value", ",", "ev", "&&", "ev", ".", "type", ")", ";", "}", ")", ";", "}" ]
On click functionality.
[ "On", "click", "functionality", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/radioButton/radio-button.js#L299-L305
5,056
angular/material
src/components/radioButton/radio-button.js
configureAria
function configureAria(element, scope){ element.attr({ id: attr.id || 'radio_' + $mdUtil.nextUid(), role: 'radio', 'aria-checked': 'false' }); $mdAria.expectWithText(element, 'aria-label'); }
javascript
function configureAria(element, scope){ element.attr({ id: attr.id || 'radio_' + $mdUtil.nextUid(), role: 'radio', 'aria-checked': 'false' }); $mdAria.expectWithText(element, 'aria-label'); }
[ "function", "configureAria", "(", "element", ",", "scope", ")", "{", "element", ".", "attr", "(", "{", "id", ":", "attr", ".", "id", "||", "'radio_'", "+", "$mdUtil", ".", "nextUid", "(", ")", ",", "role", ":", "'radio'", ",", "'aria-checked'", ":", "'false'", "}", ")", ";", "$mdAria", ".", "expectWithText", "(", "element", ",", "'aria-label'", ")", ";", "}" ]
Inject ARIA-specific attributes appropriate for each radio button
[ "Inject", "ARIA", "-", "specific", "attributes", "appropriate", "for", "each", "radio", "button" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/radioButton/radio-button.js#L335-L343
5,057
angular/material
src/components/icon/js/iconService.js
fontSet
function fontSet(alias, className) { config.fontSets.push({ alias: alias, fontSet: className || alias }); return this; }
javascript
function fontSet(alias, className) { config.fontSets.push({ alias: alias, fontSet: className || alias }); return this; }
[ "function", "fontSet", "(", "alias", ",", "className", ")", "{", "config", ".", "fontSets", ".", "push", "(", "{", "alias", ":", "alias", ",", "fontSet", ":", "className", "||", "alias", "}", ")", ";", "return", "this", ";", "}" ]
Register an alias name associated with a font-icon library style ;
[ "Register", "an", "alias", "name", "associated", "with", "a", "font", "-", "icon", "library", "style", ";" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/icon/js/iconService.js#L322-L328
5,058
angular/material
src/components/icon/js/iconService.js
findRegisteredFontSet
function findRegisteredFontSet(alias) { var useDefault = angular.isUndefined(alias) || !(alias && alias.length); if (useDefault) { return config.defaultFontSet; } var result = alias; angular.forEach(config.fontSets, function(fontSet) { if (fontSet.alias === alias) { result = fontSet.fontSet || result; } }); return result; }
javascript
function findRegisteredFontSet(alias) { var useDefault = angular.isUndefined(alias) || !(alias && alias.length); if (useDefault) { return config.defaultFontSet; } var result = alias; angular.forEach(config.fontSets, function(fontSet) { if (fontSet.alias === alias) { result = fontSet.fontSet || result; } }); return result; }
[ "function", "findRegisteredFontSet", "(", "alias", ")", "{", "var", "useDefault", "=", "angular", ".", "isUndefined", "(", "alias", ")", "||", "!", "(", "alias", "&&", "alias", ".", "length", ")", ";", "if", "(", "useDefault", ")", "{", "return", "config", ".", "defaultFontSet", ";", "}", "var", "result", "=", "alias", ";", "angular", ".", "forEach", "(", "config", ".", "fontSets", ",", "function", "(", "fontSet", ")", "{", "if", "(", "fontSet", ".", "alias", "===", "alias", ")", "{", "result", "=", "fontSet", ".", "fontSet", "||", "result", ";", "}", "}", ")", ";", "return", "result", ";", "}" ]
Lookup a registered fontSet style using its alias. @param {string} alias used to lookup the alias in the array of fontSets @returns {*} matching fontSet or the defaultFontSet if that alias does not match
[ "Lookup", "a", "registered", "fontSet", "style", "using", "its", "alias", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/icon/js/iconService.js#L459-L473
5,059
angular/material
src/components/icon/js/iconService.js
isIcon
function isIcon(target) { return angular.isDefined(target.element) && angular.isDefined(target.config); }
javascript
function isIcon(target) { return angular.isDefined(target.element) && angular.isDefined(target.config); }
[ "function", "isIcon", "(", "target", ")", "{", "return", "angular", ".", "isDefined", "(", "target", ".", "element", ")", "&&", "angular", ".", "isDefined", "(", "target", ".", "config", ")", ";", "}" ]
Check target signature to see if it is an Icon instance. @param {Icon|Element} target @returns {boolean} true if the specified target is an Icon object, false otherwise.
[ "Check", "target", "signature", "to", "see", "if", "it", "is", "an", "Icon", "instance", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/icon/js/iconService.js#L668-L670
5,060
angular/material
src/components/icon/js/iconService.js
Icon
function Icon(el, config) { // If the node is a <symbol>, it won't be rendered so we have to convert it into <svg>. if (el && el.tagName.toLowerCase() === 'symbol') { var viewbox = el.getAttribute('viewBox'); // // Check if innerHTML is supported as IE11 does not support innerHTML on SVG elements. if (el.innerHTML) { el = angular.element('<svg xmlns="http://www.w3.org/2000/svg">') .html(el.innerHTML)[0]; } else { el = angular.element('<svg xmlns="http://www.w3.org/2000/svg">') .append($mdUtil.getInnerHTML(el))[0]; } if (viewbox) el.setAttribute('viewBox', viewbox); } if (el && el.tagName.toLowerCase() !== 'svg') { el = angular.element( '<svg xmlns="http://www.w3.org/2000/svg">').append(el.cloneNode(true))[0]; } // Inject the namespace if not available... if (!el.getAttribute('xmlns')) { el.setAttribute('xmlns', "http://www.w3.org/2000/svg"); } this.element = el; this.config = config; this.prepare(); }
javascript
function Icon(el, config) { // If the node is a <symbol>, it won't be rendered so we have to convert it into <svg>. if (el && el.tagName.toLowerCase() === 'symbol') { var viewbox = el.getAttribute('viewBox'); // // Check if innerHTML is supported as IE11 does not support innerHTML on SVG elements. if (el.innerHTML) { el = angular.element('<svg xmlns="http://www.w3.org/2000/svg">') .html(el.innerHTML)[0]; } else { el = angular.element('<svg xmlns="http://www.w3.org/2000/svg">') .append($mdUtil.getInnerHTML(el))[0]; } if (viewbox) el.setAttribute('viewBox', viewbox); } if (el && el.tagName.toLowerCase() !== 'svg') { el = angular.element( '<svg xmlns="http://www.w3.org/2000/svg">').append(el.cloneNode(true))[0]; } // Inject the namespace if not available... if (!el.getAttribute('xmlns')) { el.setAttribute('xmlns', "http://www.w3.org/2000/svg"); } this.element = el; this.config = config; this.prepare(); }
[ "function", "Icon", "(", "el", ",", "config", ")", "{", "// If the node is a <symbol>, it won't be rendered so we have to convert it into <svg>.", "if", "(", "el", "&&", "el", ".", "tagName", ".", "toLowerCase", "(", ")", "===", "'symbol'", ")", "{", "var", "viewbox", "=", "el", ".", "getAttribute", "(", "'viewBox'", ")", ";", "// // Check if innerHTML is supported as IE11 does not support innerHTML on SVG elements.", "if", "(", "el", ".", "innerHTML", ")", "{", "el", "=", "angular", ".", "element", "(", "'<svg xmlns=\"http://www.w3.org/2000/svg\">'", ")", ".", "html", "(", "el", ".", "innerHTML", ")", "[", "0", "]", ";", "}", "else", "{", "el", "=", "angular", ".", "element", "(", "'<svg xmlns=\"http://www.w3.org/2000/svg\">'", ")", ".", "append", "(", "$mdUtil", ".", "getInnerHTML", "(", "el", ")", ")", "[", "0", "]", ";", "}", "if", "(", "viewbox", ")", "el", ".", "setAttribute", "(", "'viewBox'", ",", "viewbox", ")", ";", "}", "if", "(", "el", "&&", "el", ".", "tagName", ".", "toLowerCase", "(", ")", "!==", "'svg'", ")", "{", "el", "=", "angular", ".", "element", "(", "'<svg xmlns=\"http://www.w3.org/2000/svg\">'", ")", ".", "append", "(", "el", ".", "cloneNode", "(", "true", ")", ")", "[", "0", "]", ";", "}", "// Inject the namespace if not available...", "if", "(", "!", "el", ".", "getAttribute", "(", "'xmlns'", ")", ")", "{", "el", ".", "setAttribute", "(", "'xmlns'", ",", "\"http://www.w3.org/2000/svg\"", ")", ";", "}", "this", ".", "element", "=", "el", ";", "this", ".", "config", "=", "config", ";", "this", ".", "prepare", "(", ")", ";", "}" ]
Define the Icon class @param {Element} el @param {=ConfigurationItem} config @constructor
[ "Define", "the", "Icon", "class" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/icon/js/iconService.js#L678-L706
5,061
angular/material
src/components/icon/js/iconService.js
prepareAndStyle
function prepareAndStyle() { var viewBoxSize = this.config ? this.config.viewBoxSize : config.defaultViewBoxSize; angular.forEach({ 'fit': '', 'height': '100%', 'width': '100%', 'preserveAspectRatio': 'xMidYMid meet', 'viewBox': this.element.getAttribute('viewBox') || ('0 0 ' + viewBoxSize + ' ' + viewBoxSize), 'focusable': false // Disable IE11s default behavior to make SVGs focusable }, function(val, attr) { this.element.setAttribute(attr, val); }, this); }
javascript
function prepareAndStyle() { var viewBoxSize = this.config ? this.config.viewBoxSize : config.defaultViewBoxSize; angular.forEach({ 'fit': '', 'height': '100%', 'width': '100%', 'preserveAspectRatio': 'xMidYMid meet', 'viewBox': this.element.getAttribute('viewBox') || ('0 0 ' + viewBoxSize + ' ' + viewBoxSize), 'focusable': false // Disable IE11s default behavior to make SVGs focusable }, function(val, attr) { this.element.setAttribute(attr, val); }, this); }
[ "function", "prepareAndStyle", "(", ")", "{", "var", "viewBoxSize", "=", "this", ".", "config", "?", "this", ".", "config", ".", "viewBoxSize", ":", "config", ".", "defaultViewBoxSize", ";", "angular", ".", "forEach", "(", "{", "'fit'", ":", "''", ",", "'height'", ":", "'100%'", ",", "'width'", ":", "'100%'", ",", "'preserveAspectRatio'", ":", "'xMidYMid meet'", ",", "'viewBox'", ":", "this", ".", "element", ".", "getAttribute", "(", "'viewBox'", ")", "||", "(", "'0 0 '", "+", "viewBoxSize", "+", "' '", "+", "viewBoxSize", ")", ",", "'focusable'", ":", "false", "// Disable IE11s default behavior to make SVGs focusable", "}", ",", "function", "(", "val", ",", "attr", ")", "{", "this", ".", "element", ".", "setAttribute", "(", "attr", ",", "val", ")", ";", "}", ",", "this", ")", ";", "}" ]
Prepare the DOM element that will be cached in the loaded iconCache store.
[ "Prepare", "the", "DOM", "element", "that", "will", "be", "cached", "in", "the", "loaded", "iconCache", "store", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/icon/js/iconService.js#L712-L724
5,062
angular/material
src/components/gridList/grid-list.js
watchMedia
function watchMedia() { for (var mediaName in $mdConstant.MEDIA) { $mdMedia(mediaName); // initialize $mdMedia.getQuery($mdConstant.MEDIA[mediaName]) .addListener(invalidateLayout); } return $mdMedia.watchResponsiveAttributes( ['md-cols', 'md-row-height', 'md-gutter'], attrs, layoutIfMediaMatch); }
javascript
function watchMedia() { for (var mediaName in $mdConstant.MEDIA) { $mdMedia(mediaName); // initialize $mdMedia.getQuery($mdConstant.MEDIA[mediaName]) .addListener(invalidateLayout); } return $mdMedia.watchResponsiveAttributes( ['md-cols', 'md-row-height', 'md-gutter'], attrs, layoutIfMediaMatch); }
[ "function", "watchMedia", "(", ")", "{", "for", "(", "var", "mediaName", "in", "$mdConstant", ".", "MEDIA", ")", "{", "$mdMedia", "(", "mediaName", ")", ";", "// initialize", "$mdMedia", ".", "getQuery", "(", "$mdConstant", ".", "MEDIA", "[", "mediaName", "]", ")", ".", "addListener", "(", "invalidateLayout", ")", ";", "}", "return", "$mdMedia", ".", "watchResponsiveAttributes", "(", "[", "'md-cols'", ",", "'md-row-height'", ",", "'md-gutter'", "]", ",", "attrs", ",", "layoutIfMediaMatch", ")", ";", "}" ]
Watches for changes in media, invalidating layout as necessary.
[ "Watches", "for", "changes", "in", "media", "invalidating", "layout", "as", "necessary", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/gridList/grid-list.js#L122-L130
5,063
angular/material
src/components/gridList/grid-list.js
layoutDelegate
function layoutDelegate(tilesInvalidated) { var tiles = getTileElements(); var props = { tileSpans: getTileSpans(tiles), colCount: getColumnCount(), rowMode: getRowMode(), rowHeight: getRowHeight(), gutter: getGutter() }; if (!tilesInvalidated && angular.equals(props, lastLayoutProps)) { return; } var performance = $mdGridLayout(props.colCount, props.tileSpans, tiles) .map(function(tilePositions, rowCount) { return { grid: { element: element, style: getGridStyle(props.colCount, rowCount, props.gutter, props.rowMode, props.rowHeight) }, tiles: tilePositions.map(function(ps, i) { return { element: angular.element(tiles[i]), style: getTileStyle(ps.position, ps.spans, props.colCount, rowCount, props.gutter, props.rowMode, props.rowHeight) }; }) }; }) .reflow() .performance(); // Report layout scope.mdOnLayout({ $event: { performance: performance } }); lastLayoutProps = props; }
javascript
function layoutDelegate(tilesInvalidated) { var tiles = getTileElements(); var props = { tileSpans: getTileSpans(tiles), colCount: getColumnCount(), rowMode: getRowMode(), rowHeight: getRowHeight(), gutter: getGutter() }; if (!tilesInvalidated && angular.equals(props, lastLayoutProps)) { return; } var performance = $mdGridLayout(props.colCount, props.tileSpans, tiles) .map(function(tilePositions, rowCount) { return { grid: { element: element, style: getGridStyle(props.colCount, rowCount, props.gutter, props.rowMode, props.rowHeight) }, tiles: tilePositions.map(function(ps, i) { return { element: angular.element(tiles[i]), style: getTileStyle(ps.position, ps.spans, props.colCount, rowCount, props.gutter, props.rowMode, props.rowHeight) }; }) }; }) .reflow() .performance(); // Report layout scope.mdOnLayout({ $event: { performance: performance } }); lastLayoutProps = props; }
[ "function", "layoutDelegate", "(", "tilesInvalidated", ")", "{", "var", "tiles", "=", "getTileElements", "(", ")", ";", "var", "props", "=", "{", "tileSpans", ":", "getTileSpans", "(", "tiles", ")", ",", "colCount", ":", "getColumnCount", "(", ")", ",", "rowMode", ":", "getRowMode", "(", ")", ",", "rowHeight", ":", "getRowHeight", "(", ")", ",", "gutter", ":", "getGutter", "(", ")", "}", ";", "if", "(", "!", "tilesInvalidated", "&&", "angular", ".", "equals", "(", "props", ",", "lastLayoutProps", ")", ")", "{", "return", ";", "}", "var", "performance", "=", "$mdGridLayout", "(", "props", ".", "colCount", ",", "props", ".", "tileSpans", ",", "tiles", ")", ".", "map", "(", "function", "(", "tilePositions", ",", "rowCount", ")", "{", "return", "{", "grid", ":", "{", "element", ":", "element", ",", "style", ":", "getGridStyle", "(", "props", ".", "colCount", ",", "rowCount", ",", "props", ".", "gutter", ",", "props", ".", "rowMode", ",", "props", ".", "rowHeight", ")", "}", ",", "tiles", ":", "tilePositions", ".", "map", "(", "function", "(", "ps", ",", "i", ")", "{", "return", "{", "element", ":", "angular", ".", "element", "(", "tiles", "[", "i", "]", ")", ",", "style", ":", "getTileStyle", "(", "ps", ".", "position", ",", "ps", ".", "spans", ",", "props", ".", "colCount", ",", "rowCount", ",", "props", ".", "gutter", ",", "props", ".", "rowMode", ",", "props", ".", "rowHeight", ")", "}", ";", "}", ")", "}", ";", "}", ")", ".", "reflow", "(", ")", ".", "performance", "(", ")", ";", "// Report layout", "scope", ".", "mdOnLayout", "(", "{", "$event", ":", "{", "performance", ":", "performance", "}", "}", ")", ";", "lastLayoutProps", "=", "props", ";", "}" ]
Invokes the layout engine, and uses its results to lay out our tile elements. @param {boolean} tilesInvalidated Whether tiles have been added/removed/moved since the last layout. This is to avoid situations where tiles are replaced with properties identical to their removed counterparts.
[ "Invokes", "the", "layout", "engine", "and", "uses", "its", "results", "to", "lay", "out", "our", "tile", "elements", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/gridList/grid-list.js#L167-L211
5,064
angular/material
src/components/gridList/grid-list.js
getTileStyle
function getTileStyle(position, spans, colCount, rowCount, gutter, rowMode, rowHeight) { // TODO(shyndman): There are style caching opportunities here. // Percent of the available horizontal space that one column takes up. var hShare = (1 / colCount) * 100; // Fraction of the gutter size that each column takes up. var hGutterShare = (colCount - 1) / colCount; // Base horizontal size of a column. var hUnit = UNIT({share: hShare, gutterShare: hGutterShare, gutter: gutter}); // The width and horizontal position of each tile is always calculated the same way, but the // height and vertical position depends on the rowMode. var ltr = document.dir != 'rtl' && document.body.dir != 'rtl'; var style = ltr ? { left: POSITION({ unit: hUnit, offset: position.col, gutter: gutter }), width: DIMENSION({ unit: hUnit, span: spans.col, gutter: gutter }), // resets paddingTop: '', marginTop: '', top: '', height: '' } : { right: POSITION({ unit: hUnit, offset: position.col, gutter: gutter }), width: DIMENSION({ unit: hUnit, span: spans.col, gutter: gutter }), // resets paddingTop: '', marginTop: '', top: '', height: '' }; switch (rowMode) { case 'fixed': // In fixed mode, simply use the given rowHeight. style.top = POSITION({ unit: rowHeight, offset: position.row, gutter: gutter }); style.height = DIMENSION({ unit: rowHeight, span: spans.row, gutter: gutter }); break; case 'ratio': // Percent of the available vertical space that one row takes up. Here, rowHeight holds // the ratio value. For example, if the width:height ratio is 4:3, rowHeight = 1.333. var vShare = hShare / rowHeight; // Base veritcal size of a row. var vUnit = UNIT({ share: vShare, gutterShare: hGutterShare, gutter: gutter }); // padidngTop and marginTop are used to maintain the given aspect ratio, as // a percentage-based value for these properties is applied to the *width* of the // containing block. See http://www.w3.org/TR/CSS2/box.html#margin-properties style.paddingTop = DIMENSION({ unit: vUnit, span: spans.row, gutter: gutter}); style.marginTop = POSITION({ unit: vUnit, offset: position.row, gutter: gutter }); break; case 'fit': // Fraction of the gutter size that each column takes up. var vGutterShare = (rowCount - 1) / rowCount; // Percent of the available vertical space that one row takes up. vShare = (1 / rowCount) * 100; // Base vertical size of a row. vUnit = UNIT({share: vShare, gutterShare: vGutterShare, gutter: gutter}); style.top = POSITION({unit: vUnit, offset: position.row, gutter: gutter}); style.height = DIMENSION({unit: vUnit, span: spans.row, gutter: gutter}); break; } return style; }
javascript
function getTileStyle(position, spans, colCount, rowCount, gutter, rowMode, rowHeight) { // TODO(shyndman): There are style caching opportunities here. // Percent of the available horizontal space that one column takes up. var hShare = (1 / colCount) * 100; // Fraction of the gutter size that each column takes up. var hGutterShare = (colCount - 1) / colCount; // Base horizontal size of a column. var hUnit = UNIT({share: hShare, gutterShare: hGutterShare, gutter: gutter}); // The width and horizontal position of each tile is always calculated the same way, but the // height and vertical position depends on the rowMode. var ltr = document.dir != 'rtl' && document.body.dir != 'rtl'; var style = ltr ? { left: POSITION({ unit: hUnit, offset: position.col, gutter: gutter }), width: DIMENSION({ unit: hUnit, span: spans.col, gutter: gutter }), // resets paddingTop: '', marginTop: '', top: '', height: '' } : { right: POSITION({ unit: hUnit, offset: position.col, gutter: gutter }), width: DIMENSION({ unit: hUnit, span: spans.col, gutter: gutter }), // resets paddingTop: '', marginTop: '', top: '', height: '' }; switch (rowMode) { case 'fixed': // In fixed mode, simply use the given rowHeight. style.top = POSITION({ unit: rowHeight, offset: position.row, gutter: gutter }); style.height = DIMENSION({ unit: rowHeight, span: spans.row, gutter: gutter }); break; case 'ratio': // Percent of the available vertical space that one row takes up. Here, rowHeight holds // the ratio value. For example, if the width:height ratio is 4:3, rowHeight = 1.333. var vShare = hShare / rowHeight; // Base veritcal size of a row. var vUnit = UNIT({ share: vShare, gutterShare: hGutterShare, gutter: gutter }); // padidngTop and marginTop are used to maintain the given aspect ratio, as // a percentage-based value for these properties is applied to the *width* of the // containing block. See http://www.w3.org/TR/CSS2/box.html#margin-properties style.paddingTop = DIMENSION({ unit: vUnit, span: spans.row, gutter: gutter}); style.marginTop = POSITION({ unit: vUnit, offset: position.row, gutter: gutter }); break; case 'fit': // Fraction of the gutter size that each column takes up. var vGutterShare = (rowCount - 1) / rowCount; // Percent of the available vertical space that one row takes up. vShare = (1 / rowCount) * 100; // Base vertical size of a row. vUnit = UNIT({share: vShare, gutterShare: vGutterShare, gutter: gutter}); style.top = POSITION({unit: vUnit, offset: position.row, gutter: gutter}); style.height = DIMENSION({unit: vUnit, span: spans.row, gutter: gutter}); break; } return style; }
[ "function", "getTileStyle", "(", "position", ",", "spans", ",", "colCount", ",", "rowCount", ",", "gutter", ",", "rowMode", ",", "rowHeight", ")", "{", "// TODO(shyndman): There are style caching opportunities here.", "// Percent of the available horizontal space that one column takes up.", "var", "hShare", "=", "(", "1", "/", "colCount", ")", "*", "100", ";", "// Fraction of the gutter size that each column takes up.", "var", "hGutterShare", "=", "(", "colCount", "-", "1", ")", "/", "colCount", ";", "// Base horizontal size of a column.", "var", "hUnit", "=", "UNIT", "(", "{", "share", ":", "hShare", ",", "gutterShare", ":", "hGutterShare", ",", "gutter", ":", "gutter", "}", ")", ";", "// The width and horizontal position of each tile is always calculated the same way, but the", "// height and vertical position depends on the rowMode.", "var", "ltr", "=", "document", ".", "dir", "!=", "'rtl'", "&&", "document", ".", "body", ".", "dir", "!=", "'rtl'", ";", "var", "style", "=", "ltr", "?", "{", "left", ":", "POSITION", "(", "{", "unit", ":", "hUnit", ",", "offset", ":", "position", ".", "col", ",", "gutter", ":", "gutter", "}", ")", ",", "width", ":", "DIMENSION", "(", "{", "unit", ":", "hUnit", ",", "span", ":", "spans", ".", "col", ",", "gutter", ":", "gutter", "}", ")", ",", "// resets", "paddingTop", ":", "''", ",", "marginTop", ":", "''", ",", "top", ":", "''", ",", "height", ":", "''", "}", ":", "{", "right", ":", "POSITION", "(", "{", "unit", ":", "hUnit", ",", "offset", ":", "position", ".", "col", ",", "gutter", ":", "gutter", "}", ")", ",", "width", ":", "DIMENSION", "(", "{", "unit", ":", "hUnit", ",", "span", ":", "spans", ".", "col", ",", "gutter", ":", "gutter", "}", ")", ",", "// resets", "paddingTop", ":", "''", ",", "marginTop", ":", "''", ",", "top", ":", "''", ",", "height", ":", "''", "}", ";", "switch", "(", "rowMode", ")", "{", "case", "'fixed'", ":", "// In fixed mode, simply use the given rowHeight.", "style", ".", "top", "=", "POSITION", "(", "{", "unit", ":", "rowHeight", ",", "offset", ":", "position", ".", "row", ",", "gutter", ":", "gutter", "}", ")", ";", "style", ".", "height", "=", "DIMENSION", "(", "{", "unit", ":", "rowHeight", ",", "span", ":", "spans", ".", "row", ",", "gutter", ":", "gutter", "}", ")", ";", "break", ";", "case", "'ratio'", ":", "// Percent of the available vertical space that one row takes up. Here, rowHeight holds", "// the ratio value. For example, if the width:height ratio is 4:3, rowHeight = 1.333.", "var", "vShare", "=", "hShare", "/", "rowHeight", ";", "// Base veritcal size of a row.", "var", "vUnit", "=", "UNIT", "(", "{", "share", ":", "vShare", ",", "gutterShare", ":", "hGutterShare", ",", "gutter", ":", "gutter", "}", ")", ";", "// padidngTop and marginTop are used to maintain the given aspect ratio, as", "// a percentage-based value for these properties is applied to the *width* of the", "// containing block. See http://www.w3.org/TR/CSS2/box.html#margin-properties", "style", ".", "paddingTop", "=", "DIMENSION", "(", "{", "unit", ":", "vUnit", ",", "span", ":", "spans", ".", "row", ",", "gutter", ":", "gutter", "}", ")", ";", "style", ".", "marginTop", "=", "POSITION", "(", "{", "unit", ":", "vUnit", ",", "offset", ":", "position", ".", "row", ",", "gutter", ":", "gutter", "}", ")", ";", "break", ";", "case", "'fit'", ":", "// Fraction of the gutter size that each column takes up.", "var", "vGutterShare", "=", "(", "rowCount", "-", "1", ")", "/", "rowCount", ";", "// Percent of the available vertical space that one row takes up.", "vShare", "=", "(", "1", "/", "rowCount", ")", "*", "100", ";", "// Base vertical size of a row.", "vUnit", "=", "UNIT", "(", "{", "share", ":", "vShare", ",", "gutterShare", ":", "vGutterShare", ",", "gutter", ":", "gutter", "}", ")", ";", "style", ".", "top", "=", "POSITION", "(", "{", "unit", ":", "vUnit", ",", "offset", ":", "position", ".", "row", ",", "gutter", ":", "gutter", "}", ")", ";", "style", ".", "height", "=", "DIMENSION", "(", "{", "unit", ":", "vUnit", ",", "span", ":", "spans", ".", "row", ",", "gutter", ":", "gutter", "}", ")", ";", "break", ";", "}", "return", "style", ";", "}" ]
Gets the styles applied to a tile element described by the given parameters. @param {{row: number, col: number}} position The row and column indices of the tile. @param {{row: number, col: number}} spans The rowSpan and colSpan of the tile. @param {number} colCount The number of columns. @param {number} rowCount The number of rows. @param {string} gutter The amount of space between tiles. This will be something like '5px' or '2em'. @param {string} rowMode The row height mode. Can be one of: 'fixed': all rows have a fixed size, given by rowHeight, 'ratio': row height defined as a ratio to width, or 'fit': fit to the grid-list element height, divinding evenly among rows. @param {string|number} rowHeight The height of a row. This is only used for 'fixed' mode and for 'ratio' mode. For 'ratio' mode, this is the *ratio* of width-to-height (e.g., 0.75). @returns {Object} Map of CSS properties to be applied to the style element. Will define values for top, left, width, height, marginTop, and paddingTop.
[ "Gets", "the", "styles", "applied", "to", "a", "tile", "element", "described", "by", "the", "given", "parameters", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/gridList/grid-list.js#L259-L330
5,065
angular/material
src/components/gridList/grid-list.js
getTileSpans
function getTileSpans(tileElements) { return [].map.call(tileElements, function(ele) { var ctrl = angular.element(ele).controller('mdGridTile'); return { row: parseInt( $mdMedia.getResponsiveAttribute(ctrl.$attrs, 'md-rowspan'), 10) || 1, col: parseInt( $mdMedia.getResponsiveAttribute(ctrl.$attrs, 'md-colspan'), 10) || 1 }; }); }
javascript
function getTileSpans(tileElements) { return [].map.call(tileElements, function(ele) { var ctrl = angular.element(ele).controller('mdGridTile'); return { row: parseInt( $mdMedia.getResponsiveAttribute(ctrl.$attrs, 'md-rowspan'), 10) || 1, col: parseInt( $mdMedia.getResponsiveAttribute(ctrl.$attrs, 'md-colspan'), 10) || 1 }; }); }
[ "function", "getTileSpans", "(", "tileElements", ")", "{", "return", "[", "]", ".", "map", ".", "call", "(", "tileElements", ",", "function", "(", "ele", ")", "{", "var", "ctrl", "=", "angular", ".", "element", "(", "ele", ")", ".", "controller", "(", "'mdGridTile'", ")", ";", "return", "{", "row", ":", "parseInt", "(", "$mdMedia", ".", "getResponsiveAttribute", "(", "ctrl", ".", "$attrs", ",", "'md-rowspan'", ")", ",", "10", ")", "||", "1", ",", "col", ":", "parseInt", "(", "$mdMedia", ".", "getResponsiveAttribute", "(", "ctrl", ".", "$attrs", ",", "'md-colspan'", ")", ",", "10", ")", "||", "1", "}", ";", "}", ")", ";", "}" ]
Gets an array of objects containing the rowspan and colspan for each tile. @returns {Array<{row: number, col: number}>}
[ "Gets", "an", "array", "of", "objects", "containing", "the", "rowspan", "and", "colspan", "for", "each", "tile", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/gridList/grid-list.js#L370-L380
5,066
angular/material
src/components/gridList/grid-list.js
GridLayout
function GridLayout(colCount, tileSpans) { var self, layoutInfo, gridStyles, layoutTime, mapTime, reflowTime; layoutTime = $mdUtil.time(function() { layoutInfo = calculateGridFor(colCount, tileSpans); }); return self = { /** * An array of objects describing each tile's position in the grid. */ layoutInfo: function() { return layoutInfo; }, /** * Maps grid positioning to an element and a set of styles using the * provided updateFn. */ map: function(updateFn) { mapTime = $mdUtil.time(function() { var info = self.layoutInfo(); gridStyles = updateFn(info.positioning, info.rowCount); }); return self; }, /** * Default animator simply sets the element.css( <styles> ). An alternate * animator can be provided as an argument. The function has the following * signature: * * function({grid: {element: JQLite, style: Object}, tiles: Array<{element: JQLite, style: Object}>) */ reflow: function(animatorFn) { reflowTime = $mdUtil.time(function() { var animator = animatorFn || defaultAnimator; animator(gridStyles.grid, gridStyles.tiles); }); return self; }, /** * Timing for the most recent layout run. */ performance: function() { return { tileCount: tileSpans.length, layoutTime: layoutTime, mapTime: mapTime, reflowTime: reflowTime, totalTime: layoutTime + mapTime + reflowTime }; } }; }
javascript
function GridLayout(colCount, tileSpans) { var self, layoutInfo, gridStyles, layoutTime, mapTime, reflowTime; layoutTime = $mdUtil.time(function() { layoutInfo = calculateGridFor(colCount, tileSpans); }); return self = { /** * An array of objects describing each tile's position in the grid. */ layoutInfo: function() { return layoutInfo; }, /** * Maps grid positioning to an element and a set of styles using the * provided updateFn. */ map: function(updateFn) { mapTime = $mdUtil.time(function() { var info = self.layoutInfo(); gridStyles = updateFn(info.positioning, info.rowCount); }); return self; }, /** * Default animator simply sets the element.css( <styles> ). An alternate * animator can be provided as an argument. The function has the following * signature: * * function({grid: {element: JQLite, style: Object}, tiles: Array<{element: JQLite, style: Object}>) */ reflow: function(animatorFn) { reflowTime = $mdUtil.time(function() { var animator = animatorFn || defaultAnimator; animator(gridStyles.grid, gridStyles.tiles); }); return self; }, /** * Timing for the most recent layout run. */ performance: function() { return { tileCount: tileSpans.length, layoutTime: layoutTime, mapTime: mapTime, reflowTime: reflowTime, totalTime: layoutTime + mapTime + reflowTime }; } }; }
[ "function", "GridLayout", "(", "colCount", ",", "tileSpans", ")", "{", "var", "self", ",", "layoutInfo", ",", "gridStyles", ",", "layoutTime", ",", "mapTime", ",", "reflowTime", ";", "layoutTime", "=", "$mdUtil", ".", "time", "(", "function", "(", ")", "{", "layoutInfo", "=", "calculateGridFor", "(", "colCount", ",", "tileSpans", ")", ";", "}", ")", ";", "return", "self", "=", "{", "/**\n * An array of objects describing each tile's position in the grid.\n */", "layoutInfo", ":", "function", "(", ")", "{", "return", "layoutInfo", ";", "}", ",", "/**\n * Maps grid positioning to an element and a set of styles using the\n * provided updateFn.\n */", "map", ":", "function", "(", "updateFn", ")", "{", "mapTime", "=", "$mdUtil", ".", "time", "(", "function", "(", ")", "{", "var", "info", "=", "self", ".", "layoutInfo", "(", ")", ";", "gridStyles", "=", "updateFn", "(", "info", ".", "positioning", ",", "info", ".", "rowCount", ")", ";", "}", ")", ";", "return", "self", ";", "}", ",", "/**\n * Default animator simply sets the element.css( <styles> ). An alternate\n * animator can be provided as an argument. The function has the following\n * signature:\n *\n * function({grid: {element: JQLite, style: Object}, tiles: Array<{element: JQLite, style: Object}>)\n */", "reflow", ":", "function", "(", "animatorFn", ")", "{", "reflowTime", "=", "$mdUtil", ".", "time", "(", "function", "(", ")", "{", "var", "animator", "=", "animatorFn", "||", "defaultAnimator", ";", "animator", "(", "gridStyles", ".", "grid", ",", "gridStyles", ".", "tiles", ")", ";", "}", ")", ";", "return", "self", ";", "}", ",", "/**\n * Timing for the most recent layout run.\n */", "performance", ":", "function", "(", ")", "{", "return", "{", "tileCount", ":", "tileSpans", ".", "length", ",", "layoutTime", ":", "layoutTime", ",", "mapTime", ":", "mapTime", ",", "reflowTime", ":", "reflowTime", ",", "totalTime", ":", "layoutTime", "+", "mapTime", "+", "reflowTime", "}", ";", "}", "}", ";", "}" ]
Publish layout function
[ "Publish", "layout", "function" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/gridList/grid-list.js#L481-L537
5,067
angular/material
src/components/gridList/grid-list.js
function(updateFn) { mapTime = $mdUtil.time(function() { var info = self.layoutInfo(); gridStyles = updateFn(info.positioning, info.rowCount); }); return self; }
javascript
function(updateFn) { mapTime = $mdUtil.time(function() { var info = self.layoutInfo(); gridStyles = updateFn(info.positioning, info.rowCount); }); return self; }
[ "function", "(", "updateFn", ")", "{", "mapTime", "=", "$mdUtil", ".", "time", "(", "function", "(", ")", "{", "var", "info", "=", "self", ".", "layoutInfo", "(", ")", ";", "gridStyles", "=", "updateFn", "(", "info", ".", "positioning", ",", "info", ".", "rowCount", ")", ";", "}", ")", ";", "return", "self", ";", "}" ]
Maps grid positioning to an element and a set of styles using the provided updateFn.
[ "Maps", "grid", "positioning", "to", "an", "element", "and", "a", "set", "of", "styles", "using", "the", "provided", "updateFn", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/gridList/grid-list.js#L501-L507
5,068
angular/material
src/components/gridList/grid-list.js
function() { return { tileCount: tileSpans.length, layoutTime: layoutTime, mapTime: mapTime, reflowTime: reflowTime, totalTime: layoutTime + mapTime + reflowTime }; }
javascript
function() { return { tileCount: tileSpans.length, layoutTime: layoutTime, mapTime: mapTime, reflowTime: reflowTime, totalTime: layoutTime + mapTime + reflowTime }; }
[ "function", "(", ")", "{", "return", "{", "tileCount", ":", "tileSpans", ".", "length", ",", "layoutTime", ":", "layoutTime", ",", "mapTime", ":", "mapTime", ",", "reflowTime", ":", "reflowTime", ",", "totalTime", ":", "layoutTime", "+", "mapTime", "+", "reflowTime", "}", ";", "}" ]
Timing for the most recent layout run.
[ "Timing", "for", "the", "most", "recent", "layout", "run", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/gridList/grid-list.js#L527-L535
5,069
angular/material
src/components/gridList/grid-list.js
calculateGridFor
function calculateGridFor(colCount, tileSpans) { var curCol = 0, curRow = 0, spaceTracker = newSpaceTracker(); return { positioning: tileSpans.map(function(spans, i) { return { spans: spans, position: reserveSpace(spans, i) }; }), rowCount: curRow + Math.max.apply(Math, spaceTracker) }; function reserveSpace(spans, i) { if (spans.col > colCount) { throw 'md-grid-list: Tile at position ' + i + ' has a colspan ' + '(' + spans.col + ') that exceeds the column count ' + '(' + colCount + ')'; } var start = 0, end = 0; // TODO(shyndman): This loop isn't strictly necessary if you can // determine the minimum number of rows before a space opens up. To do // this, recognize that you've iterated across an entire row looking for // space, and if so fast-forward by the minimum rowSpan count. Repeat // until the required space opens up. while (end - start < spans.col) { if (curCol >= colCount) { nextRow(); continue; } start = spaceTracker.indexOf(0, curCol); if (start === -1 || (end = findEnd(start + 1)) === -1) { start = end = 0; nextRow(); continue; } curCol = end + 1; } adjustRow(start, spans.col, spans.row); curCol = start + spans.col; return { col: start, row: curRow }; } function nextRow() { curCol = 0; curRow++; adjustRow(0, colCount, -1); // Decrement row spans by one } function adjustRow(from, cols, by) { for (var i = from; i < from + cols; i++) { spaceTracker[i] = Math.max(spaceTracker[i] + by, 0); } } function findEnd(start) { var i; for (i = start; i < spaceTracker.length; i++) { if (spaceTracker[i] !== 0) { return i; } } if (i === spaceTracker.length) { return i; } } function newSpaceTracker() { var tracker = []; for (var i = 0; i < colCount; i++) { tracker.push(0); } return tracker; } }
javascript
function calculateGridFor(colCount, tileSpans) { var curCol = 0, curRow = 0, spaceTracker = newSpaceTracker(); return { positioning: tileSpans.map(function(spans, i) { return { spans: spans, position: reserveSpace(spans, i) }; }), rowCount: curRow + Math.max.apply(Math, spaceTracker) }; function reserveSpace(spans, i) { if (spans.col > colCount) { throw 'md-grid-list: Tile at position ' + i + ' has a colspan ' + '(' + spans.col + ') that exceeds the column count ' + '(' + colCount + ')'; } var start = 0, end = 0; // TODO(shyndman): This loop isn't strictly necessary if you can // determine the minimum number of rows before a space opens up. To do // this, recognize that you've iterated across an entire row looking for // space, and if so fast-forward by the minimum rowSpan count. Repeat // until the required space opens up. while (end - start < spans.col) { if (curCol >= colCount) { nextRow(); continue; } start = spaceTracker.indexOf(0, curCol); if (start === -1 || (end = findEnd(start + 1)) === -1) { start = end = 0; nextRow(); continue; } curCol = end + 1; } adjustRow(start, spans.col, spans.row); curCol = start + spans.col; return { col: start, row: curRow }; } function nextRow() { curCol = 0; curRow++; adjustRow(0, colCount, -1); // Decrement row spans by one } function adjustRow(from, cols, by) { for (var i = from; i < from + cols; i++) { spaceTracker[i] = Math.max(spaceTracker[i] + by, 0); } } function findEnd(start) { var i; for (i = start; i < spaceTracker.length; i++) { if (spaceTracker[i] !== 0) { return i; } } if (i === spaceTracker.length) { return i; } } function newSpaceTracker() { var tracker = []; for (var i = 0; i < colCount; i++) { tracker.push(0); } return tracker; } }
[ "function", "calculateGridFor", "(", "colCount", ",", "tileSpans", ")", "{", "var", "curCol", "=", "0", ",", "curRow", "=", "0", ",", "spaceTracker", "=", "newSpaceTracker", "(", ")", ";", "return", "{", "positioning", ":", "tileSpans", ".", "map", "(", "function", "(", "spans", ",", "i", ")", "{", "return", "{", "spans", ":", "spans", ",", "position", ":", "reserveSpace", "(", "spans", ",", "i", ")", "}", ";", "}", ")", ",", "rowCount", ":", "curRow", "+", "Math", ".", "max", ".", "apply", "(", "Math", ",", "spaceTracker", ")", "}", ";", "function", "reserveSpace", "(", "spans", ",", "i", ")", "{", "if", "(", "spans", ".", "col", ">", "colCount", ")", "{", "throw", "'md-grid-list: Tile at position '", "+", "i", "+", "' has a colspan '", "+", "'('", "+", "spans", ".", "col", "+", "') that exceeds the column count '", "+", "'('", "+", "colCount", "+", "')'", ";", "}", "var", "start", "=", "0", ",", "end", "=", "0", ";", "// TODO(shyndman): This loop isn't strictly necessary if you can", "// determine the minimum number of rows before a space opens up. To do", "// this, recognize that you've iterated across an entire row looking for", "// space, and if so fast-forward by the minimum rowSpan count. Repeat", "// until the required space opens up.", "while", "(", "end", "-", "start", "<", "spans", ".", "col", ")", "{", "if", "(", "curCol", ">=", "colCount", ")", "{", "nextRow", "(", ")", ";", "continue", ";", "}", "start", "=", "spaceTracker", ".", "indexOf", "(", "0", ",", "curCol", ")", ";", "if", "(", "start", "===", "-", "1", "||", "(", "end", "=", "findEnd", "(", "start", "+", "1", ")", ")", "===", "-", "1", ")", "{", "start", "=", "end", "=", "0", ";", "nextRow", "(", ")", ";", "continue", ";", "}", "curCol", "=", "end", "+", "1", ";", "}", "adjustRow", "(", "start", ",", "spans", ".", "col", ",", "spans", ".", "row", ")", ";", "curCol", "=", "start", "+", "spans", ".", "col", ";", "return", "{", "col", ":", "start", ",", "row", ":", "curRow", "}", ";", "}", "function", "nextRow", "(", ")", "{", "curCol", "=", "0", ";", "curRow", "++", ";", "adjustRow", "(", "0", ",", "colCount", ",", "-", "1", ")", ";", "// Decrement row spans by one", "}", "function", "adjustRow", "(", "from", ",", "cols", ",", "by", ")", "{", "for", "(", "var", "i", "=", "from", ";", "i", "<", "from", "+", "cols", ";", "i", "++", ")", "{", "spaceTracker", "[", "i", "]", "=", "Math", ".", "max", "(", "spaceTracker", "[", "i", "]", "+", "by", ",", "0", ")", ";", "}", "}", "function", "findEnd", "(", "start", ")", "{", "var", "i", ";", "for", "(", "i", "=", "start", ";", "i", "<", "spaceTracker", ".", "length", ";", "i", "++", ")", "{", "if", "(", "spaceTracker", "[", "i", "]", "!==", "0", ")", "{", "return", "i", ";", "}", "}", "if", "(", "i", "===", "spaceTracker", ".", "length", ")", "{", "return", "i", ";", "}", "}", "function", "newSpaceTracker", "(", ")", "{", "var", "tracker", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "colCount", ";", "i", "++", ")", "{", "tracker", ".", "push", "(", "0", ")", ";", "}", "return", "tracker", ";", "}", "}" ]
Calculates the positions of tiles. The algorithm works as follows: An Array<Number> with length colCount (spaceTracker) keeps track of available tiling positions, where elements of value 0 represents an empty position. Space for a tile is reserved by finding a sequence of 0s with length <= than the tile's colspan. When such a space has been found, the occupied tile positions are incremented by the tile's rowspan value, as these positions have become unavailable for that many rows. If the end of a row has been reached without finding space for the tile, spaceTracker's elements are each decremented by 1 to a minimum of 0. Rows are searched in this fashion until space is found.
[ "Calculates", "the", "positions", "of", "tiles", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/gridList/grid-list.js#L572-L659
5,070
angular/material
release.js
validate
function validate () { if (exec('npm whoami') !== 'angular') { err('You must be authenticated with npm as "angular" to perform a release.'); } else if (exec('git rev-parse --abbrev-ref HEAD') !== 'staging') { err('Releases can only performed from "staging" at this time.'); } else { return true; } function err (msg) { const str = 'Error: ' + msg; log(str.red); } }
javascript
function validate () { if (exec('npm whoami') !== 'angular') { err('You must be authenticated with npm as "angular" to perform a release.'); } else if (exec('git rev-parse --abbrev-ref HEAD') !== 'staging') { err('Releases can only performed from "staging" at this time.'); } else { return true; } function err (msg) { const str = 'Error: ' + msg; log(str.red); } }
[ "function", "validate", "(", ")", "{", "if", "(", "exec", "(", "'npm whoami'", ")", "!==", "'angular'", ")", "{", "err", "(", "'You must be authenticated with npm as \"angular\" to perform a release.'", ")", ";", "}", "else", "if", "(", "exec", "(", "'git rev-parse --abbrev-ref HEAD'", ")", "!==", "'staging'", ")", "{", "err", "(", "'Releases can only performed from \"staging\" at this time.'", ")", ";", "}", "else", "{", "return", "true", ";", "}", "function", "err", "(", "msg", ")", "{", "const", "str", "=", "'Error: '", "+", "msg", ";", "log", "(", "str", ".", "red", ")", ";", "}", "}" ]
utility methods confirms that you will be able to perform the release before attempting
[ "utility", "methods", "confirms", "that", "you", "will", "be", "able", "to", "perform", "the", "release", "before", "attempting" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L62-L74
5,071
angular/material
release.js
checkoutVersionBranch
function checkoutVersionBranch () { exec(`git branch -q -D release/${newVersion}`); exec(`git checkout -q -b release/${newVersion}`); abortCmds.push('git checkout master'); abortCmds.push(`git branch -D release/${newVersion}`); }
javascript
function checkoutVersionBranch () { exec(`git branch -q -D release/${newVersion}`); exec(`git checkout -q -b release/${newVersion}`); abortCmds.push('git checkout master'); abortCmds.push(`git branch -D release/${newVersion}`); }
[ "function", "checkoutVersionBranch", "(", ")", "{", "exec", "(", "`", "${", "newVersion", "}", "`", ")", ";", "exec", "(", "`", "${", "newVersion", "}", "`", ")", ";", "abortCmds", ".", "push", "(", "'git checkout master'", ")", ";", "abortCmds", ".", "push", "(", "`", "${", "newVersion", "}", "`", ")", ";", "}" ]
creates the version branch and adds abort steps
[ "creates", "the", "version", "branch", "and", "adds", "abort", "steps" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L77-L82
5,072
angular/material
release.js
updateVersion
function updateVersion () { start(`Updating ${"package.json".cyan} version from ${oldVersion.cyan} to ${newVersion.cyan}...`); pkg.version = newVersion; fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2)); done(); abortCmds.push('git checkout package.json'); pushCmds.push('git add package.json'); }
javascript
function updateVersion () { start(`Updating ${"package.json".cyan} version from ${oldVersion.cyan} to ${newVersion.cyan}...`); pkg.version = newVersion; fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2)); done(); abortCmds.push('git checkout package.json'); pushCmds.push('git add package.json'); }
[ "function", "updateVersion", "(", ")", "{", "start", "(", "`", "${", "\"package.json\"", ".", "cyan", "}", "${", "oldVersion", ".", "cyan", "}", "${", "newVersion", ".", "cyan", "}", "`", ")", ";", "pkg", ".", "version", "=", "newVersion", ";", "fs", ".", "writeFileSync", "(", "'./package.json'", ",", "JSON", ".", "stringify", "(", "pkg", ",", "null", ",", "2", ")", ")", ";", "done", "(", ")", ";", "abortCmds", ".", "push", "(", "'git checkout package.json'", ")", ";", "pushCmds", ".", "push", "(", "'git add package.json'", ")", ";", "}" ]
writes the new version to package.json
[ "writes", "the", "new", "version", "to", "package", ".", "json" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L85-L92
5,073
angular/material
release.js
createChangelog
function createChangelog () { start(`Generating changelog from ${oldVersion.cyan} to ${newVersion.cyan}...`); exec(`git fetch --tags ${origin}`); exec(`git checkout CHANGELOG.md`); exec(`gulp changelog --sha=$(git merge-base v${lastMajorVer} HEAD)`); done(); abortCmds.push('git checkout CHANGELOG.md'); pushCmds.push('git add CHANGELOG.md'); }
javascript
function createChangelog () { start(`Generating changelog from ${oldVersion.cyan} to ${newVersion.cyan}...`); exec(`git fetch --tags ${origin}`); exec(`git checkout CHANGELOG.md`); exec(`gulp changelog --sha=$(git merge-base v${lastMajorVer} HEAD)`); done(); abortCmds.push('git checkout CHANGELOG.md'); pushCmds.push('git add CHANGELOG.md'); }
[ "function", "createChangelog", "(", ")", "{", "start", "(", "`", "${", "oldVersion", ".", "cyan", "}", "${", "newVersion", ".", "cyan", "}", "`", ")", ";", "exec", "(", "`", "${", "origin", "}", "`", ")", ";", "exec", "(", "`", "`", ")", ";", "exec", "(", "`", "${", "lastMajorVer", "}", "`", ")", ";", "done", "(", ")", ";", "abortCmds", ".", "push", "(", "'git checkout CHANGELOG.md'", ")", ";", "pushCmds", ".", "push", "(", "'git add CHANGELOG.md'", ")", ";", "}" ]
generates the changelog from the commits since the last release
[ "generates", "the", "changelog", "from", "the", "commits", "since", "the", "last", "release" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L95-L106
5,074
angular/material
release.js
getNewVersion
function getNewVersion () { header(); const options = getVersionOptions(oldVersion); let key, version; log(`The current version is ${oldVersion.cyan}.`); log(''); log('What should the next version be?'); for (key in options) { log((+key + 1) + ') ' + options[ key ].cyan); } log(''); write('Please select a new version: '); const type = prompt(); if (options[ type - 1 ]) version = options[ type - 1 ]; else if (type.match(/^\d+\.\d+\.\d+(-rc\.?\d+)?$/)) version = type; else throw new Error('Your entry was invalid.'); log(''); log('The new version will be ' + version.cyan + '.'); write(`Is this correct? ${"[yes/no]".cyan} `); return prompt() === 'yes' ? version : getNewVersion(); function getVersionOptions (version) { return version.match(/-rc\.?\d+$/) ? [increment(version, 'rc'), increment(version, 'minor')] : [increment(version, 'patch'), addRC(increment(version, 'minor'))]; function increment (versionString, type) { const version = parseVersion(versionString); if (version.rc) { switch (type) { case 'minor': version.rc = 0; break; case 'rc': version.rc++; break; } } else { version[ type ]++; // reset any version numbers lower than the one changed switch (type) { case 'minor': version.patch = 0; case 'patch': version.rc = 0; } } return getVersionString(version); function parseVersion (version) { const parts = version.split(/-rc\.|\./g); return { string: version, major: parts[ 0 ], minor: parts[ 1 ], patch: parts[ 2 ], rc: parts[ 3 ] || 0 }; } function getVersionString (version) { let str = version.major + '.' + version.minor + '.' + version.patch; if (version.rc) str += '-rc.' + version.rc; return str; } } function addRC (str) { return str + '-rc.1'; } } }
javascript
function getNewVersion () { header(); const options = getVersionOptions(oldVersion); let key, version; log(`The current version is ${oldVersion.cyan}.`); log(''); log('What should the next version be?'); for (key in options) { log((+key + 1) + ') ' + options[ key ].cyan); } log(''); write('Please select a new version: '); const type = prompt(); if (options[ type - 1 ]) version = options[ type - 1 ]; else if (type.match(/^\d+\.\d+\.\d+(-rc\.?\d+)?$/)) version = type; else throw new Error('Your entry was invalid.'); log(''); log('The new version will be ' + version.cyan + '.'); write(`Is this correct? ${"[yes/no]".cyan} `); return prompt() === 'yes' ? version : getNewVersion(); function getVersionOptions (version) { return version.match(/-rc\.?\d+$/) ? [increment(version, 'rc'), increment(version, 'minor')] : [increment(version, 'patch'), addRC(increment(version, 'minor'))]; function increment (versionString, type) { const version = parseVersion(versionString); if (version.rc) { switch (type) { case 'minor': version.rc = 0; break; case 'rc': version.rc++; break; } } else { version[ type ]++; // reset any version numbers lower than the one changed switch (type) { case 'minor': version.patch = 0; case 'patch': version.rc = 0; } } return getVersionString(version); function parseVersion (version) { const parts = version.split(/-rc\.|\./g); return { string: version, major: parts[ 0 ], minor: parts[ 1 ], patch: parts[ 2 ], rc: parts[ 3 ] || 0 }; } function getVersionString (version) { let str = version.major + '.' + version.minor + '.' + version.patch; if (version.rc) str += '-rc.' + version.rc; return str; } } function addRC (str) { return str + '-rc.1'; } } }
[ "function", "getNewVersion", "(", ")", "{", "header", "(", ")", ";", "const", "options", "=", "getVersionOptions", "(", "oldVersion", ")", ";", "let", "key", ",", "version", ";", "log", "(", "`", "${", "oldVersion", ".", "cyan", "}", "`", ")", ";", "log", "(", "''", ")", ";", "log", "(", "'What should the next version be?'", ")", ";", "for", "(", "key", "in", "options", ")", "{", "log", "(", "(", "+", "key", "+", "1", ")", "+", "') '", "+", "options", "[", "key", "]", ".", "cyan", ")", ";", "}", "log", "(", "''", ")", ";", "write", "(", "'Please select a new version: '", ")", ";", "const", "type", "=", "prompt", "(", ")", ";", "if", "(", "options", "[", "type", "-", "1", "]", ")", "version", "=", "options", "[", "type", "-", "1", "]", ";", "else", "if", "(", "type", ".", "match", "(", "/", "^\\d+\\.\\d+\\.\\d+(-rc\\.?\\d+)?$", "/", ")", ")", "version", "=", "type", ";", "else", "throw", "new", "Error", "(", "'Your entry was invalid.'", ")", ";", "log", "(", "''", ")", ";", "log", "(", "'The new version will be '", "+", "version", ".", "cyan", "+", "'.'", ")", ";", "write", "(", "`", "${", "\"[yes/no]\"", ".", "cyan", "}", "`", ")", ";", "return", "prompt", "(", ")", "===", "'yes'", "?", "version", ":", "getNewVersion", "(", ")", ";", "function", "getVersionOptions", "(", "version", ")", "{", "return", "version", ".", "match", "(", "/", "-rc\\.?\\d+$", "/", ")", "?", "[", "increment", "(", "version", ",", "'rc'", ")", ",", "increment", "(", "version", ",", "'minor'", ")", "]", ":", "[", "increment", "(", "version", ",", "'patch'", ")", ",", "addRC", "(", "increment", "(", "version", ",", "'minor'", ")", ")", "]", ";", "function", "increment", "(", "versionString", ",", "type", ")", "{", "const", "version", "=", "parseVersion", "(", "versionString", ")", ";", "if", "(", "version", ".", "rc", ")", "{", "switch", "(", "type", ")", "{", "case", "'minor'", ":", "version", ".", "rc", "=", "0", ";", "break", ";", "case", "'rc'", ":", "version", ".", "rc", "++", ";", "break", ";", "}", "}", "else", "{", "version", "[", "type", "]", "++", ";", "// reset any version numbers lower than the one changed", "switch", "(", "type", ")", "{", "case", "'minor'", ":", "version", ".", "patch", "=", "0", ";", "case", "'patch'", ":", "version", ".", "rc", "=", "0", ";", "}", "}", "return", "getVersionString", "(", "version", ")", ";", "function", "parseVersion", "(", "version", ")", "{", "const", "parts", "=", "version", ".", "split", "(", "/", "-rc\\.|\\.", "/", "g", ")", ";", "return", "{", "string", ":", "version", ",", "major", ":", "parts", "[", "0", "]", ",", "minor", ":", "parts", "[", "1", "]", ",", "patch", ":", "parts", "[", "2", "]", ",", "rc", ":", "parts", "[", "3", "]", "||", "0", "}", ";", "}", "function", "getVersionString", "(", "version", ")", "{", "let", "str", "=", "version", ".", "major", "+", "'.'", "+", "version", ".", "minor", "+", "'.'", "+", "version", ".", "patch", ";", "if", "(", "version", ".", "rc", ")", "str", "+=", "'-rc.'", "+", "version", ".", "rc", ";", "return", "str", ";", "}", "}", "function", "addRC", "(", "str", ")", "{", "return", "str", "+", "'-rc.1'", ";", "}", "}", "}" ]
prompts the user for the new version
[ "prompts", "the", "user", "for", "the", "new", "version" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L114-L179
5,075
angular/material
release.js
cloneRepo
function cloneRepo (repo) { start(`Cloning ${repo.cyan} from Github...`); exec(`rm -rf ${repo}`); exec(`git clone [email protected]:angular/${repo}.git --depth=1`); done(); cleanupCmds.push(`rm -rf ${repo}`); }
javascript
function cloneRepo (repo) { start(`Cloning ${repo.cyan} from Github...`); exec(`rm -rf ${repo}`); exec(`git clone [email protected]:angular/${repo}.git --depth=1`); done(); cleanupCmds.push(`rm -rf ${repo}`); }
[ "function", "cloneRepo", "(", "repo", ")", "{", "start", "(", "`", "${", "repo", ".", "cyan", "}", "`", ")", ";", "exec", "(", "`", "${", "repo", "}", "`", ")", ";", "exec", "(", "`", "${", "repo", "}", "`", ")", ";", "done", "(", ")", ";", "cleanupCmds", ".", "push", "(", "`", "${", "repo", "}", "`", ")", ";", "}" ]
utility method for cloning github repos
[ "utility", "method", "for", "cloning", "github", "repos" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L199-L205
5,076
angular/material
release.js
writeScript
function writeScript (name, cmds) { fs.writeFileSync(name, '#!/usr/bin/env bash\n\n' + cmds.join('\n')); exec('chmod +x ' + name); }
javascript
function writeScript (name, cmds) { fs.writeFileSync(name, '#!/usr/bin/env bash\n\n' + cmds.join('\n')); exec('chmod +x ' + name); }
[ "function", "writeScript", "(", "name", ",", "cmds", ")", "{", "fs", ".", "writeFileSync", "(", "name", ",", "'#!/usr/bin/env bash\\n\\n'", "+", "cmds", ".", "join", "(", "'\\n'", ")", ")", ";", "exec", "(", "'chmod +x '", "+", "name", ")", ";", "}" ]
writes an array of commands to a bash script
[ "writes", "an", "array", "of", "commands", "to", "a", "bash", "script" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L208-L211
5,077
angular/material
release.js
updateBowerVersion
function updateBowerVersion () { start('Updating bower version...'); const options = { cwd: './bower-material' }; const bower = require(options.cwd + '/bower.json'), pkg = require(options.cwd + '/package.json'); // update versions in config files bower.version = pkg.version = newVersion; fs.writeFileSync(options.cwd + '/package.json', JSON.stringify(pkg, null, 2)); fs.writeFileSync(options.cwd + '/bower.json', JSON.stringify(bower, null, 2)); done(); start('Building bower files...'); // build files for bower exec([ 'rm -rf dist', 'gulp build', 'gulp build-all-modules --mode=default', 'gulp build-all-modules --mode=closure', 'rm -rf dist/demos' ]); done(); start('Copy files into bower repo...'); // copy files over to bower repo exec([ 'cp -Rf ../dist/* ./', 'git add -A', `git commit -m "release: version ${newVersion}"`, 'rm -rf ../dist' ], options); done(); // add steps to push script pushCmds.push( comment('push to bower (master and tag) and publish to npm'), 'cd ' + options.cwd, 'cp ../CHANGELOG.md .', 'git add CHANGELOG.md', 'git commit --amend --no-edit', `git tag -f v${newVersion}`, 'git pull --rebase --strategy=ours', 'git push', 'git push --tags', 'rm -rf .git/', 'npm publish', 'cd ..' ); }
javascript
function updateBowerVersion () { start('Updating bower version...'); const options = { cwd: './bower-material' }; const bower = require(options.cwd + '/bower.json'), pkg = require(options.cwd + '/package.json'); // update versions in config files bower.version = pkg.version = newVersion; fs.writeFileSync(options.cwd + '/package.json', JSON.stringify(pkg, null, 2)); fs.writeFileSync(options.cwd + '/bower.json', JSON.stringify(bower, null, 2)); done(); start('Building bower files...'); // build files for bower exec([ 'rm -rf dist', 'gulp build', 'gulp build-all-modules --mode=default', 'gulp build-all-modules --mode=closure', 'rm -rf dist/demos' ]); done(); start('Copy files into bower repo...'); // copy files over to bower repo exec([ 'cp -Rf ../dist/* ./', 'git add -A', `git commit -m "release: version ${newVersion}"`, 'rm -rf ../dist' ], options); done(); // add steps to push script pushCmds.push( comment('push to bower (master and tag) and publish to npm'), 'cd ' + options.cwd, 'cp ../CHANGELOG.md .', 'git add CHANGELOG.md', 'git commit --amend --no-edit', `git tag -f v${newVersion}`, 'git pull --rebase --strategy=ours', 'git push', 'git push --tags', 'rm -rf .git/', 'npm publish', 'cd ..' ); }
[ "function", "updateBowerVersion", "(", ")", "{", "start", "(", "'Updating bower version...'", ")", ";", "const", "options", "=", "{", "cwd", ":", "'./bower-material'", "}", ";", "const", "bower", "=", "require", "(", "options", ".", "cwd", "+", "'/bower.json'", ")", ",", "pkg", "=", "require", "(", "options", ".", "cwd", "+", "'/package.json'", ")", ";", "// update versions in config files", "bower", ".", "version", "=", "pkg", ".", "version", "=", "newVersion", ";", "fs", ".", "writeFileSync", "(", "options", ".", "cwd", "+", "'/package.json'", ",", "JSON", ".", "stringify", "(", "pkg", ",", "null", ",", "2", ")", ")", ";", "fs", ".", "writeFileSync", "(", "options", ".", "cwd", "+", "'/bower.json'", ",", "JSON", ".", "stringify", "(", "bower", ",", "null", ",", "2", ")", ")", ";", "done", "(", ")", ";", "start", "(", "'Building bower files...'", ")", ";", "// build files for bower", "exec", "(", "[", "'rm -rf dist'", ",", "'gulp build'", ",", "'gulp build-all-modules --mode=default'", ",", "'gulp build-all-modules --mode=closure'", ",", "'rm -rf dist/demos'", "]", ")", ";", "done", "(", ")", ";", "start", "(", "'Copy files into bower repo...'", ")", ";", "// copy files over to bower repo", "exec", "(", "[", "'cp -Rf ../dist/* ./'", ",", "'git add -A'", ",", "`", "${", "newVersion", "}", "`", ",", "'rm -rf ../dist'", "]", ",", "options", ")", ";", "done", "(", ")", ";", "// add steps to push script", "pushCmds", ".", "push", "(", "comment", "(", "'push to bower (master and tag) and publish to npm'", ")", ",", "'cd '", "+", "options", ".", "cwd", ",", "'cp ../CHANGELOG.md .'", ",", "'git add CHANGELOG.md'", ",", "'git commit --amend --no-edit'", ",", "`", "${", "newVersion", "}", "`", ",", "'git pull --rebase --strategy=ours'", ",", "'git push'", ",", "'git push --tags'", ",", "'rm -rf .git/'", ",", "'npm publish'", ",", "'cd ..'", ")", ";", "}" ]
updates the version for bower-material in package.json and bower.json
[ "updates", "the", "version", "for", "bower", "-", "material", "in", "package", ".", "json", "and", "bower", ".", "json" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L214-L258
5,078
angular/material
release.js
updateSite
function updateSite () { start('Adding new version of the docs site...'); const options = { cwd: './code.material.angularjs.org' }; writeDocsJson(); // build files for bower exec([ 'rm -rf dist', 'gulp docs' ]); replaceFilePaths(); // copy files over to site repo exec([ `cp -Rf ../dist/docs ${newVersion}`, 'rm -rf latest && cp -Rf ../dist/docs latest', 'git add -A', `git commit -m "release: version ${newVersion}"`, 'rm -rf ../dist' ], options); replaceBaseHref(newVersion); replaceBaseHref('latest'); // update firebase.json file updateFirebaseJson(); exec(['git commit --amend --no-edit -a'], options); done(); // add steps to push script pushCmds.push( comment('push the site'), 'cd ' + options.cwd, 'git pull --rebase --strategy=ours', 'git push', 'cd ..' ); function updateFirebaseJson () { fs.writeFileSync(options.cwd + '/firebase.json', getFirebaseJson()); function getFirebaseJson () { const json = require(options.cwd + '/firebase.json'); json.hosting.rewrites = json.hosting.rewrites || []; const rewrites = json.hosting.rewrites; switch (rewrites.length) { case 0: rewrites.push(getRewrite('HEAD')); case 1: rewrites.push(getRewrite('latest')); default: rewrites.push(getRewrite(newVersion)); } return JSON.stringify(json, null, 2); function getRewrite (str) { return { source: '/' + str + '/**/!(*.@(js|html|css|json|svg|png|jpg|jpeg))', destination: '/' + str + '/index.html' }; } } } function writeDocsJson () { const config = require(options.cwd + '/docs.json'); config.versions.unshift(newVersion); // only set to default if not a release candidate config.latest = newVersion; fs.writeFileSync(options.cwd + '/docs.json', JSON.stringify(config, null, 2)); } }
javascript
function updateSite () { start('Adding new version of the docs site...'); const options = { cwd: './code.material.angularjs.org' }; writeDocsJson(); // build files for bower exec([ 'rm -rf dist', 'gulp docs' ]); replaceFilePaths(); // copy files over to site repo exec([ `cp -Rf ../dist/docs ${newVersion}`, 'rm -rf latest && cp -Rf ../dist/docs latest', 'git add -A', `git commit -m "release: version ${newVersion}"`, 'rm -rf ../dist' ], options); replaceBaseHref(newVersion); replaceBaseHref('latest'); // update firebase.json file updateFirebaseJson(); exec(['git commit --amend --no-edit -a'], options); done(); // add steps to push script pushCmds.push( comment('push the site'), 'cd ' + options.cwd, 'git pull --rebase --strategy=ours', 'git push', 'cd ..' ); function updateFirebaseJson () { fs.writeFileSync(options.cwd + '/firebase.json', getFirebaseJson()); function getFirebaseJson () { const json = require(options.cwd + '/firebase.json'); json.hosting.rewrites = json.hosting.rewrites || []; const rewrites = json.hosting.rewrites; switch (rewrites.length) { case 0: rewrites.push(getRewrite('HEAD')); case 1: rewrites.push(getRewrite('latest')); default: rewrites.push(getRewrite(newVersion)); } return JSON.stringify(json, null, 2); function getRewrite (str) { return { source: '/' + str + '/**/!(*.@(js|html|css|json|svg|png|jpg|jpeg))', destination: '/' + str + '/index.html' }; } } } function writeDocsJson () { const config = require(options.cwd + '/docs.json'); config.versions.unshift(newVersion); // only set to default if not a release candidate config.latest = newVersion; fs.writeFileSync(options.cwd + '/docs.json', JSON.stringify(config, null, 2)); } }
[ "function", "updateSite", "(", ")", "{", "start", "(", "'Adding new version of the docs site...'", ")", ";", "const", "options", "=", "{", "cwd", ":", "'./code.material.angularjs.org'", "}", ";", "writeDocsJson", "(", ")", ";", "// build files for bower", "exec", "(", "[", "'rm -rf dist'", ",", "'gulp docs'", "]", ")", ";", "replaceFilePaths", "(", ")", ";", "// copy files over to site repo", "exec", "(", "[", "`", "${", "newVersion", "}", "`", ",", "'rm -rf latest && cp -Rf ../dist/docs latest'", ",", "'git add -A'", ",", "`", "${", "newVersion", "}", "`", ",", "'rm -rf ../dist'", "]", ",", "options", ")", ";", "replaceBaseHref", "(", "newVersion", ")", ";", "replaceBaseHref", "(", "'latest'", ")", ";", "// update firebase.json file", "updateFirebaseJson", "(", ")", ";", "exec", "(", "[", "'git commit --amend --no-edit -a'", "]", ",", "options", ")", ";", "done", "(", ")", ";", "// add steps to push script", "pushCmds", ".", "push", "(", "comment", "(", "'push the site'", ")", ",", "'cd '", "+", "options", ".", "cwd", ",", "'git pull --rebase --strategy=ours'", ",", "'git push'", ",", "'cd ..'", ")", ";", "function", "updateFirebaseJson", "(", ")", "{", "fs", ".", "writeFileSync", "(", "options", ".", "cwd", "+", "'/firebase.json'", ",", "getFirebaseJson", "(", ")", ")", ";", "function", "getFirebaseJson", "(", ")", "{", "const", "json", "=", "require", "(", "options", ".", "cwd", "+", "'/firebase.json'", ")", ";", "json", ".", "hosting", ".", "rewrites", "=", "json", ".", "hosting", ".", "rewrites", "||", "[", "]", ";", "const", "rewrites", "=", "json", ".", "hosting", ".", "rewrites", ";", "switch", "(", "rewrites", ".", "length", ")", "{", "case", "0", ":", "rewrites", ".", "push", "(", "getRewrite", "(", "'HEAD'", ")", ")", ";", "case", "1", ":", "rewrites", ".", "push", "(", "getRewrite", "(", "'latest'", ")", ")", ";", "default", ":", "rewrites", ".", "push", "(", "getRewrite", "(", "newVersion", ")", ")", ";", "}", "return", "JSON", ".", "stringify", "(", "json", ",", "null", ",", "2", ")", ";", "function", "getRewrite", "(", "str", ")", "{", "return", "{", "source", ":", "'/'", "+", "str", "+", "'/**/!(*.@(js|html|css|json|svg|png|jpg|jpeg))'", ",", "destination", ":", "'/'", "+", "str", "+", "'/index.html'", "}", ";", "}", "}", "}", "function", "writeDocsJson", "(", ")", "{", "const", "config", "=", "require", "(", "options", ".", "cwd", "+", "'/docs.json'", ")", ";", "config", ".", "versions", ".", "unshift", "(", "newVersion", ")", ";", "// only set to default if not a release candidate", "config", ".", "latest", "=", "newVersion", ";", "fs", ".", "writeFileSync", "(", "options", ".", "cwd", "+", "'/docs.json'", ",", "JSON", ".", "stringify", "(", "config", ",", "null", ",", "2", ")", ")", ";", "}", "}" ]
builds the website for the new version
[ "builds", "the", "website", "for", "the", "new", "version" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L261-L331
5,079
angular/material
release.js
replaceFilePaths
function replaceFilePaths () { // handle docs.js const filePath = path.join(__dirname, '/dist/docs/docs.js'); const file = fs.readFileSync(filePath); const contents = file.toString() .replace(/http:\/\/localhost:8080\/angular-material/g, 'https://gitcdn.xyz/cdn/angular/bower-material/v' + newVersion + '/angular-material') .replace(/http:\/\/localhost:8080\/docs.css/g, 'https://material.angularjs.org/' + newVersion + '/docs.css'); fs.writeFileSync(filePath, contents); }
javascript
function replaceFilePaths () { // handle docs.js const filePath = path.join(__dirname, '/dist/docs/docs.js'); const file = fs.readFileSync(filePath); const contents = file.toString() .replace(/http:\/\/localhost:8080\/angular-material/g, 'https://gitcdn.xyz/cdn/angular/bower-material/v' + newVersion + '/angular-material') .replace(/http:\/\/localhost:8080\/docs.css/g, 'https://material.angularjs.org/' + newVersion + '/docs.css'); fs.writeFileSync(filePath, contents); }
[ "function", "replaceFilePaths", "(", ")", "{", "// handle docs.js", "const", "filePath", "=", "path", ".", "join", "(", "__dirname", ",", "'/dist/docs/docs.js'", ")", ";", "const", "file", "=", "fs", ".", "readFileSync", "(", "filePath", ")", ";", "const", "contents", "=", "file", ".", "toString", "(", ")", ".", "replace", "(", "/", "http:\\/\\/localhost:8080\\/angular-material", "/", "g", ",", "'https://gitcdn.xyz/cdn/angular/bower-material/v'", "+", "newVersion", "+", "'/angular-material'", ")", ".", "replace", "(", "/", "http:\\/\\/localhost:8080\\/docs.css", "/", "g", ",", "'https://material.angularjs.org/'", "+", "newVersion", "+", "'/docs.css'", ")", ";", "fs", ".", "writeFileSync", "(", "filePath", ",", "contents", ")", ";", "}" ]
replaces localhost file paths with public URLs
[ "replaces", "localhost", "file", "paths", "with", "public", "URLs" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L334-L342
5,080
angular/material
release.js
replaceBaseHref
function replaceBaseHref (folder) { // handle index.html const filePath = path.join(__dirname, '/code.material.angularjs.org/', folder, '/index.html'); const file = fs.readFileSync(filePath); const contents = file.toString().replace(/base href="\//g, 'base href="/' + folder + '/'); fs.writeFileSync(filePath, contents); }
javascript
function replaceBaseHref (folder) { // handle index.html const filePath = path.join(__dirname, '/code.material.angularjs.org/', folder, '/index.html'); const file = fs.readFileSync(filePath); const contents = file.toString().replace(/base href="\//g, 'base href="/' + folder + '/'); fs.writeFileSync(filePath, contents); }
[ "function", "replaceBaseHref", "(", "folder", ")", "{", "// handle index.html", "const", "filePath", "=", "path", ".", "join", "(", "__dirname", ",", "'/code.material.angularjs.org/'", ",", "folder", ",", "'/index.html'", ")", ";", "const", "file", "=", "fs", ".", "readFileSync", "(", "filePath", ")", ";", "const", "contents", "=", "file", ".", "toString", "(", ")", ".", "replace", "(", "/", "base href=\"\\/", "/", "g", ",", "'base href=\"/'", "+", "folder", "+", "'/'", ")", ";", "fs", ".", "writeFileSync", "(", "filePath", ",", "contents", ")", ";", "}" ]
replaces base href in index.html for new version as well as latest
[ "replaces", "base", "href", "in", "index", ".", "html", "for", "new", "version", "as", "well", "as", "latest" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L345-L351
5,081
angular/material
release.js
updateMaster
function updateMaster () { pushCmds.push( comment('update package.json in master'), 'git checkout master', `git pull --rebase ${origin} master --strategy=theirs`, `git checkout release/${newVersion} -- CHANGELOG.md`, `node -e "const newVersion = '${newVersion}'; ${stringifyFunction(buildCommand)}"`, 'git add CHANGELOG.md', 'git add package.json', `git commit -m "update version number in package.json to ${newVersion}"`, `git push ${origin} master` ); function buildCommand () { require('fs').writeFileSync('package.json', JSON.stringify(getUpdatedJson(), null, 2)); function getUpdatedJson () { const json = require('./package.json'); json.version = newVersion; return json; } } function stringifyFunction (method) { return method .toString() .split('\n') .slice(1, -1) .map(function (line) { return line.trim(); }) .join(' ') .replace(/"/g, '\\"'); } }
javascript
function updateMaster () { pushCmds.push( comment('update package.json in master'), 'git checkout master', `git pull --rebase ${origin} master --strategy=theirs`, `git checkout release/${newVersion} -- CHANGELOG.md`, `node -e "const newVersion = '${newVersion}'; ${stringifyFunction(buildCommand)}"`, 'git add CHANGELOG.md', 'git add package.json', `git commit -m "update version number in package.json to ${newVersion}"`, `git push ${origin} master` ); function buildCommand () { require('fs').writeFileSync('package.json', JSON.stringify(getUpdatedJson(), null, 2)); function getUpdatedJson () { const json = require('./package.json'); json.version = newVersion; return json; } } function stringifyFunction (method) { return method .toString() .split('\n') .slice(1, -1) .map(function (line) { return line.trim(); }) .join(' ') .replace(/"/g, '\\"'); } }
[ "function", "updateMaster", "(", ")", "{", "pushCmds", ".", "push", "(", "comment", "(", "'update package.json in master'", ")", ",", "'git checkout master'", ",", "`", "${", "origin", "}", "`", ",", "`", "${", "newVersion", "}", "`", ",", "`", "${", "newVersion", "}", "${", "stringifyFunction", "(", "buildCommand", ")", "}", "`", ",", "'git add CHANGELOG.md'", ",", "'git add package.json'", ",", "`", "${", "newVersion", "}", "`", ",", "`", "${", "origin", "}", "`", ")", ";", "function", "buildCommand", "(", ")", "{", "require", "(", "'fs'", ")", ".", "writeFileSync", "(", "'package.json'", ",", "JSON", ".", "stringify", "(", "getUpdatedJson", "(", ")", ",", "null", ",", "2", ")", ")", ";", "function", "getUpdatedJson", "(", ")", "{", "const", "json", "=", "require", "(", "'./package.json'", ")", ";", "json", ".", "version", "=", "newVersion", ";", "return", "json", ";", "}", "}", "function", "stringifyFunction", "(", "method", ")", "{", "return", "method", ".", "toString", "(", ")", ".", "split", "(", "'\\n'", ")", ".", "slice", "(", "1", ",", "-", "1", ")", ".", "map", "(", "function", "(", "line", ")", "{", "return", "line", ".", "trim", "(", ")", ";", "}", ")", ".", "join", "(", "' '", ")", ".", "replace", "(", "/", "\"", "/", "g", ",", "'\\\\\"'", ")", ";", "}", "}" ]
copies the changelog back over to master branch
[ "copies", "the", "changelog", "back", "over", "to", "master", "branch" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L354-L385
5,082
angular/material
release.js
center
function center (msg) { msg = ' ' + msg.trim() + ' '; const length = msg.length; const spaces = Math.floor((lineWidth - length) / 2); return Array(spaces + 1).join('-') + msg.green + Array(lineWidth - msg.length - spaces + 1).join('-'); }
javascript
function center (msg) { msg = ' ' + msg.trim() + ' '; const length = msg.length; const spaces = Math.floor((lineWidth - length) / 2); return Array(spaces + 1).join('-') + msg.green + Array(lineWidth - msg.length - spaces + 1).join('-'); }
[ "function", "center", "(", "msg", ")", "{", "msg", "=", "' '", "+", "msg", ".", "trim", "(", ")", "+", "' '", ";", "const", "length", "=", "msg", ".", "length", ";", "const", "spaces", "=", "Math", ".", "floor", "(", "(", "lineWidth", "-", "length", ")", "/", "2", ")", ";", "return", "Array", "(", "spaces", "+", "1", ")", ".", "join", "(", "'-'", ")", "+", "msg", ".", "green", "+", "Array", "(", "lineWidth", "-", "msg", ".", "length", "-", "spaces", "+", "1", ")", ".", "join", "(", "'-'", ")", ";", "}" ]
outputs a centered message in the terminal
[ "outputs", "a", "centered", "message", "in", "the", "terminal" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L396-L401
5,083
angular/material
release.js
start
function start (msg) { const msgLength = strip(msg).length, diff = lineWidth - 4 - msgLength; write(msg + Array(diff + 1).join(' ')); }
javascript
function start (msg) { const msgLength = strip(msg).length, diff = lineWidth - 4 - msgLength; write(msg + Array(diff + 1).join(' ')); }
[ "function", "start", "(", "msg", ")", "{", "const", "msgLength", "=", "strip", "(", "msg", ")", ".", "length", ",", "diff", "=", "lineWidth", "-", "4", "-", "msgLength", ";", "write", "(", "msg", "+", "Array", "(", "diff", "+", "1", ")", ".", "join", "(", "' '", ")", ")", ";", "}" ]
prints the left side of a task while it is being performed
[ "prints", "the", "left", "side", "of", "a", "task", "while", "it", "is", "being", "performed" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L430-L434
5,084
angular/material
src/core/util/animation/animate.js
reverseTranslate
function reverseTranslate (newFrom) { return $animateCss(target, { to: newFrom || from, addClass: options.transitionOutClass, removeClass: options.transitionInClass, duration: options.duration }).start(); }
javascript
function reverseTranslate (newFrom) { return $animateCss(target, { to: newFrom || from, addClass: options.transitionOutClass, removeClass: options.transitionInClass, duration: options.duration }).start(); }
[ "function", "reverseTranslate", "(", "newFrom", ")", "{", "return", "$animateCss", "(", "target", ",", "{", "to", ":", "newFrom", "||", "from", ",", "addClass", ":", "options", ".", "transitionOutClass", ",", "removeClass", ":", "options", ".", "transitionInClass", ",", "duration", ":", "options", ".", "duration", "}", ")", ".", "start", "(", ")", ";", "}" ]
Specific reversal of the request translate animation above...
[ "Specific", "reversal", "of", "the", "request", "translate", "animation", "above", "..." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/animation/animate.js#L40-L48
5,085
angular/material
src/core/util/animation/animate.js
noTransitionFound
function noTransitionFound(styles) { styles = styles || window.getComputedStyle(element[0]); return styles.transitionDuration == '0s' || (!styles.transition && !styles.transitionProperty); }
javascript
function noTransitionFound(styles) { styles = styles || window.getComputedStyle(element[0]); return styles.transitionDuration == '0s' || (!styles.transition && !styles.transitionProperty); }
[ "function", "noTransitionFound", "(", "styles", ")", "{", "styles", "=", "styles", "||", "window", ".", "getComputedStyle", "(", "element", "[", "0", "]", ")", ";", "return", "styles", ".", "transitionDuration", "==", "'0s'", "||", "(", "!", "styles", ".", "transition", "&&", "!", "styles", ".", "transitionProperty", ")", ";", "}" ]
Checks whether or not there is a transition. @param styles The cached styles to use for the calculation. If null, getComputedStyle() will be used. @returns {boolean} True if there is no transition/duration; false otherwise.
[ "Checks", "whether", "or", "not", "there", "is", "a", "transition", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/animation/animate.js#L94-L98
5,086
angular/material
src/core/util/animation/animate.js
currentBounds
function currentBounds() { var cntr = element ? element.parent() : null; var parent = cntr ? cntr.parent() : null; return parent ? self.clientRect(parent) : null; }
javascript
function currentBounds() { var cntr = element ? element.parent() : null; var parent = cntr ? cntr.parent() : null; return parent ? self.clientRect(parent) : null; }
[ "function", "currentBounds", "(", ")", "{", "var", "cntr", "=", "element", "?", "element", ".", "parent", "(", ")", ":", "null", ";", "var", "parent", "=", "cntr", "?", "cntr", ".", "parent", "(", ")", ":", "null", ";", "return", "parent", "?", "self", ".", "clientRect", "(", "parent", ")", ":", "null", ";", "}" ]
This is a fallback if the origin information is no longer valid, then the origin bounds simply becomes the current bounds for the dialogContainer's parent
[ "This", "is", "a", "fallback", "if", "the", "origin", "information", "is", "no", "longer", "valid", "then", "the", "origin", "bounds", "simply", "becomes", "the", "current", "bounds", "for", "the", "dialogContainer", "s", "parent" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/animation/animate.js#L126-L131
5,087
angular/material
src/core/util/animation/animate.js
function (element, originator) { var zoomTemplate = "translate3d( {centerX}px, {centerY}px, 0 ) scale( {scaleX}, {scaleY} )"; var buildZoom = angular.bind(null, $mdUtil.supplant, zoomTemplate); return buildZoom(self.calculateTransformValues(element, originator)); }
javascript
function (element, originator) { var zoomTemplate = "translate3d( {centerX}px, {centerY}px, 0 ) scale( {scaleX}, {scaleY} )"; var buildZoom = angular.bind(null, $mdUtil.supplant, zoomTemplate); return buildZoom(self.calculateTransformValues(element, originator)); }
[ "function", "(", "element", ",", "originator", ")", "{", "var", "zoomTemplate", "=", "\"translate3d( {centerX}px, {centerY}px, 0 ) scale( {scaleX}, {scaleY} )\"", ";", "var", "buildZoom", "=", "angular", ".", "bind", "(", "null", ",", "$mdUtil", ".", "supplant", ",", "zoomTemplate", ")", ";", "return", "buildZoom", "(", "self", ".", "calculateTransformValues", "(", "element", ",", "originator", ")", ")", ";", "}" ]
Calculate the zoom transform from dialog to origin. We use this to set the dialog position immediately; then the md-transition-in actually translates back to `translate3d(0,0,0) scale(1.0)`... NOTE: all values are rounded to the nearest integer
[ "Calculate", "the", "zoom", "transform", "from", "dialog", "to", "origin", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/animation/animate.js#L143-L148
5,088
angular/material
src/core/util/animation/animate.js
function(raw) { var css = { }; var lookups = 'left top right bottom width height x y min-width min-height max-width max-height'; angular.forEach(raw, function(value,key) { if (angular.isUndefined(value)) return; if (lookups.indexOf(key) >= 0) { css[key] = value + 'px'; } else { switch (key) { case 'transition': convertToVendor(key, $mdConstant.CSS.TRANSITION, value); break; case 'transform': convertToVendor(key, $mdConstant.CSS.TRANSFORM, value); break; case 'transformOrigin': convertToVendor(key, $mdConstant.CSS.TRANSFORM_ORIGIN, value); break; case 'font-size': css['font-size'] = value; // font sizes aren't always in px break; } } }); return css; function convertToVendor(key, vendor, value) { angular.forEach(vendor.split(' '), function (key) { css[key] = value; }); } }
javascript
function(raw) { var css = { }; var lookups = 'left top right bottom width height x y min-width min-height max-width max-height'; angular.forEach(raw, function(value,key) { if (angular.isUndefined(value)) return; if (lookups.indexOf(key) >= 0) { css[key] = value + 'px'; } else { switch (key) { case 'transition': convertToVendor(key, $mdConstant.CSS.TRANSITION, value); break; case 'transform': convertToVendor(key, $mdConstant.CSS.TRANSFORM, value); break; case 'transformOrigin': convertToVendor(key, $mdConstant.CSS.TRANSFORM_ORIGIN, value); break; case 'font-size': css['font-size'] = value; // font sizes aren't always in px break; } } }); return css; function convertToVendor(key, vendor, value) { angular.forEach(vendor.split(' '), function (key) { css[key] = value; }); } }
[ "function", "(", "raw", ")", "{", "var", "css", "=", "{", "}", ";", "var", "lookups", "=", "'left top right bottom width height x y min-width min-height max-width max-height'", ";", "angular", ".", "forEach", "(", "raw", ",", "function", "(", "value", ",", "key", ")", "{", "if", "(", "angular", ".", "isUndefined", "(", "value", ")", ")", "return", ";", "if", "(", "lookups", ".", "indexOf", "(", "key", ")", ">=", "0", ")", "{", "css", "[", "key", "]", "=", "value", "+", "'px'", ";", "}", "else", "{", "switch", "(", "key", ")", "{", "case", "'transition'", ":", "convertToVendor", "(", "key", ",", "$mdConstant", ".", "CSS", ".", "TRANSITION", ",", "value", ")", ";", "break", ";", "case", "'transform'", ":", "convertToVendor", "(", "key", ",", "$mdConstant", ".", "CSS", ".", "TRANSFORM", ",", "value", ")", ";", "break", ";", "case", "'transformOrigin'", ":", "convertToVendor", "(", "key", ",", "$mdConstant", ".", "CSS", ".", "TRANSFORM_ORIGIN", ",", "value", ")", ";", "break", ";", "case", "'font-size'", ":", "css", "[", "'font-size'", "]", "=", "value", ";", "// font sizes aren't always in px", "break", ";", "}", "}", "}", ")", ";", "return", "css", ";", "function", "convertToVendor", "(", "key", ",", "vendor", ",", "value", ")", "{", "angular", ".", "forEach", "(", "vendor", ".", "split", "(", "' '", ")", ",", "function", "(", "key", ")", "{", "css", "[", "key", "]", "=", "value", ";", "}", ")", ";", "}", "}" ]
Enhance raw values to represent valid css stylings...
[ "Enhance", "raw", "values", "to", "represent", "valid", "css", "stylings", "..." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/animation/animate.js#L164-L198
5,089
angular/material
src/core/util/animation/animate.js
function (element) { var bounds = angular.element(element)[0].getBoundingClientRect(); var isPositiveSizeClientRect = function (rect) { return rect && (rect.width > 0) && (rect.height > 0); }; // If the event origin element has zero size, it has probably been hidden. return isPositiveSizeClientRect(bounds) ? self.copyRect(bounds) : null; }
javascript
function (element) { var bounds = angular.element(element)[0].getBoundingClientRect(); var isPositiveSizeClientRect = function (rect) { return rect && (rect.width > 0) && (rect.height > 0); }; // If the event origin element has zero size, it has probably been hidden. return isPositiveSizeClientRect(bounds) ? self.copyRect(bounds) : null; }
[ "function", "(", "element", ")", "{", "var", "bounds", "=", "angular", ".", "element", "(", "element", ")", "[", "0", "]", ".", "getBoundingClientRect", "(", ")", ";", "var", "isPositiveSizeClientRect", "=", "function", "(", "rect", ")", "{", "return", "rect", "&&", "(", "rect", ".", "width", ">", "0", ")", "&&", "(", "rect", ".", "height", ">", "0", ")", ";", "}", ";", "// If the event origin element has zero size, it has probably been hidden.", "return", "isPositiveSizeClientRect", "(", "bounds", ")", "?", "self", ".", "copyRect", "(", "bounds", ")", ":", "null", ";", "}" ]
Calculate ClientRect of element; return null if hidden or zero size
[ "Calculate", "ClientRect", "of", "element", ";", "return", "null", "if", "hidden", "or", "zero", "size" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/animation/animate.js#L238-L246
5,090
angular/material
src/core/util/animation/animate.js
function (targetRect) { return targetRect ? { x: Math.round(targetRect.left + (targetRect.width / 2)), y: Math.round(targetRect.top + (targetRect.height / 2)) } : { x : 0, y : 0 }; }
javascript
function (targetRect) { return targetRect ? { x: Math.round(targetRect.left + (targetRect.width / 2)), y: Math.round(targetRect.top + (targetRect.height / 2)) } : { x : 0, y : 0 }; }
[ "function", "(", "targetRect", ")", "{", "return", "targetRect", "?", "{", "x", ":", "Math", ".", "round", "(", "targetRect", ".", "left", "+", "(", "targetRect", ".", "width", "/", "2", ")", ")", ",", "y", ":", "Math", ".", "round", "(", "targetRect", ".", "top", "+", "(", "targetRect", ".", "height", "/", "2", ")", ")", "}", ":", "{", "x", ":", "0", ",", "y", ":", "0", "}", ";", "}" ]
Calculate 'rounded' center point of Rect
[ "Calculate", "rounded", "center", "point", "of", "Rect" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/animation/animate.js#L251-L256
5,091
angular/material
src/components/toast/toast.js
MdToastController
function MdToastController($mdToast, $scope, $log) { // For compatibility with AngularJS 1.6+, we should always use the $onInit hook in // interimElements. The $mdCompiler simulates the $onInit hook for all versions. this.$onInit = function() { var self = this; if (self.highlightAction) { $scope.highlightClasses = [ 'md-highlight', self.highlightClass ]; } // If an action is defined and no actionKey is specified, then log a warning. if (self.action && !self.actionKey) { $log.warn('Toasts with actions should define an actionKey for accessibility.', 'Details: https://material.angularjs.org/latest/api/service/$mdToast#mdtoast-simple'); } if (self.actionKey && !self.actionHint) { self.actionHint = 'Press Control-"' + self.actionKey + '" to '; } if (!self.dismissHint) { self.dismissHint = 'Press Escape to dismiss.'; } $scope.$watch(function() { return activeToastContent; }, function() { self.content = activeToastContent; }); this.resolve = function() { $mdToast.hide(ACTION_RESOLVE); }; }; }
javascript
function MdToastController($mdToast, $scope, $log) { // For compatibility with AngularJS 1.6+, we should always use the $onInit hook in // interimElements. The $mdCompiler simulates the $onInit hook for all versions. this.$onInit = function() { var self = this; if (self.highlightAction) { $scope.highlightClasses = [ 'md-highlight', self.highlightClass ]; } // If an action is defined and no actionKey is specified, then log a warning. if (self.action && !self.actionKey) { $log.warn('Toasts with actions should define an actionKey for accessibility.', 'Details: https://material.angularjs.org/latest/api/service/$mdToast#mdtoast-simple'); } if (self.actionKey && !self.actionHint) { self.actionHint = 'Press Control-"' + self.actionKey + '" to '; } if (!self.dismissHint) { self.dismissHint = 'Press Escape to dismiss.'; } $scope.$watch(function() { return activeToastContent; }, function() { self.content = activeToastContent; }); this.resolve = function() { $mdToast.hide(ACTION_RESOLVE); }; }; }
[ "function", "MdToastController", "(", "$mdToast", ",", "$scope", ",", "$log", ")", "{", "// For compatibility with AngularJS 1.6+, we should always use the $onInit hook in", "// interimElements. The $mdCompiler simulates the $onInit hook for all versions.", "this", ".", "$onInit", "=", "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "self", ".", "highlightAction", ")", "{", "$scope", ".", "highlightClasses", "=", "[", "'md-highlight'", ",", "self", ".", "highlightClass", "]", ";", "}", "// If an action is defined and no actionKey is specified, then log a warning.", "if", "(", "self", ".", "action", "&&", "!", "self", ".", "actionKey", ")", "{", "$log", ".", "warn", "(", "'Toasts with actions should define an actionKey for accessibility.'", ",", "'Details: https://material.angularjs.org/latest/api/service/$mdToast#mdtoast-simple'", ")", ";", "}", "if", "(", "self", ".", "actionKey", "&&", "!", "self", ".", "actionHint", ")", "{", "self", ".", "actionHint", "=", "'Press Control-\"'", "+", "self", ".", "actionKey", "+", "'\" to '", ";", "}", "if", "(", "!", "self", ".", "dismissHint", ")", "{", "self", ".", "dismissHint", "=", "'Press Escape to dismiss.'", ";", "}", "$scope", ".", "$watch", "(", "function", "(", ")", "{", "return", "activeToastContent", ";", "}", ",", "function", "(", ")", "{", "self", ".", "content", "=", "activeToastContent", ";", "}", ")", ";", "this", ".", "resolve", "=", "function", "(", ")", "{", "$mdToast", ".", "hide", "(", "ACTION_RESOLVE", ")", ";", "}", ";", "}", ";", "}" ]
Controller for the Toast interim elements. @ngInject
[ "Controller", "for", "the", "Toast", "interim", "elements", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/toast/toast.js#L381-L416
5,092
angular/material
src/components/panel/panel.spec.js
attachToBody
function attachToBody(el) { var element = angular.element(el); angular.element(document.body).append(element); attachedElements.push(element); }
javascript
function attachToBody(el) { var element = angular.element(el); angular.element(document.body).append(element); attachedElements.push(element); }
[ "function", "attachToBody", "(", "el", ")", "{", "var", "element", "=", "angular", ".", "element", "(", "el", ")", ";", "angular", ".", "element", "(", "document", ".", "body", ")", ".", "append", "(", "element", ")", ";", "attachedElements", ".", "push", "(", "element", ")", ";", "}" ]
Attached an element to document.body. Keeps track of attached elements so that they can be removed in an afterEach. @param el
[ "Attached", "an", "element", "to", "document", ".", "body", ".", "Keeps", "track", "of", "attached", "elements", "so", "that", "they", "can", "be", "removed", "in", "an", "afterEach", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/panel/panel.spec.js#L3366-L3370
5,093
angular/material
src/core/util/color.js
hexToRgba
function hexToRgba (color) { var hex = color[ 0 ] === '#' ? color.substr(1) : color, dig = hex.length / 3, red = hex.substr(0, dig), green = hex.substr(dig, dig), blue = hex.substr(dig * 2); if (dig === 1) { red += red; green += green; blue += blue; } return 'rgba(' + parseInt(red, 16) + ',' + parseInt(green, 16) + ',' + parseInt(blue, 16) + ',0.1)'; }
javascript
function hexToRgba (color) { var hex = color[ 0 ] === '#' ? color.substr(1) : color, dig = hex.length / 3, red = hex.substr(0, dig), green = hex.substr(dig, dig), blue = hex.substr(dig * 2); if (dig === 1) { red += red; green += green; blue += blue; } return 'rgba(' + parseInt(red, 16) + ',' + parseInt(green, 16) + ',' + parseInt(blue, 16) + ',0.1)'; }
[ "function", "hexToRgba", "(", "color", ")", "{", "var", "hex", "=", "color", "[", "0", "]", "===", "'#'", "?", "color", ".", "substr", "(", "1", ")", ":", "color", ",", "dig", "=", "hex", ".", "length", "/", "3", ",", "red", "=", "hex", ".", "substr", "(", "0", ",", "dig", ")", ",", "green", "=", "hex", ".", "substr", "(", "dig", ",", "dig", ")", ",", "blue", "=", "hex", ".", "substr", "(", "dig", "*", "2", ")", ";", "if", "(", "dig", "===", "1", ")", "{", "red", "+=", "red", ";", "green", "+=", "green", ";", "blue", "+=", "blue", ";", "}", "return", "'rgba('", "+", "parseInt", "(", "red", ",", "16", ")", "+", "','", "+", "parseInt", "(", "green", ",", "16", ")", "+", "','", "+", "parseInt", "(", "blue", ",", "16", ")", "+", "',0.1)'", ";", "}" ]
Converts hex value to RGBA string @param color {string} @returns {string}
[ "Converts", "hex", "value", "to", "RGBA", "string" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/color.js#L17-L29
5,094
angular/material
src/core/util/color.js
rgbaToHex
function rgbaToHex(color) { color = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i); var hex = (color && color.length === 4) ? "#" + ("0" + parseInt(color[1],10).toString(16)).slice(-2) + ("0" + parseInt(color[2],10).toString(16)).slice(-2) + ("0" + parseInt(color[3],10).toString(16)).slice(-2) : ''; return hex.toUpperCase(); }
javascript
function rgbaToHex(color) { color = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i); var hex = (color && color.length === 4) ? "#" + ("0" + parseInt(color[1],10).toString(16)).slice(-2) + ("0" + parseInt(color[2],10).toString(16)).slice(-2) + ("0" + parseInt(color[3],10).toString(16)).slice(-2) : ''; return hex.toUpperCase(); }
[ "function", "rgbaToHex", "(", "color", ")", "{", "color", "=", "color", ".", "match", "(", "/", "^rgba?[\\s+]?\\([\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?", "/", "i", ")", ";", "var", "hex", "=", "(", "color", "&&", "color", ".", "length", "===", "4", ")", "?", "\"#\"", "+", "(", "\"0\"", "+", "parseInt", "(", "color", "[", "1", "]", ",", "10", ")", ".", "toString", "(", "16", ")", ")", ".", "slice", "(", "-", "2", ")", "+", "(", "\"0\"", "+", "parseInt", "(", "color", "[", "2", "]", ",", "10", ")", ".", "toString", "(", "16", ")", ")", ".", "slice", "(", "-", "2", ")", "+", "(", "\"0\"", "+", "parseInt", "(", "color", "[", "3", "]", ",", "10", ")", ".", "toString", "(", "16", ")", ")", ".", "slice", "(", "-", "2", ")", ":", "''", ";", "return", "hex", ".", "toUpperCase", "(", ")", ";", "}" ]
Converts rgba value to hex string @param {string} color @returns {string}
[ "Converts", "rgba", "value", "to", "hex", "string" ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/color.js#L36-L45
5,095
angular/material
src/components/datepicker/js/dateUtil.js
isSameMonthAndYear
function isSameMonthAndYear(d1, d2) { return d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth(); }
javascript
function isSameMonthAndYear(d1, d2) { return d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth(); }
[ "function", "isSameMonthAndYear", "(", "d1", ",", "d2", ")", "{", "return", "d1", ".", "getFullYear", "(", ")", "===", "d2", ".", "getFullYear", "(", ")", "&&", "d1", ".", "getMonth", "(", ")", "===", "d2", ".", "getMonth", "(", ")", ";", "}" ]
Gets whether two dates have the same month and year. @param {Date} d1 @param {Date} d2 @returns {boolean}
[ "Gets", "whether", "two", "dates", "have", "the", "same", "month", "and", "year", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/dateUtil.js#L77-L79
5,096
angular/material
src/components/datepicker/js/dateUtil.js
getWeekOfMonth
function getWeekOfMonth(date) { var firstDayOfMonth = getFirstDateOfMonth(date); return Math.floor((firstDayOfMonth.getDay() + date.getDate() - 1) / 7); }
javascript
function getWeekOfMonth(date) { var firstDayOfMonth = getFirstDateOfMonth(date); return Math.floor((firstDayOfMonth.getDay() + date.getDate() - 1) / 7); }
[ "function", "getWeekOfMonth", "(", "date", ")", "{", "var", "firstDayOfMonth", "=", "getFirstDateOfMonth", "(", "date", ")", ";", "return", "Math", ".", "floor", "(", "(", "firstDayOfMonth", ".", "getDay", "(", ")", "+", "date", ".", "getDate", "(", ")", "-", "1", ")", "/", "7", ")", ";", "}" ]
Gets the week of the month that a given date occurs in. @param {Date} date @returns {number} Index of the week of the month (zero-based).
[ "Gets", "the", "week", "of", "the", "month", "that", "a", "given", "date", "occurs", "in", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/dateUtil.js#L128-L131
5,097
angular/material
src/components/datepicker/js/dateUtil.js
incrementDays
function incrementDays(date, numberOfDays) { return new Date(date.getFullYear(), date.getMonth(), date.getDate() + numberOfDays); }
javascript
function incrementDays(date, numberOfDays) { return new Date(date.getFullYear(), date.getMonth(), date.getDate() + numberOfDays); }
[ "function", "incrementDays", "(", "date", ",", "numberOfDays", ")", "{", "return", "new", "Date", "(", "date", ".", "getFullYear", "(", ")", ",", "date", ".", "getMonth", "(", ")", ",", "date", ".", "getDate", "(", ")", "+", "numberOfDays", ")", ";", "}" ]
Gets a new date incremented by the given number of days. Number of days can be negative. @param {Date} date @param {number} numberOfDays @returns {Date}
[ "Gets", "a", "new", "date", "incremented", "by", "the", "given", "number", "of", "days", ".", "Number", "of", "days", "can", "be", "negative", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/dateUtil.js#L139-L141
5,098
angular/material
src/components/datepicker/js/dateUtil.js
incrementMonths
function incrementMonths(date, numberOfMonths) { // If the same date in the target month does not actually exist, the Date object will // automatically advance *another* month by the number of missing days. // For example, if you try to go from Jan. 30 to Feb. 30, you'll end up on March 2. // So, we check if the month overflowed and go to the last day of the target month instead. var dateInTargetMonth = new Date(date.getFullYear(), date.getMonth() + numberOfMonths, 1); var numberOfDaysInMonth = getNumberOfDaysInMonth(dateInTargetMonth); if (numberOfDaysInMonth < date.getDate()) { dateInTargetMonth.setDate(numberOfDaysInMonth); } else { dateInTargetMonth.setDate(date.getDate()); } return dateInTargetMonth; }
javascript
function incrementMonths(date, numberOfMonths) { // If the same date in the target month does not actually exist, the Date object will // automatically advance *another* month by the number of missing days. // For example, if you try to go from Jan. 30 to Feb. 30, you'll end up on March 2. // So, we check if the month overflowed and go to the last day of the target month instead. var dateInTargetMonth = new Date(date.getFullYear(), date.getMonth() + numberOfMonths, 1); var numberOfDaysInMonth = getNumberOfDaysInMonth(dateInTargetMonth); if (numberOfDaysInMonth < date.getDate()) { dateInTargetMonth.setDate(numberOfDaysInMonth); } else { dateInTargetMonth.setDate(date.getDate()); } return dateInTargetMonth; }
[ "function", "incrementMonths", "(", "date", ",", "numberOfMonths", ")", "{", "// If the same date in the target month does not actually exist, the Date object will", "// automatically advance *another* month by the number of missing days.", "// For example, if you try to go from Jan. 30 to Feb. 30, you'll end up on March 2.", "// So, we check if the month overflowed and go to the last day of the target month instead.", "var", "dateInTargetMonth", "=", "new", "Date", "(", "date", ".", "getFullYear", "(", ")", ",", "date", ".", "getMonth", "(", ")", "+", "numberOfMonths", ",", "1", ")", ";", "var", "numberOfDaysInMonth", "=", "getNumberOfDaysInMonth", "(", "dateInTargetMonth", ")", ";", "if", "(", "numberOfDaysInMonth", "<", "date", ".", "getDate", "(", ")", ")", "{", "dateInTargetMonth", ".", "setDate", "(", "numberOfDaysInMonth", ")", ";", "}", "else", "{", "dateInTargetMonth", ".", "setDate", "(", "date", ".", "getDate", "(", ")", ")", ";", "}", "return", "dateInTargetMonth", ";", "}" ]
Gets a new date incremented by the given number of months. Number of months can be negative. If the date of the given month does not match the target month, the date will be set to the last day of the month. @param {Date} date @param {number} numberOfMonths @returns {Date}
[ "Gets", "a", "new", "date", "incremented", "by", "the", "given", "number", "of", "months", ".", "Number", "of", "months", "can", "be", "negative", ".", "If", "the", "date", "of", "the", "given", "month", "does", "not", "match", "the", "target", "month", "the", "date", "will", "be", "set", "to", "the", "last", "day", "of", "the", "month", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/dateUtil.js#L151-L165
5,099
angular/material
src/components/datepicker/js/dateUtil.js
isDateWithinRange
function isDateWithinRange(date, minDate, maxDate) { var dateAtMidnight = createDateAtMidnight(date); var minDateAtMidnight = isValidDate(minDate) ? createDateAtMidnight(minDate) : null; var maxDateAtMidnight = isValidDate(maxDate) ? createDateAtMidnight(maxDate) : null; return (!minDateAtMidnight || minDateAtMidnight <= dateAtMidnight) && (!maxDateAtMidnight || maxDateAtMidnight >= dateAtMidnight); }
javascript
function isDateWithinRange(date, minDate, maxDate) { var dateAtMidnight = createDateAtMidnight(date); var minDateAtMidnight = isValidDate(minDate) ? createDateAtMidnight(minDate) : null; var maxDateAtMidnight = isValidDate(maxDate) ? createDateAtMidnight(maxDate) : null; return (!minDateAtMidnight || minDateAtMidnight <= dateAtMidnight) && (!maxDateAtMidnight || maxDateAtMidnight >= dateAtMidnight); }
[ "function", "isDateWithinRange", "(", "date", ",", "minDate", ",", "maxDate", ")", "{", "var", "dateAtMidnight", "=", "createDateAtMidnight", "(", "date", ")", ";", "var", "minDateAtMidnight", "=", "isValidDate", "(", "minDate", ")", "?", "createDateAtMidnight", "(", "minDate", ")", ":", "null", ";", "var", "maxDateAtMidnight", "=", "isValidDate", "(", "maxDate", ")", "?", "createDateAtMidnight", "(", "maxDate", ")", ":", "null", ";", "return", "(", "!", "minDateAtMidnight", "||", "minDateAtMidnight", "<=", "dateAtMidnight", ")", "&&", "(", "!", "maxDateAtMidnight", "||", "maxDateAtMidnight", ">=", "dateAtMidnight", ")", ";", "}" ]
Checks if a date is within a min and max range, ignoring the time component. If minDate or maxDate are not dates, they are ignored. @param {Date} date @param {Date} minDate @param {Date} maxDate
[ "Checks", "if", "a", "date", "is", "within", "a", "min", "and", "max", "range", "ignoring", "the", "time", "component", ".", "If", "minDate", "or", "maxDate", "are", "not", "dates", "they", "are", "ignored", "." ]
84ac558674e73958be84312444c48d9f823f6684
https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/dateUtil.js#L235-L241