document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
anchor.addEventListener('click', function (e) { | |
e.preventDefault(); | |
document.querySelector(this.getAttribute('href')).scrollIntoView({ | |
behavior: 'smooth' | |
}); | |
}); | |
}); |
- Специальные атрибуты
async
иdefer
используются для того, чтобы пока грузится внешний скрипт – браузер показал остальную (следующую за ним) часть страницы. Без них этого не происходит. - Разница между
async
иdefer
: атрибутdefer
сохраняет относительную последовательность скриптов, аasync
– нет. Кроме того, defer всегда ждёт, пока весь HTML-документ будет готов, аasync
– нет.
- Директива выглядит как строка
"use strict";
или'use strict';
и ставится в начале скрипта.
Например:
"use strict";
<!DOCTYPE html> | |
<html lang="zxx"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Title</title> | |
<meta name="description" content="Description"> | |
<meta name="keywords" content="Keywords"> | |
<meta name="author" content="Author"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
Global project search phrase:
- @FormElement(
- '#type' =>
- @RenderElement(
By default, Drupal, will attaches the JS assets at page bottom to avoid some frequents problems like: DOM content loading block, access to unready DOM element from jquery code, ecc... If for certain reason it's needed to attach JS assets into the section it's possible the use of header option, in this way:
version: 1.x
header: true
js:
js/cuddly-slider.js: {}
So, now, the js/curry-slider.js will be attached at page top.
dependencies - A list of other modules your module depends on. Dependencies should be namespaced in the format {project}:{module}, where {project} is the project name as it appears in the Drupal.org URL (e.g. drupal.org/project/views) and {module} is the module's machine name. Dependencies can also include version restrictions, for examplewebform:webform (>=8.x-5.x). Note that if your module has dependencies on other contributed modules or libraries, these should be declared in the module's composer.json file.
test_dependencies - A list of other modules (in the same format as dependencies) that are needed to run certain automated tests for your module on Drupal's automated test runner ("DrupalCI"),
<?php | |
namespace DesignPatterns\Structural\DependencyInjection; | |
/** | |
* Class DatabaseConfiguration | |
* | |
* @package DesignPatterns\Structural\DependencyInjection | |
*/ | |
class DatabaseConfiguration { |
<?php | |
use Lib\Eddard as AnotherEddard; | |
class Eddard { | |
public static function whoAmI() { | |
return 'It\'s method whoAmI in index.php.'; | |
} | |